3 # Configuration script, to be run before compilation
7 if [ x$BASH_VERSION = x ]; then
8 echo warning: you are not using bash shell on which this script is tested
12 # User-changeable part -------------------------------
15 #LCG platform. Can be needed if external libraries are specified
16 if [ x$MYLCGPLATFORM = x ]; then
17 export MYLCGPLATFORM=slc4_ia32_gcc34
25 if [ "x$arg" = "x--enable-debug" ] ; then
27 elif [ "x$arg" = "x--enable-shared" ] ; then
29 elif [ "x$arg" = "x--enable-64bits" ] ; then
31 elif [ "x$arg" = "x--help" ] ; then
32 echo "Usage: ./configure [options] , where options are:"
33 echo "--help : prints this help"
34 echo "--enable-debug : turns on debugging flags and turns off optimization"
35 echo "--enable-shared : turns on shared library creation (default no)"
36 echo "--enable-64bits : turns on 64 bits compilation flags"
37 echo "--lcgplatform=name : LCG platform name, default is slc4_ia32_gcc34"
38 echo "--with-hepmc=path : path to HepMC library to build interface (default is not build)"
39 echo "--with-hepmcversion=v : HepMC version (simplified alternative when using CERN AFS LCG external, e.g. =2.04.00)"
41 echo "Use the following environment variables to force the configuration process or add flags:"
42 echo "USRCXXFLAGS - to add flags. Use this variable to add -fPIC to the compilation flags for the static libraries"
43 echo "USRLDFLAGSSHARED - to add flags to the shared library build command"
44 echo "USRSHAREDSUFFIX - to force shared libraries suffix to be like this (default on MacOSX is dylib)"
46 elif [ x`echo x${arg} | grep "="` != x ] ; then
47 option=`echo ${arg} | awk -F = '{print $1}'`
48 value=`echo ${arg} | awk -F = '{print $2}'`
49 if [ "x${option}" = "x--lcgplatform" ] ; then
50 MYLCGPLATFORM=${value}
51 elif [ "x${option}" = "x--with-hepmcversion" ] ; then
53 elif [ "x${option}" = "x--with-hepmc" ] ; then
54 HEPMCLOCATION=${value}
56 echo "${arg}: wrong option. Ignored." >&2
61 echo compilation mode is $COMPMODE
62 echo sharedlibs = $SHAREDLIBS
64 # Environment variables for building HepMC interface library. Note that
65 # the HepMC interface library is used by the examples main31, main32.
66 # Attention: if you have already run these examples and you change HepMC
67 # version you should reset your LD_LIBRARY_PATH
68 # The default values here correspond to CERN AFS lcg external
70 if [ "x${HEPMCVERSION}" != "x" ] ; then
71 if [ "x${HEPMCLOCATION}" = "x" ] ; then
72 export HEPMCLOCATION=/afs/cern.ch/sw/lcg/external/HepMC/${HEPMCVERSION}/${MYLCGPLATFORM}
75 # If you want to assign these variables by hand:
77 #export HEPMCVERSION=2.04.00
78 #export HEPMCLOCATION=/afs/cern.ch/sw/lcg/external/HepMC/${HEPMCVERSION}/${MYLCGPLATFORM}
81 if [ "x${HEPMCVERSION}" = "x" ] ; then
82 if [ "x${HEPMCLOCATION}" != "x" ] ; then
83 # try to find out which HepMC version
84 test1=`echo $HEPMCLOCATION | grep \/1.`
85 test2=`echo $HEPMCLOCATION | grep \/2.`
88 if [ "x${test1}" != "x" ] ; then
89 echo "Warning: HepMC 1 cannot be used anymore; Please use HepMC 2"
90 echo " The interface will not be built"
93 if [ "x${test2}" != "x" ] ; then
94 export HEPMCVERSION=2.`echo $HEPMCLOCATION | awk -F \/2. '{print $2}' | awk -F \/ '{print $1}'`
98 if [ "x${HEPMCVERSION}" != "x" ] ; then
99 export HEPMCMAINVERSION=`echo ${HEPMCVERSION} | awk -F . '{print$1}'`
100 if [ ${HEPMCMAINVERSION} = 1 ] ; then
101 echo "Warning: HepMC 1 cannot be used anymore; Please use HepMC 2"
102 echo " The interface will not be built"
103 export HEPMCLOCATION=
106 if [ "x${HEPMCLOCATION}" != "x" ] ; then
107 if [ "x${HEPMCVERSION}" = "x" ] ; then
108 echo "Warning: hepmc specifyed, but cannot find out which HepMC version"
109 echo "Warning: if you specify HepMC 1 the compilation of interface will fail"
114 # User-changeable part, experts -----------------------------
117 # export FFLAGS_OPT="-O2 -Wuninitialized"
118 # -Wuninitialized outputs many irrelevant warnings and therefore obscurs
119 export FFLAGS_OPT="-O2 -fbounds-check"
121 export CFLAGS_OPT="-O2 -fbounds-check"
123 export CXXFLAGS_OPT="-O2 -ansi -pedantic -W -Wall -Wshadow -fbounds-check ${ENABLE64}"
124 export CXXFLAGS_DBG="-g -ansi -pedantic -W -Wall -Wshadow -fbounds-check ${ENABLE64}"
128 export ARCH0="`uname`"
130 export theGcc=`g++ --version | head -n 1 | awk '{print$3}' | awk -F . '{print $1}'`
131 if [ ${theGcc} = 4 ]; then
132 export ARCH=${ARCH}-gcc4
134 echo Platform is $ARCH
136 #default platform settings:
139 export FFLAGS="${FFLAGS_OPT}"
140 export CFLAGS="${CFLAGS_OPT}"
141 export CXXFLAGS="${CXXFLAGS_OPT}"
142 export FLIBS="-lfrtbegin -lg2c"
143 if [ ${COMPMODE} = OPT ]; then
144 export FFLAGS="${FFLAGS_OPT}"
145 export CFLAGS="${CFLAGS_OPT}"
146 export CXXFLAGS="${CXXFLAGS_OPT}"
148 if [ ${COMPMODE} = DBG ]; then
149 export FFLAGS="${FFLAGS_DBG}"
150 export CFLAGS="${CFLAGS_DBG}"
151 export CXXFLAGS="${CXXFLAGS_DBG}"
153 LDFLAGSSHARED="${CXXFLAGS} -pthread -fPIC -shared"
154 LDFLAGLIBNAME="-Wl,-soname"
156 if [ $ARCH = Linux ]; then
158 export FFLAGS="${FFLAGS_OPT} -Wno-globals"
159 export CFLAGS="${CFLAGS_OPT}"
160 export CXXFLAGS="${CXXFLAGS_OPT}"
161 export FLIBS="-lfrtbegin -lg2c"
162 if [ ${COMPMODE} = OPT ]; then
163 export FFLAGS="${FFLAGS_OPT}"
164 export CFLAGS="${CFLAGS_OPT}"
165 export CXXFLAGS="${CXXFLAGS_OPT}"
167 if [ ${COMPMODE} = DBG ]; then
168 export FFLAGS="${FFLAGS_DBG} -Wno-globals"
169 export CFLAGS="${CFLAGS_DBG}"
170 export CXXFLAGS="${CXXFLAGS_DBG}"
172 LDFLAGSSHARED="${CXXFLAGS} -pthread -fPIC -shared"
173 LDFLAGLIBNAME="-Wl,-soname"
176 # Linux platform with gcc4: new Fortran90 compiler.
177 if [ $ARCH = Linux-gcc4 ]; then
179 export FFLAGS="${FFLAGS_OPT}"
180 export CFLAGS="${CFLAGS_OPT}"
181 export CXXFLAGS="${CXXFLAGS_OPT}"
182 export FLIBS="-lgfortran -lgfortranbegin"
183 if [ ${COMPMODE} = OPT ]; then
184 export FFLAGS="${FFLAGS_OPT}"
185 export CFLAGS="${CFLAGS_OPT}"
186 export CXXFLAGS="${CXXFLAGS_OPT}"
188 if [ ${COMPMODE} = DBG ]; then
189 export FFLAGS="${FFLAGS_DBG}"
190 export CFLAGS="${CFLAGS_DBG}"
191 export CXXFLAGS="${CXXFLAGS_DBG}"
193 LDFLAGSSHARED="${CXXFLAGS} -pthread -fPIC -shared"
194 LDFLAGLIBNAME="-Wl,-soname"
198 if [ $ARCH = Darwin-gcc4 ]; then
200 export FFLAGS="${FFLAGS_OPT}"
201 export CFLAGS="${CFLAGS_OPT}"
202 export CXXFLAGS="${CXXFLAGS_OPT}"
203 export FLIBS="-lgfortran"
204 if [ ${COMPMODE} = OPT ]; then
205 export FFLAGS="${FFLAGS_OPT}"
206 export CFLAGS="${CFLAGS_OPT}"
207 export CXXFLAGS="${CXXFLAGS_OPT}"
209 if [ ${COMPMODE} = DBG ]; then
210 export FFLAGS="${FFLAGS_DBG}"
211 export CFLAGS="${CFLAGS_DBG}"
212 export CXXFLAGS="${CXXFLAGS_DBG}"
214 LDFLAGSSHARED="${CXXFLAGS} -dynamiclib -single_module -flat_namespace -undefined suppress"
215 LDFLAGLIBNAME="-Wl,-dylib_install_name"
218 # Mac-OSX with gcc3; is not tested
219 if [ $ARCH = Darwin ]; then
221 export FFLAGS="${FFLAGS_OPT}"
222 export CFLAGS="${CFLAGS_OPT}"
223 export CXXFLAGS="${CXXFLAGS_OPT}"
224 export FLIBS="-lfrtbegin -lg2c"
225 if [ ${COMPMODE} = OPT ]; then
226 export FFLAGS="${FFLAGS_OPT}"
227 export CFLAGS="${CFLAGS_OPT}"
228 export CXXFLAGS="${CXXFLAGS_OPT}"
230 if [ ${COMPMODE} = DBG ]; then
231 export FFLAGS="${FFLAGS_DBG}"
232 export CFLAGS="${CFLAGS_DBG}"
233 export CXXFLAGS="${CXXFLAGS_DBG}"
235 LDFLAGSSHARED="${CXXFLAGS} -dynamiclib -single_module -flat_namespace -undefined suppress"
236 LDFLAGLIBNAME="-Wl,-dylib_install_name"
241 CXXFLAGS="${CXXFLAGS} $USRCXXFLAGS"
242 LDFLAGSSHARED="${LDFLAGSSHARED} $USRLDFLAGSSHARED"
243 if [ "x${USRSHAREDSUFFIX}" != "x" ] ; then
244 SHAREDSUFFIX="${USRSHAREDSUFFIX}"
248 #Platform & opt/dbg - independent flags and variables:
252 # End of the user-changeable part ---------------------------
256 if [ $?HEPMCLOCATION ]; then
257 if [ x${HEPMCLOCATION} != x ]; then
258 if [ ! -d ${HEPMCLOCATION}/include ]; then
259 echo "Warning: bad HEPMCLOCATION: directory ${HEPMCLOCATION}/include does not exist"
260 echo " The interface will not be built"
261 export HEPMCLOCATION=
263 if [ ! -d ${HEPMCLOCATION}/lib ]; then
264 echo "Warning: bad HEPMCLOCATION: directory ${HEPMCLOCATION}/lib does not exist"
265 echo " The interface will not be built"
266 export HEPMCLOCATION=
273 echo SHELL = /bin/sh > config.mk
274 echo ARCH = ${ARCH} >> config.mk
275 echo MYLCGPLATFORM = ${MYLCGPLATFORM} >> config.mk
276 echo SHAREDLIBS = ${SHAREDLIBS} >> config.mk
277 echo FC = ${FC} >> config.mk
278 echo CC = ${CC} >> config.mk
279 echo FFLAGS = ${FFLAGS} >> config.mk
280 echo CFLAGS = ${CFLAGS} >> config.mk
281 echo CXXFLAGS = ${CXXFLAGS} >> config.mk
282 echo FLIBS = ${FLIBS} >> config.mk
283 echo LDFLAGSSHARED = ${LDFLAGSSHARED} >> config.mk
284 echo LDFLAGLIBNAME = ${LDFLAGLIBNAME} >> config.mk
285 echo SHAREDSUFFIX = ${SHAREDSUFFIX} >> config.mk
287 if [ x${HEPMCLOCATION} != x ]; then
288 if [ x${HEPMCVERSION} != x ]; then
289 echo HEPMCVERSION = ${HEPMCVERSION} >> config.mk
291 echo HEPMCLOCATION = ${HEPMCLOCATION} >> config.mk
296 rm -f examples/config.sh
297 rm -f examples/config.csh
298 if [ x${HEPMCLOCATION} != x ]; then
299 if [ $ARCH0 != Darwin ]; then
300 echo "#!/bin/csh" > examples/config.csh
301 echo 'if( ! $?LD_LIBRARY_PATH ) then' >> examples/config.csh
302 echo " setenv LD_LIBRARY_PATH ${HEPMCLOCATION}/lib" >> examples/config.csh
303 echo "else" >> examples/config.csh
304 echo " setenv LD_LIBRARY_PATH" '${LD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.csh
305 echo "endif" >> examples/config.csh
306 echo "#!/bin/sh" > examples/config.sh
307 echo 'if [ ! $?LD_LIBRARY_PATH ]; then' >> examples/config.sh
308 echo " export LD_LIBRARY_PATH=${HEPMCLOCATION}/lib" >> examples/config.sh
309 echo fi >> examples/config.sh
310 echo 'if [ $?LD_LIBRARY_PATH ]; then' >> examples/config.sh
311 echo " export LD_LIBRARY_PATH="'${LD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.sh
312 echo fi >> examples/config.sh
314 echo "#!/bin/csh" > examples/config.csh
315 echo 'if( ! $?DYLD_LIBRARY_PATH ) then' >> examples/config.csh
316 echo " setenv DYLD_LIBRARY_PATH ${HEPMCLOCATION}/lib" >> examples/config.csh
317 echo "else" >> examples/config.csh
318 echo " setenv DYLD_LIBRARY_PATH" '${DYLD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.csh
319 echo "endif" >> examples/config.csh
320 echo "#!/bin/sh" > examples/config.sh
321 echo 'if [ ! $?DYLD_LIBRARY_PATH ]; then' >> examples/config.sh
322 echo " export DYLD_LIBRARY_PATH=${HEPMCLOCATION}/lib" >> examples/config.sh
323 echo fi >> examples/config.sh
324 echo 'if [ $?DYLD_LIBRARY_PATH ]; then' >> examples/config.sh
325 echo " export DYLD_LIBRARY_PATH="'${DYLD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.sh
326 echo fi >> examples/config.sh