#/*@@ # @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$ # @@*/ # 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 # Check if the user specified options which are only used at configure time # We only check some obvious configuration options here. ifneq ($(strip $(DEBUG)), ) $(warning "You specified 'DEBUG=$(DEBUG)'. This option is evaluated only at configuration time and will be ignored at compile time.") endif ifneq ($(strip $(OPTIMISE)), ) $(warning "You specified 'OPTIMISE=$(OPTIMISE)'. This option is evaluated only at configuration time and will be ignored at compile time.") endif ifneq ($(strip $(OPTIMIZE)), ) $(warning "You specified 'OPTIMIZE=$(OPTIMIZE)'. This option is evaluated only at configuration time and will be ignored at compile time.") endif ifneq ($(strip $(PROFILE)), ) $(warning "You specified 'PROFILE=$(PROFILE)'. This option is evaluated only at configuration time and will be ignored at compile time.") endif export MAKE_DIR = $(CCTK_HOME)/lib/make CCTK_LIBNAME_PREFIX=thorn_ FLESHLIB = Cactus BINDINGSLIB= CactusBindings CACTUSLIBS = $(FLESHLIB) $(BINDINGSLIB) # Dividers to make the screen output slightly nicer DIVEL = __________________ DIVIDER = $(DIVEL)$(DIVEL)$(DIVEL)$(DIVEL) ifeq ($(shell echo $(VERBOSE) | tr '[:upper:]' '[:lower:]'),yes) define NOTIFY_DIVIDER echo $(DIVIDER) endef else define NOTIFY_DIVIDER : endef endif # Include the definitions for this configuration include $(CONFIG)/make.config.defn # Define the name of the source file which is the one object on the linkline DATESTAMP = $(CCTK_HOME)/src/datestamp.c export PERLINTERP = $(shell echo $(PERL) | sed 's,^/cygdrive/\(.\)/,\1:/,' | sed 's,^//\(.\)/,\1:/,' ) # Use a phony main target to make sure we print a nice ending message 8-) .PHONY: main main: $(EXEDIR)$(DIRSEP)$(EXE) @echo All done ! $(NOTIFY_DIVIDER) # Put this in temporarily to make sure that people with existing # configurations aren't disturbed ifeq ($(strip $(LIBNAME_PREFIX)),) ifeq ($(strip $(LIBNAME_SUFFIX)),) LIBNAME_PREFIX = lib# LIBNAME_SUFFIX = .a endif endif # 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 # because 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 ifeq ($(strip $(MAKECMDGOALS)), utils) -include $(CONFIG)/make.thornlist endif ifeq ($(strip $(MAKECMDGOALS)), build) -include $(CONFIG)/make.thornlist endif ifeq ($(suffix $(strip $(MAKECMDGOALS))), .custom) -include $(CONFIG)/make.thornlist endif # When building utility programs, include makefile definitions # generated from a thorn's configuration.ccl ifeq ($(strip $(UTILS)),) ifneq ($(strip $(THORN_LINKLIST)),) -include $(THORN_LINKLIST:%=$(BINDINGS_DIR)/Configuration/Thorns/make.%.defn) endif endif # Allow each thorn to include some global definitions ifneq ($(strip $(THORNS)),) -include $(THORNS:%=$(PACKAGE_DIR)/%/src/make.configuration.defn) endif ifeq ($(strip $(UTILS)),) override UTILS = $(ALL_UTILS) endif UTIL_DIR=$(EXEDIR)$(DIRSEP)$(CONFIG_NAME) # Build the list of all libraries ifeq ($(strip $(BEGIN_WHOLE_ARCHIVE_FLAGS)),) # Repeat Cactus only if --whole-archive is not used ALLCACTUSLIBS_BASE = $(notdir $(CACTUSLIBS) $(THORN_LINKLIST) $(CACTUSLIBS)) else ALLCACTUSLIBS_BASE = $(notdir $(THORNS) $(CACTUSLIBS)) endif ALLCACTUSLIBS = $(ALLCACTUSLIBS_BASE:%=$(CCTK_LIBNAME_PREFIX)%) $(CCTK_LIBDIR)/LINKLIST: $(patsubst %,$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX),$(notdir $(THORNS) $(CACTUSLIBS))) cd $(CCTK_LIBDIR); \ for thorn in $(notdir $(THORNS) $(CACTUSLIBS)); do \ $(XARGS) -n 1 -I :OBJFILE: echo $$thorn/:OBJFILE: <$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)$$thorn$(LIBNAME_SUFFIX).objectlist; \ done >$@.tmp mv $@.tmp $@ # Build the executable $(EXEDIR)$(DIRSEP)$(EXE): $(CONFIG)/make.thornlist $(CONFIG)/cctki_version.h $(patsubst %,$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX),$(notdir $(THORNS) $(CACTUSLIBS))) $(CCTK_LIBDIR)/LINKLIST @echo Creating $(EXE) in $(EXEDIR) from $(THORNS) datetime=`/bin/date +'%Y-%m-%dT%H:%M:%S%z' 2>&1` ; \ if [ $$? != 0 ]; then datetime=`/bin/date` ; fi ; \ $(CC) $(CFLAGS) -DCCTK_COMPILE_DATETIME="$$datetime" $(CCOMPILEONLY)$(OPTIONSEP)"$(call TRANSFORM_DIRS,$(TOP)/datestamp.o)" -I"$(call TRANSFORM_DIRS,$(CCTK_HOME)/src/include)" -I"$(call TRANSFORM_DIRS,$(CONFIG))" "$(call TRANSFORM_DIRS,$(DATESTAMP))" if [ ! -d $(EXEDIR) ]; then $(MKDIR) $(MKDIRFLAGS) $(EXEDIR) ; fi $(LD) $(CREATEEXE)$(OPTIONSEP)"$(call TRANSFORM_DIRS,$@)" $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(EXTRAFLAGS) "$(call TRANSFORM_DIRS,$(TOP)/datestamp.o)" $(BEGIN_WHOLE_ARCHIVE_FLAGS) $(CACTUSLIBLINKLINE) $(END_WHOLE_ARCHIVE_FLAGS) $(GENERAL_LIBRARIES) @echo Done creating $(EXE). $(NOTIFY_DIVIDER) # Version file $(CONFIG)/cctki_version.h: $(CCTK_HOME)/Makefile echo "#ifndef _CCTKI_VERSION_H_" > $@ echo "#define _CCTKI_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 /* _CCTKI_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)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX): update # (the mkdir below is protected against parallel makes) @thorn_name=$(@:$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX)=%) ; \ echo "Checking status of thorn $$thorn_name" ; \ if [ ! -d $(SCRATCH_BUILD) ] ; \ then \ msg=`$(MKDIR) $(MKDIRFLAGS) $(SCRATCH_BUILD) 2>&1` ; \ if [ ! -d $(SCRATCH_BUILD) ] ; \ then \ echo "$$msg" ; \ exit 1 ; \ fi ; \ fi ; \ if [ ! -d $(BUILD_DIR) ] ; \ then \ msg=`$(MKDIR) $(MKDIRFLAGS) $(BUILD_DIR) 2>&1` ; \ if [ ! -d $(BUILD_DIR) ] ; \ then \ echo "$$msg" ; \ exit 1 ; \ fi ; \ fi ; \ 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)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX)=$(filter %/$(@:$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX)=%), $(THORNS)))/src ; \ fi ; \ fi ; \ if [ ! -d $(BUILD_DIR)/$$thorn_name ]; \ then \ $(MKDIR) $(MKDIRFLAGS) $(BUILD_DIR)/$$thorn_name ; \ fi ; \ cd $(BUILD_DIR)/$$thorn_name ; \ $(NOTIFY_DIVIDER) ; \ 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 USESTHORNS="$(USESTHORNS_$(@:$(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX)=%))" -f $$make_file $(FPARFLAGS) $(NOTIFY_DIVIDER) # Include any extra dependencies include $(CONFIG)/make.config.deps # Rule to build the make.thornlist file from the ThornList file rebuild: $(CONFIG)/make.thornlist $(CONFIG)/make.thornlist: $(TOP)/ThornList $(foreach lib, $(CCTK_HOME)/src $(THORNS:%=$(PACKAGE_DIR)/%), $(lib)/param.ccl $(lib)/interface.ccl $(lib)/schedule.ccl) $(CCTK_HOME)/src/configuration.ccl $(CONFIG_THORNS:%=$(PACKAGE_DIR)/%/configuration.ccl) $(CCTK_HOME)/lib/make/force-rebuild if [ -r $@ ] ; then echo Reconfiguring thorns ; rm $@ ;\ else echo Processing CCL files ; fi +$(PERL) -s $(CST) -config_dir=$(CONFIG) -cctk_home=$(CCTK_HOME) -top=$(TOP) $< # Rule to build ThornList $(TOP)/ThornList: @echo Creating compiled ThornList containing all thorns in the arrangements directory $(PERL) -s $(BUILD_ACTIVETHORNS) $(CCTK_HOME)/arrangements > $@ if test "x$(PROMPT)" = "xyes" ; then \ 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 ; \ $(NOTIFY_DIVIDER) ; \ cat $@ ; \ $(NOTIFY_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; \ fi $(NOTIFY_DIVIDER) # Allow each thorn to include some global dependencies ifneq ($(strip $(THORNS)),) -include $(THORNS:%=$(PACKAGE_DIR)/%/src/make.configuration.deps) $(THORNS:%=$(BINDINGS_DIR)/Configuration/Thorns/make.%.deps) endif # Catch the special case of a thorn being removed from the disk entirely. $(foreach lib, $(CCTK_HOME)/src $(THORNS:%=$(PACKAGE_DIR)/%), $(lib)/param.ccl $(lib)/interface.ccl $(lib)/schedule.ccl) $(CCTK_HOME)/src/configuration.ccl $(CONFIG_THORNS:%=$(PACKAGE_DIR)/%/configuration.ccl): @echo "Missing file $@" @echo "Possibly from a thorn deleted from an arrangement" @echo "Deleting make.thornlist" rm $(CONFIG)/make.thornlist @echo "Please try building again" exit 1 # Phony targets. .PHONY:update editthorns clean cleandeps cleanobjs realclean build # This phony target forces an update. update: editthorns: if test ! -r $(TOP)/ThornList ; then \ echo "Creating compiled ThornList containing all thorns in the arrangements directory" \ $(PERL) -s $(BUILD_ACTIVETHORNS) $(CCTK_HOME)/arrangements > $@ ; fi 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 ; \ $(NOTIFY_DIVIDER) ; \ cat $(TOP)/ThornList ; \ $(NOTIFY_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 $(TOP)/ThornList ; fi ; \ done $(NOTIFY_DIVIDER) clean: @echo Deleting all object and dependency files in $(TOP) find $(TOP) \( -name '*.[od]' -o -name '*.a' \) -exec rm {} \; rm -rf $(TOP)/scratch; $(MKDIR) $(MKDIRFLAGS) $(TOP)/scratch cleandeps: @echo Deleting all dependency files in $(TOP) if test -d $(TOP)/build; then \ find $(TOP)/build \( -name '*.[d]' -o -name '*.a' \) -exec rm {} \; ; \ fi cleanobjs: @echo Deleting all object files in $(TOP) find $(TOP) \( -name '*.[o]' -o -name '*.a' \) -exec rm {} \; rm -rf $(TOP)/scratch; $(MKDIR) $(MKDIRFLAGS) $(TOP)/scratch 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; $(MKDIR) $(MKDIRFLAGS) $(TOP)/lib rm -rf $(TOP)/scratch; $(MKDIR) $(MKDIRFLAGS) $(TOP)/scratch rm -f datestamp.o # This target will build only a subset of the thorns for a given configuration. # It also warns about thorns which don't exist. THORN_BUILDLIST = $(filter $(ALLCACTUSLIBS_BASE), $(BUILDLIST)) UNKNOWN_THORNS = $(filter-out $(ALLCACTUSLIBS_BASE), $(BUILDLIST)) build: $(CONFIG)/make.thornlist $(CONFIG)/cctki_version.h $(patsubst %, $(CCTK_LIBDIR)/$(LIBNAME_PREFIX)$(CCTK_LIBNAME_PREFIX)%$(LIBNAME_SUFFIX), $(THORN_BUILDLIST)) if test "x$(UNKNOWN_THORNS)" != "x"; then \ echo "WARNING: Don't know anything about '$(UNKNOWN_THORNS)' !"; \ $(NOTIFY_DIVIDER); \ fi # This target allows thorns to add to $(ALL_UTILS) and then # have them built by a make utils .PHONY: utils utils: $(UTILS:%=$(UTIL_DIR)$(DIRSEP)%)