/[svn]/hopm/trunk/src/libopm/ltmain.sh
ViewVC logotype

Contents of /hopm/trunk/src/libopm/ltmain.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5135 - (show annotations)
Thu Dec 25 18:51:51 2014 UTC (4 years, 11 months ago) by michael
File MIME type: application/x-shellscript
File size: 322647 byte(s)
- propset svn:eol-style native

<
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'"