/[pcre]/code/trunk/ltmain.sh
ViewVC logotype

Diff of /code/trunk/ltmain.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 74 by nigel, Sat Feb 24 21:40:03 2007 UTC revision 75 by nigel, Sat Feb 24 21:40:37 2007 UTC
# Line 1  Line 1 
1  # ltmain.sh - Provide generalized library-building support services.  # ltmain.sh - Provide generalized library-building support services.
2  # NOTE: Changing this file will not affect anything until you rerun configure.  # NOTE: Changing this file will not affect anything until you rerun configure.
3  #  #
4  # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001  # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
5  # Free Software Foundation, Inc.  # Free Software Foundation, Inc.
6  # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996  # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7  #  #
# Line 24  Line 24 
24  # configuration script generated by Autoconf, you may include it under  # configuration script generated by Autoconf, you may include it under
25  # the same distribution terms that you use for the rest of that program.  # the same distribution terms that you use for the rest of that program.
26    
27    basename="s,^.*/,,g"
28    
29    # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30    # is ksh but when the shell is invoked as "sh" and the current value of
31    # the _XPG environment variable is not equal to 1 (one), the special
32    # positional parameter $0, within a function call, is the name of the
33    # function.
34    progpath="$0"
35    
36    # Modification by PH (26-Aug-2004, originally 18-Feb-2003) to ensure that
37    # ${SED} is always set (it is not set on my system).
38    
39    case "X${SED}" in
40      X) SED=sed ;;
41    esac
42    
43    # The name of this program:
44    progname=`echo "$progpath" | $SED $basename`
45    modename="$progname"
46    
47    # Global variables:
48    EXIT_SUCCESS=0
49    EXIT_FAILURE=1
50    
51    PROGRAM=ltmain.sh
52    PACKAGE=libtool
53    VERSION=1.5.8
54    TIMESTAMP=" (1.1220.2.117 2004/08/04 14:12:05)"
55    
56    # See if we are running on zsh, and set the options which allow our
57    # commands through without removal of \ escapes.
58    if test -n "${ZSH_VERSION+set}" ; then
59      setopt NO_GLOB_SUBST
60    fi
61    
62  # Check that we have a working $echo.  # Check that we have a working $echo.
63  if test "X$1" = X--no-reexec; then  if test "X$1" = X--no-reexec; then
64    # Discard the --no-reexec flag, and continue.    # Discard the --no-reexec flag, and continue.
# Line 36  elif test "X`($echo '\t') 2>/dev/null`" Line 71  elif test "X`($echo '\t') 2>/dev/null`"
71    :    :
72  else  else
73    # Restart under the correct shell, and then maybe $echo will work.    # Restart under the correct shell, and then maybe $echo will work.
74    exec $SHELL "$0" --no-reexec ${1+"$@"}    exec $SHELL "$progpath" --no-reexec ${1+"$@"}
75  fi  fi
76    
77  if test "X$1" = X--fallback-echo; then  if test "X$1" = X--fallback-echo; then
# Line 45  if test "X$1" = X--fallback-echo; then Line 80  if test "X$1" = X--fallback-echo; then
80    cat <<EOF    cat <<EOF
81  $*  $*
82  EOF  EOF
83    exit 0    exit $EXIT_SUCCESS
84  fi  fi
85    
 # Modification by PH (18-Feb-2003) to ensure that ${SED} is always set  
 # (it is not set on my system).  
   
 case "X${SED}" in  
   X) SED=sed ;;  
 esac  
   
 # The name of this program.  
 progname=`$echo "$0" | ${SED} 's%^.*/%%'`  
 modename="$progname"  
   
 # Constants.  
 PROGRAM=ltmain.sh  
 PACKAGE=libtool  
 VERSION=1.4.3  
 TIMESTAMP=" (1.922.2.110 2002/10/23 01:39:54)"  
   
86  default_mode=  default_mode=
87  help="Try \`$progname --help' for more information."  help="Try \`$progname --help' for more information."
88  magic="%%%MAGIC variable%%%"  magic="%%%MAGIC variable%%%"
# Line 76  rm="rm -f" Line 94  rm="rm -f"
94  # metacharacters that are still active within double-quoted strings.  # metacharacters that are still active within double-quoted strings.
95  Xsed="${SED}"' -e 1s/^X//'  Xsed="${SED}"' -e 1s/^X//'
96  sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'  sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
97  # test EBCDIC or ASCII  # test EBCDIC or ASCII
98  case `echo A|od -x` in  case `echo A|tr A '\301'` in
99   *[Cc]1*) # EBCDIC based system   A) # EBCDIC based system
100    SP2NL="tr '\100' '\n'"    SP2NL="tr '\100' '\n'"
101    NL2SP="tr '\r\n' '\100\100'"    NL2SP="tr '\r\n' '\100\100'"
102    ;;    ;;
103   *) # Assume ASCII based system   *) # Assume ASCII based system
104    SP2NL="tr '\040' '\012'"    SP2NL="tr '\040' '\012'"
105    NL2SP="tr '\015\012' '\040\040'"    NL2SP="tr '\015\012' '\040\040'"
106    ;;    ;;
107  esac  esac
108    
109  # NLS nuisances.  # NLS nuisances.
110  # Only set LANG and LC_ALL to C if already set.  # Only set LANG and LC_ALL to C if already set.
# Line 101  if test "${LANG+set}" = set; then Line 119  if test "${LANG+set}" = set; then
119  fi  fi
120    
121  # Make sure IFS has a sensible default  # Make sure IFS has a sensible default
122  : ${IFS="       "}  : ${IFS="
123    "}
124    
125  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
126    echo "$modename: not configured to build any kind of library" 1>&2    $echo "$modename: not configured to build any kind of library" 1>&2
127    echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2    $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
128    exit 1    exit $EXIT_FAILURE
129  fi  fi
130    
131  # Global variables.  # Global variables.
# Line 121  execute_dlfiles= Line 140  execute_dlfiles=
140  lo2o="s/\\.lo\$/.${objext}/"  lo2o="s/\\.lo\$/.${objext}/"
141  o2lo="s/\\.${objext}\$/.lo/"  o2lo="s/\\.${objext}\$/.lo/"
142    
143    #####################################
144    # Shell function definitions:
145    # This seems to be the best place for them
146    
147    # func_win32_libid arg
148    # return the library type of file 'arg'
149    #
150    # Need a lot of goo to handle *both* DLLs and import libs
151    # Has to be a shell function in order to 'eat' the argument
152    # that is supplied when $file_magic_command is called.
153    func_win32_libid () {
154      win32_libid_type="unknown"
155      win32_fileres=`file -L $1 2>/dev/null`
156      case $win32_fileres in
157      *ar\ archive\ import\ library*) # definitely import
158        win32_libid_type="x86 archive import"
159        ;;
160      *ar\ archive*) # could be an import, or static
161        if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
162          $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
163          win32_nmres=`eval $NM -f posix -A $1 | \
164            sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
165          if test "X$win32_nmres" = "Ximport" ; then
166            win32_libid_type="x86 archive import"
167          else
168            win32_libid_type="x86 archive static"
169          fi
170        fi
171        ;;
172      *DLL*)
173        win32_libid_type="x86 DLL"
174        ;;
175      *executable*) # but shell scripts are "executable" too...
176        case $win32_fileres in
177        *MS\ Windows\ PE\ Intel*)
178          win32_libid_type="x86 DLL"
179          ;;
180        esac
181        ;;
182      esac
183      $echo $win32_libid_type
184    }
185    
186    
187    # func_infer_tag arg
188    # Infer tagged configuration to use if any are available and
189    # if one wasn't chosen via the "--tag" command line option.
190    # Only attempt this if the compiler in the base compile
191    # command doesn't match the default compiler.
192    # arg is usually of the form 'gcc ...'
193    func_infer_tag () {
194        if test -n "$available_tags" && test -z "$tagname"; then
195          CC_quoted=
196          for arg in $CC; do
197            case $arg in
198              *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
199              arg="\"$arg\""
200              ;;
201            esac
202            CC_quoted="$CC_quoted $arg"
203          done
204          case $@ in
205          # Blanks in the command may have been stripped by the calling shell,
206          # but not from the CC environment variable when configure was run.
207          " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
208          # Blanks at the start of $base_compile will cause this to fail
209          # if we don't check for them as well.
210          *)
211            for z in $available_tags; do
212              if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
213                # Evaluate the configuration.
214                eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
215                CC_quoted=
216                for arg in $CC; do
217                # Double-quote args containing other shell metacharacters.
218                case $arg in
219                  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
220                  arg="\"$arg\""
221                  ;;
222                esac
223                CC_quoted="$CC_quoted $arg"
224              done
225                case "$@ " in
226                  " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
227                  # The compiler in the base compile command matches
228                  # the one in the tagged configuration.
229                  # Assume this is the tagged configuration we want.
230                  tagname=$z
231                  break
232                  ;;
233                esac
234              fi
235            done
236            # If $tagname still isn't set, then no tagged configuration
237            # was found and let the user know that the "--tag" command
238            # line option must be used.
239            if test -z "$tagname"; then
240              $echo "$modename: unable to infer tagged configuration"
241              $echo "$modename: specify a tag with \`--tag'" 1>&2
242              exit $EXIT_FAILURE
243    #        else
244    #          $echo "$modename: using $tagname tagged configuration"
245            fi
246            ;;
247          esac
248        fi
249    }
250    
251    
252    # func_extract_archives gentop oldlib ...
253    func_extract_archives () {
254        my_gentop="$1"; shift
255        my_oldlibs=${1+"$@"}
256        my_oldobjs=""
257        my_xlib=""
258        my_xabs=""
259        my_xdir=""
260        my_status=""
261    
262        $show "${rm}r $my_gentop"
263        $run ${rm}r "$my_gentop"
264        $show "$mkdir $my_gentop"
265        $run $mkdir "$my_gentop"
266        my_status=$?
267        if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
268          exit $my_status
269        fi
270    
271        for my_xlib in $my_oldlibs; do
272          # Extract the objects.
273          case $my_xlib in
274            [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
275            *) my_xabs=`pwd`"/$my_xlib" ;;
276          esac
277          my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
278          my_xdir="$my_gentop/$my_xlib"
279    
280          $show "${rm}r $my_xdir"
281          $run ${rm}r "$my_xdir"
282          $show "$mkdir $my_xdir"
283          $run $mkdir "$my_xdir"
284          status=$?
285          if test "$status" -ne 0 && test ! -d "$my_xdir"; then
286            exit $status
287          fi
288          case $host in
289          *-darwin*)
290            $show "Extracting $my_xabs"
291            # Do not bother doing anything if just a dry run
292            if test -z "$run"; then
293              darwin_orig_dir=`pwd`
294              cd $my_xdir || exit $?
295              darwin_archive=$my_xabs
296              darwin_curdir=`pwd`
297              darwin_base_archive=`basename $darwin_archive`
298              darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
299              if test -n "$darwin_arches"; then
300                darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
301                darwin_arch=
302                $show "$darwin_base_archive has multiple architectures $darwin_arches"
303                for darwin_arch in  $darwin_arches ; do
304                  mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
305                  lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
306                  # Remove the table of contents from the thin files.
307                  $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF 2>/dev/null || true
308                  $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF\ SORTED 2>/dev/null || true
309                  cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
310                  $AR -xo "${darwin_base_archive}"
311                  rm "${darwin_base_archive}"
312                  cd "$darwin_curdir"
313                done # $darwin_arches
314          ## Okay now we have a bunch of thin objects, gotta fatten them up :)
315                darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP`
316                darwin_file=
317                darwin_files=
318                for darwin_file in $darwin_filelist; do
319                  darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
320                  lipo -create -output "$darwin_file" $darwin_files
321                done # $darwin_filelist
322                rm -rf unfat-$$
323                cd "$darwin_orig_dir"
324              else
325                cd $darwin_orig_dir
326                (cd $my_xdir && $AR x $my_xabs) || exit $?
327              fi # $darwin_arches
328            fi # $run
329          ;;
330          *)
331            # We will extract separately just the conflicting names and we will
332            # no longer touch any unique names. It is faster to leave these
333            # extract automatically by $AR in one run.
334            $show "(cd $my_xdir && $AR x $my_xabs)"
335            $run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $?
336            if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then
337              :
338            else
339              $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
340              $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
341              $AR t "$my_xabs" | sort | uniq -cd | while read -r count name
342              do
343                i=1
344                while test "$i" -le "$count"
345                do
346                  # Put our $i before any first dot (extension)
347                  # Never overwrite any file
348                  name_to="$name"
349                  while test "X$name_to" = "X$name" || test -f "$my_xdir/$name_to"
350                  do
351                    name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
352                  done
353                  $show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' '$name_to')"
354                  $run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv '$name' '$name_to')" || exit $?
355                  i=`expr $i + 1`
356                done
357              done
358            fi
359            ;;
360          esac
361          my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
362        done
363    
364        func_extract_archives_result="$my_oldobjs"
365    }
366    # End of Shell function definitions
367    #####################################
368    
369    # Darwin sucks
370    eval std_shrext=\"$shrext_cmds\"
371    
372  # Parse our command line options once, thoroughly.  # Parse our command line options once, thoroughly.
373  while test $# -gt 0  while test "$#" -gt 0
374  do  do
375    arg="$1"    arg="$1"
376    shift    shift
# Line 138  do Line 386  do
386      execute_dlfiles)      execute_dlfiles)
387        execute_dlfiles="$execute_dlfiles $arg"        execute_dlfiles="$execute_dlfiles $arg"
388        ;;        ;;
389        tag)
390          tagname="$arg"
391          preserve_args="${preserve_args}=$arg"
392    
393          # Check whether tagname contains only valid characters
394          case $tagname in
395          *[!-_A-Za-z0-9,/]*)
396            $echo "$progname: invalid tag name: $tagname" 1>&2
397            exit $EXIT_FAILURE
398            ;;
399          esac
400    
401          case $tagname in
402          CC)
403            # Don't test for the "default" C tag, as we know, it's there, but
404            # not specially marked.
405            ;;
406          *)
407            if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
408              taglist="$taglist $tagname"
409              # Evaluate the configuration.
410              eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
411            else
412              $echo "$progname: ignoring unknown tag $tagname" 1>&2
413            fi
414            ;;
415          esac
416          ;;
417      *)      *)
418        eval "$prev=\$arg"        eval "$prev=\$arg"
419        ;;        ;;
# Line 155  do Line 431  do
431      ;;      ;;
432    
433    --version)    --version)
434      echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"      $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
435      exit 0      $echo
436        $echo "Copyright (C) 2003  Free Software Foundation, Inc."
437        $echo "This is free software; see the source for copying conditions.  There is NO"
438        $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
439        exit $EXIT_SUCCESS
440      ;;      ;;
441    
442    --config)    --config)
443      ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0      ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
444      exit 0      # Now print the configurations for the tags.
445        for tagname in $taglist; do
446          ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
447        done
448        exit $EXIT_SUCCESS
449      ;;      ;;
450    
451    --debug)    --debug)
452      echo "$progname: enabling shell trace mode"      $echo "$progname: enabling shell trace mode"
453      set -x      set -x
454        preserve_args="$preserve_args $arg"
455      ;;      ;;
456    
457    --dry-run | -n)    --dry-run | -n)
# Line 174  do Line 459  do
459      ;;      ;;
460    
461    --features)    --features)
462      echo "host: $host"      $echo "host: $host"
463      if test "$build_libtool_libs" = yes; then      if test "$build_libtool_libs" = yes; then
464        echo "enable shared libraries"        $echo "enable shared libraries"
465      else      else
466        echo "disable shared libraries"        $echo "disable shared libraries"
467      fi      fi
468      if test "$build_old_libs" = yes; then      if test "$build_old_libs" = yes; then
469        echo "enable static libraries"        $echo "enable static libraries"
470      else      else
471        echo "disable static libraries"        $echo "disable static libraries"
472      fi      fi
473      exit 0      exit $EXIT_SUCCESS
474      ;;      ;;
475    
476    --finish) mode="finish" ;;    --finish) mode="finish" ;;
# Line 197  do Line 482  do
482    
483    --quiet | --silent)    --quiet | --silent)
484      show=:      show=:
485        preserve_args="$preserve_args $arg"
486        ;;
487    
488      --tag) prevopt="--tag" prev=tag ;;
489      --tag=*)
490        set tag "$optarg" ${1+"$@"}
491        shift
492        prev=tag
493        preserve_args="$preserve_args --tag"
494      ;;      ;;
495    
496    -dlopen)    -dlopen)
# Line 207  do Line 501  do
501    -*)    -*)
502      $echo "$modename: unrecognized option \`$arg'" 1>&2      $echo "$modename: unrecognized option \`$arg'" 1>&2
503      $echo "$help" 1>&2      $echo "$help" 1>&2
504      exit 1      exit $EXIT_FAILURE
505      ;;      ;;
506    
507    *)    *)
# Line 220  done Line 514  done
514  if test -n "$prevopt"; then  if test -n "$prevopt"; then
515    $echo "$modename: option \`$prevopt' requires an argument" 1>&2    $echo "$modename: option \`$prevopt' requires an argument" 1>&2
516    $echo "$help" 1>&2    $echo "$help" 1>&2
517    exit 1    exit $EXIT_FAILURE
518  fi  fi
519    
520  # If this variable is set in any of the actions, the command in it  # If this variable is set in any of the actions, the command in it
# Line 232  if test -z "$show_help"; then Line 526  if test -z "$show_help"; then
526    
527    # Infer the operation mode.    # Infer the operation mode.
528    if test -z "$mode"; then    if test -z "$mode"; then
529        $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
530        $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
531      case $nonopt in      case $nonopt in
532      *cc | *++ | gcc* | *-gcc* | xlc*)      *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
533        mode=link        mode=link
534        for arg        for arg
535        do        do
# Line 274  if test -z "$show_help"; then Line 570  if test -z "$show_help"; then
570    if test -n "$execute_dlfiles" && test "$mode" != execute; then    if test -n "$execute_dlfiles" && test "$mode" != execute; then
571      $echo "$modename: unrecognized option \`-dlopen'" 1>&2      $echo "$modename: unrecognized option \`-dlopen'" 1>&2
572      $echo "$help" 1>&2      $echo "$help" 1>&2
573      exit 1      exit $EXIT_FAILURE
574    fi    fi
575    
576    # Change the help message to a mode-specific one.    # Change the help message to a mode-specific one.
# Line 288  if test -z "$show_help"; then Line 584  if test -z "$show_help"; then
584      modename="$modename: compile"      modename="$modename: compile"
585      # Get the compilation command and the source file.      # Get the compilation command and the source file.
586      base_compile=      base_compile=
587      prev=      srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
588      lastarg=      suppress_opt=yes
     srcfile="$nonopt"  
