# This is the Makefile for my area-interaction coupling from the 
# past algorithm.  My first ever makefile, so it's a bit basic!
# A great intro to 'make' is at 
# http://www.delorie.com/djgpp/doc/ug/larger/makefiles.html

USER = magka
CC = gcc
OUTFILE = cftpsim
OBJECTS = cftpmain.o getp.o init.o dom.o process.o rand41.o fgetword.o ssort2.o cover.o maxmeasure.o minmeasure.o maxbirth.o minbirth.o maxdeath.o mindeath.o rnorm.o
SOURCES = cftpmain.c getp.c init.c dom.c process.c rand41.c fgetword.c ssort2.c cover.c maxmeasure.c minmeasure.c maxbirth.c minbirth.c maxdeath.c mindeath.c rnorm.c
HEADERS = cftpmain.h getp.h init.h dom.h process.h fgetword.h cover.h maxmeasure.h minmeasure.h maxbirth.h minbirth.h maxdeath.h mindeath.h
CATFILES = head.h cftpmain.h cftpmain.c getp.h getp.c fgetword.h fgetword.c init.h init.c ../include/rand41.h ../random/rand41.c dom.h dom.c process.h process.c cover.h cover.c ../include/ssort.h ../sort/ssort2.c maxmeasure.h maxmeasure.c minmeasure.h minmeasure.c maxbirth.h maxbirth.c minbirth.h minbirth.c maxdeath.h maxdeath.c mindeath.h mindeath.c ../include/rnorm.h ../random/rnorm.c 
CFLAGS = -march=i686 -malign-double -O2 -ffast-math -fomit-frame-pointer -Wall -I$(HPATH)
LOADLIBES = -lm
VPATH = ../random:../sort
HPATH = /home/$(USER)/Cfiles/include

$(OUTFILE) : $(OBJECTS) $(HEADERS) head.h
	$(CC) $(CFLAGS) $(OBJECTS) -o $(OUTFILE) $(LOADLIBES)

%.o : %.c %.h
	$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

.PHONY : clean
clean :
	rm $(OBJECTS) $(OUTFILE)

allsource.c.bz2 : $(CATFILES)
	if test -f allsource.c.bz2 ; then rm allsource.c.bz2 ; fi
	if test -f allsource.c ; then rm allsource.c ; fi
	cat $(CATFILES) > allsource.c
	bzip2 allsource.c

.PHONY : all
all : $(OUTFILE)

.PHONY : cat
cat : allsource.c.bz2
