# Updates variable with the application version from the
# abc2ps.h file.

AppBldVer=`gawk -f getver.awk abc2ps.h`

# Set the following to your RPM source directory
# if that is something other than the RPM v3.0.3
# default used below.  If you are not using RPM
# then set the following to the directory where
# you want to store the distribution tar/zip file.
# Used only by target "distri" -- not required
# for other targets.

RPMSources=/usr/src/RPM/SOURCES

# The following variables are used for all targets
# except the executable and "clean."
VerPath=jaabc2ps-$(AppBldVer)
#echo $VerPath

# The following variables are used for target 
# "jaabc2ps" (the executable). 

cc=gcc
CFLAGS=-Wall
OBJECTS=abc2ps.o buffer.o format.o music.o \
        parse.o subs.o util.o syms.o

# The executable target.

jaabc2ps: $(OBJECTS)
	gcc $(CFLAGS) -o jaabc2ps $(OBJECTS)

OBJECTS: jaabc2ps.h

# The distribution target.  Builds a gzipped tar file that
# incorporates the version number and that will untar to
# a sub-directory that incorporates the version number.
# You must be super user (root) for this target!

distri:
	rm -f $(RPMSources)/jaabc2ps-$(AppBldVer)-src.tar.gz
	cp -f jaabc2ps release/jaabc2ps
	ln -s . $(VerPath); \
	tar -cvf $(RPMSources)/jaabc2ps-$(AppBldVer)-src.tar \
		$(VerPath)/getver.awk \
		$(VerPath)/License \
		$(VerPath)/Makefile \
		$(VerPath)/abc2ps.h \
		$(VerPath)/style.h \
		$(VerPath)/abc2ps.c \
		$(VerPath)/buffer.c \
		$(VerPath)/format.c \
		$(VerPath)/music.c \
		$(VerPath)/parse.c \
		$(VerPath)/subs.c \
		$(VerPath)/syms.c \
		$(VerPath)/util.c \
		$(VerPath)/changes.h \
		$(VerPath)/style.pure \
		$(VerPath)/layout.txt \
		$(VerPath)/release/101best.abc \
		$(VerPath)/release/desafinado.abc \
		$(VerPath)/release/mtunes2.abc \
		$(VerPath)/release/tight.fmt \
		$(VerPath)/release/jaabc2ps \
		$(VerPath)/release/newfeatures.abc \
		$(VerPath)/release/voices.abc \
		$(VerPath)/release/License \
		$(VerPath)/release/example.bat \
		$(VerPath)/release/journey.abc \
		$(VerPath)/release/ricercar.abc \
		$(VerPath)/release/blue_boy_bass.abc \
		$(VerPath)/release/fbook.fmt \
		$(VerPath)/release/landscape.fmt \
		$(VerPath)/release/scotland.abc \
		$(VerPath)/release/celloprelude.abc \
		$(VerPath)/release/fixln \
		$(VerPath)/release/mtunes1.abc \
		$(VerPath)/release/snbook.fmt \
		$(VerPath)/release/defaults.fmt \
		$(VerPath)/release/fonts.fmt \
		$(VerPath)/docs/New.Features \
		$(VerPath)/docs/book.png \
		$(VerPath)/docs/justified.png \
		$(VerPath)/docs/simple.png \
		$(VerPath)/docs/ReadMe.abc2ps \
		$(VerPath)/docs/jaabc2ps.html \
		$(VerPath)/docs/shifted.png \
		$(VerPath)/docs/simple2.png; \
	gzip $(RPMSources)/jaabc2ps-$(AppBldVer)-src.tar
	rm -f $(VerPath)

# The install target.
# You must be super user (root) for this target!

install:
	mkdir -p /usr/local/doc/jaabc2ps
	cp -f docs/New.Features \
		docs/book.png \
		docs/justified.png \
		docs/simple.png \
		docs/ReadMe.abc2ps \
		docs/jaabc2ps.html \
		docs/shifted.png \
		docs/simple2.png /usr/local/doc/jaabc2ps
	cp -f release/License /usr/local/doc/jaabc2ps
	mkdir -p /usr/local/doc/jaabc2ps/examples
	cp -f release/101best.abc \
		release/desafinado.abc \
		release/mtunes2.abc \
		release/tight.fmt \
		release/newfeatures.abc \
		release/voices.abc \
		release/example.bat \
		release/journey.abc \
		release/ricercar.abc \
		release/blue_boy_bass.abc \
		release/fbook.fmt \
		release/landscape.fmt \
		release/scotland.abc \
		release/celloprelude.abc \
		release/mtunes1.abc \
		release/snbook.fmt \
		release/defaults.fmt \
		release/fonts.fmt /usr/local/doc/jaabc2ps/examples
	cp -f release/jaabc2ps release/fixln /usr/local/bin

# Target "clean" removes the intermediate files.

clean:
	rm -f *.o