589      suppress_output=      suppress_output=
590        arg_mode=normal
591        libobj=
592        later=
593    
     user_target=no  
594      for arg      for arg
595      do      do
596        case $prev in        case "$arg_mode" in
597        "") ;;        arg  )
598        xcompiler)          # do not "continue".  Instead, add this to base_compile
599          # Aesthetically quote the previous argument.          lastarg="$arg"
600          prev=          arg_mode=normal
         lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`  
   
         case $arg in  
         # Double-quote args containing other shell metacharacters.  
         # Many Bourne shells cannot handle close brackets correctly  
         # in scan sets, so we specify it separately.  
         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")  
           arg="\"$arg\""  
           ;;  
         esac  
   
         # Add the previous argument to base_compile.  
         if test -z "$base_compile"; then  
           base_compile="$lastarg"  
         else  
           base_compile="$base_compile $lastarg"  
         fi  
         continue  
601          ;;          ;;
       esac  
602    
603        # Accept any command-line options.        target )
604        case $arg in          libobj="$arg"
605        -o)          arg_mode=normal
         if test "$user_target" != "no"; then  
           $echo "$modename: you cannot specify \`-o' more than once" 1>&2  
           exit 1  
         fi  
         user_target=next  
         ;;  
   
       -static)  
         build_old_libs=yes  
606          continue          continue
607          ;;          ;;
608    
609        -prefer-pic)        normal )
610          pic_mode=yes          # Accept any command-line options.
611          continue          case $arg in
612          ;;          -o)
613              if test -n "$libobj" ; then
614                $echo "$modename: you cannot specify \`-o' more than once" 1>&2
615                exit $EXIT_FAILURE
616              fi
617              arg_mode=target
618              continue
619              ;;
620    
621        -prefer-non-pic)          -static | -prefer-pic | -prefer-non-pic)
622          pic_mode=no            later="$later $arg"
623          continue            continue
624          ;;            ;;
625    
626        -Xcompiler)          -no-suppress)
627          prev=xcompiler            suppress_opt=no
628          continue            continue
629          ;;            ;;
630    
631        -Wc,*)          -Xcompiler)
632          args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`            arg_mode=arg  #  the next one goes into the "base_compile" arg list
633          lastarg=            continue      #  The current "srcfile" will either be retained or
634          save_ifs="$IFS"; IFS=','            ;;            #  replaced later.  I would guess that would be a bug.
635          for arg in $args; do  
636            IFS="$save_ifs"          -Wc,*)
637              args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
638              lastarg=
639              save_ifs="$IFS"; IFS=','
640              for arg in $args; do
641                IFS="$save_ifs"
642    
643            # Double-quote args containing other shell metacharacters.              # Double-quote args containing other shell metacharacters.
644            # Many Bourne shells cannot handle close brackets correctly              # Many Bourne shells cannot handle close brackets correctly
645            # in scan sets, so we specify it separately.              # in scan sets, so we specify it separately.
646            case $arg in              case $arg in
647              *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")                *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
648              arg="\"$arg\""                arg="\"$arg\""
649              ;;                ;;
650            esac              esac
651            lastarg="$lastarg $arg"              lastarg="$lastarg $arg"
652          done            done
653          IFS="$save_ifs"            IFS="$save_ifs"
654          lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`            lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
655    
656          # Add the arguments to base_compile.            # Add the arguments to base_compile.
         if test -z "$base_compile"; then  
           base_compile="$lastarg"  
         else  
657            base_compile="$base_compile $lastarg"            base_compile="$base_compile $lastarg"
658          fi            continue
659          continue            ;;
         ;;  
       esac  
660    
661        case $user_target in          * )
662        next)            # Accept the current argument as the source file.
663          # The next one is the -o target name            # The previous "srcfile" becomes the current argument.
664          user_target=yes            #
665          continue            lastarg="$srcfile"
666          ;;            srcfile="$arg"
667        yes)            ;;
668          # We got the output file          esac  #  case $arg
         user_target=set  
         libobj="$arg"  
         continue  
669          ;;          ;;
670        esac        esac    #  case $arg_mode
   
       # Accept the current argument as the source file.  
       lastarg="$srcfile"  
       srcfile="$arg"  
671    
672        # Aesthetically quote the previous argument.        # Aesthetically quote the previous argument.
   
       # Backslashify any backslashes, double quotes, and dollar signs.  
       # These are the only characters that are still specially  
       # interpreted inside of double-quoted scrings.  
673        lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`        lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
674    
675          case $lastarg in
676        # Double-quote args containing other shell metacharacters.        # Double-quote args containing other shell metacharacters.
677        # Many Bourne shells cannot handle close brackets correctly        # Many Bourne shells cannot handle close brackets correctly
678        # in scan sets, so we specify it separately.        # in scan sets, so we specify it separately.
       case $lastarg in  
679        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
680          lastarg="\"$lastarg\""          lastarg="\"$lastarg\""
681          ;;          ;;
682        esac        esac
683    
684        # Add the previous argument to base_compile.        base_compile="$base_compile $lastarg"
685        if test -z "$base_compile"; then      done # for arg
         base_compile="$lastarg"  
       else  
         base_compile="$base_compile $lastarg"  
       fi  
     done  
686    
687      case $user_target in      case $arg_mode in
688      set)      arg)
689          $echo "$modename: you must specify an argument for -Xcompile"
690          exit $EXIT_FAILURE
691        ;;        ;;
692      no)      target)
693        # Get the name of the library object.        $echo "$modename: you must specify a target with \`-o'" 1>&2
694        libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`        exit $EXIT_FAILURE
695        ;;        ;;
696      *)      *)
697        $echo "$modename: you must specify a target with \`-o'" 1>&2        # Get the name of the library object.
698        exit 1        [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
699        ;;        ;;
700      esac      esac
701    
702      # Recognize several different file suffixes.      # Recognize several different file suffixes.
703      # If the user specifies -o file.o, it is replaced with file.lo      # If the user specifies -o file.o, it is replaced with file.lo
704      xform='[cCFSfmso]'      xform='[cCFSifmso]'
705      case $libobj in      case $libobj in
706      *.ada) xform=ada ;;      *.ada) xform=ada ;;
707      *.adb) xform=adb ;;      *.adb) xform=adb ;;
# Line 447  if test -z "$show_help"; then Line 709  if test -z "$show_help"; then
709      *.asm) xform=asm ;;      *.asm) xform=asm ;;
710      *.c++) xform=c++ ;;      *.c++) xform=c++ ;;
711      *.cc) xform=cc ;;      *.cc) xform=cc ;;
712        *.ii) xform=ii ;;
713        *.class) xform=class ;;
714      *.cpp) xform=cpp ;;      *.cpp) xform=cpp ;;
715      *.cxx) xform=cxx ;;      *.cxx) xform=cxx ;;
716      *.f90) xform=f90 ;;      *.f90) xform=f90 ;;
717      *.for) xform=for ;;      *.for) xform=for ;;
718        *.java) xform=java ;;
719      esac      esac
720    
721      libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`      libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
# Line 459  if test -z "$show_help"; then Line 724  if test -z "$show_help"; then
724      *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;      *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
725      *)      *)
726        $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2        $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
727        exit 1        exit $EXIT_FAILURE
728        ;;        ;;
729      esac      esac
730    
731        func_infer_tag $base_compile
732    
733        for arg in $later; do
734          case $arg in
735          -static)
736            build_old_libs=yes
737            continue
738            ;;
739    
740          -prefer-pic)
741            pic_mode=yes
742            continue
743            ;;
744    
745          -prefer-non-pic)
746            pic_mode=no
747            continue
748            ;;
749          esac
750        done
751    
752        objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
753        xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
754        if test "X$xdir" = "X$obj"; then
755          xdir=
756        else
757          xdir=$xdir/
758        fi
759        lobj=${xdir}$objdir/$objname
760    
761      if test -z "$base_compile"; then      if test -z "$base_compile"; then
762        $echo "$modename: you must specify a compilation command" 1>&2        $echo "$modename: you must specify a compilation command" 1>&2
763        $echo "$help" 1>&2        $echo "$help" 1>&2
764        exit 1        exit $EXIT_FAILURE
765      fi      fi
766    
767      # Delete any leftover library objects.      # Delete any leftover library objects.
768      if test "$build_old_libs" = yes; then      if test "$build_old_libs" = yes; then
769        removelist="$obj $libobj"        removelist="$obj $lobj $libobj ${libobj}T"
770      else      else
771        removelist="$libobj"        removelist="$lobj $libobj ${libobj}T"
772      fi      fi
773    
774      $run $rm $removelist      $run $rm $removelist
775      trap "$run $rm $removelist; exit 1" 1 2 15      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
776    
777      # On Cygwin there's no "real" PIC flag so we must build both object types      # On Cygwin there's no "real" PIC flag so we must build both object types
778      case $host_os in      case $host_os in
# Line 496  if test -z "$show_help"; then Line 791  if test -z "$show_help"; then
791        output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}        output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
792        lockfile="$output_obj.lock"        lockfile="$output_obj.lock"
793        removelist="$removelist $output_obj $lockfile"        removelist="$removelist $output_obj $lockfile"
794        trap "$run $rm $removelist; exit 1" 1 2 15        trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
795      else      else
796          output_obj=
797        need_locks=no        need_locks=no
798        lockfile=        lockfile=
799      fi      fi
# Line 505  if test -z "$show_help"; then Line 801  if test -z "$show_help"; then
801      # Lock this critical section if it is needed      # Lock this critical section if it is needed
802      # We use this script file to make the link, it avoids creating a new file      # We use this script file to make the link, it avoids creating a new file
803      if test "$need_locks" = yes; then      if test "$need_locks" = yes; then
804        until $run ln "$0" "$lockfile" 2>/dev/null; do        until $run ln "$progpath" "$lockfile" 2>/dev/null; do
805          $show "Waiting for $lockfile to be removed"          $show "Waiting for $lockfile to be removed"
806          sleep 2          sleep 2
807        done        done
808      elif test "$need_locks" = warn; then      elif test "$need_locks" = warn; then
809        if test -f "$lockfile"; then        if test -f "$lockfile"; then
810          echo "\          $echo "\
811  *** ERROR, $lockfile exists and contains:  *** ERROR, $lockfile exists and contains:
812  `cat $lockfile 2>/dev/null`  `cat $lockfile 2>/dev/null`
813    
# Line 523  avoid parallel builds (make -j) in this Line 819  avoid parallel builds (make -j) in this
819  compiler."  compiler."
820    
821          $run $rm $removelist          $run $rm $removelist
822          exit 1          exit $EXIT_FAILURE
823        fi        fi
824        echo $srcfile > "$lockfile"        $echo $srcfile > "$lockfile"
825      fi      fi
826    
827      if test -n "$fix_srcfile_path"; then      if test -n "$fix_srcfile_path"; then
828        eval srcfile=\"$fix_srcfile_path\"        eval srcfile=\"$fix_srcfile_path\"
829      fi      fi
830    
831        $run $rm "$libobj" "${libobj}T"
832    
833        # Create a libtool object file (analogous to a ".la" file),
834        # but don't create it if we're doing a dry run.
835        test -z "$run" && cat > ${libobj}T <<EOF
836    # $libobj - a libtool object file
837    # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
838    #
839    # Please DO NOT delete this file!
840    # It is necessary for linking the library.
841    
842    # Name of the PIC object.
843    EOF
844    
845      # Only build a PIC object if we are building libtool libraries.      # Only build a PIC object if we are building libtool libraries.
846      if test "$build_libtool_libs" = yes; then      if test "$build_libtool_libs" = yes; then
847        # Without this assignment, base_compile gets emptied.        # Without this assignment, base_compile gets emptied.
848        fbsd_hideous_sh_bug=$base_compile        fbsd_hideous_sh_bug=$base_compile
849    
850        if test "$pic_mode" != no; then        if test "$pic_mode" != no; then
851          # All platforms use -DPIC, to notify preprocessed assembler code.          command="$base_compile $srcfile $pic_flag"
         command="$base_compile $srcfile $pic_flag -DPIC"  
852        else        else
853          # Don't build PIC code          # Don't build PIC code
854          command="$base_compile $srcfile"          command="$base_compile $srcfile"
855        fi        fi
       if test "$build_old_libs" = yes; then  
         lo_libobj="$libobj"  
         dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`  
         if test "X$dir" = "X$libobj"; then  
           dir="$objdir"  
         else  
           dir="$dir/$objdir"  
         fi  
         libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`  
856    
857          if test -d "$dir"; then        if test ! -d "${xdir}$objdir"; then
858            $show "$rm $libobj"          $show "$mkdir ${xdir}$objdir"
859            $run $rm $libobj          $run $mkdir ${xdir}$objdir
860          else          status=$?
861            $show "$mkdir $dir"          if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
862            $run $mkdir $dir            exit $status
           status=$?  
           if test $status -ne 0 && test ! -d $dir; then  
             exit $status  
           fi  
863          fi          fi
864        fi        fi
865        if test "$compiler_o_lo" = yes; then  
866          output_obj="$libobj"        if test -z "$output_obj"; then
867          command="$command -o $output_obj"          # Place PIC objects in $objdir
868        elif test "$compiler_c_o" = yes; then          command="$command -o $lobj"
         output_obj="$obj"  
         command="$command -o $output_obj"  
869        fi        fi
870    
871        $run $rm "$output_obj"        $run $rm "$lobj" "$output_obj"
872    
873        $show "$command"        $show "$command"
874        if $run eval "$command"; then :        if $run eval "$command"; then :
875        else        else
876          test -n "$output_obj" && $run $rm $removelist          test -n "$output_obj" && $run $rm $removelist
877          exit 1          exit $EXIT_FAILURE
878        fi        fi
879    
880        if test "$need_locks" = warn &&        if test "$need_locks" = warn &&
881           test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then           test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
882          echo "\          $echo "\
883  *** ERROR, $lockfile contains:  *** ERROR, $lockfile contains:
884  `cat $lockfile 2>/dev/null`  `cat $lockfile 2>/dev/null`
885    
# Line 599  avoid parallel builds (make -j) in this Line 894  avoid parallel builds (make -j) in this
894  compiler."  compiler."
895    
896          $run $rm $removelist          $run $rm $removelist
897          exit 1          exit $EXIT_FAILURE
898        fi        fi
899    
900        # Just move the object if needed, then go on to compile the next one        # Just move the object if needed, then go on to compile the next one
901        if test x"$output_obj" != x"$libobj"; then        if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
902          $show "$mv $output_obj $libobj"          $show "$mv $output_obj $lobj"
903          if $run $mv $output_obj $libobj; then :          if $run $mv $output_obj $lobj; then :
904          else          else
905            error=$?            error=$?
906            $run $rm $removelist            $run $rm $removelist
# Line 613  compiler." Line 908  compiler."
908          fi          fi
909        fi        fi
910    
911        # If we have no pic_flag, then copy the object into place and finish.        # Append the name of the PIC object to the libtool object file.
912        if (test -z "$pic_flag" || test "$pic_mode" != default) &&        test -z "$run" && cat >> ${libobj}T <<EOF
913           test "$build_old_libs" = yes; then  pic_object='$objdir/$objname'
         # Rename the .lo from within objdir to obj  
         if test -f $obj; then  
           $show $rm $obj  
           $run $rm $obj  
         fi  
914    
915          $show "$mv $libobj $obj"  EOF
         if $run $mv $libobj $obj; then :  
         else  
           error=$?  
           $run $rm $removelist  
           exit $error  
         fi  
