1 ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
2 ## Copyright (C) 1996-1998 Free Software Foundation, Inc.
3 ## 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 24 AM_PROG_LIBTOOL
25 AC_DEFUN(AM_PROG_LIBTOOL,
26 [AC_REQUIRE([AM_ENABLE_SHARED])dnl
27 AC_REQUIRE([AM_ENABLE_STATIC])dnl
28 AC_REQUIRE([AC_CANONICAL_HOST])dnl
29 AC_REQUIRE([AC_PROG_RANLIB])dnl
30 AC_REQUIRE([AC_PROG_CC])dnl
31 AC_REQUIRE([AM_PROG_LD])dnl
32 AC_REQUIRE([AM_PROG_NM])dnl
33 AC_REQUIRE([AC_PROG_LN_S])dnl
35 # Always use our own libtool.
36 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
39 # Check for any special flags to pass to ltconfig.
41 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
42 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
43 test "$silent" = yes && libtool_flags="$libtool_flags --silent"
44 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
45 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
47 # Some flags need to be propagated to the compiler or linker for good
51 # Find out which ABI we are using.
52 echo '[#]line __oline__ "configure"' > conftest.$ac_ext
53 if AC_TRY_EVAL(ac_compile); then
54 case "`/usr/bin/file conftest.o`" in
70 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
71 CFLAGS="$CFLAGS -belf"
75 # Actually configure libtool. ac_aux_dir is where install-sh is found.
76 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
77 LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
78 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
79 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
80 || AC_MSG_ERROR([libtool configure failed])
83 # AM_ENABLE_SHARED - implement the --enable-shared flag
84 # Usage: AM_ENABLE_SHARED[(DEFAULT)]
85 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
87 AC_DEFUN(AM_ENABLE_SHARED,
88 [define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
90 changequote(<<, >>)dnl
91 << --enable-shared build shared libraries [default=>>AM_ENABLE_SHARED_DEFAULT]
93 [ --enable-shared=PKGS only build shared libraries if the current package
94 appears as an element in the PKGS list],
97 yes) enable_shared=yes ;;
98 no) enable_shared=no ;;
101 # Look at the argument we got. We use all the common list separators.
102 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
103 for pkg in $enableval; do
104 if test "X$pkg" = "X$p"; then
111 enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
114 # AM_DISABLE_SHARED - set the default shared flag to --disable-shared
115 AC_DEFUN(AM_DISABLE_SHARED,
116 [AM_ENABLE_SHARED(no)])
118 # AM_DISABLE_STATIC - set the default static flag to --disable-static
119 AC_DEFUN(AM_DISABLE_STATIC,
120 [AM_ENABLE_STATIC(no)])
122 # AM_ENABLE_STATIC - implement the --enable-static flag
123 # Usage: AM_ENABLE_STATIC[(DEFAULT)]
124 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
126 AC_DEFUN(AM_ENABLE_STATIC,
127 [define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
128 AC_ARG_ENABLE(static,
129 changequote(<<, >>)dnl
130 << --enable-static build static libraries [default=>>AM_ENABLE_STATIC_DEFAULT]
132 [ --enable-static=PKGS only build shared libraries if the current package
133 appears as an element in the PKGS list],
134 [p=${PACKAGE-default}
136 yes) enable_static=yes ;;
137 no) enable_static=no ;;
140 # Look at the argument we got. We use all the common list separators.
141 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
142 for pkg in $enableval; do
143 if test "X$pkg" = "X$p"; then
150 enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
154 # AM_PROG_LD - find the path to the GNU or non-GNU linker
157 [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
158 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
159 AC_REQUIRE([AC_PROG_CC])
161 if test "$ac_cv_prog_gcc" = yes; then
162 # Check if gcc -print-prog-name=ld gives a path.
163 AC_MSG_CHECKING([for ld used by GCC])
164 ac_prog=`($CC -print-prog-name=ld) 2>&5`
166 # Accept absolute paths.
168 test -z "$LD" && LD="$ac_prog"
171 # If it fails, then pretend we aren't using GCC.
175 # If it is relative, then search for the first ld in PATH.
179 elif test "$with_gnu_ld" = yes; then
180 AC_MSG_CHECKING([for GNU ld])
182 AC_MSG_CHECKING([for non-GNU ld])
184 AC_CACHE_VAL(ac_cv_path_LD,
185 [if test -z "$LD"; then
186 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
187 for ac_dir in $PATH; do
188 test -z "$ac_dir" && ac_dir=.
189 if test -f "$ac_dir/$ac_prog"; then
190 ac_cv_path_LD="$ac_dir/$ac_prog"
191 # Check to see if the program is GNU ld. I'd rather use --version,
192 # but apparently some GNU ld's only accept -v.
193 # Break only if it was the GNU/non-GNU ld that we prefer.
194 if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
195 test "$with_gnu_ld" != no && break
197 test "$with_gnu_ld" != yes && break
203 ac_cv_path_LD="$LD" # Let the user override the test with a path.
206 if test -n "$LD"; then
211 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
216 AC_DEFUN(AM_PROG_LD_GNU,
217 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
218 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
219 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
220 ac_cv_prog_gnu_ld=yes
226 # AM_PROG_NM - find the path to a BSD-compatible name lister
228 [AC_MSG_CHECKING([for BSD-compatible nm])
229 AC_CACHE_VAL(ac_cv_path_NM,
232 ac_cv_path_NM="$NM" # Let the user override the test with a path.
235 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
236 for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
237 test -z "$ac_dir" && ac_dir=.
238 if test -f $ac_dir/nm; then
239 # Check to see if the nm accepts a BSD-compat flag.
240 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
241 # nm: unknown option "B" ignored
242 if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
243 ac_cv_path_NM="$ac_dir/nm -B"
244 elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
245 ac_cv_path_NM="$ac_dir/nm -p"
247 ac_cv_path_NM="$ac_dir/nm"
253 test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm