#
# You may need to change this for your system.
# The ``h'' directory supplements your system, not replacing it.
# The first variation is for gcc when it isn't the native complier,
# the second variation is for systems with missing ANSI C include files,
# the third variation is for conforming ANSI C implementations.
#
# H = -I/usr/local/lib/gcc-include -I/usr/include -Ih
# H = -I/usr/include -Ih
H =
# H =				# dgux

#
# the name of the compiler to use
#
CC = cc
# CC = gcc
# CC = gcc			# dgux
# CC = rcc			# SCO

#
# The compiler flags to use, except for include path.
#
CFLAGS = -O
# CFLAGS = -g
# CFLAGS = -O			# dgux
# CFLAGS = -O -Wall -ansi	# gcc

#
# where to put the library directory
#	(not used in testing mode)
#
LIB = -D'LIB="/usr/local/lib/aegis"'

#
# extra libraries required for your system
#
LIBRARIES =
# LIBRARIES = -lbsd

# You should not need to alter anything below this point.
#------------------------------------------------------------

all: bin/fcomp bin/fhist bin/fmerge


common/ansi.o: common/ansi.c common/main.h
	$(CC) $(CFLAGS) -Icommon $(H) -c common/ansi.c
	mv ansi.o common/ansi.o

common/arglex.o: common/arglex.c common/arglex.h common/main.h \
		common/cmalloc.h common/error.h 
	$(CC) $(CFLAGS) -Icommon $(H) -c common/arglex.c
	mv arglex.o common/arglex.o

common/cmalloc.o: common/cmalloc.c common/cmalloc.h common/main.h \
		common/error.h 
	$(CC) $(CFLAGS) -Icommon $(H) -c common/cmalloc.c
	mv cmalloc.o common/cmalloc.o

common/compare.o: common/compare.c common/compare.h common/main.h \
		common/cmalloc.h common/error.h common/fileio.h 
	$(CC) $(CFLAGS) -Icommon $(H) -c common/compare.c
	mv compare.o common/compare.o

common/error.o: common/error.c common/s-v-arg.h common/main.h \
		common/error.h common/arglex.h 
	$(CC) $(CFLAGS) -Icommon $(H) -c common/error.c
	mv error.o common/error.o

common/fileio.o: common/fileio.c common/fileio.h common/main.h \
		common/cmalloc.h common/s-v-arg.h 
	$(CC) $(CFLAGS) -Icommon $(H) -c common/fileio.c
	mv fileio.o common/fileio.o

common/help.o: common/help.c common/arglex.h common/main.h \
		common/error.h common/help.h common/patchlevel.h 
	$(CC) $(CFLAGS) -Icommon $(H) -c common/help.c
	mv help.o common/help.o

common/version.o: common/version.c common/arglex.h common/main.h \
		common/cmalloc.h common/error.h common/help.h \
		common/version.h 
	$(CC) $(CFLAGS) -Icommon $(H) -c common/version.c
	mv version.o common/version.o

fcomp/main.o: fcomp/main.c common/arglex.h common/main.h \
		common/cmalloc.h common/compare.h common/error.h \
		common/fileio.h common/help.h common/version.h 
	$(CC) $(CFLAGS) -Ifcomp -Icommon $(H) -c fcomp/main.c
	mv main.o fcomp/main.o

fhist/breaks.o: fhist/breaks.c fhist/breaks.h common/main.h
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/breaks.c
	mv breaks.o fhist/breaks.o

fhist/diff.o: fhist/diff.c common/cmalloc.h common/main.h \
		common/compare.h fhist/diff.h common/error.h \
		fhist/extract.h fhist/fhist.h common/fileio.h \
		fhist/modlin.h fhist/subroutine.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/diff.c
	mv diff.o fhist/diff.o

fhist/extract.o: fhist/extract.c common/cmalloc.h common/main.h \
		common/compare.h common/error.h fhist/extract.h \
		fhist/fhist.h common/fileio.h fhist/modlin.h \
		fhist/subroutine.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/extract.c
	mv extract.o fhist/extract.o

fhist/list.o: fhist/list.c common/cmalloc.h common/main.h \
		common/compare.h common/error.h fhist/fhist.h \
		common/fileio.h fhist/list.h fhist/subroutine.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/list.c
	mv list.o fhist/list.o

fhist/main.o: fhist/main.c common/arglex.h common/main.h fhist/breaks.h \
		common/cmalloc.h common/compare.h fhist/diff.h \
		common/error.h fhist/extract.h fhist/fhist.h \
		common/help.h fhist/list.h fhist/modlin.h fhist/name.h \
		fhist/prune.h fhist/subroutine.h fhist/update.h \
		common/version.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/main.c
	mv main.o fhist/main.o

fhist/modlin.o: fhist/modlin.c common/cmalloc.h common/main.h \
		common/compare.h common/error.h fhist/fhist.h \
		common/fileio.h fhist/modlin.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/modlin.c
	mv modlin.o fhist/modlin.o

fhist/name.o: fhist/name.c fhist/breaks.h common/main.h \
		common/compare.h common/error.h fhist/fhist.h \
		common/fileio.h fhist/name.h fhist/subroutine.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/name.c
	mv name.o fhist/name.o