916    
917          xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`        # Allow error messages only from the first compilation.
918          if test "X$xdir" = "X$obj"; then        if test "$suppress_opt" = yes; then
919            xdir="."          suppress_output=' >/dev/null 2>&1'
         else  
           xdir="$xdir"  
         fi  
         baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"`  
         libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`  
         # Now arrange that obj and lo_libobj become the same file  
         $show "(cd $xdir && $LN_S $baseobj $libobj)"  
         if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then  
           # Unlock the critical section if it was locked  
           if test "$need_locks" != no; then  
             $run $rm "$lockfile"  
           fi  
           exit 0  
         else  
           error=$?  
           $run $rm $removelist  
           exit $error  
         fi  
920        fi        fi
921        else
922          # No PIC object so indicate it doesn't exist in the libtool
923          # object file.
924          test -z "$run" && cat >> ${libobj}T <<EOF
925    pic_object=none
926    
927        # Allow error messages only from the first compilation.  EOF
       suppress_output=' >/dev/null 2>&1'  
928      fi      fi
929    
930      # Only build a position-dependent object if we build old libraries.      # Only build a position-dependent object if we build old libraries.
# Line 663  compiler." Line 933  compiler."
933          # Don't build PIC code          # Don't build PIC code
934          command="$base_compile $srcfile"          command="$base_compile $srcfile"
935        else        else
936          # All platforms use -DPIC, to notify preprocessed assembler code.          command="$base_compile $srcfile $pic_flag"
         command="$base_compile $srcfile $pic_flag -DPIC"  
937        fi        fi
938        if test "$compiler_c_o" = yes; then        if test "$compiler_c_o" = yes; then
939          command="$command -o $obj"          command="$command -o $obj"
         output_obj="$obj"  
940        fi        fi
941    
942        # Suppress compiler output if we already did a PIC compilation.        # Suppress compiler output if we already did a PIC compilation.
943        command="$command$suppress_output"        command="$command$suppress_output"
944        $run $rm "$output_obj"        $run $rm "$obj" "$output_obj"
945        $show "$command"        $show "$command"
946        if $run eval "$command"; then :        if $run eval "$command"; then :
947        else        else
948          $run $rm $removelist          $run $rm $removelist
949          exit 1          exit $EXIT_FAILURE
950        fi        fi
951    
952        if test "$need_locks" = warn &&        if test "$need_locks" = warn &&
953           test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then           test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
954          echo "\          $echo "\
955  *** ERROR, $lockfile contains:  *** ERROR, $lockfile contains:
956  `cat $lockfile 2>/dev/null`  `cat $lockfile 2>/dev/null`
957    
# Line 698  avoid parallel builds (make -j) in this Line 966  avoid parallel builds (make -j) in this
966  compiler."  compiler."
967    
968          $run $rm $removelist          $run $rm $removelist
969          exit 1          exit $EXIT_FAILURE
970        fi        fi
971    
972        # Just move the object if needed        # Just move the object if needed
973        if test x"$output_obj" != x"$obj"; then        if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
974          $show "$mv $output_obj $obj"          $show "$mv $output_obj $obj"
975          if $run $mv $output_obj $obj; then :          if $run $mv $output_obj $obj; then :
976          else          else
# Line 712  compiler." Line 980  compiler."
980          fi          fi
981        fi        fi
982    
983        # Create an invalid libtool object if no PIC, so that we do not        # Append the name of the non-PIC object the libtool object file.
984        # accidentally link it into a program.        # Only append if the libtool object file exists.
985        if test "$build_libtool_libs" != yes; then        test -z "$run" && cat >> ${libobj}T <<EOF
986          $show "echo timestamp > $libobj"  # Name of the non-PIC object.
987          $run eval "echo timestamp > \$libobj" || exit $?  non_pic_object='$objname'
988        else  
989          # Move the .lo from within objdir  EOF
990          $show "$mv $libobj $lo_libobj"      else
991          if $run $mv $libobj $lo_libobj; then :        # Append the name of the non-PIC object the libtool object file.
992          else        # Only append if the libtool object file exists.
993            error=$?        test -z "$run" && cat >> ${libobj}T <<EOF
994            $run $rm $removelist  # Name of the non-PIC object.
995            exit $error  non_pic_object=none
996          fi  
997        fi  EOF
998      fi      fi
999    
1000        $run $mv "${libobj}T" "${libobj}"
1001    
1002      # Unlock the critical section if it was locked      # Unlock the critical section if it was locked
1003      if test "$need_locks" != no; then      if test "$need_locks" != no; then
1004        $run $rm "$lockfile"        $run $rm "$lockfile"
1005      fi      fi
1006    
1007      exit 0      exit $EXIT_SUCCESS
1008      ;;      ;;
1009    
1010    # libtool link mode    # libtool link mode
# Line 745  compiler." Line 1015  compiler."
1015        # It is impossible to link a dll without this setting, and        # It is impossible to link a dll without this setting, and
1016        # we shouldn't force the makefile maintainer to figure out        # we shouldn't force the makefile maintainer to figure out
1017        # which system we are compiling for in order to pass an extra        # which system we are compiling for in order to pass an extra
1018        # flag for every libtool invokation.        # flag for every libtool invocation.
1019        # allow_undefined=no        # allow_undefined=no
1020    
1021        # FIXME: Unfortunately, there are problems with the above when trying        # FIXME: Unfortunately, there are problems with the above when trying
# Line 760  compiler." Line 1030  compiler."
1030        ;;        ;;
1031      esac      esac
1032      libtool_args="$nonopt"      libtool_args="$nonopt"
1033        base_compile="$nonopt $@"
1034      compile_command="$nonopt"      compile_command="$nonopt"
1035      finalize_command="$nonopt"      finalize_command="$nonopt"
1036    
# Line 775  compiler." Line 1046  compiler."
1046      linker_flags=      linker_flags=
1047      dllsearchpath=      dllsearchpath=
1048      lib_search_path=`pwd`      lib_search_path=`pwd`
1049        inst_prefix_dir=
1050    
1051      avoid_version=no      avoid_version=no
1052      dlfiles=      dlfiles=
# Line 789  compiler." Line 1061  compiler."
1061      module=no      module=no
1062      no_install=no      no_install=no
1063      objs=      objs=
1064        non_pic_objects=
1065        precious_files_regex=
1066      prefer_static_libs=no      prefer_static_libs=no
1067      preload=no      preload=no
1068      prev=      prev=
# Line 800  compiler." Line 1074  compiler."
1074      temp_rpath=      temp_rpath=
1075      thread_safe=no      thread_safe=no
1076      vinfo=      vinfo=
1077        vinfo_number=no
1078    
1079        func_infer_tag $base_compile
1080    
1081      # We need to know -static, to get the right output filenames.      # We need to know -static, to get the right output filenames.
1082      for arg      for arg
# Line 830  compiler." Line 1107  compiler."
1107      test -n "$old_archive_from_new_cmds" && build_old_libs=yes      test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1108    
1109      # Go through the arguments, transforming them on the way.      # Go through the arguments, transforming them on the way.
1110      while test $# -gt 0; do      while test "$#" -gt 0; do
1111        arg="$1"        arg="$1"
1112        shift        shift
1113        case $arg in        case $arg in
# Line 895  compiler." Line 1172  compiler."
1172            export_symbols="$arg"            export_symbols="$arg"
1173            if test ! -f "$arg"; then            if test ! -f "$arg"; then
1174              $echo "$modename: symbol file \`$arg' does not exist"              $echo "$modename: symbol file \`$arg' does not exist"
1175              exit 1              exit $EXIT_FAILURE
1176            fi            fi
1177            prev=            prev=
1178            continue            continue
# Line 905  compiler." Line 1182  compiler."
1182            prev=            prev=
1183            continue            continue
1184            ;;            ;;
1185          release)          inst_prefix)
1186            release="-$arg"            inst_prefix_dir="$arg"
1187              prev=
1188              continue
1189              ;;
1190            precious_regex)
1191              precious_files_regex="$arg"
1192              prev=
1193              continue
1194              ;;
1195            release)
1196              release="-$arg"
1197              prev=
1198              continue
1199              ;;
1200            objectlist)
1201              if test -f "$arg"; then
1202                save_arg=$arg
1203                moreargs=
1204                for fil in `cat $save_arg`
1205                do
1206    #             moreargs="$moreargs $fil"
1207                  arg=$fil
1208                  # A libtool-controlled object.
1209    
1210                  # Check to see that this really is a libtool object.
1211                  if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1212                    pic_object=
1213                    non_pic_object=
1214    
1215                    # Read the .lo file
1216                    # If there is no directory component, then add one.
1217                    case $arg in
1218                    */* | *\\*) . $arg ;;
1219                    *) . ./$arg ;;
1220                    esac
1221    
1222                    if test -z "$pic_object" || \
1223                       test -z "$non_pic_object" ||
1224                       test "$pic_object" = none && \
1225                       test "$non_pic_object" = none; then
1226                      $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1227                      exit $EXIT_FAILURE
1228                    fi
1229    
1230                    # Extract subdirectory from the argument.
1231                    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1232                    if test "X$xdir" = "X$arg"; then
1233                      xdir=
1234                    else
1235                      xdir="$xdir/"
1236                    fi
1237    
1238                    if test "$pic_object" != none; then
1239                      # Prepend the subdirectory the object is found in.
1240                      pic_object="$xdir$pic_object"
1241    
1242                      if test "$prev" = dlfiles; then
1243                        if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1244                          dlfiles="$dlfiles $pic_object"
1245                          prev=
1246                          continue
1247                        else
1248                          # If libtool objects are unsupported, then we need to preload.
1249                          prev=dlprefiles
1250                        fi
1251                      fi
1252    
1253                      # CHECK ME:  I think I busted this.  -Ossama
1254                      if test "$prev" = dlprefiles; then
1255                        # Preload the old-style object.
1256                        dlprefiles="$dlprefiles $pic_object"
1257                        prev=
1258                      fi
1259    
1260                      # A PIC object.
1261                      libobjs="$libobjs $pic_object"
1262                      arg="$pic_object"
1263                    fi
1264    
1265                    # Non-PIC object.
1266                    if test "$non_pic_object" != none; then
1267                      # Prepend the subdirectory the object is found in.
1268                      non_pic_object="$xdir$non_pic_object"
1269    
1270                      # A standard non-PIC object
1271                      non_pic_objects="$non_pic_objects $non_pic_object"
1272                      if test -z "$pic_object" || test "$pic_object" = none ; then
1273                        arg="$non_pic_object"
1274                      fi
1275                    fi
1276                  else
1277                    # Only an error if not doing a dry-run.
1278                    if test -z "$run"; then
1279                      $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1280                      exit $EXIT_FAILURE
1281                    else
1282                      # Dry-run case.
1283    
1284                      # Extract subdirectory from the argument.
1285                      xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1286                      if test "X$xdir" = "X$arg"; then
1287                        xdir=
1288                      else
1289                        xdir="$xdir/"
1290                      fi
1291    
1292                      pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1293                      non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1294                      libobjs="$libobjs $pic_object"
1295                      non_pic_objects="$non_pic_objects $non_pic_object"
1296                    fi
1297                  fi
1298                done
1299              else
1300                $echo "$modename: link input file \`$save_arg' does not exist"
1301                exit $EXIT_FAILURE
1302              fi
1303              arg=$save_arg
1304            prev=            prev=
1305            continue            continue
1306            ;;            ;;
# Line 916  compiler." Line 1310  compiler."
1310            [\\/]* | [A-Za-z]:[\\/]*) ;;            [\\/]* | [A-Za-z]:[\\/]*) ;;
1311            *)            *)
1312              $echo "$modename: only absolute run-paths are allowed" 1>&2              $echo "$modename: only absolute run-paths are allowed" 1>&2
1313              exit 1              exit $EXIT_FAILURE
1314              ;;              ;;
1315            esac            esac
1316            if test "$prev" = rpath; then            if test "$prev" = rpath; then
# Line 948  compiler." Line 1342  compiler."
1342            finalize_command="$finalize_command $wl$qarg"            finalize_command="$finalize_command $wl$qarg"
1343            continue            continue
1344            ;;            ;;
1345            xcclinker)
1346              linker_flags="$linker_flags $qarg"
1347              compiler_flags="$compiler_flags $qarg"
1348              prev=
1349              compile_command="$compile_command $qarg"
1350              finalize_command="$finalize_command $qarg"
1351              continue
1352              ;;
1353            shrext)
1354              shrext_cmds="$arg"
1355              prev=
1356              continue
1357              ;;
1358          *)          *)
1359            eval "$prev=\"\$arg\""            eval "$prev=\"\$arg\""
1360            prev=            prev=
1361            continue            continue
1362            ;;            ;;
1363          esac          esac
1364        fi # test -n $prev        fi # test -n "$prev"
1365    
1366        prevarg="$arg"        prevarg="$arg"
1367    
# Line 996  compiler." Line 1403  compiler."
1403        -export-symbols | -export-symbols-regex)        -export-symbols | -export-symbols-regex)
1404          if test -n "$export_symbols" || test -n "$export_symbols_regex"; then          if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1405            $echo "$modename: more than one -exported-symbols argument is not allowed"            $echo "$modename: more than one -exported-symbols argument is not allowed"
1406            exit 1            exit $EXIT_FAILURE
1407          fi          fi
1408          if test "X$arg" = "X-export-symbols"; then          if test "X$arg" = "X-export-symbols"; then
1409            prev=expsyms            prev=expsyms
# Line 1006  compiler." Line 1413  compiler."
1413          continue          continue
1414          ;;          ;;
1415    
1416          -inst-prefix-dir)
1417            prev=inst_prefix
1418            continue
1419            ;;
1420    
1421        # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*        # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1422        # so, if we see these flags be careful not to treat them like -L        # so, if we see these flags be careful not to treat them like -L
1423        -L[A-Z][A-Z]*:*)        -L[A-Z][A-Z]*:*)
1424          case $with_gcc/$host in          case $with_gcc/$host in
1425          no/*-*-irix* | no/*-*-nonstopux*)          no/*-*-irix* | /*-*-irix*)
1426            compile_command="$compile_command $arg"            compile_command="$compile_command $arg"
1427            finalize_command="$finalize_command $arg"            finalize_command="$finalize_command $arg"
1428            ;;            ;;
# Line 1027  compiler." Line 1439  compiler."
1439            absdir=`cd "$dir" && pwd`            absdir=`cd "$dir" && pwd`
1440            if test -z "$absdir"; then            if test -z "$absdir"; then
1441              $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2              $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1442              exit 1              exit $EXIT_FAILURE
1443            fi            fi
1444            dir="$absdir"            dir="$absdir"
1445            ;;            ;;
# Line 1065  compiler." Line 1477  compiler."
1477              # Do not include libc due to us having libc/libc_r.              # Do not include libc due to us having libc/libc_r.
1478              test "X$arg" = "X-lc" && continue              test "X$arg" = "X-lc" && continue
1479              ;;              ;;
1480            esac            *-*-rhapsody* | *-*-darwin1.[012])
1481           elif test "X$arg" = "X-lc_r"; then              # Rhapsody C and math libraries are in the System framework
1482            case $host in              deplibs="$deplibs -framework System"
          *-*-openbsd* | *-*-freebsd*)  
             # Do not include libc_r directly, use -pthread flag.  
1483              continue              continue
             ;;  
1484            esac            esac
1485            elif test "X$arg" = "X-lc_r"; then
1486             case $host in
1487             *-*-openbsd* | *-*-freebsd*)
1488               # Do not include libc_r directly, use -pthread flag.
1489               continue
1490               ;;
1491             esac
1492          fi          fi
1493          deplibs="$deplibs $arg"          deplibs="$deplibs $arg"
1494          continue          continue
1495          ;;          ;;
1496    
1497         -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1498            deplibs="$deplibs $arg"
1499            continue
1500            ;;
1501    
1502        -module)        -module)
1503          module=yes          module=yes
1504          continue          continue
1505          ;;          ;;
1506    
1507          # gcc -m* arguments should be passed to the linker via $compiler_flags
1508          # in order to pass architecture information to the linker
1509          # (e.g. 32 vs 64-bit).  This may also be accomplished via -Wl,-mfoo
1510          # but this is not reliable with gcc because gcc may use -mfoo to
1511          # select a different linker, different libraries, etc, while
1512          # -Wl,-mfoo simply passes -mfoo to the linker.
1513          -m*)
1514            # Unknown arguments in both finalize_command and compile_command need
1515            # to be aesthetically quoted because they are evaled later.
1516            arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1517            case $arg in
1518            *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
1519              arg="\"$arg\""
1520              ;;
1521            esac
1522            compile_command="$compile_command $arg"
1523            finalize_command="$finalize_command $arg"
1524            if test "$with_gcc" = "yes" ; then
1525              compiler_flags="$compiler_flags $arg"
1526            fi
1527            continue
1528            ;;
1529    
1530          -shrext)
1531            prev=shrext
1532            continue
1533            ;;
1534    
1535        -no-fast-install)        -no-fast-install)
1536          fast_install=no          fast_install=no
1537          continue          continue
# Line 1107  compiler." Line 1556  compiler."
1556          continue          continue
1557          ;;          ;;
1558    
1559          -objectlist)
1560            prev=objectlist
1561            continue
1562            ;;
1563    
1564        -o) prev=output ;;        -o) prev=output ;;
1565    
1566          -precious-files-regex)
1567            prev=precious_regex
1568            continue
1569            ;;
1570    
1571        -release)        -release)
1572          prev=release          prev=release
1573          continue          continue
# Line 1131  compiler." Line 1590  compiler."
1590          [\\/]* | [A-Za-z]:[\\/]*) ;;          [\\/]* | [A-Za-z]:[\\/]*) ;;
1591          *)          *)
1592            $echo "$modename: only absolute run-paths are allowed" 1>&2            $echo "$modename: only absolute run-paths are allowed" 1>&2
1593            exit 1            exit $EXIT_FAILURE
1594            ;;            ;;
1595          esac          esac
1596          case "$xrpath " in          case "$xrpath " in
# Line 1159  compiler." Line 1618  compiler."
1618          prev=vinfo          prev=vinfo
1619          continue          continue
1620          ;;          ;;
1621          -version-number)
1622            prev=vinfo
1623            vinfo_number=yes
1624            continue
1625            ;;
1626    
1627        -Wc,*)        -Wc,*)
1628          args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`          args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
# Line 1207  compiler." Line 1671  compiler."
1671          continue          continue
1672          ;;          ;;
1673    
1674          -XCClinker)
1675            prev=xcclinker
1676            continue
1677            ;;
1678    
1679        # Some other compiler flag.        # Some other compiler flag.
1680        -* | +*)        -* | +*)
1681          # Unknown arguments in both finalize_command and compile_command need          # Unknown arguments in both finalize_command and compile_command need
# Line 1219  compiler." Line 1688  compiler."
1688          esac          esac
1689          ;;          ;;
1690    
1691        *.lo | *.$objext)        *.$objext)
1692          # A library or standard object.          # A standard object.
1693          if test "$prev" = dlfiles; then          objs="$objs $arg"
1694            # This file was specified with -dlopen.          ;;
1695            if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then  
1696              dlfiles="$dlfiles $arg"        *.lo)
1697              prev=          # A libtool-controlled object.
1698              continue  
1699            # Check to see that this really is a libtool object.
1700            if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1701              pic_object=
1702              non_pic_object=
1703    
1704              # Read the .lo file
1705              # If there is no directory component, then add one.
1706              case $arg in
1707              */* | *\\*) . $arg ;;
1708              *) . ./$arg ;;
1709              esac
1710    
1711              if test -z "$pic_object" || \
1712                 test -z "$non_pic_object" ||
1713                 test "$pic_object" = none && \
1714                 test "$non_pic_object" = none; then
1715                $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1716                exit $EXIT_FAILURE
1717              fi
1718    
1719              # Extract subdirectory from the argument.
1720              xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1721              if test "X$xdir" = "X$arg"; then
1722                xdir=
1723            else            else
1724              # If libtool objects are unsupported, then we need to preload.              xdir="$xdir/"
             prev=dlprefiles  
1725            fi            fi
         fi  
1726    
1727          if test "$prev" = dlprefiles; then            if test "$pic_object" != none; then
1728            # Preload the old-style object.              # Prepend the subdirectory the object is found in.
1729            dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`              pic_object="$xdir$pic_object"
1730            prev=  
1731                if test "$prev" = dlfiles; then
1732                  if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1733                    dlfiles="$dlfiles $pic_object"
1734                    prev=
1735                    continue
1736                  else
1737                    # If libtool objects are unsupported, then we need to preload.
1738                    prev=dlprefiles
1739                  fi
1740                fi
1741    
1742                # CHECK ME:  I think I busted this.  -Ossama
1743                if test "$prev" = dlprefiles; then
1744                  # Preload the old-style object.
1745                  dlprefiles="$dlprefiles $pic_object"
1746                  prev=
1747                fi
1748    
1749                # A PIC object.
1750                libobjs="$libobjs $pic_object"
1751                arg="$pic_object"
1752              fi
1753    
1754              # Non-PIC object.
1755              if test "$non_pic_object" != none; then
1756                # Prepend the subdirectory the object is found in.
1757                non_pic_object="$xdir$non_pic_object"
1758    
1759                # A standard non-PIC object
1760                non_pic_objects="$non_pic_objects $non_pic_object"
1761                if test -z "$pic_object" || test "$pic_object" = none ; then
1762                  arg="$non_pic_object"
1763                fi
1764              fi
1765          else          else
1766            case $arg in            # Only an error if not doing a dry-run.
1767            *.lo) libobjs="$libobjs $arg" ;;            if test -z "$run"; then
1768            *) objs="$objs $arg" ;;              $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1769            esac              exit $EXIT_FAILURE
1770              else
1771                # Dry-run case.
1772    
1773                # Extract subdirectory from the argument.
1774                xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1775                if test "X$xdir" = "X$arg"; then
1776                  xdir=
1777                else
1778                  xdir="$xdir/"
1779                fi
1780    
1781                pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1782                non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1783                libobjs="$libobjs $pic_object"
1784                non_pic_objects="$non_pic_objects $non_pic_object"
1785              fi
1786          fi          fi
1787          ;;          ;;
1788    
# Line 1292  compiler." Line 1833  compiler."
1833      if test -n "$prev"; then      if test -n "$prev"; then
1834        $echo "$modename: the \`$prevarg' option requires an argument" 1>&2        $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
1835        $echo "$help" 1>&2        $echo "$help" 1>&2
1836        exit 1        exit $EXIT_FAILURE
1837      fi      fi
1838    
1839      if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then      if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
# Line 1301  compiler." Line 1842  compiler."
1842        finalize_command="$finalize_command $arg"        finalize_command="$finalize_command $arg"
1843      fi      fi
1844    
1845        oldlibs=
1846      # calculate the name of the file, without its directory      # calculate the name of the file, without its directory
1847      outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`      outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
1848      libobjs_save="$libobjs"      libobjs_save="$libobjs"
# Line 1321  compiler." Line 1863  compiler."
1863        output_objdir="$output_objdir/$objdir"        output_objdir="$output_objdir/$objdir"
1864      fi      fi
1865      # Create the object directory.      # Create the object directory.
1866      if test ! -d $output_objdir; then      if test ! -d "$output_objdir"; then
1867        $show "$mkdir $output_objdir"        $show "$mkdir $output_objdir"
1868        $run $mkdir $output_objdir        $run $mkdir $output_objdir
1869        status=$?        status=$?
1870        if test $status -ne 0 && test ! -d $output_objdir; then        if test "$status" -ne 0 && test ! -d "$output_objdir"; then
1871          exit $status          exit $status
1872        fi        fi
1873      fi      fi
# Line 1335  compiler." Line 1877  compiler."
1877      "")      "")
1878        $echo "$modename: you must specify an output file" 1>&2        $echo "$modename: you must specify an output file" 1>&2
1879        $echo "$help" 1>&2        $echo "$help" 1>&2
1880        exit 1        exit $EXIT_FAILURE
1881        ;;        ;;
1882      *.$libext) linkmode=oldlib ;;      *.$libext) linkmode=oldlib ;;
1883      *.lo | *.$objext) linkmode=obj ;;      *.lo | *.$objext) linkmode=obj ;;
# Line 1343  compiler." Line 1885  compiler."
1885      *) linkmode=prog ;; # Anything else should be a program.      *) linkmode=prog ;; # Anything else should be a program.
1886      esac      esac
1887    
1888        case $host in
1889        *cygwin* | *mingw* | *pw32*)
1890          # don't eliminate duplications in $postdeps and $predeps
1891          duplicate_compiler_generated_deps=yes
1892          ;;
1893        *)
1894          duplicate_compiler_generated_deps=$duplicate_deps
1895          ;;
1896        esac
1897      specialdeplibs=      specialdeplibs=
1898    
1899      libs=      libs=
1900      # Find all interdependent deplibs by searching for libraries      # Find all interdependent deplibs by searching for libraries
1901      # that are linked more than once (e.g. -la -lb -la)      # that are linked more than once (e.g. -la -lb -la)
# Line 1355  compiler." Line 1907  compiler."
1907        fi        fi
1908        libs="$libs $deplib"        libs="$libs $deplib"
1909      done      done
1910    
1911        if test "$linkmode" = lib; then
1912          libs="$predeps $libs $compiler_lib_search_path $postdeps"
1913    
1914          # Compute libraries that are listed more than once in $predeps
1915          # $postdeps and mark them as special (i.e., whose duplicates are
1916          # not to be eliminated).
1917          pre_post_deps=
1918          if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
1919            for pre_post_dep in $predeps $postdeps; do
1920              case "$pre_post_deps " in
1921              *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
1922              esac
1923              pre_post_deps="$pre_post_deps $pre_post_dep"
1924            done
1925          fi
1926          pre_post_deps=
1927        fi
1928    
1929      deplibs=      deplibs=
1930      newdependency_libs=      newdependency_libs=
1931      newlib_search_path=      newlib_search_path=
# Line 1369  compiler." Line 1940  compiler."
1940            *.la) ;;            *.la) ;;
1941            *)            *)
1942              $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2              $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
1943              exit 1              exit $EXIT_FAILURE
1944              ;;              ;;
1945            esac            esac
1946          done          done
# Line 1386  compiler." Line 1957  compiler."
1957          ;;          ;;
1958      esac      esac
1959      for pass in $passes; do      for pass in $passes; do
1960        if test $linkmode = prog; then        if test "$linkmode,$pass" = "lib,link" ||
1961          # Determine which files to process           test "$linkmode,$pass" = "prog,scan"; then
1962            libs="$deplibs"
1963            deplibs=
1964          fi
1965          if test "$linkmode" = prog; then
1966          case $pass in          case $pass in
1967          dlopen)          dlopen) libs="$dlfiles" ;;
           libs="$dlfiles"  
           save_deplibs="$deplibs" # Collect dlpreopened libraries  
           deplibs=  
           ;;  
1968          dlpreopen) libs="$dlprefiles" ;;          dlpreopen) libs="$dlprefiles" ;;
1969          link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;          link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
1970          esac          esac
1971        fi        fi
1972          if test "$pass" = dlopen; then
1973            # Collect dlpreopened libraries
1974            save_deplibs="$deplibs"
1975            deplibs=
1976          fi
1977        for deplib in $libs; do        for deplib in $libs; do
1978          lib=          lib=
1979          found=no          found=no
1980          case $deplib in          case $deplib in
1981            -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1982              if test "$linkmode,$pass" = "prog,link"; then
1983                compile_deplibs="$deplib $compile_deplibs"
1984                finalize_deplibs="$deplib $finalize_deplibs"
1985              else
1986                deplibs="$deplib $deplibs"
1987              fi
1988              continue
1989              ;;
1990          -l*)          -l*)
1991            if test $linkmode = oldlib && test $linkmode = obj; then            if test "$linkmode" != lib && test "$linkmode" != prog; then
1992              $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2              $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
1993              continue              continue
1994            fi            fi
1995            if test $pass = conv; then            if test "$pass" = conv; then
1996              deplibs="$deplib $deplibs"              deplibs="$deplib $deplibs"
1997              continue              continue
1998            fi            fi
1999            name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`            name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
2000            for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do            for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
2001              # Search the libtool library              for search_ext in .la $std_shrext .so .a; do
2002              lib="$searchdir/lib${name}.la"                # Search the libtool library
2003              if test -f "$lib"; then                lib="$searchdir/lib${name}${search_ext}"
2004                found=yes                if test -f "$lib"; then
2005                break                  if test "$search_ext" = ".la"; then
2006              fi                    found=yes
2007                    else
2008                      found=no
2009                    fi
2010                    break 2
2011                  fi
2012                done
2013            done            done
2014            if test "$found" != yes; then            if test "$found" != yes; then
2015              # deplib doesn't seem to be a libtool library              # deplib doesn't seem to be a libtool library
# Line 1427  compiler." Line 2018  compiler."
2018                finalize_deplibs="$deplib $finalize_deplibs"                finalize_deplibs="$deplib $finalize_deplibs"
2019              else              else
2020                deplibs="$deplib $deplibs"                deplibs="$deplib $deplibs"
2021                test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs"                test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2022              fi              fi
2023              continue              continue
2024              else # deplib is a libtool library
2025                # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2026                # We need to do some special things here, and not later.
2027                if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2028                  case " $predeps $postdeps " in
2029                  *" $deplib "*)
2030                    if (${SED} -e '2q' $lib |
2031                        grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2032                      library_names=
2033                      old_library=
2034                      case $lib in
2035                      */* | *\\*) . $lib ;;
2036                      *) . ./$lib ;;
2037                      esac
2038                      for l in $old_library $library_names; do
2039                        ll="$l"
2040                      done
2041                      if test "X$ll" = "X$old_library" ; then # only static version available
2042                        found=no
2043                        ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2044                        test "X$ladir" = "X$lib" && ladir="."
2045                        lib=$ladir/$old_library
2046                        if test "$linkmode,$pass" = "prog,link"; then
2047                          compile_deplibs="$deplib $compile_deplibs"
2048                          finalize_deplibs="$deplib $finalize_deplibs"
2049                        else
2050                          deplibs="$deplib $deplibs"
2051                          test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2052                        fi
2053                        continue
2054                      fi
2055                    fi
2056                    ;;
2057                  *) ;;
2058                  esac
2059                fi
2060            fi            fi
2061            ;; # -l            ;; # -l
2062          -L*)          -L*)
2063            case $linkmode in            case $linkmode in
2064            lib)            lib)
2065              deplibs="$deplib $deplibs"              deplibs="$deplib $deplibs"
2066              test $pass = conv && continue              test "$pass" = conv && continue
2067              newdependency_libs="$deplib $newdependency_libs"              newdependency_libs="$deplib $newdependency_libs"
2068              newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`              newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2069              ;;              ;;
2070            prog)            prog)
2071              if test $pass = conv; then              if test "$pass" = conv; then
2072                deplibs="$deplib $deplibs"                deplibs="$deplib $deplibs"
2073                continue                continue
2074              fi              fi
2075              if test $pass = scan; then              if test "$pass" = scan; then
2076                deplibs="$deplib $deplibs"                deplibs="$deplib $deplibs"
               newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`  
