Makefile.in
# This Makefile uses the GNU make convention that CAPITAL_NAMES are reserved
# for variables that are either derived from the environment or are explicitly
# set by the user during invocation.
.DEFAULT_GOAL := all
# ChaNGa source directory
source_dir := @srcdir@
# Directory from which `configure` was called.
build_dir := @builddir@
# These canned recipes allow for building different variations of source
# and destination file mappings. They can also be used by subprojects.
define compile-cxx =
@ echo Compiling $*.cpp...
$(quiet) $(charmc) $(cxx_flags) $(depend_flags) $(depend_dir)/$*$(depend_suffix) -c $< -o $@
endef
define compile-c =
@ echo Compiling $*.c...
$(quiet) $(charmc) $(c_flags) $(depend_flags) $(depend_dir)/$*$(depend_suffix) -c $< -o $@
endef
define link-charmc =
@ echo Building $@...
$(quiet) $(charmc) -o $@ $^ $(ld_flags) $(ld_libs)
endef
# ------- Basic commands ------------------------------------------------------
AR := @AR@
RM := rm -f
RMR := $(RM) -r
# ------- Verbosity -----------------------------------------------------------
charm_quiet := $(if $(filter $(CHARM_VERBOSE),1),-verbose,)
quiet := $(if $(filter $(VERBOSE),1),,@)
# ------- Compiler setup ------------------------------------------------------
charmc := @CHARM_PATH@/bin/charmc $(charm_quiet)
target := $(build_dir)/ChaNGa
charmrun := charmrun
cxx_std := c++11
c_std := c99
opt_flag := -O3
target_arch := -m64
threads := -lpthread
# ------- Debugging -----------------------------------------------------------
# -DPRINT_MERGED_TREE
# -DCOSMO_PRINT=1 # enable really verbose prints
# -DCOSMO_PRINT_BK=2 # enable verbose book-keeping prints
# -DCOSMO_DEBUG=2 # enable debugging information
# -DMCLBMSV # Multistepping LB verbosity
# -DCOSMO_STATS=1 # enable statistics collection
# -DCHANGA_REFACTOR_WALKCHECK
# -DCHANGA_REFACTOR_WALKCHECK_INTERLIST
# -DCHANGA_REFACTOR_MEMCHECK
# -DCHANGA_REFACTOR_INTERLIST_PRINT_LIST_STATE
# -DCHANGA_REFACTOR_PRINT_INTERACTIONS
#
# Check walk correctness and trace walk for TEST_BUCKET on TEST_TP:
# -DCHANGA_REFACTOR_WALKCHECK_INTERLIST
# -DCHANGA_REFACTOR_INTERLIST_PRINT_LIST_STATE
# -DCHECK_WALK_COMPLETIONS
debug_defines =
ifeq (1,$(DEBUG))
debug_defines += -DCOSMO_DEBUG=2
opt_flag := @OPT_DEBUG@
target := $(target).dbg
charmrun := $(charmrun).dbg
endif
# Always emit debug symbols in case of core dumps
opt_flag += -g
# ------- Projections ---------------------------------------------------------
ifeq (yes,@PROJECTIONS@)
target := $(target).prj
charmrun := $(charmrun).prj
debug_ldflags += -tracemode projections
endif
# ------- Sanitizers ----------------------------------------------------------
ifneq (no,@FLAG_SANITIZER@)
target := $(target).san
charmrun := $(charmrun).san
debug_flags += -fno-omit-frame-pointer -fsanitize=@FLAG_SANITIZER@
debug_ldflags += -fsanitize=@FLAG_SANITIZER@
endif
# ------- CUDA ----------------------------------------------------------------
ifeq (yes,@ENABLE_CUDA@)
# Use a conditional include so seqential cleans work
-include $(build_dir)/cuda.mk
endif
# ------- Include paths -------------------------------------------------------
structures_path := @STRUCT_DIR@
charm_util_path := @CHARM_PATH@/tmp
cache_lib_path := @CHARM_PATH@/tmp/libs/ck-libs/cache
threadsafe_ht_path := $(cache_lib_path)/threadsafe_hashtable
# ------- Modules to build ----------------------------------------------------
changa_modules := $(strip MultistepLB MultistepOrbLB MultistepLB_notopo \
MultistepNodeLB_notopo Orb3dLB Orb3dLB_notopo HierarchOrbLB)
charm_modules := $(strip CkCache CkIO CkMulticast RefineLB RefineCommLB \
GreedyLB GreedyCommLB OrbLB RotateLB liveViz CkLoop)
# ------- Helper Variables ----------------------------------------------------
defines := $(strip @HEXADECAPOLE@ @FLAG_RTFORCE@ @FLAG_ARCH@ \
@FLAG_CHANGESOFT@ @FLAG_BIGKEYS@ @FLAG_DTADJUST@ \
@FLAG_SPH_KERNEL@ @FLAG_COOLING@ @FLAG_DIFFUSION@ \
@FLAG_FEEDBACKDIFFLIMIT@ @FLAG_CULLENALPHA@ \
@FLAG_VSIGVISC@ @FLAG_DAMPING@ @FLAG_DIFFHARMONIC@ \
@FLAG_TREE_BUILD@ $(debug_defines) @FLAG_INTERLIST@ \
$(cuda_defines) -DREDUCTION_HELPER)
modules := $(strip -language charm++ -balancer @DEFAULT_LB@ \
$(foreach m,$(charm_modules),-module $(m)) \
$(foreach m,$(changa_modules),-module $(m)))
includes := $(strip -I$(structures_path) -I$(cache_lib_path) \
-I$(source_dir) -I$(threadsafe_ht_path) -I$(build_dir) \
-I$(charm_util_path) -I@CHARM_PATH@/include)
basic_flags := $(opt_flag) $(threads) $(target_arch) $(debug_flags)
basic_ldlibs := $(cuda_libs) $(modules) $(structures_path)/libTipsy.a $(threads)
basic_ldflags := $(debug_ldflags) $(cuda_ldflags) -L. -L@CHARM_PATH@/lib
# ------- Standard Variables --------------------------------------------------
# The global version of each flag must be at the end so that the user
# can override our defaults here from the command line
cpp_flags := $(includes) $(defines) $(CPPFLAGS)
c_flags := $(basic_flags) -std=$(c_std) $(cpp_flags) $(CFLAGS)
cxx_flags := $(basic_flags) -std=$(cxx_std) $(cpp_flags) $(CXXFLAGS)
ld_libs := $(basic_ldlibs) $(LDLIBS)
ld_flags := $(basic_ldflags) $(LDFLAGS)
# ------- Sources -------------------------------------------------------------
# Capture all sources except the ones for cooling
c_srcs := $(filter-out $(source_dir)/cooling%,$(wildcard $(source_dir)/*.c))
cxx_srcs := $(filter-out $(source_dir)/cooling%,$(wildcard $(source_dir)/*.cpp))
# If cha_commitid.c wasn't picked up in the source directory,
# then we are doing an out-of-source build, so add it here.
ifneq ($(source_dir),$(build_dir))
c_srcs += $(build_dir)/cha_commitid.c
endif
# Add the cooling sources (if any)
ifeq (-DCOOLING_PLANET,@FLAG_COOLING@)
c_srcs += $(source_dir)/cooling_planet.c $(source_dir)/stiff.c
endif
ifeq (-DCOOLING_COSMO,@FLAG_COOLING@)
c_srcs += $(source_dir)/cooling_cosmo.c $(source_dir)/stiff.c
endif
ifeq (-DCOOLING_GRACKLE,@FLAG_COOLING@)
c_srcs += $(source_dir)/cooling_grackle.c
endif
sources := $(c_srcs) $(cxx_srcs)
ci_files := $(wildcard $(source_dir)/*.ci)
ci_headers := $(patsubst %.ci,%.decl.h,$(subst $(source_dir),$(build_dir),$(ci_files)))
c_objs := $(patsubst %.c,%.o,$(subst $(source_dir),$(build_dir),$(c_srcs)))
cxx_objs := $(patsubst %.cpp,%.o,$(subst $(source_dir),$(build_dir),$(cxx_srcs)))
objects := $(strip $(cxx_objs) $(c_objs) $(cuda_objs))
# ------- Dependencies --------------------------------------------------------
depend_flags := -MMD -MP -MF
depend_dir := $(build_dir)/.
depend_suffix := .d
depend_files := $(wildcard $(depend_dir)/*$(depend_suffix))
# ------- Build targets -------------------------------------------------------
all: $(target)
.PHONY: show-config
show-config:
@ echo TARGET = $(target)"\n"
@ echo DEFAULT_LB = @DEFAULT_LB@"\n"
@ echo TARGET_ARCH = $(target_arch)"\n"
@ echo CPPFLAGS = $(cpp_flags)"\n"
@ echo CFLAGS = $(filter-out $(cpp_flags),$(c_flags))"\n"
@ echo CXXFLAGS = $(filter-out $(cpp_flags),$(cxx_flags))"\n"
@ echo LDFLAGS = $(ld_flags)"\n"
@ echo LDLIBS = $(ld_libs)"\n"
$(build_dir)/%.decl.h: $(source_dir)/%.ci
@ echo Compiling $<...
$(quiet) $(charmc) -E $(cpp_flags) $<
$(build_dir)/%.o: $(build_dir)/Makefile
$(cxx_srcs): $(ci_headers)
%.o: %.cpp
$(compile-cxx)
%.o: %.c
$(compile-c)
$(build_dir)/%.o: $(source_dir)/%.cpp
$(compile-cxx)
$(build_dir)/%.o: $(source_dir)/%.c
$(compile-c)
# Use a conditional include so consecutive cleans work
-include $(depend_files)
# Force a rebuild if the compiler flags have changed
.PHONY: force
$(build_dir)/settings: force
$(quiet) flags="$(cxx_flags) $(c_flags) $(ld_libs) $(ld_flags)" && \
echo "$$flags" | cmp -s - $@ || echo "$$flags" > $@
$(ci_files): $(build_dir)/settings
$(objects): $(build_dir)/settings
$(build_dir)/$(target): $(foreach m,$(changa_modules),libmodule$(m).a)
$(build_dir)/$(target): $(objects) $(structures_path)/libTipsy.a
$(link-charmc)
ifneq (charmrun,$(charmrun))
$(quiet) mv $(build_dir)/charmrun $(build_dir)/$(charmrun)
endif
$(structures_path)/libTipsy.a:
$(quiet) cd $(structures_path); $(MAKE) libTipsy.a
$(build_dir)/libmodule%.a: $(build_dir)/%.o
@ echo Creating library $@...
$(quiet) $(AR) $@ $^
.PHONY: docs
docs:
@ Building docs...
$(quiet) doxygen $(source_dir)/Doxyfile
.PHONY: clean
clean:
@ echo Cleaning...
$(quiet) $(RM) $(objects) *~ *.decl.h *.def.h $(depend_files) settings
$(quiet) $(RM) $(foreach m,$(changa_modules),libmodule$(m).a)
$(quiet) cd $(structures_path); $(MAKE) clean
.PHONY: dist-clean
dist-clean: clean
$(quiet) $(RM) $(target) $(charmrun) ChaNGa.* charmrun.* config.status
$(quiet) $(RM) config.log config.h Makefile $(build_dir)/cha_commitid.c
.PHONY: full-clean
full-clean: dist-clean
$(quiet) $(RMR) $(source_dir)/autom4te.cache $(source_dir)/configure
# for backwards compatibility
.PHONY: ref-clean
ref-clean:
.PHONY: depends
depends:
.PHONY: test
test: