#/*@@ # @file make.configuration # @date Sun Jan 17 22:15:23 1999 # @author Tom Goodale # @desc # Makes the CCTK executable for a particular configuration # @enddesc # @version $Id$ # @@*/ # Silence all but designated output #.SILENT: # Some configuration variables CONFIG = $(TOP)/config-data BINDINGS_DIR = $(TOP)/bindings FLESH_DIR = $(CCTK_HOME)/src # Scratch build area - need this to make sure F90 module files end up all # in one directory. export SCRATCH_BUILD=$(TOP)/scratch DATESTAMP = $(CCTK_HOME)/src/datestamp.c FLESHLIB = Cactus BINDINGSLIB= CactusBindings CACTUSLIBS = $(FLESHLIB) $(BINDINGSLIB) export MAKE_DIR = $(CCTK_HOME)/lib/make ALLCACTUSLIBS = $(notdir $(CACTUSLIBS) $(THORNS) $(THORNS) $(CACTUSLIBS)) # Dividers to make the screen output slightly nicer DIVEL = __________________ DIVIDER = $(DIVEL)$(DIVEL)$(DIVEL)$(DIVEL) # Include the definitions for this configuration include $(CONFIG)/make.config.defn # Include the list of thorns to be built # (Use -include to prevent warnings messages, as the file will be built if # it is missing .) # We don't want to include this file if doing something like a make clean # as, if the file didn't exist, it would first be made, which would be # pretty confusing during a make clean ! ifeq ($(strip $(MAKECMDGOALS)),) -include $(CONFIG)/make.thornlist endif # Allow each thorn to include some global definitions ifneq ($(strip $(THORNS)),) -include $(THORNS:%=$(PACKAGE_DIR)/%/src/make.configuration.defn) endif # Build the executable $(EXEDIR)$(DIRSEP)$(EXE): $(CONFIG)/make.thornlist $(CONFIG)/cctk_version.h $(patsubst %,$(CCTK_LIBDIR)/lib%.a,$(notdir $(THORNS) $(CACTUSLIBS))) @echo $(DIVIDER) @echo Creating $(EXE) in $(EXEDIR) from $(THORNS) $(CC) $(DEBUG_C) $(CFLAGS) $(CCOMPILEONLY)$(OPTIONSEP)$(TOP)$(DIRSEP)datestamp.o -I$(CONFIG) $(subst /,$(DIRSEP),$(DATESTAMP)) if [ ! -d $(EXEDIR) ]; then $(MKDIR) $(EXEDIR) ; fi $(LD) $(CREATEEXE)$(OPTIONSEP)$(subst /,$(DIRSEP),$@) $(DEBUG_LD) $(LDFLAGS) $(EXTRAFLAGS) $(subst /,$(DIRSEP), $(TOP)/datestamp.o) $(CACTUSLIBLINKLINE) $(LIBDIRS:%=-L%) $(LIBS:%=-l%) @echo $(DIVIDER) @echo All done ! @echo $(DIVIDER) # Version file $(CONFIG)/cctk_version.h: $(CCTK_HOME)/Makefile echo "#ifndef _CCTK_VERSION_H_" > $@ echo "#define _CCTK_VERSION_H_" >> $@ echo "#define CCTK_VERSION_MAJOR $(CCTK_VERSION_MAJOR)" >> $@ echo "#define CCTK_VERSION_MINOR $(CCTK_VERSION_MINOR)" >> $@ echo "#define CCTK_VERSION_OTHER $(CCTK_VERSION_OTHER)" >> $@ echo "#define CCTK_VERSION $(CCTK_VERSION)" >> $@ echo "#endif /* _CCTK_VERSION_H_*/" >> $@ # Build a thorn library # Libraries go into the appropriate library directory # Each thorn's object files go into $(BUILD_DIR)/ # This makes sure the appropriate build directories exist # Also checks for the existance of Makefile in the thorn's # src directory, and calls that rather than the default makefile # used for making thorn libraries. # # Checks if the library is Cactus, in which case it uses the main source # directory. $(CCTK_LIBDIR)/lib%.a: update @echo $(DIVIDER) @echo Checking status of $(notdir $@) if [ ! -d $(SCRATCH_BUILD) ]; then $(MKDIR) $(SCRATCH_BUILD) ; fi if [ ! -d $(BUILD_DIR) ]; then $(MKDIR) $(BUILD_DIR) ; fi thorn_name=$(@:$(CCTK_LIBDIR)/lib%.a=%); \ if [ "$$thorn_name" = "Cactus" ] ; then src_dir=$(CCTK_HOME)/src ; \ else if [ "$$thorn_name" = "CactusBindings" ] ; then src_dir=$(BINDINGS_DIR) ; \ else src_dir=$(PACKAGE_DIR)/$(@:$(CCTK_LIBDIR)/lib%.a=$(filter %/$(@:$(CCTK_LIBDIR)/lib%.a=%), $(THORNS)))/src ; fi ; fi ;\ if [ ! -d $(BUILD_DIR)/$$thorn_name ]; then $(MKDIR) $(BUILD_DIR)/$$thorn_name ; fi ; \ cd $(BUILD_DIR)/$$thorn_name ; \ if [ -r "$$src_dir/Makefile" ] ; then make_file=$$src_dir/Makefile ; \ else make_file=$(MAKE_DIR)/make.thornlib ; fi ; \ $(MAKE) TOP=$(TOP) SRCDIR=$$src_dir CONFIG=$(CONFIG) NAME=$@ THORN=$$thorn_name -f $$make_file -j $(FJOBS) @echo $(DIVIDER) # Include any extra dependencies include $(CONFIG)/make.config.deps # Rule to build the make.thornlist file from the ThornList file $(CONFIG)/make.thornlist: $(TOP)/ThornList $(foreach lib, $(CCTK_HOME)/src $(THORNS:%=$(PACKAGE_DIR)/%), $(lib)/param.ccl $(lib)/interface.ccl $(lib)/schedule.ccl) @echo $(DIVIDER) if [ -r $@ ] ; then echo Reconfiguring thorns ; rm $@ ;\ else echo Configuring thorns ; fi $(PERL) -s $(CST) -config_dir=$(CONFIG) -cctk_home=$(CCTK_HOME) -top=$(TOP) $< # Rule to build ThornList $(TOP)/ThornList: @echo $(DIVIDER) @echo Creating compiled ThornList containing all thorns in the arrangements directory $(PERL) -s $(BUILD_ACTIVETHORNS) $(CCTK_HOME)/arrangements > $@ action="yes"; if [ "x$$EDITOR" = "x" ] ; then EDITOR=vi ; fi; \ while [ "x$$action" = "xyes" -o "x$$action" = "xy" -o "x$$action" = "xYES" -o "x$$action" = "xY" ] ; \ do \ echo The thorn list is ; \ echo $(DIVIDER) ; \ cat $@ ; \ echo $(DIVIDER) ; \ echo Edit this list \(no\) \? ; \ read action rest ; \ if [ "x$$action" = "xyes" -o "x$$action" = "xy" -o "x$$action" = "xYES" -o "x$$action" = "xY" ] ; \ then $$EDITOR $@ ; fi ; \ done @echo $(DIVIDER) # Allow each thorn to include some global dependencies ifneq ($(strip $(THORNS)),) -include $(THORNS:%=$(PACKAGE_DIR)/%/src/make.configuration.deps) endif # Phony targets. .PHONY:update clean cleandeps cleanobjs realclean update: clean: @echo Deleting all object and dependency files in $(TOP) find $(TOP) \( -name '*.[od]' -o -name '*.a' \) -exec rm {} \; cleandeps: @echo Deleting all dependency files in $(TOP) find $(TOP) \( -name '*.[d]' -o -name '*.a' \) -exec rm {} \; cleanobjs: @echo Deleting all object files in $(TOP) find $(TOP) \( -name '*.[o]' -o -name '*.a' \) -exec rm {} \; realclean: @echo Deleting all built files in $(TOP) rm -rf $(TOP)/build rm -rf $(TOP)/bindings rm -rf $(TOP)/config-data/make.thornlist rm -rf $(TOP)/lib/* rm -f datestamp.o