/[svn]/ircd-hybrid-7.2/libltdl/config/ltmain.sh
ViewVC logotype

Contents of /ircd-hybrid-7.2/libltdl/config/ltmain.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 945 - (show annotations)
Mon Jul 20 15:48:27 2009 UTC (10 years, 1 month ago) by michael
File MIME type: application/x-shellscript
File size: 243942 byte(s)
- fixed some configure mess and imported latest libtool sources

1 # Generated from ltmain.m4sh.
2
3 # ltmain.sh (GNU libtool) 2.2.6
4 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5
6 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
7 # This is free software; see the source for copying conditions. There is NO
8 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
10 # GNU Libtool is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 # As a special exception to the GNU General Public License,
16 # if you distribute this file as part of a program or library that
17 # is built using GNU Libtool, you may include this file under the
18 # same distribution terms that you use for the rest of that program.
19 #
20 # GNU Libtool is distributed in the hope that it will be useful, but
21 # WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 # General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with GNU Libtool; see the file COPYING. If not, a copy
27 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
28 # or obtained by writing to the Free Software Foundation, Inc.,
29 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31 # Usage: $progname [OPTION]... [MODE-ARG]...
32 #
33 # Provide generalized library-building support services.
34 #
35 # --config show all configuration variables
36 # --debug enable verbose shell tracing
37 # -n, --dry-run display commands without modifying any files
38 # --features display basic configuration information and exit
39 # --mode=MODE use operation mode MODE
40 # --preserve-dup-deps don't remove duplicate dependency libraries
41 # --quiet, --silent don't print informational messages
42 # --tag=TAG use configuration variables from tag TAG
43 # -v, --verbose print informational messages (default)
44 # --version print version information
45 # -h, --help print short or long help message
46 #
47 # MODE must be one of the following:
48 #
49 # clean remove files from the build directory
50 # compile compile a source file into a libtool object
51 # execute automatically set library path, then run a program
52 # finish complete the installation of libtool libraries
53 # install install libraries or executables
54 # link create a library or an executable
55 # uninstall remove libraries from an installed directory
56 #
57 # MODE-ARGS vary depending on the MODE.
58 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59 #
60 # When reporting a bug, please describe a test case to reproduce it and
61 # include the following information:
62 #
63 # host-triplet: $host
64 # shell: $SHELL
65 # compiler: $LTCC
66 # compiler flags: $LTCFLAGS
67 # linker: $LD (gnu? $with_gnu_ld)
68 # $progname: (GNU libtool) 2.2.6
69 # automake: $automake_version
70 # autoconf: $autoconf_version
71 #
72 # Report bugs to <bug-libtool@gnu.org>.
73
74 PROGRAM=ltmain.sh
75 PACKAGE=libtool
76 VERSION=2.2.6
77 TIMESTAMP=""
78 package_revision=1.3012
79
80 # define SED for historic ltconfig's generated by Libtool 1.3
81 test -z "$SED" && SED=sed
82
83 # Be Bourne compatible
84 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
85 emulate sh
86 NULLCMD=:
87 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
88 # is contrary to our usage. Disable this feature.
89 alias -g '${1+"$@"}'='"$@"'
90 setopt NO_GLOB_SUBST
91 else
92 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
93 fi
94 BIN_SH=xpg4; export BIN_SH # for Tru64
95 DUALCASE=1; export DUALCASE # for MKS sh
96
97 # NLS nuisances: We save the old values to restore during execute mode.
98 # Only set LANG and LC_ALL to C if already set.
99 # These must not be set unconditionally because not all systems understand
100 # e.g. LANG=C (notably SCO).
101 lt_user_locale=
102 lt_safe_locale=
103 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
104 do
105 eval "if test \"\${$lt_var+set}\" = set; then
106 save_$lt_var=\$$lt_var
107 $lt_var=C
108 export $lt_var
109 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
110 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
111 fi"
112 done
113
114 $lt_unset CDPATH
115
116
117
118
119
120 : ${CP="cp -f"}
121 : ${ECHO="echo"}
122 : ${EGREP="/bin/grep -E"}
123 : ${FGREP="/bin/grep -F"}
124 : ${GREP="/bin/grep"}
125 : ${LN_S="ln -s"}
126 : ${MAKE="make"}
127 : ${MKDIR="mkdir"}
128 : ${MV="mv -f"}
129 : ${RM="rm -f"}
130 : ${SED="/bin/sed"}
131 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
132 : ${Xsed="$SED -e 1s/^X//"}
133
134 # Global variables:
135 EXIT_SUCCESS=0
136 EXIT_FAILURE=1
137 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
138 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
139
140 exit_status=$EXIT_SUCCESS
141
142 # Make sure IFS has a sensible default
143 lt_nl='
144 '
145 IFS=" $lt_nl"
146
147 dirname="s,/[^/]*$,,"
148 basename="s,^.*/,,"
149
150 # func_dirname_and_basename file append nondir_replacement
151 # perform func_basename and func_dirname in a single function
152 # call:
153 # dirname: Compute the dirname of FILE. If nonempty,
154 # add APPEND to the result, otherwise set result
155 # to NONDIR_REPLACEMENT.
156 # value returned in "$func_dirname_result"
157 # basename: Compute filename of FILE.
158 # value retuned in "$func_basename_result"
159 # Implementation must be kept synchronized with func_dirname
160 # and func_basename. For efficiency, we do not delegate to
161 # those functions but instead duplicate the functionality here.
162 func_dirname_and_basename ()
163 {
164 # Extract subdirectory from the argument.
165 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
166 if test "X$func_dirname_result" = "X${1}"; then
167 func_dirname_result="${3}"
168 else
169 func_dirname_result="$func_dirname_result${2}"
170 fi
171 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
172 }
173
174 # Generated shell functions inserted here.
175
176 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
177 # is ksh but when the shell is invoked as "sh" and the current value of
178 # the _XPG environment variable is not equal to 1 (one), the special
179 # positional parameter $0, within a function call, is the name of the
180 # function.
181 progpath="$0"
182
183 # The name of this program:
184 # In the unlikely event $progname began with a '-', it would play havoc with
185 # func_echo (imagine progname=-n), so we prepend ./ in that case:
186 func_dirname_and_basename "$progpath"
187 progname=$func_basename_result
188 case $progname in
189 -*) progname=./$progname ;;
190 esac
191
192 # Make sure we have an absolute path for reexecution:
193 case $progpath in
194 [\\/]*|[A-Za-z]:\\*) ;;
195 *[\\/]*)
196 progdir=$func_dirname_result
197 progdir=`cd "$progdir" && pwd`
198 progpath="$progdir/$progname"
199 ;;
200 *)
201 save_IFS="$IFS"
202 IFS=:
203 for progdir in $PATH; do
204 IFS="$save_IFS"
205 test -x "$progdir/$progname" && break
206 done
207 IFS="$save_IFS"
208 test -n "$progdir" || progdir=`pwd`
209 progpath="$progdir/$progname"
210 ;;
211 esac
212
213 # Sed substitution that helps us do robust quoting. It backslashifies
214 # metacharacters that are still active within double-quoted strings.
215 Xsed="${SED}"' -e 1s/^X//'
216 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
217
218 # Same as above, but do not quote variable references.
219 double_quote_subst='s/\(["`\\]\)/\\\1/g'
220
221 # Re-`\' parameter expansions in output of double_quote_subst that were
222 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
223 # in input to double_quote_subst, that '$' was protected from expansion.
224 # Since each input `\' is now two `\'s, look for any number of runs of
225 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
226 bs='\\'
227 bs2='\\\\'
228 bs4='\\\\\\\\'
229 dollar='\$'
230 sed_double_backslash="\
231 s/$bs4/&\\
232 /g
233 s/^$bs2$dollar/$bs&/
234 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
235 s/\n//g"
236
237 # Standard options:
238 opt_dry_run=false
239 opt_help=false
240 opt_quiet=false
241 opt_verbose=false
242 opt_warning=:
243
244 # func_echo arg...
245 # Echo program name prefixed message, along with the current mode
246 # name if it has been set yet.
247 func_echo ()
248 {
249 $ECHO "$progname${mode+: }$mode: $*"
250 }
251
252 # func_verbose arg...
253 # Echo program name prefixed message in verbose mode only.
254 func_verbose ()
255 {
256 $opt_verbose && func_echo ${1+"$@"}
257
258 # A bug in bash halts the script if the last line of a function
259 # fails when set -e is in force, so we need another command to
260 # work around that:
261 :
262 }
263
264 # func_error arg...
265 # Echo program name prefixed message to standard error.
266 func_error ()
267 {
268 $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
269 }
270
271 # func_warning arg...
272 # Echo program name prefixed warning message to standard error.
273 func_warning ()
274 {
275 $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
276
277 # bash bug again:
278 :
279 }
280
281 # func_fatal_error arg...
282 # Echo program name prefixed message to standard error, and exit.
283 func_fatal_error ()
284 {
285 func_error ${1+"$@"}
286 exit $EXIT_FAILURE
287 }
288
289 # func_fatal_help arg...
290 # Echo program name prefixed message to standard error, followed by
291 # a help hint, and exit.
292 func_fatal_help ()
293 {
294 func_error ${1+"$@"}
295 func_fatal_error "$help"
296 }
297 help="Try \`$progname --help' for more information." ## default
298
299
300 # func_grep expression filename
301 # Check whether EXPRESSION matches any line of FILENAME, without output.
302 func_grep ()
303 {
304 $GREP "$1" "$2" >/dev/null 2>&1
305 }
306
307
308 # func_mkdir_p directory-path
309 # Make sure the entire path to DIRECTORY-PATH is available.
310 func_mkdir_p ()
311 {
312 my_directory_path="$1"
313 my_dir_list=
314
315 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
316
317 # Protect directory names starting with `-'
318 case $my_directory_path in
319 -*) my_directory_path="./$my_directory_path" ;;
320 esac
321
322 # While some portion of DIR does not yet exist...
323 while test ! -d "$my_directory_path"; do
324 # ...make a list in topmost first order. Use a colon delimited
325 # list incase some portion of path contains whitespace.
326 my_dir_list="$my_directory_path:$my_dir_list"
327
328 # If the last portion added has no slash in it, the list is done
329 case $my_directory_path in */*) ;; *) break ;; esac
330
331 # ...otherwise throw away the child directory and loop
332 my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
333 done
334 my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
335
336 save_mkdir_p_IFS="$IFS"; IFS=':'
337 for my_dir in $my_dir_list; do
338 IFS="$save_mkdir_p_IFS"
339 # mkdir can fail with a `File exist' error if two processes
340 # try to create one of the directories concurrently. Don't
341 # stop in that case!
342 $MKDIR "$my_dir" 2>/dev/null || :
343 done
344 IFS="$save_mkdir_p_IFS"
345
346 # Bail out if we (or some other process) failed to create a directory.
347 test -d "$my_directory_path" || \
348 func_fatal_error "Failed to create \`$1'"
349 fi
350 }
351
352
353 # func_mktempdir [string]
354 # Make a temporary directory that won't clash with other running
355 # libtool processes, and avoids race conditions if possible. If
356 # given, STRING is the basename for that directory.
357 func_mktempdir ()
358 {
359 my_template="${TMPDIR-/tmp}/${1-$progname}"
360
361 if test "$opt_dry_run" = ":"; then
362 # Return a directory name, but don't create it in dry-run mode
363 my_tmpdir="${my_template}-$$"
364 else
365
366 # If mktemp works, use that first and foremost
367 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
368
369 if test ! -d "$my_tmpdir"; then
370 # Failing that, at least try and use $RANDOM to avoid a race
371 my_tmpdir="${my_template}-${RANDOM-0}$$"
372
373 save_mktempdir_umask=`umask`
374 umask 0077
375 $MKDIR "$my_tmpdir"
376 umask $save_mktempdir_umask
377 fi
378
379 # If we're not in dry-run mode, bomb out on failure
380 test -d "$my_tmpdir" || \
381 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
382 fi
383
384 $ECHO "X$my_tmpdir" | $Xsed
385 }
386
387
388 # func_quote_for_eval arg
389 # Aesthetically quote ARG to be evaled later.
390 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
391 # is double-quoted, suitable for a subsequent eval, whereas
392 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
393 # which are still active within double quotes backslashified.
394 func_quote_for_eval ()
395 {
396 case $1 in
397 *[\\\`\"\$]*)
398 func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
399 *)
400 func_quote_for_eval_unquoted_result="$1" ;;
401 esac
402
403 case $func_quote_for_eval_unquoted_result in
404 # Double-quote args containing shell metacharacters to delay
405 # word splitting, command substitution and and variable
406 # expansion for a subsequent eval.
407 # Many Bourne shells cannot handle close brackets correctly
408 # in scan sets, so we specify it separately.
409 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
410 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
411 ;;
412 *)
413 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
414 esac
415 }
416
417
418 # func_quote_for_expand arg
419 # Aesthetically quote ARG to be evaled later; same as above,
420 # but do not quote variable references.
421 func_quote_for_expand ()
422 {
423 case $1 in
424 *[\\\`\"]*)
425 my_arg=`$ECHO "X$1" | $Xsed \
426 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
427 *)
428 my_arg="$1" ;;
429 esac
430
431 case $my_arg in
432 # Double-quote args containing shell metacharacters to delay
433 # word splitting and command substitution for a subsequent eval.
434 # Many Bourne shells cannot handle close brackets correctly
435 # in scan sets, so we specify it separately.
436 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
437 my_arg="\"$my_arg\""
438 ;;
439 esac
440
441 func_quote_for_expand_result="$my_arg"
442 }
443
444
445 # func_show_eval cmd [fail_exp]
446 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
447 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
448 # is given, then evaluate it.
449 func_show_eval ()
450 {
451 my_cmd="$1"
452 my_fail_exp="${2-:}"
453
454 ${opt_silent-false} || {
455 func_quote_for_expand "$my_cmd"
456 eval "func_echo $func_quote_for_expand_result"
457 }
458
459 if ${opt_dry_run-false}; then :; else
460 eval "$my_cmd"
461 my_status=$?
462 if test "$my_status" -eq 0; then :; else
463 eval "(exit $my_status); $my_fail_exp"
464 fi
465 fi
466 }
467
468
469 # func_show_eval_locale cmd [fail_exp]
470 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
471 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
472 # is given, then evaluate it. Use the saved locale for evaluation.
473 func_show_eval_locale ()
474 {
475 my_cmd="$1"
476 my_fail_exp="${2-:}"
477
478 ${opt_silent-false} || {
479 func_quote_for_expand "$my_cmd"
480 eval "func_echo $func_quote_for_expand_result"
481 }
482
483 if ${opt_dry_run-false}; then :; else
484 eval "$lt_user_locale
485 $my_cmd"
486 my_status=$?
487 eval "$lt_safe_locale"
488 if test "$my_status" -eq 0; then :; else
489 eval "(exit $my_status); $my_fail_exp"
490 fi
491 fi
492 }
493
494
495
496
497
498 # func_version
499 # Echo version message to standard output and exit.
500 func_version ()
501 {
502 $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
503 s/^# //
504 s/^# *$//
505 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
506 p
507 }' < "$progpath"
508 exit $?
509 }
510
511 # func_usage
512 # Echo short help message to standard output and exit.
513 func_usage ()
514 {
515 $SED -n '/^# Usage:/,/# -h/ {
516 s/^# //
517 s/^# *$//
518 s/\$progname/'$progname'/
519 p
520 }' < "$progpath"
521 $ECHO
522 $ECHO "run \`$progname --help | more' for full usage"
523 exit $?
524 }
525
526 # func_help
527 # Echo long help message to standard output and exit.
528 func_help ()
529 {
530 $SED -n '/^# Usage:/,/# Report bugs to/ {
531 s/^# //
532 s/^# *$//
533 s*\$progname*'$progname'*
534 s*\$host*'"$host"'*
535 s*\$SHELL*'"$SHELL"'*
536 s*\$LTCC*'"$LTCC"'*
537 s*\$LTCFLAGS*'"$LTCFLAGS"'*
538 s*\$LD*'"$LD"'*
539 s/\$with_gnu_ld/'"$with_gnu_ld"'/
540 s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
541 s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
542 p
543 }' < "$progpath"
544 exit $?
545 }
546
547 # func_missing_arg argname
548 # Echo program name prefixed message to standard error and set global
549 # exit_cmd.
550 func_missing_arg ()
551 {
552 func_error "missing argument for $1"
553 exit_cmd=exit
554 }
555
556 exit_cmd=:
557
558
559
560
561
562 # Check that we have a working $ECHO.
563 if test "X$1" = X--no-reexec; then
564 # Discard the --no-reexec flag, and continue.
565 shift
566 elif test "X$1" = X--fallback-echo; then
567 # Avoid inline document here, it may be left over
568 :
569 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
570 # Yippee, $ECHO works!
571 :
572 else
573 # Restart under the correct shell, and then maybe $ECHO will work.
574 exec $SHELL "$progpath" --no-reexec ${1+"$@"}
575 fi
576
577 if test "X$1" = X--fallback-echo; then
578 # used as fallback echo
579 shift
580 cat <<EOF
581 $*
582 EOF
583 exit $EXIT_SUCCESS
584 fi
585
586 magic="%%%MAGIC variable%%%"
587 magic_exe="%%%MAGIC EXE variable%%%"
588
589 # Global variables.
590 # $mode is unset
591 nonopt=
592 execute_dlfiles=
593 preserve_args=
594 lo2o="s/\\.lo\$/.${objext}/"
595 o2lo="s/\\.${objext}\$/.lo/"
596 extracted_archives=
597 extracted_serial=0
598
599 opt_dry_run=false
600 opt_duplicate_deps=false
601 opt_silent=false
602 opt_debug=:
603
604 # If this variable is set in any of the actions, the command in it
605 # will be execed at the end. This prevents here-documents from being
606 # left over by shells.
607 exec_cmd=
608
609 # func_fatal_configuration arg...
610 # Echo program name prefixed message to standard error, followed by
611 # a configuration failure hint, and exit.
612 func_fatal_configuration ()
613 {
614 func_error ${1+"$@"}
615 func_error "See the $PACKAGE documentation for more information."
616 func_fatal_error "Fatal configuration error."
617 }
618
619
620 # func_config
621 # Display the configuration for all the tags in this script.
622 func_config ()
623 {
624 re_begincf='^# ### BEGIN LIBTOOL'
625 re_endcf='^# ### END LIBTOOL'
626
627 # Default configuration.
628 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
629
630 # Now print the configurations for the tags.
631 for tagname in $taglist; do
632 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
633 done
634
635 exit $?
636 }
637
638 # func_features
639 # Display the features supported by this script.
640 func_features ()
641 {
642 $ECHO "host: $host"
643 if test "$build_libtool_libs" = yes; then
644 $ECHO "enable shared libraries"
645 else
646 $ECHO "disable shared libraries"
647 fi
648 if test "$build_old_libs" = yes; then
649 $ECHO "enable static libraries"
650 else
651 $ECHO "disable static libraries"
652 fi
653
654 exit $?
655 }
656
657 # func_enable_tag tagname
658 # Verify that TAGNAME is valid, and either flag an error and exit, or
659 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
660 # variable here.
661 func_enable_tag ()
662 {
663 # Global variable:
664 tagname="$1"
665
666 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
667 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
668 sed_extractcf="/$re_begincf/,/$re_endcf/p"
669
670 # Validate tagname.
671 case $tagname in
672 *[!-_A-Za-z0-9,/]*)
673 func_fatal_error "invalid tag name: $tagname"
674 ;;
675 esac
676
677 # Don't test for the "default" C tag, as we know it's
678 # there but not specially marked.
679 case $tagname in
680 CC) ;;
681 *)
682 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
683 taglist="$taglist $tagname"
684
685 # Evaluate the configuration. Be careful to quote the path
686 # and the sed script, to avoid splitting on whitespace, but
687 # also don't use non-portable quotes within backquotes within
688 # quotes we have to do it in 2 steps:
689 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
690 eval "$extractedcf"
691 else
692 func_error "ignoring unknown tag $tagname"
693 fi
694 ;;
695 esac
696 }
697
698 # Parse options once, thoroughly. This comes as soon as possible in
699 # the script to make things like `libtool --version' happen quickly.
700 {
701
702 # Shorthand for --mode=foo, only valid as the first argument
703 case $1 in
704 clean|clea|cle|cl)
705 shift; set dummy --mode clean ${1+"$@"}; shift
706 ;;
707 compile|compil|compi|comp|com|co|c)
708 shift; set dummy --mode compile ${1+"$@"}; shift
709 ;;
710 execute|execut|execu|exec|exe|ex|e)
711 shift; set dummy --mode execute ${1+"$@"}; shift
712 ;;
713 finish|finis|fini|fin|fi|f)
714 shift; set dummy --mode finish ${1+"$@"}; shift
715 ;;
716 install|instal|insta|inst|ins|in|i)
717 shift; set dummy --mode install ${1+"$@"}; shift
718 ;;
719 link|lin|li|l)
720 shift; set dummy --mode link ${1+"$@"}; shift
721 ;;
722 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
723 shift; set dummy --mode uninstall ${1+"$@"}; shift
724 ;;
725 esac
726
727 # Parse non-mode specific arguments:
728 while test "$#" -gt 0; do
729 opt="$1"
730 shift
731
732 case $opt in
733 --config) func_config ;;
734
735 --debug) preserve_args="$preserve_args $opt"
736 func_echo "enabling shell trace mode"
737 opt_debug='set -x'
738 $opt_debug
739 ;;
740
741 -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
742 execute_dlfiles="$execute_dlfiles $1"
743 shift
744 ;;
745
746 --dry-run | -n) opt_dry_run=: ;;
747 --features) func_features ;;
748 --finish) mode="finish" ;;
749
750 --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
751 case $1 in
752 # Valid mode arguments:
753 clean) ;;
754 compile) ;;
755 execute) ;;
756 finish) ;;
757 install) ;;
758 link) ;;
759 relink) ;;
760 uninstall) ;;
761
762 # Catch anything else as an error
763 *) func_error "invalid argument for $opt"
764 exit_cmd=exit
765 break
766 ;;
767 esac
768
769 mode="$1"
770 shift
771 ;;
772
773 --preserve-dup-deps)
774 opt_duplicate_deps=: ;;
775
776 --quiet|--silent) preserve_args="$preserve_args $opt"
777 opt_silent=:
778 ;;
779
780 --verbose| -v) preserve_args="$preserve_args $opt"
781 opt_silent=false
782 ;;
783
784 --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
785 preserve_args="$preserve_args $opt $1"
786 func_enable_tag "$1" # tagname is set here
787 shift
788 ;;
789
790 # Separate optargs to long options:
791 -dlopen=*|--mode=*|--tag=*)
792 func_opt_split "$opt"
793 set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
794 shift
795 ;;
796
797 -\?|-h) func_usage ;;
798 --help) opt_help=: ;;
799 --version) func_version ;;
800
801 -*) func_fatal_help "unrecognized option \`$opt'" ;;
802
803 *) nonopt="$opt"
804 break
805 ;;
806 esac
807 done
808
809
810 case $host in
811 *cygwin* | *mingw* | *pw32* | *cegcc*)
812 # don't eliminate duplications in $postdeps and $predeps
813 opt_duplicate_compiler_generated_deps=:
814 ;;
815 *)
816 opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
817 ;;
818 esac
819
820 # Having warned about all mis-specified options, bail out if
821 # anything was wrong.
822 $exit_cmd $EXIT_FAILURE
823 }
824
825 # func_check_version_match
826 # Ensure that we are using m4 macros, and libtool script from the same
827 # release of libtool.
828 func_check_version_match ()
829 {
830 if test "$package_revision" != "$macro_revision"; then
831 if test "$VERSION" != "$macro_version"; then
832 if test -z "$macro_version"; then
833 cat >&2 <<_LT_EOF
834 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
835 $progname: definition of this LT_INIT comes from an older release.
836 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
837 $progname: and run autoconf again.
838 _LT_EOF
839 else
840 cat >&2 <<_LT_EOF
841 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
842 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
843 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
844 $progname: and run autoconf again.
845 _LT_EOF
846 fi
847 else
848 cat >&2 <<_LT_EOF
849 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
850 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
851 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
852 $progname: of $PACKAGE $VERSION and run autoconf again.
853 _LT_EOF
854 fi
855
856 exit $EXIT_MISMATCH
857 fi
858 }
859
860
861 ## ----------- ##
862 ## Main. ##
863 ## ----------- ##
864
865 $opt_help || {
866 # Sanity checks first:
867 func_check_version_match
868
869 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
870 func_fatal_configuration "not configured to build any kind of library"
871 fi
872
873 test -z "$mode" && func_fatal_error "error: you must specify a MODE."
874
875
876 # Darwin sucks
877 eval std_shrext=\"$shrext_cmds\"
878
879
880 # Only execute mode is allowed to have -dlopen flags.
881 if test -n "$execute_dlfiles" && test "$mode" != execute; then
882 func_error "unrecognized option \`-dlopen'"
883 $ECHO "$help" 1>&2
884 exit $EXIT_FAILURE
885 fi
886
887 # Change the help message to a mode-specific one.
888 generic_help="$help"
889 help="Try \`$progname --help --mode=$mode' for more information."
890 }
891
892
893 # func_lalib_p file
894 # True iff FILE is a libtool `.la' library or `.lo' object file.
895 # This function is only a basic sanity check; it will hardly flush out
896 # determined imposters.
897 func_lalib_p ()
898 {
899 test -f "$1" &&
900 $SED -e 4q "$1" 2>/dev/null \
901 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
902 }
903
904 # func_lalib_unsafe_p file
905 # True iff FILE is a libtool `.la' library or `.lo' object file.
906 # This function implements the same check as func_lalib_p without
907 # resorting to external programs. To this end, it redirects stdin and
908 # closes it afterwards, without saving the original file descriptor.
909 # As a safety measure, use it only where a negative result would be
910 # fatal anyway. Works if `file' does not exist.
911 func_lalib_unsafe_p ()
912 {
913 lalib_p=no
914 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
915 for lalib_p_l in 1 2 3 4
916 do
917 read lalib_p_line
918 case "$lalib_p_line" in
919 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
920 esac
921 done
922 exec 0<&5 5<&-
923 fi
924 test "$lalib_p" = yes
925 }
926
927 # func_ltwrapper_script_p file
928 # True iff FILE is a libtool wrapper script
929 # This function is only a basic sanity check; it will hardly flush out
930 # determined imposters.
931 func_ltwrapper_script_p ()
932 {
933 func_lalib_p "$1"
934 }
935
936 # func_ltwrapper_executable_p file
937 # True iff FILE is a libtool wrapper executable
938 # This function is only a basic sanity check; it will hardly flush out
939 # determined imposters.
940 func_ltwrapper_executable_p ()
941 {
942 func_ltwrapper_exec_suffix=
943 case $1 in
944 *.exe) ;;
945 *) func_ltwrapper_exec_suffix=.exe ;;
946 esac
947 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
948 }
949
950 # func_ltwrapper_scriptname file
951 # Assumes file is an ltwrapper_executable
952 # uses $file to determine the appropriate filename for a
953 # temporary ltwrapper_script.
954 func_ltwrapper_scriptname ()
955 {
956 func_ltwrapper_scriptname_result=""
957 if func_ltwrapper_executable_p "$1"; then
958 func_dirname_and_basename "$1" "" "."
959 func_stripname '' '.exe' "$func_basename_result"
960 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
961 fi
962 }
963
964 # func_ltwrapper_p file
965 # True iff FILE is a libtool wrapper script or wrapper executable
966 # This function is only a basic sanity check; it will hardly flush out
967 # determined imposters.
968 func_ltwrapper_p ()
969 {
970 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
971 }
972
973
974 # func_execute_cmds commands fail_cmd
975 # Execute tilde-delimited COMMANDS.
976 # If FAIL_CMD is given, eval that upon failure.
977 # FAIL_CMD may read-access the current command in variable CMD!
978 func_execute_cmds ()
979 {
980 $opt_debug
981 save_ifs=$IFS; IFS='~'
982 for cmd in $1; do
983 IFS=$save_ifs
984 eval cmd=\"$cmd\"
985 func_show_eval "$cmd" "${2-:}"
986 done
987 IFS=$save_ifs
988 }
989
990
991 # func_source file
992 # Source FILE, adding directory component if necessary.
993 # Note that it is not necessary on cygwin/mingw to append a dot to
994 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
995 # behavior happens only for exec(3), not for open(2)! Also, sourcing
996 # `FILE.' does not work on cygwin managed mounts.
997 func_source ()
998 {
999 $opt_debug
1000 case $1 in
1001 */* | *\\*) . "$1" ;;
1002 *) . "./$1" ;;
1003 esac
1004 }
1005
1006
1007 # func_infer_tag arg
1008 # Infer tagged configuration to use if any are available and
1009 # if one wasn't chosen via the "--tag" command line option.
1010 # Only attempt this if the compiler in the base compile
1011 # command doesn't match the default compiler.
1012 # arg is usually of the form 'gcc ...'
1013 func_infer_tag ()
1014 {
1015 $opt_debug
1016 if test -n "$available_tags" && test -z "$tagname"; then
1017 CC_quoted=
1018 for arg in $CC; do
1019 func_quote_for_eval "$arg"
1020 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1021 done
1022 case $@ in
1023 # Blanks in the command may have been stripped by the calling shell,
1024 # but not from the CC environment variable when configure was run.
1025 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1026 # Blanks at the start of $base_compile will cause this to fail
1027 # if we don't check for them as well.
1028 *)
1029 for z in $available_tags; do
1030 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1031 # Evaluate the configuration.
1032 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1033 CC_quoted=
1034 for arg in $CC; do
1035 # Double-quote args containing other shell metacharacters.
1036 func_quote_for_eval "$arg"
1037 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1038 done
1039 case "$@ " in
1040 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1041 # The compiler in the base compile command matches
1042 # the one in the tagged configuration.
1043 # Assume this is the tagged configuration we want.
1044 tagname=$z
1045 break
1046 ;;
1047 esac
1048 fi
1049 done
1050 # If $tagname still isn't set, then no tagged configuration
1051 # was found and let the user know that the "--tag" command
1052 # line option must be used.
1053 if test -z "$tagname"; then
1054 func_echo "unable to infer tagged configuration"
1055 func_fatal_error "specify a tag with \`--tag'"
1056 # else
1057 # func_verbose "using $tagname tagged configuration"
1058 fi
1059 ;;
1060 esac
1061 fi
1062 }
1063
1064
1065
1066 # func_write_libtool_object output_name pic_name nonpic_name
1067 # Create a libtool object file (analogous to a ".la" file),
1068 # but don't create it if we're doing a dry run.
1069 func_write_libtool_object ()
1070 {
1071 write_libobj=${1}
1072 if test "$build_libtool_libs" = yes; then
1073 write_lobj=\'${2}\'
1074 else
1075 write_lobj=none
1076 fi
1077
1078 if test "$build_old_libs" = yes; then
1079 write_oldobj=\'${3}\'
1080 else
1081 write_oldobj=none
1082 fi
1083
1084 $opt_dry_run || {
1085 cat >${write_libobj}T <<EOF
1086 # $write_libobj - a libtool object file
1087 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1088 #
1089 # Please DO NOT delete this file!
1090 # It is necessary for linking the library.
1091
1092 # Name of the PIC object.
1093 pic_object=$write_lobj
1094
1095 # Name of the non-PIC object
1096 non_pic_object=$write_oldobj
1097
1098 EOF
1099 $MV "${write_libobj}T" "${write_libobj}"
1100 }
1101 }
1102
1103 # func_mode_compile arg...
1104 func_mode_compile ()
1105 {
1106 $opt_debug
1107 # Get the compilation command and the source file.
1108 base_compile=
1109 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
1110 suppress_opt=yes
1111 suppress_output=
1112 arg_mode=normal
1113 libobj=
1114 later=
1115 pie_flag=
1116
1117 for arg
1118 do
1119 case $arg_mode in
1120 arg )
1121 # do not "continue". Instead, add this to base_compile
1122 lastarg="$arg"
1123 arg_mode=normal
1124 ;;
1125
1126 target )
1127 libobj="$arg"
1128 arg_mode=normal
1129 continue
1130 ;;
1131
1132 normal )
1133 # Accept any command-line options.
1134 case $arg in
1135 -o)
1136 test -n "$libobj" && \
1137 func_fatal_error "you cannot specify \`-o' more than once"
1138 arg_mode=target
1139 continue
1140 ;;
1141
1142 -pie | -fpie | -fPIE)
1143 pie_flag="$pie_flag $arg"
1144 continue
1145 ;;
1146
1147 -shared | -static | -prefer-pic | -prefer-non-pic)
1148 later="$later $arg"
1149 continue
1150 ;;
1151
1152 -no-suppress)
1153 suppress_opt=no
1154 continue
1155 ;;
1156
1157 -Xcompiler)
1158 arg_mode=arg # the next one goes into the "base_compile" arg list
1159 continue # The current "srcfile" will either be retained or
1160 ;; # replaced later. I would guess that would be a bug.
1161
1162 -Wc,*)
1163 func_stripname '-Wc,' '' "$arg"
1164 args=$func_stripname_result
1165 lastarg=
1166 save_ifs="$IFS"; IFS=','
1167 for arg in $args; do
1168 IFS="$save_ifs"
1169 func_quote_for_eval "$arg"
1170 lastarg="$lastarg $func_quote_for_eval_result"
1171 done
1172 IFS="$save_ifs"
1173 func_stripname ' ' '' "$lastarg"
1174 lastarg=$func_stripname_result
1175
1176 # Add the arguments to base_compile.
1177 base_compile="$base_compile $lastarg"
1178 continue
1179 ;;
1180
1181 *)
1182 # Accept the current argument as the source file.
1183 # The previous "srcfile" becomes the current argument.
1184 #
1185 lastarg="$srcfile"
1186 srcfile="$arg"
1187 ;;
1188 esac # case $arg
1189 ;;
1190 esac # case $arg_mode
1191
1192 # Aesthetically quote the previous argument.
1193 func_quote_for_eval "$lastarg"
1194 base_compile="$base_compile $func_quote_for_eval_result"
1195 done # for arg
1196
1197 case $arg_mode in
1198 arg)
1199 func_fatal_error "you must specify an argument for -Xcompile"
1200 ;;
1201 target)
1202 func_fatal_error "you must specify a target with \`-o'"
1203 ;;
1204 *)
1205 # Get the name of the library object.
1206 test -z "$libobj" && {
1207 func_basename "$srcfile"
1208 libobj="$func_basename_result"
1209 }
1210 ;;
1211 esac
1212
1213 # Recognize several different file suffixes.
1214 # If the user specifies -o file.o, it is replaced with file.lo
1215 case $libobj in
1216 *.[cCFSifmso] | \
1217 *.ada | *.adb | *.ads | *.asm | \
1218 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1219 *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1220 func_xform "$libobj"
1221 libobj=$func_xform_result
1222 ;;
1223 esac
1224
1225 case $libobj in
1226 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1227 *)
1228 func_fatal_error "cannot determine name of library object from \`$libobj'"
1229 ;;
1230 esac
1231
1232 func_infer_tag $base_compile
1233
1234 for arg in $later; do
1235 case $arg in
1236 -shared)
1237 test "$build_libtool_libs" != yes && \
1238 func_fatal_configuration "can not build a shared library"
1239 build_old_libs=no
1240 continue
1241 ;;
1242
1243 -static)
1244 build_libtool_libs=no
1245 build_old_libs=yes
1246 continue
1247 ;;
1248
1249 -prefer-pic)
1250 pic_mode=yes
1251 continue
1252 ;;
1253
1254 -prefer-non-pic)
1255 pic_mode=no
1256 continue
1257 ;;
1258 esac
1259 done
1260
1261 func_quote_for_eval "$libobj"
1262 test "X$libobj" != "X$func_quote_for_eval_result" \
1263 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
1264 && func_warning "libobj name \`$libobj' may not contain shell special characters."
1265 func_dirname_and_basename "$obj" "/" ""
1266 objname="$func_basename_result"
1267 xdir="$func_dirname_result"
1268 lobj=${xdir}$objdir/$objname
1269
1270 test -z "$base_compile" && \
1271 func_fatal_help "you must specify a compilation command"
1272
1273 # Delete any leftover library objects.
1274 if test "$build_old_libs" = yes; then
1275 removelist="$obj $lobj $libobj ${libobj}T"
1276 else
1277 removelist="$lobj $libobj ${libobj}T"
1278 fi
1279
1280 # On Cygwin there's no "real" PIC flag so we must build both object types
1281 case $host_os in
1282 cygwin* | mingw* | pw32* | os2* | cegcc*)
1283 pic_mode=default
1284 ;;
1285 esac
1286 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1287 # non-PIC code in shared libraries is not supported
1288 pic_mode=default
1289 fi
1290
1291 # Calculate the filename of the output object if compiler does
1292 # not support -o with -c
1293 if test "$compiler_c_o" = no; then
1294 output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1295 lockfile="$output_obj.lock"
1296 else
1297 output_obj=
1298 need_locks=no
1299 lockfile=
1300 fi
1301
1302 # Lock this critical section if it is needed
1303 # We use this script file to make the link, it avoids creating a new file
1304 if test "$need_locks" = yes; then
1305 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1306 func_echo "Waiting for $lockfile to be removed"
1307 sleep 2
1308 done
1309 elif test "$need_locks" = warn; then
1310 if test -f "$lockfile"; then
1311 $ECHO "\
1312 *** ERROR, $lockfile exists and contains:
1313 `cat $lockfile 2>/dev/null`
1314
1315 This indicates that another process is trying to use the same
1316 temporary object file, and libtool could not work around it because
1317 your compiler does not support \`-c' and \`-o' together. If you
1318 repeat this compilation, it may succeed, by chance, but you had better
1319 avoid parallel builds (make -j) in this platform, or get a better
1320 compiler."
1321
1322 $opt_dry_run || $RM $removelist
1323 exit $EXIT_FAILURE
1324 fi
1325 removelist="$removelist $output_obj"
1326 $ECHO "$srcfile" > "$lockfile"
1327 fi
1328
1329 $opt_dry_run || $RM $removelist
1330 removelist="$removelist $lockfile"
1331 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1332
1333 if test -n "$fix_srcfile_path"; then
1334 eval srcfile=\"$fix_srcfile_path\"
1335 fi
1336 func_quote_for_eval "$srcfile"
1337 qsrcfile=$func_quote_for_eval_result
1338
1339 # Only build a PIC object if we are building libtool libraries.
1340 if test "$build_libtool_libs" = yes; then
1341 # Without this assignment, base_compile gets emptied.
1342 fbsd_hideous_sh_bug=$base_compile
1343
1344 if test "$pic_mode" != no; then
1345 command="$base_compile $qsrcfile $pic_flag"
1346 else
1347 # Don't build PIC code
1348 command="$base_compile $qsrcfile"
1349 fi
1350
1351 func_mkdir_p "$xdir$objdir"
1352
1353 if test -z "$output_obj"; then
1354 # Place PIC objects in $objdir
1355 command="$command -o $lobj"
1356 fi
1357
1358 func_show_eval_locale "$command" \
1359 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1360
1361 if test "$need_locks" = warn &&
1362 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1363 $ECHO "\
1364 *** ERROR, $lockfile contains:
1365 `cat $lockfile 2>/dev/null`
1366
1367 but it should contain:
1368 $srcfile
1369
1370 This indicates that another process is trying to use the same
1371 temporary object file, and libtool could not work around it because
1372 your compiler does not support \`-c' and \`-o' together. If you
1373 repeat this compilation, it may succeed, by chance, but you had better
1374 avoid parallel builds (make -j) in this platform, or get a better
1375 compiler."
1376
1377 $opt_dry_run || $RM $removelist
1378 exit $EXIT_FAILURE
1379 fi
1380
1381 # Just move the object if needed, then go on to compile the next one
1382 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1383 func_show_eval '$MV "$output_obj" "$lobj"' \
1384 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1385 fi
1386
1387 # Allow error messages only from the first compilation.
1388 if test "$suppress_opt" = yes; then
1389 suppress_output=' >/dev/null 2>&1'
1390 fi
1391 fi
1392
1393 # Only build a position-dependent object if we build old libraries.
1394 if test "$build_old_libs" = yes; then
1395 if test "$pic_mode" != yes; then
1396 # Don't build PIC code
1397 command="$base_compile $qsrcfile$pie_flag"
1398 else
1399 command="$base_compile $qsrcfile $pic_flag"
1400 fi
1401 if test "$compiler_c_o" = yes; then
1402 command="$command -o $obj"
1403 fi
1404
1405 # Suppress compiler output if we already did a PIC compilation.
1406 command="$command$suppress_output"
1407 func_show_eval_locale "$command" \
1408 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1409
1410 if test "$need_locks" = warn &&
1411 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1412 $ECHO "\
1413 *** ERROR, $lockfile contains:
1414 `cat $lockfile 2>/dev/null`
1415
1416 but it should contain:
1417 $srcfile
1418
1419 This indicates that another process is trying to use the same
1420 temporary object file, and libtool could not work around it because
1421 your compiler does not support \`-c' and \`-o' together. If you
1422 repeat this compilation, it may succeed, by chance, but you had better
1423 avoid parallel builds (make -j) in this platform, or get a better
1424 compiler."
1425
1426 $opt_dry_run || $RM $removelist
1427 exit $EXIT_FAILURE
1428 fi
1429
1430 # Just move the object if needed
1431 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1432 func_show_eval '$MV "$output_obj" "$obj"' \
1433 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1434 fi
1435 fi
1436
1437 $opt_dry_run || {
1438 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1439
1440 # Unlock the critical section if it was locked
1441 if test "$need_locks" != no; then
1442 removelist=$lockfile
1443 $RM "$lockfile"
1444 fi
1445 }
1446
1447 exit $EXIT_SUCCESS
1448 }
1449
1450 $opt_help || {
1451 test "$mode" = compile && func_mode_compile ${1+"$@"}
1452 }
1453
1454 func_mode_help ()
1455 {
1456 # We need to display help for each of the modes.
1457 case $mode in
1458 "")
1459 # Generic help is extracted from the usage comments
1460 # at the start of this file.
1461 func_help
1462 ;;
1463
1464 clean)
1465 $ECHO \
1466 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1467
1468 Remove files from the build directory.
1469
1470 RM is the name of the program to use to delete files associated with each FILE
1471 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1472 to RM.
1473
1474 If FILE is a libtool library, object or program, all the files associated
1475 with it are deleted. Otherwise, only FILE itself is deleted using RM."
1476 ;;
1477
1478 compile)
1479 $ECHO \
1480 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1481
1482 Compile a source file into a libtool library object.
1483
1484 This mode accepts the following additional options:
1485
1486 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
1487 -no-suppress do not suppress compiler output for multiple passes
1488 -prefer-pic try to building PIC objects only
1489 -prefer-non-pic try to building non-PIC objects only
1490 -shared do not build a \`.o' file suitable for static linking
1491 -static only build a \`.o' file suitable for static linking
1492
1493 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
1494 from the given SOURCEFILE.
1495
1496 The output file name is determined by removing the directory component from
1497 SOURCEFILE, then substituting the C source code suffix \`.c' with the
1498 library object suffix, \`.lo'."
1499 ;;
1500
1501 execute)
1502 $ECHO \
1503 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1504
1505 Automatically set library path, then run a program.
1506
1507 This mode accepts the following additional options:
1508
1509 -dlopen FILE add the directory containing FILE to the library path
1510
1511 This mode sets the library path environment variable according to \`-dlopen'
1512 flags.
1513
1514 If any of the ARGS are libtool executable wrappers, then they are translated
1515 into their corresponding uninstalled binary, and any of their required library
1516 directories are added to the library path.
1517
1518 Then, COMMAND is executed, with ARGS as arguments."
1519 ;;
1520
1521 finish)
1522 $ECHO \
1523 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1524
1525 Complete the installation of libtool libraries.
1526
1527 Each LIBDIR is a directory that contains libtool libraries.
1528
1529 The commands that this mode executes may require superuser privileges. Use
1530 the \`--dry-run' option if you just want to see what would be executed."
1531 ;;
1532
1533 install)
1534 $ECHO \
1535 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1536
1537 Install executables or libraries.
1538
1539 INSTALL-COMMAND is the installation command. The first component should be
1540 either the \`install' or \`cp' program.
1541
1542 The following components of INSTALL-COMMAND are treated specially:
1543
1544 -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation
1545
1546 The rest of the components are interpreted as arguments to that command (only
1547 BSD-compatible install options are recognized)."
1548 ;;
1549
1550 link)
1551 $ECHO \
1552 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1553
1554 Link object files or libraries together to form another library, or to
1555 create an executable program.
1556
1557 LINK-COMMAND is a command using the C compiler that you would use to create
1558 a program from several object files.
1559
1560 The following components of LINK-COMMAND are treated specially:
1561
1562 -all-static do not do any dynamic linking at all
1563 -avoid-version do not add a version suffix if possible
1564 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
1565 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
1566 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1567 -export-symbols SYMFILE
1568 try to export only the symbols listed in SYMFILE
1569 -export-symbols-regex REGEX
1570 try to export only the symbols matching REGEX
1571 -LLIBDIR search LIBDIR for required installed libraries
1572 -lNAME OUTPUT-FILE requires the installed library libNAME
1573 -module build a library that can dlopened
1574 -no-fast-install disable the fast-install mode
1575 -no-install link a not-installable executable
1576 -no-undefined declare that a library does not refer to external symbols
1577 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
1578 -objectlist FILE Use a list of object files found in FILE to specify objects
1579 -precious-files-regex REGEX
1580 don't remove output files matching REGEX
1581 -release RELEASE specify package release information
1582 -rpath LIBDIR the created library will eventually be installed in LIBDIR
1583 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
1584 -shared only do dynamic linking of libtool libraries
1585 -shrext SUFFIX override the standard shared library file extension
1586 -static do not do any dynamic linking of uninstalled libtool libraries
1587 -static-libtool-libs
1588 do not do any dynamic linking of libtool libraries
1589 -version-info CURRENT[:REVISION[:AGE]]
1590 specify library version info [each variable defaults to 0]
1591 -weak LIBNAME declare that the target provides the LIBNAME interface
1592
1593 All other options (arguments beginning with \`-') are ignored.
1594
1595 Every other argument is treated as a filename. Files ending in \`.la' are
1596 treated as uninstalled libtool libraries, other files are standard or library
1597 object files.
1598
1599 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1600 only library objects (\`.lo' files) may be specified, and \`-rpath' is
1601 required, except when creating a convenience library.
1602
1603 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1604 using \`ar' and \`ranlib', or on Windows using \`lib'.
1605
1606 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1607 is created, otherwise an executable program is created."
1608 ;;
1609
1610 uninstall)
1611 $ECHO \
1612 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1613
1614 Remove libraries from an installation directory.
1615
1616 RM is the name of the program to use to delete files associated with each FILE
1617 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1618 to RM.
1619
1620 If FILE is a libtool library, all the files associated with it are deleted.
1621 Otherwise, only FILE itself is deleted using RM."
1622 ;;
1623
1624 *)
1625 func_fatal_help "invalid operation mode \`$mode'"
1626 ;;
1627 esac
1628
1629 $ECHO
1630 $ECHO "Try \`$progname --help' for more information about other modes."
1631
1632 exit $?
1633 }
1634
1635 # Now that we've collected a possible --mode arg, show help if necessary
1636 $opt_help && func_mode_help
1637
1638
1639 # func_mode_execute arg...
1640 func_mode_execute ()
1641 {
1642 $opt_debug
1643 # The first argument is the command name.
1644 cmd="$nonopt"
1645 test -z "$cmd" && \
1646 func_fatal_help "you must specify a COMMAND"
1647
1648 # Handle -dlopen flags immediately.
1649 for file in $execute_dlfiles; do
1650 test -f "$file" \
1651 || func_fatal_help "\`$file' is not a file"
1652
1653 dir=
1654 case $file in
1655 *.la)
1656 # Check to see that this really is a libtool archive.
1657 func_lalib_unsafe_p "$file" \
1658 || func_fatal_help "\`$lib' is not a valid libtool archive"
1659
1660 # Read the libtool library.
1661 dlname=
1662 library_names=
1663 func_source "$file"
1664
1665 # Skip this library if it cannot be dlopened.
1666 if test -z "$dlname"; then
1667 # Warn if it was a shared library.
1668 test -n "$library_names" && \
1669 func_warning "\`$file' was not linked with \`-export-dynamic'"
1670 continue
1671 fi
1672
1673 func_dirname "$file" "" "."
1674 dir="$func_dirname_result"
1675
1676 if test -f "$dir/$objdir/$dlname"; then
1677 dir="$dir/$objdir"
1678 else
1679 if test ! -f "$dir/$dlname"; then
1680 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1681 fi
1682 fi
1683 ;;
1684
1685 *.lo)
1686 # Just add the directory containing the .lo file.
1687 func_dirname "$file" "" "."
1688 dir="$func_dirname_result"
1689 ;;
1690
1691 *)
1692 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1693 continue
1694 ;;
1695 esac
1696
1697 # Get the absolute pathname.
1698 absdir=`cd "$dir" && pwd`
1699 test -n "$absdir" && dir="$absdir"
1700
1701 # Now add the directory to shlibpath_var.
1702 if eval "test -z \"\$$shlibpath_var\""; then
1703 eval "$shlibpath_var=\"\$dir\""
1704 else
1705 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1706 fi
1707 done
1708
1709 # This variable tells wrapper scripts just to set shlibpath_var
1710 # rather than running their programs.
1711 libtool_execute_magic="$magic"
1712
1713 # Check if any of the arguments is a wrapper script.
1714 args=
1715 for file
1716 do
1717 case $file in
1718 -*) ;;
1719 *)
1720 # Do a test to see if this is really a libtool program.
1721 if func_ltwrapper_script_p "$file"; then
1722 func_source "$file"
1723 # Transform arg to wrapped name.
1724 file="$progdir/$program"
1725 elif func_ltwrapper_executable_p "$file"; then
1726 func_ltwrapper_scriptname "$file"
1727 func_source "$func_ltwrapper_scriptname_result"
1728 # Transform arg to wrapped name.
1729 file="$progdir/$program"
1730 fi
1731 ;;
1732 esac
1733 # Quote arguments (to preserve shell metacharacters).
1734 func_quote_for_eval "$file"
1735 args="$args $func_quote_for_eval_result"
1736 done
1737
1738 if test "X$opt_dry_run" = Xfalse; then
1739 if test -n "$shlibpath_var"; then
1740 # Export the shlibpath_var.
1741 eval "export $shlibpath_var"
1742 fi
1743
1744 # Restore saved environment variables
1745 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1746 do
1747 eval "if test \"\${save_$lt_var+set}\" = set; then
1748 $lt_var=\$save_$lt_var; export $lt_var
1749 else
1750 $lt_unset $lt_var
1751 fi"
1752 done
1753
1754 # Now prepare to actually exec the command.
1755 exec_cmd="\$cmd$args"
1756 else
1757 # Display what would be done.
1758 if test -n "$shlibpath_var"; then
1759 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1760 $ECHO "export $shlibpath_var"
1761 fi
1762 $ECHO "$cmd$args"
1763 exit $EXIT_SUCCESS
1764 fi
1765 }
1766
1767 test "$mode" = execute && func_mode_execute ${1+"$@"}
1768
1769
1770 # func_mode_finish arg...
1771 func_mode_finish ()
1772 {
1773 $opt_debug
1774 libdirs="$nonopt"
1775 admincmds=
1776
1777 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1778 for dir
1779 do
1780 libdirs="$libdirs $dir"
1781 done
1782
1783 for libdir in $libdirs; do
1784 if test -n "$finish_cmds"; then
1785 # Do each command in the finish commands.
1786 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1787 '"$cmd"'"'
1788 fi
1789 if test -n "$finish_eval"; then
1790 # Do the single finish_eval.
1791 eval cmds=\"$finish_eval\"
1792 $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1793 $cmds"
1794 fi
1795 done
1796 fi
1797
1798 # Exit here if they wanted silent mode.
1799 $opt_silent && exit $EXIT_SUCCESS
1800
1801 $ECHO "X----------------------------------------------------------------------" | $Xsed
1802 $ECHO "Libraries have been installed in:"
1803 for libdir in $libdirs; do
1804 $ECHO " $libdir"
1805 done
1806 $ECHO
1807 $ECHO "If you ever happen to want to link against installed libraries"
1808 $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1809 $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1810 $ECHO "flag during linking and do at least one of the following:"
1811 if test -n "$shlibpath_var"; then
1812 $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable"
1813 $ECHO " during execution"
1814 fi
1815 if test -n "$runpath_var"; then
1816 $ECHO " - add LIBDIR to the \`$runpath_var' environment variable"
1817 $ECHO " during linking"
1818 fi
1819 if test -n "$hardcode_libdir_flag_spec"; then
1820 libdir=LIBDIR
1821 eval flag=\"$hardcode_libdir_flag_spec\"
1822
1823 $ECHO " - use the \`$flag' linker flag"
1824 fi
1825 if test -n "$admincmds"; then
1826 $ECHO " - have your system administrator run these commands:$admincmds"
1827 fi
1828 if test -f /etc/ld.so.conf; then
1829 $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1830 fi
1831 $ECHO
1832
1833 $ECHO "See any operating system documentation about shared libraries for"
1834 case $host in
1835 solaris2.[6789]|solaris2.1[0-9])
1836 $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1837 $ECHO "pages."
1838 ;;
1839 *)
1840 $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1841 ;;
1842 esac
1843 $ECHO "X----------------------------------------------------------------------" | $Xsed
1844 exit $EXIT_SUCCESS
1845 }
1846
1847 test "$mode" = finish && func_mode_finish ${1+"$@"}
1848
1849
1850 # func_mode_install arg...
1851 func_mode_install ()
1852 {
1853 $opt_debug
1854 # There may be an optional sh(1) argument at the beginning of
1855 # install_prog (especially on Windows NT).
1856 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1857 # Allow the use of GNU shtool's install command.
1858 $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1859 # Aesthetically quote it.
1860 func_quote_for_eval "$nonopt"
1861 install_prog="$func_quote_for_eval_result "
1862 arg=$1
1863 shift
1864 else
1865 install_prog=
1866 arg=$nonopt
1867 fi
1868
1869 # The real first argument should be the name of the installation program.
1870 # Aesthetically quote it.
1871 func_quote_for_eval "$arg"
1872 install_prog="$install_prog$func_quote_for_eval_result"
1873
1874 # We need to accept at least all the BSD install flags.
1875 dest=
1876 files=
1877 opts=
1878 prev=
1879 install_type=
1880 isdir=no
1881 stripme=
1882 for arg
1883 do
1884 if test -n "$dest"; then
1885 files="$files $dest"
1886 dest=$arg
1887 continue
1888 fi
1889
1890 case $arg in
1891 -d) isdir=yes ;;
1892 -f)
1893 case " $install_prog " in
1894 *[\\\ /]cp\ *) ;;
1895 *) prev=$arg ;;
1896 esac
1897 ;;
1898 -g | -m | -o)
1899 prev=$arg
1900 ;;
1901 -s)
1902 stripme=" -s"
1903 continue
1904 ;;
1905 -*)
1906 ;;
1907 *)
1908 # If the previous option needed an argument, then skip it.
1909 if test -n "$prev"; then
1910 prev=
1911 else
1912 dest=$arg
1913 continue
1914 fi
1915 ;;
1916 esac
1917
1918 # Aesthetically quote the argument.
1919 func_quote_for_eval "$arg"
1920 install_prog="$install_prog $func_quote_for_eval_result"
1921 done
1922
1923 test -z "$install_prog" && \
1924 func_fatal_help "you must specify an install program"
1925
1926 test -n "$prev" && \
1927 func_fatal_help "the \`$prev' option requires an argument"
1928
1929 if test -z "$files"; then
1930 if test -z "$dest"; then
1931 func_fatal_help "no file or destination specified"
1932 else
1933 func_fatal_help "you must specify a destination"
1934 fi
1935 fi
1936
1937 # Strip any trailing slash from the destination.
1938 func_stripname '' '/' "$dest"
1939 dest=$func_stripname_result
1940
1941 # Check to see that the destination is a directory.
1942 test -d "$dest" && isdir=yes
1943 if test "$isdir" = yes; then
1944 destdir="$dest"
1945 destname=
1946 else
1947 func_dirname_and_basename "$dest" "" "."
1948 destdir="$func_dirname_result"
1949 destname="$func_basename_result"
1950
1951 # Not a directory, so check to see that there is only one file specified.
1952 set dummy $files; shift
1953 test "$#" -gt 1 && \
1954 func_fatal_help "\`$dest' is not a directory"
1955 fi
1956 case $destdir in
1957 [\\/]* | [A-Za-z]:[\\/]*) ;;
1958 *)
1959 for file in $files; do
1960 case $file in
1961 *.lo) ;;
1962 *)
1963 func_fatal_help "\`$destdir' must be an absolute directory name"
1964 ;;
1965 esac
1966 done
1967 ;;
1968 esac
1969
1970 # This variable tells wrapper scripts just to set variables rather
1971 # than running their programs.
1972 libtool_install_magic="$magic"
1973
1974 staticlibs=
1975 future_libdirs=
1976 current_libdirs=
1977 for file in $files; do
1978
1979 # Do each installation.
1980 case $file in
1981 *.$libext)
1982 # Do the static libraries later.
1983 staticlibs="$staticlibs $file"
1984 ;;
1985
1986 *.la)
1987 # Check to see that this really is a libtool archive.
1988 func_lalib_unsafe_p "$file" \
1989 || func_fatal_help "\`$file' is not a valid libtool archive"
1990
1991 library_names=
1992 old_library=
1993 relink_command=
1994 func_source "$file"
1995
1996 # Add the libdir to current_libdirs if it is the destination.
1997 if test "X$destdir" = "X$libdir"; then
1998 case "$current_libdirs " in
1999 *" $libdir "*) ;;
2000 *) current_libdirs="$current_libdirs $libdir" ;;
2001 esac
2002 else
2003 # Note the libdir as a future libdir.
2004 case "$future_libdirs " in
2005 *" $libdir "*) ;;
2006 *) future_libdirs="$future_libdirs $libdir" ;;
2007 esac
2008 fi
2009
2010 func_dirname "$file" "/" ""
2011 dir="$func_dirname_result"
2012 dir="$dir$objdir"
2013
2014 if test -n "$relink_command"; then
2015 # Determine the prefix the user has applied to our future dir.
2016 inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2017
2018 # Don't allow the user to place us outside of our expected
2019 # location b/c this prevents finding dependent libraries that
2020 # are installed to the same prefix.
2021 # At present, this check doesn't affect windows .dll's that
2022 # are installed into $libdir/../bin (currently, that works fine)
2023 # but it's something to keep an eye on.
2024 test "$inst_prefix_dir" = "$destdir" && \
2025 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2026
2027 if test -n "$inst_prefix_dir"; then
2028 # Stick the inst_prefix_dir data into the link command.
2029 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2030 else
2031 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2032 fi
2033
2034 func_warning "relinking \`$file'"
2035 func_show_eval "$relink_command" \
2036 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2037 fi
2038
2039 # See the names of the shared library.
2040 set dummy $library_names; shift
2041 if test -n "$1"; then
2042 realname="$1"
2043 shift
2044
2045 srcname="$realname"
2046 test -n "$relink_command" && srcname="$realname"T
2047
2048 # Install the shared library and build the symlinks.
2049 func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2050 'exit $?'
2051 tstripme="$stripme"
2052 case $host_os in
2053 cygwin* | mingw* | pw32* | cegcc*)
2054 case $realname in
2055 *.dll.a)
2056 tstripme=""
2057 ;;
2058 esac
2059 ;;
2060 esac
2061 if test -n "$tstripme" && test -n "$striplib"; then
2062 func_show_eval "$striplib $destdir/$realname" 'exit $?'
2063 fi
2064
2065 if test "$#" -gt 0; then
2066 # Delete the old symlinks, and create new ones.
2067 # Try `ln -sf' first, because the `ln' binary might depend on
2068 # the symlink we replace! Solaris /bin/ln does not understand -f,
2069 # so we also need to try rm && ln -s.
2070 for linkname
2071 do
2072 test "$linkname" != "$realname" \
2073 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2074 done
2075 fi
2076
2077 # Do each command in the postinstall commands.
2078 lib="$destdir/$realname"
2079 func_execute_cmds "$postinstall_cmds" 'exit $?'
2080 fi
2081
2082 # Install the pseudo-library for information purposes.
2083 func_basename "$file"
2084 name="$func_basename_result"
2085 instname="$dir/$name"i
2086 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2087
2088 # Maybe install the static library, too.
2089 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2090 ;;
2091
2092 *.lo)
2093 # Install (i.e. copy) a libtool object.
2094
2095 # Figure out destination file name, if it wasn't already specified.
2096 if test -n "$destname"; then
2097 destfile="$destdir/$destname"
2098 else
2099 func_basename "$file"
2100 destfile="$func_basename_result"
2101 destfile="$destdir/$destfile"
2102 fi
2103
2104 # Deduce the name of the destination old-style object file.
2105 case $destfile in
2106 *.lo)
2107 func_lo2o "$destfile"
2108 staticdest=$func_lo2o_result
2109 ;;
2110 *.$objext)
2111 staticdest="$destfile"
2112 destfile=
2113 ;;
2114 *)
2115 func_fatal_help "cannot copy a libtool object to \`$destfile'"
2116 ;;
2117 esac
2118
2119 # Install the libtool object if requested.
2120 test -n "$destfile" && \
2121 func_show_eval "$install_prog $file $destfile" 'exit $?'
2122
2123 # Install the old object if enabled.
2124 if test "$build_old_libs" = yes; then
2125 # Deduce the name of the old-style object file.
2126 func_lo2o "$file"
2127 staticobj=$func_lo2o_result
2128 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2129 fi
2130 exit $EXIT_SUCCESS
2131 ;;
2132
2133 *)
2134 # Figure out destination file name, if it wasn't already specified.
2135 if test -n "$destname"; then
2136 destfile="$destdir/$destname"
2137 else
2138 func_basename "$file"
2139 destfile="$func_basename_result"
2140 destfile="$destdir/$destfile"
2141 fi
2142
2143 # If the file is missing, and there is a .exe on the end, strip it
2144 # because it is most likely a libtool script we actually want to
2145 # install
2146 stripped_ext=""
2147 case $file in
2148 *.exe)
2149 if test ! -f "$file"; then
2150 func_stripname '' '.exe' "$file"
2151 file=$func_stripname_result
2152 stripped_ext=".exe"
2153 fi
2154 ;;
2155 esac
2156
2157 # Do a test to see if this is really a libtool program.
2158 case $host in
2159 *cygwin* | *mingw*)
2160 if func_ltwrapper_executable_p "$file"; then
2161 func_ltwrapper_scriptname "$file"
2162 wrapper=$func_ltwrapper_scriptname_result
2163 else
2164 func_stripname '' '.exe' "$file"
2165 wrapper=$func_stripname_result
2166 fi
2167 ;;
2168 *)
2169 wrapper=$file
2170 ;;
2171 esac
2172 if func_ltwrapper_script_p "$wrapper"; then
2173 notinst_deplibs=
2174 relink_command=
2175
2176 func_source "$wrapper"
2177
2178 # Check the variables that should have been set.
2179 test -z "$generated_by_libtool_version" && \
2180 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2181
2182 finalize=yes
2183 for lib in $notinst_deplibs; do
2184 # Check to see that each library is installed.
2185 libdir=
2186 if test -f "$lib"; then
2187 func_source "$lib"
2188 fi
2189 libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2190 if test -n "$libdir" && test ! -f "$libfile"; then
2191 func_warning "\`$lib' has not been installed in \`$libdir'"
2192 finalize=no
2193 fi
2194 done
2195
2196 relink_command=
2197 func_source "$wrapper"
2198
2199 outputname=
2200 if test "$fast_install" = no && test -n "$relink_command"; then
2201 $opt_dry_run || {
2202 if test "$finalize" = yes; then
2203 tmpdir=`func_mktempdir`
2204 func_basename "$file$stripped_ext"
2205 file="$func_basename_result"
2206 outputname="$tmpdir/$file"
2207 # Replace the output file specification.
2208 relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2209
2210 $opt_silent || {
2211 func_quote_for_expand "$relink_command"
2212 eval "func_echo $func_quote_for_expand_result"
2213 }
2214 if eval "$relink_command"; then :
2215 else
2216 func_error "error: relink \`$file' with the above command before installing it"
2217 $opt_dry_run || ${RM}r "$tmpdir"
2218 continue
2219 fi
2220 file="$outputname"
2221 else
2222 func_warning "cannot relink \`$file'"
2223 fi
2224 }
2225 else
2226 # Install the binary that we compiled earlier.
2227 file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2228 fi
2229 fi
2230
2231 # remove .exe since cygwin /usr/bin/install will append another
2232 # one anyway
2233 case $install_prog,$host in
2234 */usr/bin/install*,*cygwin*)
2235 case $file:$destfile in
2236 *.exe:*.exe)
2237 # this is ok
2238 ;;
2239 *.exe:*)
2240 destfile=$destfile.exe
2241 ;;
2242 *:*.exe)
2243 func_stripname '' '.exe' "$destfile"
2244 destfile=$func_stripname_result
2245 ;;
2246 esac
2247 ;;
2248 esac
2249 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2250 $opt_dry_run || if test -n "$outputname"; then
2251 ${RM}r "$tmpdir"
2252 fi
2253 ;;
2254 esac
2255 done
2256
2257 for file in $staticlibs; do
2258 func_basename "$file"
2259 name="$func_basename_result"
2260
2261 # Set up the ranlib parameters.
2262 oldlib="$destdir/$name"
2263
2264 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2265
2266 if test -n "$stripme" && test -n "$old_striplib"; then
2267 func_show_eval "$old_striplib $oldlib" 'exit $?'
2268 fi
2269
2270 # Do each command in the postinstall commands.
2271 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2272 done
2273
2274 test -n "$future_libdirs" && \
2275 func_warning "remember to run \`$progname --finish$future_libdirs'"
2276
2277 if test -n "$current_libdirs"; then
2278 # Maybe just do a dry run.
2279 $opt_dry_run && current_libdirs=" -n$current_libdirs"
2280 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2281 else
2282 exit $EXIT_SUCCESS
2283 fi
2284 }
2285
2286 test "$mode" = install && func_mode_install ${1+"$@"}
2287
2288
2289 # func_generate_dlsyms outputname originator pic_p
2290 # Extract symbols from dlprefiles and create ${outputname}S.o with
2291 # a dlpreopen symbol table.
2292 func_generate_dlsyms ()
2293 {
2294 $opt_debug
2295 my_outputname="$1"
2296 my_originator="$2"
2297 my_pic_p="${3-no}"
2298 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2299 my_dlsyms=
2300
2301 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2302 if test -n "$NM" && test -n "$global_symbol_pipe"; then
2303 my_dlsyms="${my_outputname}S.c"
2304 else
2305 func_error "not configured to extract global symbols from dlpreopened files"
2306 fi
2307 fi
2308
2309 if test -n "$my_dlsyms"; then
2310 case $my_dlsyms in
2311 "") ;;
2312 *.c)
2313 # Discover the nlist of each of the dlfiles.
2314 nlist="$output_objdir/${my_outputname}.nm"
2315
2316 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2317
2318 # Parse the name list into a source file.
2319 func_verbose "creating $output_objdir/$my_dlsyms"
2320
2321 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2322 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2323 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2324
2325 #ifdef __cplusplus
2326 extern \"C\" {
2327 #endif
2328
2329 /* External symbol declarations for the compiler. */\
2330 "
2331
2332 if test "$dlself" = yes; then
2333 func_verbose "generating symbol list for \`$output'"
2334
2335 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2336
2337 # Add our own program objects to the symbol list.
2338 progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2339 for progfile in $progfiles; do
2340 func_verbose "extracting global C symbols from \`$progfile'"
2341 $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2342 done
2343
2344 if test -n "$exclude_expsyms"; then
2345 $opt_dry_run || {
2346 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2347 eval '$MV "$nlist"T "$nlist"'
2348 }
2349 fi
2350
2351 if test -n "$export_symbols_regex"; then
2352 $opt_dry_run || {
2353 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2354 eval '$MV "$nlist"T "$nlist"'
2355 }
2356 fi
2357
2358 # Prepare the list of exported symbols
2359 if test -z "$export_symbols"; then
2360 export_symbols="$output_objdir/$outputname.exp"
2361 $opt_dry_run || {
2362 $RM $export_symbols
2363 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2364 case $host in
2365 *cygwin* | *mingw* | *cegcc* )
2366 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2367 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2368 ;;
2369 esac
2370 }
2371 else
2372 $opt_dry_run || {
2373 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2374 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2375 eval '$MV "$nlist"T "$nlist"'
2376 case $host in
2377 *cygwin | *mingw* | *cegcc* )
2378 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2379 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2380 ;;
2381 esac
2382 }
2383 fi
2384 fi
2385
2386 for dlprefile in $dlprefiles; do
2387 func_verbose "extracting global C symbols from \`$dlprefile'"
2388 func_basename "$dlprefile"
2389 name="$func_basename_result"
2390 $opt_dry_run || {
2391 eval '$ECHO ": $name " >> "$nlist"'
2392 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2393 }
2394 done
2395
2396 $opt_dry_run || {
2397 # Make sure we have at least an empty file.
2398 test -f "$nlist" || : > "$nlist"
2399
2400 if test -n "$exclude_expsyms"; then
2401 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2402 $MV "$nlist"T "$nlist"
2403 fi
2404
2405 # Try sorting and uniquifying the output.
2406 if $GREP -v "^: " < "$nlist" |
2407 if sort -k 3 </dev/null >/dev/null 2>&1; then
2408 sort -k 3
2409 else
2410 sort +2
2411 fi |
2412 uniq > "$nlist"S; then
2413 :
2414 else
2415 $GREP -v "^: " < "$nlist" > "$nlist"S
2416 fi
2417
2418 if test -f "$nlist"S; then
2419 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2420 else
2421 $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2422 fi
2423
2424 $ECHO >> "$output_objdir/$my_dlsyms" "\
2425
2426 /* The mapping between symbol names and symbols. */
2427 typedef struct {
2428 const char *name;
2429 void *address;
2430 } lt_dlsymlist;
2431 "
2432 case $host in
2433 *cygwin* | *mingw* | *cegcc* )
2434 $ECHO >> "$output_objdir/$my_dlsyms" "\
2435 /* DATA imports from DLLs on WIN32 con't be const, because
2436 runtime relocations are performed -- see ld's documentation
2437 on pseudo-relocs. */"
2438 lt_dlsym_const= ;;
2439 *osf5*)
2440 echo >> "$output_objdir/$my_dlsyms" "\
2441 /* This system does not cope well with relocations in const data */"
2442 lt_dlsym_const= ;;
2443 *)
2444 lt_dlsym_const=const ;;
2445 esac
2446
2447 $ECHO >> "$output_objdir/$my_dlsyms" "\
2448 extern $lt_dlsym_const lt_dlsymlist
2449 lt_${my_prefix}_LTX_preloaded_symbols[];
2450 $lt_dlsym_const lt_dlsymlist
2451 lt_${my_prefix}_LTX_preloaded_symbols[] =
2452 {\
2453 { \"$my_originator\", (void *) 0 },"
2454
2455 case $need_lib_prefix in
2456 no)
2457 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2458 ;;
2459 *)
2460 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2461 ;;
2462 esac
2463 $ECHO >> "$output_objdir/$my_dlsyms" "\
2464 {0, (void *) 0}
2465 };
2466
2467 /* This works around a problem in FreeBSD linker */
2468 #ifdef FREEBSD_WORKAROUND
2469 static const void *lt_preloaded_setup() {
2470 return lt_${my_prefix}_LTX_preloaded_symbols;
2471 }
2472 #endif
2473
2474 #ifdef __cplusplus
2475 }
2476 #endif\
2477 "
2478 } # !$opt_dry_run
2479
2480 pic_flag_for_symtable=
2481 case "$compile_command " in
2482 *" -static "*) ;;
2483 *)
2484 case $host in
2485 # compiling the symbol table file with pic_flag works around
2486 # a FreeBSD bug that causes programs to crash when -lm is
2487 # linked before any other PIC object. But we must not use
2488 # pic_flag when linking with -static. The problem exists in
2489 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2490 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2491 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2492 *-*-hpux*)
2493 pic_flag_for_symtable=" $pic_flag" ;;
2494 *)
2495 if test "X$my_pic_p" != Xno; then
2496 pic_flag_for_symtable=" $pic_flag"
2497 fi
2498 ;;
2499 esac
2500 ;;
2501 esac
2502 symtab_cflags=
2503 for arg in $LTCFLAGS; do
2504 case $arg in
2505 -pie | -fpie | -fPIE) ;;
2506 *) symtab_cflags="$symtab_cflags $arg" ;;
2507 esac
2508 done
2509
2510 # Now compile the dynamic symbol file.
2511 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2512
2513 # Clean up the generated files.
2514 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2515
2516 # Transform the symbol file into the correct name.
2517 symfileobj="$output_objdir/${my_outputname}S.$objext"
2518 case $host in
2519 *cygwin* | *mingw* | *cegcc* )
2520 if test -f "$output_objdir/$my_outputname.def"; then
2521 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2522 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2523 else
2524 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2525 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2526 fi
2527 ;;
2528 *)
2529 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2530 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2531 ;;
2532 esac
2533 ;;
2534 *)
2535 func_fatal_error "unknown suffix for \`$my_dlsyms'"
2536 ;;
2537 esac
2538 else
2539 # We keep going just in case the user didn't refer to
2540 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
2541 # really was required.
2542
2543 # Nullify the symbol file.
2544 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2545 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2546 fi
2547 }
2548
2549 # func_win32_libid arg
2550 # return the library type of file 'arg'
2551 #
2552 # Need a lot of goo to handle *both* DLLs and import libs
2553 # Has to be a shell function in order to 'eat' the argument
2554 # that is supplied when $file_magic_command is called.
2555 func_win32_libid ()
2556 {
2557 $opt_debug
2558 win32_libid_type="unknown"
2559 win32_fileres=`file -L $1 2>/dev/null`
2560 case $win32_fileres in
2561 *ar\ archive\ import\ library*) # definitely import
2562 win32_libid_type="x86 archive import"
2563 ;;
2564 *ar\ archive*) # could be an import, or static
2565 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2566 $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2567 win32_nmres=`eval $NM -f posix -A $1 |
2568 $SED -n -e '
2569 1,100{
2570 / I /{
2571 s,.*,import,
2572 p
2573 q
2574 }
2575 }'`
2576 case $win32_nmres in
2577 import*) win32_libid_type="x86 archive import";;
2578 *) win32_libid_type="x86 archive static";;
2579 esac
2580 fi
2581 ;;
2582 *DLL*)
2583 win32_libid_type="x86 DLL"
2584 ;;
2585 *executable*) # but shell scripts are "executable" too...
2586 case $win32_fileres in
2587 *MS\ Windows\ PE\ Intel*)
2588 win32_libid_type="x86 DLL"
2589 ;;
2590 esac
2591 ;;
2592 esac
2593 $ECHO "$win32_libid_type"
2594 }
2595
2596
2597
2598 # func_extract_an_archive dir oldlib
2599 func_extract_an_archive ()
2600 {
2601 $opt_debug
2602 f_ex_an_ar_dir="$1"; shift
2603 f_ex_an_ar_oldlib="$1"
2604 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2605 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2606 :
2607 else
2608 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2609 fi
2610 }
2611
2612
2613 # func_extract_archives gentop oldlib ...
2614 func_extract_archives ()
2615 {
2616 $opt_debug
2617 my_gentop="$1"; shift
2618 my_oldlibs=${1+"$@"}
2619 my_oldobjs=""
2620 my_xlib=""
2621 my_xabs=""
2622 my_xdir=""
2623
2624 for my_xlib in $my_oldlibs; do
2625 # Extract the objects.
2626 case $my_xlib in
2627 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2628 *) my_xabs=`pwd`"/$my_xlib" ;;
2629 esac
2630 func_basename "$my_xlib"
2631 my_xlib="$func_basename_result"
2632 my_xlib_u=$my_xlib
2633 while :; do
2634 case " $extracted_archives " in
2635 *" $my_xlib_u "*)
2636 func_arith $extracted_serial + 1
2637 extracted_serial=$func_arith_result
2638 my_xlib_u=lt$extracted_serial-$my_xlib ;;
2639 *) break ;;
2640 esac
2641 done
2642 extracted_archives="$extracted_archives $my_xlib_u"
2643 my_xdir="$my_gentop/$my_xlib_u"
2644
2645 func_mkdir_p "$my_xdir"
2646
2647 case $host in
2648 *-darwin*)
2649 func_verbose "Extracting $my_xabs"
2650 # Do not bother doing anything if just a dry run
2651 $opt_dry_run || {
2652 darwin_orig_dir=`pwd`
2653 cd $my_xdir || exit $?
2654 darwin_archive=$my_xabs
2655 darwin_curdir=`pwd`
2656 darwin_base_archive=`basename "$darwin_archive"`
2657 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2658 if test -n "$darwin_arches"; then
2659 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2660 darwin_arch=
2661 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2662 for darwin_arch in $darwin_arches ; do
2663 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2664 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2665 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2666 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2667 cd "$darwin_curdir"
2668 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2669 done # $darwin_arches
2670 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2671 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2672 darwin_file=
2673 darwin_files=
2674 for darwin_file in $darwin_filelist; do
2675 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2676 $LIPO -create -output "$darwin_file" $darwin_files
2677 done # $darwin_filelist
2678 $RM -rf unfat-$$
2679 cd "$darwin_orig_dir"
2680 else
2681 cd $darwin_orig_dir
2682 func_extract_an_archive "$my_xdir" "$my_xabs"
2683 fi # $darwin_arches
2684 } # !$opt_dry_run
2685 ;;
2686 *)
2687 func_extract_an_archive "$my_xdir" "$my_xabs"
2688 ;;
2689 esac
2690 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2691 done
2692
2693 func_extract_archives_result="$my_oldobjs"
2694 }
2695
2696
2697
2698 # func_emit_wrapper_part1 [arg=no]
2699 #
2700 # Emit the first part of a libtool wrapper script on stdout.
2701 # For more information, see the description associated with
2702 # func_emit_wrapper(), below.
2703 func_emit_wrapper_part1 ()
2704 {
2705 func_emit_wrapper_part1_arg1=no
2706 if test -n "$1" ; then
2707 func_emit_wrapper_part1_arg1=$1
2708 fi
2709
2710 $ECHO "\
2711 #! $SHELL
2712
2713 # $output - temporary wrapper script for $objdir/$outputname
2714 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2715 #
2716 # The $output program cannot be directly executed until all the libtool
2717 # libraries that it depends on are installed.
2718 #
2719 # This wrapper script should never be moved out of the build directory.
2720 # If it is, it will not operate correctly.
2721
2722 # Sed substitution that helps us do robust quoting. It backslashifies
2723 # metacharacters that are still active within double-quoted strings.
2724 Xsed='${SED} -e 1s/^X//'
2725 sed_quote_subst='$sed_quote_subst'
2726
2727 # Be Bourne compatible
2728 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2729 emulate sh
2730 NULLCMD=:
2731 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2732 # is contrary to our usage. Disable this feature.
2733 alias -g '\${1+\"\$@\"}'='\"\$@\"'
2734 setopt NO_GLOB_SUBST
2735 else
2736 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2737 fi
2738 BIN_SH=xpg4; export BIN_SH # for Tru64
2739 DUALCASE=1; export DUALCASE # for MKS sh
2740
2741 # The HP-UX ksh and POSIX shell print the target directory to stdout
2742 # if CDPATH is set.
2743 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2744
2745 relink_command=\"$relink_command\"
2746
2747 # This environment variable determines our operation mode.
2748 if test \"\$libtool_install_magic\" = \"$magic\"; then
2749 # install mode needs the following variables:
2750 generated_by_libtool_version='$macro_version'
2751 notinst_deplibs='$notinst_deplibs'
2752 else
2753 # When we are sourced in execute mode, \$file and \$ECHO are already set.
2754 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2755 ECHO=\"$qecho\"
2756 file=\"\$0\"
2757 # Make sure echo works.
2758 if test \"X\$1\" = X--no-reexec; then
2759 # Discard the --no-reexec flag, and continue.
2760 shift
2761 elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2762 # Yippee, \$ECHO works!
2763 :
2764 else
2765 # Restart under the correct shell, and then maybe \$ECHO will work.
2766 exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2767 fi
2768 fi\
2769 "
2770 $ECHO "\
2771
2772 # Find the directory that this script lives in.
2773 thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2774 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2775
2776 # Follow symbolic links until we get to the real thisdir.
2777 file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2778 while test -n \"\$file\"; do
2779 destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2780
2781 # If there was a directory component, then change thisdir.
2782 if test \"x\$destdir\" != \"x\$file\"; then
2783 case \"\$destdir\" in
2784 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2785 *) thisdir=\"\$thisdir/\$destdir\" ;;
2786 esac
2787 fi
2788
2789 file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2790 file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2791 done
2792 "
2793 }
2794 # end: func_emit_wrapper_part1
2795
2796 # func_emit_wrapper_part2 [arg=no]
2797 #
2798 # Emit the second part of a libtool wrapper script on stdout.
2799 # For more information, see the description associated with
2800 # func_emit_wrapper(), below.
2801 func_emit_wrapper_part2 ()
2802 {
2803 func_emit_wrapper_part2_arg1=no
2804 if test -n "$1" ; then
2805 func_emit_wrapper_part2_arg1=$1
2806 fi
2807
2808 $ECHO "\
2809
2810 # Usually 'no', except on cygwin/mingw when embedded into
2811 # the cwrapper.
2812 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2813 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2814 # special case for '.'
2815 if test \"\$thisdir\" = \".\"; then
2816 thisdir=\`pwd\`
2817 fi
2818 # remove .libs from thisdir
2819 case \"\$thisdir\" in
2820 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2821 $objdir ) thisdir=. ;;
2822 esac
2823 fi
2824
2825 # Try to get the absolute directory name.
2826 absdir=\`cd \"\$thisdir\" && pwd\`
2827 test -n \"\$absdir\" && thisdir=\"\$absdir\"
2828 "
2829
2830 if test "$fast_install" = yes; then
2831 $ECHO "\
2832 program=lt-'$outputname'$exeext
2833 progdir=\"\$thisdir/$objdir\"
2834
2835 if test ! -f \"\$progdir/\$program\" ||
2836 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2837 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2838
2839 file=\"\$\$-\$program\"
2840
2841 if test ! -d \"\$progdir\"; then
2842 $MKDIR \"\$progdir\"
2843 else
2844 $RM \"\$progdir/\$file\"
2845 fi"
2846
2847 $ECHO "\
2848
2849 # relink executable if necessary
2850 if test -n \"\$relink_command\"; then
2851 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2852 else
2853 $ECHO \"\$relink_command_output\" >&2
2854 $RM \"\$progdir/\$file\"
2855 exit 1
2856 fi
2857 fi
2858
2859 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2860 { $RM \"\$progdir/\$program\";
2861 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2862 $RM \"\$progdir/\$file\"
2863 fi"
2864 else
2865 $ECHO "\
2866 program='$outputname'
2867 progdir=\"\$thisdir/$objdir\"
2868 "
2869 fi
2870
2871 $ECHO "\
2872
2873 if test -f \"\$progdir/\$program\"; then"
2874
2875 # Export our shlibpath_var if we have one.
2876 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2877 $ECHO "\
2878 # Add our own library path to $shlibpath_var
2879 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2880
2881 # Some systems cannot cope with colon-terminated $shlibpath_var
2882 # The second colon is a workaround for a bug in BeOS R4 sed
2883 $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2884
2885 export $shlibpath_var
2886 "
2887 fi
2888
2889 # fixup the dll searchpath if we need to.
2890 if test -n "$dllsearchpath"; then
2891 $ECHO "\
2892 # Add the dll search path components to the executable PATH
2893 PATH=$dllsearchpath:\$PATH
2894 "
2895 fi
2896
2897 $ECHO "\
2898 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2899 # Run the actual program with our arguments.
2900 "
2901 case $host in
2902 # Backslashes separate directories on plain windows
2903 *-*-mingw | *-*-os2* | *-cegcc*)
2904 $ECHO "\
2905 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2906 "
2907 ;;
2908
2909 *)
2910 $ECHO "\
2911 exec \"\$progdir/\$program\" \${1+\"\$@\"}
2912 "
2913 ;;
2914 esac
2915 $ECHO "\
2916 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2917 exit 1
2918 fi
2919 else
2920 # The program doesn't exist.
2921 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2922 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2923 $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2924 exit 1
2925 fi
2926 fi\
2927 "
2928 }
2929 # end: func_emit_wrapper_part2
2930
2931
2932 # func_emit_wrapper [arg=no]
2933 #
2934 # Emit a libtool wrapper script on stdout.
2935 # Don't directly open a file because we may want to
2936 # incorporate the script contents within a cygwin/mingw
2937 # wrapper executable. Must ONLY be called from within
2938 # func_mode_link because it depends on a number of variables
2939 # set therein.
2940 #
2941 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2942 # variable will take. If 'yes', then the emitted script
2943 # will assume that the directory in which it is stored is
2944 # the $objdir directory. This is a cygwin/mingw-specific
2945 # behavior.
2946 func_emit_wrapper ()
2947 {
2948 func_emit_wrapper_arg1=no
2949 if test -n "$1" ; then
2950 func_emit_wrapper_arg1=$1
2951 fi
2952
2953 # split this up so that func_emit_cwrapperexe_src
2954 # can call each part independently.
2955 func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2956 func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2957 }
2958
2959
2960 # func_to_host_path arg
2961 #
2962 # Convert paths to host format when used with build tools.
2963 # Intended for use with "native" mingw (where libtool itself
2964 # is running under the msys shell), or in the following cross-
2965 # build environments:
2966 # $build $host
2967 # mingw (msys) mingw [e.g. native]
2968 # cygwin mingw
2969 # *nix + wine mingw
2970 # where wine is equipped with the `winepath' executable.
2971 # In the native mingw case, the (msys) shell automatically
2972 # converts paths for any non-msys applications it launches,
2973 # but that facility isn't available from inside the cwrapper.
2974 # Similar accommodations are necessary for $host mingw and
2975 # $build cygwin. Calling this function does no harm for other
2976 # $host/$build combinations not listed above.
2977 #
2978 # ARG is the path (on $build) that should be converted to
2979 # the proper representation for $host. The result is stored
2980 # in $func_to_host_path_result.
2981 func_to_host_path ()
2982 {
2983 func_to_host_path_result="$1"
2984 if test -n "$1" ; then
2985 case $host in
2986 *mingw* )
2987 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
2988 case $build in
2989 *mingw* ) # actually, msys
2990 # awkward: cmd appends spaces to result
2991 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
2992 func_to_host_path_tmp1=`( cmd //c echo "$1" |\
2993 $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
2994 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2995 $SED -e "$lt_sed_naive_backslashify"`
2996 ;;
2997 *cygwin* )
2998 func_to_host_path_tmp1=`cygpath -w "$1"`
2999 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3000 $SED -e "$lt_sed_naive_backslashify"`
3001 ;;
3002 * )
3003 # Unfortunately, winepath does not exit with a non-zero
3004 # error code, so we are forced to check the contents of
3005 # stdout. On the other hand, if the command is not
3006 # found, the shell will set an exit code of 127 and print
3007 # *an error message* to stdout. So we must check for both
3008 # error code of zero AND non-empty stdout, which explains
3009 # the odd construction:
3010 func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3011 if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3012 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3013 $SED -e "$lt_sed_naive_backslashify"`
3014 else
3015 # Allow warning below.
3016 func_to_host_path_result=""
3017 fi
3018 ;;
3019 esac
3020 if test -z "$func_to_host_path_result" ; then
3021 func_error "Could not determine host path corresponding to"
3022 func_error " '$1'"
3023 func_error "Continuing, but uninstalled executables may not work."
3024 # Fallback:
3025 func_to_host_path_result="$1"
3026 fi
3027 ;;
3028 esac
3029 fi
3030 }
3031 # end: func_to_host_path
3032
3033 # func_to_host_pathlist arg
3034 #
3035 # Convert pathlists to host format when used with build tools.
3036 # See func_to_host_path(), above. This function supports the
3037 # following $build/$host combinations (but does no harm for
3038 # combinations not listed here):
3039 # $build $host
3040 # mingw (msys) mingw [e.g. native]
3041 # cygwin mingw
3042 # *nix + wine mingw
3043 #
3044 # Path separators are also converted from $build format to
3045 # $host format. If ARG begins or ends with a path separator
3046 # character, it is preserved (but converted to $host format)
3047 # on output.
3048 #
3049 # ARG is a pathlist (on $build) that should be converted to
3050 # the proper representation on $host. The result is stored
3051 # in $func_to_host_pathlist_result.
3052 func_to_host_pathlist ()
3053 {
3054 func_to_host_pathlist_result="$1"
3055 if test -n "$1" ; then
3056 case $host in
3057 *mingw* )
3058 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3059 # Remove leading and trailing path separator characters from
3060 # ARG. msys behavior is inconsistent here, cygpath turns them
3061 # into '.;' and ';.', and winepath ignores them completely.
3062 func_to_host_pathlist_tmp2="$1"
3063 # Once set for this call, this variable should not be
3064 # reassigned. It is used in tha fallback case.
3065 func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3066 $SED -e 's|^:*||' -e 's|:*$||'`
3067 case $build in
3068 *mingw* ) # Actually, msys.
3069 # Awkward: cmd appends spaces to result.
3070 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3071 func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3072 $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3073 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3074 $SED -e "$lt_sed_naive_backslashify"`
3075 ;;
3076 *cygwin* )
3077 func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3078 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3079 $SED -e "$lt_sed_naive_backslashify"`
3080 ;;
3081 * )
3082 # unfortunately, winepath doesn't convert pathlists
3083 func_to_host_pathlist_result=""
3084 func_to_host_pathlist_oldIFS=$IFS
3085 IFS=:
3086 for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3087 IFS=$func_to_host_pathlist_oldIFS
3088 if test -n "$func_to_host_pathlist_f" ; then
3089 func_to_host_path "$func_to_host_pathlist_f"
3090 if test -n "$func_to_host_path_result" ; then
3091 if test -z "$func_to_host_pathlist_result" ; then
3092 func_to_host_pathlist_result="$func_to_host_path_result"
3093 else
3094 func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3095 fi
3096 fi
3097 fi
3098 IFS=:
3099 done
3100 IFS=$func_to_host_pathlist_oldIFS
3101 ;;
3102 esac
3103 if test -z "$func_to_host_pathlist_result" ; then
3104 func_error "Could not determine the host path(s) corresponding to"
3105 func_error " '$1'"
3106 func_error "Continuing, but uninstalled executables may not work."
3107 # Fallback. This may break if $1 contains DOS-style drive
3108 # specifications. The fix is not to complicate the expression
3109 # below, but for the user to provide a working wine installation
3110 # with winepath so that path translation in the cross-to-mingw
3111 # case works properly.
3112 lt_replace_pathsep_nix_to_dos="s|:|;|g"
3113 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3114 $SED -e "$lt_replace_pathsep_nix_to_dos"`
3115 fi
3116 # Now, add the leading and trailing path separators back
3117 case "$1" in
3118 :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3119 ;;
3120 esac
3121 case "$1" in
3122 *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3123 ;;
3124 esac
3125 ;;
3126 esac
3127 fi
3128 }
3129 # end: func_to_host_pathlist
3130
3131 # func_emit_cwrapperexe_src
3132 # emit the source code for a wrapper executable on stdout
3133 # Must ONLY be called from within func_mode_link because
3134 # it depends on a number of variable set therein.
3135 func_emit_cwrapperexe_src ()
3136 {
3137 cat <<EOF
3138
3139 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3140 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3141
3142 The $output program cannot be directly executed until all the libtool
3143 libraries that it depends on are installed.
3144
3145 This wrapper executable should never be moved out of the build directory.
3146 If it is, it will not operate correctly.
3147
3148 Currently, it simply execs the wrapper *script* "$SHELL $output",
3149 but could eventually absorb all of the scripts functionality and
3150 exec $objdir/$outputname directly.
3151 */
3152 EOF
3153 cat <<"EOF"
3154 #include <stdio.h>
3155 #include <stdlib.h>
3156 #ifdef _MSC_VER
3157 # include <direct.h>
3158 # include <process.h>
3159 # include <io.h>
3160 # define setmode _setmode
3161 #else
3162 # include <unistd.h>
3163 # include <stdint.h>
3164 # ifdef __CYGWIN__
3165 # include <io.h>
3166 # define HAVE_SETENV
3167 # ifdef __STRICT_ANSI__
3168 char *realpath (const char *, char *);
3169 int putenv (char *);
3170 int setenv (const char *, const char *, int);
3171 # endif
3172 # endif
3173 #endif
3174 #include <malloc.h>
3175 #include <stdarg.h>
3176 #include <assert.h>
3177 #include <string.h>
3178 #include <ctype.h>
3179 #include <errno.h>
3180 #include <fcntl.h>
3181 #include <sys/stat.h>
3182
3183 #if defined(PATH_MAX)
3184 # define LT_PATHMAX PATH_MAX
3185 #elif defined(MAXPATHLEN)
3186 # define LT_PATHMAX MAXPATHLEN
3187 #else
3188 # define LT_PATHMAX 1024
3189 #endif
3190
3191 #ifndef S_IXOTH
3192 # define S_IXOTH 0
3193 #endif
3194 #ifndef S_IXGRP
3195 # define S_IXGRP 0
3196 #endif
3197
3198 #ifdef _MSC_VER
3199 # define S_IXUSR _S_IEXEC
3200 # define stat _stat
3201 # ifndef _INTPTR_T_DEFINED
3202 # define intptr_t int
3203 # endif
3204 #endif
3205
3206 #ifndef DIR_SEPARATOR
3207 # define DIR_SEPARATOR '/'
3208 # define PATH_SEPARATOR ':'
3209 #endif
3210
3211 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3212 defined (__OS2__)
3213 # define HAVE_DOS_BASED_FILE_SYSTEM
3214 # define FOPEN_WB "wb"
3215 # ifndef DIR_SEPARATOR_2
3216 # define DIR_SEPARATOR_2 '\\'
3217 # endif
3218 # ifndef PATH_SEPARATOR_2
3219 # define PATH_SEPARATOR_2 ';'
3220 # endif
3221 #endif
3222
3223 #ifndef DIR_SEPARATOR_2
3224 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3225 #else /* DIR_SEPARATOR_2 */
3226 # define IS_DIR_SEPARATOR(ch) \
3227 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3228 #endif /* DIR_SEPARATOR_2 */
3229
3230 #ifndef PATH_SEPARATOR_2
3231 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3232 #else /* PATH_SEPARATOR_2 */
3233 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3234 #endif /* PATH_SEPARATOR_2 */
3235
3236 #ifdef __CYGWIN__
3237 # define FOPEN_WB "wb"
3238 #endif
3239
3240 #ifndef FOPEN_WB
3241 # define FOPEN_WB "w"
3242 #endif
3243 #ifndef _O_BINARY
3244 # define _O_BINARY 0
3245 #endif
3246
3247 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
3248 #define XFREE(stale) do { \
3249 if (stale) { free ((void *) stale); stale = 0; } \
3250 } while (0)
3251
3252 #undef LTWRAPPER_DEBUGPRINTF
3253 #if defined DEBUGWRAPPER
3254 # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3255 static void
3256 ltwrapper_debugprintf (const char *fmt, ...)
3257 {
3258 va_list args;
3259 va_start (args, fmt);
3260 (void) vfprintf (stderr, fmt, args);
3261 va_end (args);
3262 }
3263 #else
3264 # define LTWRAPPER_DEBUGPRINTF(args)
3265 #endif
3266
3267 const char *program_name = NULL;
3268
3269 void *xmalloc (size_t num);
3270 char *xstrdup (const char *string);
3271 const char *base_name (const char *name);
3272 char *find_executable (const char *wrapper);
3273 char *chase_symlinks (const char *pathspec);
3274 int make_executable (const char *path);
3275 int check_executable (const char *path);
3276 char *strendzap (char *str, const char *pat);
3277 void lt_fatal (const char *message, ...);
3278 void lt_setenv (const char *name, const char *value);
3279 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
3280 void lt_opt_process_env_set (const char *arg);
3281 void lt_opt_process_env_prepend (const char *arg);
3282 void lt_opt_process_env_append (const char *arg);
3283 int lt_split_name_value (const char *arg, char** name, char** value);
3284 void lt_update_exe_path (const char *name, const char *value);
3285 void lt_update_lib_path (const char *name, const char *value);
3286
3287 static const char *script_text_part1 =
3288 EOF
3289
3290 func_emit_wrapper_part1 yes |
3291 $SED -e 's/\([\\"]\)/\\\1/g' \
3292 -e 's/^/ "/' -e 's/$/\\n"/'
3293 echo ";"
3294 cat <<EOF
3295
3296 static const char *script_text_part2 =
3297 EOF
3298 func_emit_wrapper_part2 yes |
3299 $SED -e 's/\([\\"]\)/\\\1/g' \
3300 -e 's/^/ "/' -e 's/$/\\n"/'
3301 echo ";"
3302
3303 cat <<EOF
3304 const char * MAGIC_EXE = "$magic_exe";
3305 const char * LIB_PATH_VARNAME = "$shlibpath_var";
3306 EOF
3307
3308 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3309 func_to_host_pathlist "$temp_rpath"
3310 cat <<EOF
3311 const char * LIB_PATH_VALUE = "$func_to_host_pathlist_result";
3312 EOF
3313 else
3314 cat <<"EOF"
3315 const char * LIB_PATH_VALUE = "";
3316 EOF
3317 fi
3318
3319 if test -n "$dllsearchpath"; then
3320 func_to_host_pathlist "$dllsearchpath:"
3321 cat <<EOF
3322 const char * EXE_PATH_VARNAME = "PATH";
3323 const char * EXE_PATH_VALUE = "$func_to_host_pathlist_result";
3324 EOF
3325 else
3326 cat <<"EOF"
3327 const char * EXE_PATH_VARNAME = "";
3328 const char * EXE_PATH_VALUE = "";
3329 EOF
3330 fi
3331
3332 if test "$fast_install" = yes; then
3333 cat <<EOF
3334 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3335 EOF
3336 else
3337 cat <<EOF
3338 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3339 EOF
3340 fi
3341
3342
3343 cat <<"EOF"
3344
3345 #define LTWRAPPER_OPTION_PREFIX "--lt-"
3346 #define LTWRAPPER_OPTION_PREFIX_LENGTH 5
3347
3348 static const size_t opt_prefix_len = LTWRAPPER_OPTION_PREFIX_LENGTH;
3349 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3350
3351 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
3352
3353 static const size_t env_set_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3354 static const char *env_set_opt = LTWRAPPER_OPTION_PREFIX "env-set";
3355 /* argument is putenv-style "foo=bar", value of foo is set to bar */
3356
3357 static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3358 static const char *env_prepend_opt = LTWRAPPER_OPTION_PREFIX "env-prepend";
3359 /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3360
3361 static const size_t env_append_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3362 static const char *env_append_opt = LTWRAPPER_OPTION_PREFIX "env-append";
3363 /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3364
3365 int
3366 main (int argc, char *argv[])
3367 {
3368 char **newargz;
3369 int newargc;
3370 char *tmp_pathspec;
3371 char *actual_cwrapper_path;
3372 char *actual_cwrapper_name;
3373 char *target_name;
3374 char *lt_argv_zero;
3375 intptr_t rval = 127;
3376
3377 int i;
3378
3379 program_name = (char *) xstrdup (base_name (argv[0]));
3380 LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
3381 LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3382
3383 /* very simple arg parsing; don't want to rely on getopt */
3384 for (i = 1; i < argc; i++)
3385 {
3386 if (strcmp (argv[i], dumpscript_opt) == 0)
3387 {
3388 EOF
3389 case "$host" in
3390 *mingw* | *cygwin* )
3391 # make stdout use "unix" line endings
3392 echo " setmode(1,_O_BINARY);"
3393 ;;
3394 esac
3395
3396 cat <<"EOF"
3397 printf ("%s", script_text_part1);
3398 printf ("%s", script_text_part2);
3399 return 0;
3400 }
3401 }
3402
3403 newargz = XMALLOC (char *, argc + 1);
3404 tmp_pathspec = find_executable (argv[0]);
3405 if (tmp_pathspec == NULL)
3406 lt_fatal ("Couldn't find %s", argv[0]);
3407 LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3408 tmp_pathspec));
3409
3410 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3411 LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3412 actual_cwrapper_path));
3413 XFREE (tmp_pathspec);
3414
3415 actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3416 strendzap (actual_cwrapper_path, actual_cwrapper_name);
3417
3418 /* wrapper name transforms */
3419 strendzap (actual_cwrapper_name, ".exe");
3420 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3421 XFREE (actual_cwrapper_name);
3422 actual_cwrapper_name = tmp_pathspec;
3423 tmp_pathspec = 0;
3424
3425 /* target_name transforms -- use actual target program name; might have lt- prefix */
3426 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3427 strendzap (target_name, ".exe");
3428 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3429 XFREE (target_name);
3430 target_name = tmp_pathspec;
3431 tmp_pathspec = 0;
3432
3433 LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3434 target_name));
3435 EOF
3436
3437 cat <<EOF
3438 newargz[0] =
3439 XMALLOC (char, (strlen (actual_cwrapper_path) +
3440 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3441 strcpy (newargz[0], actual_cwrapper_path);
3442 strcat (newargz[0], "$objdir");
3443 strcat (newargz[0], "/");
3444 EOF
3445
3446 cat <<"EOF"
3447 /* stop here, and copy so we don't have to do this twice */
3448 tmp_pathspec = xstrdup (newargz[0]);
3449
3450 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3451 strcat (newargz[0], actual_cwrapper_name);
3452
3453 /* DO want the lt- prefix here if it exists, so use target_name */
3454 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3455 XFREE (tmp_pathspec);
3456 tmp_pathspec = NULL;
3457 EOF
3458
3459 case $host_os in
3460 mingw*)
3461 cat <<"EOF"
3462 {
3463 char* p;
3464 while ((p = strchr (newargz[0], '\\')) != NULL)
3465 {
3466 *p = '/';
3467 }
3468 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3469 {
3470 *p = '/';
3471 }
3472 }
3473 EOF
3474 ;;
3475 esac
3476
3477 cat <<"EOF"
3478 XFREE (target_name);
3479 XFREE (actual_cwrapper_path);
3480 XFREE (actual_cwrapper_name);
3481
3482 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3483 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
3484 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3485 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3486
3487 newargc=0;
3488 for (i = 1; i < argc; i++)
3489 {
3490 if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3491 {
3492 if (argv[i][env_set_opt_len] == '=')
3493 {
3494 const char *p = argv[i] + env_set_opt_len + 1;
3495 lt_opt_process_env_set (p);
3496 }
3497 else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3498 {
3499 lt_opt_process_env_set (argv[++i]); /* don't copy */
3500 }
3501 else
3502 lt_fatal ("%s missing required argument", env_set_opt);
3503 continue;
3504 }
3505 if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3506 {
3507 if (argv[i][env_prepend_opt_len] == '=')
3508 {
3509 const char *p = argv[i] + env_prepend_opt_len + 1;
3510 lt_opt_process_env_prepend (p);
3511 }
3512 else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3513 {
3514 lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3515 }
3516 else
3517 lt_fatal ("%s missing required argument", env_prepend_opt);
3518 continue;
3519 }
3520 if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3521 {
3522 if (argv[i][env_append_opt_len] == '=')
3523 {
3524 const char *p = argv[i] + env_append_opt_len + 1;
3525 lt_opt_process_env_append (p);
3526 }
3527 else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3528 {
3529 lt_opt_process_env_append (argv[++i]); /* don't copy */
3530 }
3531 else
3532 lt_fatal ("%s missing required argument", env_append_opt);
3533 continue;
3534 }
3535 if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3536 {
3537 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3538 namespace, but it is not one of the ones we know about and
3539 have already dealt with, above (inluding dump-script), then
3540 report an error. Otherwise, targets might begin to believe
3541 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3542 namespace. The first time any user complains about this, we'll
3543 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3544 or a configure.ac-settable value.
3545 */
3546 lt_fatal ("Unrecognized option in %s namespace: '%s'",
3547 ltwrapper_option_prefix, argv[i]);
3548 }
3549 /* otherwise ... */
3550 newargz[++newargc] = xstrdup (argv[i]);
3551 }
3552 newargz[++newargc] = NULL;
3553
3554 LTWRAPPER_DEBUGPRINTF (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3555 for (i = 0; i < newargc; i++)
3556 {
3557 LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3558 }
3559
3560 EOF
3561
3562 case $host_os in
3563 mingw*)
3564 cat <<"EOF"
3565 /* execv doesn't actually work on mingw as expected on unix */
3566 rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3567 if (rval == -1)
3568 {
3569 /* failed to start process */
3570 LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3571 return 127;
3572 }
3573 return rval;
3574 EOF
3575 ;;
3576 *)
3577 cat <<"EOF"
3578 execv (lt_argv_zero, newargz);
3579 return rval; /* =127, but avoids unused variable warning */
3580 EOF
3581 ;;
3582 esac
3583
3584 cat <<"EOF"
3585 }
3586
3587 void *
3588 xmalloc (size_t num)
3589 {
3590 void *p = (void *) malloc (num);
3591 if (!p)
3592 lt_fatal ("Memory exhausted");
3593
3594 return p;
3595 }
3596
3597 char *
3598 xstrdup (const char *string)
3599 {
3600 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3601 string) : NULL;
3602 }
3603
3604 const char *
3605 base_name (const char *name)
3606 {
3607 const char *base;
3608
3609 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3610 /* Skip over the disk name in MSDOS pathnames. */
3611 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3612 name += 2;
3613 #endif
3614
3615 for (base = name; *name; name++)
3616 if (IS_DIR_SEPARATOR (*name))
3617 base = name + 1;
3618 return base;
3619 }
3620
3621 int
3622 check_executable (const char *path)
3623 {
3624 struct stat st;
3625
3626 LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
3627 path ? (*path ? path : "EMPTY!") : "NULL!"));
3628 if ((!path) || (!*path))
3629 return 0;
3630
3631 if ((stat (path, &st) >= 0)
3632 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3633 return 1;
3634 else
3635 return 0;
3636 }
3637
3638 int
3639 make_executable (const char *path)
3640 {
3641 int rval = 0;
3642 struct stat st;
3643
3644 LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
3645 path ? (*path ? path : "EMPTY!") : "NULL!"));
3646 if ((!path) || (!*path))
3647 return 0;
3648
3649 if (stat (path, &st) >= 0)
3650 {
3651 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3652 }
3653 return rval;
3654 }
3655
3656 /* Searches for the full path of the wrapper. Returns
3657 newly allocated full path name if found, NULL otherwise
3658 Does not chase symlinks, even on platforms that support them.
3659 */
3660 char *
3661 find_executable (const char *wrapper)
3662 {
3663 int has_slash = 0;
3664 const char *p;
3665 const char *p_next;
3666 /* static buffer for getcwd */
3667 char tmp[LT_PATHMAX + 1];
3668 int tmp_len;
3669 char *concat_name;
3670
3671 LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
3672 wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3673
3674 if ((wrapper == NULL) || (*wrapper == '\0'))
3675 return NULL;
3676
3677 /* Absolute path? */
3678 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3679 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3680 {
3681 concat_name = xstrdup (wrapper);
3682 if (check_executable (concat_name))
3683 return concat_name;
3684 XFREE (concat_name);
3685 }
3686 else
3687 {
3688 #endif
3689 if (IS_DIR_SEPARATOR (wrapper[0]))
3690 {
3691 concat_name = xstrdup (wrapper);
3692 if (check_executable (concat_name))
3693 return concat_name;
3694 XFREE (concat_name);
3695 }
3696 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3697 }
3698 #endif
3699
3700 for (p = wrapper; *p; p++)
3701 if (*p == '/')
3702 {
3703 has_slash = 1;
3704 break;
3705 }
3706 if (!has_slash)
3707 {
3708 /* no slashes; search PATH */
3709 const char *path = getenv ("PATH");
3710 if (path != NULL)
3711 {
3712 for (p = path; *p; p = p_next)
3713 {
3714 const char *q;
3715 size_t p_len;
3716 for (q = p; *q; q++)
3717 if (IS_PATH_SEPARATOR (*q))
3718 break;
3719 p_len = q - p;
3720 p_next = (*q == '\0' ? q : q + 1);
3721 if (p_len == 0)
3722 {
3723 /* empty path: current directory */
3724 if (getcwd (tmp, LT_PATHMAX) == NULL)
3725 lt_fatal ("getcwd failed");
3726 tmp_len = strlen (tmp);
3727 concat_name =
3728 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3729 memcpy (concat_name, tmp, tmp_len);
3730 concat_name[tmp_len] = '/';
3731 strcpy (concat_name + tmp_len + 1, wrapper);
3732 }
3733 else
3734 {
3735 concat_name =
3736 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3737 memcpy (concat_name, p, p_len);
3738 concat_name[p_len] = '/';
3739 strcpy (concat_name + p_len + 1, wrapper);
3740 }
3741 if (check_executable (concat_name))
3742 return concat_name;
3743 XFREE (concat_name);
3744 }
3745 }
3746 /* not found in PATH; assume curdir */
3747 }
3748 /* Relative path | not found in path: prepend cwd */
3749 if (getcwd (tmp, LT_PATHMAX) == NULL)
3750 lt_fatal ("getcwd failed");
3751 tmp_len = strlen (tmp);
3752 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3753 memcpy (concat_name, tmp, tmp_len);
3754 concat_name[tmp_len] = '/';
3755 strcpy (concat_name + tmp_len + 1, wrapper);
3756
3757 if (check_executable (concat_name))
3758 return concat_name;
3759 XFREE (concat_name);
3760 return NULL;
3761 }
3762
3763 char *
3764 chase_symlinks (const char *pathspec)
3765 {
3766 #ifndef S_ISLNK
3767 return xstrdup (pathspec);
3768 #else
3769 char buf[LT_PATHMAX];
3770 struct stat s;
3771 char *tmp_pathspec = xstrdup (pathspec);
3772 char *p;
3773 int has_symlinks = 0;
3774 while (strlen (tmp_pathspec) && !has_symlinks)
3775 {
3776 LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3777 tmp_pathspec));
3778 if (lstat (tmp_pathspec, &s) == 0)
3779 {
3780 if (S_ISLNK (s.st_mode) != 0)
3781 {
3782 has_symlinks = 1;
3783 break;
3784 }
3785
3786 /* search backwards for last DIR_SEPARATOR */
3787 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3788 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3789 p--;
3790 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3791 {
3792 /* no more DIR_SEPARATORS left */
3793 break;
3794 }
3795 *p = '\0';
3796 }
3797 else
3798 {
3799 char *errstr = strerror (errno);
3800 lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3801 }
3802 }
3803 XFREE (tmp_pathspec);
3804
3805 if (!has_symlinks)
3806 {
3807 return xstrdup (pathspec);
3808 }
3809
3810 tmp_pathspec = realpath (pathspec, buf);
3811 if (tmp_pathspec == 0)
3812 {
3813 lt_fatal ("Could not follow symlinks for %s", pathspec);
3814 }
3815 return xstrdup (tmp_pathspec);
3816 #endif
3817 }
3818
3819 char *
3820 strendzap (char *str, const char *pat)
3821 {
3822 size_t len, patlen;
3823
3824 assert (str != NULL);
3825 assert (pat != NULL);
3826
3827 len = strlen (str);
3828 patlen = strlen (pat);
3829
3830 if (patlen <= len)
3831 {
3832 str += len - patlen;
3833 if (strcmp (str, pat) == 0)
3834 *str = '\0';
3835 }
3836 return str;
3837 }
3838
3839 static void
3840 lt_error_core (int exit_status, const char *mode,
3841 const char *message, va_list ap)
3842 {
3843 fprintf (stderr, "%s: %s: ", program_name, mode);
3844 vfprintf (stderr, message, ap);
3845 fprintf (stderr, ".\n");
3846
3847 if (exit_status >= 0)
3848 exit (exit_status);
3849 }
3850
3851 void
3852 lt_fatal (const char *message, ...)
3853 {
3854 va_list ap;
3855 va_start (ap, message);
3856 lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3857 va_end (ap);
3858 }
3859
3860 void
3861 lt_setenv (const char *name, const char *value)
3862 {
3863 LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3864 (name ? name : "<NULL>"),
3865 (value ? value : "<NULL>")));
3866 {
3867 #ifdef HAVE_SETENV
3868 /* always make a copy, for consistency with !HAVE_SETENV */
3869 char *str = xstrdup (value);
3870 setenv (name, str, 1);
3871 #else
3872 int len = strlen (name) + 1 + strlen (value) + 1;
3873 char *str = XMALLOC (char, len);
3874 sprintf (str, "%s=%s", name, value);
3875 if (putenv (str) != EXIT_SUCCESS)
3876 {
3877 XFREE (str);
3878 }
3879 #endif
3880 }
3881 }
3882
3883 char *
3884 lt_extend_str (const char *orig_value, const char *add, int to_end)
3885 {
3886 char *new_value;
3887 if (orig_value && *orig_value)
3888 {
3889 int orig_value_len = strlen (orig_value);
3890 int add_len = strlen (add);
3891 new_value = XMALLOC (char, add_len + orig_value_len + 1);
3892 if (to_end)
3893 {
3894 strcpy (new_value, orig_value);
3895 strcpy (new_value + orig_value_len, add);
3896 }
3897 else
3898 {
3899 strcpy (new_value, add);
3900 strcpy (new_value + add_len, orig_value);
3901 }
3902 }
3903 else
3904 {
3905 new_value = xstrdup (add);
3906 }
3907 return new_value;
3908 }
3909
3910 int
3911 lt_split_name_value (const char *arg, char** name, char** value)
3912 {
3913 const char *p;
3914 int len;
3915 if (!arg || !*arg)
3916 return 1;
3917
3918 p = strchr (arg, (int)'=');
3919
3920 if (!p)
3921 return 1;
3922
3923 *value = xstrdup (++p);
3924
3925 len = strlen (arg) - strlen (*value);
3926 *name = XMALLOC (char, len);
3927 strncpy (*name, arg, len-1);
3928 (*name)[len - 1] = '\0';
3929
3930 return 0;
3931 }
3932
3933 void
3934 lt_opt_process_env_set (const char *arg)
3935 {
3936 char *name = NULL;
3937 char *value = NULL;
3938
3939 if (lt_split_name_value (arg, &name, &value) != 0)
3940 {
3941 XFREE (name);
3942 XFREE (value);
3943 lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3944 }
3945
3946 lt_setenv (name, value);
3947 XFREE (name);
3948 XFREE (value);
3949 }
3950
3951 void
3952 lt_opt_process_env_prepend (const char *arg)
3953 {
3954 char *name = NULL;
3955 char *value = NULL;
3956 char *new_value = NULL;
3957
3958 if (lt_split_name_value (arg, &name, &value) != 0)
3959 {
3960 XFREE (name);
3961 XFREE (value);
3962 lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3963 }
3964
3965 new_value = lt_extend_str (getenv (name), value, 0);
3966 lt_setenv (name, new_value);
3967 XFREE (new_value);
3968 XFREE (name);
3969 XFREE (value);
3970 }
3971
3972 void
3973 lt_opt_process_env_append (const char *arg)
3974 {
3975 char *name = NULL;
3976 char *value = NULL;
3977 char *new_value = NULL;
3978
3979 if (lt_split_name_value (arg, &name, &value) != 0)
3980 {
3981 XFREE (name);
3982 XFREE (value);
3983 lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
3984 }
3985
3986 new_value = lt_extend_str (getenv (name), value, 1);
3987 lt_setenv (name, new_value);
3988 XFREE (new_value);
3989 XFREE (name);
3990 XFREE (value);
3991 }
3992
3993 void
3994 lt_update_exe_path (const char *name, const char *value)
3995 {
3996 LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
3997 (name ? name : "<NULL>"),
3998 (value ? value : "<NULL>")));
3999
4000 if (name && *name && value && *value)
4001 {
4002 char *new_value = lt_extend_str (getenv (name), value, 0);
4003 /* some systems can't cope with a ':'-terminated path #' */
4004 int len = strlen (new_value);
4005 while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4006 {
4007 new_value[len-1] = '\0';
4008 }
4009 lt_setenv (name, new_value);
4010 XFREE (new_value);
4011 }
4012 }
4013
4014 void
4015 lt_update_lib_path (const char *name, const char *value)
4016 {
4017 LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4018 (name ? name : "<NULL>"),
4019 (value ? value : "<NULL>")));
4020
4021 if (name && *name && value && *value)
4022 {
4023 char *new_value = lt_extend_str (getenv (name), value, 0);
4024 lt_setenv (name, new_value);
4025 XFREE (new_value);
4026 }
4027 }
4028
4029
4030 EOF
4031 }
4032 # end: func_emit_cwrapperexe_src
4033
4034 # func_mode_link arg...
4035 func_mode_link ()
4036 {
4037 $opt_debug
4038 case $host in
4039 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4040 # It is impossible to link a dll without this setting, and
4041 # we shouldn't force the makefile maintainer to figure out
4042 # which system we are compiling for in order to pass an extra
4043 # flag for every libtool invocation.
4044 # allow_undefined=no
4045
4046 # FIXME: Unfortunately, there are problems with the above when trying
4047 # to make a dll which has undefined symbols, in which case not
4048 # even a static library is built. For now, we need to specify
4049 # -no-undefined on the libtool link line when we can be certain
4050 # that all symbols are satisfied, otherwise we get a static library.
4051 allow_undefined=yes
4052 ;;
4053 *)
4054 allow_undefined=yes
4055 ;;
4056 esac
4057 libtool_args=$nonopt
4058 base_compile="$nonopt $@"
4059 compile_command=$nonopt
4060 finalize_command=$nonopt
4061
4062 compile_rpath=
4063 finalize_rpath=
4064 compile_shlibpath=
4065 finalize_shlibpath=
4066 convenience=
4067 old_convenience=
4068 deplibs=
4069 old_deplibs=
4070 compiler_flags=
4071 linker_flags=
4072 dllsearchpath=
4073 lib_search_path=`pwd`
4074 inst_prefix_dir=
4075 new_inherited_linker_flags=
4076
4077 avoid_version=no
4078 dlfiles=
4079 dlprefiles=
4080 dlself=no
4081 export_dynamic=no
4082 export_symbols=
4083 export_symbols_regex=
4084 generated=
4085 libobjs=
4086 ltlibs=
4087 module=no
4088 no_install=no
4089 objs=
4090 non_pic_objects=
4091 precious_files_regex=
4092 prefer_static_libs=no
4093 preload=no
4094 prev=
4095 prevarg=
4096 release=
4097 rpath=
4098 xrpath=
4099 perm_rpath=
4100 temp_rpath=
4101 thread_safe=no
4102 vinfo=
4103 vinfo_number=no
4104 weak_libs=
4105 single_module="${wl}-single_module"
4106 func_infer_tag $base_compile
4107
4108 # We need to know -static, to get the right output filenames.
4109 for arg
4110 do
4111 case $arg in
4112 -shared)
4113 test "$build_libtool_libs" != yes && \
4114 func_fatal_configuration "can not build a shared library"
4115 build_old_libs=no
4116 break
4117 ;;
4118 -all-static | -static | -static-libtool-libs)
4119 case $arg in
4120 -all-static)
4121 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4122 func_warning "complete static linking is impossible in this configuration"
4123 fi
4124 if test -n "$link_static_flag"; then
4125 dlopen_self=$dlopen_self_static
4126 fi
4127 prefer_static_libs=yes
4128 ;;
4129 -static)
4130 if test -z "$pic_flag" && test -n "$link_static_flag"; then
4131 dlopen_self=$dlopen_self_static
4132 fi
4133 prefer_static_libs=built
4134 ;;
4135 -static-libtool-libs)
4136 if test -z "$pic_flag" && test -n "$link_static_flag"; then
4137 dlopen_self=$dlopen_self_static
4138 fi
4139 prefer_static_libs=yes
4140 ;;
4141 esac
4142 build_libtool_libs=no
4143 build_old_libs=yes
4144 break
4145 ;;
4146 esac
4147 done
4148
4149 # See if our shared archives depend on static archives.
4150 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4151
4152 # Go through the arguments, transforming them on the way.
4153 while test "$#" -gt 0; do
4154 arg="$1"
4155 shift
4156 func_quote_for_eval "$arg"
4157 qarg=$func_quote_for_eval_unquoted_result
4158 func_append libtool_args " $func_quote_for_eval_result"
4159
4160 # If the previous option needs an argument, assign it.
4161 if test -n "$prev"; then
4162 case $prev in
4163 output)
4164 func_append compile_command " @OUTPUT@"
4165 func_append finalize_command " @OUTPUT@"
4166 ;;
4167 esac
4168
4169 case $prev in
4170 dlfiles|dlprefiles)
4171 if test "$preload" = no; then
4172 # Add the symbol object into the linking commands.
4173 func_append compile_command " @SYMFILE@"
4174 func_append finalize_command " @SYMFILE@"
4175 preload=yes
4176 fi
4177 case $arg in
4178 *.la | *.lo) ;; # We handle these cases below.
4179 force)
4180 if test "$dlself" = no; then
4181 dlself=needless
4182 export_dynamic=yes
4183 fi
4184 prev=
4185 continue
4186 ;;
4187 self)
4188 if test "$prev" = dlprefiles; then
4189 dlself=yes
4190 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4191 dlself=yes
4192 else
4193 dlself=needless
4194 export_dynamic=yes
4195 fi
4196 prev=
4197 continue
4198 ;;
4199 *)
4200 if test "$prev" = dlfiles; then
4201 dlfiles="$dlfiles $arg"
4202 else
4203 dlprefiles="$dlprefiles $arg"
4204 fi
4205 prev=
4206 continue
4207 ;;
4208 esac
4209 ;;
4210 expsyms)
4211 export_symbols="$arg"
4212 test -f "$arg" \
4213 || func_fatal_error "symbol file \`$arg' does not exist"
4214 prev=
4215 continue
4216 ;;
4217 expsyms_regex)
4218 export_symbols_regex="$arg"
4219 prev=
4220 continue
4221 ;;
4222 framework)
4223 case $host in
4224 *-*-darwin*)
4225 case "$deplibs " in
4226 *" $qarg.ltframework "*) ;;
4227 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4228 ;;
4229 esac
4230 ;;
4231 esac
4232 prev=
4233 continue
4234 ;;
4235 inst_prefix)
4236 inst_prefix_dir="$arg"
4237 prev=
4238 continue
4239 ;;
4240 objectlist)
4241 if test -f "$arg"; then
4242 save_arg=$arg
4243 moreargs=
4244 for fil in `cat "$save_arg"`
4245 do
4246 # moreargs="$moreargs $fil"
4247 arg=$fil
4248 # A libtool-controlled object.
4249
4250 # Check to see that this really is a libtool object.
4251 if func_lalib_unsafe_p "$arg"; then
4252 pic_object=
4253 non_pic_object=
4254
4255 # Read the .lo file
4256 func_source "$arg"
4257
4258 if test -z "$pic_object" ||
4259 test -z "$non_pic_object" ||
4260 test "$pic_object" = none &&
4261 test "$non_pic_object" = none; then
4262 func_fatal_error "cannot find name of object for \`$arg'"
4263 fi
4264
4265 # Extract subdirectory from the argument.
4266 func_dirname "$arg" "/" ""
4267 xdir="$func_dirname_result"
4268
4269 if test "$pic_object" != none; then
4270 # Prepend the subdirectory the object is found in.
4271 pic_object="$xdir$pic_object"
4272
4273 if test "$prev" = dlfiles; then
4274 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4275 dlfiles="$dlfiles $pic_object"
4276 prev=
4277 continue
4278 else
4279 # If libtool objects are unsupported, then we need to preload.
4280 prev=dlprefiles
4281 fi
4282 fi
4283
4284 # CHECK ME: I think I busted this. -Ossama
4285 if test "$prev" = dlprefiles; then
4286 # Preload the old-style object.
4287 dlprefiles="$dlprefiles $pic_object"
4288 prev=
4289 fi
4290
4291 # A PIC object.
4292 func_append libobjs " $pic_object"
4293 arg="$pic_object"
4294 fi
4295
4296 # Non-PIC object.
4297 if test "$non_pic_object" != none; then
4298 # Prepend the subdirectory the object is found in.
4299 non_pic_object="$xdir$non_pic_object"
4300
4301 # A standard non-PIC object
4302 func_append non_pic_objects " $non_pic_object"
4303 if test -z "$pic_object" || test "$pic_object" = none ; then
4304 arg="$non_pic_object"
4305 fi
4306 else
4307 # If the PIC object exists, use it instead.
4308 # $xdir was prepended to $pic_object above.
4309 non_pic_object="$pic_object"
4310 func_append non_pic_objects " $non_pic_object"
4311 fi
4312 else
4313 # Only an error if not doing a dry-run.
4314 if $opt_dry_run; then
4315 # Extract subdirectory from the argument.
4316 func_dirname "$arg" "/" ""
4317 xdir="$func_dirname_result"
4318
4319 func_lo2o "$arg"
4320 pic_object=$xdir$objdir/$func_lo2o_result
4321 non_pic_object=$xdir$func_lo2o_result
4322 func_append libobjs " $pic_object"
4323 func_append non_pic_objects " $non_pic_object"
4324 else
4325 func_fatal_error "\`$arg' is not a valid libtool object"
4326 fi
4327 fi
4328 done
4329 else
4330 func_fatal_error "link input file \`$arg' does not exist"
4331 fi
4332 arg=$save_arg
4333 prev=
4334 continue
4335 ;;
4336 precious_regex)
4337 precious_files_regex="$arg"
4338 prev=
4339 continue
4340 ;;
4341 release)
4342 release="-$arg"
4343 prev=
4344 continue
4345 ;;
4346 rpath | xrpath)
4347 # We need an absolute path.
4348 case $arg in
4349 [\\/]* | [A-Za-z]:[\\/]*) ;;
4350 *)
4351 func_fatal_error "only absolute run-paths are allowed"
4352 ;;
4353 esac
4354 if test "$prev" = rpath; then
4355 case "$rpath " in
4356 *" $arg "*) ;;
4357 *) rpath="$rpath $arg" ;;
4358 esac
4359 else
4360 case "$xrpath " in
4361 *" $arg "*) ;;
4362 *) xrpath="$xrpath $arg" ;;
4363 esac
4364 fi
4365 prev=
4366 continue
4367 ;;
4368 shrext)
4369 shrext_cmds="$arg"
4370 prev=
4371 continue
4372 ;;
4373 weak)
4374 weak_libs="$weak_libs $arg"
4375 prev=
4376 continue
4377 ;;
4378 xcclinker)
4379 linker_flags="$linker_flags $qarg"
4380 compiler_flags="$compiler_flags $qarg"
4381 prev=
4382 func_append compile_command " $qarg"
4383 func_append finalize_command " $qarg"
4384 continue
4385 ;;
4386 xcompiler)
4387 compiler_flags="$compiler_flags $qarg"
4388 prev=
4389 func_append compile_command " $qarg"
4390 func_append finalize_command " $qarg"
4391 continue
4392 ;;
4393 xlinker)
4394 linker_flags="$linker_flags $qarg"
4395 compiler_flags="$compiler_flags $wl$qarg"
4396 prev=
4397 func_append compile_command " $wl$qarg"
4398 func_append finalize_command " $wl$qarg"
4399 continue
4400 ;;
4401 *)
4402 eval "$prev=\"\$arg\""
4403 prev=
4404 continue
4405 ;;
4406 esac
4407 fi # test -n "$prev"
4408
4409 prevarg="$arg"
4410
4411 case $arg in
4412 -all-static)
4413 if test -n "$link_static_flag"; then
4414 # See comment for -static flag below, for more details.
4415 func_append compile_command " $link_static_flag"
4416 func_append finalize_command " $link_static_flag"
4417 fi
4418 continue
4419 ;;
4420
4421 -allow-undefined)
4422 # FIXME: remove this flag sometime in the future.
4423 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4424 ;;
4425
4426 -avoid-version)
4427 avoid_version=yes
4428 continue
4429 ;;
4430
4431 -dlopen)
4432 prev=dlfiles
4433 continue
4434 ;;
4435
4436 -dlpreopen)
4437 prev=dlprefiles
4438 continue
4439 ;;
4440
4441 -export-dynamic)
4442 export_dynamic=yes
4443 continue
4444 ;;
4445
4446 -export-symbols | -export-symbols-regex)
4447 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4448 func_fatal_error "more than one -exported-symbols argument is not allowed"
4449 fi
4450 if test "X$arg" = "X-export-symbols"; then
4451 prev=expsyms
4452 else
4453 prev=expsyms_regex
4454 fi
4455 continue
4456 ;;
4457
4458 -framework)
4459 prev=framework
4460 continue
4461 ;;
4462
4463 -inst-prefix-dir)
4464 prev=inst_prefix
4465 continue
4466 ;;
4467
4468 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4469 # so, if we see these flags be careful not to treat them like -L
4470 -L[A-Z][A-Z]*:*)
4471 case $with_gcc/$host in
4472 no/*-*-irix* | /*-*-irix*)
4473 func_append compile_command " $arg"
4474 func_append finalize_command " $arg"
4475 ;;
4476 esac
4477 continue
4478 ;;
4479
4480 -L*)
4481 func_stripname '-L' '' "$arg"
4482 dir=$func_stripname_result
4483 if test -z "$dir"; then
4484 if test "$#" -gt 0; then
4485 func_fatal_error "require no space between \`-L' and \`$1'"
4486 else
4487 func_fatal_error "need path for \`-L' option"
4488 fi
4489 fi
4490 # We need an absolute path.
4491 case $dir in
4492 [\\/]* | [A-Za-z]:[\\/]*) ;;
4493 *)
4494 absdir=`cd "$dir" && pwd`
4495 test -z "$absdir" && \
4496 func_fatal_error "cannot determine absolute directory name of \`$dir'"
4497 dir="$absdir"
4498 ;;
4499 esac
4500 case "$deplibs " in
4501 *" -L$dir "*) ;;
4502 *)
4503 deplibs="$deplibs -L$dir"
4504 lib_search_path="$lib_search_path $dir"
4505 ;;
4506 esac
4507 case $host in
4508 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4509 testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4510 case :$dllsearchpath: in
4511 *":$dir:"*) ;;
4512 ::) dllsearchpath=$dir;;
4513 *) dllsearchpath="$dllsearchpath:$dir";;
4514 esac
4515 case :$dllsearchpath: in
4516 *":$testbindir:"*) ;;
4517 ::) dllsearchpath=$testbindir;;
4518 *) dllsearchpath="$dllsearchpath:$testbindir";;
4519 esac
4520 ;;
4521 esac
4522 continue
4523 ;;
4524
4525 -l*)
4526 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4527 case $host in
4528 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4529 # These systems don't actually have a C or math library (as such)
4530 continue
4531 ;;
4532 *-*-os2*)
4533 # These systems don't actually have a C library (as such)
4534 test "X$arg" = "X-lc" && continue
4535 ;;
4536 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4537 # Do not include libc due to us having libc/libc_r.
4538 test "X$arg" = "X-lc" && continue
4539 ;;
4540 *-*-rhapsody* | *-*-darwin1.[012])
4541 # Rhapsody C and math libraries are in the System framework
4542 deplibs="$deplibs System.ltframework"
4543 continue
4544 ;;
4545 *-*-sco3.2v5* | *-*-sco5v6*)
4546 # Causes problems with __ctype
4547 test "X$arg" = "X-lc" && continue
4548 ;;
4549 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4550 # Compiler inserts libc in the correct place for threads to work
4551 test "X$arg" = "X-lc" && continue
4552 ;;
4553 esac
4554 elif test "X$arg" = "X-lc_r"; then
4555 case $host in
4556 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4557 # Do not include libc_r directly, use -pthread flag.
4558 continue
4559 ;;
4560 esac
4561 fi
4562 deplibs="$deplibs $arg"
4563 continue
4564 ;;
4565
4566 -module)
4567 module=yes
4568 continue
4569 ;;
4570
4571 # Tru64 UNIX uses -model [arg] to determine the layout of C++
4572 # classes, name mangling, and exception handling.
4573 # Darwin uses the -arch flag to determine output architecture.
4574 -model|-arch|-isysroot)
4575 compiler_flags="$compiler_flags $arg"
4576 func_append compile_command " $arg"
4577 func_append finalize_command " $arg"
4578 prev=xcompiler
4579 continue
4580 ;;
4581
4582 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4583 compiler_flags="$compiler_flags $arg"
4584 func_append compile_command " $arg"
4585 func_append finalize_command " $arg"
4586 case "$new_inherited_linker_flags " in
4587 *" $arg "*) ;;
4588 * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4589 esac
4590 continue
4591 ;;
4592
4593 -multi_module