# Makefile to compile Spectroscopic Toolkit version 1.62 under UNIX.
# Pieter Suurmond december 2, 2002.
# Before running ST, first build and run the pconv program
# that produces a correct binary version of the spectroscopic database.

       # Name of executable (may be full (install-)pathname):
PRG    = ST

       # Compiler to user (or just 'cc'):
CC     = gcc

       # Source files (maybe not all ST_cXX_xxxx.c files may be necessary):
SRC    = gt/gt.c\
         pconv/ST_more.pbin.c\
         ST.c\
         ST_wavelets.c\
         ST_score.c\
         ST_aiff.c\
         comp/c00_example.c\
         comp/c01_twoWeeks.c\
         comp/c02_smear.c\
         comp/c03_H.c\
         comp/c04_Mendelejev.c\
         comp/c04_Xenofobia.c\
	 comp/c05_hydrogenBirds.c\
	 comp/c06_JEBASE.c\
	 comp/c06_Hsplit.c\
         comp/c06_Hbells.c\
         comp/c06_Hmelody.c

       # Compiler optimization level
       # (-Wall is not recognised by MIPS compiler on SGI, for gcc only):
CFLAGS = -O2 -Wall

       # MATH library (syntax: -lfilename (where filename = libname)):
LIBS   = -lm

       # Objects (one object per sourcefile):
OBJ    = $(SRC:.c=.o)

all: $(PRG)

# Rules to build objects. Corresponding .c and .h files are mentioned on 
# the first line to get dependancies right, i.e. when these file are changed, 
# appropriate objects get recompiled automatically.

# Separate rule to enforce graphic toolkit 'gt.o' to be built in subdirectory 'gt':
gt/gt.o: gt/gt.c gt/gt.h
	$(CC) $(CFLAGS) -c gt/gt.c -o gt/gt.o

# Separate rule to enforce 'ST.more.pbin.o' to be built in subdirectory 'pconv':
pconv/ST_more.pbin.o: pconv/ST_more.pbin.c pconv/ST_more.pbin.h
	$(CC) $(CFLAGS) -c pconv/ST_more.pbin.c -o pconv/ST_more.pbin.o

# Some files need to include headers from subdirectories, to avoid use of platform-
# dependent pathnames, we use -I option here to let the compiler find headers:

ST.o: ST.c ST_wavelets.h ST_score.h comp/c00.h
	$(CC) $(CFLAGS) -Icomp -c ST.c -o ST.o

ST_score.o: ST_score.c ST_score.h ST_wavelets.h ST_engine.h
	$(CC) $(CFLAGS) -Igt -c ST_score.c -o ST_score.o

# Needs header from parent directory:
comp/c00_example.o: comp/c00_example.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -c comp/c00_example.c -o comp/c00_example.o

comp/c01_twoWeeks.o: comp/c01_twoWeeks.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Igt -Ipconv -c comp/c01_twoWeeks.c -o comp/c01_twoWeeks.o

comp/c02_smear.o: comp/c02_smear.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Ipconv -c comp/c02_smear.c -o comp/c02_smear.o

comp/c03_H.o: comp/c03_H.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Igt -Ipconv -c comp/c03_H.c -o comp/c03_H.o

comp/c04_Mendelejev.o: comp/c04_Mendelejev.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Ipconv -c comp/c04_Mendelejev.c -o comp/c04_Mendelejev.o

comp/c04_Xenofobia.o: comp/c04_Xenofobia.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Ipconv -c comp/c04_Xenofobia.c -o comp/c04_Xenofobia.o

comp/c05_hydrogenBirds.o: comp/c05_hydrogenBirds.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Igt -Ipconv -c comp/c05_hydrogenBirds.c -o comp/c05_hydrogenBirds.o

comp/c06_Hsplit.o: comp/c06_Hsplit.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Ipconv -c comp/c06_Hsplit.c -o comp/c06_Hsplit.o

comp/c06_Hbells.o: comp/c06_Hbells.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Ipconv -c comp/c06_Hbells.c -o comp/c06_Hbells.o

comp/c06_Hmelody.o: comp/c06_Hmelody.c ST_wavelets.h
	$(CC) $(CFLAGS) -I. -Ipconv -c comp/c06_Hmelody.c -o comp/c06_Hmelody.o

comp/c06_JEBASE.o: comp/c06_JEBASE.c comp/c06_JEBASE.h
	$(CC) $(CFLAGS) -I. -Ipconv -c comp/c06_JEBASE.c -o comp/c06_JEBASE.o

# Only some dependancies:

ST_wavelets.o: ST_wavelets.c ST_wavelets.h ST_engine.h

# How to build the program:

$(PRG): $(OBJ)
	$(CC) $(CFLAGS) $(OBJ) $(LIBS) -o $(PRG)

clean:
	-rm $(OBJ) $(PRG) core
