| [886] | 1 | # $Id: binmake.gmk,v 1.138 2008/11/14 19:58:19 gcosmo Exp $
|
|---|
| [472] | 2 | # ----------------------------------------------------------
|
|---|
| 3 | # Script defining rules and paths for making binaries.
|
|---|
| 4 | # First implementation: Gabriele Cosmo, 25/06/1998.
|
|---|
| 5 | # ----------------------------------------------------------
|
|---|
| 6 |
|
|---|
| 7 | ifndef LDFLAGS
|
|---|
| 8 | include $(G4INSTALL)/config/architecture.gmk
|
|---|
| 9 | endif
|
|---|
| 10 |
|
|---|
| 11 | G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
|
|---|
| 12 |
|
|---|
| 13 | # Define variable checking for existence of centrally installed headers.
|
|---|
| 14 | # If check will be true, avoid explicit definition of paths to INCFLAGS.
|
|---|
| 15 | #
|
|---|
| 16 | G4INCLUDE_EXEC := $(shell [ -r $(G4INCLUDE)/globals.hh ] && echo 1)
|
|---|
| 17 |
|
|---|
| 18 | include $(G4INSTALL)/config/G4UI_USE.gmk
|
|---|
| 19 | include $(G4INSTALL)/config/G4VIS_USE.gmk
|
|---|
| 20 | include $(G4INSTALL)/config/interactivity.gmk
|
|---|
| 21 | include $(G4INSTALL)/config/analysis.gmk
|
|---|
| 22 |
|
|---|
| 23 | # Verify the existance of the global static libraries first.
|
|---|
| 24 | # if not verify the existance of global shared libraries (Unix only).
|
|---|
| 25 | #
|
|---|
| 26 | ifndef G4LIB_USE_GRANULAR
|
|---|
| 27 | GLOBALLIBS := $(shell test -f $(G4LIB)/$(G4SYSTEM)/libG4global.a && echo yes)
|
|---|
| 28 | ifndef GLOBALLIBS
|
|---|
| 29 | GLOBALLIBS := $(shell test -f $(G4LIB)/$(G4SYSTEM)/libG4global.$(SHEXT) && echo yes)
|
|---|
| 30 | SHAREDLIBS := $(shell test -f $(G4LIB)/$(G4SYSTEM)/libG4global.$(SHEXT) && echo yes)
|
|---|
| 31 | endif
|
|---|
| 32 | endif
|
|---|
| 33 |
|
|---|
| 34 | # Verify the existance of granular shared libraries (Unix) or global DLLs (Windows)
|
|---|
| 35 | #
|
|---|
| 36 | ifneq (,$(findstring WIN32-VC,$(G4SYSTEM)))
|
|---|
| 37 | SHAREDLIBS := $(shell test -f $(G4LIB)/$(G4SYSTEM)/G4global.$(SHEXT) && echo yes)
|
|---|
| 38 | endif
|
|---|
| 39 |
|
|---|
| 40 | ifndef INCFLAGS
|
|---|
| 41 | ifeq ($(G4INCLUDE_EXEC),1)
|
|---|
| 42 | INCFLAGS := -I$(G4INCLUDE)
|
|---|
| 43 | else
|
|---|
| 44 | INCFLAGS := \
|
|---|
| 45 | -I$(G4BASE)/global/management/include \
|
|---|
| 46 | -I$(G4BASE)/global/HEPRandom/include \
|
|---|
| 47 | -I$(G4BASE)/global/HEPGeometry/include \
|
|---|
| 48 | -I$(G4BASE)/global/HEPNumerics/include \
|
|---|
| 49 | -I$(G4BASE)/run/include \
|
|---|
| 50 | -I$(G4BASE)/materials/include \
|
|---|
| 51 | -I$(G4BASE)/parameterisations/gflash/include \
|
|---|
| 52 | -I$(G4BASE)/particles/management/include \
|
|---|
| [886] | 53 | -I$(G4BASE)/particles/adjoint/include \
|
|---|
| [472] | 54 | -I$(G4BASE)/particles/bosons/include \
|
|---|
| 55 | -I$(G4BASE)/particles/leptons/include \
|
|---|
| 56 | -I$(G4BASE)/particles/hadrons/barions/include \
|
|---|
| 57 | -I$(G4BASE)/particles/hadrons/ions/include \
|
|---|
| 58 | -I$(G4BASE)/particles/hadrons/mesons/include \
|
|---|
| 59 | -I$(G4BASE)/particles/shortlived/include \
|
|---|
| [593] | 60 | -I$(G4BASE)/physics_lists/lists/include \
|
|---|
| 61 | -I$(G4BASE)/physics_lists/builders/include \
|
|---|
| [472] | 62 | -I$(G4BASE)/processes/management/include \
|
|---|
| 63 | -I$(G4BASE)/processes/cuts/include \
|
|---|
| [593] | 64 | -I$(G4BASE)/processes/biasing/include \
|
|---|
| [483] | 65 | -I$(G4BASE)/processes/scoring/include \
|
|---|
| [472] | 66 | -I$(G4BASE)/processes/decay/include \
|
|---|
| 67 | -I$(G4BASE)/processes/optical/include \
|
|---|
| 68 | -I$(G4BASE)/processes/transportation/include \
|
|---|
| 69 | -I$(G4BASE)/processes/parameterisation/include \
|
|---|
| [886] | 70 | -I$(G4BASE)/processes/electromagnetic/adjoint/include \
|
|---|
| [472] | 71 | -I$(G4BASE)/processes/electromagnetic/standard/include \
|
|---|
| 72 | -I$(G4BASE)/processes/electromagnetic/muons/include \
|
|---|
| 73 | -I$(G4BASE)/processes/electromagnetic/utils/include \
|
|---|
| 74 | -I$(G4BASE)/processes/electromagnetic/xrays/include \
|
|---|
| 75 | -I$(G4BASE)/processes/electromagnetic/lowenergy/include \
|
|---|
| 76 | -I$(G4BASE)/processes/electromagnetic/highenergy/include \
|
|---|
| [483] | 77 | -I$(G4BASE)/processes/electromagnetic/polarisation/include \
|
|---|
| [472] | 78 | -I$(G4BASE)/processes/hadronic/cross_sections/include \
|
|---|
| [593] | 79 | -I$(G4BASE)/processes/hadronic/management/include \
|
|---|
| 80 | -I$(G4BASE)/processes/hadronic/models/abrasion/include \
|
|---|
| [472] | 81 | -I$(G4BASE)/processes/hadronic/models/binary_cascade/include \
|
|---|
| [593] | 82 | -I$(G4BASE)/processes/hadronic/models/cascade/cascade/include \
|
|---|
| 83 | -I$(G4BASE)/processes/hadronic/models/cascade/evaporation/include \
|
|---|
| 84 | -I$(G4BASE)/processes/hadronic/models/cascade/utils/include \
|
|---|
| [472] | 85 | -I$(G4BASE)/processes/hadronic/models/chiral_inv_phase_space/body/include \
|
|---|
| 86 | -I$(G4BASE)/processes/hadronic/models/chiral_inv_phase_space/interface/include \
|
|---|
| 87 | -I$(G4BASE)/processes/hadronic/models/coherent_elastic/include \
|
|---|
| [593] | 88 | -I$(G4BASE)/processes/hadronic/models/de_excitation/ablation/include \
|
|---|
| [472] | 89 | -I$(G4BASE)/processes/hadronic/models/de_excitation/evaporation/include \
|
|---|
| 90 | -I$(G4BASE)/processes/hadronic/models/de_excitation/fermi_breakup/include \
|
|---|
| [593] | 91 | -I$(G4BASE)/processes/hadronic/models/de_excitation/fission/include \
|
|---|
| [472] | 92 | -I$(G4BASE)/processes/hadronic/models/de_excitation/gem_evaporation/include \
|
|---|
| 93 | -I$(G4BASE)/processes/hadronic/models/de_excitation/handler/include \
|
|---|
| 94 | -I$(G4BASE)/processes/hadronic/models/de_excitation/management/include \
|
|---|
| 95 | -I$(G4BASE)/processes/hadronic/models/de_excitation/multifragmentation/include \
|
|---|
| 96 | -I$(G4BASE)/processes/hadronic/models/de_excitation/photon_evaporation/include \
|
|---|
| 97 | -I$(G4BASE)/processes/hadronic/models/de_excitation/util/include \
|
|---|
| 98 | -I$(G4BASE)/processes/hadronic/models/em_dissociation/include \
|
|---|
| 99 | -I$(G4BASE)/processes/hadronic/models/general_finalstate/include \
|
|---|
| 100 | -I$(G4BASE)/processes/hadronic/models/high_energy/include \
|
|---|
| 101 | -I$(G4BASE)/processes/hadronic/models/im_r_matrix/include \
|
|---|
| [606] | 102 | -I$(G4BASE)/processes/hadronic/models/incl/include \
|
|---|
| [472] | 103 | -I$(G4BASE)/processes/hadronic/models/inucl/include \
|
|---|
| 104 | -I$(G4BASE)/processes/hadronic/models/isotope_production/include \
|
|---|
| 105 | -I$(G4BASE)/processes/hadronic/models/leading_particle/include \
|
|---|
| [593] | 106 | -I$(G4BASE)/processes/hadronic/models/lll_fission/include \
|
|---|
| [472] | 107 | -I$(G4BASE)/processes/hadronic/models/low_energy/include \
|
|---|
| 108 | -I$(G4BASE)/processes/hadronic/models/management/include \
|
|---|
| 109 | -I$(G4BASE)/processes/hadronic/models/neutron_hp/include \
|
|---|
| 110 | -I$(G4BASE)/processes/hadronic/models/parton_string/diffraction/include \
|
|---|
| 111 | -I$(G4BASE)/processes/hadronic/models/parton_string/hadronization/include \
|
|---|
| 112 | -I$(G4BASE)/processes/hadronic/models/parton_string/management/include \
|
|---|
| 113 | -I$(G4BASE)/processes/hadronic/models/parton_string/qgsm/include \
|
|---|
| 114 | -I$(G4BASE)/processes/hadronic/models/photolepton_hadron/muon_nuclear/include \
|
|---|
| 115 | -I$(G4BASE)/processes/hadronic/models/pre_equilibrium/exciton_model/include \
|
|---|
| [689] | 116 | -I$(G4BASE)/processes/hadronic/models/qmd/include \
|
|---|
| [472] | 117 | -I$(G4BASE)/processes/hadronic/models/quark_molecular_dynamics/body/include \
|
|---|
| 118 | -I$(G4BASE)/processes/hadronic/models/quark_molecular_dynamics/util/include \
|
|---|
| 119 | -I$(G4BASE)/processes/hadronic/models/radioactive_decay/include \
|
|---|
| 120 | -I$(G4BASE)/processes/hadronic/models/relativistic_qmd/include \
|
|---|
| 121 | -I$(G4BASE)/processes/hadronic/models/relativistic_qmd/uplusplus/include \
|
|---|
| [593] | 122 | -I$(G4BASE)/processes/hadronic/models/rpg/include \
|
|---|
| [472] | 123 | -I$(G4BASE)/processes/hadronic/models/theo_high_energy/include \
|
|---|
| 124 | -I$(G4BASE)/processes/hadronic/models/util/include \
|
|---|
| 125 | -I$(G4BASE)/processes/hadronic/processes/include \
|
|---|
| 126 | -I$(G4BASE)/processes/hadronic/stopping/include \
|
|---|
| 127 | -I$(G4BASE)/processes/hadronic/util/include \
|
|---|
| 128 | -I$(G4BASE)/geometry/management/include \
|
|---|
| 129 | -I$(G4BASE)/geometry/solids/CSG/include \
|
|---|
| 130 | -I$(G4BASE)/geometry/solids/specific/include \
|
|---|
| 131 | -I$(G4BASE)/geometry/solids/BREPS/include \
|
|---|
| 132 | -I$(G4BASE)/geometry/solids/Boolean/include \
|
|---|
| 133 | -I$(G4BASE)/geometry/divisions/include \
|
|---|
| 134 | -I$(G4BASE)/geometry/volumes/include \
|
|---|
| 135 | -I$(G4BASE)/geometry/navigation/include \
|
|---|
| 136 | -I$(G4BASE)/geometry/magneticfield/include \
|
|---|
| 137 | -I$(G4BASE)/geometry/biasing/include \
|
|---|
| 138 | -I$(G4BASE)/track/include \
|
|---|
| 139 | -I$(G4BASE)/tracking/include \
|
|---|
| 140 | -I$(G4BASE)/digits_hits/detector/include \
|
|---|
| 141 | -I$(G4BASE)/digits_hits/hits/include \
|
|---|
| 142 | -I$(G4BASE)/digits_hits/digits/include \
|
|---|
| [593] | 143 | -I$(G4BASE)/digits_hits/scorer/include \
|
|---|
| [472] | 144 | -I$(G4BASE)/digits_hits/utils/include \
|
|---|
| [886] | 145 | -I$(G4BASE)/persistency/ascii/include \
|
|---|
| [606] | 146 | -I$(G4BASE)/persistency/gdml/include \
|
|---|
| 147 | -I$(G4BASE)/persistency/mctruth/include \
|
|---|
| [472] | 148 | -I$(G4BASE)/readout/include \
|
|---|
| 149 | -I$(G4BASE)/event/include \
|
|---|
| [593] | 150 | -I$(G4BASE)/error_propagation/include \
|
|---|
| [472] | 151 | -I$(G4BASE)/graphics_reps/include \
|
|---|
| 152 | -I$(G4BASE)/intercoms/include
|
|---|
| 153 | ifdef G4LIB_USE_G3TOG4
|
|---|
| 154 | INCFLAGS += -I$(G4BASE)/g3tog4/include
|
|---|
| 155 | endif
|
|---|
| 156 | endif
|
|---|
| 157 | endif
|
|---|
| 158 |
|
|---|
| 159 | CPPFLAGS += $(INCFLAGS)
|
|---|
| 160 | LDFLAGS += -L$(G4LIBDIR)
|
|---|
| 161 |
|
|---|
| 162 | G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(G4TARGET)
|
|---|
| 163 | G4BINDIR := $(G4BIN)/$(G4SYSTEM)
|
|---|
| 164 |
|
|---|
| 165 | ifdef G4EXLIB
|
|---|
| 166 | G4LIBDIR := $(G4TMPDIR)
|
|---|
| 167 | LDFLAGS += -L$(G4LIBDIR)
|
|---|
| 168 | ifdef SHAREDLIBS
|
|---|
| 169 | ifdef G4RUNPATHOPTION
|
|---|
| 170 | # For the example dependent directory, keep the
|
|---|
| 171 | # path to the shared lib in the executable.
|
|---|
| 172 | LDFLAGS += $(G4RUNPATHOPTION)$(G4LIBDIR)
|
|---|
| 173 | endif
|
|---|
| 174 | endif
|
|---|
| 175 | include $(G4INSTALL)/config/common.gmk
|
|---|
| 176 | endif
|
|---|
| 177 |
|
|---|
| 178 | ifdef LDLIBS
|
|---|
| 179 | USER_DEFINED_LDLIBS := 1
|
|---|
| 180 | endif
|
|---|
| 181 |
|
|---|
| 182 | # Because of the script for granular libraries which replaces part of LDLIBS
|
|---|
| 183 | # and because of the way user defined LDLIBS was augmented historically I
|
|---|
| 184 | # have split LDLIBS into 4 parts...
|
|---|
| 185 | #
|
|---|
| 186 | ifndef USER_DEFINED_LDLIBS
|
|---|
| 187 |
|
|---|
| 188 | # TARGETLIB is the library generated for the final user application;
|
|---|
| 189 | # TARGOBJEXT defines the target object extension
|
|---|
| 190 | #
|
|---|
| 191 | ifdef G4EXLIB
|
|---|
| 192 | ifeq (,$(findstring WIN32-VC,$(G4SYSTEM)))
|
|---|
| 193 | # Unix
|
|---|
| 194 | TARGETLIB := -l$(G4TARGET)
|
|---|
| 195 | TARGOBJEXT := o
|
|---|
| 196 | else
|
|---|
| 197 | # Windows
|
|---|
| 198 | TARGETLIB := lib$(G4TARGET).a
|
|---|
| 199 | TARGOBJEXT := OBJ
|
|---|
| 200 | endif
|
|---|
| 201 | endif
|
|---|
| 202 |
|
|---|
| 203 | # LDLIBS1 contains the very high level libraries...
|
|---|
| 204 | #
|
|---|
| 205 | LDLIBS1 := $(EXTRALIBS)
|
|---|
| 206 |
|
|---|
| 207 | # VISLIBS (and UILIBS?) is handled by the granular library script...
|
|---|
| 208 | #
|
|---|
| 209 | ifdef GLOBALLIBS
|
|---|
| 210 | LDLIBS2 := $(VISLIBS) -lG4interfaces -lG4persistency
|
|---|
| 211 |
|
|---|
| 212 | ifdef G4LIB_USE_G3TOG4
|
|---|
| 213 | LDLIBS2 += -lG3toG4
|
|---|
| 214 | endif
|
|---|
| 215 |
|
|---|
| [593] | 216 | LDLIBS2 += -lG4error_propagation \
|
|---|
| 217 | -lG4readout \
|
|---|
| 218 | -lG4physicslists \
|
|---|
| 219 | -lG4run \
|
|---|
| [472] | 220 | -lG4event \
|
|---|
| 221 | -lG4tracking \
|
|---|
| [593] | 222 | -lG4parmodels \
|
|---|
| [472] | 223 | -lG4processes \
|
|---|
| 224 | -lG4digits_hits \
|
|---|
| 225 | -lG4track \
|
|---|
| 226 | -lG4particles \
|
|---|
| 227 | -lG4geometry \
|
|---|
| 228 | -lG4materials \
|
|---|
| 229 | -lG4graphics_reps \
|
|---|
| 230 | -lG4intercoms \
|
|---|
| 231 | -lG4global
|
|---|
| 232 | else
|
|---|
| 233 | # The next lines specifically should read LDLIBS2 = , not LDLIBS2 :=, so
|
|---|
| 234 | # that it is not expanded until the directory G4TMPDIR is created.
|
|---|
| 235 | ifeq ($(G4INCLUDE_EXEC),1)
|
|---|
| 236 | LDLIBS2 = $(shell \
|
|---|
| 237 | G4TMP=$(G4TMP); export G4TMP; \
|
|---|
| [593] | 238 | if [ \( -f $(G4LIB)/$(G4SYSTEM)/liblist \
|
|---|
| 239 | -a -f $(G4LIB)/$(G4SYSTEM)/libname.map \) ]; then \
|
|---|
| 240 | $(G4LIB)/$(G4SYSTEM)/liblist \
|
|---|
| 241 | -m $(G4LIB)/$(G4SYSTEM) \
|
|---|
| 242 | < $(G4LIB)/$(G4SYSTEM)/libname.map; fi)
|
|---|
| [472] | 243 | else
|
|---|
| [787] | 244 | LDLIBS2 = $(shell \
|
|---|
| [472] | 245 | G4TMP=$(G4TMP); export G4TMP; \
|
|---|
| [593] | 246 | if [ \( -f $(G4LIB)/$(G4SYSTEM)/liblist \
|
|---|
| 247 | -a -f $(G4LIB)/$(G4SYSTEM)/libname.map \) ]; then \
|
|---|
| 248 | $(G4LIB)/$(G4SYSTEM)/liblist \
|
|---|
| 249 | -d $(G4TMPDIR) \
|
|---|
| 250 | < $(G4LIB)/$(G4SYSTEM)/libname.map; fi)
|
|---|
| [472] | 251 | # Warning: do not add to LDLIBS2 with += because this causes it to be
|
|---|
| 252 | # expanded too soon. Hence extra libraries must have a different name...
|
|---|
| 253 | # Extra libraries to resolve remaining circular dependencies...
|
|---|
| 254 | # LDLIBS2EXTRA =
|
|---|
| 255 | endif
|
|---|
| 256 | endif
|
|---|
| 257 |
|
|---|
| [689] | 258 | ifdef G4LIB_USE_ZLIB
|
|---|
| [472] | 259 | LDLIBS2 += -lG4zlib
|
|---|
| 260 | endif
|
|---|
| 261 |
|
|---|
| 262 | # LDLIBS3 contains the first set of low level libraries...
|
|---|
| 263 | #
|
|---|
| [689] | 264 | ifdef G4LIB_USE_GDML
|
|---|
| [606] | 265 | LDLIBS3 += $(GDMLLIBS)
|
|---|
| 266 | endif
|
|---|
| [472] | 267 | LDLIBS3 += $(INTYLIBS)
|
|---|
| 268 | LDLIBS3 += $(ANALYSISLIBS)
|
|---|
| 269 |
|
|---|
| 270 | endif # ifndef USER_DEFINED_LDLIBS
|
|---|
| 271 |
|
|---|
| 272 | # LDLIBS4 contains the next set of low level libraries which historically
|
|---|
| 273 | # (why?) the user is not supposed to be able to define...
|
|---|
| 274 | #
|
|---|
| [921] | 275 | LDLIBS5 += $(LOADLIBS)
|
|---|
| [472] | 276 |
|
|---|
| 277 | # Finally assemble libraries...
|
|---|
| 278 | #
|
|---|
| 279 | ifdef USER_DEFINED_LDLIBS
|
|---|
| 280 | LDLIBS_PREFINAL := $(LDLIBS)
|
|---|
| 281 | LDLIBS_KERNEL := $(LDLIBS)
|
|---|
| 282 | else
|
|---|
| 283 | # Again, do not use := or +=. See note on LDLIBS2 above.
|
|---|
| [921] | 284 | LDLIBS_PREFINAL = $(LDLIBS1) $(LDLIBS2) $(LDLIBS2EXTRA) $(LDLIBS3) $(LDLIBS4)
|
|---|
| [472] | 285 | # Version leaving out EXTRALIBS
|
|---|
| [921] | 286 | LDLIBS_KERNEL = $(LDLIBS2) $(LDLIBS2EXTRA) $(LDLIBS3) $(LDLIBS4)
|
|---|
| [472] | 287 | endif
|
|---|
| [921] | 288 | LDLIBS_PREFINAL += $(LDLIBS5)
|
|---|
| 289 | LDLIBS_KERNEL += $(LDLIBS5)
|
|---|
| [472] | 290 |
|
|---|
| 291 | ifneq (,$(findstring WIN32-VC,$(G4SYSTEM)))
|
|---|
| [593] | 292 | # Windows
|
|---|
| [472] | 293 | WIN32TMP := $(patsubst -L%,$(LIB_PATH)%,$(LDFLAGS))
|
|---|
| 294 | LDFLAGS = $(patsubst /,$(PATH_DEL),$(WIN32TMP))
|
|---|
| 295 | WIN32TMP2 := $(patsubst -L%,$(LIB_PATH)%,$(LDLIBS_PREFINAL))
|
|---|
| 296 | WIN32TMP3 := $(patsubst -L%,$(LIB_PATH)%,$(LDLIBS1))
|
|---|
| 297 | WIN32TMP4 := $(patsubst -L%,$(LIB_PATH)%,$(LDLIBS_KERNEL))
|
|---|
| 298 | ifdef SHAREDLIBS
|
|---|
| 299 | ifdef G4LIB_USE_DLL
|
|---|
| 300 | LDLIBS = $(TARGETLIB) $(patsubst -l%,lib%.a,$(WIN32TMP3)) $(patsubst -l%,lib%.lib,$(WIN32TMP4))
|
|---|
| 301 | else
|
|---|
| [593] | 302 | LDLIBS = $(TARGETLIB) $(patsubst -l%,lib%.lib,$(WIN32TMP2))
|
|---|
| [472] | 303 | endif
|
|---|
| 304 | else
|
|---|
| [593] | 305 | LDLIBS = $(TARGETLIB) $(patsubst -l%,lib%.a,$(WIN32TMP2))
|
|---|
| [472] | 306 | endif
|
|---|
| [593] | 307 | OUT := /Fe
|
|---|
| [472] | 308 | else
|
|---|
| [593] | 309 | # Unix
|
|---|
| [787] | 310 | LDLIBS = $(TARGETLIB) $(LDLIBS_PREFINAL)
|
|---|
| [593] | 311 | OUT := -o
|
|---|
| [472] | 312 | endif
|
|---|
| 313 |
|
|---|
| 314 | ifdef transform-RPath
|
|---|
| 315 | # Invoke system specific transformation of
|
|---|
| 316 | include $(G4INSTALL)/config/sys/$(G4SYSTEM)-runpath.gmk
|
|---|
| 317 | endif
|
|---|
| [593] | 318 |
|
|---|
| [472] | 319 | sources := $(wildcard $(G4TARGET).cc)
|
|---|
| 320 | objects := $(patsubst %.cc,$(G4TMPDIR)/exe/%.$(TARGOBJEXT),$(sources))
|
|---|
| 321 | dependencies := $(patsubst %.cc,$(G4TMPDIR)/exe/%.d,$(sources))
|
|---|
| 322 |
|
|---|
| 323 | LINK_DEPENDENCIES := $(G4TMPDIR)/exe/obj.last $(EXTRA_LINK_DEPENDENCIES)
|
|---|
| 324 |
|
|---|
| 325 | .PHONY: bin clean clean_bin debug
|
|---|
| 326 |
|
|---|
| 327 | # Make $(G4TARGET) executable.
|
|---|
| 328 |
|
|---|
| 329 | bin: $(G4BINDIR)/$(G4TARGET)
|
|---|
| 330 |
|
|---|
| 331 | $(G4BINDIR)/$(G4TARGET): $(LINK_DEPENDENCIES)
|
|---|
| 332 | ifndef USER_DEFINED_LDLIBS
|
|---|
| 333 | ifndef GLOBALLIBS
|
|---|
| 334 | @echo "Using granular libraries ..."
|
|---|
| 335 | @if [ ! \( -f $(G4LIB)/$(G4SYSTEM)/liblist \
|
|---|
| 336 | -a -f $(G4LIB)/$(G4SYSTEM)/libname.map \) ]; then \
|
|---|
| 337 | echo "ERROR: No liblist program or library map file."; \
|
|---|
| 338 | echo " These are needed for building with granular"; \
|
|---|
| 339 | echo " libraries."; \
|
|---|
| 340 | echo ' cd $$G4INSTALL/source'; \
|
|---|
| 341 | echo " gmake"; \
|
|---|
| 342 | echo " or if you are sure you have already made all the"; \
|
|---|
| 343 | echo " granular libraries:"; \
|
|---|
| 344 | echo " gmake libmap"; \
|
|---|
| 345 | exit 1; fi
|
|---|
| 346 | else
|
|---|
| 347 | @echo "Using global libraries ..."
|
|---|
| 348 | endif
|
|---|
| 349 | endif
|
|---|
| 350 | @if [ ! -d $(G4BINDIR) ] ; then mkdir $(G4BINDIR) ;fi
|
|---|
| 351 | ifdef CPPVERBOSE
|
|---|
| 352 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) \
|
|---|
| [921] | 353 | $(OUT)$(G4BINDIR)/$(G4TARGET) $(objects) $(LDFLAGS) \
|
|---|
| [472] | 354 | $(LDLIBS)
|
|---|
| 355 | else
|
|---|
| 356 | @echo Linking $(G4TARGET) ...
|
|---|
| 357 | @$(CXX) $(CXXFLAGS) $(CPPFLAGS) \
|
|---|
| [921] | 358 | $(OUT)$(G4BINDIR)/$(G4TARGET) $(objects) $(LDFLAGS)\
|
|---|
| [472] | 359 | $(LDLIBS)
|
|---|
| 360 | @if [ \( -f $(G4BINDIR)/$(G4TARGET) \) ]; then \
|
|---|
| 361 | echo "... Done!"; fi
|
|---|
| 362 | endif
|
|---|
| 363 |
|
|---|
| 364 | # Touch the versioning file
|
|---|
| 365 | ifdef G4EXLIB
|
|---|
| 366 | $(G4TMPDIR)/exe/obj.last: lib $(objects)
|
|---|
| 367 | else
|
|---|
| 368 | $(G4TMPDIR)/exe/obj.last: $(objects)
|
|---|
| 369 | endif
|
|---|
| 370 | @touch $@
|
|---|
| 371 |
|
|---|
| 372 | # Make the $(G4TARGET).$(TARGOBJEXT) file.
|
|---|
| 373 | $(G4TMPDIR)/exe/$(G4TARGET).$(TARGOBJEXT) : $(G4TARGET).cc
|
|---|
| 374 | ifdef CPPVERBOSE
|
|---|
| 375 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(APPFLAGS) \
|
|---|
| 376 | -c $(OUT_OBJ)$(G4TMPDIR)/exe/$(G4TARGET).$(TARGOBJEXT) $(G4TARGET).cc
|
|---|
| 377 | else
|
|---|
| 378 | @echo Compiling $(G4TARGET).cc ...
|
|---|
| 379 | @$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(APPFLAGS) \
|
|---|
| 380 | -c $(OUT_OBJ)$(G4TMPDIR)/exe/$(G4TARGET).$(TARGOBJEXT) $(G4TARGET).cc
|
|---|
| 381 | endif
|
|---|
| 382 |
|
|---|
| 383 | GPPFLAGS := "-M"
|
|---|
| 384 |
|
|---|
| 385 | # Make the $(G4TARGET).d file and include it.
|
|---|
| 386 |
|
|---|
| 387 | # The ideas for this come from the GNU Make Manual, Section 4.12,
|
|---|
| 388 | # Generating Prerequisites Automatically. The g++ compiler has an
|
|---|
| 389 | # option -M or -MM to write to standard output a list of dependencies
|
|---|
| 390 | # based on the #include statements. The "sed" adds the dependency
|
|---|
| 391 | # file itself as a second target. The result is a mini-makefile which
|
|---|
| 392 | # specifies the .o and .d files as targets which depend on all the
|
|---|
| 393 | # files found through the #include statements. This file is then
|
|---|
| 394 | # included, causing GNU Make to honour these dependencies.
|
|---|
| 395 |
|
|---|
| 396 | # The "set -e" causes the shell to exit with an error when the "g++"
|
|---|
| 397 | # fails (otherwise it would only notice the last command in the
|
|---|
| 398 | # pipeline, namely "sed"). GNU Make notices the error and exits
|
|---|
| 399 | # sooner than it otherwise would (still not as soon as I expect,
|
|---|
| 400 | # though!). Even then, an empty file is made, so "[ -s $@ ] || rm -f
|
|---|
| 401 | # $@" removes it ([ -s filename ] gives zero exit code only if file
|
|---|
| 402 | # exists and has a size greater than zero). This avoids making
|
|---|
| 403 | # corrupt .d files which would play havoc with your next build.
|
|---|
| 404 |
|
|---|
| 405 | $(G4TMPDIR)/exe/$(G4TARGET).d: $(G4TARGET).cc
|
|---|
| 406 | @if [ ! -d $(G4TMP)/$(G4SYSTEM) ] ; then mkdir $(G4TMP)/$(G4SYSTEM) ;fi
|
|---|
| 407 | @if [ ! -d $(G4TMPDIR) ] ; then mkdir $(G4TMPDIR) ;fi
|
|---|
| 408 | @if [ ! -d $(G4TMPDIR)/exe ] ; then mkdir $(G4TMPDIR)/exe ;fi
|
|---|
| 409 | @echo Making dependency for file $< ...
|
|---|
| 410 | @set -e;\
|
|---|
| 411 | g++ $(GPPFLAGS) $(CPPFLAGS) -w $< |\
|
|---|
| 412 | sed 's!$(G4TARGET)\.$(TARGOBJEXT)!$(G4TMPDIR)/exe/& $@!' >$@;\
|
|---|
| 413 | [ -s $@ ] || rm -f $@
|
|---|
| 414 | ifneq ($(dependencies),)
|
|---|
| [593] | 415 | ifneq ($(MAKECMDGOALS),clean)
|
|---|
| [472] | 416 | -include $(dependencies)
|
|---|
| 417 | endif
|
|---|
| [593] | 418 | endif
|
|---|
| [472] | 419 |
|
|---|
| 420 | clean::
|
|---|
| 421 | @echo Cleaning up ...
|
|---|
| 422 | @rm -f ./core
|
|---|
| 423 | @rm -rf $(G4TMPDIR)
|
|---|
| 424 | @rm -f $(G4LIBDIR)/lib$(G4TARGET).a
|
|---|
| 425 | @rm -f $(G4BINDIR)/$(G4TARGET)
|
|---|
| 426 | ifdef CFRONT
|
|---|
| 427 | @rm -rf $(G4TREP)/exec
|
|---|
| 428 | endif
|
|---|
| 429 |
|
|---|
| 430 | clean_bin::
|
|---|
| 431 | @echo Removing application $(G4TARGET) ...
|
|---|
| 432 | @rm -f ./core
|
|---|
| 433 | @rm -f $(G4BINDIR)/$(G4TARGET)
|
|---|