ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/ltmain.sh
Revision: 4960
Committed: Sun Nov 30 17:50:57 2014 UTC (9 years, 4 months ago) by michael
Content type: text/x-sh
File size: 322647 byte(s)
Log Message:
- libtool 2.4.4

File Contents

# Content
1 #! /bin/sh
2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3 ## by inline-source v2014-01-03.01
4
5 # libtool (GNU libtool) 2.4.4
6 # Provide generalized library-building support services.
7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8
9 # Copyright (C) 1996-2014 Free Software Foundation, Inc.
10 # This is free software; see the source for copying conditions. There is NO
11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 # GNU Libtool is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # As a special exception to the GNU General Public License,
19 # if you distribute this file as part of a program or library that
20 # is built using GNU Libtool, you may include this file under the
21 # same distribution terms that you use for the rest of that program.
22 #
23 # GNU Libtool is distributed in the hope that it will be useful, but
24 # WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 # General Public License for more details.
27 #
28 # You should have received a copy of the GNU General Public License
29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
30
31
32 PROGRAM=libtool
33 PACKAGE=libtool
34 VERSION=2.4.4
35 package_revision=2.4.4
36
37
38 ## ------ ##
39 ## Usage. ##
40 ## ------ ##
41
42 # Run './libtool --help' for help with using this script from the
43 # command line.
44
45
46 ## ------------------------------- ##
47 ## User overridable command paths. ##
48 ## ------------------------------- ##
49
50 # After configure completes, it has a better idea of some of the
51 # shell tools we need than the defaults used by the functions shared
52 # with bootstrap, so set those here where they can still be over-
53 # ridden by the user, but otherwise take precedence.
54
55 : ${AUTOCONF="autoconf"}
56 : ${AUTOMAKE="automake"}
57
58
59 ## -------------------------- ##
60 ## Source external libraries. ##
61 ## -------------------------- ##
62
63 # Much of our low-level functionality needs to be sourced from external
64 # libraries, which are installed to $pkgauxdir.
65
66 # Set a version string for this script.
67 scriptversion=2014-01-03.01; # UTC
68
69 # General shell script boiler plate, and helper functions.
70 # Written by Gary V. Vaughan, 2004
71
72 # Copyright (C) 2004-2014 Free Software Foundation, Inc.
73 # This is free software; see the source for copying conditions. There is NO
74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
75
76 # This program is free software; you can redistribute it and/or modify
77 # it under the terms of the GNU General Public License as published by
78 # the Free Software Foundation; either version 3 of the License, or
79 # (at your option) any later version.
80
81 # As a special exception to the GNU General Public License, if you distribute
82 # this file as part of a program or library that is built using GNU Libtool,
83 # you may include this file under the same distribution terms that you use
84 # for the rest of that program.
85
86 # This program is distributed in the hope that it will be useful,
87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89 # General Public License for more details.
90
91 # You should have received a copy of the GNU General Public License
92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
93
94 # Please report bugs or propose patches to gary@gnu.org.
95
96
97 ## ------ ##
98 ## Usage. ##
99 ## ------ ##
100
101 # Evaluate this file near the top of your script to gain access to
102 # the functions and variables defined here:
103 #
104 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
105 #
106 # If you need to override any of the default environment variable
107 # settings, do that before evaluating this file.
108
109
110 ## -------------------- ##
111 ## Shell normalisation. ##
112 ## -------------------- ##
113
114 # Some shells need a little help to be as Bourne compatible as possible.
115 # Before doing anything else, make sure all that help has been provided!
116
117 DUALCASE=1; export DUALCASE # for MKS sh
118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
119 emulate sh
120 NULLCMD=:
121 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
122 # is contrary to our usage. Disable this feature.
123 alias -g '${1+"$@"}'='"$@"'
124 setopt NO_GLOB_SUBST
125 else
126 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127 fi
128
129 # NLS nuisances: We save the old values in case they are required later.
130 _G_user_locale=
131 _G_safe_locale=
132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
133 do
134 eval "if test set = \"\${$_G_var+set}\"; then
135 save_$_G_var=\$$_G_var
136 $_G_var=C
137 export $_G_var
138 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
140 fi"
141 done
142
143 # CDPATH.
144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145
146 # Make sure IFS has a sensible default
147 sp=' '
148 nl='
149 '
150 IFS="$sp $nl"
151
152 # There are apparently some retarded systems that use ';' as a PATH separator!
153 if test "${PATH_SEPARATOR+set}" != set; then
154 PATH_SEPARATOR=:
155 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
157 PATH_SEPARATOR=';'
158 }
159 fi
160
161
162
163 ## ------------------------- ##
164 ## Locate command utilities. ##
165 ## ------------------------- ##
166
167
168 # func_executable_p FILE
169 # ----------------------
170 # Check that FILE is an executable regular file.
171 func_executable_p ()
172 {
173 test -f "$1" && test -x "$1"
174 }
175
176
177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178 # --------------------------------------------
179 # Search for either a program that responds to --version with output
180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
181 # trying all the directories in PATH with each of the elements of
182 # PROGS_LIST.
183 #
184 # CHECK_FUNC should accept the path to a candidate program, and
185 # set $func_check_prog_result if it truncates its output less than
186 # $_G_path_prog_max characters.
187 func_path_progs ()
188 {
189 _G_progs_list=$1
190 _G_check_func=$2
191 _G_PATH=${3-"$PATH"}
192
193 _G_path_prog_max=0
194 _G_path_prog_found=false
195 _G_save_IFS=$IFS; IFS=$PATH_SEPARATOR
196 for _G_dir in $_G_PATH; do
197 IFS=$_G_save_IFS
198 test -z "$_G_dir" && _G_dir=.
199 for _G_prog_name in $_G_progs_list; do
200 for _exeext in '' .EXE; do
201 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
202 func_executable_p "$_G_path_prog" || continue
203 case `"$_G_path_prog" --version 2>&1` in
204 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205 *) $_G_check_func $_G_path_prog
206 func_path_progs_result=$func_check_prog_result
207 ;;
208 esac
209 $_G_path_prog_found && break 3
210 done
211 done
212 done
213 IFS=$_G_save_IFS
214 test -z "$func_path_progs_result" && {
215 echo "no acceptable sed could be found in \$PATH" >&2
216 exit 1
217 }
218 }
219
220
221 # We want to be able to use the functions in this file before configure
222 # has figured out where the best binaries are kept, which means we have
223 # to search for them ourselves - except when the results are already set
224 # where we skip the searches.
225
226 # Unless the user overrides by setting SED, search the path for either GNU
227 # sed, or the sed that truncates its output the least.
228 test -z "$SED" && {
229 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230 for _G_i in 1 2 3 4 5 6 7; do
231 _G_sed_script=$_G_sed_script$nl$_G_sed_script
232 done
233 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
234 _G_sed_script=
235
236 func_check_prog_sed ()
237 {
238 _G_path_prog=$1
239
240 _G_count=0
241 printf 0123456789 >conftest.in
242 while :
243 do
244 cat conftest.in conftest.in >conftest.tmp
245 mv conftest.tmp conftest.in
246 cp conftest.in conftest.nl
247 echo '' >> conftest.nl
248 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249 diff conftest.out conftest.nl >/dev/null 2>&1 || break
250 _G_count=`expr $_G_count + 1`
251 if test "$_G_count" -gt "$_G_path_prog_max"; then
252 # Best one so far, save it but keep looking for a better one
253 func_check_prog_result=$_G_path_prog
254 _G_path_prog_max=$_G_count
255 fi
256 # 10*(2^10) chars as input seems more than enough
257 test 10 -lt "$_G_count" && break
258 done
259 rm -f conftest.in conftest.tmp conftest.nl conftest.out
260 }
261
262 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
263 rm -f conftest.sed
264 SED=$func_path_progs_result
265 }
266
267
268 # Unless the user overrides by setting GREP, search the path for either GNU
269 # grep, or the grep that truncates its output the least.
270 test -z "$GREP" && {
271 func_check_prog_grep ()
272 {
273 _G_path_prog=$1
274
275 _G_count=0
276 _G_path_prog_max=0
277 printf 0123456789 >conftest.in
278 while :
279 do
280 cat conftest.in conftest.in >conftest.tmp
281 mv conftest.tmp conftest.in
282 cp conftest.in conftest.nl
283 echo 'GREP' >> conftest.nl
284 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285 diff conftest.out conftest.nl >/dev/null 2>&1 || break
286 _G_count=`expr $_G_count + 1`
287 if test "$_G_count" -gt "$_G_path_prog_max"; then
288 # Best one so far, save it but keep looking for a better one
289 func_check_prog_result=$_G_path_prog
290 _G_path_prog_max=$_G_count
291 fi
292 # 10*(2^10) chars as input seems more than enough
293 test 10 -lt "$_G_count" && break
294 done
295 rm -f conftest.in conftest.tmp conftest.nl conftest.out
296 }
297
298 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299 GREP=$func_path_progs_result
300 }
301
302
303 ## ------------------------------- ##
304 ## User overridable command paths. ##
305 ## ------------------------------- ##
306
307 # All uppercase variable names are used for environment variables. These
308 # variables can be overridden by the user before calling a script that
309 # uses them if a suitable command of that name is not already available
310 # in the command search PATH.
311
312 : ${CP="cp -f"}
313 : ${ECHO="printf %s\n"}
314 : ${EGREP="$GREP -E"}
315 : ${FGREP="$GREP -F"}
316 : ${LN_S="ln -s"}
317 : ${MAKE="make"}
318 : ${MKDIR="mkdir"}
319 : ${MV="mv -f"}
320 : ${RM="rm -f"}
321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322
323
324 ## -------------------- ##
325 ## Useful sed snippets. ##
326 ## -------------------- ##
327
328 sed_dirname='s|/[^/]*$||'
329 sed_basename='s|^.*/||'
330
331 # Sed substitution that helps us do robust quoting. It backslashifies
332 # metacharacters that are still active within double-quoted strings.
333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334
335 # Same as above, but do not quote variable references.
336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337
338 # Sed substitution that turns a string into a regex matching for the
339 # string literally.
340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341
342 # Sed substitution that converts a w32 file name or path
343 # that contains forward slashes, into one that contains
344 # (escaped) backslashes. A very naive implementation.
345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
346
347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
348 # were '\'-ed in input to the same. If an odd number of '\' preceded a
349 # '$' in input to sed_double_quote_subst, that '$' was protected from
350 # expansion. Since each input '\' is now two '\'s, look for any number
351 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
352 _G_bs='\\'
353 _G_bs2='\\\\'
354 _G_bs4='\\\\\\\\'
355 _G_dollar='\$'
356 sed_double_backslash="\
357 s/$_G_bs4/&\\
358 /g
359 s/^$_G_bs2$_G_dollar/$_G_bs&/
360 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
361 s/\n//g"
362
363
364 ## ----------------- ##
365 ## Global variables. ##
366 ## ----------------- ##
367
368 # Except for the global variables explicitly listed below, the following
369 # functions in the '^func_' namespace, and the '^require_' namespace
370 # variables initialised in the 'Resource management' section, sourcing
371 # this file will not pollute your global namespace with anything
372 # else. There's no portable way to scope variables in Bourne shell
373 # though, so actually running these functions will sometimes place
374 # results into a variable named after the function, and often use
375 # temporary variables in the '^_G_' namespace. If you are careful to
376 # avoid using those namespaces casually in your sourcing script, things
377 # should continue to work as you expect. And, of course, you can freely
378 # overwrite any of the functions or variables defined here before
379 # calling anything to customize them.
380
381 EXIT_SUCCESS=0
382 EXIT_FAILURE=1
383 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
384 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
385
386 # Allow overriding, eg assuming that you follow the convention of
387 # putting '$debug_cmd' at the start of all your functions, you can get
388 # bash to show function call trace with:
389 #
390 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391 debug_cmd=${debug_cmd-":"}
392 exit_cmd=:
393
394 # By convention, finish your script with:
395 #
396 # exit $exit_status
397 #
398 # so that you can set exit_status to non-zero if you want to indicate
399 # something went wrong during execution without actually bailing out at
400 # the point of failure.
401 exit_status=$EXIT_SUCCESS
402
403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404 # is ksh but when the shell is invoked as "sh" and the current value of
405 # the _XPG environment variable is not equal to 1 (one), the special
406 # positional parameter $0, within a function call, is the name of the
407 # function.
408 progpath=$0
409
410 # The name of this program.
411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
412
413 # Make sure we have an absolute progpath for reexecution:
414 case $progpath in
415 [\\/]*|[A-Za-z]:\\*) ;;
416 *[\\/]*)
417 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418 progdir=`cd "$progdir" && pwd`
419 progpath=$progdir/$progname
420 ;;
421 *)
422 _G_IFS=$IFS
423 IFS=${PATH_SEPARATOR-:}
424 for progdir in $PATH; do
425 IFS=$_G_IFS
426 test -x "$progdir/$progname" && break
427 done
428 IFS=$_G_IFS
429 test -n "$progdir" || progdir=`pwd`
430 progpath=$progdir/$progname
431 ;;
432 esac
433
434
435 ## ----------------- ##
436 ## Standard options. ##
437 ## ----------------- ##
438
439 # The following options affect the operation of the functions defined
440 # below, and should be set appropriately depending on run-time para-
441 # meters passed on the command line.
442
443 opt_dry_run=false
444 opt_quiet=false
445 opt_verbose=false
446
447 # Categories 'all' and 'none' are always available. Append any others
448 # you will pass as the first argument to func_warning from your own
449 # code.
450 warning_categories=
451
452 # By default, display warnings according to 'opt_warning_types'. Set
453 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
454 # treat the next displayed warning as a fatal error.
455 warning_func=func_warn_and_continue
456
457 # Set to 'all' to display all warnings, 'none' to suppress all
458 # warnings, or a space delimited list of some subset of
459 # 'warning_categories' to display only the listed warnings.
460 opt_warning_types=all
461
462
463 ## -------------------- ##
464 ## Resource management. ##
465 ## -------------------- ##
466
467 # This section contains definitions for functions that each ensure a
468 # particular resource (a file, or a non-empty configuration variable for
469 # example) is available, and if appropriate to extract default values
470 # from pertinent package files. Call them using their associated
471 # 'require_*' variable to ensure that they are executed, at most, once.
472 #
473 # It's entirely deliberate that calling these functions can set
474 # variables that don't obey the namespace limitations obeyed by the rest
475 # of this file, in order that that they be as useful as possible to
476 # callers.
477
478
479 # require_term_colors
480 # -------------------
481 # Allow display of bold text on terminals that support it.
482 require_term_colors=func_require_term_colors
483 func_require_term_colors ()
484 {
485 $debug_cmd
486
487 test -t 1 && {
488 # COLORTERM and USE_ANSI_COLORS environment variables take
489 # precedence, because most terminfo databases neglect to describe
490 # whether color sequences are supported.
491 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
492
493 if test 1 = "$USE_ANSI_COLORS"; then
494 # Standard ANSI escape sequences
495 tc_reset=''
496 tc_bold=''; tc_standout=''
497 tc_red=''; tc_green=''
498 tc_blue=''; tc_cyan=''
499 else
500 # Otherwise trust the terminfo database after all.
501 test -n "`tput sgr0 2>/dev/null`" && {
502 tc_reset=`tput sgr0`
503 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
504 tc_standout=$tc_bold
505 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
510 }
511 fi
512 }
513
514 require_term_colors=:
515 }
516
517
518 ## ----------------- ##
519 ## Function library. ##
520 ## ----------------- ##
521
522 # This section contains a variety of useful functions to call in your
523 # scripts. Take note of the portable wrappers for features provided by
524 # some modern shells, which will fall back to slower equivalents on
525 # less featureful shells.
526
527
528 # func_append VAR VALUE
529 # ---------------------
530 # Append VALUE onto the existing contents of VAR.
531
532 # We should try to minimise forks, especially on Windows where they are
533 # unreasonably slow, so skip the feature probes when bash or zsh are
534 # being used:
535 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536 : ${_G_HAVE_ARITH_OP="yes"}
537 : ${_G_HAVE_XSI_OPS="yes"}
538 # The += operator was introduced in bash 3.1
539 case $BASH_VERSION in
540 [12].* | 3.0 | 3.0*) ;;
541 *)
542 : ${_G_HAVE_PLUSEQ_OP="yes"}
543 ;;
544 esac
545 fi
546
547 # _G_HAVE_PLUSEQ_OP
548 # Can be empty, in which case the shell is probed, "yes" if += is
549 # useable or anything else if it does not work.
550 test -z "$_G_HAVE_PLUSEQ_OP" \
551 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552 && _G_HAVE_PLUSEQ_OP=yes
553
554 if test yes = "$_G_HAVE_PLUSEQ_OP"
555 then
556 # This is an XSI compatible shell, allowing a faster implementation...
557 eval 'func_append ()
558 {
559 $debug_cmd
560
561 eval "$1+=\$2"
562 }'
563 else
564 # ...otherwise fall back to using expr, which is often a shell builtin.
565 func_append ()
566 {
567 $debug_cmd
568
569 eval "$1=\$$1\$2"
570 }
571 fi
572
573
574 # func_append_quoted VAR VALUE
575 # ----------------------------
576 # Quote VALUE and append to the end of shell variable VAR, separated
577 # by a space.
578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
579 eval 'func_append_quoted ()
580 {
581 $debug_cmd
582
583 func_quote_for_eval "$2"
584 eval "$1+=\\ \$func_quote_for_eval_result"
585 }'
586 else
587 func_append_quoted ()
588 {
589 $debug_cmd
590
591 func_quote_for_eval "$2"
592 eval "$1=\$$1\\ \$func_quote_for_eval_result"
593 }
594 fi
595
596
597 # func_append_uniq VAR VALUE
598 # --------------------------
599 # Append unique VALUE onto the existing contents of VAR, assuming
600 # entries are delimited by the first character of VALUE. For example:
601 #
602 # func_append_uniq options " --another-option option-argument"
603 #
604 # will only append to $options if " --another-option option-argument "
605 # is not already present somewhere in $options already (note spaces at
606 # each end implied by leading space in second argument).
607 func_append_uniq ()
608 {
609 $debug_cmd
610
611 eval _G_current_value='`$ECHO $'$1'`'
612 _G_delim=`expr "$2" : '\(.\)'`
613
614 case $_G_delim$_G_current_value$_G_delim in
615 *"$2$_G_delim"*) ;;
616 *) func_append "$@" ;;
617 esac
618 }
619
620
621 # func_arith TERM...
622 # ------------------
623 # Set func_arith_result to the result of evaluating TERMs.
624 test -z "$_G_HAVE_ARITH_OP" \
625 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626 && _G_HAVE_ARITH_OP=yes
627
628 if test yes = "$_G_HAVE_ARITH_OP"; then
629 eval 'func_arith ()
630 {
631 $debug_cmd
632
633 func_arith_result=$(( $* ))
634 }'
635 else
636 func_arith ()
637 {
638 $debug_cmd
639
640 func_arith_result=`expr "$@"`
641 }
642 fi
643
644
645 # func_basename FILE
646 # ------------------
647 # Set func_basename_result to FILE with everything up to and including
648 # the last / stripped.
649 if test yes = "$_G_HAVE_XSI_OPS"; then
650 # If this shell supports suffix pattern removal, then use it to avoid
651 # forking. Hide the definitions single quotes in case the shell chokes
652 # on unsupported syntax...
653 _b='func_basename_result=${1##*/}'
654 _d='case $1 in
655 */*) func_dirname_result=${1%/*}$2 ;;
656 * ) func_dirname_result=$3 ;;
657 esac'
658
659 else
660 # ...otherwise fall back to using sed.
661 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
663 if test "X$func_dirname_result" = "X$1"; then
664 func_dirname_result=$3
665 else
666 func_append func_dirname_result "$2"
667 fi'
668 fi
669
670 eval 'func_basename ()
671 {
672 $debug_cmd
673
674 '"$_b"'
675 }'
676
677
678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
679 # -------------------------------------------
680 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
681 # otherwise set result to NONDIR_REPLACEMENT.
682 eval 'func_dirname ()
683 {
684 $debug_cmd
685
686 '"$_d"'
687 }'
688
689
690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691 # --------------------------------------------------------
692 # Perform func_basename and func_dirname in a single function
693 # call:
694 # dirname: Compute the dirname of FILE. If nonempty,
695 # add APPEND to the result, otherwise set result
696 # to NONDIR_REPLACEMENT.
697 # value returned in "$func_dirname_result"
698 # basename: Compute filename of FILE.
699 # value retuned in "$func_basename_result"
700 # For efficiency, we do not delegate to the functions above but instead
701 # duplicate the functionality here.
702 eval 'func_dirname_and_basename ()
703 {
704 $debug_cmd
705
706 '"$_b"'
707 '"$_d"'
708 }'
709
710
711 # func_echo ARG...
712 # ----------------
713 # Echo program name prefixed message.
714 func_echo ()
715 {
716 $debug_cmd
717
718 _G_message=$*
719
720 func_echo_IFS=$IFS
721 IFS=$nl
722 for _G_line in $_G_message; do
723 IFS=$func_echo_IFS
724 $ECHO "$progname: $_G_line"
725 done
726 IFS=$func_echo_IFS
727 }
728
729
730 # func_echo_all ARG...
731 # --------------------
732 # Invoke $ECHO with all args, space-separated.
733 func_echo_all ()
734 {
735 $ECHO "$*"
736 }
737
738
739 # func_echo_infix_1 INFIX ARG...
740 # ------------------------------
741 # Echo program name, followed by INFIX on the first line, with any
742 # additional lines not showing INFIX.
743 func_echo_infix_1 ()
744 {
745 $debug_cmd
746
747 $require_term_colors
748
749 _G_infix=$1; shift
750 _G_indent=$_G_infix
751 _G_prefix="$progname: $_G_infix: "
752 _G_message=$*
753
754 # Strip color escape sequences before counting printable length
755 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
756 do
757 test -n "$_G_tc" && {
758 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
760 }
761 done
762 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
763
764 func_echo_infix_1_IFS=$IFS
765 IFS=$nl
766 for _G_line in $_G_message; do
767 IFS=$func_echo_infix_1_IFS
768 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
769 _G_prefix=$_G_indent
770 done
771 IFS=$func_echo_infix_1_IFS
772 }
773
774
775 # func_error ARG...
776 # -----------------
777 # Echo program name prefixed message to standard error.
778 func_error ()
779 {
780 $debug_cmd
781
782 $require_term_colors
783
784 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
785 }
786
787
788 # func_fatal_error ARG...
789 # -----------------------
790 # Echo program name prefixed message to standard error, and exit.
791 func_fatal_error ()
792 {
793 $debug_cmd
794
795 func_error "$*"
796 exit $EXIT_FAILURE
797 }
798
799
800 # func_grep EXPRESSION FILENAME
801 # -----------------------------
802 # Check whether EXPRESSION matches any line of FILENAME, without output.
803 func_grep ()
804 {
805 $debug_cmd
806
807 $GREP "$1" "$2" >/dev/null 2>&1
808 }
809
810
811 # func_len STRING
812 # ---------------
813 # Set func_len_result to the length of STRING. STRING may not
814 # start with a hyphen.
815 test -z "$_G_HAVE_XSI_OPS" \
816 && (eval 'x=a/b/c;
817 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818 && _G_HAVE_XSI_OPS=yes
819
820 if test yes = "$_G_HAVE_XSI_OPS"; then
821 eval 'func_len ()
822 {
823 $debug_cmd
824
825 func_len_result=${#1}
826 }'
827 else
828 func_len ()
829 {
830 $debug_cmd
831
832 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
833 }
834 fi
835
836
837 # func_mkdir_p DIRECTORY-PATH
838 # ---------------------------
839 # Make sure the entire path to DIRECTORY-PATH is available.
840 func_mkdir_p ()
841 {
842 $debug_cmd
843
844 _G_directory_path=$1
845 _G_dir_list=
846
847 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
848
849 # Protect directory names starting with '-'
850 case $_G_directory_path in
851 -*) _G_directory_path=./$_G_directory_path ;;
852 esac
853
854 # While some portion of DIR does not yet exist...
855 while test ! -d "$_G_directory_path"; do
856 # ...make a list in topmost first order. Use a colon delimited
857 # list incase some portion of path contains whitespace.
858 _G_dir_list=$_G_directory_path:$_G_dir_list
859
860 # If the last portion added has no slash in it, the list is done
861 case $_G_directory_path in */*) ;; *) break ;; esac
862
863 # ...otherwise throw away the child directory and loop
864 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865 done
866 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867
868 func_mkdir_p_IFS=$IFS; IFS=:
869 for _G_dir in $_G_dir_list; do
870 IFS=$func_mkdir_p_IFS
871 # mkdir can fail with a 'File exist' error if two processes
872 # try to create one of the directories concurrently. Don't
873 # stop in that case!
874 $MKDIR "$_G_dir" 2>/dev/null || :
875 done
876 IFS=$func_mkdir_p_IFS
877
878 # Bail out if we (or some other process) failed to create a directory.
879 test -d "$_G_directory_path" || \
880 func_fatal_error "Failed to create '$1'"
881 fi
882 }
883
884
885 # func_mktempdir [BASENAME]
886 # -------------------------
887 # Make a temporary directory that won't clash with other running
888 # libtool processes, and avoids race conditions if possible. If
889 # given, BASENAME is the basename for that directory.
890 func_mktempdir ()
891 {
892 $debug_cmd
893
894 _G_template=${TMPDIR-/tmp}/${1-$progname}
895
896 if test : = "$opt_dry_run"; then
897 # Return a directory name, but don't create it in dry-run mode
898 _G_tmpdir=$_G_template-$$
899 else
900
901 # If mktemp works, use that first and foremost
902 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903
904 if test ! -d "$_G_tmpdir"; then
905 # Failing that, at least try and use $RANDOM to avoid a race
906 _G_tmpdir=$_G_template-${RANDOM-0}$$
907
908 func_mktempdir_umask=`umask`
909 umask 0077
910 $MKDIR "$_G_tmpdir"
911 umask $func_mktempdir_umask
912 fi
913
914 # If we're not in dry-run mode, bomb out on failure
915 test -d "$_G_tmpdir" || \
916 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
917 fi
918
919 $ECHO "$_G_tmpdir"
920 }
921
922
923 # func_normal_abspath PATH
924 # ------------------------
925 # Remove doubled-up and trailing slashes, "." path components,
926 # and cancel out any ".." path components in PATH after making
927 # it an absolute path.
928 func_normal_abspath ()
929 {
930 $debug_cmd
931
932 # These SED scripts presuppose an absolute path with a trailing slash.
933 _G_pathcar='s|^/\([^/]*\).*$|\1|'
934 _G_pathcdr='s|^/[^/]*||'
935 _G_removedotparts=':dotsl
936 s|/\./|/|g
937 t dotsl
938 s|/\.$|/|'
939 _G_collapseslashes='s|/\{1,\}|/|g'
940 _G_finalslash='s|/*$|/|'
941
942 # Start from root dir and reassemble the path.
943 func_normal_abspath_result=
944 func_normal_abspath_tpath=$1
945 func_normal_abspath_altnamespace=
946 case $func_normal_abspath_tpath in
947 "")
948 # Empty path, that just means $cwd.
949 func_stripname '' '/' "`pwd`"
950 func_normal_abspath_result=$func_stripname_result
951 return
952 ;;
953 # The next three entries are used to spot a run of precisely
954 # two leading slashes without using negated character classes;
955 # we take advantage of case's first-match behaviour.
956 ///*)
957 # Unusual form of absolute path, do nothing.
958 ;;
959 //*)
960 # Not necessarily an ordinary path; POSIX reserves leading '//'
961 # and for example Cygwin uses it to access remote file shares
962 # over CIFS/SMB, so we conserve a leading double slash if found.
963 func_normal_abspath_altnamespace=/
964 ;;
965 /*)
966 # Absolute path, do nothing.
967 ;;
968 *)
969 # Relative path, prepend $cwd.
970 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
971 ;;
972 esac
973
974 # Cancel out all the simple stuff to save iterations. We also want
975 # the path to end with a slash for ease of parsing, so make sure
976 # there is one (and only one) here.
977 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
979 while :; do
980 # Processed it all yet?
981 if test / = "$func_normal_abspath_tpath"; then
982 # If we ascended to the root using ".." the result may be empty now.
983 if test -z "$func_normal_abspath_result"; then
984 func_normal_abspath_result=/
985 fi
986 break
987 fi
988 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
989 -e "$_G_pathcar"`
990 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
991 -e "$_G_pathcdr"`
992 # Figure out what to do with it
993 case $func_normal_abspath_tcomponent in
994 "")
995 # Trailing empty path component, ignore it.
996 ;;
997 ..)
998 # Parent dir; strip last assembled component from result.
999 func_dirname "$func_normal_abspath_result"
1000 func_normal_abspath_result=$func_dirname_result
1001 ;;
1002 *)
1003 # Actual path component, append it.
1004 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1005 ;;
1006 esac
1007 done
1008 # Restore leading double-slash if one was found on entry.
1009 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1010 }
1011
1012
1013 # func_notquiet ARG...
1014 # --------------------
1015 # Echo program name prefixed message only when not in quiet mode.
1016 func_notquiet ()
1017 {
1018 $debug_cmd
1019
1020 $opt_quiet || func_echo ${1+"$@"}
1021
1022 # A bug in bash halts the script if the last line of a function
1023 # fails when set -e is in force, so we need another command to
1024 # work around that:
1025 :
1026 }
1027
1028
1029 # func_relative_path SRCDIR DSTDIR
1030 # --------------------------------
1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032 func_relative_path ()
1033 {
1034 $debug_cmd
1035
1036 func_relative_path_result=
1037 func_normal_abspath "$1"
1038 func_relative_path_tlibdir=$func_normal_abspath_result
1039 func_normal_abspath "$2"
1040 func_relative_path_tbindir=$func_normal_abspath_result
1041
1042 # Ascend the tree starting from libdir
1043 while :; do
1044 # check if we have found a prefix of bindir
1045 case $func_relative_path_tbindir in
1046 $func_relative_path_tlibdir)
1047 # found an exact match
1048 func_relative_path_tcancelled=
1049 break
1050 ;;
1051 $func_relative_path_tlibdir*)
1052 # found a matching prefix
1053 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054 func_relative_path_tcancelled=$func_stripname_result
1055 if test -z "$func_relative_path_result"; then
1056 func_relative_path_result=.
1057 fi
1058 break
1059 ;;
1060 *)
1061 func_dirname $func_relative_path_tlibdir
1062 func_relative_path_tlibdir=$func_dirname_result
1063 if test -z "$func_relative_path_tlibdir"; then
1064 # Have to descend all the way to the root!
1065 func_relative_path_result=../$func_relative_path_result
1066 func_relative_path_tcancelled=$func_relative_path_tbindir
1067 break
1068 fi
1069 func_relative_path_result=../$func_relative_path_result
1070 ;;
1071 esac
1072 done
1073
1074 # Now calculate path; take care to avoid doubling-up slashes.
1075 func_stripname '' '/' "$func_relative_path_result"
1076 func_relative_path_result=$func_stripname_result
1077 func_stripname '/' '/' "$func_relative_path_tcancelled"
1078 if test -n "$func_stripname_result"; then
1079 func_append func_relative_path_result "/$func_stripname_result"
1080 fi
1081
1082 # Normalisation. If bindir is libdir, return '.' else relative path.
1083 if test -n "$func_relative_path_result"; then
1084 func_stripname './' '' "$func_relative_path_result"
1085 func_relative_path_result=$func_stripname_result
1086 fi
1087
1088 test -n "$func_relative_path_result" || func_relative_path_result=.
1089
1090 :
1091 }
1092
1093
1094 # func_quote_for_eval ARG...
1095 # --------------------------
1096 # Aesthetically quote ARGs to be evaled later.
1097 # This function returns two values:
1098 # i) func_quote_for_eval_result
1099 # double-quoted, suitable for a subsequent eval
1100 # ii) func_quote_for_eval_unquoted_result
1101 # has all characters that are still active within double
1102 # quotes backslashified.
1103 func_quote_for_eval ()
1104 {
1105 $debug_cmd
1106
1107 func_quote_for_eval_unquoted_result=
1108 func_quote_for_eval_result=
1109 while test 0 -lt $#; do
1110 case $1 in
1111 *[\\\`\"\$]*)
1112 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1113 *)
1114 _G_unquoted_arg=$1 ;;
1115 esac
1116 if test -n "$func_quote_for_eval_unquoted_result"; then
1117 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1118 else
1119 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1120 fi
1121
1122 case $_G_unquoted_arg in
1123 # Double-quote args containing shell metacharacters to delay
1124 # word splitting, command substitution and variable expansion
1125 # for a subsequent eval.
1126 # Many Bourne shells cannot handle close brackets correctly
1127 # in scan sets, so we specify it separately.
1128 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1129 _G_quoted_arg=\"$_G_unquoted_arg\"
1130 ;;
1131 *)
1132 _G_quoted_arg=$_G_unquoted_arg
1133 ;;
1134 esac
1135
1136 if test -n "$func_quote_for_eval_result"; then
1137 func_append func_quote_for_eval_result " $_G_quoted_arg"
1138 else
1139 func_append func_quote_for_eval_result "$_G_quoted_arg"
1140 fi
1141 shift
1142 done
1143 }
1144
1145
1146 # func_quote_for_expand ARG
1147 # -------------------------
1148 # Aesthetically quote ARG to be evaled later; same as above,
1149 # but do not quote variable references.
1150 func_quote_for_expand ()
1151 {
1152 $debug_cmd
1153
1154 case $1 in
1155 *[\\\`\"]*)
1156 _G_arg=`$ECHO "$1" | $SED \
1157 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1158 *)
1159 _G_arg=$1 ;;
1160 esac
1161
1162 case $_G_arg in
1163 # Double-quote args containing shell metacharacters to delay
1164 # word splitting and command substitution for a subsequent eval.
1165 # Many Bourne shells cannot handle close brackets correctly
1166 # in scan sets, so we specify it separately.
1167 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1168 _G_arg=\"$_G_arg\"
1169 ;;
1170 esac
1171
1172 func_quote_for_expand_result=$_G_arg
1173 }
1174
1175
1176 # func_stripname PREFIX SUFFIX NAME
1177 # ---------------------------------
1178 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179 # PREFIX and SUFFIX must not contain globbing or regex special
1180 # characters, hashes, percent signs, but SUFFIX may contain a leading
1181 # dot (in which case that matches only a dot).
1182 if test yes = "$_G_HAVE_XSI_OPS"; then
1183 eval 'func_stripname ()
1184 {
1185 $debug_cmd
1186
1187 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188 # positional parameters, so assign one to ordinary variable first.
1189 func_stripname_result=$3
1190 func_stripname_result=${func_stripname_result#"$1"}
1191 func_stripname_result=${func_stripname_result%"$2"}
1192 }'
1193 else
1194 func_stripname ()
1195 {
1196 $debug_cmd
1197
1198 case $2 in
1199 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1201 esac
1202 }
1203 fi
1204
1205
1206 # func_show_eval CMD [FAIL_EXP]
1207 # -----------------------------
1208 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1209 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1210 # is given, then evaluate it.
1211 func_show_eval ()
1212 {
1213 $debug_cmd
1214
1215 _G_cmd=$1
1216 _G_fail_exp=${2-':'}
1217
1218 func_quote_for_expand "$_G_cmd"
1219 eval "func_notquiet $func_quote_for_expand_result"
1220
1221 $opt_dry_run || {
1222 eval "$_G_cmd"
1223 _G_status=$?
1224 if test 0 -ne "$_G_status"; then
1225 eval "(exit $_G_status); $_G_fail_exp"
1226 fi
1227 }
1228 }
1229
1230
1231 # func_show_eval_locale CMD [FAIL_EXP]
1232 # ------------------------------------
1233 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1234 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1235 # is given, then evaluate it. Use the saved locale for evaluation.
1236 func_show_eval_locale ()
1237 {
1238 $debug_cmd
1239
1240 _G_cmd=$1
1241 _G_fail_exp=${2-':'}
1242
1243 $opt_quiet || {
1244 func_quote_for_expand "$_G_cmd"
1245 eval "func_echo $func_quote_for_expand_result"
1246 }
1247
1248 $opt_dry_run || {
1249 eval "$_G_user_locale
1250 $_G_cmd"
1251 _G_status=$?
1252 eval "$_G_safe_locale"
1253 if test 0 -ne "$_G_status"; then
1254 eval "(exit $_G_status); $_G_fail_exp"
1255 fi
1256 }
1257 }
1258
1259
1260 # func_tr_sh
1261 # ----------
1262 # Turn $1 into a string suitable for a shell variable name.
1263 # Result is stored in $func_tr_sh_result. All characters
1264 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1265 # if $1 begins with a digit, a '_' is prepended as well.
1266 func_tr_sh ()
1267 {
1268 $debug_cmd
1269
1270 case $1 in
1271 [0-9]* | *[!a-zA-Z0-9_]*)
1272 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1273 ;;
1274 * )
1275 func_tr_sh_result=$1
1276 ;;
1277 esac
1278 }
1279
1280
1281 # func_verbose ARG...
1282 # -------------------
1283 # Echo program name prefixed message in verbose mode only.
1284 func_verbose ()
1285 {
1286 $debug_cmd
1287
1288 $opt_verbose && func_echo "$*"
1289
1290 :
1291 }
1292
1293
1294 # func_warn_and_continue ARG...
1295 # -----------------------------
1296 # Echo program name prefixed warning message to standard error.
1297 func_warn_and_continue ()
1298 {
1299 $debug_cmd
1300
1301 $require_term_colors
1302
1303 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1304 }
1305
1306
1307 # func_warning CATEGORY ARG...
1308 # ----------------------------
1309 # Echo program name prefixed warning message to standard error. Warning
1310 # messages can be filtered according to CATEGORY, where this function
1311 # elides messages where CATEGORY is not listed in the global variable
1312 # 'opt_warning_types'.
1313 func_warning ()
1314 {
1315 $debug_cmd
1316
1317 # CATEGORY must be in the warning_categories list!
1318 case " $warning_categories " in
1319 *" $1 "*) ;;
1320 *) func_internal_error "invalid warning category '$1'" ;;
1321 esac
1322
1323 _G_category=$1
1324 shift
1325
1326 case " $opt_warning_types " in
1327 *" $_G_category "*) $warning_func ${1+"$@"} ;;
1328 esac
1329 }
1330
1331
1332 # func_sort_ver VER1 VER2
1333 # -----------------------
1334 # 'sort -V' is not generally available.
1335 # Note this deviates from the version comparison in automake
1336 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337 # but this should suffice as we won't be specifying old
1338 # version formats or redundant trailing .0 in bootstrap.conf.
1339 # If we did want full compatibility then we should probably
1340 # use m4_version_compare from autoconf.
1341 func_sort_ver ()
1342 {
1343 $debug_cmd
1344
1345 printf '%s\n%s\n' "$1" "$2" \
1346 | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
1347 }
1348
1349 # func_lt_ver PREV CURR
1350 # ---------------------
1351 # Return true if PREV and CURR are in the correct order according to
1352 # func_sort_ver, otherwise false. Use it like this:
1353 #
1354 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1355 func_lt_ver ()
1356 {
1357 $debug_cmd
1358
1359 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1360 }
1361
1362
1363 # Local variables:
1364 # mode: shell-script
1365 # sh-indentation: 2
1366 # eval: (add-hook 'before-save-hook 'time-stamp)
1367 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368 # time-stamp-time-zone: "UTC"
1369 # End:
1370 #! /bin/sh
1371
1372 # Set a version string for this script.
1373 scriptversion=2014-01-07.03; # UTC
1374
1375 # A portable, pluggable option parser for Bourne shell.
1376 # Written by Gary V. Vaughan, 2010
1377
1378 # Copyright (C) 2010-2014 Free Software Foundation, Inc.
1379 # This is free software; see the source for copying conditions. There is NO
1380 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1381
1382 # This program is free software: you can redistribute it and/or modify
1383 # it under the terms of the GNU General Public License as published by
1384 # the Free Software Foundation, either version 3 of the License, or
1385 # (at your option) any later version.
1386
1387 # This program is distributed in the hope that it will be useful,
1388 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1389 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1390 # GNU General Public License for more details.
1391
1392 # You should have received a copy of the GNU General Public License
1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1394
1395 # Please report bugs or propose patches to gary@gnu.org.
1396
1397
1398 ## ------ ##
1399 ## Usage. ##
1400 ## ------ ##
1401
1402 # This file is a library for parsing options in your shell scripts along
1403 # with assorted other useful supporting features that you can make use
1404 # of too.
1405 #
1406 # For the simplest scripts you might need only:
1407 #
1408 # #!/bin/sh
1409 # . relative/path/to/funclib.sh
1410 # . relative/path/to/options-parser
1411 # scriptversion=1.0
1412 # func_options ${1+"$@"}
1413 # eval set dummy "$func_options_result"; shift
1414 # ...rest of your script...
1415 #
1416 # In order for the '--version' option to work, you will need to have a
1417 # suitably formatted comment like the one at the top of this file
1418 # starting with '# Written by ' and ending with '# warranty; '.
1419 #
1420 # For '-h' and '--help' to work, you will also need a one line
1421 # description of your script's purpose in a comment directly above the
1422 # '# Written by ' line, like the one at the top of this file.
1423 #
1424 # The default options also support '--debug', which will turn on shell
1425 # execution tracing (see the comment above debug_cmd below for another
1426 # use), and '--verbose' and the func_verbose function to allow your script
1427 # to display verbose messages only when your user has specified
1428 # '--verbose'.
1429 #
1430 # After sourcing this file, you can plug processing for additional
1431 # options by amending the variables from the 'Configuration' section
1432 # below, and following the instructions in the 'Option parsing'
1433 # section further down.
1434
1435 ## -------------- ##
1436 ## Configuration. ##
1437 ## -------------- ##
1438
1439 # You should override these variables in your script after sourcing this
1440 # file so that they reflect the customisations you have added to the
1441 # option parser.
1442
1443 # The usage line for option parsing errors and the start of '-h' and
1444 # '--help' output messages. You can embed shell variables for delayed
1445 # expansion at the time the message is displayed, but you will need to
1446 # quote other shell meta-characters carefully to prevent them being
1447 # expanded when the contents are evaled.
1448 usage='$progpath [OPTION]...'
1449
1450 # Short help message in response to '-h' and '--help'. Add to this or
1451 # override it after sourcing this library to reflect the full set of
1452 # options your script accepts.
1453 usage_message="\
1454 --debug enable verbose shell tracing
1455 -W, --warnings=CATEGORY
1456 report the warnings falling in CATEGORY [all]
1457 -v, --verbose verbosely report processing
1458 --version print version information and exit
1459 -h, --help print short or long help message and exit
1460 "
1461
1462 # Additional text appended to 'usage_message' in response to '--help'.
1463 long_help_message="
1464 Warning categories include:
1465 'all' show all warnings
1466 'none' turn off all the warnings
1467 'error' warnings are treated as fatal errors"
1468
1469 # Help message printed before fatal option parsing errors.
1470 fatal_help="Try '\$progname --help' for more information."
1471
1472
1473
1474 ## ------------------------- ##
1475 ## Hook function management. ##
1476 ## ------------------------- ##
1477
1478 # This section contains functions for adding, removing, and running hooks
1479 # to the main code. A hook is just a named list of of function, that can
1480 # be run in order later on.
1481
1482 # func_hookable FUNC_NAME
1483 # -----------------------
1484 # Declare that FUNC_NAME will run hooks added with
1485 # 'func_add_hook FUNC_NAME ...'.
1486 func_hookable ()
1487 {
1488 $debug_cmd
1489
1490 func_append hookable_fns " $1"
1491 }
1492
1493
1494 # func_add_hook FUNC_NAME HOOK_FUNC
1495 # ---------------------------------
1496 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1497 # first have been declared "hookable" by a call to 'func_hookable'.
1498 func_add_hook ()
1499 {
1500 $debug_cmd
1501
1502 case " $hookable_fns " in
1503 *" $1 "*) ;;
1504 *) func_fatal_error "'$1' does not accept hook functions." ;;
1505 esac
1506
1507 eval func_append ${1}_hooks '" $2"'
1508 }
1509
1510
1511 # func_remove_hook FUNC_NAME HOOK_FUNC
1512 # ------------------------------------
1513 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1514 func_remove_hook ()
1515 {
1516 $debug_cmd
1517
1518 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1519 }
1520
1521
1522 # func_run_hooks FUNC_NAME [ARG]...
1523 # ---------------------------------
1524 # Run all hook functions registered to FUNC_NAME.
1525 # It is assumed that the list of hook functions contains nothing more
1526 # than a whitespace-delimited list of legal shell function names, and
1527 # no effort is wasted trying to catch shell meta-characters or preserve
1528 # whitespace.
1529 func_run_hooks ()
1530 {
1531 $debug_cmd
1532
1533 case " $hookable_fns " in
1534 *" $1 "*) ;;
1535 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1536 esac
1537
1538 eval _G_hook_fns=\$$1_hooks; shift
1539
1540 for _G_hook in $_G_hook_fns; do
1541 eval $_G_hook '"$@"'
1542
1543 # store returned options list back into positional
1544 # parameters for next 'cmd' execution.
1545 eval _G_hook_result=\$${_G_hook}_result
1546 eval set dummy "$_G_hook_result"; shift
1547 done
1548
1549 func_quote_for_eval ${1+"$@"}
1550 func_run_hooks_result=$func_quote_for_eval_result
1551 }
1552
1553
1554
1555 ## --------------- ##
1556 ## Option parsing. ##
1557 ## --------------- ##
1558
1559 # In order to add your own option parsing hooks, you must accept the
1560 # full positional parameter list in your hook function, remove any
1561 # options that you action, and then pass back the remaining unprocessed
1562 # options in '<hooked_function_name>_result', escaped suitably for
1563 # 'eval'. Like this:
1564 #
1565 # my_options_prep ()
1566 # {
1567 # $debug_cmd
1568 #
1569 # # Extend the existing usage message.
1570 # usage_message=$usage_message'
1571 # -s, --silent don'\''t print informational messages
1572 # '
1573 #
1574 # func_quote_for_eval ${1+"$@"}
1575 # my_options_prep_result=$func_quote_for_eval_result
1576 # }
1577 # func_add_hook func_options_prep my_options_prep
1578 #
1579 #
1580 # my_silent_option ()
1581 # {
1582 # $debug_cmd
1583 #
1584 # # Note that for efficiency, we parse as many options as we can
1585 # # recognise in a loop before passing the remainder back to the
1586 # # caller on the first unrecognised argument we encounter.
1587 # while test $# -gt 0; do
1588 # opt=$1; shift
1589 # case $opt in
1590 # --silent|-s) opt_silent=: ;;
1591 # # Separate non-argument short options:
1592 # -s*) func_split_short_opt "$_G_opt"
1593 # set dummy "$func_split_short_opt_name" \
1594 # "-$func_split_short_opt_arg" ${1+"$@"}
1595 # shift
1596 # ;;
1597 # *) set dummy "$_G_opt" "$*"; shift; break ;;
1598 # esac
1599 # done
1600 #
1601 # func_quote_for_eval ${1+"$@"}
1602 # my_silent_option_result=$func_quote_for_eval_result
1603 # }
1604 # func_add_hook func_parse_options my_silent_option
1605 #
1606 #
1607 # my_option_validation ()
1608 # {
1609 # $debug_cmd
1610 #
1611 # $opt_silent && $opt_verbose && func_fatal_help "\
1612 # '--silent' and '--verbose' options are mutually exclusive."
1613 #
1614 # func_quote_for_eval ${1+"$@"}
1615 # my_option_validation_result=$func_quote_for_eval_result
1616 # }
1617 # func_add_hook func_validate_options my_option_validation
1618 #
1619 # You'll alse need to manually amend $usage_message to reflect the extra
1620 # options you parse. It's preferable to append if you can, so that
1621 # multiple option parsing hooks can be added safely.
1622
1623
1624 # func_options [ARG]...
1625 # ---------------------
1626 # All the functions called inside func_options are hookable. See the
1627 # individual implementations for details.
1628 func_hookable func_options
1629 func_options ()
1630 {
1631 $debug_cmd
1632
1633 func_options_prep ${1+"$@"}
1634 eval func_parse_options \
1635 ${func_options_prep_result+"$func_options_prep_result"}
1636 eval func_validate_options \
1637 ${func_parse_options_result+"$func_parse_options_result"}
1638
1639 eval func_run_hooks func_options \
1640 ${func_validate_options_result+"$func_validate_options_result"}
1641
1642 # save modified positional parameters for caller
1643 func_options_result=$func_run_hooks_result
1644 }
1645
1646
1647 # func_options_prep [ARG]...
1648 # --------------------------
1649 # All initialisations required before starting the option parse loop.
1650 # Note that when calling hook functions, we pass through the list of
1651 # positional parameters. If a hook function modifies that list, and
1652 # needs to propogate that back to rest of this script, then the complete
1653 # modified list must be put in 'func_run_hooks_result' before
1654 # returning.
1655 func_hookable func_options_prep
1656 func_options_prep ()
1657 {
1658 $debug_cmd
1659
1660 # Option defaults:
1661 opt_verbose=false
1662 opt_warning_types=
1663
1664 func_run_hooks func_options_prep ${1+"$@"}
1665
1666 # save modified positional parameters for caller
1667 func_options_prep_result=$func_run_hooks_result
1668 }
1669
1670
1671 # func_parse_options [ARG]...
1672 # ---------------------------
1673 # The main option parsing loop.
1674 func_hookable func_parse_options
1675 func_parse_options ()
1676 {
1677 $debug_cmd
1678
1679 func_parse_options_result=
1680
1681 # this just eases exit handling
1682 while test $# -gt 0; do
1683 # Defer to hook functions for initial option parsing, so they
1684 # get priority in the event of reusing an option name.
1685 func_run_hooks func_parse_options ${1+"$@"}
1686
1687 # Adjust func_parse_options positional parameters to match
1688 eval set dummy "$func_run_hooks_result"; shift
1689
1690 # Break out of the loop if we already parsed every option.
1691 test $# -gt 0 || break
1692
1693 _G_opt=$1
1694 shift
1695 case $_G_opt in
1696 --debug|-x) debug_cmd='set -x'
1697 func_echo "enabling shell trace mode"
1698 $debug_cmd
1699 ;;
1700
1701 --no-warnings|--no-warning|--no-warn)
1702 set dummy --warnings none ${1+"$@"}
1703 shift
1704 ;;
1705
1706 --warnings|--warning|-W)
1707 test $# = 0 && func_missing_arg $_G_opt && break
1708 case " $warning_categories $1" in
1709 *" $1 "*)
1710 # trailing space prevents matching last $1 above
1711 func_append_uniq opt_warning_types " $1"
1712 ;;
1713 *all)
1714 opt_warning_types=$warning_categories
1715 ;;
1716 *none)
1717 opt_warning_types=none
1718 warning_func=:
1719 ;;
1720 *error)
1721 opt_warning_types=$warning_categories
1722 warning_func=func_fatal_error
1723 ;;
1724 *)
1725 func_fatal_error \
1726 "unsupported warning category: '$1'"
1727 ;;
1728 esac
1729 shift
1730 ;;
1731
1732 --verbose|-v) opt_verbose=: ;;
1733 --version) func_version ;;
1734 -\?|-h) func_usage ;;
1735 --help) func_help ;;
1736
1737 # Separate optargs to long options (plugins may need this):
1738 --*=*) func_split_equals "$_G_opt"
1739 set dummy "$func_split_equals_lhs" \
1740 "$func_split_equals_rhs" ${1+"$@"}
1741 shift
1742 ;;
1743
1744 # Separate optargs to short options:
1745 -W*)
1746 func_split_short_opt "$_G_opt"
1747 set dummy "$func_split_short_opt_name" \
1748 "$func_split_short_opt_arg" ${1+"$@"}
1749 shift
1750 ;;
1751
1752 # Separate non-argument short options:
1753 -\?*|-h*|-v*|-x*)
1754 func_split_short_opt "$_G_opt"
1755 set dummy "$func_split_short_opt_name" \
1756 "-$func_split_short_opt_arg" ${1+"$@"}
1757 shift
1758 ;;
1759
1760 --) break ;;
1761 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
1762 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1763 esac
1764 done
1765
1766 # save modified positional parameters for caller
1767 func_quote_for_eval ${1+"$@"}
1768 func_parse_options_result=$func_quote_for_eval_result
1769 }
1770
1771
1772 # func_validate_options [ARG]...
1773 # ------------------------------
1774 # Perform any sanity checks on option settings and/or unconsumed
1775 # arguments.
1776 func_hookable func_validate_options
1777 func_validate_options ()
1778 {
1779 $debug_cmd
1780
1781 # Display all warnings if -W was not given.
1782 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783
1784 func_run_hooks func_validate_options ${1+"$@"}
1785
1786 # Bail if the options were screwed!
1787 $exit_cmd $EXIT_FAILURE
1788
1789 # save modified positional parameters for caller
1790 func_validate_options_result=$func_run_hooks_result
1791 }
1792
1793
1794
1795 ## ----------------- ##
1796 ## Helper functions. ##
1797 ## ----------------- ##
1798
1799 # This section contains the helper functions used by the rest of the
1800 # hookable option parser framework in ascii-betical order.
1801
1802
1803 # func_fatal_help ARG...
1804 # ----------------------
1805 # Echo program name prefixed message to standard error, followed by
1806 # a help hint, and exit.
1807 func_fatal_help ()
1808 {
1809 $debug_cmd
1810
1811 eval \$ECHO \""Usage: $usage"\"
1812 eval \$ECHO \""$fatal_help"\"
1813 func_error ${1+"$@"}
1814 exit $EXIT_FAILURE
1815 }
1816
1817
1818 # func_help
1819 # ---------
1820 # Echo long help message to standard output and exit.
1821 func_help ()
1822 {
1823 $debug_cmd
1824
1825 func_usage_message
1826 $ECHO "$long_help_message"
1827 exit 0
1828 }
1829
1830
1831 # func_missing_arg ARGNAME
1832 # ------------------------
1833 # Echo program name prefixed message to standard error and set global
1834 # exit_cmd.
1835 func_missing_arg ()
1836 {
1837 $debug_cmd
1838
1839 func_error "Missing argument for '$1'."
1840 exit_cmd=exit
1841 }
1842
1843
1844 # func_split_equals STRING
1845 # ------------------------
1846 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1847 # splitting STRING at the '=' sign.
1848 test -z "$_G_HAVE_XSI_OPS" \
1849 && (eval 'x=a/b/c;
1850 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1851 && _G_HAVE_XSI_OPS=yes
1852
1853 if test yes = "$_G_HAVE_XSI_OPS"
1854 then
1855 # This is an XSI compatible shell, allowing a faster implementation...
1856 eval 'func_split_equals ()
1857 {
1858 $debug_cmd
1859
1860 func_split_equals_lhs=${1%%=*}
1861 func_split_equals_rhs=${1#*=}
1862 test "x$func_split_equals_lhs" = "x$1" \
1863 && func_split_equals_rhs=
1864 }'
1865 else
1866 # ...otherwise fall back to using expr, which is often a shell builtin.
1867 func_split_equals ()
1868 {
1869 $debug_cmd
1870
1871 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1872 func_split_equals_rhs=
1873 test "x$func_split_equals_lhs" = "x$1" \
1874 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1875 }
1876 fi #func_split_equals
1877
1878
1879 # func_split_short_opt SHORTOPT
1880 # -----------------------------
1881 # Set func_split_short_opt_name and func_split_short_opt_arg shell
1882 # variables after splitting SHORTOPT after the 2nd character.
1883 if test yes = "$_G_HAVE_XSI_OPS"
1884 then
1885 # This is an XSI compatible shell, allowing a faster implementation...
1886 eval 'func_split_short_opt ()
1887 {
1888 $debug_cmd
1889
1890 func_split_short_opt_arg=${1#??}
1891 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1892 }'
1893 else
1894 # ...otherwise fall back to using expr, which is often a shell builtin.
1895 func_split_short_opt ()
1896 {
1897 $debug_cmd
1898
1899 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1900 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1901 }
1902 fi #func_split_short_opt
1903
1904
1905 # func_usage
1906 # ----------
1907 # Echo short help message to standard output and exit.
1908 func_usage ()
1909 {
1910 $debug_cmd
1911
1912 func_usage_message
1913 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1914 exit 0
1915 }
1916
1917
1918 # func_usage_message
1919 # ------------------
1920 # Echo short help message to standard output.
1921 func_usage_message ()
1922 {
1923 $debug_cmd
1924
1925 eval \$ECHO \""Usage: $usage"\"
1926 echo
1927 $SED -n 's|^# ||
1928 /^Written by/{
1929 x;p;x
1930 }
1931 h
1932 /^Written by/q' < "$progpath"
1933 echo
1934 eval \$ECHO \""$usage_message"\"
1935 }
1936
1937
1938 # func_version
1939 # ------------
1940 # Echo version message to standard output and exit.
1941 func_version ()
1942 {
1943 $debug_cmd
1944
1945 printf '%s\n' "$progname $scriptversion"
1946 $SED -n '
1947 /(C)/!b go
1948 :more
1949 /\./!{
1950 N
1951 s|\n# | |
1952 b more
1953 }
1954 :go
1955 /^# Written by /,/# warranty; / {
1956 s|^# ||
1957 s|^# *$||
1958 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1959 p
1960 }
1961 /^# Written by / {
1962 s|^# ||
1963 p
1964 }
1965 /^warranty; /q' < "$progpath"
1966
1967 exit $?
1968 }
1969
1970
1971 # Local variables:
1972 # mode: shell-script
1973 # sh-indentation: 2
1974 # eval: (add-hook 'before-save-hook 'time-stamp)
1975 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1976 # time-stamp-time-zone: "UTC"
1977 # End:
1978
1979 # Set a version string.
1980 scriptversion='(GNU libtool) 2.4.4'
1981
1982
1983 # func_echo ARG...
1984 # ----------------
1985 # Libtool also displays the current mode in messages, so override
1986 # funclib.sh func_echo with this custom definition.
1987 func_echo ()
1988 {
1989 $debug_cmd
1990
1991 _G_message=$*
1992
1993 func_echo_IFS=$IFS
1994 IFS=$nl
1995 for _G_line in $_G_message; do
1996 IFS=$func_echo_IFS
1997 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
1998 done
1999 IFS=$func_echo_IFS
2000 }
2001
2002
2003 # func_warning ARG...
2004 # -------------------
2005 # Libtool warnings are not categorized, so override funclib.sh
2006 # func_warning with this simpler definition.
2007 func_warning ()
2008 {
2009 $debug_cmd
2010
2011 $warning_func ${1+"$@"}
2012 }
2013
2014
2015 ## ---------------- ##
2016 ## Options parsing. ##
2017 ## ---------------- ##
2018
2019 # Hook in the functions to make sure our own options are parsed during
2020 # the option parsing loop.
2021
2022 usage='$progpath [OPTION]... [MODE-ARG]...'
2023
2024 # Short help message in response to '-h'.
2025 usage_message="Options:
2026 --config show all configuration variables
2027 --debug enable verbose shell tracing
2028 -n, --dry-run display commands without modifying any files
2029 --features display basic configuration information and exit
2030 --mode=MODE use operation mode MODE
2031 --no-warnings equivalent to '-Wnone'
2032 --preserve-dup-deps don't remove duplicate dependency libraries
2033 --quiet, --silent don't print informational messages
2034 --tag=TAG use configuration variables from tag TAG
2035 -v, --verbose print more informational messages than default
2036 --version print version information
2037 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
2038 -h, --help, --help-all print short, long, or detailed help message
2039 "
2040
2041 # Additional text appended to 'usage_message' in response to '--help'.
2042 long_help_message=$long_help_message"
2043
2044 MODE must be one of the following:
2045
2046 clean remove files from the build directory
2047 compile compile a source file into a libtool object
2048 execute automatically set library path, then run a program
2049 finish complete the installation of libtool libraries
2050 install install libraries or executables
2051 link create a library or an executable
2052 uninstall remove libraries from an installed directory
2053
2054 MODE-ARGS vary depending on the MODE. When passed as first option,
2055 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2056 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
2057
2058 When reporting a bug, please describe a test case to reproduce it and
2059 include the following information:
2060
2061 host-triplet: $host
2062 shell: $SHELL
2063 compiler: $LTCC
2064 compiler flags: $LTCFLAGS
2065 linker: $LD (gnu? $with_gnu_ld)
2066 version: $progname (GNU libtool) 2.4.4
2067 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2068 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2069
2070 Report bugs to <bug-libtool@gnu.org>.
2071 GNU libtool home page: <http://www.gnu.org/software/libtool/>.
2072 General help using GNU software: <http://www.gnu.org/gethelp/>."
2073
2074
2075 # func_lo2o OBJECT-NAME
2076 # ---------------------
2077 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2078 # object suffix.
2079
2080 lo2o=s/\\.lo\$/.$objext/
2081 o2lo=s/\\.$objext\$/.lo/
2082
2083 if test yes = "$_G_HAVE_XSI_OPS"; then
2084 eval 'func_lo2o ()
2085 {
2086 case $1 in
2087 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2088 * ) func_lo2o_result=$1 ;;
2089 esac
2090 }'
2091
2092 # func_xform LIBOBJ-OR-SOURCE
2093 # ---------------------------
2094 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2095 # suffix to a '.lo' libtool-object suffix.
2096 eval 'func_xform ()
2097 {
2098 func_xform_result=${1%.*}.lo
2099 }'
2100 else
2101 # ...otherwise fall back to using sed.
2102 func_lo2o ()
2103 {
2104 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2105 }
2106
2107 func_xform ()
2108 {
2109 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2110 }
2111 fi
2112
2113
2114 # func_fatal_configuration ARG...
2115 # -------------------------------
2116 # Echo program name prefixed message to standard error, followed by
2117 # a configuration failure hint, and exit.
2118 func_fatal_configuration ()
2119 {
2120 func__fatal_error ${1+"$@"} \
2121 "See the $PACKAGE documentation for more information." \
2122 "Fatal configuration error."
2123 }
2124
2125
2126 # func_config
2127 # -----------
2128 # Display the configuration for all the tags in this script.
2129 func_config ()
2130 {
2131 re_begincf='^# ### BEGIN LIBTOOL'
2132 re_endcf='^# ### END LIBTOOL'
2133
2134 # Default configuration.
2135 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2136
2137 # Now print the configurations for the tags.
2138 for tagname in $taglist; do
2139 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2140 done
2141
2142 exit $?
2143 }
2144
2145
2146 # func_features
2147 # -------------
2148 # Display the features supported by this script.
2149 func_features ()
2150 {
2151 echo "host: $host"
2152 if test yes = "$build_libtool_libs"; then
2153 echo "enable shared libraries"
2154 else
2155 echo "disable shared libraries"
2156 fi
2157 if test yes = "$build_old_libs"; then
2158 echo "enable static libraries"
2159 else
2160 echo "disable static libraries"
2161 fi
2162
2163 exit $?
2164 }
2165
2166
2167 # func_enable_tag TAGNAME
2168 # -----------------------
2169 # Verify that TAGNAME is valid, and either flag an error and exit, or
2170 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
2171 # variable here.
2172 func_enable_tag ()
2173 {
2174 # Global variable:
2175 tagname=$1
2176
2177 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2178 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2179 sed_extractcf=/$re_begincf/,/$re_endcf/p
2180
2181 # Validate tagname.
2182 case $tagname in
2183 *[!-_A-Za-z0-9,/]*)
2184 func_fatal_error "invalid tag name: $tagname"
2185 ;;
2186 esac
2187
2188 # Don't test for the "default" C tag, as we know it's
2189 # there but not specially marked.
2190 case $tagname in
2191 CC) ;;
2192 *)
2193 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2194 taglist="$taglist $tagname"
2195
2196 # Evaluate the configuration. Be careful to quote the path
2197 # and the sed script, to avoid splitting on whitespace, but
2198 # also don't use non-portable quotes within backquotes within
2199 # quotes we have to do it in 2 steps:
2200 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2201 eval "$extractedcf"
2202 else
2203 func_error "ignoring unknown tag $tagname"
2204 fi
2205 ;;
2206 esac
2207 }
2208
2209
2210 # func_check_version_match
2211 # ------------------------
2212 # Ensure that we are using m4 macros, and libtool script from the same
2213 # release of libtool.
2214 func_check_version_match ()
2215 {
2216 if test "$package_revision" != "$macro_revision"; then
2217 if test "$VERSION" != "$macro_version"; then
2218 if test -z "$macro_version"; then
2219 cat >&2 <<_LT_EOF
2220 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2221 $progname: definition of this LT_INIT comes from an older release.
2222 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2223 $progname: and run autoconf again.
2224 _LT_EOF
2225 else
2226 cat >&2 <<_LT_EOF
2227 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2228 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2229 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230 $progname: and run autoconf again.
2231 _LT_EOF
2232 fi
2233 else
2234 cat >&2 <<_LT_EOF
2235 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
2236 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
2237 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
2238 $progname: of $PACKAGE $VERSION and run autoconf again.
2239 _LT_EOF
2240 fi
2241
2242 exit $EXIT_MISMATCH
2243 fi
2244 }
2245
2246
2247 # libtool_options_prep [ARG]...
2248 # -----------------------------
2249 # Preparation for options parsed by libtool.
2250 libtool_options_prep ()
2251 {
2252 $debug_mode
2253
2254 # Option defaults:
2255 opt_config=false
2256 opt_dlopen=
2257 opt_dry_run=false
2258 opt_help=false
2259 opt_mode=
2260 opt_preserve_dup_deps=false
2261 opt_quiet=false
2262
2263 nonopt=
2264 preserve_args=
2265
2266 # Shorthand for --mode=foo, only valid as the first argument
2267 case $1 in
2268 clean|clea|cle|cl)
2269 shift; set dummy --mode clean ${1+"$@"}; shift
2270 ;;
2271 compile|compil|compi|comp|com|co|c)
2272 shift; set dummy --mode compile ${1+"$@"}; shift
2273 ;;
2274 execute|execut|execu|exec|exe|ex|e)
2275 shift; set dummy --mode execute ${1+"$@"}; shift
2276 ;;
2277 finish|finis|fini|fin|fi|f)
2278 shift; set dummy --mode finish ${1+"$@"}; shift
2279 ;;
2280 install|instal|insta|inst|ins|in|i)
2281 shift; set dummy --mode install ${1+"$@"}; shift
2282 ;;
2283 link|lin|li|l)
2284 shift; set dummy --mode link ${1+"$@"}; shift
2285 ;;
2286 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2287 shift; set dummy --mode uninstall ${1+"$@"}; shift
2288 ;;
2289 esac
2290
2291 # Pass back the list of options.
2292 func_quote_for_eval ${1+"$@"}
2293 libtool_options_prep_result=$func_quote_for_eval_result
2294 }
2295 func_add_hook func_options_prep libtool_options_prep
2296
2297
2298 # libtool_parse_options [ARG]...
2299 # ---------------------------------
2300 # Provide handling for libtool specific options.
2301 libtool_parse_options ()
2302 {
2303 $debug_cmd
2304
2305 # Perform our own loop to consume as many options as possible in
2306 # each iteration.
2307 while test $# -gt 0; do
2308 _G_opt=$1
2309 shift
2310 case $_G_opt in
2311 --dry-run|--dryrun|-n)
2312 opt_dry_run=:
2313 ;;
2314
2315 --config) func_config ;;
2316
2317 --dlopen|-dlopen)
2318 opt_dlopen="${opt_dlopen+$opt_dlopen
2319 }$1"
2320 shift
2321 ;;
2322
2323 --preserve-dup-deps)
2324 opt_preserve_dup_deps=: ;;
2325
2326 --features) func_features ;;
2327
2328 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
2329
2330 --help) opt_help=: ;;
2331
2332 --help-all) opt_help=': help-all' ;;
2333
2334 --mode) test $# = 0 && func_missing_arg $_G_opt && break
2335 opt_mode=$1
2336 case $1 in
2337 # Valid mode arguments:
2338 clean|compile|execute|finish|install|link|relink|uninstall) ;;
2339
2340 # Catch anything else as an error
2341 *) func_error "invalid argument for $_G_opt"
2342 exit_cmd=exit
2343 break
2344 ;;
2345 esac
2346 shift
2347 ;;
2348
2349 --no-silent|--no-quiet)
2350 opt_quiet=false
2351 func_append preserve_args " $_G_opt"
2352 ;;
2353
2354 --no-warnings|--no-warning|--no-warn)
2355 opt_warning=false
2356 func_append preserve_args " $_G_opt"
2357 ;;
2358
2359 --no-verbose)
2360 opt_verbose=false
2361 func_append preserve_args " $_G_opt"
2362 ;;
2363
2364 --silent|--quiet)
2365 opt_quiet=:
2366 opt_verbose=false
2367 func_append preserve_args " $_G_opt"
2368 ;;
2369
2370 --tag) test $# = 0 && func_missing_arg $_G_opt && break
2371 opt_tag=$1
2372 func_append preserve_args " $_G_opt $1"
2373 func_enable_tag "$1"
2374 shift
2375 ;;
2376
2377 --verbose|-v) opt_quiet=false
2378 opt_verbose=:
2379 func_append preserve_args " $_G_opt"
2380 ;;
2381
2382 # An option not handled by this hook function:
2383 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
2384 esac
2385 done
2386
2387
2388 # save modified positional parameters for caller
2389 func_quote_for_eval ${1+"$@"}
2390 libtool_parse_options_result=$func_quote_for_eval_result
2391 }
2392 func_add_hook func_parse_options libtool_parse_options
2393
2394
2395
2396 # libtool_validate_options [ARG]...
2397 # ---------------------------------
2398 # Perform any sanity checks on option settings and/or unconsumed
2399 # arguments.
2400 libtool_validate_options ()
2401 {
2402 # save first non-option argument
2403 if test 0 -lt $#; then
2404 nonopt=$1
2405 shift
2406 fi
2407
2408 # preserve --debug
2409 test : = "$debug_cmd" || func_append preserve_args " --debug"
2410
2411 case $host in
2412 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2413 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2414 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2415 # don't eliminate duplications in $postdeps and $predeps
2416 opt_duplicate_compiler_generated_deps=:
2417 ;;
2418 *)
2419 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2420 ;;
2421 esac
2422
2423 $opt_help || {
2424 # Sanity checks first:
2425 func_check_version_match
2426
2427 test yes != "$build_libtool_libs" \
2428 && test yes != "$build_old_libs" \
2429 && func_fatal_configuration "not configured to build any kind of library"
2430
2431 # Darwin sucks
2432 eval std_shrext=\"$shrext_cmds\"
2433
2434 # Only execute mode is allowed to have -dlopen flags.
2435 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2436 func_error "unrecognized option '-dlopen'"
2437 $ECHO "$help" 1>&2
2438 exit $EXIT_FAILURE
2439 fi
2440
2441 # Change the help message to a mode-specific one.
2442 generic_help=$help
2443 help="Try '$progname --help --mode=$opt_mode' for more information."
2444 }
2445
2446 # Pass back the unparsed argument list
2447 func_quote_for_eval ${1+"$@"}
2448 libtool_validate_options_result=$func_quote_for_eval_result
2449 }
2450 func_add_hook func_validate_options libtool_validate_options
2451
2452
2453 # Process options as early as possible so that --help and --version
2454 # can return quickly.
2455 func_options ${1+"$@"}
2456 eval set dummy "$func_options_result"; shift
2457
2458
2459
2460 ## ----------- ##
2461 ## Main. ##
2462 ## ----------- ##
2463
2464 magic='%%%MAGIC variable%%%'
2465 magic_exe='%%%MAGIC EXE variable%%%'
2466
2467 # Global variables.
2468 extracted_archives=
2469 extracted_serial=0
2470
2471 # If this variable is set in any of the actions, the command in it
2472 # will be execed at the end. This prevents here-documents from being
2473 # left over by shells.
2474 exec_cmd=
2475
2476
2477 # A function that is used when there is no print builtin or printf.
2478 func_fallback_echo ()
2479 {
2480 eval 'cat <<_LTECHO_EOF
2481 $1
2482 _LTECHO_EOF'
2483 }
2484
2485 # func_generated_by_libtool
2486 # True iff stdin has been generated by Libtool. This function is only
2487 # a basic sanity check; it will hardly flush out determined imposters.
2488 func_generated_by_libtool_p ()
2489 {
2490 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2491 }
2492
2493 # func_lalib_p file
2494 # True iff FILE is a libtool '.la' library or '.lo' object file.
2495 # This function is only a basic sanity check; it will hardly flush out
2496 # determined imposters.
2497 func_lalib_p ()
2498 {
2499 test -f "$1" &&
2500 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2501 }
2502
2503 # func_lalib_unsafe_p file
2504 # True iff FILE is a libtool '.la' library or '.lo' object file.
2505 # This function implements the same check as func_lalib_p without
2506 # resorting to external programs. To this end, it redirects stdin and
2507 # closes it afterwards, without saving the original file descriptor.
2508 # As a safety measure, use it only where a negative result would be
2509 # fatal anyway. Works if 'file' does not exist.
2510 func_lalib_unsafe_p ()
2511 {
2512 lalib_p=no
2513 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2514 for lalib_p_l in 1 2 3 4
2515 do
2516 read lalib_p_line
2517 case $lalib_p_line in
2518 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2519 esac
2520 done
2521 exec 0<&5 5<&-
2522 fi
2523 test yes = "$lalib_p"
2524 }
2525
2526 # func_ltwrapper_script_p file
2527 # True iff FILE is a libtool wrapper script
2528 # This function is only a basic sanity check; it will hardly flush out
2529 # determined imposters.
2530 func_ltwrapper_script_p ()
2531 {
2532 test -f "$1" &&
2533 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2534 }
2535
2536 # func_ltwrapper_executable_p file
2537 # True iff FILE is a libtool wrapper executable
2538 # This function is only a basic sanity check; it will hardly flush out
2539 # determined imposters.
2540 func_ltwrapper_executable_p ()
2541 {
2542 func_ltwrapper_exec_suffix=
2543 case $1 in
2544 *.exe) ;;
2545 *) func_ltwrapper_exec_suffix=.exe ;;
2546 esac
2547 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2548 }
2549
2550 # func_ltwrapper_scriptname file
2551 # Assumes file is an ltwrapper_executable
2552 # uses $file to determine the appropriate filename for a
2553 # temporary ltwrapper_script.
2554 func_ltwrapper_scriptname ()
2555 {
2556 func_dirname_and_basename "$1" "" "."
2557 func_stripname '' '.exe' "$func_basename_result"
2558 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2559 }
2560
2561 # func_ltwrapper_p file
2562 # True iff FILE is a libtool wrapper script or wrapper executable
2563 # This function is only a basic sanity check; it will hardly flush out
2564 # determined imposters.
2565 func_ltwrapper_p ()
2566 {
2567 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2568 }
2569
2570
2571 # func_execute_cmds commands fail_cmd
2572 # Execute tilde-delimited COMMANDS.
2573 # If FAIL_CMD is given, eval that upon failure.
2574 # FAIL_CMD may read-access the current command in variable CMD!
2575 func_execute_cmds ()
2576 {
2577 $debug_cmd
2578
2579 save_ifs=$IFS; IFS='~'
2580 for cmd in $1; do
2581 IFS=$sp$nl
2582 eval cmd=\"$cmd\"
2583 IFS=$save_ifs
2584 func_show_eval "$cmd" "${2-:}"
2585 done
2586 IFS=$save_ifs
2587 }
2588
2589
2590 # func_source file
2591 # Source FILE, adding directory component if necessary.
2592 # Note that it is not necessary on cygwin/mingw to append a dot to
2593 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2594 # behavior happens only for exec(3), not for open(2)! Also, sourcing
2595 # 'FILE.' does not work on cygwin managed mounts.
2596 func_source ()
2597 {
2598 $debug_cmd
2599
2600 case $1 in
2601 */* | *\\*) . "$1" ;;
2602 *) . "./$1" ;;
2603 esac
2604 }
2605
2606
2607 # func_resolve_sysroot PATH
2608 # Replace a leading = in PATH with a sysroot. Store the result into
2609 # func_resolve_sysroot_result
2610 func_resolve_sysroot ()
2611 {
2612 func_resolve_sysroot_result=$1
2613 case $func_resolve_sysroot_result in
2614 =*)
2615 func_stripname '=' '' "$func_resolve_sysroot_result"
2616 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2617 ;;
2618 esac
2619 }
2620
2621 # func_replace_sysroot PATH
2622 # If PATH begins with the sysroot, replace it with = and
2623 # store the result into func_replace_sysroot_result.
2624 func_replace_sysroot ()
2625 {
2626 case $lt_sysroot:$1 in
2627 ?*:"$lt_sysroot"*)
2628 func_stripname "$lt_sysroot" '' "$1"
2629 func_replace_sysroot_result='='$func_stripname_result
2630 ;;
2631 *)
2632 # Including no sysroot.
2633 func_replace_sysroot_result=$1
2634 ;;
2635 esac
2636 }
2637
2638 # func_infer_tag arg
2639 # Infer tagged configuration to use if any are available and
2640 # if one wasn't chosen via the "--tag" command line option.
2641 # Only attempt this if the compiler in the base compile
2642 # command doesn't match the default compiler.
2643 # arg is usually of the form 'gcc ...'
2644 func_infer_tag ()
2645 {
2646 $debug_cmd
2647
2648 if test -n "$available_tags" && test -z "$tagname"; then
2649 CC_quoted=
2650 for arg in $CC; do
2651 func_append_quoted CC_quoted "$arg"
2652 done
2653 CC_expanded=`func_echo_all $CC`
2654 CC_quoted_expanded=`func_echo_all $CC_quoted`
2655 case $@ in
2656 # Blanks in the command may have been stripped by the calling shell,
2657 # but not from the CC environment variable when configure was run.
2658 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2659 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2660 # Blanks at the start of $base_compile will cause this to fail
2661 # if we don't check for them as well.
2662 *)
2663 for z in $available_tags; do
2664 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2665 # Evaluate the configuration.
2666 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2667 CC_quoted=
2668 for arg in $CC; do
2669 # Double-quote args containing other shell metacharacters.
2670 func_append_quoted CC_quoted "$arg"
2671 done
2672 CC_expanded=`func_echo_all $CC`
2673 CC_quoted_expanded=`func_echo_all $CC_quoted`
2674 case "$@ " in
2675 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2676 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2677 # The compiler in the base compile command matches
2678 # the one in the tagged configuration.
2679 # Assume this is the tagged configuration we want.
2680 tagname=$z
2681 break
2682 ;;
2683 esac
2684 fi
2685 done
2686 # If $tagname still isn't set, then no tagged configuration
2687 # was found and let the user know that the "--tag" command
2688 # line option must be used.
2689 if test -z "$tagname"; then
2690 func_echo "unable to infer tagged configuration"
2691 func_fatal_error "specify a tag with '--tag'"
2692 # else
2693 # func_verbose "using $tagname tagged configuration"
2694 fi
2695 ;;
2696 esac
2697 fi
2698 }
2699
2700
2701
2702 # func_write_libtool_object output_name pic_name nonpic_name
2703 # Create a libtool object file (analogous to a ".la" file),
2704 # but don't create it if we're doing a dry run.
2705 func_write_libtool_object ()
2706 {
2707 write_libobj=$1
2708 if test yes = "$build_libtool_libs"; then
2709 write_lobj=\'$2\'
2710 else
2711 write_lobj=none
2712 fi
2713
2714 if test yes = "$build_old_libs"; then
2715 write_oldobj=\'$3\'
2716 else
2717 write_oldobj=none
2718 fi
2719
2720 $opt_dry_run || {
2721 cat >${write_libobj}T <<EOF
2722 # $write_libobj - a libtool object file
2723 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2724 #
2725 # Please DO NOT delete this file!
2726 # It is necessary for linking the library.
2727
2728 # Name of the PIC object.
2729 pic_object=$write_lobj
2730
2731 # Name of the non-PIC object
2732 non_pic_object=$write_oldobj
2733
2734 EOF
2735 $MV "${write_libobj}T" "$write_libobj"
2736 }
2737 }
2738
2739
2740 ##################################################
2741 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2742 ##################################################
2743
2744 # func_convert_core_file_wine_to_w32 ARG
2745 # Helper function used by file name conversion functions when $build is *nix,
2746 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
2747 # correctly configured wine environment available, with the winepath program
2748 # in $build's $PATH.
2749 #
2750 # ARG is the $build file name to be converted to w32 format.
2751 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
2752 # be empty on error (or when ARG is empty)
2753 func_convert_core_file_wine_to_w32 ()
2754 {
2755 $debug_cmd
2756
2757 func_convert_core_file_wine_to_w32_result=$1
2758 if test -n "$1"; then
2759 # Unfortunately, winepath does not exit with a non-zero error code, so we
2760 # are forced to check the contents of stdout. On the other hand, if the
2761 # command is not found, the shell will set an exit code of 127 and print
2762 # *an error message* to stdout. So we must check for both error code of
2763 # zero AND non-empty stdout, which explains the odd construction:
2764 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2765 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2766 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2767 $SED -e "$sed_naive_backslashify"`
2768 else
2769 func_convert_core_file_wine_to_w32_result=
2770 fi
2771 fi
2772 }
2773 # end: func_convert_core_file_wine_to_w32
2774
2775
2776 # func_convert_core_path_wine_to_w32 ARG
2777 # Helper function used by path conversion functions when $build is *nix, and
2778 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2779 # configured wine environment available, with the winepath program in $build's
2780 # $PATH. Assumes ARG has no leading or trailing path separator characters.
2781 #
2782 # ARG is path to be converted from $build format to win32.
2783 # Result is available in $func_convert_core_path_wine_to_w32_result.
2784 # Unconvertible file (directory) names in ARG are skipped; if no directory names
2785 # are convertible, then the result may be empty.
2786 func_convert_core_path_wine_to_w32 ()
2787 {
2788 $debug_cmd
2789
2790 # unfortunately, winepath doesn't convert paths, only file names
2791 func_convert_core_path_wine_to_w32_result=
2792 if test -n "$1"; then
2793 oldIFS=$IFS
2794 IFS=:
2795 for func_convert_core_path_wine_to_w32_f in $1; do
2796 IFS=$oldIFS
2797 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2798 if test -n "$func_convert_core_file_wine_to_w32_result"; then
2799 if test -z "$func_convert_core_path_wine_to_w32_result"; then
2800 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2801 else
2802 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2803 fi
2804 fi
2805 done
2806 IFS=$oldIFS
2807 fi
2808 }
2809 # end: func_convert_core_path_wine_to_w32
2810
2811
2812 # func_cygpath ARGS...
2813 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2814 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2815 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2816 # (2), returns the Cygwin file name or path in func_cygpath_result (input
2817 # file name or path is assumed to be in w32 format, as previously converted
2818 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
2819 # or path in func_cygpath_result (input file name or path is assumed to be in
2820 # Cygwin format). Returns an empty string on error.
2821 #
2822 # ARGS are passed to cygpath, with the last one being the file name or path to
2823 # be converted.
2824 #
2825 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2826 # environment variable; do not put it in $PATH.
2827 func_cygpath ()
2828 {
2829 $debug_cmd
2830
2831 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2832 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2833 if test "$?" -ne 0; then
2834 # on failure, ensure result is empty
2835 func_cygpath_result=
2836 fi
2837 else
2838 func_cygpath_result=
2839 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2840 fi
2841 }
2842 #end: func_cygpath
2843
2844
2845 # func_convert_core_msys_to_w32 ARG
2846 # Convert file name or path ARG from MSYS format to w32 format. Return
2847 # result in func_convert_core_msys_to_w32_result.
2848 func_convert_core_msys_to_w32 ()
2849 {
2850 $debug_cmd
2851
2852 # awkward: cmd appends spaces to result
2853 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2854 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2855 }
2856 #end: func_convert_core_msys_to_w32
2857
2858
2859 # func_convert_file_check ARG1 ARG2
2860 # Verify that ARG1 (a file name in $build format) was converted to $host
2861 # format in ARG2. Otherwise, emit an error message, but continue (resetting
2862 # func_to_host_file_result to ARG1).
2863 func_convert_file_check ()
2864 {
2865 $debug_cmd
2866
2867 if test -z "$2" && test -n "$1"; then
2868 func_error "Could not determine host file name corresponding to"
2869 func_error " '$1'"
2870 func_error "Continuing, but uninstalled executables may not work."
2871 # Fallback:
2872 func_to_host_file_result=$1
2873 fi
2874 }
2875 # end func_convert_file_check
2876
2877
2878 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2879 # Verify that FROM_PATH (a path in $build format) was converted to $host
2880 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2881 # func_to_host_file_result to a simplistic fallback value (see below).
2882 func_convert_path_check ()
2883 {
2884 $debug_cmd
2885
2886 if test -z "$4" && test -n "$3"; then
2887 func_error "Could not determine the host path corresponding to"
2888 func_error " '$3'"
2889 func_error "Continuing, but uninstalled executables may not work."
2890 # Fallback. This is a deliberately simplistic "conversion" and
2891 # should not be "improved". See libtool.info.
2892 if test "x$1" != "x$2"; then
2893 lt_replace_pathsep_chars="s|$1|$2|g"
2894 func_to_host_path_result=`echo "$3" |
2895 $SED -e "$lt_replace_pathsep_chars"`
2896 else
2897 func_to_host_path_result=$3
2898 fi
2899 fi
2900 }
2901 # end func_convert_path_check
2902
2903
2904 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2905 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2906 # and appending REPL if ORIG matches BACKPAT.
2907 func_convert_path_front_back_pathsep ()
2908 {
2909 $debug_cmd
2910
2911 case $4 in
2912 $1 ) func_to_host_path_result=$3$func_to_host_path_result
2913 ;;
2914 esac
2915 case $4 in
2916 $2 ) func_append func_to_host_path_result "$3"
2917 ;;
2918 esac
2919 }
2920 # end func_convert_path_front_back_pathsep
2921
2922
2923 ##################################################
2924 # $build to $host FILE NAME CONVERSION FUNCTIONS #
2925 ##################################################
2926 # invoked via '$to_host_file_cmd ARG'
2927 #
2928 # In each case, ARG is the path to be converted from $build to $host format.
2929 # Result will be available in $func_to_host_file_result.
2930
2931
2932 # func_to_host_file ARG
2933 # Converts the file name ARG from $build format to $host format. Return result
2934 # in func_to_host_file_result.
2935 func_to_host_file ()
2936 {
2937 $debug_cmd
2938
2939 $to_host_file_cmd "$1"
2940 }
2941 # end func_to_host_file
2942
2943
2944 # func_to_tool_file ARG LAZY
2945 # converts the file name ARG from $build format to toolchain format. Return
2946 # result in func_to_tool_file_result. If the conversion in use is listed
2947 # in (the comma separated) LAZY, no conversion takes place.
2948 func_to_tool_file ()
2949 {
2950 $debug_cmd
2951
2952 case ,$2, in
2953 *,"$to_tool_file_cmd",*)
2954 func_to_tool_file_result=$1
2955 ;;
2956 *)
2957 $to_tool_file_cmd "$1"
2958 func_to_tool_file_result=$func_to_host_file_result
2959 ;;
2960 esac
2961 }
2962 # end func_to_tool_file
2963
2964
2965 # func_convert_file_noop ARG
2966 # Copy ARG to func_to_host_file_result.
2967 func_convert_file_noop ()
2968 {
2969 func_to_host_file_result=$1
2970 }
2971 # end func_convert_file_noop
2972
2973
2974 # func_convert_file_msys_to_w32 ARG
2975 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2976 # conversion to w32 is not available inside the cwrapper. Returns result in
2977 # func_to_host_file_result.
2978 func_convert_file_msys_to_w32 ()
2979 {
2980 $debug_cmd
2981
2982 func_to_host_file_result=$1
2983 if test -n "$1"; then
2984 func_convert_core_msys_to_w32 "$1"
2985 func_to_host_file_result=$func_convert_core_msys_to_w32_result
2986 fi
2987 func_convert_file_check "$1" "$func_to_host_file_result"
2988 }
2989 # end func_convert_file_msys_to_w32
2990
2991
2992 # func_convert_file_cygwin_to_w32 ARG
2993 # Convert file name ARG from Cygwin to w32 format. Returns result in
2994 # func_to_host_file_result.
2995 func_convert_file_cygwin_to_w32 ()
2996 {
2997 $debug_cmd
2998
2999 func_to_host_file_result=$1
3000 if test -n "$1"; then
3001 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3002 # LT_CYGPATH in this case.
3003 func_to_host_file_result=`cygpath -m "$1"`
3004 fi
3005 func_convert_file_check "$1" "$func_to_host_file_result"
3006 }
3007 # end func_convert_file_cygwin_to_w32
3008
3009
3010 # func_convert_file_nix_to_w32 ARG
3011 # Convert file name ARG from *nix to w32 format. Requires a wine environment
3012 # and a working winepath. Returns result in func_to_host_file_result.
3013 func_convert_file_nix_to_w32 ()
3014 {
3015 $debug_cmd
3016
3017 func_to_host_file_result=$1
3018 if test -n "$1"; then
3019 func_convert_core_file_wine_to_w32 "$1"
3020 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3021 fi
3022 func_convert_file_check "$1" "$func_to_host_file_result"
3023 }
3024 # end func_convert_file_nix_to_w32
3025
3026
3027 # func_convert_file_msys_to_cygwin ARG
3028 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3029 # Returns result in func_to_host_file_result.
3030 func_convert_file_msys_to_cygwin ()
3031 {
3032 $debug_cmd
3033
3034 func_to_host_file_result=$1
3035 if test -n "$1"; then
3036 func_convert_core_msys_to_w32 "$1"
3037 func_cygpath -u "$func_convert_core_msys_to_w32_result"
3038 func_to_host_file_result=$func_cygpath_result
3039 fi
3040 func_convert_file_check "$1" "$func_to_host_file_result"
3041 }
3042 # end func_convert_file_msys_to_cygwin
3043
3044
3045 # func_convert_file_nix_to_cygwin ARG
3046 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
3047 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
3048 # in func_to_host_file_result.
3049 func_convert_file_nix_to_cygwin ()
3050 {
3051 $debug_cmd
3052
3053 func_to_host_file_result=$1
3054 if test -n "$1"; then
3055 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3056 func_convert_core_file_wine_to_w32 "$1"
3057 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3058 func_to_host_file_result=$func_cygpath_result
3059 fi
3060 func_convert_file_check "$1" "$func_to_host_file_result"
3061 }
3062 # end func_convert_file_nix_to_cygwin
3063
3064
3065 #############################################
3066 # $build to $host PATH CONVERSION FUNCTIONS #
3067 #############################################
3068 # invoked via '$to_host_path_cmd ARG'
3069 #
3070 # In each case, ARG is the path to be converted from $build to $host format.
3071 # The result will be available in $func_to_host_path_result.
3072 #
3073 # Path separators are also converted from $build format to $host format. If
3074 # ARG begins or ends with a path separator character, it is preserved (but
3075 # converted to $host format) on output.
3076 #
3077 # All path conversion functions are named using the following convention:
3078 # file name conversion function : func_convert_file_X_to_Y ()
3079 # path conversion function : func_convert_path_X_to_Y ()
3080 # where, for any given $build/$host combination the 'X_to_Y' value is the
3081 # same. If conversion functions are added for new $build/$host combinations,
3082 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
3083 # will break.
3084
3085
3086 # func_init_to_host_path_cmd
3087 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
3088 # appropriate value, based on the value of $to_host_file_cmd.
3089 to_host_path_cmd=
3090 func_init_to_host_path_cmd ()
3091 {
3092 $debug_cmd
3093
3094 if test -z "$to_host_path_cmd"; then
3095 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3096 to_host_path_cmd=func_convert_path_$func_stripname_result
3097 fi
3098 }
3099
3100
3101 # func_to_host_path ARG
3102 # Converts the path ARG from $build format to $host format. Return result
3103 # in func_to_host_path_result.
3104 func_to_host_path ()
3105 {
3106 $debug_cmd
3107
3108 func_init_to_host_path_cmd
3109 $to_host_path_cmd "$1"
3110 }
3111 # end func_to_host_path
3112
3113
3114 # func_convert_path_noop ARG
3115 # Copy ARG to func_to_host_path_result.
3116 func_convert_path_noop ()
3117 {
3118 func_to_host_path_result=$1
3119 }
3120 # end func_convert_path_noop
3121
3122
3123 # func_convert_path_msys_to_w32 ARG
3124 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3125 # conversion to w32 is not available inside the cwrapper. Returns result in
3126 # func_to_host_path_result.
3127 func_convert_path_msys_to_w32 ()
3128 {
3129 $debug_cmd
3130
3131 func_to_host_path_result=$1
3132 if test -n "$1"; then
3133 # Remove leading and trailing path separator characters from ARG. MSYS
3134 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3135 # and winepath ignores them completely.
3136 func_stripname : : "$1"
3137 func_to_host_path_tmp1=$func_stripname_result
3138 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3139 func_to_host_path_result=$func_convert_core_msys_to_w32_result
3140 func_convert_path_check : ";" \
3141 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3142 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3143 fi
3144 }
3145 # end func_convert_path_msys_to_w32
3146
3147
3148 # func_convert_path_cygwin_to_w32 ARG
3149 # Convert path ARG from Cygwin to w32 format. Returns result in
3150 # func_to_host_file_result.
3151 func_convert_path_cygwin_to_w32 ()
3152 {
3153 $debug_cmd
3154
3155 func_to_host_path_result=$1
3156 if test -n "$1"; then
3157 # See func_convert_path_msys_to_w32:
3158 func_stripname : : "$1"
3159 func_to_host_path_tmp1=$func_stripname_result
3160 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3161 func_convert_path_check : ";" \
3162 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3163 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3164 fi
3165 }
3166 # end func_convert_path_cygwin_to_w32
3167
3168
3169 # func_convert_path_nix_to_w32 ARG
3170 # Convert path ARG from *nix to w32 format. Requires a wine environment and
3171 # a working winepath. Returns result in func_to_host_file_result.
3172 func_convert_path_nix_to_w32 ()
3173 {
3174 $debug_cmd
3175
3176 func_to_host_path_result=$1
3177 if test -n "$1"; then
3178 # See func_convert_path_msys_to_w32:
3179 func_stripname : : "$1"
3180 func_to_host_path_tmp1=$func_stripname_result
3181 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3182 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3183 func_convert_path_check : ";" \
3184 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3185 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3186 fi
3187 }
3188 # end func_convert_path_nix_to_w32
3189
3190
3191 # func_convert_path_msys_to_cygwin ARG
3192 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3193 # Returns result in func_to_host_file_result.
3194 func_convert_path_msys_to_cygwin ()
3195 {
3196 $debug_cmd
3197
3198 func_to_host_path_result=$1
3199 if test -n "$1"; then
3200 # See func_convert_path_msys_to_w32:
3201 func_stripname : : "$1"
3202 func_to_host_path_tmp1=$func_stripname_result
3203 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3204 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3205 func_to_host_path_result=$func_cygpath_result
3206 func_convert_path_check : : \
3207 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3208 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3209 fi
3210 }
3211 # end func_convert_path_msys_to_cygwin
3212
3213
3214 # func_convert_path_nix_to_cygwin ARG
3215 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
3216 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
3217 # func_to_host_file_result.
3218 func_convert_path_nix_to_cygwin ()
3219 {
3220 $debug_cmd
3221
3222 func_to_host_path_result=$1
3223 if test -n "$1"; then
3224 # Remove leading and trailing path separator characters from
3225 # ARG. msys behavior is inconsistent here, cygpath turns them
3226 # into '.;' and ';.', and winepath ignores them completely.
3227 func_stripname : : "$1"
3228 func_to_host_path_tmp1=$func_stripname_result
3229 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3230 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3231 func_to_host_path_result=$func_cygpath_result
3232 func_convert_path_check : : \
3233 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3234 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3235 fi
3236 }
3237 # end func_convert_path_nix_to_cygwin
3238
3239
3240 # func_dll_def_p FILE
3241 # True iff FILE is a Windows DLL '.def' file.
3242 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
3243 func_dll_def_p ()
3244 {
3245 $debug_cmd
3246
3247 func_dll_def_p_tmp=`$SED -n \
3248 -e 's/^[ ]*//' \
3249 -e '/^\(;.*\)*$/d' \
3250 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
3251 -e q \
3252 "$1"`
3253 test DEF = "$func_dll_def_p_tmp"
3254 }
3255
3256
3257 # func_mode_compile arg...
3258 func_mode_compile ()
3259 {
3260 $debug_cmd
3261
3262 # Get the compilation command and the source file.
3263 base_compile=
3264 srcfile=$nonopt # always keep a non-empty value in "srcfile"
3265 suppress_opt=yes
3266 suppress_output=
3267 arg_mode=normal
3268 libobj=
3269 later=
3270 pie_flag=
3271
3272 for arg
3273 do
3274 case $arg_mode in
3275 arg )
3276 # do not "continue". Instead, add this to base_compile
3277 lastarg=$arg
3278 arg_mode=normal
3279 ;;
3280
3281 target )
3282 libobj=$arg
3283 arg_mode=normal
3284 continue
3285 ;;
3286
3287 normal )
3288 # Accept any command-line options.
3289 case $arg in
3290 -o)
3291 test -n "$libobj" && \
3292 func_fatal_error "you cannot specify '-o' more than once"
3293 arg_mode=target
3294 continue
3295 ;;
3296
3297 -pie | -fpie | -fPIE)
3298 func_append pie_flag " $arg"
3299 continue
3300 ;;
3301
3302 -shared | -static | -prefer-pic | -prefer-non-pic)
3303 func_append later " $arg"
3304 continue
3305 ;;
3306
3307 -no-suppress)
3308 suppress_opt=no
3309 continue
3310 ;;
3311
3312 -Xcompiler)
3313 arg_mode=arg # the next one goes into the "base_compile" arg list
3314 continue # The current "srcfile" will either be retained or
3315 ;; # replaced later. I would guess that would be a bug.
3316
3317 -Wc,*)
3318 func_stripname '-Wc,' '' "$arg"
3319 args=$func_stripname_result
3320 lastarg=
3321 save_ifs=$IFS; IFS=,
3322 for arg in $args; do
3323 IFS=$save_ifs
3324 func_append_quoted lastarg "$arg"
3325 done
3326 IFS=$save_ifs
3327 func_stripname ' ' '' "$lastarg"
3328 lastarg=$func_stripname_result
3329
3330 # Add the arguments to base_compile.
3331 func_append base_compile " $lastarg"
3332 continue
3333 ;;
3334
3335 *)
3336 # Accept the current argument as the source file.
3337 # The previous "srcfile" becomes the current argument.
3338 #
3339 lastarg=$srcfile
3340 srcfile=$arg
3341 ;;
3342 esac # case $arg
3343 ;;
3344 esac # case $arg_mode
3345
3346 # Aesthetically quote the previous argument.
3347 func_append_quoted base_compile "$lastarg"
3348 done # for arg
3349
3350 case $arg_mode in
3351 arg)
3352 func_fatal_error "you must specify an argument for -Xcompile"
3353 ;;
3354 target)
3355 func_fatal_error "you must specify a target with '-o'"
3356 ;;
3357 *)
3358 # Get the name of the library object.
3359 test -z "$libobj" && {
3360 func_basename "$srcfile"
3361 libobj=$func_basename_result
3362 }
3363 ;;
3364 esac
3365
3366 # Recognize several different file suffixes.
3367 # If the user specifies -o file.o, it is replaced with file.lo
3368 case $libobj in
3369 *.[cCFSifmso] | \
3370 *.ada | *.adb | *.ads | *.asm | \
3371 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3372 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3373 func_xform "$libobj"
3374 libobj=$func_xform_result
3375 ;;
3376 esac
3377
3378 case $libobj in
3379 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3380 *)
3381 func_fatal_error "cannot determine name of library object from '$libobj'"
3382 ;;
3383 esac
3384
3385 func_infer_tag $base_compile
3386
3387 for arg in $later; do
3388 case $arg in
3389 -shared)
3390 test yes = "$build_libtool_libs" \
3391 || func_fatal_configuration "cannot build a shared library"
3392 build_old_libs=no
3393 continue
3394 ;;
3395
3396 -static)
3397 build_libtool_libs=no
3398 build_old_libs=yes
3399 continue
3400 ;;
3401
3402 -prefer-pic)
3403 pic_mode=yes
3404 continue
3405 ;;
3406
3407 -prefer-non-pic)
3408 pic_mode=no
3409 continue
3410 ;;
3411 esac
3412 done
3413
3414 func_quote_for_eval "$libobj"
3415 test "X$libobj" != "X$func_quote_for_eval_result" \
3416 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
3417 && func_warning "libobj name '$libobj' may not contain shell special characters."
3418 func_dirname_and_basename "$obj" "/" ""
3419 objname=$func_basename_result
3420 xdir=$func_dirname_result
3421 lobj=$xdir$objdir/$objname
3422
3423 test -z "$base_compile" && \
3424 func_fatal_help "you must specify a compilation command"
3425
3426 # Delete any leftover library objects.
3427 if test yes = "$build_old_libs"; then
3428 removelist="$obj $lobj $libobj ${libobj}T"
3429 else
3430 removelist="$lobj $libobj ${libobj}T"
3431 fi
3432
3433 # On Cygwin there's no "real" PIC flag so we must build both object types
3434 case $host_os in
3435 cygwin* | mingw* | pw32* | os2* | cegcc*)
3436 pic_mode=default
3437 ;;
3438 esac
3439 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3440 # non-PIC code in shared libraries is not supported
3441 pic_mode=default
3442 fi
3443
3444 # Calculate the filename of the output object if compiler does
3445 # not support -o with -c
3446 if test no = "$compiler_c_o"; then
3447 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3448 lockfile=$output_obj.lock
3449 else
3450 output_obj=
3451 need_locks=no
3452 lockfile=
3453 fi
3454
3455 # Lock this critical section if it is needed
3456 # We use this script file to make the link, it avoids creating a new file
3457 if test yes = "$need_locks"; then
3458 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3459 func_echo "Waiting for $lockfile to be removed"
3460 sleep 2
3461 done
3462 elif test warn = "$need_locks"; then
3463 if test -f "$lockfile"; then
3464 $ECHO "\
3465 *** ERROR, $lockfile exists and contains:
3466 `cat $lockfile 2>/dev/null`
3467
3468 This indicates that another process is trying to use the same
3469 temporary object file, and libtool could not work around it because
3470 your compiler does not support '-c' and '-o' together. If you
3471 repeat this compilation, it may succeed, by chance, but you had better
3472 avoid parallel builds (make -j) in this platform, or get a better
3473 compiler."
3474
3475 $opt_dry_run || $RM $removelist
3476 exit $EXIT_FAILURE
3477 fi
3478 func_append removelist " $output_obj"
3479 $ECHO "$srcfile" > "$lockfile"
3480 fi
3481
3482 $opt_dry_run || $RM $removelist
3483 func_append removelist " $lockfile"
3484 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3485
3486 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3487 srcfile=$func_to_tool_file_result
3488 func_quote_for_eval "$srcfile"
3489 qsrcfile=$func_quote_for_eval_result
3490
3491 # Only build a PIC object if we are building libtool libraries.
3492 if test yes = "$build_libtool_libs"; then
3493 # Without this assignment, base_compile gets emptied.
3494 fbsd_hideous_sh_bug=$base_compile
3495
3496 if test no != "$pic_mode"; then
3497 command="$base_compile $qsrcfile $pic_flag"
3498 else
3499 # Don't build PIC code
3500 command="$base_compile $qsrcfile"
3501 fi
3502
3503 func_mkdir_p "$xdir$objdir"
3504
3505 if test -z "$output_obj"; then
3506 # Place PIC objects in $objdir
3507 func_append command " -o $lobj"
3508 fi
3509
3510 func_show_eval_locale "$command" \
3511 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3512
3513 if test warn = "$need_locks" &&
3514 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3515 $ECHO "\
3516 *** ERROR, $lockfile contains:
3517 `cat $lockfile 2>/dev/null`
3518
3519 but it should contain:
3520 $srcfile
3521
3522 This indicates that another process is trying to use the same
3523 temporary object file, and libtool could not work around it because
3524 your compiler does not support '-c' and '-o' together. If you
3525 repeat this compilation, it may succeed, by chance, but you had better
3526 avoid parallel builds (make -j) in this platform, or get a better
3527 compiler."
3528
3529 $opt_dry_run || $RM $removelist
3530 exit $EXIT_FAILURE
3531 fi
3532
3533 # Just move the object if needed, then go on to compile the next one
3534 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3535 func_show_eval '$MV "$output_obj" "$lobj"' \
3536 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3537 fi
3538
3539 # Allow error messages only from the first compilation.
3540 if test yes = "$suppress_opt"; then
3541 suppress_output=' >/dev/null 2>&1'
3542 fi
3543 fi
3544
3545 # Only build a position-dependent object if we build old libraries.
3546 if test yes = "$build_old_libs"; then
3547 if test yes != "$pic_mode"; then
3548 # Don't build PIC code
3549 command="$base_compile $qsrcfile$pie_flag"
3550 else
3551 command="$base_compile $qsrcfile $pic_flag"
3552 fi
3553 if test yes = "$compiler_c_o"; then
3554 func_append command " -o $obj"
3555 fi
3556
3557 # Suppress compiler output if we already did a PIC compilation.
3558 func_append command "$suppress_output"
3559 func_show_eval_locale "$command" \
3560 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3561
3562 if test warn = "$need_locks" &&
3563 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3564 $ECHO "\
3565 *** ERROR, $lockfile contains:
3566 `cat $lockfile 2>/dev/null`
3567
3568 but it should contain:
3569 $srcfile
3570
3571 This indicates that another process is trying to use the same
3572 temporary object file, and libtool could not work around it because
3573 your compiler does not support '-c' and '-o' together. If you
3574 repeat this compilation, it may succeed, by chance, but you had better
3575 avoid parallel builds (make -j) in this platform, or get a better
3576 compiler."
3577
3578 $opt_dry_run || $RM $removelist
3579 exit $EXIT_FAILURE
3580 fi
3581
3582 # Just move the object if needed
3583 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3584 func_show_eval '$MV "$output_obj" "$obj"' \
3585 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3586 fi
3587 fi
3588
3589 $opt_dry_run || {
3590 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3591
3592 # Unlock the critical section if it was locked
3593 if test no != "$need_locks"; then
3594 removelist=$lockfile
3595 $RM "$lockfile"
3596 fi
3597 }
3598
3599 exit $EXIT_SUCCESS
3600 }
3601
3602 $opt_help || {
3603 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3604 }
3605
3606 func_mode_help ()
3607 {
3608 # We need to display help for each of the modes.
3609 case $opt_mode in
3610 "")
3611 # Generic help is extracted from the usage comments
3612 # at the start of this file.
3613 func_help
3614 ;;
3615
3616 clean)
3617 $ECHO \
3618 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3619
3620 Remove files from the build directory.
3621
3622 RM is the name of the program to use to delete files associated with each FILE
3623 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3624 to RM.
3625
3626 If FILE is a libtool library, object or program, all the files associated
3627 with it are deleted. Otherwise, only FILE itself is deleted using RM."
3628 ;;
3629
3630 compile)
3631 $ECHO \
3632 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3633
3634 Compile a source file into a libtool library object.
3635
3636 This mode accepts the following additional options:
3637
3638 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
3639 -no-suppress do not suppress compiler output for multiple passes
3640 -prefer-pic try to build PIC objects only
3641 -prefer-non-pic try to build non-PIC objects only
3642 -shared do not build a '.o' file suitable for static linking
3643 -static only build a '.o' file suitable for static linking
3644 -Wc,FLAG pass FLAG directly to the compiler
3645
3646 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
3647 from the given SOURCEFILE.
3648
3649 The output file name is determined by removing the directory component from
3650 SOURCEFILE, then substituting the C source code suffix '.c' with the
3651 library object suffix, '.lo'."
3652 ;;
3653
3654 execute)
3655 $ECHO \
3656 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3657
3658 Automatically set library path, then run a program.
3659
3660 This mode accepts the following additional options:
3661
3662 -dlopen FILE add the directory containing FILE to the library path
3663
3664 This mode sets the library path environment variable according to '-dlopen'
3665 flags.
3666
3667 If any of the ARGS are libtool executable wrappers, then they are translated
3668 into their corresponding uninstalled binary, and any of their required library
3669 directories are added to the library path.
3670
3671 Then, COMMAND is executed, with ARGS as arguments."
3672 ;;
3673
3674 finish)
3675 $ECHO \
3676 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3677
3678 Complete the installation of libtool libraries.
3679
3680 Each LIBDIR is a directory that contains libtool libraries.
3681
3682 The commands that this mode executes may require superuser privileges. Use
3683 the '--dry-run' option if you just want to see what would be executed."
3684 ;;
3685
3686 install)
3687 $ECHO \
3688 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3689
3690 Install executables or libraries.
3691
3692 INSTALL-COMMAND is the installation command. The first component should be
3693 either the 'install' or 'cp' program.
3694
3695 The following components of INSTALL-COMMAND are treated specially:
3696
3697 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
3698
3699 The rest of the components are interpreted as arguments to that command (only
3700 BSD-compatible install options are recognized)."
3701 ;;
3702
3703 link)
3704 $ECHO \
3705 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3706
3707 Link object files or libraries together to form another library, or to
3708 create an executable program.
3709
3710 LINK-COMMAND is a command using the C compiler that you would use to create
3711 a program from several object files.
3712
3713 The following components of LINK-COMMAND are treated specially:
3714
3715 -all-static do not do any dynamic linking at all
3716 -avoid-version do not add a version suffix if possible
3717 -bindir BINDIR specify path to binaries directory (for systems where
3718 libraries must be found in the PATH setting at runtime)
3719 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
3720 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
3721 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3722 -export-symbols SYMFILE
3723 try to export only the symbols listed in SYMFILE
3724 -export-symbols-regex REGEX
3725 try to export only the symbols matching REGEX
3726 -LLIBDIR search LIBDIR for required installed libraries
3727 -lNAME OUTPUT-FILE requires the installed library libNAME
3728 -module build a library that can dlopened
3729 -no-fast-install disable the fast-install mode
3730 -no-install link a not-installable executable
3731 -no-undefined declare that a library does not refer to external symbols
3732 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
3733 -objectlist FILE use a list of object files found in FILE to specify objects
3734 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
3735 -precious-files-regex REGEX
3736 don't remove output files matching REGEX
3737 -release RELEASE specify package release information
3738 -rpath LIBDIR the created library will eventually be installed in LIBDIR
3739 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
3740 -shared only do dynamic linking of libtool libraries
3741 -shrext SUFFIX override the standard shared library file extension
3742 -static do not do any dynamic linking of uninstalled libtool libraries
3743 -static-libtool-libs
3744 do not do any dynamic linking of libtool libraries
3745 -version-info CURRENT[:REVISION[:AGE]]
3746 specify library version info [each variable defaults to 0]
3747 -weak LIBNAME declare that the target provides the LIBNAME interface
3748 -Wc,FLAG
3749 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
3750 -Wl,FLAG
3751 -Xlinker FLAG pass linker-specific FLAG directly to the linker
3752 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
3753
3754 All other options (arguments beginning with '-') are ignored.
3755
3756 Every other argument is treated as a filename. Files ending in '.la' are
3757 treated as uninstalled libtool libraries, other files are standard or library
3758 object files.
3759
3760 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
3761 only library objects ('.lo' files) may be specified, and '-rpath' is
3762 required, except when creating a convenience library.
3763
3764 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3765 using 'ar' and 'ranlib', or on Windows using 'lib'.
3766
3767 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3768 is created, otherwise an executable program is created."
3769 ;;
3770
3771 uninstall)
3772 $ECHO \
3773 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3774
3775 Remove libraries from an installation directory.
3776
3777 RM is the name of the program to use to delete files associated with each FILE
3778 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3779 to RM.
3780
3781 If FILE is a libtool library, all the files associated with it are deleted.
3782 Otherwise, only FILE itself is deleted using RM."
3783 ;;
3784
3785 *)
3786 func_fatal_help "invalid operation mode '$opt_mode'"
3787 ;;
3788 esac
3789
3790 echo
3791 $ECHO "Try '$progname --help' for more information about other modes."
3792 }
3793
3794 # Now that we've collected a possible --mode arg, show help if necessary
3795 if $opt_help; then
3796 if test : = "$opt_help"; then
3797 func_mode_help
3798 else
3799 {
3800 func_help noexit
3801 for opt_mode in compile link execute install finish uninstall clean; do
3802 func_mode_help
3803 done
3804 } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
3805 {
3806 func_help noexit
3807 for opt_mode in compile link execute install finish uninstall clean; do
3808 echo
3809 func_mode_help
3810 done
3811 } |
3812 $SED '1d
3813 /^When reporting/,/^Report/{
3814 H
3815 d
3816 }
3817 $x
3818 /information about other modes/d
3819 /more detailed .*MODE/d
3820 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3821 fi
3822 exit $?
3823 fi
3824
3825
3826 # func_mode_execute arg...
3827 func_mode_execute ()
3828 {
3829 $debug_cmd
3830
3831 # The first argument is the command name.
3832 cmd=$nonopt
3833 test -z "$cmd" && \
3834 func_fatal_help "you must specify a COMMAND"
3835
3836 # Handle -dlopen flags immediately.
3837 for file in $opt_dlopen; do
3838 test -f "$file" \
3839 || func_fatal_help "'$file' is not a file"
3840
3841 dir=
3842 case $file in
3843 *.la)
3844 func_resolve_sysroot "$file"
3845 file=$func_resolve_sysroot_result
3846
3847 # Check to see that this really is a libtool archive.
3848 func_lalib_unsafe_p "$file" \
3849 || func_fatal_help "'$lib' is not a valid libtool archive"
3850
3851 # Read the libtool library.
3852 dlname=
3853 library_names=
3854 func_source "$file"
3855
3856 # Skip this library if it cannot be dlopened.
3857 if test -z "$dlname"; then
3858 # Warn if it was a shared library.
3859 test -n "$library_names" && \
3860 func_warning "'$file' was not linked with '-export-dynamic'"
3861 continue
3862 fi
3863
3864 func_dirname "$file" "" "."
3865 dir=$func_dirname_result
3866
3867 if test -f "$dir/$objdir/$dlname"; then
3868 func_append dir "/$objdir"
3869 else
3870 if test ! -f "$dir/$dlname"; then
3871 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3872 fi
3873 fi
3874 ;;
3875
3876 *.lo)
3877 # Just add the directory containing the .lo file.
3878 func_dirname "$file" "" "."
3879 dir=$func_dirname_result
3880 ;;
3881
3882 *)
3883 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3884 continue
3885 ;;
3886 esac
3887
3888 # Get the absolute pathname.
3889 absdir=`cd "$dir" && pwd`
3890 test -n "$absdir" && dir=$absdir
3891
3892 # Now add the directory to shlibpath_var.
3893 if eval "test -z \"\$$shlibpath_var\""; then
3894 eval "$shlibpath_var=\"\$dir\""
3895 else
3896 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3897 fi
3898 done
3899
3900 # This variable tells wrapper scripts just to set shlibpath_var
3901 # rather than running their programs.
3902 libtool_execute_magic=$magic
3903
3904 # Check if any of the arguments is a wrapper script.
3905 args=
3906 for file
3907 do
3908 case $file in
3909 -* | *.la | *.lo ) ;;
3910 *)
3911 # Do a test to see if this is really a libtool program.
3912 if func_ltwrapper_script_p "$file"; then
3913 func_source "$file"
3914 # Transform arg to wrapped name.
3915 file=$progdir/$program
3916 elif func_ltwrapper_executable_p "$file"; then
3917 func_ltwrapper_scriptname "$file"
3918 func_source "$func_ltwrapper_scriptname_result"
3919 # Transform arg to wrapped name.
3920 file=$progdir/$program
3921 fi
3922 ;;
3923 esac
3924 # Quote arguments (to preserve shell metacharacters).
3925 func_append_quoted args "$file"
3926 done
3927
3928 if $opt_dry_run; then
3929 # Display what would be done.
3930 if test -n "$shlibpath_var"; then
3931 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3932 echo "export $shlibpath_var"
3933 fi
3934 $ECHO "$cmd$args"
3935 exit $EXIT_SUCCESS
3936 else
3937 if test -n "$shlibpath_var"; then
3938 # Export the shlibpath_var.
3939 eval "export $shlibpath_var"
3940 fi
3941
3942 # Restore saved environment variables
3943 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3944 do
3945 eval "if test \"\${save_$lt_var+set}\" = set; then
3946 $lt_var=\$save_$lt_var; export $lt_var
3947 else
3948 $lt_unset $lt_var
3949 fi"
3950 done
3951
3952 # Now prepare to actually exec the command.
3953 exec_cmd=\$cmd$args
3954 fi
3955 }
3956
3957 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3958
3959
3960 # func_mode_finish arg...
3961 func_mode_finish ()
3962 {
3963 $debug_cmd
3964
3965 libs=
3966 libdirs=
3967 admincmds=
3968
3969 for opt in "$nonopt" ${1+"$@"}
3970 do
3971 if test -d "$opt"; then
3972 func_append libdirs " $opt"
3973
3974 elif test -f "$opt"; then
3975 if func_lalib_unsafe_p "$opt"; then
3976 func_append libs " $opt"
3977 else
3978 func_warning "'$opt' is not a valid libtool archive"
3979 fi
3980
3981 else
3982 func_fatal_error "invalid argument '$opt'"
3983 fi
3984 done
3985
3986 if test -n "$libs"; then
3987 if test -n "$lt_sysroot"; then
3988 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3989 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3990 else
3991 sysroot_cmd=
3992 fi
3993
3994 # Remove sysroot references
3995 if $opt_dry_run; then
3996 for lib in $libs; do
3997 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
3998 done
3999 else
4000 tmpdir=`func_mktempdir`
4001 for lib in $libs; do
4002 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4003 > $tmpdir/tmp-la
4004 mv -f $tmpdir/tmp-la $lib
4005 done
4006 ${RM}r "$tmpdir"
4007 fi
4008 fi
4009
4010 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4011 for libdir in $libdirs; do
4012 if test -n "$finish_cmds"; then
4013 # Do each command in the finish commands.
4014 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4015 '"$cmd"'"'
4016 fi
4017 if test -n "$finish_eval"; then
4018 # Do the single finish_eval.
4019 eval cmds=\"$finish_eval\"
4020 $opt_dry_run || eval "$cmds" || func_append admincmds "
4021 $cmds"
4022 fi
4023 done
4024 fi
4025
4026 # Exit here if they wanted silent mode.
4027 $opt_quiet && exit $EXIT_SUCCESS
4028
4029 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4030 echo "----------------------------------------------------------------------"
4031 echo "Libraries have been installed in:"
4032 for libdir in $libdirs; do
4033 $ECHO " $libdir"
4034 done
4035 echo
4036 echo "If you ever happen to want to link against installed libraries"
4037 echo "in a given directory, LIBDIR, you must either use libtool, and"
4038 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4039 echo "flag during linking and do at least one of the following:"
4040 if test -n "$shlibpath_var"; then
4041 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
4042 echo " during execution"
4043 fi
4044 if test -n "$runpath_var"; then
4045 echo " - add LIBDIR to the '$runpath_var' environment variable"
4046 echo " during linking"
4047 fi
4048 if test -n "$hardcode_libdir_flag_spec"; then
4049 libdir=LIBDIR
4050 eval flag=\"$hardcode_libdir_flag_spec\"
4051
4052 $ECHO " - use the '$flag' linker flag"
4053 fi
4054 if test -n "$admincmds"; then
4055 $ECHO " - have your system administrator run these commands:$admincmds"
4056 fi
4057 if test -f /etc/ld.so.conf; then
4058 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4059 fi
4060 echo
4061
4062 echo "See any operating system documentation about shared libraries for"
4063 case $host in
4064 solaris2.[6789]|solaris2.1[0-9])
4065 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4066 echo "pages."
4067 ;;
4068 *)
4069 echo "more information, such as the ld(1) and ld.so(8) manual pages."
4070 ;;
4071 esac
4072 echo "----------------------------------------------------------------------"
4073 fi
4074 exit $EXIT_SUCCESS
4075 }
4076
4077 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4078
4079
4080 # func_mode_install arg...
4081 func_mode_install ()
4082 {
4083 $debug_cmd
4084
4085 # There may be an optional sh(1) argument at the beginning of
4086 # install_prog (especially on Windows NT).
4087 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4088 # Allow the use of GNU shtool's install command.
4089 case $nonopt in *shtool*) :;; *) false;; esac
4090 then
4091 # Aesthetically quote it.
4092 func_quote_for_eval "$nonopt"
4093 install_prog="$func_quote_for_eval_result "
4094 arg=$1
4095 shift
4096 else
4097 install_prog=
4098 arg=$nonopt
4099 fi
4100
4101 # The real first argument should be the name of the installation program.
4102 # Aesthetically quote it.
4103 func_quote_for_eval "$arg"
4104 func_append install_prog "$func_quote_for_eval_result"
4105 install_shared_prog=$install_prog
4106 case " $install_prog " in
4107 *[\\\ /]cp\ *) install_cp=: ;;
4108 *) install_cp=false ;;
4109 esac
4110
4111 # We need to accept at least all the BSD install flags.
4112 dest=
4113 files=
4114 opts=
4115 prev=
4116 install_type=
4117 isdir=false
4118 stripme=
4119 no_mode=:
4120 for arg
4121 do
4122 arg2=
4123 if test -n "$dest"; then
4124 func_append files " $dest"
4125 dest=$arg
4126 continue
4127 fi
4128
4129 case $arg in
4130 -d) isdir=: ;;
4131 -f)
4132 if $install_cp; then :; else
4133 prev=$arg
4134 fi
4135 ;;
4136 -g | -m | -o)
4137 prev=$arg
4138 ;;
4139 -s)
4140 stripme=" -s"
4141 continue
4142 ;;
4143 -*)
4144 ;;
4145 *)
4146 # If the previous option needed an argument, then skip it.
4147 if test -n "$prev"; then
4148 if test X-m = "X$prev" && test -n "$install_override_mode"; then
4149 arg2=$install_override_mode
4150 no_mode=false
4151 fi
4152 prev=
4153 else
4154 dest=$arg
4155 continue
4156 fi
4157 ;;
4158 esac
4159
4160 # Aesthetically quote the argument.
4161 func_quote_for_eval "$arg"
4162 func_append install_prog " $func_quote_for_eval_result"
4163 if test -n "$arg2"; then
4164 func_quote_for_eval "$arg2"
4165 fi
4166 func_append install_shared_prog " $func_quote_for_eval_result"
4167 done
4168
4169 test -z "$install_prog" && \
4170 func_fatal_help "you must specify an install program"
4171
4172 test -n "$prev" && \
4173 func_fatal_help "the '$prev' option requires an argument"
4174
4175 if test -n "$install_override_mode" && $no_mode; then
4176 if $install_cp; then :; else
4177 func_quote_for_eval "$install_override_mode"
4178 func_append install_shared_prog " -m $func_quote_for_eval_result"
4179 fi
4180 fi
4181
4182 if test -z "$files"; then
4183 if test -z "$dest"; then
4184 func_fatal_help "no file or destination specified"
4185 else
4186 func_fatal_help "you must specify a destination"
4187 fi
4188 fi
4189
4190 # Strip any trailing slash from the destination.
4191 func_stripname '' '/' "$dest"
4192 dest=$func_stripname_result
4193
4194 # Check to see that the destination is a directory.
4195 test -d "$dest" && isdir=:
4196 if $isdir; then
4197 destdir=$dest
4198 destname=
4199 else
4200 func_dirname_and_basename "$dest" "" "."
4201 destdir=$func_dirname_result
4202 destname=$func_basename_result
4203
4204 # Not a directory, so check to see that there is only one file specified.
4205 set dummy $files; shift
4206 test "$#" -gt 1 && \
4207 func_fatal_help "'$dest' is not a directory"
4208 fi
4209 case $destdir in
4210 [\\/]* | [A-Za-z]:[\\/]*) ;;
4211 *)
4212 for file in $files; do
4213 case $file in
4214 *.lo) ;;
4215 *)
4216 func_fatal_help "'$destdir' must be an absolute directory name"
4217 ;;
4218 esac
4219 done
4220 ;;
4221 esac
4222
4223 # This variable tells wrapper scripts just to set variables rather
4224 # than running their programs.
4225 libtool_install_magic=$magic
4226
4227 staticlibs=
4228 future_libdirs=
4229 current_libdirs=
4230 for file in $files; do
4231
4232 # Do each installation.
4233 case $file in
4234 *.$libext)
4235 # Do the static libraries later.
4236 func_append staticlibs " $file"
4237 ;;
4238
4239 *.la)
4240 func_resolve_sysroot "$file"
4241 file=$func_resolve_sysroot_result
4242
4243 # Check to see that this really is a libtool archive.
4244 func_lalib_unsafe_p "$file" \
4245 || func_fatal_help "'$file' is not a valid libtool archive"
4246
4247 library_names=
4248 old_library=
4249 relink_command=
4250 func_source "$file"
4251
4252 # Add the libdir to current_libdirs if it is the destination.
4253 if test "X$destdir" = "X$libdir"; then
4254 case "$current_libdirs " in
4255 *" $libdir "*) ;;
4256 *) func_append current_libdirs " $libdir" ;;
4257 esac
4258 else
4259 # Note the libdir as a future libdir.
4260 case "$future_libdirs " in
4261 *" $libdir "*) ;;
4262 *) func_append future_libdirs " $libdir" ;;
4263 esac
4264 fi
4265
4266 func_dirname "$file" "/" ""
4267 dir=$func_dirname_result
4268 func_append dir "$objdir"
4269
4270 if test -n "$relink_command"; then
4271 # Determine the prefix the user has applied to our future dir.
4272 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4273
4274 # Don't allow the user to place us outside of our expected
4275 # location b/c this prevents finding dependent libraries that
4276 # are installed to the same prefix.
4277 # At present, this check doesn't affect windows .dll's that
4278 # are installed into $libdir/../bin (currently, that works fine)
4279 # but it's something to keep an eye on.
4280 test "$inst_prefix_dir" = "$destdir" && \
4281 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4282
4283 if test -n "$inst_prefix_dir"; then
4284 # Stick the inst_prefix_dir data into the link command.
4285 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4286 else
4287 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4288 fi
4289
4290 func_warning "relinking '$file'"
4291 func_show_eval "$relink_command" \
4292 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4293 fi
4294
4295 # See the names of the shared library.
4296 set dummy $library_names; shift
4297 if test -n "$1"; then
4298 realname=$1
4299 shift
4300
4301 srcname=$realname
4302 test -n "$relink_command" && srcname=${realname}T
4303
4304 # Install the shared library and build the symlinks.
4305 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4306 'exit $?'
4307 tstripme=$stripme
4308 case $host_os in
4309 cygwin* | mingw* | pw32* | cegcc*)
4310 case $realname in
4311 *.dll.a)
4312 tstripme=
4313 ;;
4314 esac
4315 ;;
4316 os2*)
4317 case $realname in
4318 *_dll.a)
4319 tstripme=
4320 ;;
4321 esac
4322 ;;
4323 esac
4324 if test -n "$tstripme" && test -n "$striplib"; then
4325 func_show_eval "$striplib $destdir/$realname" 'exit $?'
4326 fi
4327
4328 if test "$#" -gt 0; then
4329 # Delete the old symlinks, and create new ones.
4330 # Try 'ln -sf' first, because the 'ln' binary might depend on
4331 # the symlink we replace! Solaris /bin/ln does not understand -f,
4332 # so we also need to try rm && ln -s.
4333 for linkname
4334 do
4335 test "$linkname" != "$realname" \
4336 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4337 done
4338 fi
4339
4340 # Do each command in the postinstall commands.
4341 lib=$destdir/$realname
4342 func_execute_cmds "$postinstall_cmds" 'exit $?'
4343 fi
4344
4345 # Install the pseudo-library for information purposes.
4346 func_basename "$file"
4347 name=$func_basename_result
4348 instname=$dir/${name}i
4349 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4350
4351 # Maybe install the static library, too.
4352 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4353 ;;
4354
4355 *.lo)
4356 # Install (i.e. copy) a libtool object.
4357
4358 # Figure out destination file name, if it wasn't already specified.
4359 if test -n "$destname"; then
4360 destfile=$destdir/$destname
4361 else
4362 func_basename "$file"
4363 destfile=$func_basename_result
4364 destfile=$destdir/$destfile
4365 fi
4366
4367 # Deduce the name of the destination old-style object file.
4368 case $destfile in
4369 *.lo)
4370 func_lo2o "$destfile"
4371 staticdest=$func_lo2o_result
4372 ;;
4373 *.$objext)
4374 staticdest=$destfile
4375 destfile=
4376 ;;
4377 *)
4378 func_fatal_help "cannot copy a libtool object to '$destfile'"
4379 ;;
4380 esac
4381
4382 # Install the libtool object if requested.
4383 test -n "$destfile" && \
4384 func_show_eval "$install_prog $file $destfile" 'exit $?'
4385
4386 # Install the old object if enabled.
4387 if test yes = "$build_old_libs"; then
4388 # Deduce the name of the old-style object file.
4389 func_lo2o "$file"
4390 staticobj=$func_lo2o_result
4391 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4392 fi
4393 exit $EXIT_SUCCESS
4394 ;;
4395
4396 *)
4397 # Figure out destination file name, if it wasn't already specified.
4398 if test -n "$destname"; then
4399 destfile=$destdir/$destname
4400 else
4401 func_basename "$file"
4402 destfile=$func_basename_result
4403 destfile=$destdir/$destfile
4404 fi
4405
4406 # If the file is missing, and there is a .exe on the end, strip it
4407 # because it is most likely a libtool script we actually want to
4408 # install
4409 stripped_ext=
4410 case $file in
4411 *.exe)
4412 if test ! -f "$file"; then
4413 func_stripname '' '.exe' "$file"
4414 file=$func_stripname_result
4415 stripped_ext=.exe
4416 fi
4417 ;;
4418 esac
4419
4420 # Do a test to see if this is really a libtool program.
4421 case $host in
4422 *cygwin* | *mingw*)
4423 if func_ltwrapper_executable_p "$file"; then
4424 func_ltwrapper_scriptname "$file"
4425 wrapper=$func_ltwrapper_scriptname_result
4426 else
4427 func_stripname '' '.exe' "$file"
4428 wrapper=$func_stripname_result
4429 fi
4430 ;;
4431 *)
4432 wrapper=$file
4433 ;;
4434 esac
4435 if func_ltwrapper_script_p "$wrapper"; then
4436 notinst_deplibs=
4437 relink_command=
4438
4439 func_source "$wrapper"
4440
4441 # Check the variables that should have been set.
4442 test -z "$generated_by_libtool_version" && \
4443 func_fatal_error "invalid libtool wrapper script '$wrapper'"
4444
4445 finalize=:
4446 for lib in $notinst_deplibs; do
4447 # Check to see that each library is installed.
4448 libdir=
4449 if test -f "$lib"; then
4450 func_source "$lib"
4451 fi
4452 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4453 if test -n "$libdir" && test ! -f "$libfile"; then
4454 func_warning "'$lib' has not been installed in '$libdir'"
4455 finalize=false
4456 fi
4457 done
4458
4459 relink_command=
4460 func_source "$wrapper"
4461
4462 outputname=
4463 if test no = "$fast_install" && test -n "$relink_command"; then
4464 $opt_dry_run || {
4465 if $finalize; then
4466 tmpdir=`func_mktempdir`
4467 func_basename "$file$stripped_ext"
4468 file=$func_basename_result
4469 outputname=$tmpdir/$file
4470 # Replace the output file specification.
4471 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4472
4473 $opt_quiet || {
4474 func_quote_for_expand "$relink_command"
4475 eval "func_echo $func_quote_for_expand_result"
4476 }
4477 if eval "$relink_command"; then :
4478 else
4479 func_error "error: relink '$file' with the above command before installing it"
4480 $opt_dry_run || ${RM}r "$tmpdir"
4481 continue
4482 fi
4483 file=$outputname
4484 else
4485 func_warning "cannot relink '$file'"
4486 fi
4487 }
4488 else
4489 # Install the binary that we compiled earlier.
4490 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4491 fi
4492 fi
4493
4494 # remove .exe since cygwin /usr/bin/install will append another
4495 # one anyway
4496 case $install_prog,$host in
4497 */usr/bin/install*,*cygwin*)
4498 case $file:$destfile in
4499 *.exe:*.exe)
4500 # this is ok
4501 ;;
4502 *.exe:*)
4503 destfile=$destfile.exe
4504 ;;
4505 *:*.exe)
4506 func_stripname '' '.exe' "$destfile"
4507 destfile=$func_stripname_result
4508 ;;
4509 esac
4510 ;;
4511 esac
4512 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4513 $opt_dry_run || if test -n "$outputname"; then
4514 ${RM}r "$tmpdir"
4515 fi
4516 ;;
4517 esac
4518 done
4519
4520 for file in $staticlibs; do
4521 func_basename "$file"
4522 name=$func_basename_result
4523
4524 # Set up the ranlib parameters.
4525 oldlib=$destdir/$name
4526 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4527 tool_oldlib=$func_to_tool_file_result
4528
4529 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4530
4531 if test -n "$stripme" && test -n "$old_striplib"; then
4532 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4533 fi
4534
4535 # Do each command in the postinstall commands.
4536 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4537 done
4538
4539 test -n "$future_libdirs" && \
4540 func_warning "remember to run '$progname --finish$future_libdirs'"
4541
4542 if test -n "$current_libdirs"; then
4543 # Maybe just do a dry run.
4544 $opt_dry_run && current_libdirs=" -n$current_libdirs"
4545 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4546 else
4547 exit $EXIT_SUCCESS
4548 fi
4549 }
4550
4551 test install = "$opt_mode" && func_mode_install ${1+"$@"}
4552
4553
4554 # func_generate_dlsyms outputname originator pic_p
4555 # Extract symbols from dlprefiles and create ${outputname}S.o with
4556 # a dlpreopen symbol table.
4557 func_generate_dlsyms ()
4558 {
4559 $debug_cmd
4560
4561 my_outputname=$1
4562 my_originator=$2
4563 my_pic_p=${3-false}
4564 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4565 my_dlsyms=
4566
4567 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4568 if test -n "$NM" && test -n "$global_symbol_pipe"; then
4569 my_dlsyms=${my_outputname}S.c
4570 else
4571 func_error "not configured to extract global symbols from dlpreopened files"
4572 fi
4573 fi
4574
4575 if test -n "$my_dlsyms"; then
4576 case $my_dlsyms in
4577 "") ;;
4578 *.c)
4579 # Discover the nlist of each of the dlfiles.
4580 nlist=$output_objdir/$my_outputname.nm
4581
4582 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4583
4584 # Parse the name list into a source file.
4585 func_verbose "creating $output_objdir/$my_dlsyms"
4586
4587 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4588 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4589 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4590
4591 #ifdef __cplusplus
4592 extern \"C\" {
4593 #endif
4594
4595 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4596 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4597 #endif
4598
4599 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
4600 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4601 /* DATA imports from DLLs on WIN32 can't be const, because runtime
4602 relocations are performed -- see ld's documentation on pseudo-relocs. */
4603 # define LT_DLSYM_CONST
4604 #elif defined __osf__
4605 /* This system does not cope well with relocations in const data. */
4606 # define LT_DLSYM_CONST
4607 #else
4608 # define LT_DLSYM_CONST const
4609 #endif
4610
4611 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4612
4613 /* External symbol declarations for the compiler. */\
4614 "
4615
4616 if test yes = "$dlself"; then
4617 func_verbose "generating symbol list for '$output'"
4618
4619 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4620
4621 # Add our own program objects to the symbol list.
4622 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4623 for progfile in $progfiles; do
4624 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4625 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4626 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4627 done
4628
4629 if test -n "$exclude_expsyms"; then
4630 $opt_dry_run || {
4631 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4632 eval '$MV "$nlist"T "$nlist"'
4633 }
4634 fi
4635
4636 if test -n "$export_symbols_regex"; then
4637 $opt_dry_run || {
4638 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4639 eval '$MV "$nlist"T "$nlist"'
4640 }
4641 fi
4642
4643 # Prepare the list of exported symbols
4644 if test -z "$export_symbols"; then
4645 export_symbols=$output_objdir/$outputname.exp
4646 $opt_dry_run || {
4647 $RM $export_symbols
4648 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4649 case $host in
4650 *cygwin* | *mingw* | *cegcc* )
4651 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4652 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4653 ;;
4654 esac
4655 }
4656 else
4657 $opt_dry_run || {
4658 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4659 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4660 eval '$MV "$nlist"T "$nlist"'
4661 case $host in
4662 *cygwin* | *mingw* | *cegcc* )
4663 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4664 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4665 ;;
4666 esac
4667 }
4668 fi
4669 fi
4670
4671 for dlprefile in $dlprefiles; do
4672 func_verbose "extracting global C symbols from '$dlprefile'"
4673 func_basename "$dlprefile"
4674 name=$func_basename_result
4675 case $host in
4676 *cygwin* | *mingw* | *cegcc* )
4677 # if an import library, we need to obtain dlname
4678 if func_win32_import_lib_p "$dlprefile"; then
4679 func_tr_sh "$dlprefile"
4680 eval "curr_lafile=\$libfile_$func_tr_sh_result"
4681 dlprefile_dlbasename=
4682 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4683 # Use subshell, to avoid clobbering current variable values
4684 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4685 if test -n "$dlprefile_dlname"; then
4686 func_basename "$dlprefile_dlname"
4687 dlprefile_dlbasename=$func_basename_result
4688 else
4689 # no lafile. user explicitly requested -dlpreopen <import library>.
4690 $sharedlib_from_linklib_cmd "$dlprefile"
4691 dlprefile_dlbasename=$sharedlib_from_linklib_result
4692 fi
4693 fi
4694 $opt_dry_run || {
4695 if test -n "$dlprefile_dlbasename"; then
4696 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4697 else
4698 func_warning "Could not compute DLL name from $name"
4699 eval '$ECHO ": $name " >> "$nlist"'
4700 fi
4701 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4702 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4703 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4704 }
4705 else # not an import lib
4706 $opt_dry_run || {
4707 eval '$ECHO ": $name " >> "$nlist"'
4708 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4710 }
4711 fi
4712 ;;
4713 *)
4714 $opt_dry_run || {
4715 eval '$ECHO ": $name " >> "$nlist"'
4716 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4717 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4718 }
4719 ;;
4720 esac
4721 done
4722
4723 $opt_dry_run || {
4724 # Make sure we have at least an empty file.
4725 test -f "$nlist" || : > "$nlist"
4726
4727 if test -n "$exclude_expsyms"; then
4728 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4729 $MV "$nlist"T "$nlist"
4730 fi
4731
4732 # Try sorting and uniquifying the output.
4733 if $GREP -v "^: " < "$nlist" |
4734 if sort -k 3 </dev/null >/dev/null 2>&1; then
4735 sort -k 3
4736 else
4737 sort +2
4738 fi |
4739 uniq > "$nlist"S; then
4740 :
4741 else
4742 $GREP -v "^: " < "$nlist" > "$nlist"S
4743 fi
4744
4745 if test -f "$nlist"S; then
4746 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4747 else
4748 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4749 fi
4750
4751 func_show_eval '$RM "${nlist}I"'
4752 if test -n "$global_symbol_to_import"; then
4753 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4754 fi
4755
4756 echo >> "$output_objdir/$my_dlsyms" "\
4757
4758 /* The mapping between symbol names and symbols. */
4759 typedef struct {
4760 const char *name;
4761 void *address;
4762 } lt_dlsymlist;
4763 extern LT_DLSYM_CONST lt_dlsymlist
4764 lt_${my_prefix}_LTX_preloaded_symbols[];\
4765 "
4766
4767 if test -s "$nlist"I; then
4768 echo >> "$output_objdir/$my_dlsyms" "\
4769 static void lt_syminit(void)
4770 {
4771 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4772 for (; symbol->name; ++symbol)
4773 {"
4774 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4775 echo >> "$output_objdir/$my_dlsyms" "\
4776 }
4777 }"
4778 fi
4779 echo >> "$output_objdir/$my_dlsyms" "\
4780 LT_DLSYM_CONST lt_dlsymlist
4781 lt_${my_prefix}_LTX_preloaded_symbols[] =
4782 { {\"$my_originator\", (void *) 0},"
4783
4784 if test -s "$nlist"I; then
4785 echo >> "$output_objdir/$my_dlsyms" "\
4786 {\"@INIT@\", (void *) &lt_syminit},"
4787 fi
4788
4789 case $need_lib_prefix in
4790 no)
4791 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4792 ;;
4793 *)
4794 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4795 ;;
4796 esac
4797 echo >> "$output_objdir/$my_dlsyms" "\
4798 {0, (void *) 0}
4799 };
4800
4801 /* This works around a problem in FreeBSD linker */
4802 #ifdef FREEBSD_WORKAROUND
4803 static const void *lt_preloaded_setup() {
4804 return lt_${my_prefix}_LTX_preloaded_symbols;
4805 }
4806 #endif
4807
4808 #ifdef __cplusplus
4809 }
4810 #endif\
4811 "
4812 } # !$opt_dry_run
4813
4814 pic_flag_for_symtable=
4815 case "$compile_command " in
4816 *" -static "*) ;;
4817 *)
4818 case $host in
4819 # compiling the symbol table file with pic_flag works around
4820 # a FreeBSD bug that causes programs to crash when -lm is
4821 # linked before any other PIC object. But we must not use
4822 # pic_flag when linking with -static. The problem exists in
4823 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4824 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4825 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4826 *-*-hpux*)
4827 pic_flag_for_symtable=" $pic_flag" ;;
4828 *)
4829 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4830 ;;
4831 esac
4832 ;;
4833 esac
4834 symtab_cflags=
4835 for arg in $LTCFLAGS; do
4836 case $arg in
4837 -pie | -fpie | -fPIE) ;;
4838 *) func_append symtab_cflags " $arg" ;;
4839 esac
4840 done
4841
4842 # Now compile the dynamic symbol file.
4843 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4844
4845 # Clean up the generated files.
4846 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4847
4848 # Transform the symbol file into the correct name.
4849 symfileobj=$output_objdir/${my_outputname}S.$objext
4850 case $host in
4851 *cygwin* | *mingw* | *cegcc* )
4852 if test -f "$output_objdir/$my_outputname.def"; then
4853 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4854 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4855 else
4856 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4857 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4858 fi
4859 ;;
4860 *)
4861 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4862 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4863 ;;
4864 esac
4865 ;;
4866 *)
4867 func_fatal_error "unknown suffix for '$my_dlsyms'"
4868 ;;
4869 esac
4870 else
4871 # We keep going just in case the user didn't refer to
4872 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
4873 # really was required.
4874
4875 # Nullify the symbol file.
4876 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4877 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4878 fi
4879 }
4880
4881 # func_cygming_gnu_implib_p ARG
4882 # This predicate returns with zero status (TRUE) if
4883 # ARG is a GNU/binutils-style import library. Returns
4884 # with nonzero status (FALSE) otherwise.
4885 func_cygming_gnu_implib_p ()
4886 {
4887 $debug_cmd
4888
4889 func_to_tool_file "$1" func_convert_file_msys_to_w32
4890 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
4891 test -n "$func_cygming_gnu_implib_tmp"
4892 }
4893
4894 # func_cygming_ms_implib_p ARG
4895 # This predicate returns with zero status (TRUE) if
4896 # ARG is an MS-style import library. Returns
4897 # with nonzero status (FALSE) otherwise.
4898 func_cygming_ms_implib_p ()
4899 {
4900 $debug_cmd
4901
4902 func_to_tool_file "$1" func_convert_file_msys_to_w32
4903 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4904 test -n "$func_cygming_ms_implib_tmp"
4905 }
4906
4907 # func_win32_libid arg
4908 # return the library type of file 'arg'
4909 #
4910 # Need a lot of goo to handle *both* DLLs and import libs
4911 # Has to be a shell function in order to 'eat' the argument
4912 # that is supplied when $file_magic_command is called.
4913 # Despite the name, also deal with 64 bit binaries.
4914 func_win32_libid ()
4915 {
4916 $debug_cmd
4917
4918 win32_libid_type=unknown
4919 win32_fileres=`file -L $1 2>/dev/null`
4920 case $win32_fileres in
4921 *ar\ archive\ import\ library*) # definitely import
4922 win32_libid_type="x86 archive import"
4923 ;;
4924 *ar\ archive*) # could be an import, or static
4925 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4926 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4927 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4928 case $nm_interface in
4929 "MS dumpbin")
4930 if func_cygming_ms_implib_p "$1" ||
4931 func_cygming_gnu_implib_p "$1"
4932 then
4933 win32_nmres=import
4934 else
4935 win32_nmres=
4936 fi
4937 ;;
4938 *)
4939 func_to_tool_file "$1" func_convert_file_msys_to_w32
4940 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4941 $SED -n -e '
4942 1,100{
4943 / I /{
4944 s|.*|import|
4945 p
4946 q
4947 }
4948 }'`
4949 ;;
4950 esac
4951 case $win32_nmres in
4952 import*) win32_libid_type="x86 archive import";;
4953 *) win32_libid_type="x86 archive static";;
4954 esac
4955 fi
4956 ;;
4957 *DLL*)
4958 win32_libid_type="x86 DLL"
4959 ;;
4960 *executable*) # but shell scripts are "executable" too...
4961 case $win32_fileres in
4962 *MS\ Windows\ PE\ Intel*)
4963 win32_libid_type="x86 DLL"
4964 ;;
4965 esac
4966 ;;
4967 esac
4968 $ECHO "$win32_libid_type"
4969 }
4970
4971 # func_cygming_dll_for_implib ARG
4972 #
4973 # Platform-specific function to extract the
4974 # name of the DLL associated with the specified
4975 # import library ARG.
4976 # Invoked by eval'ing the libtool variable
4977 # $sharedlib_from_linklib_cmd
4978 # Result is available in the variable
4979 # $sharedlib_from_linklib_result
4980 func_cygming_dll_for_implib ()
4981 {
4982 $debug_cmd
4983
4984 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4985 }
4986
4987 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4988 #
4989 # The is the core of a fallback implementation of a
4990 # platform-specific function to extract the name of the
4991 # DLL associated with the specified import library LIBNAME.
4992 #
4993 # SECTION_NAME is either .idata$6 or .idata$7, depending
4994 # on the platform and compiler that created the implib.
4995 #
4996 # Echos the name of the DLL associated with the
4997 # specified import library.
4998 func_cygming_dll_for_implib_fallback_core ()
4999 {
5000 $debug_cmd
5001
5002 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5003 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5004 $SED '/^Contents of section '"$match_literal"':/{
5005 # Place marker at beginning of archive member dllname section
5006 s/.*/====MARK====/
5007 p
5008 d
5009 }
5010 # These lines can sometimes be longer than 43 characters, but
5011 # are always uninteresting
5012 /:[ ]*file format pe[i]\{,1\}-/d
5013 /^In archive [^:]*:/d
5014 # Ensure marker is printed
5015 /^====MARK====/p
5016 # Remove all lines with less than 43 characters
5017 /^.\{43\}/!d
5018 # From remaining lines, remove first 43 characters
5019 s/^.\{43\}//' |
5020 $SED -n '
5021 # Join marker and all lines until next marker into a single line
5022 /^====MARK====/ b para
5023 H
5024 $ b para
5025 b
5026 :para
5027 x
5028 s/\n//g
5029 # Remove the marker
5030 s/^====MARK====//
5031 # Remove trailing dots and whitespace
5032 s/[\. \t]*$//
5033 # Print
5034 /./p' |
5035 # we now have a list, one entry per line, of the stringified
5036 # contents of the appropriate section of all members of the
5037 # archive that possess that section. Heuristic: eliminate
5038 # all those that have a first or second character that is
5039 # a '.' (that is, objdump's representation of an unprintable
5040 # character.) This should work for all archives with less than
5041 # 0x302f exports -- but will fail for DLLs whose name actually
5042 # begins with a literal '.' or a single character followed by
5043 # a '.'.
5044 #
5045 # Of those that remain, print the first one.
5046 $SED -e '/^\./d;/^.\./d;q'
5047 }
5048
5049 # func_cygming_dll_for_implib_fallback ARG
5050 # Platform-specific function to extract the
5051 # name of the DLL associated with the specified
5052 # import library ARG.
5053 #
5054 # This fallback implementation is for use when $DLLTOOL
5055 # does not support the --identify-strict option.
5056 # Invoked by eval'ing the libtool variable
5057 # $sharedlib_from_linklib_cmd
5058 # Result is available in the variable
5059 # $sharedlib_from_linklib_result
5060 func_cygming_dll_for_implib_fallback ()
5061 {
5062 $debug_cmd
5063
5064 if func_cygming_gnu_implib_p "$1"; then
5065 # binutils import library
5066 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5067 elif func_cygming_ms_implib_p "$1"; then
5068 # ms-generated import library
5069 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5070 else
5071 # unknown
5072 sharedlib_from_linklib_result=
5073 fi
5074 }
5075
5076
5077 # func_extract_an_archive dir oldlib
5078 func_extract_an_archive ()
5079 {
5080 $debug_cmd
5081
5082 f_ex_an_ar_dir=$1; shift
5083 f_ex_an_ar_oldlib=$1
5084 if test yes = "$lock_old_archive_extraction"; then
5085 lockfile=$f_ex_an_ar_oldlib.lock
5086 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5087 func_echo "Waiting for $lockfile to be removed"
5088 sleep 2
5089 done
5090 fi
5091 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5092 'stat=$?; rm -f "$lockfile"; exit $stat'
5093 if test yes = "$lock_old_archive_extraction"; then
5094 $opt_dry_run || rm -f "$lockfile"
5095 fi
5096 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5097 :
5098 else
5099 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5100 fi
5101 }
5102
5103
5104 # func_extract_archives gentop oldlib ...
5105 func_extract_archives ()
5106 {
5107 $debug_cmd
5108
5109 my_gentop=$1; shift
5110 my_oldlibs=${1+"$@"}
5111 my_oldobjs=
5112 my_xlib=
5113 my_xabs=
5114 my_xdir=
5115
5116 for my_xlib in $my_oldlibs; do
5117 # Extract the objects.
5118 case $my_xlib in
5119 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5120 *) my_xabs=`pwd`"/$my_xlib" ;;
5121 esac
5122 func_basename "$my_xlib"
5123 my_xlib=$func_basename_result
5124 my_xlib_u=$my_xlib
5125 while :; do
5126 case " $extracted_archives " in
5127 *" $my_xlib_u "*)
5128 func_arith $extracted_serial + 1
5129 extracted_serial=$func_arith_result
5130 my_xlib_u=lt$extracted_serial-$my_xlib ;;
5131 *) break ;;
5132 esac
5133 done
5134 extracted_archives="$extracted_archives $my_xlib_u"
5135 my_xdir=$my_gentop/$my_xlib_u
5136
5137 func_mkdir_p "$my_xdir"
5138
5139 case $host in
5140 *-darwin*)
5141 func_verbose "Extracting $my_xabs"
5142 # Do not bother doing anything if just a dry run
5143 $opt_dry_run || {
5144 darwin_orig_dir=`pwd`
5145 cd $my_xdir || exit $?
5146 darwin_archive=$my_xabs
5147 darwin_curdir=`pwd`
5148 func_basename "$darwin_archive"
5149 darwin_base_archive=$func_basename_result
5150 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5151 if test -n "$darwin_arches"; then
5152 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5153 darwin_arch=
5154 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5155 for darwin_arch in $darwin_arches; do
5156 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5157 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5158 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5159 func_extract_an_archive "`pwd`" "$darwin_base_archive"
5160 cd "$darwin_curdir"
5161 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5162 done # $darwin_arches
5163 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5164 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5165 darwin_file=
5166 darwin_files=
5167 for darwin_file in $darwin_filelist; do
5168 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5169 $LIPO -create -output "$darwin_file" $darwin_files
5170 done # $darwin_filelist
5171 $RM -rf unfat-$$
5172 cd "$darwin_orig_dir"
5173 else
5174 cd $darwin_orig_dir
5175 func_extract_an_archive "$my_xdir" "$my_xabs"
5176 fi # $darwin_arches
5177 } # !$opt_dry_run
5178 ;;
5179 *)
5180 func_extract_an_archive "$my_xdir" "$my_xabs"
5181 ;;
5182 esac
5183 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5184 done
5185
5186 func_extract_archives_result=$my_oldobjs
5187 }
5188
5189
5190 # func_emit_wrapper [arg=no]
5191 #
5192 # Emit a libtool wrapper script on stdout.
5193 # Don't directly open a file because we may want to
5194 # incorporate the script contents within a cygwin/mingw
5195 # wrapper executable. Must ONLY be called from within
5196 # func_mode_link because it depends on a number of variables
5197 # set therein.
5198 #
5199 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5200 # variable will take. If 'yes', then the emitted script
5201 # will assume that the directory where it is stored is
5202 # the $objdir directory. This is a cygwin/mingw-specific
5203 # behavior.
5204 func_emit_wrapper ()
5205 {
5206 func_emit_wrapper_arg1=${1-no}
5207
5208 $ECHO "\
5209 #! $SHELL
5210
5211 # $output - temporary wrapper script for $objdir/$outputname
5212 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5213 #
5214 # The $output program cannot be directly executed until all the libtool
5215 # libraries that it depends on are installed.
5216 #
5217 # This wrapper script should never be moved out of the build directory.
5218 # If it is, it will not operate correctly.
5219
5220 # Sed substitution that helps us do robust quoting. It backslashifies
5221 # metacharacters that are still active within double-quoted strings.
5222 sed_quote_subst='$sed_quote_subst'
5223
5224 # Be Bourne compatible
5225 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5226 emulate sh
5227 NULLCMD=:
5228 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5229 # is contrary to our usage. Disable this feature.
5230 alias -g '\${1+\"\$@\"}'='\"\$@\"'
5231 setopt NO_GLOB_SUBST
5232 else
5233 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5234 fi
5235 BIN_SH=xpg4; export BIN_SH # for Tru64
5236 DUALCASE=1; export DUALCASE # for MKS sh
5237
5238 # The HP-UX ksh and POSIX shell print the target directory to stdout
5239 # if CDPATH is set.
5240 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5241
5242 relink_command=\"$relink_command\"
5243
5244 # This environment variable determines our operation mode.
5245 if test \"\$libtool_install_magic\" = \"$magic\"; then
5246 # install mode needs the following variables:
5247 generated_by_libtool_version='$macro_version'
5248 notinst_deplibs='$notinst_deplibs'
5249 else
5250 # When we are sourced in execute mode, \$file and \$ECHO are already set.
5251 if test \"\$libtool_execute_magic\" != \"$magic\"; then
5252 file=\"\$0\""
5253
5254 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5255 $ECHO "\
5256
5257 # A function that is used when there is no print builtin or printf.
5258 func_fallback_echo ()
5259 {
5260 eval 'cat <<_LTECHO_EOF
5261 \$1
5262 _LTECHO_EOF'
5263 }
5264 ECHO=\"$qECHO\"
5265 fi
5266
5267 # Very basic option parsing. These options are (a) specific to
5268 # the libtool wrapper, (b) are identical between the wrapper
5269 # /script/ and the wrapper /executable/ that is used only on
5270 # windows platforms, and (c) all begin with the string "--lt-"
5271 # (application programs are unlikely to have options that match
5272 # this pattern).
5273 #
5274 # There are only two supported options: --lt-debug and
5275 # --lt-dump-script. There is, deliberately, no --lt-help.
5276 #
5277 # The first argument to this parsing function should be the
5278 # script's $0 value, followed by "$@".
5279 lt_option_debug=
5280 func_parse_lt_options ()
5281 {
5282 lt_script_arg0=\$0
5283 shift
5284 for lt_opt
5285 do
5286 case \"\$lt_opt\" in
5287 --lt-debug) lt_option_debug=1 ;;
5288 --lt-dump-script)
5289 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5290 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5291 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5292 cat \"\$lt_dump_D/\$lt_dump_F\"
5293 exit 0
5294 ;;
5295 --lt-*)
5296 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5297 exit 1
5298 ;;
5299 esac
5300 done
5301
5302 # Print the debug banner immediately:
5303 if test -n \"\$lt_option_debug\"; then
5304 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5305 fi
5306 }
5307
5308 # Used when --lt-debug. Prints its arguments to stdout
5309 # (redirection is the responsibility of the caller)
5310 func_lt_dump_args ()
5311 {
5312 lt_dump_args_N=1;
5313 for lt_arg
5314 do
5315 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5316 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5317 done
5318 }
5319
5320 # Core function for launching the target application
5321 func_exec_program_core ()
5322 {
5323 "
5324 case $host in
5325 # Backslashes separate directories on plain windows
5326 *-*-mingw | *-*-os2* | *-cegcc*)
5327 $ECHO "\
5328 if test -n \"\$lt_option_debug\"; then
5329 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5330 func_lt_dump_args \${1+\"\$@\"} 1>&2
5331 fi
5332 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5333 "
5334 ;;
5335
5336 *)
5337 $ECHO "\
5338 if test -n \"\$lt_option_debug\"; then
5339 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5340 func_lt_dump_args \${1+\"\$@\"} 1>&2
5341 fi
5342 exec \"\$progdir/\$program\" \${1+\"\$@\"}
5343 "
5344 ;;
5345 esac
5346 $ECHO "\
5347 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5348 exit 1
5349 }
5350
5351 # A function to encapsulate launching the target application
5352 # Strips options in the --lt-* namespace from \$@ and
5353 # launches target application with the remaining arguments.
5354 func_exec_program ()
5355 {
5356 case \" \$* \" in
5357 *\\ --lt-*)
5358 for lt_wr_arg
5359 do
5360 case \$lt_wr_arg in
5361 --lt-*) ;;
5362 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5363 esac
5364 shift
5365 done ;;
5366 esac
5367 func_exec_program_core \${1+\"\$@\"}
5368 }
5369
5370 # Parse options
5371 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5372
5373 # Find the directory that this script lives in.
5374 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5375 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5376
5377 # Follow symbolic links until we get to the real thisdir.
5378 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5379 while test -n \"\$file\"; do
5380 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5381
5382 # If there was a directory component, then change thisdir.
5383 if test \"x\$destdir\" != \"x\$file\"; then
5384 case \"\$destdir\" in
5385 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5386 *) thisdir=\"\$thisdir/\$destdir\" ;;
5387 esac
5388 fi
5389
5390 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5391 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5392 done
5393
5394 # Usually 'no', except on cygwin/mingw when embedded into
5395 # the cwrapper.
5396 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5397 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5398 # special case for '.'
5399 if test \"\$thisdir\" = \".\"; then
5400 thisdir=\`pwd\`
5401 fi
5402 # remove .libs from thisdir
5403 case \"\$thisdir\" in
5404 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5405 $objdir ) thisdir=. ;;
5406 esac
5407 fi
5408
5409 # Try to get the absolute directory name.
5410 absdir=\`cd \"\$thisdir\" && pwd\`
5411 test -n \"\$absdir\" && thisdir=\"\$absdir\"
5412 "
5413
5414 if test yes = "$fast_install"; then
5415 $ECHO "\
5416 program=lt-'$outputname'$exeext
5417 progdir=\"\$thisdir/$objdir\"
5418
5419 if test ! -f \"\$progdir/\$program\" ||
5420 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5421 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5422
5423 file=\"\$\$-\$program\"
5424
5425 if test ! -d \"\$progdir\"; then
5426 $MKDIR \"\$progdir\"
5427 else
5428 $RM \"\$progdir/\$file\"
5429 fi"
5430
5431 $ECHO "\
5432
5433 # relink executable if necessary
5434 if test -n \"\$relink_command\"; then
5435 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5436 else
5437 \$ECHO \"\$relink_command_output\" >&2
5438 $RM \"\$progdir/\$file\"
5439 exit 1
5440 fi
5441 fi
5442
5443 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5444 { $RM \"\$progdir/\$program\";
5445 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5446 $RM \"\$progdir/\$file\"
5447 fi"
5448 else
5449 $ECHO "\
5450 program='$outputname'
5451 progdir=\"\$thisdir/$objdir\"
5452 "
5453 fi
5454
5455 $ECHO "\
5456
5457 if test -f \"\$progdir/\$program\"; then"
5458
5459 # fixup the dll searchpath if we need to.
5460 #
5461 # Fix the DLL searchpath if we need to. Do this before prepending
5462 # to shlibpath, because on Windows, both are PATH and uninstalled
5463 # libraries must come first.
5464 if test -n "$dllsearchpath"; then
5465 $ECHO "\
5466 # Add the dll search path components to the executable PATH
5467 PATH=$dllsearchpath:\$PATH
5468 "
5469 fi
5470
5471 # Export our shlibpath_var if we have one.
5472 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5473 $ECHO "\
5474 # Add our own library path to $shlibpath_var
5475 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5476
5477 # Some systems cannot cope with colon-terminated $shlibpath_var
5478 # The second colon is a workaround for a bug in BeOS R4 sed
5479 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5480
5481 export $shlibpath_var
5482 "
5483 fi
5484
5485 $ECHO "\
5486 if test \"\$libtool_execute_magic\" != \"$magic\"; then
5487 # Run the actual program with our arguments.
5488 func_exec_program \${1+\"\$@\"}
5489 fi
5490 else
5491 # The program doesn't exist.
5492 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5493 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5494 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5495 exit 1
5496 fi
5497 fi\
5498 "
5499 }
5500
5501
5502 # func_emit_cwrapperexe_src
5503 # emit the source code for a wrapper executable on stdout
5504 # Must ONLY be called from within func_mode_link because
5505 # it depends on a number of variable set therein.
5506 func_emit_cwrapperexe_src ()
5507 {
5508 cat <<EOF
5509
5510 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5511 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5512
5513 The $output program cannot be directly executed until all the libtool
5514 libraries that it depends on are installed.
5515
5516 This wrapper executable should never be moved out of the build directory.
5517 If it is, it will not operate correctly.
5518 */
5519 EOF
5520 cat <<"EOF"
5521 #ifdef _MSC_VER
5522 # define _CRT_SECURE_NO_DEPRECATE 1
5523 #endif
5524 #include <stdio.h>
5525 #include <stdlib.h>
5526 #ifdef _MSC_VER
5527 # include <direct.h>
5528 # include <process.h>
5529 # include <io.h>
5530 #else
5531 # include <unistd.h>
5532 # include <stdint.h>
5533 # ifdef __CYGWIN__
5534 # include <io.h>
5535 # endif
5536 #endif
5537 #include <malloc.h>
5538 #include <stdarg.h>
5539 #include <assert.h>
5540 #include <string.h>
5541 #include <ctype.h>
5542 #include <errno.h>
5543 #include <fcntl.h>
5544 #include <sys/stat.h>
5545
5546 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5547
5548 /* declarations of non-ANSI functions */
5549 #if defined __MINGW32__
5550 # ifdef __STRICT_ANSI__
5551 int _putenv (const char *);
5552 # endif
5553 #elif defined __CYGWIN__
5554 # ifdef __STRICT_ANSI__
5555 char *realpath (const char *, char *);
5556 int putenv (char *);
5557 int setenv (const char *, const char *, int);
5558 # endif
5559 /* #elif defined other_platform || defined ... */
5560 #endif
5561
5562 /* portability defines, excluding path handling macros */
5563 #if defined _MSC_VER
5564 # define setmode _setmode
5565 # define stat _stat
5566 # define chmod _chmod
5567 # define getcwd _getcwd
5568 # define putenv _putenv
5569 # define S_IXUSR _S_IEXEC
5570 #elif defined __MINGW32__
5571 # define setmode _setmode
5572 # define stat _stat
5573 # define chmod _chmod
5574 # define getcwd _getcwd
5575 # define putenv _putenv
5576 #elif defined __CYGWIN__
5577 # define HAVE_SETENV
5578 # define FOPEN_WB "wb"
5579 /* #elif defined other platforms ... */
5580 #endif
5581
5582 #if defined PATH_MAX
5583 # define LT_PATHMAX PATH_MAX
5584 #elif defined MAXPATHLEN
5585 # define LT_PATHMAX MAXPATHLEN
5586 #else
5587 # define LT_PATHMAX 1024
5588 #endif
5589
5590 #ifndef S_IXOTH
5591 # define S_IXOTH 0
5592 #endif
5593 #ifndef S_IXGRP
5594 # define S_IXGRP 0
5595 #endif
5596
5597 /* path handling portability macros */
5598 #ifndef DIR_SEPARATOR
5599 # define DIR_SEPARATOR '/'
5600 # define PATH_SEPARATOR ':'
5601 #endif
5602
5603 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5604 defined __OS2__
5605 # define HAVE_DOS_BASED_FILE_SYSTEM
5606 # define FOPEN_WB "wb"
5607 # ifndef DIR_SEPARATOR_2
5608 # define DIR_SEPARATOR_2 '\\'
5609 # endif
5610 # ifndef PATH_SEPARATOR_2
5611 # define PATH_SEPARATOR_2 ';'
5612 # endif
5613 #endif
5614
5615 #ifndef DIR_SEPARATOR_2
5616 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5617 #else /* DIR_SEPARATOR_2 */
5618 # define IS_DIR_SEPARATOR(ch) \
5619 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5620 #endif /* DIR_SEPARATOR_2 */
5621
5622 #ifndef PATH_SEPARATOR_2
5623 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5624 #else /* PATH_SEPARATOR_2 */
5625 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5626 #endif /* PATH_SEPARATOR_2 */
5627
5628 #ifndef FOPEN_WB
5629 # define FOPEN_WB "w"
5630 #endif
5631 #ifndef _O_BINARY
5632 # define _O_BINARY 0
5633 #endif
5634
5635 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
5636 #define XFREE(stale) do { \
5637 if (stale) { free (stale); stale = 0; } \
5638 } while (0)
5639
5640 #if defined LT_DEBUGWRAPPER
5641 static int lt_debug = 1;
5642 #else
5643 static int lt_debug = 0;
5644 #endif
5645
5646 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5647
5648 void *xmalloc (size_t num);
5649 char *xstrdup (const char *string);
5650 const char *base_name (const char *name);
5651 char *find_executable (const char *wrapper);
5652 char *chase_symlinks (const char *pathspec);
5653 int make_executable (const char *path);
5654 int check_executable (const char *path);
5655 char *strendzap (char *str, const char *pat);
5656 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
5657 void lt_fatal (const char *file, int line, const char *message, ...);
5658 static const char *nonnull (const char *s);
5659 static const char *nonempty (const char *s);
5660 void lt_setenv (const char *name, const char *value);
5661 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
5662 void lt_update_exe_path (const char *name, const char *value);
5663 void lt_update_lib_path (const char *name, const char *value);
5664 char **prepare_spawn (char **argv);
5665 void lt_dump_script (FILE *f);
5666 EOF
5667
5668 cat <<EOF
5669 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5670 # define externally_visible volatile
5671 #else
5672 # define externally_visible __attribute__((externally_visible)) volatile
5673 #endif
5674 externally_visible const char * MAGIC_EXE = "$magic_exe";
5675 const char * LIB_PATH_VARNAME = "$shlibpath_var";
5676 EOF
5677
5678 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5679 func_to_host_path "$temp_rpath"
5680 cat <<EOF
5681 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
5682 EOF
5683 else
5684 cat <<"EOF"
5685 const char * LIB_PATH_VALUE = "";
5686 EOF
5687 fi
5688
5689 if test -n "$dllsearchpath"; then
5690 func_to_host_path "$dllsearchpath:"
5691 cat <<EOF
5692 const char * EXE_PATH_VARNAME = "PATH";
5693 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
5694 EOF
5695 else
5696 cat <<"EOF"
5697 const char * EXE_PATH_VARNAME = "";
5698 const char * EXE_PATH_VALUE = "";
5699 EOF
5700 fi
5701
5702 if test yes = "$fast_install"; then
5703 cat <<EOF
5704 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5705 EOF
5706 else
5707 cat <<EOF
5708 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5709 EOF
5710 fi
5711
5712
5713 cat <<"EOF"
5714
5715 #define LTWRAPPER_OPTION_PREFIX "--lt-"
5716
5717 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5718 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
5719 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
5720
5721 int
5722 main (int argc, char *argv[])
5723 {
5724 char **newargz;
5725 int newargc;
5726 char *tmp_pathspec;
5727 char *actual_cwrapper_path;
5728 char *actual_cwrapper_name;
5729 char *target_name;
5730 char *lt_argv_zero;
5731 int rval = 127;
5732
5733 int i;
5734
5735 program_name = (char *) xstrdup (base_name (argv[0]));
5736 newargz = XMALLOC (char *, (size_t) argc + 1);
5737
5738 /* very simple arg parsing; don't want to rely on getopt
5739 * also, copy all non cwrapper options to newargz, except
5740 * argz[0], which is handled differently
5741 */
5742 newargc=0;
5743 for (i = 1; i < argc; i++)
5744 {
5745 if (STREQ (argv[i], dumpscript_opt))
5746 {
5747 EOF
5748 case $host in
5749 *mingw* | *cygwin* )
5750 # make stdout use "unix" line endings
5751 echo " setmode(1,_O_BINARY);"
5752 ;;
5753 esac
5754
5755 cat <<"EOF"
5756 lt_dump_script (stdout);
5757 return 0;
5758 }
5759 if (STREQ (argv[i], debug_opt))
5760 {
5761 lt_debug = 1;
5762 continue;
5763 }
5764 if (STREQ (argv[i], ltwrapper_option_prefix))
5765 {
5766 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5767 namespace, but it is not one of the ones we know about and
5768 have already dealt with, above (inluding dump-script), then
5769 report an error. Otherwise, targets might begin to believe
5770 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5771 namespace. The first time any user complains about this, we'll
5772 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5773 or a configure.ac-settable value.
5774 */
5775 lt_fatal (__FILE__, __LINE__,
5776 "unrecognized %s option: '%s'",
5777 ltwrapper_option_prefix, argv[i]);
5778 }
5779 /* otherwise ... */
5780 newargz[++newargc] = xstrdup (argv[i]);
5781 }
5782 newargz[++newargc] = NULL;
5783
5784 EOF
5785 cat <<EOF
5786 /* The GNU banner must be the first non-error debug message */
5787 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5788 EOF
5789 cat <<"EOF"
5790 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5791 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5792
5793 tmp_pathspec = find_executable (argv[0]);
5794 if (tmp_pathspec == NULL)
5795 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5796 lt_debugprintf (__FILE__, __LINE__,
5797 "(main) found exe (before symlink chase) at: %s\n",
5798 tmp_pathspec);
5799
5800 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5801 lt_debugprintf (__FILE__, __LINE__,
5802 "(main) found exe (after symlink chase) at: %s\n",
5803 actual_cwrapper_path);
5804 XFREE (tmp_pathspec);
5805
5806 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5807 strendzap (actual_cwrapper_path, actual_cwrapper_name);
5808
5809 /* wrapper name transforms */
5810 strendzap (actual_cwrapper_name, ".exe");
5811 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5812 XFREE (actual_cwrapper_name);
5813 actual_cwrapper_name = tmp_pathspec;
5814 tmp_pathspec = 0;
5815
5816 /* target_name transforms -- use actual target program name; might have lt- prefix */
5817 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5818 strendzap (target_name, ".exe");
5819 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5820 XFREE (target_name);
5821 target_name = tmp_pathspec;
5822 tmp_pathspec = 0;
5823
5824 lt_debugprintf (__FILE__, __LINE__,
5825 "(main) libtool target name: %s\n",
5826 target_name);
5827 EOF
5828
5829 cat <<EOF
5830 newargz[0] =
5831 XMALLOC (char, (strlen (actual_cwrapper_path) +
5832 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5833 strcpy (newargz[0], actual_cwrapper_path);
5834 strcat (newargz[0], "$objdir");
5835 strcat (newargz[0], "/");
5836 EOF
5837
5838 cat <<"EOF"
5839 /* stop here, and copy so we don't have to do this twice */
5840 tmp_pathspec = xstrdup (newargz[0]);
5841
5842 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5843 strcat (newargz[0], actual_cwrapper_name);
5844
5845 /* DO want the lt- prefix here if it exists, so use target_name */
5846 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5847 XFREE (tmp_pathspec);
5848 tmp_pathspec = NULL;
5849 EOF
5850
5851 case $host_os in
5852 mingw*)
5853 cat <<"EOF"
5854 {
5855 char* p;
5856 while ((p = strchr (newargz[0], '\\')) != NULL)
5857 {
5858 *p = '/';
5859 }
5860 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5861 {
5862 *p = '/';
5863 }
5864 }
5865 EOF
5866 ;;
5867 esac
5868
5869 cat <<"EOF"
5870 XFREE (target_name);
5871 XFREE (actual_cwrapper_path);
5872 XFREE (actual_cwrapper_name);
5873
5874 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5875 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
5876 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
5877 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5878 because on Windows, both *_VARNAMEs are PATH but uninstalled
5879 libraries must come first. */
5880 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5881 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5882
5883 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5884 nonnull (lt_argv_zero));
5885 for (i = 0; i < newargc; i++)
5886 {
5887 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5888 i, nonnull (newargz[i]));
5889 }
5890
5891 EOF
5892
5893 case $host_os in
5894 mingw*)
5895 cat <<"EOF"
5896 /* execv doesn't actually work on mingw as expected on unix */
5897 newargz = prepare_spawn (newargz);
5898 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5899 if (rval == -1)
5900 {
5901 /* failed to start process */
5902 lt_debugprintf (__FILE__, __LINE__,
5903 "(main) failed to launch target \"%s\": %s\n",
5904 lt_argv_zero, nonnull (strerror (errno)));
5905 return 127;
5906 }
5907 return rval;
5908 EOF
5909 ;;
5910 *)
5911 cat <<"EOF"
5912 execv (lt_argv_zero, newargz);
5913 return rval; /* =127, but avoids unused variable warning */
5914 EOF
5915 ;;
5916 esac
5917
5918 cat <<"EOF"
5919 }
5920
5921 void *
5922 xmalloc (size_t num)
5923 {
5924 void *p = (void *) malloc (num);
5925 if (!p)
5926 lt_fatal (__FILE__, __LINE__, "memory exhausted");
5927
5928 return p;
5929 }
5930
5931 char *
5932 xstrdup (const char *string)
5933 {
5934 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5935 string) : NULL;
5936 }
5937
5938 const char *
5939 base_name (const char *name)
5940 {
5941 const char *base;
5942
5943 #if defined HAVE_DOS_BASED_FILE_SYSTEM
5944 /* Skip over the disk name in MSDOS pathnames. */
5945 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5946 name += 2;
5947 #endif
5948
5949 for (base = name; *name; name++)
5950 if (IS_DIR_SEPARATOR (*name))
5951 base = name + 1;
5952 return base;
5953 }
5954
5955 int
5956 check_executable (const char *path)
5957 {
5958 struct stat st;
5959
5960 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5961 nonempty (path));
5962 if ((!path) || (!*path))
5963 return 0;
5964
5965 if ((stat (path, &st) >= 0)
5966 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5967 return 1;
5968 else
5969 return 0;
5970 }
5971
5972 int
5973 make_executable (const char *path)
5974 {
5975 int rval = 0;
5976 struct stat st;
5977
5978 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5979 nonempty (path));
5980 if ((!path) || (!*path))
5981 return 0;
5982
5983 if (stat (path, &st) >= 0)
5984 {
5985 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5986 }
5987 return rval;
5988 }
5989
5990 /* Searches for the full path of the wrapper. Returns
5991 newly allocated full path name if found, NULL otherwise
5992 Does not chase symlinks, even on platforms that support them.
5993 */
5994 char *
5995 find_executable (const char *wrapper)
5996 {
5997 int has_slash = 0;
5998 const char *p;
5999 const char *p_next;
6000 /* static buffer for getcwd */
6001 char tmp[LT_PATHMAX + 1];
6002 size_t tmp_len;
6003 char *concat_name;
6004
6005 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6006 nonempty (wrapper));
6007
6008 if ((wrapper == NULL) || (*wrapper == '\0'))
6009 return NULL;
6010
6011 /* Absolute path? */
6012 #if defined HAVE_DOS_BASED_FILE_SYSTEM
6013 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6014 {
6015 concat_name = xstrdup (wrapper);
6016 if (check_executable (concat_name))
6017 return concat_name;
6018 XFREE (concat_name);
6019 }
6020 else
6021 {
6022 #endif
6023 if (IS_DIR_SEPARATOR (wrapper[0]))
6024 {
6025 concat_name = xstrdup (wrapper);
6026 if (check_executable (concat_name))
6027 return concat_name;
6028 XFREE (concat_name);
6029 }
6030 #if defined HAVE_DOS_BASED_FILE_SYSTEM
6031 }
6032 #endif
6033
6034 for (p = wrapper; *p; p++)
6035 if (*p == '/')
6036 {
6037 has_slash = 1;
6038 break;
6039 }
6040 if (!has_slash)
6041 {
6042 /* no slashes; search PATH */
6043 const char *path = getenv ("PATH");
6044 if (path != NULL)
6045 {
6046 for (p = path; *p; p = p_next)
6047 {
6048 const char *q;
6049 size_t p_len;
6050 for (q = p; *q; q++)
6051 if (IS_PATH_SEPARATOR (*q))
6052 break;
6053 p_len = (size_t) (q - p);
6054 p_next = (*q == '\0' ? q : q + 1);
6055 if (p_len == 0)
6056 {
6057 /* empty path: current directory */
6058 if (getcwd (tmp, LT_PATHMAX) == NULL)
6059 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6060 nonnull (strerror (errno)));
6061 tmp_len = strlen (tmp);
6062 concat_name =
6063 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6064 memcpy (concat_name, tmp, tmp_len);
6065 concat_name[tmp_len] = '/';
6066 strcpy (concat_name + tmp_len + 1, wrapper);
6067 }
6068 else
6069 {
6070 concat_name =
6071 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6072 memcpy (concat_name, p, p_len);
6073 concat_name[p_len] = '/';
6074 strcpy (concat_name + p_len + 1, wrapper);
6075 }
6076 if (check_executable (concat_name))
6077 return concat_name;
6078 XFREE (concat_name);
6079 }
6080 }
6081 /* not found in PATH; assume curdir */
6082 }
6083 /* Relative path | not found in path: prepend cwd */
6084 if (getcwd (tmp, LT_PATHMAX) == NULL)
6085 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6086 nonnull (strerror (errno)));
6087 tmp_len = strlen (tmp);
6088 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6089 memcpy (concat_name, tmp, tmp_len);
6090 concat_name[tmp_len] = '/';
6091 strcpy (concat_name + tmp_len + 1, wrapper);
6092
6093 if (check_executable (concat_name))
6094 return concat_name;
6095 XFREE (concat_name);
6096 return NULL;
6097 }
6098
6099 char *
6100 chase_symlinks (const char *pathspec)
6101 {
6102 #ifndef S_ISLNK
6103 return xstrdup (pathspec);
6104 #else
6105 char buf[LT_PATHMAX];
6106 struct stat s;
6107 char *tmp_pathspec = xstrdup (pathspec);
6108 char *p;
6109 int has_symlinks = 0;
6110 while (strlen (tmp_pathspec) && !has_symlinks)
6111 {
6112 lt_debugprintf (__FILE__, __LINE__,
6113 "checking path component for symlinks: %s\n",
6114 tmp_pathspec);
6115 if (lstat (tmp_pathspec, &s) == 0)
6116 {
6117 if (S_ISLNK (s.st_mode) != 0)
6118 {
6119 has_symlinks = 1;
6120 break;
6121 }
6122
6123 /* search backwards for last DIR_SEPARATOR */
6124 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6125 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6126 p--;
6127 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6128 {
6129 /* no more DIR_SEPARATORS left */
6130 break;
6131 }
6132 *p = '\0';
6133 }
6134 else
6135 {
6136 lt_fatal (__FILE__, __LINE__,
6137 "error accessing file \"%s\": %s",
6138 tmp_pathspec, nonnull (strerror (errno)));
6139 }
6140 }
6141 XFREE (tmp_pathspec);
6142
6143 if (!has_symlinks)
6144 {
6145 return xstrdup (pathspec);
6146 }
6147
6148 tmp_pathspec = realpath (pathspec, buf);
6149 if (tmp_pathspec == 0)
6150 {
6151 lt_fatal (__FILE__, __LINE__,
6152 "could not follow symlinks for %s", pathspec);
6153 }
6154 return xstrdup (tmp_pathspec);
6155 #endif
6156 }
6157
6158 char *
6159 strendzap (char *str, const char *pat)
6160 {
6161 size_t len, patlen;
6162
6163 assert (str != NULL);
6164 assert (pat != NULL);
6165
6166 len = strlen (str);
6167 patlen = strlen (pat);
6168
6169 if (patlen <= len)
6170 {
6171 str += len - patlen;
6172 if (STREQ (str, pat))
6173 *str = '\0';
6174 }
6175 return str;
6176 }
6177
6178 void
6179 lt_debugprintf (const char *file, int line, const char *fmt, ...)
6180 {
6181 va_list args;
6182 if (lt_debug)
6183 {
6184 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6185 va_start (args, fmt);
6186 (void) vfprintf (stderr, fmt, args);
6187 va_end (args);
6188 }
6189 }
6190
6191 static void
6192 lt_error_core (int exit_status, const char *file,
6193 int line, const char *mode,
6194 const char *message, va_list ap)
6195 {
6196 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6197 vfprintf (stderr, message, ap);
6198 fprintf (stderr, ".\n");
6199
6200 if (exit_status >= 0)
6201 exit (exit_status);
6202 }
6203
6204 void
6205 lt_fatal (const char *file, int line, const char *message, ...)
6206 {
6207 va_list ap;
6208 va_start (ap, message);
6209 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6210 va_end (ap);
6211 }
6212
6213 static const char *
6214 nonnull (const char *s)
6215 {
6216 return s ? s : "(null)";
6217 }
6218
6219 static const char *
6220 nonempty (const char *s)
6221 {
6222 return (s && !*s) ? "(empty)" : nonnull (s);
6223 }
6224
6225 void
6226 lt_setenv (const char *name, const char *value)
6227 {
6228 lt_debugprintf (__FILE__, __LINE__,
6229 "(lt_setenv) setting '%s' to '%s'\n",
6230 nonnull (name), nonnull (value));
6231 {
6232 #ifdef HAVE_SETENV
6233 /* always make a copy, for consistency with !HAVE_SETENV */
6234 char *str = xstrdup (value);
6235 setenv (name, str, 1);
6236 #else
6237 size_t len = strlen (name) + 1 + strlen (value) + 1;
6238 char *str = XMALLOC (char, len);
6239 sprintf (str, "%s=%s", name, value);
6240 if (putenv (str) != EXIT_SUCCESS)
6241 {
6242 XFREE (str);
6243 }
6244 #endif
6245 }
6246 }
6247
6248 char *
6249 lt_extend_str (const char *orig_value, const char *add, int to_end)
6250 {
6251 char *new_value;
6252 if (orig_value && *orig_value)
6253 {
6254 size_t orig_value_len = strlen (orig_value);
6255 size_t add_len = strlen (add);
6256 new_value = XMALLOC (char, add_len + orig_value_len + 1);
6257 if (to_end)
6258 {
6259 strcpy (new_value, orig_value);
6260 strcpy (new_value + orig_value_len, add);
6261 }
6262 else
6263 {
6264 strcpy (new_value, add);
6265 strcpy (new_value + add_len, orig_value);
6266 }
6267 }
6268 else
6269 {
6270 new_value = xstrdup (add);
6271 }
6272 return new_value;
6273 }
6274
6275 void
6276 lt_update_exe_path (const char *name, const char *value)
6277 {
6278 lt_debugprintf (__FILE__, __LINE__,
6279 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6280 nonnull (name), nonnull (value));
6281
6282 if (name && *name && value && *value)
6283 {
6284 char *new_value = lt_extend_str (getenv (name), value, 0);
6285 /* some systems can't cope with a ':'-terminated path #' */
6286 size_t len = strlen (new_value);
6287 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6288 {
6289 new_value[--len] = '\0';
6290 }
6291 lt_setenv (name, new_value);
6292 XFREE (new_value);
6293 }
6294 }
6295
6296 void
6297 lt_update_lib_path (const char *name, const char *value)
6298 {
6299 lt_debugprintf (__FILE__, __LINE__,
6300 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6301 nonnull (name), nonnull (value));
6302
6303 if (name && *name && value && *value)
6304 {
6305 char *new_value = lt_extend_str (getenv (name), value, 0);
6306 lt_setenv (name, new_value);
6307 XFREE (new_value);
6308 }
6309 }
6310
6311 EOF
6312 case $host_os in
6313 mingw*)
6314 cat <<"EOF"
6315
6316 /* Prepares an argument vector before calling spawn().
6317 Note that spawn() does not by itself call the command interpreter
6318 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6319 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6320 GetVersionEx(&v);
6321 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6322 }) ? "cmd.exe" : "command.com").
6323 Instead it simply concatenates the arguments, separated by ' ', and calls
6324 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
6325 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6326 special way:
6327 - Space and tab are interpreted as delimiters. They are not treated as
6328 delimiters if they are surrounded by double quotes: "...".
6329 - Unescaped double quotes are removed from the input. Their only effect is
6330 that within double quotes, space and tab are treated like normal
6331 characters.
6332 - Backslashes not followed by double quotes are not special.
6333 - But 2*n+1 backslashes followed by a double quote become
6334 n backslashes followed by a double quote (n >= 0):
6335 \" -> "
6336 \\\" -> \"
6337 \\\\\" -> \\"
6338 */
6339 #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
6340 #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
6341 char **
6342 prepare_spawn (char **argv)
6343 {
6344 size_t argc;
6345 char **new_argv;
6346 size_t i;
6347
6348 /* Count number of arguments. */
6349 for (argc = 0; argv[argc] != NULL; argc++)
6350 ;
6351
6352 /* Allocate new argument vector. */
6353 new_argv = XMALLOC (char *, argc + 1);
6354
6355 /* Put quoted arguments into the new argument vector. */
6356 for (i = 0; i < argc; i++)
6357 {
6358 const char *string = argv[i];
6359
6360 if (string[0] == '\0')
6361 new_argv[i] = xstrdup ("\"\"");
6362 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6363 {
6364 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6365 size_t length;
6366 unsigned int backslashes;
6367 const char *s;
6368 char *quoted_string;
6369 char *p;
6370
6371 length = 0;
6372 backslashes = 0;
6373 if (quote_around)
6374 length++;
6375 for (s = string; *s != '\0'; s++)
6376 {
6377 char c = *s;
6378 if (c == '"')
6379 length += backslashes + 1;
6380 length++;
6381 if (c == '\\')
6382 backslashes++;
6383 else
6384 backslashes = 0;
6385 }
6386 if (quote_around)
6387 length += backslashes + 1;
6388
6389 quoted_string = XMALLOC (char, length + 1);
6390
6391 p = quoted_string;
6392 backslashes = 0;
6393 if (quote_around)
6394 *p++ = '"';
6395 for (s = string; *s != '\0'; s++)
6396 {
6397 char c = *s;
6398 if (c == '"')
6399 {
6400 unsigned int j;
6401 for (j = backslashes + 1; j > 0; j--)
6402 *p++ = '\\';
6403 }
6404 *p++ = c;
6405 if (c == '\\')
6406 backslashes++;
6407 else
6408 backslashes = 0;
6409 }
6410 if (quote_around)
6411 {
6412 unsigned int j;
6413 for (j = backslashes; j > 0; j--)
6414 *p++ = '\\';
6415 *p++ = '"';
6416 }
6417 *p = '\0';
6418
6419 new_argv[i] = quoted_string;
6420 }
6421 else
6422 new_argv[i] = (char *) string;
6423 }
6424 new_argv[argc] = NULL;
6425
6426 return new_argv;
6427 }
6428 EOF
6429 ;;
6430 esac
6431
6432 cat <<"EOF"
6433 void lt_dump_script (FILE* f)
6434 {
6435 EOF
6436 func_emit_wrapper yes |
6437 $SED -n -e '
6438 s/^\(.\{79\}\)\(..*\)/\1\
6439 \2/
6440 h
6441 s/\([\\"]\)/\\\1/g
6442 s/$/\\n/
6443 s/\([^\n]*\).*/ fputs ("\1", f);/p
6444 g
6445 D'
6446 cat <<"EOF"
6447 }
6448 EOF
6449 }
6450 # end: func_emit_cwrapperexe_src
6451
6452 # func_win32_import_lib_p ARG
6453 # True if ARG is an import lib, as indicated by $file_magic_cmd
6454 func_win32_import_lib_p ()
6455 {
6456 $debug_cmd
6457
6458 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6459 *import*) : ;;
6460 *) false ;;
6461 esac
6462 }
6463
6464 # func_mode_link arg...
6465 func_mode_link ()
6466 {
6467 $debug_cmd
6468
6469 case $host in
6470 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6471 # It is impossible to link a dll without this setting, and
6472 # we shouldn't force the makefile maintainer to figure out
6473 # what system we are compiling for in order to pass an extra
6474 # flag for every libtool invocation.
6475 # allow_undefined=no
6476
6477 # FIXME: Unfortunately, there are problems with the above when trying
6478 # to make a dll that has undefined symbols, in which case not
6479 # even a static library is built. For now, we need to specify
6480 # -no-undefined on the libtool link line when we can be certain
6481 # that all symbols are satisfied, otherwise we get a static library.
6482 allow_undefined=yes
6483 ;;
6484 *)
6485 allow_undefined=yes
6486 ;;
6487 esac
6488 libtool_args=$nonopt
6489 base_compile="$nonopt $@"
6490 compile_command=$nonopt
6491 finalize_command=$nonopt
6492
6493 compile_rpath=
6494 finalize_rpath=
6495 compile_shlibpath=
6496 finalize_shlibpath=
6497 convenience=
6498 old_convenience=
6499 deplibs=
6500 old_deplibs=
6501 compiler_flags=
6502 linker_flags=
6503 dllsearchpath=
6504 lib_search_path=`pwd`
6505 inst_prefix_dir=
6506 new_inherited_linker_flags=
6507
6508 avoid_version=no
6509 bindir=
6510 dlfiles=
6511 dlprefiles=
6512 dlself=no
6513 export_dynamic=no
6514 export_symbols=
6515 export_symbols_regex=
6516 generated=
6517 libobjs=
6518 ltlibs=
6519 module=no
6520 no_install=no
6521 objs=
6522 os2dllname=
6523 non_pic_objects=
6524 precious_files_regex=
6525 prefer_static_libs=no
6526 preload=false
6527 prev=
6528 prevarg=
6529 release=
6530 rpath=
6531 xrpath=
6532 perm_rpath=
6533 temp_rpath=
6534 thread_safe=no
6535 vinfo=
6536 vinfo_number=no
6537 weak_libs=
6538 single_module=$wl-single_module
6539 func_infer_tag $base_compile
6540
6541 # We need to know -static, to get the right output filenames.
6542 for arg
6543 do
6544 case $arg in
6545 -shared)
6546 test yes != "$build_libtool_libs" \
6547 && func_fatal_configuration "cannot build a shared library"
6548 build_old_libs=no
6549 break
6550 ;;
6551 -all-static | -static | -static-libtool-libs)
6552 case $arg in
6553 -all-static)
6554 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6555 func_warning "complete static linking is impossible in this configuration"
6556 fi
6557 if test -n "$link_static_flag"; then
6558 dlopen_self=$dlopen_self_static
6559 fi
6560 prefer_static_libs=yes
6561 ;;
6562 -static)
6563 if test -z "$pic_flag" && test -n "$link_static_flag"; then
6564 dlopen_self=$dlopen_self_static
6565 fi
6566 prefer_static_libs=built
6567 ;;
6568 -static-libtool-libs)
6569 if test -z "$pic_flag" && test -n "$link_static_flag"; then
6570 dlopen_self=$dlopen_self_static
6571 fi
6572 prefer_static_libs=yes
6573 ;;
6574 esac
6575 build_libtool_libs=no
6576 build_old_libs=yes
6577 break
6578 ;;
6579 esac
6580 done
6581
6582 # See if our shared archives depend on static archives.
6583 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6584
6585 # Go through the arguments, transforming them on the way.
6586 while test "$#" -gt 0; do
6587 arg=$1
6588 shift
6589 func_quote_for_eval "$arg"
6590 qarg=$func_quote_for_eval_unquoted_result
6591 func_append libtool_args " $func_quote_for_eval_result"
6592
6593 # If the previous option needs an argument, assign it.
6594 if test -n "$prev"; then
6595 case $prev in
6596 output)
6597 func_append compile_command " @OUTPUT@"
6598 func_append finalize_command " @OUTPUT@"
6599 ;;
6600 esac
6601
6602 case $prev in
6603 bindir)
6604 bindir=$arg
6605 prev=
6606 continue
6607 ;;
6608 dlfiles|dlprefiles)
6609 $preload || {
6610 # Add the symbol object into the linking commands.
6611 func_append compile_command " @SYMFILE@"
6612 func_append finalize_command " @SYMFILE@"
6613 preload=:
6614 }
6615 case $arg in
6616 *.la | *.lo) ;; # We handle these cases below.
6617 force)
6618 if test no = "$dlself"; then
6619 dlself=needless
6620 export_dynamic=yes
6621 fi
6622 prev=
6623 continue
6624 ;;
6625 self)
6626 if test dlprefiles = "$prev"; then
6627 dlself=yes
6628 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6629 dlself=yes
6630 else
6631 dlself=needless
6632 export_dynamic=yes
6633 fi
6634 prev=
6635 continue
6636 ;;
6637 *)
6638 if test dlfiles = "$prev"; then
6639 func_append dlfiles " $arg"
6640 else
6641 func_append dlprefiles " $arg"
6642 fi
6643 prev=
6644 continue
6645 ;;
6646 esac
6647 ;;
6648 expsyms)
6649 export_symbols=$arg
6650 test -f "$arg" \
6651 || func_fatal_error "symbol file '$arg' does not exist"
6652 prev=
6653 continue
6654 ;;
6655 expsyms_regex)
6656 export_symbols_regex=$arg
6657 prev=
6658 continue
6659 ;;
6660 framework)
6661 case $host in
6662 *-*-darwin*)
6663 case "$deplibs " in
6664 *" $qarg.ltframework "*) ;;
6665 *) func_append deplibs " $qarg.ltframework" # this is fixed later
6666 ;;
6667 esac
6668 ;;
6669 esac
6670 prev=
6671 continue
6672 ;;
6673 inst_prefix)
6674 inst_prefix_dir=$arg
6675 prev=
6676 continue
6677 ;;
6678 mllvm)
6679 # Clang does not use LLVM to link, so we can simply discard any
6680 # '-mllvm $arg' options when doing the link step.
6681 prev=
6682 continue
6683 ;;
6684 objectlist)
6685 if test -f "$arg"; then
6686 save_arg=$arg
6687 moreargs=
6688 for fil in `cat "$save_arg"`
6689 do
6690 # func_append moreargs " $fil"
6691 arg=$fil
6692 # A libtool-controlled object.
6693
6694 # Check to see that this really is a libtool object.
6695 if func_lalib_unsafe_p "$arg"; then
6696 pic_object=
6697 non_pic_object=
6698
6699 # Read the .lo file
6700 func_source "$arg"
6701
6702 if test -z "$pic_object" ||
6703 test -z "$non_pic_object" ||
6704 test none = "$pic_object" &&
6705 test none = "$non_pic_object"; then
6706 func_fatal_error "cannot find name of object for '$arg'"
6707 fi
6708
6709 # Extract subdirectory from the argument.
6710 func_dirname "$arg" "/" ""
6711 xdir=$func_dirname_result
6712
6713 if test none != "$pic_object"; then
6714 # Prepend the subdirectory the object is found in.
6715 pic_object=$xdir$pic_object
6716
6717 if test dlfiles = "$prev"; then
6718 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6719 func_append dlfiles " $pic_object"
6720 prev=
6721 continue
6722 else
6723 # If libtool objects are unsupported, then we need to preload.
6724 prev=dlprefiles
6725 fi
6726 fi
6727
6728 # CHECK ME: I think I busted this. -Ossama
6729 if test dlprefiles = "$prev"; then
6730 # Preload the old-style object.
6731 func_append dlprefiles " $pic_object"
6732 prev=
6733 fi
6734
6735 # A PIC object.
6736 func_append libobjs " $pic_object"
6737 arg=$pic_object
6738 fi
6739
6740 # Non-PIC object.
6741 if test none != "$non_pic_object"; then
6742 # Prepend the subdirectory the object is found in.
6743 non_pic_object=$xdir$non_pic_object
6744
6745 # A standard non-PIC object
6746 func_append non_pic_objects " $non_pic_object"
6747 if test -z "$pic_object" || test none = "$pic_object"; then
6748 arg=$non_pic_object
6749 fi
6750 else
6751 # If the PIC object exists, use it instead.
6752 # $xdir was prepended to $pic_object above.
6753 non_pic_object=$pic_object
6754 func_append non_pic_objects " $non_pic_object"
6755 fi
6756 else
6757 # Only an error if not doing a dry-run.
6758 if $opt_dry_run; then
6759 # Extract subdirectory from the argument.
6760 func_dirname "$arg" "/" ""
6761 xdir=$func_dirname_result
6762
6763 func_lo2o "$arg"
6764 pic_object=$xdir$objdir/$func_lo2o_result
6765 non_pic_object=$xdir$func_lo2o_result
6766 func_append libobjs " $pic_object"
6767 func_append non_pic_objects " $non_pic_object"
6768 else
6769 func_fatal_error "'$arg' is not a valid libtool object"
6770 fi
6771 fi
6772 done
6773 else
6774 func_fatal_error "link input file '$arg' does not exist"
6775 fi
6776 arg=$save_arg
6777 prev=
6778 continue
6779 ;;
6780 os2dllname)
6781 os2dllname=$arg
6782 prev=
6783 continue
6784 ;;
6785 precious_regex)
6786 precious_files_regex=$arg
6787 prev=
6788 continue
6789 ;;
6790 release)
6791 release=-$arg
6792 prev=
6793 continue
6794 ;;
6795 rpath | xrpath)
6796 # We need an absolute path.
6797 case $arg in
6798 [\\/]* | [A-Za-z]:[\\/]*) ;;
6799 *)
6800 func_fatal_error "only absolute run-paths are allowed"
6801 ;;
6802 esac
6803 if test rpath = "$prev"; then
6804 case "$rpath " in
6805 *" $arg "*) ;;
6806 *) func_append rpath " $arg" ;;
6807 esac
6808 else
6809 case "$xrpath " in
6810 *" $arg "*) ;;
6811 *) func_append xrpath " $arg" ;;
6812 esac
6813 fi
6814 prev=
6815 continue
6816 ;;
6817 shrext)
6818 shrext_cmds=$arg
6819 prev=
6820 continue
6821 ;;
6822 weak)
6823 func_append weak_libs " $arg"
6824 prev=
6825 continue
6826 ;;
6827 xcclinker)
6828 func_append linker_flags " $qarg"
6829 func_append compiler_flags " $qarg"
6830 prev=
6831 func_append compile_command " $qarg"
6832 func_append finalize_command " $qarg"
6833 continue
6834 ;;
6835 xcompiler)
6836 func_append compiler_flags " $qarg"
6837 prev=
6838 func_append compile_command " $qarg"
6839 func_append finalize_command " $qarg"
6840 continue
6841 ;;
6842 xlinker)
6843 func_append linker_flags " $qarg"
6844 func_append compiler_flags " $wl$qarg"
6845 prev=
6846 func_append compile_command " $wl$qarg"
6847 func_append finalize_command " $wl$qarg"
6848 continue
6849 ;;
6850 *)
6851 eval "$prev=\"\$arg\""
6852 prev=
6853 continue
6854 ;;
6855 esac
6856 fi # test -n "$prev"
6857
6858 prevarg=$arg
6859
6860 case $arg in
6861 -all-static)
6862 if test -n "$link_static_flag"; then
6863 # See comment for -static flag below, for more details.
6864 func_append compile_command " $link_static_flag"
6865 func_append finalize_command " $link_static_flag"
6866 fi
6867 continue
6868 ;;
6869
6870 -allow-undefined)
6871 # FIXME: remove this flag sometime in the future.
6872 func_fatal_error "'-allow-undefined' must not be used because it is the default"
6873 ;;
6874
6875 -avoid-version)
6876 avoid_version=yes
6877 continue
6878 ;;
6879
6880 -bindir)
6881 prev=bindir
6882 continue
6883 ;;
6884
6885 -dlopen)
6886 prev=dlfiles
6887 continue
6888 ;;
6889
6890 -dlpreopen)
6891 prev=dlprefiles
6892 continue
6893 ;;
6894
6895 -export-dynamic)
6896 export_dynamic=yes
6897 continue
6898 ;;
6899
6900 -export-symbols | -export-symbols-regex)
6901 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6902 func_fatal_error "more than one -exported-symbols argument is not allowed"
6903 fi
6904 if test X-export-symbols = "X$arg"; then
6905 prev=expsyms
6906 else
6907 prev=expsyms_regex
6908 fi
6909 continue
6910 ;;
6911
6912 -framework)
6913 prev=framework
6914 continue
6915 ;;
6916
6917 -inst-prefix-dir)
6918 prev=inst_prefix
6919 continue
6920 ;;
6921
6922 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6923 # so, if we see these flags be careful not to treat them like -L
6924 -L[A-Z][A-Z]*:*)
6925 case $with_gcc/$host in
6926 no/*-*-irix* | /*-*-irix*)
6927 func_append compile_command " $arg"
6928 func_append finalize_command " $arg"
6929 ;;
6930 esac
6931 continue
6932 ;;
6933
6934 -L*)
6935 func_stripname "-L" '' "$arg"
6936 if test -z "$func_stripname_result"; then
6937 if test "$#" -gt 0; then
6938 func_fatal_error "require no space between '-L' and '$1'"
6939 else
6940 func_fatal_error "need path for '-L' option"
6941 fi
6942 fi
6943 func_resolve_sysroot "$func_stripname_result"
6944 dir=$func_resolve_sysroot_result
6945 # We need an absolute path.
6946 case $dir in
6947 [\\/]* | [A-Za-z]:[\\/]*) ;;
6948 *)
6949 absdir=`cd "$dir" && pwd`
6950 test -z "$absdir" && \
6951 func_fatal_error "cannot determine absolute directory name of '$dir'"
6952 dir=$absdir
6953 ;;
6954 esac
6955 case "$deplibs " in
6956 *" -L$dir "* | *" $arg "*)
6957 # Will only happen for absolute or sysroot arguments
6958 ;;
6959 *)
6960 # Preserve sysroot, but never include relative directories
6961 case $dir in
6962 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6963 *) func_append deplibs " -L$dir" ;;
6964 esac
6965 func_append lib_search_path " $dir"
6966 ;;
6967 esac
6968 case $host in
6969 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6970 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6971 case :$dllsearchpath: in
6972 *":$dir:"*) ;;
6973 ::) dllsearchpath=$dir;;
6974 *) func_append dllsearchpath ":$dir";;
6975 esac
6976 case :$dllsearchpath: in
6977 *":$testbindir:"*) ;;
6978 ::) dllsearchpath=$testbindir;;
6979 *) func_append dllsearchpath ":$testbindir";;
6980 esac
6981 ;;
6982 esac
6983 continue
6984 ;;
6985
6986 -l*)
6987 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
6988 case $host in
6989 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
6990 # These systems don't actually have a C or math library (as such)
6991 continue
6992 ;;
6993 *-*-os2*)
6994 # These systems don't actually have a C library (as such)
6995 test X-lc = "X$arg" && continue
6996 ;;
6997 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
6998 # Do not include libc due to us having libc/libc_r.
6999 test X-lc = "X$arg" && continue
7000 ;;
7001 *-*-rhapsody* | *-*-darwin1.[012])
7002 # Rhapsody C and math libraries are in the System framework
7003 func_append deplibs " System.ltframework"
7004 continue
7005 ;;
7006 *-*-sco3.2v5* | *-*-sco5v6*)
7007 # Causes problems with __ctype
7008 test X-lc = "X$arg" && continue
7009 ;;
7010 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7011 # Compiler inserts libc in the correct place for threads to work
7012 test X-lc = "X$arg" && continue
7013 ;;
7014 esac
7015 elif test X-lc_r = "X$arg"; then
7016 case $host in
7017 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7018 # Do not include libc_r directly, use -pthread flag.
7019 continue
7020 ;;
7021 esac
7022 fi
7023 func_append deplibs " $arg"
7024 continue
7025 ;;
7026
7027 -mllvm)
7028 prev=mllvm
7029 continue
7030 ;;
7031
7032 -module)
7033 module=yes
7034 continue
7035 ;;
7036
7037 # Tru64 UNIX uses -model [arg] to determine the layout of C++
7038 # classes, name mangling, and exception handling.
7039 # Darwin uses the -arch flag to determine output architecture.
7040 -model|-arch|-isysroot|--sysroot)
7041 func_append compiler_flags " $arg"
7042 func_append compile_command " $arg"
7043 func_append finalize_command " $arg"
7044 prev=xcompiler
7045 continue
7046 ;;
7047
7048 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7049 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7050 func_append compiler_flags " $arg"
7051 func_append compile_command " $arg"
7052 func_append finalize_command " $arg"
7053 case "$new_inherited_linker_flags " in
7054 *" $arg "*) ;;
7055 * ) func_append new_inherited_linker_flags " $arg" ;;
7056 esac
7057 continue
7058 ;;
7059
7060 -multi_module)
7061 single_module=$wl-multi_module
7062 continue
7063 ;;
7064
7065 -no-fast-install)
7066 fast_install=no
7067 continue
7068 ;;
7069
7070 -no-install)
7071 case $host in
7072 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7073 # The PATH hackery in wrapper scripts is required on Windows
7074 # and Darwin in order for the loader to find any dlls it needs.
7075 func_warning "'-no-install' is ignored for $host"
7076 func_warning "assuming '-no-fast-install' instead"
7077 fast_install=no
7078 ;;
7079 *) no_install=yes ;;
7080 esac
7081 continue
7082 ;;
7083
7084 -no-undefined)
7085 allow_undefined=no
7086 continue
7087 ;;
7088
7089 -objectlist)
7090 prev=objectlist
7091 continue
7092 ;;
7093
7094 -os2dllname)
7095 prev=os2dllname
7096 continue
7097 ;;
7098
7099 -o) prev=output ;;
7100
7101 -precious-files-regex)
7102 prev=precious_regex
7103 continue
7104 ;;
7105
7106 -release)
7107 prev=release
7108 continue
7109 ;;
7110
7111 -rpath)
7112 prev=rpath
7113 continue
7114 ;;
7115
7116 -R)
7117 prev=xrpath
7118 continue
7119 ;;
7120
7121 -R*)
7122 func_stripname '-R' '' "$arg"
7123 dir=$func_stripname_result
7124 # We need an absolute path.
7125 case $dir in
7126 [\\/]* | [A-Za-z]:[\\/]*) ;;
7127 =*)
7128 func_stripname '=' '' "$dir"
7129 dir=$lt_sysroot$func_stripname_result
7130 ;;
7131 *)
7132 func_fatal_error "only absolute run-paths are allowed"
7133 ;;
7134 esac
7135 case "$xrpath " in
7136 *" $dir "*) ;;
7137 *) func_append xrpath " $dir" ;;
7138 esac
7139 continue
7140 ;;
7141
7142 -shared)
7143 # The effects of -shared are defined in a previous loop.
7144 continue
7145 ;;
7146
7147 -shrext)
7148 prev=shrext
7149 continue
7150 ;;
7151
7152 -static | -static-libtool-libs)
7153 # The effects of -static are defined in a previous loop.
7154 # We used to do the same as -all-static on platforms that
7155 # didn't have a PIC flag, but the assumption that the effects
7156 # would be equivalent was wrong. It would break on at least
7157 # Digital Unix and AIX.
7158 continue
7159 ;;
7160
7161 -thread-safe)
7162 thread_safe=yes
7163 continue
7164 ;;
7165
7166 -version-info)
7167 prev=vinfo
7168 continue
7169 ;;
7170
7171 -version-number)
7172 prev=vinfo
7173 vinfo_number=yes
7174 continue
7175 ;;
7176
7177 -weak)
7178 prev=weak
7179 continue
7180 ;;
7181
7182 -Wc,*)
7183 func_stripname '-Wc,' '' "$arg"
7184 args=$func_stripname_result
7185 arg=
7186 save_ifs=$IFS; IFS=,
7187 for flag in $args; do
7188 IFS=$save_ifs
7189 func_quote_for_eval "$flag"
7190 func_append arg " $func_quote_for_eval_result"
7191 func_append compiler_flags " $func_quote_for_eval_result"
7192 done
7193 IFS=$save_ifs
7194 func_stripname ' ' '' "$arg"
7195 arg=$func_stripname_result
7196 ;;
7197
7198 -Wl,*)
7199 func_stripname '-Wl,' '' "$arg"
7200 args=$func_stripname_result
7201 arg=
7202 save_ifs=$IFS; IFS=,
7203 for flag in $args; do
7204 IFS=$save_ifs
7205 func_quote_for_eval "$flag"
7206 func_append arg " $wl$func_quote_for_eval_result"
7207 func_append compiler_flags " $wl$func_quote_for_eval_result"
7208 func_append linker_flags " $func_quote_for_eval_result"
7209 done
7210 IFS=$save_ifs
7211 func_stripname ' ' '' "$arg"
7212 arg=$func_stripname_result
7213 ;;
7214
7215 -Xcompiler)
7216 prev=xcompiler
7217 continue
7218 ;;
7219
7220 -Xlinker)
7221 prev=xlinker
7222 continue
7223 ;;
7224
7225 -XCClinker)
7226 prev=xcclinker
7227 continue
7228 ;;
7229
7230 # -msg_* for osf cc
7231 -msg_*)
7232 func_quote_for_eval "$arg"
7233 arg=$func_quote_for_eval_result
7234 ;;
7235
7236 # Flags to be passed through unchanged, with rationale:
7237 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
7238 # -r[0-9][0-9]* specify processor for the SGI compiler
7239 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7240 # +DA*, +DD* enable 64-bit mode for the HP compiler
7241 # -q* compiler args for the IBM compiler
7242 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7243 # -F/path path to uninstalled frameworks, gcc on darwin
7244 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
7245 # -fstack-protector* stack protector flags for GCC
7246 # @file GCC response files
7247 # -tp=* Portland pgcc target processor selection
7248 # --sysroot=* for sysroot support
7249 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7250 # -stdlib=* select c++ std lib with clang
7251 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7252 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7253 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
7254 func_quote_for_eval "$arg"
7255 arg=$func_quote_for_eval_result
7256 func_append compile_command " $arg"
7257 func_append finalize_command " $arg"
7258 func_append compiler_flags " $arg"
7259 continue
7260 ;;
7261
7262 -Z*)
7263 if test os2 = "`expr $host : '.*\(os2\)'`"; then
7264 # OS/2 uses -Zxxx to specify OS/2-specific options
7265 compiler_flags="$compiler_flags $arg"
7266 func_append compile_command " $arg"
7267 func_append finalize_command " $arg"
7268 case $arg in
7269 -Zlinker | -Zstack)
7270 prev=xcompiler
7271 ;;
7272 esac
7273 continue
7274 else
7275 # Otherwise treat like 'Some other compiler flag' below
7276 func_quote_for_eval "$arg"
7277 arg=$func_quote_for_eval_result
7278 fi
7279 ;;
7280
7281 # Some other compiler flag.
7282 -* | +*)
7283 func_quote_for_eval "$arg"
7284 arg=$func_quote_for_eval_result
7285 ;;
7286
7287 *.$objext)
7288 # A standard object.
7289 func_append objs " $arg"
7290 ;;
7291
7292 *.lo)
7293 # A libtool-controlled object.
7294
7295 # Check to see that this really is a libtool object.
7296 if func_lalib_unsafe_p "$arg"; then
7297 pic_object=
7298 non_pic_object=
7299
7300 # Read the .lo file
7301 func_source "$arg"
7302
7303 if test -z "$pic_object" ||
7304 test -z "$non_pic_object" ||
7305 test none = "$pic_object" &&
7306 test none = "$non_pic_object"; then
7307 func_fatal_error "cannot find name of object for '$arg'"
7308 fi
7309
7310 # Extract subdirectory from the argument.
7311 func_dirname "$arg" "/" ""
7312 xdir=$func_dirname_result
7313
7314 test none = "$pic_object" || {
7315 # Prepend the subdirectory the object is found in.
7316 pic_object=$xdir$pic_object
7317
7318 if test dlfiles = "$prev"; then
7319 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7320 func_append dlfiles " $pic_object"
7321 prev=
7322 continue
7323 else
7324 # If libtool objects are unsupported, then we need to preload.
7325 prev=dlprefiles
7326 fi
7327 fi
7328
7329 # CHECK ME: I think I busted this. -Ossama
7330 if test dlprefiles = "$prev"; then
7331 # Preload the old-style object.
7332 func_append dlprefiles " $pic_object"
7333 prev=
7334 fi
7335
7336 # A PIC object.
7337 func_append libobjs " $pic_object"
7338 arg=$pic_object
7339 }
7340
7341 # Non-PIC object.
7342 if test none != "$non_pic_object"; then
7343 # Prepend the subdirectory the object is found in.
7344 non_pic_object=$xdir$non_pic_object
7345
7346 # A standard non-PIC object
7347 func_append non_pic_objects " $non_pic_object"
7348 if test -z "$pic_object" || test none = "$pic_object"; then
7349 arg=$non_pic_object
7350 fi
7351 else
7352 # If the PIC object exists, use it instead.
7353 # $xdir was prepended to $pic_object above.
7354 non_pic_object=$pic_object
7355 func_append non_pic_objects " $non_pic_object"
7356 fi
7357 else
7358 # Only an error if not doing a dry-run.
7359 if $opt_dry_run; then
7360 # Extract subdirectory from the argument.
7361 func_dirname "$arg" "/" ""
7362 xdir=$func_dirname_result
7363
7364 func_lo2o "$arg"
7365 pic_object=$xdir$objdir/$func_lo2o_result
7366 non_pic_object=$xdir$func_lo2o_result
7367 func_append libobjs " $pic_object"
7368 func_append non_pic_objects " $non_pic_object"
7369 else
7370 func_fatal_error "'$arg' is not a valid libtool object"
7371 fi
7372 fi
7373 ;;
7374
7375 *.$libext)
7376 # An archive.
7377 func_append deplibs " $arg"
7378 func_append old_deplibs " $arg"
7379 continue
7380 ;;
7381
7382 *.la)
7383 # A libtool-controlled library.
7384
7385 func_resolve_sysroot "$arg"
7386 if test dlfiles = "$prev"; then
7387 # This library was specified with -dlopen.
7388 func_append dlfiles " $func_resolve_sysroot_result"
7389 prev=
7390 elif test dlprefiles = "$prev"; then
7391 # The library was specified with -dlpreopen.
7392 func_append dlprefiles " $func_resolve_sysroot_result"
7393 prev=
7394 else
7395 func_append deplibs " $func_resolve_sysroot_result"
7396 fi
7397 continue
7398 ;;
7399
7400 # Some other compiler argument.
7401 *)
7402 # Unknown arguments in both finalize_command and compile_command need
7403 # to be aesthetically quoted because they are evaled later.
7404 func_quote_for_eval "$arg"
7405 arg=$func_quote_for_eval_result
7406 ;;
7407 esac # arg
7408
7409 # Now actually substitute the argument into the commands.
7410 if test -n "$arg"; then
7411 func_append compile_command " $arg"
7412 func_append finalize_command " $arg"
7413 fi
7414 done # argument parsing loop
7415
7416 test -n "$prev" && \
7417 func_fatal_help "the '$prevarg' option requires an argument"
7418
7419 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7420 eval arg=\"$export_dynamic_flag_spec\"
7421 func_append compile_command " $arg"
7422 func_append finalize_command " $arg"
7423 fi
7424
7425 oldlibs=
7426 # calculate the name of the file, without its directory
7427 func_basename "$output"
7428 outputname=$func_basename_result
7429 libobjs_save=$libobjs
7430
7431 if test -n "$shlibpath_var"; then
7432 # get the directories listed in $shlibpath_var
7433 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7434 else
7435 shlib_search_path=
7436 fi
7437 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7438 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7439
7440 func_dirname "$output" "/" ""
7441 output_objdir=$func_dirname_result$objdir
7442 func_to_tool_file "$output_objdir/"
7443 tool_output_objdir=$func_to_tool_file_result
7444 # Create the object directory.
7445 func_mkdir_p "$output_objdir"
7446
7447 # Determine the type of output
7448 case $output in
7449 "")
7450 func_fatal_help "you must specify an output file"
7451 ;;
7452 *.$libext) linkmode=oldlib ;;
7453 *.lo | *.$objext) linkmode=obj ;;
7454 *.la) linkmode=lib ;;
7455 *) linkmode=prog ;; # Anything else should be a program.
7456 esac
7457
7458 specialdeplibs=
7459
7460 libs=
7461 # Find all interdependent deplibs by searching for libraries
7462 # that are linked more than once (e.g. -la -lb -la)
7463 for deplib in $deplibs; do
7464 if $opt_preserve_dup_deps; then
7465 case "$libs " in
7466 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7467 esac
7468 fi
7469 func_append libs " $deplib"
7470 done
7471
7472 if test lib = "$linkmode"; then
7473 libs="$predeps $libs $compiler_lib_search_path $postdeps"
7474
7475 # Compute libraries that are listed more than once in $predeps
7476 # $postdeps and mark them as special (i.e., whose duplicates are
7477 # not to be eliminated).
7478 pre_post_deps=
7479 if $opt_duplicate_compiler_generated_deps; then
7480 for pre_post_dep in $predeps $postdeps; do
7481 case "$pre_post_deps " in
7482 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7483 esac
7484 func_append pre_post_deps " $pre_post_dep"
7485 done
7486 fi
7487 pre_post_deps=
7488 fi
7489
7490 deplibs=
7491 newdependency_libs=
7492 newlib_search_path=
7493 need_relink=no # whether we're linking any uninstalled libtool libraries
7494 notinst_deplibs= # not-installed libtool libraries
7495 notinst_path= # paths that contain not-installed libtool libraries
7496
7497 case $linkmode in
7498 lib)
7499 passes="conv dlpreopen link"
7500 for file in $dlfiles $dlprefiles; do
7501 case $file in
7502 *.la) ;;
7503 *)
7504 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7505 ;;
7506 esac
7507 done
7508 ;;
7509 prog)
7510 compile_deplibs=
7511 finalize_deplibs=
7512 alldeplibs=false
7513 newdlfiles=
7514 newdlprefiles=
7515 passes="conv scan dlopen dlpreopen link"
7516 ;;
7517 *) passes="conv"
7518 ;;
7519 esac
7520
7521 for pass in $passes; do
7522 # The preopen pass in lib mode reverses $deplibs; put it back here
7523 # so that -L comes before libs that need it for instance...
7524 if test lib,link = "$linkmode,$pass"; then
7525 ## FIXME: Find the place where the list is rebuilt in the wrong
7526 ## order, and fix it there properly
7527 tmp_deplibs=
7528 for deplib in $deplibs; do
7529 tmp_deplibs="$deplib $tmp_deplibs"
7530 done
7531 deplibs=$tmp_deplibs
7532 fi
7533
7534 if test lib,link = "$linkmode,$pass" ||
7535 test prog,scan = "$linkmode,$pass"; then
7536 libs=$deplibs
7537 deplibs=
7538 fi
7539 if test prog = "$linkmode"; then
7540 case $pass in
7541 dlopen) libs=$dlfiles ;;
7542 dlpreopen) libs=$dlprefiles ;;
7543 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7544 esac
7545 fi
7546 if test lib,dlpreopen = "$linkmode,$pass"; then
7547 # Collect and forward deplibs of preopened libtool libs
7548 for lib in $dlprefiles; do
7549 # Ignore non-libtool-libs
7550 dependency_libs=
7551 func_resolve_sysroot "$lib"
7552 case $lib in
7553 *.la) func_source "$func_resolve_sysroot_result" ;;
7554 esac
7555
7556 # Collect preopened libtool deplibs, except any this library
7557 # has declared as weak libs
7558 for deplib in $dependency_libs; do
7559 func_basename "$deplib"
7560 deplib_base=$func_basename_result
7561 case " $weak_libs " in
7562 *" $deplib_base "*) ;;
7563 *) func_append deplibs " $deplib" ;;
7564 esac
7565 done
7566 done
7567 libs=$dlprefiles
7568 fi
7569 if test dlopen = "$pass"; then
7570 # Collect dlpreopened libraries
7571 save_deplibs=$deplibs
7572 deplibs=
7573 fi
7574
7575 for deplib in $libs; do
7576 lib=
7577 found=false
7578 case $deplib in
7579 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7580 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7581 if test prog,link = "$linkmode,$pass"; then
7582 compile_deplibs="$deplib $compile_deplibs"
7583 finalize_deplibs="$deplib $finalize_deplibs"
7584 else
7585 func_append compiler_flags " $deplib"
7586 if test lib = "$linkmode"; then
7587 case "$new_inherited_linker_flags " in
7588 *" $deplib "*) ;;
7589 * ) func_append new_inherited_linker_flags " $deplib" ;;
7590 esac
7591 fi
7592 fi
7593 continue
7594 ;;
7595 -l*)
7596 if test lib != "$linkmode" && test prog != "$linkmode"; then
7597 func_warning "'-l' is ignored for archives/objects"
7598 continue
7599 fi
7600 func_stripname '-l' '' "$deplib"
7601 name=$func_stripname_result
7602 if test lib = "$linkmode"; then
7603 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7604 else
7605 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7606 fi
7607 for searchdir in $searchdirs; do
7608 for search_ext in .la $std_shrext .so .a; do
7609 # Search the libtool library
7610 lib=$searchdir/lib$name$search_ext
7611 if test -f "$lib"; then
7612 if test .la = "$search_ext"; then
7613 found=:
7614 else
7615 found=false
7616 fi
7617 break 2
7618 fi
7619 done
7620 done
7621 if $found; then
7622 # deplib is a libtool library
7623 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7624 # We need to do some special things here, and not later.
7625 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7626 case " $predeps $postdeps " in
7627 *" $deplib "*)
7628 if func_lalib_p "$lib"; then
7629 library_names=
7630 old_library=
7631 func_source "$lib"
7632 for l in $old_library $library_names; do
7633 ll=$l
7634 done
7635 if test "X$ll" = "X$old_library"; then # only static version available
7636 found=false
7637 func_dirname "$lib" "" "."
7638 ladir=$func_dirname_result
7639 lib=$ladir/$old_library
7640 if test prog,link = "$linkmode,$pass"; then
7641 compile_deplibs="$deplib $compile_deplibs"
7642 finalize_deplibs="$deplib $finalize_deplibs"
7643 else
7644 deplibs="$deplib $deplibs"
7645 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7646 fi
7647 continue
7648 fi
7649 fi
7650 ;;
7651 *) ;;
7652 esac
7653 fi
7654 else
7655 # deplib doesn't seem to be a libtool library
7656 if test prog,link = "$linkmode,$pass"; then
7657 compile_deplibs="$deplib $compile_deplibs"
7658 finalize_deplibs="$deplib $finalize_deplibs"
7659 else
7660 deplibs="$deplib $deplibs"
7661 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7662 fi
7663 continue
7664 fi
7665 ;; # -l
7666 *.ltframework)
7667 if test prog,link = "$linkmode,$pass"; then
7668 compile_deplibs="$deplib $compile_deplibs"
7669 finalize_deplibs="$deplib $finalize_deplibs"
7670 else
7671 deplibs="$deplib $deplibs"
7672 if test lib = "$linkmode"; then
7673 case "$new_inherited_linker_flags " in
7674 *" $deplib "*) ;;
7675 * ) func_append new_inherited_linker_flags " $deplib" ;;
7676 esac
7677 fi
7678 fi
7679 continue
7680 ;;
7681 -L*)
7682 case $linkmode in
7683 lib)
7684 deplibs="$deplib $deplibs"
7685 test conv = "$pass" && continue
7686 newdependency_libs="$deplib $newdependency_libs"
7687 func_stripname '-L' '' "$deplib"
7688 func_resolve_sysroot "$func_stripname_result"
7689 func_append newlib_search_path " $func_resolve_sysroot_result"
7690 ;;
7691 prog)
7692 if test conv = "$pass"; then
7693 deplibs="$deplib $deplibs"
7694 continue
7695 fi
7696 if test scan = "$pass"; then
7697 deplibs="$deplib $deplibs"
7698 else
7699 compile_deplibs="$deplib $compile_deplibs"
7700 finalize_deplibs="$deplib $finalize_deplibs"
7701 fi
7702 func_stripname '-L' '' "$deplib"
7703 func_resolve_sysroot "$func_stripname_result"
7704 func_append newlib_search_path " $func_resolve_sysroot_result"
7705 ;;
7706 *)
7707 func_warning "'-L' is ignored for archives/objects"
7708 ;;
7709 esac # linkmode
7710 continue
7711 ;; # -L
7712 -R*)
7713 if test link = "$pass"; then
7714 func_stripname '-R' '' "$deplib"
7715 func_resolve_sysroot "$func_stripname_result"
7716 dir=$func_resolve_sysroot_result
7717 # Make sure the xrpath contains only unique directories.
7718 case "$xrpath " in
7719 *" $dir "*) ;;
7720 *) func_append xrpath " $dir" ;;
7721 esac
7722 fi
7723 deplibs="$deplib $deplibs"
7724 continue
7725 ;;
7726 *.la)
7727 func_resolve_sysroot "$deplib"
7728 lib=$func_resolve_sysroot_result
7729 ;;
7730 *.$libext)
7731 if test conv = "$pass"; then
7732 deplibs="$deplib $deplibs"
7733 continue
7734 fi
7735 case $linkmode in
7736 lib)
7737 # Linking convenience modules into shared libraries is allowed,
7738 # but linking other static libraries is non-portable.
7739 case " $dlpreconveniencelibs " in
7740 *" $deplib "*) ;;
7741 *)
7742 valid_a_lib=false
7743 case $deplibs_check_method in
7744 match_pattern*)
7745 set dummy $deplibs_check_method; shift
7746 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7747 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7748 | $EGREP "$match_pattern_regex" > /dev/null; then
7749 valid_a_lib=:
7750 fi
7751 ;;
7752 pass_all)
7753 valid_a_lib=:
7754 ;;
7755 esac
7756 if $valid_a_lib; then
7757 echo
7758 $ECHO "*** Warning: Linking the shared library $output against the"
7759 $ECHO "*** static library $deplib is not portable!"
7760 deplibs="$deplib $deplibs"
7761 else
7762 echo
7763 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
7764 echo "*** I have the capability to make that library automatically link in when"
7765 echo "*** you link to this library. But I can only do this if you have a"
7766 echo "*** shared version of the library, which you do not appear to have"
7767 echo "*** because the file extensions .$libext of this argument makes me believe"
7768 echo "*** that it is just a static archive that I should not use here."
7769 fi
7770 ;;
7771 esac
7772 continue
7773 ;;
7774 prog)
7775 if test link != "$pass"; then
7776 deplibs="$deplib $deplibs"
7777 else
7778 compile_deplibs="$deplib $compile_deplibs"
7779 finalize_deplibs="$deplib $finalize_deplibs"
7780 fi
7781 continue
7782 ;;
7783 esac # linkmode
7784 ;; # *.$libext
7785 *.lo | *.$objext)
7786 if test conv = "$pass"; then
7787 deplibs="$deplib $deplibs"
7788 elif test prog = "$linkmode"; then
7789 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7790 # If there is no dlopen support or we're linking statically,
7791 # we need to preload.
7792 func_append newdlprefiles " $deplib"
7793 compile_deplibs="$deplib $compile_deplibs"
7794 finalize_deplibs="$deplib $finalize_deplibs"
7795 else
7796 func_append newdlfiles " $deplib"
7797 fi
7798 fi
7799 continue
7800 ;;
7801 %DEPLIBS%)
7802 alldeplibs=:
7803 continue
7804 ;;
7805 esac # case $deplib
7806
7807 $found || test -f "$lib" \
7808 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7809
7810 # Check to see that this really is a libtool archive.
7811 func_lalib_unsafe_p "$lib" \
7812 || func_fatal_error "'$lib' is not a valid libtool archive"
7813
7814 func_dirname "$lib" "" "."
7815 ladir=$func_dirname_result
7816
7817 dlname=
7818 dlopen=
7819 dlpreopen=
7820 libdir=
7821 library_names=
7822 old_library=
7823 inherited_linker_flags=
7824 # If the library was installed with an old release of libtool,
7825 # it will not redefine variables installed, or shouldnotlink
7826 installed=yes
7827 shouldnotlink=no
7828 avoidtemprpath=
7829
7830
7831 # Read the .la file
7832 func_source "$lib"
7833
7834 # Convert "-framework foo" to "foo.ltframework"
7835 if test -n "$inherited_linker_flags"; then
7836 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7837 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7838 case " $new_inherited_linker_flags " in
7839 *" $tmp_inherited_linker_flag "*) ;;
7840 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7841 esac
7842 done
7843 fi
7844 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7845 if test lib,link = "$linkmode,$pass" ||
7846 test prog,scan = "$linkmode,$pass" ||
7847 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7848 test -n "$dlopen" && func_append dlfiles " $dlopen"
7849 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7850 fi
7851
7852 if test conv = "$pass"; then
7853 # Only check for convenience libraries
7854 deplibs="$lib $deplibs"
7855 if test -z "$libdir"; then
7856 if test -z "$old_library"; then
7857 func_fatal_error "cannot find name of link library for '$lib'"
7858 fi
7859 # It is a libtool convenience library, so add in its objects.
7860 func_append convenience " $ladir/$objdir/$old_library"
7861 func_append old_convenience " $ladir/$objdir/$old_library"
7862 elif test prog != "$linkmode" && test lib != "$linkmode"; then
7863 func_fatal_error "'$lib' is not a convenience library"
7864 fi
7865 tmp_libs=
7866 for deplib in $dependency_libs; do
7867 deplibs="$deplib $deplibs"
7868 if $opt_preserve_dup_deps; then
7869 case "$tmp_libs " in
7870 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7871 esac
7872 fi
7873 func_append tmp_libs " $deplib"
7874 done
7875 continue
7876 fi # $pass = conv
7877
7878
7879 # Get the name of the library we link against.
7880 linklib=
7881 if test -n "$old_library" &&
7882 { test yes = "$prefer_static_libs" ||
7883 test built,no = "$prefer_static_libs,$installed"; }; then
7884 linklib=$old_library
7885 else
7886 for l in $old_library $library_names; do
7887 linklib=$l
7888 done
7889 fi
7890 if test -z "$linklib"; then
7891 func_fatal_error "cannot find name of link library for '$lib'"
7892 fi
7893
7894 # This library was specified with -dlopen.
7895 if test dlopen = "$pass"; then
7896 test -z "$libdir" \
7897 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7898 if test -z "$dlname" ||
7899 test yes != "$dlopen_support" ||
7900 test no = "$build_libtool_libs"
7901 then
7902 # If there is no dlname, no dlopen support or we're linking
7903 # statically, we need to preload. We also need to preload any
7904 # dependent libraries so libltdl's deplib preloader doesn't
7905 # bomb out in the load deplibs phase.
7906 func_append dlprefiles " $lib $dependency_libs"
7907 else
7908 func_append newdlfiles " $lib"
7909 fi
7910 continue
7911 fi # $pass = dlopen
7912
7913 # We need an absolute path.
7914 case $ladir in
7915 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7916 *)
7917 abs_ladir=`cd "$ladir" && pwd`
7918 if test -z "$abs_ladir"; then
7919 func_warning "cannot determine absolute directory name of '$ladir'"
7920 func_warning "passing it literally to the linker, although it might fail"
7921 abs_ladir=$ladir
7922 fi
7923 ;;
7924 esac
7925 func_basename "$lib"
7926 laname=$func_basename_result
7927
7928 # Find the relevant object directory and library name.
7929 if test yes = "$installed"; then
7930 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7931 func_warning "library '$lib' was moved."
7932 dir=$ladir
7933 absdir=$abs_ladir
7934 libdir=$abs_ladir
7935 else
7936 dir=$lt_sysroot$libdir
7937 absdir=$lt_sysroot$libdir
7938 fi
7939 test yes = "$hardcode_automatic" && avoidtemprpath=yes
7940 else
7941 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7942 dir=$ladir
7943 absdir=$abs_ladir
7944 # Remove this search path later
7945 func_append notinst_path " $abs_ladir"
7946 else
7947 dir=$ladir/$objdir
7948 absdir=$abs_ladir/$objdir
7949 # Remove this search path later
7950 func_append notinst_path " $abs_ladir"
7951 fi
7952 fi # $installed = yes
7953 func_stripname 'lib' '.la' "$laname"
7954 name=$func_stripname_result
7955
7956 # This library was specified with -dlpreopen.
7957 if test dlpreopen = "$pass"; then
7958 if test -z "$libdir" && test prog = "$linkmode"; then
7959 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7960 fi
7961 case $host in
7962 # special handling for platforms with PE-DLLs.
7963 *cygwin* | *mingw* | *cegcc* )
7964 # Linker will automatically link against shared library if both
7965 # static and shared are present. Therefore, ensure we extract
7966 # symbols from the import library if a shared library is present
7967 # (otherwise, the dlopen module name will be incorrect). We do
7968 # this by putting the import library name into $newdlprefiles.
7969 # We recover the dlopen module name by 'saving' the la file
7970 # name in a special purpose variable, and (later) extracting the
7971 # dlname from the la file.
7972 if test -n "$dlname"; then
7973 func_tr_sh "$dir/$linklib"
7974 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
7975 func_append newdlprefiles " $dir/$linklib"
7976 else
7977 func_append newdlprefiles " $dir/$old_library"
7978 # Keep a list of preopened convenience libraries to check
7979 # that they are being used correctly in the link pass.
7980 test -z "$libdir" && \
7981 func_append dlpreconveniencelibs " $dir/$old_library"
7982 fi
7983 ;;
7984 * )
7985 # Prefer using a static library (so that no silly _DYNAMIC symbols
7986 # are required to link).
7987 if test -n "$old_library"; then
7988 func_append newdlprefiles " $dir/$old_library"
7989 # Keep a list of preopened convenience libraries to check
7990 # that they are being used correctly in the link pass.
7991 test -z "$libdir" && \
7992 func_append dlpreconveniencelibs " $dir/$old_library"
7993 # Otherwise, use the dlname, so that lt_dlopen finds it.
7994 elif test -n "$dlname"; then
7995 func_append newdlprefiles " $dir/$dlname"
7996 else
7997 func_append newdlprefiles " $dir/$linklib"
7998 fi
7999 ;;
8000 esac
8001 fi # $pass = dlpreopen
8002
8003 if test -z "$libdir"; then
8004 # Link the convenience library
8005 if test lib = "$linkmode"; then
8006 deplibs="$dir/$old_library $deplibs"
8007 elif test prog,link = "$linkmode,$pass"; then
8008 compile_deplibs="$dir/$old_library $compile_deplibs"
8009 finalize_deplibs="$dir/$old_library $finalize_deplibs"
8010 else
8011 deplibs="$lib $deplibs" # used for prog,scan pass
8012 fi
8013 continue
8014 fi
8015
8016
8017 if test prog = "$linkmode" && test link != "$pass"; then
8018 func_append newlib_search_path " $ladir"
8019 deplibs="$lib $deplibs"
8020
8021 linkalldeplibs=false
8022 if test no != "$link_all_deplibs" || test -z "$library_names" ||
8023 test no = "$build_libtool_libs"; then
8024 linkalldeplibs=:
8025 fi
8026
8027 tmp_libs=
8028 for deplib in $dependency_libs; do
8029 case $deplib in
8030 -L*) func_stripname '-L' '' "$deplib"
8031 func_resolve_sysroot "$func_stripname_result"
8032 func_append newlib_search_path " $func_resolve_sysroot_result"
8033 ;;
8034 esac
8035 # Need to link against all dependency_libs?
8036 if $linkalldeplibs; then
8037 deplibs="$deplib $deplibs"
8038 else
8039 # Need to hardcode shared library paths
8040 # or/and link against static libraries
8041 newdependency_libs="$deplib $newdependency_libs"
8042 fi
8043 if $opt_preserve_dup_deps; then
8044 case "$tmp_libs " in
8045 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8046 esac
8047 fi
8048 func_append tmp_libs " $deplib"
8049 done # for deplib
8050 continue
8051 fi # $linkmode = prog...
8052
8053 if test prog,link = "$linkmode,$pass"; then
8054 if test -n "$library_names" &&
8055 { { test no = "$prefer_static_libs" ||
8056 test built,yes = "$prefer_static_libs,$installed"; } ||
8057 test -z "$old_library"; }; then
8058 # We need to hardcode the library path
8059 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8060 # Make sure the rpath contains only unique directories.
8061 case $temp_rpath: in
8062 *"$absdir:"*) ;;
8063 *) func_append temp_rpath "$absdir:" ;;
8064 esac
8065 fi
8066
8067 # Hardcode the library path.
8068 # Skip directories that are in the system default run-time
8069 # search path.
8070 case " $sys_lib_dlsearch_path " in
8071 *" $absdir "*) ;;
8072 *)
8073 case "$compile_rpath " in
8074 *" $absdir "*) ;;
8075 *) func_append compile_rpath " $absdir" ;;
8076 esac
8077 ;;
8078 esac
8079 case " $sys_lib_dlsearch_path " in
8080 *" $libdir "*) ;;
8081 *)
8082 case "$finalize_rpath " in
8083 *" $libdir "*) ;;
8084 *) func_append finalize_rpath " $libdir" ;;
8085 esac
8086 ;;
8087 esac
8088 fi # $linkmode,$pass = prog,link...
8089
8090 if $alldeplibs &&
8091 { test pass_all = "$deplibs_check_method" ||
8092 { test yes = "$build_libtool_libs" &&
8093 test -n "$library_names"; }; }; then
8094 # We only need to search for static libraries
8095 continue
8096 fi
8097 fi
8098
8099 link_static=no # Whether the deplib will be linked statically
8100 use_static_libs=$prefer_static_libs
8101 if test built = "$use_static_libs" && test yes = "$installed"; then
8102 use_static_libs=no
8103 fi
8104 if test -n "$library_names" &&
8105 { test no = "$use_static_libs" || test -z "$old_library"; }; then
8106 case $host in
8107 *cygwin* | *mingw* | *cegcc* | *os2*)
8108 # No point in relinking DLLs because paths are not encoded
8109 func_append notinst_deplibs " $lib"
8110 need_relink=no
8111 ;;
8112 *)
8113 if test no = "$installed"; then
8114 func_append notinst_deplibs " $lib"
8115 need_relink=yes
8116 fi
8117 ;;
8118 esac
8119 # This is a shared library
8120
8121 # Warn about portability, can't link against -module's on some
8122 # systems (darwin). Don't bleat about dlopened modules though!
8123 dlopenmodule=
8124 for dlpremoduletest in $dlprefiles; do
8125 if test "X$dlpremoduletest" = "X$lib"; then
8126 dlopenmodule=$dlpremoduletest
8127 break
8128 fi
8129 done
8130 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8131 echo
8132 if test prog = "$linkmode"; then
8133 $ECHO "*** Warning: Linking the executable $output against the loadable module"
8134 else
8135 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8136 fi
8137 $ECHO "*** $linklib is not portable!"
8138 fi
8139 if test lib = "$linkmode" &&
8140 test yes = "$hardcode_into_libs"; then
8141 # Hardcode the library path.
8142 # Skip directories that are in the system default run-time
8143 # search path.
8144 case " $sys_lib_dlsearch_path " in
8145 *" $absdir "*) ;;
8146 *)
8147 case "$compile_rpath " in
8148 *" $absdir "*) ;;
8149 *) func_append compile_rpath " $absdir" ;;
8150 esac
8151 ;;
8152 esac
8153 case " $sys_lib_dlsearch_path " in
8154 *" $libdir "*) ;;
8155 *)
8156 case "$finalize_rpath " in
8157 *" $libdir "*) ;;
8158 *) func_append finalize_rpath " $libdir" ;;
8159 esac
8160 ;;
8161 esac
8162 fi
8163
8164 if test -n "$old_archive_from_expsyms_cmds"; then
8165 # figure out the soname
8166 set dummy $library_names
8167 shift
8168 realname=$1
8169 shift
8170 libname=`eval "\\$ECHO \"$libname_spec\""`
8171 # use dlname if we got it. it's perfectly good, no?
8172 if test -n "$dlname"; then
8173 soname=$dlname
8174 elif test -n "$soname_spec"; then
8175 # bleh windows
8176 case $host in
8177 *cygwin* | mingw* | *cegcc* | *os2*)
8178 func_arith $current - $age
8179 major=$func_arith_result
8180 versuffix=-$major
8181 ;;
8182 esac
8183 eval soname=\"$soname_spec\"
8184 else
8185 soname=$realname
8186 fi
8187
8188 # Make a new name for the extract_expsyms_cmds to use
8189 soroot=$soname
8190 func_basename "$soroot"
8191 soname=$func_basename_result
8192 func_stripname 'lib' '.dll' "$soname"
8193 newlib=libimp-$func_stripname_result.a
8194
8195 # If the library has no export list, then create one now
8196 if test -f "$output_objdir/$soname-def"; then :
8197 else
8198 func_verbose "extracting exported symbol list from '$soname'"
8199 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8200 fi
8201
8202 # Create $newlib
8203 if test -f "$output_objdir/$newlib"; then :; else
8204 func_verbose "generating import library for '$soname'"
8205 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8206 fi
8207 # make sure the library variables are pointing to the new library
8208 dir=$output_objdir
8209 linklib=$newlib
8210 fi # test -n "$old_archive_from_expsyms_cmds"
8211
8212 if test prog = "$linkmode" || test relink != "$opt_mode"; then
8213 add_shlibpath=
8214 add_dir=
8215 add=
8216 lib_linked=yes
8217 case $hardcode_action in
8218 immediate | unsupported)
8219 if test no = "$hardcode_direct"; then
8220 add=$dir/$linklib
8221 case $host in
8222 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8223 *-*-sysv4*uw2*) add_dir=-L$dir ;;
8224 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8225 *-*-unixware7*) add_dir=-L$dir ;;
8226 *-*-darwin* )
8227 # if the lib is a (non-dlopened) module then we cannot
8228 # link against it, someone is ignoring the earlier warnings
8229 if /usr/bin/file -L $add 2> /dev/null |
8230 $GREP ": [^:]* bundle" >/dev/null; then
8231 if test "X$dlopenmodule" != "X$lib"; then
8232 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
8233 if test -z "$old_library"; then
8234 echo
8235 echo "*** And there doesn't seem to be a static archive available"
8236 echo "*** The link will probably fail, sorry"
8237 else
8238 add=$dir/$old_library
8239 fi
8240 elif test -n "$old_library"; then
8241 add=$dir/$old_library
8242 fi
8243 fi
8244 esac
8245 elif test no = "$hardcode_minus_L"; then
8246 case $host in
8247 *-*-sunos*) add_shlibpath=$dir ;;
8248 esac
8249 add_dir=-L$dir
8250 add=-l$name
8251 elif test no = "$hardcode_shlibpath_var"; then
8252 add_shlibpath=$dir
8253 add=-l$name
8254 else
8255 lib_linked=no
8256 fi
8257 ;;
8258 relink)
8259 if test yes = "$hardcode_direct" &&
8260 test no = "$hardcode_direct_absolute"; then
8261 add=$dir/$linklib
8262 elif test yes = "$hardcode_minus_L"; then
8263 add_dir=-L$absdir
8264 # Try looking first in the location we're being installed to.
8265 if test -n "$inst_prefix_dir"; then
8266 case $libdir in
8267 [\\/]*)
8268 func_append add_dir " -L$inst_prefix_dir$libdir"
8269 ;;
8270 esac
8271 fi
8272 add=-l$name
8273 elif test yes = "$hardcode_shlibpath_var"; then
8274 add_shlibpath=$dir
8275 add=-l$name
8276 else
8277 lib_linked=no
8278 fi
8279 ;;
8280 *) lib_linked=no ;;
8281 esac
8282
8283 if test yes != "$lib_linked"; then
8284 func_fatal_configuration "unsupported hardcode properties"
8285 fi
8286
8287 if test -n "$add_shlibpath"; then
8288 case :$compile_shlibpath: in
8289 *":$add_shlibpath:"*) ;;
8290 *) func_append compile_shlibpath "$add_shlibpath:" ;;
8291 esac
8292 fi
8293 if test prog = "$linkmode"; then
8294 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8295 test -n "$add" && compile_deplibs="$add $compile_deplibs"
8296 else
8297 test -n "$add_dir" && deplibs="$add_dir $deplibs"
8298 test -n "$add" && deplibs="$add $deplibs"
8299 if test yes != "$hardcode_direct" &&
8300 test yes != "$hardcode_minus_L" &&
8301 test yes = "$hardcode_shlibpath_var"; then
8302 case :$finalize_shlibpath: in
8303 *":$libdir:"*) ;;
8304 *) func_append finalize_shlibpath "$libdir:" ;;
8305 esac
8306 fi
8307 fi
8308 fi
8309
8310 if test prog = "$linkmode" || test relink = "$opt_mode"; then
8311 add_shlibpath=
8312 add_dir=
8313 add=
8314 # Finalize command for both is simple: just hardcode it.
8315 if test yes = "$hardcode_direct" &&
8316 test no = "$hardcode_direct_absolute"; then
8317 add=$libdir/$linklib
8318 elif test yes = "$hardcode_minus_L"; then
8319 add_dir=-L$libdir
8320 add=-l$name
8321 elif test yes = "$hardcode_shlibpath_var"; then
8322 case :$finalize_shlibpath: in
8323 *":$libdir:"*) ;;
8324 *) func_append finalize_shlibpath "$libdir:" ;;
8325 esac
8326 add=-l$name
8327 elif test yes = "$hardcode_automatic"; then
8328 if test -n "$inst_prefix_dir" &&
8329 test -f "$inst_prefix_dir$libdir/$linklib"; then
8330 add=$inst_prefix_dir$libdir/$linklib
8331 else
8332 add=$libdir/$linklib
8333 fi
8334 else
8335 # We cannot seem to hardcode it, guess we'll fake it.
8336 add_dir=-L$libdir
8337 # Try looking first in the location we're being installed to.
8338 if test -n "$inst_prefix_dir"; then
8339 case $libdir in
8340 [\\/]*)
8341 func_append add_dir " -L$inst_prefix_dir$libdir"
8342 ;;
8343 esac
8344 fi
8345 add=-l$name
8346 fi
8347
8348 if test prog = "$linkmode"; then
8349 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8350 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8351 else
8352 test -n "$add_dir" && deplibs="$add_dir $deplibs"
8353 test -n "$add" && deplibs="$add $deplibs"
8354 fi
8355 fi
8356 elif test prog = "$linkmode"; then
8357 # Here we assume that one of hardcode_direct or hardcode_minus_L
8358 # is not unsupported. This is valid on all known static and
8359 # shared platforms.
8360 if test unsupported != "$hardcode_direct"; then
8361 test -n "$old_library" && linklib=$old_library
8362 compile_deplibs="$dir/$linklib $compile_deplibs"
8363 finalize_deplibs="$dir/$linklib $finalize_deplibs"
8364 else
8365 compile_deplibs="-l$name -L$dir $compile_deplibs"
8366 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8367 fi
8368 elif test yes = "$build_libtool_libs"; then
8369 # Not a shared library
8370 if test pass_all != "$deplibs_check_method"; then
8371 # We're trying link a shared library against a static one
8372 # but the system doesn't support it.
8373
8374 # Just print a warning and add the library to dependency_libs so
8375 # that the program can be linked against the static library.
8376 echo
8377 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8378 echo "*** I have the capability to make that library automatically link in when"
8379 echo "*** you link to this library. But I can only do this if you have a"
8380 echo "*** shared version of the library, which you do not appear to have."
8381 if test yes = "$module"; then
8382 echo "*** But as you try to build a module library, libtool will still create "
8383 echo "*** a static module, that should work as long as the dlopening application"
8384 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8385 if test -z "$global_symbol_pipe"; then
8386 echo
8387 echo "*** However, this would only work if libtool was able to extract symbol"
8388 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8389 echo "*** not find such a program. So, this module is probably useless."
8390 echo "*** 'nm' from GNU binutils and a full rebuild may help."
8391 fi
8392 if test no = "$build_old_libs"; then
8393 build_libtool_libs=module
8394 build_old_libs=yes
8395 else
8396 build_libtool_libs=no
8397 fi
8398 fi
8399 else
8400 deplibs="$dir/$old_library $deplibs"
8401 link_static=yes
8402 fi
8403 fi # link shared/static library?
8404
8405 if test lib = "$linkmode"; then
8406 if test -n "$dependency_libs" &&
8407 { test yes != "$hardcode_into_libs" ||
8408 test yes = "$build_old_libs" ||
8409 test yes = "$link_static"; }; then
8410 # Extract -R from dependency_libs
8411 temp_deplibs=
8412 for libdir in $dependency_libs; do
8413 case $libdir in
8414 -R*) func_stripname '-R' '' "$libdir"
8415 temp_xrpath=$func_stripname_result
8416 case " $xrpath " in
8417 *" $temp_xrpath "*) ;;
8418 *) func_append xrpath " $temp_xrpath";;
8419 esac;;
8420 *) func_append temp_deplibs " $libdir";;
8421 esac
8422 done
8423 dependency_libs=$temp_deplibs
8424 fi
8425
8426 func_append newlib_search_path " $absdir"
8427 # Link against this library
8428 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8429 # ... and its dependency_libs
8430 tmp_libs=
8431 for deplib in $dependency_libs; do
8432 newdependency_libs="$deplib $newdependency_libs"
8433 case $deplib in
8434 -L*) func_stripname '-L' '' "$deplib"
8435 func_resolve_sysroot "$func_stripname_result";;
8436 *) func_resolve_sysroot "$deplib" ;;
8437 esac
8438 if $opt_preserve_dup_deps; then
8439 case "$tmp_libs " in
8440 *" $func_resolve_sysroot_result "*)
8441 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8442 esac
8443 fi
8444 func_append tmp_libs " $func_resolve_sysroot_result"
8445 done
8446
8447 if test no != "$link_all_deplibs"; then
8448 # Add the search paths of all dependency libraries
8449 for deplib in $dependency_libs; do
8450 path=
8451 case $deplib in
8452 -L*) path=$deplib ;;
8453 *.la)
8454 func_resolve_sysroot "$deplib"
8455 deplib=$func_resolve_sysroot_result
8456 func_dirname "$deplib" "" "."
8457 dir=$func_dirname_result
8458 # We need an absolute path.
8459 case $dir in
8460 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8461 *)
8462 absdir=`cd "$dir" && pwd`
8463 if test -z "$absdir"; then
8464 func_warning "cannot determine absolute directory name of '$dir'"
8465 absdir=$dir
8466 fi
8467 ;;
8468 esac
8469 if $GREP "^installed=no" $deplib > /dev/null; then
8470 case $host in
8471 *-*-darwin*)
8472 depdepl=
8473 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8474 if test -n "$deplibrary_names"; then
8475 for tmp in $deplibrary_names; do
8476 depdepl=$tmp
8477 done
8478 if test -f "$absdir/$objdir/$depdepl"; then
8479 depdepl=$absdir/$objdir/$depdepl
8480 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8481 if test -z "$darwin_install_name"; then
8482 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8483 fi
8484 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8485 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8486 path=
8487 fi
8488 fi
8489 ;;
8490 *)
8491 path=-L$absdir/$objdir
8492 ;;
8493 esac
8494 else
8495 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8496 test -z "$libdir" && \
8497 func_fatal_error "'$deplib' is not a valid libtool archive"
8498 test "$absdir" != "$libdir" && \
8499 func_warning "'$deplib' seems to be moved"
8500
8501 path=-L$absdir
8502 fi
8503 ;;
8504 esac
8505 case " $deplibs " in
8506 *" $path "*) ;;
8507 *) deplibs="$path $deplibs" ;;
8508 esac
8509 done
8510 fi # link_all_deplibs != no
8511 fi # linkmode = lib
8512 done # for deplib in $libs
8513 if test link = "$pass"; then
8514 if test prog = "$linkmode"; then
8515 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8516 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8517 else
8518 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8519 fi
8520 fi
8521 dependency_libs=$newdependency_libs
8522 if test dlpreopen = "$pass"; then
8523 # Link the dlpreopened libraries before other libraries
8524 for deplib in $save_deplibs; do
8525 deplibs="$deplib $deplibs"
8526 done
8527 fi
8528 if test dlopen != "$pass"; then
8529 test conv = "$pass" || {
8530 # Make sure lib_search_path contains only unique directories.
8531 lib_search_path=
8532 for dir in $newlib_search_path; do
8533 case "$lib_search_path " in
8534 *" $dir "*) ;;
8535 *) func_append lib_search_path " $dir" ;;
8536 esac
8537 done
8538 newlib_search_path=
8539 }
8540
8541 if test prog,link = "$linkmode,$pass"; then
8542 vars="compile_deplibs finalize_deplibs"
8543 else
8544 vars=deplibs
8545 fi
8546 for var in $vars dependency_libs; do
8547 # Add libraries to $var in reverse order
8548 eval tmp_libs=\"\$$var\"
8549 new_libs=
8550 for deplib in $tmp_libs; do
8551 # FIXME: Pedantically, this is the right thing to do, so
8552 # that some nasty dependency loop isn't accidentally
8553 # broken:
8554 #new_libs="$deplib $new_libs"
8555 # Pragmatically, this seems to cause very few problems in
8556 # practice:
8557 case $deplib in
8558 -L*) new_libs="$deplib $new_libs" ;;
8559 -R*) ;;
8560 *)
8561 # And here is the reason: when a library appears more
8562 # than once as an explicit dependence of a library, or
8563 # is implicitly linked in more than once by the
8564 # compiler, it is considered special, and multiple
8565 # occurrences thereof are not removed. Compare this
8566 # with having the same library being listed as a
8567 # dependency of multiple other libraries: in this case,
8568 # we know (pedantically, we assume) the library does not
8569 # need to be listed more than once, so we keep only the
8570 # last copy. This is not always right, but it is rare
8571 # enough that we require users that really mean to play
8572 # such unportable linking tricks to link the library
8573 # using -Wl,-lname, so that libtool does not consider it
8574 # for duplicate removal.
8575 case " $specialdeplibs " in
8576 *" $deplib "*) new_libs="$deplib $new_libs" ;;
8577 *)
8578 case " $new_libs " in
8579 *" $deplib "*) ;;
8580 *) new_libs="$deplib $new_libs" ;;
8581 esac
8582 ;;
8583 esac
8584 ;;
8585 esac
8586 done
8587 tmp_libs=
8588 for deplib in $new_libs; do
8589 case $deplib in
8590 -L*)
8591 case " $tmp_libs " in
8592 *" $deplib "*) ;;
8593 *) func_append tmp_libs " $deplib" ;;
8594 esac
8595 ;;
8596 *) func_append tmp_libs " $deplib" ;;
8597 esac
8598 done
8599 eval $var=\"$tmp_libs\"
8600 done # for var
8601 fi
8602 # Last step: remove runtime libs from dependency_libs
8603 # (they stay in deplibs)
8604 tmp_libs=
8605 for i in $dependency_libs; do
8606 case " $predeps $postdeps $compiler_lib_search_path " in
8607 *" $i "*)
8608 i=
8609 ;;
8610 esac
8611 if test -n "$i"; then
8612 func_append tmp_libs " $i"
8613 fi
8614 done
8615 dependency_libs=$tmp_libs
8616 done # for pass
8617 if test prog = "$linkmode"; then
8618 dlfiles=$newdlfiles
8619 fi
8620 if test prog = "$linkmode" || test lib = "$linkmode"; then
8621 dlprefiles=$newdlprefiles
8622 fi
8623
8624 case $linkmode in
8625 oldlib)
8626 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8627 func_warning "'-dlopen' is ignored for archives"
8628 fi
8629
8630 case " $deplibs" in
8631 *\ -l* | *\ -L*)
8632 func_warning "'-l' and '-L' are ignored for archives" ;;
8633 esac
8634
8635 test -n "$rpath" && \
8636 func_warning "'-rpath' is ignored for archives"
8637
8638 test -n "$xrpath" && \
8639 func_warning "'-R' is ignored for archives"
8640
8641 test -n "$vinfo" && \
8642 func_warning "'-version-info/-version-number' is ignored for archives"
8643
8644 test -n "$release" && \
8645 func_warning "'-release' is ignored for archives"
8646
8647 test -n "$export_symbols$export_symbols_regex" && \
8648 func_warning "'-export-symbols' is ignored for archives"
8649
8650 # Now set the variables for building old libraries.
8651 build_libtool_libs=no
8652 oldlibs=$output
8653 func_append objs "$old_deplibs"
8654 ;;
8655
8656 lib)
8657 # Make sure we only generate libraries of the form 'libNAME.la'.
8658 case $outputname in
8659 lib*)
8660 func_stripname 'lib' '.la' "$outputname"
8661 name=$func_stripname_result
8662 eval shared_ext=\"$shrext_cmds\"
8663 eval libname=\"$libname_spec\"
8664 ;;
8665 *)
8666 test no = "$module" \
8667 && func_fatal_help "libtool library '$output' must begin with 'lib'"
8668
8669 if test no != "$need_lib_prefix"; then
8670 # Add the "lib" prefix for modules if required
8671 func_stripname '' '.la' "$outputname"
8672 name=$func_stripname_result
8673 eval shared_ext=\"$shrext_cmds\"
8674 eval libname=\"$libname_spec\"
8675 else
8676 func_stripname '' '.la' "$outputname"
8677 libname=$func_stripname_result
8678 fi
8679 ;;
8680 esac
8681
8682 if test -n "$objs"; then
8683 if test pass_all != "$deplibs_check_method"; then
8684 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8685 else
8686 echo
8687 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8688 $ECHO "*** objects $objs is not portable!"
8689 func_append libobjs " $objs"
8690 fi
8691 fi
8692
8693 test no = "$dlself" \
8694 || func_warning "'-dlopen self' is ignored for libtool libraries"
8695
8696 set dummy $rpath
8697 shift
8698 test 1 -lt "$#" \
8699 && func_warning "ignoring multiple '-rpath's for a libtool library"
8700
8701 install_libdir=$1
8702
8703 oldlibs=
8704 if test -z "$rpath"; then
8705 if test yes = "$build_libtool_libs"; then
8706 # Building a libtool convenience library.
8707 # Some compilers have problems with a '.al' extension so
8708 # convenience libraries should have the same extension an
8709 # archive normally would.
8710 oldlibs="$output_objdir/$libname.$libext $oldlibs"
8711 build_libtool_libs=convenience
8712 build_old_libs=yes
8713 fi
8714
8715 test -n "$vinfo" && \
8716 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8717
8718 test -n "$release" && \
8719 func_warning "'-release' is ignored for convenience libraries"
8720 else
8721
8722 # Parse the version information argument.
8723 save_ifs=$IFS; IFS=:
8724 set dummy $vinfo 0 0 0
8725 shift
8726 IFS=$save_ifs
8727
8728 test -n "$7" && \
8729 func_fatal_help "too many parameters to '-version-info'"
8730
8731 # convert absolute version numbers to libtool ages
8732 # this retains compatibility with .la files and attempts
8733 # to make the code below a bit more comprehensible
8734
8735 case $vinfo_number in
8736 yes)
8737 number_major=$1
8738 number_minor=$2
8739 number_revision=$3
8740 #
8741 # There are really only two kinds -- those that
8742 # use the current revision as the major version
8743 # and those that subtract age and use age as
8744 # a minor version. But, then there is irix
8745 # that has an extra 1 added just for fun
8746 #
8747 case $version_type in
8748 # correct linux to gnu/linux during the next big refactor
8749 darwin|freebsd-elf|linux|osf|windows|none)
8750 func_arith $number_major + $number_minor
8751 current=$func_arith_result
8752 age=$number_minor
8753 revision=$number_revision
8754 ;;
8755 freebsd-aout|qnx|sunos)
8756 current=$number_major
8757 revision=$number_minor
8758 age=0
8759 ;;
8760 irix|nonstopux)
8761 func_arith $number_major + $number_minor
8762 current=$func_arith_result
8763 age=$number_minor
8764 revision=$number_minor
8765 lt_irix_increment=no
8766 ;;
8767 esac
8768 ;;
8769 no)
8770 current=$1
8771 revision=$2
8772 age=$3
8773 ;;
8774 esac
8775
8776 # Check that each of the things are valid numbers.
8777 case $current in
8778 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
8779 *)
8780 func_error "CURRENT '$current' must be a nonnegative integer"
8781 func_fatal_error "'$vinfo' is not valid version information"
8782 ;;
8783 esac
8784
8785 case $revision in
8786 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
8787 *)
8788 func_error "REVISION '$revision' must be a nonnegative integer"
8789 func_fatal_error "'$vinfo' is not valid version information"
8790 ;;
8791 esac
8792
8793 case $age in
8794 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
8795 *)
8796 func_error "AGE '$age' must be a nonnegative integer"
8797 func_fatal_error "'$vinfo' is not valid version information"
8798 ;;
8799 esac
8800
8801 if test "$age" -gt "$current"; then
8802 func_error "AGE '$age' is greater than the current interface number '$current'"
8803 func_fatal_error "'$vinfo' is not valid version information"
8804 fi
8805
8806 # Calculate the version variables.
8807 major=
8808 versuffix=
8809 verstring=
8810 case $version_type in
8811 none) ;;
8812
8813 darwin)
8814 # Like Linux, but with the current version available in
8815 # verstring for coding it into the library header
8816 func_arith $current - $age
8817 major=.$func_arith_result
8818 versuffix=$major.$age.$revision
8819 # Darwin ld doesn't like 0 for these options...
8820 func_arith $current + 1
8821 minor_current=$func_arith_result
8822 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8823 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8824 # On Darwin other compilers
8825 case $CC in
8826 nagfor*)
8827 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8828 ;;
8829 *)
8830 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8831 ;;
8832 esac
8833 ;;
8834
8835 freebsd-aout)
8836 major=.$current
8837 versuffix=.$current.$revision
8838 ;;
8839
8840 freebsd-elf)
8841 func_arith $current - $age
8842 major=.$func_arith_result
8843 versuffix=$major.$age.$revision
8844 ;;
8845
8846 irix | nonstopux)
8847 if test no = "$lt_irix_increment"; then
8848 func_arith $current - $age
8849 else
8850 func_arith $current - $age + 1
8851 fi
8852 major=$func_arith_result
8853
8854 case $version_type in
8855 nonstopux) verstring_prefix=nonstopux ;;
8856 *) verstring_prefix=sgi ;;
8857 esac
8858 verstring=$verstring_prefix$major.$revision
8859
8860 # Add in all the interfaces that we are compatible with.
8861 loop=$revision
8862 while test 0 -ne "$loop"; do
8863 func_arith $revision - $loop
8864 iface=$func_arith_result
8865 func_arith $loop - 1
8866 loop=$func_arith_result
8867 verstring=$verstring_prefix$major.$iface:$verstring
8868 done
8869
8870 # Before this point, $major must not contain '.'.
8871 major=.$major
8872 versuffix=$major.$revision
8873 ;;
8874
8875 linux) # correct to gnu/linux during the next big refactor
8876 func_arith $current - $age
8877 major=.$func_arith_result
8878 versuffix=$major.$age.$revision
8879 ;;
8880
8881 osf)
8882 func_arith $current - $age
8883 major=.$func_arith_result
8884 versuffix=.$current.$age.$revision
8885 verstring=$current.$age.$revision
8886
8887 # Add in all the interfaces that we are compatible with.
8888 loop=$age
8889 while test 0 -ne "$loop"; do
8890 func_arith $current - $loop
8891 iface=$func_arith_result
8892 func_arith $loop - 1
8893 loop=$func_arith_result
8894 verstring=$verstring:$iface.0
8895 done
8896
8897 # Make executables depend on our current version.
8898 func_append verstring ":$current.0"
8899 ;;
8900
8901 qnx)
8902 major=.$current
8903 versuffix=.$current
8904 ;;
8905
8906 sco)
8907 major=.$current
8908 versuffix=.$current
8909 ;;
8910
8911 sunos)
8912 major=.$current
8913 versuffix=.$current.$revision
8914 ;;
8915
8916 windows)
8917 # Use '-' rather than '.', since we only want one
8918 # extension on DOS 8.3 file systems.
8919 func_arith $current - $age
8920 major=$func_arith_result
8921 versuffix=-$major
8922 ;;
8923
8924 *)
8925 func_fatal_configuration "unknown library version type '$version_type'"
8926 ;;
8927 esac
8928
8929 # Clear the version info if we defaulted, and they specified a release.
8930 if test -z "$vinfo" && test -n "$release"; then
8931 major=
8932 case $version_type in
8933 darwin)
8934 # we can't check for "0.0" in archive_cmds due to quoting
8935 # problems, so we reset it completely
8936 verstring=
8937 ;;
8938 *)
8939 verstring=0.0
8940 ;;
8941 esac
8942 if test no = "$need_version"; then
8943 versuffix=
8944 else
8945 versuffix=.0.0
8946 fi
8947 fi
8948
8949 # Remove version info from name if versioning should be avoided
8950 if test yes,no = "$avoid_version,$need_version"; then
8951 major=
8952 versuffix=
8953 verstring=
8954 fi
8955
8956 # Check to see if the archive will have undefined symbols.
8957 if test yes = "$allow_undefined"; then
8958 if test unsupported = "$allow_undefined_flag"; then
8959 if test yes = "$build_old_libs"; then
8960 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
8961 build_libtool_libs=no
8962 else
8963 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
8964 fi
8965 fi
8966 else
8967 # Don't allow undefined symbols.
8968 allow_undefined_flag=$no_undefined_flag
8969 fi
8970
8971 fi
8972
8973 func_generate_dlsyms "$libname" "$libname" :
8974 func_append libobjs " $symfileobj"
8975 test " " = "$libobjs" && libobjs=
8976
8977 if test relink != "$opt_mode"; then
8978 # Remove our outputs, but don't remove object files since they
8979 # may have been created when compiling PIC objects.
8980 removelist=
8981 tempremovelist=`$ECHO "$output_objdir/*"`
8982 for p in $tempremovelist; do
8983 case $p in
8984 *.$objext | *.gcno)
8985 ;;
8986 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
8987 if test -n "$precious_files_regex"; then
8988 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
8989 then
8990 continue
8991 fi
8992 fi
8993 func_append removelist " $p"
8994 ;;
8995 *) ;;
8996 esac
8997 done
8998 test -n "$removelist" && \
8999 func_show_eval "${RM}r \$removelist"
9000 fi
9001
9002 # Now set the variables for building old libraries.
9003 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9004 func_append oldlibs " $output_objdir/$libname.$libext"
9005
9006 # Transform .lo files to .o files.
9007 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9008 fi
9009
9010 # Eliminate all temporary directories.
9011 #for path in $notinst_path; do
9012 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9013 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9014 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9015 #done
9016
9017 if test -n "$xrpath"; then
9018 # If the user specified any rpath flags, then add them.
9019 temp_xrpath=
9020 for libdir in $xrpath; do
9021 func_replace_sysroot "$libdir"
9022 func_append temp_xrpath " -R$func_replace_sysroot_result"
9023 case "$finalize_rpath " in
9024 *" $libdir "*) ;;
9025 *) func_append finalize_rpath " $libdir" ;;
9026 esac
9027 done
9028 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9029 dependency_libs="$temp_xrpath $dependency_libs"
9030 fi
9031 fi
9032
9033 # Make sure dlfiles contains only unique files that won't be dlpreopened
9034 old_dlfiles=$dlfiles
9035 dlfiles=
9036 for lib in $old_dlfiles; do
9037 case " $dlprefiles $dlfiles " in
9038 *" $lib "*) ;;
9039 *) func_append dlfiles " $lib" ;;
9040 esac
9041 done
9042
9043 # Make sure dlprefiles contains only unique files
9044 old_dlprefiles=$dlprefiles
9045 dlprefiles=
9046 for lib in $old_dlprefiles; do
9047 case "$dlprefiles " in
9048 *" $lib "*) ;;
9049 *) func_append dlprefiles " $lib" ;;
9050 esac
9051 done
9052
9053 if test yes = "$build_libtool_libs"; then
9054 if test -n "$rpath"; then
9055 case $host in
9056 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9057 # these systems don't actually have a c library (as such)!
9058 ;;
9059 *-*-rhapsody* | *-*-darwin1.[012])
9060 # Rhapsody C library is in the System framework
9061 func_append deplibs " System.ltframework"
9062 ;;
9063 *-*-netbsd*)
9064 # Don't link with libc until the a.out ld.so is fixed.
9065 ;;
9066 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9067 # Do not include libc due to us having libc/libc_r.
9068 ;;
9069 *-*-sco3.2v5* | *-*-sco5v6*)
9070 # Causes problems with __ctype
9071 ;;
9072 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9073 # Compiler inserts libc in the correct place for threads to work
9074 ;;
9075 *)
9076 # Add libc to deplibs on all other systems if necessary.
9077 if test yes = "$build_libtool_need_lc"; then
9078 func_append deplibs " -lc"
9079 fi
9080 ;;
9081 esac
9082 fi
9083
9084 # Transform deplibs into only deplibs that can be linked in shared.
9085 name_save=$name
9086 libname_save=$libname
9087 release_save=$release
9088 versuffix_save=$versuffix
9089 major_save=$major
9090 # I'm not sure if I'm treating the release correctly. I think
9091 # release should show up in the -l (ie -lgmp5) so we don't want to
9092 # add it in twice. Is that correct?
9093 release=
9094 versuffix=
9095 major=
9096 newdeplibs=
9097 droppeddeps=no
9098 case $deplibs_check_method in
9099 pass_all)
9100 # Don't check for shared/static. Everything works.
9101 # This might be a little naive. We might want to check
9102 # whether the library exists or not. But this is on
9103 # osf3 & osf4 and I'm not really sure... Just
9104 # implementing what was already the behavior.
9105 newdeplibs=$deplibs
9106 ;;
9107 test_compile)
9108 # This code stresses the "libraries are programs" paradigm to its
9109 # limits. Maybe even breaks it. We compile a program, linking it
9110 # against the deplibs as a proxy for the library. Then we can check
9111 # whether they linked in statically or dynamically with ldd.
9112 $opt_dry_run || $RM conftest.c
9113 cat > conftest.c <<EOF
9114 int main() { return 0; }
9115 EOF
9116 $opt_dry_run || $RM conftest
9117 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9118 ldd_output=`ldd conftest`
9119 for i in $deplibs; do
9120 case $i in
9121 -l*)
9122 func_stripname -l '' "$i"
9123 name=$func_stripname_result
9124 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9125 case " $predeps $postdeps " in
9126 *" $i "*)
9127 func_append newdeplibs " $i"
9128 i=
9129 ;;
9130 esac
9131 fi
9132 if test -n "$i"; then
9133 libname=`eval "\\$ECHO \"$libname_spec\""`
9134 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9135 set dummy $deplib_matches; shift
9136 deplib_match=$1
9137 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9138 func_append newdeplibs " $i"
9139 else
9140 droppeddeps=yes
9141 echo
9142 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9143 echo "*** I have the capability to make that library automatically link in when"
9144 echo "*** you link to this library. But I can only do this if you have a"
9145 echo "*** shared version of the library, which I believe you do not have"
9146 echo "*** because a test_compile did reveal that the linker did not use it for"
9147 echo "*** its dynamic dependency list that programs get resolved with at runtime."
9148 fi
9149 fi
9150 ;;
9151 *)
9152 func_append newdeplibs " $i"
9153 ;;
9154 esac
9155 done
9156 else
9157 # Error occurred in the first compile. Let's try to salvage
9158 # the situation: Compile a separate program for each library.
9159 for i in $deplibs; do
9160 case $i in
9161 -l*)
9162 func_stripname -l '' "$i"
9163 name=$func_stripname_result
9164 $opt_dry_run || $RM conftest
9165 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9166 ldd_output=`ldd conftest`
9167 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9168 case " $predeps $postdeps " in
9169 *" $i "*)
9170 func_append newdeplibs " $i"
9171 i=
9172 ;;
9173 esac
9174 fi
9175 if test -n "$i"; then
9176 libname=`eval "\\$ECHO \"$libname_spec\""`
9177 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9178 set dummy $deplib_matches; shift
9179 deplib_match=$1
9180 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9181 func_append newdeplibs " $i"
9182 else
9183 droppeddeps=yes
9184 echo
9185 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9186 echo "*** I have the capability to make that library automatically link in when"
9187 echo "*** you link to this library. But I can only do this if you have a"
9188 echo "*** shared version of the library, which you do not appear to have"
9189 echo "*** because a test_compile did reveal that the linker did not use this one"
9190 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9191 fi
9192 fi
9193 else
9194 droppeddeps=yes
9195 echo
9196 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
9197 echo "*** make it link in! You will probably need to install it or some"
9198 echo "*** library that it depends on before this library will be fully"
9199 echo "*** functional. Installing it before continuing would be even better."
9200 fi
9201 ;;
9202 *)
9203 func_append newdeplibs " $i"
9204 ;;
9205 esac
9206 done
9207 fi
9208 ;;
9209 file_magic*)
9210 set dummy $deplibs_check_method; shift
9211 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9212 for a_deplib in $deplibs; do
9213 case $a_deplib in
9214 -l*)
9215 func_stripname -l '' "$a_deplib"
9216 name=$func_stripname_result
9217 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9218 case " $predeps $postdeps " in
9219 *" $a_deplib "*)
9220 func_append newdeplibs " $a_deplib"
9221 a_deplib=
9222 ;;
9223 esac
9224 fi
9225 if test -n "$a_deplib"; then
9226 libname=`eval "\\$ECHO \"$libname_spec\""`
9227 if test -n "$file_magic_glob"; then
9228 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9229 else
9230 libnameglob=$libname
9231 fi
9232 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9233 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9234 if test yes = "$want_nocaseglob"; then
9235 shopt -s nocaseglob
9236 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9237 $nocaseglob
9238 else
9239 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9240 fi
9241 for potent_lib in $potential_libs; do
9242 # Follow soft links.
9243 if ls -lLd "$potent_lib" 2>/dev/null |
9244 $GREP " -> " >/dev/null; then
9245 continue
9246 fi
9247 # The statement above tries to avoid entering an
9248 # endless loop below, in case of cyclic links.
9249 # We might still enter an endless loop, since a link
9250 # loop can be closed while we follow links,
9251 # but so what?
9252 potlib=$potent_lib
9253 while test -h "$potlib" 2>/dev/null; do
9254 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9255 case $potliblink in
9256 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9257 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9258 esac
9259 done
9260 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9261 $SED -e 10q |
9262 $EGREP "$file_magic_regex" > /dev/null; then
9263 func_append newdeplibs " $a_deplib"
9264 a_deplib=
9265 break 2
9266 fi
9267 done
9268 done
9269 fi
9270 if test -n "$a_deplib"; then
9271 droppeddeps=yes
9272 echo
9273 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9274 echo "*** I have the capability to make that library automatically link in when"
9275 echo "*** you link to this library. But I can only do this if you have a"
9276 echo "*** shared version of the library, which you do not appear to have"
9277 echo "*** because I did check the linker path looking for a file starting"
9278 if test -z "$potlib"; then
9279 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9280 else
9281 $ECHO "*** with $libname and none of the candidates passed a file format test"
9282 $ECHO "*** using a file magic. Last file checked: $potlib"
9283 fi
9284 fi
9285 ;;
9286 *)
9287 # Add a -L argument.
9288 func_append newdeplibs " $a_deplib"
9289 ;;
9290 esac
9291 done # Gone through all deplibs.
9292 ;;
9293 match_pattern*)
9294 set dummy $deplibs_check_method; shift
9295 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9296 for a_deplib in $deplibs; do
9297 case $a_deplib in
9298 -l*)
9299 func_stripname -l '' "$a_deplib"
9300 name=$func_stripname_result
9301 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9302 case " $predeps $postdeps " in
9303 *" $a_deplib "*)
9304 func_append newdeplibs " $a_deplib"
9305 a_deplib=
9306 ;;
9307 esac
9308 fi
9309 if test -n "$a_deplib"; then
9310 libname=`eval "\\$ECHO \"$libname_spec\""`
9311 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9312 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9313 for potent_lib in $potential_libs; do
9314 potlib=$potent_lib # see symlink-check above in file_magic test
9315 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9316 $EGREP "$match_pattern_regex" > /dev/null; then
9317 func_append newdeplibs " $a_deplib"
9318 a_deplib=
9319 break 2
9320 fi
9321 done
9322 done
9323 fi
9324 if test -n "$a_deplib"; then
9325 droppeddeps=yes
9326 echo
9327 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9328 echo "*** I have the capability to make that library automatically link in when"
9329 echo "*** you link to this library. But I can only do this if you have a"
9330 echo "*** shared version of the library, which you do not appear to have"
9331 echo "*** because I did check the linker path looking for a file starting"
9332 if test -z "$potlib"; then
9333 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9334 else
9335 $ECHO "*** with $libname and none of the candidates passed a file format test"
9336 $ECHO "*** using a regex pattern. Last file checked: $potlib"
9337 fi
9338 fi
9339 ;;
9340 *)
9341 # Add a -L argument.
9342 func_append newdeplibs " $a_deplib"
9343 ;;
9344 esac
9345 done # Gone through all deplibs.
9346 ;;
9347 none | unknown | *)
9348 newdeplibs=
9349 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9350 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9351 for i in $predeps $postdeps; do
9352 # can't use Xsed below, because $i might contain '/'
9353 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9354 done
9355 fi
9356 case $tmp_deplibs in
9357 *[!\ \ ]*)
9358 echo
9359 if test none = "$deplibs_check_method"; then
9360 echo "*** Warning: inter-library dependencies are not supported in this platform."
9361 else
9362 echo "*** Warning: inter-library dependencies are not known to be supported."
9363 fi
9364 echo "*** All declared inter-library dependencies are being dropped."
9365 droppeddeps=yes
9366 ;;
9367 esac
9368 ;;
9369 esac
9370 versuffix=$versuffix_save
9371 major=$major_save
9372 release=$release_save
9373 libname=$libname_save
9374 name=$name_save
9375
9376 case $host in
9377 *-*-rhapsody* | *-*-darwin1.[012])
9378 # On Rhapsody replace the C library with the System framework
9379 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9380 ;;
9381 esac
9382
9383 if test yes = "$droppeddeps"; then
9384 if test yes = "$module"; then
9385 echo
9386 echo "*** Warning: libtool could not satisfy all declared inter-library"
9387 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
9388 echo "*** a static module, that should work as long as the dlopening"
9389 echo "*** application is linked with the -dlopen flag."
9390 if test -z "$global_symbol_pipe"; then
9391 echo
9392 echo "*** However, this would only work if libtool was able to extract symbol"
9393 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9394 echo "*** not find such a program. So, this module is probably useless."
9395 echo "*** 'nm' from GNU binutils and a full rebuild may help."
9396 fi
9397 if test no = "$build_old_libs"; then
9398 oldlibs=$output_objdir/$libname.$libext
9399 build_libtool_libs=module
9400 build_old_libs=yes
9401 else
9402 build_libtool_libs=no
9403 fi
9404 else
9405 echo "*** The inter-library dependencies that have been dropped here will be"
9406 echo "*** automatically added whenever a program is linked with this library"
9407 echo "*** or is declared to -dlopen it."
9408
9409 if test no = "$allow_undefined"; then
9410 echo
9411 echo "*** Since this library must not contain undefined symbols,"
9412 echo "*** because either the platform does not support them or"
9413 echo "*** it was explicitly requested with -no-undefined,"
9414 echo "*** libtool will only create a static version of it."
9415 if test no = "$build_old_libs"; then
9416 oldlibs=$output_objdir/$libname.$libext
9417 build_libtool_libs=module
9418 build_old_libs=yes
9419 else
9420 build_libtool_libs=no
9421 fi
9422 fi
9423 fi
9424 fi
9425 # Done checking deplibs!
9426 deplibs=$newdeplibs
9427 fi
9428 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9429 case $host in
9430 *-*-darwin*)
9431 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9432 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9433 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9434 ;;
9435 esac
9436
9437 # move library search paths that coincide with paths to not yet
9438 # installed libraries to the beginning of the library search list
9439 new_libs=
9440 for path in $notinst_path; do
9441 case " $new_libs " in
9442 *" -L$path/$objdir "*) ;;
9443 *)
9444 case " $deplibs " in
9445 *" -L$path/$objdir "*)
9446 func_append new_libs " -L$path/$objdir" ;;
9447 esac
9448 ;;
9449 esac
9450 done
9451 for deplib in $deplibs; do
9452 case $deplib in
9453 -L*)
9454 case " $new_libs " in
9455 *" $deplib "*) ;;
9456 *) func_append new_libs " $deplib" ;;
9457 esac
9458 ;;
9459 *) func_append new_libs " $deplib" ;;
9460 esac
9461 done
9462 deplibs=$new_libs
9463
9464 # All the library-specific variables (install_libdir is set above).
9465 library_names=
9466 old_library=
9467 dlname=
9468
9469 # Test again, we may have decided not to build it any more
9470 if test yes = "$build_libtool_libs"; then
9471 # Remove $wl instances when linking with ld.
9472 # FIXME: should test the right _cmds variable.
9473 case $archive_cmds in
9474 *\$LD\ *) wl= ;;
9475 esac
9476 if test yes = "$hardcode_into_libs"; then
9477 # Hardcode the library paths
9478 hardcode_libdirs=
9479 dep_rpath=
9480 rpath=$finalize_rpath
9481 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9482 for libdir in $rpath; do
9483 if test -n "$hardcode_libdir_flag_spec"; then
9484 if test -n "$hardcode_libdir_separator"; then
9485 func_replace_sysroot "$libdir"
9486 libdir=$func_replace_sysroot_result
9487 if test -z "$hardcode_libdirs"; then
9488 hardcode_libdirs=$libdir
9489 else
9490 # Just accumulate the unique libdirs.
9491 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9492 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9493 ;;
9494 *)
9495 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9496 ;;
9497 esac
9498 fi
9499 else
9500 eval flag=\"$hardcode_libdir_flag_spec\"
9501 func_append dep_rpath " $flag"
9502 fi
9503 elif test -n "$runpath_var"; then
9504 case "$perm_rpath " in
9505 *" $libdir "*) ;;
9506 *) func_append perm_rpath " $libdir" ;;
9507 esac
9508 fi
9509 done
9510 # Substitute the hardcoded libdirs into the rpath.
9511 if test -n "$hardcode_libdir_separator" &&
9512 test -n "$hardcode_libdirs"; then
9513 libdir=$hardcode_libdirs
9514 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9515 fi
9516 if test -n "$runpath_var" && test -n "$perm_rpath"; then
9517 # We should set the runpath_var.
9518 rpath=
9519 for dir in $perm_rpath; do
9520 func_append rpath "$dir:"
9521 done
9522 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9523 fi
9524 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9525 fi
9526
9527 shlibpath=$finalize_shlibpath
9528 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9529 if test -n "$shlibpath"; then
9530 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9531 fi
9532
9533 # Get the real and link names of the library.
9534 eval shared_ext=\"$shrext_cmds\"
9535 eval library_names=\"$library_names_spec\"
9536 set dummy $library_names
9537 shift
9538 realname=$1
9539 shift
9540
9541 if test -n "$soname_spec"; then
9542 eval soname=\"$soname_spec\"
9543 else
9544 soname=$realname
9545 fi
9546 if test -z "$dlname"; then
9547 dlname=$soname
9548 fi
9549
9550 lib=$output_objdir/$realname
9551 linknames=
9552 for link
9553 do
9554 func_append linknames " $link"
9555 done
9556
9557 # Use standard objects if they are pic
9558 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9559 test "X$libobjs" = "X " && libobjs=
9560
9561 delfiles=
9562 if test -n "$export_symbols" && test -n "$include_expsyms"; then
9563 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9564 export_symbols=$output_objdir/$libname.uexp
9565 func_append delfiles " $export_symbols"
9566 fi
9567
9568 orig_export_symbols=
9569 case $host_os in
9570 cygwin* | mingw* | cegcc*)
9571 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9572 # exporting using user supplied symfile
9573 func_dll_def_p "$export_symbols" || {
9574 # and it's NOT already a .def file. Must figure out
9575 # which of the given symbols are data symbols and tag
9576 # them as such. So, trigger use of export_symbols_cmds.
9577 # export_symbols gets reassigned inside the "prepare
9578 # the list of exported symbols" if statement, so the
9579 # include_expsyms logic still works.
9580 orig_export_symbols=$export_symbols
9581 export_symbols=
9582 always_export_symbols=yes
9583 }
9584 fi
9585 ;;
9586 esac
9587
9588 # Prepare the list of exported symbols
9589 if test -z "$export_symbols"; then
9590 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9591 func_verbose "generating symbol list for '$libname.la'"
9592 export_symbols=$output_objdir/$libname.exp
9593 $opt_dry_run || $RM $export_symbols
9594 cmds=$export_symbols_cmds
9595 save_ifs=$IFS; IFS='~'
9596 for cmd1 in $cmds; do
9597 IFS=$save_ifs
9598 # Take the normal branch if the nm_file_list_spec branch
9599 # doesn't work or if tool conversion is not needed.
9600 case $nm_file_list_spec~$to_tool_file_cmd in
9601 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9602 try_normal_branch=yes
9603 eval cmd=\"$cmd1\"
9604 func_len " $cmd"
9605 len=$func_len_result
9606 ;;
9607 *)
9608 try_normal_branch=no
9609 ;;
9610 esac
9611 if test yes = "$try_normal_branch" \
9612 && { test "$len" -lt "$max_cmd_len" \
9613 || test "$max_cmd_len" -le -1; }
9614 then
9615 func_show_eval "$cmd" 'exit $?'
9616 skipped_export=false
9617 elif test -n "$nm_file_list_spec"; then
9618 func_basename "$output"
9619 output_la=$func_basename_result
9620 save_libobjs=$libobjs
9621 save_output=$output
9622 output=$output_objdir/$output_la.nm
9623 func_to_tool_file "$output"
9624 libobjs=$nm_file_list_spec$func_to_tool_file_result
9625 func_append delfiles " $output"
9626 func_verbose "creating $NM input file list: $output"
9627 for obj in $save_libobjs; do
9628 func_to_tool_file "$obj"
9629 $ECHO "$func_to_tool_file_result"
9630 done > "$output"
9631 eval cmd=\"$cmd1\"
9632 func_show_eval "$cmd" 'exit $?'
9633 output=$save_output
9634 libobjs=$save_libobjs
9635 skipped_export=false
9636 else
9637 # The command line is too long to execute in one step.
9638 func_verbose "using reloadable object file for export list..."
9639 skipped_export=:
9640 # Break out early, otherwise skipped_export may be
9641 # set to false by a later but shorter cmd.
9642 break
9643 fi
9644 done
9645 IFS=$save_ifs
9646 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9647 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9648 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9649 fi
9650 fi
9651 fi
9652
9653 if test -n "$export_symbols" && test -n "$include_expsyms"; then
9654 tmp_export_symbols=$export_symbols
9655 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9656 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9657 fi
9658
9659 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9660 # The given exports_symbols file has to be filtered, so filter it.
9661 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9662 # FIXME: $output_objdir/$libname.filter potentially contains lots of
9663 # 's' commands, which not all seds can handle. GNU sed should be fine
9664 # though. Also, the filter scales superlinearly with the number of
9665 # global variables. join(1) would be nice here, but unfortunately
9666 # isn't a blessed tool.
9667 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9668 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9669 export_symbols=$output_objdir/$libname.def
9670 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9671 fi
9672
9673 tmp_deplibs=
9674 for test_deplib in $deplibs; do
9675 case " $convenience " in
9676 *" $test_deplib "*) ;;
9677 *)
9678 func_append tmp_deplibs " $test_deplib"
9679 ;;
9680 esac
9681 done
9682 deplibs=$tmp_deplibs
9683
9684 if test -n "$convenience"; then
9685 if test -n "$whole_archive_flag_spec" &&
9686 test yes = "$compiler_needs_object" &&
9687 test -z "$libobjs"; then
9688 # extract the archives, so we have objects to list.
9689 # TODO: could optimize this to just extract one archive.
9690 whole_archive_flag_spec=
9691 fi
9692 if test -n "$whole_archive_flag_spec"; then
9693 save_libobjs=$libobjs
9694 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9695 test "X$libobjs" = "X " && libobjs=
9696 else
9697 gentop=$output_objdir/${outputname}x
9698 func_append generated " $gentop"
9699
9700 func_extract_archives $gentop $convenience
9701 func_append libobjs " $func_extract_archives_result"
9702 test "X$libobjs" = "X " && libobjs=
9703 fi
9704 fi
9705
9706 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9707 eval flag=\"$thread_safe_flag_spec\"
9708 func_append linker_flags " $flag"
9709 fi
9710
9711 # Make a backup of the uninstalled library when relinking
9712 if test relink = "$opt_mode"; then
9713 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9714 fi
9715
9716 # Do each of the archive commands.
9717 if test yes = "$module" && test -n "$module_cmds"; then
9718 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9719 eval test_cmds=\"$module_expsym_cmds\"
9720 cmds=$module_expsym_cmds
9721 else
9722 eval test_cmds=\"$module_cmds\"
9723 cmds=$module_cmds
9724 fi
9725 else
9726 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9727 eval test_cmds=\"$archive_expsym_cmds\"
9728 cmds=$archive_expsym_cmds
9729 else
9730 eval test_cmds=\"$archive_cmds\"
9731 cmds=$archive_cmds
9732 fi
9733 fi
9734
9735 if test : != "$skipped_export" &&
9736 func_len " $test_cmds" &&
9737 len=$func_len_result &&
9738 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9739 :
9740 else
9741 # The command line is too long to link in one step, link piecewise
9742 # or, if using GNU ld and skipped_export is not :, use a linker
9743 # script.
9744
9745 # Save the value of $output and $libobjs because we want to
9746 # use them later. If we have whole_archive_flag_spec, we
9747 # want to use save_libobjs as it was before
9748 # whole_archive_flag_spec was expanded, because we can't
9749 # assume the linker understands whole_archive_flag_spec.
9750 # This may have to be revisited, in case too many
9751 # convenience libraries get linked in and end up exceeding
9752 # the spec.
9753 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9754 save_libobjs=$libobjs
9755 fi
9756 save_output=$output
9757 func_basename "$output"
9758 output_la=$func_basename_result
9759
9760 # Clear the reloadable object creation command queue and
9761 # initialize k to one.
9762 test_cmds=
9763 concat_cmds=
9764 objlist=
9765 last_robj=
9766 k=1
9767
9768 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9769 output=$output_objdir/$output_la.lnkscript
9770 func_verbose "creating GNU ld script: $output"
9771 echo 'INPUT (' > $output
9772 for obj in $save_libobjs
9773 do
9774 func_to_tool_file "$obj"
9775 $ECHO "$func_to_tool_file_result" >> $output
9776 done
9777 echo ')' >> $output
9778 func_append delfiles " $output"
9779 func_to_tool_file "$output"
9780 output=$func_to_tool_file_result
9781 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9782 output=$output_objdir/$output_la.lnk
9783 func_verbose "creating linker input file list: $output"
9784 : > $output
9785 set x $save_libobjs
9786 shift
9787 firstobj=
9788 if test yes = "$compiler_needs_object"; then
9789 firstobj="$1 "
9790 shift
9791 fi
9792 for obj
9793 do
9794 func_to_tool_file "$obj"
9795 $ECHO "$func_to_tool_file_result" >> $output
9796 done
9797 func_append delfiles " $output"
9798 func_to_tool_file "$output"
9799 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9800 else
9801 if test -n "$save_libobjs"; then
9802 func_verbose "creating reloadable object files..."
9803 output=$output_objdir/$output_la-$k.$objext
9804 eval test_cmds=\"$reload_cmds\"
9805 func_len " $test_cmds"
9806 len0=$func_len_result
9807 len=$len0
9808
9809 # Loop over the list of objects to be linked.
9810 for obj in $save_libobjs
9811 do
9812 func_len " $obj"
9813 func_arith $len + $func_len_result
9814 len=$func_arith_result
9815 if test -z "$objlist" ||
9816 test "$len" -lt "$max_cmd_len"; then
9817 func_append objlist " $obj"
9818 else
9819 # The command $test_cmds is almost too long, add a
9820 # command to the queue.
9821 if test 1 -eq "$k"; then
9822 # The first file doesn't have a previous command to add.
9823 reload_objs=$objlist
9824 eval concat_cmds=\"$reload_cmds\"
9825 else
9826 # All subsequent reloadable object files will link in
9827 # the last one created.
9828 reload_objs="$objlist $last_robj"
9829 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9830 fi
9831 last_robj=$output_objdir/$output_la-$k.$objext
9832 func_arith $k + 1
9833 k=$func_arith_result
9834 output=$output_objdir/$output_la-$k.$objext
9835 objlist=" $obj"
9836 func_len " $last_robj"
9837 func_arith $len0 + $func_len_result
9838 len=$func_arith_result
9839 fi
9840 done
9841 # Handle the remaining objects by creating one last
9842 # reloadable object file. All subsequent reloadable object
9843 # files will link in the last one created.
9844 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9845 reload_objs="$objlist $last_robj"
9846 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9847 if test -n "$last_robj"; then
9848 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9849 fi
9850 func_append delfiles " $output"
9851
9852 else
9853 output=
9854 fi
9855
9856 ${skipped_export-false} && {
9857 func_verbose "generating symbol list for '$libname.la'"
9858 export_symbols=$output_objdir/$libname.exp
9859 $opt_dry_run || $RM $export_symbols
9860 libobjs=$output
9861 # Append the command to create the export file.
9862 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9863 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9864 if test -n "$last_robj"; then
9865 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9866 fi
9867 }
9868
9869 test -n "$save_libobjs" &&
9870 func_verbose "creating a temporary reloadable object file: $output"
9871
9872 # Loop through the commands generated above and execute them.
9873 save_ifs=$IFS; IFS='~'
9874 for cmd in $concat_cmds; do
9875 IFS=$save_ifs
9876 $opt_quiet || {
9877 func_quote_for_expand "$cmd"
9878 eval "func_echo $func_quote_for_expand_result"
9879 }
9880 $opt_dry_run || eval "$cmd" || {
9881 lt_exit=$?
9882
9883 # Restore the uninstalled library and exit
9884 if test relink = "$opt_mode"; then
9885 ( cd "$output_objdir" && \
9886 $RM "${realname}T" && \
9887 $MV "${realname}U" "$realname" )
9888 fi
9889
9890 exit $lt_exit
9891 }
9892 done
9893 IFS=$save_ifs
9894
9895 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9896 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9897 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9898 fi
9899 fi
9900
9901 ${skipped_export-false} && {
9902 if test -n "$export_symbols" && test -n "$include_expsyms"; then
9903 tmp_export_symbols=$export_symbols
9904 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9905 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9906 fi
9907
9908 if test -n "$orig_export_symbols"; then
9909 # The given exports_symbols file has to be filtered, so filter it.
9910 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9911 # FIXME: $output_objdir/$libname.filter potentially contains lots of
9912 # 's' commands, which not all seds can handle. GNU sed should be fine
9913 # though. Also, the filter scales superlinearly with the number of
9914 # global variables. join(1) would be nice here, but unfortunately
9915 # isn't a blessed tool.
9916 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9917 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9918 export_symbols=$output_objdir/$libname.def
9919 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9920 fi
9921 }
9922
9923 libobjs=$output
9924 # Restore the value of output.
9925 output=$save_output
9926
9927 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9928 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9929 test "X$libobjs" = "X " && libobjs=
9930 fi
9931 # Expand the library linking commands again to reset the
9932 # value of $libobjs for piecewise linking.
9933
9934 # Do each of the archive commands.
9935 if test yes = "$module" && test -n "$module_cmds"; then
9936 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9937 cmds=$module_expsym_cmds
9938 else
9939 cmds=$module_cmds
9940 fi
9941 else
9942 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9943 cmds=$archive_expsym_cmds
9944 else
9945 cmds=$archive_cmds
9946 fi
9947 fi
9948 fi
9949
9950 if test -n "$delfiles"; then
9951 # Append the command to remove temporary files to $cmds.
9952 eval cmds=\"\$cmds~\$RM $delfiles\"
9953 fi
9954
9955 # Add any objects from preloaded convenience libraries
9956 if test -n "$dlprefiles"; then
9957 gentop=$output_objdir/${outputname}x
9958 func_append generated " $gentop"
9959
9960 func_extract_archives $gentop $dlprefiles
9961 func_append libobjs " $func_extract_archives_result"
9962 test "X$libobjs" = "X " && libobjs=
9963 fi
9964
9965 save_ifs=$IFS; IFS='~'
9966 for cmd in $cmds; do
9967 IFS=$sp$nl
9968 eval cmd=\"$cmd\"
9969 IFS=$save_ifs
9970 $opt_quiet || {
9971 func_quote_for_expand "$cmd"
9972 eval "func_echo $func_quote_for_expand_result"
9973 }
9974 $opt_dry_run || eval "$cmd" || {
9975 lt_exit=$?
9976
9977 # Restore the uninstalled library and exit
9978 if test relink = "$opt_mode"; then
9979 ( cd "$output_objdir" && \
9980 $RM "${realname}T" && \
9981 $MV "${realname}U" "$realname" )
9982 fi
9983
9984 exit $lt_exit
9985 }
9986 done
9987 IFS=$save_ifs
9988
9989 # Restore the uninstalled library and exit
9990 if test relink = "$opt_mode"; then
9991 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
9992
9993 if test -n "$convenience"; then
9994 if test -z "$whole_archive_flag_spec"; then
9995 func_show_eval '${RM}r "$gentop"'
9996 fi
9997 fi
9998
9999 exit $EXIT_SUCCESS
10000 fi
10001
10002 # Create links to the real library.
10003 for linkname in $linknames; do
10004 if test "$realname" != "$linkname"; then
10005 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10006 fi
10007 done
10008
10009 # If -module or -export-dynamic was specified, set the dlname.
10010 if test yes = "$module" || test yes = "$export_dynamic"; then
10011 # On all known operating systems, these are identical.
10012 dlname=$soname
10013 fi
10014 fi
10015 ;;
10016
10017 obj)
10018 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10019 func_warning "'-dlopen' is ignored for objects"
10020 fi
10021
10022 case " $deplibs" in
10023 *\ -l* | *\ -L*)
10024 func_warning "'-l' and '-L' are ignored for objects" ;;
10025 esac
10026
10027 test -n "$rpath" && \
10028 func_warning "'-rpath' is ignored for objects"
10029
10030 test -n "$xrpath" && \
10031 func_warning "'-R' is ignored for objects"
10032
10033 test -n "$vinfo" && \
10034 func_warning "'-version-info' is ignored for objects"
10035
10036 test -n "$release" && \
10037 func_warning "'-release' is ignored for objects"
10038
10039 case $output in
10040 *.lo)
10041 test -n "$objs$old_deplibs" && \
10042 func_fatal_error "cannot build library object '$output' from non-libtool objects"
10043
10044 libobj=$output
10045 func_lo2o "$libobj"
10046 obj=$func_lo2o_result
10047 ;;
10048 *)
10049 libobj=
10050 obj=$output
10051 ;;
10052 esac
10053
10054 # Delete the old objects.
10055 $opt_dry_run || $RM $obj $libobj
10056
10057 # Objects from convenience libraries. This assumes
10058 # single-version convenience libraries. Whenever we create
10059 # different ones for PIC/non-PIC, this we'll have to duplicate
10060 # the extraction.
10061 reload_conv_objs=
10062 gentop=
10063 # if reload_cmds runs $LD directly, get rid of -Wl from
10064 # whole_archive_flag_spec and hope we can get by with turning comma
10065 # into space.
10066 case $reload_cmds in
10067 *\$LD[\ \$]*) wl= ;;
10068 esac
10069 if test -n "$convenience"; then
10070 if test -n "$whole_archive_flag_spec"; then
10071 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10072 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10073 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10074 else
10075 gentop=$output_objdir/${obj}x
10076 func_append generated " $gentop"
10077
10078 func_extract_archives $gentop $convenience
10079 reload_conv_objs="$reload_objs $func_extract_archives_result"
10080 fi
10081 fi
10082
10083 # If we're not building shared, we need to use non_pic_objs
10084 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10085
10086 # Create the old-style object.
10087 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10088
10089 output=$obj
10090 func_execute_cmds "$reload_cmds" 'exit $?'
10091
10092 # Exit if we aren't doing a library object file.
10093 if test -z "$libobj"; then
10094 if test -n "$gentop"; then
10095 func_show_eval '${RM}r "$gentop"'
10096 fi
10097
10098 exit $EXIT_SUCCESS
10099 fi
10100
10101 test yes = "$build_libtool_libs" || {
10102 if test -n "$gentop"; then
10103 func_show_eval '${RM}r "$gentop"'
10104 fi
10105
10106 # Create an invalid libtool object if no PIC, so that we don't
10107 # accidentally link it into a program.
10108 # $show "echo timestamp > $libobj"
10109 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10110 exit $EXIT_SUCCESS
10111 }
10112
10113 if test -n "$pic_flag" || test default != "$pic_mode"; then
10114 # Only do commands if we really have different PIC objects.
10115 reload_objs="$libobjs $reload_conv_objs"
10116 output=$libobj
10117 func_execute_cmds "$reload_cmds" 'exit $?'
10118 fi
10119
10120 if test -n "$gentop"; then
10121 func_show_eval '${RM}r "$gentop"'
10122 fi
10123
10124 exit $EXIT_SUCCESS
10125 ;;
10126
10127 prog)
10128 case $host in
10129 *cygwin*) func_stripname '' '.exe' "$output"
10130 output=$func_stripname_result.exe;;
10131 esac
10132 test -n "$vinfo" && \
10133 func_warning "'-version-info' is ignored for programs"
10134
10135 test -n "$release" && \
10136 func_warning "'-release' is ignored for programs"
10137
10138 $preload \
10139 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10140 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10141
10142 case $host in
10143 *-*-rhapsody* | *-*-darwin1.[012])
10144 # On Rhapsody replace the C library is the System framework
10145 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10146 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10147 ;;
10148 esac
10149
10150 case $host in
10151 *-*-darwin*)
10152 # Don't allow lazy linking, it breaks C++ global constructors
10153 # But is supposedly fixed on 10.4 or later (yay!).
10154 if test CXX = "$tagname"; then
10155 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10156 10.[0123])
10157 func_append compile_command " $wl-bind_at_load"
10158 func_append finalize_command " $wl-bind_at_load"
10159 ;;
10160 esac
10161 fi
10162 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
10163 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10164 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10165 ;;
10166 esac
10167
10168
10169 # move library search paths that coincide with paths to not yet
10170 # installed libraries to the beginning of the library search list
10171 new_libs=
10172 for path in $notinst_path; do
10173 case " $new_libs " in
10174 *" -L$path/$objdir "*) ;;
10175 *)
10176 case " $compile_deplibs " in
10177 *" -L$path/$objdir "*)
10178 func_append new_libs " -L$path/$objdir" ;;
10179 esac
10180 ;;
10181 esac
10182 done
10183 for deplib in $compile_deplibs; do
10184 case $deplib in
10185 -L*)
10186 case " $new_libs " in
10187 *" $deplib "*) ;;
10188 *) func_append new_libs " $deplib" ;;
10189 esac
10190 ;;
10191 *) func_append new_libs " $deplib" ;;
10192 esac
10193 done
10194 compile_deplibs=$new_libs
10195
10196
10197 func_append compile_command " $compile_deplibs"
10198 func_append finalize_command " $finalize_deplibs"
10199
10200 if test -n "$rpath$xrpath"; then
10201 # If the user specified any rpath flags, then add them.
10202 for libdir in $rpath $xrpath; do
10203 # This is the magic to use -rpath.
10204 case "$finalize_rpath " in
10205 *" $libdir "*) ;;
10206 *) func_append finalize_rpath " $libdir" ;;
10207 esac
10208 done
10209 fi
10210
10211 # Now hardcode the library paths
10212 rpath=
10213 hardcode_libdirs=
10214 for libdir in $compile_rpath $finalize_rpath; do
10215 if test -n "$hardcode_libdir_flag_spec"; then
10216 if test -n "$hardcode_libdir_separator"; then
10217 if test -z "$hardcode_libdirs"; then
10218 hardcode_libdirs=$libdir
10219 else
10220 # Just accumulate the unique libdirs.
10221 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10222 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10223 ;;
10224 *)
10225 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10226 ;;
10227 esac
10228 fi
10229 else
10230 eval flag=\"$hardcode_libdir_flag_spec\"
10231 func_append rpath " $flag"
10232 fi
10233 elif test -n "$runpath_var"; then
10234 case "$perm_rpath " in
10235 *" $libdir "*) ;;
10236 *) func_append perm_rpath " $libdir" ;;
10237 esac
10238 fi
10239 case $host in
10240 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10241 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10242 case :$dllsearchpath: in
10243 *":$libdir:"*) ;;
10244 ::) dllsearchpath=$libdir;;
10245 *) func_append dllsearchpath ":$libdir";;
10246 esac
10247 case :$dllsearchpath: in
10248 *":$testbindir:"*) ;;
10249 ::) dllsearchpath=$testbindir;;
10250 *) func_append dllsearchpath ":$testbindir";;
10251 esac
10252 ;;
10253 esac
10254 done
10255 # Substitute the hardcoded libdirs into the rpath.
10256 if test -n "$hardcode_libdir_separator" &&
10257 test -n "$hardcode_libdirs"; then
10258 libdir=$hardcode_libdirs
10259 eval rpath=\" $hardcode_libdir_flag_spec\"
10260 fi
10261 compile_rpath=$rpath
10262
10263 rpath=
10264 hardcode_libdirs=
10265 for libdir in $finalize_rpath; do
10266 if test -n "$hardcode_libdir_flag_spec"; then
10267 if test -n "$hardcode_libdir_separator"; then
10268 if test -z "$hardcode_libdirs"; then
10269 hardcode_libdirs=$libdir
10270 else
10271 # Just accumulate the unique libdirs.
10272 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10273 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10274 ;;
10275 *)
10276 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10277 ;;
10278 esac
10279 fi
10280 else
10281 eval flag=\"$hardcode_libdir_flag_spec\"
10282 func_append rpath " $flag"
10283 fi
10284 elif test -n "$runpath_var"; then
10285 case "$finalize_perm_rpath " in
10286 *" $libdir "*) ;;
10287 *) func_append finalize_perm_rpath " $libdir" ;;
10288 esac
10289 fi
10290 done
10291 # Substitute the hardcoded libdirs into the rpath.
10292 if test -n "$hardcode_libdir_separator" &&
10293 test -n "$hardcode_libdirs"; then
10294 libdir=$hardcode_libdirs
10295 eval rpath=\" $hardcode_libdir_flag_spec\"
10296 fi
10297 finalize_rpath=$rpath
10298
10299 if test -n "$libobjs" && test yes = "$build_old_libs"; then
10300 # Transform all the library objects into standard objects.
10301 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10302 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10303 fi
10304
10305 func_generate_dlsyms "$outputname" "@PROGRAM@" false
10306
10307 # template prelinking step
10308 if test -n "$prelink_cmds"; then
10309 func_execute_cmds "$prelink_cmds" 'exit $?'
10310 fi
10311
10312 wrappers_required=:
10313 case $host in
10314 *cegcc* | *mingw32ce*)
10315 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10316 wrappers_required=false
10317 ;;
10318 *cygwin* | *mingw* )
10319 test yes = "$build_libtool_libs" || wrappers_required=false
10320 ;;
10321 *)
10322 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10323 wrappers_required=false
10324 fi
10325 ;;
10326 esac
10327 $wrappers_required || {
10328 # Replace the output file specification.
10329 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10330 link_command=$compile_command$compile_rpath
10331
10332 # We have no uninstalled library dependencies, so finalize right now.
10333 exit_status=0
10334 func_show_eval "$link_command" 'exit_status=$?'
10335
10336 if test -n "$postlink_cmds"; then
10337 func_to_tool_file "$output"
10338 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10339 func_execute_cmds "$postlink_cmds" 'exit $?'
10340 fi
10341
10342 # Delete the generated files.
10343 if test -f "$output_objdir/${outputname}S.$objext"; then
10344 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10345 fi
10346
10347 exit $exit_status
10348 }
10349
10350 if test -n "$compile_shlibpath$finalize_shlibpath"; then
10351 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10352 fi
10353 if test -n "$finalize_shlibpath"; then
10354 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10355 fi
10356
10357 compile_var=
10358 finalize_var=
10359 if test -n "$runpath_var"; then
10360 if test -n "$perm_rpath"; then
10361 # We should set the runpath_var.
10362 rpath=
10363 for dir in $perm_rpath; do
10364 func_append rpath "$dir:"
10365 done
10366 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10367 fi
10368 if test -n "$finalize_perm_rpath"; then
10369 # We should set the runpath_var.
10370 rpath=
10371 for dir in $finalize_perm_rpath; do
10372 func_append rpath "$dir:"
10373 done
10374 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10375 fi
10376 fi
10377
10378 if test yes = "$no_install"; then
10379 # We don't need to create a wrapper script.
10380 link_command=$compile_var$compile_command$compile_rpath
10381 # Replace the output file specification.
10382 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10383 # Delete the old output file.
10384 $opt_dry_run || $RM $output
10385 # Link the executable and exit
10386 func_show_eval "$link_command" 'exit $?'
10387
10388 if test -n "$postlink_cmds"; then
10389 func_to_tool_file "$output"
10390 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10391 func_execute_cmds "$postlink_cmds" 'exit $?'
10392 fi
10393
10394 exit $EXIT_SUCCESS
10395 fi
10396
10397 case $hardcode_action,$fast_install in
10398 relink,*)
10399 # Fast installation is not supported
10400 link_command=$compile_var$compile_command$compile_rpath
10401 relink_command=$finalize_var$finalize_command$finalize_rpath
10402
10403 func_warning "this platform does not like uninstalled shared libraries"
10404 func_warning "'$output' will be relinked during installation"
10405 ;;
10406 *,yes)
10407 link_command=$finalize_var$compile_command$finalize_rpath
10408 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10409 ;;
10410 *,no)
10411 link_command=$compile_var$compile_command$compile_rpath
10412 relink_command=$finalize_var$finalize_command$finalize_rpath
10413 ;;
10414 *,needless)
10415 link_command=$finalize_var$compile_command$finalize_rpath
10416 relink_command=
10417 ;;
10418 esac
10419
10420 # Replace the output file specification.
10421 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10422
10423 # Delete the old output files.
10424 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10425
10426 func_show_eval "$link_command" 'exit $?'
10427
10428 if test -n "$postlink_cmds"; then
10429 func_to_tool_file "$output_objdir/$outputname"
10430 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10431 func_execute_cmds "$postlink_cmds" 'exit $?'
10432 fi
10433
10434 # Now create the wrapper script.
10435 func_verbose "creating $output"
10436
10437 # Quote the relink command for shipping.
10438 if test -n "$relink_command"; then
10439 # Preserve any variables that may affect compiler behavior
10440 for var in $variables_saved_for_relink; do
10441 if eval test -z \"\${$var+set}\"; then
10442 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10443 elif eval var_value=\$$var; test -z "$var_value"; then
10444 relink_command="$var=; export $var; $relink_command"
10445 else
10446 func_quote_for_eval "$var_value"
10447 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10448 fi
10449 done
10450 relink_command="(cd `pwd`; $relink_command)"
10451 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10452 fi
10453
10454 # Only actually do things if not in dry run mode.
10455 $opt_dry_run || {
10456 # win32 will think the script is a binary if it has
10457 # a .exe suffix, so we strip it off here.
10458 case $output in
10459 *.exe) func_stripname '' '.exe' "$output"
10460 output=$func_stripname_result ;;
10461 esac
10462 # test for cygwin because mv fails w/o .exe extensions
10463 case $host in
10464 *cygwin*)
10465 exeext=.exe
10466 func_stripname '' '.exe' "$outputname"
10467 outputname=$func_stripname_result ;;
10468 *) exeext= ;;
10469 esac
10470 case $host in
10471 *cygwin* | *mingw* )
10472 func_dirname_and_basename "$output" "" "."
10473 output_name=$func_basename_result
10474 output_path=$func_dirname_result
10475 cwrappersource=$output_path/$objdir/lt-$output_name.c
10476 cwrapper=$output_path/$output_name.exe
10477 $RM $cwrappersource $cwrapper
10478 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10479
10480 func_emit_cwrapperexe_src > $cwrappersource
10481
10482 # The wrapper executable is built using the $host compiler,
10483 # because it contains $host paths and files. If cross-
10484 # compiling, it, like the target executable, must be
10485 # executed on the $host or under an emulation environment.
10486 $opt_dry_run || {
10487 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10488 $STRIP $cwrapper
10489 }
10490
10491 # Now, create the wrapper script for func_source use:
10492 func_ltwrapper_scriptname $cwrapper
10493 $RM $func_ltwrapper_scriptname_result
10494 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10495 $opt_dry_run || {
10496 # note: this script will not be executed, so do not chmod.
10497 if test "x$build" = "x$host"; then
10498 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10499 else
10500 func_emit_wrapper no > $func_ltwrapper_scriptname_result
10501 fi
10502 }
10503 ;;
10504 * )
10505 $RM $output
10506 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10507
10508 func_emit_wrapper no > $output
10509 chmod +x $output
10510 ;;
10511 esac
10512 }
10513 exit $EXIT_SUCCESS
10514 ;;
10515 esac
10516
10517 # See if we need to build an old-fashioned archive.
10518 for oldlib in $oldlibs; do
10519
10520 case $build_libtool_libs in
10521 convenience)
10522 oldobjs="$libobjs_save $symfileobj"
10523 addlibs=$convenience
10524 build_libtool_libs=no
10525 ;;
10526 module)
10527 oldobjs=$libobjs_save
10528 addlibs=$old_convenience
10529 build_libtool_libs=no
10530 ;;
10531 *)
10532 oldobjs="$old_deplibs $non_pic_objects"
10533 $preload && test -f "$symfileobj" \
10534 && func_append oldobjs " $symfileobj"
10535 addlibs=$old_convenience
10536 ;;
10537 esac
10538
10539 if test -n "$addlibs"; then
10540 gentop=$output_objdir/${outputname}x
10541 func_append generated " $gentop"
10542
10543 func_extract_archives $gentop $addlibs
10544 func_append oldobjs " $func_extract_archives_result"
10545 fi
10546
10547 # Do each command in the archive commands.
10548 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10549 cmds=$old_archive_from_new_cmds
10550 else
10551
10552 # Add any objects from preloaded convenience libraries
10553 if test -n "$dlprefiles"; then
10554 gentop=$output_objdir/${outputname}x
10555 func_append generated " $gentop"
10556
10557 func_extract_archives $gentop $dlprefiles
10558 func_append oldobjs " $func_extract_archives_result"
10559 fi
10560
10561 # POSIX demands no paths to be encoded in archives. We have
10562 # to avoid creating archives with duplicate basenames if we
10563 # might have to extract them afterwards, e.g., when creating a
10564 # static archive out of a convenience library, or when linking
10565 # the entirety of a libtool archive into another (currently
10566 # not supported by libtool).
10567 if (for obj in $oldobjs
10568 do
10569 func_basename "$obj"
10570 $ECHO "$func_basename_result"
10571 done | sort | sort -uc >/dev/null 2>&1); then
10572 :
10573 else
10574 echo "copying selected object files to avoid basename conflicts..."
10575 gentop=$output_objdir/${outputname}x
10576 func_append generated " $gentop"
10577 func_mkdir_p "$gentop"
10578 save_oldobjs=$oldobjs
10579 oldobjs=
10580 counter=1
10581 for obj in $save_oldobjs
10582 do
10583 func_basename "$obj"
10584 objbase=$func_basename_result
10585 case " $oldobjs " in
10586 " ") oldobjs=$obj ;;
10587 *[\ /]"$objbase "*)
10588 while :; do
10589 # Make sure we don't pick an alternate name that also
10590 # overlaps.
10591 newobj=lt$counter-$objbase
10592 func_arith $counter + 1
10593 counter=$func_arith_result
10594 case " $oldobjs " in
10595 *[\ /]"$newobj "*) ;;
10596 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
10597 esac
10598 done
10599 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10600 func_append oldobjs " $gentop/$newobj"
10601 ;;
10602 *) func_append oldobjs " $obj" ;;
10603 esac
10604 done
10605 fi
10606 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10607 tool_oldlib=$func_to_tool_file_result
10608 eval cmds=\"$old_archive_cmds\"
10609
10610 func_len " $cmds"
10611 len=$func_len_result
10612 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10613 cmds=$old_archive_cmds
10614 elif test -n "$archiver_list_spec"; then
10615 func_verbose "using command file archive linking..."
10616 for obj in $oldobjs
10617 do
10618 func_to_tool_file "$obj"
10619 $ECHO "$func_to_tool_file_result"
10620 done > $output_objdir/$libname.libcmd
10621 func_to_tool_file "$output_objdir/$libname.libcmd"
10622 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10623 cmds=$old_archive_cmds
10624 else
10625 # the command line is too long to link in one step, link in parts
10626 func_verbose "using piecewise archive linking..."
10627 save_RANLIB=$RANLIB
10628 RANLIB=:
10629 objlist=
10630 concat_cmds=
10631 save_oldobjs=$oldobjs
10632 oldobjs=
10633 # Is there a better way of finding the last object in the list?
10634 for obj in $save_oldobjs
10635 do
10636 last_oldobj=$obj
10637 done
10638 eval test_cmds=\"$old_archive_cmds\"
10639 func_len " $test_cmds"
10640 len0=$func_len_result
10641 len=$len0
10642 for obj in $save_oldobjs
10643 do
10644 func_len " $obj"
10645 func_arith $len + $func_len_result
10646 len=$func_arith_result
10647 func_append objlist " $obj"
10648 if test "$len" -lt "$max_cmd_len"; then
10649 :
10650 else
10651 # the above command should be used before it gets too long
10652 oldobjs=$objlist
10653 if test "$obj" = "$last_oldobj"; then
10654 RANLIB=$save_RANLIB
10655 fi
10656 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10657 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10658 objlist=
10659 len=$len0
10660 fi
10661 done
10662 RANLIB=$save_RANLIB
10663 oldobjs=$objlist
10664 if test -z "$oldobjs"; then
10665 eval cmds=\"\$concat_cmds\"
10666 else
10667 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10668 fi
10669 fi
10670 fi
10671 func_execute_cmds "$cmds" 'exit $?'
10672 done
10673
10674 test -n "$generated" && \
10675 func_show_eval "${RM}r$generated"
10676
10677 # Now create the libtool archive.
10678 case $output in
10679 *.la)
10680 old_library=
10681 test yes = "$build_old_libs" && old_library=$libname.$libext
10682 func_verbose "creating $output"
10683
10684 # Preserve any variables that may affect compiler behavior
10685 for var in $variables_saved_for_relink; do
10686 if eval test -z \"\${$var+set}\"; then
10687 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10688 elif eval var_value=\$$var; test -z "$var_value"; then
10689 relink_command="$var=; export $var; $relink_command"
10690 else
10691 func_quote_for_eval "$var_value"
10692 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10693 fi
10694 done
10695 # Quote the link command for shipping.
10696 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10697 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10698 if test yes = "$hardcode_automatic"; then
10699 relink_command=
10700 fi
10701
10702 # Only create the output if not a dry run.
10703 $opt_dry_run || {
10704 for installed in no yes; do
10705 if test yes = "$installed"; then
10706 if test -z "$install_libdir"; then
10707 break
10708 fi
10709 output=$output_objdir/${outputname}i
10710 # Replace all uninstalled libtool libraries with the installed ones
10711 newdependency_libs=
10712 for deplib in $dependency_libs; do
10713 case $deplib in
10714 *.la)
10715 func_basename "$deplib"
10716 name=$func_basename_result
10717 func_resolve_sysroot "$deplib"
10718 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10719 test -z "$libdir" && \
10720 func_fatal_error "'$deplib' is not a valid libtool archive"
10721 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10722 ;;
10723 -L*)
10724 func_stripname -L '' "$deplib"
10725 func_replace_sysroot "$func_stripname_result"
10726 func_append newdependency_libs " -L$func_replace_sysroot_result"
10727 ;;
10728 -R*)
10729 func_stripname -R '' "$deplib"
10730 func_replace_sysroot "$func_stripname_result"
10731 func_append newdependency_libs " -R$func_replace_sysroot_result"
10732 ;;
10733 *) func_append newdependency_libs " $deplib" ;;
10734 esac
10735 done
10736 dependency_libs=$newdependency_libs
10737 newdlfiles=
10738
10739 for lib in $dlfiles; do
10740 case $lib in
10741 *.la)
10742 func_basename "$lib"
10743 name=$func_basename_result
10744 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10745 test -z "$libdir" && \
10746 func_fatal_error "'$lib' is not a valid libtool archive"
10747 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10748 ;;
10749 *) func_append newdlfiles " $lib" ;;
10750 esac
10751 done
10752 dlfiles=$newdlfiles
10753 newdlprefiles=
10754 for lib in $dlprefiles; do
10755 case $lib in
10756 *.la)
10757 # Only pass preopened files to the pseudo-archive (for
10758 # eventual linking with the app. that links it) if we
10759 # didn't already link the preopened objects directly into
10760 # the library:
10761 func_basename "$lib"
10762 name=$func_basename_result
10763 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10764 test -z "$libdir" && \
10765 func_fatal_error "'$lib' is not a valid libtool archive"
10766 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10767 ;;
10768 esac
10769 done
10770 dlprefiles=$newdlprefiles
10771 else
10772 newdlfiles=
10773 for lib in $dlfiles; do
10774 case $lib in
10775 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10776 *) abs=`pwd`"/$lib" ;;
10777 esac
10778 func_append newdlfiles " $abs"
10779 done
10780 dlfiles=$newdlfiles
10781 newdlprefiles=
10782 for lib in $dlprefiles; do
10783 case $lib in
10784 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10785 *) abs=`pwd`"/$lib" ;;
10786 esac
10787 func_append newdlprefiles " $abs"
10788 done
10789 dlprefiles=$newdlprefiles
10790 fi
10791 $RM $output
10792 # place dlname in correct position for cygwin
10793 # In fact, it would be nice if we could use this code for all target
10794 # systems that can't hard-code library paths into their executables
10795 # and that have no shared library path variable independent of PATH,
10796 # but it turns out we can't easily determine that from inspecting
10797 # libtool variables, so we have to hard-code the OSs to which it
10798 # applies here; at the moment, that means platforms that use the PE
10799 # object format with DLL files. See the long comment at the top of
10800 # tests/bindir.at for full details.
10801 tdlname=$dlname
10802 case $host,$output,$installed,$module,$dlname in
10803 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10804 # If a -bindir argument was supplied, place the dll there.
10805 if test -n "$bindir"; then
10806 func_relative_path "$install_libdir" "$bindir"
10807 tdlname=$func_relative_path_result/$dlname
10808 else
10809 # Otherwise fall back on heuristic.
10810 tdlname=../bin/$dlname
10811 fi
10812 ;;
10813 esac
10814 $ECHO > $output "\
10815 # $outputname - a libtool library file
10816 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10817 #
10818 # Please DO NOT delete this file!
10819 # It is necessary for linking the library.
10820
10821 # The name that we can dlopen(3).
10822 dlname='$tdlname'
10823
10824 # Names of this library.
10825 library_names='$library_names'
10826
10827 # The name of the static archive.
10828 old_library='$old_library'
10829
10830 # Linker flags that cannot go in dependency_libs.
10831 inherited_linker_flags='$new_inherited_linker_flags'
10832
10833 # Libraries that this one depends upon.
10834 dependency_libs='$dependency_libs'
10835
10836 # Names of additional weak libraries provided by this library
10837 weak_library_names='$weak_libs'
10838
10839 # Version information for $libname.
10840 current=$current
10841 age=$age
10842 revision=$revision
10843
10844 # Is this an already installed library?
10845 installed=$installed
10846
10847 # Should we warn about portability when linking against -modules?
10848 shouldnotlink=$module
10849
10850 # Files to dlopen/dlpreopen
10851 dlopen='$dlfiles'
10852 dlpreopen='$dlprefiles'
10853
10854 # Directory that this library needs to be installed in:
10855 libdir='$install_libdir'"
10856 if test no,yes = "$installed,$need_relink"; then
10857 $ECHO >> $output "\
10858 relink_command=\"$relink_command\""
10859 fi
10860 done
10861 }
10862
10863 # Do a symbolic link so that the libtool archive can be found in
10864 # LD_LIBRARY_PATH before the program is installed.
10865 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10866 ;;
10867 esac
10868 exit $EXIT_SUCCESS
10869 }
10870
10871 if test link = "$opt_mode" || test relink = "$opt_mode"; then
10872 func_mode_link ${1+"$@"}
10873 fi
10874
10875
10876 # func_mode_uninstall arg...
10877 func_mode_uninstall ()
10878 {
10879 $debug_cmd
10880
10881 RM=$nonopt
10882 files=
10883 rmforce=false
10884 exit_status=0
10885
10886 # This variable tells wrapper scripts just to set variables rather
10887 # than running their programs.
10888 libtool_install_magic=$magic
10889
10890 for arg
10891 do
10892 case $arg in
10893 -f) func_append RM " $arg"; rmforce=: ;;
10894 -*) func_append RM " $arg" ;;
10895 *) func_append files " $arg" ;;
10896 esac
10897 done
10898
10899 test -z "$RM" && \
10900 func_fatal_help "you must specify an RM program"
10901
10902 rmdirs=
10903
10904 for file in $files; do
10905 func_dirname "$file" "" "."
10906 dir=$func_dirname_result
10907 if test . = "$dir"; then
10908 odir=$objdir
10909 else
10910 odir=$dir/$objdir
10911 fi
10912 func_basename "$file"
10913 name=$func_basename_result
10914 test uninstall = "$opt_mode" && odir=$dir
10915
10916 # Remember odir for removal later, being careful to avoid duplicates
10917 if test clean = "$opt_mode"; then
10918 case " $rmdirs " in
10919 *" $odir "*) ;;
10920 *) func_append rmdirs " $odir" ;;
10921 esac
10922 fi
10923
10924 # Don't error if the file doesn't exist and rm -f was used.
10925 if { test -L "$file"; } >/dev/null 2>&1 ||
10926 { test -h "$file"; } >/dev/null 2>&1 ||
10927 test -f "$file"; then
10928 :
10929 elif test -d "$file"; then
10930 exit_status=1
10931 continue
10932 elif $rmforce; then
10933 continue
10934 fi
10935
10936 rmfiles=$file
10937
10938 case $name in
10939 *.la)
10940 # Possibly a libtool archive, so verify it.
10941 if func_lalib_p "$file"; then
10942 func_source $dir/$name
10943
10944 # Delete the libtool libraries and symlinks.
10945 for n in $library_names; do
10946 func_append rmfiles " $odir/$n"
10947 done
10948 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
10949
10950 case $opt_mode in
10951 clean)
10952 case " $library_names " in
10953 *" $dlname "*) ;;
10954 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
10955 esac
10956 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
10957 ;;
10958 uninstall)
10959 if test -n "$library_names"; then
10960 # Do each command in the postuninstall commands.
10961 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
10962 fi
10963
10964 if test -n "$old_library"; then
10965 # Do each command in the old_postuninstall commands.
10966 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
10967 fi
10968 # FIXME: should reinstall the best remaining shared library.
10969 ;;
10970 esac
10971 fi
10972 ;;
10973
10974 *.lo)
10975 # Possibly a libtool object, so verify it.
10976 if func_lalib_p "$file"; then
10977
10978 # Read the .lo file
10979 func_source $dir/$name
10980
10981 # Add PIC object to the list of files to remove.
10982 if test -n "$pic_object" && test none != "$pic_object"; then
10983 func_append rmfiles " $dir/$pic_object"
10984 fi
10985
10986 # Add non-PIC object to the list of files to remove.
10987 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
10988 func_append rmfiles " $dir/$non_pic_object"
10989 fi
10990 fi
10991 ;;
10992
10993 *)
10994 if test clean = "$opt_mode"; then
10995 noexename=$name
10996 case $file in
10997 *.exe)
10998 func_stripname '' '.exe' "$file"
10999 file=$func_stripname_result
11000 func_stripname '' '.exe' "$name"
11001 noexename=$func_stripname_result
11002 # $file with .exe has already been added to rmfiles,
11003 # add $file without .exe
11004 func_append rmfiles " $file"
11005 ;;
11006 esac
11007 # Do a test to see if this is a libtool program.
11008 if func_ltwrapper_p "$file"; then
11009 if func_ltwrapper_executable_p "$file"; then
11010 func_ltwrapper_scriptname "$file"
11011 relink_command=
11012 func_source $func_ltwrapper_scriptname_result
11013 func_append rmfiles " $func_ltwrapper_scriptname_result"
11014 else
11015 relink_command=
11016 func_source $dir/$noexename
11017 fi
11018
11019 # note $name still contains .exe if it was in $file originally
11020 # as does the version of $file that was added into $rmfiles
11021 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11022 if test yes = "$fast_install" && test -n "$relink_command"; then
11023 func_append rmfiles " $odir/lt-$name"
11024 fi
11025 if test "X$noexename" != "X$name"; then
11026 func_append rmfiles " $odir/lt-$noexename.c"
11027 fi
11028 fi
11029 fi
11030 ;;
11031 esac
11032 func_show_eval "$RM $rmfiles" 'exit_status=1'
11033 done
11034
11035 # Try to remove the $objdir's in the directories where we deleted files
11036 for dir in $rmdirs; do
11037 if test -d "$dir"; then
11038 func_show_eval "rmdir $dir >/dev/null 2>&1"
11039 fi
11040 done
11041
11042 exit $exit_status
11043 }
11044
11045 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11046 func_mode_uninstall ${1+"$@"}
11047 fi
11048
11049 test -z "$opt_mode" && {
11050 help=$generic_help
11051 func_fatal_help "you must specify a MODE"
11052 }
11053
11054 test -z "$exec_cmd" && \
11055 func_fatal_help "invalid operation mode '$opt_mode'"
11056
11057 if test -n "$exec_cmd"; then
11058 eval exec "$exec_cmd"
11059 exit $EXIT_FAILURE
11060 fi
11061
11062 exit $exit_status
11063
11064
11065 # The TAGs below are defined such that we never get into a situation
11066 # where we disable both kinds of libraries. Given conflicting
11067 # choices, we go for a static library, that is the most portable,
11068 # since we can't tell whether shared libraries were disabled because
11069 # the user asked for that or because the platform doesn't support
11070 # them. This is particularly important on AIX, because we don't
11071 # support having both static and shared libraries enabled at the same
11072 # time on that platform, so we default to a shared-only configuration.
11073 # If a disable-shared tag is given, we'll fallback to a static-only
11074 # configuration. But we'll never go from static-only to shared-only.
11075
11076 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11077 build_libtool_libs=no
11078 build_old_libs=yes
11079 # ### END LIBTOOL TAG CONFIG: disable-shared
11080
11081 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
11082 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11083 # ### END LIBTOOL TAG CONFIG: disable-static
11084
11085 # Local Variables:
11086 # mode:shell-script
11087 # sh-indentation:2
11088 # End:

Properties

Name Value
svn:eol-style native
svn:executable *