Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309596
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
View Options
diff --git a/bin/rivet-buildplugin.in b/bin/rivet-buildplugin.in
--- a/bin/rivet-buildplugin.in
+++ b/bin/rivet-buildplugin.in
@@ -1,123 +1,129 @@
#!/usr/bin/env bash
## -*- sh -*-
## @configure_input@
## Print help
PROG=$(basename $0)
tmp=$(echo $* | egrep -- '--\<help\>|-\<h\>')
if test $# -lt 1 || test -n "$tmp"; then
echo "$PROG: compilation helper for Rivet analysis plugins"
echo
echo "Usage: $PROG [<libname>] <source1> [<source2> [compiler_flags] ...]"
echo
echo "<libname> can be a path, provided the filename is of the form 'Rivet*.so'"
echo "If <libname> is not specified, the default name is 'RivetAnalysis.so'."
echo
echo "To make special build variations you can add appropriate compiler flags"
echo "to the arguments and these will be passed directly to the compiler. For"
echo "example, for a debug build of your plugin library, add '-g', and for a"
echo "32 bit build on a 64 bit system add '-m32'."
echo
echo "Options:"
echo " -h | --help: display this help message"
echo " --with-root: add ROOT link options (requires root-config on system)"
echo
echo "TODO:"
echo " * is there a GCC option to parallelise the single-command compilation?"
test -n "$tmp"
exit $?
fi
## Work out shared library build flags by platform
shared_flags=
SWVERS=$(which sw_vers 2> /dev/null)
if test "$SWVERS" && test -x "$SWVERS"; then
## Mac OS X
shared_flags="-undefined dynamic_lookup -bundle"
else
## Unix
shared_flags="-shared -fPIC"
fi
## Get Rivet system C++ compiler (fall back to $CXX and then g++ if needed)
mycxx=g++
rivetcxx=$(which "@CXX@" 2> /dev/null)
abscxx=$(which "$CXX" 2> /dev/null)
if [[ -x "$rivetcxx" ]]; then
mycxx="@CXX@"
elif [[ -x "$abscxx" ]]; then
mycxx=$CXX
fi
## Get Rivet system C++ compiler flags
mycxxflags=""
if [[ -n "@AM_CXXFLAGS@" ]]; then
mycxxflags="@AM_CXXFLAGS@"
fi
if [[ -n "@CXXFLAGS@" ]]; then
mycxxflags="$mycxxflags @CXXFLAGS@"
fi
## Get Rivet system C preprocessor flags (duplicating that in rivet-config.in)
mycppflags=""
prefix="@prefix@"
irivet="@includedir@"
test -n "$irivet" && mycppflags="$mycppflags -I${irivet}"
ihepmc="@HEPMCINCPATH@"
test -n "$ihepmc" && mycppflags="$mycppflags -I${ihepmc}"
iyoda="@YODAINCPATH@"
test -n "$iyoda" && mycppflags="$mycppflags -I${iyoda}"
ifastjet="@FASTJETINCPATH@"
test -n "$ifastjet" && mycppflags="$mycppflags -I${ifastjet}"
igsl="@GSLINCPATH@"
test -n "$igsl" && mycppflags="$mycppflags -I${igsl}"
iboost="@BOOST_CPPFLAGS@"
test -n "$iboost" && mycppflags="$mycppflags ${iboost}"
+
## Get Rivet system linker flags (duplicating that in rivet-config.in)
-myldflags="-Wl,--no-as-needed"
+myldflags=""
lrivet="@libdir@"
test -n "$lrivet" && myldflags="$myldflags -L${lrivet}"
lhepmc="@HEPMCLIBPATH@"
test -n "$lhepmc" && myldflags="$myldflags -L${lhepmc}"
lyoda="@YODALIBPATH@"
test -n "$lyoda" && myldflags="$myldflags -L${lyoda}"
lfastjet="@FASTJETCONFIGLIBADD@"
test -n "$lfastjet" && myldflags="$myldflags ${lfastjet}"
+## Detect whether the linker accepts the --no-as-needed flag and prepend the linker flag with it if possible
+if (cd /tmp && echo -e 'int main() { return 0; }' > $$.cc; $mycxx -Wl,--no-as-needed $$.cc -o $$ 2> /dev/null); then
+ myldflags="-Wl,--no-as-needed $myldflags"
+fi
+
## Link against ROOT if requested
with_root=$(echo $* | egrep -- '--\<with-root\>')
# echo $with_root
tmp=${@//--with-root/}
set $tmp
## Get and check the library name
libname=$1
match1=$(basename "$libname" | egrep '^.*\.so')
match2=$(basename "$libname" | egrep '^Rivet.*\.so')
if test -n "$match1"; then
if test -z "$match2"; then
echo "Library name '$libname' does not have the required 'Rivet*.so' name pattern" 1>&2
exit 1
fi
## If we're using the first arg as the library name, shift it off the positional list
shift
else
echo "Using default library name 'RivetAnalysis.so'"
libname="RivetAnalysis.so"
fi
## Get the source files (and more flags)
sources_and_flags="$@"
if [[ -n $with_root ]]; then
root_flags=$(root-config --libs --cflags 2> /dev/null)
# echo $root_flags
sources_and_flags="$root_flags $sources_and_flags"
fi
## Build
cmd="$mycxx -o \"$libname\" $shared_flags $mycppflags $mycxxflags $myldflags $sources_and_flags"
echo $cmd
eval $cmd
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Dec 21, 3:52 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4023356
Default Alt Text
(4 KB)
Attached To
rRIVETHG rivethg
Event Timeline
Log In to Comment