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 29 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_CANONICAL_BUILD])dnl
30 AC_REQUIRE([AC_PROG_RANLIB])dnl
31 AC_REQUIRE([AC_PROG_CC])dnl
32 AC_REQUIRE([AM_PROG_LD])dnl
33 AC_REQUIRE([AM_PROG_NM])dnl
34 AC_REQUIRE([AM_SYS_NM_PARSE])dnl
35 AC_REQUIRE([AM_SYS_SYMBOL_UNDERSCORE])dnl
36 AC_REQUIRE([AC_PROG_LN_S])dnl
38 # Always use our own libtool.
39 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
42 # Check for any special flags to pass to ltconfig.
44 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
45 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
46 test "$silent" = yes && libtool_flags="$libtool_flags --silent"
47 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
48 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
50 # Some flags need to be propagated to the compiler or linker for good
54 # Find out which ABI we are using.
55 echo '[#]line __oline__ "configure"' > conftest.$ac_ext
56 if AC_TRY_EVAL(ac_compile); then
57 case "`/usr/bin/file conftest.o`" in
73 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
75 CFLAGS="$CFLAGS -belf"
76 AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
77 [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
78 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
79 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
85 AM_SYS_LIBTOOL_CYGWIN32
90 # enable the --disable-libtool-lock switch
92 AC_ARG_ENABLE(libtool-lock,
93 [ --disable-libtool-lock force libtool not to do file locking],
94 need_locks=$enableval,
97 if test x"$need_locks" = xno; then
98 libtool_flags="$libtool_flags --disable-lock"
102 # Actually configure libtool. ac_aux_dir is where install-sh is found.
103 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
104 LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
105 DLLTOOL="$DLLTOOL" AS="$AS" \
106 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
107 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
108 || AC_MSG_ERROR([libtool configure failed])
110 # Redirect the config.log output again, so that the ltconfig log is not
111 # clobbered by the next message.
115 # AM_ENABLE_SHARED - implement the --enable-shared flag
116 # Usage: AM_ENABLE_SHARED[(DEFAULT)]
117 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
119 AC_DEFUN(AM_ENABLE_SHARED,
120 [define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
121 AC_ARG_ENABLE(shared,
122 changequote(<<, >>)dnl
123 << --enable-shared[=PKGS] build shared libraries [default=>>AM_ENABLE_SHARED_DEFAULT],
125 [p=${PACKAGE-default}
127 yes) enable_shared=yes ;;
128 no) enable_shared=no ;;
131 # Look at the argument we got. We use all the common list separators.
132 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
133 for pkg in $enableval; do
134 if test "X$pkg" = "X$p"; then
141 enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
144 # AM_DISABLE_SHARED - set the default shared flag to --disable-shared
145 AC_DEFUN(AM_DISABLE_SHARED,
146 [AM_ENABLE_SHARED(no)])
148 # AM_DISABLE_STATIC - set the default static flag to --disable-static
149 AC_DEFUN(AM_DISABLE_STATIC,
150 [AM_ENABLE_STATIC(no)])
152 # AM_ENABLE_STATIC - implement the --enable-static flag
153 # Usage: AM_ENABLE_STATIC[(DEFAULT)]
154 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
156 AC_DEFUN(AM_ENABLE_STATIC,
157 [define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
158 AC_ARG_ENABLE(static,
159 changequote(<<, >>)dnl
160 << --enable-static[=PKGS] build static libraries [default=>>AM_ENABLE_STATIC_DEFAULT],
162 [p=${PACKAGE-default}
164 yes) enable_static=yes ;;
165 no) enable_static=no ;;
168 # Look at the argument we got. We use all the common list separators.
169 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
170 for pkg in $enableval; do
171 if test "X$pkg" = "X$p"; then
178 enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
182 # AM_PROG_LD - find the path to the GNU or non-GNU linker
185 [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
186 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
187 AC_REQUIRE([AC_PROG_CC])dnl
188 AC_REQUIRE([AC_CANONICAL_HOST])dnl
189 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
191 if test "$ac_cv_prog_gcc" = yes; then
192 # Check if gcc -print-prog-name=ld gives a path.
193 AC_MSG_CHECKING([for ld used by GCC])
194 ac_prog=`($CC -print-prog-name=ld) 2>&5`
196 # Accept absolute paths.
199 # Canonicalize the path of ld
200 re_direlt='/[^/][^/]*/\.\./'
201 sub_uncdrive='s%^\([A-Za-z]\):/%//\1/%'
203 while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
204 ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
208 # Convert to a UNC path for cygwin
209 test -z "$LD" && LD=`echo X$ac_prog | $Xsed -e "$sub_uncdrive"`
212 test -z "$LD" && LD="$ac_prog"
217 ## FIXME: The code fails later on if we try to use an $LD with
218 ## '\\' path separators.
222 # Canonicalize the path of ld
223 re_direlt='\\[^\\][^\\]*\\\.\.\(\\\)'
224 sub_uncdrive='s%^\([A-Za-z]\):\\%//\1/%'
226 sub_uncdir='s%\\%/%g'
227 while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
228 ac_prog=`echo $ac_prog| sed "s%$re_direlt%\1%"`
232 # Convert to a UNC path for cygwin
233 test -z "$LD" && LD=`echo X$ac_prog | sed -e 's%^X%%' -e "$sub_uncdrive" -e "$sub_uncdir"`
236 test -z "$LD" && LD="$ac_prog"
241 # If it fails, then pretend we aren't using GCC.
245 # If it is relative, then search for the first ld in PATH.
249 elif test "$with_gnu_ld" = yes; then
250 AC_MSG_CHECKING([for GNU ld])
252 AC_MSG_CHECKING([for non-GNU ld])
254 AC_CACHE_VAL(ac_cv_path_LD,
255 [if test -z "$LD"; then
256 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
257 for ac_dir in $PATH; do
258 test -z "$ac_dir" && ac_dir=.
259 if test -f "$ac_dir/$ac_prog"; then
260 ac_cv_path_LD="$ac_dir/$ac_prog"
261 # Check to see if the program is GNU ld. I'd rather use --version,
262 # but apparently some GNU ld's only accept -v.
263 # Break only if it was the GNU/non-GNU ld that we prefer.
264 if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
265 test "$with_gnu_ld" != no && break
267 test "$with_gnu_ld" != yes && break
273 ac_cv_path_LD="$LD" # Let the user override the test with a path.
276 if test -n "$LD"; then
281 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
286 AC_DEFUN(AM_PROG_LD_GNU,
287 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
288 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
289 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
290 ac_cv_prog_gnu_ld=yes
296 # AM_PROG_NM - find the path to a BSD-compatible name lister
298 [AC_MSG_CHECKING([for BSD-compatible nm])
299 AC_CACHE_VAL(ac_cv_path_NM,
300 [if test -n "$NM"; then
301 # Let the user override the test.
304 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
305 for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
306 test -z "$ac_dir" && ac_dir=.
307 if test -f $ac_dir/nm; then
308 # Check to see if the nm accepts a BSD-compat flag.
309 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
310 # nm: unknown option "B" ignored
311 if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
312 ac_cv_path_NM="$ac_dir/nm -B"
313 elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
314 ac_cv_path_NM="$ac_dir/nm -p"
316 ac_cv_path_NM="$ac_dir/nm"
322 test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
329 # AM_SYS_NM_PARSE - Check for command ro grab the raw symbol name followed
330 # by C symbol name from nm.
331 AC_DEFUN(AM_SYS_NM_PARSE,
332 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
333 AC_REQUIRE([AM_PROG_NM])dnl
334 # Check for command to grab the raw symbol name followed by C symbol from nm.
335 AC_MSG_CHECKING([command to parse $NM output])
336 AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
337 [# These are sane defaults that work on at least a few old systems.
338 # {They come from Ultrix. What could be older than Ultrix?!! ;)}
341 # Character class describing NM global symbol codes.
342 ac_symcode='[BCDEGRSTU]'
344 # Regexp to match symbols that can be accessed directly from C.
345 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
347 # Transform the above into a raw symbol and a C symbol.
350 # Define system-specific variables.
355 sunos* | cygwin32* | mingw32*)
356 ac_sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
360 # Cannot use undefined symbols on IRIX because inlined functions mess us up.
361 ac_symcode='[BCDEGRST]'
368 # If we're using GNU nm, then use its standard symbol codes.
369 if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
370 ac_symcode='[ABCDGISTUW]'
374 cygwin32* | mingw32*)
375 # We do not want undefined symbols on cygwin32. The user must
376 # arrange to define them via -l arguments.
377 ac_symcode='[ABCDGISTW]'
382 # Write the raw and C identifiers.
383 ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.* $ac_symcode $ac_sympat$/$ac_symxfrm/p'"
385 # Check to see that the pipe works correctly.
387 cat > conftest.$ac_ext <<EOF
392 void nm_test_func(){}
396 int main(){nm_test_var='a';nm_test_func;return 0;}
398 if AC_TRY_EVAL(ac_compile); then
399 # Now try to grab the symbols.
401 if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
403 # Try sorting and uniquifying the output.
404 if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
405 mv -f "$ac_nlist"T "$ac_nlist"
406 ac_wcout=`wc "$ac_nlist" 2>/dev/null`
408 ac_count=`echo "X$ac_wcout" | sed -e 's,^X,,' -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'`
410 (test "$ac_count" -ge 0) 2>/dev/null || ac_count=-1
416 # Make sure that we snagged all the symbols we need.
417 if egrep ' nm_test_var$' "$ac_nlist" >/dev/null; then
418 if egrep ' nm_test_func$' "$ac_nlist" >/dev/null; then
419 cat <<EOF > conftest.c
425 # Now generate the symbol file.
426 sed 's/^.* \(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
428 cat <<EOF >> conftest.c
429 #if defined (__STDC__) && __STDC__
430 # define __ptr_t void *
432 # define __ptr_t char *
435 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
436 int dld_preloaded_symbol_count = $ac_count;
438 /* The mapping between symbol names and symbols. */
444 dld_preloaded_symbols[] =
448 sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
449 cat <<\EOF >> conftest.c
457 # Now try linking the two files.
458 mv conftest.$ac_objext conftestm.$ac_objext
460 ac_save_CFLAGS="$CFLAGS"
461 LIBS="conftestm.$ac_objext"
462 CFLAGS="$CFLAGS$no_builtin_flag"
463 if AC_TRY_EVAL(ac_link) && test -s conftest; then
466 echo "configure: failed program was:" >&AC_FD_CC
467 cat conftest.c >&AC_FD_CC
470 CFLAGS="$ac_save_CFLAGS"
472 echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
475 echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
478 echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
481 echo "$progname: failed program was:" >&AC_FD_CC
482 cat conftest.c >&AC_FD_CC
486 # Do not use the global_symbol_pipe unless it works.
487 test "$ac_pipe_works" = yes || ac_cv_sys_global_symbol_pipe=
491 if test -z "$ac_cv_sys_global_symbol_pipe"; then
494 AC_MSG_RESULT($ac_result)
497 # AM_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
498 AC_DEFUN(AM_SYS_LIBTOOL_CYGWIN32,
499 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
500 AC_CHECK_TOOL(AS, as, false)
503 # AM_SYS_SYMBOL_UNDERSCORE - does the compiler prefix global symbols
504 # with an underscore?
505 AC_DEFUN(AM_SYS_SYMBOL_UNDERSCORE,
506 [AC_REQUIRE([AM_PROG_NM])dnl
507 AC_REQUIRE([AM_SYS_NM_PARSE])dnl
508 AC_MSG_CHECKING([for _ prefix in compiled symbols])
509 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
510 [ac_cv_sys_symbol_underscore=no
511 cat > conftest.$ac_ext <<EOF
512 void nm_test_func(){}
513 int main(){nm_test_func;return 0;}
515 if AC_TRY_EVAL(ac_compile); then
516 # Now try to grab the symbols.
518 if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
519 # See whether the symbols have a leading underscore.
520 if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
521 ac_cv_sys_symbol_underscore=yes
523 if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
526 echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
530 echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
533 echo "configure: failed program was:" >&AC_FD_CC
534 cat conftest.c >&AC_FD_CC
538 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
539 if test x$ac_cv_sys_symbol_underscore = xyes; then
540 AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
541 [define if compiled symbols have a leading underscore])