2077              else              else
2078                compile_deplibs="$deplib $compile_deplibs"                compile_deplibs="$deplib $compile_deplibs"
2079                finalize_deplibs="$deplib $finalize_deplibs"                finalize_deplibs="$deplib $finalize_deplibs"
2080              fi              fi
2081                newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2082              ;;              ;;
2083            *)            *)
2084              $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2              $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2085              ;;              ;;
2086            esac # linkmode            esac # linkmode
2087            continue            continue
2088            ;; # -L            ;; # -L
2089          -R*)          -R*)
2090            if test $pass = link; then            if test "$pass" = link; then
2091              dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`              dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2092              # Make sure the xrpath contains only unique directories.              # Make sure the xrpath contains only unique directories.
2093              case "$xrpath " in              case "$xrpath " in
# Line 1473  compiler." Line 2100  compiler."
2100            ;;            ;;
2101          *.la) lib="$deplib" ;;          *.la) lib="$deplib" ;;
2102          *.$libext)          *.$libext)
2103            if test $pass = conv; then            if test "$pass" = conv; then
2104              deplibs="$deplib $deplibs"              deplibs="$deplib $deplibs"
2105              continue              continue
2106            fi            fi
2107            case $linkmode in            case $linkmode in
2108            lib)            lib)
2109              if test "$deplibs_check_method" != pass_all; then              valid_a_lib=no
2110                echo              case $deplibs_check_method in
2111                echo "*** Warning: Trying to link with static lib archive $deplib."                match_pattern*)
2112                echo "*** I have the capability to make that library automatically link in when"                  set dummy $deplibs_check_method
2113                echo "*** you link to this library.  But I can only do this if you have a"                  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2114                echo "*** shared version of the library, which you do not appear to have"                  if eval $echo \"$deplib\" 2>/dev/null \
2115                echo "*** because the file extensions .$libext of this argument makes me believe"                      | $SED 10q \
2116                echo "*** that it is just a static archive that I should not used here."                      | $EGREP "$match_pattern_regex" > /dev/null; then
2117                      valid_a_lib=yes
2118                    fi
2119                    ;;
2120                  pass_all)
2121                    valid_a_lib=yes
2122                    ;;
2123                esac
2124                if test "$valid_a_lib" != yes; then
2125                  $echo
2126                  $echo "*** Warning: Trying to link with static lib archive $deplib."
2127                  $echo "*** I have the capability to make that library automatically link in when"
2128                  $echo "*** you link to this library.  But I can only do this if you have a"
2129                  $echo "*** shared version of the library, which you do not appear to have"
2130                  $echo "*** because the file extensions .$libext of this argument makes me believe"
2131                  $echo "*** that it is just a static archive that I should not used here."
2132              else              else
2133                echo                $echo
2134                echo "*** Warning: Linking the shared library $output against the"                $echo "*** Warning: Linking the shared library $output against the"
2135                echo "*** static library $deplib is not portable!"                $echo "*** static library $deplib is not portable!"
2136                deplibs="$deplib $deplibs"                deplibs="$deplib $deplibs"
2137              fi              fi
2138              continue              continue
2139              ;;              ;;
2140            prog)            prog)
2141              if test $pass != link; then              if test "$pass" != link; then
2142                deplibs="$deplib $deplibs"                deplibs="$deplib $deplibs"
2143              else              else
2144                compile_deplibs="$deplib $compile_deplibs"                compile_deplibs="$deplib $compile_deplibs"
# Line 1507  compiler." Line 2149  compiler."
2149            esac # linkmode            esac # linkmode
2150            ;; # *.$libext            ;; # *.$libext
2151          *.lo | *.$objext)          *.lo | *.$objext)
2152            if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then            if test "$pass" = conv; then
2153              # If there is no dlopen support or we're linking statically,              deplibs="$deplib $deplibs"
2154              # we need to preload.            elif test "$linkmode" = prog; then
2155              newdlprefiles="$newdlprefiles $deplib"              if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2156              compile_deplibs="$deplib $compile_deplibs"                # If there is no dlopen support or we're linking statically,
2157              finalize_deplibs="$deplib $finalize_deplibs"                # we need to preload.
2158            else                newdlprefiles="$newdlprefiles $deplib"
2159              newdlfiles="$newdlfiles $deplib"                compile_deplibs="$deplib $compile_deplibs"
2160                  finalize_deplibs="$deplib $finalize_deplibs"
2161                else
2162                  newdlfiles="$newdlfiles $deplib"
2163                fi
2164            fi            fi
2165            continue            continue
2166            ;;            ;;
# Line 1523  compiler." Line 2169  compiler."
2169            continue            continue
2170            ;;            ;;
2171          esac # case $deplib          esac # case $deplib
2172          if test $found = yes || test -f "$lib"; then :          if test "$found" = yes || test -f "$lib"; then :
2173          else          else
2174            $echo "$modename: cannot find the library \`$lib'" 1>&2            $echo "$modename: cannot find the library \`$lib'" 1>&2
2175            exit 1            exit $EXIT_FAILURE
2176          fi          fi
2177    
2178          # Check to see that this really is a libtool archive.          # Check to see that this really is a libtool archive.
2179          if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :          if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2180          else          else
2181            $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2            $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2182            exit 1            exit $EXIT_FAILURE
2183          fi          fi
2184    
2185          ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`          ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
# Line 1546  compiler." Line 2192  compiler."
2192          library_names=          library_names=
2193          old_library=          old_library=
2194          # If the library was installed with an old release of libtool,          # If the library was installed with an old release of libtool,
2195          # it will not redefine variable installed.          # it will not redefine variables installed, or shouldnotlink
2196          installed=yes          installed=yes
2197            shouldnotlink=no
2198    
2199          # Read the .la file          # Read the .la file
2200          case $lib in          case $lib in
# Line 1557  compiler." Line 2204  compiler."
2204    
2205          if test "$linkmode,$pass" = "lib,link" ||          if test "$linkmode,$pass" = "lib,link" ||
2206             test "$linkmode,$pass" = "prog,scan" ||             test "$linkmode,$pass" = "prog,scan" ||
2207             { test $linkmode = oldlib && test $linkmode = obj; }; then             { test "$linkmode" != prog && test "$linkmode" != lib; }; then
            # Add dl[pre]opened files of deplib  
