#	You may modify this file to serve as a makefile
#	for your own program using the SnapPea kernel.
#	In the simplest case, all you need to do is insert
#	the name of your program (here) and the location
#	of the SnapPea kernel code (below).  Your program
#	(and this makefile) can live in any directory --
#	they needn't be with the SnapPea kernel.
YOUR_PROGRAM = NameOfYourProgram

#	Where is the SnapPea kernel source code on your computer?
SNAPPEA_KERNEL = /home/jeff/SnapPea/kernel

#	Compiler options.
#		-g	debugging code
#		-O	optimize
CFLAGS = -g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations 

#	This tells the compiler where to look for the header files.
HEADER_PATH = -I$(SNAPPEA_KERNEL)/headers/ -I$(SNAPPEA_KERNEL)/unix_kit/


$(YOUR_PROGRAM):  $(YOUR_PROGRAM).o KernelObjects/BuildDate

	gcc -o $(YOUR_PROGRAM) $(CFLAGS)	\
		$(YOUR_PROGRAM).o				\
		KernelObjects/*.o				\
		-lm
	
$(YOUR_PROGRAM).o: $(YOUR_PROGRAM).c
	gcc -c $(CFLAGS) $(HEADER_PATH) $(YOUR_PROGRAM).c

KernelObjects/BuildDate:	$(SNAPPEA_KERNEL)/code/*.c		\
							$(SNAPPEA_KERNEL)/headers/*.h	\
							$(SNAPPEA_KERNEL)/unix_kit/*

	mkdir -p KernelObjects
	cd KernelObjects;									\
	date > BuildDate;									\
	gcc -c $(CFLAGS) $(HEADER_PATH)						\
		$(SNAPPEA_KERNEL)/code/*.c						\
		$(SNAPPEA_KERNEL)/unix_kit/unix_UI.c			\
		$(SNAPPEA_KERNEL)/unix_kit/unix_cusped_census.c	\
		$(SNAPPEA_KERNEL)/unix_kit/unix_file_io.c

clean:
	rm -f  $(YOUR_PROGRAM).o
	rm -rf KernelObjects
	rm -f  *.pyc
