#***************************************************************************
# PROJECT  MusixTeX Preprocessor  
# TITLE    sed source for makefile 
# FILE     Makefile.in
# AUTHOR   J.C. Nieuwenhuizen
#          copyright (c) FlowerSoft 1995
#
#***************************************************************************

NAME = mpp
VERSION = 0.44
MS_VERSION = 0x44

# this makefile file:
#
MYSELF = @MYSELF@
#

# extentions:
#
BAT = @BAT@
EXE = @EXE@
#

# offending msdos backslash:
#
Z = @Z@
#

# utilities:
#
SHELL = @SHELL@
CAT = @CAT@
CP = @CP@
RM = @RM@
#

# compiler:
#
CC = @CC@ 
CXX = @CPLUSPLUS@
DEPEND = @DEPEND@ 
#

# compile switches:
#
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
DEFINES = @DEFINES@
#

# linker:
#
LD = @LD@
#

# link switches:
#
LDFLAGS = @LDFLAGS@
#

# library path:
#
LIBDIR = @LIBDIR@
#

# libraries:
#
LOADLIBES = @LOADLIBES@
#

# stripper:
#
STRIP = @STRIP@
#

# list of header files:
#
HFILES = array.h\
 bar.h\
 beam.h\
 beamlist.h\
 beamnote.h\
 chord.h\
 chordlis.h\
 citerate.h\
 clef.h\
 clist.h\
 cplusplu.h\
 cresc.h\
 define.h\
 duration.h\
 error.h\
 featlist.h\
 feature.h\
 garray.h\
 generic.h\
 getopt.h\
 getoptin.h\
 glist.h\
 grlist.h\
 gslist.h\
 ifeature.h\
 imacro.h\
 init.h\
 inote.h\
 inote.h\
 integer.h\
 interval.h\
 intlist.h\
 itoa.h\
 key.h\
 list.h\
 loptions.h\
 maclist.h\
 macro.h\
 mpp.h\
 namearra.h\
 note.h\
 notelist.h\
 notename.h\
 noteslis.h\
 object.h\
 options.h\
 quote.h\
 score.h\
 script.h\
 simpnote.h\
 slope.h\
 slur.h\
 slurlist.h\
 snotelis.h\
 sortable.h\
 staff.h\
 staflist.h\
 stem.h\
 string.h\
 strike.h\
 strlist.h\
 strupr.h\
 textdata.h\
 token.h\
 verb.h\
 version.h

# list of input files:
#
CFILES = assign.cc\
 comma.cc\
 array.cc\
 bar.cc\
 beam.cc\
 beamlist.cc\
 beamnote.cc\
 clef.cc\
 chord.cc\
 cresc.cc\
 define.cc\
 duration.cc\
 error.cc\
 feature.cc\
 getopt.c\
 getopt1.c\
 getoptin.c\
 ifeature.cc\
 imacro.cc\
 init.cc\
 inote.cc\
 itoa.c\
 key.cc\
 list.cc\
 loptions.cc\
 maclist.cc\
 macro.cc\
 mpp.cc\
 note.cc\
 notename.cc\
 noteslis.cc\
 object.cc\
 options.cc\
 postfix.cc\
 quote.cc\
 score.cc\
 score0.cc\
 script.cc\
 simpnote.cc\
 simpnot0.cc\
 simpnot1.cc\
 slope.cc\
 slur.cc\
 slurlist.cc\
 staff.cc\
 stem.cc\
 string.cc\
 strike.cc\
 strupr.c\
 textdata.cc\
 token.cc\
 verb.cc\
 version.cc
#

# list of object dependencies:
#
OBJECTS = array.o\
 bar.o\
 beam.o\
 beamlist.o\
 beamnote.o\
 clef.o\
 chord.o\
 cresc.o\
 define.o\
 duration.o\
 error.o\
 feature.o\
 getopt.o\
 getopt1.o\
 getoptin.o\
 ifeature.o\
 imacro.o\
 init.o\
 inote.o\
 itoa.o\
 key.o\
 list.o\
 loptions.o\
 maclist.o\
 macro.o\
 mpp.o\
 note.o\
 notename.o\
 noteslis.o\
 options.o\
 quote.o\
 score.o\
 score0.o\
 script.o\
 simpnote.o\
 simpnot0.o\
 simpnot1.o\
 slope.o\
 slur.o\
 slurlist.o\
 staff.o\
 stem.o\
 string.o\
 strike.o\
 strupr.o\
 textdata.o\
 token.o\
 verb.o\
 version.o\
 object.o
#

# list of init files:
#
INITS = bar.ini clef.ini feature.ini key.ini macro.ini\
 note.ini notecc.ini script.ini scriptcc.ini