2208            test -n "$dlopen" && dlfiles="$dlfiles $dlopen"            test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2209            test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"            test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2210          fi          fi
2211    
2212          if test $pass = conv; then          if test "$pass" = conv; then
2213            # Only check for convenience libraries            # Only check for convenience libraries
2214            deplibs="$lib $deplibs"            deplibs="$lib $deplibs"
2215            if test -z "$libdir"; then            if test -z "$libdir"; then
2216              if test -z "$old_library"; then              if test -z "$old_library"; then
2217                $echo "$modename: cannot find name of link library for \`$lib'" 1>&2                $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2218                exit 1                exit $EXIT_FAILURE
2219              fi              fi
2220              # It is a libtool convenience library, so add in its objects.              # It is a libtool convenience library, so add in its objects.
2221              convenience="$convenience $ladir/$objdir/$old_library"              convenience="$convenience $ladir/$objdir/$old_library"
# Line 1584  compiler." Line 2230  compiler."
2230                fi                fi
2231                tmp_libs="$tmp_libs $deplib"                tmp_libs="$tmp_libs $deplib"
2232              done              done
2233            elif test $linkmode != prog && test $linkmode != lib; then            elif test "$linkmode" != prog && test "$linkmode" != lib; then
2234              $echo "$modename: \`$lib' is not a convenience library" 1>&2              $echo "$modename: \`$lib' is not a convenience library" 1>&2
2235              exit 1              exit $EXIT_FAILURE
2236            fi            fi
2237            continue            continue
2238          fi # $pass = conv          fi # $pass = conv
2239    
2240    
2241          # Get the name of the library we link against.          # Get the name of the library we link against.
2242          linklib=          linklib=
2243          for l in $old_library $library_names; do          for l in $old_library $library_names; do
# Line 1598  compiler." Line 2245  compiler."
2245          done          done
2246          if test -z "$linklib"; then          if test -z "$linklib"; then
2247            $echo "$modename: cannot find name of link library for \`$lib'" 1>&2            $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2248            exit 1            exit $EXIT_FAILURE
2249          fi          fi
2250    
2251          # This library was specified with -dlopen.          # This library was specified with -dlopen.
2252          if test $pass = dlopen; then          if test "$pass" = dlopen; then
2253            if test -z "$libdir"; then            if test -z "$libdir"; then
2254              $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2              $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2255              exit 1              exit $EXIT_FAILURE
2256            fi            fi
2257            if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then            if test -z "$dlname" ||
2258                 test "$dlopen_support" != yes ||
2259                 test "$build_libtool_libs" = no; then
2260              # If there is no dlname, no dlopen support or we're linking              # If there is no dlname, no dlopen support or we're linking
2261              # statically, we need to preload.              # statically, we need to preload.  We also need to preload any
2262              dlprefiles="$dlprefiles $lib"              # dependent libraries so libltdl's deplib preloader doesn't
2263                # bomb out in the load deplibs phase.
2264                dlprefiles="$dlprefiles $lib $dependency_libs"
2265            else            else
2266              newdlfiles="$newdlfiles $lib"              newdlfiles="$newdlfiles $lib"
2267            fi            fi
# Line 1643  compiler." Line 2294  compiler."
2294              absdir="$libdir"              absdir="$libdir"
2295            fi            fi
2296          else          else
2297            dir="$ladir/$objdir"            if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2298            absdir="$abs_ladir/$objdir"              dir="$ladir"
2299            # Remove this search path later              absdir="$abs_ladir"
2300            notinst_path="$notinst_path $abs_ladir"              # Remove this search path later
2301                notinst_path="$notinst_path $abs_ladir"
2302              else
2303                dir="$ladir/$objdir"
2304                absdir="$abs_ladir/$objdir"
2305                # Remove this search path later
2306                notinst_path="$notinst_path $abs_ladir"
2307              fi
2308          fi # $installed = yes          fi # $installed = yes
2309          name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`          name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2310    
2311          # This library was specified with -dlpreopen.          # This library was specified with -dlpreopen.
2312          if test $pass = dlpreopen; then          if test "$pass" = dlpreopen; then
2313            if test -z "$libdir"; then            if test -z "$libdir"; then
2314              $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2              $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2315              exit 1              exit $EXIT_FAILURE
2316            fi            fi
2317            # Prefer using a static library (so that no silly _DYNAMIC symbols            # Prefer using a static library (so that no silly _DYNAMIC symbols
2318            # are required to link).            # are required to link).
# Line 1670  compiler." Line 2328  compiler."
2328    
2329          if test -z "$libdir"; then          if test -z "$libdir"; then
2330            # Link the convenience library            # Link the convenience library
2331            if test $linkmode = lib; then            if test "$linkmode" = lib; then
2332              deplibs="$dir/$old_library $deplibs"              deplibs="$dir/$old_library $deplibs"
2333            elif test "$linkmode,$pass" = "prog,link"; then            elif test "$linkmode,$pass" = "prog,link"; then
2334              compile_deplibs="$dir/$old_library $compile_deplibs"              compile_deplibs="$dir/$old_library $compile_deplibs"
2335              finalize_deplibs="$dir/$old_library $finalize_deplibs"              finalize_deplibs="$dir/$old_library $finalize_deplibs"
2336            else            else
2337              deplibs="$lib $deplibs"              deplibs="$lib $deplibs" # used for prog,scan pass
2338            fi            fi
2339            continue            continue
2340          fi          fi
2341    
2342          if test $linkmode = prog && test $pass != link; then  
2343            if test "$linkmode" = prog && test "$pass" != link; then
2344            newlib_search_path="$newlib_search_path $ladir"            newlib_search_path="$newlib_search_path $ladir"
2345            deplibs="$lib $deplibs"            deplibs="$lib $deplibs"
2346    
# Line 1697  compiler." Line 2356  compiler."
2356              -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test              -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2357              esac              esac
2358              # Need to link against all dependency_libs?              # Need to link against all dependency_libs?
2359              if test $linkalldeplibs = yes; then              if test "$linkalldeplibs" = yes; then
2360                deplibs="$deplib $deplibs"                deplibs="$deplib $deplibs"
2361              else              else
2362                # Need to hardcode shared library paths                # Need to hardcode shared library paths
# Line 1714  compiler." Line 2373  compiler."
2373            continue            continue
2374          fi # $linkmode = prog...          fi # $linkmode = prog...
2375    
2376          link_static=no # Whether the deplib will be linked statically          if test "$linkmode,$pass" = "prog,link"; then
2377          if test -n "$library_names" &&            if test -n "$library_names" &&
2378             { test "$prefer_static_libs" = no || test -z "$old_library"; }; then               { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2379            # Link against this shared library              # We need to hardcode the library path
2380                if test -n "$shlibpath_var"; then
2381                  # Make sure the rpath contains only unique directories.
2382                  case "$temp_rpath " in
2383                  *" $dir "*) ;;
2384                  *" $absdir "*) ;;
2385                  *) temp_rpath="$temp_rpath $dir" ;;
2386                  esac
2387                fi
2388    
           if test "$linkmode,$pass" = "prog,link" ||  
            { test $linkmode = lib && test $hardcode_into_libs = yes; }; then  
2389              # Hardcode the library path.              # Hardcode the library path.
2390              # Skip directories that are in the system default run-time              # Skip directories that are in the system default run-time
2391              # search path.              # search path.
# Line 1742  compiler." Line 2407  compiler."
2407                esac                esac
2408                ;;                ;;
2409              esac              esac
             if test $linkmode = prog; then  
               # We need to hardcode the library path  
               if test -n "$shlibpath_var"; then  
                 # Make sure the rpath contains only unique directories.  
                 case "$temp_rpath " in  
                 *" $dir "*) ;;  
                 *" $absdir "*) ;;  
                 *) temp_rpath="$temp_rpath $dir" ;;  
                 esac  
               fi  
             fi  
2410            fi # $linkmode,$pass = prog,link...            fi # $linkmode,$pass = prog,link...
2411    
2412            if test "$alldeplibs" = yes &&            if test "$alldeplibs" = yes &&
# Line 1762  compiler." Line 2416  compiler."
2416              # We only need to search for static libraries              # We only need to search for static libraries
2417              continue              continue
2418            fi            fi
2419            fi
2420    
2421            link_static=no # Whether the deplib will be linked statically
2422            if test -n "$library_names" &&
2423               { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2424            if test "$installed" = no; then            if test "$installed" = no; then
2425              notinst_deplibs="$notinst_deplibs $lib"              notinst_deplibs="$notinst_deplibs $lib"
2426              need_relink=yes              need_relink=yes
2427            fi            fi
2428              # This is a shared library
2429    
2430              # Warn about portability, can't link against -module's on
2431              # some systems (darwin)
2432              if test "$shouldnotlink" = yes && test "$pass" = link ; then
2433                $echo
2434                if test "$linkmode" = prog; then
2435                  $echo "*** Warning: Linking the executable $output against the loadable module"
2436                else
2437                  $echo "*** Warning: Linking the shared library $output against the loadable module"
2438                fi
2439                $echo "*** $linklib is not portable!"
2440              fi
2441              if test "$linkmode" = lib &&
2442                 test "$hardcode_into_libs" = yes; then
2443                # Hardcode the library path.
2444                # Skip directories that are in the system default run-time
2445                # search path.
2446                case " $sys_lib_dlsearch_path " in
2447                *" $absdir "*) ;;
2448                *)
2449                  case "$compile_rpath " in
2450                  *" $absdir "*) ;;
2451                  *) compile_rpath="$compile_rpath $absdir"
2452                  esac
2453                  ;;
2454                esac
2455                case " $sys_lib_dlsearch_path " in
2456                *" $libdir "*) ;;
2457                *)
2458                  case "$finalize_rpath " in
2459                  *" $libdir "*) ;;
2460                  *) finalize_rpath="$finalize_rpath $libdir"
2461                  esac
2462                  ;;
2463                esac
2464              fi
2465    
2466            if test -n "$old_archive_from_expsyms_cmds"; then            if test -n "$old_archive_from_expsyms_cmds"; then
2467              # figure out the soname              # figure out the soname
# Line 1780  compiler." Line 2475  compiler."
2475              elif test -n "$soname_spec"; then              elif test -n "$soname_spec"; then
2476                # bleh windows                # bleh windows
2477                case $host in                case $host in
2478                *cygwin*)                *cygwin* | mingw*)
2479                  major=`expr $current - $age`                  major=`expr $current - $age`
2480                  versuffix="-$major"                  versuffix="-$major"
2481                  ;;                  ;;
# Line 1792  compiler." Line 2487  compiler."
2487    
2488              # Make a new name for the extract_expsyms_cmds to use              # Make a new name for the extract_expsyms_cmds to use
2489              soroot="$soname"              soroot="$soname"
2490              soname=`echo $soroot | ${SED} -e 's/^.*\///'`              soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2491              newlib="libimp-`echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"              newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2492    
2493              # If the library has no export list, then create one now              # If the library has no export list, then create one now
2494              if test -f "$output_objdir/$soname-def"; then :              if test -f "$output_objdir/$soname-def"; then :
2495              else              else
2496                $show "extracting exported symbol list from \`$soname'"                $show "extracting exported symbol list from \`$soname'"
2497                save_ifs="$IFS"; IFS='~'                save_ifs="$IFS"; IFS='~'
2498                eval cmds=\"$extract_expsyms_cmds\"                cmds=$extract_expsyms_cmds
2499                for cmd in $cmds; do                for cmd in $cmds; do
2500                  IFS="$save_ifs"                  IFS="$save_ifs"
2501                    eval cmd=\"$cmd\"
2502                  $show "$cmd"                  $show "$cmd"
2503                  $run eval "$cmd" || exit $?                  $run eval "$cmd" || exit $?
2504                done                done
# Line 1813  compiler." Line 2509  compiler."
2509              if test -f "$output_objdir/$newlib"; then :; else              if test -f "$output_objdir/$newlib"; then :; else
2510                $show "generating import library for \`$soname'"                $show "generating import library for \`$soname'"
2511                save_ifs="$IFS"; IFS='~'                save_ifs="$IFS"; IFS='~'
2512                eval cmds=\"$old_archive_from_expsyms_cmds\"                cmds=$old_archive_from_expsyms_cmds
2513                for cmd in $cmds; do                for cmd in $cmds; do
2514                  IFS="$save_ifs"                  IFS="$save_ifs"
2515                    eval cmd=\"$cmd\"
2516                  $show "$cmd"                  $show "$cmd"
2517                  $run eval "$cmd" || exit $?                  $run eval "$cmd" || exit $?
2518                done                done
# Line 1824  compiler." Line 2521  compiler."
2521              # make sure the library variables are pointing to the new library              # make sure the library variables are pointing to the new library
2522              dir=$output_objdir              dir=$output_objdir
2523              linklib=$newlib              linklib=$newlib
2524            fi # test -n $old_archive_from_expsyms_cmds            fi # test -n "$old_archive_from_expsyms_cmds"
2525    
2526            if test $linkmode = prog || test "$mode" != relink; then            if test "$linkmode" = prog || test "$mode" != relink; then
2527              add_shlibpath=              add_shlibpath=
2528              add_dir=              add_dir=
2529              add=              add=
# Line 1835  compiler." Line 2532  compiler."
2532              immediate | unsupported)              immediate | unsupported)
2533                if test "$hardcode_direct" = no; then                if test "$hardcode_direct" = no; then
2534                  add="$dir/$linklib"                  add="$dir/$linklib"
2535                    case $host in
2536                      *-*-sco3.2v5* ) add_dir="-L$dir" ;;
2537                      *-*-darwin* )
2538                        # if the lib is a module then we can not link against
2539                        # it, someone is ignoring the new warnings I added
2540                        if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2541                          $echo "** Warning, lib $linklib is a module, not a shared library"
2542                          if test -z "$old_library" ; then
2543                            $echo
2544                            $echo "** And there doesn't seem to be a static archive available"
2545                            $echo "** The link will probably fail, sorry"
2546                          else
2547                            add="$dir/$old_library"
2548                          fi
2549                        fi
2550                    esac
2551                elif test "$hardcode_minus_L" = no; then                elif test "$hardcode_minus_L" = no; then
2552                  case $host in                  case $host in
2553                  *-*-sunos*) add_shlibpath="$dir" ;;                  *-*-sunos*) add_shlibpath="$dir" ;;
# Line 1853  compiler." Line 2566  compiler."
2566                  add="$dir/$linklib"                  add="$dir/$linklib"
2567                elif test "$hardcode_minus_L" = yes; then                elif test "$hardcode_minus_L" = yes; then
2568                  add_dir="-L$dir"                  add_dir="-L$dir"
2569                    # Try looking first in the location we're being installed to.
2570                    if test -n "$inst_prefix_dir"; then
2571                      case "$libdir" in
2572                        [\\/]*)
2573                          add_dir="$add_dir -L$inst_prefix_dir$libdir"
2574                          ;;
2575                      esac
2576                    fi
2577                  add="-l$name"                  add="-l$name"
2578                elif test "$hardcode_shlibpath_var" = yes; then                elif test "$hardcode_shlibpath_var" = yes; then
2579                  add_shlibpath="$dir"                  add_shlibpath="$dir"
# Line 1866  compiler." Line 2587  compiler."
2587    
2588              if test "$lib_linked" != yes; then              if test "$lib_linked" != yes; then
2589                $echo "$modename: configuration error: unsupported hardcode properties"                $echo "$modename: configuration error: unsupported hardcode properties"
2590                exit 1                exit $EXIT_FAILURE
2591              fi              fi
2592    
2593              if test -n "$add_shlibpath"; then              if test -n "$add_shlibpath"; then
# Line 1875  compiler." Line 2596  compiler."
2596                *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;                *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2597                esac                esac
2598              fi              fi
2599              if test $linkmode = prog; then              if test "$linkmode" = prog; then
2600                test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"                test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2601                test -n "$add" && compile_deplibs="$add $compile_deplibs"                test -n "$add" && compile_deplibs="$add $compile_deplibs"
2602              else              else
# Line 1892  compiler." Line 2613  compiler."
2613              fi              fi
2614            fi            fi
2615    
2616            if test $linkmode = prog || test "$mode" = relink; then            if test "$linkmode" = prog || test "$mode" = relink; then
2617              add_shlibpath=              add_shlibpath=
2618              add_dir=              add_dir=
2619              add=              add=
# Line 1908  compiler." Line 2629  compiler."
2629                *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;                *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2630                esac                esac
2631                add="-l$name"                add="-l$name"
2632                elif test "$hardcode_automatic" = yes; then
2633                  if test -n "$inst_prefix_dir" &&
2634                     test -f "$inst_prefix_dir$libdir/$linklib" ; then
2635                    add="$inst_prefix_dir$libdir/$linklib"
2636                  else
2637                    add="$libdir/$linklib"
2638                  fi
2639              else              else
2640                # We cannot seem to hardcode it, guess we'll fake it.                # We cannot seem to hardcode it, guess we'll fake it.
2641                add_dir="-L$libdir"                add_dir="-L$libdir"
2642                  # Try looking first in the location we're being installed to.
2643                  if test -n "$inst_prefix_dir"; then
2644                    case "$libdir" in
2645                      [\\/]*)
2646                        add_dir="$add_dir -L$inst_prefix_dir$libdir"
2647                        ;;
2648                    esac
2649                  fi
2650                add="-l$name"                add="-l$name"
2651              fi              fi
2652    
2653              if test $linkmode = prog; then              if test "$linkmode" = prog; then
2654                test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"                test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2655                test -n "$add" && finalize_deplibs="$add $finalize_deplibs"                test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2656              else              else
# Line 1922  compiler." Line 2658  compiler."
2658                test -n "$add" && deplibs="$add $deplibs"                test -n "$add" && deplibs="$add $deplibs"
2659              fi              fi
2660            fi            fi
2661          elif test $linkmode = prog; then          elif test "$linkmode" = prog; then
           if test "$alldeplibs" = yes &&  
              { test "$deplibs_check_method" = pass_all ||  
                { test "$build_libtool_libs" = yes &&  
                  test -n "$library_names"; }; }; then  
             # We only need to search for static libraries  
             continue  
           fi  
   
           # Try to link the static library  
