forked from alisw/pythia8
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·329 lines (304 loc) · 15.8 KB
/
configure
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/usr/bin/env bash
# configure is a part of the PYTHIA event generator.
# Copyright (C) 2017 Torbjorn Sjostrand.
# PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
# Please respect the MCnet Guidelines, see GUIDELINES for details.
# Author: Philip Ilten, October 2014 - May 2015.
#
# This is is the configuration script which should be run prior to building
# PYTHIA. Example usage is:
# ./configure --with-lhapdf5
# For help please use:
# ./configure --help
# which will print a full list of configuration options.
################################################################################
# VARIABLES: Global variables not defined via command line arguments.
# CFG_FILE: The Makefile configuration file.
# USAGE: Text printed when the --help option is passed.
# OPTIONS: List of valid options that can be passed by the user.
################################################################################
CFG_FILE="Makefile.inc"
read -d "" USAGE << "BLOCKTEXT"
Usage: ./configure [OPTIONS]
The available options are defined below. Defaults for the options are specified
by square brackets in the option description. Arguments to the options are
indicated in caps, i.e. DIR.
Configuration options.
--help : Print this help message (also -h, --h, and -help).
--enable-debug : Turn on debugging and disable optimization.
--enable-64bit : Turn on 64-bit compilation.
--enable-shared : Build the shared PYTHIA library during compilation.
--lcg=PLATFORM : Specify the LCG platform to use when the
--with-PACKAGE-version option, described below, is set for a
given optional package [x86_64-slc6-gcc48-opt]. The packages
are accessed via the path /afs/cern.ch/sw/lcg/releases on AFS.
Optional external packages.
--with-PACKAGE[=DIR] : Use the external PACKAGE from the list below with
its top directory optionally set by DIR. If the
enabled PACKAGE requires other external packages,
these packages will also be enabled.
--with-PACKAGE-bin=DIR : Set the path to the PACKAGE binaries.
--with-PACKAGE-lib=DIR : Set the path to the PACKAGE libraries.
--with-PACKAGE-include=DIR : Set the path to the PACKAGE headers.
--with-PACKAGE-version=VER : When using an LCG platform, set with the option
--lcg above, automatically set the PACKAGE path
for the given version VER.
--with-lhapdf6-plugin=CODE : Set the LHAPDF6 plugin code [LHAPDF5.h]. LHAPDF5.h
uses the FORTRAN wrapper while LHAPDF6.h uses the
native C++ interface (requires BOOST headers).
evtgen : Particle decays with the EvtGen decay pacakge, requires HEPMC2.
fastjet3 : Building of jets using the FastJet package, version 3.
hepmc2 : Export PYTHIA events to the HEPMC format, version 2.
hepmc3 : Export PYTHIA events to the HEPMC format, version 3.
lhapdf5 : Support the use of external PDF sets via LHAPDF, version 5.
lhapdf6 : Support the use of external PDF sets via LHAPDF, version 6.
powheg : Hard process production with POWHEGBOX matrix element executables.
promc : Export PYTHIA events to the PROMC format.
root : Use ROOT trees and histograms with PYTHIA.
gzip : Enable reading of GZIPPED files using the libz library.
boost : Needed for LHAPDF6 when using the LHAPDF6.h plugin.
python : Interface to use PYTHIA in Python.
Installation directories.
--prefix=DIR : Directory to install PYTHIA [$PWD].
--prefix-COMPONENT=DIR : Set the installation directory for each PYTHIA
COMPONENT from the following list.
bin : Binaries, including the configuration script [PREFIX/bin].
lib : Libraries, both shared and static [PREFIX/lib].
include : Source headers [PREFIX/include/Pythia8].
share : Shared data, including configuration, READMEs, documentation, and
examples [PREFIX/share/Pythia8].
Advanced options.
--arch=ARCH : Architecture of the system. When not set, this
is determined automatically. Options are LINUX for *nix
systems and DARWIN for OS X.
--cxx=COMPILER : Use this C++ compiler [g++].
--cxx-common='FLAGS' : Set the common C++ flags.
--cxx-shared='FLAGS' : Set the shared C++ flags.
--cxx-soname='FLAGS' : Use these C++ flags when setting shared library names.
--lib-suffix=SUF : Shared library name suffix: [.so] for Linux and [.dylib]
for OS X.
BLOCKTEXT
OPTIONS="-h --h -help --help --enable-debug --enable-64bit"
OPTIONS+=" --enable-shared --lcg"
OPTIONS+=" --prefix --prefix-bin --prefix-lib --prefix-include --prefix-share"
for PKG in "evtgen" "fastjet3" "hepmc2" "hepmc3" "lhapdf5" "lhapdf6" "powheg"\
"promc" "root" "gzip" "boost" "python"; do
OPTIONS+=" --with-$PKG --with-$PKG-bin --with-$PKG-lib --with-$PKG-include"
OPTIONS+=" --with-$PKG-version"; done
OPTIONS+=" --with-lhapdf6-plugin"
OPTIONS+=" --arch --cxx --cxx-common --cxx-shared --cxx-soname --lib-suffix"
################################################################################
# FUNCTION: Configure a package.
# configure_package <package> <LCG path> <relative bin path>
# <relative include path> <relative library path>
# <bin deps> <header deps> <lib deps> <package deps>
# The following array structure stores the package configuration to the global
# variable <upper-case package name>_CFG.
# 0: Use the package. 5: Header dependencies.
# 1: Binary directory. 6: Library dependencies.
# 2: Include directory. 7: Package dependencies.
# 3: Library directory. 8: Dependency messages (empty if success).
# 4: Binary dependencies.
# Note that the global variable CXX must be defined prior to calling this
# function.
################################################################################
function configure_package() {
# Check global package variable and set the local package variables.
local PKG=$(echo $1 | awk '{print toupper($0)}')
eval local PKG_CFG=\${${PKG}_CFG[0]}
if [ "${PKG_CFG[0]}" != true ]; then PKG_CFG[0]=false; fi
PKG_CFG[4]=$6; PKG_CFG[5]=$7; PKG_CFG[6]=$8; PKG_CFG[7]=$9; PKG_CFG[8]=""
local LCG_DIR=$2; local PKG_BIN=$3; local PKG_INC=$4; local PKG_LIB=$5;
local WARN="WARNING: Disabling $PKG -"
eval PKG_CFG[1]=\$${PKG}_BIN; eval PKG_CFG[2]=\$${PKG}_INCLUDE
eval PKG_CFG[3]=\$${PKG}_LIB
eval local PKG_DIR=\$$PKG; eval local PKG_SET=\$${PKG}_SET
eval local PKG_VER=\$${PKG}_VERSION
if [ "$PKG_SET" = true ] || [ -n "${PKG_CFG[1]}" ] || \
[ -n "${PKG_CFG[2]}" ] || [ -n "${PKG_CFG[3]}" ] || \
[ -n "${PKG_VER}" ]; then PKG_CFG[0]=true; fi
if [ -z "${PKG_CFG[2]}" ]; then PKG_CFG[2]="./"; fi
if [ -z "${PKG_CFG[3]}" ]; then PKG_CFG[3]="./"; fi
# Set package path for LCG if available and requested.
if [ -n "$PKG_VER" ] && [ -n "$LCG_DIR" ]; then
if [ ! -d $LCG_DIR/$PKG_VER ]; then
echo "$WARN version $PKG_VER not available via LCG."
elif [ ! -d $LCG_DIR/$PKG_VER/$LCG ]; then
echo "$WARN platform $LCG not available via LCG."
else PKG_DIR=$LCG_DIR/$PKG_VER/$LCG; fi
elif [ -n "$PKG_VER" ]; then
echo "$WARN package not available via LCG."; fi
# Set binary, include, and library paths from specified package path.
if [ -n "$PKG_DIR" ]; then
if [ -z "${PKG_CFG[1]}" ]; then PKG_CFG[1]=$PKG_DIR/$PKG_BIN; fi;
if [ "${PKG_CFG[2]}" = "./" ]; then PKG_CFG[2]=$PKG_DIR/$PKG_INC; fi;
if [ "${PKG_CFG[3]}" = "./" ]; then PKG_CFG[3]=$PKG_DIR/$PKG_LIB; fi; fi
# Check header and library dependencies and store warnings.
IFS=","
for BIN in ${PKG_CFG[4]}; do
if [ -n "${PKG_CFG[1]}" ]; then
if ! type "${PKG_CFG[1]}/$BIN" &> /dev/null; then
PKG_CFG[8]="${PKG_CFG[8]},$WARN binary $BIN missing."; fi;
elif ! type "$BIN" &> /dev/null; then
PKG_CFG[8]="${PKG_CFG[8]},$WARN binary $BIN missing."; fi; done
if [ -z "${PKG_CFG[2]}" ]; then PKG_CFG[2]="./"; fi;
for INC in ${PKG_CFG[5]}; do
local TEST=$(echo "#include \"$INC\"" | $CXX -o /dev/null -x c - \
-I${PKG_CFG[2]} 2>&1 | grep -e "$INC: No such file" \
-e "'$INC' file not found")
if [ -n "$TEST" ]; then
PKG_CFG[8]="${PKG_CFG[8]},$WARN header $INC missing."; fi; done
if [ -z "${PKG_CFG[3]}" ]; then PKG_CFG[1]="./"; fi;
for LIB in ${PKG_CFG[6]}; do
local TEST=$(echo "int main(){}" | $CXX -o /dev/null -x c - \
-L${PKG_CFG[3]} -l$LIB 2>&1 | grep "\-l$LIB")
if [ -n "$TEST" ]; then
PKG_CFG[8]="${PKG_CFG[8]},$WARN library $LIB missing."; fi; done
IFS=" "
# Export local package to global variable and update global package list.
for IDX in ${!PKG_CFG[@]}; do
eval ${PKG}_CFG[$IDX]=\"${PKG_CFG[$IDX]}\"; done
PKG_LIST+=($PKG)
# Flag inter-package dependencies (if this package available).
if [ "${PKG_CFG[0]}" = true ] && [ -z "${PKG_CFG[8]}" ]; then
IFS=","; for PKG in ${PKG_CFG[7]}; do eval ${PKG}_CFG[0]=true; done;
IFS=" "; fi
}
################################################################################
# MAIN: The main execution of the configuration script.
################################################################################
# Check if help requested.
for VAR in "$@"; do
if [ "$VAR" = "-h" ] || [ "$VAR" = "--h" ] || [ "$VAR" = "-help" ] \
|| [ "$VAR" = "--help" ]; then echo "$USAGE"; exit; fi; done
# Parse the user arguments and evaluate each as a global variable.
echo "# PYTHIA configuration file." > $CFG_FILE
echo "# Generated on" `date` "with the user supplied options:" >> $CFG_FILE
for VAR in "$@"; do
if [[ $OPTIONS =~ (^| )${VAR%%=*}($| ) ]]; then echo "# $VAR" >> $CFG_FILE;
else echo "WARNING: Ignoring invalid option \"${VAR%=*}\"."; continue; fi;
VAR=${VAR#--with-}; VAR=${VAR#--};
KEY=${VAR%%=*}; VAL=${VAR#$KEY}; VAL=${VAL#*=}; KEY=${KEY//"-"/"_"};
KEY=$(echo $KEY | awk '{print toupper($0)}'); VAL=$(eval echo $VAL)
eval $KEY=\"$VAL\"; eval ${KEY}_SET=true; done
# Set the compilation flags and options (order matters).
if [ "$LCG_SET" != true ]; then LCG=x86_64-slc6-gcc48-opt; fi
[ "$ENABLE_DEBUG_SET" = true ] && ENABLE_DEBUG="-g " || ENABLE_DEBUG="-O2 "
[ "$ENABLE_64BIT_SET" = true ] && ENABLE_64BIT="-m64 " || ENABLE_64BIT=""
[ "$ENABLE_SHARED_SET" = true ] && ENABLE_SHARED="true" || ENABLE_SHARED="false"
if [ -z "$ARCH" ]; then ARCH=$(uname | grep -i -o -e Linux -e Darwin); fi
ARCH=$(echo $ARCH | awk '{print toupper($0)}')
if [ "$ARCH" != "LINUX" ] && [ "$ARCH" != "DARWIN" ]; then
echo "WARNING: Unknown architecture $ARCH, set as LINUX."; ARCH="LINUX"; fi
if [ -z "$CXX" ]; then CXX="g++"; fi
if [ -z "$CXX_COMMON" ]; then
CXX_COMMON="${ENABLE_DEBUG}${ENABLE_64BIT}-std=c++98"
CXX_COMMON="$CXX_COMMON -pedantic -W -Wall -Wshadow -fPIC"; fi
if [ -z "$CXX_SHARED" ]; then
if [ "$ARCH" = "LINUX" ]; then CXX_SHARED="-shared"; fi
if [ "$ARCH" = "DARWIN" ]; then CXX_SHARED="-dynamiclib"; fi; fi
if [ -z "$CXX_SONAME" ]; then
if [ "$ARCH" = "LINUX" ]; then CXX_SONAME="-Wl,-soname,"; fi
if [ "$ARCH" = "DARWIN" ]; then CXX_SONAME="-Wl,-dylib_install_name,@rpath/"
fi; fi
if [ -z "$LIB_SUFFIX" ]; then
if [ "$ARCH" = "LINUX" ]; then LIB_SUFFIX=".so"; fi
if [ "$ARCH" = "DARWIN" ]; then LIB_SUFFIX=".dylib"; fi; fi
# Configure the installation directories (order matters).
if [ "$PREFIX_SET" != true ]; then PREFIX=$PWD; fi
if [ -z "$PREFIX_BIN" ]; then PREFIX_BIN=$PREFIX/bin; fi
if [ -z "$PREFIX_INCLUDE" ]; then PREFIX_INCLUDE=$PREFIX/include; fi
if [ -z "$PREFIX_LIB" ]; then PREFIX_LIB=$PREFIX/lib; fi
if [ -z "$PREFIX_SHARE" ]; then PREFIX_SHARE=$PREFIX/share/Pythia8; fi
# Configure the packages (order does not matter).
configure_package "EVTGEN"\
"/afs/cern.ch/sw/lcg/releases/MCGenerators/evtgen/1.3.0-9000e"\
"bin" "include" "lib" "" "EvtGen/EvtGen.hh" "EvtGen" "HEPMC2"
configure_package "FASTJET3" "/afs/cern.ch/sw/lcg/releases/fastjet"\
"bin" "include" "lib" "" "fastjet/config.h" "fastjet" ""
configure_package "HEPMC2" "/afs/cern.ch/sw/lcg/releases/HepMC"\
"bin" "include" "lib" "" "HepMC/GenEvent.h" "HepMC" ""
configure_package "HEPMC3" "" \
"bin" "include" "lib" "" "HepMC/GenEvent.h" "HepMC" ""
configure_package "LHAPDF5" "/afs/cern.ch/sw/lcg/releases/MCGenerators/lhapdf"\
"bin" "include" "lib" "" "" "LHAPDF" ""
if [ "$LHAPDF6_PLUGIN" = "LHAPDF6.h" ]; then configure_package\
"LHAPDF6" "/afs/cern.ch/sw/lcg/releases/MCGenerators/lhapdf6"\
"bin" "include" "lib" "" "LHAPDF/LHAPDF.h" "LHAPDF" "BOOST"
else LHAPDF6_PLUGIN="LHAPDF5.h"; configure_package\
"LHAPDF6" "/afs/cern.ch/sw/lcg/releases/MCGenerators/lhapdf6"\
"bin" "include" "lib" "" "" "LHAPDF" ""; fi
configure_package "POWHEG" "" "bin" "" "lib" "hvq" "" "" ""
configure_package "PROMC" ""\
"bin" "" "lib" "" "src/ProMCBook.h" "promc" "GZIP"
configure_package "ROOT" "/afs/cern.ch/sw/lcg/releases/ROOT"\
"bin" "include" "lib" "rootcint,root-config" "TH1D.h" "" ""
configure_package "GZIP" "" "" "include" "lib" "" "zlib.h" "z" ""
configure_package "BOOST" "/afs/cern.ch/sw/lcg/releases/Boost"\
"bin" "include" "lib" "" "boost/shared_ptr.hpp" "" ""
configure_package "PYTHON" "/afs/cern.ch/sw/lcg/external/Python"\
"bin" "include" "lib" "python" "Python.h" "" ""
# Check package dependencies (order does not matter).
for IDX in ${!PKG_LIST[@]}; do PKG=${PKG_LIST[$IDX]}
eval PKG_USE=\${${PKG}_CFG[0]}; eval PKG_WRN=\${${PKG}_CFG[8]}
if [ "$PKG_USE" = true ] && [ -n "$PKG_WRN" ]; then
eval ${PKG}_CFG[0]=false; IFS=","
for WRN in $PKG_WRN; do if [ -n "$WRN" ]; then echo $WRN; fi; done;
IFS=" "; fi; done
# Check package inter-dependencies (order does not matter).
for IDX in ${!PKG_LIST[@]}; do PKG=${PKG_LIST[$IDX]}
eval PKG_USE=\${${PKG}_CFG[0]}; eval PKG_DPS=\${${PKG}_CFG[7]}
if [ "$PKG_USE" = true ]; then IFS=","
for DEP in $PKG_DPS; do eval DEP_USE=\${${DEP}_CFG[0]}
if [ "$DEP_USE" != true ]; then
eval ${PKG}_CFG[0]=false
echo "WARNING: Disabling $PKG - requires $DEP.";
fi; done; IFS=" "; fi; done
# Write the configuation to screen and file, update the pythia8-config script.
sed 's|^CFG_FILE=.*|CFG_FILE='"$PREFIX_SHARE"'/examples/Makefile.inc|;n' \
bin/pythia8-config > bin/tmp
chmod a+x bin/tmp; mv bin/tmp bin/pythia8-config
echo "---------------------------------------------------------------------"
echo "| PYTHIA Configuration Summary |"
echo "---------------------------------------------------------------------"
echo "Configured for $ARCH with the following options:"
if [ "$ENABLE_DEBUG_SET" = true ]; then echo "--enable-debug"; fi
if [ "$ENABLE_64BIT_SET" = true ]; then echo "--enable-64bit"; fi
if [ "$ENABLE_SHARED_SET" = true ]; then echo "--enable-shared"; fi
if [ "$LCG_SET" = true ]; then echo "--lcg=$LCG"; fi
cat >> $CFG_FILE << BLOCKTEXT
# Install directory prefixes.
PREFIX_BIN=$PREFIX_BIN
PREFIX_INCLUDE=$PREFIX_INCLUDE
PREFIX_LIB=$PREFIX_LIB
PREFIX_SHARE=$PREFIX_SHARE
# Compilation flags (see ./configure --help for further documentation).
ENABLE_SHARED=$ENABLE_SHARED
CXX=$CXX
CXX_COMMON=$CXX_COMMON
CXX_SHARED=$CXX_SHARED
CXX_SONAME=$CXX_SONAME
LIB_SUFFIX=$LIB_SUFFIX
BLOCKTEXT
echo ""
echo "The following optional external packages will be used:"
for IDX in ${!PKG_LIST[@]}; do
PKG=${PKG_LIST[$IDX]}
eval PKG_USE=\${${PKG}_CFG[0]}
if [ "$PKG_USE" = true ]; then echo "* $PKG"
eval PKG_BIN=\${${PKG}_CFG[1]}; eval PKG_INC=\${${PKG}_CFG[2]};
eval PKG_LIB=\${${PKG}_CFG[3]};
if [ -n "$PKG_BIN" ]; then PKG_BIN+=/; fi
else PKG_BIN=""; PKG_INC="./"; PKG_LIB="./"; fi
cat >> $CFG_FILE << BLOCKTEXT
# $PKG configuration.
${PKG}_USE=$PKG_USE
${PKG}_BIN=$PKG_BIN
${PKG}_INCLUDE=$PKG_INC
${PKG}_LIB=$PKG_LIB
BLOCKTEXT
if [ "$PKG" = "LHAPDF6" ]; then
echo "${PKG}_PLUGIN=$LHAPDF6_PLUGIN" >> $CFG_FILE; fi
if [ "$PKG" = "LHAPDF5" ]; then echo "${PKG}_PLUGIN=LHAPDF5.h" >> $CFG_FILE; fi
done
echo ""