~mbogomilov/maus/devel2

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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/bin/bash
# Configure script

# This is the maximum length of text (ignoring whitespace), 50 chars
##################################################
# this is the maximum amount of characters (including whitespace) per line)
######################################################################


arch=`uname -s`

DYLIB_VAR=LD_LIBRARY_PATH  # DYLIB_VAR is LD_LIBRARY_PATH for Linux.  Substituted into env.sh.
if [ "$arch" = "Darwin" ]; then
    DYLIB_VAR=DYLD_LIBRARY_PATH  # else for Mac OSX it's DYLD_LIBRARY_PATH

    echo "WARNING: You are using Mac OSX.  However, the version that MICE uses";
    echo "WARNING: of Recpack does not work on Mac OSX.  Please consult the";
    echo "WARNING: following link to install a Mac OSX version of Recpack:";
    echo "WARNING:";
    echo "WARNING:   http://micewww.pp.rl.ac.uk/projects/maus/wiki/InstallMacOSX";
    echo "WARNING:";
    echo "WARNING: and realize that you may not publish results with unoffical";
    echo "WARNING: versions of Recpack.";
    echo "WARNING: ";
fi

            ##################################################
echo "INFO: This is the './configure' script.  You should only"
echo "INFO: run this once. The purpose of me is to:"
echo "INFO:"
echo "INFO:     1. Check that you have a compiler"
echo "INFO:     2. Check that you have Python"
echo "INFO:     3. Check your version of Python is supported"
echo "INFO:     4. Create a file called 'env.sh'"
echo "INFO:"
echo

# Check for g++ ##################################################
(type -P gcc &>/dev/null && type -P g++ &>/dev/null) || {
    echo "FATAL: gcc/g++ is required to compile code." >&2;
    exit 1; }

# Find where MAUS is installed
maus_root_dir=`pwd`

if echo $maus_root_dir | grep -E '[ "]' >/dev/null;
then
    echo "FATAL: No whitespace allowed in directory names.">&2;
    echo "FATAL:">&2;
    echo "FATAL: See:" >&2;
    echo "FATAL:" >&2;
    echo "FATAL: http://micewww.pp.rl.ac.uk:8080/issues/306" >&2;
    exit 1;
fi

# Assign the location of the third party libraries  
# In order of preference the location is set to:
# 1. The first command line argument passed to the configure script
# 2. Any existing environment variable called "maus_third_party" e.g. if set by user's .bashrc file
# 3. The current maus working directory, as held by the variable maus_root_dir  
if [ "$1" ]; then
    #if a command line argument is entered, set third party directory from it - 
    #cd $1; pwd forces to absolute path; -P gives physical path (no links)
    maus_third_party=`cd $1; pwd -P`
elif [ -z "${maus_third_party}" ]; then
    maus_third_party=${maus_root_dir} #if not set above or anywhere else use the local maus working directory
fi

# Temporarily setup the environment (this gets repeated in the env.sh output)
#      maus_central says where the precompiled third party libraries are (if any)
#      PATH says where the binaries are
#      DYLIB_VAR says where your shared libraries are
if [ "${maus_third_party}" ]; then
    echo "INFO: Attempting to use third party libraries from " ${maus_third_party}
    echo
    if [ -z "${PATH}" ]; then  # see if the variable exists yet
        PATH="${maus_third_party}/third_party/install/bin"       # if not, initialize it
    else
        PATH="${maus_third_party}/third_party/install/bin:$PATH" # else add to it
    fi

    if [ -z "${!DYLIB_VAR}" ]; then  # see if the variable exists yet
        eval ${DYLIB_VAR}="${maus_third_party}/third_party/install/lib"                  # if not, initialize it
    else
        eval ${DYLIB_VAR}="${maus_third_party}/third_party/install/lib:${!DYLIB_VAR}" # else add to to it
    fi
else
    if [ -z "${PATH}" ]; then  # see if the variable exists yet
        PATH="${maus_root_dir}/third_party/install/bin"       # if not, initialize it
    else
        PATH="${maus_root_dir}/third_party/install/bin:$PATH" # else add to it
    fi

    if [ -z "${!DYLIB_VAR}" ]; then  # see if the variable exists yet
        eval ${DYLIB_VAR}="${maus_root_dir}/third_party/install/lib"                  # if not, initialize it
    else
        eval ${DYLIB_VAR}="${maus_root_dir}/third_party/install/lib:${!DYLIB_VAR}" # else add to to it
    fi
