forked from cms-externals/fastjet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fastjet-config.in
executable file
·353 lines (312 loc) · 9.49 KB
/
fastjet-config.in
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
#!/bin/bash
#
# @configure_input@
#
# This is the base script for retrieving all information
# regarding compiling and linking programs using FastJet.
# Run ./fastjet-config without arguments for usage details
#########################################################
# the list of plugins is dynamic so we need the following
# line to deal with the static lib link
installationdir=@prefix@
prefix=@prefix@
exec_prefix=@exec_prefix@
# print a usage message and exit
# exit code passed as argument:
# 0 if it is a normal call
# 1 if it is due to a misusage.
usage()
{
if [ "x@HAS_SHARED@" == "xyes" ] ; then
cat 1>&2 <<EOF
This is FastJet @VERSION@ configuration tool.
Usage:
fastjet-config [--help] [--version] [--prefix] [--cxxflags] [--libs]
[--shared[=yes|no]] [--plugins[=yes|no]] [--rpath[=yes|no]] [--runpath]
[--list-plugins] [--config]
The arguments can be either queries (one must be present):
--help prints this message and exits
--version prints FastJet version and exits
--prefix gets the FastJet installation directory
--cxxflags returns the compilation flags to be used with C++ programs
--libs returns the flags to pass to the linker
or flags (optional):
--shared controls whether you want to use the static or shared lib
(default=yes)
--plugins controls whether you also want to link the FastJet plugins
(default=no)
--rpath adds a -rpath argument at link-time that points to the
directory where FastJet libraries are installed. This
avoid having to set LD_LIBRARY_PATH at runtime when
using shared libs in a non standard location (but may
cause the program to inadvertently pick up other shared
libraries that happen to be in the FastJet installation
directory).
(default=yes)
--runpath at link-time, adds info about the directory where FastJet
libraries are installed to the runpath (ELF systens
only). This avoids having to set LD_LIBRARY_PATH at
runtime when using shared libs in a non standard
location but gives priority to an existing LD_LIBRARY_PATH.
--list-plugins list all the available plugins
--config shows a summary of how FastJet was configured
EOF
else
cat 1>&2 <<EOF
This is FastJet @VERSION@ configuration tool.
Usage:
fastjet-config [--help] [--version] [--prefix] [--cxxflags] [--libs]
[--plugins[=yes|no]] [--list-plugins] [--config]
The arguments can be either queries (one must be present):
--help prints this message and exits
--version prints FastJet version and exits
--prefix get the FastJet installation directory
--cxxflags returns the compilation flags to be used with C++ programs
--libs returns the flags to pass to the linker
or flags (optional):
--plugins controls whether you also want to link the FastJet plugins
(default=no)
--list-plugins list all the available plugins
--config shows a summary of how FastJet was configured
EOF
fi
exit $1
}
# first deal with the case where no argument is passed
[ $# -gt 0 ] || usage 1
# tools to parse options
########################
# option_name _string
# Returns NAME if _string is of the form: --NAME[=...]
option_name()
{
echo "$1" | sed 's/^--//;s/=.*//' | tr '-' '_'
}
# option_value _string
# Returns FOO if _string is of the form: --option=FOO
option_value()
{
echo "$1" | sed 's/^[^=]*=//'
}
# is_in_list _arg _arg_list
# return true if the argument _arg is in the list _arg_list
# and false otherwise
is_in_list()
{
arg_match="$1"
shift
for arg_match_i do
[ "x$arg_match_i" != "x$arg_match" ] || return 0
done
false
}
# useful utilities
##################
# wite error messages and exit
write_error()
{
echo "Error: $1"
echo "Use fastjet-config --help for more information"
exit 1
}
# browse the argument list
# This is done the following way:
# - at first pass, we check if the --help argument is set. If yes,
# print usage and exit.
# we also and make sure that there is no interference between the
# arguments (e.g. --cflags --libs is wrong)
# - we then check for extra arguments and return the requested info
#####################################################################
# useful lists of arguments
arg_query_list="version prefix list_plugins config help" # cxxflags libs
arg_yesno_list="shared plugins rpath"
# default behaviour for parameters
plugins_included="no"
use_shared="yes"
add_rpath="yes"
add_runpath="no"
# no query found initially
found_query="no"
found_flags="no"
found_libs="no"
# browse arguments
for arg do
case "$arg" in
--help|-h)
usage 0
;;
--*=*)
arg_name=`option_name $arg`
arg_value=`option_value $arg`
# check the validity of the parmeter value
if ! is_in_list $arg_value yes no ; then
write_error "$arg: parameter value must be yes or no"
fi
# set the parameter value
case $arg_name in
plugins)
plugins_included="$arg_value"
;;
shared)
use_shared="$arg_value"
if [ "x$arg_value" == "xno" ] ; then
add_rpath="no"
fi
;;
rpath)
if test "x@HAS_SHARED@" = "xyes" ; then
add_rpath="$arg_value"
else
write_error "--rpath is only available together with shared libraries"
fi
;;
*)
write_error "$arg: unrecognised argument"
;;
esac
;;
--cxxflags)
# we've found a query, make sure we don't already have one
# except if it is --libs
if [[ "x$found_query" != "xno" && "x$found_query" != "xlibs" ]]; then
write_error "--cxxflags cannot be used with --$found_query"
fi
# update found_query
# note: for the "big case" later, don't overwrite it if libs are already asked for
found_flags="yes"
if [ "x$found_query" != "xlibs" ]; then
found_query="cxxflags"
fi
;;
--libs)
# we've found a query, make sure we don't already have one
# except if it is --cxxflags
if [[ "x$found_query" != "xno" && "x$found_query" != "xcxxflags" ]]; then
write_error "--libs cannot be used with --$found_query"
fi
# update found_query
found_libs="yes"
found_query="libs"
;;
--*)
arg_name=`option_name $arg`
if is_in_list $arg_name $arg_query_list ; then
# we've found a query, make sure we don't already have one
if [ "x$found_flags" != "xno" ] ; then
write_error "--$arg_name cannot be used with --cxxflags"
fi
if [ "x$found_libs" != "xno" ] ; then
write_error "--$arg_name cannot be used with --libs"
fi
if [ "x$found_query" != "xno" ] ; then
write_error "You can only make one query at a time"
fi
found_query="$arg_name"
else
if is_in_list $arg_name $arg_yesno_list ; then
# we've found a parameter, set it to "yes"
case $arg_name in
plugins)
plugins_included="yes"
;;
shared)
use_shared="yes"
;;
rpath)
if test "x@HAS_SHARED@" = "xyes" ; then
add_rpath="yes"
else
write_error "--rpath is only available together with shared libraries"
fi
;;
*)
write_error "$arg: unrecognised argument"
;;
esac
else
case $arg_name in
runpath)
if test "x@HAS_SHARED@" = "xyes" ; then
if test "x@HAS_RUNPATH_SUPPORT@" = "xyes" ; then
add_runpath="yes"
add_rpath="no"
else
write_error "--runpath is not available on this platform"
fi
else
write_error "--runpath is only available together with shared libraries"
fi
;;
*)
write_error "$arg: unrecognised argument"
;;
esac
fi
fi
;;
*)
write_error "$arg is not a valid argument"
;;
esac
done
# now deal with the output
case $found_query in
no)
write_error "you must at least specify one query in '$arg_query_list'"
;;
version)
echo @PACKAGE_VERSION@
;;
prefix)
echo @prefix@
;;
cxxflags)
echo -I@includedir@ @CONFIG_CXXFLAGS@
;;
libs)
libs_string=" @CONFIG_LIBS@"
# since we use the system default (use shared lib if available, static
# otherwise), we only need to worry if shared available and static
# explicitely asked
if test "x$use_shared" = "xno" && test "x@HAS_SHARED@" = "xyes" ; then
libs_string=$libs_string" @libdir@/libfastjettools.a @libdir@/libfastjet.a"
else
libs_string=$libs_string" -L@libdir@ -lfastjettools -lfastjet"
fi
if test "x$add_rpath" = "xyes" ; then
libs_string="-Wl,-rpath,@libdir@ "$libs_string
else
# GPS 2009-05-29: remove any left over -Wl, e.g. related to CGAL.
libs_string=`echo $libs_string | sed 's/-Wl,-rpath[^ ]*//'`
fi
if test "x$add_runpath" = "xyes" ; then
libs_string="@CONFIG_RUNPATH_FLAGS@ -Wl,-rpath,@libdir@ "$libs_string
fi
if test "x$plugins_included" = "xyes" ; then
if test "x$use_shared" = "xno" && test "x@HAS_SHARED@" = "xyes" ; then
libs_string=$libs_string" @CONFIG_LIBS_PLUGINS_STATIC@"
else
libs_string=$libs_string" @CONFIG_LIBS_PLUGINS@"
fi
fi
if [ "x$found_flags" = "xyes" ] ; then
echo -I@includedir@ @CONFIG_CXXFLAGS@ $libs_string
else
echo $libs_string
fi
;;
list_plugins)
echo "Available plugins: "
echo -n " "
echo @LIST_ALL_PLUGINS@ | sed -e "s/ /\\`printf '\n\r '`/g"
;;
config)
echo "This is FastJet version @PACKAGE_VERSION@"
echo ""
echo "Configuration invocation was"
echo ""
echo " @CONFIGURE_INVOCATION@"
echo ""
printf "@CONFIG_SUMMARY@"
;;
esac