# Master Unix makefile for the ToneGen program
# Steve McConnel, 24-Oct-2002

@SET_MAKE@
srcdir      = @srcdir@
VPATH       = @srcdir@
CC          = @CC@
CFLAGS      = @ANSIFLAGS@ @CFLAGS@ @DEFS@ -I. -I.. -I../include -I../TonePGLib\
 -DTONEPARS -DTONEGEN
RANLIB      = @RANLIB@
INSTALL     = @INSTALL@
COPY        = @COPYPROG@
prefix      = @prefix@
exec_prefix = @exec_prefix@

.SUFFIXES: .op
.c.op:
	$(CC) $(CFLAGS) -pg -c -o $@ $<

@make_shell@ = /bin/sh
BINDIR = $(exec_prefix)/bin

SOURCES = tonegen.c version.h version.c
DISTFILES = $(SOURCES) Makefile.in ToneGen.dsp ToneGen.vcproj
DISTDOCFILES = Doc/ToneGen.html Doc/ToneGenChanges.txt Doc/prec.gif \
 Doc/silewp.css Doc/tp01.gif Doc/tp03a.gif Doc/tp03b.gif Doc/tp03c.gif \
 Doc/tp04.gif Doc/tp05.gif Doc/tp06.gif Doc/tp18.gif Doc/tp20.gif \
 Doc/tp25.gif Doc/tp26.gif Doc/tp35.gif

TESTFILES =
#
#  ToneGen program
#
OBJ =tonegen.o version.o
LIBS=../lib/libtoneg.a ../lib/libample.a ../lib/libopac.a ../lib/libcport.a

tonegen: $(OBJ) $(LIBS)
	$(CC) -o tonegen $(OBJ) $(LIBS) @LIBS@
#
#  ToneGen program compiled for profiling
#
OBJP =tonegen.op version.op
LIBSP=../lib/libtoneg_p.a ../lib/libample_p.a ../lib/libopac_p.a \
 ../lib/libcport_p.a

tonegen_p: $(OBJP) $(LIBSP)
	$(CC) -pg -o tonegen_p $(OBJP) $(LIBSP) @LIBS@
#
#  sources unique to ToneGen
#
tonegen.o tonegen.op: tonegen.c version.h ../config.h \
    ../TonePGLib/toneanal.h ../include/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
version.o version.op: version.c version.h ../config.h
#############################################################################

libs profile_libs: installdirs

installdirs:
	@if [ ! -d $(BINDIR) ];  then mkdir $(BINDIR);  fi
	@if [ ! -d ../lib ];     then mkdir ../lib;     fi
	@if [ ! -d ../include ]; then mkdir ../include; fi

all: libs tonegen

profile: profile_libs tonegen_p

install: all
	$(INSTALL) -s tonegen $(BINDIR)

uninstall:
	rm -f $(BINDIR)/tonegen

check: tonegen

mostlyclean:
	rm -f *.o *.op *~

clean: mostlyclean

distclean: clean
	rm -f tonegen tonegen_p Makefile TAGS

maintainer-clean: distclean

TAGS: $(SOURCES)
	etags $(SOURCES)

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

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

testdist: 

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

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