#
# Makefile adapted from the InterMezzo project
#
include config.mk

help all:
	@echo "Pick one of the following targets:"
	@echo -e "\tmake config\t\t- configure and check system setup"
	@echo -e "\tmake modules\t\t- build modules"
	@echo -e "\tmake install\t\t- install module"
	@echo -e "\tmake clean\t\t- clean up the directory"

config .prereq.ok:
	@if [ ! -d include/linux ]; then mkdir -p include/linux ; fi
	@touch config.mk
	@$(MAKE) -s clean
	@./Configure

oldconfig:
	@touch config.mk
	@$(MAKE) -s clean
	@./Configure -n

kcheck:
	@. config.out ; \
	if [ "$$CHECK" != "" ] ; then \
	    if [ "`cksum < $$CHECK`" != "$$CKSUM" ] ; then \
		/bin/echo -n "Kernel configuration has changed." ; \
		/bin/echo "  Please re-run 'make config'." ; \
		exit 1 ; \
	    fi ; \
	fi

modules: zkshim.o

zkshim.o: .prereq.ok
	( cd src; make )

install: .prereq.ok
	( cd src; make install ) 

clean:
	cd src; rm -f core core.* *.o .*.o *.d *.s *.a *~ .depend .depfiles/*.d

distclean: clean
	rm -rf .prereq.ok config.out config.mk src/.depfiles include/linux
	touch config.mk