2662            # Here we assume that one of hardcode_direct or hardcode_minus_L            # Here we assume that one of hardcode_direct or hardcode_minus_L
2663            # is not unsupported.  This is valid on all known static and            # is not unsupported.  This is valid on all known static and
2664            # shared platforms.            # shared platforms.
# Line 1951  compiler." Line 2678  compiler."
2678    
2679              # Just print a warning and add the library to dependency_libs so              # Just print a warning and add the library to dependency_libs so
2680              # that the program can be linked against the static library.              # that the program can be linked against the static library.
2681              echo              $echo
2682              echo "*** Warning: This system can not link to static lib archive $lib."              $echo "*** Warning: This system can not link to static lib archive $lib."
2683              echo "*** I have the capability to make that library automatically link in when"              $echo "*** I have the capability to make that library automatically link in when"
2684              echo "*** you link to this library.  But I can only do this if you have a"              $echo "*** you link to this library.  But I can only do this if you have a"
2685              echo "*** shared version of the library, which you do not appear to have."              $echo "*** shared version of the library, which you do not appear to have."
2686              if test "$module" = yes; then              if test "$module" = yes; then
2687                echo "*** But as you try to build a module library, libtool will still create "                $echo "*** But as you try to build a module library, libtool will still create "
2688                echo "*** a static module, that should work as long as the dlopening application"                $echo "*** a static module, that should work as long as the dlopening application"
2689                echo "*** is linked with the -dlopen flag to resolve symbols at runtime."                $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2690                if test -z "$global_symbol_pipe"; then                if test -z "$global_symbol_pipe"; then
2691                  echo                  $echo
2692                  echo "*** However, this would only work if libtool was able to extract symbol"                  $echo "*** However, this would only work if libtool was able to extract symbol"
2693                  echo "*** lists from a program, using \`nm' or equivalent, but libtool could"                  $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2694                  echo "*** not find such a program.  So, this module is probably useless."                  $echo "*** not find such a program.  So, this module is probably useless."
2695                  echo "*** \`nm' from GNU binutils and a full rebuild may help."                  $echo "*** \`nm' from GNU binutils and a full rebuild may help."
2696                fi                fi
2697                if test "$build_old_libs" = no; then                if test "$build_old_libs" = no; then
2698                  build_libtool_libs=module                  build_libtool_libs=module
# Line 1982  compiler." Line 2709  compiler."
2709            fi            fi
2710          fi # link shared/static library?          fi # link shared/static library?
2711    
2712          if test $linkmode = lib; then          if test "$linkmode" = lib; then
2713            if test -n "$dependency_libs" &&            if test -n "$dependency_libs" &&
2714               { test $hardcode_into_libs != yes || test $build_old_libs = yes ||               { test "$hardcode_into_libs" != yes ||
2715                 test $link_static = yes; }; then                 test "$build_old_libs" = yes ||
2716                   test "$link_static" = yes; }; then
2717              # Extract -R from dependency_libs              # Extract -R from dependency_libs
2718              temp_deplibs=              temp_deplibs=
2719              for libdir in $dependency_libs; do              for libdir in $dependency_libs; do
# Line 2016  compiler." Line 2744  compiler."
2744              tmp_libs="$tmp_libs $deplib"              tmp_libs="$tmp_libs $deplib"
2745            done            done
2746    
2747            if test $link_all_deplibs != no; then            if test "$link_all_deplibs" != no; then
2748              # Add the search paths of all dependency libraries              # Add the search paths of all dependency libraries
2749              for deplib in $dependency_libs; do              for deplib in $dependency_libs; do
2750                case $deplib in                case $deplib in
# Line 2036  compiler." Line 2764  compiler."
2764                    ;;                    ;;
2765                  esac                  esac
2766                  if grep "^installed=no" $deplib > /dev/null; then                  if grep "^installed=no" $deplib > /dev/null; then
2767                    path="-L$absdir/$objdir"                    path="$absdir/$objdir"
2768                  else                  else
2769                    eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`                    eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2770                    if test -z "$libdir"; then                    if test -z "$libdir"; then
2771                      $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2                      $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2772                      exit 1                      exit $EXIT_FAILURE
2773                    fi                    fi
2774                    if test "$absdir" != "$libdir"; then                    if test "$absdir" != "$libdir"; then
2775                      $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2                      $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2776                    fi                    fi
2777                    path="-L$absdir"                    path="$absdir"
2778                  fi                  fi
2779                    depdepl=
2780                    case $host in
2781                    *-*-darwin*)
2782                      # we do not want to link against static libs,
2783                      # but need to link against shared
2784                      eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2785                      if test -n "$deplibrary_names" ; then
2786                        for tmp in $deplibrary_names ; do
2787                          depdepl=$tmp
2788                        done
2789                        if test -f "$path/$depdepl" ; then
2790                          depdepl="$path/$depdepl"
2791                        fi
2792                        # do not add paths which are already there
2793                        case " $newlib_search_path " in
2794                        *" $path "*) ;;
2795                        *) newlib_search_path="$newlib_search_path $path";;
2796                        esac
2797                      fi
2798                      path=""
2799                      ;;
2800                    *)
2801                      path="-L$path"
2802                      ;;
2803                    esac
2804                    ;;
2805                  -l*)
2806                    case $host in
2807                    *-*-darwin*)
2808                      # Again, we only want to link against shared libraries
2809                      eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2810                      for tmp in $newlib_search_path ; do
2811                        if test -f "$tmp/lib$tmp_libs.dylib" ; then
2812                          eval depdepl="$tmp/lib$tmp_libs.dylib"
2813                          break
2814                        fi
2815                      done
2816                      path=""
2817                      ;;
2818                    *) continue ;;
2819                    esac
2820                  ;;                  ;;
2821                *) continue ;;                *) continue ;;
2822                esac                esac
2823                case " $deplibs " in                case " $deplibs " in
2824                  *" $depdepl "*) ;;
2825                  *) deplibs="$depdepl $deplibs" ;;
2826                  esac
2827                  case " $deplibs " in
2828                *" $path "*) ;;                *" $path "*) ;;
2829                *) deplibs="$deplibs $path" ;;                *) deplibs="$deplibs $path" ;;
2830                esac                esac
# Line 2059  compiler." Line 2832  compiler."
2832            fi # link_all_deplibs != no            fi # link_all_deplibs != no
2833          fi # linkmode = lib          fi # linkmode = lib
2834        done # for deplib in $libs        done # for deplib in $libs
2835        if test $pass = dlpreopen; then        dependency_libs="$newdependency_libs"
2836          if test "$pass" = dlpreopen; then
2837          # Link the dlpreopened libraries before other libraries          # Link the dlpreopened libraries before other libraries
2838          for deplib in $save_deplibs; do          for deplib in $save_deplibs; do
2839            deplibs="$deplib $deplibs"            deplibs="$deplib $deplibs"
2840          done          done
2841        fi        fi
2842        if test $pass != dlopen; then        if test "$pass" != dlopen; then
2843          test $pass != scan && dependency_libs="$newdependency_libs"          if test "$pass" != conv; then
         if test $pass != conv; then  
2844            # Make sure lib_search_path contains only unique directories.            # Make sure lib_search_path contains only unique directories.
2845            lib_search_path=            lib_search_path=
2846            for dir in $newlib_search_path; do            for dir in $newlib_search_path; do
# Line 2089  compiler." Line 2862  compiler."
2862            eval tmp_libs=\"\$$var\"            eval tmp_libs=\"\$$var\"
2863            new_libs=            new_libs=
2864            for deplib in $tmp_libs; do            for deplib in $tmp_libs; do
2865                # FIXME: Pedantically, this is the right thing to do, so
2866                #        that some nasty dependency loop isn't accidentally
2867                #        broken:
2868                #new_libs="$deplib $new_libs"
2869                # Pragmatically, this seems to cause very few problems in
2870                # practice:
2871              case $deplib in              case $deplib in
2872              -L*) new_libs="$deplib $new_libs" ;;              -L*) new_libs="$deplib $new_libs" ;;
2873                -R*) ;;
2874              *)              *)
2875                  # And here is the reason: when a library appears more
2876                  # than once as an explicit dependence of a library, or
2877                  # is implicitly linked in more than once by the
2878                  # compiler, it is considered special, and multiple
2879                  # occurrences thereof are not removed.  Compare this
2880                  # with having the same library being listed as a
2881                  # dependency of multiple other libraries: in this case,
2882                  # we know (pedantically, we assume) the library does not
2883                  # need to be listed more than once, so we keep only the
2884                  # last copy.  This is not always right, but it is rare
2885                  # enough that we require users that really mean to play
2886                  # such unportable linking tricks to link the library
2887                  # using -Wl,-lname, so that libtool does not consider it
2888                  # for duplicate removal.
2889                case " $specialdeplibs " in                case " $specialdeplibs " in
2890                *" $deplib "*) new_libs="$deplib $new_libs" ;;                *" $deplib "*) new_libs="$deplib $new_libs" ;;
2891                *)                *)
# Line 2119  compiler." Line 2913  compiler."
2913            eval $var=\"$tmp_libs\"            eval $var=\"$tmp_libs\"
2914          done # for var          done # for var
2915        fi        fi
2916        if test "$pass" = "conv" &&        # Last step: remove runtime libs from dependency_libs
2917         { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then        # (they stay in deplibs)
2918          libs="$deplibs" # reset libs        tmp_libs=
2919          deplibs=        for i in $dependency_libs ; do
2920        fi          case " $predeps $postdeps $compiler_lib_search_path " in
2921            *" $i "*)
2922              i=""
2923              ;;
2924            esac
2925            if test -n "$i" ; then
2926              tmp_libs="$tmp_libs $i"
2927            fi
2928          done
2929          dependency_libs=$tmp_libs
2930      done # for pass      done # for pass
2931      if test $linkmode = prog; then      if test "$linkmode" = prog; then
2932        dlfiles="$newdlfiles"        dlfiles="$newdlfiles"
2933        dlprefiles="$newdlprefiles"        dlprefiles="$newdlprefiles"
2934      fi      fi
2935    
2936      case $linkmode in      case $linkmode in
2937      oldlib)      oldlib)
2938          if test -n "$deplibs"; then
2939            $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
2940          fi
2941    
2942        if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then        if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2943          $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2          $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
2944        fi        fi
# Line 2145  compiler." Line 2952  compiler."
2952        fi        fi
2953    
2954        if test -n "$vinfo"; then        if test -n "$vinfo"; then
2955          $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2          $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
2956        fi        fi
2957    
2958        if test -n "$release"; then        if test -n "$release"; then
# Line 2167  compiler." Line 2974  compiler."
2974        case $outputname in        case $outputname in
2975        lib*)        lib*)
2976          name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`          name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2977            eval shared_ext=\"$shrext_cmds\"
2978          eval libname=\"$libname_spec\"          eval libname=\"$libname_spec\"
2979          ;;          ;;
2980        *)        *)
2981          if test "$module" = no; then          if test "$module" = no; then
2982            $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2            $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
2983            $echo "$help" 1>&2            $echo "$help" 1>&2
2984            exit 1            exit $EXIT_FAILURE
2985          fi          fi
2986          if test "$need_lib_prefix" != no; then          if test "$need_lib_prefix" != no; then
2987            # Add the "lib" prefix for modules if required            # Add the "lib" prefix for modules if required
2988            name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`            name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
2989              eval shared_ext=\"$shrext_cmds\"
2990            eval libname=\"$libname_spec\"            eval libname=\"$libname_spec\"
2991          else          else
2992            libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`            libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
# Line 2188  compiler." Line 2997  compiler."
2997        if test -n "$objs"; then        if test -n "$objs"; then
2998          if test "$deplibs_check_method" != pass_all; then          if test "$deplibs_check_method" != pass_all; then
2999            $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1            $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
3000            exit 1            exit $EXIT_FAILURE
3001          else          else
3002            echo            $echo
3003            echo "*** Warning: Linking the shared library $output against the non-libtool"            $echo "*** Warning: Linking the shared library $output against the non-libtool"
3004            echo "*** objects $objs is not portable!"            $echo "*** objects $objs is not portable!"
3005            libobjs="$libobjs $objs"            libobjs="$libobjs $objs"
3006          fi          fi
3007        fi        fi
# Line 2202  compiler." Line 3011  compiler."
3011        fi        fi
3012    
3013        set dummy $rpath        set dummy $rpath
3014        if test $# -gt 2; then        if test "$#" -gt 2; then
3015          $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2          $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3016        fi        fi
3017        install_libdir="$2"        install_libdir="$2"
# Line 2211  compiler." Line 3020  compiler."
3020        if test -z "$rpath"; then        if test -z "$rpath"; then
3021          if test "$build_libtool_libs" = yes; then          if test "$build_libtool_libs" = yes; then
3022            # Building a libtool convenience library.            # Building a libtool convenience library.
3023            libext=al            # Some compilers have problems with a `.al' extension so
3024              # convenience libraries should have the same extension an
3025              # archive normally would.
3026            oldlibs="$output_objdir/$libname.$libext $oldlibs"            oldlibs="$output_objdir/$libname.$libext $oldlibs"
3027            build_libtool_libs=convenience            build_libtool_libs=convenience
3028            build_old_libs=yes            build_old_libs=yes
3029          fi          fi
3030    
3031          if test -n "$vinfo"; then          if test -n "$vinfo"; then
3032            $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2            $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3033          fi          fi
3034    
3035          if test -n "$release"; then          if test -n "$release"; then
# Line 2234  compiler." Line 3045  compiler."
3045          if test -n "$8"; then          if test -n "$8"; then
3046            $echo "$modename: too many parameters to \`-version-info'" 1>&2            $echo "$modename: too many parameters to \`-version-info'" 1>&2
3047            $echo "$help" 1>&2            $echo "$help" 1>&2
3048            exit 1            exit $EXIT_FAILURE
3049          fi          fi
3050    
3051          current="$2"          # convert absolute version numbers to libtool ages
3052          revision="$3"          # this retains compatibility with .la files and attempts
3053          age="$4"          # to make the code below a bit more comprehensible
3054    
3055            case $vinfo_number in
3056            yes)
3057              number_major="$2"
3058              number_minor="$3"
3059              number_revision="$4"
3060              #
3061              # There are really only two kinds -- those that
3062              # use the current revision as the major version
3063              # and those that subtract age and use age as
3064              # a minor version.  But, then there is irix
3065              # which has an extra 1 added just for fun
3066              #
3067              case $version_type in
3068              darwin|linux|osf|windows)
3069                current=`expr $number_major + $number_minor`
3070                age="$number_minor"
3071                revision="$number_revision"
3072                ;;
3073              freebsd-aout|freebsd-elf|sunos)
3074                current="$number_major"
3075                revision="$number_minor"
3076                age="0"
3077                ;;
3078              irix|nonstopux)
3079                current=`expr $number_major + $number_minor - 1`
3080                age="$number_minor"
3081                revision="$number_minor"
3082                ;;
3083              esac
3084              ;;
3085            no)
3086              current="$2"
3087              revision="$3"
3088              age="$4"
3089              ;;
3090            esac
3091    
3092          # Check that each of the things are valid numbers.          # Check that each of the things are valid numbers.
3093          case $current in          case $current in
# Line 2247  compiler." Line 3095  compiler."
3095          *)          *)
3096            $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2            $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
3097            $echo "$modename: \`$vinfo' is not valid version information" 1>&2            $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3098            exit 1            exit $EXIT_FAILURE
3099            ;;            ;;
3100          esac          esac
3101    
# Line 2256  compiler." Line 3104  compiler."
3104          *)          *)
3105            $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2            $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
3106            $echo "$modename: \`$vinfo' is not valid version information" 1>&2            $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3107            exit 1            exit $EXIT_FAILURE
3108            ;;            ;;
3109          esac          esac
3110    
# Line 2265  compiler." Line 3113  compiler."
3113          *)          *)
3114            $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2            $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
3115            $echo "$modename: \`$vinfo' is not valid version information" 1>&2            $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3116            exit 1            exit $EXIT_FAILURE
3117            ;;            ;;
3118          esac          esac
3119    
3120          if test $age -gt $current; then          if test "$age" -gt "$current"; then
3121            $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2            $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3122            $echo "$modename: \`$vinfo' is not valid version information" 1>&2            $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3123            exit 1            exit $EXIT_FAILURE
3124          fi          fi
3125    
3126          # Calculate the version variables.          # Calculate the version variables.
# Line 2289  compiler." Line 3137  compiler."
3137            versuffix="$major.$age.$revision"            versuffix="$major.$age.$revision"
3138            # Darwin ld doesn't like 0 for these options...            # Darwin ld doesn't like 0 for these options...
3139            minor_current=`expr $current + 1`            minor_current=`expr $current + 1`
3140            verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"            verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3141            ;;            ;;
3142    
3143          freebsd-aout)          freebsd-aout)
# Line 2313  compiler." Line 3161  compiler."
3161    
3162            # Add in all the interfaces that we are compatible with.            # Add in all the interfaces that we are compatible with.
3163            loop=$revision            loop=$revision
3164            while test $loop != 0; do            while test "$loop" -ne 0; do
3165              iface=`expr $revision - $loop`              iface=`expr $revision - $loop`
3166              loop=`expr $loop - 1`              loop=`expr $loop - 1`
3167              verstring="$verstring_prefix$major.$iface:$verstring"              verstring="$verstring_prefix$major.$iface:$verstring"
# Line 2336  compiler." Line 3184  compiler."
3184    
3185            # Add in all the interfaces that we are compatible with.            # Add in all the interfaces that we are compatible with.
3186            loop=$age            loop=$age
3187            while test $loop != 0; do            while test "$loop" -ne 0; do
3188              iface=`expr $current - $loop`              iface=`expr $current - $loop`
3189              loop=`expr $loop - 1`              loop=`expr $loop - 1`
3190              verstring="$verstring:${iface}.0"              verstring="$verstring:${iface}.0"
# Line 2360  compiler." Line 3208  compiler."
3208    
3209          *)          *)
3210            $echo "$modename: unknown library version type \`$version_type'" 1>&2            $echo "$modename: unknown library version type \`$version_type'" 1>&2
3211            echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2            $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3212            exit 1            exit $EXIT_FAILURE
3213            ;;            ;;
3214          esac          esac
3215    
3216          # Clear the version info if we defaulted, and they specified a release.          # Clear the version info if we defaulted, and they specified a release.
3217          if test -z "$vinfo" && test -n "$release"; then          if test -z "$vinfo" && test -n "$release"; then
3218            major=            major=
           verstring="0.0"  
