#
# Makefile
#
# This file is the Makefile for lib/graphlet/config.
#
#------------------------------------------
#
# $Source: /home/br/CVS/graphlet/lib/graphlet/config/GNUmakefile,v $
# $Author: himsolt $
# $Revision: 1.2 $
# $Date: 1999/03/05 20:39:18 $
# $Locker:  $
# $State: Exp $
#
#------------------------------------------
#
# (C) University of Passau 1995-1999, graphlet project
#

GRAPHLET_BASE_DIR=../../..


include $(GRAPHLET_BASE_DIR)/lib/graphlet/config/common

.PHONY:	install.local

#
# All is configure
#

all:	configure

##########################################
#
# configure
#
##########################################

configure:	configure.config configure.modules

# subtargets (for my eyes only -- MH)
configure.config::	$(GRAPHLET_SRC_GT_BASE_DIR)/config.h
configure.modules::	$(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.h
configure.modules::	$(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp
#configure.modules::	$(GRAPHLET_GRAPHSCRIPT_DIR)/init/modules.tcl


$(GRAPHLET_SRC_GT_BASE_DIR)/config.h:	config version
	echo "// This file is generated automatically" > \
		$(GRAPHLET_SRC_GT_BASE_DIR)/config.h
	echo "#define GT_MAJOR_VERSION "$(MAJORVERSION) >> \
		$(GRAPHLET_SRC_GT_BASE_DIR)/config.h
	echo "#define GT_MINOR_VERSION "$(MINORVERSION) >> \
		$(GRAPHLET_SRC_GT_BASE_DIR)/config.h
	echo "#define GT_MINI_VERSION "$(MINIVERSION) >> \
		$(GRAPHLET_SRC_GT_BASE_DIR)/config.h
	echo "#define GT_RELEASE \""$(RELEASE)"\"" >> \
		$(GRAPHLET_SRC_GT_BASE_DIR)/config.h
	echo "#define GT_GRAPHLET_DIR \""$(INSTALL_DIR)"\"" >> \
		$(GRAPHLET_SRC_GT_BASE_DIR)/config.h


$(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.h:	modules config
	echo "// This file is generated automatically" > \
	    $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.h
ifneq ($(strip $(EXTENSION_MODULES)),)
	for m in $(EXTENSION_MODULES) ; do \
	    mod=`echo $$m | sed -e s/gt_//` ; \
	    echo "extern \"C\" int Gt_$${mod}_Init (Tcl_Interp *interp);" >> \
	        $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.h ; \
	done
endif


$(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp:	modules config
	echo "// This file is generated automatically" > \
	    $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp;
ifdef GT_SUPPORT_SHARED_LIBRARIES
	echo "#ifdef GT_STATIC_LINKING" >> \
	    $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp;
endif
	echo "Tcl_StaticPackage(interp, \"Graphscript\", Gt_tcl_Init, 0);" >> \
	    $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp;
ifneq ($(strip $(EXTENSION_MODULES)),)
	for m in $(EXTENSION_MODULES) ; do \
	    mod=`echo $$m | sed -e s/gt_//` ; \
	    echo "code = Gt_$${mod}_Init (interp);" >> \
	        $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp ; \
	    echo "if (code == TCL_ERROR) { return code; }" >> \
	        $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp ; \
	    echo "Tcl_StaticPackage(interp, \"Gt_$${mod}\", Gt_$${mod}_Init, 0);" >> \
	        $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp ; \
	done ;
endif
ifdef GT_SUPPORT_SHARED_LIBRARIES
	echo "#endif" >> \
	    $(GRAPHLET_SRC_GRAPHSCRIPT_DIR)/modules.cpp;
endif


#$(GRAPHLET_GRAPHSCRIPT_DIR)/init/modules.tcl:	modules config
#	echo "# This file is generated automatically" > \
#		$(GRAPHLET_GRAPHSCRIPT_DIR)/init/modules.tcl
#	echo "global GT" >> \
#		$(GRAPHLET_GRAPHSCRIPT_DIR)/init/modules.tcl
#ifneq ($(strip $(EXTENSION_MODULES)),)
#	for m in "$(EXTENSION_MODULES)" ; do \
#	    echo "lappend GT(modules) $${m}" >> \
#	        $(GRAPHLET_GRAPHSCRIPT_DIR)/init/modules.tcl ; \
#	done
#endif


##########################################
#
# newversion (upgrade miniversion; contact himsolt@fmi.uni-passau.de)
#
##########################################

newversion:
	$(RM) version-$(VERSION) ; \
	$(CP) version version-$(VERSION) ; \
	$(CAT) version | \
		$(SED) -ne '1,/AUTOGENERATED CODE START/ p' > version.tmp ;\
	echo MAJORVERSION=$(MAJORVERSION) >> version.tmp ; \
	echo MINORVERSION=$(MINORVERSION) >> version.tmp ; \
	echo MINIVERSION=`expr $(MINIVERSION) + 1` >> version.tmp ; \
	echo RELEASE=$(RELEASE) >> version.tmp ; \
	$(CAT) version | \
		$(SED) -ne '/AUTOGENERATED CODE END/,$$ p' >> version.tmp ; \
	$(RM) version ; \
	$(CP) version.tmp version ; \
	$(RM) version.tmp version-$(VERSION) ;

##########################################
#
# install
#
##########################################

CONFIG_FILES=application config config-details system-specs version common modules

install.local::
	$(INSTALL_MAKE_DIR) $(INSTALL_CONFIG_DIR)
	$(INSTALL_FILE) $(CONFIG_FILES) $(INSTALL_CONFIG_DIR)


##########################################
#
# Set emacs variables
#
##########################################

# ;;; Local Variables: ***
# ;;; mode: makefile ***
# ;;; End: ***
