Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/config/common.gmk is written in an unsupported language. File is not indexed.

0001 # ----------------------------------------------------------------
0002 # Common part of GNUmakefile for libraries.  John Allison, 5/7/95.
0003 # ----------------------------------------------------------------
0004 # Libraries are created according to G4SYSTEM. G.Cosmo, 11/6/96.
0005 # Introduced G4LIBDIR and G4TMPDIR. G.Cosmo, 23/6/98.
0006 # Introduced Qt moc rule, L.Garnier 15/2/08.
0007 
0008 ifndef G4LIBDIR
0009   G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
0010 endif
0011 G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
0012 
0013 # A module may have specified its sources already, so only
0014 # wildcard if the variable is empty
0015 # (Temporary feature to support toolkit builds until final retirement)
0016 ifeq ($(sources),)
0017   sources      ?= $(wildcard src/*.cc)
0018 endif
0019 dependencies := $(patsubst src/%.cc,$(G4TMPDIR)/%.d,$(sources))
0020 objects      := $(patsubst src/%.cc,$(G4TMPDIR)/%.o,$(sources))
0021 
0022 ifneq ($(G4INTY_BUILD_QT),)
0023  sources      += $(moc_sources)
0024  dependencies += $(moc_dependencies)
0025  objects      += $(moc_objects)
0026 endif
0027 
0028    g4libraries_to_build :=
0029 ifeq ($(G4LIB_NO_SHARED),)
0030 ifneq ($(G4LIB_BUILD_SHARED),)
0031    g4libraries_to_build += $(G4LIBDIR)/lib$(name).$(SHEXT)
0032 endif
0033 endif
0034 ifneq ($(G4LIB_BUILD_STATIC),)
0035    g4libraries_to_build += $(G4LIBDIR)/lib$(name).a
0036 endif
0037 
0038 # GPPFLAGS is defined here to make the .d file(s) and include it(them).
0039 
0040 GPPFLAGS := "-M"
0041 
0042 ###############################################################################
0043 #
0044 # Actual gmake targets.
0045 #
0046 
0047 lib: $(g4libraries_to_build)
0048 
0049 ifeq ($(G4LIB_NO_SHARED),)
0050 ifneq ($(G4LIB_BUILD_SHARED),)
0051 # Make shared library.
0052 $(G4LIBDIR)/lib$(name).$(SHEXT): $(G4TMPDIR)/obj.last
0053         @if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi
0054         @echo Creating shared library $@ ...
0055         @$(RM) $@
0056 #      use architecture specific macro defined in sys/$(G4SYSTEM).gmk
0057         $(build-granular-shared-lib)
0058 endif
0059 endif
0060 
0061 ifneq ($(G4LIB_BUILD_STATIC),)
0062 # Make static (archive) library.
0063 $(G4LIBDIR)/lib$(name).a: $(G4TMPDIR)/obj.last
0064         @if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi
0065         @echo Creating/replacing object files in $(G4LIBDIR)/lib$(name).a ...
0066         @rm -f $(G4LIBDIR)/lib$(name).a
0067         @$(AR) $(OUT_LIB)$(G4LIBDIR)/lib$(name).a $(G4TMPDIR)/*.o
0068         @if [ X$(G4SYSTEM) != XWIN32-VC ] ; then  \
0069         if [ -f /usr/bin/ranlib -o -f /bin/ranlib ] ; then \
0070         ranlib $(G4LIBDIR)/lib$(name).a ; fi ; fi
0071 endif
0072 
0073 
0074 ###############################################################################
0075 #
0076 # Actual targets for .o, .d files
0077 #
0078 
0079 $(G4TMPDIR)/%.o: src/%.cc
0080 ifdef CPPVERBOSE
0081         $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F).o src/$*.cc
0082 else
0083         @echo Compiling $*.cc ...
0084         @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F).o src/$*.cc
0085 endif
0086 
0087 # .PHONY targets are executed regardless of time-stamp of any file of
0088 # same name.
0089 .PHONY: all obj lib clean clean_libs includes
0090 
0091 obj: $(G4TMPDIR)/obj.last
0092 
0093 # Touch the versioning file
0094 $(G4TMPDIR)/obj.last: $(objects)
0095         @$(TOUCH) $@
0096 
0097 # Make the .d file(s) and include it(them).
0098 
0099 # The ideas for this come from the GNU Make Manual, Section 4.12,
0100 # Generating Prerequisites Automatically.  The g++ compiler has an
0101 # option -M or -MM to write to standard output a list of dependencies
0102 # based on the #include statements.  The "sed" adds the dependency
0103 # file itself as a second target.  The result is a mini-makefile which
0104 # specifies the .o and .d files as targets which depend on all the
0105 # files found through the #include statements.  This file is then
0106 # included, causing GNU Make to honour these dependencies.
0107 
0108 # The "set -e" causes the shell to exit with an error when the "g++"
0109 # fails (otherwise it would only notice the last command in the
0110 # pipeline, namely "sed").  GNU Make notices the error and exits
0111 # sooner than it otherwise would (still not as soon as I expect,
0112 # though!).  Even then, an empty file is made, so "[ -s $@ ] || rm -f
0113 # $@" removes it ([ -s filename ] gives zero exit code only if file
0114 # exists and has a size greater than zero).  This avoids making
0115 # corrupt .d files which would play havoc with your next build.
0116 
0117 $(G4TMPDIR)/%.d: src/%.cc
0118         @echo Making dependency for file $< ...
0119         @if [ ! -d $(G4TMPDIR) ] ; then mkdir -p $(G4TMPDIR)  ;fi
0120         @set -e;\
0121         g++ $(GPPFLAGS) $(CPPFLAGS) -w $< |\
0122         sed 's!$*\.o!$(G4TMPDIR)/& $@!' >$@;\
0123         [ -s $@ ] || rm -f $@
0124 ifneq ($(dependencies),)
0125 ifneq ($(MAKECMDGOALS),clean)
0126 ifneq ($(MAKECMDGOALS),setup)
0127 ifneq ($(MAKECMDGOALS),clean_setup)
0128 -include $(dependencies)
0129 endif
0130 endif
0131 endif
0132 endif
0133 
0134 #
0135 # Installation of include files
0136 #
0137 installed_includes:=$(foreach file,$(wildcard include/*),$(shell test -e $(file) && echo $(file)))
0138 installed_includes:=$(patsubst include/%,$(G4INCLUDE)/%,$(installed_includes))
0139 
0140 # NOTE: the double colon rule allows to add other rules for the same target
0141 #
0142 includes:: $(installed_includes)
0143 
0144 # Static Pattern rules, see GNU make manual for details.
0145 #           target(s): target-pattern : dep-pattern
0146 #
0147 $(installed_includes): $(G4INCLUDE)/% : include/%
0148         @cp -rp $< $@
0149 
0150 #
0151 # Clean up libraries
0152 #
0153 ifndef G4EXLIB
0154 clean::
0155         @echo Cleaning up ...
0156         @rm -f $(G4LIBDIR)/lib$(name).a
0157         @rm -f $(G4LIBDIR)/*$(name).lib
0158         @rm -f $(G4LIBDIR)/*$(name).exp
0159         @rm -f $(G4LIBDIR)/lib$(name).$(SHEXT)
0160         @rm -rf $(G4TMPDIR)
0161         @rm -rf moc
0162 endif
0163 
0164 clean_libs::
0165         @echo Removing library lib$(name).a ...
0166         @rm -f $(G4LIBDIR)/*$(name).a
0167         @echo Removing library lib$(name).$(SHEXT) ...
0168         @rm -f $(G4LIBDIR)/*$(name).lib
0169         @rm -f $(G4LIBDIR)/*$(name).exp
0170         @rm -f $(G4LIBDIR)/*$(name).$(SHEXT)