]> Pileus Git - ~andy/gtk/blob - acinclude.m4
acinclude.m4 ltconfig upgrade to libtool 1.2d (with fixes for irix6 and
[~andy/gtk] / acinclude.m4
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
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 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
37 dnl
38 # Always use our own libtool.
39 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
40 AC_SUBST(LIBTOOL)dnl
41
42 # Check for any special flags to pass to ltconfig.
43 libtool_flags=
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"
49
50 # Some flags need to be propagated to the compiler or linker for good
51 # libtool support.
52 case "$host" in
53 *-*-irix6*)
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
58     *32-bit*)
59       LD="${LD-ld} -32"
60       ;;
61     *N32*)
62       LD="${LD-ld} -n32"
63       ;;
64     *64-bit*)
65       LD="${LD-ld} -64"
66       ;;
67     esac
68   fi
69   rm -rf conftest*
70   ;;
71
72 *-*-sco3.2v5*)
73   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
74   SAVE_CFLAGS="$CFLAGS"
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
80     CFLAGS="$SAVE_CFLAGS"
81   fi
82   ;;
83
84 *-*-cygwin32*)
85   AM_SYS_LIBTOOL_CYGWIN32
86   ;;
87
88 esac
89
90 # enable the --disable-libtool-lock switch
91
92 AC_ARG_ENABLE(libtool-lock,
93 [  --disable-libtool-lock  force libtool not to do file locking],
94 need_locks=$enableval,
95 need_locks=yes)
96
97 if test x"$need_locks" = xno; then
98   libtool_flags="$libtool_flags --disable-lock"
99 fi
100
101
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])
109
110 # Redirect the config.log output again, so that the ltconfig log is not
111 # clobbered by the next message.
112 exec 5>>./config.log
113 ])
114
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
118 #   `yes'.
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],
124 changequote([, ])dnl
125 [p=${PACKAGE-default}
126 case "$enableval" in
127 yes) enable_shared=yes ;;
128 no) enable_shared=no ;;
129 *)
130   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
135       enable_shared=yes
136     fi
137   done
138   IFS="$ac_save_ifs"
139   ;;
140 esac],
141 enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
142 ])
143
144 # AM_DISABLE_SHARED - set the default shared flag to --disable-shared
145 AC_DEFUN(AM_DISABLE_SHARED,
146 [AM_ENABLE_SHARED(no)])
147
148 # AM_DISABLE_STATIC - set the default static flag to --disable-static
149 AC_DEFUN(AM_DISABLE_STATIC,
150 [AM_ENABLE_STATIC(no)])
151
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
155 #   `yes'.
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],
161 changequote([, ])dnl
162 [p=${PACKAGE-default}
163 case "$enableval" in
164 yes) enable_static=yes ;;
165 no) enable_static=no ;;
166 *)
167   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
172       enable_static=yes
173     fi
174   done
175   IFS="$ac_save_ifs"
176   ;;
177 esac],
178 enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
179 ])
180
181
182 # AM_PROG_LD - find the path to the GNU or non-GNU linker
183 AC_DEFUN(AM_PROG_LD,
184 [AC_ARG_WITH(gnu-ld,
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
190 ac_prog=ld
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`
195   case "$ac_prog" in
196     # Accept absolute paths.
197 changequote(,)dnl
198     /* | [A-Za-z]:/*)
199       # Canonicalize the path of ld
200       re_direlt='/[^/][^/]*/\.\./'
201       sub_uncdrive='s%^\([A-Za-z]\):/%//\1/%'
202 changequote([,])dnl
203       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
204         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
205       done
206       case "$host_os" in
207       cygwin*)
208         # Convert to a UNC path for cygwin
209         test -z "$LD" && LD=`echo X$ac_prog | $Xsed -e "$sub_uncdrive"`
210         ;;
211       *)
212         test -z "$LD" && LD="$ac_prog"
213         ;;
214       esac
215       ;;
216     ##
217     ## FIXME:  The code fails later on if we try to use an $LD with
218     ##         '\\' path separators.
219     ##
220 changequote(,)dnl
221     [A-Za-z]:[\\]*)
222       # Canonicalize the path of ld
223       re_direlt='\\[^\\][^\\]*\\\.\.\(\\\)'
224       sub_uncdrive='s%^\([A-Za-z]\):\\%//\1/%'
225 changequote([,])dnl
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%"`
229       done
230       case "$host_os" in
231       cygwin*)
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"`
234         ;;
235       *)
236         test -z "$LD" && LD="$ac_prog"
237         ;;
238       esac
239       ;;
240   "")
241     # If it fails, then pretend we aren't using GCC.
242     ac_prog=ld
243     ;;
244   *)
245     # If it is relative, then search for the first ld in PATH.
246     with_gnu_ld=unknown
247     ;;
248   esac
249 elif test "$with_gnu_ld" = yes; then
250   AC_MSG_CHECKING([for GNU ld])
251 else
252   AC_MSG_CHECKING([for non-GNU ld])
253 fi
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
266       else
267         test "$with_gnu_ld" != yes && break
268       fi
269     fi
270   done
271   IFS="$ac_save_ifs"
272 else
273   ac_cv_path_LD="$LD" # Let the user override the test with a path.
274 fi])
275 LD="$ac_cv_path_LD"
276 if test -n "$LD"; then
277   AC_MSG_RESULT($LD)
278 else
279   AC_MSG_RESULT(no)
280 fi
281 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
282 AC_SUBST(LD)
283 AM_PROG_LD_GNU
284 ])
285
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
291 else
292   ac_cv_prog_gnu_ld=no
293 fi])
294 ])
295
296 # AM_PROG_NM - find the path to a BSD-compatible name lister
297 AC_DEFUN(AM_PROG_NM,
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.
302   ac_cv_path_NM="$NM"
303 else
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"
315       else
316         ac_cv_path_NM="$ac_dir/nm"
317       fi
318       break
319     fi
320   done
321   IFS="$ac_save_ifs"
322   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
323 fi])
324 NM="$ac_cv_path_NM"
325 AC_MSG_RESULT([$NM])
326 AC_SUBST(NM)
327 ])
328
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?!! ;)}
339
340 changequote(,)dnl
341 # Character class describing NM global symbol codes.
342 ac_symcode='[BCDEGRSTU]'
343
344 # Regexp to match symbols that can be accessed directly from C.
345 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
346
347 # Transform the above into a raw symbol and a C symbol.
348 ac_symxfrm='\1 \1'
349
350 # Define system-specific variables.
351 case "$host_os" in
352 aix*)
353   ac_symcode='[BCDTU]'
354   ;;
355 sunos* | cygwin32* | mingw32*)
356   ac_sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
357   ac_symxfrm='_\1 \1'
358   ;;
359 irix*)
360   # Cannot use undefined symbols on IRIX because inlined functions mess us up.
361   ac_symcode='[BCDEGRST]'
362   ;;
363 solaris*)
364   ac_symcode='[BDTU]'
365   ;;
366 esac
367
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]'
371 fi
372
373 case "$host_os" in
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]'
378   ;;
379 esac
380 changequote([,])dnl
381
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'"
384
385 # Check to see that the pipe works correctly.
386 ac_pipe_works=no
387 cat > conftest.$ac_ext <<EOF
388 #ifdef __cplusplus
389 extern "C" {
390 #endif
391 char nm_test_var;
392 void nm_test_func(){}
393 #ifdef __cplusplus
394 }
395 #endif
396 int main(){nm_test_var='a';nm_test_func;return 0;}
397 EOF
398 if AC_TRY_EVAL(ac_compile); then
399   # Now try to grab the symbols.
400   ac_nlist=conftest.nm
401   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
402
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`
407 changequote(,)dnl
408       ac_count=`echo "X$ac_wcout" | sed -e 's,^X,,' -e 's/^[    ]*\([0-9][0-9]*\).*$/\1/'`
409 changequote([,])dnl
410       (test "$ac_count" -ge 0) 2>/dev/null || ac_count=-1
411     else
412       rm -f "$ac_nlist"T
413       ac_count=-1
414     fi
415
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
420 #ifdef __cplusplus
421 extern "C" {
422 #endif
423
424 EOF
425         # Now generate the symbol file.
426         sed 's/^.* \(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
427
428         cat <<EOF >> conftest.c
429 #if defined (__STDC__) && __STDC__
430 # define __ptr_t void *
431 #else
432 # define __ptr_t char *
433 #endif
434
435 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
436 int dld_preloaded_symbol_count = $ac_count;
437
438 /* The mapping between symbol names and symbols. */
439 struct {
440   char *name;
441   __ptr_t address;
442 }
443 changequote(,)dnl
444 dld_preloaded_symbols[] =
445 changequote([,])dnl
446 {
447 EOF
448         sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
449         cat <<\EOF >> conftest.c
450   {0, (__ptr_t) 0}
451 };
452
453 #ifdef __cplusplus
454 }
455 #endif
456 EOF
457         # Now try linking the two files.
458         mv conftest.$ac_objext conftestm.$ac_objext
459         ac_save_LIBS="$LIBS"
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
464           ac_pipe_works=yes
465         else
466           echo "configure: failed program was:" >&AC_FD_CC
467           cat conftest.c >&AC_FD_CC
468         fi
469         LIBS="$ac_save_LIBS"
470         CFLAGS="$ac_save_CFLAGS"
471       else
472         echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
473       fi
474     else
475       echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
476     fi
477   else
478     echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
479   fi
480 else
481   echo "$progname: failed program was:" >&AC_FD_CC
482   cat conftest.c >&AC_FD_CC
483 fi
484 rm -rf conftest*
485
486 # Do not use the global_symbol_pipe unless it works.
487 test "$ac_pipe_works" = yes || ac_cv_sys_global_symbol_pipe=
488 ])
489
490 ac_result=yes
491 if test -z "$ac_cv_sys_global_symbol_pipe"; then
492    ac_result=no
493 fi
494 AC_MSG_RESULT($ac_result)
495 ])
496
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)
501 ])
502
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;}
514 EOF
515 if AC_TRY_EVAL(ac_compile); then
516   # Now try to grab the symbols.
517   ac_nlist=conftest.nm
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
522     else
523       if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
524         :
525       else
526         echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
527       fi
528     fi
529   else
530     echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
531   fi
532 else
533   echo "configure: failed program was:" >&AC_FD_CC
534   cat conftest.c >&AC_FD_CC
535 fi
536 rm -rf conftest*
537 ])
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])
542 fi
543 ])