# Master Unix makefile for the SIL Tone Parse/Generate Library (GNU make)
# Steve McConnel, 25-Oct-2002

@SET_MAKE@
srcdir      = @srcdir@
VPATH       = @srcdir@
CC          = @CC@
YACC        = @YACC@
LEX         = @LEX@
CFLAGS      = @ANSIFLAGS@ @CFLAGS@ @DEFS@ -I. -I.. -I../stamp -I../include
RANLIB      = @RANLIB@
INSTALL     = @INSTALL@
COPY        = @COPYPROG@

.SUFFIXES: .og .ogp .op .opp
.c.og:
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ $<
.c.ogp:
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ $<
.c.op:
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ $<
.c.opp:
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ $<

@make_shell@ = /bin/sh

SOURCES = domain.c   domain.h   loadseg.c  moras.c    pword.c    segparse.c \
          syllable.c sytest_y.h tbu.c      tone.c     tone.h     toneanal.c \
          toneanal.h tonepars.h trule.h    trule_ls.l trule_yg.y \
          trule_ls.c trule_ls.h trule_yg.c trule_yg.h \
          trule_yg_tab.c trule_yg_tab.h 

DISTFILES = $(SOURCES) Makefile.in \
            ToneGLib.dsp ToneGLib.vcproj TonePLib.dsp TonePLib.vcproj
TESTFILES =
#
# Tone Generate library
#
GOBJS = domain.og loadseg.og moras.og pword.og segparse.og syllable.og \
        tbu.og tone.og toneanal.og trule_ls.og trule_yg.og \
        dtbio.og envchk.og lexchg.og lexchg.og menvck.og synrsc.og \
        synth.og syntst.og sytest_l.og sytest_y.og tmatch.og \
        transfer.og treplace.og trules.og tsdict.og tsinit.og tsutil.og

libtoneg.a:  $(GOBJS)
	ar rc libtoneg.a $(GOBJS)
	$(RANLIB) libtoneg.a
#
# Tone Generate library compiled for profiling
#
GOBJSP = domain.ogp loadseg.ogp moras.ogp pword.ogp segparse.ogp syllable.ogp \
         tbu.ogp tone.ogp toneanal.ogp trule_ls.ogp trule_yg.ogp \
         dtbio.ogp envchk.ogp lexchg.ogp lexchg.ogp menvck.ogp synrsc.ogp \
         synth.ogp syntst.ogp sytest_l.ogp sytest_y.ogp tmatch.ogp \
         transfer.ogp treplace.ogp trules.ogp tsdict.ogp tsinit.ogp tsutil.ogp

libtoneg_p.a:  $(GOBJSP)
	ar rc libtoneg_p.a $(GOBJSP)
	$(RANLIB) libtoneg_p.a
#
# Tone Parse library
#
POBJS = domain.op loadseg.op moras.op pword.op segparse.op syllable.op \
        tbu.op tone.op toneanal.op trule_ls.op trule_yg.op \
        dtbio.op envchk.op lexchg.op menvck.op synrsc.op synth.op \
        syntst.op sytest_l.op sytest_y.op tmatch.op transfer.op \
        treplace.op trules.op tsdict.op tsinit.op tsutil.op
libtonep.a: $(POBJS)
	ar rc libtonep.a $(POBJS)
	$(RANLIB) libtonep.a
#
# Tone Parse library compiled for profiling
#
POBJSP = domain.opp loadseg.opp moras.opp pword.opp segparse.opp syllable.opp \
         tbu.opp tone.opp toneanal.opp trule_ls.opp trule_yg.opp \
         dtbio.opp envchk.opp lexchg.opp menvck.opp synrsc.opp synth.opp \
         syntst.opp sytest_l.opp sytest_y.opp tmatch.opp transfer.opp \
         treplace.opp trules.opp tsdict.opp tsinit.opp tsutil.opp
libtonep_p.a: $(POBJSP)
	ar rc libtonep_p.a $(POBJSP)
	$(RANLIB) libtonep_p.a

OPACINCLUDE = ../config.h \
../stamp/stamp.h ../include/cportlib.h ../include/opaclib.h \
../include/allocmem.h ../include/trie.h ../include/record.h \
../include/rpterror.h ../include/template.h ../include/textctl.h \
../include/change.h ../include/strclass.h ../include/strlist.h \
../include/dynstr.h ../include/stample.h ../include/punclass.h

