~gkafka/maus/devel

7 by tunnell
cleanup of initial setup
1
#!/bin/bash
2
# Configure script
3
208 by Christopher Tunnell
c shell support
4
# This is the maximum length of text (ignoring whitespace), 50 chars
299 by Christopher Tunnell
closes #306
5
##################################################
208 by Christopher Tunnell
c shell support
6
# this is the maximum amount of characters (including whitespace) per line)
7
######################################################################
8
9
459 by Chris Rogers
Broken configure file
10
arch=`uname -s`
11
12
DYLIB_VAR=LD_LIBRARY_PATH  # DYLIB_VAR is LD_LIBRARY_PATH for Linux.  Substituted into env.sh.
13
if [ "$arch" = "Darwin" ]; then
14
    DYLIB_VAR=DYLD_LIBRARY_PATH  # else for Mac OSX it's DYLD_LIBRARY_PATH
15
16
    echo "WARNING: You are using Mac OSX.  However, the version that MICE uses";
17
    echo "WARNING: of Recpack does not work on Mac OSX.  Please consult the";
18
    echo "WARNING: following link to install a Mac OSX version of Recpack:";
19
    echo "WARNING:";
20
    echo "WARNING:   http://micewww.pp.rl.ac.uk/projects/maus/wiki/InstallMacOSX";
21
    echo "WARNING:";
22
    echo "WARNING: and realize that you may not publish results with unoffical";
23
    echo "WARNING: versions of Recpack.";
24
    echo "WARNING: ";
25
fi
26
208 by Christopher Tunnell
c shell support
27
            ##################################################
28
echo "INFO: This is the './configure' script.  You should only"
29
echo "INFO: run this once. The purpose of me is to:"
30
echo "INFO:"
71 by Christopher Tunnell
refs #139
31
echo "INFO:     1. Check that you have a compiler"
32
echo "INFO:     2. Check that you have Python"
33
echo "INFO:     3. Check your version of Python is supported"
485 by Christopher Tunnell
remove csh from maus closes #416
34
echo "INFO:     4. Create a file called 'env.sh'"
46 by Christopher Tunnell
refiddling build system
35
echo "INFO:"
45 by Christopher Tunnell
tweaking
36
echo
37
299 by Christopher Tunnell
closes #306
38
# Check for g++ ##################################################
208 by Christopher Tunnell
c shell support
39
(type -P gcc &>/dev/null && type -P g++ &>/dev/null) || {
40
    echo "FATAL: gcc/g++ is required to compile code." >&2;
41
    exit 1; }
71 by Christopher Tunnell
refs #139
42
45 by Christopher Tunnell
tweaking
43
# Find where MAUS is installed
44
maus_root_dir=`pwd`
45
301 by Christopher Tunnell
#300 refix
46
if echo $maus_root_dir | grep -E '[ "]' >/dev/null;
299 by Christopher Tunnell
closes #306
47
then
48
    echo "FATAL: No whitespace allowed in directory names.">&2;
49
    echo "FATAL:">&2;
50
    echo "FATAL: See:" >&2;
51
    echo "FATAL:" >&2;
52
    echo "FATAL: http://micewww.pp.rl.ac.uk:8080/issues/306" >&2;
53
    exit 1;
54
fi
55
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
56
# Assign the location of the third party libraries  
57
# In order of preference the location is set to:
58
# 1. The first command line argument passed to the configure script
59
# 2. Any existing environment variable called "maus_third_party" e.g. if set by user's .bashrc file
60
# 3. The current maus working directory, as held by the variable maus_root_dir  
61
if [ "$1" ]; then
62
    maus_third_party=$1 #if a command line argument is entered, set third party directory from it
63
elif [ -z "${maus_third_party}" ]; then
64
    maus_third_party=${maus_root_dir} #if not set above or anywhere else use the local maus working directory
65
fi
66
45 by Christopher Tunnell
tweaking
67
# Temporarily setup the environment (this gets repeated in the env.sh output)
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
68
#      maus_central says where the precompiled third party libraries are (if any)
45 by Christopher Tunnell
tweaking
69
#      PATH says where the binaries are
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
70
#      DYLIB_VAR says where your shared libraries are
71
if [ "${maus_third_party}" ]; then
72
    echo "INFO: Attempting to use third party libraries from " ${maus_third_party}
73
    echo
74
    if [ -z "${PATH}" ]; then  # see if the variable exists yet
