-
Notifications
You must be signed in to change notification settings - Fork 0
/
pythia8-config.inc
165 lines (150 loc) · 7.57 KB
/
pythia8-config.inc
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
#!/usr/bin/env bash
# pythia8-config is a part of the PYTHIA event generator.
# Copyright (C) 2024 Torbjorn Sjostrand.
# PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
# Please respect the MCnet Guidelines, see GUIDELINES for details.
# Author: Philip Ilten, October 2014 - Februrary 2024.
#
# Configuration tool for the PYTHIA event generator library. Eaxmple usage is:
# ./pythia8-config --cxxflags --ldflags --hepmc2
# For help please use:
# ./pythia8-config --help
# which will print a full list of 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=examples/Makefile.inc
read -d "" USAGE << "BLOCKTEXT"
Usage: ./pythia8-config [OPTIONS]
Configuration tool for the PYTHIA event generator library. The available
options are defined below. All available options (without arguments) for the
PYTHIA configuration script are also valid for this script. See
"./configuration --help" in the top PYTHIA 8 directory for more details.
Available options.
--help : Print this help message (also -h, --h, and -help).
--config : Print the argument(s) used to configure Pythia.
--prefix : Installation prefix (cf. autoconf). Note that if the
installation is spread over multiple directories, the
binary directory with the trailing "bin" removed is
then returned.
--bindir : PYTHIA binary directory (equivalent to --prefix-bin).
--libdir : PYTHIA library directory (equivalent to --prefix-lib).
--includedir : PYTHIA header directory (equivalent to --prefix-include).
--datadir : PYTHIA share directory (equivalent to --prefix-share).
--xmldoc : PYTHIA xmldoc directory.
--cxxflags : Returns the compiler flags and PYTHIA -I flag string needed
for compilation.
--cflags : Equivalent to --cxxflags.
--ldflags : Returns the PYTHIA -L/-l flag string needed for compilation.
--libs : Equivalent to --ldflags.
--PACKAGE : Provides the -I/-L/-l flags needed to link with an external
PACKAGE from the following list.
--with-PACKAGE : Returns "true" if the package is enabled, otherwise "false".
evtgen : Particle decays with the EvtGen decay pacakge, requires HEPMC2.
fastjet3 : Building of jets using the FastJet package, version 3.
(run fastjet-config --prefix to see which path to use.)
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.2.
powheg : Hard process production with POWHEGBOX matrix element executables.
rivet : Support use of RIVET through direct interface.
root : Use ROOT trees and histograms with PYTHIA.
Note: this option automatically invokes DIR/bin/root-config to set
the ROOT lib/ and include/ paths. To set your ROOT paths manually
instead, use --with-root-lib=DIR and --with-root-include=DIR.
gzip : Enable reading of GZIPPED files using the libz library.
python : Interface to use PYTHIA in Python.
mg5mes : MadGraph matrix element plugins for parton showers.
openmp : Multi-threading support via OpenMP.
mpich : Multi-threading support via MPICH.
hdf5 : Support the use of HDF5.
highfive : HighFive headers, also needed for reading HDF5 Les Houches.
BLOCKTEXT
OPTIONS="-h --h -help --help --config --prefix --bindir --libdir --includedir"
OPTIONS+=" --datadir --xmldoc --cxxflags --cflags --ldflags --libs"
for PKG in "evtgen" "fastjet3" "hepmc2" "hepmc3" "lhapdf5" "lhapdf6" "powheg"\
"rivet" "root" "gzip" "python" "mg5mes" "openmp" "mpich" "hdf5"\
"highfive"; do
OPTIONS+=" --$PKG --with-$PKG"; done
################################################################################
# FUNCTION: Print formatted information to screen.
# bold/error/warn <message>
# Errors are reported as white-on-red and warnings as black on yellow.
################################################################################
function bold() {
if [ -z "$TERM" ] || ! type "tput" &> /dev/null; then echo -e $@
else echo -e $(tput bold)$@$(tput sgr0); fi
}
function warn() {
if [ -z "$TERM" ] || ! type "tput" &> /dev/null; then echo -e $@
else echo -e $(tput setaf 0)$(tput setab 3)WARNING: $@$(tput sgr0); fi
}
function error() {
if [ -z "$TERM" ] || ! type "tput" &> /dev/null; then echo -e $@
else echo -e $(tput setaf 7)$(tput setab 1)ERROR: $@$(tput sgr0); fi
}
################################################################################
# MAIN: The main execution of the script.
################################################################################
# Check if help requested.
if [ $# -eq 0 ]; then echo "$USAGE"; exit; fi
for VAR in "$@"; do
if [ "$VAR" = "-h" ] || [ "$VAR" = "--h" ] || [ "$VAR" = "-help" ] \
|| [ "$VAR" = "--help" ]; then echo "$USAGE"; exit; fi; done
# Read the configuration (use local version first, then installed version).
PREFIX=$(cd "$(dirname "${BASH_SOURCE[0]}")"; cd ../; pwd)
if [ -f $PREFIX/Makefile.inc ]; then CFG_FILE="$PREFIX/Makefile.inc"
elif [ ! -f $CFG_FILE ]; then
echo "Error: cannot find valid configuration for Pythia 8"; exit; fi
while read LINE; do
if [[ $LINE == \#\ --* ]]; then CONFIG+=${LINE#?}; fi
if [[ $LINE != *=* ]]; then continue; fi
VAR=${LINE%%=*}; VAL=${LINE#*=};
eval $VAR=\"$VAL\"; done < $CFG_FILE
# Check if configuration is requested.
for VAR in "$@"; do
if [ "$VAR" = "--config" ]; then echo "./configure$CONFIG"; exit; fi; done
# Change the prefixes if local version.
if [ "$CFG_FILE" = "$PREFIX/Makefile.inc" ]; then
PREFIX_BIN="$PREFIX/bin"; PREFIX_INCLUDE="$PREFIX/include"
PREFIX_LIB="$PREFIX/lib"; PREFIX_SHARE="$PREFIX/share/Pythia8"; fi
# Parse the arguments.
for VAR in "$@"; do
if ! [[ $OPTIONS =~ (^| )${VAR%%=*}($| ) ]]; then
warn "Ignoring invalid option \"${VAR%=*}\".";
continue;
fi
VAR=$(echo ${VAR#--} | awk '{print toupper($0)}'); VAR=${VAR//"-"/"_"}
# Handle the equivalent arguments.
if [ "$VAR" = "BINDIR" ]; then VAR="PREFIX_BIN"
elif [ "$VAR" = "LIBDIR" ]; then VAR="PREFIX_LIB"
elif [ "$VAR" = "INCLUDEDIR" ]; then VAR="PREFIX_INCLUDE"
elif [ "$VAR" = "DATADIR" ]; then VAR="PREFIX_SHARE"
elif [ "$VAR" = "XMLDOC" ]; then VAR="PREFIX_SHARE/xmldoc"
elif [ "$VAR" = "LIBS" ]; then VAR="LDFLAGS"
elif [ "$VAR" = "CFLAGS" ]; then VAR="CXXFLAGS"; fi
# All "--with" arguments.
if [[ $VAR = WITH_* ]]; then
VAR=${VAR#WITH_}; eval VAL=\$${VAR}_USE
if [ -z "$VAL" ]; then eval OUT=\"$OUT \$$VAR\"
else OUT="$OUT $VAL"; fi;
# All "--prefix" arguments.
elif [[ $VAR = PREFIX* ]]; then eval OUT=\"$OUT \$$VAR\"
# Flag arguments.
elif [ "$VAR" = "CXXFLAGS" ]; then OUT="$OUT $CXX_COMMON -I$PREFIX_INCLUDE"
elif [ "$VAR" = "LDFLAGS" ]; then
OUT="$OUT -L$PREFIX_LIB -Wl,-rpath,$PREFIX_LIB -lpythia8 $GZIP_LIB"
# Package arguments.
else
eval INC=\$${VAR}_INCLUDE
eval LIB=\$${VAR}_LIB
OUT="$OUT $INC $LIB"
fi
done
# Print the output.
if [ "$VAR" = "LDFLAGS" ]; then OUT+=" -ldl"; fi
if [[ ! -z "${OUT// }" ]]; then echo $OUT; fi