3219            case $version_type in            case $version_type in
3220            darwin)            darwin)
3221              # we can't check for "0.0" in archive_cmds due to quoting              # we can't check for "0.0" in archive_cmds due to quoting
3222              # problems, so we reset it completely              # problems, so we reset it completely
3223              verstring=""              verstring=
3224              ;;              ;;
3225            *)            *)
3226              verstring="0.0"              verstring="0.0"
# Line 2407  compiler." Line 3254  compiler."
3254        fi        fi
3255    
3256        if test "$mode" != relink; then        if test "$mode" != relink; then
3257          # Remove our outputs.          # Remove our outputs, but don't remove object files since they
3258          $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"          # may have been created when compiling PIC objects.
3259          $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*          removelist=
3260            tempremovelist=`$echo "$output_objdir/*"`
3261            for p in $tempremovelist; do
3262              case $p in
3263                *.$objext)
3264                   ;;
3265                $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3266                   if test "X$precious_files_regex" != "X"; then
3267                     if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3268                     then
3269                       continue
3270                     fi
3271                   fi
3272                   removelist="$removelist $p"
3273                   ;;
3274                *) ;;
3275              esac
3276            done
3277            if test -n "$removelist"; then
3278              $show "${rm}r $removelist"
3279              $run ${rm}r $removelist
3280            fi
3281        fi        fi
3282    
3283        # Now set the variables for building old libraries.        # Now set the variables for building old libraries.
# Line 2422  compiler." Line 3290  compiler."
3290    
3291        # Eliminate all temporary directories.        # Eliminate all temporary directories.
3292        for path in $notinst_path; do        for path in $notinst_path; do
3293          lib_search_path=`echo "$lib_search_path " | ${SED} -e 's% $path % %g'`          lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
3294          deplibs=`echo "$deplibs " | ${SED} -e 's% -L$path % %g'`          deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
3295          dependency_libs=`echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`          dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
3296        done        done
3297    
3298        if test -n "$xrpath"; then        if test -n "$xrpath"; then
# Line 2437  compiler." Line 3305  compiler."
3305            *) finalize_rpath="$finalize_rpath $libdir" ;;            *) finalize_rpath="$finalize_rpath $libdir" ;;
3306            esac            esac
3307          done          done
3308          if test $hardcode_into_libs != yes || test $build_old_libs = yes; then          if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3309            dependency_libs="$temp_xrpath $dependency_libs"            dependency_libs="$temp_xrpath $dependency_libs"
3310          fi          fi
3311        fi        fi
# Line 2477  compiler." Line 3345  compiler."
3345              ;;              ;;
3346            *-*-openbsd* | *-*-freebsd*)            *-*-openbsd* | *-*-freebsd*)
3347              # Do not include libc due to us having libc/libc_r.              # Do not include libc due to us having libc/libc_r.
3348                test "X$arg" = "X-lc" && continue
3349              ;;              ;;
3350            *)            *)
3351              # Add libc to deplibs on all other systems if necessary.              # Add libc to deplibs on all other systems if necessary.
3352              if test $build_libtool_need_lc = "yes"; then              if test "$build_libtool_need_lc" = "yes"; then
3353                deplibs="$deplibs -lc"                deplibs="$deplibs -lc"
3354              fi              fi
3355              ;;              ;;
# Line 2507  compiler." Line 3376  compiler."
3376            # This might be a little naive.  We might want to check            # This might be a little naive.  We might want to check
3377            # whether the library exists or not.  But this is on            # whether the library exists or not.  But this is on
3378            # osf3 & osf4 and I'm not really sure... Just            # osf3 & osf4 and I'm not really sure... Just
3379            # implementing what was already the behaviour.            # implementing what was already the behavior.
3380            newdeplibs=$deplibs            newdeplibs=$deplibs
3381            ;;            ;;
3382          test_compile)          test_compile)
# Line 2520  compiler." Line 3389  compiler."
3389            int main() { return 0; }            int main() { return 0; }
3390  EOF  EOF
3391            $rm conftest            $rm conftest
3392            $CC -o conftest conftest.c $deplibs            $LTCC -o conftest conftest.c $deplibs
3393            if test $? -eq 0 ; then            if test "$?" -eq 0 ; then
3394              ldd_output=`ldd conftest`              ldd_output=`ldd conftest`
3395              for i in $deplibs; do              for i in $deplibs; do
3396                name="`expr $i : '-l\(.*\)'`"                name="`expr $i : '-l\(.*\)'`"
3397                # If $name is empty we are operating on a -L argument.                # If $name is empty we are operating on a -L argument.
3398                if test -n "$name" && test "$name" != "0"; then                if test "$name" != "" && test "$name" -ne "0"; then
3399                  libname=`eval \\$echo \"$libname_spec\"`                  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3400                  deplib_matches=`eval \\$echo \"$library_names_spec\"`                    case " $predeps $postdeps " in
3401                  set dummy $deplib_matches                    *" $i "*)
3402                  deplib_match=$2                      newdeplibs="$newdeplibs $i"
3403                  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then                      i=""
3404                    newdeplibs="$newdeplibs $i"                      ;;
3405                  else                    esac
3406                    droppeddeps=yes                  fi
3407                    echo                  if test -n "$i" ; then
3408                    echo "*** Warning: dynamic linker does not accept needed library $i."                    libname=`eval \\$echo \"$libname_spec\"`
3409                    echo "*** I have the capability to make that library automatically link in when"                    deplib_matches=`eval \\$echo \"$library_names_spec\"`
3410                    echo "*** you link to this library.  But I can only do this if you have a"                    set dummy $deplib_matches
3411                    echo "*** shared version of the library, which I believe you do not have"                    deplib_match=$2
3412                    echo "*** because a test_compile did reveal that the linker did not use it for"                    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3413                    echo "*** its dynamic dependency list that programs get resolved with at runtime."                      newdeplibs="$newdeplibs $i"
3414                      else
3415                        droppeddeps=yes
3416                        $echo
3417                        $echo "*** Warning: dynamic linker does not accept needed library $i."
3418                        $echo "*** I have the capability to make that library automatically link in when"
3419                        $echo "*** you link to this library.  But I can only do this if you have a"
3420                        $echo "*** shared version of the library, which I believe you do not have"
3421                        $echo "*** because a test_compile did reveal that the linker did not use it for"
3422                        $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3423                      fi
3424                  fi                  fi
3425                else                else
3426                  newdeplibs="$newdeplibs $i"                  newdeplibs="$newdeplibs $i"
3427                fi                fi
3428              done              done
3429            else            else
3430              # Error occured in the first compile.  Let's try to salvage              # Error occurred in the first compile.  Let's try to salvage
3431              # the situation: Compile a separate program for each library.              # the situation: Compile a separate program for each library.
3432              for i in $deplibs; do              for i in $deplibs; do
3433                name="`expr $i : '-l\(.*\)'`"                name="`expr $i : '-l\(.*\)'`"
3434               # If $name is empty we are operating on a -L argument.                # If $name is empty we are operating on a -L argument.
3435                if test -n "$name" && test "$name" != "0"; then                if test "$name" != "" && test "$name" != "0"; then
3436                  $rm conftest                  $rm conftest
3437                  $CC -o conftest conftest.c $i                  $LTCC -o conftest conftest.c $i
3438                  # Did it work?                  # Did it work?
3439                  if test $? -eq 0 ; then                  if test "$?" -eq 0 ; then
3440                    ldd_output=`ldd conftest`                    ldd_output=`ldd conftest`
3441                    libname=`eval \\$echo \"$libname_spec\"`                    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3442                    deplib_matches=`eval \\$echo \"$library_names_spec\"`                      case " $predeps $postdeps " in
3443                    set dummy $deplib_matches                      *" $i "*)
3444                    deplib_match=$2                        newdeplibs="$newdeplibs $i"
3445                    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then                        i=""
3446                      newdeplibs="$newdeplibs $i"                        ;;
3447                    else                      esac
3448                      droppeddeps=yes                    fi
3449                      echo                    if test -n "$i" ; then
3450                      echo "*** Warning: dynamic linker does not accept needed library $i."                      libname=`eval \\$echo \"$libname_spec\"`
3451                      echo "*** I have the capability to make that library automatically link in when"                      deplib_matches=`eval \\$echo \"$library_names_spec\"`
3452                      echo "*** you link to this library.  But I can only do this if you have a"                      set dummy $deplib_matches
3453                      echo "*** shared version of the library, which you do not appear to have"                      deplib_match=$2
3454                      echo "*** because a test_compile did reveal that the linker did not use this one"                      if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3455                      echo "*** as a dynamic dependency that programs can get resolved with at runtime."                        newdeplibs="$newdeplibs $i"
3456                        else
3457                          droppeddeps=yes
3458                          $echo
3459                          $echo "*** Warning: dynamic linker does not accept needed library $i."
3460                          $echo "*** I have the capability to make that library automatically link in when"
3461                          $echo "*** you link to this library.  But I can only do this if you have a"
3462                          $echo "*** shared version of the library, which you do not appear to have"
3463                          $echo "*** because a test_compile did reveal that the linker did not use this one"
3464                          $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3465                        fi
3466                    fi                    fi
3467                  else                  else
3468                    droppeddeps=yes                    droppeddeps=yes
3469                    echo                    $echo
3470                    echo "*** Warning!  Library $i is needed by this library but I was not able to"                    $echo "*** Warning!  Library $i is needed by this library but I was not able to"
3471                    echo "***  make it link in!  You will probably need to install it or some"                    $echo "***  make it link in!  You will probably need to install it or some"
3472                    echo "*** library that it depends on before this library will be fully"                    $echo "*** library that it depends on before this library will be fully"
3473                    echo "*** functional.  Installing it before continuing would be even better."                    $echo "*** functional.  Installing it before continuing would be even better."
3474                  fi                  fi
3475                else                else
3476                  newdeplibs="$newdeplibs $i"                  newdeplibs="$newdeplibs $i"
# Line 2595  EOF Line 3484  EOF
3484            for a_deplib in $deplibs; do            for a_deplib in $deplibs; do
3485              name="`expr $a_deplib : '-l\(.*\)'`"              name="`expr $a_deplib : '-l\(.*\)'`"
3486              # If $name is empty we are operating on a -L argument.              # If $name is empty we are operating on a -L argument.
3487              if test -n "$name" && test "$name" != "0"; then              if test "$name" != "" && test  "$name" != "0"; then
3488                libname=`eval \\$echo \"$libname_spec\"`                if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3489                for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do                  case " $predeps $postdeps " in
3490                      potential_libs=`ls $i/$libname[.-]* 2>/dev/null`                  *" $a_deplib "*)
3491                      for potent_lib in $potential_libs; do                    newdeplibs="$newdeplibs $a_deplib"
3492                      a_deplib=""
3493                      ;;
3494                    esac
3495                  fi
3496                  if test -n "$a_deplib" ; then
3497                    libname=`eval \\$echo \"$libname_spec\"`
3498                    for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3499                      potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3500                      for potent_lib in $potential_libs; do
3501                        # Follow soft links.                        # Follow soft links.
3502                        if ls -lLd "$potent_lib" 2>/dev/null \                        if ls -lLd "$potent_lib" 2>/dev/null \
3503                           | grep " -> " >/dev/null; then                           | grep " -> " >/dev/null; then
# Line 2620  EOF Line 3518  EOF
3518                        done                        done
3519                        if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \                        if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3520                           | ${SED} 10q \                           | ${SED} 10q \
3521                           | egrep "$file_magic_regex" > /dev/null; then                           | $EGREP "$file_magic_regex" > /dev/null; then
3522                          newdeplibs="$newdeplibs $a_deplib"                          newdeplibs="$newdeplibs $a_deplib"
3523                          a_deplib=""                          a_deplib=""
3524                          break 2                          break 2
3525                        fi                        fi
3526                      done                    done
3527                done                  done
3528                  fi
3529                if test -n "$a_deplib" ; then                if test -n "$a_deplib" ; then
3530                  droppeddeps=yes                  droppeddeps=yes
3531                  echo                  $echo
3532                  echo "*** Warning: linker path does not have real file for library $a_deplib."                  $echo "*** Warning: linker path does not have real file for library $a_deplib."
3533                  echo "*** I have the capability to make that library automatically link in when"                  $echo "*** I have the capability to make that library automatically link in when"
3534                  echo "*** you link to this library.  But I can only do this if you have a"                  $echo "*** you link to this library.  But I can only do this if you have a"
3535                  echo "*** shared version of the library, which you do not appear to have"                  $echo "*** shared version of the library, which you do not appear to have"
3536                  echo "*** because I did check the linker path looking for a file starting"                  $echo "*** because I did check the linker path looking for a file starting"
3537                  if test -z "$potlib" ; then                  if test -z "$potlib" ; then
3538                    echo "*** with $libname but no candidates were found. (...for file magic test)"                    $echo "*** with $libname but no candidates were found. (...for file magic test)"
3539                  else                  else
3540                    echo "*** with $libname and none of the candidates passed a file format test"                    $echo "*** with $libname and none of the candidates passed a file format test"
3541                    echo "*** using a file magic. Last file checked: $potlib"                    $echo "*** using a file magic. Last file checked: $potlib"
3542                  fi                  fi
3543                fi                fi
3544              else              else
# Line 2655  EOF Line 3554  EOF
3554              name="`expr $a_deplib : '-l\(.*\)'`"              name="`expr $a_deplib : '-l\(.*\)'`"
3555              # If $name is empty we are operating on a -L argument.              # If $name is empty we are operating on a -L argument.
3556              if test -n "$name" && test "$name" != "0"; then              if test -n "$name" && test "$name" != "0"; then
3557                libname=`eval \\$echo \"$libname_spec\"`                if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3558                for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do                  case " $predeps $postdeps " in
3559                  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`                  *" $a_deplib "*)
3560                  for potent_lib in $potential_libs; do                    newdeplibs="$newdeplibs $a_deplib"
3561                    potlib="$potent_lib" # see symlink-check below in file_magic test                    a_deplib=""
3562                    if eval echo \"$potent_lib\" 2>/dev/null \                    ;;
3563                        | ${SED} 10q \                  esac
3564                        | egrep "$match_pattern_regex" > /dev/null; then                fi
3565                      newdeplibs="$newdeplibs $a_deplib"                if test -n "$a_deplib" ; then
3566                      a_deplib=""                  libname=`eval \\$echo \"$libname_spec\"`
3567                      break 2                  for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3568                    fi                    potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3569                      for potent_lib in $potential_libs; do
3570                        potlib="$potent_lib" # see symlink-check above in file_magic test
3571                        if eval $echo \"$potent_lib\" 2>/dev/null \
3572                            | ${SED} 10q \
3573                            | $EGREP "$match_pattern_regex" > /dev/null; then
3574                          newdeplibs="$newdeplibs $a_deplib"
3575                          a_deplib=""
3576                          break 2
3577                        fi
3578                      done
3579                  done                  done
3580                done                fi
3581                if test -n "$a_deplib" ; then                if test -n "$a_deplib" ; then
3582                  droppeddeps=yes                  droppeddeps=yes
3583                  echo                  $echo
3584                  echo "*** Warning: linker path does not have real file for library $a_deplib."                  $echo "*** Warning: linker path does not have real file for library $a_deplib."
3585                  echo "*** I have the capability to make that library automatically link in when"                  $echo "*** I have the capability to make that library automatically link in when"
3586                  echo "*** you link to this library.  But I can only do this if you have a"                  $echo "*** you link to this library.  But I can only do this if you have a"
3587                  echo "*** shared version of the library, which you do not appear to have"                  $echo "*** shared version of the library, which you do not appear to have"
3588                  echo "*** because I did check the linker path looking for a file starting"                  $echo "*** because I did check the linker path looking for a file starting"
3589                  if test -z "$potlib" ; then                  if test -z "$potlib" ; then
3590                    echo "*** with $libname but no candidates were found. (...for regex pattern test)"                    $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3591                  else                  else
3592                    echo "*** with $libname and none of the candidates passed a file format test"                    $echo "*** with $libname and none of the candidates passed a file format test"
3593                    echo "*** using a regex pattern. Last file checked: $potlib"                    $echo "*** using a regex pattern. Last file checked: $potlib"
3594                  fi                  fi
3595                fi                fi
3596              else              else
# Line 2692  EOF Line 3601  EOF
3601            ;;            ;;
3602          none | unknown | *)          none | unknown | *)
3603            newdeplibs=""            newdeplibs=""
3604            if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \            tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3605                 -e 's/ -[LR][^ ]*//g' -e 's/[    ]//g' |              -e 's/ -[LR][^ ]*//g'`
3606               grep . >/dev/null; then            if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3607              echo              for i in $predeps $postdeps ; do
3608                  # can't use Xsed below, because $i might contain '/'
3609                  tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3610                done
3611              fi
3612              if $echo "X $tmp_deplibs" | $Xsed -e 's/[     ]//g' \
3613                | grep . >/dev/null; then
3614                $echo
3615              if test "X$deplibs_check_method" = "Xnone"; then              if test "X$deplibs_check_method" = "Xnone"; then
3616                echo "*** Warning: inter-library dependencies are not supported in this platform."                $echo "*** Warning: inter-library dependencies are not supported in this platform."
3617              else              else
3618                echo "*** Warning: inter-library dependencies are not known to be supported."                $echo "*** Warning: inter-library dependencies are not known to be supported."
3619              fi              fi
3620              echo "*** All declared inter-library dependencies are being dropped."              $echo "*** All declared inter-library dependencies are being dropped."
3621              droppeddeps=yes              droppeddeps=yes
3622            fi            fi
3623            ;;            ;;
# Line 2721  EOF Line 3637  EOF
3637    
3638          if test "$droppeddeps" = yes; then          if test "$droppeddeps" = yes; then
3639            if test "$module" = yes; then            if test "$module" = yes; then
3640              echo              $echo
3641              echo "*** Warning: libtool could not satisfy all declared inter-library"              $echo "*** Warning: libtool could not satisfy all declared inter-library"
3642              echo "*** dependencies of module $libname.  Therefore, libtool will create"              $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3643              echo "*** a static module, that should work as long as the dlopening"              $echo "*** a static module, that should work as long as the dlopening"
3644              echo "*** application is linked with the -dlopen flag."              $echo "*** application is linked with the -dlopen flag."
3645              if test -z "$global_symbol_pipe"; then              if test -z "$global_symbol_pipe"; then
3646                echo                $echo
3647                echo "*** However, this would only work if libtool was able to extract symbol"                $echo "*** However, this would only work if libtool was able to extract symbol"
3648                echo "*** lists from a program, using \`nm' or equivalent, but libtool could"                $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3649                echo "*** not find such a program.  So, this module is probably useless."                $echo "*** not find such a program.  So, this module is probably useless."
3650                echo "*** \`nm' from GNU binutils and a full rebuild may help."                $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3651              fi              fi
3652              if test "$build_old_libs" = no; then              if test "$build_old_libs" = no; then
3653                oldlibs="$output_objdir/$libname.$libext"                oldlibs="$output_objdir/$libname.$libext"
# Line 2741  EOF Line 3657  EOF
3657                build_libtool_libs=no                build_libtool_libs=no
3658              fi              fi
3659            else            else
3660              echo "*** The inter-library dependencies that have been dropped here will be"              $echo "*** The inter-library dependencies that have been dropped here will be"
3661              echo "*** automatically added whenever a program is linked with this library"              $echo "*** automatically added whenever a program is linked with this library"
3662              echo "*** or is declared to -dlopen it."              $echo "*** or is declared to -dlopen it."
3663    
3664              if test $allow_undefined = no; then              if test "$allow_undefined" = no; then
3665                echo                $echo
3666                echo "*** Since this library must not contain undefined symbols,"                $echo "*** Since this library must not contain undefined symbols,"
3667                echo "*** because either the platform does not support them or"                $echo "*** because either the platform does not support them or"
3668                echo "*** it was explicitly requested with -no-undefined,"                $echo "*** it was explicitly requested with -no-undefined,"
3669                echo "*** libtool will only create a static version of it."                $echo "*** libtool will only create a static version of it."
3670                if test "$build_old_libs" = no; then                if test "$build_old_libs" = no; then
3671                  oldlibs="$output_objdir/$libname.$libext"                  oldlibs="$output_objdir/$libname.$libext"
3672                  build_libtool_libs=module                  build_libtool_libs=module
# Line 2772  EOF Line 3688  EOF
3688    
3689        # Test again, we may have decided not to build it any more        # Test again, we may have decided not to build it any more
3690        if test "$build_libtool_libs" = yes; then        if test "$build_libtool_libs" = yes; then
3691          if test $hardcode_into_libs = yes; then          if test "$hardcode_into_libs" = yes; then
3692            # Hardcode the library paths            # Hardcode the library paths
3693            hardcode_libdirs=            hardcode_libdirs=
3694            dep_rpath=            dep_rpath=
# Line 2808  EOF Line 3724  EOF
3724            if test -n "$hardcode_libdir_separator" &&            if test -n "$hardcode_libdir_separator" &&
3725               test -n "$hardcode_libdirs"; then               test -n "$hardcode_libdirs"; then
3726              libdir="$hardcode_libdirs"              libdir="$hardcode_libdirs"
3727              eval dep_rpath=\"$hardcode_libdir_flag_spec\"              if test -n "$hardcode_libdir_flag_spec_ld"; then
3728                  eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
3729                else
3730                  eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3731                fi
3732            fi            fi
3733            if test -n "$runpath_var" && test -n "$perm_rpath"; then            if test -n "$runpath_var" && test -n "$perm_rpath"; then
3734              # We should set the runpath_var.              # We should set the runpath_var.
# Line 2828  EOF Line 3748  EOF
3748          fi          fi
3749    
3750          # Get the real and link names of the library.          # Get the real and link names of the library.
3751            eval shared_ext=\"$shrext_cmds\"
3752          eval library_names=\"$library_names_spec\"          eval library_names=\"$library_names_spec\"
3753          set dummy $library_names          set dummy $library_names
3754          realname="$2"          realname="$2"
# Line 2838  EOF Line 3759  EOF
3759          else          else
3760            soname="$realname"            soname="$realname"
3761          fi          fi
3762          test -z "$dlname" && dlname=$soname          if test -z "$dlname"; then
3763              dlname=$soname
3764            fi
3765    
3766          lib="$output_objdir/$realname"          lib="$output_objdir/$realname"
3767          for link          for link
# Line 2846  EOF Line 3769  EOF
3769            linknames="$linknames $link"            linknames="$linknames $link"
3770          done          done
3771    
         # Ensure that we have .o objects for linkers which dislike .lo  
         # (e.g. aix) in case we are running --disable-static  
         for obj in $libobjs; do  
           xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`  
           if test "X$xdir" = "X$obj"; then  
             xdir="."  
           else  
             xdir="$xdir"  
           fi  
           baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`  
           oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`  
           if test ! -f $xdir/$oldobj; then  
             $show "(cd $xdir && ${LN_S} $baseobj $oldobj)"  
             $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $?  
           fi  
         done  
   
