[832] | 1 | # $Id: GNUmakefile,v 1.88 2007/11/30 16:50:46 gcosmo Exp $ |
---|
| 2 | # ----------------------------------------------------------------- |
---|
| 3 | # "gmake" makes default libraries for each subdomain. |
---|
| 4 | # "gmake global" makes global libraries for each subdomain. |
---|
| 5 | # Composite libraries are built. |
---|
| 6 | # "gmake includes" places header files .h/.hh in $G4INCLUDE |
---|
| 7 | # "gmake libmap" forces rebuilding of map-file for granular libraries. |
---|
| 8 | # "gmake dll" forces building of DLLs global libraries and generates DLLs on WIN32 |
---|
| 9 | # "gmake clean_libs" removes just archive (.a) and shared (.so) libraries |
---|
| 10 | # of current platform installation. |
---|
| 11 | # "gmake clean" removes installation of current platform. |
---|
| 12 | # "gmake clean_all" removes all platforms installations. |
---|
| 13 | # |
---|
| 14 | # (The .o files(s) are made by implicit rules.) |
---|
| 15 | |
---|
| 16 | ifndef G4INSTALL |
---|
| 17 | G4INSTALL = .. |
---|
| 18 | endif |
---|
| 19 | |
---|
| 20 | include $(G4INSTALL)/config/architecture.gmk |
---|
| 21 | |
---|
| 22 | SUBDIR1 = global intercoms graphics_reps materials |
---|
| 23 | SUBDIR2 = geometry particles track digits_hits processes parameterisations |
---|
| 24 | SUBDIR2 += tracking event run error_propagation readout physics_lists |
---|
| 25 | SUBDIR3 = persistency interfaces visualization |
---|
| 26 | |
---|
| 27 | SUBDIR4 = g3tog4 |
---|
| 28 | |
---|
| 29 | G4BINDIR := $(G4BIN)/$(G4SYSTEM) |
---|
| 30 | G4LIBDIR := $(G4LIB)/$(G4SYSTEM) |
---|
| 31 | G4TMPDIR := $(G4TMP)/$(G4SYSTEM) |
---|
| 32 | unique := $(shell echo $$$$) |
---|
| 33 | |
---|
| 34 | .PHONY: all glob global kernel_global kernel liblist libmap dll win32def includes clean_libs clean clean_lists clean_all |
---|
| 35 | |
---|
| 36 | all: banner kernel |
---|
| 37 | ifdef G4LIB_USE_G3TOG4 |
---|
| 38 | @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE)); done;: |
---|
| 39 | endif |
---|
| 40 | @$(MAKE) libmap |
---|
| 41 | @$(ECHO) "Libraries installation completed !" |
---|
| 42 | |
---|
| 43 | glob global: banner kernel_global |
---|
| 44 | ifdef G4LIB_USE_G3TOG4 |
---|
| 45 | @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE)); done;: |
---|
| 46 | endif |
---|
| 47 | @$(MAKE) liblist |
---|
| 48 | @$(ECHO) "Libraries installation completed !" |
---|
| 49 | |
---|
| 50 | fpe_debug: banner kernel |
---|
| 51 | @$(ECHO) Activating FPE debug build ... |
---|
| 52 | ifneq (,$(findstring Linux-g++,$(G4SYSTEM))) |
---|
| 53 | @rm -f $(G4TMPDIR)/G4run/G4RunManagerKernel.* |
---|
| 54 | @cd $(G4INSTALL)/source/run; $(MAKE) G4FPE_DEBUG=1; |
---|
| 55 | @cd $(G4INSTALL)/source; $(MAKE) libmap; |
---|
| 56 | @$(ECHO) "Libraries installation completed !" |
---|
| 57 | else |
---|
| 58 | @$(ECHO) "Build of FPE check is only supported on Linux platforms with gcc !" |
---|
| 59 | @$(ECHO) "The system you have currently selected is $(G4SYSTEM)." |
---|
| 60 | @$(ECHO) "No actions taken !" |
---|
| 61 | endif |
---|
| 62 | |
---|
| 63 | kernel_global: |
---|
| 64 | @for dir in $(SUBDIR1); do (cd $$dir && $(MAKE) global); done;: |
---|
| 65 | @for dir in $(SUBDIR2); do (cd $$dir && $(MAKE) global); done;: |
---|
| 66 | @for dir in $(SUBDIR3); do (cd $$dir && $(MAKE) global); done;: |
---|
| 67 | |
---|
| 68 | kernel: |
---|
| 69 | @for dir in $(SUBDIR1); do (cd $$dir && $(MAKE)); done;: |
---|
| 70 | @for dir in $(SUBDIR2); do (cd $$dir && $(MAKE)); done;: |
---|
| 71 | @for dir in $(SUBDIR3); do (cd $$dir && $(MAKE)); done;: |
---|
| 72 | |
---|
| 73 | libmap: liblist |
---|
| 74 | @$(ECHO) "Libmap stage. Searching for GNUmakefiles and sorting ..." |
---|
| 75 | @find . \ |
---|
| 76 | -name GNUmakefile -exec $(GREP) -l '^ *name *:=' {} \; \ |
---|
| 77 | | sort \ |
---|
| 78 | > /tmp/G4_all_lib_makefiles.$(unique); |
---|
| 79 | @$(ECHO) "Weeding out paths and files ..." |
---|
| 80 | @for i in `$(CAT) /tmp/G4_all_lib_makefiles.$(unique)`; \ |
---|
| 81 | do \ |
---|
| 82 | $(ECHO) $$i | $(GREP) -q -e '/tests\?/' -e 'models/verification' || \ |
---|
| 83 | $(GREP) -q -e SUBDIR -e G4hepgeometry $$i || \ |
---|
| 84 | $(ECHO) $$i >> /tmp/G4_granlib_makefiles.$(unique); \ |
---|
| 85 | done |
---|
| 86 | @$(ECHO) "Making libname.map starter file ..." |
---|
| 87 | @touch /tmp/G4libname.map.starter.$(unique); |
---|
| 88 | @for i in `$(CAT) /tmp/G4_granlib_makefiles.$(unique)`; \ |
---|
| 89 | do \ |
---|
| 90 | $(GREP) '^ *name *:=' $$i | $(CUT) -d \ -f 3 \ |
---|
| 91 | >> /tmp/G4libname.map.starter.$(unique); \ |
---|
| 92 | $(ECHO) $$i | $(SED) "s/^\\./source/" \ |
---|
| 93 | >> /tmp/G4libname.map.starter.$(unique); \ |
---|
| 94 | done |
---|
| 95 | @$(ECHO) "Making libname.map ..." |
---|
| 96 | @rm -f $(G4LIBDIR)/libname.map; |
---|
| 97 | @G4TMP=$(G4TMP); export G4TMP; \ |
---|
| 98 | $(G4LIBDIR)/liblist -l -d $(G4TMPDIR) \ |
---|
| 99 | < /tmp/G4libname.map.starter.$(unique) \ |
---|
| 100 | > $(G4LIBDIR)/libname.map |
---|
| 101 | @rm -f /tmp/G4_all_lib_makefiles.$(unique); |
---|
| 102 | @rm -f /tmp/G4_granlib_makefiles.$(unique); |
---|
| 103 | @rm -f /tmp/G4libname.map.starter.$(unique); |
---|
| 104 | |
---|
| 105 | liblist: $(G4LIBDIR)/liblist |
---|
| 106 | |
---|
| 107 | $(G4LIBDIR)/liblist: $(G4INSTALL)/config/liblist.c |
---|
| 108 | @$(ECHO) "Building library management utility liblist ..." |
---|
| 109 | @if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi |
---|
| 110 | @$(CC) $(CCFLAGS) -o $(G4LIBDIR)/liblist $(G4INSTALL)/config/liblist.c |
---|
| 111 | |
---|
| 112 | dll: banner win32def |
---|
| 113 | ifneq (,$(findstring WIN32-VC,$(G4SYSTEM))) |
---|
| 114 | @$(ECHO) "Verifying existence of global libraries for DLLs ..." |
---|
| 115 | @$(MAKE) kernel_global G4LIB_BUILD_DLL=1 |
---|
| 116 | @$(ECHO) "Building Windows DLL libraries ..." |
---|
| 117 | @$(MAKE) kernel_global G4LIB_BUILD_DLL=1 G4LIB_BUILD_SHARED=1 |
---|
| 118 | @$(ECHO) "Clearing temporary DLL objects and temporaries ..." |
---|
| 119 | @rm -rf $(G4LIBDIR)/*.def $(G4LIBDIR)/*.exp |
---|
| 120 | @rm -rf $(G4TMPDIR)/* |
---|
| 121 | ifdef G4LIB_USE_G3TOG4 |
---|
| 122 | @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE)); done;: |
---|
| 123 | @mv $(G4LIBDIR)/libG3toG4.a $(G4LIBDIR)/libG3toG4.lib |
---|
| 124 | endif |
---|
| 125 | @$(ECHO) "Done !" |
---|
| 126 | else |
---|
| 127 | @$(ECHO) "Sorry !" |
---|
| 128 | endif |
---|
| 129 | |
---|
| 130 | win32def: $(G4INSTALL)/config/win32def.c |
---|
| 131 | ifneq (,$(findstring WIN32-VC,$(G4SYSTEM))) |
---|
| 132 | @$(ECHO) "Building DLL management utility win32def ..." |
---|
| 133 | @if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi |
---|
| 134 | @$(CC) $(CCFLAGS) -o $(G4LIBDIR)/win32def $(G4INSTALL)/config/win32def.c |
---|
| 135 | else |
---|
| 136 | @$(ECHO) "Build of DLLs is only supported on Windows platforms !" |
---|
| 137 | @$(ECHO) "The system you have currently selected is $(G4SYSTEM)." |
---|
| 138 | @$(ECHO) "No actions taken !" |
---|
| 139 | endif |
---|
| 140 | |
---|
| 141 | includes: |
---|
| 142 | @$(ECHO) Installing header files in $(G4INCLUDE) ... |
---|
| 143 | @for dir in $(SUBDIR1); do (cd $$dir && $(MAKE) $@); done |
---|
| 144 | @for dir in $(SUBDIR2); do (cd $$dir && $(MAKE) $@); done |
---|
| 145 | @for dir in $(SUBDIR3); do (cd $$dir && $(MAKE) $@); done |
---|
| 146 | ifdef G4LIB_USE_G3TOG4 |
---|
| 147 | @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE) $@); done |
---|
| 148 | endif |
---|
| 149 | |
---|
| 150 | banner: |
---|
| 151 | @$(ECHO) "*************************************************************" |
---|
| 152 | @$(ECHO) " Installation Geant4 version $$Name: $ " |
---|
| 153 | @$(ECHO) " Copyright (C) 1994-2008 Geant4 Collaboration " |
---|
| 154 | @$(ECHO) "*************************************************************" |
---|
| 155 | |
---|
| 156 | clean_libs:: |
---|
| 157 | @$(ECHO) Removing all libraries ... |
---|
| 158 | @for dir in $(SUBDIR1); do (cd $$dir && $(MAKE) clean_libs); done |
---|
| 159 | @for dir in $(SUBDIR2); do (cd $$dir && $(MAKE) clean_libs); done |
---|
| 160 | @for dir in $(SUBDIR3); do (cd $$dir && $(MAKE) clean_libs); done |
---|
| 161 | ifdef G4LIB_USE_G3TOG4 |
---|
| 162 | @for dir in $(SUBDIR4); do (cd $$dir && $(MAKE) clean_libs); done |
---|
| 163 | endif |
---|
| 164 | @rm -rf $(G4LIBDIR)/libname.map |
---|
| 165 | |
---|
| 166 | clean:: |
---|
| 167 | @$(ECHO) Removing current $(G4SYSTEM) installation ... |
---|
| 168 | @rm -rf $(G4TMPDIR) |
---|
| 169 | @rm -rf $(G4LIBDIR) |
---|
| 170 | @rm -rf $(G4BINDIR) |
---|
| 171 | @rm -rf $(G4INSTALL)/.config/bin/$(G4SYSTEM) |
---|
| 172 | ifdef CFRONT |
---|
| 173 | @rm -rf $(G4TREP) |
---|
| 174 | endif |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | # Pay _extremely_ attention before executing the following target !! |
---|
| 178 | # |
---|
| 179 | clean_all:: |
---|
| 180 | @$(ECHO) Removing all installations ... |
---|
| 181 | @$(ECHO) Removing $(G4TMP) ... |
---|
| 182 | @rm -rf $(G4TMP) |
---|
| 183 | @$(ECHO) Removing $(G4LIB) ... |
---|
| 184 | @rm -rf $(G4LIB) |
---|
| 185 | @$(ECHO) Removing $(G4BIN) ... |
---|
| 186 | @rm -rf $(G4BIN) |
---|
| 187 | @$(ECHO) Removing $(G4INCLUDE) ... |
---|
| 188 | @rm -rf $(G4INCLUDE) |
---|
| 189 | @$(ECHO) Removing installation configurations ... |
---|
| 190 | @rm -rf $(G4INSTALL)/.config |
---|