domain.og domain.ogp domain.op domain.opp: domain.c $(OPACINCLUDE) \
                                           tonepars.h domain.h
loadseg.og loadseg.ogp loadseg.op loadseg.opp: loadseg.c $(OPACINCLUDE) tone.h
moras.og moras.ogp moras.op moras.opp: moras.c $(OPACINCLUDE) tonepars.h
pword.og pword.ogp pword.op pword.opp: pword.c $(OPACINCLUDE)
segparse.og segparse.ogp segparse.op segparse.opp: segparse.c $(OPACINCLUDE)
syllable.og syllable.ogp syllable.op syllable.opp: syllable.c $(OPACINCLUDE) \
                                                   tonepars.h
tbu.og tbu.ogp tbu.op tbu.opp: tbu.c $(OPACINCLUDE) tonepars.h trule.h
tone.og tone.ogp tone.op tone.opp: tone.c $(OPACINCLUDE) tonepars.h trule.h
toneanal.og toneanal.ogp toneanal.op toneanal.opp: toneanal.c $(OPACINCLUDE) \
                                                   tonepars.h domain.h trule.h
trule_ls.og trule_ls.ogp trule_ls.op trule_ls.opp: trule_ls.c $(OPACINCLUDE) \
                                                   trule_yg.h
trule_yg.og trule_yg.ogp trule_yg.op trule_yg.opp: trule_yg.c $(OPACINCLUDE) \
                                                   tone.h trule.h

dtbio.og: ../stamp/dtbio.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/dtbio.c
dtbio.ogp: ../stamp/dtbio.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/dtbio.c
dtbio.op: ../stamp/dtbio.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/dtbio.c
dtbio.opp: ../stamp/dtbio.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/dtbio.c
envchk.og: ../stamp/envchk.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/envchk.c
envchk.ogp: ../stamp/envchk.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/envchk.c
envchk.op: ../stamp/envchk.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/envchk.c
envchk.opp: ../stamp/envchk.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/envchk.c
lexchg.og: ../stamp/lexchg.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/lexchg.c
lexchg.ogp: ../stamp/lexchg.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/lexchg.c
lexchg.op: ../stamp/lexchg.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/lexchg.c
lexchg.opp: ../stamp/lexchg.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/lexchg.c
menvck.og: ../stamp/menvck.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/menvck.c
menvck.ogp: ../stamp/menvck.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/menvck.c
menvck.op: ../stamp/menvck.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/menvck.c
menvck.opp: ../stamp/menvck.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/menvck.c
synrsc.og: ../stamp/synrsc.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/synrsc.c
synrsc.ogp: ../stamp/synrsc.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/synrsc.c
synrsc.op: ../stamp/synrsc.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/synrsc.c
synrsc.opp: ../stamp/synrsc.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/synrsc.c
synth.og: ../stamp/synth.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/synth.c
synth.ogp: ../stamp/synth.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/synth.c
synth.op: ../stamp/synth.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/synth.c
synth.opp: ../stamp/synth.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/synth.c
syntst.og: ../stamp/syntst.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/syntst.c
syntst.ogp: ../stamp/syntst.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/syntst.c
syntst.op: ../stamp/syntst.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/syntst.c
syntst.opp: ../stamp/syntst.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/syntst.c
sytest_l.og: ../stamp/sytest_l.c $(OPACINCLUDE) ../stamp/sytest_y.h
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/sytest_l.c
sytest_l.ogp: ../stamp/sytest_l.c $(OPACINCLUDE) ../stamp/sytest_y.h
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/sytest_l.c
sytest_l.op: ../stamp/sytest_l.c $(OPACINCLUDE) ../stamp/sytest_y.h
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/sytest_l.c
sytest_l.opp: ../stamp/sytest_l.c $(OPACINCLUDE) ../stamp/sytest_y.h
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/sytest_l.c
sytest_y.og: ../stamp/sytest_y.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/sytest_y.c
sytest_y.ogp: ../stamp/sytest_y.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/sytest_y.c
sytest_y.op: ../stamp/sytest_y.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/sytest_y.c
sytest_y.opp: ../stamp/sytest_y.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/sytest_y.c
tmatch.og: ../stamp/tmatch.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/tmatch.c
tmatch.ogp: ../stamp/tmatch.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/tmatch.c
tmatch.op: ../stamp/tmatch.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/tmatch.c
tmatch.opp: ../stamp/tmatch.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/tmatch.c
transfer.og: ../stamp/transfer.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/transfer.c
transfer.ogp: ../stamp/transfer.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/transfer.c
transfer.op: ../stamp/transfer.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/transfer.c
transfer.opp: ../stamp/transfer.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/transfer.c
treplace.og: ../stamp/treplace.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/treplace.c
treplace.ogp: ../stamp/treplace.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/treplace.c
treplace.op: ../stamp/treplace.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/treplace.c
treplace.opp: ../stamp/treplace.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/treplace.c
trules.og: ../stamp/trules.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/trules.c
trules.ogp: ../stamp/trules.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/trules.c
trules.op: ../stamp/trules.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/trules.c
trules.opp: ../stamp/trules.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/trules.c
tsdict.og: ../stamp/tsdict.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/tsdict.c
tsdict.ogp: ../stamp/tsdict.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/tsdict.c
tsdict.op: ../stamp/tsdict.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/tsdict.c
tsdict.opp: ../stamp/tsdict.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/tsdict.c
tsinit.og: ../stamp/tsinit.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/tsinit.c
tsinit.ogp: ../stamp/tsinit.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/tsinit.c
tsinit.op: ../stamp/tsinit.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/tsinit.c
tsinit.opp: ../stamp/tsinit.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/tsinit.c
tsutil.og: ../stamp/tsutil.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -c -o $@ ../stamp/tsutil.c
tsutil.ogp: ../stamp/tsutil.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -DTONEGEN -pg -c -o $@ ../stamp/tsutil.c
tsutil.op: ../stamp/tsutil.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -c -o $@ ../stamp/tsutil.c
tsutil.opp: ../stamp/tsutil.c $(OPACINCLUDE)
	$(CC) $(CFLAGS) -DTONEPARS -pg -c -o $@ ../stamp/tsutil.c