fi

# Check for Python
type -P python &>/dev/null || {
    echo "FATAL: Python is required.">&2;
    echo "FATAL:">&2;
    echo "FATAL: To install within MAUS, set the MAUS_ROOT_DIR" >&2;
    echo "FATAL: environmental variable.  For Bourne-compatible" >&2;
    echo "FATAL: shells like 'bash', run:" >&2;
    echo "FATAL:" >&2;
    echo "FATAL:      export MAUS_ROOT_DIR=\"${maus_root_dir}\"" >&2;
    echo "FATAL:" >&2;
    echo "FATAL: then run the following to install Python 2.7:" >&2;
    echo "FATAL:" >&2;
    echo "FATAL:      ./third_party/bash/01python.bash" >&2;
    exit 1; }

python_version=`env $DYLIB_VAR=./third_party/install/lib python -V 2>&1`
## Check for supported python version
if [ "${python_version}" != "Python 2.7" ]
then               ##################################################
    if [ ! -f "env.sh" ]
    then
        echo "WARNING: Unsupported python version (You are using ${python_version}),";
        echo "WARNING: so using Python 2.7 is recommended.  MAUS will install extra";
        echo "WARNING: packages in this location like numpy and xboa and currently";
        echo "WARNING: the way we go about this is having our own Python install.";
        echo "WARNING: ";
        echo "WARNING: To install within MAUS, set the MAUS_ROOT_DIR";
        echo "WARNING: environmental variable.  For Bourne-compatible";
        echo "WARNING: shells like 'bash', run:";
        echo "WARNING: ";
        echo "WARNING:       export MAUS_ROOT_DIR=\"${maus_root_dir}\"";
        echo "WARNING: ";
        echo "WARNING: then run the following to install Python 2.7:"
        echo "WARNING: ";
        echo "WARNING:       ./third_party/bash/01python.bash";
        echo
    fi
fi

# check for SCons
type -P scons &>/dev/null || {
    if [ ! -f "env.sh" ]
    then
        echo "WARNING: Scons is required to proceed after this step"
        echo "WARNING:"
        echo "WARNING: To install within MAUS, set the MAUS_ROOT_DIR";
        echo "WARNING: environmental variable.  For Bourne-compatible";
        echo "WARNING: shells like 'bash', run:";
        echo "WARNING: ";
        echo "WARNING:       export MAUS_ROOT_DIR=\"${maus_root_dir}\"";
        echo "WARNING: ";
        echo "WARNING: then run the following to install Scons:" >&2;
        echo "WARNING:" >&2;
        echo "WARNING:      ./third_party/bash/40python_extras.bash";
        echo "WARNING:";
        echo
    fi
    }


root_version=root_v5.30.03

if [ ! -f "env.sh" ]
then
    echo "RECOMMENDATION:  This appears to be your first time running MAUS."
    echo "RECOMMENDATION:  If you want to install all the external dependencies"
    echo "RECOMMENDATION:  automatically (takes an hour or so since geant is big)"
    echo "RECOMMENDATION:  then run the following command:"
    echo "RECOMMENDATION:"
    echo "RECOMMENDATION:       ./tests/integration/install_then_build_then_test.bash"
    echo "RECOMMENDATION:"
    echo
fi


### Create environment files

cat > env.sh <<EOF
#/bin/sh

############################## DO NOT EDIT #####################################
# This file was automatically generated by the script
# ${maus_root_dir}/configure
################################################################################

