#!/bin/bash # configure for G4beamline, including non-system libraries VERSION="2.12" # This is the only definition of the version number # # This is the new configure for G4beamline. The standard usage is: # (user unpacks source tarball into G4beamline-VERSION-source) # (user installs binary version of Root, if desired) # mkdir G4beamline-VERSION # cd G4beamline-VERSION # ../G4beamline-VERSION-source/configure [--options] # make # source bin/g4bl-setup.sh # g4bldata --install # cd test # ./all # #(should end "All Tests Passed") # cd ../examples # g4bl example1.in viewer=best # # configure uses $PWD for the directory into which all build products # are placed; it uses the path by which it was run to find the source. # Sourcing g4bl-setup.sh via absolute path will set up this instance # in your PATH. # # The build directory need not be right next to the source directory, in # which case run configure via an absolute path. # # Note that configure can be executed in the top-level source directory, # in which case the build products are put there. There are no conflicts # between source files or directories and build files and directories. # This is not recommended. # # The current configuration is written to .config, and if that file # exists it is read at the start of configure. The result is that # configure remembers its previous parameters for this build directory, # so you only need to add new options when re-running it. Note that #` .config is also read by the Makefile. # # A sentinel file .complete is used in the top-level # directory of each library to indicate its build is # complete, including its make install. # # The installed library files are put into these directories under $PWD: # include lib bin share # # The intermediate build products are put into this directory under $PWD: # build # # Library sources are in LibrarySource; if necessary they are copied # into build and built from there. By default, the most recent version # of each library is used, determined by lexocographical order; # --old-libs uses the oldest version (determined by HEADTAIL). # # In Windows/Cygwin, all paths MUST be absolute, and must be "mixed" # as in C:/path/dir (start with drive: and use forward-slashes). This is # the only path format understood by both cygwin and Windows tools. # # Spaces in directory names are not allowed (quoting in shell and make # are different). This applies only to building from source; the # binary packages can be installed into "C:\Program Files". # # NOTE: When running Windows in a virtual machine using shared folders # from the host, building in the shared folder is excessively slow # (more than a factor of 10!). So make sure your source and build # directories are in the root directory of the C: drive. # # Root is a special case: by default it will be built from source. but # that fails all too often. So you can specify a pre-installed binary # Root distribution via --with-root=dir. echo "configure for G4beamline $VERSION, including non-system libraries" echo "--help for help." ### ### configuration defaults ### G4BL_VISUAL=y G4BL_MPI='' G4BL_FORCEMPI=n G4BL_ROOT=y G4BL_DEBUG=n HEADTAIL=tail ### ### read previous configuration, if any (everything except VERSION will be ### over-written by .config values, and then the flag variables will be ### over-written by flags to this command) ### if test -r .config then T=$VERSION source .config VERSION=$T fi ### ### determine SOURCE, SYSTEM, and G4BL_DIR ### ### Note that PWD is a Cygwin-style path, while G4BL_DIR is a mixed-style path. ### (On Linux and Mac OS X this distinction is irrlevant.) SOURCE="$('cd' "$(dirname "$BASH_SOURCE")" >/dev/null; pwd)" if test -z "$SYSTEM" then case `uname -s` in Linux*) SYSTEM=Linux OBJEXT='o' ;; Darwin*) SYSTEM=Darwin OBJEXT='o' ;; CYGWIN*) SYSTEM=WIN32 OBJEXT='obj' ;; *) echo "ERROR: UNSUPPORTED OS -- set SYSTEM manually."; exit 1 ;; esac fi export G4BL_DIR="$PWD" if test -x /bin/cygpath then G4BL_DIR=`/bin/cygpath -m "$PWD"` SOURCE=`/bin/cygpath -m "$SOURCE"` fi if echo "$SOURCE$G4BL_DIR" | grep '[ ]' >/dev/null 2>&1 then echo "configure: ERROR -- neither SOURCE nor G4BL_DIR can contain space or tab" echo "(The binary distribution can be installed into a directory containing spaces;" echo "this does not apply to building from source.)" exit 1 fi echo SYSTEM=$SYSTEM echo SOURCE=$SOURCE echo G4BL_DIR=$G4BL_DIR ### ### verify that cmake is installed (needed by Geant4, perhaps other libs) ### if ! type cmake >/dev/null 2>&1 then echo "configure: ERROR -- Cmake is not installed" echo " It can be obtained from http://www.cmake.org" exit 1 fi ### ### determine the number of CPUs ### case $SYSTEM in Linux) NCPU=`grep -i '^processor' /proc/cpuinfo | wc -l` ;; Darwin) NCPU=`sysctl -n hw.ncpu` ;; WIN32) NCPU=1 ;; esac case "$NCPU" in [1-9]|[1-9][0-9]) ;; *) NCPU=1 ;; esac ### ### add USER name to VERSION, if this is a custom build ### if test "$USER" -a "$USER" != "g4bl" -a "$USER" != "tjrob" then VERSION=${VERSION%%-*}-$USER fi ### ### get configuration from arguments ### ERROR=false for i in $* do case "$i" in --source-distrib|--distrib-source) echo "Creating G4beamline-$VERSION-source.tgz..." trap "rm -fr G4beamline-$VERSION-source" 0 mkdir G4beamline-$VERSION-source ('cd' G4beamline-$VERSION-source >/dev/null 2>&1; \ ln -s ../configure ../LibrarySource ../source .) # -h makes tar follow symbolic links tar -chzf G4beamline-$VERSION-source.tgz G4beamline-$VERSION-source rm -fr G4beamline-$VERSION-source echo "Done." exit 0 ;; --enable-debug|--debug) G4BL_DEBUG=y G4BL_VISUAL=n G4BL_MPI='' G4BL_ROOT=n echo "G4BL_DEBUG enabled; visual, root, and MPI are disabled" ;; --enable-visual|--enable-viewer) G4BL_VISUAL=y ;; --disable-visual|--disable-viewer) G4BL_VISUAL=n ;; --with-root=*) ROOT="${i#--with-root=}" G4BL_ROOT=bin ;; --enable-root) G4BL_ROOT=y ;; --disable-root) G4BL_ROOT=n ;; --ncpus=*|--ncpu=*|--cpus=*|--cpu=*|--NCPUS=*|--NCPU=*|--CPUS=*|--CPU=*) NCPU="${i#*=}" ;; --mpi=*|--MPI=*|--enable-mpi=*|--enable-MPI=*) G4BL_MPI="${i#*=}" ;; --old-versions) HEADTAIL=head ;; --disable-mpi|--disable-MPI) G4BL_MPI='' G4BL_FORCEMPI=n ;; --force-mpi|--force-MPI) G4BL_FORCEMPI=y ;; --help) echo echo "configure constructs a top-level Makefile to build the libraries" echo "required by g4beamline, and then g4beamline itself." echo "It can take 0.5 to 8 hours to build the libraries, then 2 minutes" echo "for g4beamline. The make can run unattended; configure is quick." echo echo "The configuration is determined by command-line arguments:" echo " --help Print this help message" echo " --enable-visual Enable visualization (default)" echo " --disable-visual Disable visualization " echo " --cpus=$NCPU # CPUs to use (default is # present)" echo " --mpi=/dir Enable MPI support in /dir (default=disabled)" echo " --force-mpi Force MPI to be used (for supercomputer)" echo " --disable-mpi Disable MPI support (default=disabled)" echo " --with-root=dir Enable Root support with binary Root installation" echo " --enable-root Ensable Root support (default=enabled)" echo " --disable-root Disable Root support (default=enabled)" echo " --old-versions Use the old versions of libraries DEPRECATED" echo " --debug Enable debugging; also does --disable-visual" echo " and --disable-mpi and --disable-root" echo " (but you can enable them after --debug)" echo " --source-distrib Create a source-distribution tarball." echo " Any other options are ignored." echo echo "configure uses \$PWD for the directory into which all build" echo "products are placed; it uses the path by which it was run to" echo "find the source (can be relative or absolute). They can be" echo "the same, but that is not recommended." echo echo "Motif is required for --enable-visual, and is called 'libXm';" echo "Your system administrator may need to install the 'lesstif' " echo "developemnt package (via Fink on Mac OS X)." echo echo "MPI permits multiple instances of a program on different CPUs" echo "to work cooperatively on a single task. If MPI is enabled," echo "the MPI libraries must have been built for your system." echo "Note that if MPI is not forced, then Open MPI is assumed and" echo "MPI is used only when g4beamline is run via 'mpirun'." echo echo "Root support can be either via the included source or via an" echo "already installed Root instance. If ROOTSYS is defined and Root" echo "is enabled, that instance of Root will be used; --enable-root" echo "with ROOTSYS not set will build from source. As there are often" echo "problems building Root, using an existing installation can be better." echo echo "--debug is meant for debugging Geant4, CLHEP, and G4beamline." echo "If you want visualization, MPI, or root, you must --enable" echo "them AFTER the --debug flag." echo echo "The usual configure and build procedure is:" echo " (user unpacks source tarball into G4beamline-VERSION-source)" echo " mkdir G4beamline-VERSION" echo " cd G4beamline-VERSION" echo " ../G4beamline-VERSION-source/configure [--options...]" echo " make" echo echo "To install the required data files:" echo " bin/g4bldata --install" echo "This requires an Internet connection, and will download ~400 MB" echo "of data from CERN that unpacks to ~1.5 GB." echo echo "All build products and Geant4Data are put in \$PWD." echo "Sourcing bin/g4bl-setup.sh via absolute path will set up this" echo "instance in your PATH (can be put into \$HOME/.bash_profile):" echo " source /path.../G4beamline-VERSION/bin/g4bl-setup.sh" echo " cd ...wherever..." echo " g4bl input.file [args...]" echo exit ;; *) echo "*** Invalid argument '$i'" ERROR=true ;; esac done if $ERROR then echo "$0" --help exit 1 fi ### ### Add debug to VERSION ### if test "$G4BL_DEBUG" = "y" then VERSION=${VERSION%-debug}-debug fi ### ### Use binary installation of Root, rather than building Root from source ### if test "$G4BL_ROOT" = "y" -a "$ROOTSYS" -a -x "$ROOTSYS/bin/root-config" then echo "Using existing installation of root '$ROOTSYS'." ROOT="$ROOTSYS" G4BL_ROOT=bin fi ### ### Verify Root binary distribution ### if test "$G4BL_ROOT" = "bin" then if ! test -x "$ROOT/bin/root-config" then echo "*** Invalid Root binary installation." exit 1 fi fi ### ### Get library directories (including their versions) ### if test "$HEADTAIL" = head then echo "configure: NOTE: --old-versions is set." fi CLHEP=`ls -d -1 $SOURCE/LibrarySource/clhep* | $HEADTAIL -1` GEANT4=`ls -d -1 $SOURCE/LibrarySource/geant* | $HEADTAIL -1` if test "$G4BL_ROOT" != "bin"; then ROOT=`ls -d -1 $SOURCE/LibrarySource/root* | $HEADTAIL -1` fi COIN=`ls -d -1 $SOURCE/LibrarySource/coin* | $HEADTAIL -1` SOXT=`ls -d -1 $SOURCE/LibrarySource/soxt* | $HEADTAIL -1` SOWIN=`ls -d -1 $SOURCE/LibrarySource/sowin* | $HEADTAIL -1` GSL=`ls -d -1 $SOURCE/LibrarySource/gsl* | $HEADTAIL -1` WINGSL=`ls -d -1 $SOURCE/LibrarySource/wingsl* | $HEADTAIL -1` FFTW=`ls -d -1 $SOURCE/LibrarySource/fftw* | $HEADTAIL -1` WINFFTW=`ls -d -1 $SOURCE/LibrarySource/winfftw* | $HEADTAIL -1` WINEXPAT=`ls -d -1 $SOURCE/LibrarySource/winexpat* | $HEADTAIL -1` ### ### figure out 32/64-bits (Root gets it wrong for 32-bit compilers on MAC OS X) ### Used by distrib-Linux to distinguish 32- and 64-bit distributions ### echo "int main() { }" >/tmp/bits$$.cc g++ -o /tmp/bits$$ /tmp/bits$$.cc if file /tmp/bits$$ | egrep -i 'x86_64|64-bit' >/dev/null 2>&1 then BITS=64 else BITS='' fi rm -f /tmp/bits$$* ### ### write configuration ### NOTE: This is a bilingual file, read by both bash and make. ### No spaces are permitted in any directory name. ### echo >.config '# G4beamline .config - this file is bilingual, bash and make' echo >>.config VERSION=$VERSION echo >>.config SYSTEM=$SYSTEM echo >>.config SOURCE=$SOURCE echo >>.config G4BL_DIR=$G4BL_DIR echo >>.config OBJEXT=$OBJEXT echo >>.config G4BL_VISUAL=$G4BL_VISUAL echo >>.config G4BL_MPI=$G4BL_MPI echo >>.config G4BL_FORCEMPI=$G4BL_FORCEMPI echo >>.config G4BL_ROOT=$G4BL_ROOT echo >>.config G4BL_DEBUG=$G4BL_DEBUG echo >>.config NCPU=$NCPU echo >>.config HEADTAIL=$HEADTAIL echo >>.config BITS=$BITS echo >>.config echo >>.config CLHEP=$CLHEP echo >>.config GEANT4=$GEANT4 echo >>.config ROOT=$ROOT echo >>.config COIN=$COIN echo >>.config SOXT=$SOXT echo >>.config SOWIN=$SOWIN echo >>.config GSL=$GSL echo >>.config WINGSL=$WINGSL echo >>.config FFTW=$FFTW echo >>.config WINFFTW=$WINFFTW echo >>.config WINEXPAT=$WINEXPAT ### ### create required build directories, preserving existing ones ### for i in bin include lib share build build/g4beamline do if test ! -d $i; then mkdir $i; fi done cp -Rp $SOURCE/source/doc $SOURCE/source/test $SOURCE/source/examples . cp -Rp $SOURCE/source/Validation . cp -Rp $SOURCE/source/bin/* bin cp -Rp $SOURCE/source/share/g4beamline share ### ### create the top-level Makefile ### ### (first the SYSTEM-independent stuff) cat <<\EOF >Makefile # Top-Level Makefile for G4beamline # (Constructed by configure -- DO NOT EDIT) include .config $(shell echo "G4beamline build begun $(shell date) VERSION=$(VERSION)" >&2) $(shell echo "============= G4beamline build begun $(shell date)" >>build/g4beamline/build.log) #$(shell if test -r lib/.complete; then echo "Building g4beamline Log is $(PWD)/build/g4beamline/build.log" >&2; fi) ### ### User targets ### all: bin/g4beamline $(SOURCE)/source/make-help @echo @( "$(G4BL_DIR)/bin/g4bldata" --check ; exit 0; ) @echo @echo "G4beamline build complete!" `date` @echo "There is no 'make install' -- programs must be run from here." @echo @echo "To run G4beamline do this:" @echo " source $$PWD/bin/g4bl-setup.sh" @echo " cd wherever..." @echo " g4bl input.file [args...]" @echo "(The first can be put into your $$HOME/.bash_profile)" help: @echo "make targets:" @echo " help This help text" @echo " all g4beamline itself, including libraries (default)" @echo " distrib Construct a binary distribution (for this OS)" @echo " clean Remove all g4beamline products; keep libraries" @echo " distclean Remove all products as if configure was never run" @echo " data Install the Geant4 data." clean: rm -f bin/g4beamline* build/g4beamline/* build/g4beamline/.complete distclean: rm -fr Makefile bin build doc examples include lib share test .config data: bin/g4bldata --install distrib: $(SOURCE)/source/make-help $(SOURCE)/source/distrib-$(SYSTEM) $(VERSION) install: @echo "There is no 'make install' -- programs must be run from this directory." @exit 1 ### ### Geant4 options to Cmake ### G4OPTS = ifeq ($(SYSTEM),WIN32) G4OPTS += -G "Unix Makefiles" endif G4OPTS += -DCMAKE_INSTALL_PREFIX="$(G4BL_DIR)" \ -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON \ -DGEANT4_USE_SYSTEM_EXPAT=ON \ -DGEANT4_USE_SYSTEM_CLHEP=ON -DCLHEP_ROOT_DIR=$(G4BL_DIR) ifeq ($(G4BL_DEBUG),y) G4OPTS += -DCMAKE_BUILD_TYPE=Debug endif ifeq ($(G4BL_VISUAL),y) # NOTE the code in BLVisManager.hh must #define the Geant4 Visualization driver # control variables inside a #ifdef G4BL_VISUAL. G4OPTS += -DGEANT4_USE_INVENTOR=ON \ -DINVENTOR_INCLUDE_DIR=$(G4BL_DIR)/include ifeq ($(SYSTEM),WIN32) G4OPTS += -DGEANT4_USE_OPENGL_WIN32=ON \ -DINVENTOR_LIBRARY_RELEASE=$(G4BL_DIR)/lib/libCoin.a \ -DINVENTOR_SOWIN_LIBRARY=$(G4BL_DIR)/lib/sowin.a else ifeq ($(SYSTEM),Darwin) G4OPTS += -DGEANT4_USE_OPENGL_X11=ON \ -DGEANT4_USE_XM=ON \ -DGEANT4_USE_RAYTRACER_X11=ON \ -DINVENTOR_LIBRARY_RELEASE=$(G4BL_DIR)/lib/libCoin.a \ -DINVENTOR_SOXT_LIBRARY=$(G4BL_DIR)/lib/libSoXt.a else G4OPTS += -DGEANT4_USE_OPENGL_X11=ON \ -DGEANT4_USE_XM=ON \ -DGEANT4_USE_RAYTRACER_X11=ON \ -DINVENTOR_LIBRARY_RELEASE=$(G4BL_DIR)/lib/libCoin.a \ -DINVENTOR_SOXT_LIBRARY=$(G4BL_DIR)/lib/libSoXt.a endif endif endif ### ### CPPFLAGS for compiling ### CPPFLAGS += $(shell $(G4BL_DIR)/bin/g4bl-config --include) ### ### general dependencies ### bin/g4beamline: build/g4beamline/.complete # libraries that are always needed build/geant4/.complete: build/clhep/.complete lib/.complete: build/clhep/.complete build/geant4/.complete \ build/gsl/.complete build/fftw/.complete # G4beamline objects G4BLOBJS = $(patsubst $(SOURCE)/source/src/%.cc,build/g4beamline/%.$(OBJEXT),$(wildcard $(SOURCE)/source/src/*.cc)) $(G4BLOBJS): lib/.complete build/g4beamline/.complete: $(G4BLOBJS) ### ### Libraries that depend on configuration options ### ifeq ($(G4BL_VISUAL),y) lib/.complete: build/coin/.complete build/so/.complete build/geant4/.complete: build/coin/.complete build/so/.complete build/so/.complete: build/coin/.complete endif ifeq ($(G4BL_ROOT),y) lib/.complete: build/root/.complete endif ifeq ($(G4BL_ROOT),bin) lib/.complete: build/root/.complete endif lib/.complete: @echo "All required libraries are now complete." @touch lib/.complete @echo "Building g4beamline Log is $(PWD)/build/g4beamline/build.log" build/g4beamline/.complete: @touch build/g4beamline/.complete ### ### G4beamline source dependencies ### G4BLDEPS = $(patsubst %.$(OBJEXT),%.d,$(G4BLOBJS)) -include $(G4BLDEPS) ### ### End of SYSTEM-independent Makefile ### EOF trap "rm -f /tmp/$$.*" 0 cat <<\EOF >/tmp/$$.Darwin ### ### Makefile for Darwin ### build/clhep/.complete: @echo "Building CLHEP... Log is $(PWD)/build/clhep/build.log" @if test ! -d build/clhep; then mkdir build/clhep; fi -@(echo "================= `date`"; set -e -x; cd build/clhep; \ if test ! -r Makefile; then \ $(CLHEP)/CLHEP/configure --disable-shared --prefix=$(G4BL_DIR); \ fi; \ make -j $(NCPU); \ make install; \ ../../test/test40; \ touch .complete; \ cd ../..; rm -f lib/libCLHEP-[A-Z]*.a; \ ) >>build/clhep/build.log 2>&1 @if test -r build/clhep/.complete; then echo Building CLHEP complete.; \ else echo 'Building CLHEP FAILED *****'; exit 1; fi build/geant4/.complete: @echo "Building Geant4... Log is $(PWD)/build/geant4/build.log" @if test ! -d build/geant4; then mkdir build/geant4; fi -@(echo "================= `date`"; set -e -x; cd build/geant4; \ if test ! -r Makefile; then cmake $(G4OPTS) $(GEANT4); fi; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/geant4/build.log 2>&1 @if test -r build/geant4/.complete; then echo Building Geant4 complete.; \ else echo 'Building Geant4 FAILED *****'; exit 1; fi build/gsl/.complete: @echo "Building GSL... Log is $(PWD)/build/gsl/build.log" @if test ! -d build/gsl; then cp -Rp $(GSL) build/gsl; fi -@(echo "================= `date`"; set -e -x; cd build/gsl; \ ./configure --prefix=$(G4BL_DIR) --disable-shared --enable-static; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/gsl/build.log 2>&1 @if test -r build/gsl/.complete; then echo Building GSL complete.; \ else echo 'Building GSL FAILED *****'; exit 1; fi build/fftw/.complete: @echo "Building FFTW... Log is $(PWD)/build/fftw/build.log" @if test ! -d build/fftw; then cp -Rp $(FFTW) build/fftw; fi -@(echo "================= `date`"; set -e -x; cd build/fftw; \ ./configure --prefix=$(G4BL_DIR) --disable-shared --enable-static \ --enable-float --disable-dependency-tracking \ --disable-fortran; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/fftw/build.log 2>&1 @if test -r build/fftw/.complete; then echo Building FFTW complete.; \ else echo 'Building FFTW FAILED *****'; exit 1; fi build/coin/.complete: @echo "Building Coin... Log is $(PWD)/build/coin/build.log" @if test ! -d build/coin; then cp -Rp $(COIN) build/coin; fi -@(echo "================= `date`"; set -e -x; cd build/coin; \ ./configure --prefix=$(G4BL_DIR) --enable-system-expat \ --without-openal --disable-sound --disable-shared \ --enable-static --disable-debug --without-framework \ --enable-darwin-x11 --with-motif=/sw --disable-dyld; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/coin/build.log 2>&1 @if test -r build/coin/.complete; then echo Building Coin complete.; \ else echo 'Building Coin FAILED *****'; exit 1; fi build/so/.complete: @echo "Building SoXt... Log is $(PWD)/build/so/build.log" @if test ! -d build/so; then cp -Rp $(SOXT) build/so; fi -@(echo "================= `date`"; set -e -x; cd build/so; \ if test ! -r Makefile; then \ ./configure --prefix=$(G4BL_DIR) --disable-shared \ --enable-static --disable-debug --without-framework \ --enable-darwin-x11 --with-motif=/sw --disable-dyld \ --disable-sound --with-coin=$(G4BL_DIR); \ fi; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/so/build.log 2>&1 @if test -r build/so/.complete; then echo Building SoXt complete.; \ else echo 'Building SoXt FAILED *****'; exit 1; fi build/root/.complete: @echo "Building Root... Log is $(PWD)/build/root/build.log" ifeq ($(G4BL_ROOT),y) @if test ! -d build/root; then cp -Rp $(ROOT) build/root; fi @# make -j 4 may fail, but a second one succeeds, so use 3 of them @# make may fail after libs are built, so require just the libs we need -@(echo "================= `date`"; set -e -x; cd build/root; \ if test ! -r config.status; then ./configure macosx$(BITS) --minimal; fi; \ make -j $(NCPU) || make -j $(NCPU) || make -j 1 || true; \ cp -p lib/libCore.so $(G4BL_DIR)/lib; \ cp -p lib/libCint.so $(G4BL_DIR)/lib; \ cp -p lib/libMathCore.so $(G4BL_DIR)/lib; \ cp -p lib/libNet.so $(G4BL_DIR)/lib; \ cp -p lib/libRIO.so $(G4BL_DIR)/lib; \ cp -p lib/libThread.so $(G4BL_DIR)/lib; \ cp -p lib/libTree.so $(G4BL_DIR)/lib; \ if test ! -d $(G4BL_DIR)/include/root; then \ mkdir $(G4BL_DIR)/include/root; fi; \ cp -Rp include/* $(G4BL_DIR)/include/root; \ touch .complete; \ ) >>build/root/build.log 2>&1 else @if test ! -d build/root; then mkdir build/root; fi -@(echo "================= `date`"; set -e -x; \ cp $(ROOT)/lib/libCint.so lib; \ cp $(ROOT)/lib/libCore.so lib; \ cp $(ROOT)/lib/libMathCore.so lib; \ cp $(ROOT)/lib/libNet.so lib; \ cp $(ROOT)/lib/libRIO.so lib; \ cp $(ROOT)/lib/libThread.so lib; \ cp $(ROOT)/lib/libTree.so lib; \ touch build/root/.complete; \ ) >>build/root/build.log 2>&1 endif @if test -r build/root/.complete; then echo Building Root complete.; \ else echo 'Building Root FAILED *****'; exit 1; fi # g4bl-config knows which libraries are needed by the configuration LIBS = $(shell $(G4BL_DIR)/bin/g4bl-config --libs) MAIN = $(shell $(G4BL_DIR)/bin/g4bl-config --main) bin/g4beamline: $(G4BLOBJS) $(SOURCE)/source/g4beamline.cc @echo Linking g4beamline @(set -e -x; \ $(CXX) -o bin/g4beamline $(CPPFLAGS) $(MAIN) $(G4BLOBJS) $(LIBS) \ ) >>build/g4beamline/build.log 2>&1 ### ### rule to compile G4beamline source and create its dependency file ### build/g4beamline/%.$(OBJEXT): $(SOURCE)/source/src/%.cc @echo Compiling `basename $<` @(set -e -x; \ $(CXX) $(CPPFLAGS) -c -o $@ $<; \ g++ $(CPPFLAGS) -MM -MP -MT $@ $< >$(patsubst %.$(OBJEXT),%.d,$@) \ ) >>build/g4beamline/build.log 2>&1 EOF cat <<\EOF >/tmp/$$.Linux ### ### Makefile for Linux ### build/clhep/.complete: @echo "Building CLHEP... Log is $(PWD)/build/clhep/build.log" @if test ! -d build/clhep; then mkdir build/clhep; fi -@(echo "================= `date`"; set -e -x; cd build/clhep; \ if test ! -r Makefile; then \ $(CLHEP)/CLHEP/configure --disable-shared --prefix=$(G4BL_DIR); \ fi; \ make -j $(NCPU); \ make install; \ ../../test/test40; \ touch .complete; \ cd ../..; rm -f lib/libCLHEP-[A-Z]*.a; \ ) >>build/clhep/build.log 2>&1 @if test -r build/clhep/.complete; then echo Building CLHEP complete.; \ else echo 'Building CLHEP FAILED *****'; exit 1; fi build/geant4/.complete: @echo "Building Geant4... Log is $(PWD)/build/geant4/build.log" @if test ! -d build/geant4; then mkdir build/geant4; fi -@(echo "================= `date`"; set -e -x; cd build/geant4; \ if test ! -r Makefile; then cmake $(G4OPTS) $(GEANT4); fi; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/geant4/build.log 2>&1 @if test -r build/geant4/.complete; then echo Building Geant4 complete.; \ else echo 'Building Geant4 FAILED *****'; exit 1; fi build/gsl/.complete: @echo "Building GSL... Log is $(PWD)/build/gsl/build.log" @if test ! -d build/gsl; then cp -Rp $(GSL) build/gsl; fi -@(echo "================= `date`"; set -e -x; cd build/gsl; \ ./configure --prefix=$(G4BL_DIR) --disable-shared --enable-static; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/gsl/build.log 2>&1 @if test -r build/gsl/.complete; then echo Building GSL complete.; \ else echo 'Building GSL FAILED *****'; exit 1; fi build/fftw/.complete: @echo "Building FFTW... Log is $(PWD)/build/fftw/build.log" @if test ! -d build/fftw; then cp -Rp $(FFTW) build/fftw; fi -@(echo "================= `date`"; set -e -x; cd build/fftw; \ ./configure --prefix=$(G4BL_DIR) --disable-shared --enable-static \ --enable-float --disable-dependency-tracking \ --disable-fortran; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/fftw/build.log 2>&1 @if test -r build/fftw/.complete; then echo Building FFTW complete.; \ else echo 'Building FFTW FAILED *****'; exit 1; fi build/coin/.complete: @echo "Building Coin... Log is $(PWD)/build/coin/build.log" @if test ! -d build/coin; then cp -Rp $(COIN) build/coin; fi -@(echo "================= `date`"; set -e -x; cd build/coin; \ ./configure --prefix=$(G4BL_DIR) --enable-system-expat \ --without-openal --disable-sound --disable-shared \ --enable-static --disable-debug; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/coin/build.log 2>&1 @if test -r build/coin/.complete; then echo Building Coin complete.; \ else echo 'Building Coin FAILED *****'; exit 1; fi build/so/.complete: @echo "Building SoXt... Log is $(PWD)/build/so/build.log" @if test ! -d build/so; then cp -Rp $(SOXT) build/so; fi -@(echo "================= `date`"; set -e -x; cd build/so; \ if test ! -r Makefile; then \ ./configure --prefix=$(G4BL_DIR) --disable-shared \ --enable-static --disable-debug \ --disable-sound --with-coin=$(G4BL_DIR); \ fi; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/so/build.log 2>&1 @if test -r build/so/.complete; then echo Building SoXt complete.; \ else echo 'Building SoXt FAILED *****'; exit 1; fi build/root/.complete: @echo "Building Root... Log is $(PWD)/build/root/build.log" @if test ! -d build/root; then cp -Rp $(ROOT) build/root; fi @# make -j 4 may fail, but a second one succeeds, so use 3 of them -@(echo "================= `date`"; set -e -x; cd build/root; \ if test ! -r config.status; then ./configure; fi; \ make -j $(NCPU) || make -j $(NCPU) || make -j 1; \ cp -p lib/libCore.so $(G4BL_DIR)/lib; \ cp -p lib/libCint.so $(G4BL_DIR)/lib; \ cp -p lib/libMathCore.so $(G4BL_DIR)/lib; \ cp -p lib/libNet.so $(G4BL_DIR)/lib; \ cp -p lib/libRIO.so $(G4BL_DIR)/lib; \ cp -p lib/libThread.so $(G4BL_DIR)/lib; \ cp -p lib/libTree.so $(G4BL_DIR)/lib; \ if test ! -d $(G4BL_DIR)/include/root; then \ mkdir $(G4BL_DIR)/include/root; fi; \ cp -Rp include/* $(G4BL_DIR)/include/root; \ touch .complete; \ ) >>build/root/build.log 2>&1 @if test -r build/root/.complete; then echo Building Root complete.; \ else echo 'Building Root FAILED *****'; exit 1; fi # g4bl-config knows which libraries are needed by the configuration LIBS = $(shell $(G4BL_DIR)/bin/g4bl-config --libs) MAIN = $(shell $(G4BL_DIR)/bin/g4bl-config --main) bin/g4beamline: $(G4BLOBJS) $(SOURCE)/source/g4beamline.cc @echo Linking g4beamline @(set -e -x; \ $(CXX) -o bin/g4beamline $(CPPFLAGS) $(MAIN) $(G4BLOBJS) $(LIBS) \ ) >>build/g4beamline/build.log 2>&1 ### ### rule to compile G4beamline source and create its dependency file ### build/g4beamline/%.$(OBJEXT): $(SOURCE)/source/src/%.cc @echo Compiling `basename $<` @(set -e -x; \ $(CXX) $(CPPFLAGS) -c -o $@ $<; \ g++ $(CPPFLAGS) -MM -MP -MT $@ $< >$(patsubst %.$(OBJEXT),%.d,$@) \ ) >>build/g4beamline/build.log 2>&1 EOF cat <<\EOF >/tmp/$$.WIN32 ### ### Makefile for WIN32 ### CXX = cl CPPFLAGS += -DWIN32 build/clhep/.complete: @echo "Building CLHEP... Log is $(PWD)/build/clhep/build.log" @if test ! -d build/clhep; then cp -Rp $(CLHEP) build/clhep; fi -@(echo "================= `date`"; set -e -x; cd build/clhep; \ if test ! -r Makefile; then \ CLHEP/configure --disable-shared --prefix=$(G4BL_DIR); \ fi; \ make -j $(NCPU); \ make install; \ ../../test/test40; \ touch .complete; \ cd ../..; rm -f lib/CLHEP-*.* bin/[A-Z]*-config; \ ) >>build/clhep/build.log 2>&1 @if test -r build/clhep/.complete; then echo Building CLHEP complete.; \ else echo 'Building CLHEP FAILED *****'; exit 1; fi build/geant4/.complete: @echo "Building Geant4... Log is $(PWD)/build/geant4/build.log" @if test ! -d build/geant4; then mkdir build/geant4; fi -@(echo "================= `date`"; set -e -x; cd build/geant4; \ if test ! -r Makefile; then \ CXXFLAGS="-DCOIN_NOT_DLL -DSOWIN_NOT_DLL" cmake $(G4OPTS) \ `cygpath -m $(GEANT4)`; fi; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/geant4/build.log 2>&1 @if test -r build/geant4/.complete; then echo Building Geant4 complete.; \ else echo 'Building Geant4 FAILED *****'; exit 1; fi build/gsl/.complete: @echo "Building WinGSL... Log is $(PWD)/build/gsl/build.log" @if test ! -d build/gsl; then mkdir build/gsl; fi -@(echo "================= `date`"; set -e -x; cd build/gsl; \ cp -Rp $(WINGSL)/include/* $(G4BL_DIR)/include; \ cp -Rp $(WINGSL)/lib/* $(G4BL_DIR)/lib; \ touch .complete; \ ) >>build/gsl/build.log 2>&1 @if test -r build/gsl/.complete; then echo Building WinGSL complete.; \ else echo 'Building WinGSL FAILED *****'; exit 1; fi build/fftw/.complete: @echo "Building WinFFTW... Log is $(PWD)/build/fftw/build.log" @if test ! -d build/fftw; then mkdir build/fftw; fi -@(echo "================= `date`"; set -e -x; cd build/fftw; \ cp -Rp $(WINFFTW)/include/* $(G4BL_DIR)/include; \ cp -Rp $(WINFFTW)/lib/* $(G4BL_DIR)/lib; \ cp -Rp $(WINFFTW)/bin/* $(G4BL_DIR)/bin; \ touch .complete; \ ) >>build/fftw/build.log 2>&1 @if test -r build/fftw/.complete; then echo Building WinFFTW complete.; \ else echo 'Building WinFFTW FAILED *****'; exit 1; fi build/coin/.complete: @echo "Building Coin... Log is $(PWD)/build/coin/build.log" @if test ! -d build/coin; then cp -Rp $(COIN) build/coin; fi -@(echo "================= `date`"; set -e -x; cd build/coin; \ ./configure --prefix=$(G4BL_DIR) --enable-system-expat \ --without-openal --disable-sound --disable-shared \ --enable-static --disable-debug; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/coin/build.log 2>&1 @if test -r build/coin/.complete; then echo Building Coin complete.; \ else echo 'Building Coin FAILED *****'; exit 1; fi build/so/.complete: @echo "Building SoWin... Log is $(PWD)/build/so/build.log" @if test ! -d build/so; then cp -Rp $(SOWIN) build/so; fi -@(echo "================= `date`"; set -e -x; cd build/so; \ if test ! -r Makefile; then \ ./configure --prefix=$(G4BL_DIR) --disable-shared \ --enable-static --disable-debug --disable-sound \ --with-coin=$(shell cygpath -u $(G4BL_DIR)); \ fi; \ make -j $(NCPU); \ make install; \ touch .complete; \ ) >>build/so/build.log 2>&1 @if test -r build/so/.complete; then echo Building SoWin complete.; \ else echo 'Building SoWin FAILED *****'; exit 1; fi build/root/.complete: @echo "Building Root... Log is $(PWD)/build/root/build.log" @if test ! -d build/root; then cp -Rp $(ROOT) build/root; fi @# make -j 4 may fail, but a second one succeeds, so use 3 of them -@(echo "================= `date`"; set -e -x; cd build/root; \ if test ! -r config.status; then ./configure; fi; \ make -j $(NCPU) || make -j $(NCPU) || make -j 1; \ cp -p lib/libCore.* $(G4BL_DIR)/lib; \ cp -p lib/libCint.* $(G4BL_DIR)/lib; \ cp -p lib/libMathCore.* $(G4BL_DIR)/lib; \ cp -p lib/libNet.* $(G4BL_DIR)/lib; \ cp -p lib/libRIO.* $(G4BL_DIR)/lib; \ cp -p lib/libThread.* $(G4BL_DIR)/lib; \ cp -p lib/libTree.* $(G4BL_DIR)/lib; \ if test ! -d $(G4BL_DIR)/include/root; then \ mkdir $(G4BL_DIR)/include/root; fi; \ cp -Rp include/* $(G4BL_DIR)/include/root; \ cp -p bin/*.dll $(G4BL_DIR)/bin; \ touch .complete; \ ) >>build/root/build.log 2>&1 @if test -r build/root/.complete; then echo Building Root complete.; \ else echo 'Building Root FAILED *****'; exit 1; fi lib/.complete: build/expat/.complete build/expat/.complete: @echo "Building WinExpat... Log is $(PWD)/build/expat/build.log" @if test ! -d build/expat; then mkdir build/expat; fi -@(echo "================= `date`"; set -e -x; cd build/expat; \ cp -Rp $(WINEXPAT)/lib/* $(G4BL_DIR)/lib; \ cp -Rp $(WINEXPAT)/bin/* $(G4BL_DIR)/bin; \ touch .complete; \ ) >>build/expat/build.log 2>&1 @if test -r build/expat/.complete; then echo Building WinExpat complete.; \ else echo 'Building WinExpat FAILED *****'; exit 1; fi # g4bl-config knows which libraries are needed by the configuration LIBS = $(shell $(G4BL_DIR)/bin/g4bl-config --libs) MAIN = $(shell $(G4BL_DIR)/bin/g4bl-config --main) VCFLAGS = $(shell $(G4BL_DIR)/bin/g4bl-config --vcflags) bin/g4beamline: $(G4BLOBJS) $(SOURCE)/source/g4beamline.cc @echo Linking g4beamline @(set -e -x; \ $(CXX) $(VCFLAGS) /Febin/g4beamline $(CPPFLAGS) $(MAIN) $(G4BLOBJS) $(LIBS) \ ) >>build/g4beamline/build.log 2>&1 ### ### rule to compile G4beamline source and create its dependency file ### build/g4beamline/%.$(OBJEXT): $(SOURCE)/source/src/%.cc @echo Compiling `basename $<` @(set -e -x; \ $(CXX) $(VCFLAGS) $(CPPFLAGS) -c /Fo$@ $<; \ g++ $(CPPFLAGS) -MM -MP -MT $@ $< >$(patsubst %.$(OBJEXT),%.d,$@) \ ) >>build/g4beamline/build.log 2>&1 EOF ### ### Put in the SYSTEM-dependent Makefile ### cat /tmp/$$.$SYSTEM >>Makefile ### ### Display results to the user ### echo echo "Library versions used:" echo "CLHEP is $(basename $CLHEP)" echo "Geant4 is $(basename $GEANT4)" case $G4BL_ROOT in y) echo "Root is $(basename $ROOT)" ;; n) ;; bin) echo "Root is from $ROOT" ;; esac if test $G4BL_VISUAL = y then echo "Coin is $(basename $COIN)" if test $SYSTEM = WIN32 then echo "SoWin is $(basename $SOWIN)" else echo "SoXt is $(basename $SOXT)" fi fi if test $SYSTEM = WIN32 then echo "Gsl is $(basename $WINGSL)" echo "FFTW is $(basename $WINFFTW)" echo "Expat is $(basename $WINEXPAT)" else echo "Gsl is $(basename $GSL)" echo "FFTW is $(basename $FFTW)" echo "Expat is the system version" fi echo echo "G4beamline configuration complete." echo "Now do 'make'."