diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ada1e6b..3a7a6b4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,7 +19,7 @@ concurrency: jobs: # The CI test job test: - name: ${{ matrix.gap-version }} ${{ matrix.os }} + name: ${{ matrix.gap-version }} ${{ matrix.os }}${{ matrix.system-libnormaliz && ' libnormaliz' || '' }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -31,15 +31,19 @@ jobs: - '4.13' - '4.12' os: [ubuntu-latest] + system-libnormaliz: [true,false] include: - - gap-version: master + - gap-version: 'devel' os: macos-latest + system-libnormaliz: false steps: - uses: actions/checkout@v6 - - uses: Chocobo1/setup-ccache-action@v1 - with: - update_packager_index: false + - name: "Install and use system libnormaliz" + if: ${{ matrix.system-libnormaliz }} + run: | + rm prerequisites.sh # prevent build-pkg from building Normaliz + sudo apt install libnormaliz-dev # install system libnormaliz - uses: gap-actions/setup-gap@v3 with: gap-version: ${{ matrix.gap-version }} diff --git a/README.md b/README.md index 6d3f062..64f31c7 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,24 @@ Not specifying GAPDIR is equivalent to passing `../..` as GAPDIR. If more than one argument is specified, then any arguments beyond the first are passed on to the Normaliz `configure` script. -Once the script completed successfully, you can build NormalizInterface -like this: +If you already have a suitable Normaliz installation in a standard +location such as `/opt/homebrew`, `/usr/local`, `/opt/local`, `/usr`, +or `/opt`, then `configure` will try to detect and use it +automatically. Otherwise, or if you want to override the detected +location, you can still use `prerequisites.sh` to build a local copy +or pass `--with-normaliz=PATH` explicitly. + +Once the script completed successfully, or if you rely on an installed +Normaliz found by `configure`, you can build NormalizInterface like +this: ./configure --with-gaproot=GAPDIR make The ` --with-gaproot=GAPDIR` parameter is actually optional, and if omitted, the package will search for GAP in `../..`. +Likewise, `--with-normaliz=PATH` is optional and only needed if +automatic detection does not pick the desired installation. ## Documentation and tests diff --git a/configure.ac b/configure.ac index 7415482..5c74749 100644 --- a/configure.ac +++ b/configure.ac @@ -68,20 +68,62 @@ dnl ## Locate Normaliz dnl ## NORMALIZ_RPATH_EXTRA="" +NORMALIZ_LIBDIR="" AC_ARG_WITH([normaliz], [AS_HELP_STRING([--with-normaliz=], [specify root of Normaliz installation])], [NORMALIZ="$with_normaliz"], - [NORMALIZ="$PWD/NormalizInstallDir" - # The following is a hack to ensure compatibility with versions of gac that - # don't use GNU libtool anymore, and thus don't set a run path pointing to - # the specific version of libnormaliz we requested. Without this, when GAP - # loads NormalizInterface.so it may not find the libnormaliz shared library. - NORMALIZ_RPATH_EXTRA="-Wl,-rpath,$NORMALIZ/lib" + [NORMALIZ="" + NORMALIZ_DIRS=${NORMALIZ_DIRS:-"/opt/homebrew /usr/local /opt/local /usr /opt"} + AC_MSG_CHECKING([for an installed Normaliz]) + for normaliz_dir in $NORMALIZ_DIRS; do + if test -f "$normaliz_dir/include/libnormaliz/cone.h"; then + if test -d "$normaliz_dir/lib64"; then + normaliz_libdir="$normaliz_dir/lib64" + elif test -d "$normaliz_dir/lib"; then + normaliz_libdir="$normaliz_dir/lib" + else + continue + fi + + old_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$normaliz_dir/include $GMP_CPPFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include "libnormaliz/cone.h"]], + [[#if !defined(NMZ_RELEASE) || NMZ_RELEASE < 30504 + #error Normaliz too old + #endif + return 0;]])], + [NORMALIZ="$normaliz_dir" + NORMALIZ_LIBDIR="$normaliz_libdir" + break], + []) + CPPFLAGS="$old_CPPFLAGS" + fi + done + + if test "x$NORMALIZ" != "x"; then + AC_MSG_RESULT([$NORMALIZ]) + else + NORMALIZ="$PWD/NormalizInstallDir" + NORMALIZ_LIBDIR="$NORMALIZ/lib" + AC_MSG_RESULT([not found, falling back to $NORMALIZ]) + # The following is a hack to ensure compatibility with versions of gac that + # don't use GNU libtool anymore, and thus don't set a run path pointing to + # the specific version of libnormaliz we requested. Without this, when GAP + # loads NormalizInterface.so it may not find the libnormaliz shared library. + NORMALIZ_RPATH_EXTRA="-Wl,-rpath,$NORMALIZ_LIBDIR" + fi ] ) +if test "x$NORMALIZ_LIBDIR" = "x"; then + if test -d "$NORMALIZ/lib64"; then + NORMALIZ_LIBDIR="$NORMALIZ/lib64" + else + NORMALIZ_LIBDIR="$NORMALIZ/lib" + fi +fi NORMALIZ_CPPFLAGS="-I$NORMALIZ/include" -NORMALIZ_LDFLAGS="$NORMALIZ_RPATH_EXTRA -L$NORMALIZ/lib" +NORMALIZ_LDFLAGS="$NORMALIZ_RPATH_EXTRA -L$NORMALIZ_LIBDIR" AC_SUBST(NORMALIZ_LDFLAGS) AC_SUBST(NORMALIZ_CPPFLAGS) diff --git a/examples/docs.g b/examples/docs.g index 843ab23..91ff073 100644 --- a/examples/docs.g +++ b/examples/docs.g @@ -13,16 +13,16 @@ NmzHasConeProperty(cone, "ExtremeRays"); #! @EndChunk #! @BeginChunk NmzKnownConeProperties_example -#! @BeginExample -NmzKnownConeProperties(cone); +#! @BeginLogSession +#! NmzKnownConeProperties(cone); #! [ ] -#! @EndExample +#! @EndLogSession #! @EndChunk #! @BeginChunk NmzCompute_example #! @BeginExample -NmzKnownConeProperties(cone); -#! [ ] +NmzHasConeProperty(cone, "SupportHyperplanes"); +#! false NmzCompute(cone, ["SupportHyperplanes", "IsPointed"]); #! true NmzKnownConeProperties(cone); diff --git a/tst/normalizinterface01.tst b/tst/normalizinterface01.tst index b4ce4ef..d94b750 100644 --- a/tst/normalizinterface01.tst +++ b/tst/normalizinterface01.tst @@ -18,13 +18,9 @@ gap> cone := NmzCone(["integral_closure",[[2,1],[1,3]]]); gap> NmzHasConeProperty(cone, "ExtremeRays"); false -# doc/_Chunks.xml:123-126 -gap> NmzKnownConeProperties(cone); -[ ] - # doc/_Chunks.xml:131-148 -gap> NmzKnownConeProperties(cone); -[ ] +gap> NmzHasConeProperty(cone, "SupportHyperplanes"); +false gap> NmzCompute(cone, ["SupportHyperplanes", "IsPointed"]); true gap> NmzKnownConeProperties(cone);