1## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
2## Copyright (C) 1996-1999 Free Software Foundation, Inc.
3## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4##
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.
9##
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.
14##
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.
18##
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.
23
24# serial 40 AC_PROG_LIBTOOL
25AC_DEFUN(AC_PROG_LIBTOOL,
26[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
27
28# Save cache, so that ltconfig can load it
29AC_CACHE_SAVE
30
31# Actually configure libtool.  ac_aux_dir is where install-sh is found.
32CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
33LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
34LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
35DLLTOOL="$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 $host \
38|| AC_MSG_ERROR([libtool configure failed])
39
40# Reload cache, that may have been modified by ltconfig
41AC_CACHE_LOAD
42
43# This can be used to rebuild libtool when needed
44LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
45
46# Always use our own libtool.
47LIBTOOL='$(SHELL) $(top_builddir)/libtool'
48AC_SUBST(LIBTOOL)dnl
49
50# Redirect the config.log output again, so that the ltconfig log is not
51# clobbered by the next message.
52exec 5>>./config.log
53])
54
55AC_DEFUN(AC_LIBTOOL_SETUP,
56[AC_PREREQ(2.13)dnl
57AC_REQUIRE([AC_ENABLE_SHARED])dnl
58AC_REQUIRE([AC_ENABLE_STATIC])dnl
59AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
60AC_REQUIRE([AC_CANONICAL_HOST])dnl
61AC_REQUIRE([AC_CANONICAL_BUILD])dnl
62AC_REQUIRE([AC_PROG_RANLIB])dnl
63AC_REQUIRE([AC_PROG_CC])dnl
64AC_REQUIRE([AC_PROG_LD])dnl
65AC_REQUIRE([AC_PROG_NM])dnl
66AC_REQUIRE([AC_PROG_LN_S])dnl
67dnl
68
69# Check for any special flags to pass to ltconfig.
70libtool_flags="--cache-file=$cache_file"
71test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
72test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
73test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
74test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
75test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
76ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
77[libtool_flags="$libtool_flags --enable-dlopen"])
78ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
79[libtool_flags="$libtool_flags --enable-win32-dll"])
80AC_ARG_ENABLE(libtool-lock,
81  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
82test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
83test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
84
85# Some flags need to be propagated to the compiler or linker for good
86# libtool support.
87case "$host" in
88*-*-irix6*)
89  # Find out which ABI we are using.
90  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
91  if AC_TRY_EVAL(ac_compile); then
92    case "`/usr/bin/file conftest.o`" in
93    *32-bit*)
94      LD="${LD-ld} -32"
95      ;;
96    *N32*)
97      LD="${LD-ld} -n32"
98      ;;
99    *64-bit*)
100      LD="${LD-ld} -64"
101      ;;
102    esac
103  fi
104  rm -rf conftest*
105  ;;
106
107*-*-sco3.2v5*)
108  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
109  SAVE_CFLAGS="$CFLAGS"
110  CFLAGS="$CFLAGS -belf"
111  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
112    [AC_LANG_SAVE
113     AC_LANG_C
114     AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
115     AC_LANG_RESTORE])
116  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
117    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
118    CFLAGS="$SAVE_CFLAGS"
119  fi
120  ;;
121
122ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
123[*-*-cygwin* | *-*-mingw*)
124  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
125  AC_CHECK_TOOL(AS, as, false)
126  AC_CHECK_TOOL(OBJDUMP, objdump, false)
127  ;;
128])
129esac
130])
131
132# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
133AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
134
135# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
136AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
137
138# AC_ENABLE_SHARED - implement the --enable-shared flag
139# Usage: AC_ENABLE_SHARED[(DEFAULT)]
140#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
141#   `yes'.
142AC_DEFUN(AC_ENABLE_SHARED, [dnl
143define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
144AC_ARG_ENABLE(shared,
145changequote(<<, >>)dnl
146<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
147changequote([, ])dnl
148[p=${PACKAGE-default}
149case "$enableval" in
150yes) enable_shared=yes ;;
151no) enable_shared=no ;;
152*)
153  enable_shared=no
154  # Look at the argument we got.  We use all the common list separators.
155  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
156  for pkg in $enableval; do
157    if test "X$pkg" = "X$p"; then
158      enable_shared=yes
159    fi
160  done
161  IFS="$ac_save_ifs"
162  ;;
163esac],
164enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
165])
166
167# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
168AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
169AC_ENABLE_SHARED(no)])
170
171# AC_ENABLE_STATIC - implement the --enable-static flag
172# Usage: AC_ENABLE_STATIC[(DEFAULT)]
173#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
174#   `yes'.
175AC_DEFUN(AC_ENABLE_STATIC, [dnl
176define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
177AC_ARG_ENABLE(static,
178changequote(<<, >>)dnl
179<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
180changequote([, ])dnl
181[p=${PACKAGE-default}
182case "$enableval" in
183yes) enable_static=yes ;;
184no) enable_static=no ;;
185*)
186  enable_static=no
187  # Look at the argument we got.  We use all the common list separators.
188  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
189  for pkg in $enableval; do
190    if test "X$pkg" = "X$p"; then
191      enable_static=yes
192    fi
193  done
194  IFS="$ac_save_ifs"
195  ;;
196esac],
197enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
198])
199
200# AC_DISABLE_STATIC - set the default static flag to --disable-static
201AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
202AC_ENABLE_STATIC(no)])
203
204
205# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
206# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
207#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
208#   `yes'.
209AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
210define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
211AC_ARG_ENABLE(fast-install,
212changequote(<<, >>)dnl
213<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
214changequote([, ])dnl
215[p=${PACKAGE-default}
216case "$enableval" in
217yes) enable_fast_install=yes ;;
218no) enable_fast_install=no ;;
219*)
220  enable_fast_install=no
221  # Look at the argument we got.  We use all the common list separators.
222  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
223  for pkg in $enableval; do
224    if test "X$pkg" = "X$p"; then
225      enable_fast_install=yes
226    fi
227  done
228  IFS="$ac_save_ifs"
229  ;;
230esac],
231enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
232])
233
234# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
235AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
236AC_ENABLE_FAST_INSTALL(no)])
237
238# AC_PROG_LD - find the path to the GNU or non-GNU linker
239AC_DEFUN(AC_PROG_LD,
240[AC_ARG_WITH(gnu-ld,
241[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
242test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
243AC_REQUIRE([AC_PROG_CC])dnl
244AC_REQUIRE([AC_CANONICAL_HOST])dnl
245AC_REQUIRE([AC_CANONICAL_BUILD])dnl
246ac_prog=ld
247if test "$ac_cv_prog_gcc" = yes; then
248  # Check if gcc -print-prog-name=ld gives a path.
249  AC_MSG_CHECKING([for ld used by GCC])
250  ac_prog=`($CC -print-prog-name=ld) 2>&5`
251  case "$ac_prog" in
252    # Accept absolute paths.
253changequote(,)dnl
254    [\\/]* | [A-Za-z]:[\\/]*)
255      re_direlt='/[^/][^/]*/\.\./'
256changequote([,])dnl
257      # Canonicalize the path of ld
258      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
259      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
260	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
261      done
262      test -z "$LD" && LD="$ac_prog"
263      ;;
264  "")
265    # If it fails, then pretend we aren't using GCC.
266    ac_prog=ld
267    ;;
268  *)
269    # If it is relative, then search for the first ld in PATH.
270    with_gnu_ld=unknown
271    ;;
272  esac
273elif test "$with_gnu_ld" = yes; then
274  AC_MSG_CHECKING([for GNU ld])
275else
276  AC_MSG_CHECKING([for non-GNU ld])
277fi
278AC_CACHE_VAL(ac_cv_path_LD,
279[if test -z "$LD"; then
280  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
281  for ac_dir in $PATH; do
282    test -z "$ac_dir" && ac_dir=.
283    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
284      ac_cv_path_LD="$ac_dir/$ac_prog"
285      # Check to see if the program is GNU ld.  I'd rather use --version,
286      # but apparently some GNU ld's only accept -v.
287      # Break only if it was the GNU/non-GNU ld that we prefer.
288      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
289	test "$with_gnu_ld" != no && break
290      else
291	test "$with_gnu_ld" != yes && break
292      fi
293    fi
294  done
295  IFS="$ac_save_ifs"
296else
297  ac_cv_path_LD="$LD" # Let the user override the test with a path.
298fi])
299LD="$ac_cv_path_LD"
300if test -n "$LD"; then
301  AC_MSG_RESULT($LD)
302else
303  AC_MSG_RESULT(no)
304fi
305test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
306AC_SUBST(LD)
307AC_PROG_LD_GNU
308])
309
310AC_DEFUN(AC_PROG_LD_GNU,
311[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
312[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
313if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
314  ac_cv_prog_gnu_ld=yes
315else
316  ac_cv_prog_gnu_ld=no
317fi])
318])
319
320# AC_PROG_NM - find the path to a BSD-compatible name lister
321AC_DEFUN(AC_PROG_NM,
322[AC_MSG_CHECKING([for BSD-compatible nm])
323AC_CACHE_VAL(ac_cv_path_NM,
324[if test -n "$NM"; then
325  # Let the user override the test.
326  ac_cv_path_NM="$NM"
327else
328  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
329  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
330    test -z "$ac_dir" && ac_dir=.
331    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
332      # Check to see if the nm accepts a BSD-compat flag.
333      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
334      #   nm: unknown option "B" ignored
335      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
336	ac_cv_path_NM="$ac_dir/nm -B"
337	break
338      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
339	ac_cv_path_NM="$ac_dir/nm -p"
340	break
341      else
342	ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
343	continue # so that we can try to find one that supports BSD flags
344      fi
345    fi
346  done
347  IFS="$ac_save_ifs"
348  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
349fi])
350NM="$ac_cv_path_NM"
351AC_MSG_RESULT([$NM])
352AC_SUBST(NM)
353])
354
355# AC_CHECK_LIBM - check for math library
356AC_DEFUN(AC_CHECK_LIBM,
357[AC_REQUIRE([AC_CANONICAL_HOST])dnl
358LIBM=
359case "$host" in
360*-*-beos* | *-*-cygwin*)
361  # These system don't have libm
362  ;;
363*-ncr-sysv4.3*)
364  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
365  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
366  ;;
367*)
368  AC_CHECK_LIB(m, main, LIBM="-lm")
369  ;;
370esac
371])
372
373# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
374# the libltdl convenience library, adds --enable-ltdl-convenience to
375# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
376# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
377# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
378# '${top_builddir}/' (note the single quotes!) if your package is not
379# flat, and, if you're not using automake, define top_builddir as
380# appropriate in the Makefiles.
381AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
382  case "$enable_ltdl_convenience" in
383  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
384  "") enable_ltdl_convenience=yes
385      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
386  esac
387  LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
388  INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
389])
390
391# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
392# the libltdl installable library, and adds --enable-ltdl-install to
393# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
394# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
395# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
396# '${top_builddir}/' (note the single quotes!) if your package is not
397# flat, and, if you're not using automake, define top_builddir as
398# appropriate in the Makefiles.
399# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
400AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
401  AC_CHECK_LIB(ltdl, main,
402  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
403  [if test x"$enable_ltdl_install" = xno; then
404     AC_MSG_WARN([libltdl not installed, but installation disabled])
405   else
406     enable_ltdl_install=yes
407   fi
408  ])
409  if test x"$enable_ltdl_install" = x"yes"; then
410    ac_configure_args="$ac_configure_args --enable-ltdl-install"
411    LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
412    INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
413  else
414    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
415    LIBLTDL="-lltdl"
416    INCLTDL=
417  fi
418])
419
420dnl old names
421AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
422AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
423AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
424AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
425AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
426AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
427AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
428
429dnl This is just to silence aclocal about the macro not being used
430ifelse([AC_DISABLE_FAST_INSTALL])dnl
431