1 ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
2 ## Copyright (C) 1996-1999, 2000 Free Software Foundation, Inc.
3 ## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2 of the License, or
8 ## (at your option) any later version.
10 ## This program is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ## As a special exception to the GNU General Public License, if you
20 ## distribute this file as part of a program that contains a
21 ## configuration script generated by Autoconf, you may include it under
22 ## the same distribution terms that you use for the rest of that program.
24 # serial 40 AC_PROG_LIBTOOL
25 AC_DEFUN(AC_PROG_LIBTOOL,
26 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
28 # Save cache, so that ltconfig can load it
31 # Actually configure libtool. ac_aux_dir is where install-sh is found.
32 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
33 LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
34 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
35 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
36 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
37 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
38 || AC_MSG_ERROR([libtool configure failed])
40 # Reload cache, that may have been modified by ltconfig
43 # This can be used to rebuild libtool when needed
44 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
46 # Always use our own libtool.
47 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
50 # Redirect the config.log output again, so that the ltconfig log is not
51 # clobbered by the next message.
55 AC_DEFUN(AC_LIBTOOL_SETUP,
57 AC_REQUIRE([AC_ENABLE_SHARED])dnl
58 AC_REQUIRE([AC_ENABLE_STATIC])dnl
59 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
60 AC_REQUIRE([AC_CANONICAL_HOST])dnl
61 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
62 AC_REQUIRE([AC_PROG_RANLIB])dnl
63 AC_REQUIRE([AC_PROG_CC])dnl
64 AC_REQUIRE([AC_PROG_LD])dnl
65 AC_REQUIRE([AC_PROG_NM])dnl
66 AC_REQUIRE([AC_PROG_LN_S])dnl
70 NONE) lt_target="$host" ;;
71 *) lt_target="$target" ;;
74 # Check for any special flags to pass to ltconfig.
75 libtool_flags="--cache-file=$cache_file"
76 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
77 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
78 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
79 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
80 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
81 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
82 [libtool_flags="$libtool_flags --enable-dlopen"])
83 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
84 [libtool_flags="$libtool_flags --enable-win32-dll"])
85 AC_ARG_ENABLE(libtool-lock,
86 [ --disable-libtool-lock avoid locking (might break parallel builds)])
87 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
88 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
90 # Some flags need to be propagated to the compiler or linker for good
94 # Find out which ABI we are using.
95 echo '[#]line __oline__ "configure"' > conftest.$ac_ext
96 if AC_TRY_EVAL(ac_compile); then
97 case "`/usr/bin/file conftest.o`" in
113 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
114 SAVE_CFLAGS="$CFLAGS"
115 CFLAGS="$CFLAGS -belf"
116 AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
117 [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
118 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
119 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
120 CFLAGS="$SAVE_CFLAGS"
124 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
125 [*-*-cygwin* | *-*-mingw*)
126 AC_CHECK_TOOL(DLLTOOL, dlltool, false)
127 AC_CHECK_TOOL(AS, as, false)
128 AC_CHECK_TOOL(OBJDUMP, objdump, false)
134 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
135 AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
137 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
138 AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
140 # AC_ENABLE_SHARED - implement the --enable-shared flag
141 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
142 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
144 AC_DEFUN(AC_ENABLE_SHARED, [dnl
145 define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
146 AC_ARG_ENABLE(shared,
147 changequote(<<, >>)dnl
148 << --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
150 [p=${PACKAGE-default}
152 yes) enable_shared=yes ;;
153 no) enable_shared=no ;;
156 # Look at the argument we got. We use all the common list separators.
157 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
158 for pkg in $enableval; do
159 if test "X$pkg" = "X$p"; then
166 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
169 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
170 AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
171 AC_ENABLE_SHARED(no)])
173 # AC_ENABLE_STATIC - implement the --enable-static flag
174 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
175 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
177 AC_DEFUN(AC_ENABLE_STATIC, [dnl
178 define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
179 AC_ARG_ENABLE(static,
180 changequote(<<, >>)dnl
181 << --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
183 [p=${PACKAGE-default}
185 yes) enable_static=yes ;;
186 no) enable_static=no ;;
189 # Look at the argument we got. We use all the common list separators.
190 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
191 for pkg in $enableval; do
192 if test "X$pkg" = "X$p"; then
199 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
202 # AC_DISABLE_STATIC - set the default static flag to --disable-static
203 AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
204 AC_ENABLE_STATIC(no)])
207 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
208 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
209 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
211 AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
212 define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
213 AC_ARG_ENABLE(fast-install,
214 changequote(<<, >>)dnl
215 << --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
217 [p=${PACKAGE-default}
219 yes) enable_fast_install=yes ;;
220 no) enable_fast_install=no ;;
222 enable_fast_install=no
223 # Look at the argument we got. We use all the common list separators.
224 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
225 for pkg in $enableval; do
226 if test "X$pkg" = "X$p"; then
227 enable_fast_install=yes
233 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
236 # AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
237 AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
238 AC_ENABLE_FAST_INSTALL(no)])
240 # AC_PROG_LD - find the path to the GNU or non-GNU linker
243 [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
244 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
245 AC_REQUIRE([AC_PROG_CC])dnl
246 AC_REQUIRE([AC_CANONICAL_HOST])dnl
247 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
249 if test "$ac_cv_prog_gcc" = yes; then
250 # Check if gcc -print-prog-name=ld gives a path.
251 AC_MSG_CHECKING([for ld used by GCC])
252 ac_prog=`($CC -print-prog-name=ld) 2>&5`
254 # Accept absolute paths.
256 [\\/]* | [A-Za-z]:[\\/]*)
257 re_direlt='/[^/][^/]*/\.\./'
259 # Canonicalize the path of ld
260 ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
261 while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
262 ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
264 test -z "$LD" && LD="$ac_prog"
267 # If it fails, then pretend we aren't using GCC.
271 # If it is relative, then search for the first ld in PATH.
275 elif test "$with_gnu_ld" = yes; then
276 AC_MSG_CHECKING([for GNU ld])
278 AC_MSG_CHECKING([for non-GNU ld])
280 AC_CACHE_VAL(ac_cv_path_LD,
281 [if test -z "$LD"; then
282 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
283 for ac_dir in $PATH; do
284 test -z "$ac_dir" && ac_dir=.
285 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
286 ac_cv_path_LD="$ac_dir/$ac_prog"
287 # Check to see if the program is GNU ld. I'd rather use --version,
288 # but apparently some GNU ld's only accept -v.
289 # Break only if it was the GNU/non-GNU ld that we prefer.
290 if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
291 test "$with_gnu_ld" != no && break
293 test "$with_gnu_ld" != yes && break
299 ac_cv_path_LD="$LD" # Let the user override the test with a path.
302 if test -n "$LD"; then
307 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
311 AC_DEFUN(AC_PROG_LD_GNU,
312 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
313 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
314 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
315 ac_cv_prog_gnu_ld=yes
321 # AC_PROG_NM - find the path to a BSD-compatible name lister
323 [AC_MSG_CHECKING([for BSD-compatible nm])
324 AC_CACHE_VAL(ac_cv_path_NM,
325 [if test -n "$NM"; then
326 # Let the user override the test.
329 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
330 for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
331 test -z "$ac_dir" && ac_dir=.
332 if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
333 # Check to see if the nm accepts a BSD-compat flag.
334 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
335 # nm: unknown option "B" ignored
336 if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
337 ac_cv_path_NM="$ac_dir/nm -B"
339 elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
340 ac_cv_path_NM="$ac_dir/nm -p"
343 ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
344 continue # so that we can try to find one that supports BSD flags
349 test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
355 # AC_CHECK_LIBM - check for math library
356 AC_DEFUN(AC_CHECK_LIBM,
357 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
360 *-*-beos* | *-*-cygwin*)
361 # These system don't have libm
364 AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
365 AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
368 AC_CHECK_LIB(m, main, LIBM="-lm")
373 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
374 # the libltdl convenience library and INCLTDL to the include flags for
375 # the libltdl header and adds --enable-ltdl-convenience to the
376 # configure arguments. Note that LIBLTDL and INCLTDL are not
377 # AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not
378 # provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed
379 # with '${top_builddir}/' and INCLTDL will be prefixed with
380 # '${top_srcdir}/' (note the single quotes!). If your package is not
381 # flat and you're not using automake, define top_builddir and
382 # top_srcdir appropriately in the Makefiles.
383 AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
384 case "$enable_ltdl_convenience" in
385 no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
386 "") enable_ltdl_convenience=yes
387 ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
389 LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
390 INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
393 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
394 # the libltdl installable library and INCLTDL to the include flags for
395 # the libltdl header and adds --enable-ltdl-install to the configure
396 # arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
397 # AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed
398 # libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will
399 # be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
400 # with '${top_srcdir}/' (note the single quotes!). If your package is
401 # not flat and you're not using automake, define top_builddir and
402 # top_srcdir appropriately in the Makefiles.
403 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
404 AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
405 AC_CHECK_LIB(ltdl, main,
406 [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
407 [if test x"$enable_ltdl_install" = xno; then
408 AC_MSG_WARN([libltdl not installed, but installation disabled])
410 enable_ltdl_install=yes
413 if test x"$enable_ltdl_install" = x"yes"; then
414 ac_configure_args="$ac_configure_args --enable-ltdl-install"
415 LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
416 INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
418 ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
425 AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
426 AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
427 AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
428 AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
429 AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
430 AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
431 AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
433 dnl This is just to silence aclocal about the macro not being used
434 ifelse([AC_DISABLE_FAST_INSTALL])dnl