forked from ClarkMcGrew/edep-sim
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.sh
106 lines (91 loc) · 2.83 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
#
# Setup the edep-sim directory for development (or simply running the
# simulation). This makes sure that the ROOT and GEANT4 environment
# variables are set (using thisroot.sh and geant4.sh), and then
# defines a couple of conveniences commands:
#
# edep-build == Source ./build/edep-build.sh which will conveniently
# run cmake/make/make install from any place so that it's
# really easy to recompile.
#
# edep-setup == Source this file. You probably never have to use
# this one.
#
# This setup script is not needed. You can also do it by hand. It's
# a usual cmake build, but you need to make sure root and geant are
# "in the path".
#
# source thisroot.sh
# source geant4.sh
# cd the-build-directory
# cmake -DCMAKE_INSTALL_PREFIX=the-install-directory the-edep-sim-directory
# make
# make install
# Try to setup root. ROOT installs thisroot.sh in the bin directory
# to setup the environment. The first "thisroot.sh" in the path will
# define the root that is used.
. thisroot.sh >& /dev/null
if [ $? != 0 ]; then
echo ROOT not available.
fi
# Try to setup geant4. GEANT4 installs geant4.sh in the bin directory
# to setup the environment. The first "geant4.sh" in the path will
# define the geant that is used.
. geant4.sh >& /dev/null
if [ $? != 0 ]; then
echo GEANT not available.
fi
# Find the root of the building area.
___edep_root() {
COUNT=50
while true; do
if [ -e ./build -a -d ./build -a -e ./build/edep-build.sh ]; then
echo ${PWD}
return
fi
COUNT=$(expr ${COUNT} - 1)
if [ ${COUNT} -lt 1 ]; then
echo invalid-directory
return
fi
cd ..
done
}
export EDEP_ROOT
EDEP_ROOT=$(___edep_root)
unset -f ___edep_root
if [ ${EDEP_ROOT} = "invalid-directory" ]; then
echo EDEP-SIM setup.sh must be sourced in edep-sim directory.
return
fi
___edep_target () {
target="edep"
compiler=gcc
target="${target}-${compiler}-$(cc -dumpversion)-$(cc -dumpmachine)"
echo $target
}
export EDEP_TARGET
EDEP_TARGET=$(___edep_target)
unset -f ___edep_target
___path_prepend () {
___path_remove $1 $2
eval export $1="$2:\$$1"
}
___path_remove () {
export $1=$(eval echo -n \$$1 | \
awk -v RS=: -v ORS=: '$0 != "'$2'"' | \
sed 's/:$//');
}
___path_prepend PATH ${EDEP_ROOT}/${EDEP_TARGET}/bin
___path_prepend LD_LIBRARY_PATH ${EDEP_ROOT}/${EDEP_TARGET}/lib
# Uncomment the next line to automatically add edep-sim to the cmake path
# ___path_prepend CMAKE_PREFIX_PATH ${EDEP_ROOT}/${EDEP_TARGET}
unset -f ___path_prepend
unset -f ___path_remove
alias edep-setup=". ${EDEP_ROOT}/setup.sh"
alias edep-build="${EDEP_ROOT}/build/edep-build.sh"
echo Declare edep-sim to cmake using
echo " $" export CMAKE_PREFIX_PATH='${EDEP_ROOT}/${EDEP_TARGET}'
echo Defined edep-setup to re-setup the edep-sim package.
echo Defined edep-build to build the the edep-sim package.