if [ -z "\$MAUS_ROOT_DIR" ]; then

     export MAUS_ROOT_DIR="${maus_root_dir}"

     export MAUS_THIRD_PARTY="${maus_third_party}"
     echo "INFO: Using third party libraries from ${maus_third_party}"

     maus_bin_dirs="\${MAUS_THIRD_PARTY}/third_party/install/bin"
     if [ "$arch" == "Darwin" ]; then
         maus_bin_dirs="\${MAUS_THIRD_PARTY}/third_party/install/Python.framework/Versions/2.7/bin:\${maus_bin_dirs}"
     fi

     if [ -z "\${PATH}" ]; then  # see if the variable exists yet
         export PATH="\${maus_bin_dirs}" # initialize it
     else
         export PATH="\${maus_bin_dirs}:\${PATH}" # else add it
     fi

     maus_lib_dirs="\${MAUS_THIRD_PARTY}/third_party/install/lib"
     if [ "$arch" == "Darwin" ]; then
         maus_lib_dirs="\${MAUS_THIRD_PARTY}/third_party/install/Python.framework/Versions/2.7/lib:\${maus_lib_dirs}"
     fi

     if [ -z "\${$DYLIB_VAR}" ]; then  # see if the variable exists yet
          export $DYLIB_VAR="\${maus_lib_dirs}" # intiailize it
     else
          export $DYLIB_VAR="\${maus_lib_dirs}:\${$DYLIB_VAR}" # else add it
     fi

     if [ -z "\${PYTHONPATH}" ]; then  # see if the variable exists yet
          export PYTHONPATH="\$MAUS_ROOT_DIR/build" #initialize it
     else
          export PYTHONPATH="\$MAUS_ROOT_DIR/build:\$PYTHONPATH" # else add it
     fi

     export $DYLIB_VAR="\$MAUS_THIRD_PARTY/build:\$$DYLIB_VAR"
     export $DYLIB_VAR="\$MAUS_ROOT_DIR/build:\$$DYLIB_VAR"

     # maus common
     export PYTHONPATH="\$MAUS_ROOT_DIR/src/common_py:\$PYTHONPATH"
     export $DYLIB_VAR="\$MAUS_ROOT_DIR/src/common_py:\$$DYLIB_VAR"

     # Celery
     export CELERY_CONFIG_MODULE="mauscelery.celeryconfig"

     export G4DEBUG=1
     export G4VERS=geant4.9.2.p04
     export G4SYSTEM=$arch-g++
     export G4INSTALL="\${MAUS_THIRD_PARTY}/third_party/build/\${G4VERS}"
     export G4LIB="\${G4INSTALL}/lib"
     export $DYLIB_VAR="\${G4LIB}/\${G4SYSTEM}:\${$DYLIB_VAR}"
     export G4INCLUDE="\${G4INSTALL}/include/"
     export G4TMP="\${G4INSTALL}"
     export G4VIS_BUILD_DAWNFILE_DRIVER=1
     export G4VIS_USE_DAWNFILE=1
     export G4VIS_USE=0
     export G4OPTIMISE=2
     export OGLHOME=/usr/X11R6
     export G4LEDATA="\${G4INSTALL}/data/G4EMLOW6.2/"
     export G4ABLADATA="\${G4INSTALL}/data/G4ABLA3.0/"
     export G4NEUTRONDATA="\${G4INSTALL}/data/G4NDL3.13/"
     export G4LEVELGAMMADATA"=\${G4INSTALL}/data/PhotonEvaporation2.0/"
     export G4RADIOACTIVEDATA"=\${G4INSTALL}/data/RadioactiveDecay3.2/"

     export MICEFILES="\${MAUS_ROOT_DIR}/src/legacy/FILES"

     export maus_no_optimize=0 # force gcc not to optimise
     export maus_lcov=0 # enable cpp coverage - requires lcov
     export maus_debug=0 # enable debugging
     export maus_gprof=0 # enable cpp profiling of cpp unit tests 
                         # requires gprof

     echo "SUCCESS: MAUS setup"
else
     echo "WARNING: MAUS already setup"
fi

# setup ROOT
if [ -f \${MAUS_THIRD_PARTY}/third_party/build/$root_version/bin/thisroot.sh ]
then
     source \${MAUS_THIRD_PARTY}/third_party/build/$root_version/bin/thisroot.sh
fi

EOF

echo "SUCCESS: Whenever you want to use MAUS, you must 'source'"
echo "SUCCESS: the environmental variables file.  For Bourne-"
echo "SUCCESS: compatible shells like 'bash', run:"
echo "SUCCESS:"
echo "SUCCESS:      source env.sh"
echo "SUCCESS:"
echo "SUCCESS: which can be added to your respective shell's"
echo "SUCCESS: startup scripts.  Example: ~/.bashrc for 'bash'."