##############################################################################
#
# Global Makefile for Cpptcl under Unix.
#
# This just cd's to the tmp directory and runs make from there, for people
# who prefer to run configure and make from the root directory ala GNU
# software.  As such, it only supports the most commonly used targets in
# tmp/Makefile.  It would be nice if make had a way to pass target
# info to recursive makes.
#
# Note: if the default configure settings are acceptable, then you can just
# type "make" and configure will be run for you.  In general however it is
# best to run configure yourself to ensure all options are set correctly.
#
##############################################################################

prefix = ${HOME}
exec-prefix = ${HOME}

libtype = shared
#libtype = static

default:	${libtype}Libs demo

demo:
	cd Demo; $(MAKE); cd ..
	
sharedLibs:
	cd Cpptcl/tmp${ARCH} ; $(MAKE) sharedLib; $(MAKE) installShared; cd ../..
	cd Cpptclextra/tmp${ARCH}; $(MAKE) sharedLib; $(MAKE) installShared; cd ../..
	make installLibFiles
	
1:
	cd Cpptcl/tmp${ARCH} ; $(MAKE) sharedLib; $(MAKE) installShared; cd ../..

2:
	cd Cpptclextra/tmp${ARCH}; $(MAKE) sharedLib; $(MAKE) installShared; cd ../..

staticLibs:
	cd Cpptcl/tmp${ARCH} ; $(MAKE) staticLib; $(MAKE) installStatic; cd ../..
	cd Cpptclextra/tmp${ARCH}; $(MAKE) staticLib; $(MAKE) installStatic; cd ../..
	make installLibFiles

installLibFiles:
	mkdir ${ARCHINDEPDIR}/lib/cpptcl2.0
	cp library/* ${ARCHINDEPDIR}/lib/cpptcl2.0/

install:
	echo "Install defunct; occurs during compilation"
	cp Cpptcl/Headers/Cpptcl.h ${ARCHINDEPDIR}/include
	cp Cpptclextra/Headers/Cpptclextra.h ${ARCHINDEPDIR}/include

cleanlibs:
	rm -f Cpptcl/lib*.a
	rm -f Cpptclextra/lib*.a
	
cleanshlibs:
	rm -f Cpptcl/lib*.so*
	rm -f Cpptclextra/lib*.so*
	rm -f lib*.so*

clean: cleanbackups
	rm -fr tmpsun4
	cd Cpptcl ; rm -fr tmpsun4 ; cd ..
	cd Cpptclextra; rm -fr tmpsun4 ; cd ..
	cd Demo; rm -f *.o; rm -f Makefile; cd ..

makefiles:
	rm -f tmpsun4/Makefile
	rm -f Cpptcl/configure
	rm -f Cpptclextra/configure
	rm -f Cpptcl/tmpsun4/Makefile
	rm -f Cpptclextra/tmpsun4/Makefile
	./configure

cleanbackups:
	cd Cpptcl ; rm -f *~ ; cd ..
	cd Cpptclextra; rm -f *~ ; cd ..
	cd Demo; rm -f *~ ; cd ..
    
veryclean: clean cleanshlibs
	rm -f Cpptcl/configure
	rm -f Cpptclextra/configure
	
depend:		
	cd Cpptcl/tmp${ARCH} ; $(MAKE) depend; cd ../..
	cd Cpptclextra/tmp${ARCH}; $(MAKE) depend; cd ../..
	
archive:
	cd ..
	rm -f cpptcl.tar.gz	
	tar -cf cpptcl.tar Cpptcl/*
	tar -rf cpptcl.tar Cpptcl/Cpptcl/*
	tar -rf cpptcl.tar Cpptcl/Cpptcl/Source/*.*c
	tar -rf cpptcl.tar Cpptcl/Cpptcl/Source/*.*p
	tar -rf cpptcl.tar Cpptcl/Cpptcl/Headers/*.h
	tar -rf cpptcl.tar Cpptcl/Cpptcl/Headers/*.*c
	tar -rf cpptcl.tar Cpptcl/Cpptclextra/*
	tar -rf cpptcl.tar Cpptcl/Cpptclextra/Source/*.*c
	tar -rf cpptcl.tar Cpptcl/Cpptclextra/Source/*.*p
	tar -rf cpptcl.tar Cpptcl/Cpptclextra/Headers/*.h
	tar -rf cpptcl.tar Cpptcl/Cpptclextra/Headers/*.*c
	tar -rf cpptcl.tar Cpptcl/library/*
	tar -rf cpptcl.tar Cpptcl/Demo/*.cc
	tar -rf cpptcl.tar Cpptcl/Demo/*.h
	tar -rf cpptcl.tar Cpptcl/Demo/*.txt
	tar -rf cpptcl.tar Cpptcl/Demo/*.orig
	gzip cpptcl.tar
	cd Cpptcl
	echo "Done tarring"

unarchive:
	cd ..
	rm -f cpptcl.tar
	gunzip cpptcl.tar.gz
	tar -xf cpptcl.tar
	cd Cpptcl
	echo "Done un-tarring"

tags:
	cd headers
	etags *.h
	cd ../source
	etags *.*c
	cd ..
	etags -include=headers/TAGS -include=source/TAGS

		





