include ./Make.config

LIBS		= libs
PROGS		= dbms utils interface
INCS		= includes protos
MAN		= man
SUBDIRS		= $(LIBS) $(PROGS) $(INCS) $(MAN)

all:
	@ for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "making" "in $$i..."; \
	$(MAKE) ) || exit $$? ; \
	done

target: all install.progs install.man
	@ cd $(DBDIR); (make create && make installdb)

depend:
	@ for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "depending" "in $$i..."; \
	$(MAKE) depend ) || exit $$? ; \
	done

install: install.libs install.progs install.includes install.man

install.libs:
	@ for i in $(LIBS) ;\
	do \
	(cd $$i ; echo "install" "in $$i..."; \
	$(MAKE) install ) || exit $$? ; \
	done
	@ (cd interface/xlincks/libxl; $(MAKE) install)

install.progs:
	@ for i in $(PROGS) ;\
	do \
	(cd $$i ; echo "install" "in $$i..."; \
	$(MAKE) install ) || exit $$? ; \
	done

install.includes:
	@ for i in $(INCS) ;\
	do \
	(cd $$i ; echo "install" "in $$i..."; \
	$(MAKE) install ) || exit $$? ; \
	done

install.man:
	@ for i in $(MAN) ;\
	do \
	(cd $$i ; echo "install" "in $$i..."; \
	$(MAKE) install ) || exit $$? ; \
	done

lint:
	@ for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "lint" "in $$i..."; \
	$(MAKE) lint ) || exit $$? ; \
	done

clean:
	/bin/rm -f TAGS *~ *.bak core *.a
	@ for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "cleaning" "in $$i..."; \
	$(MAKE) clean ) || exit $$? ; \
	done

tags:
	etags -t `find . -name '*.c' -print` `find . -name '*.h' -print`

current:
	@ for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "getting current" "in $$i..."; \
	$(MAKE) current ) || exit $$? ; \
	done

dbms:
	@ (cd dbms ; echo "making in dbms"; $(MAKE))

includes:
	@ (cd includes ; echo "making in includes"; $(MAKE))

interface:
	@ (cd interface ; echo "making in interface"; $(MAKE))

libs:
	@ (cd libs ; echo "making in libs"; $(MAKE))

utils:
	@ (cd utils ; echo "making in utils"; $(MAKE))

help:
	@ echo "\"make\" by itself will make the whole system."
	@ echo "\"make help\" prints this message."
	@ echo "\"make dbms\" will make the database management system."
	@ echo "\"make interface\" will make the X interface to the system."
	@ echo "\"make libs\" will make the libraries."
	@ echo "\"make utils\" will make the various utilities for use in the system."
	@ echo "\"make install\" will install the whole system."
	@ echo "\"make install.libs\" will install only the libraries."
	@ echo "\"make install.progs\" will install only the various runnable programs."
	@ echo "\"make install.includes\" will install the include files."
	@ echo "\"make install.man\" will install the man pages."
	@ echo "\"make clean\" will clean out executables and .o files in the source tree."
	@ echo "\"make depend\" will make dependencies for the whole system."
