root / ImageMagick / branches / ImageMagick-6.3.5 / libtool

Revision 8081, 213.9 kB (checked in by cristy, 13 months ago)
  • Property svn:executable set to *
Line 
1#! /bin/sh
2
3# libtoolT - Provide generalized library-building support services.
4# Generated automatically by  (GNU ImageMagick 6.3.5)
5# NOTE: Changes made to this file will be lost: look at ltmain.sh.
6#
7# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
8# Free Software Foundation, Inc.
9#
10# This file is part of GNU Libtool:
11# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
12#
13# This program is free software; you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation; either version 2 of the License, or
16# (at your option) any later version.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, write to the Free Software
25# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26#
27# As a special exception to the GNU General Public License, if you
28# distribute this file as part of a program that contains a
29# configuration script generated by Autoconf, you may include it under
30# the same distribution terms that you use for the rest of that program.
31
32# A sed program that does not truncate output.
33SED="/bin/sed"
34
35# Sed that helps us avoid accidentally triggering echo(1) options like -n.
36Xsed="/bin/sed -e 1s/^X//"
37
38# The HP-UX ksh and POSIX shell print the target directory to stdout
39# if CDPATH is set.
40(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
41
42# The names of the tagged configurations supported by this script.
43available_tags=
44
45# ### BEGIN LIBTOOL CONFIG
46
47# Libtool was configured on host magick.imagemagick.org:
48
49# Shell to use when invoking shell scripts.
50SHELL="/bin/sh"
51
52# Whether or not to build shared libraries.
53build_libtool_libs=yes
54
55# Whether or not to build static libraries.
56build_old_libs=yes
57
58# Whether or not to add -lc for building shared libraries.
59build_libtool_need_lc=no
60
61# Whether or not to disallow shared libs when runtime libs are static
62allow_libtool_libs_with_static_runtimes=no
63
64# Whether or not to optimize for fast installation.
65fast_install=yes
66
67# The host system.
68host_alias=
69host=x86_64-unknown-linux-gnu
70host_os=linux-gnu
71
72# The build system.
73build_alias=
74build=x86_64-unknown-linux-gnu
75build_os=linux-gnu
76
77# An echo program that does not interpret backslashes.
78echo="echo"
79
80# The archiver.
81AR="ar"
82AR_FLAGS="cru"
83
84# A C compiler.
85LTCC="gcc"
86
87# LTCC compiler flags.
88LTCFLAGS="-g -O2 -Wall -W -pthread "
89
90# A language-specific compiler.
91CC="gcc"
92
93# Is the compiler the GNU C compiler?
94with_gcc=yes
95
96# An ERE matcher.
97EGREP="/bin/grep -E"
98
99# The linker used to build libraries.
100LD="/usr/bin/ld -m elf_x86_64"
101
102# Whether we need hard or soft links.
103LN_S="ln -s"
104
105# A BSD-compatible nm program.
106NM="/usr/bin/nm -B"
107
108# A symbol stripping program
109STRIP="strip"
110
111# Used to examine libraries when file_magic_cmd begins "file"
112MAGIC_CMD=file
113
114# Used on cygwin: DLL creation program.
115DLLTOOL="dlltool"
116
117# Used on cygwin: object dumper.
118OBJDUMP="objdump"
119
120# Used on cygwin: assembler.
121AS="as"
122
123# The name of the directory that contains temporary libtool files.
124objdir=.libs
125
126# How to create reloadable object files.
127reload_flag=" -r"
128reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs"
129
130# How to pass a linker flag through the compiler.
131wl="-Wl,"
132
133# Object file suffix (normally "o").
134objext="o"
135
136# Old archive suffix (normally "a").
137libext="a"
138
139# Shared library suffix (normally ".so").
140shrext_cmds='.so'
141
142# Executable file suffix (normally "").
143exeext=""
144
145# Additional compiler flags for building library objects.
146pic_flag=" -fPIC -DPIC"
147pic_mode=default
148
149# What is the maximum length of a command?
150max_cmd_len=98304
151
152# Does compiler simultaneously support -c and -o options?
153compiler_c_o="yes"
154
155# Must we lock files when doing compilation?
156need_locks="no"
157
158# Do we need the lib prefix for modules?
159need_lib_prefix=no
160
161# Do we need a version for libraries?
162need_version=no
163
164# Whether dlopen is supported.
165dlopen_support=yes
166
167# Whether dlopen of programs is supported.
168dlopen_self=yes
169
170# Whether dlopen of statically linked programs is supported.
171dlopen_self_static=no
172
173# Compiler flag to prevent dynamic linking.
174link_static_flag="-static"
175
176# Compiler flag to turn off builtin functions.
177no_builtin_flag=" -fno-builtin"
178
179# Compiler flag to allow reflexive dlopens.
180export_dynamic_flag_spec="\${wl}--export-dynamic"
181
182# Compiler flag to generate shared objects directly from archives.
183whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive"
184
185# Compiler flag to generate thread-safe objects.
186thread_safe_flag_spec=""
187
188# Library versioning type.
189version_type=linux
190
191# Format of library name prefix.
192libname_spec="lib\$name"
193
194# List of archive names.  First name is the real one, the rest are links.
195# The last name is the one that the linker finds with -lNAME.
196library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}"
197
198# The coded name of the library, if different from the real name.
199soname_spec="\${libname}\${release}\${shared_ext}\$major"
200
201# Commands used to build and install an old-style archive.
202RANLIB="ranlib"
203old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$oldlib"
204old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$oldlib"
205old_postuninstall_cmds=""
206
207# Create an old-style archive from a shared archive.
208old_archive_from_new_cmds=""
209
210# Create a temporary old-style archive to link instead of a shared archive.
211old_archive_from_expsyms_cmds=""
212
213# Commands used to build and install a shared archive.
214archive_cmds="\$CC -shared \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib"
215archive_expsym_cmds="\$echo \\\"{ global:\\\" > \$output_objdir/\$libname.ver~
216  cat \$export_symbols | sed -e \\\"s/\\\\(.*\\\\)/\\\\1;/\\\" >> \$output_objdir/\$libname.ver~
217  \$echo \\\"local: *; };\\\" >> \$output_objdir/\$libname.ver~
218          \$CC -shared \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname \${wl}-version-script \${wl}\$output_objdir/\$libname.ver -o \$lib"
219postinstall_cmds=""
220postuninstall_cmds=""
221
222# Commands used to build a loadable module (assumed same as above if empty)
223module_cmds=""
224module_expsym_cmds=""
225
226# Commands to strip libraries.
227old_striplib="strip --strip-debug"
228striplib="strip --strip-unneeded"
229
230# Dependencies to place before the objects being linked to create a
231# shared library.
232predep_objects=""
233
234# Dependencies to place after the objects being linked to create a
235# shared library.
236postdep_objects=""
237
238# Dependencies to place before the objects being linked to create a
239# shared library.
240predeps=""
241
242# Dependencies to place after the objects being linked to create a
243# shared library.
244postdeps=""
245
246# The library search path used internally by the compiler when linking
247# a shared library.
248compiler_lib_search_path=""
249
250# Method to check whether dependent libraries are shared objects.
251deplibs_check_method="pass_all"
252
253# Command to use when deplibs_check_method == file_magic.
254file_magic_cmd="\$MAGIC_CMD"
255
256# Flag that allows shared libraries with undefined symbols to be built.
257allow_undefined_flag=""
258
259# Flag that forces no undefined symbols.
260no_undefined_flag=""
261
262# Commands used to finish a libtool library installation in a directory.
263finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir"
264
265# Same as above, but a single script fragment to be evaled but not shown.
266finish_eval=""
267
268# Take the output of nm and produce a listing of raw symbols and C names.
269global_symbol_pipe="sed -n -e 's/^.*[   ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[       ][      ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p'"
270
271# Transform the output of nm in a proper C declaration
272global_symbol_to_cdecl="sed -n -e 's/^. .* \\(.*\\)\$/extern int \\1;/p'"
273
274# Transform the output of nm in a C name address pair
275global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/  {\\\"\\1\\\", (lt_ptr) 0},/p' -e 's/^[BCDEGRST] \\([^ ]*\\) \\([^ ]*\\)\$/  {\"\\2\", (lt_ptr) \\&\\2},/p'"
276
277# This is the shared library runtime path variable.
278runpath_var=LD_RUN_PATH
279
280# This is the shared library path variable.
281shlibpath_var=LD_LIBRARY_PATH
282
283# Is shlibpath searched before the hard-coded library search path?
284shlibpath_overrides_runpath=no
285
286# How to hardcode a shared library path into an executable.
287hardcode_action=immediate
288
289# Whether we should hardcode library paths into libraries.
290hardcode_into_libs=yes
291
292# Flag to hardcode $libdir into a binary during linking.
293# This must work even if $libdir does not exist.
294hardcode_libdir_flag_spec="\${wl}--rpath \${wl}\$libdir"
295
296# If ld is used when linking, flag to hardcode $libdir into
297# a binary during linking. This must work even if $libdir does
298# not exist.
299hardcode_libdir_flag_spec_ld=""
300
301# Whether we need a single -rpath flag with a separated argument.
302hardcode_libdir_separator=""
303
304# Set to yes if using DIR/libNAME during linking hardcodes DIR into the
305# resulting binary.
306hardcode_direct=no
307
308# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
309# resulting binary.
310hardcode_minus_L=no
311
312# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
313# the resulting binary.
314hardcode_shlibpath_var=unsupported
315
316# Set to yes if building a shared library automatically hardcodes DIR into the library
317# and all subsequent libraries and executables linked against it.
318hardcode_automatic=no
319
320# Variables whose values should be saved in libtool wrapper scripts and
321# restored at relink time.
322variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
323
324# Whether libtool must link a program against all its dependency libraries.
325link_all_deplibs=unknown
326
327# Compile-time system search path for libraries
328sys_lib_search_path_spec="/usr/lib64 /lib64 /usr/local/lib64"
329
330# Run-time system search path for libraries
331sys_lib_dlsearch_path_spec="/usr/lib64 /lib64 /usr/local/lib /usr/lib/mysql /usr/lib64/mysql /usr/lib64/qt-3.3/lib "
332
333# Fix the shell variable $srcfile for the compiler.
334fix_srcfile_path=""
335
336# Set to yes if exported symbols are required.
337always_export_symbols=no
338
339# The commands to list exported symbols.
340export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols"
341
342# The commands to extract the exported symbol list from a shared archive.
343extract_expsyms_cmds=""
344
345# Symbols that should not be listed in the preloaded symbols.
346exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
347
348# Symbols that must always be exported.
349include_expsyms=""
350
351# ### END LIBTOOL CONFIG
352
353# ltmain.sh - Provide generalized library-building support services.
354# NOTE: Changing this file will not affect anything until you rerun configure.
355#
356# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
357# 2007  Free Software Foundation, Inc.
358# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
359#
360# This program is free software; you can redistribute it and/or modify
361# it under the terms of the GNU General Public License as published by
362# the Free Software Foundation; either version 2 of the License, or
363# (at your option) any later version.
364#
365# This program is distributed in the hope that it will be useful, but
366# WITHOUT ANY WARRANTY; without even the implied warranty of
367# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
368# General Public License for more details.
369#
370# You should have received a copy of the GNU General Public License
371# along with this program; if not, write to the Free Software
372# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
373#
374# As a special exception to the GNU General Public License, if you
375# distribute this file as part of a program that contains a
376# configuration script generated by Autoconf, you may include it under
377# the same distribution terms that you use for the rest of that program.
378
379basename="s,^.*/,,g"
380
381# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
382# is ksh but when the shell is invoked as "sh" and the current value of
383# the _XPG environment variable is not equal to 1 (one), the special
384# positional parameter $0, within a function call, is the name of the
385# function.
386progpath="$0"
387
388# The name of this program:
389progname=`echo "$progpath" | $SED $basename`
390modename="$progname"
391
392# Global variables:
393EXIT_SUCCESS=0
394EXIT_FAILURE=1
395
396PROGRAM=ltmain.sh
397PACKAGE=libtool
398VERSION=1.5.24
399TIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)"
400
401# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
402if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
403  emulate sh
404  NULLCMD=:
405  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
406  # is contrary to our usage.  Disable this feature.
407  alias -g '${1+"$@"}'='"$@"'
408  setopt NO_GLOB_SUBST
409else
410  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
411fi
412BIN_SH=xpg4; export BIN_SH # for Tru64
413DUALCASE=1; export DUALCASE # for MKS sh
414
415# Check that we have a working $echo.
416if test "X$1" = X--no-reexec; then
417  # Discard the --no-reexec flag, and continue.
418  shift
419elif test "X$1" = X--fallback-echo; then
420  # Avoid inline document here, it may be left over
421  :
422elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
423  # Yippee, $echo works!
424  :
425else
426  # Restart under the correct shell, and then maybe $echo will work.
427  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
428fi
429
430if test "X$1" = X--fallback-echo; then
431  # used as fallback echo
432  shift
433  cat <<EOF
434$*
435EOF
436  exit $EXIT_SUCCESS
437fi
438
439default_mode=
440help="Try \`$progname --help' for more information."
441magic="%%%MAGIC variable%%%"
442mkdir="mkdir"
443mv="mv -f"
444rm="rm -f"
445
446# Sed substitution that helps us do robust quoting.  It backslashifies
447# metacharacters that are still active within double-quoted strings.
448Xsed="${SED}"' -e 1s/^X//'
449sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
450# test EBCDIC or ASCII
451case `echo X|tr X '\101'` in
452 A) # ASCII based system
453    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
454  SP2NL='tr \040 \012'
455  NL2SP='tr \015\012 \040\040'
456  ;;
457 *) # EBCDIC based system
458  SP2NL='tr \100 \n'
459  NL2SP='tr \r\n \100\100'
460  ;;
461esac
462
463# NLS nuisances.
464# Only set LANG and LC_ALL to C if already set.
465# These must not be set unconditionally because not all systems understand
466# e.g. LANG=C (notably SCO).
467# We save the old values to restore during execute mode.
468for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
469do
470  eval "if test \"\${$lt_var+set}\" = set; then
471          save_$lt_var=\$$lt_var
472          $lt_var=C
473          export $lt_var
474        fi"
475done
476
477# Make sure IFS has a sensible default
478lt_nl='
479'
480IFS="   $lt_nl"
481
482if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
483  $echo "$modename: not configured to build any kind of library" 1>&2
484  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
485  exit $EXIT_FAILURE
486fi
487
488# Global variables.
489mode=$default_mode
490nonopt=
491prev=
492prevopt=
493run=
494show="$echo"
495show_help=
496execute_dlfiles=
497duplicate_deps=no
498preserve_args=
499lo2o="s/\\.lo\$/.${objext}/"
500o2lo="s/\\.${objext}\$/.lo/"
501extracted_archives=
502extracted_serial=0
503
504#####################################
505# Shell function definitions:
506# This seems to be the best place for them
507
508# func_mktempdir [string]
509# Make a temporary directory that won't clash with other running
510# libtool processes, and avoids race conditions if possible.  If
511# given, STRING is the basename for that directory.
512func_mktempdir ()
513{
514    my_template="${TMPDIR-/tmp}/${1-$progname}"
515
516    if test "$run" = ":"; then
517      # Return a directory name, but don't create it in dry-run mode
518      my_tmpdir="${my_template}-$$"
519    else
520
521      # If mktemp works, use that first and foremost
522      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
523
524      if test ! -d "$my_tmpdir"; then
525        # Failing that, at least try and use $RANDOM to avoid a race
526        my_tmpdir="${my_template}-${RANDOM-0}$$"
527
528        save_mktempdir_umask=`umask`
529        umask 0077
530        $mkdir "$my_tmpdir"
531        umask $save_mktempdir_umask
532      fi
533
534      # If we're not in dry-run mode, bomb out on failure
535      test -d "$my_tmpdir" || {
536        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
537        exit $EXIT_FAILURE
538      }
539    fi
540
541    $echo "X$my_tmpdir" | $Xsed
542}
543
544
545# func_win32_libid arg
546# return the library type of file 'arg'
547#
548# Need a lot of goo to handle *both* DLLs and import libs
549# Has to be a shell function in order to 'eat' the argument
550# that is supplied when $file_magic_command is called.
551func_win32_libid ()
552{
553  win32_libid_type="unknown"
554  win32_fileres=`file -L $1 2>/dev/null`
555  case $win32_fileres in
556  *ar\ archive\ import\ library*) # definitely import
557    win32_libid_type="x86 archive import"
558    ;;
559  *ar\ archive*) # could be an import, or static
560    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
561      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
562      win32_nmres=`eval $NM -f posix -A $1 | \
563        $SED -n -e '1,100{
564                / I /{
565                        s,.*,import,
566                        p
567                        q
568                        }
569                }'`
570      case $win32_nmres in
571      import*)  win32_libid_type="x86 archive import";;
572      *)        win32_libid_type="x86 archive static";;
573      esac
574    fi
575    ;;
576  *DLL*)
577    win32_libid_type="x86 DLL"
578    ;;
579  *executable*) # but shell scripts are "executable" too...
580    case $win32_fileres in
581    *MS\ Windows\ PE\ Intel*)
582      win32_libid_type="x86 DLL"
583      ;;
584    esac
585    ;;
586  esac
587  $echo $win32_libid_type
588}
589
590
591# func_infer_tag arg
592# Infer tagged configuration to use if any are available and
593# if one wasn't chosen via the "--tag" command line option.
594# Only attempt this if the compiler in the base compile
595# command doesn't match the default compiler.
596# arg is usually of the form 'gcc ...'
597func_infer_tag ()
598{
599    if test -n "$available_tags" && test -z "$tagname"; then
600      CC_quoted=
601      for arg in $CC; do
602        case $arg in
603          *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
604          arg="\"$arg\""
605          ;;
606        esac
607        CC_quoted="$CC_quoted $arg"
608      done
609      case $@ in
610      # Blanks in the command may have been stripped by the calling shell,
611      # but not from the CC environment variable when configure was run.
612      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
613      # Blanks at the start of $base_compile will cause this to fail
614      # if we don't check for them as well.
615      *)
616        for z in $available_tags; do
617          if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
618            # Evaluate the configuration.
619            eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
620            CC_quoted=
621            for arg in $CC; do
622            # Double-quote args containing other shell metacharacters.
623            case $arg in
624              *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
625              arg="\"$arg\""
626              ;;
627            esac
628            CC_quoted="$CC_quoted $arg"
629          done
630            case "$@ " in
631              " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
632              # The compiler in the base compile command matches
633              # the one in the tagged configuration.
634              # Assume this is the tagged configuration we want.
635              tagname=$z
636              break
637              ;;
638            esac
639          fi
640        done
641        # If $tagname still isn't set, then no tagged configuration
642        # was found and let the user know that the "--tag" command
643        # line option must be used.
644        if test -z "$tagname"; then
645          $echo "$modename: unable to infer tagged configuration"
646          $echo "$modename: specify a tag with \`--tag'" 1>&2
647          exit $EXIT_FAILURE
648#        else
649#          $echo "$modename: using $tagname tagged configuration"
650        fi
651        ;;
652      esac
653    fi
654}
655
656
657# func_extract_an_archive dir oldlib
658func_extract_an_archive ()
659{
660    f_ex_an_ar_dir="$1"; shift
661    f_ex_an_ar_oldlib="$1"
662
663    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
664    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
665    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
666     :
667    else
668      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
669      exit $EXIT_FAILURE
670    fi
671}
672
673# func_extract_archives gentop oldlib ...
674func_extract_archives ()
675{
676    my_gentop="$1"; shift
677    my_oldlibs=${1+"$@"}
678    my_oldobjs=""
679    my_xlib=""
680    my_xabs=""
681    my_xdir=""
682    my_status=""
683
684    $show "${rm}r $my_gentop"
685    $run ${rm}r "$my_gentop"
686    $show "$mkdir $my_gentop"
687    $run $mkdir "$my_gentop"
688    my_status=$?
689    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
690      exit $my_status
691    fi
692
693    for my_xlib in $my_oldlibs; do
694      # Extract the objects.
695      case $my_xlib in
696        [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
697        *) my_xabs=`pwd`"/$my_xlib" ;;
698      esac
699      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
700      my_xlib_u=$my_xlib
701      while :; do
702        case " $extracted_archives " in
703        *" $my_xlib_u "*)
704          extracted_serial=`expr $extracted_serial + 1`
705          my_xlib_u=lt$extracted_serial-$my_xlib ;;
706        *) break ;;
707        esac
708      done
709      extracted_archives="$extracted_archives $my_xlib_u"
710      my_xdir="$my_gentop/$my_xlib_u"
711
712      $show "${rm}r $my_xdir"
713      $run ${rm}r "$my_xdir"
714      $show "$mkdir $my_xdir"
715      $run $mkdir "$my_xdir"
716      exit_status=$?
717      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
718        exit $exit_status
719      fi
720      case $host in
721      *-darwin*)
722        $show "Extracting $my_xabs"
723        # Do not bother doing anything if just a dry run
724        if test -z "$run"; then
725          darwin_orig_dir=`pwd`
726          cd $my_xdir || exit $?
727          darwin_archive=$my_xabs
728          darwin_curdir=`pwd`
729          darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
730          darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
731          if test -n "$darwin_arches"; then
732            darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
733            darwin_arch=
734            $show "$darwin_base_archive has multiple architectures $darwin_arches"
735            for darwin_arch in  $darwin_arches ; do
736              mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
737              lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
738              cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
739              func_extract_an_archive "`pwd`" "${darwin_base_archive}"
740              cd "$darwin_curdir"
741              $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
742            done # $darwin_arches
743      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
744            darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
745            darwin_file=
746            darwin_files=
747            for darwin_file in $darwin_filelist; do
748              darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
749              lipo -create -output "$darwin_file" $darwin_files
750            done # $darwin_filelist
751            ${rm}r unfat-$$
752            cd "$darwin_orig_dir"
753          else
754            cd "$darwin_orig_dir"
755            func_extract_an_archive "$my_xdir" "$my_xabs"
756          fi # $darwin_arches
757        fi # $run
758        ;;
759      *)
760        func_extract_an_archive "$my_xdir" "$my_xabs"
761        ;;
762      esac
763      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
764    done
765    func_extract_archives_result="$my_oldobjs"
766}
767# End of Shell function definitions
768#####################################
769
770# Darwin sucks
771eval std_shrext=\"$shrext_cmds\"
772
773disable_libs=no
774
775# Parse our command line options once, thoroughly.
776while test "$#" -gt 0
777do
778  arg="$1"
779  shift
780
781  case $arg in
782  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
783  *) optarg= ;;
784  esac
785
786  # If the previous option needs an argument, assign it.
787  if test -n "$prev"; then
788    case $prev in
789    execute_dlfiles)
790      execute_dlfiles="$execute_dlfiles $arg"
791      ;;
792    tag)
793      tagname="$arg"
794      preserve_args="${preserve_args}=$arg"
795
796      # Check whether tagname contains only valid characters
797      case $tagname in
798      *[!-_A-Za-z0-9,/]*)
799        $echo "$progname: invalid tag name: $tagname" 1>&2
800        exit $EXIT_FAILURE
801        ;;
802      esac
803
804      case $tagname in
805      CC)
806        # Don't test for the "default" C tag, as we know, it's there, but
807        # not specially marked.
808        ;;
809      *)
810        if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
811          taglist="$taglist $tagname"
812          # Evaluate the configuration.
813          eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
814        else
815          $echo "$progname: ignoring unknown tag $tagname" 1>&2
816        fi
817        ;;
818      esac
819      ;;
820    *)
821      eval "$prev=\$arg"
822      ;;
823    esac
824
825    prev=
826    prevopt=
827    continue
828  fi
829
830  # Have we seen a non-optional argument yet?
831  case $arg in
832  --help)
833    show_help=yes
834    ;;
835
836  --version)
837    echo "\
838$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
839
840Copyright (C) 2007  Free Software Foundation, Inc.
841This is free software; see the source for copying conditions.  There is NO
842warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
843    exit $?
844    ;;
845
846  --config)
847    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
848    # Now print the configurations for the tags.
849    for tagname in $taglist; do
850      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
851    done
852    exit $?
853    ;;
854
855  --debug)
856    $echo "$progname: enabling shell trace mode"
857    set -x
858    preserve_args="$preserve_args $arg"
859    ;;
860
861  --dry-run | -n)
862    run=:
863    ;;
864
865  --features)
866    $echo "host: $host"
867    if test "$build_libtool_libs" = yes; then
868      $echo "enable shared libraries"
869    else
870      $echo "disable shared libraries"
871    fi
872    if test "$build_old_libs" = yes; then
873      $echo "enable static libraries"
874    else
875      $echo "disable static libraries"
876    fi
877    exit $?
878    ;;
879
880  --finish) mode="finish" ;;
881
882  --mode) prevopt="--mode" prev=mode ;;
883  --mode=*) mode="$optarg" ;;
884
885  --preserve-dup-deps) duplicate_deps="yes" ;;
886
887  --quiet | --silent)
888    show=:
889    preserve_args="$preserve_args $arg"
890    ;;
891
892  --tag)
893    prevopt="--tag"
894    prev=tag
895    preserve_args="$preserve_args --tag"
896    ;;
897  --tag=*)
898    set tag "$optarg" ${1+"$@"}
899    shift
900    prev=tag
901    preserve_args="$preserve_args --tag"
902    ;;
903
904  -dlopen)
905    prevopt="-dlopen"
906    prev=execute_dlfiles
907    ;;
908
909  -*)
910    $echo "$modename: unrecognized option \`$arg'" 1>&2
911    $echo "$help" 1>&2
912    exit $EXIT_FAILURE
913    ;;
914
915  *)
916    nonopt="$arg"
917    break
918    ;;
919  esac
920done
921
922if test -n "$prevopt"; then
923  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
924  $echo "$help" 1>&2
925  exit $EXIT_FAILURE
926fi
927
928case $disable_libs in
929no)
930  ;;
931shared)
932  build_libtool_libs=no
933  build_old_libs=yes
934  ;;
935static)
936  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
937  ;;
938esac
939
940# If this variable is set in any of the actions, the command in it
941# will be execed at the end.  This prevents here-documents from being
942# left over by shells.
943exec_cmd=
944
945if test -z "$show_help"; then
946
947  # Infer the operation mode.
948  if test -z "$mode"; then
949    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
950    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
951    case $nonopt in
952    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
953      mode=link
954      for arg
955      do
956        case $arg in
957        -c)
958           mode=compile
959           break
960           ;;
961        esac
962      done
963      ;;
964    *db | *dbx | *strace | *truss)
965      mode=execute
966      ;;
967    *install*|cp|mv)
968      mode=install
969      ;;
970    *rm)
971      mode=uninstall
972      ;;
973    *)
974      # If we have no mode, but dlfiles were specified, then do execute mode.
975      test -n "$execute_dlfiles" && mode=execute
976
977      # Just use the default operation mode.
978      if test -z "$mode"; then
979        if test -n "$nonopt"; then
980          $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
981        else
982          $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
983        fi
984      fi
985      ;;
986    esac
987  fi
988
989  # Only execute mode is allowed to have -dlopen flags.
990  if test -n "$execute_dlfiles" && test "$mode" != execute; then
991    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
992    $echo "$help" 1>&2
993    exit $EXIT_FAILURE
994  fi
995
996  # Change the help message to a mode-specific one.
997  generic_help="$help"
998  help="Try \`$modename --help --mode=$mode' for more information."
999
1000  # These modes are in order of execution frequency so that they run quickly.
1001  case $mode in
1002  # libtool compile mode
1003  compile)
1004    modename="$modename: compile"
1005    # Get the compilation command and the source file.
1006    base_compile=
1007    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1008    suppress_opt=yes
1009    suppress_output=
1010    arg_mode=normal
1011    libobj=
1012    later=
1013
1014    for arg
1015    do
1016      case $arg_mode in
1017      arg  )
1018        # do not "continue".  Instead, add this to base_compile
1019        lastarg="$arg"
1020        arg_mode=normal
1021        ;;
1022
1023      target )
1024        libobj="$arg"
1025        arg_mode=normal
1026        continue
1027        ;;
1028
1029      normal )
1030        # Accept any command-line options.
1031        case $arg in
1032        -o)
1033          if test -n "$libobj" ; then
1034            $echo "$modename: you cannot specify \`-o' more than once" 1>&2
1035            exit $EXIT_FAILURE
1036          fi
1037          arg_mode=target
1038          continue
1039          ;;
1040
1041        -static | -prefer-pic | -prefer-non-pic)
1042          later="$later $arg"
1043          continue
1044          ;;
1045
1046        -no-suppress)
1047          suppress_opt=no
1048          continue
1049          ;;
1050
1051        -Xcompiler)
1052          arg_mode=arg  #  the next one goes into the "base_compile" arg list
1053          continue      #  The current "srcfile" will either be retained or
1054          ;;            #  replaced later.  I would guess that would be a bug.
1055
1056        -Wc,*)
1057          args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
1058          lastarg=
1059          save_ifs="$IFS"; IFS=','
1060          for arg in $args; do
1061            IFS="$save_ifs"
1062
1063            # Double-quote args containing other shell metacharacters.
1064            # Many Bourne shells cannot handle close brackets correctly
1065            # in scan sets, so we specify it separately.
1066            case $arg in
1067              *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
1068              arg="\"$arg\""
1069              ;;
1070            esac
1071            lastarg="$lastarg $arg"
1072          done
1073          IFS="$save_ifs"
1074          lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
1075
1076          # Add the arguments to base_compile.
1077          base_compile="$base_compile $lastarg"
1078          continue
1079          ;;
1080
1081        * )
1082          # Accept the current argument as the source file.
1083          # The previous "srcfile" becomes the current argument.
1084          #
1085          lastarg="$srcfile"
1086          srcfile="$arg"
1087          ;;
1088        esac  #  case $arg
1089        ;;
1090      esac    #  case $arg_mode
1091
1092      # Aesthetically quote the previous argument.
1093      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
1094
1095      case $lastarg in
1096      # Double-quote args containing other shell metacharacters.
1097      # Many Bourne shells cannot handle close brackets correctly
1098      # in scan sets, and some SunOS ksh mistreat backslash-escaping
1099      # in scan sets (worked around with variable expansion),
1100      # and furthermore cannot handle '|' '&' '(' ')' in scan sets
1101      # at all, so we specify them separately.
1102      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
1103        lastarg="\"$lastarg\""
1104        ;;
1105      esac
1106
1107      base_compile="$base_compile $lastarg"
1108    done # for arg
1109
1110    case $arg_mode in
1111    arg)
1112      $echo "$modename: you must specify an argument for -Xcompile"
1113      exit $EXIT_FAILURE
1114      ;;
1115    target)
1116      $echo "$modename: you must specify a target with \`-o'" 1>&2
1117      exit $EXIT_FAILURE
1118      ;;
1119    *)
1120      # Get the name of the library object.
1121      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
1122      ;;
1123    esac
1124
1125    # Recognize several different file suffixes.
1126    # If the user specifies -o file.o, it is replaced with file.lo
1127    xform='[cCFSifmso]'
1128    case $libobj in
1129    *.ada) xform=ada ;;
1130    *.adb) xform=adb ;;
1131    *.ads) xform=ads ;;
1132    *.asm) xform=asm ;;
1133    *.c++) xform=c++ ;;
1134    *.cc) xform=cc ;;
1135    *.ii) xform=ii ;;
1136    *.class) xform=class ;;
1137    *.cpp) xform=cpp ;;
1138    *.cxx) xform=cxx ;;
1139    *.[fF][09]?) xform=[fF][09]. ;;
1140    *.for) xform=for ;;
1141    *.java) xform=java ;;
1142    *.obj) xform=obj ;;
1143    esac
1144
1145    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
1146
1147    case $libobj in
1148    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
1149    *)
1150      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
1151      exit $EXIT_FAILURE
1152      ;;
1153    esac
1154
1155    func_infer_tag $base_compile
1156
1157    for arg in $later; do
1158      case $arg in
1159      -static)
1160        build_old_libs=yes
1161        continue
1162        ;;
1163
1164      -prefer-pic)
1165        pic_mode=yes
1166        continue
1167        ;;
1168
1169      -prefer-non-pic)
1170        pic_mode=no
1171        continue
1172        ;;
1173      esac
1174    done
1175
1176    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
1177    case $qlibobj in
1178      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
1179        qlibobj="\"$qlibobj\"" ;;
1180    esac
1181    test "X$libobj" != "X$qlibobj" \
1182        && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"'  &()|`$[]' \
1183        && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
1184    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
1185    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
1186    if test "X$xdir" = "X$obj"; then
1187      xdir=
1188    else
1189      xdir=$xdir/
1190    fi
1191    lobj=${xdir}$objdir/$objname
1192
1193    if test -z "$base_compile"; then
1194      $echo "$modename: you must specify a compilation command" 1>&2
1195      $echo "$help" 1>&2
1196      exit $EXIT_FAILURE
1197    fi
1198
1199    # Delete any leftover library objects.
1200    if test "$build_old_libs" = yes; then
1201      removelist="$obj $lobj $libobj ${libobj}T"
1202    else
1203      removelist="$lobj $libobj ${libobj}T"
1204    fi
1205
1206    $run $rm $removelist
1207    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
1208
1209    # On Cygwin there's no "real" PIC flag so we must build both object types
1210    case $host_os in
1211    cygwin* | mingw* | pw32* | os2*)
1212      pic_mode=default
1213      ;;
1214    esac
1215    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1216      # non-PIC code in shared libraries is not supported
1217      pic_mode=default
1218    fi
1219
1220    # Calculate the filename of the output object if compiler does
1221    # not support -o with -c
1222    if test "$compiler_c_o" = no; then
1223      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1224      lockfile="$output_obj.lock"
1225      removelist="$removelist $output_obj $lockfile"
1226      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
1227    else
1228      output_obj=
1229      need_locks=no
1230      lockfile=
1231    fi
1232
1233    # Lock this critical section if it is needed
1234    # We use this script file to make the link, it avoids creating a new file
1235    if test "$need_locks" = yes; then
1236      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
1237        $show "Waiting for $lockfile to be removed"
1238        sleep 2
1239      done
1240    elif test "$need_locks" = warn; then
1241      if test -f "$lockfile"; then
1242        $echo "\
1243*** ERROR, $lockfile exists and contains:
1244`cat $lockfile 2>/dev/null`
1245
1246This indicates that another process is trying to use the same
1247temporary object file, and libtool could not work around it because
1248your compiler does not support \`-c' and \`-o' together.  If you
1249repeat this compilation, it may succeed, by chance, but you had better
1250avoid parallel builds (make -j) in this platform, or get a better
1251compiler."
1252
1253        $run $rm $removelist
1254        exit $EXIT_FAILURE
1255      fi
1256      $echo "$srcfile" > "$lockfile"
1257    fi
1258
1259    if test -n "$fix_srcfile_path"; then
1260      eval srcfile=\"$fix_srcfile_path\"
1261    fi
1262    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
1263    case $qsrcfile in
1264      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
1265      qsrcfile="\"$qsrcfile\"" ;;
1266    esac
1267
1268    $run $rm "$libobj" "${libobj}T"
1269
1270    # Create a libtool object file (analogous to a ".la" file),
1271    # but don't create it if we're doing a dry run.
1272    test -z "$run" && cat > ${libobj}T <<EOF
1273# $libobj - a libtool object file
1274# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
1275#
1276# Please DO NOT delete this file!
1277# It is necessary for linking the library.
1278
1279# Name of the PIC object.
1280EOF
1281
1282    # Only build a PIC object if we are building libtool libraries.
1283    if test "$build_libtool_libs" = yes; then
1284      # Without this assignment, base_compile gets emptied.
1285      fbsd_hideous_sh_bug=$base_compile
1286
1287      if test "$pic_mode" != no; then
1288        command="$base_compile $qsrcfile $pic_flag"
1289      else
1290        # Don't build PIC code
1291        command="$base_compile $qsrcfile"
1292      fi
1293
1294      if test ! -d "${xdir}$objdir"; then
1295        $show "$mkdir ${xdir}$objdir"
1296        $run $mkdir ${xdir}$objdir
1297        exit_status=$?
1298        if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
1299          exit $exit_status
1300        fi
1301      fi
1302
1303      if test -z "$output_obj"; then
1304        # Place PIC objects in $objdir
1305        command="$command -o $lobj"
1306      fi
1307
1308      $run $rm "$lobj" "$output_obj"
1309
1310      $show "$command"
1311      if $run eval "$command"; then :
1312      else
1313        test -n "$output_obj" && $run $rm $removelist
1314        exit $EXIT_FAILURE
1315      fi
1316
1317      if test "$need_locks" = warn &&
1318         test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1319        $echo "\
1320*** ERROR, $lockfile contains:
1321`cat $lockfile 2>/dev/null`
1322
1323but it should contain:
1324$srcfile
1325
1326This indicates that another process is trying to use the same
1327temporary object file, and libtool could not work around it because
1328your compiler does not support \`-c' and \`-o' together.  If you
1329repeat this compilation, it may succeed, by chance, but you had better
1330avoid parallel builds (make -j) in this platform, or get a better
1331compiler."
1332
1333        $run $rm $removelist
1334        exit $EXIT_FAILURE
1335      fi
1336
1337      # Just move the object if needed, then go on to compile the next one
1338      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1339        $show "$mv $output_obj $lobj"
1340        if $run $mv $output_obj $lobj; then :
1341        else
1342          error=$?
1343          $run $rm $removelist
1344          exit $error
1345        fi
1346      fi
1347
1348      # Append the name of the PIC object to the libtool object file.
1349      test -z "$run" && cat >> ${libobj}T <<EOF
1350pic_object='$objdir/$objname'
1351
1352EOF
1353
1354      # Allow error messages only from the first compilation.
1355      if test "$suppress_opt" = yes; then
1356        suppress_output=' >/dev/null 2>&1'
1357      fi
1358    else
1359      # No PIC object so indicate it doesn't exist in the libtool
1360      # object file.
1361      test -z "$run" && cat >> ${libobj}T <<EOF
1362pic_object=none
1363
1364EOF
1365    fi
1366
1367    # Only build a position-dependent object if we build old libraries.
1368    if test "$build_old_libs" = yes; then
1369      if test "$pic_mode" != yes; then
1370        # Don't build PIC code
1371        command="$base_compile $qsrcfile"
1372      else
1373        command="$base_compile $qsrcfile $pic_flag"