# DOCK top-level installation Makefile.
# This is mostly for building and testing executables from source files.
# It merely invokes make with the appropriate target, for example install
# or clean, in all the specified directories.

include ./rules.h


install: configured
	@echo "Starting installation of "
	@echo ${DOCK_VERSION}
	@echo "at `date`."
	@echo ""
	cd ../src && make install
	@echo ""
	@echo "Installation of "
	@echo ${DOCK_VERSION}
	@echo "is complete at `date`."
	@echo ""

all: install

dock: configured
	@echo "Starting installation of "
	@echo ${DOCK_VERSION}
	@echo "program dock at `date`."
	@echo ""
	cd ../src/dock && make install
	@echo ""
	@echo "Installation of "
	@echo ${DOCK_VERSION}
	@echo "program dock is complete at `date`."
	@echo ""

utils: configured
	@echo "Starting installation of "
	@echo ${DOCK_VERSION}
	@echo "utilities at `date`."
	@echo ""
	cd ../src && make utils
	@echo ""
	@echo "Installation of "
	@echo ${DOCK_VERSION}
	@echo "utilities is complete at `date`."
	@echo ""

test: 
	cd test && make test
	cd test && make check

# This target removes all object files.
clean: 
	cd ../src && make clean

# This target removes dock object files.
cleandock: 
	cd ../src/dock && make clean

dockclean: cleandock

# This target removes installed executables from bin.
uninstall:
	cd ../src && make uninstall

# This target cleans and removes executables from the source directories.
realclean:
	cd ../src && make realclean

# This target realcleans, removes the configuration file and cleans the tests.
distclean: realclean
	cd ./test && make clean
	-/bin/rm $(CONFIG_FILE)

# This target cleans and removes all executables and the configuration file.
superclean: uninstall distclean

configured:
	@# abort if the configuration file does not exist
	@(if [ ! -f $(CONFIG_FILE) ] ; then \
	    echo "Error: $(CONFIG_COMMAND) must be executed before make !" ;\
	    exit 2 ;\
	fi ;\
	)

# This target exports and archives the DOCK directory tree.
# It is a template for a bourne script taking the tag name and destination
# as arguments.
DESTINATION=sbrozell@pusar.scripps.edu:tmp
DISTRIBUTION_TAG=HEAD
DISTRIBUTION_TAG=dock6-1-release
#DOCK_HOME=..
DOCK_MODULE=dock6
archive_export:
	#cd $(DOCK_HOME) && cvs tag -c $(DISTRIBUTION_TAG)
	cd /tmp && cvs -Q export -r $(DISTRIBUTION_TAG) $(DOCK_MODULE)
	cd /tmp/$(DOCK_MODULE) && mkdir bin  # because export prunes empty directories
	cd /tmp/$(DOCK_MODULE) && rm -rf developer  # developer is non-public
	cd /tmp/$(DOCK_MODULE) && rm -rf docs  # docs is only released on the web
	cd /tmp/$(DOCK_MODULE) && tar zvcf ../$(DOCK_MODULE).$(DISTRIBUTION_TAG).tgz .
	rm -rf /tmp/$(DOCK_MODULE)
	-cd /tmp && scp $(DOCK_MODULE).$(DISTRIBUTION_TAG).tgz $(DESTINATION)
	rm -i /tmp/$(DOCK_MODULE).$(DISTRIBUTION_TAG).tgz
	@echo "Exporting of $(DOCK_MODULE).$(DISTRIBUTION_TAG) is completed."

