Import Geant4 8.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:55:03 +02:00
parent 216a75eeb1
commit fe73f43734
6714 changed files with 118229 additions and 68144 deletions
+101
View File
@@ -0,0 +1,101 @@
$Id: 00README,v 1.5 2006/08/09 06:26:23 kmura Exp $
==========================================================================
Geant4Py
Geant4Py is a set of python modules for using Geant4.
Tools package
In dafault situation, Geant4 creates and uses "granular static libraries".
But, Python interface requires "global shared library".
This directory contains some utility tools for helping build
Geant4 environment for using Python interface.
==========================================================================
env
---
Additonal setup script for co-building global shared libraries
A small setup script helps co-build global shared libraries,
in addition to an existing granular static environment.
g4autobuild
-----------
An automatic build tool. The tool takes care of multiple Geant4/CLHEP instances
(granular static libray, global static library and global shared library),
configuring visualization and UI environments. The building procedures
are fully automated, avoiding duplicated building processes.
A sample configuration file is as follows;
---------------------------------------------------------------------
#
# G4SYS
#
G4SYS Linux-g++
#
# Base directory of Geant4 builds
#
G4BASE /opt/heplib/Geant4
#
# Base directory of CLHEP
#
CLHEPBASE /opt/heplib/CLHEP
#
# G4 version and CLHEP version (starting with "-")
#
# G4 version CLHEP version
- geant4.8.1.p01 2.0.2.3
- geant4.8.1 2.0.2.3
#
# Visualization Options (starting with "v")
# G4VIS_BUILD_XXX_DRIVER and G4VIS_USE_XXX are activated.
#
v DAWN
v VRML
v RAYTRACERX_DRIVER
v OPENGLX
#
# UI Options (starting with "u")
# G4UI_USE_XXX is activated.
#
u TCSH
u GAG
---------------------------------------------------------------------
Users just specify the base directories of Geant4 and CLHEP,
and give combinations of their versions.
Then, type
$ ./g4autobuild
. A series of building processes will start.
The "status" directory will be created by the script. Note that null files
(named geant4-%version%-xxx) associated with tasks will be created in this
directory after finishing each task. These files works as flags for task status.
g4package
---------
A packaging tool. CLHEP and Geant4 libraries and headers are packed into
a specified directory. This script contains a special care for embedded
MacOSX(Mach-O) library paths. Using the packaged libraries makes free from
setting DYLD_LIBRARY_PATH in MacOSX, especially for CLHEP.
For example, on MacOSX,
$ ./g4pack --with-g4system=Darwin-g++ \
--with-g4-dir=/opt/heplib/Geant4/geant4.8.1.p01 \
--with-clhep-dir=/opt/heplib/CLHEP/2.0.2.3 \
--with-install-dir=/Library/Frameworks/Geant4.framework/Versions/8.1.1
creates new package in a "g4" directory. Then you can copy it to the framework
directory specified.
+30
View File
@@ -0,0 +1,30 @@
#$Id: env+.csh,v 1.2 2006/08/08 09:32:52 kmura Exp $
# ======================================================================
# [csh version]
# Additonal setup script for co-building global shared libraries
#
# In dafault situation, Geant4 creates and uses "granular static libraries".
# But, Python interface requires "global shared library".
# This small setup script helps co-build global shared libraries,
# in addition to an existing granular static environment.
#
# After sourcing "env.csh", which is created by the "Configure" script,
# source this file additionally, then "make global".
# Global shared library staffs will be created in another directory.
# ======================================================================
if (! $?G4INSTALL) then
echo "*** G4INSTALL is not defined! Please source env.csh first."
exit
endif
# Recompilation is necessary because position-independent codes (-fPIC option)
# shoud be required. The temporal directory should be different from
# the existing one.
setenv G4TMP $G4INSTALL/tmp-slib
# Under this directory, new global shared library staffs will be created.
setenv G4LIB $G4INSTALL/slib
setenv G4LIB_BUILD_SHARED 1
+30
View File
@@ -0,0 +1,30 @@
#$Id: env+.sh,v 1.2 2006/08/08 09:32:52 kmura Exp $
# ======================================================================
# [sh version]
# Additonal setup script for co-building global shared libraries
#
# In dafault situation, Geant4 creates and uses "granular static libraries".
# But, Python interface requires "global shared library".
# This small setup script helps co-build global shared libraries,
# in addition to an existing granular static environment.
#
# After sourcing "env.csh", which is created by the "Configure" script,
# source this file additionally, then "make global".
# Global shared library staffs will be created in another directory.
# ======================================================================
if [ ! ${G4INSTALL:+1} ]; then
echo "*** G4INSTALL is not defined! Please source env.csh first."
exit
fi
# Recompilation is necessary because position-independent codes (-fPIC option)
# shoud be required. The temporal directory should be different from
# the existing one.
export G4TMP=$G4INSTALL/tmp-slib
# Under this directory, new global shared library staffs will be created.
export G4LIB=$G4INSTALL/slib
export G4LIB_BUILD_SHARED=1
@@ -0,0 +1,44 @@
# ======================================================================
# Geant4 Autobuild Configuration
#
# A sample configuration
# ======================================================================
#
# G4SYS
#
G4SYS Linux-g++
#
# Base directory of Geant4 builds
#
G4BASE /opt/heplib/Geant4
#
# Base directory of CLHEP
#
CLHEPBASE /opt/heplib/CLHEP
#
# G4 version and CLHEP version (starting with "-")
#
# G4 version CLHEP version
- geant4.8.1.p01 2.0.2.3
- geant4.8.1 2.0.2.3
#
# Visualization Options (starting with "v")
# G4VIS_BUILD_XXX_DRIVER and G4VIS_USE_XXX are activated.
#
v DAWN
v VRML
v RAYTRACERX_DRIVER
v OPENGLX
#
# UI Options (starting with "u")
# G4UI_USE_XXX is activated.
#
u TCSH
u GAG
+286
View File
@@ -0,0 +1,286 @@
#! /bin/sh -
# ======================================================================
# A script for Geant4 autobuild
#
# [usage]
# g4autobuild [<options>]
#
# [options]
# --help, -h print this message
# --prefix=PREFIX base directory of Geant4 builds [$(cwd)/]
# --config=CONFIG configure file [PREFIX/g4auto.cfg]
# ======================================================================
export LANG=C
IFS='
'
PATH=/bin:/usr/bin
export PATH
# ======================================================================
# help message
# ======================================================================
show_help() {
cat <<EOF
[usage]
g4autobuild [<options>]
[options]
--help, -h print this message
--prefix=PREFIX root directory of autobuild [\$(PWD)/]
--config=CONFIG configure file [PREFIX/g4auto.cfg]
EOF
}
# ======================================================================
# vis. environment
# ======================================================================
add_vis_envs() {
avis=$1
# for bash
cat >> g4rc.sh <<EOF
export G4VIS_BUILD_${avis}_DRIVER=1
export G4VIS_USE_${avis}=1
EOF
# for csh
cat >> g4rc.csh <<EOF
setenv G4VIS_BUILD_${avis}_DRIVER 1
setenv G4VIS_USE_${avis} 1
EOF
}
# ======================================================================
# ui environment
# ======================================================================
add_ui_envs() {
aui=$1
# for bash
cat >> g4rc.sh <<EOF
export G4UI_USE_${aui}=1
EOF
# for csh
cat >> g4rc.csh <<EOF
setenv G4UI_USE_${aui} 1
EOF
}
# ======================================================================
# main
# ======================================================================
# default values
prefix=`pwd`
config=$prefix/g4auto.cfg
status_dir=$prefix/status
# parsing options
while test $# -gt 0
do
case $1 in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--help|-h) show_help; exit 0 ;;
# ---------------------------------------------------------------
--prefix=*) prefix=$optarg ;;
--config=*) config=$optarg ;;
# ---------------------------------------------------------------
-*)
echo "Unrecognized option: $1"
exit -1
;;
*)
echo "Invalid argument: $1"
exit -1
;;
esac
shift
done
# check something
if [ ! -d $prefix ]; then
echo "*** abort :$prefix does not exist."
exit -1
fi
if [ ! -e $config ]; then
echo "*** abort :$config does not exist."
exit -1
fi
if [ ! -d $status_dir ]; then
echo "$status_dir does not exist. It is created."
mkdir $status_dir
fi
# ======================================================================
# parsing a config file...
# ======================================================================
g4sys=`grep '^G4SYS' $config | awk '{print $2}'`
g4base=`grep '^G4BASE' $config | awk '{print $2}'`
clhepbase=`grep '^CLHEPBASE' $config | awk '{print $2}'`
geant4_set=`grep '^-' $config | awk '{print $2}'`
clhep_set=( `grep '^-' $config | awk '{print $3}'` )
vis_set=`grep '^v' $config | awk '{print $2}'`
ui_set=`grep '^u' $config | awk '{print $2}'`
if [ ! -d $g4base ]; then
echo "*** abort :$g4base does not exist."
exit -1
fi
if [ ! -d $clhepbase ]; then
echo "*** abort :$clhepbase does not exist."
exit -1
fi
# ======================================================================
# building Geant4
idx=0
for g4 in $geant4_set
do
echo "@@@ building Geant4 ($g4) ..."
g4dir=$g4base/$g4
if [ ! -d $g4dir ]; then
echo "*** (error) target directory does not exist."
exit -1
fi
pushd $g4dir >& /dev/null
cat > g4rc.sh << EOF
# ========================================================================
# Geant4 development environment
# ========================================================================
export LANG=C
# ========================================================================
# System
# ========================================================================
export G4SYSTEM=$g4sys
export G4INSTALL=$g4base/$g4
export CLHEP_BASE_DIR=$clhepbase/${clhep_set[$idx]}
# ========================================================================
# Visualization
# ========================================================================
EOF
cat > g4rc.csh << EOF
# ========================================================================
# Geant4 development environment
# ========================================================================
setenv LANG C
# ========================================================================
# System
# ========================================================================
setenv G4SYSTEM $g4sys
setenv G4INSTALL $g4base/$g4
setenv CLHEP_BASE_DIR $clhepbase/${clhep_set[$idx]}
# ========================================================================
# Visualization
# ========================================================================
EOF
# vis. envs
for vis in $vis_set
do
add_vis_envs $vis
done
cat >> g4rc.sh <<EOF
# ========================================================================
# UI
# ========================================================================
EOF
cat >> g4rc.csh <<EOF
# ========================================================================
# UI
# ========================================================================
EOF
# ui envs
for ui in $ui_set
do
add_ui_envs $ui
done
# ======================================================================
# ok, Lets' build...
. g4rc.sh
# ======================================================================
# normal lib
if [ ! -e $status_dir/$g4.lib ]; then
echo "@@@ building normal lib ..."
pushd source >& /dev/null
make >& make.log
make includes >& /dev/null
popd >& /dev/null
touch $status_dir/$g4.lib
fi
# ======================================================================
# global lib
if [ ! -e $status_dir/$g4.glib ]; then
echo "@@@ buinding global lib ..."
export G4LIB=$G4INSTALL/glib
pushd source >& /dev/null
make global >& make-global.log
popd >& /dev/null
touch $status_dir/$g4.glib
fi
# ======================================================================
# shared lib
if [ ! -e $status_dir/$g4.slib ]; then
echo "@@@ buinding shared lib ..."
export G4LIB=$G4INSTALL/slib
if [ $g4sys == Darwin-g++ ]; then
export G4TMP=$G4INSTALL/tmp
else
export G4TMP=$G4INSTALL/tmp-slib
fi
export G4LIB_BUILD_SHARED=1
pushd source >& /dev/null
make global >& make-slib.log
popd >& /dev/null
touch $status_dir/$g4.slib
fi
# ======================================================================
# done
unset G4LIB
unset G4TMP
unset G4LIB_BUILD_SHARED
popd >& /dev/null
echo $((idx++)) >& /dev/null
done
exit 0
+242
View File
@@ -0,0 +1,242 @@
#! /bin/sh -
# ======================================================================
# A script for Geant4 packaging
#
# ======================================================================
export LANG=C
IFS='
'
PATH=/bin:/usr/bin
export PATH
# ======================================================================
# help message
# ======================================================================
show_help() {
cat <<EOF
Usage: g4pack [<options>]
Options:
--help, -h print this message
--with-g4system=G4SYSTEM G4SYSTEM [\$G4SYSTEM]
--with-g4-dir=DIR Geant4 dir [\$G4INSTALL]
--with-clhep-dir=DIR CLHEP dir [\$CLHEP_BASE_DIR]
--with-lib-dir=DIR G4 static granular libdir [lib]
--with-glib-dir=DIR G4 global static libdir [glib]
--with-slib-dir=DIR G4 global shared libdir [slib]
--with-install-dir=DIR install path (MacOSX only)
Enable/disable options: prefix with either --enable- or --disable-
lib packing static granular lib [disable]
glib packing global static lib [enable]
slib packing global shared lib [enable]
EOF
}
# ======================================================================
# rebuild shared library (MacOSX only)
# ======================================================================
rebuild_sharedlib() {
mkdir tmp
mv lib*.dylib ./tmp
liblist=lib*.a
for lib in $liblist
do
slibname=${lib%.*}.dylib
#check linked libraries...
extliblist=`otool -L tmp/$slibname | grep -v /usr/lib | grep -v $slibname | awk '{print $1}'`
ar x $lib
g++ -dynamiclib -single_module -undefined dynamic_lookup \
-install_name $install_dir/lib/$slibname \
$extliblist -o $slibname *.o
rm *.o __.SYMDEF
chmod 755 $slibname
done
rm -r tmp
}
# ======================================================================
# main
# ======================================================================
# default values
g4system=${G4SYSTEM:-XXX}
g4dir=${G4INSTALL:-/zzz}
clhepdir=${CLHEP_BASE_DIR:-/zzz}
install_dir=/zzz
libdir=lib
glibdir=glib
slibdir=slib
enable_lib=0
enable_glib=1
enable_slib=1
# parsing options
while test $# -gt 0
do
case $1 in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--help|-h) show_help; exit 0 ;;
# ---------------------------------------------------------------
--with-g4system=*) g4system=$optarg ;;
--with-g4-dir=*) g4dir=$optarg ;;
--with-clhep-dir=*) clhepdir=$optarg ;;
--with-lib-dir=*) libdir=$optarg ;;
--with-glib-dir=*) glibdir=$optarg ;;
--with-slib-dir=*) slibdir=$optarg ;;
--with-install-dir=*) install_dir=$optarg ;;
# ---------------------------------------------------------------
--enable-lib ) enable_lib=1 ;;
--disable-lib ) enable_lib=0 ;;
--enable-glib ) enable_glib=1 ;;
--disable-glib ) enable_glib=0 ;;
--enable-slib ) enable_slib=1 ;;
--disable-slib ) enable_slib=0 ;;
# ---------------------------------------------------------------
-*)
echo "Unrecognized option: $1"
exit -1
;;
*)
echo "Invalid argument: $1"
exit -1
;;
esac
shift
done
# check something
shlib=so
if [ $g4system == Darwin-g++ ]; then
shlib=dylib
fi
echo -n "Checking for G4 dir ..."
if [ ! -d $g4dir ]; then
echo "no"
echo "### $g4dir does not exist."
exit -1
fi
echo $g4dir
echo -n "Checking for CLHEP dir ..."
if [ ! -d $clhepdir ]; then
echo "no"
echo "### $clhepdir does not exist."
exit -1
fi
echo $clhepdir
echo -n "Checking for G4SYSTEM ..."
if [ ! -e $g4dir/config/sys/$g4system.gmk ]; then
echo "no"
echo "### $g4system is invalid."
exit -1
fi
echo $g4system
if [ $enable_lib == 1 ]; then
echo -n "Checking for lib dir ..."
if [ ! -d $g4dir/$libdir ]; then
echo "no"
echo "### $libdir is invalid."
exit -1
fi
echo $libdir
fi
if [ $enable_glib == 1 ]; then
echo -n "Checking for glib dir ..."
if [ ! -d $g4dir/$glibdir ]; then
echo "no"
echo "### $glibdir is invalid."
exit -1
fi
echo $glibdir
fi
if [ $enable_slib == 1 ]; then
echo -n "Checking for glib dir ..."
if [ ! -d $g4dir/$slibdir ]; then
echo "no"
echo "### $slibdir is invalid."
exit -1
fi
echo $slibdir
fi
# ----------------------------------------------------------------------
# ok go ahead
echo ""
echo "Packing ..."
g4packdir=g4
if [ -d $g4packdir ]; then
echo "### $g4packdir/ already exist. Please move it."
exit -1
fi
mkdir -p $g4packdir
mkdir -p $g4packdir/include
mkdir -p $g4packdir/lib
# CLHEP
cp -pR $clhepdir/include/CLHEP $g4packdir/include/
cp -pR $clhepdir/lib/libCLHEP-[12]* $g4packdir/lib/
# Geant4
cp -pR $g4dir/include $g4packdir/include/
mv $g4packdir/include/include $g4packdir/include/Geant4
rm $g4packdir/include/Geant4/README
if [ $enable_glib == 1 ]; then
cp -pR $g4dir/$glibdir/$g4system/lib* $g4packdir/lib
fi
if [ $enable_slib == 1 ]; then
cp -pR $g4dir/$slibdir/$g4system/lib* $g4packdir/lib
if [ $g4system == Darwin-g++ ]; then
if [ $enable_glib == 0 ]; then
echo "### gobal static library is required for the operation."
exit -1
fi
pushd $g4packdir/lib >& /dev/null
rebuild_sharedlib
popd >& /dev/null
fi
fi
if [ $enable_lib == 1 ]; then
cp -pR $g4dir/$libdir/$g4system/lib* $g4packdir/lib
fi
# CLHEP links
pushd $g4packdir/lib >& /dev/null
ln -s libCLHEP-[12]*.a libCLHEP.a
ln -s libCLHEP-[12]*.$shlib libCLHEP.$shlib
popd >& /dev/null
exit 0