default: all

RIP=`pwd`

# RIP Code
links:
	cd include; $(MAKE); cd ..
definitions:
	cd defs; $(MAKE); cd ..
libs:
	./utils/mkinstalldirs lib; cd modules; $(MAKE); cd ..
test:
	cd tests; $(MAKE); cd ..
rip:
	cd bin/rip; $(MAKE); cd ../..
load:
	cd bin/load; $(MAKE); cd ../..
dbupdate:
	cd bin/dbupdate; $(MAKE); cd ../..

all: links libs rip load dbupdate



# RIP Documentation
INCDIRS = -I./include -I/ncc/dbwork/platforms/sparc-sun-solaris2.7/lib/glib/include -I/opt/package/mysql/include/mysql
DEF = -DHAVE_STRTOK_R
CXREF = /usr/local/bin/cxref ${INCDIRS} ${DEF}
cxref: links clean_cxref
	./utils/mkinstalldirs ./doc/cxref
	${CXREF} -O ./doc/cxref -N index -verbatim-comments -xref-all -index-all -html32-src ./modules/*/*.c modules/*/*.h ./include/*.h

GTAGS = /usr/local/bin/gtags
HTAGS = /usr/local/bin/htags -na
global: clean_global
	${GTAGS}
	${HTAGS}
	rm GPATH GRTAGS GSYMS GTAGS
	utils/mkinstalldirs doc
	mv HTML doc/global

docs: cxref global

# Release tag.
RELEASE_TAG=V_`cat VERSION | head -5 | cut -f2 -d'=' | tr -d " \n"`

clean_global:
	rm -rf doc/global/*/*
	rm -rf doc/global

clean_cxref:
	rm -rf doc/cxref/include/*
	rm -rf doc/cxref

clean_docs: clean_cxref clean_global
	rm -rf doc

# RIP Cleaning
clean_include:
	cd include; $(MAKE) clean; cd ..

clean_modules:
	cd modules; $(MAKE) clean; cd ..

clean_libs:
	$(RM) lib/*.a

clean_definitions:
	cd defs; $(MAKE) clean; cd ..

clean_test:
	cd tests; $(MAKE) clean; cd ..

clean_rip:
	cd bin/rip; $(MAKE) clean; cd ..

clean_create:
	cd bin/create; $(MAKE) clean; cd ..

clean_dbupdate:
	cd bin/dbupdate; $(MAKE) clean; cd ..

clean_loader:
	cd bin/load; $(MAKE) clean; cd ..

clean_kit:
	rm -rf RIP-${VERSION}

clean_release_tag:
	cvs tag -d ${RELEASE_TAG}

clean: clean_include clean_modules clean_libs clean_test clean_rip clean_kit clean_dbupdate clean_loader 



DISTFILES = COPYING INSTALL Makefile Makefile.site Makefile.site.generic NAME README RELEASE-NOTES PROPERTIES.example VERSION bin defs design doc include modules utils
include VERSION

# Distribution kit
kit: clean
	mkdir RIP-${VERSION}
	@(cd RIP-${VERSION}; for i in ${DISTFILES}; do ln -s ../$$i $$i; done)
	gtar -c -v -z -h --exclude-from=EXCLFILE -f RIP-${VERSION}.tar.gz RIP-${VERSION}
	rm -rf RIP-${VERSION}

release_tag: 
	cvs tag ${RELEASE_TAG}
	@echo tagged with ${RELEASE_TAG}
	@echo Ready for pre-release testing.  Run...
	@echo % RIP_test ${RELEASE_TAG}

release: docs kit 
