|
|
| |
EAPI="1" | EAPI="1" |
| |
inherit eutils fortran multilib versionator |
inherit eutils fortran multilib versionator toolchain-funcs |
| |
MY_P=${PN}$(replace_version_separator 3 .) | MY_P=${PN}$(replace_version_separator 3 .) |
| |
DESCRIPTION="CERN's detector description and simulation Tool" | DESCRIPTION="CERN's detector description and simulation Tool" |
HOMEPAGE="http://geant4.cern.ch/" |
HOMEPAGE="http://www.geant4.org/" |
| |
SRC_COM="http://geant4.web.cern.ch/geant4/support/source/" | SRC_COM="http://geant4.web.cern.ch/geant4/support/source/" |
SRC_URI="${SRC_COM}/${MY_P}.tar.gz" | SRC_URI="${SRC_COM}/${MY_P}.tar.gz" |
|
Lines 44-185
S="${WORKDIR}/${MY_P}"
|
Link Here
|
|---|
|
pkg_setup() { | pkg_setup() { |
FORTRAN="gfortran g77 ifc" | FORTRAN="gfortran g77 ifc" |
use geant3 && fortran_pkg_setup | use geant3 && fortran_pkg_setup |
|
eval unset ${!G4_*} |
} | } |
| |
src_unpack() { | src_unpack() { |
unpack ${A} | unpack ${A} |
cd "${S}" | cd "${S}" |
| |
# this patch sanitize the Configure script |
# TODO is this still needed? We are using emake below ... |
epatch "${FILESDIR}"/${P}-configure.patch |
|
epatch "${FILESDIR}"/${P}-no-source.patch |
|
|
|
# propagate user's make options |
|
sed -i \ |
|
-e "s/g4make=gmake/g4make=\"gmake ${MAKEOPTS}\"/" \ |
|
Configure || die "sed Configure failed" |
|
|
|
# propagate user's flags. | # propagate user's flags. |
sed -i \ | sed -i \ |
-e "s:\(CXXFLAGS*+=\)*-O2:\1 ${CXXFLAGS:--O2}:g" \ | -e "s:\(CXXFLAGS*+=\)*-O2:\1 ${CXXFLAGS:--O2}:g" \ |
-e "s:\(FCFLAGS*+=\)*-O2:\1 ${FFLAGS:--O2}:g" \ | -e "s:\(FCFLAGS*+=\)*-O2:\1 ${FFLAGS:--O2}:g" \ |
-e "s:\(CCFLAGS*+=\)*-O2:\1 ${CFLAGS:--O2}:g" \ | -e "s:\(CCFLAGS*+=\)*-O2:\1 ${CFLAGS:--O2}:g" \ |
config/sys/Linux* || die "flag substitution failed" | config/sys/Linux* || die "flag substitution failed" |
|
|
# libdir stuff |
|
sed -i \ |
|
-e "s:lib/geant4:$(get_libdir)/geant:g" \ |
|
Configure config/scripts/move.sh.SH \ |
|
|| die "multilib substitution failed" |
|
} |
|
|
|
g4ui_use() { |
|
local answer=$(use $1 && echo y || echo n) |
|
echo "-D g4ui_build_${2:-$1}_session=${answer} |
|
-D g4ui_use_${2:-$1}=${answer}" |
|
} |
|
|
|
g4vis_use() { |
|
local answer=$(use $1 && echo y || echo n) |
|
echo "-D g4vis_build_${2:-$1}_driver=${answer} |
|
-D g4vis_use_${2:-$1}=${answer}" |
|
} |
|
|
|
g4w_use() { |
|
local answer=$(use $1 && echo y || echo n) |
|
echo "-D g4w_use_${2:-$1}=${answer} |
|
-D g4wlib_use_${2:-$1}=${answer}" |
|
} | } |
| |
src_compile() { | src_compile() { |
|
export GEANT4_DIR="/usr/share/${PN}-${SLOT}" |
GEANT4_DIR=/usr/share/${PN}-${SLOT} |
|
GEANT4_DATA_DIR=${GEANT4_DIR}/data |
# these should always to be set |
|
# TODO icc untested |
# The Configure shell script saves its options |
[[ $(tc-getCXX) = ic*c ]] && export G4SYSTEM=Linux-icc \ |
# in .config/bin/*/config.sh |
|| export G4SYSTEM=Linux-g++ |
local myconf="$(g4vis_use opengl openglx)" |
export G4INSTALL="${S}" |
use opengl && myconf="${glconf} $(g4vis_use motif openglxm)" |
export G4INCLUDE="${D}/usr/include/${PN}" |
use data && myconf="${myconf} -D g4data=${GEANT4_DATA_DIR}" |
export CLHEP_BASE_DIR=/usr |
|
|
# switch to see compiling flags |
# where to put compiled libraries; |
|
# we set env var G4LIB in src_install() |
|
# to avoid confusing make |
|
export LIB_DIR_TMP="/usr/$(get_libdir)/${PN}" |
|
|
|
# parse USE; just set flags of drivers to build, G4*_USE_* vars are set |
|
# later automatically for G4*_BUILD_*_DRIVER |
|
use minimal && export G4UI_NONE=y \ |
|
&& export G4VIS_NONE=y |
|
|
|
use motif && export G4UI_BUILD_XM_SESSION=y |
|
use athena && export G4UI_BUILD_XAW_SESSION=y |
|
|
|
use dawn && export G4VIS_BUILD_DAWN_DRIVER=y |
|
use raytracerx && export G4VIS_BUILD_RAYTRACERX_DRIVER=y |
|
use openinventor && export G4VIS_BUILD_OI_DRIVER=y |
|
use opengl && export G4VIS_BUILD_OPENGLX_DRIVER=y |
|
use opengl && use motif && export G4VIS_BUILD_OPENGLXM_DRIVER=y |
|
|
|
use geant3 && export G4LIB_BUILD_G3TOG4=y |
|
use zlib && export G4LIB_BUILD_ZLIB=y |
|
use vrml && export G4VIS_BUILD_VRML_DRIVER=y \ |
|
&& export G4VIS_BUILD_VRMLFILE_DRIVER=y |
|
|
|
use data && export G4DATA="${GEANT4_DIR}/data" |
|
use debug && export G4DEBUG=y || export G4OPTIMIZE=y |
|
|
|
# switch to see compiling flags |
export CPPVERBOSE=y | export CPPVERBOSE=y |
use debug && export G4DEBUG=y || export G4OPTIMIZE=y |
|
|
# internal variables of ./Configure |
# to check what they are doing and working |
# -D d_portable \ # seems to be a local variable of ./Configure |
# -D d_portable \ |
# -D g4global=n \ # create few BIG global libraries |
# -D g4global=n \ |
# -D g4granular=y # create many small libraries for submodules (default) |
# -D g4granular=y |
# -D g4_use_granular=y # link against the BIG global library when compiling apps |
# -D g4_use_granular=y |
# TODO if we really want GLOBAL libraries (too), we would use |
# -D g4make=make \ |
# use global && emake global || die "Building global geant failed" |
|
# and set G4LIB_USE_GRANULAR=y in env.*sh |
./Configure \ |
|
-deE -build \ |
|
-D g4analysis_use=n \ |
|
-D g4includes_flag=y \ |
|
-D g4include="${D}/usr/include/geant4" \ |
|
-D g4final_install="${D}/usr" \ |
|
$(g4ui_use minimal none) \ |
|
$(g4ui_use athena xaw) \ |
|
$(g4ui_use motif xm) \ |
|
$(g4vis_use minimal none) \ |
|
$(g4vis_use dawn) \ |
|
$(g4vis_use raytracerx) \ |
|
$(g4vis_use openinventor oix) \ |
|
$(g4vis_use vrml) \ |
|
$(g4vis_use vrml vrmlfile) \ |
|
$(g4w_use geant3 g3tog4) \ |
|
$(g4w_use zlib) \ |
|
${myconf} \ |
|
${EXTRA_ECONF} \ |
|
|| die "Configure failed" |
|
| |
# if shared libs are built, the script will also build static libs | # if shared libs are built, the script will also build static libs |
# with pic flags | # with pic flags |
# avoid that by building it twice and removing temporary objects | # avoid that by building it twice and removing temporary objects |
|
cd "${S}/source/" |
./Configure \ |
export G4LIB_BUILD_SHARED=y |
-deO -build \ |
emake || die "Building shared geant failed" |
-D g4lib_build_shared=y \ |
|
-D g4lib_build_static=n \ |
|
|| die "Building shared geant failed" |
|
| |
if use static; then | if use static; then |
rm -rf tmp | rm -rf tmp |
./Configure \ |
export G4LIB_BUILD_STATIC=y ; unset G4LIB_BUILD_SHARED |
-deO -build \ |
emake || die "Building static geant failed" |
-D g4lib_build_shared=n \ |
|
-D g4lib_build_static=y \ |
|
|| die "Building shared geant failed" |
|
fi | fi |
} | } |
| |
|
g4_create_env_scripts() { |
|
# we need to change some variables to the final values since we hide these |
|
# from make during the compile |
|
export G4INSTALL="${GEANT4_DIR}" |
|
export G4LIB="${LIB_DIR_TMP}" |
|
export G4INCLUDE=`echo $G4INCLUDE | sed s:${D}::` |
|
|
|
export G4WORKDIR="/tmp/geant4"/ # TODO howto set it to e.g. $HOME/geant4 ? |
|
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${G4LIB}" >> "env.sh" |
|
echo "setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:${G4LIB}" >> "env.csh" |
|
echo "export CLHEP_BASE_DIR=$CLHEP_BASE_DIR" >> "env.sh" |
|
echo "setenv CLHEP_BASE_DIR $CLHEP_BASE_DIR" >> "env.csh" |
|
# read env variables defined upto now |
|
for v in `env | grep ^G4 | uniq`; do |
|
echo "export $v" >> "env.sh" # these are already set to "y" |
|
echo "setenv $v y" >> "env.csh" |
|
done |
|
# define env vars for capabilities we can build into user projects |
|
for v in `env | grep ^G4 | uniq | grep DRIVER | cut -d= -f1 | \ |
|
sed -e s~BUILD~USE~ -e s~_DRIVER~~` |
|
do |
|
echo "export $v=y" >> "env.sh" |
|
echo "setenv $v y" >> "env.csh" |
|
done |
|
} |
|
|
src_install() { | src_install() { |
./Configure \ |
# install headers via make since we want them in a single directory |
-install \ |
cd "${S}/source/" |
|| die "Install failed" |
emake includes || die 'Installing headers failed' |
|
cd "${S}" |
| |
./Configure \ |
# but install libraries and Geant library tool manually |
|| die "Final install failed" |
insinto "${LIB_DIR_TMP}" |
|
doins -r "lib/${G4SYSTEM}/"* |
|
exeinto "${LIB_DIR_TMP}" |
|
doexe "lib/${G4SYSTEM}/liblist" |
| |
# install env stuff |
# env scripts and configs |
# todo: try to decipher and translate into a env.d file |
|
insinto ${GEANT4_DIR} | insinto ${GEANT4_DIR} |
sed -i \ |
g4_create_env_scripts |
-e "s:${S}:${GEANT4_DIR}:g" \ |
|
-e "s:${D}:/:g" \ |
|
env.*sh |
|
doins env.*sh || die "failed installing shell scripts" | doins env.*sh || die "failed installing shell scripts" |
|
sed -i s~\$\(G4LIB\)/\$\(G4SYSTEM\)~\$\(G4LIB\)~g \ |
|
config/binmake.gmk || die "Adjusting paths failed" |
doins -r config | doins -r config |
| |
# install data | # install data |
insinto ${GEANT4_DATA_DIR} |
|
if use data; then | if use data; then |
|
insinto ${G4DATA} |
cd "${WORKDIR}" | cd "${WORKDIR}" |
for d in ${GEANT4_DATA}; do | for d in ${GEANT4_DATA}; do |
local p=${d/.} | local p=${d/.} |
doins -r *${p/G4} || die "installing data ${d} failed" | doins -r *${p/G4} || die "installing data ${d} failed" |
done | done |
|
cd "${S}" |
fi | fi |
| |
# doc and examples | # doc and examples |
|
|
| |
pkg_postinst() { | pkg_postinst() { |
elog "You can set the Geant4 environment variables" | elog "You can set the Geant4 environment variables" |
elog "from ${ROOT}${GEANT4_DIR} shell scripts." |
elog "from ${GEANT4_DIR} shell scripts." |
elog "Ex: for bash" | elog "Ex: for bash" |
elog " source ${ROOT}${GEANT4_DIR}/env.sh" |
elog " source ${GEANT4_DIR}/env.sh" |
elog | elog |
elog "Help us to improve the ebuild and dependencies in" | elog "Help us to improve the ebuild and dependencies in" |
elog "http://bugs.gentoo.org/show_bug.cgi?id=212221" | elog "http://bugs.gentoo.org/show_bug.cgi?id=212221" |