default: all

RIP=`pwd`

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

all: links defs libs rip


INCDIRS = -I./include -I/space/dbdev/marek/lib/glib/include -I/space/dbdev/marek/include -I/usr/local/mysql/include


# RIP Documentation
CXREF = /home/ottrey/rowan/bin/cxref ${INCDIRS}
cxref: links clean_cxref
	./utils/mkinstalldirs ./doc/html
	${CXREF} -O ./doc/html -N index -verbatim-comments -xref-all -index-all -html32-src ./modules/*/*.c modules/*/*.h ./include/*.h

GTAGS = /spool/marek/bin/solaris/gtags
HTAGS = /spool/marek/bin/solaris/htags
global: clean_global
	${GTAGS}
	${HTAGS}
	rm GPATH GRTAGS GSYMS GTAGS
	utils/mkinstalldirs doc
	mv HTML doc

docs: cxref global

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

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

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

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_tests:
	cd tests; $(MAKE) clean; cd ..

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

clean_create:
	cd bin/create; $(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_tests clean_rip clean_kit



DISTFILES = INSTALL Makefile Makefile.in Makefile.in.solaris Makefile.in.solaris2.6 Makefile.in.solaris2.7 NAME README 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 