3772          # Use standard objects if they are pic          # Use standard objects if they are pic
3773          test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`          test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
3774    
# Line 2872  EOF Line 3778  EOF
3778              $show "generating symbol list for \`$libname.la'"              $show "generating symbol list for \`$libname.la'"
3779              export_symbols="$output_objdir/$libname.exp"              export_symbols="$output_objdir/$libname.exp"
3780              $run $rm $export_symbols              $run $rm $export_symbols
3781              eval cmds=\"$export_symbols_cmds\"              cmds=$export_symbols_cmds
3782              save_ifs="$IFS"; IFS='~'              save_ifs="$IFS"; IFS='~'
3783              for cmd in $cmds; do              for cmd in $cmds; do
3784                IFS="$save_ifs"                IFS="$save_ifs"
3785                $show "$cmd"                eval cmd=\"$cmd\"
3786                $run eval "$cmd" || exit $?                if len=`expr "X$cmd" : ".*"` &&
3787                   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3788                    $show "$cmd"
3789                    $run eval "$cmd" || exit $?
3790                    skipped_export=false
3791                  else
3792                    # The command line is too long to execute in one step.
3793                    $show "using reloadable object file for export list..."
3794                    skipped_export=:
3795                  fi
3796              done              done
3797              IFS="$save_ifs"              IFS="$save_ifs"
3798              if test -n "$export_symbols_regex"; then              if test -n "$export_symbols_regex"; then
3799                $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""                $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
3800                $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'                $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
3801                $show "$mv \"${export_symbols}T\" \"$export_symbols\""                $show "$mv \"${export_symbols}T\" \"$export_symbols\""
3802                $run eval '$mv "${export_symbols}T" "$export_symbols"'                $run eval '$mv "${export_symbols}T" "$export_symbols"'
3803              fi              fi
# Line 2893  EOF Line 3808  EOF
3808            $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'            $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
3809          fi          fi
3810    
3811            tmp_deplibs=
3812            for test_deplib in $deplibs; do
3813                    case " $convenience " in
3814                    *" $test_deplib "*) ;;
3815                    *)
3816                            tmp_deplibs="$tmp_deplibs $test_deplib"
3817                            ;;
3818                    esac
3819            done
3820            deplibs="$tmp_deplibs"
3821    
3822          if test -n "$convenience"; then          if test -n "$convenience"; then
3823            if test -n "$whole_archive_flag_spec"; then            if test -n "$whole_archive_flag_spec"; then
3824                save_libobjs=$libobjs
3825              eval libobjs=\"\$libobjs $whole_archive_flag_spec\"              eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3826            else            else
3827              gentop="$output_objdir/${outputname}x"              gentop="$output_objdir/${outputname}x"
             $show "${rm}r $gentop"  
             $run ${rm}r "$gentop"  
             $show "mkdir $gentop"  
             $run mkdir "$gentop"  
             status=$?  
             if test $status -ne 0 && test ! -d "$gentop"; then  
               exit $status  
             fi  
3828              generated="$generated $gentop"              generated="$generated $gentop"
3829    
3830              for xlib in $convenience; do              func_extract_archives $gentop $convenience
3831                # Extract the objects.              libobjs="$libobjs $func_extract_archives_result"
               case $xlib in  
               [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;  
               *) xabs=`pwd`"/$xlib" ;;  
               esac  
               xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`  
               xdir="$gentop/$xlib"  
   
               $show "${rm}r $xdir"  
               $run ${rm}r "$xdir"  
               $show "mkdir $xdir"  
               $run mkdir "$xdir"  
               status=$?  
               if test $status -ne 0 && test ! -d "$xdir"; then  
                 exit $status  
               fi  
               $show "(cd $xdir && $AR x $xabs)"  
               $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?  
   
               libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`  
             done  
3832            fi            fi
3833          fi          fi
3834    
3835          if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then          if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3836            eval flag=\"$thread_safe_flag_spec\"            eval flag=\"$thread_safe_flag_spec\"
3837            linker_flags="$linker_flags $flag"            linker_flags="$linker_flags $flag"
# Line 2944  EOF Line 3843  EOF
3843          fi          fi
3844    
3845          # Do each of the archive commands.          # Do each of the archive commands.
3846            if test "$module" = yes && test -n "$module_cmds" ; then
3847              if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
3848                eval test_cmds=\"$module_expsym_cmds\"
3849                cmds=$module_expsym_cmds
3850              else
3851                eval test_cmds=\"$module_cmds\"
3852                cmds=$module_cmds
3853              fi
3854            else
3855          if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then          if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
3856            eval cmds=\"$archive_expsym_cmds\"            eval test_cmds=\"$archive_expsym_cmds\"
3857              cmds=$archive_expsym_cmds
3858            else
3859              eval test_cmds=\"$archive_cmds\"
3860              cmds=$archive_cmds
3861              fi
3862            fi
3863    
3864            if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` &&
3865               test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3866              :
3867          else          else
3868            save_deplibs="$deplibs"            # The command line is too long to link in one step, link piecewise.
3869            for conv in $convenience; do            $echo "creating reloadable object files..."
3870              tmp_deplibs=  
3871              for test_deplib in $deplibs; do            # Save the value of $output and $libobjs because we want to
3872                if test "$test_deplib" != "$conv"; then            # use them later.  If we have whole_archive_flag_spec, we
3873                  tmp_deplibs="$tmp_deplibs $test_deplib"            # want to use save_libobjs as it was before
3874              # whole_archive_flag_spec was expanded, because we can't
3875              # assume the linker understands whole_archive_flag_spec.
3876              # This may have to be revisited, in case too many
3877              # convenience libraries get linked in and end up exceeding
3878              # the spec.
3879              if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
3880                save_libobjs=$libobjs
3881              fi
3882              save_output=$output
3883    
3884              # Clear the reloadable object creation command queue and
3885              # initialize k to one.
3886              test_cmds=
3887              concat_cmds=
3888              objlist=
3889              delfiles=
3890              last_robj=
3891              k=1
3892              output=$output_objdir/$save_output-${k}.$objext
3893              # Loop over the list of objects to be linked.
3894              for obj in $save_libobjs
3895              do
3896                eval test_cmds=\"$reload_cmds $objlist $last_robj\"
3897                if test "X$objlist" = X ||
3898                   { len=`expr "X$test_cmds" : ".*"` &&
3899                     test "$len" -le "$max_cmd_len"; }; then
3900                  objlist="$objlist $obj"
3901                else
3902                  # The command $test_cmds is almost too long, add a
3903                  # command to the queue.
3904                  if test "$k" -eq 1 ; then
3905                    # The first file doesn't have a previous command to add.
3906                    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
3907                  else
3908                    # All subsequent reloadable object files will link in
3909                    # the last one created.
3910                    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
3911                fi                fi
3912              done                last_robj=$output_objdir/$save_output-${k}.$objext
3913              deplibs="$tmp_deplibs"                k=`expr $k + 1`
3914                  output=$output_objdir/$save_output-${k}.$objext
3915                  objlist=$obj
3916                  len=1
3917                fi
3918              done
3919              # Handle the remaining objects by creating one last
3920              # reloadable object file.  All subsequent reloadable object
3921              # files will link in the last one created.
3922              test -z "$concat_cmds" || concat_cmds=$concat_cmds~
3923              eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
3924    
3925              if ${skipped_export-false}; then
3926                $show "generating symbol list for \`$libname.la'"
3927                export_symbols="$output_objdir/$libname.exp"
3928                $run $rm $export_symbols
3929                libobjs=$output
3930                # Append the command to create the export file.
3931                eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
3932              fi
3933    
3934              # Set up a command to remove the reloadale object files
3935              # after they are used.
3936              i=0
3937              while test "$i" -lt "$k"
3938              do
3939                i=`expr $i + 1`
3940                delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
3941              done
3942    
3943              $echo "creating a temporary reloadable object file: $output"
3944    
3945              # Loop through the commands generated above and execute them.
3946              save_ifs="$IFS"; IFS='~'
3947              for cmd in $concat_cmds; do
3948                IFS="$save_ifs"
3949                $show "$cmd"
3950                $run eval "$cmd" || exit $?
3951            done            done
3952            eval cmds=\"$archive_cmds\"            IFS="$save_ifs"
3953            deplibs="$save_deplibs"  
3954              libobjs=$output
3955              # Restore the value of output.
3956              output=$save_output
3957    
3958              if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
3959                eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3960              fi
3961              # Expand the library linking commands again to reset the
3962              # value of $libobjs for piecewise linking.
3963    
3964              # Do each of the archive commands.
3965              if test "$module" = yes && test -n "$module_cmds" ; then
3966                if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
3967                  cmds=$module_expsym_cmds
3968                else
3969                  cmds=$module_cmds
3970                fi
3971              else
3972              if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
3973                cmds=$archive_expsym_cmds
3974              else
3975                cmds=$archive_cmds
3976                fi
3977              fi
3978    
3979              # Append the command to remove the reloadable object files
3980              # to the just-reset $cmds.
3981              eval cmds=\"\$cmds~\$rm $delfiles\"
3982          fi          fi
3983          save_ifs="$IFS"; IFS='~'          save_ifs="$IFS"; IFS='~'
3984          for cmd in $cmds; do          for cmd in $cmds; do
3985            IFS="$save_ifs"            IFS="$save_ifs"
3986              eval cmd=\"$cmd\"
3987            $show "$cmd"            $show "$cmd"
3988            $run eval "$cmd" || exit $?            $run eval "$cmd" || exit $?
3989          done          done
# Line 2971  EOF Line 3992  EOF
3992          # Restore the uninstalled library and exit          # Restore the uninstalled library and exit
3993          if test "$mode" = relink; then          if test "$mode" = relink; then
3994            $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?            $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
3995            exit 0            exit $EXIT_SUCCESS
3996          fi          fi
3997    
3998          # Create links to the real library.          # Create links to the real library.
# Line 3019  EOF Line 4040  EOF
4040        *.lo)        *.lo)
4041          if test -n "$objs$old_deplibs"; then          if test -n "$objs$old_deplibs"; then
4042            $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2            $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
4043            exit 1            exit $EXIT_FAILURE
4044          fi          fi
4045          libobj="$output"          libobj="$output"
4046          obj=`$echo "X$output" | $Xsed -e "$lo2o"`          obj=`$echo "X$output" | $Xsed -e "$lo2o"`
# Line 3048  EOF Line 4069  EOF
4069            eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"            eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4070          else          else
4071            gentop="$output_objdir/${obj}x"            gentop="$output_objdir/${obj}x"
           $show "${rm}r $gentop"  
           $run ${rm}r "$gentop"  
           $show "mkdir $gentop"  
           $run mkdir "$gentop"  
           status=$?  
           if test $status -ne 0 && test ! -d "$gentop"; then  
             exit $status  
           fi  
4072            generated="$generated $gentop"            generated="$generated $gentop"
4073    
4074            for xlib in $convenience; do            func_extract_archives $gentop $convenience
4075              # Extract the objects.            reload_conv_objs="$reload_objs $func_extract_archives_result"
             case $xlib in  
             [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;  
             *) xabs=`pwd`"/$xlib" ;;  
             esac  
             xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`  
             xdir="$gentop/$xlib"  
   
             $show "${rm}r $xdir"  
             $run ${rm}r "$xdir"  
             $show "mkdir $xdir"  
             $run mkdir "$xdir"  
             status=$?  
             if test $status -ne 0 && test ! -d "$xdir"; then  
               exit $status  
             fi  
             $show "(cd $xdir && $AR x $xabs)"  
             $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?  
   
             reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`  
           done  
4076          fi          fi
4077        fi        fi
4078    
# Line 3087  EOF Line 4080  EOF
4080        reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test        reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
4081    
4082        output="$obj"        output="$obj"
4083        eval cmds=\"$reload_cmds\"        cmds=$reload_cmds
4084        save_ifs="$IFS"; IFS='~'        save_ifs="$IFS"; IFS='~'
4085        for cmd in $cmds; do        for cmd in $cmds; do
4086          IFS="$save_ifs"          IFS="$save_ifs"
4087            eval cmd=\"$cmd\"
4088          $show "$cmd"          $show "$cmd"
4089          $run eval "$cmd" || exit $?          $run eval "$cmd" || exit $?
4090        done        done
# Line 3103  EOF Line 4097  EOF
4097            $run ${rm}r $gentop            $run ${rm}r $gentop
4098          fi          fi
4099    
4100          exit 0          exit $EXIT_SUCCESS
4101        fi        fi
4102    
4103        if test "$build_libtool_libs" != yes; then        if test "$build_libtool_libs" != yes; then
# Line 3114  EOF Line 4108  EOF
4108    
4109          # Create an invalid libtool object if no PIC, so that we don't          # Create an invalid libtool object if no PIC, so that we don't
4110          # accidentally link it into a program.          # accidentally link it into a program.
4111          $show "echo timestamp > $libobj"          # $show "echo timestamp > $libobj"
4112          $run eval "echo timestamp > $libobj" || exit $?          # $run eval "echo timestamp > $libobj" || exit $?
4113          exit 0          exit $EXIT_SUCCESS
4114        fi        fi
4115    
4116        if test -n "$pic_flag" || test "$pic_mode" != default; then        if test -n "$pic_flag" || test "$pic_mode" != default; then
4117          # Only do commands if we really have different PIC objects.          # Only do commands if we really have different PIC objects.
4118          reload_objs="$libobjs $reload_conv_objs"          reload_objs="$libobjs $reload_conv_objs"
4119          output="$libobj"          output="$libobj"
4120          eval cmds=\"$reload_cmds\"          cmds=$reload_cmds
4121          save_ifs="$IFS"; IFS='~'          save_ifs="$IFS"; IFS='~'
4122          for cmd in $cmds; do          for cmd in $cmds; do
4123            IFS="$save_ifs"            IFS="$save_ifs"
4124              eval cmd=\"$cmd\"
4125            $show "$cmd"            $show "$cmd"
4126            $run eval "$cmd" || exit $?            $run eval "$cmd" || exit $?
4127          done          done
4128          IFS="$save_ifs"          IFS="$save_ifs"
       else  
         # Just create a symlink.  
         $show $rm $libobj  
         $run $rm $libobj  
         xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`  
         if test "X$xdir" = "X$libobj"; then  
           xdir="."  
         else  
           xdir="$xdir"  
         fi  
         baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`  
         oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`  
         $show "(cd $xdir && $LN_S $oldobj $baseobj)"  
         $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $?  
4129        fi        fi
4130    
4131        if test -n "$gentop"; then        if test -n "$gentop"; then
# Line 3152  EOF Line 4133  EOF
4133          $run ${rm}r $gentop          $run ${rm}r $gentop
4134        fi        fi
4135    
4136        exit 0        exit $EXIT_SUCCESS
4137        ;;        ;;
4138    
4139      prog)      prog)
4140        case $host in        case $host in
4141          *cygwin*) output=`echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;          *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
4142        esac        esac
4143        if test -n "$vinfo"; then        if test -n "$vinfo"; then
4144          $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2          $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
# Line 3179  EOF Line 4160  EOF
4160          # On Rhapsody replace the C library is the System framework          # On Rhapsody replace the C library is the System framework
4161          compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`          compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4162          finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`          finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
         case $host in  
         *darwin*)  
           # Don't allow lazy linking, it breaks C++ global constructors  
           compile_command="$compile_command ${wl}-bind_at_load"  
           finalize_command="$finalize_command ${wl}-bind_at_load"  
           ;;  
         esac  
4163          ;;          ;;
4164        esac        esac
4165    
4166          case $host in
4167          *darwin*)
4168            # Don't allow lazy linking, it breaks C++ global constructors
4169            if test "$tagname" = CXX ; then
4170            compile_command="$compile_command ${wl}-bind_at_load"
4171            finalize_command="$finalize_command ${wl}-bind_at_load"
4172            fi
4173            ;;
4174          esac
4175    
4176        compile_command="$compile_command $compile_deplibs"        compile_command="$compile_command $compile_deplibs"
4177        finalize_command="$finalize_command $finalize_deplibs"        finalize_command="$finalize_command $finalize_deplibs"
4178    
# Line 3339  extern \"C\" { Line 4323  extern \"C\" {
4323              done              done
4324    
4325              if test -n "$exclude_expsyms"; then              if test -n "$exclude_expsyms"; then
4326                $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'                $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4327                $run eval '$mv "$nlist"T "$nlist"'                $run eval '$mv "$nlist"T "$nlist"'
4328              fi              fi
4329    
4330              if test -n "$export_symbols_regex"; then              if test -n "$export_symbols_regex"; then
4331                $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'                $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4332                $run eval '$mv "$nlist"T "$nlist"'                $run eval '$mv "$nlist"T "$nlist"'
4333              fi              fi
4334    
# Line 3362  extern \"C\" { Line 4346  extern \"C\" {
4346    
4347            for arg in $dlprefiles; do            for arg in $dlprefiles; do
4348              $show "extracting global C symbols from \`$arg'"              $show "extracting global C symbols from \`$arg'"
4349              name=`echo "$arg" | ${SED} -e 's%^.*/%%'`              name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
4350              $run eval 'echo ": $name " >> "$nlist"'              $run eval '$echo ": $name " >> "$nlist"'
4351              $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"              $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4352            done            done
4353    
# Line 3372  extern \"C\" { Line 4356  extern \"C\" {
4356              test -f "$nlist" || : > "$nlist"              test -f "$nlist" || : > "$nlist"
4357    
4358              if test -n "$exclude_expsyms"; then              if test -n "$exclude_expsyms"; then
4359                egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T                $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4360                $mv "$nlist"T "$nlist"                $mv "$nlist"T "$nlist"
4361              fi              fi
4362    
# Line 3392  extern \"C\" { Line 4376  extern \"C\" {
4376              if test -f "$nlist"S; then              if test -f "$nlist"S; then
4377                eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'                eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
4378              else              else
4379                echo '/* NONE */' >> "$output_objdir/$dlsyms"                $echo '/* NONE */' >> "$output_objdir/$dlsyms"
4380              fi              fi
4381    
4382              $echo >> "$output_objdir/$dlsyms" "\              $echo >> "$output_objdir/$dlsyms" "\
# Line 3444  static const void *lt_preloaded_setup() Line 4428  static const void *lt_preloaded_setup()
4428            *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)            *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4429              case "$compile_command " in              case "$compile_command " in
4430              *" -static "*) ;;              *" -static "*) ;;
4431              *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;              *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;