Skip to content

Commit

Permalink
Trac #29335: Fix Singular configure so it accepts NTL installed in no…
Browse files Browse the repository at this point in the history
…nstandard locations

As observed in #29104, Singular's configure may fail to find NTL even if
Sage finds a system NTL. It continues to build, but the result is
broken.

The details:

NTL's `spkg-configure.m4` (from #27265/#27822) uses
`AC_CHECK_HEADER`/`AC_LINK_IFELSE`/`AC_RUN_IFELSE` and therefore is able
to find NTL in an environment where the user has set CPPFLAGS and
LDFLAGS accordingly.
In that case, it sets `AC_SUBST(SAGE_NTL_PREFIX, [''])`

Then `build/bin/sage-build-env-config.in` does:
{{{
# This is usually blank if the system NTL is used, or $SAGE_LOCAL
otherwise
export SAGE_NTL_PREFIX="@SAGE_NTL_PREFIX@"
if [ -n "$SAGE_NTL_PREFIX" ]; then
    # Many packages that depend on NTL accept a --with-ntl=<prefix> flag
to
    # their ./configure scripts.  When using the system's NTL this is
not
    # generally necessary, but when using the NTL package installed in
    # SAGE_LOCAL it is useful to pass it.
    export SAGE_CONFIGURE_NTL="--with-ntl=$SAGE_NTL_PREFIX"
fi
}}}

But Singular's `configure` (via its `m4/ntl-check.m4`) insists to find
the headers in `NTL_HOME_PATH`, which defaults to
`DEFAULT_CHECKING_PATH="/usr /usr/local /sw /opt/local"`, which can of
course be quite wrong.

On this ticket, we use a simple patch that modifies Singular's NTL
detection code to make it similar to its GMP and FLINT detection codes.

An alternative solution would be to always provide the --with-ntl=PREFIX
option to Singular.
We should also make it an error if Singular's configure cannot find NTL.

See also: #25993 - Upgrade Singular

URL: https://trac.sagemath.org/29335
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Dima Pasechnik
  • Loading branch information
Release Manager committed Mar 18, 2020
2 parents be1e22c + 50f62c7 commit c480201
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions build/pkgs/singular/patches/configure-no-ntl-header-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/configure b/configure
index 6bc79d9935..f39dcdb95f 100755
--- a/configure
+++ b/configure
@@ -20713,7 +20713,7 @@ fi

for NTL_HOME in ${NTL_HOME_PATH}
do
-if test -r "$NTL_HOME/include/NTL/ZZ.h"; then
+## if test -r "$NTL_HOME/include/NTL/ZZ.h"; then

if test "x$NTL_HOME" != "x/usr"; then
NTL_CPPFLAGS="-I${NTL_HOME}/include"
@@ -20784,9 +20784,9 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-else
- ntl_found="no"
-fi
+## else
+## ntl_found="no"
+## fi
done

if test "x$ntl_found" = "xyes" ; then
26 changes: 26 additions & 0 deletions build/pkgs/singular/patches/ntl-check-m4-no-ntl-header-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/m4/ntl-check.m4 b/m4/ntl-check.m4
index 50af64be6b..ae81557a77 100644
--- a/m4/ntl-check.m4
+++ b/m4/ntl-check.m4
@@ -48,7 +48,7 @@ fi

for NTL_HOME in ${NTL_HOME_PATH}
do
-if test -r "$NTL_HOME/include/NTL/ZZ.h"; then
+## if test -r "$NTL_HOME/include/NTL/ZZ.h"; then

if test "x$NTL_HOME" != "x/usr"; then
NTL_CPPFLAGS="-I${NTL_HOME}/include"
@@ -92,9 +92,9 @@ if test -r "$NTL_HOME/include/NTL/ZZ.h"; then
unset NTL_CPPFLAGS
unset NTL_LIBS
])
-else
- ntl_found="no"
-fi
+## else
+## ntl_found="no"
+## fi
done

if test "x$ntl_found" = "xyes" ; then

0 comments on commit c480201

Please sign in to comment.