Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #29454: hack m4/ppl.m4 to define PPL_LIBS.
Browse files Browse the repository at this point in the history
The upstream AM_PATH_PPL macro gets its LDFLAGS from the ppl-config
program, but fails to differentiate between LDFLAGS and LIBS. This
ultimately causes "-lppl" to be appended to the command-line in the
wrong spot. This commit hacks the macro to additionally define a
PPL_LIBS variable in the event that PPL is detected. This allows us to
append the flag in the right place, and avoid appending it in the
wrong place.
  • Loading branch information
orlitzky committed Apr 3, 2020
1 parent d766c29 commit 23d2b36
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
19 changes: 12 additions & 7 deletions build/pkgs/ppl/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
SAGE_SPKG_CONFIGURE([ppl], [
SAGE_SPKG_DEPCHECK([glpk gmp mpir], [
# If our dependencies come from the system, then we can use
# the system ppl, too. This macro works sort-of like the
# If our dependencies come from the system, then we can use the
# system ppl, too. This macro works sort-of like the
# PKG_CHECK_MODULES macro, defining e.g. PPL_CFLAGS when a
# suitable version of PPL is detected. But notably, it doesn't
# define PPL_LIBS.
AM_PATH_PPL([1.2],
[sage_spkg_install_ppl=no],
[sage_spkg_install_ppl=yes])
# suitable version of PPL is detected. The upstream version fails
# to differentiate between LDFLAGS and LIBS (which is in turn the
# fault of the ppl-config program), leading to argument-order
# problems on the command line. Our version of the macro
# defines PPL_LIBS separately so that we can distinguish the two.
AM_PATH_PPL([1.2], [
LIBS="$LIBS $PPL_LIBS"
sage_spkg_install_ppl=no
],
[sage_spkg_install_ppl=yes])
],
[ # Some of its dependencies are installed as SPKGs, so install the
# ppl SPKG as well.
Expand Down
23 changes: 22 additions & 1 deletion m4/ppl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,31 @@ then
no_ppl=yes
else
PPL_CPPFLAGS=`$PPL_CONFIG $ppl_config_args --cppflags`
PPL_LDFLAGS=`$PPL_CONFIG $ppl_config_args --ldflags`
PPL_LDFLAGS=""
PPL_LIBS=""
for flag in $($PPL_CONFIG $ppl_config_args --ldflags); do
dnl Check if each "ldflag" starts with -l or not. The ones that do
dnl start with -l are libs and belong in PPL_LIBS, the others belong
dnl in PPL_LDFLAGS. The LDFLAGS and LIBS variables get appended at
dnl different locations in the link command, so the distinction is
dnl not academic.
if test "x${flag#-l}" = "x$flag"; then
dnl this flag doesn't start with -l
PPL_LDFLAGS="$PPL_LDFLAGS $flag"
else
PPL_LIBS="$PPL_LIBS $flag"
fi
done
ppl_config_version="`$PPL_CONFIG $ppl_config_args --version`"
if test "x$enable_ppltest" = xyes
then
ac_save_CPPFLAGS="$CPPFLAGS"
ac_save_LDFLAGS="$LDFLAGS"
ac_save_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $PPL_CPPFLAGS"
LDFLAGS="$PPL_LDFLAGS $LDFLAGS"
LIBS="$LIBS $PPL_LIBS"
dnl Now check if the installed PPL is sufficiently new.
dnl (Also sanity checks the results of ppl-config to some extent.)
Expand Down Expand Up @@ -224,6 +240,7 @@ main() {
CPPFLAGS="$ac_save_CPPFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
Expand All @@ -247,6 +264,7 @@ else
echo "*** Could not run PPL test program, checking why..."
CPPFLAGS="$CPPFLAGS $PPL_CPPFLAGS"
LDFLAGS="$LDFLAGS $PPL_LDFLAGS"
LIBS="$LIBS $PPL_LIBS"
AC_TRY_LINK([
#include <ppl.hh>
using namespace Parma_Polyhedra_Library;
Expand Down Expand Up @@ -276,13 +294,16 @@ using namespace Parma_Polyhedra_Library;
])
CPPFLAGS="$ac_save_CPPFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
PPL_CPPFLAGS=""
PPL_LDFLAGS=""
PPL_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(PPL_CPPFLAGS)
AC_SUBST(PPL_LDFLAGS)
AC_SUBST(PPL_LIBS)
rm -f conf.ppltest
])

0 comments on commit 23d2b36

Please sign in to comment.