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=x86_64-slc5-gcc43-opt
28 if [ "x$arg" = "x--enable-debug" ] ; then
30 elif [ "x$arg" = "x--enable-shared" ] ; then
32 elif [ "x$arg" = "x--enable-64bits" ] ; then
34 elif [ "x$arg" = "x--enable-gzip" ] ; then
36 elif [ "x$arg" = "x--help" ] ; then
37 echo "Usage: ./configure [options] , where options are:"
38 echo "--help : prints this help"
39 echo "--enable-debug : turns on debugging flags and turns off optimization"
40 echo "--enable-shared : turns on shared library creation (default no)"
41 echo "--enable-64bits : turns on 64 bits compilation flags"
42 echo "--lcgplatform=name : LCG platform name, default is x86_64-slc5-gcc43-opt"
43 echo "--installdir=name : install directory, default is . "
44 echo "--prefix=name : install directory (equivalent to --installdir)"
45 echo "--datadir=name : data directory (for xmldoc), default is install directory"
46 echo "--with-hepmc=path : path to HepMC library to build interface (default is not build)"
47 echo "--with-hepmcversion=v : HepMC version (simplified alternative when using CERN AFS LCG external, e.g. =2.04.00)"
48 echo "--enable-gzip : turns on support for reading in gzipped files (default no)"
49 echo " (experimental feature, see README for more details)"
50 echo "--with-boost=path : path to boost installation (default /usr) (required for gzip support)"
51 echo "--with-zlib=path : path to zlib (default /usr/lib) (required for gzip support)"
53 echo "Use the following environment variables to force the configuration process or add flags:"
54 echo "USRCXXFLAGS - to add flags. Use this variable to add -fPIC to the compilation flags for the static libraries"
55 echo "USRLDFLAGSSHARED - to add flags to the shared library build command"
56 echo "USRSHAREDSUFFIX - to force shared libraries suffix to be like this (default on MacOSX is dylib)"
59 elif [ x`echo x${arg} | grep "="` != x ] ; then
60 option=`echo ${arg} | awk -F = '{print $1}'`
61 value=`echo ${arg} | awk -F = '{print $2}'`
62 if [ "x${option}" = "x--lcgplatform" ] ; then
63 MYLCGPLATFORM=${value}
64 elif [ "x${option}" = "x--installdir" ] ; then
66 elif [ "x${option}" = "x--prefix" ] ; then
68 elif [ "x${option}" = "x--datadir" ] ; then
70 elif [ "x${option}" = "x--with-hepmcversion" ] ; then
72 elif [ "x${option}" = "x--with-hepmc" ] ; then
73 HEPMCLOCATION=${value}
74 elif [ "x${option}" = "x--with-boost" ] ; then
75 BOOSTLOCATION=${value}
76 elif [ "x${option}" = "x--with-zlib" ] ; then
79 echo "${arg}: wrong option. Ignored." >&2
84 echo compilation mode is $COMPMODE
85 echo sharedlibs = $SHAREDLIBS
87 if [ "x${DATADIR}" = "x" ] ; then
91 # Environment variables for building HepMC interface library. Note that
92 # the HepMC interface library is used by the examples main41, main42, .. .
93 # Attention: if you have already run these examples and you change HepMC
94 # version you should reset your LD_LIBRARY_PATH
95 # The default values here correspond to CERN AFS lcg external
97 if [ "x${HEPMCVERSION}" != "x" ] ; then
98 if [ "x${HEPMCLOCATION}" = "x" ] ; then
99 export HEPMCLOCATION=/afs/cern.ch/sw/lcg/external/HepMC/${HEPMCVERSION}/${MYLCGPLATFORM}
102 # If you want to assign these variables by hand:
104 #export HEPMCVERSION=2.04.00
105 #export HEPMCLOCATION=/afs/cern.ch/sw/lcg/external/HepMC/${HEPMCVERSION}/${MYLCGPLATFORM}
108 if [ "x${HEPMCVERSION}" = "x" ] ; then
109 if [ "x${HEPMCLOCATION}" != "x" ] ; then
110 # try to find out which HepMC version
111 test1=`echo $HEPMCLOCATION | grep \/1.`
112 test2=`echo $HEPMCLOCATION | grep \/2.`
115 if [ "x${test1}" != "x" ] ; then
116 echo "Warning: HepMC 1 cannot be used anymore; Please use HepMC 2"
117 echo " The interface will not be built"
118 export HEPMCLOCATION=
120 if [ "x${test2}" != "x" ] ; then
121 export HEPMCVERSION=2.`echo $HEPMCLOCATION | awk -F \/2. '{print $2}' | awk -F \/ '{print $1}'`
125 if [ "x${HEPMCVERSION}" != "x" ] ; then
126 export HEPMCMAINVERSION=`echo ${HEPMCVERSION} | awk -F . '{print$1}'`
127 if [ ${HEPMCMAINVERSION} = 1 ] ; then
128 echo "Warning: HepMC 1 cannot be used anymore; Please use HepMC 2"
129 echo " The interface will not be built"
130 export HEPMCLOCATION=
133 if [ "x${HEPMCLOCATION}" != "x" ] ; then
134 if [ "x${HEPMCVERSION}" = "x" ] ; then
135 echo "Warning: hepmc specified, but cannot find out which HepMC version"
136 echo "Warning: if you specify HepMC 1 the compilation of interface will fail"
142 # User-changeable part, experts -----------------------------
145 # Switch off -Wshadow when gzip support is enabled
147 if [ "x${ENABLEGZIP}" = "xyes" ]; then
151 # export FFLAGS_OPT="-O2 -Wuninitialized"
152 # -Wuninitialized outputs many irrelevant warnings and therefore obscurs
153 export FFLAGS_OPT="-O2"
155 export CFLAGS_OPT="-O2"
157 export CXXFLAGS_OPT="-O2 -ansi -pedantic -W -Wall ${WSHADOW} ${ENABLE64}"
158 export CXXFLAGS_DBG="-g -ansi -pedantic -W -Wall ${WSHADOW} ${ENABLE64}"
162 export ARCH0="`uname`"
164 export theGcc=`gcc -dumpversion | awk -F . '{print $1}'`
165 if [ ${theGcc} = 4 ]; then
166 export ARCH=${ARCH}-gcc4
168 echo Platform is $ARCH
170 #default platform settings:
173 export FFLAGS="${FFLAGS_OPT}"
174 export CFLAGS="${CFLAGS_OPT}"
175 export CXXFLAGS="${CXXFLAGS_OPT}"
176 export FLIBS="-lfrtbegin -lg2c"
177 if [ ${COMPMODE} = OPT ]; then
178 export FFLAGS="${FFLAGS_OPT}"
179 export CFLAGS="${CFLAGS_OPT}"
180 export CXXFLAGS="${CXXFLAGS_OPT}"
182 if [ ${COMPMODE} = DBG ]; then
183 export FFLAGS="${FFLAGS_DBG}"
184 export CFLAGS="${CFLAGS_DBG}"
185 export CXXFLAGS="${CXXFLAGS_DBG}"
187 LDFLAGSSHARED="${CXXFLAGS} -fPIC -shared"
188 LDFLAGLIBNAME="-Wl,-soname"
190 if [ $ARCH = Linux ]; then
192 export FFLAGS="${FFLAGS_OPT} -Wno-globals"
193 export CFLAGS="${CFLAGS_OPT}"
194 export CXXFLAGS="${CXXFLAGS_OPT}"
195 export FLIBS="-lfrtbegin -lg2c"
196 if [ ${COMPMODE} = OPT ]; then
197 export FFLAGS="${FFLAGS_OPT}"
198 export CFLAGS="${CFLAGS_OPT}"
199 export CXXFLAGS="${CXXFLAGS_OPT}"
201 if [ ${COMPMODE} = DBG ]; then
202 export FFLAGS="${FFLAGS_DBG} -Wno-globals"
203 export CFLAGS="${CFLAGS_DBG}"
204 export CXXFLAGS="${CXXFLAGS_DBG}"
206 LDFLAGSSHARED="${CXXFLAGS} -fPIC -shared"
207 LDFLAGLIBNAME="-Wl,-soname"
210 # Linux platform with gcc4: new Fortran90 compiler.
211 if [ $ARCH = Linux-gcc4 ]; then
213 export FFLAGS="${FFLAGS_OPT}"
214 export CFLAGS="${CFLAGS_OPT}"
215 export CXXFLAGS="${CXXFLAGS_OPT}"
216 export FLIBS="-lgfortran -lgfortranbegin"
217 if [ ${COMPMODE} = OPT ]; then
218 export FFLAGS="${FFLAGS_OPT}"
219 export CFLAGS="${CFLAGS_OPT}"
220 export CXXFLAGS="${CXXFLAGS_OPT}"
222 if [ ${COMPMODE} = DBG ]; then
223 export FFLAGS="${FFLAGS_DBG}"
224 export CFLAGS="${CFLAGS_DBG}"
225 export CXXFLAGS="${CXXFLAGS_DBG}"
227 LDFLAGSSHARED="${CXXFLAGS} -fPIC -shared"
228 LDFLAGLIBNAME="-Wl,-soname"
232 if [ $ARCH = Darwin-gcc4 ]; then
234 export FFLAGS="${FFLAGS_OPT}"
235 export CFLAGS="${CFLAGS_OPT}"
236 export CXXFLAGS="${CXXFLAGS_OPT}"
237 export FLIBS="-lgfortran"
238 if [ ${COMPMODE} = OPT ]; then
239 export FFLAGS="${FFLAGS_OPT}"
240 export CFLAGS="${CFLAGS_OPT}"
241 export CXXFLAGS="${CXXFLAGS_OPT}"
243 if [ ${COMPMODE} = DBG ]; then
244 export FFLAGS="${FFLAGS_DBG}"
245 export CFLAGS="${CFLAGS_DBG}"
246 export CXXFLAGS="${CXXFLAGS_DBG}"
248 LDFLAGSSHARED="${CXXFLAGS} -dynamiclib -single_module -flat_namespace -undefined suppress"
249 LDFLAGLIBNAME="-Wl,-dylib_install_name"
252 # Mac-OSX with gcc3; is not tested
253 if [ $ARCH = Darwin ]; then
255 export FFLAGS="${FFLAGS_OPT}"
256 export CFLAGS="${CFLAGS_OPT}"
257 export CXXFLAGS="${CXXFLAGS_OPT}"
258 export FLIBS="-lfrtbegin -lg2c"
259 if [ ${COMPMODE} = OPT ]; then
260 export FFLAGS="${FFLAGS_OPT}"
261 export CFLAGS="${CFLAGS_OPT}"
262 export CXXFLAGS="${CXXFLAGS_OPT}"
264 if [ ${COMPMODE} = DBG ]; then
265 export FFLAGS="${FFLAGS_DBG}"
266 export CFLAGS="${CFLAGS_DBG}"
267 export CXXFLAGS="${CXXFLAGS_DBG}"
269 LDFLAGSSHARED="${CXXFLAGS} -dynamiclib -single_module -flat_namespace -undefined suppress"
270 LDFLAGLIBNAME="-Wl,-dylib_install_name"
275 CXXFLAGS="${CXXFLAGS} $USRCXXFLAGS"
276 LDFLAGSSHARED="${LDFLAGSSHARED} $USRLDFLAGSSHARED"
277 if [ "x${USRSHAREDSUFFIX}" != "x" ] ; then
278 SHAREDSUFFIX="${USRSHAREDSUFFIX}"
282 #Platform & opt/dbg - independent flags and variables:
286 # End of the user-changeable part ---------------------------
290 if [ $?HEPMCLOCATION ]; then
291 if [ x${HEPMCLOCATION} != x ]; then
292 if [ ! -d ${HEPMCLOCATION}/include ]; then
293 echo "Warning: bad HEPMCLOCATION: directory ${HEPMCLOCATION}/include does not exist"
294 echo " The interface will not be built"
295 export HEPMCLOCATION=
297 if [ ! -d ${HEPMCLOCATION}/lib ]; then
298 echo "Warning: bad HEPMCLOCATION: directory ${HEPMCLOCATION}/lib does not exist"
299 echo " The interface will not be built"
300 export HEPMCLOCATION=
305 # gzip support - do after SHAREDSUFFIX is set
306 if [ "x${ENABLEGZIP}" = "xyes" ]; then
308 # Default locations if none given
309 if [ "x${BOOSTLOCATION}" = "x" ]; then
312 if [ "x${ZLIBLOCATION}" = "x" ]; then
313 ZLIBLOCATION=/usr/lib
316 # Check for Boost and zlib
317 if [ "x${ENABLEGZIP}" = "xyes" ] ; then
318 if [ ! -d "${BOOSTLOCATION}/include/boost/iostreams" ]; then
319 echo "Error: cannot find required Boost include files; gzip support disabled"
323 # Some systems have Boost only under lib64?
324 for i in lib lib64; do
325 if [ -f "${BOOSTLOCATION}/$i/libboost_iostreams.${SHAREDSUFFIX}" ]; then
326 BOOSTLIBLOCATION=${BOOSTLOCATION}/$i
331 if [ "x${ENABLEGZIP}" = "xyes" -a x"${BOOSTLIBLOCATION}" = x ]; then
332 echo "Error: cannot find required Boost library files; gzip support disabled"
336 if [ "x${ENABLEGZIP}" = "xyes" -a ! -f "${ZLIBLOCATION}/libz.${SHAREDSUFFIX}" ]; then
337 echo "Error: cannot find zlib; gzip support disabled"
343 if [ "x${ENABLEGZIP}" = "xyes" ] ; then
344 echo gzip support is enabled
345 CXXFLAGS="${CXXFLAGS} -DGZIPSUPPORT -I${BOOSTLOCATION}/include"
351 echo SHELL = /bin/sh > config.mk
352 echo ARCH = ${ARCH} >> config.mk
353 echo MYLCGPLATFORM = ${MYLCGPLATFORM} >> config.mk
354 echo SHAREDLIBS = ${SHAREDLIBS} >> config.mk
355 echo FC = ${FC} >> config.mk
356 echo CC = ${CC} >> config.mk
357 echo FFLAGS = ${FFLAGS} >> config.mk
358 echo CFLAGS = ${CFLAGS} >> config.mk
359 echo CXXFLAGS = ${CXXFLAGS} >> config.mk
360 echo FLIBS = ${FLIBS} >> config.mk
361 echo LDFLAGSSHARED = ${LDFLAGSSHARED} >> config.mk
362 echo LDFLAGLIBNAME = ${LDFLAGLIBNAME} >> config.mk
363 echo SHAREDSUFFIX = ${SHAREDSUFFIX} >> config.mk
364 echo INSTALLDIR = ${INSTALLDIR} >> config.mk
365 echo DATADIR = ${DATADIR} >> config.mk
367 if [ x${HEPMCLOCATION} != x ]; then
368 if [ x${HEPMCVERSION} != x ]; then
369 echo HEPMCVERSION = ${HEPMCVERSION} >> config.mk
371 echo HEPMCLOCATION = ${HEPMCLOCATION} >> config.mk
376 rm -f examples/config.sh
377 rm -f examples/config.csh
378 if [ x${HEPMCLOCATION} != x ]; then
379 if [ $ARCH0 != Darwin ]; then
380 echo "#!/bin/csh" > examples/config.csh
381 echo 'if( ! $?LD_LIBRARY_PATH ) then' >> examples/config.csh
382 echo " setenv LD_LIBRARY_PATH ${HEPMCLOCATION}/lib" >> examples/config.csh
383 echo "else" >> examples/config.csh
384 echo " setenv LD_LIBRARY_PATH" '${LD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.csh
385 echo "endif" >> examples/config.csh
386 echo "#!/bin/sh" > examples/config.sh
387 echo 'if [ ! $?LD_LIBRARY_PATH ]; then' >> examples/config.sh
388 echo " export LD_LIBRARY_PATH=${HEPMCLOCATION}/lib" >> examples/config.sh
389 echo fi >> examples/config.sh
390 echo 'if [ $?LD_LIBRARY_PATH ]; then' >> examples/config.sh
391 echo " export LD_LIBRARY_PATH="'${LD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.sh
392 echo fi >> examples/config.sh
394 echo "#!/bin/csh" > examples/config.csh
395 echo 'if( ! $?DYLD_LIBRARY_PATH ) then' >> examples/config.csh
396 echo " setenv DYLD_LIBRARY_PATH ${HEPMCLOCATION}/lib" >> examples/config.csh
397 echo "else" >> examples/config.csh
398 echo " setenv DYLD_LIBRARY_PATH" '${DYLD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.csh
399 echo "endif" >> examples/config.csh
400 echo "#!/bin/sh" > examples/config.sh
401 echo 'if [ ! $?DYLD_LIBRARY_PATH ]; then' >> examples/config.sh
402 echo " export DYLD_LIBRARY_PATH=${HEPMCLOCATION}/lib" >> examples/config.sh
403 echo fi >> examples/config.sh
404 echo 'if [ $?DYLD_LIBRARY_PATH ]; then' >> examples/config.sh
405 echo " export DYLD_LIBRARY_PATH="'${DYLD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.sh
406 echo fi >> examples/config.sh
410 # gzip support - write locations into config.mk
411 if [ "x${ENABLEGZIP}" = "xyes" ] ; then
412 echo "ENABLEGZIP = yes" >> config.mk
413 echo "BOOSTLOCATION = ${BOOSTLOCATION}" >> config.mk
414 echo "BOOSTLIBLOCATION = ${BOOSTLIBLOCATION}" >> config.mk
415 echo "ZLIBLOCATION = ${ZLIBLOCATION}" >> config.mk