#

# list of shell scripts:
#
SCRIPTS = configure configur.bat docmpp dodocmpp mdo mdo.bat # make.bat
#

# list of other project files:
#
PROJECT = COPYING INSTALL NEWS README TODO\
 ChangeLog\
 gnu.sed msdos.sed unix.sed\
 Makefile.in Makefile.dos\
 mppdoc.doc mppdoc.tex mppdoc.sty\
 mpp.tex\
 generic.in $(NAME).in $(NAME).dos\
 $(NAME).dep $(NAME).ol $(NAME).exe
#

# list of example files:
#
EXAMPLES = test.mpp\
 s1.mpp s2.mpp\
 mlalt.mpp mlvio1.mpp mlvio2.mpp mlcello.mpp\
 mppdoc.ps test.ps s1.ps mlalt.ps
#

# list of all files:
#
ALLFILES = $(PROJECT) $(SCRIPTS) $(EXAMPLES) $(HFILES) $(CFILES) $(INITS)
#

# implicit rules; problems? use gnu make 
#
.c.o:
	$(CC) $(DEFINES) -c $(CFLAGS) $<
.cc.o:
	$(CXX) $(DEFINES) -c $(CXXFLAGS) $<
#

# dependency list of executable:
#
$(NAME)$(EXE): $(OBJECTS) $(MYSELF) $(NAME).dep $(NAME).ol version
	@LD_COMMAND@
	$(STRIP) $@
#

# always compile version.cc:
#
version: version.o
	touch version.cc
#

# list of objects: stupid msdos commandline
#
$(NAME).ol: $(OBJECTS)
	echo $(OBJECTS) > $(NAME).ol
#

objects: $(NAME).ol

#dependency list of objects:
#
$(NAME).dep: $(HFILES) $(CFILES)
	-$(DEPEND) $(DEFINES) $(CFILES) > $(NAME).dep
#

depend: $(NAME).dep

# platform dependant  makefiles:
#
$(NAME).make:
	sed -f unix.sed $(NAME).in > $@
$(NAME).gnu:
	sed -f gnu.sed $(NAME).in > $@
$(NAME).dos:
	sed -f msdos.sed $(NAME).in > $@
#

# Makefile.in and Makefile
#
Makefile.in:
	$(CP) $(NAME).in $@
Makefile: $(NAME).make
	$(CP) $(NAME).make $@
Makefile.dos: $(NAME).dos
	$(CP) $(NAME).dos $@
#

# install
#
install: mpp$(EXE)
	$(CP) mpp$(EXE) ..
	$(CP) mpp.tex ..
	$(CP) note.ini ..
	$(CP) script.ini ..
	$(CP) mdo$(BAT) ..
	$(CP) mppdoc.tex ..
	$(CP) mppdoc.sty ..
#

# clean
#
clean:
	-$(RM) *.o
	-$(RM) $(NAME)$(EXE)
	-$(RM) m.log
#

# distclean
#
distclean: clean
	-$(RM) Makefile
	-$(RM) Makefile.dos
	-$(RM) $(NAME).make
	-$(RM) $(NAME).gnu
	-$(RM) $(NAME).dos
#

###########################################
# DISTRIBUTION
###########################################

# naming convention for zips:
#
# unix:
#  zips have extention .tar.gz
#  zaps have extention .zap
#
# msdos:
#  zips have extention .arj
#  zaps have extention .zip
#

# text files transported between unix and msdos platform
# always have msdos line break format
# conversion is simply too fast on unix platform
#

dist: zip

#
MS_DISTDIR =$(NAME)-$(MS_VERSION)
ARJ = $(MS_DISTDIR).arj
MS_ZIP = $(MS_DISTDIR).zap
UNIX_ZIP = $(MS_DISTDIR).zip
#

# tar and zip file name:
#
DISTDIR = @DISTDIR@
TAR = @TAR@
ZIP = @ZIP@
DRIVE = @DRIVE@
#

# dependency list of tar file:
#
# unix
$(TAR): $(ALLFILES)
	-mkdir $(DISTDIR)
