summaryrefslogtreecommitdiff
path: root/gphoto-m4
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2021-10-18 04:08:06 +0200
committerHans Ulrich Niedermann <hun@n-dimensional.de>2021-11-03 22:02:45 +0100
commit9878f31b79bd0dcc9c6ae7ab7083410c30bbd404 (patch)
treefa4ab66efdb8431fcf7fa417107ae522617e4b8e /gphoto-m4
parent302f4bf4b6b8c7e567d7a02be2ea24d2acd9f2ed (diff)
downloadlibgphoto2-9878f31b79bd0dcc9c6ae7ab7083410c30bbd404.tar.gz
Update libltdl checks (GP_LIBLTDL)
We still do not use LTDL_INIT() as LTDL_INIT insists on us shipping libltdl sources in our release tarballs and we still do not like shipping third party sources. This now checks locations other than the default include and linker paths, so that configure should find libltdl by itself now on e.g. FreeBSD or OSX/homebrew.
Diffstat (limited to 'gphoto-m4')
-rw-r--r--gphoto-m4/gp-libltdl.m4144
1 files changed, 106 insertions, 38 deletions
diff --git a/gphoto-m4/gp-libltdl.m4 b/gphoto-m4/gp-libltdl.m4
index 2a37c9305..db931dcd3 100644
--- a/gphoto-m4/gp-libltdl.m4
+++ b/gphoto-m4/gp-libltdl.m4
@@ -1,59 +1,127 @@
dnl Written by Hans Ulrich Niedermann
dnl LDFLAGS vs LIBS fix by Dan Nicholson
-dnl
+dnl
+dnl ####################################################################
+dnl GP_LIBLTDL
+dnl ####################################################################
+dnl
dnl We are using our own libltdl checks instead of AC_WITH_LTDL
-dnl because we do not want to ship our own copy of libltdl any more.
-dnl Not shipping libltdl makes it possible to ditch our own autogen.sh
-dnl and relying on standard autoconf's "autoreconf".
+dnl because we do not want to ship our own copy of libltdl.
dnl
dnl Look for external libltdl, not shipping internal libltdl.
-AC_DEFUN([GP_LIB_LTDL],[dnl
-AC_ARG_VAR([LTDLINCL],[CFLAGS for compiling with libltdl])
-AC_ARG_VAR([LIBLTDL],[LIBS to add for linking against libltdl])
-if test "x${LTDLINCL}${LIBLTDL}" = "x"; then
-AC_CHECK_HEADER([ltdl.h],
-[dnl
-AC_CHECK_LIB([ltdl], [lt_dlinit],[dnl
-LTDLINCL=""
-LIBLTDL="-lltdl"
-AC_DEFINE([HAVE_LTDL],[1],[Whether libltdl (of libtool fame) is present])
-],[dnl
+AC_DEFUN([GP_LIBLTDL], [dnl
+AC_ARG_VAR([LTDLINCL], [CFLAGS for compiling with libltdl])
+AC_ARG_VAR([LIBLTDL], [LIBS to add for linking against libltdl])
+dnl
+have_libltdl=no
+AC_MSG_CHECKING([for libltdl])
+AS_IF([test "x${LTDLINCL}${LIBLTDL}" != x], [dnl
+ AC_MSG_RESULT([variables given explicitly])
+
+ AC_MSG_CHECKING([LTDLINCL (given explicitly)])
+ AC_MSG_RESULT([${LTDLINCL}])
+ AC_MSG_CHECKING([LIBLTDL (given explictly)])
+ AC_MSG_RESULT([${LIBLTDL}])
+
+ GP_LINK_LIBLTDL_IFELSE([dnl
+ have_libltdl=yes
+ ], [dnl
+ GP_MSG_ERROR_LIBLTDL
+ ])
+], [dnl
+ AC_MSG_RESULT([autodetecting])
+
+ AS_VAR_IF([have_libltdl], [no], [dnl Try default location
+ LTDLINCL=""
+ LIBLTDL="-lltdl"
+ AC_MSG_CHECKING([for libltdl at default location])
+ GP_LINK_LIBLTDL_IFELSE([
+ have_libltdl=yes
+ ], [dnl
+ AS_UNSET([LTDLINCL])
+ AS_UNSET([LIBLTDL])
+ ])
+ AC_MSG_RESULT([$have_libltdl])
+ ])
+
+ dnl FreeBSD packages install to /usr/local
+ dnl NetBSD packages install to /usr/pkg
+ dnl MacOSX brew packages install to `brew --prefix`
+ for gp_prefix in /usr/local /usr/pkg `brew --prefix 2>/dev/null`; do
+ AS_IF([test -d "$gp_prefix"], [dnl
+ AS_VAR_IF([have_libltdl], [no], [dnl
+ LTDLINCL="-I${gp_prefix}/include"
+ LIBLTDL="-L${gp_prefix}/lib -lltdl"
+ AC_MSG_CHECKING([for libltdl at $gp_prefix])
+ GP_LINK_LIBLTDL_IFELSE([
+ have_libltdl=yes
+ AC_MSG_RESULT([$have_libltdl])
+ break
+ ], [dnl
+ AS_UNSET([LTDLINCL])
+ AS_UNSET([LIBLTDL])
+ AC_MSG_RESULT([$have_libltdl])
+ ])
+ ])
+ ])
+ done
+
+ AS_VAR_IF([have_libltdl], [yes], [dnl
+ AC_MSG_CHECKING([LTDLINCL (autodetected)])
+ AC_MSG_RESULT([${LTDLINCL}])
+ AC_MSG_CHECKING([LIBLTDL (autodetected)])
+ AC_MSG_RESULT([${LIBLTDL}])
+ ], [dnl
+ GP_MSG_ERROR_LIBLTDL
+ ])
+])
+])dnl
+dnl
+dnl
+dnl ####################################################################
+dnl GP_MSG_ERROR_LIBLTDL
+dnl ####################################################################
+dnl
+dnl Print the error message when libltdl has not been found to work.
+dnl
+AC_DEFUN([GP_MSG_ERROR_LIBLTDL], [dnl
AC_MSG_ERROR([
-$PACKAGE requires the ltdl library, included with libtool
+${PACKAGE} requires libltdl (a part of libtool)
Please make sure that the proper development package is installed
-(libltdl-dev, libtool-ltdl-devel, etc.)
-])[]dnl
-])dnl
+(may be called libltdl-dev, libtool-ltdl-devel, libltdl, etc.) and if
+the autodetection fails, that the LTDLINCL and LIBLTDL variables are
+set properly on the configure command line.
])
-else
- AC_MSG_CHECKING([for libltdl flags])
- AC_MSG_RESULT([set explicitly: ${LTDLINCL} ${LIBLTDL}])
-fi
-AC_SUBST([LTDLINCL])
-AC_SUBST([LIBLTDL])
+])dnl
+dnl
+dnl
+dnl ####################################################################
+dnl GP_LINK_LIBLTDL_IFELSE
+dnl ####################################################################
dnl
dnl Make sure we can actually compile and link against libltdl
+dnl
+AC_DEFUN([GP_LINK_LIBLTDL_IFELSE], [dnl
AC_LANG_PUSH([C])
-AC_MSG_CHECKING([that we can compile and link with libltdl])
saved_CPPFLAGS="$CPPFLAGS"
saved_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $LTDLINCL"
LIBS="$LIBS $LIBLTDL"
-AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdlib.h> /* for NULL */
#include <ltdl.h> /* for lt_* */
-],[dnl
-int ret = lt_dlforeachfile("/usr/lib:/usr/local/lib", NULL, NULL);
-])], [AC_MSG_RESULT([yes])], [dnl
-AC_MSG_RESULT([no])
-AC_MSG_ERROR([cannot compile and link against libltdl
-${PACKAGE_TARNAME} requires libltdl (the libtool dl* library),
-but cannot compile and link against it.
-Aborting.
-])
-])
+]], [[
+ int ret = lt_dlforeachfile("/usr/lib:/usr/local/lib", NULL, NULL);
+ (void) ret;
+]])], [$1], [$2])
CPPFLAGS="$saved_CPPFLAGS"
LIBS="$saved_LIBS"
-AC_LANG_POP
+AC_LANG_POP([C])
])dnl
+dnl
+dnl ####################################################################
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl End: