| [817] | 1 | ###############################################################################
|
|---|
| 2 | ### GNUmakefile for the G3 to G4 conversion package.
|
|---|
| 3 | ###
|
|---|
| 4 | ### T. Wenaus 20/11/1995
|
|---|
| 5 | ### Uses chunks of John Allison's generic makefiles.
|
|---|
| 6 | ###
|
|---|
| 7 | ### The presence of Fortran and several standalone programs
|
|---|
| 8 | ### make this package non-generic enough to require its
|
|---|
| 9 | ### own makefile.
|
|---|
| 10 | ###
|
|---|
| 11 | ###############################################################################
|
|---|
| 12 |
|
|---|
| 13 | G4TARGET := rztog4
|
|---|
| 14 |
|
|---|
| 15 | name := G3toG4
|
|---|
| 16 |
|
|---|
| 17 | ifndef G4INSTALL
|
|---|
| 18 | G4INSTALL := ../..
|
|---|
| 19 | endif
|
|---|
| 20 |
|
|---|
| 21 | GLOBLIBS = libG4tracking.lib libG4processes.lib libG4digits_hits.lib
|
|---|
| 22 | GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
|
|---|
| 23 | GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
|
|---|
| 24 | GLOBLIBS += libG4intercoms.lib libG4global.lib
|
|---|
| 25 |
|
|---|
| 26 | include $(G4INSTALL)/config/architecture.gmk
|
|---|
| 27 |
|
|---|
| 28 | CPPFLAGS += \
|
|---|
| 29 | -I$(G4BASE)/global/management/include \
|
|---|
| 30 | -I$(G4BASE)/global/HEPGeometry/include \
|
|---|
| 31 | -I$(G4BASE)/global/HEPRandom/include \
|
|---|
| 32 | -I$(G4BASE)/geometry/magneticfield/include \
|
|---|
| 33 | -I$(G4BASE)/geometry/volumes/include \
|
|---|
| 34 | -I$(G4BASE)/geometry/management/include \
|
|---|
| 35 | -I$(G4BASE)/geometry/solids/CSG/include \
|
|---|
| 36 | -I$(G4BASE)/geometry/solids/specific/include \
|
|---|
| 37 | -I$(G4BASE)/geometry/solids/Boolean/include \
|
|---|
| 38 | -I$(G4BASE)/geometry/solids/BREPS/include \
|
|---|
| 39 | -I$(G4BASE)/graphics_reps/include \
|
|---|
| 40 | -I$(G4BASE)/materials/include \
|
|---|
| 41 | -I$(G4BASE)/particles/management/include \
|
|---|
| 42 | -I$(G4BASE)/processes/management/include \
|
|---|
| 43 | -I$(G4BASE)/processes/general/include \
|
|---|
| 44 | -I$(G4BASE)/processes/decay/include \
|
|---|
| 45 | -I$(G4BASE)/track/include \
|
|---|
| 46 | -I$(G4BASE)/tracking/include \
|
|---|
| 47 | -I$(G4BASE)/digits_hits/detector/include \
|
|---|
| 48 | -I$(G4BASE)/digits_hits/hits/include
|
|---|
| 49 |
|
|---|
| 50 | ### kludge for AIX
|
|---|
| 51 |
|
|---|
| 52 | ifeq ($(FC),xlf)
|
|---|
| 53 | cpp_include_flag=-WF,-I
|
|---|
| 54 | ### -d writes out F*.f file
|
|---|
| 55 | FCFLAGS += -d $(patsubst -I%,$(cpp_include_flag)%,-Iinclude)
|
|---|
| 56 | ### xlf prepends .f name with F
|
|---|
| 57 | dotf_prepend=F
|
|---|
| 58 | else
|
|---|
| 59 | ### other compilers do not prepend .f name with F
|
|---|
| 60 | dotf_prepend=
|
|---|
| 61 | FCFLAGS += -Iinclude
|
|---|
| 62 | endif
|
|---|
| 63 |
|
|---|
| 64 | .SUFFIXES:
|
|---|
| 65 | .SUFFIXES: .a .o .cc .cxx .c .f .F .d
|
|---|
| 66 |
|
|---|
| 67 | ### --------------------- vpaths ----------------------------------------------
|
|---|
| 68 |
|
|---|
| 69 | vpath %.hh $(patsubst -I%,%,$(filter -I%,$(CPPFLAGS)))
|
|---|
| 70 | vpath %.inc $(patsubst -I%,%,$(filter -I%,$(CPPFLAGS)))
|
|---|
| 71 |
|
|---|
| 72 | G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
|
|---|
| 73 | G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
|
|---|
| 74 | G4BINDIR := $(G4BIN)/$(G4SYSTEM)
|
|---|
| 75 |
|
|---|
| 76 | Fbinsources = src/$(G4TARGET).F
|
|---|
| 77 | Fbinobjects = $(patsubst src/%.F,$(G4TMPDIR)/%.o,$(Fbinsources))
|
|---|
| 78 | Flibsources = $(filter-out $(Fbinsources),$(wildcard src/*.F))
|
|---|
| 79 | Flibobjects = $(patsubst src/%.F,$(G4TMPDIR)/%.o,$(Flibsources))
|
|---|
| 80 | Fdependencies = $(patsubst %.o,%.d,$(Fbinobjects) $(Flibobjects))
|
|---|
| 81 |
|
|---|
| 82 | ifdef G3G4DEBUG
|
|---|
| 83 | CPPFLAGS += -DG3G4DEBUG
|
|---|
| 84 | endif
|
|---|
| 85 | ifdef G3G4_NO_REFLECTION
|
|---|
| 86 | CPPFLAGS += -DG3G4_NO_REFLECTION
|
|---|
| 87 | endif
|
|---|
| 88 |
|
|---|
| 89 | ###############################################################################
|
|---|
| 90 | ### user beware! .rz files made with cernlib v 95a cannot be read with later
|
|---|
| 91 | ### versions. You can use cernlib -v option to specify the cernlib version
|
|---|
| 92 | ###############################################################################
|
|---|
| 93 |
|
|---|
| 94 | ### .PHONY targets are executed regardless of time-stamp of any file of same
|
|---|
| 95 | ### name
|
|---|
| 96 |
|
|---|
| 97 | .PHONY: global all lib bin libC libF
|
|---|
| 98 |
|
|---|
| 99 | ###--------------------- section to define explicit rules --------------------
|
|---|
| 100 |
|
|---|
| 101 | first: lib
|
|---|
| 102 |
|
|---|
| 103 | global: lib bin
|
|---|
| 104 |
|
|---|
| 105 | all: lib
|
|---|
| 106 |
|
|---|
| 107 | lib: libc libF
|
|---|
| 108 |
|
|---|
| 109 | ifneq ($(G4LIB_BUILD_SHARED),)
|
|---|
| 110 | libc : $(G4LIBDIR)/lib$(name).$(SHEXT)
|
|---|
| 111 | else
|
|---|
| 112 | libc : $(G4LIBDIR)/lib$(name).a
|
|---|
| 113 | endif
|
|---|
| 114 | @echo $@ stage done
|
|---|
| 115 |
|
|---|
| 116 | libF : $(G4LIBDIR)/lib$(name)F.a
|
|---|
| 117 | @echo $@ stage done
|
|---|
| 118 |
|
|---|
| 119 | bin: $(G4BINDIR)/$(G4TARGET)
|
|---|
| 120 | @echo $@ stage done
|
|---|
| 121 |
|
|---|
| 122 | ### Make Fortran library.
|
|---|
| 123 |
|
|---|
| 124 | $(G4LIBDIR)/lib$(name)F.a: $(Flibobjects)
|
|---|
| 125 | @if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi
|
|---|
| 126 | @echo Creating/replacing object files in lib$(name)F.a
|
|---|
| 127 | @ar r $@ $?
|
|---|
| 128 | @if [ -f /usr/bin/ranlib -o -f /bin/ranlib ] ; then \
|
|---|
| 129 | echo Running ranlib on lib$(name)F.a ; ranlib $@ ; fi
|
|---|
| 130 |
|
|---|
| 131 | ### rztog4: Standalone Fortran program that reads an RZ file and converts
|
|---|
| 132 | ### the geometry and other init structures therein to G4. A call
|
|---|
| 133 | ### list file and G4 C++ code are generated; either can be used
|
|---|
| 134 | ### on the G4 side to build the geometry.
|
|---|
| 135 |
|
|---|
| 136 | $(G4BINDIR)/$(G4TARGET) : $(Fbinobjects) $(G4LIBDIR)/lib$(name)F.a
|
|---|
| 137 | @if [ ! -d $(G4BINDIR) ] ; then mkdir $(G4BINDIR) ;fi
|
|---|
| 138 | @echo Linking $(G4TARGET)
|
|---|
| 139 | $(RM) $@
|
|---|
| 140 | echo $(G4TARGET) dependencies: $^
|
|---|
| 141 | $(FC) $(Fbinobjects) -o $@ $(G4LIBDIR)/lib$(name)F.a $(shell cernlib -v pro geant321 packlib)
|
|---|
| 142 | @echo Finished linking $(G4TARGET)
|
|---|
| 143 |
|
|---|
| 144 | ###-------------------- locally defined pattern rules ------------------------
|
|---|
| 145 |
|
|---|
| 146 | ### Make the .o files from src/*.F
|
|---|
| 147 | $(G4TMPDIR)/%.o : src/%.F
|
|---|
| 148 | $(FC) $(FCFLAGS) -o $(G4TMPDIR)/$(*F).o -c src/$(*F).F
|
|---|
| 149 | @file=$(dotf_prepend)$(*F).f;\
|
|---|
| 150 | if [ -f $$file ]; then echo Moving $$file to $(G4TMPDIR)/$$file; \
|
|---|
| 151 | mv $$file $(G4TMPDIR)/$$file; fi
|
|---|
| 152 |
|
|---|
| 153 | ### Move the .f files
|
|---|
| 154 | $(G4TMPDIR)/%.f : %.f
|
|---|
| 155 | @echo Moving $< to $@
|
|---|
| 156 | @mv $< $@
|
|---|
| 157 |
|
|---|
| 158 | ### --------------------- .d files --------------------------------------------
|
|---|
| 159 |
|
|---|
| 160 | ### Make the .d file(s) and include it(them).
|
|---|
| 161 | ### g++ -MM is good at this, except it forgets the subdirectory (hence
|
|---|
| 162 | ### the echo $(@D)/).
|
|---|
| 163 |
|
|---|
| 164 | $(G4TMPDIR)/%.d: src/%.F
|
|---|
| 165 | @if [ ! -d $(G4TMP)/$(G4SYSTEM) ] ; then mkdir $(G4TMP)/$(G4SYSTEM) ;fi
|
|---|
| 166 | @if [ ! -d $(G4TMPDIR) ] ; then mkdir $(G4TMPDIR) ;fi
|
|---|
| 167 | @if test -f $@ ; then rm -f $@; fi
|
|---|
| 168 | @echo $(G4LIBDIR)/lib$(name)F.a\($*.o\) $@ " : " $? "\\" > $@
|
|---|
| 169 | @if test -f $< ; then awk '$$1=="#include" { print $$2 " \\" }' $< | tr -d \"\>\< >> $@ ; echo >> $@ ; fi
|
|---|
| 170 |
|
|---|
| 171 | ###@if test -f $< ; then echo Making $@ depend file for $<; awk '$$1=="#include" { print $$2 " \\" }' $< | tr -d \"\>\< >> $@ ; echo >> $@ ; fi
|
|---|
| 172 |
|
|---|
| 173 | ### --------------------- end of pattern rules --------------------------------
|
|---|
| 174 |
|
|---|
| 175 | -include $(Fdependencies)
|
|---|
| 176 |
|
|---|
| 177 | clean:: cleanf
|
|---|
| 178 |
|
|---|
| 179 | cleanf:
|
|---|
| 180 | @$(RM) $(Flibobjects)
|
|---|
| 181 | @$(RM) $(Fbinobjects)
|
|---|
| 182 | @$(RM) $(Fdependencies)
|
|---|
| 183 | @$(RM) $(G4BINDIR)/$(G4TARGET)
|
|---|
| 184 |
|
|---|
| 185 | include $(G4INSTALL)/config/common.gmk
|
|---|
| 186 |
|
|---|
| 187 | test1:
|
|---|
| 188 | @echo $(sources)
|
|---|
| 189 | @echo $(objects)
|
|---|
| 190 | @echo $(dependencies)
|
|---|