-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathg4cmp.gmk
94 lines (72 loc) · 2.62 KB
/
g4cmp.gmk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# G4CMP/g4cmp.gmk -- GNUmakefile fragment for building app directories
# $Id: a82ab26afcc85bee91813a3bb17ef3c9e291eedf $
#
# 20140326 Add support for "G4CMP_DEBUG" compile-time symbol
# 20150109 Add G4CMP_SET_ELECTRON_MASS support to build with dynamic mass code
# 20160518 Use G4CMPINSTALL instead of ".." to find things
# 20160829 Drop G4CMP_SET_ELECTRON_MASS code blocks; not physical
# 20161007 Handle multiple executable names with common local library
# 20200531 Add support for thread-safety "code sanitizer" flags
# Default targets
.PHONY: all lib bin $(G4CMP_NAME)
bin : $(G4CMP_NAME)
# Ensure that all required variables are properly defined
ifndef G4CMP_NAME
$(error Please set G4CMP_NAME in directory-level GNUmakefile)
endif
ifndef G4INSTALL
$(error Please configure your GEANT4 environment before building G4CMP)
endif
# For multiple executables, provide targets and ensure all are cleaned up
ifndef G4TARGET
ifneq (1,$(words $(G4CMP_NAME))) # This will name the executable
$(G4CMP_NAME) :
@$(MAKE) G4TARGET=$@
clean ::
@rm -rf $(foreach t,$(G4CMP_NAME),$(G4WORKDIR)/tmp/$(G4SYSTEM)/$t)
@rm -f $(foreach t,$(G4CMP_NAME),$(G4BINDIR)/$t)
clean_bin ::
@rm -f $(foreach t,$(G4CMP_NAME),$(G4BINDIR)/$t)
endif
G4TARGET := $(word 1,$(G4CMP_NAME))
endif
# Build library in user's common area instead of using "G4EXLIB"
ifneq (,$(wildcard include)$(wildcard src))
name := $(word 1,$(G4CMP_NAME))
G4LIBDIR := $(G4WORKDIR)/lib/$(G4SYSTEM)
$(shell mkdir -p $(G4WORKDIR)/tmp/$(G4SYSTEM)/$(name))
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/common.gmk
EXTRALIBS := -l$(name)
$(G4TARGET) : lib
clean ::
@rm -rf $(G4WORKDIR)/lib/$(G4SYSTEM)/lib$(name).*
endif
# Configure compiling and linking flags before binmake.gmk
ifndef G4CMPLIB
G4CMPLIB := $(G4WORKDIR)/lib/$(G4SYSTEM)
endif
LDFLAGS := -L$(G4CMPLIB)
ifdef G4RUNPATHOPTION
LDFLAGS += $(strip $(G4RUNPATHOPTION)),$(G4CMPLIB)
LDFLAGS += $(strip $(G4RUNPATHOPTION)),$(G4LIB)/$(G4SYSTEM)
endif
EXTRALIBS += -lG4cmp -lqhullcpp -lqhullstatic_p
ifndef G4CMPINCLUDE
G4CMPINCLUDE := $(G4CMPINSTALL)/library/include
endif
G4CMP_FLAGS := -I$(G4CMPINCLUDE) \
-I$(G4CMPINSTALL)/library/qhull-2012.1/src -Dqh_QHpointer
ifdef G4CMP_DEBUG
G4CMP_FLAGS += -DG4CMP_DEBUG
endif
ifdef G4CMP_USE_SANITIZER
G4CMP_SANITIZER_TYPE := thread # User can override w/envvar
G4CMP_FLAGS += -fno-omit-frame-pointer -fsanitize=$(G4CMP_SANITIZER_TYPE)
endif
include $(G4INSTALL)/config/binmake.gmk
# Prepend custom flags to ensure proper order of include search
CPPFLAGS := $(G4CMP_FLAGS) $(CPPFLAGS)
visclean:
rm -f g4*.prim g4*.eps g4*.wrl
rm -f .DAWN_*