gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master b420190 1/2: Installation: More robust checks


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master b420190 1/2: Installation: More robust checks of libraries with AC_LIB_LINKFLAGS
Date: Fri, 31 May 2019 15:27:42 -0400 (EDT)

branch: master
commit b420190fd5153522ea4c564c25980821021413d1
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Installation: More robust checks of libraries with AC_LIB_LINKFLAGS
    
    Until now, we only check for the link-ability of a library. But it was
    recently pointed out by Bruno Haible that we can use Gnulib's
    `AC_LIB_LINKFLAGS' to add `rpath', while doing better tests on the properly
    found libraries.
    
    With this commit, the checking of libraries now uses this Gnulib autoconf
    check which actually includes compiling and linking a small test
    program. Also, the test for the Steffen library in GSL now uses the much
    more robust `AC_LINK_IFELSE' Autoconf test which actually tries compiling
    and linking a small test program also. This will allow avoiding many
    frustrating bugs when multiple versions of GSL are available in the system.
    
    This test was done with the help of Elham Saremi and Raul Infante Sainz.
---
 NEWS                         |   5 ++
 THANKS                       |   1 +
 bin/TEMPLATE/Makefile.am     |   2 +-
 bin/arithmetic/Makefile.am   |   2 +-
 bin/buildprog/Makefile.am    |   2 +-
 bin/buildprog/buildprog.c    |   3 +-
 bin/convertt/Makefile.am     |   2 +-
 bin/convolve/Makefile.am     |   2 +-
 bin/cosmiccal/Makefile.am    |   2 +-
 bin/crop/Makefile.am         |   2 +-
 bin/fits/Makefile.am         |   2 +-
 bin/match/Makefile.am        |   2 +-
 bin/mkcatalog/Makefile.am    |   2 +-
 bin/mknoise/Makefile.am      |   2 +-
 bin/mkprof/Makefile.am       |   2 +-
 bin/noisechisel/Makefile.am  |   2 +-
 bin/segment/Makefile.am      |   2 +-
 bin/statistics/Makefile.am   |   2 +-
 bin/table/Makefile.am        |   2 +-
 bin/warp/Makefile.am         |   2 +-
 bootstrap.conf               |   1 +
 configure.ac                 | 141 ++++++++++++++++++++++++++++++++++---------
 doc/announce-acknowledge.txt |   1 +
 lib/Makefile.am              |   2 +-
 tests/Makefile.am            |   2 +-
 25 files changed, 143 insertions(+), 47 deletions(-)

diff --git a/NEWS b/NEWS
index 1f656bd..f334c9e 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,11 @@ See the end of the file for license conditions.
 
 ** Changed features
 
+  Installation:
+   - Better `./configure' tests (using Gnulib's `AC_LIB_HAVE_LINKFLAGS') to
+     avoid some crashes during `make' when the host had multiple
+     conflicting versions of some dependencies (GSL in particular).
+
   Arithmetic:
    - The output of coadding operators is no longer the same type as the
      input in general. The output of the `min' and `max' operators are
diff --git a/THANKS b/THANKS
index 90a71a5..bfe6ab9 100644
--- a/THANKS
+++ b/THANKS
@@ -38,6 +38,7 @@ support in Gnuastro. The list is ordered alphabetically (by 
family name).
     Gaspar Galaz                         address@hidden
     Thérèse Godefroy                     address@hidden
     Madusha Gunawardhana                 address@hidden
+    Bruno Haible                         address@hidden
     Stephen Hamer                        address@hidden
     Takashi Ichikawa                     address@hidden
     Raúl Infante Sainz                   address@hidden
diff --git a/bin/TEMPLATE/Makefile.am b/bin/TEMPLATE/Makefile.am
index bab4ad9..abf9666 100644
--- a/bin/TEMPLATE/Makefile.am
+++ b/bin/TEMPLATE/Makefile.am
@@ -33,7 +33,7 @@ bin_PROGRAMS = astTEMPLATE
 ## don't keep external variables (needed in Argp) after the first link. So
 ## the `libgnu' (that is indirectly linked through `libgnuastro') can't see
 ## those variables. We thus need to explicitly link with `libgnu' first.
-astTEMPLATE_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astTEMPLATE_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astTEMPLATE_SOURCES = main.c ui.c TEMPLATE.c
 
diff --git a/bin/arithmetic/Makefile.am b/bin/arithmetic/Makefile.am
index 6d562d8..332450b 100644
--- a/bin/arithmetic/Makefile.am
+++ b/bin/arithmetic/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astarithmetic
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astarithmetic_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astarithmetic_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astarithmetic_SOURCES = main.c ui.c arithmetic.c operands.c
 