75
        PATH="${maus_third_party}/third_party/install/bin"       # if not, initialize it
76
    else
77
        PATH="${maus_third_party}/third_party/install/bin:$PATH" # else add to it
78
    fi
79
80
    if [ -z "${!DYLIB_VAR}" ]; then  # see if the variable exists yet
81
        eval ${DYLIB_VAR}="${maus_third_party}/third_party/install/lib"                  # if not, initialize it
82
    else
83
        eval ${DYLIB_VAR}="${maus_third_party}/third_party/install/lib:${!DYLIB_VAR}" # else add to to it
84
    fi
85
else
86
    if [ -z "${PATH}" ]; then  # see if the variable exists yet
87
        PATH="${maus_root_dir}/third_party/install/bin"       # if not, initialize it
88
    else
89
        PATH="${maus_root_dir}/third_party/install/bin:$PATH" # else add to it
90
    fi
91
92
    if [ -z "${!DYLIB_VAR}" ]; then  # see if the variable exists yet
93
        eval ${DYLIB_VAR}="${maus_root_dir}/third_party/install/lib"                  # if not, initialize it
94
    else
95
        eval ${DYLIB_VAR}="${maus_root_dir}/third_party/install/lib:${!DYLIB_VAR}" # else add to to it
96
    fi
299 by Christopher Tunnell
closes #306
97
fi
45 by Christopher Tunnell
tweaking
98
99
# Check for Python
208 by Christopher Tunnell
c shell support
100
type -P python &>/dev/null || {
101
    echo "FATAL: Python is required.">&2;
102
    echo "FATAL:">&2;
103
    echo "FATAL: To install within MAUS, set the MAUS_ROOT_DIR" >&2;
104
    echo "FATAL: environmental variable.  For Bourne-compatible" >&2;
105
    echo "FATAL: shells like 'bash', run:" >&2;
106
    echo "FATAL:" >&2;
281 by Christopher Tunnell
fixes #305
107
    echo "FATAL:      export MAUS_ROOT_DIR=\"${maus_root_dir}\"" >&2;
208 by Christopher Tunnell
c shell support
108
    echo "FATAL:" >&2;
109
    echo "FATAL: then run the following to install Python 2.7:" >&2;
110
    echo "FATAL:" >&2;
459 by Chris Rogers
Broken configure file
111
    echo "FATAL:      ./third_party/bash/01python.bash" >&2;
208 by Christopher Tunnell
c shell support
112
    exit 1; }
45 by Christopher Tunnell
tweaking
113
459 by Chris Rogers
Broken configure file
114
python_version=`env $DYLIB_VAR=./third_party/install/lib python -V 2>&1`
45 by Christopher Tunnell
tweaking
115
## Check for supported python version
116
if [ "${python_version}" != "Python 2.7" ]
299 by Christopher Tunnell
closes #306
117
then               ##################################################
485 by Christopher Tunnell
remove csh from maus closes #416
118
    if [ ! -f "env.sh" ]
119
    then
