source: trunk/src/binutils/libtool.m4@ 2302

Last change on this file since 2302 was 1104, checked in by bird, 22 years ago

Synced with gcc.

  • Property cvs2svn:cvs-rev set to 1.4
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 29.5 KB
Line 
1## libtool.m4 - Configure libtool for the host system. -*-Shell-script-*-
2## Copyright 1996, 1997, 1998, 1999, 2000, 2001
3## Free Software Foundation, Inc.
4## Originally by Gordon Matzigkeit <[email protected]>, 1996
5##
6## This program is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published by
8## the Free Software Foundation; either version 2 of the License, or
9## (at your option) any later version.
10##
11## This program is distributed in the hope that it will be useful, but
12## WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14## General Public License for more details.
15##
16## You should have received a copy of the GNU General Public License
17## along with this program; if not, write to the Free Software
18## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19##
20## As a special exception to the GNU General Public License, if you
21## distribute this file as part of a program that contains a
22## configuration script generated by Autoconf, you may include it under
23## the same distribution terms that you use for the rest of that program.
24
25# serial 46 AC_PROG_LIBTOOL
26AC_DEFUN([AC_PROG_LIBTOOL],
27[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
28dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
29dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
30 AC_PROVIDE_IFELSE([AC_PROG_CXX],
31 [AC_LIBTOOL_CXX],
32 [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
33])])
34
35dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
36dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
37dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
38 AC_PROVIDE_IFELSE([AC_PROG_GCJ],
39 [AC_LIBTOOL_GCJ],
40 [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
41 [AC_LIBTOOL_GCJ],
42 [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
43 [AC_LIBTOOL_GCJ],
44 [ifdef([AC_PROG_GCJ],
45 [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ
46])])
47 ifdef([A][M_PROG_GCJ],
48 [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ
49])])
50 ifdef([LT_AC_PROG_GCJ],
51 [define([LT_AC_PROG_GCJ], defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ
52])])])])])])
53
54AC_DEFUN([_AC_PROG_LIBTOOL],
55[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
56AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
57AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
58
59# Save cache, so that ltconfig can load it
60AC_CACHE_SAVE
61
62# Actually configure libtool. ac_aux_dir is where install-sh is found.
63AR="$AR" LTCC="$CC" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
64MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
65LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
66AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
67objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
68deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \
69${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
70$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \
71|| AC_MSG_ERROR([libtool configure failed])
72
73# Reload cache, that may have been modified by ltconfig
74AC_CACHE_LOAD
75
76# This can be used to rebuild libtool when needed
77LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh $ac_aux_dir/ltcf-c.sh"
78
79# Always use our own libtool.
80LIBTOOL='$(SHELL) $(top_builddir)/libtool'
81AC_SUBST(LIBTOOL)dnl
82
83# Redirect the config.log output again, so that the ltconfig log is not
84# clobbered by the next message.
85exec 5>>./config.log
86])
87
88AC_DEFUN([AC_LIBTOOL_SETUP],
89[AC_PREREQ(2.13)dnl
90AC_REQUIRE([AC_ENABLE_SHARED])dnl
91AC_REQUIRE([AC_ENABLE_STATIC])dnl
92AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
93AC_REQUIRE([AC_CANONICAL_HOST])dnl
94AC_REQUIRE([AC_CANONICAL_BUILD])dnl
95AC_REQUIRE([AC_PROG_CC])dnl
96AC_REQUIRE([AC_PROG_LD])dnl
97AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
98AC_REQUIRE([AC_PROG_NM])dnl
99AC_REQUIRE([AC_PROG_LN_S])dnl
100AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
101# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
102AC_REQUIRE([AC_OBJEXT])dnl
103AC_REQUIRE([AC_EXEEXT])dnl
104dnl
105
106# Only perform the check for file, if the check method requires it
107case $deplibs_check_method in
108file_magic*)
109 if test "$file_magic_cmd" = '$MAGIC_CMD'; then
110 AC_PATH_MAGIC
111 fi
112 ;;
113esac
114
115AC_CHECK_TOOL(RANLIB, ranlib, :)
116AC_CHECK_TOOL(STRIP, strip, :)
117
118# Check for any special flags to pass to ltconfig.
119libtool_flags="--cache-file=$cache_file"
120test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
121test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
122test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
123test "$GCC" = yes && libtool_flags="$libtool_flags --with-gcc"
124test "$lt_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
125ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
126[libtool_flags="$libtool_flags --enable-dlopen"])
127ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
128[libtool_flags="$libtool_flags --enable-win32-dll"])
129AC_ARG_ENABLE(libtool-lock,
130 [ --disable-libtool-lock avoid locking (might break parallel builds)])
131test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
132test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
133
134AC_ARG_WITH(pic,
135 [ --with-pic try to use only PIC/non-PIC objects [default=use both]],
136 pic_mode="$withval", pic_mode=default)
137test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic"
138test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
139
140# Some flags need to be propagated to the compiler or linker for good
141# libtool support.
142case $host in
143*-*-irix6*)
144 # Find out which ABI we are using.
145 echo '[#]line __oline__ "configure"' > conftest.$ac_ext
146 if AC_TRY_EVAL(ac_compile); then
147 if test "$lt_cv_prog_gnu_ld" = yes; then
148 case `/usr/bin/file conftest.$ac_objext` in
149 *32-bit*)
150 LD="${LD-ld} -melf32bsmip"
151 ;;
152 *N32*)
153 LD="${LD-ld} -melf32bmipn32"
154 ;;
155 *64-bit*)
156 LD="${LD-ld} -melf64bmip"
157 ;;
158 esac
159 else
160 case `/usr/bin/file conftest.$ac_objext` in
161 *32-bit*)
162 LD="${LD-ld} -32"
163 ;;
164 *N32*)
165 LD="${LD-ld} -n32"
166 ;;
167 *64-bit*)
168 LD="${LD-ld} -64"
169 ;;
170 esac
171 fi
172 fi
173 rm -rf conftest*
174 ;;
175
176ia64-*-hpux*)
177 # Find out which ABI we are using.
178 echo 'int i;' > conftest.$ac_ext
179 if AC_TRY_EVAL(ac_compile); then
180 case "`/usr/bin/file conftest.o`" in
181 *ELF-32*)
182 HPUX_IA64_MODE="32"
183 ;;
184 *ELF-64*)
185 HPUX_IA64_MODE="64"
186 ;;
187 esac
188 fi
189 rm -rf conftest*
190 ;;
191
192*-*-sco3.2v5*)
193 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
194 SAVE_CFLAGS="$CFLAGS"
195 CFLAGS="$CFLAGS -belf"
196 AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
197 [AC_LANG_SAVE
198 AC_LANG_C
199 AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
200 AC_LANG_RESTORE])
201 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
202 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
203 CFLAGS="$SAVE_CFLAGS"
204 fi
205 ;;
206
207ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
208[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
209 AC_CHECK_TOOL(DLLTOOL, dlltool, false)
210 AC_CHECK_TOOL(AS, as, false)
211 AC_CHECK_TOOL(OBJDUMP, objdump, false)
212
213 # recent cygwin and mingw systems supply a stub DllMain which the user
214 # can override, but on older systems we have to supply one
215 AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain,
216 [AC_TRY_LINK([],
217 [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);
218 DllMain (0, 0, 0);],
219 [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])])
220
221 case $host/$CC in
222 *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*)
223 # old mingw systems require "-dll" to link a DLL, while more recent ones
224 # require "-mdll"
225 SAVE_CFLAGS="$CFLAGS"
226 CFLAGS="$CFLAGS -mdll"
227 AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch,
228 [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])])
229 CFLAGS="$SAVE_CFLAGS" ;;
230 *-*-cygwin* | *-*-pw32*)
231 # cygwin systems need to pass --dll to the linker, and not link
232 # crt.o which will require a WinMain@16 definition.
233 lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;;
234 esac
235 ;;
236 ])
237esac
238])
239
240# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
241AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
242
243# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
244AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
245
246# AC_ENABLE_SHARED - implement the --enable-shared flag
247# Usage: AC_ENABLE_SHARED[(DEFAULT)]
248# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
249# `yes'.
250AC_DEFUN([AC_ENABLE_SHARED],
251[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
252AC_ARG_ENABLE(shared,
253changequote(<<, >>)dnl
254<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
255changequote([, ])dnl
256[p=${PACKAGE-default}
257case $enableval in
258yes) enable_shared=yes ;;
259no) enable_shared=no ;;
260*)
261 enable_shared=no
262 # Look at the argument we got. We use all the common list separators.
263 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
264 for pkg in $enableval; do
265 if test "X$pkg" = "X$p"; then