Merge remote-tracking branch 'origin/stable-2.0'
[bpt/guile.git] / meta / guile.m4
index 1e30d50..a7186fb 100644 (file)
@@ -1,11 +1,11 @@
 ## Autoconf macros for working with Guile.
 ##
-##   Copyright (C) 1998,2001, 2006 Free Software Foundation, Inc.
+##   Copyright (C) 1998,2001, 2006, 2010 Free Software Foundation, Inc.
 ##
 ## This library is free software; you can redistribute it and/or
-## modify it under the terms of the GNU Lesser General Public
-## License as published by the Free Software Foundation; either
-## version 2.1 of the License, or (at your option) any later version.
+## modify it under the terms of the GNU Lesser General Public License
+## as published by the Free Software Foundation; either version 3 of
+## the License, or (at your option) any later version.
 ## 
 ## This library is distributed in the hope that it will be useful,
 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
 ## 
 ## You should have received a copy of the GNU Lesser General Public
 ## License along with this library; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301 USA
 
-# serial 9
+# serial 10
 
 ## Index
 ## -----
@@ -69,29 +70,56 @@ AC_DEFUN([GUILE_PROGS],
 #
 # This macro runs the @code{guile-config} script, installed with Guile, to
 # find out where Guile's header files and libraries are installed.  It sets
-# two variables, @var{GUILE_CFLAGS} and @var{GUILE_LDFLAGS}.
+# four variables, @var{GUILE_CFLAGS}, @var{GUILE_LDFLAGS}, @var{GUILE_LIBS},
+# and @var{GUILE_LTLIBS}.
 #
 # @var{GUILE_CFLAGS}: flags to pass to a C or C++ compiler to build code that
-# uses Guile header files.  This is almost always just a @code{-I} flag.
+# uses Guile header files.  This is almost always just one or more @code{-I}
+# flags.
 #
-# @var{GUILE_LDFLAGS}: flags to pass to the linker to link a program against
+# @var{GUILE_LDFLAGS}: flags to pass to the compiler to link a program against
 # Guile.  This includes @code{-lguile} for the Guile library itself, any
 # libraries that Guile itself requires (like -lqthreads), and so on.  It may
-# also include a @code{-L} flag to tell the compiler where to find the
-# libraries.
+# also include one or more @code{-L} flag to tell the compiler where to find
+# the libraries.  But it does not include flags that influence the program's
+# runtime search path for libraries, and will therefore lead to a program
+# that fails to start, unless all necessary libraries are installed in a
+# standard location such as @file{/usr/lib}.
+#
+# @var{GUILE_LIBS} and @var{GUILE_LTLIBS}: flags to pass to the compiler or to
+# libtool, respectively, to link a program against Guile.  It includes flags
+# that augment the program's runtime search path for libraries, so that shared
+# libraries will be found at the location where they were during linking, even
+# in non-standard locations.  @var{GUILE_LIBS} is to be used when linking the
+# program directly with the compiler, whereas @var{GUILE_LTLIBS} is to be used
+# when linking the program is done through libtool.
 #
 # The variables are marked for substitution, as by @code{AC_SUBST}.
 #
 AC_DEFUN([GUILE_FLAGS],
- [AC_REQUIRE([GUILE_PROGS])dnl
+ [dnl Find guile-config.
+  AC_REQUIRE([GUILE_PROGS])dnl
+
   AC_MSG_CHECKING([libguile compile flags])
   GUILE_CFLAGS="`$GUILE_CONFIG compile`"
   AC_MSG_RESULT([$GUILE_CFLAGS])
+
   AC_MSG_CHECKING([libguile link flags])
   GUILE_LDFLAGS="`$GUILE_CONFIG link`"
   AC_MSG_RESULT([$GUILE_LDFLAGS])
-  AC_SUBST(GUILE_CFLAGS)
-  AC_SUBST(GUILE_LDFLAGS)
+
+  dnl Determine the platform dependent parameters needed to use rpath.
+  dnl AC_LIB_LINKFLAGS_FROM_LIBS is defined in gnulib/m4/lib-link.m4 and needs
+  dnl the file gnulib/build-aux/config.rpath.
+  AC_LIB_LINKFLAGS_FROM_LIBS([GUILE_LIBS], [$GUILE_LDFLAGS], [])
+  GUILE_LIBS="$GUILE_LDFLAGS $GUILE_LIBS"
+  AC_LIB_LINKFLAGS_FROM_LIBS([GUILE_LTLIBS], [$GUILE_LDFLAGS], [yes])
+  GUILE_LTLIBS="$GUILE_LDFLAGS $GUILE_LTLIBS"
+
+  AC_SUBST([GUILE_CFLAGS])
+  AC_SUBST([GUILE_LDFLAGS])
+  AC_SUBST([GUILE_LIBS])
+  AC_SUBST([GUILE_LTLIBS])
  ])
 
 # GUILE_SITE_DIR -- find path to Guile "site" directory
@@ -108,6 +136,9 @@ AC_DEFUN([GUILE_SITE_DIR],
  [AC_REQUIRE([GUILE_PROGS])dnl
   AC_MSG_CHECKING(for Guile site directory)
   GUILE_SITE=`[$GUILE_CONFIG] info sitedir`
+  if test "$GUILE_SITE" = ""; then
+     GUILE_SITE=`[$GUILE_CONFIG] info pkgdatadir`/site
+  fi
   AC_MSG_RESULT($GUILE_SITE)
   AC_SUBST(GUILE_SITE)
  ])