656.1.11 by Chris Rogers
add some options to env.sh (already present in SConstruct
120
        echo "WARNING: Unsupported python version (You are using ${python_version}),";
121
        echo "WARNING: so using Python 2.7 is recommended.  MAUS will install extra";
122
        echo "WARNING: packages in this location like numpy and xboa and currently";
123
        echo "WARNING: the way we go about this is having our own Python install.";
124
        echo "WARNING: ";
125
        echo "WARNING: To install within MAUS, set the MAUS_ROOT_DIR";
126
        echo "WARNING: environmental variable.  For Bourne-compatible";
127
        echo "WARNING: shells like 'bash', run:";
128
        echo "WARNING: ";
129
        echo "WARNING:       export MAUS_ROOT_DIR=\"${maus_root_dir}\"";
130
        echo "WARNING: ";
131
        echo "WARNING: then run the following to install Python 2.7:"
132
        echo "WARNING: ";
133
        echo "WARNING:       ./third_party/bash/01python.bash";
134
        echo
485 by Christopher Tunnell
remove csh from maus closes #416
135
    fi
45 by Christopher Tunnell
tweaking
136
fi
137
205 by Christopher Tunnell
set manpath correctly
138
# check for SCons
208 by Christopher Tunnell
c shell support
139
type -P scons &>/dev/null || {
485 by Christopher Tunnell
remove csh from maus closes #416
140
    if [ ! -f "env.sh" ]
141
    then
656.1.11 by Chris Rogers
add some options to env.sh (already present in SConstruct
142
        echo "WARNING: Scons is required to proceed after this step"
143
        echo "WARNING:"
144
        echo "WARNING: To install within MAUS, set the MAUS_ROOT_DIR";
145
        echo "WARNING: environmental variable.  For Bourne-compatible";
146
        echo "WARNING: shells like 'bash', run:";
147
        echo "WARNING: ";
148
        echo "WARNING:       export MAUS_ROOT_DIR=\"${maus_root_dir}\"";
149
        echo "WARNING: ";
150
        echo "WARNING: then run the following to install Scons:" >&2;
151
        echo "WARNING:" >&2;
152
        echo "WARNING:      ./third_party/bash/40python_extras.bash";
153
        echo "WARNING:";
154
        echo
485 by Christopher Tunnell
remove csh from maus closes #416
155
    fi
459 by Chris Rogers
Broken configure file
156
    }
157
433 by Christopher Tunnell
add help in the configure script for new users
158
656.1.35 by Chris Rogers
Configure script update to new root version
159
root_version=root_v5.30.03
371 by Christopher Tunnell
make root version a variable
160
459 by Chris Rogers
Broken configure file
161
if [ ! -f "env.sh" ]
162
then
163
    echo "RECOMMENDATION:  This appears to be your first time running MAUS."
164
    echo "RECOMMENDATION:  If you want to install all the external dependencies"
165
    echo "RECOMMENDATION:  automatically (takes an hour or so since geant is big)"
166
    echo "RECOMMENDATION:  then run the following command:"
167
    echo "RECOMMENDATION:"
168
    echo "RECOMMENDATION:       ./tests/integration/install_then_build_then_test.bash"
169
    echo "RECOMMENDATION:"
170
    echo
171
fi
172
600.1.4 by Peter Lane
Python is now built as an OS X "framework" so that it will load OS X shared libraries. Restored SConsruct building shared libraries instead of bundles. Hacked SConstruct to force the use of .so extensions for shared libraries instead of .dylib so that Python can find them to load them as modules. Updated configure (env.sh) and some third-party build scripts to accomodate the new Python location when it's built as a framework.
173
7 by tunnell
cleanup of initial setup
174
### Create environment files
175
176
cat > env.sh <<EOF
46 by Christopher Tunnell
refiddling build system
177
#/bin/sh
372 by Christopher Tunnell
try to fix ROOT thisroot.sh finding
178
600.1.13 by Peter Lane
Fixed some mac environment issues.
179
############################## DO NOT EDIT #####################################
180
# This file was automatically generated by the script
181
# ${maus_root_dir}/configure
182
################################################################################
183
25 by Christopher Tunnell
tweaking config
184
if [ -z "\$MAUS_ROOT_DIR" ]; then
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
185
281 by Christopher Tunnell
fixes #305
186
     export MAUS_ROOT_DIR="${maus_root_dir}"
46 by Christopher Tunnell
refiddling build system
187
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
188
     export MAUS_THIRD_PARTY="${maus_third_party}"
189
     echo "INFO: Using third party libraries from ${maus_third_party}"
190
191
     maus_bin_dirs="\${MAUS_THIRD_PARTY}/third_party/install/bin"
600.1.13 by Peter Lane
Fixed some mac environment issues.
192
     if [ "$arch" == "Darwin" ]; then
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
193
         maus_bin_dirs="\${MAUS_THIRD_PARTY}/third_party/install/Python.framework/Versions/2.7/bin:\${maus_bin_dirs}"
600.1.4 by Peter Lane
Python is now built as an OS X "framework" so that it will load OS X shared libraries. Restored SConsruct building shared libraries instead of bundles. Hacked SConstruct to force the use of .so extensions for shared libraries instead of .dylib so that Python can find them to load them as modules. Updated configure (env.sh) and some third-party build scripts to accomodate the new Python location when it's built as a framework.
194
     fi
195
46 by Christopher Tunnell
refiddling build system
196
     if [ -z "\${PATH}" ]; then  # see if the variable exists yet
600.1.13 by Peter Lane
Fixed some mac environment issues.
197
         export PATH="\${maus_bin_dirs}" # initialize it
46 by Christopher Tunnell
refiddling build system
198
     else
600.1.13 by Peter Lane
Fixed some mac environment issues.
199
         export PATH="\${maus_bin_dirs}:\${PATH}" # else add it
200
     fi
201
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
202
     maus_lib_dirs="\${MAUS_THIRD_PARTY}/third_party/install/lib"
600.1.13 by Peter Lane
Fixed some mac environment issues.
203
     if [ "$arch" == "Darwin" ]; then
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
204
         maus_lib_dirs="\${MAUS_THIRD_PARTY}/third_party/install/Python.framework/Versions/2.7/lib:\${maus_lib_dirs}"
46 by Christopher Tunnell
refiddling build system
205
     fi
206
459 by Chris Rogers
Broken configure file
207
     if [ -z "\${$DYLIB_VAR}" ]; then  # see if the variable exists yet
600.1.13 by Peter Lane
Fixed some mac environment issues.
208
          export $DYLIB_VAR="\${maus_lib_dirs}" # intiailize it
46 by Christopher Tunnell
refiddling build system
209
     else
600.1.13 by Peter Lane
Fixed some mac environment issues.
210
          export $DYLIB_VAR="\${maus_lib_dirs}:\${$DYLIB_VAR}" # else add it
46 by Christopher Tunnell
refiddling build system
211
     fi
212
405 by Christopher Tunnell
BUG: closes #402 since we now check if pythonpath exists before trying to set stuff. There was a trailing :
213
     if [ -z "\${PYTHONPATH}" ]; then  # see if the variable exists yet
459 by Chris Rogers
Broken configure file
214
          export PYTHONPATH="\$MAUS_ROOT_DIR/build" #initialize it
405 by Christopher Tunnell
BUG: closes #402 since we now check if pythonpath exists before trying to set stuff. There was a trailing :
215
     else
459 by Chris Rogers
Broken configure file
216
          export PYTHONPATH="\$MAUS_ROOT_DIR/build:\$PYTHONPATH" # else add it
405 by Christopher Tunnell
BUG: closes #402 since we now check if pythonpath exists before trying to set stuff. There was a trailing :
217
     fi
218
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
219
     export $DYLIB_VAR="\$MAUS_THIRD_PARTY/build:\$$DYLIB_VAR"
459 by Chris Rogers
Broken configure file
220
     export $DYLIB_VAR="\$MAUS_ROOT_DIR/build:\$$DYLIB_VAR"
131 by Christopher Tunnell
new worker path
221
340.1.116 by Chris Rogers
Builds but segv on executation of test_cpp
222
     # maus common
340.1.172 by Chris Rogers
move cpplint to python site-packages
223
     export PYTHONPATH="\$MAUS_ROOT_DIR/src/common_py:\$PYTHONPATH"
340.1.116 by Chris Rogers
Builds but segv on executation of test_cpp
224
     export $DYLIB_VAR="\$MAUS_ROOT_DIR/src/common_py:\$$DYLIB_VAR"
202 by Christopher Tunnell
updated go sanity checks and added unit tests
225
549.2.16 by Christopher Tunnell
BUG: fix confiugre not adding docstore
226
     export PYTHONPATH="\$MAUS_ROOT_DIR/src/common_py/docstore:\$PYTHONPATH" 
227
656.2.44 by Mike Jackson
Moved mauscelery and docstore to common_py. Changed configure to reflect change in paths to these directories. Removed no-longer-needed Task classes from maustasks.py. Replaced prints in maustasks.py with logger.info calls.
228
     export PYTHONPATH="\$MAUS_ROOT_DIR/src/common_py/mauscelery:\$PYTHONPATH"
229
     export LD_LIBRARY_PATH="\$MAUS_ROOT_DIR/src/common_py/mauscelery:\$LD_LIBRARY_PATH"
656.2.10 by Mike Jackson
Added celery to 40python_extras.bash. Added Celery paths to configure. Added first prototype of Celery tasks and custom loader to src/celery. Extended Go.py to support use of Celery tasks
230
     export CELERY_LOADER="mausloader.CeleryLoader"
231
656.2.44 by Mike Jackson
Moved mauscelery and docstore to common_py. Changed configure to reflect change in paths to these directories. Removed no-longer-needed Task classes from maustasks.py. Replaced prints in maustasks.py with logger.info calls.
232
     export PYTHONPATH="\$MAUS_ROOT_DIR/src/common_py/docstore:\$PYTHONPATH"
233
     export LD_LIBRARY_PATH="\$MAUS_ROOT_DIR/src/common_py/docstore:\$LD_LIBRARY_PATH"
656.2.20 by Mike Jackson
Created docstore classes wrapping array and CouchDB. Go.py uses dynamic class load to load these in. Added tests for the docstore classes. Added src/docstore to configure and easy_install CouchDB to 40python_extras.bash
234
130 by Christopher Tunnell
geant4 checks
235
     export G4DEBUG=1
327 by Christopher Tunnell
another stupid geant4 typo in version name
236
     export G4VERS=geant4.9.2.p04
459 by Chris Rogers
Broken configure file
237
     export G4SYSTEM=$arch-g++
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
238
     export G4INSTALL="\${MAUS_THIRD_PARTY}/third_party/build/\${G4VERS}"
282 by Christopher Tunnell
configure works on csh
239
     export G4LIB="\${G4INSTALL}/lib"
459 by Chris Rogers
Broken configure file
240
     export $DYLIB_VAR="\${G4LIB}/\${G4SYSTEM}:\${$DYLIB_VAR}"
282 by Christopher Tunnell
configure works on csh
241
     export G4INCLUDE="\${G4INSTALL}/include/"
242
     export G4TMP="\${G4INSTALL}"
130 by Christopher Tunnell
geant4 checks
243
     export G4VIS_BUILD_DAWNFILE_DRIVER=1
244
     export G4VIS_USE_DAWNFILE=1
245
     export G4VIS_USE=0
246
     export G4OPTIMISE=2
247
     export OGLHOME=/usr/X11R6
282 by Christopher Tunnell
configure works on csh
248
     export G4LEDATA="\${G4INSTALL}/data/G4EMLOW6.2/"
249
     export G4ABLADATA="\${G4INSTALL}/data/G4ABLA3.0/"
250
     export G4NEUTRONDATA="\${G4INSTALL}/data/G4NDL3.13/"
251
     export G4LEVELGAMMADATA"=\${G4INSTALL}/data/PhotonEvaporation2.0/"
252
     export G4RADIOACTIVEDATA"=\${G4INSTALL}/data/RadioactiveDecay3.2/"
163 by Christopher Tunnell
cleanup of commoncpp, update sim worker
253
340.1.118 by Chris Rogers
FILES is in legacy
254
     export MICEFILES="\${MAUS_ROOT_DIR}/src/legacy/FILES"
299 by Christopher Tunnell
closes #306
255
656.1.11 by Chris Rogers
add some options to env.sh (already present in SConstruct
256
     export maus_no_optimize=0 # force gcc not to optimise
257
     export maus_lcov=0 # enable cpp coverage - requires lcov
258
     export maus_debug=0 # enable debugging
259
     export maus_gprof=0 # enable cpp profiling - requires gprof
260
25 by Christopher Tunnell
tweaking config
261
     echo "SUCCESS: MAUS setup"
262
else
372 by Christopher Tunnell
try to fix ROOT thisroot.sh finding
263
     echo "WARNING: MAUS already setup"
25 by Christopher Tunnell
tweaking config
264
fi
265
459 by Chris Rogers
Broken configure file
266
# setup ROOT
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
267
if [ -f \${MAUS_THIRD_PARTY}/third_party/build/$root_version/bin/thisroot.sh ]
459 by Chris Rogers
Broken configure file
268
then
656.9.4 by Adam Dobbs
Modofied build system to allow for compiling against precompiled third party libraries.
269
     source \${MAUS_THIRD_PARTY}/third_party/build/$root_version/bin/thisroot.sh
459 by Chris Rogers
Broken configure file
270
fi
271
7 by tunnell
cleanup of initial setup
272
EOF
273
208 by Christopher Tunnell
c shell support
274
echo "SUCCESS: Whenever you want to use MAUS, you must 'source'"
275
echo "SUCCESS: the environmental variables file.  For Bourne-"
276
echo "SUCCESS: compatible shells like 'bash', run:"
46 by Christopher Tunnell
refiddling build system
277
echo "SUCCESS:"
278
echo "SUCCESS:      source env.sh"
279
echo "SUCCESS:"
208 by Christopher Tunnell
c shell support
280
echo "SUCCESS: which can be added to your respective shell's"
281
echo "SUCCESS: startup scripts.  Example: ~/.bashrc for 'bash'."