fhist/prune.o: fhist/prune.c fhist/breaks.h common/main.h \
		common/compare.h common/error.h fhist/fhist.h \
		common/fileio.h fhist/prune.h fhist/subroutine.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/prune.c
	mv prune.o fhist/prune.o

fhist/subroutine.o: fhist/subroutine.c common/cmalloc.h common/main.h \
		common/compare.h common/error.h fhist/fhist.h \
		common/fileio.h fhist/subroutine.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/subroutine.c
	mv subroutine.o fhist/subroutine.o

fhist/update.o: fhist/update.c fhist/breaks.h common/main.h \
		common/cmalloc.h common/compare.h common/error.h \
		fhist/fhist.h common/fileio.h fhist/modlin.h \
		fhist/subroutine.h fhist/update.h 
	$(CC) $(CFLAGS)  -Ifhist -Icommon $(H) -c fhist/update.c
	mv update.o fhist/update.o

fmerge/main.o: fmerge/main.c common/arglex.h common/main.h \
		common/cmalloc.h common/compare.h common/error.h \
		common/fileio.h common/help.h common/version.h \
		fmerge/work.h 
	$(CC) $(CFLAGS)  -Ifmerge -Icommon $(H) -c fmerge/main.c
	mv main.o fmerge/main.o

fmerge/work.o: fmerge/work.c common/cmalloc.h common/main.h \
		common/compare.h common/error.h common/fileio.h \
		fmerge/work.h 
	$(CC) $(CFLAGS)  -Ifmerge -Icommon $(H) -c fmerge/work.c
	mv work.o fmerge/work.o

t0001a: all test/00/t0001a.sh
	sh test/00/t0001a.sh

t0002a: all test/00/t0002a.sh
	sh test/00/t0002a.sh

t0003a: all test/00/t0003a.sh
	sh test/00/t0003a.sh

t0004a: all test/00/t0004a.sh
	sh test/00/t0004a.sh

t0005a: all test/00/t0005a.sh
	sh test/00/t0005a.sh

t0006a: all test/00/t0006a.sh
	sh test/00/t0006a.sh

t0007a: all test/00/t0007a.sh
	sh test/00/t0007a.sh

t0008a: all test/00/t0008a.sh
	sh test/00/t0008a.sh

t0009a: all test/00/t0009a.sh
	sh test/00/t0009a.sh

t0010a: all test/00/t0010a.sh
	sh test/00/t0010a.sh

t0011a: all test/00/t0011a.sh
	sh test/00/t0011a.sh

t0012a: all test/00/t0012a.sh
	sh test/00/t0012a.sh

t0013a: all test/00/t0013a.sh
	sh test/00/t0013a.sh

t0014a: all test/00/t0014a.sh
	sh test/00/t0014a.sh

clean:
	rm -f core common/ansi.o common/arglex.o common/cmalloc.o \
		common/compare.o common/error.o common/fileio.o \
		common/help.o common/version.o fcomp/main.o \
		fhist/breaks.o fhist/diff.o fhist/extract.o \
		fhist/list.o fhist/main.o fhist/modlin.o fhist/name.o \
		fhist/prune.o fhist/subroutine.o fhist/update.o \
		fmerge/main.o fmerge/work.o 

realclean: clean
	rm -f bin/fcomp bin/fhist bin/fmerge

clobber: realclean
	rm -f common/conf.h

common/conf.h:
	echo "#include <../conf/`uname -s`-`uname -r`>" > common/conf.h

FcompFiles = fcomp/main.o common/ansi.o common/arglex.o \
		common/cmalloc.o common/compare.o common/error.o \
		common/fileio.o common/help.o common/version.o 

bin/fcomp: $(FcompFiles)
	if [ ! -d bin ]; then mkdir bin; fi
	$(CC) -o bin/fcomp $(FcompFiles) $(LIBRARIES)

FhistFiles = fhist/breaks.o fhist/diff.o fhist/extract.o fhist/list.o \
		fhist/main.o fhist/modlin.o fhist/name.o fhist/prune.o \
		fhist/subroutine.o fhist/update.o common/ansi.o \
		common/arglex.o common/cmalloc.o common/compare.o \
		common/error.o common/fileio.o common/help.o \
		common/version.o 

bin/fhist: $(FhistFiles)
	if [ ! -d bin ]; then mkdir bin; fi
	$(CC) -o bin/fhist $(FhistFiles) $(LIBRARIES)

FmergeFiles = fmerge/main.o fmerge/work.o common/ansi.o common/arglex.o \
		common/cmalloc.o common/compare.o common/error.o \
		common/fileio.o common/help.o common/version.o 

bin/fmerge: $(FmergeFiles)
	if [ ! -d bin ]; then mkdir bin; fi
	$(CC) -o bin/fmerge $(FmergeFiles) $(LIBRARIES)

sure: t0001a t0002a t0003a t0004a t0005a t0006a t0007a t0008a t0009a \
		t0010a t0011a t0012a t0013a t0014a 
	@echo Passed All Tests