diff --git a/bin/buildprog/Makefile.am b/bin/buildprog/Makefile.am
index fa4f1c5..3c81205 100644
--- a/bin/buildprog/Makefile.am
+++ b/bin/buildprog/Makefile.am
@@ -35,7 +35,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib \
 bin_PROGRAMS = astbuildprog
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astbuildprog_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astbuildprog_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 # Basic program sources.
 astbuildprog_SOURCES = main.c ui.c buildprog.c
diff --git a/bin/buildprog/buildprog.c b/bin/buildprog/buildprog.c
index ef706a8..52454ea 100644
--- a/bin/buildprog/buildprog.c
+++ b/bin/buildprog/buildprog.c
@@ -103,13 +103,14 @@ buildprog(struct buildprogparams *p)
       error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
 
   /* Write the full Libtool command into a string (to run afterwards). */
-  if( asprintf(&command, "%s -c \"%s %s %s%s --mode=link gcc %s %s "
+  if( asprintf(&command, "%s -c \"%s %s %s%s --mode=link gcc %s %s %s "
                "%s %s %s %s %s -I%s %s -o %s\"",
                GAL_CONFIG_GNULIBTOOL_SHELL,
                GAL_CONFIG_GNULIBTOOL_EXEC,
                p->cp.quiet ? "--quiet" : "",
                p->tag      ? "--tag="   : "",
                p->tag      ? p->tag    : "",
+               LDADD,                              /* From `config.h'. */
                warning     ? warning   : "",
                p->debug    ? "-g"      : "",
                optimize    ? optimize  : "",
diff --git a/bin/convertt/Makefile.am b/bin/convertt/Makefile.am
index c5f6e76..0f8fb5c 100644
--- a/bin/convertt/Makefile.am
+++ b/bin/convertt/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astconvertt
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astconvertt_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astconvertt_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astconvertt_SOURCES = main.c ui.c convertt.c color.c
 
diff --git a/bin/convolve/Makefile.am b/bin/convolve/Makefile.am
index 72aeadd..c47d0f0 100644
--- a/bin/convolve/Makefile.am
+++ b/bin/convolve/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astconvolve
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astconvolve_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astconvolve_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astconvolve_SOURCES = main.c ui.c convolve.c
 
diff --git a/bin/cosmiccal/Makefile.am b/bin/cosmiccal/Makefile.am
index 96cafdd..3021844 100644
--- a/bin/cosmiccal/Makefile.am
+++ b/bin/cosmiccal/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astcosmiccal
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astcosmiccal_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astcosmiccal_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astcosmiccal_SOURCES = main.c ui.c cosmiccal.c
 
diff --git a/bin/crop/Makefile.am b/bin/crop/Makefile.am
index e6a86a2..168cf97 100644
--- a/bin/crop/Makefile.am
+++ b/bin/crop/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astcrop
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astcrop_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astcrop_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astcrop_SOURCES = main.c ui.c crop.c wcsmode.c onecrop.c
 
diff --git a/bin/fits/Makefile.am b/bin/fits/Makefile.am
index 8d7d0e8..0f00d00 100644
--- a/bin/fits/Makefile.am
+++ b/bin/fits/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astfits
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astfits_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astfits_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astfits_SOURCES = main.c ui.c extension.c fits.c keywords.c
 
diff --git a/bin/match/Makefile.am b/bin/match/Makefile.am
index c11c58d..28ab4fa 100644
--- a/bin/match/Makefile.am
+++ b/bin/match/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astmatch
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astmatch_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astmatch_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astmatch_SOURCES = main.c ui.c match.c
 
diff --git a/bin/mkcatalog/Makefile.am b/bin/mkcatalog/Makefile.am
index b834dff..0797e92 100644
--- a/bin/mkcatalog/Makefile.am
+++ b/bin/mkcatalog/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astmkcatalog
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astmkcatalog_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astmkcatalog_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astmkcatalog_SOURCES = main.c ui.c mkcatalog.c columns.c upperlimit.c parse.c
 
diff --git a/bin/mknoise/Makefile.am b/bin/mknoise/Makefile.am
index 6f09968..4573434 100644
--- a/bin/mknoise/Makefile.am
+++ b/bin/mknoise/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astmknoise
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astmknoise_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astmknoise_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astmknoise_SOURCES = main.c ui.c mknoise.c
 
diff --git a/bin/mkprof/Makefile.am b/bin/mkprof/Makefile.am
index c7c06b0..8df0a37 100644
--- a/bin/mkprof/Makefile.am
+++ b/bin/mkprof/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astmkprof
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astmkprof_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astmkprof_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astmkprof_SOURCES = main.c ui.c mkprof.c oneprofile.c profiles.c
 
diff --git a/bin/noisechisel/Makefile.am b/bin/noisechisel/Makefile.am
index a3f51e7..c59949e 100644
--- a/bin/noisechisel/Makefile.am
+++ b/bin/noisechisel/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astnoisechisel
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astnoisechisel_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astnoisechisel_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astnoisechisel_SOURCES = main.c ui.c detection.c noisechisel.c sky.c     \
   threshold.c
diff --git a/bin/segment/Makefile.am b/bin/segment/Makefile.am
index 242ec48..f7e4762 100644
--- a/bin/segment/Makefile.am
+++ b/bin/segment/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astsegment
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astsegment_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astsegment_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astsegment_SOURCES = main.c ui.c segment.c clumps.c
 
diff --git a/bin/statistics/Makefile.am b/bin/statistics/Makefile.am
index 972cc54..07b03db 100644
--- a/bin/statistics/Makefile.am
+++ b/bin/statistics/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = aststatistics
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-aststatistics_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+aststatistics_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 aststatistics_SOURCES = main.c ui.c sky.c statistics.c
 
diff --git a/bin/table/Makefile.am b/bin/table/Makefile.am
index f3313a2..72ed98a 100644
--- a/bin/table/Makefile.am
+++ b/bin/table/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = asttable
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-asttable_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+asttable_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 asttable_SOURCES = main.c ui.c table.c
 
diff --git a/bin/warp/Makefile.am b/bin/warp/Makefile.am
index b7c0a7f..898b986 100644
--- a/bin/warp/Makefile.am
+++ b/bin/warp/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib 
-I\$(top_srcdir)/lib
 bin_PROGRAMS = astwarp
 
 ## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astwarp_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro
+astwarp_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro 
$(CONFIG_LDADD)
 
 astwarp_SOURCES = main.c ui.c warp.c
 
diff --git a/bootstrap.conf b/bootstrap.conf
index 16a3739..ca381fe 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -223,6 +223,7 @@ gnulib_modules="
     stdint
     strtod
     mktime
+    havelib
     memmove
     getline
     strcase
diff --git a/configure.ac b/configure.ac
index adccad8..b8dccc6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -262,12 +262,23 @@ has_cfitsio=yes
 has_gslcblas=yes
 missing_mandatory=no
 missing_optional_lib=no
-AC_SEARCH_LIBS(sqrt, m, [],
-               [missing_mandatory=yes; has_cmath=no])
-AC_SEARCH_LIBS([cblas_sdsdot], [gslcblas], [],
-               [missing_mandatory=yes; has_gslcblas=no])
-AC_SEARCH_LIBS([gsl_integration_qng], [gsl], [],
-               [missing_mandatory=yes; has_gsl=no])
+
+# Order is important here.
+AC_LIB_HAVE_LINKFLAGS([m], [], [#include <math.h>])
+AS_IF([test "x$LIBM" = x],
+      [missing_mandatory=yes; has_cmath=no],
+      [LDADD="$LIBM $LDADD"])
+
+AC_LIB_HAVE_LINKFLAGS([gsl], [gslcblas], [
+#include <gsl/gsl_rng.h>
+void junk(void) { gsl_rng_env_setup(); } ])
+AS_IF([test "x$LIBGSL" = x],
+      [missing_mandatory=yes; has_gsl=no; has_gslcblas=no],
+      [LDADD="$LIBGSL $LDADD"])
+
+
+
+
 
 # Since version 0.42, if `libcurl' is installed, CFITSIO will link with it
 # and thus it will be necessary to explicitly link with libcurl also. If it
@@ -282,20 +293,64 @@ AC_SEARCH_LIBS([gsl_integration_qng], [gsl], [],
 # librtmp, libldap). So if you intend to make Gnuastro statically, then
 # build Libcurl in static-only mode so you won't have to check for all
 # these extra libraries here.
-AC_SEARCH_LIBS([deflateInit_], [z], [], [])
-AC_SEARCH_LIBS([curl_global_init], [curl], [], [])
-AC_SEARCH_LIBS([ffopen], [cfitsio], [],
-               [missing_mandatory=yes; has_cfitsio=no])
-AC_SEARCH_LIBS([wcspih], [wcs], [],
-               [missing_mandatory=yes; has_wcslib=no])
+AC_LIB_HAVE_LINKFLAGS([z], [], [#include <zlib.h>])
+AS_IF([test "x$LIBZ" = x], [], [LDADD="$LIBZ $LDADD"])
+
+AC_LIB_HAVE_LINKFLAGS([curl], [], [#include <curl/curl.h>])
+AS_IF([test "x$LIBCURL" = x], [], [LDADD="$LIBCURL $LDADD"])
+
+# CFITSIO can depend on libcurl (which may not exist on some
+# systems). Also, `AC_LIB_HAVE_LINKFLAGS' puts the value in its second
+# argument in single-quotes. So its not easy to set a conditional linking
+# dependency. Therefore, we need to temporarily put LDADD within LIBS so
+# the compiler knows what to link with.
+origlibs="$LIBS"
+LIBS="$LIBS $LDADD"
+AC_LIB_HAVE_LINKFLAGS([cfitsio], [], [
+#include <fitsio.h>
+void junk(void) {
+int status;
+fitsfile *f;
+ffopen(&f, "junk", READONLY, &status);} ])
+AS_IF([test "x$LIBCFITSIO" = x],
+      [missing_mandatory=yes; has_cfitsio=no],
+      [LDADD="$LIBCFITSIO $LDADD"])
+LIBS="$origlibs"
+
+AC_LIB_HAVE_LINKFLAGS([wcs], [], [
+#include <wcslib/wcshdr.h>
+void junk(void) {
+int nreject, nwcs;
+struct wcsprm *wcs;
+char *header="JUNK";
+wcspih(header, 1, 0, 0, &nreject, &nwcs, &wcs);
+} ])
+AS_IF([test "x$LIBWCS" = x],
+      [missing_mandatory=yes; has_wcslib=no],
+      [LDADD="$LIBWCS $LDADD"])
+
+
+
+
 
 # These are secondary tests for more fine-grained control in libraries that
-# have already been checked. We don't need to add them to the LIBS
-# variable, so we are using AC_CHECK_LIB for these tests.
-AC_CHECK_DECLS(gsl_interp_steffen,
-               [ gsl_version_old=no                   ],
-               [ gsl_version_old=yes; anywarnings=yes ],
-               [[#include <gsl/gsl_interp.h>]])
+# have already been checked.
+
+# GSL's `gsl_interp_steffen' isn't a function. So we'll need to use
+# `AC_LINK_IFELSE'. However, AC_LINK_IFELSE doesn't use `LDADD', so we'll
+# have to temporarily add `LDADD' to LIBS, then set it back to the
+# original.
+origlibs="$LIBS"
+LIBS="$LIBS $LDADD"
+AC_MSG_CHECKING(if GSL supports Steffen splines)
+AC_LINK_IFELSE([AC_LANG_PROGRAM(
+                   [[#include <gsl/gsl_interp.h>]],
+                   [[const gsl_interp_type *itype=gsl_interp_steffen;]])],
+               [AC_MSG_RESULT(yes)
+                gsl_version_old=no],
+               [AC_MSG_RESULT(no)
+                gsl_version_old=yes; anywarnings=yes;])
+LIBS="$origlibs"
 
 # If the CFITSIO library has the `fits_is_reentrant' function (it was added
 # since version 3.30 of April 2012).
@@ -335,8 +390,18 @@ AM_CONDITIONAL([COND_HASHELP2MAN], [test "x$has_help2man" 
= "xyes"])
 
 
 # Check libjpeg:
-AC_SEARCH_LIBS([jpeg_stdio_dest], [jpeg],
-               [has_libjpeg=yes], [has_libjpeg=no; missing_optional_lib=yes])
+AC_LIB_HAVE_LINKFLAGS([jpeg], [], [
+#include <stdio.h>
+#include <stdlib.h>
+#include <jpeglib.h>
+void junk(void) {
+  struct jpeg_decompress_struct cinfo;
+  jpeg_create_decompress(&cinfo);
+}  ])
+AS_IF([test "x$LIBJPEG" = x],
+      [missing_optional_lib=yes; has_libjpeg=no],
+      [has_libjpeg=yes; LDADD="$LIBJPEG $LDADD"])
+
 AS_IF([test "x$has_libjpeg" = "xyes"],
       [AC_DEFINE([HAVE_LIBJPEG], [], [Has libjpeg])],
       [anywarnings=yes])
@@ -351,9 +416,16 @@ AM_CONDITIONAL([COND_HASLIBJPEG], [test "x$has_libjpeg" = 
"xyes"])
 # the LZMA library. But if libtiff hasn't been linked with it and its
 # present, there is no problem, the linker will just pass over it. So we
 # don't need to stop the build if this fails.
-AC_SEARCH_LIBS([lzma_stream_decoder], [lzma], [], [])
-AC_SEARCH_LIBS([TIFFOpen], [tiff],
-               [has_libtiff=yes], [has_libtiff=no; missing_optional_lib=yes])
+AC_LIB_HAVE_LINKFLAGS([lzma], [], [#include <lzma.h>])
+AS_IF([test "x$LIBLZMA" = x], [], [LDADD="$LIBLZMA $LDADD"])
+
+AC_LIB_HAVE_LINKFLAGS([tiff], [], [
+#include <tiffio.h>
+void junk(void) {TIFF *tif=TIFFOpen("junk", "r");}
+])
+AS_IF([test "x$LIBTIFF" = x],
+      [missing_optional_lib=yes; has_libtiff=no],
+      [has_libtiff=yes; LDADD="$LIBTIFF $LDADD"])
 AS_IF([test "x$has_libtiff" = "xyes"],
       [AC_DEFINE([HAVE_LIBTIFF], [], [Has libtiff])],
       [anywarnings=yes])
@@ -363,9 +435,15 @@ AM_CONDITIONAL([COND_HASLIBTIFF], [test "x$has_libtiff" = 
"xyes"])
 
 
 
-# Check libgit2:
-AC_SEARCH_LIBS([git_libgit2_init], [git2],
-               [has_libgit2=1], [has_libgit2=0; missing_optional_lib=yes])
+# Check libgit2. Note that very old versions of libgit2 don't have the
+# `git_libgit2_init' function.
+AC_LIB_HAVE_LINKFLAGS([git2], [], [
+#include <git2.h>
+void junk(void) {git_libgit2_init();}
+])
+AS_IF([test "x$LIBGIT2" = x],
+      [missing_optional_lib=yes; has_libgit2=0],
+      [has_libgit2=1; LDADD="$LIBGIT2 $LDADD"])
 AC_DEFINE_UNQUOTED([GAL_CONFIG_HAVE_LIBGIT2], [$has_libgit2],
                    [libgit2 is installed on the system])
 AS_IF([test "x$has_libgit2" = "x1"], [], [anywarnings=yes])
@@ -848,7 +926,16 @@ AC_CONFIG_COMMANDS([man page directory], [$MKDIR_P 
doc/man])
 
 
 
-# Make the Makefiles:
+# Set the linker-necessary parameters.
+AC_SUBST(CONFIG_LDADD, [$LDADD])
+AC_DEFINE_UNQUOTED([LDADD], ["$LDADD"],
+                   [Linking information, primarily for BuildProgram])
+
+
+
+
+
+# Prepare the Makefiles.
 AC_OUTPUT
 
 
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 9479f9b..1c554bd 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -2,6 +2,7 @@ Alphabetically ordered list to acknowledge in the next release.
 
 Hamed Altafi
 Leindert Boogaard
+Bruno Haible
 Raul Infante-Sainz
 Lee Kelvin
 Elham Saremi
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 1dda613..17d88e8 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -43,7 +43,7 @@ AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib            \
 # features. This also avoids the need for the programs to link separately
 # with Gnulib, they only need to link with the Gnuastro library.
 lib_LTLIBRARIES = libgnuastro.la
-libgnuastro_la_LDFLAGS = -version-info $(GAL_LT_VERSION)
+libgnuastro_la_LDFLAGS = -version-info $(GAL_LT_VERSION) $(CONFIG_LDADD)
 libgnuastro_la_LIBADD = $(top_builddir)/bootstrapped/lib/libgnu.la
 
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b979215..c3ac5ec 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -227,11 +227,11 @@ export check_with_program=$(MAYBE_CHECK_WITH_PROGRAM);
 # `../lib/Makefile.am' and is only meant for outside users (to be tested
 # here). Thus (unlike the programs, which use `config.h') we need to add
 # the top build directory to the include search directories (`-I').
+LDADD = -lgnuastro $(CONFIG_LDADD)
 AM_LDFLAGS = -L\$(top_builddir)/lib
 AM_CPPFLAGS = -I\$(top_srcdir)/lib -I\$(top_builddir)/lib
 
 # Rest of library check settings.
-LDADD = -lgnuastro
 check_PROGRAMS = multithread $(MAYBE_CXX_PROGS)
 multithread_SOURCES = lib/multithread.c
 lib/multithread.sh: mkprof/mosaic1.sh.log



reply via email to

[Prev in Thread] Current Thread [Next in Thread]