#############################################################################

libs: installdirs ../lib/libtoneg.a ../lib/libtonep.a

profile_libs: installdirs ../lib/libtoneg_p.a ../lib/libtonep_p.a

installdirs:
	@if [ ! -d ../lib ]; then mkdir ../lib; fi

../lib/libtoneg.a: libtoneg.a
	$(INSTALL) -m 644 -c libtoneg.a ../lib
	$(RANLIB) ../lib/libtoneg.a
../lib/libtoneg_p.a: libtoneg_p.a
	$(INSTALL) -m 644 -c libtoneg_p.a ../lib
	$(RANLIB) ../lib/libtoneg_p.a
../lib/libtonep.a: libtonep.a
	$(INSTALL) -m 644 -c libtonep.a ../lib
	$(RANLIB) ../lib/libtonep.a
../lib/libtonep_p.a: libtonep_p.a
	$(INSTALL) -m 644 -c libtonep_p.a ../lib
	$(RANLIB) ../lib/libtonep_p.a

all install: libs

profile: profile_libs

uninstall:

check:

mostlyclean:
	rm -f *.og *.ogp *~

clean: mostlyclean
	rm -f lib*.a

distclean: clean
	rm -f Makefile TAGS
	rm -f ../lib/libtoneg.a ../lib/libtoneg_p.a
	rm -f ../lib/libtonep.a ../lib/libtonep_p.a

maintainer-clean: distclean

TAGS: $(SOURCES)
	etags $(SOURCES)

doc dvi html info:
	(cd ../doc; $(MAKE) cportlib$@)

dist: $(DISTFILES)
	for file in $(DISTFILES); do \
	  ln $$file $(distdir) \
	    || { echo copying $$file instead; $(COPY) $$file $(distdir);}; \
	done

testdist: 
# leave these lines commented out as long as TESTFILES is empty!
#	for file in $(TESTFILES); do \
#	  ln $$file $(distdir) \
#	    || { echo copying $$file instead; $(COPY) $$file $(distdir);}; \
#	done

############################################################################

.PHONY: all check clean dist distclean doc dvi html info install \
        libs maintainer-clean mostlyclean profile profile_libs testdist \
        uninstall installdirs