#	echo $(ALLFILES) | tr ' ' '\012' >MANIFEST
	tr -d '\\' < $(NAME).dep | tr ' ' '\012' | grep -v '\.o' > MANIFEST.$$
	echo $(ALLFILES) | tr ' ' '\012' >> MANIFEST.$$
	cat MANIFEST.$$ | sort | uniq > MANIFEST
	cp `cat MANIFEST` MANIFEST $(DISTDIR)/
	chmod 644  $(DISTDIR)/*
	chmod +x $(DISTDIR)/configure
	chmod +x $(DISTDIR)/docmpp
	chmod +x $(DISTDIR)/dodocmpp
	chmod +x $(DISTDIR)/mdo
	tar -cf $(TAR) $(DISTDIR)/*
	rm -fr $(DISTDIR)/      #CAREFUL!
#

# dependency list of zip file:
#
zip: @zip@
#

# zip for MSDOS
#
# unix
$(MS_ZIP): $(ALLFILES)
	-rm $@
	-mkdir $(MS_DISTDIR)
	echo $(ALLFILES) | tr ' ' '\012' >MANIFEST
	cp `cat MANIFEST` MANIFEST $(MS_DISTDIR)/
	cp $(NAME).dep $(MS_DISTDIR)/
	cp $(NAME).ol $(MS_DISTDIR)/
	chmod 644  $(MS_DISTDIR)/*
	u2d $(MS_DISTDIR)/*
	-cp mpp.exe $(MS_DISTDIR)
	zip -k $(MS_ZIP) $(MS_DISTDIR)/*
	rm -fr $(MS_DISTDIR)/      #CAREFUL!
#
mszip:  $(MS_ZIP)
	chmod 644 $(MS_ZIP)
#

# dependency list of arj file:
#
# msdos
$(ARJ): $(ALLFILES) MANIFEST
	-del $@
	xcopy @MANIFEST $(DRIVE)$(MS_DISTDIR)
	copy MANIFEST $(DRIVE)$(MS_DISTDIR)
	-xcopy $(NAME).exe $(DRIVE)$(MS_DISTDIR)
	attrib -a $(DRIVE)$(MS_DISTDIR)$(Z)*.*
	arj a $(ARJ) $(DRIVE)$(MS_DISTDIR)$(Z)*.*
	xdel /dsn $(DRIVE)$(MS_DISTDIR)      #CAREFUL!
#

# zip for unix
# 
# msdos
$(UNIX_ZIP): $(ALLFILES) MANIFEST
	-del $@
	xcopy @MANIFEST $(DRIVE)$(MS_DISTDIR)
# use `make unzap' on unix instead
#	d2u $(DRIVE)$(MS_DISTDIR)$(Z)*.*
	-xcopy $(NAME).exe $(DRIVE)$(MS_DISTDIR)
	pkzip -P $(UNIX_ZIP) $(DRIVE)$(MS_DISTDIR)$(Z)*.*
	xdel /dsn $(DRIVE)$(MS_DISTDIR)      #CAREFUL!
#
uzip:  $(UNIX_ZIP)
#

# zap (the zip to the other platform) dependencies:
#
zap: @zap@
#

# unzip .zap file from msdos
# 
# unix
UNIX_UNZAP:
	$(MAKE) zip            # make backup before overwrite
	unzip $(UNIX_ZIP)
	-rm $(MS_DISTDIR)/manifest
	mv $(MS_DISTDIR)/changelo $(MS_DISTDIR)/ChangeLog
	mv $(MS_DISTDIR)/configur $(MS_DISTDIR)/configure
	mv $(MS_DISTDIR)/copying $(MS_DISTDIR)/COPYING
	mv $(MS_DISTDIR)/install $(MS_DISTDIR)/INSTALL
	mv $(MS_DISTDIR)/news $(MS_DISTDIR)/NEWS
	mv $(MS_DISTDIR)/readme $(MS_DISTDIR)/README
	mv $(MS_DISTDIR)/todo $(MS_DISTDIR)/TODO
#	mv $(MS_DISTDIR)/makefile.in $(MS_DISTDIR)/Makefile.in
#	mv $(MS_DISTDIR)/makefile $(MS_DISTDIR)/Makefile
	-rm $(MS_DISTDIR)/Makefile.in
	-rm $(MS_DISTDIR)/makefile
	-mv $(MS_DISTDIR)/$(NAME).exe .
	d2u $(MS_DISTDIR)/*
	chmod +x $(MS_DISTDIR)/configure
	chmod +x $(MS_DISTDIR)/docmpp
	chmod +x $(MS_DISTDIR)/dodocmpp
	chmod +x $(MS_DISTDIR)/mdo
	mv $(MS_DISTDIR)/* .
	rmdir $(MS_DISTDIR)
#

# unzip .zip file from unix
# 
# unix
MS_UNZAP:
#	$(MAKE) zip            # make backup before overwrite
	pkunzip -d $(MS_ZIP) $(DRIVE)
	move $(DRIVE)$(MS_DISTDIR)$(Z)*.* .
	rmdir $(DRIVE)$(MS_DISTDIR)
#

# unzap (unzip the zip from the other platform) dependencies:
#
unzap: @unzap@
#

# automatically generated dependencies
#
#
include $(NAME).dep
