]>
Commit | Line | Data |
---|---|---|
6f57a957 AC |
1 | #! /bin/sh |
2 | ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in | |
3 | ## by inline-source v2014-01-03.01 | |
7083c021 | 4 | |
6f57a957 AC |
5 | # libtool (GNU libtool) 2.4.6 |
6 | # Provide generalized library-building support services. | |
7083c021 AC |
7 | # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 |
8 | ||
6f57a957 | 9 | # Copyright (C) 1996-2015 Free Software Foundation, Inc. |
7083c021 AC |
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 | |
db137867 AC |
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 | # | |
7083c021 AC |
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 | |
db137867 AC |
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 | |
6f57a957 | 29 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
db137867 | 30 | |
db137867 | 31 | |
08d019eb | 32 | PROGRAM=libtool |
db137867 | 33 | PACKAGE=libtool |
6f57a957 AC |
34 | VERSION=2.4.6 |
35 | package_revision=2.4.6 | |
db137867 | 36 | |
6f57a957 AC |
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. | |
fe037171 | 67 | scriptversion=2015-10-04.22; # UTC |
6f57a957 AC |
68 | |
69 | # General shell script boiler plate, and helper functions. | |
70 | # Written by Gary V. Vaughan, 2004 | |
71 | ||
72 | # Copyright (C) 2004-2015 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 : | |
db137867 AC |
119 | emulate sh |
120 | NULLCMD=: | |
6f57a957 | 121 | # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which |
db137867 AC |
122 | # is contrary to our usage. Disable this feature. |
123 | alias -g '${1+"$@"}'='"$@"' | |
124 | setopt NO_GLOB_SUBST | |
125 | else | |
6f57a957 | 126 | case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac |
db137867 | 127 | fi |
08d019eb | 128 | |
6f57a957 AC |
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 | |
db137867 | 133 | do |
6f57a957 AC |
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\" | |
db137867 AC |
140 | fi" |
141 | done | |
142 | ||
6f57a957 AC |
143 | # CDPATH. |
144 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH | |
7083c021 | 145 | |
6f57a957 AC |
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 | |
7083c021 AC |
160 | |
161 | ||
162 | ||
6f57a957 AC |
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. | |
7083c021 AC |
311 | |
312 | : ${CP="cp -f"} | |
6f57a957 AC |
313 | : ${ECHO="printf %s\n"} |
314 | : ${EGREP="$GREP -E"} | |
315 | : ${FGREP="$GREP -F"} | |
316 | : ${LN_S="ln -s"} | |
7083c021 AC |
317 | : ${MAKE="make"} |
318 | : ${MKDIR="mkdir"} | |
319 | : ${MV="mv -f"} | |
320 | : ${RM="rm -f"} | |
7083c021 | 321 | : ${SHELL="${CONFIG_SHELL-/bin/sh}"} |
db137867 | 322 | |
7083c021 | 323 | |
6f57a957 AC |
324 | ## -------------------- ## |
325 | ## Useful sed snippets. ## | |
326 | ## -------------------- ## | |
08d019eb | 327 | |
6f57a957 AC |
328 | sed_dirname='s|/[^/]*$||' |
329 | sed_basename='s|^.*/||' | |
08d019eb | 330 | |
6f57a957 AC |
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' | |
08d019eb | 334 | |
6f57a957 AC |
335 | # Same as above, but do not quote variable references. |
336 | sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' | |
08d019eb | 337 | |
6f57a957 AC |
338 | # Sed substitution that turns a string into a regex matching for the |
339 | # string literally. | |
340 | sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' | |
08d019eb | 341 | |
6f57a957 AC |
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" | |
08d019eb | 362 | |
08d019eb | 363 | |
6f57a957 AC |
364 | ## ----------------- ## |
365 | ## Global variables. ## | |
366 | ## ----------------- ## | |
08d019eb | 367 | |
6f57a957 AC |
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. | |
08d019eb | 380 | |
6f57a957 AC |
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. | |
db137867 | 385 | |
6f57a957 AC |
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=: | |
7083c021 | 393 | |
6f57a957 AC |
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 | |
08d019eb | 402 | |
6f57a957 AC |
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 | |
7083c021 | 409 | |
6f57a957 AC |
410 | # The name of this program. |
411 | progname=`$ECHO "$progpath" |$SED "$sed_basename"` | |
7083c021 | 412 | |
6f57a957 | 413 | # Make sure we have an absolute progpath for reexecution: |
7083c021 AC |
414 | case $progpath in |
415 | [\\/]*|[A-Za-z]:\\*) ;; | |
416 | *[\\/]*) | |
6f57a957 | 417 | progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` |
7083c021 | 418 | progdir=`cd "$progdir" && pwd` |
6f57a957 | 419 | progpath=$progdir/$progname |
7083c021 AC |
420 | ;; |
421 | *) | |
6f57a957 | 422 | _G_IFS=$IFS |
54bec06e | 423 | IFS=${PATH_SEPARATOR-:} |
7083c021 | 424 | for progdir in $PATH; do |
6f57a957 | 425 | IFS=$_G_IFS |
7083c021 AC |
426 | test -x "$progdir/$progname" && break |
427 | done | |
6f57a957 | 428 | IFS=$_G_IFS |
7083c021 | 429 | test -n "$progdir" || progdir=`pwd` |
6f57a957 | 430 | progpath=$progdir/$progname |
7083c021 AC |
431 | ;; |
432 | esac | |
433 | ||
7083c021 | 434 | |
6f57a957 AC |
435 | ## ----------------- ## |
436 | ## Standard options. ## | |
437 | ## ----------------- ## | |
08d019eb | 438 | |
6f57a957 AC |
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. | |
7083c021 | 442 | |
7083c021 | 443 | opt_dry_run=false |
7083c021 AC |
444 | opt_quiet=false |
445 | opt_verbose=false | |
7083c021 | 446 | |
6f57a957 AC |
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= | |
7083c021 | 451 | |
6f57a957 AC |
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 | |
7083c021 | 456 | |
6f57a957 AC |
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 | |
7083c021 | 461 | |
08d019eb | 462 | |
6f57a957 AC |
463 | ## -------------------- ## |
464 | ## Resource management. ## | |
465 | ## -------------------- ## | |
7083c021 | 466 | |
6f57a957 AC |
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. | |
7083c021 | 477 | |
7083c021 | 478 | |
6f57a957 AC |
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 () | |
7083c021 | 484 | { |
6f57a957 AC |
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='\e[0m' | |
496 | tc_bold='\e[1m'; tc_standout='\e[7m' | |
497 | tc_red='\e[31m'; tc_green='\e[32m' | |
498 | tc_blue='\e[34m'; tc_cyan='\e[36m' | |
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 | } | |
7083c021 | 513 | |
6f57a957 | 514 | require_term_colors=: |
7083c021 | 515 | } |
7083c021 AC |
516 | |
517 | ||
6f57a957 AC |
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 | # ----------------------------- | |
7083c021 AC |
802 | # Check whether EXPRESSION matches any line of FILENAME, without output. |
803 | func_grep () | |
804 | { | |
6f57a957 AC |
805 | $debug_cmd |
806 | ||
7083c021 AC |
807 | $GREP "$1" "$2" >/dev/null 2>&1 |
808 | } | |
809 | ||
810 | ||
6f57a957 AC |
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 | # --------------------------- | |
7083c021 AC |
839 | # Make sure the entire path to DIRECTORY-PATH is available. |
840 | func_mkdir_p () | |
841 | { | |
6f57a957 | 842 | $debug_cmd |
7083c021 | 843 | |
6f57a957 AC |
844 | _G_directory_path=$1 |
845 | _G_dir_list= | |
7083c021 | 846 | |
6f57a957 AC |
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 ;; | |
7083c021 AC |
852 | esac |
853 | ||
854 | # While some portion of DIR does not yet exist... | |
6f57a957 | 855 | while test ! -d "$_G_directory_path"; do |
7083c021 AC |
856 | # ...make a list in topmost first order. Use a colon delimited |
857 | # list incase some portion of path contains whitespace. | |
6f57a957 | 858 | _G_dir_list=$_G_directory_path:$_G_dir_list |
7083c021 AC |
859 | |
860 | # If the last portion added has no slash in it, the list is done | |
6f57a957 | 861 | case $_G_directory_path in */*) ;; *) break ;; esac |
7083c021 AC |
862 | |
863 | # ...otherwise throw away the child directory and loop | |
6f57a957 | 864 | _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` |
7083c021 | 865 | done |
6f57a957 | 866 | _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` |
7083c021 | 867 | |
6f57a957 AC |
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 | |
7083c021 AC |
872 | # try to create one of the directories concurrently. Don't |
873 | # stop in that case! | |
6f57a957 | 874 | $MKDIR "$_G_dir" 2>/dev/null || : |
7083c021 | 875 | done |
6f57a957 | 876 | IFS=$func_mkdir_p_IFS |
7083c021 AC |
877 | |
878 | # Bail out if we (or some other process) failed to create a directory. | |
6f57a957 AC |
879 | test -d "$_G_directory_path" || \ |
880 | func_fatal_error "Failed to create '$1'" | |
7083c021 AC |
881 | fi |
882 | } | |
db137867 | 883 | |
db137867 | 884 | |
6f57a957 AC |
885 | # func_mktempdir [BASENAME] |
886 | # ------------------------- | |
db137867 AC |
887 | # Make a temporary directory that won't clash with other running |
888 | # libtool processes, and avoids race conditions if possible. If | |
6f57a957 | 889 | # given, BASENAME is the basename for that directory. |
db137867 AC |
890 | func_mktempdir () |
891 | { | |
6f57a957 AC |
892 | $debug_cmd |
893 | ||
894 | _G_template=${TMPDIR-/tmp}/${1-$progname} | |
db137867 | 895 | |
6f57a957 | 896 | if test : = "$opt_dry_run"; then |
db137867 | 897 | # Return a directory name, but don't create it in dry-run mode |
6f57a957 | 898 | _G_tmpdir=$_G_template-$$ |
db137867 AC |
899 | else |
900 | ||
901 | # If mktemp works, use that first and foremost | |
6f57a957 | 902 | _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` |
db137867 | 903 | |
6f57a957 | 904 | if test ! -d "$_G_tmpdir"; then |
7083c021 | 905 | # Failing that, at least try and use $RANDOM to avoid a race |
6f57a957 | 906 | _G_tmpdir=$_G_template-${RANDOM-0}$$ |
db137867 | 907 | |
6f57a957 | 908 | func_mktempdir_umask=`umask` |
7083c021 | 909 | umask 0077 |
6f57a957 AC |
910 | $MKDIR "$_G_tmpdir" |
911 | umask $func_mktempdir_umask | |
db137867 AC |
912 | fi |
913 | ||
914 | # If we're not in dry-run mode, bomb out on failure | |
6f57a957 AC |
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 | |
db137867 AC |
1086 | fi |
1087 | ||
6f57a957 AC |
1088 | test -n "$func_relative_path_result" || func_relative_path_result=. |
1089 | ||
1090 | : | |
1091 | } | |
1092 | ||
1093 | ||
fe037171 EM |
1094 | # func_quote ARG |
1095 | # -------------- | |
1096 | # Aesthetically quote one ARG, store the result into $func_quote_result. Note | |
1097 | # that we keep attention to performance here (so far O(N) complexity as long as | |
1098 | # func_append is O(1)). | |
1099 | func_quote () | |
1100 | { | |
1101 | $debug_cmd | |
1102 | ||
1103 | func_quote_result=$1 | |
1104 | ||
1105 | case $func_quote_result in | |
1106 | *[\\\`\"\$]*) | |
1107 | case $func_quote_result in | |
1108 | *[\[\*\?]*) | |
1109 | func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"` | |
1110 | return 0 | |
1111 | ;; | |
1112 | esac | |
1113 | ||
1114 | func_quote_old_IFS=$IFS | |
1115 | for _G_char in '\' '`' '"' '$' | |
1116 | do | |
1117 | # STATE($1) PREV($2) SEPARATOR($3) | |
1118 | set start "" "" | |
1119 | func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy | |
1120 | IFS=$_G_char | |
1121 | for _G_part in $func_quote_result | |
1122 | do | |
1123 | case $1 in | |
1124 | quote) | |
1125 | func_append func_quote_result "$3$2" | |
1126 | set quote "$_G_part" "\\$_G_char" | |
1127 | ;; | |
1128 | start) | |
1129 | set first "" "" | |
1130 | func_quote_result= | |
1131 | ;; | |
1132 | first) | |
1133 | set quote "$_G_part" "" | |
1134 | ;; | |
1135 | esac | |
1136 | done | |
1137 | IFS=$func_quote_old_IFS | |
1138 | done | |
1139 | ;; | |
1140 | *) ;; | |
1141 | esac | |
1142 | } | |
1143 | ||
1144 | ||
6f57a957 AC |
1145 | # func_quote_for_eval ARG... |
1146 | # -------------------------- | |
1147 | # Aesthetically quote ARGs to be evaled later. | |
1148 | # This function returns two values: | |
1149 | # i) func_quote_for_eval_result | |
1150 | # double-quoted, suitable for a subsequent eval | |
1151 | # ii) func_quote_for_eval_unquoted_result | |
1152 | # has all characters that are still active within double | |
1153 | # quotes backslashified. | |
1154 | func_quote_for_eval () | |
1155 | { | |
1156 | $debug_cmd | |
1157 | ||
1158 | func_quote_for_eval_unquoted_result= | |
1159 | func_quote_for_eval_result= | |
1160 | while test 0 -lt $#; do | |
fe037171 EM |
1161 | func_quote "$1" |
1162 | _G_unquoted_arg=$func_quote_result | |
6f57a957 AC |
1163 | if test -n "$func_quote_for_eval_unquoted_result"; then |
1164 | func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" | |
1165 | else | |
1166 | func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" | |
1167 | fi | |
1168 | ||
1169 | case $_G_unquoted_arg in | |
1170 | # Double-quote args containing shell metacharacters to delay | |
1171 | # word splitting, command substitution and variable expansion | |
1172 | # for a subsequent eval. | |
1173 | # Many Bourne shells cannot handle close brackets correctly | |
1174 | # in scan sets, so we specify it separately. | |
1175 | *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") | |
1176 | _G_quoted_arg=\"$_G_unquoted_arg\" | |
1177 | ;; | |
1178 | *) | |
1179 | _G_quoted_arg=$_G_unquoted_arg | |
1180 | ;; | |
1181 | esac | |
1182 | ||
1183 | if test -n "$func_quote_for_eval_result"; then | |
1184 | func_append func_quote_for_eval_result " $_G_quoted_arg" | |
1185 | else | |
1186 | func_append func_quote_for_eval_result "$_G_quoted_arg" | |
1187 | fi | |
1188 | shift | |
1189 | done | |
1190 | } | |
1191 | ||
1192 | ||
1193 | # func_quote_for_expand ARG | |
1194 | # ------------------------- | |
1195 | # Aesthetically quote ARG to be evaled later; same as above, | |
1196 | # but do not quote variable references. | |
1197 | func_quote_for_expand () | |
1198 | { | |
1199 | $debug_cmd | |
1200 | ||
1201 | case $1 in | |
1202 | *[\\\`\"]*) | |
1203 | _G_arg=`$ECHO "$1" | $SED \ | |
1204 | -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; | |
1205 | *) | |
1206 | _G_arg=$1 ;; | |
1207 | esac | |
1208 | ||
1209 | case $_G_arg in | |
1210 | # Double-quote args containing shell metacharacters to delay | |
1211 | # word splitting and command substitution for a subsequent eval. | |
1212 | # Many Bourne shells cannot handle close brackets correctly | |
1213 | # in scan sets, so we specify it separately. | |
1214 | *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") | |
1215 | _G_arg=\"$_G_arg\" | |
1216 | ;; | |
1217 | esac | |
1218 | ||
1219 | func_quote_for_expand_result=$_G_arg | |
1220 | } | |
1221 | ||
1222 | ||
1223 | # func_stripname PREFIX SUFFIX NAME | |
1224 | # --------------------------------- | |
1225 | # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. | |
1226 | # PREFIX and SUFFIX must not contain globbing or regex special | |
1227 | # characters, hashes, percent signs, but SUFFIX may contain a leading | |
1228 | # dot (in which case that matches only a dot). | |
1229 | if test yes = "$_G_HAVE_XSI_OPS"; then | |
1230 | eval 'func_stripname () | |
1231 | { | |
1232 | $debug_cmd | |
1233 | ||
1234 | # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are | |
1235 | # positional parameters, so assign one to ordinary variable first. | |
1236 | func_stripname_result=$3 | |
1237 | func_stripname_result=${func_stripname_result#"$1"} | |
1238 | func_stripname_result=${func_stripname_result%"$2"} | |
1239 | }' | |
1240 | else | |
1241 | func_stripname () | |
1242 | { | |
1243 | $debug_cmd | |
1244 | ||
1245 | case $2 in | |
1246 | .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; | |
1247 | *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; | |
1248 | esac | |
1249 | } | |
1250 | fi | |
1251 | ||
1252 | ||
1253 | # func_show_eval CMD [FAIL_EXP] | |
1254 | # ----------------------------- | |
1255 | # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is | |
1256 | # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP | |
1257 | # is given, then evaluate it. | |
1258 | func_show_eval () | |
1259 | { | |
1260 | $debug_cmd | |
1261 | ||
1262 | _G_cmd=$1 | |
1263 | _G_fail_exp=${2-':'} | |
1264 | ||
1265 | func_quote_for_expand "$_G_cmd" | |
1266 | eval "func_notquiet $func_quote_for_expand_result" | |
1267 | ||
1268 | $opt_dry_run || { | |
1269 | eval "$_G_cmd" | |
1270 | _G_status=$? | |
1271 | if test 0 -ne "$_G_status"; then | |
1272 | eval "(exit $_G_status); $_G_fail_exp" | |
1273 | fi | |
1274 | } | |
1275 | } | |
1276 | ||
1277 | ||
1278 | # func_show_eval_locale CMD [FAIL_EXP] | |
1279 | # ------------------------------------ | |
1280 | # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is | |
1281 | # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP | |
1282 | # is given, then evaluate it. Use the saved locale for evaluation. | |
1283 | func_show_eval_locale () | |
1284 | { | |
1285 | $debug_cmd | |
1286 | ||
1287 | _G_cmd=$1 | |
1288 | _G_fail_exp=${2-':'} | |
1289 | ||
1290 | $opt_quiet || { | |
1291 | func_quote_for_expand "$_G_cmd" | |
1292 | eval "func_echo $func_quote_for_expand_result" | |
1293 | } | |
1294 | ||
1295 | $opt_dry_run || { | |
1296 | eval "$_G_user_locale | |
1297 | $_G_cmd" | |
1298 | _G_status=$? | |
1299 | eval "$_G_safe_locale" | |
1300 | if test 0 -ne "$_G_status"; then | |
1301 | eval "(exit $_G_status); $_G_fail_exp" | |
1302 | fi | |
1303 | } | |
1304 | } | |
1305 | ||
1306 | ||
1307 | # func_tr_sh | |
1308 | # ---------- | |
1309 | # Turn $1 into a string suitable for a shell variable name. | |
1310 | # Result is stored in $func_tr_sh_result. All characters | |
1311 | # not in the set a-zA-Z0-9_ are replaced with '_'. Further, | |
1312 | # if $1 begins with a digit, a '_' is prepended as well. | |
1313 | func_tr_sh () | |
1314 | { | |
1315 | $debug_cmd | |
1316 | ||
1317 | case $1 in | |
1318 | [0-9]* | *[!a-zA-Z0-9_]*) | |
1319 | func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` | |
1320 | ;; | |
1321 | * ) | |
1322 | func_tr_sh_result=$1 | |
1323 | ;; | |
1324 | esac | |
1325 | } | |
1326 | ||
1327 | ||
1328 | # func_verbose ARG... | |
1329 | # ------------------- | |
1330 | # Echo program name prefixed message in verbose mode only. | |
1331 | func_verbose () | |
1332 | { | |
1333 | $debug_cmd | |
1334 | ||
1335 | $opt_verbose && func_echo "$*" | |
1336 | ||
1337 | : | |
1338 | } | |
1339 | ||
1340 | ||
1341 | # func_warn_and_continue ARG... | |
1342 | # ----------------------------- | |
1343 | # Echo program name prefixed warning message to standard error. | |
1344 | func_warn_and_continue () | |
1345 | { | |
1346 | $debug_cmd | |
1347 | ||
1348 | $require_term_colors | |
1349 | ||
1350 | func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 | |
1351 | } | |
1352 | ||
1353 | ||
1354 | # func_warning CATEGORY ARG... | |
1355 | # ---------------------------- | |
1356 | # Echo program name prefixed warning message to standard error. Warning | |
1357 | # messages can be filtered according to CATEGORY, where this function | |
1358 | # elides messages where CATEGORY is not listed in the global variable | |
1359 | # 'opt_warning_types'. | |
1360 | func_warning () | |
1361 | { | |
1362 | $debug_cmd | |
1363 | ||
1364 | # CATEGORY must be in the warning_categories list! | |
1365 | case " $warning_categories " in | |
1366 | *" $1 "*) ;; | |
1367 | *) func_internal_error "invalid warning category '$1'" ;; | |
1368 | esac | |
1369 | ||
1370 | _G_category=$1 | |
1371 | shift | |
1372 | ||
1373 | case " $opt_warning_types " in | |
1374 | *" $_G_category "*) $warning_func ${1+"$@"} ;; | |
1375 | esac | |
1376 | } | |
1377 | ||
1378 | ||
1379 | # func_sort_ver VER1 VER2 | |
1380 | # ----------------------- | |
1381 | # 'sort -V' is not generally available. | |
1382 | # Note this deviates from the version comparison in automake | |
1383 | # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a | |
1384 | # but this should suffice as we won't be specifying old | |
1385 | # version formats or redundant trailing .0 in bootstrap.conf. | |
1386 | # If we did want full compatibility then we should probably | |
1387 | # use m4_version_compare from autoconf. | |
1388 | func_sort_ver () | |
1389 | { | |
1390 | $debug_cmd | |
1391 | ||
1392 | printf '%s\n%s\n' "$1" "$2" \ | |
1393 | | 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 | |
1394 | } | |
1395 | ||
1396 | # func_lt_ver PREV CURR | |
1397 | # --------------------- | |
1398 | # Return true if PREV and CURR are in the correct order according to | |
1399 | # func_sort_ver, otherwise false. Use it like this: | |
1400 | # | |
1401 | # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." | |
1402 | func_lt_ver () | |
1403 | { | |
1404 | $debug_cmd | |
1405 | ||
1406 | test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` | |
1407 | } | |
1408 | ||
1409 | ||
1410 | # Local variables: | |
1411 | # mode: shell-script | |
1412 | # sh-indentation: 2 | |
1413 | # eval: (add-hook 'before-save-hook 'time-stamp) | |
1414 | # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" | |
1415 | # time-stamp-time-zone: "UTC" | |
1416 | # End: | |
1417 | #! /bin/sh | |
1418 | ||
1419 | # Set a version string for this script. | |
1420 | scriptversion=2014-01-07.03; # UTC | |
1421 | ||
1422 | # A portable, pluggable option parser for Bourne shell. | |
1423 | # Written by Gary V. Vaughan, 2010 | |
1424 | ||
1425 | # Copyright (C) 2010-2015 Free Software Foundation, Inc. | |
1426 | # This is free software; see the source for copying conditions. There is NO | |
1427 | # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
1428 | ||
1429 | # This program is free software: you can redistribute it and/or modify | |
1430 | # it under the terms of the GNU General Public License as published by | |
1431 | # the Free Software Foundation, either version 3 of the License, or | |
1432 | # (at your option) any later version. | |
1433 | ||
1434 | # This program is distributed in the hope that it will be useful, | |
1435 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
1436 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
1437 | # GNU General Public License for more details. | |
1438 | ||
1439 | # You should have received a copy of the GNU General Public License | |
1440 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
1441 | ||
1442 | # Please report bugs or propose patches to gary@gnu.org. | |
1443 | ||
1444 | ||
1445 | ## ------ ## | |
1446 | ## Usage. ## | |
1447 | ## ------ ## | |
1448 | ||
1449 | # This file is a library for parsing options in your shell scripts along | |
1450 | # with assorted other useful supporting features that you can make use | |
1451 | # of too. | |
1452 | # | |
1453 | # For the simplest scripts you might need only: | |
1454 | # | |
1455 | # #!/bin/sh | |
1456 | # . relative/path/to/funclib.sh | |
1457 | # . relative/path/to/options-parser | |
1458 | # scriptversion=1.0 | |
1459 | # func_options ${1+"$@"} | |
1460 | # eval set dummy "$func_options_result"; shift | |
1461 | # ...rest of your script... | |
1462 | # | |
1463 | # In order for the '--version' option to work, you will need to have a | |
1464 | # suitably formatted comment like the one at the top of this file | |
1465 | # starting with '# Written by ' and ending with '# warranty; '. | |
1466 | # | |
1467 | # For '-h' and '--help' to work, you will also need a one line | |
1468 | # description of your script's purpose in a comment directly above the | |
1469 | # '# Written by ' line, like the one at the top of this file. | |
1470 | # | |
1471 | # The default options also support '--debug', which will turn on shell | |
1472 | # execution tracing (see the comment above debug_cmd below for another | |
1473 | # use), and '--verbose' and the func_verbose function to allow your script | |
1474 | # to display verbose messages only when your user has specified | |
1475 | # '--verbose'. | |
1476 | # | |
1477 | # After sourcing this file, you can plug processing for additional | |
1478 | # options by amending the variables from the 'Configuration' section | |
1479 | # below, and following the instructions in the 'Option parsing' | |
1480 | # section further down. | |
1481 | ||
1482 | ## -------------- ## | |
1483 | ## Configuration. ## | |
1484 | ## -------------- ## | |
1485 | ||
1486 | # You should override these variables in your script after sourcing this | |
1487 | # file so that they reflect the customisations you have added to the | |
1488 | # option parser. | |
1489 | ||
1490 | # The usage line for option parsing errors and the start of '-h' and | |
1491 | # '--help' output messages. You can embed shell variables for delayed | |
1492 | # expansion at the time the message is displayed, but you will need to | |
1493 | # quote other shell meta-characters carefully to prevent them being | |
1494 | # expanded when the contents are evaled. | |
1495 | usage='$progpath [OPTION]...' | |
1496 | ||
1497 | # Short help message in response to '-h' and '--help'. Add to this or | |
1498 | # override it after sourcing this library to reflect the full set of | |
1499 | # options your script accepts. | |
1500 | usage_message="\ | |
1501 | --debug enable verbose shell tracing | |
1502 | -W, --warnings=CATEGORY | |
1503 | report the warnings falling in CATEGORY [all] | |
1504 | -v, --verbose verbosely report processing | |
1505 | --version print version information and exit | |
1506 | -h, --help print short or long help message and exit | |
1507 | " | |
1508 | ||
1509 | # Additional text appended to 'usage_message' in response to '--help'. | |
1510 | long_help_message=" | |
1511 | Warning categories include: | |
1512 | 'all' show all warnings | |
1513 | 'none' turn off all the warnings | |
1514 | 'error' warnings are treated as fatal errors" | |
1515 | ||
1516 | # Help message printed before fatal option parsing errors. | |
1517 | fatal_help="Try '\$progname --help' for more information." | |
1518 | ||
1519 | ||
1520 | ||
1521 | ## ------------------------- ## | |
1522 | ## Hook function management. ## | |
1523 | ## ------------------------- ## | |
1524 | ||
1525 | # This section contains functions for adding, removing, and running hooks | |
1526 | # to the main code. A hook is just a named list of of function, that can | |
1527 | # be run in order later on. | |
1528 | ||
1529 | # func_hookable FUNC_NAME | |
1530 | # ----------------------- | |
1531 | # Declare that FUNC_NAME will run hooks added with | |
1532 | # 'func_add_hook FUNC_NAME ...'. | |
1533 | func_hookable () | |
1534 | { | |
1535 | $debug_cmd | |
1536 | ||
1537 | func_append hookable_fns " $1" | |
1538 | } | |
1539 | ||
1540 | ||
1541 | # func_add_hook FUNC_NAME HOOK_FUNC | |
1542 | # --------------------------------- | |
1543 | # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must | |
1544 | # first have been declared "hookable" by a call to 'func_hookable'. | |
1545 | func_add_hook () | |
1546 | { | |
1547 | $debug_cmd | |
1548 | ||
1549 | case " $hookable_fns " in | |
1550 | *" $1 "*) ;; | |
1551 | *) func_fatal_error "'$1' does not accept hook functions." ;; | |
1552 | esac | |
1553 | ||
1554 | eval func_append ${1}_hooks '" $2"' | |
1555 | } | |
1556 | ||
1557 | ||
1558 | # func_remove_hook FUNC_NAME HOOK_FUNC | |
1559 | # ------------------------------------ | |
1560 | # Remove HOOK_FUNC from the list of functions called by FUNC_NAME. | |
1561 | func_remove_hook () | |
1562 | { | |
1563 | $debug_cmd | |
1564 | ||
1565 | eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' | |
1566 | } | |
1567 | ||
1568 | ||
1569 | # func_run_hooks FUNC_NAME [ARG]... | |
1570 | # --------------------------------- | |
1571 | # Run all hook functions registered to FUNC_NAME. | |
1572 | # It is assumed that the list of hook functions contains nothing more | |
1573 | # than a whitespace-delimited list of legal shell function names, and | |
1574 | # no effort is wasted trying to catch shell meta-characters or preserve | |
1575 | # whitespace. | |
1576 | func_run_hooks () | |
1577 | { | |
1578 | $debug_cmd | |
1579 | ||
1580 | case " $hookable_fns " in | |
1581 | *" $1 "*) ;; | |
1582 | *) func_fatal_error "'$1' does not support hook funcions.n" ;; | |
1583 | esac | |
1584 | ||
1585 | eval _G_hook_fns=\$$1_hooks; shift | |
1586 | ||
1587 | for _G_hook in $_G_hook_fns; do | |
1588 | eval $_G_hook '"$@"' | |
1589 | ||
1590 | # store returned options list back into positional | |
1591 | # parameters for next 'cmd' execution. | |
1592 | eval _G_hook_result=\$${_G_hook}_result | |
1593 | eval set dummy "$_G_hook_result"; shift | |
1594 | done | |
1595 | ||
1596 | func_quote_for_eval ${1+"$@"} | |
1597 | func_run_hooks_result=$func_quote_for_eval_result | |
1598 | } | |
1599 | ||
1600 | ||
1601 | ||
1602 | ## --------------- ## | |
1603 | ## Option parsing. ## | |
1604 | ## --------------- ## | |
1605 | ||
1606 | # In order to add your own option parsing hooks, you must accept the | |
1607 | # full positional parameter list in your hook function, remove any | |
1608 | # options that you action, and then pass back the remaining unprocessed | |
1609 | # options in '<hooked_function_name>_result', escaped suitably for | |
1610 | # 'eval'. Like this: | |
1611 | # | |
1612 | # my_options_prep () | |
1613 | # { | |
1614 | # $debug_cmd | |
1615 | # | |
1616 | # # Extend the existing usage message. | |
1617 | # usage_message=$usage_message' | |
1618 | # -s, --silent don'\''t print informational messages | |
1619 | # ' | |
1620 | # | |
1621 | # func_quote_for_eval ${1+"$@"} | |
1622 | # my_options_prep_result=$func_quote_for_eval_result | |
1623 | # } | |
1624 | # func_add_hook func_options_prep my_options_prep | |
1625 | # | |
1626 | # | |
1627 | # my_silent_option () | |
1628 | # { | |
1629 | # $debug_cmd | |
1630 | # | |
1631 | # # Note that for efficiency, we parse as many options as we can | |
1632 | # # recognise in a loop before passing the remainder back to the | |
1633 | # # caller on the first unrecognised argument we encounter. | |
1634 | # while test $# -gt 0; do | |
1635 | # opt=$1; shift | |
1636 | # case $opt in | |
1637 | # --silent|-s) opt_silent=: ;; | |
1638 | # # Separate non-argument short options: | |
1639 | # -s*) func_split_short_opt "$_G_opt" | |
1640 | # set dummy "$func_split_short_opt_name" \ | |
1641 | # "-$func_split_short_opt_arg" ${1+"$@"} | |
1642 | # shift | |
1643 | # ;; | |
1644 | # *) set dummy "$_G_opt" "$*"; shift; break ;; | |
1645 | # esac | |
1646 | # done | |
1647 | # | |
1648 | # func_quote_for_eval ${1+"$@"} | |
1649 | # my_silent_option_result=$func_quote_for_eval_result | |
1650 | # } | |
1651 | # func_add_hook func_parse_options my_silent_option | |
1652 | # | |
1653 | # | |
1654 | # my_option_validation () | |
1655 | # { | |
1656 | # $debug_cmd | |
1657 | # | |
1658 | # $opt_silent && $opt_verbose && func_fatal_help "\ | |
1659 | # '--silent' and '--verbose' options are mutually exclusive." | |
1660 | # | |
1661 | # func_quote_for_eval ${1+"$@"} | |
1662 | # my_option_validation_result=$func_quote_for_eval_result | |
1663 | # } | |
1664 | # func_add_hook func_validate_options my_option_validation | |
1665 | # | |
1666 | # You'll alse need to manually amend $usage_message to reflect the extra | |
1667 | # options you parse. It's preferable to append if you can, so that | |
1668 | # multiple option parsing hooks can be added safely. | |
1669 | ||
1670 | ||
1671 | # func_options [ARG]... | |
1672 | # --------------------- | |
1673 | # All the functions called inside func_options are hookable. See the | |
1674 | # individual implementations for details. | |
1675 | func_hookable func_options | |
1676 | func_options () | |
1677 | { | |
1678 | $debug_cmd | |
1679 | ||
1680 | func_options_prep ${1+"$@"} | |
1681 | eval func_parse_options \ | |
1682 | ${func_options_prep_result+"$func_options_prep_result"} | |
1683 | eval func_validate_options \ | |
1684 | ${func_parse_options_result+"$func_parse_options_result"} | |
1685 | ||
1686 | eval func_run_hooks func_options \ | |
1687 | ${func_validate_options_result+"$func_validate_options_result"} | |
1688 | ||
1689 | # save modified positional parameters for caller | |
1690 | func_options_result=$func_run_hooks_result | |
db137867 AC |
1691 | } |
1692 | ||
1693 | ||
6f57a957 AC |
1694 | # func_options_prep [ARG]... |
1695 | # -------------------------- | |
1696 | # All initialisations required before starting the option parse loop. | |
1697 | # Note that when calling hook functions, we pass through the list of | |
1698 | # positional parameters. If a hook function modifies that list, and | |
1699 | # needs to propogate that back to rest of this script, then the complete | |
1700 | # modified list must be put in 'func_run_hooks_result' before | |
1701 | # returning. | |
1702 | func_hookable func_options_prep | |
1703 | func_options_prep () | |
db137867 | 1704 | { |
6f57a957 | 1705 | $debug_cmd |
7083c021 | 1706 | |
6f57a957 AC |
1707 | # Option defaults: |
1708 | opt_verbose=false | |
1709 | opt_warning_types= | |
1710 | ||
1711 | func_run_hooks func_options_prep ${1+"$@"} | |
1712 | ||
1713 | # save modified positional parameters for caller | |
1714 | func_options_prep_result=$func_run_hooks_result | |
db137867 AC |
1715 | } |
1716 | ||
1717 | ||
6f57a957 AC |
1718 | # func_parse_options [ARG]... |
1719 | # --------------------------- | |
1720 | # The main option parsing loop. | |
1721 | func_hookable func_parse_options | |
1722 | func_parse_options () | |
db137867 | 1723 | { |
6f57a957 | 1724 | $debug_cmd |
7083c021 | 1725 | |
6f57a957 | 1726 | func_parse_options_result= |
7083c021 | 1727 | |
6f57a957 AC |
1728 | # this just eases exit handling |
1729 | while test $# -gt 0; do | |
1730 | # Defer to hook functions for initial option parsing, so they | |
1731 | # get priority in the event of reusing an option name. | |
1732 | func_run_hooks func_parse_options ${1+"$@"} | |
db137867 | 1733 | |
6f57a957 AC |
1734 | # Adjust func_parse_options positional parameters to match |
1735 | eval set dummy "$func_run_hooks_result"; shift | |
db137867 | 1736 | |
6f57a957 AC |
1737 | # Break out of the loop if we already parsed every option. |
1738 | test $# -gt 0 || break | |
db137867 | 1739 | |
6f57a957 AC |
1740 | _G_opt=$1 |
1741 | shift | |
1742 | case $_G_opt in | |
1743 | --debug|-x) debug_cmd='set -x' | |
1744 | func_echo "enabling shell trace mode" | |
1745 | $debug_cmd | |
1746 | ;; | |
1747 | ||
1748 | --no-warnings|--no-warning|--no-warn) | |
1749 | set dummy --warnings none ${1+"$@"} | |
1750 | shift | |
1751 | ;; | |
7083c021 | 1752 | |
6f57a957 AC |
1753 | --warnings|--warning|-W) |
1754 | test $# = 0 && func_missing_arg $_G_opt && break | |
1755 | case " $warning_categories $1" in | |
1756 | *" $1 "*) | |
1757 | # trailing space prevents matching last $1 above | |
1758 | func_append_uniq opt_warning_types " $1" | |
1759 | ;; | |
1760 | *all) | |
1761 | opt_warning_types=$warning_categories | |
1762 | ;; | |
1763 | *none) | |
1764 | opt_warning_types=none | |
1765 | warning_func=: | |
1766 | ;; | |
1767 | *error) | |
1768 | opt_warning_types=$warning_categories | |
1769 | warning_func=func_fatal_error | |
1770 | ;; | |
1771 | *) | |
1772 | func_fatal_error \ | |
1773 | "unsupported warning category: '$1'" | |
1774 | ;; | |
1775 | esac | |
1776 | shift | |
1777 | ;; | |
1778 | ||
1779 | --verbose|-v) opt_verbose=: ;; | |
1780 | --version) func_version ;; | |
1781 | -\?|-h) func_usage ;; | |
1782 | --help) func_help ;; | |
1783 | ||
1784 | # Separate optargs to long options (plugins may need this): | |
1785 | --*=*) func_split_equals "$_G_opt" | |
1786 | set dummy "$func_split_equals_lhs" \ | |
1787 | "$func_split_equals_rhs" ${1+"$@"} | |
1788 | shift | |
1789 | ;; | |
1790 | ||
1791 | # Separate optargs to short options: | |
1792 | -W*) | |
1793 | func_split_short_opt "$_G_opt" | |
1794 | set dummy "$func_split_short_opt_name" \ | |
1795 | "$func_split_short_opt_arg" ${1+"$@"} | |
1796 | shift | |
1797 | ;; | |
1798 | ||
1799 | # Separate non-argument short options: | |
1800 | -\?*|-h*|-v*|-x*) | |
1801 | func_split_short_opt "$_G_opt" | |
1802 | set dummy "$func_split_short_opt_name" \ | |
1803 | "-$func_split_short_opt_arg" ${1+"$@"} | |
1804 | shift | |
1805 | ;; | |
1806 | ||
1807 | --) break ;; | |
1808 | -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; | |
1809 | *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; | |
1810 | esac | |
1811 | done | |
1812 | ||
1813 | # save modified positional parameters for caller | |
1814 | func_quote_for_eval ${1+"$@"} | |
1815 | func_parse_options_result=$func_quote_for_eval_result | |
db137867 AC |
1816 | } |
1817 | ||
7083c021 | 1818 | |
6f57a957 AC |
1819 | # func_validate_options [ARG]... |
1820 | # ------------------------------ | |
1821 | # Perform any sanity checks on option settings and/or unconsumed | |
1822 | # arguments. | |
1823 | func_hookable func_validate_options | |
1824 | func_validate_options () | |
db137867 | 1825 | { |
6f57a957 | 1826 | $debug_cmd |
7083c021 | 1827 | |
6f57a957 AC |
1828 | # Display all warnings if -W was not given. |
1829 | test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" | |
7083c021 | 1830 | |
6f57a957 | 1831 | func_run_hooks func_validate_options ${1+"$@"} |
db137867 | 1832 | |
6f57a957 AC |
1833 | # Bail if the options were screwed! |
1834 | $exit_cmd $EXIT_FAILURE | |
1835 | ||
1836 | # save modified positional parameters for caller | |
1837 | func_validate_options_result=$func_run_hooks_result | |
08d019eb | 1838 | } |
7083c021 AC |
1839 | |
1840 | ||
08d019eb | 1841 | |
6f57a957 AC |
1842 | ## ----------------- ## |
1843 | ## Helper functions. ## | |
1844 | ## ----------------- ## | |
7083c021 | 1845 | |
6f57a957 AC |
1846 | # This section contains the helper functions used by the rest of the |
1847 | # hookable option parser framework in ascii-betical order. | |
1848 | ||
1849 | ||
1850 | # func_fatal_help ARG... | |
1851 | # ---------------------- | |
1852 | # Echo program name prefixed message to standard error, followed by | |
1853 | # a help hint, and exit. | |
1854 | func_fatal_help () | |
7083c021 | 1855 | { |
6f57a957 | 1856 | $debug_cmd |
08d019eb | 1857 | |
6f57a957 AC |
1858 | eval \$ECHO \""Usage: $usage"\" |
1859 | eval \$ECHO \""$fatal_help"\" | |
1860 | func_error ${1+"$@"} | |
1861 | exit $EXIT_FAILURE | |
7083c021 AC |
1862 | } |
1863 | ||
6f57a957 AC |
1864 | |
1865 | # func_help | |
1866 | # --------- | |
1867 | # Echo long help message to standard output and exit. | |
7083c021 AC |
1868 | func_help () |
1869 | { | |
6f57a957 AC |
1870 | $debug_cmd |
1871 | ||
1872 | func_usage_message | |
1873 | $ECHO "$long_help_message" | |
1874 | exit 0 | |
7083c021 AC |
1875 | } |
1876 | ||
6f57a957 AC |
1877 | |
1878 | # func_missing_arg ARGNAME | |
1879 | # ------------------------ | |
7083c021 AC |
1880 | # Echo program name prefixed message to standard error and set global |
1881 | # exit_cmd. | |
1882 | func_missing_arg () | |
1883 | { | |
6f57a957 | 1884 | $debug_cmd |
08d019eb | 1885 | |
6f57a957 | 1886 | func_error "Missing argument for '$1'." |
7083c021 | 1887 | exit_cmd=exit |
db137867 | 1888 | } |
db137867 | 1889 | |
db137867 | 1890 | |
6f57a957 AC |
1891 | # func_split_equals STRING |
1892 | # ------------------------ | |
1893 | # Set func_split_equals_lhs and func_split_equals_rhs shell variables after | |
1894 | # splitting STRING at the '=' sign. | |
1895 | test -z "$_G_HAVE_XSI_OPS" \ | |
1896 | && (eval 'x=a/b/c; | |
1897 | test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ | |
1898 | && _G_HAVE_XSI_OPS=yes | |
1899 | ||
1900 | if test yes = "$_G_HAVE_XSI_OPS" | |
1901 | then | |
1902 | # This is an XSI compatible shell, allowing a faster implementation... | |
1903 | eval 'func_split_equals () | |
1904 | { | |
1905 | $debug_cmd | |
1906 | ||
1907 | func_split_equals_lhs=${1%%=*} | |
1908 | func_split_equals_rhs=${1#*=} | |
1909 | test "x$func_split_equals_lhs" = "x$1" \ | |
1910 | && func_split_equals_rhs= | |
1911 | }' | |
1912 | else | |
1913 | # ...otherwise fall back to using expr, which is often a shell builtin. | |
1914 | func_split_equals () | |
1915 | { | |
1916 | $debug_cmd | |
1917 | ||
1918 | func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` | |
1919 | func_split_equals_rhs= | |
1920 | test "x$func_split_equals_lhs" = "x$1" \ | |
1921 | || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` | |
1922 | } | |
1923 | fi #func_split_equals | |
1924 | ||
1925 | ||
1926 | # func_split_short_opt SHORTOPT | |
1927 | # ----------------------------- | |
08d019eb AC |
1928 | # Set func_split_short_opt_name and func_split_short_opt_arg shell |
1929 | # variables after splitting SHORTOPT after the 2nd character. | |
6f57a957 AC |
1930 | if test yes = "$_G_HAVE_XSI_OPS" |
1931 | then | |
1932 | # This is an XSI compatible shell, allowing a faster implementation... | |
1933 | eval 'func_split_short_opt () | |
1934 | { | |
1935 | $debug_cmd | |
1936 | ||
1937 | func_split_short_opt_arg=${1#??} | |
1938 | func_split_short_opt_name=${1%"$func_split_short_opt_arg"} | |
1939 | }' | |
1940 | else | |
1941 | # ...otherwise fall back to using expr, which is often a shell builtin. | |
1942 | func_split_short_opt () | |
1943 | { | |
1944 | $debug_cmd | |
1945 | ||
1946 | func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` | |
1947 | func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` | |
1948 | } | |
1949 | fi #func_split_short_opt | |
1950 | ||
1951 | ||
1952 | # func_usage | |
1953 | # ---------- | |
1954 | # Echo short help message to standard output and exit. | |
1955 | func_usage () | |
08d019eb | 1956 | { |
6f57a957 | 1957 | $debug_cmd |
db137867 | 1958 | |
6f57a957 AC |
1959 | func_usage_message |
1960 | $ECHO "Run '$progname --help |${PAGER-more}' for full usage" | |
1961 | exit 0 | |
1962 | } | |
08d019eb AC |
1963 | |
1964 | ||
6f57a957 AC |
1965 | # func_usage_message |
1966 | # ------------------ | |
1967 | # Echo short help message to standard output. | |
1968 | func_usage_message () | |
08d019eb | 1969 | { |
6f57a957 | 1970 | $debug_cmd |
08d019eb | 1971 | |
6f57a957 AC |
1972 | eval \$ECHO \""Usage: $usage"\" |
1973 | echo | |
1974 | $SED -n 's|^# || | |
1975 | /^Written by/{ | |
1976 | x;p;x | |
1977 | } | |
1978 | h | |
1979 | /^Written by/q' < "$progpath" | |
1980 | echo | |
1981 | eval \$ECHO \""$usage_message"\" | |
1982 | } | |
08d019eb | 1983 | |
7083c021 | 1984 | |
6f57a957 AC |
1985 | # func_version |
1986 | # ------------ | |
1987 | # Echo version message to standard output and exit. | |
1988 | func_version () | |
1989 | { | |
1990 | $debug_cmd | |
7083c021 | 1991 | |
6f57a957 AC |
1992 | printf '%s\n' "$progname $scriptversion" |
1993 | $SED -n ' | |
1994 | /(C)/!b go | |
1995 | :more | |
1996 | /\./!{ | |
1997 | N | |
1998 | s|\n# | | | |
1999 | b more | |
2000 | } | |
2001 | :go | |
2002 | /^# Written by /,/# warranty; / { | |
2003 | s|^# || | |
2004 | s|^# *$|| | |
2005 | s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| | |
2006 | p | |
2007 | } | |
2008 | /^# Written by / { | |
2009 | s|^# || | |
2010 | p | |
2011 | } | |
2012 | /^warranty; /q' < "$progpath" | |
7083c021 | 2013 | |
6f57a957 AC |
2014 | exit $? |
2015 | } | |
db137867 | 2016 | |
db137867 | 2017 | |
6f57a957 AC |
2018 | # Local variables: |
2019 | # mode: shell-script | |
2020 | # sh-indentation: 2 | |
2021 | # eval: (add-hook 'before-save-hook 'time-stamp) | |
2022 | # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" | |
2023 | # time-stamp-time-zone: "UTC" | |
2024 | # End: | |
db137867 | 2025 | |
6f57a957 AC |
2026 | # Set a version string. |
2027 | scriptversion='(GNU libtool) 2.4.6' | |
db137867 | 2028 | |
7083c021 | 2029 | |
6f57a957 AC |
2030 | # func_echo ARG... |
2031 | # ---------------- | |
2032 | # Libtool also displays the current mode in messages, so override | |
2033 | # funclib.sh func_echo with this custom definition. | |
2034 | func_echo () | |
08d019eb | 2035 | { |
6f57a957 | 2036 | $debug_cmd |
08d019eb | 2037 | |
6f57a957 | 2038 | _G_message=$* |
08d019eb | 2039 | |
6f57a957 AC |
2040 | func_echo_IFS=$IFS |
2041 | IFS=$nl | |
2042 | for _G_line in $_G_message; do | |
2043 | IFS=$func_echo_IFS | |
2044 | $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" | |
2045 | done | |
2046 | IFS=$func_echo_IFS | |
2047 | } | |
08d019eb | 2048 | |
6f57a957 AC |
2049 | |
2050 | # func_warning ARG... | |
2051 | # ------------------- | |
2052 | # Libtool warnings are not categorized, so override funclib.sh | |
2053 | # func_warning with this simpler definition. | |
2054 | func_warning () | |
08d019eb | 2055 | { |
6f57a957 | 2056 | $debug_cmd |
08d019eb | 2057 | |
6f57a957 AC |
2058 | $warning_func ${1+"$@"} |
2059 | } | |
08d019eb | 2060 | |
08d019eb | 2061 | |
6f57a957 AC |
2062 | ## ---------------- ## |
2063 | ## Options parsing. ## | |
2064 | ## ---------------- ## | |
2065 | ||
2066 | # Hook in the functions to make sure our own options are parsed during | |
2067 | # the option parsing loop. | |
2068 | ||
2069 | usage='$progpath [OPTION]... [MODE-ARG]...' | |
2070 | ||
2071 | # Short help message in response to '-h'. | |
2072 | usage_message="Options: | |
2073 | --config show all configuration variables | |
2074 | --debug enable verbose shell tracing | |
2075 | -n, --dry-run display commands without modifying any files | |
2076 | --features display basic configuration information and exit | |
2077 | --mode=MODE use operation mode MODE | |
2078 | --no-warnings equivalent to '-Wnone' | |
2079 | --preserve-dup-deps don't remove duplicate dependency libraries | |
2080 | --quiet, --silent don't print informational messages | |
2081 | --tag=TAG use configuration variables from tag TAG | |
2082 | -v, --verbose print more informational messages than default | |
2083 | --version print version information | |
2084 | -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] | |
2085 | -h, --help, --help-all print short, long, or detailed help message | |
2086 | " | |
08d019eb | 2087 | |
6f57a957 AC |
2088 | # Additional text appended to 'usage_message' in response to '--help'. |
2089 | func_help () | |
08d019eb | 2090 | { |
6f57a957 AC |
2091 | $debug_cmd |
2092 | ||
2093 | func_usage_message | |
2094 | $ECHO "$long_help_message | |
2095 | ||
2096 | MODE must be one of the following: | |
2097 | ||
2098 | clean remove files from the build directory | |
2099 | compile compile a source file into a libtool object | |
2100 | execute automatically set library path, then run a program | |
2101 | finish complete the installation of libtool libraries | |
2102 | install install libraries or executables | |
2103 | link create a library or an executable | |
2104 | uninstall remove libraries from an installed directory | |
2105 | ||
2106 | MODE-ARGS vary depending on the MODE. When passed as first option, | |
2107 | '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. | |
2108 | Try '$progname --help --mode=MODE' for a more detailed description of MODE. | |
2109 | ||
2110 | When reporting a bug, please describe a test case to reproduce it and | |
2111 | include the following information: | |
2112 | ||
2113 | host-triplet: $host | |
2114 | shell: $SHELL | |
2115 | compiler: $LTCC | |
2116 | compiler flags: $LTCFLAGS | |
2117 | linker: $LD (gnu? $with_gnu_ld) | |
2118 | version: $progname (GNU libtool) 2.4.6 | |
2119 | automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` | |
2120 | autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` | |
2121 | ||
2122 | Report bugs to <bug-libtool@gnu.org>. | |
2123 | GNU libtool home page: <http://www.gnu.org/software/libtool/>. | |
2124 | General help using GNU software: <http://www.gnu.org/gethelp/>." | |
2125 | exit 0 | |
2126 | } | |
08d019eb AC |
2127 | |
2128 | ||
6f57a957 AC |
2129 | # func_lo2o OBJECT-NAME |
2130 | # --------------------- | |
2131 | # Transform OBJECT-NAME from a '.lo' suffix to the platform specific | |
2132 | # object suffix. | |
2133 | ||
2134 | lo2o=s/\\.lo\$/.$objext/ | |
2135 | o2lo=s/\\.$objext\$/.lo/ | |
2136 | ||
2137 | if test yes = "$_G_HAVE_XSI_OPS"; then | |
2138 | eval 'func_lo2o () | |
2139 | { | |
2140 | case $1 in | |
2141 | *.lo) func_lo2o_result=${1%.lo}.$objext ;; | |
2142 | * ) func_lo2o_result=$1 ;; | |
2143 | esac | |
2144 | }' | |
2145 | ||
2146 | # func_xform LIBOBJ-OR-SOURCE | |
2147 | # --------------------------- | |
2148 | # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) | |
2149 | # suffix to a '.lo' libtool-object suffix. | |
2150 | eval 'func_xform () | |
2151 | { | |
2152 | func_xform_result=${1%.*}.lo | |
2153 | }' | |
2154 | else | |
2155 | # ...otherwise fall back to using sed. | |
2156 | func_lo2o () | |
2157 | { | |
2158 | func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` | |
2159 | } | |
2160 | ||
2161 | func_xform () | |
2162 | { | |
2163 | func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` | |
2164 | } | |
2165 | fi | |
08d019eb AC |
2166 | |
2167 | ||
6f57a957 AC |
2168 | # func_fatal_configuration ARG... |
2169 | # ------------------------------- | |
7083c021 AC |
2170 | # Echo program name prefixed message to standard error, followed by |
2171 | # a configuration failure hint, and exit. | |
2172 | func_fatal_configuration () | |
2173 | { | |
6f57a957 AC |
2174 | func__fatal_error ${1+"$@"} \ |
2175 | "See the $PACKAGE documentation for more information." \ | |
2176 | "Fatal configuration error." | |
7083c021 | 2177 | } |
db137867 | 2178 | |
db137867 | 2179 | |
7083c021 | 2180 | # func_config |
6f57a957 | 2181 | # ----------- |
7083c021 AC |
2182 | # Display the configuration for all the tags in this script. |
2183 | func_config () | |
2184 | { | |
2185 | re_begincf='^# ### BEGIN LIBTOOL' | |
2186 | re_endcf='^# ### END LIBTOOL' | |
2187 | ||
2188 | # Default configuration. | |
2189 | $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" | |
db137867 | 2190 | |
db137867 AC |
2191 | # Now print the configurations for the tags. |
2192 | for tagname in $taglist; do | |
7083c021 | 2193 | $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" |
db137867 | 2194 | done |
db137867 | 2195 | |
7083c021 AC |
2196 | exit $? |
2197 | } | |
db137867 | 2198 | |
6f57a957 | 2199 | |
7083c021 | 2200 | # func_features |
6f57a957 | 2201 | # ------------- |
7083c021 AC |
2202 | # Display the features supported by this script. |
2203 | func_features () | |
2204 | { | |
08d019eb | 2205 | echo "host: $host" |
6f57a957 | 2206 | if test yes = "$build_libtool_libs"; then |
08d019eb | 2207 | echo "enable shared libraries" |
db137867 | 2208 | else |
08d019eb | 2209 | echo "disable shared libraries" |
db137867 | 2210 | fi |
6f57a957 | 2211 | if test yes = "$build_old_libs"; then |
08d019eb | 2212 | echo "enable static libraries" |
db137867 | 2213 | else |
08d019eb | 2214 | echo "disable static libraries" |
db137867 | 2215 | fi |
7083c021 | 2216 | |
db137867 | 2217 | exit $? |
7083c021 | 2218 | } |
db137867 | 2219 | |
6f57a957 AC |
2220 | |
2221 | # func_enable_tag TAGNAME | |
2222 | # ----------------------- | |
7083c021 AC |
2223 | # Verify that TAGNAME is valid, and either flag an error and exit, or |
2224 | # enable the TAGNAME tag. We also add TAGNAME to the global $taglist | |
2225 | # variable here. | |
2226 | func_enable_tag () | |
2227 | { | |
6f57a957 AC |
2228 | # Global variable: |
2229 | tagname=$1 | |
db137867 | 2230 | |
6f57a957 AC |
2231 | re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" |
2232 | re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" | |
2233 | sed_extractcf=/$re_begincf/,/$re_endcf/p | |
db137867 | 2234 | |
6f57a957 AC |
2235 | # Validate tagname. |
2236 | case $tagname in | |
2237 | *[!-_A-Za-z0-9,/]*) | |
2238 | func_fatal_error "invalid tag name: $tagname" | |
2239 | ;; | |
2240 | esac | |
db137867 | 2241 | |
6f57a957 AC |
2242 | # Don't test for the "default" C tag, as we know it's |
2243 | # there but not specially marked. | |
2244 | case $tagname in | |
2245 | CC) ;; | |
7083c021 | 2246 | *) |
6f57a957 AC |
2247 | if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then |
2248 | taglist="$taglist $tagname" | |
2249 | ||
2250 | # Evaluate the configuration. Be careful to quote the path | |
2251 | # and the sed script, to avoid splitting on whitespace, but | |
2252 | # also don't use non-portable quotes within backquotes within | |
2253 | # quotes we have to do it in 2 steps: | |
2254 | extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` | |
2255 | eval "$extractedcf" | |
2256 | else | |
2257 | func_error "ignoring unknown tag $tagname" | |
2258 | fi | |
2259 | ;; | |
2260 | esac | |
7083c021 AC |
2261 | } |
2262 | ||
6f57a957 | 2263 | |
08d019eb | 2264 | # func_check_version_match |
6f57a957 | 2265 | # ------------------------ |
08d019eb AC |
2266 | # Ensure that we are using m4 macros, and libtool script from the same |
2267 | # release of libtool. | |
2268 | func_check_version_match () | |
7083c021 | 2269 | { |
6f57a957 AC |
2270 | if test "$package_revision" != "$macro_revision"; then |
2271 | if test "$VERSION" != "$macro_version"; then | |
2272 | if test -z "$macro_version"; then | |
2273 | cat >&2 <<_LT_EOF | |
08d019eb AC |
2274 | $progname: Version mismatch error. This is $PACKAGE $VERSION, but the |
2275 | $progname: definition of this LT_INIT comes from an older release. | |
2276 | $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION | |
2277 | $progname: and run autoconf again. | |
2278 | _LT_EOF | |
6f57a957 AC |
2279 | else |
2280 | cat >&2 <<_LT_EOF | |
08d019eb AC |
2281 | $progname: Version mismatch error. This is $PACKAGE $VERSION, but the |
2282 | $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. | |
2283 | $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION | |
2284 | $progname: and run autoconf again. | |
2285 | _LT_EOF | |
6f57a957 AC |
2286 | fi |
2287 | else | |
2288 | cat >&2 <<_LT_EOF | |
08d019eb AC |
2289 | $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, |
2290 | $progname: but the definition of this LT_INIT comes from revision $macro_revision. | |
2291 | $progname: You should recreate aclocal.m4 with macros from revision $package_revision | |
2292 | $progname: of $PACKAGE $VERSION and run autoconf again. | |
2293 | _LT_EOF | |
6f57a957 | 2294 | fi |
db137867 | 2295 | |
6f57a957 AC |
2296 | exit $EXIT_MISMATCH |
2297 | fi | |
08d019eb AC |
2298 | } |
2299 | ||
2300 | ||
6f57a957 AC |
2301 | # libtool_options_prep [ARG]... |
2302 | # ----------------------------- | |
2303 | # Preparation for options parsed by libtool. | |
2304 | libtool_options_prep () | |
2305 | { | |
2306 | $debug_mode | |
08d019eb | 2307 | |
6f57a957 AC |
2308 | # Option defaults: |
2309 | opt_config=false | |
2310 | opt_dlopen= | |
2311 | opt_dry_run=false | |
2312 | opt_help=false | |
2313 | opt_mode= | |
2314 | opt_preserve_dup_deps=false | |
2315 | opt_quiet=false | |
08d019eb | 2316 | |
6f57a957 AC |
2317 | nonopt= |
2318 | preserve_args= | |
08d019eb | 2319 | |
6f57a957 AC |
2320 | # Shorthand for --mode=foo, only valid as the first argument |
2321 | case $1 in | |
2322 | clean|clea|cle|cl) | |
2323 | shift; set dummy --mode clean ${1+"$@"}; shift | |
2324 | ;; | |
2325 | compile|compil|compi|comp|com|co|c) | |
2326 | shift; set dummy --mode compile ${1+"$@"}; shift | |
2327 | ;; | |
2328 | execute|execut|execu|exec|exe|ex|e) | |
2329 | shift; set dummy --mode execute ${1+"$@"}; shift | |
2330 | ;; | |
2331 | finish|finis|fini|fin|fi|f) | |
2332 | shift; set dummy --mode finish ${1+"$@"}; shift | |
2333 | ;; | |
2334 | install|instal|insta|inst|ins|in|i) | |
2335 | shift; set dummy --mode install ${1+"$@"}; shift | |
2336 | ;; | |
2337 | link|lin|li|l) | |
2338 | shift; set dummy --mode link ${1+"$@"}; shift | |
2339 | ;; | |
2340 | uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) | |
2341 | shift; set dummy --mode uninstall ${1+"$@"}; shift | |
2342 | ;; | |
2343 | esac | |
2344 | ||
2345 | # Pass back the list of options. | |
2346 | func_quote_for_eval ${1+"$@"} | |
2347 | libtool_options_prep_result=$func_quote_for_eval_result | |
2348 | } | |
2349 | func_add_hook func_options_prep libtool_options_prep | |
db137867 | 2350 | |
08d019eb | 2351 | |
6f57a957 AC |
2352 | # libtool_parse_options [ARG]... |
2353 | # --------------------------------- | |
2354 | # Provide handling for libtool specific options. | |
2355 | libtool_parse_options () | |
08d019eb | 2356 | { |
6f57a957 | 2357 | $debug_cmd |
7083c021 | 2358 | |
6f57a957 AC |
2359 | # Perform our own loop to consume as many options as possible in |
2360 | # each iteration. | |
2361 | while test $# -gt 0; do | |
2362 | _G_opt=$1 | |
2363 | shift | |
2364 | case $_G_opt in | |
2365 | --dry-run|--dryrun|-n) | |
2366 | opt_dry_run=: | |
2367 | ;; | |
2368 | ||
2369 | --config) func_config ;; | |
2370 | ||
2371 | --dlopen|-dlopen) | |
2372 | opt_dlopen="${opt_dlopen+$opt_dlopen | |
2373 | }$1" | |
2374 | shift | |
2375 | ;; | |
2376 | ||
2377 | --preserve-dup-deps) | |
2378 | opt_preserve_dup_deps=: ;; | |
2379 | ||
2380 | --features) func_features ;; | |
2381 | ||
2382 | --finish) set dummy --mode finish ${1+"$@"}; shift ;; | |
2383 | ||
2384 | --help) opt_help=: ;; | |
2385 | ||
2386 | --help-all) opt_help=': help-all' ;; | |
2387 | ||
2388 | --mode) test $# = 0 && func_missing_arg $_G_opt && break | |
2389 | opt_mode=$1 | |
2390 | case $1 in | |
2391 | # Valid mode arguments: | |
2392 | clean|compile|execute|finish|install|link|relink|uninstall) ;; | |
2393 | ||
2394 | # Catch anything else as an error | |
2395 | *) func_error "invalid argument for $_G_opt" | |
2396 | exit_cmd=exit | |
2397 | break | |
2398 | ;; | |
2399 | esac | |
2400 | shift | |
2401 | ;; | |
2402 | ||
2403 | --no-silent|--no-quiet) | |
2404 | opt_quiet=false | |
2405 | func_append preserve_args " $_G_opt" | |
2406 | ;; | |
2407 | ||
2408 | --no-warnings|--no-warning|--no-warn) | |
2409 | opt_warning=false | |
2410 | func_append preserve_args " $_G_opt" | |
2411 | ;; | |
2412 | ||
2413 | --no-verbose) | |
2414 | opt_verbose=false | |
2415 | func_append preserve_args " $_G_opt" | |
2416 | ;; | |
2417 | ||
2418 | --silent|--quiet) | |
2419 | opt_quiet=: | |
2420 | opt_verbose=false | |
2421 | func_append preserve_args " $_G_opt" | |
2422 | ;; | |
2423 | ||
2424 | --tag) test $# = 0 && func_missing_arg $_G_opt && break | |
2425 | opt_tag=$1 | |
2426 | func_append preserve_args " $_G_opt $1" | |
2427 | func_enable_tag "$1" | |
2428 | shift | |
2429 | ;; | |
2430 | ||
2431 | --verbose|-v) opt_quiet=false | |
2432 | opt_verbose=: | |
2433 | func_append preserve_args " $_G_opt" | |
2434 | ;; | |
2435 | ||
2436 | # An option not handled by this hook function: | |
2437 | *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; | |
2438 | esac | |
2439 | done | |
08d019eb | 2440 | |
08d019eb | 2441 | |
6f57a957 AC |
2442 | # save modified positional parameters for caller |
2443 | func_quote_for_eval ${1+"$@"} | |
2444 | libtool_parse_options_result=$func_quote_for_eval_result | |
2445 | } | |
2446 | func_add_hook func_parse_options libtool_parse_options | |
7083c021 | 2447 | |
db137867 | 2448 | |
7083c021 | 2449 | |
6f57a957 AC |
2450 | # libtool_validate_options [ARG]... |
2451 | # --------------------------------- | |
2452 | # Perform any sanity checks on option settings and/or unconsumed | |
2453 | # arguments. | |
2454 | libtool_validate_options () | |
2455 | { | |
2456 | # save first non-option argument | |
2457 | if test 0 -lt $#; then | |
2458 | nonopt=$1 | |
2459 | shift | |
7083c021 AC |
2460 | fi |
2461 | ||
6f57a957 AC |
2462 | # preserve --debug |
2463 | test : = "$debug_cmd" || func_append preserve_args " --debug" | |
7083c021 | 2464 | |
6f57a957 AC |
2465 | case $host in |
2466 | # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 | |
2467 | # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 | |
2468 | *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) | |
2469 | # don't eliminate duplications in $postdeps and $predeps | |
2470 | opt_duplicate_compiler_generated_deps=: | |
2471 | ;; | |
2472 | *) | |
2473 | opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps | |
2474 | ;; | |
2475 | esac | |
db137867 | 2476 | |
6f57a957 AC |
2477 | $opt_help || { |
2478 | # Sanity checks first: | |
2479 | func_check_version_match | |
2480 | ||
2481 | test yes != "$build_libtool_libs" \ | |
2482 | && test yes != "$build_old_libs" \ | |
2483 | && func_fatal_configuration "not configured to build any kind of library" | |
2484 | ||
2485 | # Darwin sucks | |
2486 | eval std_shrext=\"$shrext_cmds\" | |
2487 | ||
2488 | # Only execute mode is allowed to have -dlopen flags. | |
2489 | if test -n "$opt_dlopen" && test execute != "$opt_mode"; then | |
2490 | func_error "unrecognized option '-dlopen'" | |
2491 | $ECHO "$help" 1>&2 | |
2492 | exit $EXIT_FAILURE | |
2493 | fi | |
7083c021 | 2494 | |
6f57a957 AC |
2495 | # Change the help message to a mode-specific one. |
2496 | generic_help=$help | |
2497 | help="Try '$progname --help --mode=$opt_mode' for more information." | |
2498 | } | |
7083c021 | 2499 | |
6f57a957 AC |
2500 | # Pass back the unparsed argument list |
2501 | func_quote_for_eval ${1+"$@"} | |
2502 | libtool_validate_options_result=$func_quote_for_eval_result | |
08d019eb | 2503 | } |
6f57a957 | 2504 | func_add_hook func_validate_options libtool_validate_options |
7083c021 AC |
2505 | |
2506 | ||
6f57a957 AC |
2507 | # Process options as early as possible so that --help and --version |
2508 | # can return quickly. | |
2509 | func_options ${1+"$@"} | |
2510 | eval set dummy "$func_options_result"; shift | |
2511 | ||
db137867 | 2512 | |
db137867 | 2513 | |
08d019eb AC |
2514 | ## ----------- ## |
2515 | ## Main. ## | |
2516 | ## ----------- ## | |
db137867 | 2517 | |
6f57a957 AC |
2518 | magic='%%%MAGIC variable%%%' |
2519 | magic_exe='%%%MAGIC EXE variable%%%' | |
2520 | ||
2521 | # Global variables. | |
2522 | extracted_archives= | |
2523 | extracted_serial=0 | |
2524 | ||
2525 | # If this variable is set in any of the actions, the command in it | |
2526 | # will be execed at the end. This prevents here-documents from being | |
2527 | # left over by shells. | |
2528 | exec_cmd= | |
2529 | ||
2530 | ||
2531 | # A function that is used when there is no print builtin or printf. | |
2532 | func_fallback_echo () | |
2533 | { | |
2534 | eval 'cat <<_LTECHO_EOF | |
2535 | $1 | |
2536 | _LTECHO_EOF' | |
2537 | } | |
2538 | ||
2539 | # func_generated_by_libtool | |
2540 | # True iff stdin has been generated by Libtool. This function is only | |
2541 | # a basic sanity check; it will hardly flush out determined imposters. | |
2542 | func_generated_by_libtool_p () | |
2543 | { | |
2544 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 | |
2545 | } | |
2546 | ||
7083c021 | 2547 | # func_lalib_p file |
6f57a957 | 2548 | # True iff FILE is a libtool '.la' library or '.lo' object file. |
7083c021 AC |
2549 | # This function is only a basic sanity check; it will hardly flush out |
2550 | # determined imposters. | |
2551 | func_lalib_p () | |
2552 | { | |
2553 | test -f "$1" && | |
6f57a957 | 2554 | $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p |
7083c021 | 2555 | } |
db137867 | 2556 | |
7083c021 | 2557 | # func_lalib_unsafe_p file |
6f57a957 | 2558 | # True iff FILE is a libtool '.la' library or '.lo' object file. |
7083c021 AC |
2559 | # This function implements the same check as func_lalib_p without |
2560 | # resorting to external programs. To this end, it redirects stdin and | |
2561 | # closes it afterwards, without saving the original file descriptor. | |
2562 | # As a safety measure, use it only where a negative result would be | |
6f57a957 | 2563 | # fatal anyway. Works if 'file' does not exist. |
7083c021 AC |
2564 | func_lalib_unsafe_p () |
2565 | { | |
2566 | lalib_p=no | |
2567 | if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then | |
2568 | for lalib_p_l in 1 2 3 4 | |
2569 | do | |
2570 | read lalib_p_line | |
6f57a957 | 2571 | case $lalib_p_line in |
7083c021 AC |
2572 | \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; |
2573 | esac | |
2574 | done | |
2575 | exec 0<&5 5<&- | |
2576 | fi | |
6f57a957 | 2577 | test yes = "$lalib_p" |
7083c021 | 2578 | } |
db137867 | 2579 | |
7083c021 AC |
2580 | # func_ltwrapper_script_p file |
2581 | # True iff FILE is a libtool wrapper script | |
2582 | # This function is only a basic sanity check; it will hardly flush out | |
2583 | # determined imposters. | |
2584 | func_ltwrapper_script_p () | |
2585 | { | |
6f57a957 AC |
2586 | test -f "$1" && |
2587 | $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p | |
7083c021 | 2588 | } |
db137867 | 2589 | |
7083c021 AC |
2590 | # func_ltwrapper_executable_p file |
2591 | # True iff FILE is a libtool wrapper executable | |
2592 | # This function is only a basic sanity check; it will hardly flush out | |
2593 | # determined imposters. | |
2594 | func_ltwrapper_executable_p () | |
2595 | { | |
2596 | func_ltwrapper_exec_suffix= | |
2597 | case $1 in | |
2598 | *.exe) ;; | |
2599 | *) func_ltwrapper_exec_suffix=.exe ;; | |
2600 | esac | |
2601 | $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 | |
2602 | } | |
db137867 | 2603 | |
7083c021 AC |
2604 | # func_ltwrapper_scriptname file |
2605 | # Assumes file is an ltwrapper_executable | |
2606 | # uses $file to determine the appropriate filename for a | |
2607 | # temporary ltwrapper_script. | |
2608 | func_ltwrapper_scriptname () | |
2609 | { | |
08d019eb AC |
2610 | func_dirname_and_basename "$1" "" "." |
2611 | func_stripname '' '.exe' "$func_basename_result" | |
6f57a957 | 2612 | func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper |
7083c021 AC |
2613 | } |
2614 | ||
2615 | # func_ltwrapper_p file | |
2616 | # True iff FILE is a libtool wrapper script or wrapper executable | |
2617 | # This function is only a basic sanity check; it will hardly flush out | |
2618 | # determined imposters. | |
2619 | func_ltwrapper_p () | |
2620 | { | |
2621 | func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" | |
2622 | } | |
2623 | ||
2624 | ||
2625 | # func_execute_cmds commands fail_cmd | |
2626 | # Execute tilde-delimited COMMANDS. | |
2627 | # If FAIL_CMD is given, eval that upon failure. | |
2628 | # FAIL_CMD may read-access the current command in variable CMD! | |
2629 | func_execute_cmds () | |
2630 | { | |
6f57a957 AC |
2631 | $debug_cmd |
2632 | ||
7083c021 AC |
2633 | save_ifs=$IFS; IFS='~' |
2634 | for cmd in $1; do | |
6f57a957 | 2635 | IFS=$sp$nl |
7083c021 | 2636 | eval cmd=\"$cmd\" |
6f57a957 | 2637 | IFS=$save_ifs |
7083c021 AC |
2638 | func_show_eval "$cmd" "${2-:}" |
2639 | done | |
2640 | IFS=$save_ifs | |
2641 | } | |
2642 | ||
2643 | ||
2644 | # func_source file | |
2645 | # Source FILE, adding directory component if necessary. | |
2646 | # Note that it is not necessary on cygwin/mingw to append a dot to | |
2647 | # FILE even if both FILE and FILE.exe exist: automatic-append-.exe | |
2648 | # behavior happens only for exec(3), not for open(2)! Also, sourcing | |
6f57a957 | 2649 | # 'FILE.' does not work on cygwin managed mounts. |
7083c021 AC |
2650 | func_source () |
2651 | { | |
6f57a957 AC |
2652 | $debug_cmd |
2653 | ||
7083c021 AC |
2654 | case $1 in |
2655 | */* | *\\*) . "$1" ;; | |
2656 | *) . "./$1" ;; | |
2657 | esac | |
2658 | } | |
2659 | ||
2660 | ||
08d019eb AC |
2661 | # func_resolve_sysroot PATH |
2662 | # Replace a leading = in PATH with a sysroot. Store the result into | |
2663 | # func_resolve_sysroot_result | |
2664 | func_resolve_sysroot () | |
2665 | { | |
2666 | func_resolve_sysroot_result=$1 | |
2667 | case $func_resolve_sysroot_result in | |
2668 | =*) | |
2669 | func_stripname '=' '' "$func_resolve_sysroot_result" | |
2670 | func_resolve_sysroot_result=$lt_sysroot$func_stripname_result | |
2671 | ;; | |
2672 | esac | |
2673 | } | |
2674 | ||
2675 | # func_replace_sysroot PATH | |
2676 | # If PATH begins with the sysroot, replace it with = and | |
2677 | # store the result into func_replace_sysroot_result. | |
2678 | func_replace_sysroot () | |
2679 | { | |
6f57a957 | 2680 | case $lt_sysroot:$1 in |
08d019eb AC |
2681 | ?*:"$lt_sysroot"*) |
2682 | func_stripname "$lt_sysroot" '' "$1" | |
6f57a957 | 2683 | func_replace_sysroot_result='='$func_stripname_result |
08d019eb AC |
2684 | ;; |
2685 | *) | |
2686 | # Including no sysroot. | |
2687 | func_replace_sysroot_result=$1 | |
2688 | ;; | |
2689 | esac | |
2690 | } | |
2691 | ||
7083c021 AC |
2692 | # func_infer_tag arg |
2693 | # Infer tagged configuration to use if any are available and | |
2694 | # if one wasn't chosen via the "--tag" command line option. | |
2695 | # Only attempt this if the compiler in the base compile | |
2696 | # command doesn't match the default compiler. | |
2697 | # arg is usually of the form 'gcc ...' | |
2698 | func_infer_tag () | |
2699 | { | |
6f57a957 AC |
2700 | $debug_cmd |
2701 | ||
7083c021 AC |
2702 | if test -n "$available_tags" && test -z "$tagname"; then |
2703 | CC_quoted= | |
2704 | for arg in $CC; do | |
08d019eb | 2705 | func_append_quoted CC_quoted "$arg" |
7083c021 | 2706 | done |
08d019eb AC |
2707 | CC_expanded=`func_echo_all $CC` |
2708 | CC_quoted_expanded=`func_echo_all $CC_quoted` | |
7083c021 AC |
2709 | case $@ in |
2710 | # Blanks in the command may have been stripped by the calling shell, | |
2711 | # but not from the CC environment variable when configure was run. | |
08d019eb AC |
2712 | " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ |
2713 | " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; | |
7083c021 AC |
2714 | # Blanks at the start of $base_compile will cause this to fail |
2715 | # if we don't check for them as well. | |
2716 | *) | |
2717 | for z in $available_tags; do | |
2718 | if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then | |
2719 | # Evaluate the configuration. | |
6f57a957 | 2720 | eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" |
7083c021 AC |
2721 | CC_quoted= |
2722 | for arg in $CC; do | |
2723 | # Double-quote args containing other shell metacharacters. | |
08d019eb | 2724 | func_append_quoted CC_quoted "$arg" |
7083c021 | 2725 | done |
08d019eb AC |
2726 | CC_expanded=`func_echo_all $CC` |
2727 | CC_quoted_expanded=`func_echo_all $CC_quoted` | |
7083c021 | 2728 | case "$@ " in |
08d019eb AC |
2729 | " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ |
2730 | " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) | |
7083c021 AC |
2731 | # The compiler in the base compile command matches |
2732 | # the one in the tagged configuration. | |
2733 | # Assume this is the tagged configuration we want. | |
2734 | tagname=$z | |
2735 | break | |
2736 | ;; | |
2737 | esac | |
2738 | fi | |
2739 | done | |
2740 | # If $tagname still isn't set, then no tagged configuration | |
2741 | # was found and let the user know that the "--tag" command | |
2742 | # line option must be used. | |
2743 | if test -z "$tagname"; then | |
2744 | func_echo "unable to infer tagged configuration" | |
6f57a957 | 2745 | func_fatal_error "specify a tag with '--tag'" |
7083c021 AC |
2746 | # else |
2747 | # func_verbose "using $tagname tagged configuration" | |
2748 | fi | |
2749 | ;; | |
2750 | esac | |
2751 | fi | |
2752 | } | |
2753 | ||
2754 | ||
2755 | ||
2756 | # func_write_libtool_object output_name pic_name nonpic_name | |
2757 | # Create a libtool object file (analogous to a ".la" file), | |
2758 | # but don't create it if we're doing a dry run. | |
2759 | func_write_libtool_object () | |
2760 | { | |
6f57a957 AC |
2761 | write_libobj=$1 |
2762 | if test yes = "$build_libtool_libs"; then | |
2763 | write_lobj=\'$2\' | |
7083c021 AC |
2764 | else |
2765 | write_lobj=none | |
2766 | fi | |
2767 | ||
6f57a957 AC |
2768 | if test yes = "$build_old_libs"; then |
2769 | write_oldobj=\'$3\' | |
7083c021 AC |
2770 | else |
2771 | write_oldobj=none | |
2772 | fi | |
2773 | ||
2774 | $opt_dry_run || { | |
2775 | cat >${write_libobj}T <<EOF | |
2776 | # $write_libobj - a libtool object file | |
6f57a957 | 2777 | # Generated by $PROGRAM (GNU $PACKAGE) $VERSION |
7083c021 AC |
2778 | # |
2779 | # Please DO NOT delete this file! | |
2780 | # It is necessary for linking the library. | |
2781 | ||
2782 | # Name of the PIC object. | |
2783 | pic_object=$write_lobj | |
2784 | ||
2785 | # Name of the non-PIC object | |
2786 | non_pic_object=$write_oldobj | |
2787 | ||
2788 | EOF | |
6f57a957 | 2789 | $MV "${write_libobj}T" "$write_libobj" |
7083c021 AC |
2790 | } |
2791 | } | |
2792 | ||
08d019eb AC |
2793 | |
2794 | ################################################## | |
2795 | # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # | |
2796 | ################################################## | |
2797 | ||
2798 | # func_convert_core_file_wine_to_w32 ARG | |
2799 | # Helper function used by file name conversion functions when $build is *nix, | |
2800 | # and $host is mingw, cygwin, or some other w32 environment. Relies on a | |
2801 | # correctly configured wine environment available, with the winepath program | |
2802 | # in $build's $PATH. | |
2803 | # | |
2804 | # ARG is the $build file name to be converted to w32 format. | |
2805 | # Result is available in $func_convert_core_file_wine_to_w32_result, and will | |
2806 | # be empty on error (or when ARG is empty) | |
2807 | func_convert_core_file_wine_to_w32 () | |
2808 | { | |
6f57a957 AC |
2809 | $debug_cmd |
2810 | ||
2811 | func_convert_core_file_wine_to_w32_result=$1 | |
08d019eb AC |
2812 | if test -n "$1"; then |
2813 | # Unfortunately, winepath does not exit with a non-zero error code, so we | |
2814 | # are forced to check the contents of stdout. On the other hand, if the | |
2815 | # command is not found, the shell will set an exit code of 127 and print | |
2816 | # *an error message* to stdout. So we must check for both error code of | |
2817 | # zero AND non-empty stdout, which explains the odd construction: | |
2818 | func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` | |
6f57a957 | 2819 | if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then |
08d019eb | 2820 | func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | |
6f57a957 | 2821 | $SED -e "$sed_naive_backslashify"` |
08d019eb AC |
2822 | else |
2823 | func_convert_core_file_wine_to_w32_result= | |
2824 | fi | |
2825 | fi | |
2826 | } | |
2827 | # end: func_convert_core_file_wine_to_w32 | |
2828 | ||
2829 | ||
2830 | # func_convert_core_path_wine_to_w32 ARG | |
2831 | # Helper function used by path conversion functions when $build is *nix, and | |
2832 | # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly | |
2833 | # configured wine environment available, with the winepath program in $build's | |
2834 | # $PATH. Assumes ARG has no leading or trailing path separator characters. | |
2835 | # | |
2836 | # ARG is path to be converted from $build format to win32. | |
2837 | # Result is available in $func_convert_core_path_wine_to_w32_result. | |
2838 | # Unconvertible file (directory) names in ARG are skipped; if no directory names | |
2839 | # are convertible, then the result may be empty. | |
2840 | func_convert_core_path_wine_to_w32 () | |
2841 | { | |
6f57a957 AC |
2842 | $debug_cmd |
2843 | ||
08d019eb | 2844 | # unfortunately, winepath doesn't convert paths, only file names |
6f57a957 | 2845 | func_convert_core_path_wine_to_w32_result= |
08d019eb AC |
2846 | if test -n "$1"; then |
2847 | oldIFS=$IFS | |
2848 | IFS=: | |
2849 | for func_convert_core_path_wine_to_w32_f in $1; do | |
2850 | IFS=$oldIFS | |
2851 | func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" | |
6f57a957 | 2852 | if test -n "$func_convert_core_file_wine_to_w32_result"; then |
08d019eb | 2853 | if test -z "$func_convert_core_path_wine_to_w32_result"; then |
6f57a957 | 2854 | func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result |
08d019eb AC |
2855 | else |
2856 | func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" | |
2857 | fi | |
2858 | fi | |
2859 | done | |
2860 | IFS=$oldIFS | |
2861 | fi | |
2862 | } | |
2863 | # end: func_convert_core_path_wine_to_w32 | |
2864 | ||
2865 | ||
2866 | # func_cygpath ARGS... | |
2867 | # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when | |
2868 | # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) | |
2869 | # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or | |
2870 | # (2), returns the Cygwin file name or path in func_cygpath_result (input | |
2871 | # file name or path is assumed to be in w32 format, as previously converted | |
2872 | # from $build's *nix or MSYS format). In case (3), returns the w32 file name | |
2873 | # or path in func_cygpath_result (input file name or path is assumed to be in | |
2874 | # Cygwin format). Returns an empty string on error. | |
2875 | # | |
2876 | # ARGS are passed to cygpath, with the last one being the file name or path to | |
2877 | # be converted. | |
2878 | # | |
2879 | # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH | |
2880 | # environment variable; do not put it in $PATH. | |
2881 | func_cygpath () | |
2882 | { | |
6f57a957 AC |
2883 | $debug_cmd |
2884 | ||
08d019eb AC |
2885 | if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then |
2886 | func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` | |
2887 | if test "$?" -ne 0; then | |
2888 | # on failure, ensure result is empty | |
2889 | func_cygpath_result= | |
2890 | fi | |
2891 | else | |
2892 | func_cygpath_result= | |
6f57a957 | 2893 | func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" |
08d019eb AC |
2894 | fi |
2895 | } | |
2896 | #end: func_cygpath | |
2897 | ||
2898 | ||
2899 | # func_convert_core_msys_to_w32 ARG | |
2900 | # Convert file name or path ARG from MSYS format to w32 format. Return | |
2901 | # result in func_convert_core_msys_to_w32_result. | |
2902 | func_convert_core_msys_to_w32 () | |
2903 | { | |
6f57a957 AC |
2904 | $debug_cmd |
2905 | ||
08d019eb AC |
2906 | # awkward: cmd appends spaces to result |
2907 | func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | | |
6f57a957 | 2908 | $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` |
08d019eb AC |
2909 | } |
2910 | #end: func_convert_core_msys_to_w32 | |
2911 | ||
2912 | ||
2913 | # func_convert_file_check ARG1 ARG2 | |
2914 | # Verify that ARG1 (a file name in $build format) was converted to $host | |
2915 | # format in ARG2. Otherwise, emit an error message, but continue (resetting | |
2916 | # func_to_host_file_result to ARG1). | |
2917 | func_convert_file_check () | |
2918 | { | |
6f57a957 AC |
2919 | $debug_cmd |
2920 | ||
2921 | if test -z "$2" && test -n "$1"; then | |
08d019eb | 2922 | func_error "Could not determine host file name corresponding to" |
6f57a957 | 2923 | func_error " '$1'" |
08d019eb AC |
2924 | func_error "Continuing, but uninstalled executables may not work." |
2925 | # Fallback: | |
6f57a957 | 2926 | func_to_host_file_result=$1 |
08d019eb AC |
2927 | fi |
2928 | } | |
2929 | # end func_convert_file_check | |
2930 | ||
2931 | ||
2932 | # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH | |
2933 | # Verify that FROM_PATH (a path in $build format) was converted to $host | |
2934 | # format in TO_PATH. Otherwise, emit an error message, but continue, resetting | |
2935 | # func_to_host_file_result to a simplistic fallback value (see below). | |
2936 | func_convert_path_check () | |
2937 | { | |
6f57a957 AC |
2938 | $debug_cmd |
2939 | ||
08d019eb AC |
2940 | if test -z "$4" && test -n "$3"; then |
2941 | func_error "Could not determine the host path corresponding to" | |
6f57a957 | 2942 | func_error " '$3'" |
08d019eb AC |
2943 | func_error "Continuing, but uninstalled executables may not work." |
2944 | # Fallback. This is a deliberately simplistic "conversion" and | |
2945 | # should not be "improved". See libtool.info. | |
2946 | if test "x$1" != "x$2"; then | |
2947 | lt_replace_pathsep_chars="s|$1|$2|g" | |
2948 | func_to_host_path_result=`echo "$3" | | |
2949 | $SED -e "$lt_replace_pathsep_chars"` | |
2950 | else | |
6f57a957 | 2951 | func_to_host_path_result=$3 |
08d019eb AC |
2952 | fi |
2953 | fi | |
2954 | } | |
2955 | # end func_convert_path_check | |
2956 | ||
2957 | ||
2958 | # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG | |
2959 | # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT | |
2960 | # and appending REPL if ORIG matches BACKPAT. | |
2961 | func_convert_path_front_back_pathsep () | |
2962 | { | |
6f57a957 AC |
2963 | $debug_cmd |
2964 | ||
08d019eb | 2965 | case $4 in |
6f57a957 | 2966 | $1 ) func_to_host_path_result=$3$func_to_host_path_result |
08d019eb AC |
2967 | ;; |
2968 | esac | |
2969 | case $4 in | |
2970 | $2 ) func_append func_to_host_path_result "$3" | |
2971 | ;; | |
2972 | esac | |
2973 | } | |
2974 | # end func_convert_path_front_back_pathsep | |
2975 | ||
2976 | ||
2977 | ################################################## | |
2978 | # $build to $host FILE NAME CONVERSION FUNCTIONS # | |
2979 | ################################################## | |
6f57a957 | 2980 | # invoked via '$to_host_file_cmd ARG' |
08d019eb AC |
2981 | # |
2982 | # In each case, ARG is the path to be converted from $build to $host format. | |
2983 | # Result will be available in $func_to_host_file_result. | |
2984 | ||
2985 | ||
2986 | # func_to_host_file ARG | |
2987 | # Converts the file name ARG from $build format to $host format. Return result | |
2988 | # in func_to_host_file_result. | |
2989 | func_to_host_file () | |
2990 | { | |
6f57a957 AC |
2991 | $debug_cmd |
2992 | ||
08d019eb AC |
2993 | $to_host_file_cmd "$1" |
2994 | } | |
2995 | # end func_to_host_file | |
2996 | ||
2997 | ||
2998 | # func_to_tool_file ARG LAZY | |
2999 | # converts the file name ARG from $build format to toolchain format. Return | |
3000 | # result in func_to_tool_file_result. If the conversion in use is listed | |
3001 | # in (the comma separated) LAZY, no conversion takes place. | |
3002 | func_to_tool_file () | |
3003 | { | |
6f57a957 AC |
3004 | $debug_cmd |
3005 | ||
08d019eb AC |
3006 | case ,$2, in |
3007 | *,"$to_tool_file_cmd",*) | |
3008 | func_to_tool_file_result=$1 | |
3009 | ;; | |
3010 | *) | |
3011 | $to_tool_file_cmd "$1" | |
3012 | func_to_tool_file_result=$func_to_host_file_result | |
3013 | ;; | |
3014 | esac | |
3015 | } | |
3016 | # end func_to_tool_file | |
3017 | ||
3018 | ||
3019 | # func_convert_file_noop ARG | |
3020 | # Copy ARG to func_to_host_file_result. | |
3021 | func_convert_file_noop () | |
3022 | { | |
6f57a957 | 3023 | func_to_host_file_result=$1 |
08d019eb AC |
3024 | } |
3025 | # end func_convert_file_noop | |
3026 | ||
3027 | ||
3028 | # func_convert_file_msys_to_w32 ARG | |
3029 | # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic | |
3030 | # conversion to w32 is not available inside the cwrapper. Returns result in | |
3031 | # func_to_host_file_result. | |
3032 | func_convert_file_msys_to_w32 () | |
3033 | { | |
6f57a957 AC |
3034 | $debug_cmd |
3035 | ||
3036 | func_to_host_file_result=$1 | |
08d019eb AC |
3037 | if test -n "$1"; then |
3038 | func_convert_core_msys_to_w32 "$1" | |
6f57a957 | 3039 | func_to_host_file_result=$func_convert_core_msys_to_w32_result |
08d019eb AC |
3040 | fi |
3041 | func_convert_file_check "$1" "$func_to_host_file_result" | |
3042 | } | |
3043 | # end func_convert_file_msys_to_w32 | |
3044 | ||
3045 | ||
3046 | # func_convert_file_cygwin_to_w32 ARG | |
3047 | # Convert file name ARG from Cygwin to w32 format. Returns result in | |
3048 | # func_to_host_file_result. | |
3049 | func_convert_file_cygwin_to_w32 () | |
3050 | { | |
6f57a957 AC |
3051 | $debug_cmd |
3052 | ||
3053 | func_to_host_file_result=$1 | |
08d019eb AC |
3054 | if test -n "$1"; then |
3055 | # because $build is cygwin, we call "the" cygpath in $PATH; no need to use | |
3056 | # LT_CYGPATH in this case. | |
3057 | func_to_host_file_result=`cygpath -m "$1"` | |
3058 | fi | |
3059 | func_convert_file_check "$1" "$func_to_host_file_result" | |
3060 | } | |
3061 | # end func_convert_file_cygwin_to_w32 | |
3062 | ||
3063 | ||
3064 | # func_convert_file_nix_to_w32 ARG | |
3065 | # Convert file name ARG from *nix to w32 format. Requires a wine environment | |
3066 | # and a working winepath. Returns result in func_to_host_file_result. | |
3067 | func_convert_file_nix_to_w32 () | |
3068 | { | |
6f57a957 AC |
3069 | $debug_cmd |
3070 | ||
3071 | func_to_host_file_result=$1 | |
08d019eb AC |
3072 | if test -n "$1"; then |
3073 | func_convert_core_file_wine_to_w32 "$1" | |
6f57a957 | 3074 | func_to_host_file_result=$func_convert_core_file_wine_to_w32_result |
08d019eb AC |
3075 | fi |
3076 | func_convert_file_check "$1" "$func_to_host_file_result" | |
3077 | } | |
3078 | # end func_convert_file_nix_to_w32 | |
3079 | ||
3080 | ||
3081 | # func_convert_file_msys_to_cygwin ARG | |
3082 | # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. | |
3083 | # Returns result in func_to_host_file_result. | |
3084 | func_convert_file_msys_to_cygwin () | |
3085 | { | |
6f57a957 AC |
3086 | $debug_cmd |
3087 | ||
3088 | func_to_host_file_result=$1 | |
08d019eb AC |
3089 | if test -n "$1"; then |
3090 | func_convert_core_msys_to_w32 "$1" | |
3091 | func_cygpath -u "$func_convert_core_msys_to_w32_result" | |
6f57a957 | 3092 | func_to_host_file_result=$func_cygpath_result |
08d019eb AC |
3093 | fi |
3094 | func_convert_file_check "$1" "$func_to_host_file_result" | |
3095 | } | |
3096 | # end func_convert_file_msys_to_cygwin | |
3097 | ||
3098 | ||
3099 | # func_convert_file_nix_to_cygwin ARG | |
3100 | # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed | |
3101 | # in a wine environment, working winepath, and LT_CYGPATH set. Returns result | |
3102 | # in func_to_host_file_result. | |
3103 | func_convert_file_nix_to_cygwin () | |
3104 | { | |
6f57a957 AC |
3105 | $debug_cmd |
3106 | ||
3107 | func_to_host_file_result=$1 | |
08d019eb AC |
3108 | if test -n "$1"; then |
3109 | # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. | |
3110 | func_convert_core_file_wine_to_w32 "$1" | |
3111 | func_cygpath -u "$func_convert_core_file_wine_to_w32_result" | |
6f57a957 | 3112 | func_to_host_file_result=$func_cygpath_result |
08d019eb AC |
3113 | fi |
3114 | func_convert_file_check "$1" "$func_to_host_file_result" | |
3115 | } | |
3116 | # end func_convert_file_nix_to_cygwin | |
3117 | ||
3118 | ||
3119 | ############################################# | |
3120 | # $build to $host PATH CONVERSION FUNCTIONS # | |
3121 | ############################################# | |
6f57a957 | 3122 | # invoked via '$to_host_path_cmd ARG' |
08d019eb AC |
3123 | # |
3124 | # In each case, ARG is the path to be converted from $build to $host format. | |
3125 | # The result will be available in $func_to_host_path_result. | |
3126 | # | |
3127 | # Path separators are also converted from $build format to $host format. If | |
3128 | # ARG begins or ends with a path separator character, it is preserved (but | |
3129 | # converted to $host format) on output. | |
3130 | # | |
3131 | # All path conversion functions are named using the following convention: | |
3132 | # file name conversion function : func_convert_file_X_to_Y () | |
3133 | # path conversion function : func_convert_path_X_to_Y () | |
3134 | # where, for any given $build/$host combination the 'X_to_Y' value is the | |
3135 | # same. If conversion functions are added for new $build/$host combinations, | |
3136 | # the two new functions must follow this pattern, or func_init_to_host_path_cmd | |
3137 | # will break. | |
3138 | ||
3139 | ||
3140 | # func_init_to_host_path_cmd | |
3141 | # Ensures that function "pointer" variable $to_host_path_cmd is set to the | |
3142 | # appropriate value, based on the value of $to_host_file_cmd. | |
3143 | to_host_path_cmd= | |
3144 | func_init_to_host_path_cmd () | |
3145 | { | |
6f57a957 AC |
3146 | $debug_cmd |
3147 | ||
08d019eb AC |
3148 | if test -z "$to_host_path_cmd"; then |
3149 | func_stripname 'func_convert_file_' '' "$to_host_file_cmd" | |
6f57a957 | 3150 | to_host_path_cmd=func_convert_path_$func_stripname_result |
08d019eb AC |
3151 | fi |
3152 | } | |
3153 | ||
3154 | ||
3155 | # func_to_host_path ARG | |
3156 | # Converts the path ARG from $build format to $host format. Return result | |
3157 | # in func_to_host_path_result. | |
3158 | func_to_host_path () | |
3159 | { | |
6f57a957 AC |
3160 | $debug_cmd |
3161 | ||
08d019eb AC |
3162 | func_init_to_host_path_cmd |
3163 | $to_host_path_cmd "$1" | |
3164 | } | |
3165 | # end func_to_host_path | |
3166 | ||
3167 | ||
3168 | # func_convert_path_noop ARG | |
3169 | # Copy ARG to func_to_host_path_result. | |
3170 | func_convert_path_noop () | |
3171 | { | |
6f57a957 | 3172 | func_to_host_path_result=$1 |
08d019eb AC |
3173 | } |
3174 | # end func_convert_path_noop | |
3175 | ||
3176 | ||
3177 | # func_convert_path_msys_to_w32 ARG | |
3178 | # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic | |
3179 | # conversion to w32 is not available inside the cwrapper. Returns result in | |
3180 | # func_to_host_path_result. | |
3181 | func_convert_path_msys_to_w32 () | |
3182 | { | |
6f57a957 AC |
3183 | $debug_cmd |
3184 | ||
3185 | func_to_host_path_result=$1 | |
08d019eb AC |
3186 | if test -n "$1"; then |
3187 | # Remove leading and trailing path separator characters from ARG. MSYS | |
3188 | # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; | |
3189 | # and winepath ignores them completely. | |
3190 | func_stripname : : "$1" | |
3191 | func_to_host_path_tmp1=$func_stripname_result | |
3192 | func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" | |
6f57a957 | 3193 | func_to_host_path_result=$func_convert_core_msys_to_w32_result |
08d019eb AC |
3194 | func_convert_path_check : ";" \ |
3195 | "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
3196 | func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" | |
3197 | fi | |
3198 | } | |
3199 | # end func_convert_path_msys_to_w32 | |
3200 | ||
3201 | ||
3202 | # func_convert_path_cygwin_to_w32 ARG | |
3203 | # Convert path ARG from Cygwin to w32 format. Returns result in | |
3204 | # func_to_host_file_result. | |
3205 | func_convert_path_cygwin_to_w32 () | |
3206 | { | |
6f57a957 AC |
3207 | $debug_cmd |
3208 | ||
3209 | func_to_host_path_result=$1 | |
08d019eb AC |
3210 | if test -n "$1"; then |
3211 | # See func_convert_path_msys_to_w32: | |
3212 | func_stripname : : "$1" | |
3213 | func_to_host_path_tmp1=$func_stripname_result | |
3214 | func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` | |
3215 | func_convert_path_check : ";" \ | |
3216 | "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
3217 | func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" | |
3218 | fi | |
3219 | } | |
3220 | # end func_convert_path_cygwin_to_w32 | |
3221 | ||
3222 | ||
3223 | # func_convert_path_nix_to_w32 ARG | |
3224 | # Convert path ARG from *nix to w32 format. Requires a wine environment and | |
3225 | # a working winepath. Returns result in func_to_host_file_result. | |
3226 | func_convert_path_nix_to_w32 () | |
3227 | { | |
6f57a957 AC |
3228 | $debug_cmd |
3229 | ||
3230 | func_to_host_path_result=$1 | |
08d019eb AC |
3231 | if test -n "$1"; then |
3232 | # See func_convert_path_msys_to_w32: | |
3233 | func_stripname : : "$1" | |
3234 | func_to_host_path_tmp1=$func_stripname_result | |
3235 | func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" | |
6f57a957 | 3236 | func_to_host_path_result=$func_convert_core_path_wine_to_w32_result |
08d019eb AC |
3237 | func_convert_path_check : ";" \ |
3238 | "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
3239 | func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" | |
3240 | fi | |
3241 | } | |
3242 | # end func_convert_path_nix_to_w32 | |
3243 | ||
3244 | ||
3245 | # func_convert_path_msys_to_cygwin ARG | |
3246 | # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. | |
3247 | # Returns result in func_to_host_file_result. | |
3248 | func_convert_path_msys_to_cygwin () | |
3249 | { | |
6f57a957 AC |
3250 | $debug_cmd |
3251 | ||
3252 | func_to_host_path_result=$1 | |
08d019eb AC |
3253 | if test -n "$1"; then |
3254 | # See func_convert_path_msys_to_w32: | |
3255 | func_stripname : : "$1" | |
3256 | func_to_host_path_tmp1=$func_stripname_result | |
3257 | func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" | |
3258 | func_cygpath -u -p "$func_convert_core_msys_to_w32_result" | |
6f57a957 | 3259 | func_to_host_path_result=$func_cygpath_result |
08d019eb AC |
3260 | func_convert_path_check : : \ |
3261 | "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
3262 | func_convert_path_front_back_pathsep ":*" "*:" : "$1" | |
3263 | fi | |
3264 | } | |
3265 | # end func_convert_path_msys_to_cygwin | |
3266 | ||
3267 | ||
3268 | # func_convert_path_nix_to_cygwin ARG | |
3269 | # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a | |
3270 | # a wine environment, working winepath, and LT_CYGPATH set. Returns result in | |
3271 | # func_to_host_file_result. | |
3272 | func_convert_path_nix_to_cygwin () | |
3273 | { | |
6f57a957 AC |
3274 | $debug_cmd |
3275 | ||
3276 | func_to_host_path_result=$1 | |
08d019eb AC |
3277 | if test -n "$1"; then |
3278 | # Remove leading and trailing path separator characters from | |
3279 | # ARG. msys behavior is inconsistent here, cygpath turns them | |
3280 | # into '.;' and ';.', and winepath ignores them completely. | |
3281 | func_stripname : : "$1" | |
3282 | func_to_host_path_tmp1=$func_stripname_result | |
3283 | func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" | |
3284 | func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" | |
6f57a957 | 3285 | func_to_host_path_result=$func_cygpath_result |
08d019eb AC |
3286 | func_convert_path_check : : \ |
3287 | "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
3288 | func_convert_path_front_back_pathsep ":*" "*:" : "$1" | |
3289 | fi | |
3290 | } | |
3291 | # end func_convert_path_nix_to_cygwin | |
3292 | ||
3293 | ||
6f57a957 AC |
3294 | # func_dll_def_p FILE |
3295 | # True iff FILE is a Windows DLL '.def' file. | |
3296 | # Keep in sync with _LT_DLL_DEF_P in libtool.m4 | |
3297 | func_dll_def_p () | |
3298 | { | |
3299 | $debug_cmd | |
3300 | ||
3301 | func_dll_def_p_tmp=`$SED -n \ | |
3302 | -e 's/^[ ]*//' \ | |
3303 | -e '/^\(;.*\)*$/d' \ | |
3304 | -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ | |
3305 | -e q \ | |
3306 | "$1"` | |
3307 | test DEF = "$func_dll_def_p_tmp" | |
3308 | } | |
3309 | ||
3310 | ||
7083c021 AC |
3311 | # func_mode_compile arg... |
3312 | func_mode_compile () | |
3313 | { | |
6f57a957 AC |
3314 | $debug_cmd |
3315 | ||
7083c021 AC |
3316 | # Get the compilation command and the source file. |
3317 | base_compile= | |
6f57a957 | 3318 | srcfile=$nonopt # always keep a non-empty value in "srcfile" |
7083c021 AC |
3319 | suppress_opt=yes |
3320 | suppress_output= | |
3321 | arg_mode=normal | |
3322 | libobj= | |
3323 | later= | |
3324 | pie_flag= | |
3325 | ||
3326 | for arg | |
3327 | do | |
3328 | case $arg_mode in | |
3329 | arg ) | |
3330 | # do not "continue". Instead, add this to base_compile | |
6f57a957 | 3331 | lastarg=$arg |
7083c021 AC |
3332 | arg_mode=normal |
3333 | ;; | |
3334 | ||
3335 | target ) | |
6f57a957 | 3336 | libobj=$arg |
7083c021 AC |
3337 | arg_mode=normal |
3338 | continue | |
3339 | ;; | |
3340 | ||
3341 | normal ) | |
3342 | # Accept any command-line options. | |
3343 | case $arg in | |
3344 | -o) | |
3345 | test -n "$libobj" && \ | |
6f57a957 | 3346 | func_fatal_error "you cannot specify '-o' more than once" |
7083c021 AC |
3347 | arg_mode=target |
3348 | continue | |
3349 | ;; | |
3350 | ||
3351 | -pie | -fpie | -fPIE) | |
08d019eb | 3352 | func_append pie_flag " $arg" |
7083c021 AC |
3353 | continue |
3354 | ;; | |
3355 | ||
3356 | -shared | -static | -prefer-pic | -prefer-non-pic) | |
08d019eb | 3357 | func_append later " $arg" |
7083c021 AC |
3358 | continue |
3359 | ;; | |
3360 | ||
3361 | -no-suppress) | |
db137867 AC |
3362 | suppress_opt=no |
3363 | continue | |
3364 | ;; | |
3365 | ||
3366 | -Xcompiler) | |
3367 | arg_mode=arg # the next one goes into the "base_compile" arg list | |
3368 | continue # The current "srcfile" will either be retained or | |
3369 | ;; # replaced later. I would guess that would be a bug. | |
3370 | ||
3371 | -Wc,*) | |
7083c021 AC |
3372 | func_stripname '-Wc,' '' "$arg" |
3373 | args=$func_stripname_result | |
db137867 | 3374 | lastarg= |
6f57a957 | 3375 | save_ifs=$IFS; IFS=, |
7083c021 | 3376 | for arg in $args; do |
6f57a957 | 3377 | IFS=$save_ifs |
08d019eb | 3378 | func_append_quoted lastarg "$arg" |
db137867 | 3379 | done |
6f57a957 | 3380 | IFS=$save_ifs |
7083c021 AC |
3381 | func_stripname ' ' '' "$lastarg" |
3382 | lastarg=$func_stripname_result | |
db137867 AC |
3383 | |
3384 | # Add the arguments to base_compile. | |
08d019eb | 3385 | func_append base_compile " $lastarg" |
db137867 AC |
3386 | continue |
3387 | ;; | |
3388 | ||
7083c021 | 3389 | *) |
db137867 AC |
3390 | # Accept the current argument as the source file. |
3391 | # The previous "srcfile" becomes the current argument. | |
3392 | # | |
6f57a957 AC |
3393 | lastarg=$srcfile |
3394 | srcfile=$arg | |
db137867 AC |
3395 | ;; |
3396 | esac # case $arg | |
3397 | ;; | |
3398 | esac # case $arg_mode | |
3399 | ||
3400 | # Aesthetically quote the previous argument. | |
08d019eb | 3401 | func_append_quoted base_compile "$lastarg" |
db137867 AC |
3402 | done # for arg |
3403 | ||
3404 | case $arg_mode in | |
3405 | arg) | |
7083c021 | 3406 | func_fatal_error "you must specify an argument for -Xcompile" |
db137867 AC |
3407 | ;; |
3408 | target) | |
6f57a957 | 3409 | func_fatal_error "you must specify a target with '-o'" |
db137867 AC |
3410 | ;; |
3411 | *) | |
3412 | # Get the name of the library object. | |
7083c021 AC |
3413 | test -z "$libobj" && { |
3414 | func_basename "$srcfile" | |
6f57a957 | 3415 | libobj=$func_basename_result |
7083c021 | 3416 | } |
db137867 AC |
3417 | ;; |
3418 | esac | |
3419 | ||
3420 | # Recognize several different file suffixes. | |
3421 | # If the user specifies -o file.o, it is replaced with file.lo | |
db137867 | 3422 | case $libobj in |
7083c021 AC |
3423 | *.[cCFSifmso] | \ |
3424 | *.ada | *.adb | *.ads | *.asm | \ | |
3425 | *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ | |
54bec06e | 3426 | *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) |
7083c021 AC |
3427 | func_xform "$libobj" |
3428 | libobj=$func_xform_result | |
3429 | ;; | |
db137867 AC |
3430 | esac |
3431 | ||
db137867 | 3432 | case $libobj in |
7083c021 | 3433 | *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; |
db137867 | 3434 | *) |
6f57a957 | 3435 | func_fatal_error "cannot determine name of library object from '$libobj'" |
db137867 AC |
3436 | ;; |
3437 | esac | |
3438 | ||
3439 | func_infer_tag $base_compile | |
3440 | ||
3441 | for arg in $later; do | |
3442 | case $arg in | |
7083c021 | 3443 | -shared) |
6f57a957 AC |
3444 | test yes = "$build_libtool_libs" \ |
3445 | || func_fatal_configuration "cannot build a shared library" | |
7083c021 AC |
3446 | build_old_libs=no |
3447 | continue | |
3448 | ;; | |
3449 | ||
db137867 | 3450 | -static) |
7083c021 | 3451 | build_libtool_libs=no |
db137867 AC |
3452 | build_old_libs=yes |
3453 | continue | |
3454 | ;; | |
3455 | ||
3456 | -prefer-pic) | |
3457 | pic_mode=yes | |
3458 | continue | |
3459 | ;; | |
3460 | ||
3461 | -prefer-non-pic) | |
3462 | pic_mode=no | |
3463 | continue | |
3464 | ;; | |
3465 | esac | |
3466 | done | |
3467 | ||
7083c021 AC |
3468 | func_quote_for_eval "$libobj" |
3469 | test "X$libobj" != "X$func_quote_for_eval_result" \ | |
3470 | && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ | |
6f57a957 | 3471 | && func_warning "libobj name '$libobj' may not contain shell special characters." |
7083c021 | 3472 | func_dirname_and_basename "$obj" "/" "" |
6f57a957 AC |
3473 | objname=$func_basename_result |
3474 | xdir=$func_dirname_result | |
3475 | lobj=$xdir$objdir/$objname | |
db137867 | 3476 | |
7083c021 AC |
3477 | test -z "$base_compile" && \ |
3478 | func_fatal_help "you must specify a compilation command" | |
db137867 AC |
3479 | |
3480 | # Delete any leftover library objects. | |
6f57a957 | 3481 | if test yes = "$build_old_libs"; then |
db137867 AC |
3482 | removelist="$obj $lobj $libobj ${libobj}T" |
3483 | else | |
3484 | removelist="$lobj $libobj ${libobj}T" | |
3485 | fi | |
3486 | ||
db137867 AC |
3487 | # On Cygwin there's no "real" PIC flag so we must build both object types |
3488 | case $host_os in | |
7083c021 | 3489 | cygwin* | mingw* | pw32* | os2* | cegcc*) |
db137867 AC |
3490 | pic_mode=default |
3491 | ;; | |
3492 | esac | |
6f57a957 | 3493 | if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then |
db137867 AC |
3494 | # non-PIC code in shared libraries is not supported |
3495 | pic_mode=default | |
3496 | fi | |
3497 | ||
3498 | # Calculate the filename of the output object if compiler does | |
3499 | # not support -o with -c | |
6f57a957 AC |
3500 | if test no = "$compiler_c_o"; then |
3501 | output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext | |
3502 | lockfile=$output_obj.lock | |
db137867 AC |
3503 | else |
3504 | output_obj= | |
3505 | need_locks=no | |
3506 | lockfile= | |
3507 | fi | |
3508 | ||
3509 | # Lock this critical section if it is needed | |
3510 | # We use this script file to make the link, it avoids creating a new file | |
6f57a957 | 3511 | if test yes = "$need_locks"; then |
7083c021 AC |
3512 | until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do |
3513 | func_echo "Waiting for $lockfile to be removed" | |
db137867 AC |
3514 | sleep 2 |
3515 | done | |
6f57a957 | 3516 | elif test warn = "$need_locks"; then |
db137867 | 3517 | if test -f "$lockfile"; then |
7083c021 | 3518 | $ECHO "\ |
db137867 AC |
3519 | *** ERROR, $lockfile exists and contains: |
3520 | `cat $lockfile 2>/dev/null` | |
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 | |
6f57a957 | 3524 | your compiler does not support '-c' and '-o' together. If you |
db137867 AC |
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 | ||
7083c021 | 3529 | $opt_dry_run || $RM $removelist |
db137867 AC |
3530 | exit $EXIT_FAILURE |
3531 | fi | |
08d019eb | 3532 | func_append removelist " $output_obj" |
7083c021 | 3533 | $ECHO "$srcfile" > "$lockfile" |
db137867 AC |
3534 | fi |
3535 | ||
7083c021 | 3536 | $opt_dry_run || $RM $removelist |
08d019eb | 3537 | func_append removelist " $lockfile" |
7083c021 AC |
3538 | trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 |
3539 | ||
08d019eb AC |
3540 | func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 |
3541 | srcfile=$func_to_tool_file_result | |
7083c021 AC |
3542 | func_quote_for_eval "$srcfile" |
3543 | qsrcfile=$func_quote_for_eval_result | |
db137867 AC |
3544 | |
3545 | # Only build a PIC object if we are building libtool libraries. | |
6f57a957 | 3546 | if test yes = "$build_libtool_libs"; then |
db137867 AC |
3547 | # Without this assignment, base_compile gets emptied. |
3548 | fbsd_hideous_sh_bug=$base_compile | |
3549 | ||
6f57a957 | 3550 | if test no != "$pic_mode"; then |
db137867 AC |
3551 | command="$base_compile $qsrcfile $pic_flag" |
3552 | else | |
3553 | # Don't build PIC code | |
3554 | command="$base_compile $qsrcfile" | |
3555 | fi | |
3556 | ||
7083c021 | 3557 | func_mkdir_p "$xdir$objdir" |
db137867 AC |
3558 | |
3559 | if test -z "$output_obj"; then | |
3560 | # Place PIC objects in $objdir | |
08d019eb | 3561 | func_append command " -o $lobj" |
db137867 AC |
3562 | fi |
3563 | ||
7083c021 AC |
3564 | func_show_eval_locale "$command" \ |
3565 | 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' | |
db137867 | 3566 | |
6f57a957 | 3567 | if test warn = "$need_locks" && |
db137867 | 3568 | test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then |
7083c021 | 3569 | $ECHO "\ |
db137867 AC |
3570 | *** ERROR, $lockfile contains: |
3571 | `cat $lockfile 2>/dev/null` | |
3572 | ||
3573 | but it should contain: | |
3574 | $srcfile | |
3575 | ||
3576 | This indicates that another process is trying to use the same | |
3577 | temporary object file, and libtool could not work around it because | |
6f57a957 | 3578 | your compiler does not support '-c' and '-o' together. If you |
db137867 AC |
3579 | repeat this compilation, it may succeed, by chance, but you had better |
3580 | avoid parallel builds (make -j) in this platform, or get a better | |
3581 | compiler." | |
3582 | ||
7083c021 | 3583 | $opt_dry_run || $RM $removelist |
db137867 AC |
3584 | exit $EXIT_FAILURE |
3585 | fi | |
3586 | ||
3587 | # Just move the object if needed, then go on to compile the next one | |
3588 | if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then | |
7083c021 AC |
3589 | func_show_eval '$MV "$output_obj" "$lobj"' \ |
3590 | 'error=$?; $opt_dry_run || $RM $removelist; exit $error' | |
db137867 AC |
3591 | fi |
3592 | ||
db137867 | 3593 | # Allow error messages only from the first compilation. |
6f57a957 | 3594 | if test yes = "$suppress_opt"; then |
7083c021 | 3595 | suppress_output=' >/dev/null 2>&1' |
db137867 | 3596 | fi |
db137867 AC |
3597 | fi |
3598 | ||
3599 | # Only build a position-dependent object if we build old libraries. | |
6f57a957 AC |
3600 | if test yes = "$build_old_libs"; then |
3601 | if test yes != "$pic_mode"; then | |
db137867 | 3602 | # Don't build PIC code |
7083c021 | 3603 | command="$base_compile $qsrcfile$pie_flag" |
db137867 AC |
3604 | else |
3605 | command="$base_compile $qsrcfile $pic_flag" | |
3606 | fi | |
6f57a957 | 3607 | if test yes = "$compiler_c_o"; then |
08d019eb | 3608 | func_append command " -o $obj" |
db137867 AC |
3609 | fi |
3610 | ||
3611 | # Suppress compiler output if we already did a PIC compilation. | |
08d019eb | 3612 | func_append command "$suppress_output" |
7083c021 AC |
3613 | func_show_eval_locale "$command" \ |
3614 | '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' | |
db137867 | 3615 | |
6f57a957 | 3616 | if test warn = "$need_locks" && |
db137867 | 3617 | test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then |
7083c021 | 3618 | $ECHO "\ |
db137867 AC |
3619 | *** ERROR, $lockfile contains: |
3620 | `cat $lockfile 2>/dev/null` | |
3621 | ||
3622 | but it should contain: | |
3623 | $srcfile | |
3624 | ||
3625 | This indicates that another process is trying to use the same | |
3626 | temporary object file, and libtool could not work around it because | |
6f57a957 | 3627 | your compiler does not support '-c' and '-o' together. If you |
db137867 AC |
3628 | repeat this compilation, it may succeed, by chance, but you had better |
3629 | avoid parallel builds (make -j) in this platform, or get a better | |
3630 | compiler." | |
3631 | ||
7083c021 | 3632 | $opt_dry_run || $RM $removelist |
db137867 AC |
3633 | exit $EXIT_FAILURE |
3634 | fi | |
3635 | ||
3636 | # Just move the object if needed | |
3637 | if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then | |
7083c021 AC |
3638 | func_show_eval '$MV "$output_obj" "$obj"' \ |
3639 | 'error=$?; $opt_dry_run || $RM $removelist; exit $error' | |
db137867 | 3640 | fi |
db137867 AC |
3641 | fi |
3642 | ||
7083c021 AC |
3643 | $opt_dry_run || { |
3644 | func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" | |
db137867 | 3645 | |
7083c021 | 3646 | # Unlock the critical section if it was locked |
6f57a957 | 3647 | if test no != "$need_locks"; then |
7083c021 AC |
3648 | removelist=$lockfile |
3649 | $RM "$lockfile" | |
3650 | fi | |
3651 | } | |
db137867 AC |
3652 | |
3653 | exit $EXIT_SUCCESS | |
7083c021 | 3654 | } |
db137867 | 3655 | |
7083c021 | 3656 | $opt_help || { |
6f57a957 | 3657 | test compile = "$opt_mode" && func_mode_compile ${1+"$@"} |
7083c021 | 3658 | } |
db137867 | 3659 | |
7083c021 AC |
3660 | func_mode_help () |
3661 | { | |
3662 | # We need to display help for each of the modes. | |
08d019eb | 3663 | case $opt_mode in |
7083c021 AC |
3664 | "") |
3665 | # Generic help is extracted from the usage comments | |
3666 | # at the start of this file. | |
3667 | func_help | |
3668 | ;; | |
db137867 | 3669 | |
7083c021 AC |
3670 | clean) |
3671 | $ECHO \ | |
3672 | "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... | |
db137867 | 3673 | |
7083c021 | 3674 | Remove files from the build directory. |
db137867 | 3675 | |
7083c021 | 3676 | RM is the name of the program to use to delete files associated with each FILE |
6f57a957 | 3677 | (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed |
7083c021 | 3678 | to RM. |
db137867 | 3679 | |
7083c021 AC |
3680 | If FILE is a libtool library, object or program, all the files associated |
3681 | with it are deleted. Otherwise, only FILE itself is deleted using RM." | |
3682 | ;; | |
db137867 | 3683 | |
7083c021 AC |
3684 | compile) |
3685 | $ECHO \ | |
3686 | "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE | |
db137867 | 3687 | |
7083c021 | 3688 | Compile a source file into a libtool library object. |
db137867 | 3689 | |
7083c021 | 3690 | This mode accepts the following additional options: |
db137867 | 3691 | |
7083c021 AC |
3692 | -o OUTPUT-FILE set the output file name to OUTPUT-FILE |
3693 | -no-suppress do not suppress compiler output for multiple passes | |
08d019eb AC |
3694 | -prefer-pic try to build PIC objects only |
3695 | -prefer-non-pic try to build non-PIC objects only | |
6f57a957 AC |
3696 | -shared do not build a '.o' file suitable for static linking |
3697 | -static only build a '.o' file suitable for static linking | |
08d019eb | 3698 | -Wc,FLAG pass FLAG directly to the compiler |
db137867 | 3699 | |
6f57a957 | 3700 | COMPILE-COMMAND is a command to be used in creating a 'standard' object file |
7083c021 | 3701 | from the given SOURCEFILE. |
db137867 | 3702 | |
7083c021 | 3703 | The output file name is determined by removing the directory component from |
6f57a957 AC |
3704 | SOURCEFILE, then substituting the C source code suffix '.c' with the |
3705 | library object suffix, '.lo'." | |
7083c021 | 3706 | ;; |
db137867 | 3707 | |
7083c021 AC |
3708 | execute) |
3709 | $ECHO \ | |
3710 | "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... | |
db137867 | 3711 | |
7083c021 | 3712 | Automatically set library path, then run a program. |
db137867 | 3713 | |
7083c021 | 3714 | This mode accepts the following additional options: |
db137867 | 3715 | |
7083c021 | 3716 | -dlopen FILE add the directory containing FILE to the library path |
db137867 | 3717 | |
6f57a957 | 3718 | This mode sets the library path environment variable according to '-dlopen' |
7083c021 | 3719 | flags. |
db137867 | 3720 | |
7083c021 AC |
3721 | If any of the ARGS are libtool executable wrappers, then they are translated |
3722 | into their corresponding uninstalled binary, and any of their required library | |
3723 | directories are added to the library path. | |
db137867 | 3724 | |
7083c021 AC |
3725 | Then, COMMAND is executed, with ARGS as arguments." |
3726 | ;; | |
db137867 | 3727 | |
7083c021 AC |
3728 | finish) |
3729 | $ECHO \ | |
3730 | "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... | |
db137867 | 3731 | |
7083c021 | 3732 | Complete the installation of libtool libraries. |
db137867 | 3733 | |
7083c021 | 3734 | Each LIBDIR is a directory that contains libtool libraries. |
db137867 | 3735 | |
7083c021 | 3736 | The commands that this mode executes may require superuser privileges. Use |
6f57a957 | 3737 | the '--dry-run' option if you just want to see what would be executed." |
7083c021 | 3738 | ;; |
db137867 | 3739 | |
7083c021 AC |
3740 | install) |
3741 | $ECHO \ | |
3742 | "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... | |
db137867 | 3743 | |
7083c021 | 3744 | Install executables or libraries. |
db137867 | 3745 | |
7083c021 | 3746 | INSTALL-COMMAND is the installation command. The first component should be |
6f57a957 | 3747 | either the 'install' or 'cp' program. |
db137867 | 3748 | |
7083c021 | 3749 | The following components of INSTALL-COMMAND are treated specially: |
db137867 | 3750 | |
08d019eb | 3751 | -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation |
db137867 | 3752 | |
7083c021 AC |
3753 | The rest of the components are interpreted as arguments to that command (only |
3754 | BSD-compatible install options are recognized)." | |
3755 | ;; | |
db137867 | 3756 | |
7083c021 AC |
3757 | link) |
3758 | $ECHO \ | |
3759 | "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... | |
db137867 | 3760 | |
7083c021 AC |
3761 | Link object files or libraries together to form another library, or to |
3762 | create an executable program. | |
db137867 | 3763 | |
7083c021 AC |
3764 | LINK-COMMAND is a command using the C compiler that you would use to create |
3765 | a program from several object files. | |
db137867 | 3766 | |
7083c021 | 3767 | The following components of LINK-COMMAND are treated specially: |
db137867 | 3768 | |
7083c021 AC |
3769 | -all-static do not do any dynamic linking at all |
3770 | -avoid-version do not add a version suffix if possible | |
08d019eb AC |
3771 | -bindir BINDIR specify path to binaries directory (for systems where |
3772 | libraries must be found in the PATH setting at runtime) | |
6f57a957 | 3773 | -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime |
7083c021 AC |
3774 | -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols |
3775 | -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) | |
3776 | -export-symbols SYMFILE | |
3777 | try to export only the symbols listed in SYMFILE | |
3778 | -export-symbols-regex REGEX | |
3779 | try to export only the symbols matching REGEX | |
3780 | -LLIBDIR search LIBDIR for required installed libraries | |
3781 | -lNAME OUTPUT-FILE requires the installed library libNAME | |
3782 | -module build a library that can dlopened | |
3783 | -no-fast-install disable the fast-install mode | |
3784 | -no-install link a not-installable executable | |
3785 | -no-undefined declare that a library does not refer to external symbols | |
3786 | -o OUTPUT-FILE create OUTPUT-FILE from the specified objects | |
6f57a957 AC |
3787 | -objectlist FILE use a list of object files found in FILE to specify objects |
3788 | -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) | |
7083c021 AC |
3789 | -precious-files-regex REGEX |
3790 | don't remove output files matching REGEX | |
3791 | -release RELEASE specify package release information | |
3792 | -rpath LIBDIR the created library will eventually be installed in LIBDIR | |
3793 | -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries | |
3794 | -shared only do dynamic linking of libtool libraries | |
3795 | -shrext SUFFIX override the standard shared library file extension | |
3796 | -static do not do any dynamic linking of uninstalled libtool libraries | |
3797 | -static-libtool-libs | |
3798 | do not do any dynamic linking of libtool libraries | |
3799 | -version-info CURRENT[:REVISION[:AGE]] | |
3800 | specify library version info [each variable defaults to 0] | |
3801 | -weak LIBNAME declare that the target provides the LIBNAME interface | |
08d019eb AC |
3802 | -Wc,FLAG |
3803 | -Xcompiler FLAG pass linker-specific FLAG directly to the compiler | |
3804 | -Wl,FLAG | |
3805 | -Xlinker FLAG pass linker-specific FLAG directly to the linker | |
3806 | -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) | |
db137867 | 3807 | |
6f57a957 | 3808 | All other options (arguments beginning with '-') are ignored. |
db137867 | 3809 | |
6f57a957 | 3810 | Every other argument is treated as a filename. Files ending in '.la' are |
7083c021 AC |
3811 | treated as uninstalled libtool libraries, other files are standard or library |
3812 | object files. | |
3202e249 | 3813 | |
6f57a957 AC |
3814 | If the OUTPUT-FILE ends in '.la', then a libtool library is created, |
3815 | only library objects ('.lo' files) may be specified, and '-rpath' is | |
7083c021 | 3816 | required, except when creating a convenience library. |
db137867 | 3817 | |
6f57a957 AC |
3818 | If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created |
3819 | using 'ar' and 'ranlib', or on Windows using 'lib'. | |
db137867 | 3820 | |
6f57a957 | 3821 | If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file |
7083c021 | 3822 | is created, otherwise an executable program is created." |
db137867 AC |
3823 | ;; |
3824 | ||
7083c021 AC |
3825 | uninstall) |
3826 | $ECHO \ | |
3827 | "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... | |
db137867 | 3828 | |
7083c021 | 3829 | Remove libraries from an installation directory. |
db137867 | 3830 | |
7083c021 | 3831 | RM is the name of the program to use to delete files associated with each FILE |
6f57a957 | 3832 | (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed |
7083c021 | 3833 | to RM. |
db137867 | 3834 | |
7083c021 AC |
3835 | If FILE is a libtool library, all the files associated with it are deleted. |
3836 | Otherwise, only FILE itself is deleted using RM." | |
3837 | ;; | |
db137867 | 3838 | |
7083c021 | 3839 | *) |
6f57a957 | 3840 | func_fatal_help "invalid operation mode '$opt_mode'" |
7083c021 AC |
3841 | ;; |
3842 | esac | |
db137867 | 3843 | |
08d019eb | 3844 | echo |
6f57a957 | 3845 | $ECHO "Try '$progname --help' for more information about other modes." |
7083c021 | 3846 | } |
db137867 | 3847 | |
08d019eb AC |
3848 | # Now that we've collected a possible --mode arg, show help if necessary |
3849 | if $opt_help; then | |
6f57a957 | 3850 | if test : = "$opt_help"; then |
08d019eb AC |
3851 | func_mode_help |
3852 | else | |
3853 | { | |
3854 | func_help noexit | |
3855 | for opt_mode in compile link execute install finish uninstall clean; do | |
3856 | func_mode_help | |
3857 | done | |
6f57a957 | 3858 | } | $SED -n '1p; 2,$s/^Usage:/ or: /p' |
08d019eb AC |
3859 | { |
3860 | func_help noexit | |
3861 | for opt_mode in compile link execute install finish uninstall clean; do | |
3862 | echo | |
3863 | func_mode_help | |
3864 | done | |
3865 | } | | |
6f57a957 | 3866 | $SED '1d |
08d019eb AC |
3867 | /^When reporting/,/^Report/{ |
3868 | H | |
3869 | d | |
3870 | } | |
3871 | $x | |
3872 | /information about other modes/d | |
3873 | /more detailed .*MODE/d | |
3874 | s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' | |
3875 | fi | |
3876 | exit $? | |
3877 | fi | |
db137867 | 3878 | |
db137867 | 3879 | |
7083c021 AC |
3880 | # func_mode_execute arg... |
3881 | func_mode_execute () | |
3882 | { | |
6f57a957 AC |
3883 | $debug_cmd |
3884 | ||
7083c021 | 3885 | # The first argument is the command name. |
6f57a957 | 3886 | cmd=$nonopt |
7083c021 AC |
3887 | test -z "$cmd" && \ |
3888 | func_fatal_help "you must specify a COMMAND" | |
db137867 | 3889 | |
7083c021 | 3890 | # Handle -dlopen flags immediately. |
08d019eb | 3891 | for file in $opt_dlopen; do |
7083c021 | 3892 | test -f "$file" \ |
6f57a957 | 3893 | || func_fatal_help "'$file' is not a file" |
db137867 | 3894 | |
7083c021 AC |
3895 | dir= |
3896 | case $file in | |
3897 | *.la) | |
08d019eb AC |
3898 | func_resolve_sysroot "$file" |
3899 | file=$func_resolve_sysroot_result | |
3900 | ||
7083c021 AC |
3901 | # Check to see that this really is a libtool archive. |
3902 | func_lalib_unsafe_p "$file" \ | |
6f57a957 | 3903 | || func_fatal_help "'$lib' is not a valid libtool archive" |
db137867 | 3904 | |
7083c021 AC |
3905 | # Read the libtool library. |
3906 | dlname= | |
3907 | library_names= | |
3908 | func_source "$file" | |
db137867 | 3909 | |
7083c021 AC |
3910 | # Skip this library if it cannot be dlopened. |
3911 | if test -z "$dlname"; then | |
3912 | # Warn if it was a shared library. | |
3913 | test -n "$library_names" && \ | |
6f57a957 | 3914 | func_warning "'$file' was not linked with '-export-dynamic'" |
7083c021 AC |
3915 | continue |
3916 | fi | |
db137867 | 3917 | |
7083c021 | 3918 | func_dirname "$file" "" "." |
6f57a957 | 3919 | dir=$func_dirname_result |
db137867 | 3920 | |
7083c021 | 3921 | if test -f "$dir/$objdir/$dlname"; then |
08d019eb | 3922 | func_append dir "/$objdir" |
7083c021 AC |
3923 | else |
3924 | if test ! -f "$dir/$dlname"; then | |
6f57a957 | 3925 | func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" |
7083c021 AC |
3926 | fi |
3927 | fi | |
db137867 AC |
3928 | ;; |
3929 | ||
7083c021 AC |
3930 | *.lo) |
3931 | # Just add the directory containing the .lo file. | |
3932 | func_dirname "$file" "" "." | |
6f57a957 | 3933 | dir=$func_dirname_result |
db137867 AC |
3934 | ;; |
3935 | ||
7083c021 | 3936 | *) |
6f57a957 | 3937 | func_warning "'-dlopen' is ignored for non-libtool libraries and objects" |
db137867 AC |
3938 | continue |
3939 | ;; | |
7083c021 | 3940 | esac |
db137867 | 3941 | |
7083c021 AC |
3942 | # Get the absolute pathname. |
3943 | absdir=`cd "$dir" && pwd` | |
6f57a957 | 3944 | test -n "$absdir" && dir=$absdir |
db137867 | 3945 | |
7083c021 AC |
3946 | # Now add the directory to shlibpath_var. |
3947 | if eval "test -z \"\$$shlibpath_var\""; then | |
3948 | eval "$shlibpath_var=\"\$dir\"" | |
3949 | else | |
3950 | eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" | |
3951 | fi | |
3952 | done | |
db137867 | 3953 | |
7083c021 AC |
3954 | # This variable tells wrapper scripts just to set shlibpath_var |
3955 | # rather than running their programs. | |
6f57a957 | 3956 | libtool_execute_magic=$magic |
db137867 | 3957 | |
7083c021 AC |
3958 | # Check if any of the arguments is a wrapper script. |
3959 | args= | |
3960 | for file | |
3961 | do | |
3962 | case $file in | |
08d019eb | 3963 | -* | *.la | *.lo ) ;; |
7083c021 AC |
3964 | *) |
3965 | # Do a test to see if this is really a libtool program. | |
3966 | if func_ltwrapper_script_p "$file"; then | |
3967 | func_source "$file" | |
3968 | # Transform arg to wrapped name. | |
6f57a957 | 3969 | file=$progdir/$program |
7083c021 AC |
3970 | elif func_ltwrapper_executable_p "$file"; then |
3971 | func_ltwrapper_scriptname "$file" | |
3972 | func_source "$func_ltwrapper_scriptname_result" | |
3973 | # Transform arg to wrapped name. | |
6f57a957 | 3974 | file=$progdir/$program |
7083c021 AC |
3975 | fi |
3976 | ;; | |
3977 | esac | |
3978 | # Quote arguments (to preserve shell metacharacters). | |
08d019eb | 3979 | func_append_quoted args "$file" |
7083c021 | 3980 | done |
db137867 | 3981 | |
6f57a957 AC |
3982 | if $opt_dry_run; then |
3983 | # Display what would be done. | |
3984 | if test -n "$shlibpath_var"; then | |
3985 | eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" | |
3986 | echo "export $shlibpath_var" | |
3987 | fi | |
3988 | $ECHO "$cmd$args" | |
3989 | exit $EXIT_SUCCESS | |
3990 | else | |
7083c021 AC |
3991 | if test -n "$shlibpath_var"; then |
3992 | # Export the shlibpath_var. | |
3993 | eval "export $shlibpath_var" | |
3994 | fi | |
db137867 | 3995 | |
7083c021 AC |
3996 | # Restore saved environment variables |
3997 | for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES | |
3998 | do | |
3999 | eval "if test \"\${save_$lt_var+set}\" = set; then | |
4000 | $lt_var=\$save_$lt_var; export $lt_var | |
db137867 | 4001 | else |
7083c021 AC |
4002 | $lt_unset $lt_var |
4003 | fi" | |
4004 | done | |
db137867 | 4005 | |
7083c021 | 4006 | # Now prepare to actually exec the command. |
6f57a957 | 4007 | exec_cmd=\$cmd$args |
7083c021 AC |
4008 | fi |
4009 | } | |
db137867 | 4010 | |
6f57a957 | 4011 | test execute = "$opt_mode" && func_mode_execute ${1+"$@"} |
08d019eb AC |
4012 | |
4013 | ||
4014 | # func_mode_finish arg... | |
4015 | func_mode_finish () | |
4016 | { | |
6f57a957 AC |
4017 | $debug_cmd |
4018 | ||
08d019eb AC |
4019 | libs= |
4020 | libdirs= | |
4021 | admincmds= | |
4022 | ||
4023 | for opt in "$nonopt" ${1+"$@"} | |
4024 | do | |
4025 | if test -d "$opt"; then | |
4026 | func_append libdirs " $opt" | |
4027 | ||
4028 | elif test -f "$opt"; then | |
4029 | if func_lalib_unsafe_p "$opt"; then | |
4030 | func_append libs " $opt" | |
4031 | else | |
6f57a957 | 4032 | func_warning "'$opt' is not a valid libtool archive" |
08d019eb AC |
4033 | fi |
4034 | ||
4035 | else | |
6f57a957 | 4036 | func_fatal_error "invalid argument '$opt'" |
08d019eb AC |
4037 | fi |
4038 | done | |
db137867 | 4039 | |
08d019eb AC |
4040 | if test -n "$libs"; then |
4041 | if test -n "$lt_sysroot"; then | |
4042 | sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` | |
4043 | sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" | |
4044 | else | |
4045 | sysroot_cmd= | |
4046 | fi | |
db137867 | 4047 | |
08d019eb AC |
4048 | # Remove sysroot references |
4049 | if $opt_dry_run; then | |
4050 | for lib in $libs; do | |
6f57a957 | 4051 | echo "removing references to $lt_sysroot and '=' prefixes from $lib" |
08d019eb AC |
4052 | done |
4053 | else | |
4054 | tmpdir=`func_mktempdir` | |
4055 | for lib in $libs; do | |
6f57a957 | 4056 | $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ |
08d019eb AC |
4057 | > $tmpdir/tmp-la |
4058 | mv -f $tmpdir/tmp-la $lib | |
4059 | done | |
4060 | ${RM}r "$tmpdir" | |
4061 | fi | |
4062 | fi | |
db137867 | 4063 | |
7083c021 | 4064 | if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then |
7083c021 AC |
4065 | for libdir in $libdirs; do |
4066 | if test -n "$finish_cmds"; then | |
4067 | # Do each command in the finish commands. | |
4068 | func_execute_cmds "$finish_cmds" 'admincmds="$admincmds | |
4069 | '"$cmd"'"' | |
db137867 | 4070 | fi |
7083c021 AC |
4071 | if test -n "$finish_eval"; then |
4072 | # Do the single finish_eval. | |
4073 | eval cmds=\"$finish_eval\" | |
08d019eb | 4074 | $opt_dry_run || eval "$cmds" || func_append admincmds " |
7083c021 AC |
4075 | $cmds" |
4076 | fi | |
4077 | done | |
4078 | fi | |
db137867 | 4079 | |
7083c021 | 4080 | # Exit here if they wanted silent mode. |
6f57a957 | 4081 | $opt_quiet && exit $EXIT_SUCCESS |
db137867 | 4082 | |
08d019eb AC |
4083 | if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then |
4084 | echo "----------------------------------------------------------------------" | |
4085 | echo "Libraries have been installed in:" | |
4086 | for libdir in $libdirs; do | |
4087 | $ECHO " $libdir" | |
4088 | done | |
4089 | echo | |
4090 | echo "If you ever happen to want to link against installed libraries" | |
4091 | echo "in a given directory, LIBDIR, you must either use libtool, and" | |
6f57a957 | 4092 | echo "specify the full pathname of the library, or use the '-LLIBDIR'" |
08d019eb AC |
4093 | echo "flag during linking and do at least one of the following:" |
4094 | if test -n "$shlibpath_var"; then | |
6f57a957 | 4095 | echo " - add LIBDIR to the '$shlibpath_var' environment variable" |
08d019eb AC |
4096 | echo " during execution" |
4097 | fi | |
4098 | if test -n "$runpath_var"; then | |
6f57a957 | 4099 | echo " - add LIBDIR to the '$runpath_var' environment variable" |
08d019eb AC |
4100 | echo " during linking" |
4101 | fi | |
4102 | if test -n "$hardcode_libdir_flag_spec"; then | |
4103 | libdir=LIBDIR | |
4104 | eval flag=\"$hardcode_libdir_flag_spec\" | |
7083c021 | 4105 | |
6f57a957 | 4106 | $ECHO " - use the '$flag' linker flag" |
08d019eb AC |
4107 | fi |
4108 | if test -n "$admincmds"; then | |
4109 | $ECHO " - have your system administrator run these commands:$admincmds" | |
4110 | fi | |
4111 | if test -f /etc/ld.so.conf; then | |
6f57a957 | 4112 | echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" |
08d019eb AC |
4113 | fi |
4114 | echo | |
7083c021 | 4115 | |
08d019eb AC |
4116 | echo "See any operating system documentation about shared libraries for" |
4117 | case $host in | |
4118 | solaris2.[6789]|solaris2.1[0-9]) | |
4119 | echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" | |
4120 | echo "pages." | |
4121 | ;; | |
4122 | *) | |
4123 | echo "more information, such as the ld(1) and ld.so(8) manual pages." | |
4124 | ;; | |
4125 | esac | |
4126 | echo "----------------------------------------------------------------------" | |
4127 | fi | |
7083c021 AC |
4128 | exit $EXIT_SUCCESS |
4129 | } | |
4130 | ||
6f57a957 | 4131 | test finish = "$opt_mode" && func_mode_finish ${1+"$@"} |
7083c021 AC |
4132 | |
4133 | ||
4134 | # func_mode_install arg... | |
4135 | func_mode_install () | |
4136 | { | |
6f57a957 AC |
4137 | $debug_cmd |
4138 | ||
7083c021 AC |
4139 | # There may be an optional sh(1) argument at the beginning of |
4140 | # install_prog (especially on Windows NT). | |
6f57a957 | 4141 | if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || |
7083c021 | 4142 | # Allow the use of GNU shtool's install command. |
6f57a957 AC |
4143 | case $nonopt in *shtool*) :;; *) false;; esac |
4144 | then | |
7083c021 AC |
4145 | # Aesthetically quote it. |
4146 | func_quote_for_eval "$nonopt" | |
4147 | install_prog="$func_quote_for_eval_result " | |
4148 | arg=$1 | |
4149 | shift | |
4150 | else | |
4151 | install_prog= | |
4152 | arg=$nonopt | |
4153 | fi | |
4154 | ||
4155 | # The real first argument should be the name of the installation program. | |
4156 | # Aesthetically quote it. | |
4157 | func_quote_for_eval "$arg" | |
08d019eb AC |
4158 | func_append install_prog "$func_quote_for_eval_result" |
4159 | install_shared_prog=$install_prog | |
4160 | case " $install_prog " in | |
4161 | *[\\\ /]cp\ *) install_cp=: ;; | |
4162 | *) install_cp=false ;; | |
4163 | esac | |
7083c021 AC |
4164 | |
4165 | # We need to accept at least all the BSD install flags. | |
4166 | dest= | |
4167 | files= | |
4168 | opts= | |
4169 | prev= | |
4170 | install_type= | |
6f57a957 | 4171 | isdir=false |
7083c021 | 4172 | stripme= |
08d019eb | 4173 | no_mode=: |
7083c021 AC |
4174 | for arg |
4175 | do | |
08d019eb | 4176 | arg2= |
7083c021 | 4177 | if test -n "$dest"; then |
08d019eb | 4178 | func_append files " $dest" |
7083c021 AC |
4179 | dest=$arg |
4180 | continue | |
4181 | fi | |
4182 | ||
4183 | case $arg in | |
6f57a957 | 4184 | -d) isdir=: ;; |
7083c021 | 4185 | -f) |
08d019eb AC |
4186 | if $install_cp; then :; else |
4187 | prev=$arg | |
4188 | fi | |
7083c021 AC |
4189 | ;; |
4190 | -g | -m | -o) | |
4191 | prev=$arg | |
4192 | ;; | |
4193 | -s) | |
4194 | stripme=" -s" | |
4195 | continue | |
4196 | ;; | |
4197 | -*) | |
4198 | ;; | |
4199 | *) | |
4200 | # If the previous option needed an argument, then skip it. | |
4201 | if test -n "$prev"; then | |
6f57a957 | 4202 | if test X-m = "X$prev" && test -n "$install_override_mode"; then |
08d019eb AC |
4203 | arg2=$install_override_mode |
4204 | no_mode=false | |
4205 | fi | |
db137867 AC |
4206 | prev= |
4207 | else | |
7083c021 AC |
4208 | dest=$arg |
4209 | continue | |
db137867 | 4210 | fi |
db137867 | 4211 | ;; |
7083c021 | 4212 | esac |
db137867 | 4213 | |
7083c021 AC |
4214 | # Aesthetically quote the argument. |
4215 | func_quote_for_eval "$arg" | |
08d019eb AC |
4216 | func_append install_prog " $func_quote_for_eval_result" |
4217 | if test -n "$arg2"; then | |
4218 | func_quote_for_eval "$arg2" | |
4219 | fi | |
4220 | func_append install_shared_prog " $func_quote_for_eval_result" | |
7083c021 | 4221 | done |
db137867 | 4222 | |
7083c021 AC |
4223 | test -z "$install_prog" && \ |
4224 | func_fatal_help "you must specify an install program" | |
db137867 | 4225 | |
7083c021 | 4226 | test -n "$prev" && \ |
6f57a957 | 4227 | func_fatal_help "the '$prev' option requires an argument" |
db137867 | 4228 | |
08d019eb AC |
4229 | if test -n "$install_override_mode" && $no_mode; then |
4230 | if $install_cp; then :; else | |
4231 | func_quote_for_eval "$install_override_mode" | |
4232 | func_append install_shared_prog " -m $func_quote_for_eval_result" | |
4233 | fi | |
4234 | fi | |
4235 | ||
7083c021 AC |
4236 | if test -z "$files"; then |
4237 | if test -z "$dest"; then | |
4238 | func_fatal_help "no file or destination specified" | |
4239 | else | |
4240 | func_fatal_help "you must specify a destination" | |
4241 | fi | |
db137867 AC |
4242 | fi |
4243 | ||
7083c021 AC |
4244 | # Strip any trailing slash from the destination. |
4245 | func_stripname '' '/' "$dest" | |
4246 | dest=$func_stripname_result | |
db137867 | 4247 | |
7083c021 | 4248 | # Check to see that the destination is a directory. |
6f57a957 AC |
4249 | test -d "$dest" && isdir=: |
4250 | if $isdir; then | |
4251 | destdir=$dest | |
7083c021 | 4252 | destname= |
db137867 | 4253 | else |
7083c021 | 4254 | func_dirname_and_basename "$dest" "" "." |
6f57a957 AC |
4255 | destdir=$func_dirname_result |
4256 | destname=$func_basename_result | |
db137867 | 4257 | |
7083c021 AC |
4258 | # Not a directory, so check to see that there is only one file specified. |
4259 | set dummy $files; shift | |
4260 | test "$#" -gt 1 && \ | |
6f57a957 | 4261 | func_fatal_help "'$dest' is not a directory" |
db137867 | 4262 | fi |
7083c021 AC |
4263 | case $destdir in |
4264 | [\\/]* | [A-Za-z]:[\\/]*) ;; | |
db137867 | 4265 | *) |
7083c021 AC |
4266 | for file in $files; do |
4267 | case $file in | |
4268 | *.lo) ;; | |
4269 | *) | |
6f57a957 | 4270 | func_fatal_help "'$destdir' must be an absolute directory name" |
7083c021 AC |
4271 | ;; |
4272 | esac | |
4273 | done | |
db137867 AC |
4274 | ;; |
4275 | esac | |
db137867 | 4276 | |
7083c021 AC |
4277 | # This variable tells wrapper scripts just to set variables rather |
4278 | # than running their programs. | |
6f57a957 | 4279 | libtool_install_magic=$magic |
db137867 | 4280 | |
7083c021 AC |
4281 | staticlibs= |
4282 | future_libdirs= | |
4283 | current_libdirs= | |
4284 | for file in $files; do | |
db137867 | 4285 | |
7083c021 AC |
4286 | # Do each installation. |
4287 | case $file in | |
4288 | *.$libext) | |
4289 | # Do the static libraries later. | |
08d019eb | 4290 | func_append staticlibs " $file" |
7083c021 AC |
4291 | ;; |
4292 | ||
4293 | *.la) | |
08d019eb AC |
4294 | func_resolve_sysroot "$file" |
4295 | file=$func_resolve_sysroot_result | |
4296 | ||
7083c021 AC |
4297 | # Check to see that this really is a libtool archive. |
4298 | func_lalib_unsafe_p "$file" \ | |
6f57a957 | 4299 | || func_fatal_help "'$file' is not a valid libtool archive" |
7083c021 AC |
4300 | |
4301 | library_names= | |
4302 | old_library= | |
4303 | relink_command= | |
4304 | func_source "$file" | |
4305 | ||
4306 | # Add the libdir to current_libdirs if it is the destination. | |
4307 | if test "X$destdir" = "X$libdir"; then | |
4308 | case "$current_libdirs " in | |
4309 | *" $libdir "*) ;; | |
08d019eb | 4310 | *) func_append current_libdirs " $libdir" ;; |
db137867 | 4311 | esac |
7083c021 AC |
4312 | else |
4313 | # Note the libdir as a future libdir. | |
4314 | case "$future_libdirs " in | |
4315 | *" $libdir "*) ;; | |
08d019eb | 4316 | *) func_append future_libdirs " $libdir" ;; |
7083c021 AC |
4317 | esac |
4318 | fi | |
db137867 | 4319 | |
7083c021 | 4320 | func_dirname "$file" "/" "" |
6f57a957 | 4321 | dir=$func_dirname_result |
08d019eb | 4322 | func_append dir "$objdir" |
7083c021 AC |
4323 | |
4324 | if test -n "$relink_command"; then | |
4325 | # Determine the prefix the user has applied to our future dir. | |
08d019eb | 4326 | inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` |
7083c021 AC |
4327 | |
4328 | # Don't allow the user to place us outside of our expected | |
4329 | # location b/c this prevents finding dependent libraries that | |
4330 | # are installed to the same prefix. | |
4331 | # At present, this check doesn't affect windows .dll's that | |
4332 | # are installed into $libdir/../bin (currently, that works fine) | |
4333 | # but it's something to keep an eye on. | |
4334 | test "$inst_prefix_dir" = "$destdir" && \ | |
6f57a957 | 4335 | func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" |
7083c021 AC |
4336 | |
4337 | if test -n "$inst_prefix_dir"; then | |
4338 | # Stick the inst_prefix_dir data into the link command. | |
08d019eb | 4339 | relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` |
7083c021 | 4340 | else |
08d019eb | 4341 | relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` |
7083c021 AC |
4342 | fi |
4343 | ||
6f57a957 | 4344 | func_warning "relinking '$file'" |
7083c021 | 4345 | func_show_eval "$relink_command" \ |
6f57a957 | 4346 | 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' |
7083c021 AC |
4347 | fi |
4348 | ||
4349 | # See the names of the shared library. | |
4350 | set dummy $library_names; shift | |
4351 | if test -n "$1"; then | |
6f57a957 | 4352 | realname=$1 |
7083c021 AC |
4353 | shift |
4354 | ||
6f57a957 AC |
4355 | srcname=$realname |
4356 | test -n "$relink_command" && srcname=${realname}T | |
7083c021 AC |
4357 | |
4358 | # Install the shared library and build the symlinks. | |
08d019eb | 4359 | func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ |
7083c021 | 4360 | 'exit $?' |
6f57a957 | 4361 | tstripme=$stripme |
7083c021 AC |
4362 | case $host_os in |
4363 | cygwin* | mingw* | pw32* | cegcc*) | |
4364 | case $realname in | |
4365 | *.dll.a) | |
6f57a957 AC |
4366 | tstripme= |
4367 | ;; | |
4368 | esac | |
4369 | ;; | |
4370 | os2*) | |
4371 | case $realname in | |
4372 | *_dll.a) | |
4373 | tstripme= | |
7083c021 AC |
4374 | ;; |
4375 | esac | |
db137867 AC |
4376 | ;; |
4377 | esac | |
7083c021 AC |
4378 | if test -n "$tstripme" && test -n "$striplib"; then |
4379 | func_show_eval "$striplib $destdir/$realname" 'exit $?' | |
3202e249 | 4380 | fi |
7083c021 AC |
4381 | |
4382 | if test "$#" -gt 0; then | |
4383 | # Delete the old symlinks, and create new ones. | |
6f57a957 | 4384 | # Try 'ln -sf' first, because the 'ln' binary might depend on |
7083c021 AC |
4385 | # the symlink we replace! Solaris /bin/ln does not understand -f, |
4386 | # so we also need to try rm && ln -s. | |
4387 | for linkname | |
4388 | do | |
4389 | test "$linkname" != "$realname" \ | |
4390 | && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" | |
db137867 | 4391 | done |
db137867 | 4392 | fi |
db137867 | 4393 | |
7083c021 | 4394 | # Do each command in the postinstall commands. |
6f57a957 | 4395 | lib=$destdir/$realname |
7083c021 | 4396 | func_execute_cmds "$postinstall_cmds" 'exit $?' |
db137867 AC |
4397 | fi |
4398 | ||
7083c021 AC |
4399 | # Install the pseudo-library for information purposes. |
4400 | func_basename "$file" | |
6f57a957 AC |
4401 | name=$func_basename_result |
4402 | instname=$dir/${name}i | |
7083c021 | 4403 | func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' |
db137867 | 4404 | |
7083c021 | 4405 | # Maybe install the static library, too. |
08d019eb | 4406 | test -n "$old_library" && func_append staticlibs " $dir/$old_library" |
7083c021 | 4407 | ;; |
db137867 | 4408 | |
7083c021 AC |
4409 | *.lo) |
4410 | # Install (i.e. copy) a libtool object. | |
db137867 | 4411 | |
7083c021 AC |
4412 | # Figure out destination file name, if it wasn't already specified. |
4413 | if test -n "$destname"; then | |
6f57a957 | 4414 | destfile=$destdir/$destname |
7083c021 AC |
4415 | else |
4416 | func_basename "$file" | |
6f57a957 AC |
4417 | destfile=$func_basename_result |
4418 | destfile=$destdir/$destfile | |
7083c021 AC |
4419 | fi |
4420 | ||
4421 | # Deduce the name of the destination old-style object file. | |
4422 | case $destfile in | |
4423 | *.lo) | |
4424 | func_lo2o "$destfile" | |
4425 | staticdest=$func_lo2o_result | |
4426 | ;; | |
4427 | *.$objext) | |
6f57a957 | 4428 | staticdest=$destfile |
7083c021 AC |
4429 | destfile= |
4430 | ;; | |
4431 | *) | |
6f57a957 | 4432 | func_fatal_help "cannot copy a libtool object to '$destfile'" |
7083c021 | 4433 | ;; |
db137867 AC |
4434 | esac |
4435 | ||
7083c021 AC |
4436 | # Install the libtool object if requested. |
4437 | test -n "$destfile" && \ | |
4438 | func_show_eval "$install_prog $file $destfile" 'exit $?' | |
4439 | ||
4440 | # Install the old object if enabled. | |
6f57a957 | 4441 | if test yes = "$build_old_libs"; then |
7083c021 AC |
4442 | # Deduce the name of the old-style object file. |
4443 | func_lo2o "$file" | |
4444 | staticobj=$func_lo2o_result | |
4445 | func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' | |
db137867 | 4446 | fi |
7083c021 AC |
4447 | exit $EXIT_SUCCESS |
4448 | ;; | |
db137867 | 4449 | |
7083c021 AC |
4450 | *) |
4451 | # Figure out destination file name, if it wasn't already specified. | |
4452 | if test -n "$destname"; then | |
6f57a957 | 4453 | destfile=$destdir/$destname |
7083c021 AC |
4454 | else |
4455 | func_basename "$file" | |
6f57a957 AC |
4456 | destfile=$func_basename_result |
4457 | destfile=$destdir/$destfile | |
7083c021 | 4458 | fi |
db137867 | 4459 | |
7083c021 AC |
4460 | # If the file is missing, and there is a .exe on the end, strip it |
4461 | # because it is most likely a libtool script we actually want to | |
4462 | # install | |
6f57a957 | 4463 | stripped_ext= |
7083c021 AC |
4464 | case $file in |
4465 | *.exe) | |
4466 | if test ! -f "$file"; then | |
4467 | func_stripname '' '.exe' "$file" | |
4468 | file=$func_stripname_result | |
6f57a957 | 4469 | stripped_ext=.exe |
7083c021 AC |
4470 | fi |
4471 | ;; | |
4472 | esac | |
db137867 | 4473 | |
7083c021 AC |
4474 | # Do a test to see if this is really a libtool program. |
4475 | case $host in | |
4476 | *cygwin* | *mingw*) | |
4477 | if func_ltwrapper_executable_p "$file"; then | |
4478 | func_ltwrapper_scriptname "$file" | |
4479 | wrapper=$func_ltwrapper_scriptname_result | |
4480 | else | |
4481 | func_stripname '' '.exe' "$file" | |
4482 | wrapper=$func_stripname_result | |
4483 | fi | |
4484 | ;; | |
4485 | *) | |
4486 | wrapper=$file | |
4487 | ;; | |
4488 | esac | |
4489 | if func_ltwrapper_script_p "$wrapper"; then | |
4490 | notinst_deplibs= | |
4491 | relink_command= | |
db137867 | 4492 | |
7083c021 AC |
4493 | func_source "$wrapper" |
4494 | ||
4495 | # Check the variables that should have been set. | |
4496 | test -z "$generated_by_libtool_version" && \ | |
6f57a957 | 4497 | func_fatal_error "invalid libtool wrapper script '$wrapper'" |
7083c021 | 4498 | |
6f57a957 | 4499 | finalize=: |
7083c021 AC |
4500 | for lib in $notinst_deplibs; do |
4501 | # Check to see that each library is installed. | |
4502 | libdir= | |
4503 | if test -f "$lib"; then | |
4504 | func_source "$lib" | |
4505 | fi | |
6f57a957 | 4506 | libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` |
7083c021 | 4507 | if test -n "$libdir" && test ! -f "$libfile"; then |
6f57a957 AC |
4508 | func_warning "'$lib' has not been installed in '$libdir'" |
4509 | finalize=false | |
7083c021 AC |
4510 | fi |
4511 | done | |
4512 | ||
4513 | relink_command= | |
4514 | func_source "$wrapper" | |
4515 | ||
4516 | outputname= | |
6f57a957 | 4517 | if test no = "$fast_install" && test -n "$relink_command"; then |
7083c021 | 4518 | $opt_dry_run || { |
6f57a957 | 4519 | if $finalize; then |
7083c021 AC |
4520 | tmpdir=`func_mktempdir` |
4521 | func_basename "$file$stripped_ext" | |
6f57a957 AC |
4522 | file=$func_basename_result |
4523 | outputname=$tmpdir/$file | |
7083c021 | 4524 | # Replace the output file specification. |
08d019eb | 4525 | relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` |
7083c021 | 4526 | |
6f57a957 | 4527 | $opt_quiet || { |
7083c021 AC |
4528 | func_quote_for_expand "$relink_command" |
4529 | eval "func_echo $func_quote_for_expand_result" | |
4530 | } | |
4531 | if eval "$relink_command"; then : | |
4532 | else | |
6f57a957 | 4533 | func_error "error: relink '$file' with the above command before installing it" |
7083c021 AC |
4534 | $opt_dry_run || ${RM}r "$tmpdir" |
4535 | continue | |
4536 | fi | |
6f57a957 | 4537 | file=$outputname |
7083c021 | 4538 | else |
6f57a957 | 4539 | func_warning "cannot relink '$file'" |
7083c021 AC |
4540 | fi |
4541 | } | |
db137867 | 4542 | else |
7083c021 | 4543 | # Install the binary that we compiled earlier. |
08d019eb | 4544 | file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` |
db137867 | 4545 | fi |
7083c021 | 4546 | fi |
db137867 | 4547 | |
7083c021 AC |
4548 | # remove .exe since cygwin /usr/bin/install will append another |
4549 | # one anyway | |
4550 | case $install_prog,$host in | |
4551 | */usr/bin/install*,*cygwin*) | |
4552 | case $file:$destfile in | |
4553 | *.exe:*.exe) | |
4554 | # this is ok | |
4555 | ;; | |
4556 | *.exe:*) | |
4557 | destfile=$destfile.exe | |
4558 | ;; | |
4559 | *:*.exe) | |
4560 | func_stripname '' '.exe' "$destfile" | |
4561 | destfile=$func_stripname_result | |
4562 | ;; | |
4563 | esac | |
db137867 AC |
4564 | ;; |
4565 | esac | |
7083c021 AC |
4566 | func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' |
4567 | $opt_dry_run || if test -n "$outputname"; then | |
4568 | ${RM}r "$tmpdir" | |
4569 | fi | |
4570 | ;; | |
4571 | esac | |
4572 | done | |
db137867 | 4573 | |
7083c021 AC |
4574 | for file in $staticlibs; do |
4575 | func_basename "$file" | |
6f57a957 | 4576 | name=$func_basename_result |
7083c021 AC |
4577 | |
4578 | # Set up the ranlib parameters. | |
6f57a957 | 4579 | oldlib=$destdir/$name |
54bec06e AC |
4580 | func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 |
4581 | tool_oldlib=$func_to_tool_file_result | |
7083c021 AC |
4582 | |
4583 | func_show_eval "$install_prog \$file \$oldlib" 'exit $?' | |
4584 | ||
4585 | if test -n "$stripme" && test -n "$old_striplib"; then | |
54bec06e | 4586 | func_show_eval "$old_striplib $tool_oldlib" 'exit $?' |
7083c021 AC |
4587 | fi |
4588 | ||
4589 | # Do each command in the postinstall commands. | |
4590 | func_execute_cmds "$old_postinstall_cmds" 'exit $?' | |
4591 | done | |
4592 | ||
4593 | test -n "$future_libdirs" && \ | |
6f57a957 | 4594 | func_warning "remember to run '$progname --finish$future_libdirs'" |
7083c021 AC |
4595 | |
4596 | if test -n "$current_libdirs"; then | |
4597 | # Maybe just do a dry run. | |
4598 | $opt_dry_run && current_libdirs=" -n$current_libdirs" | |
6f57a957 | 4599 | exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' |
7083c021 AC |
4600 | else |
4601 | exit $EXIT_SUCCESS | |
4602 | fi | |
4603 | } | |
4604 | ||
6f57a957 | 4605 | test install = "$opt_mode" && func_mode_install ${1+"$@"} |
7083c021 AC |
4606 | |
4607 | ||
4608 | # func_generate_dlsyms outputname originator pic_p | |
4609 | # Extract symbols from dlprefiles and create ${outputname}S.o with | |
4610 | # a dlpreopen symbol table. | |
4611 | func_generate_dlsyms () | |
4612 | { | |
6f57a957 AC |
4613 | $debug_cmd |
4614 | ||
4615 | my_outputname=$1 | |
4616 | my_originator=$2 | |
4617 | my_pic_p=${3-false} | |
4618 | my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` | |
7083c021 AC |
4619 | my_dlsyms= |
4620 | ||
6f57a957 | 4621 | if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then |
7083c021 | 4622 | if test -n "$NM" && test -n "$global_symbol_pipe"; then |
6f57a957 | 4623 | my_dlsyms=${my_outputname}S.c |
7083c021 AC |
4624 | else |
4625 | func_error "not configured to extract global symbols from dlpreopened files" | |
4626 | fi | |
4627 | fi | |
4628 | ||
4629 | if test -n "$my_dlsyms"; then | |
4630 | case $my_dlsyms in | |
4631 | "") ;; | |
4632 | *.c) | |
4633 | # Discover the nlist of each of the dlfiles. | |
6f57a957 | 4634 | nlist=$output_objdir/$my_outputname.nm |
7083c021 AC |
4635 | |
4636 | func_show_eval "$RM $nlist ${nlist}S ${nlist}T" | |
4637 | ||
4638 | # Parse the name list into a source file. | |
4639 | func_verbose "creating $output_objdir/$my_dlsyms" | |
4640 | ||
4641 | $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ | |
6f57a957 AC |
4642 | /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ |
4643 | /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ | |
7083c021 AC |
4644 | |
4645 | #ifdef __cplusplus | |
4646 | extern \"C\" { | |
4647 | #endif | |
4648 | ||
6f57a957 | 4649 | #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) |
08d019eb AC |
4650 | #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" |
4651 | #endif | |
4652 | ||
4653 | /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ | |
6f57a957 AC |
4654 | #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE |
4655 | /* DATA imports from DLLs on WIN32 can't be const, because runtime | |
08d019eb AC |
4656 | relocations are performed -- see ld's documentation on pseudo-relocs. */ |
4657 | # define LT_DLSYM_CONST | |
6f57a957 | 4658 | #elif defined __osf__ |
08d019eb AC |
4659 | /* This system does not cope well with relocations in const data. */ |
4660 | # define LT_DLSYM_CONST | |
4661 | #else | |
4662 | # define LT_DLSYM_CONST const | |
4663 | #endif | |
4664 | ||
6f57a957 AC |
4665 | #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) |
4666 | ||
7083c021 AC |
4667 | /* External symbol declarations for the compiler. */\ |
4668 | " | |
4669 | ||
6f57a957 AC |
4670 | if test yes = "$dlself"; then |
4671 | func_verbose "generating symbol list for '$output'" | |
7083c021 AC |
4672 | |
4673 | $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" | |
4674 | ||
4675 | # Add our own program objects to the symbol list. | |
08d019eb | 4676 | progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` |
7083c021 | 4677 | for progfile in $progfiles; do |
08d019eb | 4678 | func_to_tool_file "$progfile" func_convert_file_msys_to_w32 |
6f57a957 | 4679 | func_verbose "extracting global C symbols from '$func_to_tool_file_result'" |
08d019eb | 4680 | $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" |
7083c021 AC |
4681 | done |
4682 | ||
4683 | if test -n "$exclude_expsyms"; then | |
4684 | $opt_dry_run || { | |
4685 | eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' | |
4686 | eval '$MV "$nlist"T "$nlist"' | |
4687 | } | |
db137867 | 4688 | fi |
7083c021 AC |
4689 | |
4690 | if test -n "$export_symbols_regex"; then | |
4691 | $opt_dry_run || { | |
4692 | eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' | |
4693 | eval '$MV "$nlist"T "$nlist"' | |
4694 | } | |
4695 | fi | |
4696 | ||
4697 | # Prepare the list of exported symbols | |
4698 | if test -z "$export_symbols"; then | |
6f57a957 | 4699 | export_symbols=$output_objdir/$outputname.exp |
7083c021 AC |
4700 | $opt_dry_run || { |
4701 | $RM $export_symbols | |
6f57a957 | 4702 | eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' |
7083c021 AC |
4703 | case $host in |
4704 | *cygwin* | *mingw* | *cegcc* ) | |
4705 | eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' | |
4706 | eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' | |
4707 | ;; | |
4708 | esac | |
4709 | } | |
db137867 | 4710 | else |
7083c021 | 4711 | $opt_dry_run || { |
6f57a957 | 4712 | eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' |
7083c021 AC |
4713 | eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' |
4714 | eval '$MV "$nlist"T "$nlist"' | |
4715 | case $host in | |
08d019eb | 4716 | *cygwin* | *mingw* | *cegcc* ) |
7083c021 AC |
4717 | eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' |
4718 | eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' | |
4719 | ;; | |
4720 | esac | |
4721 | } | |
db137867 | 4722 | fi |
7083c021 | 4723 | fi |
db137867 | 4724 | |
7083c021 | 4725 | for dlprefile in $dlprefiles; do |
6f57a957 | 4726 | func_verbose "extracting global C symbols from '$dlprefile'" |
7083c021 | 4727 | func_basename "$dlprefile" |
6f57a957 | 4728 | name=$func_basename_result |
08d019eb AC |
4729 | case $host in |
4730 | *cygwin* | *mingw* | *cegcc* ) | |
4731 | # if an import library, we need to obtain dlname | |
4732 | if func_win32_import_lib_p "$dlprefile"; then | |
4733 | func_tr_sh "$dlprefile" | |
4734 | eval "curr_lafile=\$libfile_$func_tr_sh_result" | |
6f57a957 | 4735 | dlprefile_dlbasename= |
08d019eb AC |
4736 | if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then |
4737 | # Use subshell, to avoid clobbering current variable values | |
4738 | dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` | |
6f57a957 | 4739 | if test -n "$dlprefile_dlname"; then |
08d019eb | 4740 | func_basename "$dlprefile_dlname" |
6f57a957 | 4741 | dlprefile_dlbasename=$func_basename_result |
08d019eb AC |
4742 | else |
4743 | # no lafile. user explicitly requested -dlpreopen <import library>. | |
4744 | $sharedlib_from_linklib_cmd "$dlprefile" | |
4745 | dlprefile_dlbasename=$sharedlib_from_linklib_result | |
4746 | fi | |
4747 | fi | |
4748 | $opt_dry_run || { | |
6f57a957 | 4749 | if test -n "$dlprefile_dlbasename"; then |
08d019eb AC |
4750 | eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' |
4751 | else | |
4752 | func_warning "Could not compute DLL name from $name" | |
4753 | eval '$ECHO ": $name " >> "$nlist"' | |
4754 | fi | |
4755 | func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 | |
4756 | eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | | |
4757 | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" | |
4758 | } | |
4759 | else # not an import lib | |
4760 | $opt_dry_run || { | |
4761 | eval '$ECHO ": $name " >> "$nlist"' | |
4762 | func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 | |
4763 | eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" | |
4764 | } | |
4765 | fi | |
4766 | ;; | |
4767 | *) | |
4768 | $opt_dry_run || { | |
4769 | eval '$ECHO ": $name " >> "$nlist"' | |
4770 | func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 | |
4771 | eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" | |
4772 | } | |
4773 | ;; | |
4774 | esac | |
7083c021 AC |
4775 | done |
4776 | ||
4777 | $opt_dry_run || { | |
4778 | # Make sure we have at least an empty file. | |
4779 | test -f "$nlist" || : > "$nlist" | |
4780 | ||
4781 | if test -n "$exclude_expsyms"; then | |
4782 | $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T | |
4783 | $MV "$nlist"T "$nlist" | |
db137867 | 4784 | fi |
7083c021 AC |
4785 | |
4786 | # Try sorting and uniquifying the output. | |
4787 | if $GREP -v "^: " < "$nlist" | | |
4788 | if sort -k 3 </dev/null >/dev/null 2>&1; then | |
4789 | sort -k 3 | |
4790 | else | |
4791 | sort +2 | |
4792 | fi | | |
4793 | uniq > "$nlist"S; then | |
4794 | : | |
db137867 | 4795 | else |
7083c021 | 4796 | $GREP -v "^: " < "$nlist" > "$nlist"S |
db137867 | 4797 | fi |
db137867 | 4798 | |
7083c021 AC |
4799 | if test -f "$nlist"S; then |
4800 | eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' | |
db137867 | 4801 | else |
08d019eb | 4802 | echo '/* NONE */' >> "$output_objdir/$my_dlsyms" |
db137867 | 4803 | fi |
db137867 | 4804 | |
6f57a957 AC |
4805 | func_show_eval '$RM "${nlist}I"' |
4806 | if test -n "$global_symbol_to_import"; then | |
4807 | eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' | |
4808 | fi | |
4809 | ||
08d019eb | 4810 | echo >> "$output_objdir/$my_dlsyms" "\ |
db137867 | 4811 | |
7083c021 AC |
4812 | /* The mapping between symbol names and symbols. */ |
4813 | typedef struct { | |
4814 | const char *name; | |
4815 | void *address; | |
4816 | } lt_dlsymlist; | |
08d019eb | 4817 | extern LT_DLSYM_CONST lt_dlsymlist |
6f57a957 AC |
4818 | lt_${my_prefix}_LTX_preloaded_symbols[];\ |
4819 | " | |
4820 | ||
4821 | if test -s "$nlist"I; then | |
4822 | echo >> "$output_objdir/$my_dlsyms" "\ | |
4823 | static void lt_syminit(void) | |
4824 | { | |
4825 | LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; | |
4826 | for (; symbol->name; ++symbol) | |
4827 | {" | |
4828 | $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" | |
4829 | echo >> "$output_objdir/$my_dlsyms" "\ | |
4830 | } | |
4831 | }" | |
4832 | fi | |
4833 | echo >> "$output_objdir/$my_dlsyms" "\ | |
08d019eb | 4834 | LT_DLSYM_CONST lt_dlsymlist |
7083c021 | 4835 | lt_${my_prefix}_LTX_preloaded_symbols[] = |
6f57a957 AC |
4836 | { {\"$my_originator\", (void *) 0}," |
4837 | ||
4838 | if test -s "$nlist"I; then | |
4839 | echo >> "$output_objdir/$my_dlsyms" "\ | |
4840 | {\"@INIT@\", (void *) <_syminit}," | |
4841 | fi | |
db137867 | 4842 | |
7083c021 AC |
4843 | case $need_lib_prefix in |
4844 | no) | |
4845 | eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" | |
4846 | ;; | |
4847 | *) | |
4848 | eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" | |
4849 | ;; | |
4850 | esac | |
08d019eb | 4851 | echo >> "$output_objdir/$my_dlsyms" "\ |
7083c021 AC |
4852 | {0, (void *) 0} |
4853 | }; | |
db137867 | 4854 | |
7083c021 AC |
4855 | /* This works around a problem in FreeBSD linker */ |
4856 | #ifdef FREEBSD_WORKAROUND | |
4857 | static const void *lt_preloaded_setup() { | |
4858 | return lt_${my_prefix}_LTX_preloaded_symbols; | |
4859 | } | |
4860 | #endif | |
4861 | ||
4862 | #ifdef __cplusplus | |
4863 | } | |
4864 | #endif\ | |
4865 | " | |
4866 | } # !$opt_dry_run | |
4867 | ||
4868 | pic_flag_for_symtable= | |
4869 | case "$compile_command " in | |
4870 | *" -static "*) ;; | |
4871 | *) | |
4872 | case $host in | |
4873 | # compiling the symbol table file with pic_flag works around | |
4874 | # a FreeBSD bug that causes programs to crash when -lm is | |
4875 | # linked before any other PIC object. But we must not use | |
4876 | # pic_flag when linking with -static. The problem exists in | |
4877 | # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. | |
54bec06e | 4878 | *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) |
7083c021 AC |
4879 | pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; |
4880 | *-*-hpux*) | |
4881 | pic_flag_for_symtable=" $pic_flag" ;; | |
4882 | *) | |
6f57a957 | 4883 | $my_pic_p && pic_flag_for_symtable=" $pic_flag" |
7083c021 AC |
4884 | ;; |
4885 | esac | |
4886 | ;; | |
4887 | esac | |
4888 | symtab_cflags= | |
4889 | for arg in $LTCFLAGS; do | |
4890 | case $arg in | |
4891 | -pie | -fpie | -fPIE) ;; | |
08d019eb | 4892 | *) func_append symtab_cflags " $arg" ;; |
7083c021 AC |
4893 | esac |
4894 | done | |
db137867 | 4895 | |
7083c021 AC |
4896 | # Now compile the dynamic symbol file. |
4897 | func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' | |
db137867 | 4898 | |
7083c021 | 4899 | # Clean up the generated files. |
6f57a957 | 4900 | func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' |
db137867 | 4901 | |
7083c021 | 4902 | # Transform the symbol file into the correct name. |
6f57a957 | 4903 | symfileobj=$output_objdir/${my_outputname}S.$objext |
7083c021 AC |
4904 | case $host in |
4905 | *cygwin* | *mingw* | *cegcc* ) | |
4906 | if test -f "$output_objdir/$my_outputname.def"; then | |
08d019eb AC |
4907 | compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` |
4908 | finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` | |
7083c021 | 4909 | else |
08d019eb AC |
4910 | compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` |
4911 | finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` | |
db137867 | 4912 | fi |
7083c021 AC |
4913 | ;; |
4914 | *) | |
08d019eb AC |
4915 | compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` |
4916 | finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` | |
7083c021 AC |
4917 | ;; |
4918 | esac | |
4919 | ;; | |
4920 | *) | |
6f57a957 | 4921 | func_fatal_error "unknown suffix for '$my_dlsyms'" |
7083c021 AC |
4922 | ;; |
4923 | esac | |
4924 | else | |
4925 | # We keep going just in case the user didn't refer to | |
4926 | # lt_preloaded_symbols. The linker will fail if global_symbol_pipe | |
4927 | # really was required. | |
db137867 | 4928 | |
7083c021 | 4929 | # Nullify the symbol file. |
08d019eb AC |
4930 | compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` |
4931 | finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` | |
7083c021 AC |
4932 | fi |
4933 | } | |
db137867 | 4934 | |
6f57a957 AC |
4935 | # func_cygming_gnu_implib_p ARG |
4936 | # This predicate returns with zero status (TRUE) if | |
4937 | # ARG is a GNU/binutils-style import library. Returns | |
4938 | # with nonzero status (FALSE) otherwise. | |
4939 | func_cygming_gnu_implib_p () | |
4940 | { | |
4941 | $debug_cmd | |
4942 | ||
4943 | func_to_tool_file "$1" func_convert_file_msys_to_w32 | |
4944 | func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` | |
4945 | test -n "$func_cygming_gnu_implib_tmp" | |
4946 | } | |
4947 | ||
4948 | # func_cygming_ms_implib_p ARG | |
4949 | # This predicate returns with zero status (TRUE) if | |
4950 | # ARG is an MS-style import library. Returns | |
4951 | # with nonzero status (FALSE) otherwise. | |
4952 | func_cygming_ms_implib_p () | |
4953 | { | |
4954 | $debug_cmd | |
4955 | ||
4956 | func_to_tool_file "$1" func_convert_file_msys_to_w32 | |
4957 | func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` | |
4958 | test -n "$func_cygming_ms_implib_tmp" | |
4959 | } | |
4960 | ||
7083c021 AC |
4961 | # func_win32_libid arg |
4962 | # return the library type of file 'arg' | |
4963 | # | |
4964 | # Need a lot of goo to handle *both* DLLs and import libs | |
4965 | # Has to be a shell function in order to 'eat' the argument | |
4966 | # that is supplied when $file_magic_command is called. | |
08d019eb | 4967 | # Despite the name, also deal with 64 bit binaries. |
7083c021 AC |
4968 | func_win32_libid () |
4969 | { | |
6f57a957 AC |
4970 | $debug_cmd |
4971 | ||
4972 | win32_libid_type=unknown | |
7083c021 AC |
4973 | win32_fileres=`file -L $1 2>/dev/null` |
4974 | case $win32_fileres in | |
4975 | *ar\ archive\ import\ library*) # definitely import | |
4976 | win32_libid_type="x86 archive import" | |
4977 | ;; | |
4978 | *ar\ archive*) # could be an import, or static | |
08d019eb | 4979 | # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. |
7083c021 | 4980 | if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | |
08d019eb | 4981 | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then |
6f57a957 AC |
4982 | case $nm_interface in |
4983 | "MS dumpbin") | |
4984 | if func_cygming_ms_implib_p "$1" || | |
4985 | func_cygming_gnu_implib_p "$1" | |
4986 | then | |
4987 | win32_nmres=import | |
4988 | else | |
4989 | win32_nmres= | |
4990 | fi | |
4991 | ;; | |
4992 | *) | |
4993 | func_to_tool_file "$1" func_convert_file_msys_to_w32 | |
4994 | win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | | |
4995 | $SED -n -e ' | |
7083c021 AC |
4996 | 1,100{ |
4997 | / I /{ | |
6f57a957 | 4998 | s|.*|import| |
7083c021 AC |
4999 | p |
5000 | q | |
5001 | } | |
5002 | }'` | |
6f57a957 AC |
5003 | ;; |
5004 | esac | |
7083c021 AC |
5005 | case $win32_nmres in |
5006 | import*) win32_libid_type="x86 archive import";; | |
5007 | *) win32_libid_type="x86 archive static";; | |
5008 | esac | |
5009 | fi | |
5010 | ;; | |
5011 | *DLL*) | |
5012 | win32_libid_type="x86 DLL" | |
5013 | ;; | |
5014 | *executable*) # but shell scripts are "executable" too... | |
5015 | case $win32_fileres in | |
5016 | *MS\ Windows\ PE\ Intel*) | |
5017 | win32_libid_type="x86 DLL" | |
5018 | ;; | |
5019 | esac | |
5020 | ;; | |
5021 | esac | |
5022 | $ECHO "$win32_libid_type" | |
5023 | } | |
db137867 | 5024 | |
08d019eb AC |
5025 | # func_cygming_dll_for_implib ARG |
5026 | # | |
5027 | # Platform-specific function to extract the | |
5028 | # name of the DLL associated with the specified | |
5029 | # import library ARG. | |
5030 | # Invoked by eval'ing the libtool variable | |
5031 | # $sharedlib_from_linklib_cmd | |
5032 | # Result is available in the variable | |
5033 | # $sharedlib_from_linklib_result | |
5034 | func_cygming_dll_for_implib () | |
5035 | { | |
6f57a957 AC |
5036 | $debug_cmd |
5037 | ||
08d019eb AC |
5038 | sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` |
5039 | } | |
5040 | ||
5041 | # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs | |
5042 | # | |
5043 | # The is the core of a fallback implementation of a | |
5044 | # platform-specific function to extract the name of the | |
5045 | # DLL associated with the specified import library LIBNAME. | |
5046 | # | |
5047 | # SECTION_NAME is either .idata$6 or .idata$7, depending | |
5048 | # on the platform and compiler that created the implib. | |
5049 | # | |
5050 | # Echos the name of the DLL associated with the | |
5051 | # specified import library. | |
5052 | func_cygming_dll_for_implib_fallback_core () | |
5053 | { | |
6f57a957 AC |
5054 | $debug_cmd |
5055 | ||
08d019eb AC |
5056 | match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` |
5057 | $OBJDUMP -s --section "$1" "$2" 2>/dev/null | | |
5058 | $SED '/^Contents of section '"$match_literal"':/{ | |
5059 | # Place marker at beginning of archive member dllname section | |
5060 | s/.*/====MARK====/ | |
5061 | p | |
5062 | d | |
5063 | } | |
5064 | # These lines can sometimes be longer than 43 characters, but | |
5065 | # are always uninteresting | |
5066 | /:[ ]*file format pe[i]\{,1\}-/d | |
5067 | /^In archive [^:]*:/d | |
5068 | # Ensure marker is printed | |
5069 | /^====MARK====/p | |
5070 | # Remove all lines with less than 43 characters | |
5071 | /^.\{43\}/!d | |
5072 | # From remaining lines, remove first 43 characters | |
5073 | s/^.\{43\}//' | | |
5074 | $SED -n ' | |
5075 | # Join marker and all lines until next marker into a single line | |
5076 | /^====MARK====/ b para | |
5077 | H | |
5078 | $ b para | |
5079 | b | |
5080 | :para | |
5081 | x | |
5082 | s/\n//g | |
5083 | # Remove the marker | |
5084 | s/^====MARK====// | |
5085 | # Remove trailing dots and whitespace | |
5086 | s/[\. \t]*$// | |
5087 | ||
5088 | /./p' | | |
5089 | # we now have a list, one entry per line, of the stringified | |
5090 | # contents of the appropriate section of all members of the | |
6f57a957 AC |
5091 | # archive that possess that section. Heuristic: eliminate |
5092 | # all those that have a first or second character that is | |
08d019eb AC |
5093 | # a '.' (that is, objdump's representation of an unprintable |
5094 | # character.) This should work for all archives with less than | |
5095 | # 0x302f exports -- but will fail for DLLs whose name actually | |
5096 | # begins with a literal '.' or a single character followed by | |
5097 | # a '.'. | |
5098 | # | |
5099 | # Of those that remain, print the first one. | |
5100 | $SED -e '/^\./d;/^.\./d;q' | |
5101 | } | |
5102 | ||
08d019eb AC |
5103 | # func_cygming_dll_for_implib_fallback ARG |
5104 | # Platform-specific function to extract the | |
5105 | # name of the DLL associated with the specified | |
5106 | # import library ARG. | |
5107 | # | |
5108 | # This fallback implementation is for use when $DLLTOOL | |
5109 | # does not support the --identify-strict option. | |
5110 | # Invoked by eval'ing the libtool variable | |
5111 | # $sharedlib_from_linklib_cmd | |
5112 | # Result is available in the variable | |
5113 | # $sharedlib_from_linklib_result | |
5114 | func_cygming_dll_for_implib_fallback () | |
5115 | { | |
6f57a957 AC |
5116 | $debug_cmd |
5117 | ||
5118 | if func_cygming_gnu_implib_p "$1"; then | |
08d019eb AC |
5119 | # binutils import library |
5120 | sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` | |
6f57a957 | 5121 | elif func_cygming_ms_implib_p "$1"; then |
08d019eb AC |
5122 | # ms-generated import library |
5123 | sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` | |
5124 | else | |
5125 | # unknown | |
6f57a957 | 5126 | sharedlib_from_linklib_result= |
08d019eb AC |
5127 | fi |
5128 | } | |
db137867 | 5129 | |
db137867 | 5130 | |
7083c021 AC |
5131 | # func_extract_an_archive dir oldlib |
5132 | func_extract_an_archive () | |
5133 | { | |
6f57a957 AC |
5134 | $debug_cmd |
5135 | ||
5136 | f_ex_an_ar_dir=$1; shift | |
5137 | f_ex_an_ar_oldlib=$1 | |
5138 | if test yes = "$lock_old_archive_extraction"; then | |
08d019eb AC |
5139 | lockfile=$f_ex_an_ar_oldlib.lock |
5140 | until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do | |
5141 | func_echo "Waiting for $lockfile to be removed" | |
5142 | sleep 2 | |
5143 | done | |
5144 | fi | |
5145 | func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ | |
5146 | 'stat=$?; rm -f "$lockfile"; exit $stat' | |
6f57a957 | 5147 | if test yes = "$lock_old_archive_extraction"; then |
08d019eb AC |
5148 | $opt_dry_run || rm -f "$lockfile" |
5149 | fi | |
7083c021 AC |
5150 | if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then |
5151 | : | |
5152 | else | |
5153 | func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" | |
5154 | fi | |
5155 | } | |
db137867 | 5156 | |
db137867 | 5157 | |
7083c021 AC |
5158 | # func_extract_archives gentop oldlib ... |
5159 | func_extract_archives () | |
5160 | { | |
6f57a957 AC |
5161 | $debug_cmd |
5162 | ||
5163 | my_gentop=$1; shift | |
7083c021 | 5164 | my_oldlibs=${1+"$@"} |
6f57a957 AC |
5165 | my_oldobjs= |
5166 | my_xlib= | |
5167 | my_xabs= | |
5168 | my_xdir= | |
db137867 | 5169 | |
7083c021 AC |
5170 | for my_xlib in $my_oldlibs; do |
5171 | # Extract the objects. | |
5172 | case $my_xlib in | |
6f57a957 | 5173 | [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; |
7083c021 AC |
5174 | *) my_xabs=`pwd`"/$my_xlib" ;; |
5175 | esac | |
5176 | func_basename "$my_xlib" | |
6f57a957 | 5177 | my_xlib=$func_basename_result |
7083c021 AC |
5178 | my_xlib_u=$my_xlib |
5179 | while :; do | |
5180 | case " $extracted_archives " in | |
5181 | *" $my_xlib_u "*) | |
5182 | func_arith $extracted_serial + 1 | |
5183 | extracted_serial=$func_arith_result | |
5184 | my_xlib_u=lt$extracted_serial-$my_xlib ;; | |
5185 | *) break ;; | |
5186 | esac | |
5187 | done | |
5188 | extracted_archives="$extracted_archives $my_xlib_u" | |
6f57a957 | 5189 | my_xdir=$my_gentop/$my_xlib_u |
db137867 | 5190 | |
7083c021 | 5191 | func_mkdir_p "$my_xdir" |
db137867 | 5192 | |
7083c021 AC |
5193 | case $host in |
5194 | *-darwin*) | |
5195 | func_verbose "Extracting $my_xabs" | |
5196 | # Do not bother doing anything if just a dry run | |
5197 | $opt_dry_run || { | |
5198 | darwin_orig_dir=`pwd` | |
5199 | cd $my_xdir || exit $? | |
5200 | darwin_archive=$my_xabs | |
5201 | darwin_curdir=`pwd` | |
6f57a957 AC |
5202 | func_basename "$darwin_archive" |
5203 | darwin_base_archive=$func_basename_result | |
7083c021 AC |
5204 | darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` |
5205 | if test -n "$darwin_arches"; then | |
5206 | darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` | |
5207 | darwin_arch= | |
5208 | func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" | |
6f57a957 AC |
5209 | for darwin_arch in $darwin_arches; do |
5210 | func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" | |
5211 | $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" | |
5212 | cd "unfat-$$/$darwin_base_archive-$darwin_arch" | |
5213 | func_extract_an_archive "`pwd`" "$darwin_base_archive" | |
7083c021 | 5214 | cd "$darwin_curdir" |
6f57a957 | 5215 | $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" |
7083c021 AC |
5216 | done # $darwin_arches |
5217 | ## Okay now we've a bunch of thin objects, gotta fatten them up :) | |
6f57a957 | 5218 | darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` |
7083c021 AC |
5219 | darwin_file= |
5220 | darwin_files= | |
5221 | for darwin_file in $darwin_filelist; do | |
08d019eb | 5222 | darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` |
7083c021 AC |
5223 | $LIPO -create -output "$darwin_file" $darwin_files |
5224 | done # $darwin_filelist | |
5225 | $RM -rf unfat-$$ | |
5226 | cd "$darwin_orig_dir" | |
db137867 | 5227 | else |
7083c021 AC |
5228 | cd $darwin_orig_dir |
5229 | func_extract_an_archive "$my_xdir" "$my_xabs" | |
5230 | fi # $darwin_arches | |
5231 | } # !$opt_dry_run | |
5232 | ;; | |
5233 | *) | |
5234 | func_extract_an_archive "$my_xdir" "$my_xabs" | |
5235 | ;; | |
5236 | esac | |
08d019eb | 5237 | my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` |
7083c021 | 5238 | done |
db137867 | 5239 | |
6f57a957 | 5240 | func_extract_archives_result=$my_oldobjs |
7083c021 | 5241 | } |
db137867 | 5242 | |
db137867 | 5243 | |
08d019eb AC |
5244 | # func_emit_wrapper [arg=no] |
5245 | # | |
5246 | # Emit a libtool wrapper script on stdout. | |
5247 | # Don't directly open a file because we may want to | |
5248 | # incorporate the script contents within a cygwin/mingw | |
5249 | # wrapper executable. Must ONLY be called from within | |
5250 | # func_mode_link because it depends on a number of variables | |
5251 | # set therein. | |
7083c021 | 5252 | # |
08d019eb AC |
5253 | # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR |
5254 | # variable will take. If 'yes', then the emitted script | |
6f57a957 | 5255 | # will assume that the directory where it is stored is |
08d019eb AC |
5256 | # the $objdir directory. This is a cygwin/mingw-specific |
5257 | # behavior. | |
5258 | func_emit_wrapper () | |
7083c021 | 5259 | { |
08d019eb | 5260 | func_emit_wrapper_arg1=${1-no} |
db137867 | 5261 | |
7083c021 AC |
5262 | $ECHO "\ |
5263 | #! $SHELL | |
db137867 | 5264 | |
7083c021 | 5265 | # $output - temporary wrapper script for $objdir/$outputname |
6f57a957 | 5266 | # Generated by $PROGRAM (GNU $PACKAGE) $VERSION |
7083c021 AC |
5267 | # |
5268 | # The $output program cannot be directly executed until all the libtool | |
5269 | # libraries that it depends on are installed. | |
5270 | # | |
5271 | # This wrapper script should never be moved out of the build directory. | |
5272 | # If it is, it will not operate correctly. | |
db137867 | 5273 | |
7083c021 AC |
5274 | # Sed substitution that helps us do robust quoting. It backslashifies |
5275 | # metacharacters that are still active within double-quoted strings. | |
7083c021 | 5276 | sed_quote_subst='$sed_quote_subst' |
db137867 | 5277 | |
7083c021 AC |
5278 | # Be Bourne compatible |
5279 | if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then | |
5280 | emulate sh | |
5281 | NULLCMD=: | |
5282 | # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which | |
5283 | # is contrary to our usage. Disable this feature. | |
5284 | alias -g '\${1+\"\$@\"}'='\"\$@\"' | |
5285 | setopt NO_GLOB_SUBST | |
5286 | else | |
5287 | case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac | |
5288 | fi | |
5289 | BIN_SH=xpg4; export BIN_SH # for Tru64 | |
5290 | DUALCASE=1; export DUALCASE # for MKS sh | |
db137867 | 5291 | |
7083c021 AC |
5292 | # The HP-UX ksh and POSIX shell print the target directory to stdout |
5293 | # if CDPATH is set. | |
5294 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH | |
db137867 | 5295 | |
7083c021 | 5296 | relink_command=\"$relink_command\" |
db137867 | 5297 | |
7083c021 AC |
5298 | # This environment variable determines our operation mode. |
5299 | if test \"\$libtool_install_magic\" = \"$magic\"; then | |
5300 | # install mode needs the following variables: | |
5301 | generated_by_libtool_version='$macro_version' | |
5302 | notinst_deplibs='$notinst_deplibs' | |
5303 | else | |
5304 | # When we are sourced in execute mode, \$file and \$ECHO are already set. | |
5305 | if test \"\$libtool_execute_magic\" != \"$magic\"; then | |
08d019eb AC |
5306 | file=\"\$0\"" |
5307 | ||
fe037171 EM |
5308 | func_quote "$ECHO" |
5309 | qECHO=$func_quote_result | |
08d019eb AC |
5310 | $ECHO "\ |
5311 | ||
5312 | # A function that is used when there is no print builtin or printf. | |
5313 | func_fallback_echo () | |
5314 | { | |
5315 | eval 'cat <<_LTECHO_EOF | |
5316 | \$1 | |
5317 | _LTECHO_EOF' | |
5318 | } | |
5319 | ECHO=\"$qECHO\" | |
5320 | fi | |
5321 | ||
5322 | # Very basic option parsing. These options are (a) specific to | |
5323 | # the libtool wrapper, (b) are identical between the wrapper | |
6f57a957 | 5324 | # /script/ and the wrapper /executable/ that is used only on |
08d019eb | 5325 | # windows platforms, and (c) all begin with the string "--lt-" |
6f57a957 | 5326 | # (application programs are unlikely to have options that match |
08d019eb AC |
5327 | # this pattern). |
5328 | # | |
5329 | # There are only two supported options: --lt-debug and | |
5330 | # --lt-dump-script. There is, deliberately, no --lt-help. | |
5331 | # | |
5332 | # The first argument to this parsing function should be the | |
5333 | # script's $0 value, followed by "$@". | |
5334 | lt_option_debug= | |
5335 | func_parse_lt_options () | |
5336 | { | |
5337 | lt_script_arg0=\$0 | |
5338 | shift | |
5339 | for lt_opt | |
5340 | do | |
5341 | case \"\$lt_opt\" in | |
5342 | --lt-debug) lt_option_debug=1 ;; | |
5343 | --lt-dump-script) | |
5344 | lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` | |
5345 | test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. | |
5346 | lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` | |
5347 | cat \"\$lt_dump_D/\$lt_dump_F\" | |
5348 | exit 0 | |
5349 | ;; | |
5350 | --lt-*) | |
5351 | \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 | |
5352 | exit 1 | |
5353 | ;; | |
5354 | esac | |
5355 | done | |
5356 | ||
5357 | # Print the debug banner immediately: | |
5358 | if test -n \"\$lt_option_debug\"; then | |
6f57a957 | 5359 | echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 |
08d019eb AC |
5360 | fi |
5361 | } | |
5362 | ||
5363 | # Used when --lt-debug. Prints its arguments to stdout | |
5364 | # (redirection is the responsibility of the caller) | |
5365 | func_lt_dump_args () | |
5366 | { | |
5367 | lt_dump_args_N=1; | |
5368 | for lt_arg | |
5369 | do | |
6f57a957 | 5370 | \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" |
08d019eb AC |
5371 | lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` |
5372 | done | |
5373 | } | |
5374 | ||
5375 | # Core function for launching the target application | |
5376 | func_exec_program_core () | |
5377 | { | |
7083c021 | 5378 | " |
08d019eb AC |
5379 | case $host in |
5380 | # Backslashes separate directories on plain windows | |
5381 | *-*-mingw | *-*-os2* | *-cegcc*) | |
5382 | $ECHO "\ | |
5383 | if test -n \"\$lt_option_debug\"; then | |
6f57a957 | 5384 | \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 |
08d019eb AC |
5385 | func_lt_dump_args \${1+\"\$@\"} 1>&2 |
5386 | fi | |
5387 | exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} | |
5388 | " | |
5389 | ;; | |
5390 | ||
5391 | *) | |
5392 | $ECHO "\ | |
5393 | if test -n \"\$lt_option_debug\"; then | |
6f57a957 | 5394 | \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 |
08d019eb AC |
5395 | func_lt_dump_args \${1+\"\$@\"} 1>&2 |
5396 | fi | |
5397 | exec \"\$progdir/\$program\" \${1+\"\$@\"} | |
5398 | " | |
5399 | ;; | |
5400 | esac | |
5401 | $ECHO "\ | |
5402 | \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 | |
5403 | exit 1 | |
5404 | } | |
5405 | ||
5406 | # A function to encapsulate launching the target application | |
5407 | # Strips options in the --lt-* namespace from \$@ and | |
5408 | # launches target application with the remaining arguments. | |
5409 | func_exec_program () | |
5410 | { | |
54bec06e AC |
5411 | case \" \$* \" in |
5412 | *\\ --lt-*) | |
5413 | for lt_wr_arg | |
5414 | do | |
5415 | case \$lt_wr_arg in | |
5416 | --lt-*) ;; | |
5417 | *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; | |
5418 | esac | |
5419 | shift | |
5420 | done ;; | |
5421 | esac | |
08d019eb AC |
5422 | func_exec_program_core \${1+\"\$@\"} |
5423 | } | |
5424 | ||
5425 | # Parse options | |
5426 | func_parse_lt_options \"\$0\" \${1+\"\$@\"} | |
db137867 | 5427 | |
7083c021 | 5428 | # Find the directory that this script lives in. |
08d019eb | 5429 | thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` |
7083c021 | 5430 | test \"x\$thisdir\" = \"x\$file\" && thisdir=. |
db137867 | 5431 | |
7083c021 | 5432 | # Follow symbolic links until we get to the real thisdir. |
08d019eb | 5433 | file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` |
7083c021 | 5434 | while test -n \"\$file\"; do |
08d019eb | 5435 | destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` |
db137867 | 5436 | |
7083c021 AC |
5437 | # If there was a directory component, then change thisdir. |
5438 | if test \"x\$destdir\" != \"x\$file\"; then | |
5439 | case \"\$destdir\" in | |
5440 | [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; | |
5441 | *) thisdir=\"\$thisdir/\$destdir\" ;; | |
db137867 | 5442 | esac |
7083c021 | 5443 | fi |
db137867 | 5444 | |
08d019eb AC |
5445 | file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` |
5446 | file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` | |
7083c021 | 5447 | done |
db137867 | 5448 | |
7083c021 AC |
5449 | # Usually 'no', except on cygwin/mingw when embedded into |
5450 | # the cwrapper. | |
08d019eb | 5451 | WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 |
7083c021 AC |
5452 | if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then |
5453 | # special case for '.' | |
5454 | if test \"\$thisdir\" = \".\"; then | |
5455 | thisdir=\`pwd\` | |
5456 | fi | |
5457 | # remove .libs from thisdir | |
5458 | case \"\$thisdir\" in | |
08d019eb | 5459 | *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; |
7083c021 AC |
5460 | $objdir ) thisdir=. ;; |
5461 | esac | |
5462 | fi | |
5463 | ||
5464 | # Try to get the absolute directory name. | |
5465 | absdir=\`cd \"\$thisdir\" && pwd\` | |
5466 | test -n \"\$absdir\" && thisdir=\"\$absdir\" | |
5467 | " | |
5468 | ||
6f57a957 | 5469 | if test yes = "$fast_install"; then |
7083c021 AC |
5470 | $ECHO "\ |
5471 | program=lt-'$outputname'$exeext | |
5472 | progdir=\"\$thisdir/$objdir\" | |
5473 | ||
5474 | if test ! -f \"\$progdir/\$program\" || | |
6f57a957 | 5475 | { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ |
7083c021 AC |
5476 | test \"X\$file\" != \"X\$progdir/\$program\"; }; then |
5477 | ||
5478 | file=\"\$\$-\$program\" | |
5479 | ||
5480 | if test ! -d \"\$progdir\"; then | |
5481 | $MKDIR \"\$progdir\" | |
5482 | else | |
5483 | $RM \"\$progdir/\$file\" | |
5484 | fi" | |
5485 | ||
5486 | $ECHO "\ | |
5487 | ||
5488 | # relink executable if necessary | |
5489 | if test -n \"\$relink_command\"; then | |
5490 | if relink_command_output=\`eval \$relink_command 2>&1\`; then : | |
5491 | else | |
6f57a957 | 5492 | \$ECHO \"\$relink_command_output\" >&2 |
7083c021 AC |
5493 | $RM \"\$progdir/\$file\" |
5494 | exit 1 | |
db137867 | 5495 | fi |
7083c021 | 5496 | fi |
db137867 | 5497 | |
7083c021 AC |
5498 | $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || |
5499 | { $RM \"\$progdir/\$program\"; | |
5500 | $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } | |
5501 | $RM \"\$progdir/\$file\" | |
5502 | fi" | |
5503 | else | |
5504 | $ECHO "\ | |
5505 | program='$outputname' | |
5506 | progdir=\"\$thisdir/$objdir\" | |
5507 | " | |
db137867 AC |
5508 | fi |
5509 | ||
7083c021 | 5510 | $ECHO "\ |
db137867 | 5511 | |
7083c021 | 5512 | if test -f \"\$progdir/\$program\"; then" |
db137867 | 5513 | |
08d019eb AC |
5514 | # fixup the dll searchpath if we need to. |
5515 | # | |
5516 | # Fix the DLL searchpath if we need to. Do this before prepending | |
5517 | # to shlibpath, because on Windows, both are PATH and uninstalled | |
5518 | # libraries must come first. | |
5519 | if test -n "$dllsearchpath"; then | |
5520 | $ECHO "\ | |
5521 | # Add the dll search path components to the executable PATH | |
5522 | PATH=$dllsearchpath:\$PATH | |
5523 | " | |
5524 | fi | |
5525 | ||
7083c021 | 5526 | # Export our shlibpath_var if we have one. |
6f57a957 | 5527 | if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then |
7083c021 AC |
5528 | $ECHO "\ |
5529 | # Add our own library path to $shlibpath_var | |
5530 | $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" | |
db137867 | 5531 | |
7083c021 AC |
5532 | # Some systems cannot cope with colon-terminated $shlibpath_var |
5533 | # The second colon is a workaround for a bug in BeOS R4 sed | |
08d019eb | 5534 | $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` |
7083c021 AC |
5535 | |
5536 | export $shlibpath_var | |
5537 | " | |
db137867 AC |
5538 | fi |
5539 | ||
7083c021 AC |
5540 | $ECHO "\ |
5541 | if test \"\$libtool_execute_magic\" != \"$magic\"; then | |
5542 | # Run the actual program with our arguments. | |
08d019eb | 5543 | func_exec_program \${1+\"\$@\"} |
7083c021 AC |
5544 | fi |
5545 | else | |
5546 | # The program doesn't exist. | |
6f57a957 | 5547 | \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 |
7083c021 | 5548 | \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 |
08d019eb | 5549 | \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 |
7083c021 AC |
5550 | exit 1 |
5551 | fi | |
5552 | fi\ | |
5553 | " | |
5554 | } | |
db137867 | 5555 | |
db137867 | 5556 | |
7083c021 AC |
5557 | # func_emit_cwrapperexe_src |
5558 | # emit the source code for a wrapper executable on stdout | |
5559 | # Must ONLY be called from within func_mode_link because | |
5560 | # it depends on a number of variable set therein. | |
5561 | func_emit_cwrapperexe_src () | |
5562 | { | |
5563 | cat <<EOF | |
db137867 | 5564 | |
7083c021 | 5565 | /* $cwrappersource - temporary wrapper executable for $objdir/$outputname |
6f57a957 | 5566 | Generated by $PROGRAM (GNU $PACKAGE) $VERSION |
db137867 | 5567 | |
7083c021 AC |
5568 | The $output program cannot be directly executed until all the libtool |
5569 | libraries that it depends on are installed. | |
db137867 | 5570 | |
7083c021 AC |
5571 | This wrapper executable should never be moved out of the build directory. |
5572 | If it is, it will not operate correctly. | |
7083c021 AC |
5573 | */ |
5574 | EOF | |
5575 | cat <<"EOF" | |
08d019eb AC |
5576 | #ifdef _MSC_VER |
5577 | # define _CRT_SECURE_NO_DEPRECATE 1 | |
5578 | #endif | |
7083c021 AC |
5579 | #include <stdio.h> |
5580 | #include <stdlib.h> | |
5581 | #ifdef _MSC_VER | |
5582 | # include <direct.h> | |
5583 | # include <process.h> | |
5584 | # include <io.h> | |
7083c021 AC |
5585 | #else |
5586 | # include <unistd.h> | |
5587 | # include <stdint.h> | |
5588 | # ifdef __CYGWIN__ | |
5589 | # include <io.h> | |
7083c021 AC |
5590 | # endif |
5591 | #endif | |
5592 | #include <malloc.h> | |
5593 | #include <stdarg.h> | |
5594 | #include <assert.h> | |
5595 | #include <string.h> | |
5596 | #include <ctype.h> | |
5597 | #include <errno.h> | |
5598 | #include <fcntl.h> | |
5599 | #include <sys/stat.h> | |
db137867 | 5600 | |
6f57a957 AC |
5601 | #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) |
5602 | ||
08d019eb | 5603 | /* declarations of non-ANSI functions */ |
6f57a957 | 5604 | #if defined __MINGW32__ |
08d019eb AC |
5605 | # ifdef __STRICT_ANSI__ |
5606 | int _putenv (const char *); | |
5607 | # endif | |
6f57a957 | 5608 | #elif defined __CYGWIN__ |
08d019eb AC |
5609 | # ifdef __STRICT_ANSI__ |
5610 | char *realpath (const char *, char *); | |
5611 | int putenv (char *); | |
5612 | int setenv (const char *, const char *, int); | |
5613 | # endif | |
6f57a957 | 5614 | /* #elif defined other_platform || defined ... */ |
08d019eb AC |
5615 | #endif |
5616 | ||
5617 | /* portability defines, excluding path handling macros */ | |
6f57a957 | 5618 | #if defined _MSC_VER |
08d019eb AC |
5619 | # define setmode _setmode |
5620 | # define stat _stat | |
5621 | # define chmod _chmod | |
5622 | # define getcwd _getcwd | |
5623 | # define putenv _putenv | |
5624 | # define S_IXUSR _S_IEXEC | |
6f57a957 | 5625 | #elif defined __MINGW32__ |
08d019eb AC |
5626 | # define setmode _setmode |
5627 | # define stat _stat | |
5628 | # define chmod _chmod | |
5629 | # define getcwd _getcwd | |
5630 | # define putenv _putenv | |
6f57a957 | 5631 | #elif defined __CYGWIN__ |
08d019eb AC |
5632 | # define HAVE_SETENV |
5633 | # define FOPEN_WB "wb" | |
6f57a957 | 5634 | /* #elif defined other platforms ... */ |
08d019eb AC |
5635 | #endif |
5636 | ||
6f57a957 | 5637 | #if defined PATH_MAX |
7083c021 | 5638 | # define LT_PATHMAX PATH_MAX |
6f57a957 | 5639 | #elif defined MAXPATHLEN |
7083c021 AC |
5640 | # define LT_PATHMAX MAXPATHLEN |
5641 | #else | |
5642 | # define LT_PATHMAX 1024 | |
5643 | #endif | |
db137867 | 5644 | |
7083c021 AC |
5645 | #ifndef S_IXOTH |
5646 | # define S_IXOTH 0 | |
5647 | #endif | |
5648 | #ifndef S_IXGRP | |
5649 | # define S_IXGRP 0 | |
5650 | #endif | |
db137867 | 5651 | |
08d019eb | 5652 | /* path handling portability macros */ |
7083c021 AC |
5653 | #ifndef DIR_SEPARATOR |
5654 | # define DIR_SEPARATOR '/' | |
5655 | # define PATH_SEPARATOR ':' | |
5656 | #endif | |
db137867 | 5657 | |
6f57a957 AC |
5658 | #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ |
5659 | defined __OS2__ | |
7083c021 AC |
5660 | # define HAVE_DOS_BASED_FILE_SYSTEM |
5661 | # define FOPEN_WB "wb" | |
5662 | # ifndef DIR_SEPARATOR_2 | |
5663 | # define DIR_SEPARATOR_2 '\\' | |
5664 | # endif | |
5665 | # ifndef PATH_SEPARATOR_2 | |
5666 | # define PATH_SEPARATOR_2 ';' | |
5667 | # endif | |
5668 | #endif | |
db137867 | 5669 | |
7083c021 AC |
5670 | #ifndef DIR_SEPARATOR_2 |
5671 | # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) | |
5672 | #else /* DIR_SEPARATOR_2 */ | |
5673 | # define IS_DIR_SEPARATOR(ch) \ | |
5674 | (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) | |
5675 | #endif /* DIR_SEPARATOR_2 */ | |
db137867 | 5676 | |
7083c021 AC |
5677 | #ifndef PATH_SEPARATOR_2 |
5678 | # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) | |
5679 | #else /* PATH_SEPARATOR_2 */ | |
5680 | # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) | |
5681 | #endif /* PATH_SEPARATOR_2 */ | |
db137867 | 5682 | |
7083c021 AC |
5683 | #ifndef FOPEN_WB |
5684 | # define FOPEN_WB "w" | |
5685 | #endif | |
5686 | #ifndef _O_BINARY | |
5687 | # define _O_BINARY 0 | |
5688 | #endif | |
db137867 | 5689 | |
7083c021 AC |
5690 | #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) |
5691 | #define XFREE(stale) do { \ | |
6f57a957 | 5692 | if (stale) { free (stale); stale = 0; } \ |
7083c021 | 5693 | } while (0) |
db137867 | 5694 | |
6f57a957 | 5695 | #if defined LT_DEBUGWRAPPER |
08d019eb | 5696 | static int lt_debug = 1; |
7083c021 | 5697 | #else |
08d019eb | 5698 | static int lt_debug = 0; |
7083c021 | 5699 | #endif |
db137867 | 5700 | |
08d019eb | 5701 | const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ |
db137867 | 5702 | |
7083c021 AC |
5703 | void *xmalloc (size_t num); |
5704 | char *xstrdup (const char *string); | |
5705 | const char *base_name (const char *name); | |
5706 | char *find_executable (const char *wrapper); | |
5707 | char *chase_symlinks (const char *pathspec); | |
5708 | int make_executable (const char *path); | |
5709 | int check_executable (const char *path); | |
5710 | char *strendzap (char *str, const char *pat); | |
08d019eb AC |
5711 | void lt_debugprintf (const char *file, int line, const char *fmt, ...); |
5712 | void lt_fatal (const char *file, int line, const char *message, ...); | |
5713 | static const char *nonnull (const char *s); | |
5714 | static const char *nonempty (const char *s); | |
7083c021 AC |
5715 | void lt_setenv (const char *name, const char *value); |
5716 | char *lt_extend_str (const char *orig_value, const char *add, int to_end); | |
7083c021 AC |
5717 | void lt_update_exe_path (const char *name, const char *value); |
5718 | void lt_update_lib_path (const char *name, const char *value); | |
08d019eb AC |
5719 | char **prepare_spawn (char **argv); |
5720 | void lt_dump_script (FILE *f); | |
7083c021 | 5721 | EOF |
7083c021 AC |
5722 | |
5723 | cat <<EOF | |
6f57a957 AC |
5724 | #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) |
5725 | # define externally_visible volatile | |
5726 | #else | |
5727 | # define externally_visible __attribute__((externally_visible)) volatile | |
5728 | #endif | |
5729 | externally_visible const char * MAGIC_EXE = "$magic_exe"; | |
7083c021 AC |
5730 | const char * LIB_PATH_VARNAME = "$shlibpath_var"; |
5731 | EOF | |
db137867 | 5732 | |
6f57a957 | 5733 | if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then |
08d019eb | 5734 | func_to_host_path "$temp_rpath" |
7083c021 | 5735 | cat <<EOF |
08d019eb | 5736 | const char * LIB_PATH_VALUE = "$func_to_host_path_result"; |
7083c021 AC |
5737 | EOF |
5738 | else | |
5739 | cat <<"EOF" | |
5740 | const char * LIB_PATH_VALUE = ""; | |
5741 | EOF | |
db137867 | 5742 | fi |
db137867 | 5743 | |
7083c021 | 5744 | if test -n "$dllsearchpath"; then |
08d019eb | 5745 | func_to_host_path "$dllsearchpath:" |
7083c021 AC |
5746 | cat <<EOF |
5747 | const char * EXE_PATH_VARNAME = "PATH"; | |
08d019eb | 5748 | const char * EXE_PATH_VALUE = "$func_to_host_path_result"; |
db137867 | 5749 | EOF |
db137867 | 5750 | else |
7083c021 AC |
5751 | cat <<"EOF" |
5752 | const char * EXE_PATH_VARNAME = ""; | |
5753 | const char * EXE_PATH_VALUE = ""; | |
5754 | EOF | |
db137867 | 5755 | fi |
7083c021 | 5756 | |
6f57a957 | 5757 | if test yes = "$fast_install"; then |
7083c021 AC |
5758 | cat <<EOF |
5759 | const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ | |
5760 | EOF | |
db137867 | 5761 | else |
7083c021 AC |
5762 | cat <<EOF |
5763 | const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ | |
5764 | EOF | |
db137867 | 5765 | fi |
db137867 | 5766 | |
db137867 | 5767 | |
7083c021 | 5768 | cat <<"EOF" |
db137867 | 5769 | |
7083c021 | 5770 | #define LTWRAPPER_OPTION_PREFIX "--lt-" |
db137867 | 5771 | |
7083c021 | 5772 | static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; |
7083c021 | 5773 | static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; |
08d019eb | 5774 | static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; |
db137867 | 5775 | |
7083c021 AC |
5776 | int |
5777 | main (int argc, char *argv[]) | |
5778 | { | |
5779 | char **newargz; | |
5780 | int newargc; | |
5781 | char *tmp_pathspec; | |
5782 | char *actual_cwrapper_path; | |
5783 | char *actual_cwrapper_name; | |
5784 | char *target_name; | |
5785 | char *lt_argv_zero; | |
6f57a957 | 5786 | int rval = 127; |
db137867 | 5787 | |
7083c021 | 5788 | int i; |
db137867 | 5789 | |
7083c021 | 5790 | program_name = (char *) xstrdup (base_name (argv[0])); |
6f57a957 | 5791 | newargz = XMALLOC (char *, (size_t) argc + 1); |
db137867 | 5792 | |
08d019eb AC |
5793 | /* very simple arg parsing; don't want to rely on getopt |
5794 | * also, copy all non cwrapper options to newargz, except | |
5795 | * argz[0], which is handled differently | |
5796 | */ | |
5797 | newargc=0; | |
7083c021 AC |
5798 | for (i = 1; i < argc; i++) |
5799 | { | |
6f57a957 | 5800 | if (STREQ (argv[i], dumpscript_opt)) |
7083c021 AC |
5801 | { |
5802 | EOF | |
6f57a957 | 5803 | case $host in |
7083c021 AC |
5804 | *mingw* | *cygwin* ) |
5805 | # make stdout use "unix" line endings | |
5806 | echo " setmode(1,_O_BINARY);" | |
5807 | ;; | |
5808 | esac | |
db137867 | 5809 | |
7083c021 | 5810 | cat <<"EOF" |
08d019eb | 5811 | lt_dump_script (stdout); |
7083c021 AC |
5812 | return 0; |
5813 | } | |
6f57a957 | 5814 | if (STREQ (argv[i], debug_opt)) |
08d019eb AC |
5815 | { |
5816 | lt_debug = 1; | |
5817 | continue; | |
5818 | } | |
6f57a957 | 5819 | if (STREQ (argv[i], ltwrapper_option_prefix)) |
08d019eb AC |
5820 | { |
5821 | /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX | |
5822 | namespace, but it is not one of the ones we know about and | |
5823 | have already dealt with, above (inluding dump-script), then | |
5824 | report an error. Otherwise, targets might begin to believe | |
5825 | they are allowed to use options in the LTWRAPPER_OPTION_PREFIX | |
5826 | namespace. The first time any user complains about this, we'll | |
5827 | need to make LTWRAPPER_OPTION_PREFIX a configure-time option | |
5828 | or a configure.ac-settable value. | |
5829 | */ | |
5830 | lt_fatal (__FILE__, __LINE__, | |
5831 | "unrecognized %s option: '%s'", | |
5832 | ltwrapper_option_prefix, argv[i]); | |
5833 | } | |
5834 | /* otherwise ... */ | |
5835 | newargz[++newargc] = xstrdup (argv[i]); | |
7083c021 | 5836 | } |
08d019eb AC |
5837 | newargz[++newargc] = NULL; |
5838 | ||
5839 | EOF | |
5840 | cat <<EOF | |
5841 | /* The GNU banner must be the first non-error debug message */ | |
6f57a957 | 5842 | lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); |
08d019eb AC |
5843 | EOF |
5844 | cat <<"EOF" | |
5845 | lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); | |
5846 | lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); | |
db137867 | 5847 | |
7083c021 AC |
5848 | tmp_pathspec = find_executable (argv[0]); |
5849 | if (tmp_pathspec == NULL) | |
08d019eb AC |
5850 | lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); |
5851 | lt_debugprintf (__FILE__, __LINE__, | |
5852 | "(main) found exe (before symlink chase) at: %s\n", | |
5853 | tmp_pathspec); | |
7083c021 AC |
5854 | |
5855 | actual_cwrapper_path = chase_symlinks (tmp_pathspec); | |
08d019eb AC |
5856 | lt_debugprintf (__FILE__, __LINE__, |
5857 | "(main) found exe (after symlink chase) at: %s\n", | |
5858 | actual_cwrapper_path); | |
7083c021 AC |
5859 | XFREE (tmp_pathspec); |
5860 | ||
08d019eb | 5861 | actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); |
7083c021 AC |
5862 | strendzap (actual_cwrapper_path, actual_cwrapper_name); |
5863 | ||
5864 | /* wrapper name transforms */ | |
5865 | strendzap (actual_cwrapper_name, ".exe"); | |
5866 | tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); | |
5867 | XFREE (actual_cwrapper_name); | |
5868 | actual_cwrapper_name = tmp_pathspec; | |
5869 | tmp_pathspec = 0; | |
5870 | ||
5871 | /* target_name transforms -- use actual target program name; might have lt- prefix */ | |
5872 | target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); | |
5873 | strendzap (target_name, ".exe"); | |
5874 | tmp_pathspec = lt_extend_str (target_name, ".exe", 1); | |
5875 | XFREE (target_name); | |
5876 | target_name = tmp_pathspec; | |
5877 | tmp_pathspec = 0; | |
5878 | ||
08d019eb AC |
5879 | lt_debugprintf (__FILE__, __LINE__, |
5880 | "(main) libtool target name: %s\n", | |
5881 | target_name); | |
7083c021 | 5882 | EOF |
db137867 | 5883 | |
7083c021 AC |
5884 | cat <<EOF |
5885 | newargz[0] = | |
5886 | XMALLOC (char, (strlen (actual_cwrapper_path) + | |
5887 | strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); | |
5888 | strcpy (newargz[0], actual_cwrapper_path); | |
5889 | strcat (newargz[0], "$objdir"); | |
5890 | strcat (newargz[0], "/"); | |
5891 | EOF | |
db137867 | 5892 | |
7083c021 AC |
5893 | cat <<"EOF" |
5894 | /* stop here, and copy so we don't have to do this twice */ | |
5895 | tmp_pathspec = xstrdup (newargz[0]); | |
db137867 | 5896 | |
7083c021 AC |
5897 | /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ |
5898 | strcat (newargz[0], actual_cwrapper_name); | |
db137867 | 5899 | |
7083c021 AC |
5900 | /* DO want the lt- prefix here if it exists, so use target_name */ |
5901 | lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); | |
5902 | XFREE (tmp_pathspec); | |
5903 | tmp_pathspec = NULL; | |
5904 | EOF | |
db137867 | 5905 | |
7083c021 AC |
5906 | case $host_os in |
5907 | mingw*) | |
5908 | cat <<"EOF" | |
5909 | { | |
5910 | char* p; | |
5911 | while ((p = strchr (newargz[0], '\\')) != NULL) | |
5912 | { | |
5913 | *p = '/'; | |
5914 | } | |
5915 | while ((p = strchr (lt_argv_zero, '\\')) != NULL) | |
5916 | { | |
5917 | *p = '/'; | |
5918 | } | |
5919 | } | |
5920 | EOF | |
5921 | ;; | |
5922 | esac | |
db137867 | 5923 | |
7083c021 AC |
5924 | cat <<"EOF" |
5925 | XFREE (target_name); | |
5926 | XFREE (actual_cwrapper_path); | |
5927 | XFREE (actual_cwrapper_name); | |
db137867 | 5928 | |
7083c021 AC |
5929 | lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ |
5930 | lt_setenv ("DUALCASE", "1"); /* for MSK sh */ | |
08d019eb AC |
5931 | /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must |
5932 | be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) | |
5933 | because on Windows, both *_VARNAMEs are PATH but uninstalled | |
5934 | libraries must come first. */ | |
7083c021 | 5935 | lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); |
08d019eb | 5936 | lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); |
db137867 | 5937 | |
08d019eb AC |
5938 | lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", |
5939 | nonnull (lt_argv_zero)); | |
7083c021 AC |
5940 | for (i = 0; i < newargc; i++) |
5941 | { | |
08d019eb AC |
5942 | lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", |
5943 | i, nonnull (newargz[i])); | |
7083c021 | 5944 | } |
db137867 | 5945 | |
7083c021 | 5946 | EOF |
db137867 | 5947 | |
7083c021 AC |
5948 | case $host_os in |
5949 | mingw*) | |
5950 | cat <<"EOF" | |
5951 | /* execv doesn't actually work on mingw as expected on unix */ | |
08d019eb | 5952 | newargz = prepare_spawn (newargz); |
6f57a957 | 5953 | rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); |
7083c021 AC |
5954 | if (rval == -1) |
5955 | { | |
5956 | /* failed to start process */ | |
08d019eb AC |
5957 | lt_debugprintf (__FILE__, __LINE__, |
5958 | "(main) failed to launch target \"%s\": %s\n", | |
5959 | lt_argv_zero, nonnull (strerror (errno))); | |
7083c021 AC |
5960 | return 127; |
5961 | } | |
5962 | return rval; | |
5963 | EOF | |
5964 | ;; | |
5965 | *) | |
5966 | cat <<"EOF" | |
5967 | execv (lt_argv_zero, newargz); | |
5968 | return rval; /* =127, but avoids unused variable warning */ | |
5969 | EOF | |
5970 | ;; | |
5971 | esac | |
db137867 | 5972 | |
7083c021 AC |
5973 | cat <<"EOF" |
5974 | } | |
db137867 | 5975 | |
7083c021 AC |
5976 | void * |
5977 | xmalloc (size_t num) | |
5978 | { | |
5979 | void *p = (void *) malloc (num); | |
5980 | if (!p) | |
08d019eb | 5981 | lt_fatal (__FILE__, __LINE__, "memory exhausted"); |
db137867 | 5982 | |
7083c021 AC |
5983 | return p; |
5984 | } | |
db137867 | 5985 | |
7083c021 AC |
5986 | char * |
5987 | xstrdup (const char *string) | |
5988 | { | |
5989 | return string ? strcpy ((char *) xmalloc (strlen (string) + 1), | |
5990 | string) : NULL; | |
5991 | } | |
db137867 | 5992 | |
7083c021 AC |
5993 | const char * |
5994 | base_name (const char *name) | |
5995 | { | |
5996 | const char *base; | |
db137867 | 5997 | |
6f57a957 | 5998 | #if defined HAVE_DOS_BASED_FILE_SYSTEM |
7083c021 AC |
5999 | /* Skip over the disk name in MSDOS pathnames. */ |
6000 | if (isalpha ((unsigned char) name[0]) && name[1] == ':') | |
6001 | name += 2; | |
6002 | #endif | |
db137867 | 6003 | |
7083c021 AC |
6004 | for (base = name; *name; name++) |
6005 | if (IS_DIR_SEPARATOR (*name)) | |
6006 | base = name + 1; | |
6007 | return base; | |
6008 | } | |
db137867 | 6009 | |
7083c021 AC |
6010 | int |
6011 | check_executable (const char *path) | |
6012 | { | |
6013 | struct stat st; | |
db137867 | 6014 | |
08d019eb AC |
6015 | lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", |
6016 | nonempty (path)); | |
7083c021 AC |
6017 | if ((!path) || (!*path)) |
6018 | return 0; | |
db137867 | 6019 | |
7083c021 AC |
6020 | if ((stat (path, &st) >= 0) |
6021 | && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) | |
6022 | return 1; | |
6023 | else | |
6024 | return 0; | |
6025 | } | |
db137867 | 6026 | |
7083c021 AC |
6027 | int |
6028 | make_executable (const char *path) | |
6029 | { | |
6030 | int rval = 0; | |
6031 | struct stat st; | |
db137867 | 6032 | |
08d019eb AC |
6033 | lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", |
6034 | nonempty (path)); | |
7083c021 AC |
6035 | if ((!path) || (!*path)) |
6036 | return 0; | |
db137867 | 6037 | |
7083c021 AC |
6038 | if (stat (path, &st) >= 0) |
6039 | { | |
6040 | rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); | |
6041 | } | |
6042 | return rval; | |
6043 | } | |
db137867 | 6044 | |
7083c021 AC |
6045 | /* Searches for the full path of the wrapper. Returns |
6046 | newly allocated full path name if found, NULL otherwise | |
6047 | Does not chase symlinks, even on platforms that support them. | |
6048 | */ | |
6049 | char * | |
6050 | find_executable (const char *wrapper) | |
6051 | { | |
6052 | int has_slash = 0; | |
6053 | const char *p; | |
6054 | const char *p_next; | |
6055 | /* static buffer for getcwd */ | |
6056 | char tmp[LT_PATHMAX + 1]; | |
6f57a957 | 6057 | size_t tmp_len; |
7083c021 | 6058 | char *concat_name; |
db137867 | 6059 | |
08d019eb AC |
6060 | lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", |
6061 | nonempty (wrapper)); | |
db137867 | 6062 | |
7083c021 AC |
6063 | if ((wrapper == NULL) || (*wrapper == '\0')) |
6064 | return NULL; | |
db137867 | 6065 | |
7083c021 | 6066 | /* Absolute path? */ |
6f57a957 | 6067 | #if defined HAVE_DOS_BASED_FILE_SYSTEM |
7083c021 AC |
6068 | if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') |
6069 | { | |
6070 | concat_name = xstrdup (wrapper); | |
6071 | if (check_executable (concat_name)) | |
6072 | return concat_name; | |
6073 | XFREE (concat_name); | |
6074 | } | |
6075 | else | |
6076 | { | |
6077 | #endif | |
6078 | if (IS_DIR_SEPARATOR (wrapper[0])) | |
6079 | { | |
6080 | concat_name = xstrdup (wrapper); | |
6081 | if (check_executable (concat_name)) | |
6082 | return concat_name; | |
6083 | XFREE (concat_name); | |
6084 | } | |
6f57a957 | 6085 | #if defined HAVE_DOS_BASED_FILE_SYSTEM |
7083c021 AC |
6086 | } |
6087 | #endif | |
db137867 | 6088 | |
7083c021 AC |
6089 | for (p = wrapper; *p; p++) |
6090 | if (*p == '/') | |
6091 | { | |
6092 | has_slash = 1; | |
6093 | break; | |
6094 | } | |
6095 | if (!has_slash) | |
6096 | { | |
6097 | /* no slashes; search PATH */ | |
6098 | const char *path = getenv ("PATH"); | |
6099 | if (path != NULL) | |
6100 | { | |
6101 | for (p = path; *p; p = p_next) | |
6102 | { | |
6103 | const char *q; | |
6104 | size_t p_len; | |
6105 | for (q = p; *q; q++) | |
6106 | if (IS_PATH_SEPARATOR (*q)) | |
6107 | break; | |
6f57a957 | 6108 | p_len = (size_t) (q - p); |
7083c021 AC |
6109 | p_next = (*q == '\0' ? q : q + 1); |
6110 | if (p_len == 0) | |
6111 | { | |
6112 | /* empty path: current directory */ | |
6113 | if (getcwd (tmp, LT_PATHMAX) == NULL) | |
08d019eb AC |
6114 | lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", |
6115 | nonnull (strerror (errno))); | |
7083c021 AC |
6116 | tmp_len = strlen (tmp); |
6117 | concat_name = | |
6118 | XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); | |
6119 | memcpy (concat_name, tmp, tmp_len); | |
6120 | concat_name[tmp_len] = '/'; | |
6121 | strcpy (concat_name + tmp_len + 1, wrapper); | |
6122 | } | |
6123 | else | |
6124 | { | |
6125 | concat_name = | |
6126 | XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); | |
6127 | memcpy (concat_name, p, p_len); | |
6128 | concat_name[p_len] = '/'; | |
6129 | strcpy (concat_name + p_len + 1, wrapper); | |
6130 | } | |
6131 | if (check_executable (concat_name)) | |
6132 | return concat_name; | |
6133 | XFREE (concat_name); | |
6134 | } | |
6135 | } | |
6136 | /* not found in PATH; assume curdir */ | |
6137 | } | |
6138 | /* Relative path | not found in path: prepend cwd */ | |
6139 | if (getcwd (tmp, LT_PATHMAX) == NULL) | |
08d019eb AC |
6140 | lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", |
6141 | nonnull (strerror (errno))); | |
7083c021 AC |
6142 | tmp_len = strlen (tmp); |
6143 | concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); | |
6144 | memcpy (concat_name, tmp, tmp_len); | |
6145 | concat_name[tmp_len] = '/'; | |
6146 | strcpy (concat_name + tmp_len + 1, wrapper); | |
db137867 | 6147 | |
7083c021 AC |
6148 | if (check_executable (concat_name)) |
6149 | return concat_name; | |
6150 | XFREE (concat_name); | |
6151 | return NULL; | |
6152 | } | |
db137867 | 6153 | |
7083c021 AC |
6154 | char * |
6155 | chase_symlinks (const char *pathspec) | |
6156 | { | |
6157 | #ifndef S_ISLNK | |
6158 | return xstrdup (pathspec); | |
6159 | #else | |
6160 | char buf[LT_PATHMAX]; | |
6161 | struct stat s; | |
6162 | char *tmp_pathspec = xstrdup (pathspec); | |
6163 | char *p; | |
6164 | int has_symlinks = 0; | |
6165 | while (strlen (tmp_pathspec) && !has_symlinks) | |
6166 | { | |
08d019eb AC |
6167 | lt_debugprintf (__FILE__, __LINE__, |
6168 | "checking path component for symlinks: %s\n", | |
6169 | tmp_pathspec); | |
7083c021 AC |
6170 | if (lstat (tmp_pathspec, &s) == 0) |
6171 | { | |
6172 | if (S_ISLNK (s.st_mode) != 0) | |
6173 | { | |
6174 | has_symlinks = 1; | |
6175 | break; | |
6176 | } | |
db137867 | 6177 | |
7083c021 AC |
6178 | /* search backwards for last DIR_SEPARATOR */ |
6179 | p = tmp_pathspec + strlen (tmp_pathspec) - 1; | |
6180 | while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) | |
6181 | p--; | |
6182 | if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) | |
6183 | { | |
6184 | /* no more DIR_SEPARATORS left */ | |
6185 | break; | |
6186 | } | |
6187 | *p = '\0'; | |
6188 | } | |
6189 | else | |
6190 | { | |
08d019eb AC |
6191 | lt_fatal (__FILE__, __LINE__, |
6192 | "error accessing file \"%s\": %s", | |
6193 | tmp_pathspec, nonnull (strerror (errno))); | |
7083c021 AC |
6194 | } |
6195 | } | |
6196 | XFREE (tmp_pathspec); | |
db137867 | 6197 | |
7083c021 AC |
6198 | if (!has_symlinks) |
6199 | { | |
6200 | return xstrdup (pathspec); | |
6201 | } | |
db137867 | 6202 | |
7083c021 AC |
6203 | tmp_pathspec = realpath (pathspec, buf); |
6204 | if (tmp_pathspec == 0) | |
6205 | { | |
08d019eb AC |
6206 | lt_fatal (__FILE__, __LINE__, |
6207 | "could not follow symlinks for %s", pathspec); | |
7083c021 AC |
6208 | } |
6209 | return xstrdup (tmp_pathspec); | |
6210 | #endif | |
6211 | } | |
db137867 | 6212 | |
7083c021 AC |
6213 | char * |
6214 | strendzap (char *str, const char *pat) | |
6215 | { | |
6216 | size_t len, patlen; | |
db137867 | 6217 | |
7083c021 AC |
6218 | assert (str != NULL); |
6219 | assert (pat != NULL); | |
db137867 | 6220 | |
7083c021 AC |
6221 | len = strlen (str); |
6222 | patlen = strlen (pat); | |
db137867 | 6223 | |
7083c021 AC |
6224 | if (patlen <= len) |
6225 | { | |
6226 | str += len - patlen; | |
6f57a957 | 6227 | if (STREQ (str, pat)) |
7083c021 AC |
6228 | *str = '\0'; |
6229 | } | |
6230 | return str; | |
6231 | } | |
db137867 | 6232 | |
08d019eb AC |
6233 | void |
6234 | lt_debugprintf (const char *file, int line, const char *fmt, ...) | |
6235 | { | |
6236 | va_list args; | |
6237 | if (lt_debug) | |
6238 | { | |
6239 | (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); | |
6240 | va_start (args, fmt); | |
6241 | (void) vfprintf (stderr, fmt, args); | |
6242 | va_end (args); | |
6243 | } | |
6244 | } | |
6245 | ||
7083c021 | 6246 | static void |
08d019eb AC |
6247 | lt_error_core (int exit_status, const char *file, |
6248 | int line, const char *mode, | |
7083c021 AC |
6249 | const char *message, va_list ap) |
6250 | { | |
08d019eb | 6251 | fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); |
7083c021 AC |
6252 | vfprintf (stderr, message, ap); |
6253 | fprintf (stderr, ".\n"); | |
db137867 | 6254 | |
7083c021 AC |
6255 | if (exit_status >= 0) |
6256 | exit (exit_status); | |
6257 | } | |
db137867 | 6258 | |
7083c021 | 6259 | void |
08d019eb | 6260 | lt_fatal (const char *file, int line, const char *message, ...) |
7083c021 AC |
6261 | { |
6262 | va_list ap; | |
6263 | va_start (ap, message); | |
08d019eb | 6264 | lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); |
7083c021 AC |
6265 | va_end (ap); |
6266 | } | |
db137867 | 6267 | |
08d019eb AC |
6268 | static const char * |
6269 | nonnull (const char *s) | |
6270 | { | |
6271 | return s ? s : "(null)"; | |
6272 | } | |
6273 | ||
6274 | static const char * | |
6275 | nonempty (const char *s) | |
6276 | { | |
6277 | return (s && !*s) ? "(empty)" : nonnull (s); | |
6278 | } | |
6279 | ||
7083c021 AC |
6280 | void |
6281 | lt_setenv (const char *name, const char *value) | |
6282 | { | |
08d019eb AC |
6283 | lt_debugprintf (__FILE__, __LINE__, |
6284 | "(lt_setenv) setting '%s' to '%s'\n", | |
6285 | nonnull (name), nonnull (value)); | |
7083c021 AC |
6286 | { |
6287 | #ifdef HAVE_SETENV | |
6288 | /* always make a copy, for consistency with !HAVE_SETENV */ | |
6289 | char *str = xstrdup (value); | |
6290 | setenv (name, str, 1); | |
6291 | #else | |
6f57a957 | 6292 | size_t len = strlen (name) + 1 + strlen (value) + 1; |
7083c021 AC |
6293 | char *str = XMALLOC (char, len); |
6294 | sprintf (str, "%s=%s", name, value); | |
6295 | if (putenv (str) != EXIT_SUCCESS) | |
6296 | { | |
6297 | XFREE (str); | |
6298 | } | |
6299 | #endif | |
6300 | } | |
6301 | } | |
db137867 | 6302 | |
7083c021 AC |
6303 | char * |
6304 | lt_extend_str (const char *orig_value, const char *add, int to_end) | |
6305 | { | |
6306 | char *new_value; | |
6307 | if (orig_value && *orig_value) | |
6308 | { | |
6f57a957 AC |
6309 | size_t orig_value_len = strlen (orig_value); |
6310 | size_t add_len = strlen (add); | |
7083c021 AC |
6311 | new_value = XMALLOC (char, add_len + orig_value_len + 1); |
6312 | if (to_end) | |
6313 | { | |
6314 | strcpy (new_value, orig_value); | |
6315 | strcpy (new_value + orig_value_len, add); | |
6316 | } | |
6317 | else | |
6318 | { | |
6319 | strcpy (new_value, add); | |
6320 | strcpy (new_value + add_len, orig_value); | |
6321 | } | |
6322 | } | |
6323 | else | |
6324 | { | |
6325 | new_value = xstrdup (add); | |
6326 | } | |
6327 | return new_value; | |
6328 | } | |
db137867 | 6329 | |
7083c021 AC |
6330 | void |
6331 | lt_update_exe_path (const char *name, const char *value) | |
6332 | { | |
08d019eb AC |
6333 | lt_debugprintf (__FILE__, __LINE__, |
6334 | "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", | |
6335 | nonnull (name), nonnull (value)); | |
db137867 | 6336 | |
7083c021 AC |
6337 | if (name && *name && value && *value) |
6338 | { | |
6339 | char *new_value = lt_extend_str (getenv (name), value, 0); | |
6340 | /* some systems can't cope with a ':'-terminated path #' */ | |
6f57a957 AC |
6341 | size_t len = strlen (new_value); |
6342 | while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) | |
7083c021 | 6343 | { |
6f57a957 | 6344 | new_value[--len] = '\0'; |
7083c021 AC |
6345 | } |
6346 | lt_setenv (name, new_value); | |
6347 | XFREE (new_value); | |
6348 | } | |
6349 | } | |
db137867 | 6350 | |
7083c021 AC |
6351 | void |
6352 | lt_update_lib_path (const char *name, const char *value) | |
6353 | { | |
08d019eb AC |
6354 | lt_debugprintf (__FILE__, __LINE__, |
6355 | "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", | |
6356 | nonnull (name), nonnull (value)); | |
db137867 | 6357 | |
7083c021 AC |
6358 | if (name && *name && value && *value) |
6359 | { | |
6360 | char *new_value = lt_extend_str (getenv (name), value, 0); | |
6361 | lt_setenv (name, new_value); | |
6362 | XFREE (new_value); | |
6363 | } | |
6364 | } | |
db137867 | 6365 | |
08d019eb AC |
6366 | EOF |
6367 | case $host_os in | |
6368 | mingw*) | |
6369 | cat <<"EOF" | |
6370 | ||
6371 | /* Prepares an argument vector before calling spawn(). | |
6372 | Note that spawn() does not by itself call the command interpreter | |
6373 | (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : | |
6374 | ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | |
6375 | GetVersionEx(&v); | |
6376 | v.dwPlatformId == VER_PLATFORM_WIN32_NT; | |
6377 | }) ? "cmd.exe" : "command.com"). | |
6378 | Instead it simply concatenates the arguments, separated by ' ', and calls | |
6379 | CreateProcess(). We must quote the arguments since Win32 CreateProcess() | |
6380 | interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a | |
6381 | special way: | |
6382 | - Space and tab are interpreted as delimiters. They are not treated as | |
6383 | delimiters if they are surrounded by double quotes: "...". | |
6384 | - Unescaped double quotes are removed from the input. Their only effect is | |
6385 | that within double quotes, space and tab are treated like normal | |
6386 | characters. | |
6387 | - Backslashes not followed by double quotes are not special. | |
6388 | - But 2*n+1 backslashes followed by a double quote become | |
6389 | n backslashes followed by a double quote (n >= 0): | |
6390 | \" -> " | |
6391 | \\\" -> \" | |
6392 | \\\\\" -> \\" | |
6393 | */ | |
6394 | #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" | |
6395 | #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" | |
6396 | char ** | |
6397 | prepare_spawn (char **argv) | |
6398 | { | |
6399 | size_t argc; | |
6400 | char **new_argv; | |
6401 | size_t i; | |
6402 | ||
6403 | /* Count number of arguments. */ | |
6404 | for (argc = 0; argv[argc] != NULL; argc++) | |
6405 | ; | |
6406 | ||
6407 | /* Allocate new argument vector. */ | |
6408 | new_argv = XMALLOC (char *, argc + 1); | |
6409 | ||
6410 | /* Put quoted arguments into the new argument vector. */ | |
6411 | for (i = 0; i < argc; i++) | |
6412 | { | |
6413 | const char *string = argv[i]; | |
6414 | ||
6415 | if (string[0] == '\0') | |
6416 | new_argv[i] = xstrdup ("\"\""); | |
6417 | else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) | |
6418 | { | |
6419 | int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); | |
6420 | size_t length; | |
6421 | unsigned int backslashes; | |
6422 | const char *s; | |
6423 | char *quoted_string; | |
6424 | char *p; | |
6425 | ||
6426 | length = 0; | |
6427 | backslashes = 0; | |
6428 | if (quote_around) | |
6429 | length++; | |
6430 | for (s = string; *s != '\0'; s++) | |
6431 | { | |
6432 | char c = *s; | |
6433 | if (c == '"') | |
6434 | length += backslashes + 1; | |
6435 | length++; | |
6436 | if (c == '\\') | |
6437 | backslashes++; | |
6438 | else | |
6439 | backslashes = 0; | |
6440 | } | |
6441 | if (quote_around) | |
6442 | length += backslashes + 1; | |
6443 | ||
6444 | quoted_string = XMALLOC (char, length + 1); | |
6445 | ||
6446 | p = quoted_string; | |
6447 | backslashes = 0; | |
6448 | if (quote_around) | |
6449 | *p++ = '"'; | |
6450 | for (s = string; *s != '\0'; s++) | |
6451 | { | |
6452 | char c = *s; | |
6453 | if (c == '"') | |
6454 | { | |
6455 | unsigned int j; | |
6456 | for (j = backslashes + 1; j > 0; j--) | |
6457 | *p++ = '\\'; | |
6458 | } | |
6459 | *p++ = c; | |
6460 | if (c == '\\') | |
6461 | backslashes++; | |
6462 | else | |
6463 | backslashes = 0; | |
6464 | } | |
6465 | if (quote_around) | |
6466 | { | |
6467 | unsigned int j; | |
6468 | for (j = backslashes; j > 0; j--) | |
6469 | *p++ = '\\'; | |
6470 | *p++ = '"'; | |
6471 | } | |
6472 | *p = '\0'; | |
6473 | ||
6474 | new_argv[i] = quoted_string; | |
6475 | } | |
6476 | else | |
6477 | new_argv[i] = (char *) string; | |
6478 | } | |
6479 | new_argv[argc] = NULL; | |
6480 | ||
6481 | return new_argv; | |
6482 | } | |
6483 | EOF | |
6484 | ;; | |
6485 | esac | |
6486 | ||
6487 | cat <<"EOF" | |
6488 | void lt_dump_script (FILE* f) | |
6489 | { | |
6490 | EOF | |
6491 | func_emit_wrapper yes | | |
54bec06e AC |
6492 | $SED -n -e ' |
6493 | s/^\(.\{79\}\)\(..*\)/\1\ | |
6494 | \2/ | |
6495 | h | |
6496 | s/\([\\"]\)/\\\1/g | |
6497 | s/$/\\n/ | |
6498 | s/\([^\n]*\).*/ fputs ("\1", f);/p | |
6499 | g | |
6500 | D' | |
08d019eb AC |
6501 | cat <<"EOF" |
6502 | } | |
7083c021 AC |
6503 | EOF |
6504 | } | |
6505 | # end: func_emit_cwrapperexe_src | |
db137867 | 6506 | |
08d019eb AC |
6507 | # func_win32_import_lib_p ARG |
6508 | # True if ARG is an import lib, as indicated by $file_magic_cmd | |
6509 | func_win32_import_lib_p () | |
6510 | { | |
6f57a957 AC |
6511 | $debug_cmd |
6512 | ||
08d019eb AC |
6513 | case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in |
6514 | *import*) : ;; | |
6515 | *) false ;; | |
6516 | esac | |
6517 | } | |
6518 | ||
6f57a957 AC |
6519 | # func_suncc_cstd_abi |
6520 | # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! | |
6521 | # Several compiler flags select an ABI that is incompatible with the | |
6522 | # Cstd library. Avoid specifying it if any are in CXXFLAGS. | |
6523 | func_suncc_cstd_abi () | |
6524 | { | |
6525 | $debug_cmd | |
6526 | ||
6527 | case " $compile_command " in | |
6528 | *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) | |
6529 | suncc_use_cstd_abi=no | |
6530 | ;; | |
6531 | *) | |
6532 | suncc_use_cstd_abi=yes | |
6533 | ;; | |
6534 | esac | |
6535 | } | |
6536 | ||
7083c021 AC |
6537 | # func_mode_link arg... |
6538 | func_mode_link () | |
6539 | { | |
6f57a957 AC |
6540 | $debug_cmd |
6541 | ||
7083c021 AC |
6542 | case $host in |
6543 | *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) | |
6544 | # It is impossible to link a dll without this setting, and | |
6545 | # we shouldn't force the makefile maintainer to figure out | |
6f57a957 | 6546 | # what system we are compiling for in order to pass an extra |
7083c021 AC |
6547 | # flag for every libtool invocation. |
6548 | # allow_undefined=no | |
db137867 | 6549 | |
7083c021 | 6550 | # FIXME: Unfortunately, there are problems with the above when trying |
6f57a957 | 6551 | # to make a dll that has undefined symbols, in which case not |
7083c021 AC |
6552 | # even a static library is built. For now, we need to specify |
6553 | # -no-undefined on the libtool link line when we can be certain | |
6554 | # that all symbols are satisfied, otherwise we get a static library. | |
6555 | allow_undefined=yes | |
6556 | ;; | |
6557 | *) | |
6558 | allow_undefined=yes | |
6559 | ;; | |
6560 | esac | |
6561 | libtool_args=$nonopt | |
6562 | base_compile="$nonopt $@" | |
6563 | compile_command=$nonopt | |
6564 | finalize_command=$nonopt | |
db137867 | 6565 | |
7083c021 AC |
6566 | compile_rpath= |
6567 | finalize_rpath= | |
6568 | compile_shlibpath= | |
6569 | finalize_shlibpath= | |
6570 | convenience= | |
6571 | old_convenience= | |
6572 | deplibs= | |
6573 | old_deplibs= | |
6574 | compiler_flags= | |
6575 | linker_flags= | |
6576 | dllsearchpath= | |
6577 | lib_search_path=`pwd` | |
6578 | inst_prefix_dir= | |
6579 | new_inherited_linker_flags= | |
db137867 | 6580 | |
7083c021 | 6581 | avoid_version=no |
08d019eb | 6582 | bindir= |
7083c021 AC |
6583 | dlfiles= |
6584 | dlprefiles= | |
6585 | dlself=no | |
6586 | export_dynamic=no | |
6587 | export_symbols= | |
6588 | export_symbols_regex= | |
6589 | generated= | |
6590 | libobjs= | |
6591 | ltlibs= | |
6592 | module=no | |
6593 | no_install=no | |
6594 | objs= | |
6f57a957 | 6595 | os2dllname= |
7083c021 AC |
6596 | non_pic_objects= |
6597 | precious_files_regex= | |
6598 | prefer_static_libs=no | |
6f57a957 | 6599 | preload=false |
7083c021 AC |
6600 | prev= |
6601 | prevarg= | |
6602 | release= | |
6603 | rpath= | |
6604 | xrpath= | |
6605 | perm_rpath= | |
6606 | temp_rpath= | |
6607 | thread_safe=no | |
6608 | vinfo= | |
6609 | vinfo_number=no | |
6610 | weak_libs= | |
6f57a957 | 6611 | single_module=$wl-single_module |
7083c021 | 6612 | func_infer_tag $base_compile |
db137867 | 6613 | |
7083c021 AC |
6614 | # We need to know -static, to get the right output filenames. |
6615 | for arg | |
6616 | do | |
6617 | case $arg in | |
6618 | -shared) | |
6f57a957 AC |
6619 | test yes != "$build_libtool_libs" \ |
6620 | && func_fatal_configuration "cannot build a shared library" | |
7083c021 AC |
6621 | build_old_libs=no |
6622 | break | |
6623 | ;; | |
6624 | -all-static | -static | -static-libtool-libs) | |
6625 | case $arg in | |
6626 | -all-static) | |
6f57a957 | 6627 | if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then |
7083c021 AC |
6628 | func_warning "complete static linking is impossible in this configuration" |
6629 | fi | |
6630 | if test -n "$link_static_flag"; then | |
6631 | dlopen_self=$dlopen_self_static | |
6632 | fi | |
6633 | prefer_static_libs=yes | |
6634 | ;; | |
6635 | -static) | |
6636 | if test -z "$pic_flag" && test -n "$link_static_flag"; then | |
6637 | dlopen_self=$dlopen_self_static | |
6638 | fi | |
6639 | prefer_static_libs=built | |
6640 | ;; | |
6641 | -static-libtool-libs) | |
6642 | if test -z "$pic_flag" && test -n "$link_static_flag"; then | |
6643 | dlopen_self=$dlopen_self_static | |
6644 | fi | |
6645 | prefer_static_libs=yes | |
6646 | ;; | |
6647 | esac | |
6648 | build_libtool_libs=no | |
6649 | build_old_libs=yes | |
6650 | break | |
6651 | ;; | |
6652 | esac | |
6653 | done | |
db137867 | 6654 | |
7083c021 AC |
6655 | # See if our shared archives depend on static archives. |
6656 | test -n "$old_archive_from_new_cmds" && build_old_libs=yes | |
db137867 | 6657 | |
7083c021 AC |
6658 | # Go through the arguments, transforming them on the way. |
6659 | while test "$#" -gt 0; do | |
6f57a957 | 6660 | arg=$1 |
7083c021 AC |
6661 | shift |
6662 | func_quote_for_eval "$arg" | |
6663 | qarg=$func_quote_for_eval_unquoted_result | |
6664 | func_append libtool_args " $func_quote_for_eval_result" | |
db137867 | 6665 | |
7083c021 AC |
6666 | # If the previous option needs an argument, assign it. |
6667 | if test -n "$prev"; then | |
6668 | case $prev in | |
6669 | output) | |
6670 | func_append compile_command " @OUTPUT@" | |
6671 | func_append finalize_command " @OUTPUT@" | |
6672 | ;; | |
6673 | esac | |
db137867 | 6674 | |
7083c021 | 6675 | case $prev in |
08d019eb | 6676 | bindir) |
6f57a957 | 6677 | bindir=$arg |
08d019eb AC |
6678 | prev= |
6679 | continue | |
6680 | ;; | |
7083c021 | 6681 | dlfiles|dlprefiles) |
6f57a957 | 6682 | $preload || { |
7083c021 AC |
6683 | # Add the symbol object into the linking commands. |
6684 | func_append compile_command " @SYMFILE@" | |
6685 | func_append finalize_command " @SYMFILE@" | |
6f57a957 AC |
6686 | preload=: |
6687 | } | |
7083c021 AC |
6688 | case $arg in |
6689 | *.la | *.lo) ;; # We handle these cases below. | |
6690 | force) | |
6f57a957 | 6691 | if test no = "$dlself"; then |
7083c021 AC |
6692 | dlself=needless |
6693 | export_dynamic=yes | |
6694 | fi | |
6695 | prev= | |
6696 | continue | |
6697 | ;; | |
6698 | self) | |
6f57a957 | 6699 | if test dlprefiles = "$prev"; then |
7083c021 | 6700 | dlself=yes |
6f57a957 | 6701 | elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then |
7083c021 AC |
6702 | dlself=yes |
6703 | else | |
6704 | dlself=needless | |
6705 | export_dynamic=yes | |
6706 | fi | |
6707 | prev= | |
6708 | continue | |
6709 | ;; | |
6710 | *) | |
6f57a957 | 6711 | if test dlfiles = "$prev"; then |
08d019eb | 6712 | func_append dlfiles " $arg" |
7083c021 | 6713 | else |
08d019eb | 6714 | func_append dlprefiles " $arg" |
7083c021 AC |
6715 | fi |
6716 | prev= | |
6717 | continue | |
6718 | ;; | |
6719 | esac | |
6720 | ;; | |
6721 | expsyms) | |
6f57a957 | 6722 | export_symbols=$arg |
7083c021 | 6723 | test -f "$arg" \ |
6f57a957 | 6724 | || func_fatal_error "symbol file '$arg' does not exist" |
7083c021 AC |
6725 | prev= |
6726 | continue | |
6727 | ;; | |
6728 | expsyms_regex) | |
6f57a957 | 6729 | export_symbols_regex=$arg |
7083c021 AC |
6730 | prev= |
6731 | continue | |
6732 | ;; | |
6733 | framework) | |
db137867 | 6734 | case $host in |
7083c021 AC |
6735 | *-*-darwin*) |
6736 | case "$deplibs " in | |
6737 | *" $qarg.ltframework "*) ;; | |
08d019eb | 6738 | *) func_append deplibs " $qarg.ltframework" # this is fixed later |
7083c021 AC |
6739 | ;; |
6740 | esac | |
6741 | ;; | |
db137867 | 6742 | esac |
7083c021 AC |
6743 | prev= |
6744 | continue | |
db137867 | 6745 | ;; |
7083c021 | 6746 | inst_prefix) |
6f57a957 AC |
6747 | inst_prefix_dir=$arg |
6748 | prev= | |
6749 | continue | |
6750 | ;; | |
6751 | mllvm) | |
6752 | # Clang does not use LLVM to link, so we can simply discard any | |
6753 | # '-mllvm $arg' options when doing the link step. | |
7083c021 AC |
6754 | prev= |
6755 | continue | |
db137867 | 6756 | ;; |
7083c021 AC |
6757 | objectlist) |
6758 | if test -f "$arg"; then | |
6759 | save_arg=$arg | |
6760 | moreargs= | |
6761 | for fil in `cat "$save_arg"` | |
6762 | do | |
08d019eb | 6763 | # func_append moreargs " $fil" |
7083c021 AC |
6764 | arg=$fil |
6765 | # A libtool-controlled object. | |
db137867 | 6766 | |
7083c021 AC |
6767 | # Check to see that this really is a libtool object. |
6768 | if func_lalib_unsafe_p "$arg"; then | |
6769 | pic_object= | |
6770 | non_pic_object= | |
db137867 | 6771 | |
7083c021 AC |
6772 | # Read the .lo file |
6773 | func_source "$arg" | |
db137867 | 6774 | |
7083c021 AC |
6775 | if test -z "$pic_object" || |
6776 | test -z "$non_pic_object" || | |
6f57a957 AC |
6777 | test none = "$pic_object" && |
6778 | test none = "$non_pic_object"; then | |
6779 | func_fatal_error "cannot find name of object for '$arg'" | |
7083c021 | 6780 | fi |
db137867 | 6781 | |
7083c021 AC |
6782 | # Extract subdirectory from the argument. |
6783 | func_dirname "$arg" "/" "" | |
6f57a957 | 6784 | xdir=$func_dirname_result |
db137867 | 6785 | |
6f57a957 | 6786 | if test none != "$pic_object"; then |
7083c021 | 6787 | # Prepend the subdirectory the object is found in. |
6f57a957 | 6788 | pic_object=$xdir$pic_object |
db137867 | 6789 | |
6f57a957 AC |
6790 | if test dlfiles = "$prev"; then |
6791 | if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then | |
08d019eb | 6792 | func_append dlfiles " $pic_object" |
7083c021 AC |
6793 | prev= |
6794 | continue | |
6795 | else | |
6796 | # If libtool objects are unsupported, then we need to preload. | |
6797 | prev=dlprefiles | |
6798 | fi | |
6799 | fi | |
db137867 | 6800 | |
7083c021 | 6801 | # CHECK ME: I think I busted this. -Ossama |
6f57a957 | 6802 | if test dlprefiles = "$prev"; then |
7083c021 | 6803 | # Preload the old-style object. |
08d019eb | 6804 | func_append dlprefiles " $pic_object" |
7083c021 AC |
6805 | prev= |
6806 | fi | |
db137867 | 6807 | |
7083c021 AC |
6808 | # A PIC object. |
6809 | func_append libobjs " $pic_object" | |
6f57a957 | 6810 | arg=$pic_object |
7083c021 | 6811 | fi |
db137867 | 6812 | |
7083c021 | 6813 | # Non-PIC object. |
6f57a957 | 6814 | if test none != "$non_pic_object"; then |
7083c021 | 6815 | # Prepend the subdirectory the object is found in. |
6f57a957 | 6816 | non_pic_object=$xdir$non_pic_object |
db137867 | 6817 | |
7083c021 AC |
6818 | # A standard non-PIC object |
6819 | func_append non_pic_objects " $non_pic_object" | |
6f57a957 AC |
6820 | if test -z "$pic_object" || test none = "$pic_object"; then |
6821 | arg=$non_pic_object | |
7083c021 AC |
6822 | fi |
6823 | else | |
6824 | # If the PIC object exists, use it instead. | |
6825 | # $xdir was prepended to $pic_object above. | |
6f57a957 | 6826 | non_pic_object=$pic_object |
7083c021 AC |
6827 | func_append non_pic_objects " $non_pic_object" |
6828 | fi | |
6829 | else | |
6830 | # Only an error if not doing a dry-run. | |
6831 | if $opt_dry_run; then | |
6832 | # Extract subdirectory from the argument. | |
6833 | func_dirname "$arg" "/" "" | |
6f57a957 | 6834 | xdir=$func_dirname_result |
7083c021 AC |
6835 | |
6836 | func_lo2o "$arg" | |
6837 | pic_object=$xdir$objdir/$func_lo2o_result | |
6838 | non_pic_object=$xdir$func_lo2o_result | |
6839 | func_append libobjs " $pic_object" | |
6840 | func_append non_pic_objects " $non_pic_object" | |
6841 | else | |
6f57a957 | 6842 | func_fatal_error "'$arg' is not a valid libtool object" |
7083c021 AC |
6843 | fi |
6844 | fi | |
6845 | done | |
db137867 | 6846 | else |
6f57a957 | 6847 | func_fatal_error "link input file '$arg' does not exist" |
db137867 | 6848 | fi |
7083c021 AC |
6849 | arg=$save_arg |
6850 | prev= | |
6851 | continue | |
6852 | ;; | |
6f57a957 AC |
6853 | os2dllname) |
6854 | os2dllname=$arg | |
6855 | prev= | |
6856 | continue | |
6857 | ;; | |
7083c021 | 6858 | precious_regex) |
6f57a957 | 6859 | precious_files_regex=$arg |
7083c021 AC |
6860 | prev= |
6861 | continue | |
6862 | ;; | |
6863 | release) | |
6f57a957 | 6864 | release=-$arg |
7083c021 AC |
6865 | prev= |
6866 | continue | |
6867 | ;; | |
6868 | rpath | xrpath) | |
6869 | # We need an absolute path. | |
6870 | case $arg in | |
6871 | [\\/]* | [A-Za-z]:[\\/]*) ;; | |
6872 | *) | |
6873 | func_fatal_error "only absolute run-paths are allowed" | |
6874 | ;; | |
6875 | esac | |
6f57a957 | 6876 | if test rpath = "$prev"; then |
7083c021 AC |
6877 | case "$rpath " in |
6878 | *" $arg "*) ;; | |
08d019eb | 6879 | *) func_append rpath " $arg" ;; |
7083c021 | 6880 | esac |
db137867 | 6881 | else |
7083c021 AC |
6882 | case "$xrpath " in |
6883 | *" $arg "*) ;; | |
08d019eb | 6884 | *) func_append xrpath " $arg" ;; |
7083c021 | 6885 | esac |
db137867 | 6886 | fi |
7083c021 AC |
6887 | prev= |
6888 | continue | |
6889 | ;; | |
6890 | shrext) | |
6f57a957 | 6891 | shrext_cmds=$arg |
7083c021 AC |
6892 | prev= |
6893 | continue | |
6894 | ;; | |
6895 | weak) | |
08d019eb | 6896 | func_append weak_libs " $arg" |
7083c021 AC |
6897 | prev= |
6898 | continue | |
6899 | ;; | |
6900 | xcclinker) | |
08d019eb AC |
6901 | func_append linker_flags " $qarg" |
6902 | func_append compiler_flags " $qarg" | |
7083c021 AC |
6903 | prev= |
6904 | func_append compile_command " $qarg" | |
6905 | func_append finalize_command " $qarg" | |
6906 | continue | |
6907 | ;; | |
6908 | xcompiler) | |
08d019eb | 6909 | func_append compiler_flags " $qarg" |
7083c021 AC |
6910 | prev= |
6911 | func_append compile_command " $qarg" | |
6912 | func_append finalize_command " $qarg" | |
6913 | continue | |
6914 | ;; | |
6915 | xlinker) | |
08d019eb AC |
6916 | func_append linker_flags " $qarg" |
6917 | func_append compiler_flags " $wl$qarg" | |
7083c021 AC |
6918 | prev= |
6919 | func_append compile_command " $wl$qarg" | |
6920 | func_append finalize_command " $wl$qarg" | |
6921 | continue | |
6922 | ;; | |
6923 | *) | |
6924 | eval "$prev=\"\$arg\"" | |
6925 | prev= | |
6926 | continue | |
6927 | ;; | |
db137867 | 6928 | esac |
7083c021 | 6929 | fi # test -n "$prev" |
db137867 | 6930 | |
6f57a957 | 6931 | prevarg=$arg |
db137867 | 6932 | |
7083c021 AC |
6933 | case $arg in |
6934 | -all-static) | |
6935 | if test -n "$link_static_flag"; then | |
6936 | # See comment for -static flag below, for more details. | |
6937 | func_append compile_command " $link_static_flag" | |
6938 | func_append finalize_command " $link_static_flag" | |
6939 | fi | |
6940 | continue | |
6941 | ;; | |
db137867 | 6942 | |
7083c021 AC |
6943 | -allow-undefined) |
6944 | # FIXME: remove this flag sometime in the future. | |
6f57a957 | 6945 | func_fatal_error "'-allow-undefined' must not be used because it is the default" |
7083c021 | 6946 | ;; |
db137867 | 6947 | |
7083c021 AC |
6948 | -avoid-version) |
6949 | avoid_version=yes | |
6950 | continue | |
6951 | ;; | |
db137867 | 6952 | |
08d019eb AC |
6953 | -bindir) |
6954 | prev=bindir | |
6955 | continue | |
6956 | ;; | |
6957 | ||
7083c021 AC |
6958 | -dlopen) |
6959 | prev=dlfiles | |
6960 | continue | |
6961 | ;; | |
db137867 | 6962 | |
7083c021 AC |
6963 | -dlpreopen) |
6964 | prev=dlprefiles | |
6965 | continue | |
6966 | ;; | |
db137867 | 6967 | |
7083c021 AC |
6968 | -export-dynamic) |
6969 | export_dynamic=yes | |
6970 | continue | |
6971 | ;; | |
db137867 | 6972 | |
7083c021 AC |
6973 | -export-symbols | -export-symbols-regex) |
6974 | if test -n "$export_symbols" || test -n "$export_symbols_regex"; then | |
6975 | func_fatal_error "more than one -exported-symbols argument is not allowed" | |
6976 | fi | |
6f57a957 | 6977 | if test X-export-symbols = "X$arg"; then |
7083c021 AC |
6978 | prev=expsyms |
6979 | else | |
6980 | prev=expsyms_regex | |
6981 | fi | |
6982 | continue | |
6983 | ;; | |
db137867 | 6984 | |
7083c021 AC |
6985 | -framework) |
6986 | prev=framework | |
6987 | continue | |
6988 | ;; | |
db137867 | 6989 | |
7083c021 AC |
6990 | -inst-prefix-dir) |
6991 | prev=inst_prefix | |
6992 | continue | |
6993 | ;; | |
db137867 | 6994 | |
7083c021 AC |
6995 | # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* |
6996 | # so, if we see these flags be careful not to treat them like -L | |
6997 | -L[A-Z][A-Z]*:*) | |
6998 | case $with_gcc/$host in | |
6999 | no/*-*-irix* | /*-*-irix*) | |
7000 | func_append compile_command " $arg" | |
7001 | func_append finalize_command " $arg" | |
7002 | ;; | |
7003 | esac | |
7004 | continue | |
7005 | ;; | |
db137867 | 7006 | |
7083c021 | 7007 | -L*) |
08d019eb AC |
7008 | func_stripname "-L" '' "$arg" |
7009 | if test -z "$func_stripname_result"; then | |
7083c021 | 7010 | if test "$#" -gt 0; then |
6f57a957 | 7011 | func_fatal_error "require no space between '-L' and '$1'" |
7083c021 | 7012 | else |
6f57a957 | 7013 | func_fatal_error "need path for '-L' option" |
7083c021 AC |
7014 | fi |
7015 | fi | |
08d019eb AC |
7016 | func_resolve_sysroot "$func_stripname_result" |
7017 | dir=$func_resolve_sysroot_result | |
7083c021 AC |
7018 | # We need an absolute path. |
7019 | case $dir in | |
7020 | [\\/]* | [A-Za-z]:[\\/]*) ;; | |
7021 | *) | |
7022 | absdir=`cd "$dir" && pwd` | |
7023 | test -z "$absdir" && \ | |
6f57a957 AC |
7024 | func_fatal_error "cannot determine absolute directory name of '$dir'" |
7025 | dir=$absdir | |
7083c021 AC |
7026 | ;; |
7027 | esac | |
7028 | case "$deplibs " in | |
08d019eb AC |
7029 | *" -L$dir "* | *" $arg "*) |
7030 | # Will only happen for absolute or sysroot arguments | |
7031 | ;; | |
7083c021 | 7032 | *) |
08d019eb AC |
7033 | # Preserve sysroot, but never include relative directories |
7034 | case $dir in | |
7035 | [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; | |
7036 | *) func_append deplibs " -L$dir" ;; | |
7037 | esac | |
7038 | func_append lib_search_path " $dir" | |
7083c021 AC |
7039 | ;; |
7040 | esac | |
7041 | case $host in | |
7042 | *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) | |
08d019eb | 7043 | testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` |
7083c021 AC |
7044 | case :$dllsearchpath: in |
7045 | *":$dir:"*) ;; | |
7046 | ::) dllsearchpath=$dir;; | |
08d019eb | 7047 | *) func_append dllsearchpath ":$dir";; |
7083c021 AC |
7048 | esac |
7049 | case :$dllsearchpath: in | |
7050 | *":$testbindir:"*) ;; | |
7051 | ::) dllsearchpath=$testbindir;; | |
08d019eb | 7052 | *) func_append dllsearchpath ":$testbindir";; |
7083c021 AC |
7053 | esac |
7054 | ;; | |
7055 | esac | |
7056 | continue | |
7057 | ;; | |
db137867 | 7058 | |
7083c021 | 7059 | -l*) |
6f57a957 | 7060 | if test X-lc = "X$arg" || test X-lm = "X$arg"; then |
7083c021 | 7061 | case $host in |
08d019eb | 7062 | *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) |
7083c021 AC |
7063 | # These systems don't actually have a C or math library (as such) |
7064 | continue | |
7065 | ;; | |
7066 | *-*-os2*) | |
7067 | # These systems don't actually have a C library (as such) | |
6f57a957 | 7068 | test X-lc = "X$arg" && continue |
7083c021 | 7069 | ;; |
6f57a957 | 7070 | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) |
7083c021 | 7071 | # Do not include libc due to us having libc/libc_r. |
6f57a957 | 7072 | test X-lc = "X$arg" && continue |
7083c021 AC |
7073 | ;; |
7074 | *-*-rhapsody* | *-*-darwin1.[012]) | |
7075 | # Rhapsody C and math libraries are in the System framework | |
08d019eb | 7076 | func_append deplibs " System.ltframework" |
7083c021 AC |
7077 | continue |
7078 | ;; | |
7079 | *-*-sco3.2v5* | *-*-sco5v6*) | |
7080 | # Causes problems with __ctype | |
6f57a957 | 7081 | test X-lc = "X$arg" && continue |
7083c021 AC |
7082 | ;; |
7083 | *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) | |
7084 | # Compiler inserts libc in the correct place for threads to work | |
6f57a957 | 7085 | test X-lc = "X$arg" && continue |
7083c021 AC |
7086 | ;; |
7087 | esac | |
6f57a957 | 7088 | elif test X-lc_r = "X$arg"; then |
7083c021 | 7089 | case $host in |
6f57a957 | 7090 | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) |
7083c021 AC |
7091 | # Do not include libc_r directly, use -pthread flag. |
7092 | continue | |
7093 | ;; | |
7094 | esac | |
7095 | fi | |
08d019eb | 7096 | func_append deplibs " $arg" |
7083c021 AC |
7097 | continue |
7098 | ;; | |
db137867 | 7099 | |
6f57a957 AC |
7100 | -mllvm) |
7101 | prev=mllvm | |
7102 | continue | |
7103 | ;; | |
7104 | ||
7083c021 AC |
7105 | -module) |
7106 | module=yes | |
7107 | continue | |
7108 | ;; | |
db137867 | 7109 | |
7083c021 AC |
7110 | # Tru64 UNIX uses -model [arg] to determine the layout of C++ |
7111 | # classes, name mangling, and exception handling. | |
7112 | # Darwin uses the -arch flag to determine output architecture. | |
08d019eb AC |
7113 | -model|-arch|-isysroot|--sysroot) |
7114 | func_append compiler_flags " $arg" | |
7083c021 AC |
7115 | func_append compile_command " $arg" |
7116 | func_append finalize_command " $arg" | |
7117 | prev=xcompiler | |
7118 | continue | |
7119 | ;; | |
db137867 | 7120 | |
54bec06e AC |
7121 | -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |
7122 | |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) | |
08d019eb | 7123 | func_append compiler_flags " $arg" |
7083c021 AC |
7124 | func_append compile_command " $arg" |
7125 | func_append finalize_command " $arg" | |
7126 | case "$new_inherited_linker_flags " in | |
7127 | *" $arg "*) ;; | |
08d019eb | 7128 | * ) func_append new_inherited_linker_flags " $arg" ;; |
7083c021 AC |
7129 | esac |
7130 | continue | |
7131 | ;; | |
db137867 | 7132 | |
7083c021 | 7133 | -multi_module) |
6f57a957 | 7134 | single_module=$wl-multi_module |
7083c021 AC |
7135 | continue |
7136 | ;; | |
db137867 | 7137 | |
7083c021 AC |
7138 | -no-fast-install) |
7139 | fast_install=no | |
7140 | continue | |
7141 | ;; | |
db137867 | 7142 | |
7083c021 AC |
7143 | -no-install) |
7144 | case $host in | |
7145 | *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) | |
7146 | # The PATH hackery in wrapper scripts is required on Windows | |
7147 | # and Darwin in order for the loader to find any dlls it needs. | |
6f57a957 AC |
7148 | func_warning "'-no-install' is ignored for $host" |
7149 | func_warning "assuming '-no-fast-install' instead" | |
7083c021 AC |
7150 | fast_install=no |
7151 | ;; | |
7152 | *) no_install=yes ;; | |
7153 | esac | |
7154 | continue | |
7155 | ;; | |
db137867 | 7156 | |
7083c021 AC |
7157 | -no-undefined) |
7158 | allow_undefined=no | |
7159 | continue | |
7160 | ;; | |
db137867 | 7161 | |
7083c021 AC |
7162 | -objectlist) |
7163 | prev=objectlist | |
7164 | continue | |
7165 | ;; | |
db137867 | 7166 | |
6f57a957 AC |
7167 | -os2dllname) |
7168 | prev=os2dllname | |
7169 | continue | |
7170 | ;; | |
7171 | ||
7083c021 | 7172 | -o) prev=output ;; |
db137867 | 7173 | |
7083c021 AC |
7174 | -precious-files-regex) |
7175 | prev=precious_regex | |
7176 | continue | |
7177 | ;; | |
db137867 | 7178 | |
7083c021 AC |
7179 | -release) |
7180 | prev=release | |
7181 | continue | |
7182 | ;; | |
db137867 | 7183 | |
7083c021 AC |
7184 | -rpath) |
7185 | prev=rpath | |
7186 | continue | |
7187 | ;; | |
db137867 | 7188 | |
7083c021 AC |
7189 | -R) |
7190 | prev=xrpath | |
7191 | continue | |
7192 | ;; | |
db137867 | 7193 | |
7083c021 AC |
7194 | -R*) |
7195 | func_stripname '-R' '' "$arg" | |
7196 | dir=$func_stripname_result | |
7197 | # We need an absolute path. | |
7198 | case $dir in | |
7199 | [\\/]* | [A-Za-z]:[\\/]*) ;; | |
08d019eb AC |
7200 | =*) |
7201 | func_stripname '=' '' "$dir" | |
7202 | dir=$lt_sysroot$func_stripname_result | |
7203 | ;; | |
7083c021 AC |
7204 | *) |
7205 | func_fatal_error "only absolute run-paths are allowed" | |
7206 | ;; | |
7207 | esac | |
7208 | case "$xrpath " in | |
7209 | *" $dir "*) ;; | |
08d019eb | 7210 | *) func_append xrpath " $dir" ;; |
7083c021 AC |
7211 | esac |
7212 | continue | |
7213 | ;; | |
db137867 | 7214 | |
7083c021 AC |
7215 | -shared) |
7216 | # The effects of -shared are defined in a previous loop. | |
7217 | continue | |
7218 | ;; | |
db137867 | 7219 | |
7083c021 AC |
7220 | -shrext) |
7221 | prev=shrext | |
7222 | continue | |
7223 | ;; | |
db137867 | 7224 | |
7083c021 AC |
7225 | -static | -static-libtool-libs) |
7226 | # The effects of -static are defined in a previous loop. | |
7227 | # We used to do the same as -all-static on platforms that | |
7228 | # didn't have a PIC flag, but the assumption that the effects | |
7229 | # would be equivalent was wrong. It would break on at least | |
7230 | # Digital Unix and AIX. | |
7231 | continue | |
7232 | ;; | |
db137867 | 7233 | |
7083c021 AC |
7234 | -thread-safe) |
7235 | thread_safe=yes | |
7236 | continue | |
7237 | ;; | |
db137867 | 7238 | |
7083c021 AC |
7239 | -version-info) |
7240 | prev=vinfo | |
7241 | continue | |
7242 | ;; | |
db137867 | 7243 | |
7083c021 AC |
7244 | -version-number) |
7245 | prev=vinfo | |
7246 | vinfo_number=yes | |
7247 | continue | |
7248 | ;; | |
db137867 | 7249 | |
7083c021 AC |
7250 | -weak) |
7251 | prev=weak | |
7252 | continue | |
7253 | ;; | |
db137867 | 7254 | |
7083c021 AC |
7255 | -Wc,*) |
7256 | func_stripname '-Wc,' '' "$arg" | |
7257 | args=$func_stripname_result | |
7258 | arg= | |
6f57a957 | 7259 | save_ifs=$IFS; IFS=, |
7083c021 | 7260 | for flag in $args; do |
6f57a957 | 7261 | IFS=$save_ifs |
7083c021 | 7262 | func_quote_for_eval "$flag" |
08d019eb AC |
7263 | func_append arg " $func_quote_for_eval_result" |
7264 | func_append compiler_flags " $func_quote_for_eval_result" | |
7083c021 | 7265 | done |
6f57a957 | 7266 | IFS=$save_ifs |
7083c021 AC |
7267 | func_stripname ' ' '' "$arg" |
7268 | arg=$func_stripname_result | |
7269 | ;; | |
db137867 | 7270 | |
7083c021 AC |
7271 | -Wl,*) |
7272 | func_stripname '-Wl,' '' "$arg" | |
7273 | args=$func_stripname_result | |
7274 | arg= | |
6f57a957 | 7275 | save_ifs=$IFS; IFS=, |
7083c021 | 7276 | for flag in $args; do |
6f57a957 | 7277 | IFS=$save_ifs |
7083c021 | 7278 | func_quote_for_eval "$flag" |
08d019eb AC |
7279 | func_append arg " $wl$func_quote_for_eval_result" |
7280 | func_append compiler_flags " $wl$func_quote_for_eval_result" | |
7281 | func_append linker_flags " $func_quote_for_eval_result" | |
7083c021 | 7282 | done |
6f57a957 | 7283 | IFS=$save_ifs |
7083c021 AC |
7284 | func_stripname ' ' '' "$arg" |
7285 | arg=$func_stripname_result | |
7286 | ;; | |
db137867 | 7287 | |
7083c021 AC |
7288 | -Xcompiler) |
7289 | prev=xcompiler | |
7290 | continue | |
7291 | ;; | |
db137867 | 7292 | |
7083c021 AC |
7293 | -Xlinker) |
7294 | prev=xlinker | |
7295 | continue | |
7296 | ;; | |
db137867 | 7297 | |
7083c021 AC |
7298 | -XCClinker) |
7299 | prev=xcclinker | |
7300 | continue | |
7301 | ;; | |
db137867 | 7302 | |
7083c021 AC |
7303 | # -msg_* for osf cc |
7304 | -msg_*) | |
7305 | func_quote_for_eval "$arg" | |
6f57a957 | 7306 | arg=$func_quote_for_eval_result |
7083c021 | 7307 | ;; |
db137867 | 7308 | |
08d019eb AC |
7309 | # Flags to be passed through unchanged, with rationale: |
7310 | # -64, -mips[0-9] enable 64-bit mode for the SGI compiler | |
7311 | # -r[0-9][0-9]* specify processor for the SGI compiler | |
7312 | # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler | |
7313 | # +DA*, +DD* enable 64-bit mode for the HP compiler | |
7314 | # -q* compiler args for the IBM compiler | |
7315 | # -m*, -t[45]*, -txscale* architecture-specific flags for GCC | |
7316 | # -F/path path to uninstalled frameworks, gcc on darwin | |
7317 | # -p, -pg, --coverage, -fprofile-* profiling flags for GCC | |
6f57a957 | 7318 | # -fstack-protector* stack protector flags for GCC |
08d019eb AC |
7319 | # @file GCC response files |
7320 | # -tp=* Portland pgcc target processor selection | |
7321 | # --sysroot=* for sysroot support | |
6f57a957 | 7322 | # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization |
fe037171 | 7323 | # -specs=* GCC specs files |
6f57a957 | 7324 | # -stdlib=* select c++ std lib with clang |
fe037171 EM |
7325 | # -fsanitize=* Clang/GCC memory and address sanitizer |
7326 | # -fuse-ld=* Linker select flags for GCC | |
7083c021 | 7327 | -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ |
08d019eb | 7328 | -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ |
fe037171 EM |
7329 | -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ |
7330 | -specs=*|-fsanitize=*|-fuse-ld=*) | |
7083c021 | 7331 | func_quote_for_eval "$arg" |
6f57a957 | 7332 | arg=$func_quote_for_eval_result |
7083c021 AC |
7333 | func_append compile_command " $arg" |
7334 | func_append finalize_command " $arg" | |
08d019eb | 7335 | func_append compiler_flags " $arg" |
7083c021 AC |
7336 | continue |
7337 | ;; | |
db137867 | 7338 | |
6f57a957 AC |
7339 | -Z*) |
7340 | if test os2 = "`expr $host : '.*\(os2\)'`"; then | |
7341 | # OS/2 uses -Zxxx to specify OS/2-specific options | |
7342 | compiler_flags="$compiler_flags $arg" | |
7343 | func_append compile_command " $arg" | |
7344 | func_append finalize_command " $arg" | |
7345 | case $arg in | |
7346 | -Zlinker | -Zstack) | |
7347 | prev=xcompiler | |
7348 | ;; | |
7349 | esac | |
7350 | continue | |
7351 | else | |
7352 | # Otherwise treat like 'Some other compiler flag' below | |
7353 | func_quote_for_eval "$arg" | |
7354 | arg=$func_quote_for_eval_result | |
7355 | fi | |
7356 | ;; | |
7357 | ||
7083c021 AC |
7358 | # Some other compiler flag. |
7359 | -* | +*) | |
7360 | func_quote_for_eval "$arg" | |
6f57a957 | 7361 | arg=$func_quote_for_eval_result |
7083c021 | 7362 | ;; |
db137867 | 7363 | |
7083c021 AC |
7364 | *.$objext) |
7365 | # A standard object. | |
08d019eb | 7366 | func_append objs " $arg" |
7083c021 | 7367 | ;; |
db137867 | 7368 | |
7083c021 AC |
7369 | *.lo) |
7370 | # A libtool-controlled object. | |
db137867 | 7371 | |
7083c021 AC |
7372 | # Check to see that this really is a libtool object. |
7373 | if func_lalib_unsafe_p "$arg"; then | |
7374 | pic_object= | |
7375 | non_pic_object= | |
db137867 | 7376 | |
7083c021 AC |
7377 | # Read the .lo file |
7378 | func_source "$arg" | |
db137867 | 7379 | |
7083c021 AC |
7380 | if test -z "$pic_object" || |
7381 | test -z "$non_pic_object" || | |
6f57a957 AC |
7382 | test none = "$pic_object" && |
7383 | test none = "$non_pic_object"; then | |
7384 | func_fatal_error "cannot find name of object for '$arg'" | |
7083c021 | 7385 | fi |
db137867 | 7386 | |
7083c021 AC |
7387 | # Extract subdirectory from the argument. |
7388 | func_dirname "$arg" "/" "" | |
6f57a957 | 7389 | xdir=$func_dirname_result |
db137867 | 7390 | |
6f57a957 | 7391 | test none = "$pic_object" || { |
7083c021 | 7392 | # Prepend the subdirectory the object is found in. |
6f57a957 | 7393 | pic_object=$xdir$pic_object |
db137867 | 7394 | |
6f57a957 AC |
7395 | if test dlfiles = "$prev"; then |
7396 | if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then | |
08d019eb | 7397 | func_append dlfiles " $pic_object" |
7083c021 AC |
7398 | prev= |
7399 | continue | |
7400 | else | |
7401 | # If libtool objects are unsupported, then we need to preload. | |
7402 | prev=dlprefiles | |
7403 | fi | |
7404 | fi | |
db137867 | 7405 | |
7083c021 | 7406 | # CHECK ME: I think I busted this. -Ossama |
6f57a957 | 7407 | if test dlprefiles = "$prev"; then |
7083c021 | 7408 | # Preload the old-style object. |
08d019eb | 7409 | func_append dlprefiles " $pic_object" |
7083c021 AC |
7410 | prev= |
7411 | fi | |
db137867 | 7412 | |
7083c021 AC |
7413 | # A PIC object. |
7414 | func_append libobjs " $pic_object" | |
6f57a957 AC |
7415 | arg=$pic_object |
7416 | } | |
db137867 | 7417 | |
7083c021 | 7418 | # Non-PIC object. |
6f57a957 | 7419 | if test none != "$non_pic_object"; then |
7083c021 | 7420 | # Prepend the subdirectory the object is found in. |
6f57a957 | 7421 | non_pic_object=$xdir$non_pic_object |
db137867 | 7422 | |
7083c021 AC |
7423 | # A standard non-PIC object |
7424 | func_append non_pic_objects " $non_pic_object" | |
6f57a957 AC |
7425 | if test -z "$pic_object" || test none = "$pic_object"; then |
7426 | arg=$non_pic_object | |
7083c021 AC |
7427 | fi |
7428 | else | |
7429 | # If the PIC object exists, use it instead. | |
7430 | # $xdir was prepended to $pic_object above. | |
6f57a957 | 7431 | non_pic_object=$pic_object |
7083c021 AC |
7432 | func_append non_pic_objects " $non_pic_object" |
7433 | fi | |
7434 | else | |
7435 | # Only an error if not doing a dry-run. | |
7436 | if $opt_dry_run; then | |
7437 | # Extract subdirectory from the argument. | |
7438 | func_dirname "$arg" "/" "" | |
6f57a957 | 7439 | xdir=$func_dirname_result |
7083c021 AC |
7440 | |
7441 | func_lo2o "$arg" | |
7442 | pic_object=$xdir$objdir/$func_lo2o_result | |
7443 | non_pic_object=$xdir$func_lo2o_result | |
7444 | func_append libobjs " $pic_object" | |
7445 | func_append non_pic_objects " $non_pic_object" | |
7446 | else | |
6f57a957 | 7447 | func_fatal_error "'$arg' is not a valid libtool object" |
7083c021 AC |
7448 | fi |
7449 | fi | |
7450 | ;; | |
7451 | ||
7452 | *.$libext) | |
7453 | # An archive. | |
08d019eb AC |
7454 | func_append deplibs " $arg" |
7455 | func_append old_deplibs " $arg" | |
7083c021 AC |
7456 | continue |
7457 | ;; | |
7458 | ||
7459 | *.la) | |
7460 | # A libtool-controlled library. | |
7461 | ||
08d019eb | 7462 | func_resolve_sysroot "$arg" |
6f57a957 | 7463 | if test dlfiles = "$prev"; then |
7083c021 | 7464 | # This library was specified with -dlopen. |
08d019eb | 7465 | func_append dlfiles " $func_resolve_sysroot_result" |
7083c021 | 7466 | prev= |
6f57a957 | 7467 | elif test dlprefiles = "$prev"; then |
7083c021 | 7468 | # The library was specified with -dlpreopen. |
08d019eb | 7469 | func_append dlprefiles " $func_resolve_sysroot_result" |
7083c021 AC |
7470 | prev= |
7471 | else | |
08d019eb | 7472 | func_append deplibs " $func_resolve_sysroot_result" |
7083c021 AC |
7473 | fi |
7474 | continue | |
7475 | ;; | |
7476 | ||
7477 | # Some other compiler argument. | |
7478 | *) | |
7479 | # Unknown arguments in both finalize_command and compile_command need | |
7480 | # to be aesthetically quoted because they are evaled later. | |
7481 | func_quote_for_eval "$arg" | |
6f57a957 | 7482 | arg=$func_quote_for_eval_result |
7083c021 AC |
7483 | ;; |
7484 | esac # arg | |
7485 | ||
7486 | # Now actually substitute the argument into the commands. | |
7487 | if test -n "$arg"; then | |
7488 | func_append compile_command " $arg" | |
7489 | func_append finalize_command " $arg" | |
7490 | fi | |
7491 | done # argument parsing loop | |
7492 | ||
7493 | test -n "$prev" && \ | |
6f57a957 | 7494 | func_fatal_help "the '$prevarg' option requires an argument" |
7083c021 | 7495 | |
6f57a957 | 7496 | if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then |
7083c021 AC |
7497 | eval arg=\"$export_dynamic_flag_spec\" |
7498 | func_append compile_command " $arg" | |
7499 | func_append finalize_command " $arg" | |
7500 | fi | |
7501 | ||
7502 | oldlibs= | |
7503 | # calculate the name of the file, without its directory | |
7504 | func_basename "$output" | |
6f57a957 AC |
7505 | outputname=$func_basename_result |
7506 | libobjs_save=$libobjs | |
7083c021 AC |
7507 | |
7508 | if test -n "$shlibpath_var"; then | |
7509 | # get the directories listed in $shlibpath_var | |
6f57a957 | 7510 | eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` |
7083c021 AC |
7511 | else |
7512 | shlib_search_path= | |
7513 | fi | |
7514 | eval sys_lib_search_path=\"$sys_lib_search_path_spec\" | |
7515 | eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" | |
7516 | ||
6f57a957 AC |
7517 | # Definition is injected by LT_CONFIG during libtool generation. |
7518 | func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" | |
7519 | ||
7083c021 | 7520 | func_dirname "$output" "/" "" |
6f57a957 | 7521 | output_objdir=$func_dirname_result$objdir |
08d019eb AC |
7522 | func_to_tool_file "$output_objdir/" |
7523 | tool_output_objdir=$func_to_tool_file_result | |
7083c021 AC |
7524 | # Create the object directory. |
7525 | func_mkdir_p "$output_objdir" | |
7526 | ||
7527 | # Determine the type of output | |
7528 | case $output in | |
7529 | "") | |
7530 | func_fatal_help "you must specify an output file" | |
7531 | ;; | |
7532 | *.$libext) linkmode=oldlib ;; | |
7533 | *.lo | *.$objext) linkmode=obj ;; | |
7534 | *.la) linkmode=lib ;; | |
7535 | *) linkmode=prog ;; # Anything else should be a program. | |
7536 | esac | |
7537 | ||
7538 | specialdeplibs= | |
7539 | ||
7540 | libs= | |
7541 | # Find all interdependent deplibs by searching for libraries | |
7542 | # that are linked more than once (e.g. -la -lb -la) | |
7543 | for deplib in $deplibs; do | |
6f57a957 | 7544 | if $opt_preserve_dup_deps; then |
7083c021 | 7545 | case "$libs " in |
08d019eb | 7546 | *" $deplib "*) func_append specialdeplibs " $deplib" ;; |
7083c021 AC |
7547 | esac |
7548 | fi | |
08d019eb | 7549 | func_append libs " $deplib" |
7083c021 AC |
7550 | done |
7551 | ||
6f57a957 | 7552 | if test lib = "$linkmode"; then |
7083c021 AC |
7553 | libs="$predeps $libs $compiler_lib_search_path $postdeps" |
7554 | ||
7555 | # Compute libraries that are listed more than once in $predeps | |
7556 | # $postdeps and mark them as special (i.e., whose duplicates are | |
7557 | # not to be eliminated). | |
7558 | pre_post_deps= | |
7559 | if $opt_duplicate_compiler_generated_deps; then | |
7560 | for pre_post_dep in $predeps $postdeps; do | |
7561 | case "$pre_post_deps " in | |
08d019eb | 7562 | *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; |
7083c021 | 7563 | esac |
08d019eb | 7564 | func_append pre_post_deps " $pre_post_dep" |
7083c021 AC |
7565 | done |
7566 | fi | |
7567 | pre_post_deps= | |
7568 | fi | |
7569 | ||
7570 | deplibs= | |
7571 | newdependency_libs= | |
7572 | newlib_search_path= | |
7573 | need_relink=no # whether we're linking any uninstalled libtool libraries | |
7574 | notinst_deplibs= # not-installed libtool libraries | |
7575 | notinst_path= # paths that contain not-installed libtool libraries | |
7576 | ||
7577 | case $linkmode in | |
7578 | lib) | |
7579 | passes="conv dlpreopen link" | |
7580 | for file in $dlfiles $dlprefiles; do | |
7581 | case $file in | |
7582 | *.la) ;; | |
7583 | *) | |
6f57a957 | 7584 | func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" |
7083c021 AC |
7585 | ;; |
7586 | esac | |
7587 | done | |
7588 | ;; | |
7589 | prog) | |
7590 | compile_deplibs= | |
7591 | finalize_deplibs= | |
6f57a957 | 7592 | alldeplibs=false |
7083c021 AC |
7593 | newdlfiles= |
7594 | newdlprefiles= | |
7595 | passes="conv scan dlopen dlpreopen link" | |
7596 | ;; | |
7597 | *) passes="conv" | |
7598 | ;; | |
7599 | esac | |
7600 | ||
7601 | for pass in $passes; do | |
7602 | # The preopen pass in lib mode reverses $deplibs; put it back here | |
7603 | # so that -L comes before libs that need it for instance... | |
6f57a957 | 7604 | if test lib,link = "$linkmode,$pass"; then |
7083c021 AC |
7605 | ## FIXME: Find the place where the list is rebuilt in the wrong |
7606 | ## order, and fix it there properly | |
7607 | tmp_deplibs= | |
7608 | for deplib in $deplibs; do | |
7609 | tmp_deplibs="$deplib $tmp_deplibs" | |
7610 | done | |
6f57a957 | 7611 | deplibs=$tmp_deplibs |
7083c021 AC |
7612 | fi |
7613 | ||
6f57a957 AC |
7614 | if test lib,link = "$linkmode,$pass" || |
7615 | test prog,scan = "$linkmode,$pass"; then | |
7616 | libs=$deplibs | |
7083c021 AC |
7617 | deplibs= |
7618 | fi | |
6f57a957 | 7619 | if test prog = "$linkmode"; then |
7083c021 | 7620 | case $pass in |
6f57a957 AC |
7621 | dlopen) libs=$dlfiles ;; |
7622 | dlpreopen) libs=$dlprefiles ;; | |
7472e54d | 7623 | link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; |
7083c021 AC |
7624 | esac |
7625 | fi | |
6f57a957 | 7626 | if test lib,dlpreopen = "$linkmode,$pass"; then |
7083c021 AC |
7627 | # Collect and forward deplibs of preopened libtool libs |
7628 | for lib in $dlprefiles; do | |
7629 | # Ignore non-libtool-libs | |
7630 | dependency_libs= | |
08d019eb | 7631 | func_resolve_sysroot "$lib" |
7083c021 | 7632 | case $lib in |
08d019eb | 7633 | *.la) func_source "$func_resolve_sysroot_result" ;; |
7083c021 AC |
7634 | esac |
7635 | ||
7636 | # Collect preopened libtool deplibs, except any this library | |
7637 | # has declared as weak libs | |
7638 | for deplib in $dependency_libs; do | |
08d019eb AC |
7639 | func_basename "$deplib" |
7640 | deplib_base=$func_basename_result | |
7083c021 AC |
7641 | case " $weak_libs " in |
7642 | *" $deplib_base "*) ;; | |
08d019eb | 7643 | *) func_append deplibs " $deplib" ;; |
7083c021 AC |
7644 | esac |
7645 | done | |
7646 | done | |
6f57a957 | 7647 | libs=$dlprefiles |
7083c021 | 7648 | fi |
6f57a957 | 7649 | if test dlopen = "$pass"; then |
7083c021 | 7650 | # Collect dlpreopened libraries |
6f57a957 | 7651 | save_deplibs=$deplibs |
7083c021 AC |
7652 | deplibs= |
7653 | fi | |
7654 | ||
7655 | for deplib in $libs; do | |
7656 | lib= | |
6f57a957 | 7657 | found=false |
7083c021 | 7658 | case $deplib in |
54bec06e AC |
7659 | -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |
7660 | |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) | |
6f57a957 | 7661 | if test prog,link = "$linkmode,$pass"; then |
7083c021 AC |
7662 | compile_deplibs="$deplib $compile_deplibs" |
7663 | finalize_deplibs="$deplib $finalize_deplibs" | |
7664 | else | |
08d019eb | 7665 | func_append compiler_flags " $deplib" |
6f57a957 | 7666 | if test lib = "$linkmode"; then |
7083c021 AC |
7667 | case "$new_inherited_linker_flags " in |
7668 | *" $deplib "*) ;; | |
08d019eb | 7669 | * ) func_append new_inherited_linker_flags " $deplib" ;; |
7083c021 AC |
7670 | esac |
7671 | fi | |
7672 | fi | |
7673 | continue | |
7674 | ;; | |
7675 | -l*) | |
6f57a957 AC |
7676 | if test lib != "$linkmode" && test prog != "$linkmode"; then |
7677 | func_warning "'-l' is ignored for archives/objects" | |
7083c021 AC |
7678 | continue |
7679 | fi | |
7680 | func_stripname '-l' '' "$deplib" | |
7681 | name=$func_stripname_result | |
6f57a957 | 7682 | if test lib = "$linkmode"; then |
7083c021 AC |
7683 | searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" |
7684 | else | |
7685 | searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" | |
7686 | fi | |
7687 | for searchdir in $searchdirs; do | |
7688 | for search_ext in .la $std_shrext .so .a; do | |
7689 | # Search the libtool library | |
6f57a957 | 7690 | lib=$searchdir/lib$name$search_ext |
7083c021 | 7691 | if test -f "$lib"; then |
6f57a957 AC |
7692 | if test .la = "$search_ext"; then |
7693 | found=: | |
7083c021 | 7694 | else |
6f57a957 | 7695 | found=false |
7083c021 AC |
7696 | fi |
7697 | break 2 | |
7698 | fi | |
7699 | done | |
7700 | done | |
6f57a957 AC |
7701 | if $found; then |
7702 | # deplib is a libtool library | |
7083c021 AC |
7703 | # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, |
7704 | # We need to do some special things here, and not later. | |
6f57a957 | 7705 | if test yes = "$allow_libtool_libs_with_static_runtimes"; then |
7083c021 AC |
7706 | case " $predeps $postdeps " in |
7707 | *" $deplib "*) | |
7708 | if func_lalib_p "$lib"; then | |
7709 | library_names= | |
7710 | old_library= | |
7711 | func_source "$lib" | |
7712 | for l in $old_library $library_names; do | |
6f57a957 | 7713 | ll=$l |
7083c021 | 7714 | done |
6f57a957 AC |
7715 | if test "X$ll" = "X$old_library"; then # only static version available |
7716 | found=false | |
7083c021 | 7717 | func_dirname "$lib" "" "." |
6f57a957 | 7718 | ladir=$func_dirname_result |
7083c021 | 7719 | lib=$ladir/$old_library |
6f57a957 | 7720 | if test prog,link = "$linkmode,$pass"; then |
7083c021 AC |
7721 | compile_deplibs="$deplib $compile_deplibs" |
7722 | finalize_deplibs="$deplib $finalize_deplibs" | |
7723 | else | |
7724 | deplibs="$deplib $deplibs" | |
6f57a957 | 7725 | test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" |
7083c021 AC |
7726 | fi |
7727 | continue | |
7728 | fi | |
7729 | fi | |
7730 | ;; | |
7731 | *) ;; | |
7732 | esac | |
7733 | fi | |
6f57a957 AC |
7734 | else |
7735 | # deplib doesn't seem to be a libtool library | |
7736 | if test prog,link = "$linkmode,$pass"; then | |
7737 | compile_deplibs="$deplib $compile_deplibs" | |
7738 | finalize_deplibs="$deplib $finalize_deplibs" | |
7739 | else | |
7740 | deplibs="$deplib $deplibs" | |
7741 | test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" | |
7742 | fi | |
7743 | continue | |
7083c021 AC |
7744 | fi |
7745 | ;; # -l | |
7746 | *.ltframework) | |
6f57a957 | 7747 | if test prog,link = "$linkmode,$pass"; then |
7083c021 AC |
7748 | compile_deplibs="$deplib $compile_deplibs" |
7749 | finalize_deplibs="$deplib $finalize_deplibs" | |
7750 | else | |
7751 | deplibs="$deplib $deplibs" | |
6f57a957 | 7752 | if test lib = "$linkmode"; then |
7083c021 AC |
7753 | case "$new_inherited_linker_flags " in |
7754 | *" $deplib "*) ;; | |
08d019eb | 7755 | * ) func_append new_inherited_linker_flags " $deplib" ;; |
7083c021 AC |
7756 | esac |
7757 | fi | |
7758 | fi | |
7759 | continue | |
7760 | ;; | |
7761 | -L*) | |
7762 | case $linkmode in | |
7763 | lib) | |
7764 | deplibs="$deplib $deplibs" | |
6f57a957 | 7765 | test conv = "$pass" && continue |
7083c021 AC |
7766 | newdependency_libs="$deplib $newdependency_libs" |
7767 | func_stripname '-L' '' "$deplib" | |
08d019eb AC |
7768 | func_resolve_sysroot "$func_stripname_result" |
7769 | func_append newlib_search_path " $func_resolve_sysroot_result" | |
7083c021 AC |
7770 | ;; |
7771 | prog) | |
6f57a957 | 7772 | if test conv = "$pass"; then |
7083c021 AC |
7773 | deplibs="$deplib $deplibs" |
7774 | continue | |
7775 | fi | |
6f57a957 | 7776 | if test scan = "$pass"; then |
7083c021 AC |
7777 | deplibs="$deplib $deplibs" |
7778 | else | |
7779 | compile_deplibs="$deplib $compile_deplibs" | |
7780 | finalize_deplibs="$deplib $finalize_deplibs" | |
7781 | fi | |
7782 | func_stripname '-L' '' "$deplib" | |
08d019eb AC |
7783 | func_resolve_sysroot "$func_stripname_result" |
7784 | func_append newlib_search_path " $func_resolve_sysroot_result" | |
7083c021 AC |
7785 | ;; |
7786 | *) | |
6f57a957 | 7787 | func_warning "'-L' is ignored for archives/objects" |
7083c021 AC |
7788 | ;; |
7789 | esac # linkmode | |
7790 | continue | |
7791 | ;; # -L | |
7792 | -R*) | |
6f57a957 | 7793 | if test link = "$pass"; then |
7083c021 | 7794 | func_stripname '-R' '' "$deplib" |
08d019eb AC |
7795 | func_resolve_sysroot "$func_stripname_result" |
7796 | dir=$func_resolve_sysroot_result | |
7083c021 AC |
7797 | # Make sure the xrpath contains only unique directories. |
7798 | case "$xrpath " in | |
7799 | *" $dir "*) ;; | |
08d019eb | 7800 | *) func_append xrpath " $dir" ;; |
7083c021 AC |
7801 | esac |
7802 | fi | |
7803 | deplibs="$deplib $deplibs" | |
7804 | continue | |
7805 | ;; | |
08d019eb AC |
7806 | *.la) |
7807 | func_resolve_sysroot "$deplib" | |
7808 | lib=$func_resolve_sysroot_result | |
7809 | ;; | |
7083c021 | 7810 | *.$libext) |
6f57a957 | 7811 | if test conv = "$pass"; then |
7083c021 AC |
7812 | deplibs="$deplib $deplibs" |
7813 | continue | |
7814 | fi | |
7815 | case $linkmode in | |
7816 | lib) | |
7817 | # Linking convenience modules into shared libraries is allowed, | |
7818 | # but linking other static libraries is non-portable. | |
7819 | case " $dlpreconveniencelibs " in | |
7820 | *" $deplib "*) ;; | |
7821 | *) | |
6f57a957 | 7822 | valid_a_lib=false |
7083c021 AC |
7823 | case $deplibs_check_method in |
7824 | match_pattern*) | |
7825 | set dummy $deplibs_check_method; shift | |
7826 | match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` | |
08d019eb | 7827 | if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ |
7083c021 | 7828 | | $EGREP "$match_pattern_regex" > /dev/null; then |
6f57a957 | 7829 | valid_a_lib=: |
7083c021 AC |
7830 | fi |
7831 | ;; | |
7832 | pass_all) | |
6f57a957 | 7833 | valid_a_lib=: |
7083c021 AC |
7834 | ;; |
7835 | esac | |
6f57a957 AC |
7836 | if $valid_a_lib; then |
7837 | echo | |
7838 | $ECHO "*** Warning: Linking the shared library $output against the" | |
7839 | $ECHO "*** static library $deplib is not portable!" | |
7840 | deplibs="$deplib $deplibs" | |
7841 | else | |
08d019eb | 7842 | echo |
7083c021 | 7843 | $ECHO "*** Warning: Trying to link with static lib archive $deplib." |
08d019eb AC |
7844 | echo "*** I have the capability to make that library automatically link in when" |
7845 | echo "*** you link to this library. But I can only do this if you have a" | |
7846 | echo "*** shared version of the library, which you do not appear to have" | |
7847 | echo "*** because the file extensions .$libext of this argument makes me believe" | |
7848 | echo "*** that it is just a static archive that I should not use here." | |
7083c021 AC |
7849 | fi |
7850 | ;; | |
7851 | esac | |
7852 | continue | |
7853 | ;; | |
7854 | prog) | |
6f57a957 | 7855 | if test link != "$pass"; then |
7083c021 AC |
7856 | deplibs="$deplib $deplibs" |
7857 | else | |
7858 | compile_deplibs="$deplib $compile_deplibs" | |
7859 | finalize_deplibs="$deplib $finalize_deplibs" | |
7860 | fi | |
7861 | continue | |
7862 | ;; | |
7863 | esac # linkmode | |
7864 | ;; # *.$libext | |
7865 | *.lo | *.$objext) | |
6f57a957 | 7866 | if test conv = "$pass"; then |
7083c021 | 7867 | deplibs="$deplib $deplibs" |
6f57a957 AC |
7868 | elif test prog = "$linkmode"; then |
7869 | if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then | |
7083c021 AC |
7870 | # If there is no dlopen support or we're linking statically, |
7871 | # we need to preload. | |
08d019eb | 7872 | func_append newdlprefiles " $deplib" |
7083c021 AC |
7873 | compile_deplibs="$deplib $compile_deplibs" |
7874 | finalize_deplibs="$deplib $finalize_deplibs" | |
7875 | else | |
08d019eb | 7876 | func_append newdlfiles " $deplib" |
7083c021 AC |
7877 | fi |
7878 | fi | |
7879 | continue | |
7880 | ;; | |
7881 | %DEPLIBS%) | |
6f57a957 | 7882 | alldeplibs=: |
7083c021 AC |
7883 | continue |
7884 | ;; | |
7885 | esac # case $deplib | |
7886 | ||
6f57a957 AC |
7887 | $found || test -f "$lib" \ |
7888 | || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" | |
7083c021 AC |
7889 | |
7890 | # Check to see that this really is a libtool archive. | |
7891 | func_lalib_unsafe_p "$lib" \ | |
6f57a957 | 7892 | || func_fatal_error "'$lib' is not a valid libtool archive" |
7083c021 AC |
7893 | |
7894 | func_dirname "$lib" "" "." | |
6f57a957 | 7895 | ladir=$func_dirname_result |
7083c021 AC |
7896 | |
7897 | dlname= | |
7898 | dlopen= | |
7899 | dlpreopen= | |
7900 | libdir= | |
7901 | library_names= | |
7902 | old_library= | |
7903 | inherited_linker_flags= | |
7904 | # If the library was installed with an old release of libtool, | |
7905 | # it will not redefine variables installed, or shouldnotlink | |
7906 | installed=yes | |
7907 | shouldnotlink=no | |
7908 | avoidtemprpath= | |
7909 | ||
7910 | ||
7911 | # Read the .la file | |
7912 | func_source "$lib" | |
7913 | ||
7914 | # Convert "-framework foo" to "foo.ltframework" | |
7915 | if test -n "$inherited_linker_flags"; then | |
08d019eb | 7916 | tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` |
7083c021 AC |
7917 | for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do |
7918 | case " $new_inherited_linker_flags " in | |
7919 | *" $tmp_inherited_linker_flag "*) ;; | |
08d019eb | 7920 | *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; |
7083c021 AC |
7921 | esac |
7922 | done | |
7923 | fi | |
08d019eb | 7924 | dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` |
6f57a957 AC |
7925 | if test lib,link = "$linkmode,$pass" || |
7926 | test prog,scan = "$linkmode,$pass" || | |
7927 | { test prog != "$linkmode" && test lib != "$linkmode"; }; then | |
08d019eb AC |
7928 | test -n "$dlopen" && func_append dlfiles " $dlopen" |
7929 | test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" | |
7083c021 AC |
7930 | fi |
7931 | ||
6f57a957 | 7932 | if test conv = "$pass"; then |
7083c021 AC |
7933 | # Only check for convenience libraries |
7934 | deplibs="$lib $deplibs" | |
7935 | if test -z "$libdir"; then | |
7936 | if test -z "$old_library"; then | |
6f57a957 | 7937 | func_fatal_error "cannot find name of link library for '$lib'" |
7083c021 AC |
7938 | fi |
7939 | # It is a libtool convenience library, so add in its objects. | |
08d019eb AC |
7940 | func_append convenience " $ladir/$objdir/$old_library" |
7941 | func_append old_convenience " $ladir/$objdir/$old_library" | |
6f57a957 AC |
7942 | elif test prog != "$linkmode" && test lib != "$linkmode"; then |
7943 | func_fatal_error "'$lib' is not a convenience library" | |
7083c021 | 7944 | fi |
7472e54d AC |
7945 | tmp_libs= |
7946 | for deplib in $dependency_libs; do | |
7947 | deplibs="$deplib $deplibs" | |
6f57a957 | 7948 | if $opt_preserve_dup_deps; then |
7472e54d | 7949 | case "$tmp_libs " in |
08d019eb | 7950 | *" $deplib "*) func_append specialdeplibs " $deplib" ;; |
7472e54d AC |
7951 | esac |
7952 | fi | |
08d019eb | 7953 | func_append tmp_libs " $deplib" |
7472e54d | 7954 | done |
7083c021 AC |
7955 | continue |
7956 | fi # $pass = conv | |
7957 | ||
7958 | ||
7959 | # Get the name of the library we link against. | |
7960 | linklib= | |
08d019eb | 7961 | if test -n "$old_library" && |
6f57a957 AC |
7962 | { test yes = "$prefer_static_libs" || |
7963 | test built,no = "$prefer_static_libs,$installed"; }; then | |
08d019eb AC |
7964 | linklib=$old_library |
7965 | else | |
7966 | for l in $old_library $library_names; do | |
6f57a957 | 7967 | linklib=$l |
08d019eb AC |
7968 | done |
7969 | fi | |
7083c021 | 7970 | if test -z "$linklib"; then |
6f57a957 | 7971 | func_fatal_error "cannot find name of link library for '$lib'" |
7083c021 AC |
7972 | fi |
7973 | ||
7974 | # This library was specified with -dlopen. | |
6f57a957 AC |
7975 | if test dlopen = "$pass"; then |
7976 | test -z "$libdir" \ | |
7977 | && func_fatal_error "cannot -dlopen a convenience library: '$lib'" | |
7083c021 | 7978 | if test -z "$dlname" || |
6f57a957 AC |
7979 | test yes != "$dlopen_support" || |
7980 | test no = "$build_libtool_libs" | |
7981 | then | |
7083c021 AC |
7982 | # If there is no dlname, no dlopen support or we're linking |
7983 | # statically, we need to preload. We also need to preload any | |
7984 | # dependent libraries so libltdl's deplib preloader doesn't | |
7985 | # bomb out in the load deplibs phase. | |
08d019eb | 7986 | func_append dlprefiles " $lib $dependency_libs" |
7083c021 | 7987 | else |
08d019eb | 7988 | func_append newdlfiles " $lib" |
7083c021 AC |
7989 | fi |
7990 | continue | |
7991 | fi # $pass = dlopen | |
7992 | ||
7993 | # We need an absolute path. | |
7994 | case $ladir in | |
6f57a957 | 7995 | [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; |
7083c021 AC |
7996 | *) |
7997 | abs_ladir=`cd "$ladir" && pwd` | |
7998 | if test -z "$abs_ladir"; then | |
6f57a957 | 7999 | func_warning "cannot determine absolute directory name of '$ladir'" |
7083c021 | 8000 | func_warning "passing it literally to the linker, although it might fail" |
6f57a957 | 8001 | abs_ladir=$ladir |
7083c021 AC |
8002 | fi |
8003 | ;; | |
8004 | esac | |
8005 | func_basename "$lib" | |
6f57a957 | 8006 | laname=$func_basename_result |
7083c021 AC |
8007 | |
8008 | # Find the relevant object directory and library name. | |
6f57a957 | 8009 | if test yes = "$installed"; then |
08d019eb | 8010 | if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then |
6f57a957 AC |
8011 | func_warning "library '$lib' was moved." |
8012 | dir=$ladir | |
8013 | absdir=$abs_ladir | |
8014 | libdir=$abs_ladir | |
7083c021 | 8015 | else |
6f57a957 AC |
8016 | dir=$lt_sysroot$libdir |
8017 | absdir=$lt_sysroot$libdir | |
7083c021 | 8018 | fi |
6f57a957 | 8019 | test yes = "$hardcode_automatic" && avoidtemprpath=yes |
7083c021 AC |
8020 | else |
8021 | if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then | |
6f57a957 AC |
8022 | dir=$ladir |
8023 | absdir=$abs_ladir | |
7083c021 | 8024 | # Remove this search path later |
08d019eb | 8025 | func_append notinst_path " $abs_ladir" |
7083c021 | 8026 | else |
6f57a957 AC |
8027 | dir=$ladir/$objdir |
8028 | absdir=$abs_ladir/$objdir | |
7083c021 | 8029 | # Remove this search path later |
08d019eb | 8030 | func_append notinst_path " $abs_ladir" |
7083c021 AC |
8031 | fi |
8032 | fi # $installed = yes | |
8033 | func_stripname 'lib' '.la' "$laname" | |
8034 | name=$func_stripname_result | |
8035 | ||
8036 | # This library was specified with -dlpreopen. | |
6f57a957 AC |
8037 | if test dlpreopen = "$pass"; then |
8038 | if test -z "$libdir" && test prog = "$linkmode"; then | |
8039 | func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" | |
7083c021 | 8040 | fi |
6f57a957 | 8041 | case $host in |
08d019eb AC |
8042 | # special handling for platforms with PE-DLLs. |
8043 | *cygwin* | *mingw* | *cegcc* ) | |
8044 | # Linker will automatically link against shared library if both | |
8045 | # static and shared are present. Therefore, ensure we extract | |
8046 | # symbols from the import library if a shared library is present | |
8047 | # (otherwise, the dlopen module name will be incorrect). We do | |
8048 | # this by putting the import library name into $newdlprefiles. | |
8049 | # We recover the dlopen module name by 'saving' the la file | |
8050 | # name in a special purpose variable, and (later) extracting the | |
8051 | # dlname from the la file. | |
8052 | if test -n "$dlname"; then | |
8053 | func_tr_sh "$dir/$linklib" | |
8054 | eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" | |
8055 | func_append newdlprefiles " $dir/$linklib" | |
8056 | else | |
8057 | func_append newdlprefiles " $dir/$old_library" | |
8058 | # Keep a list of preopened convenience libraries to check | |
8059 | # that they are being used correctly in the link pass. | |
8060 | test -z "$libdir" && \ | |
8061 | func_append dlpreconveniencelibs " $dir/$old_library" | |
8062 | fi | |
8063 | ;; | |
8064 | * ) | |
8065 | # Prefer using a static library (so that no silly _DYNAMIC symbols | |
8066 | # are required to link). | |
8067 | if test -n "$old_library"; then | |
8068 | func_append newdlprefiles " $dir/$old_library" | |
8069 | # Keep a list of preopened convenience libraries to check | |
8070 | # that they are being used correctly in the link pass. | |
8071 | test -z "$libdir" && \ | |
8072 | func_append dlpreconveniencelibs " $dir/$old_library" | |
8073 | # Otherwise, use the dlname, so that lt_dlopen finds it. | |
8074 | elif test -n "$dlname"; then | |
8075 | func_append newdlprefiles " $dir/$dlname" | |
8076 | else | |
8077 | func_append newdlprefiles " $dir/$linklib" | |
8078 | fi | |
8079 | ;; | |
8080 | esac | |
7083c021 AC |
8081 | fi # $pass = dlpreopen |
8082 | ||
8083 | if test -z "$libdir"; then | |
8084 | # Link the convenience library | |
6f57a957 | 8085 | if test lib = "$linkmode"; then |
7083c021 | 8086 | deplibs="$dir/$old_library $deplibs" |
6f57a957 | 8087 | elif test prog,link = "$linkmode,$pass"; then |
7083c021 AC |
8088 | compile_deplibs="$dir/$old_library $compile_deplibs" |
8089 | finalize_deplibs="$dir/$old_library $finalize_deplibs" | |
8090 | else | |
8091 | deplibs="$lib $deplibs" # used for prog,scan pass | |
8092 | fi | |
8093 | continue | |
8094 | fi | |
8095 | ||
8096 | ||
6f57a957 | 8097 | if test prog = "$linkmode" && test link != "$pass"; then |
08d019eb | 8098 | func_append newlib_search_path " $ladir" |
7083c021 AC |
8099 | deplibs="$lib $deplibs" |
8100 | ||
6f57a957 AC |
8101 | linkalldeplibs=false |
8102 | if test no != "$link_all_deplibs" || test -z "$library_names" || | |
8103 | test no = "$build_libtool_libs"; then | |
8104 | linkalldeplibs=: | |
7083c021 AC |
8105 | fi |
8106 | ||
8107 | tmp_libs= | |
8108 | for deplib in $dependency_libs; do | |
8109 | case $deplib in | |
8110 | -L*) func_stripname '-L' '' "$deplib" | |
08d019eb AC |
8111 | func_resolve_sysroot "$func_stripname_result" |
8112 | func_append newlib_search_path " $func_resolve_sysroot_result" | |
7083c021 AC |
8113 | ;; |
8114 | esac | |
8115 | # Need to link against all dependency_libs? | |
6f57a957 | 8116 | if $linkalldeplibs; then |
7083c021 AC |
8117 | deplibs="$deplib $deplibs" |
8118 | else | |
8119 | # Need to hardcode shared library paths | |
8120 | # or/and link against static libraries | |
8121 | newdependency_libs="$deplib $newdependency_libs" | |
8122 | fi | |
6f57a957 | 8123 | if $opt_preserve_dup_deps; then |
7083c021 | 8124 | case "$tmp_libs " in |
08d019eb | 8125 | *" $deplib "*) func_append specialdeplibs " $deplib" ;; |
7083c021 AC |
8126 | esac |
8127 | fi | |
08d019eb | 8128 | func_append tmp_libs " $deplib" |
7083c021 AC |
8129 | done # for deplib |
8130 | continue | |
8131 | fi # $linkmode = prog... | |
8132 | ||
6f57a957 | 8133 | if test prog,link = "$linkmode,$pass"; then |
7083c021 | 8134 | if test -n "$library_names" && |
6f57a957 AC |
8135 | { { test no = "$prefer_static_libs" || |
8136 | test built,yes = "$prefer_static_libs,$installed"; } || | |
7083c021 AC |
8137 | test -z "$old_library"; }; then |
8138 | # We need to hardcode the library path | |
6f57a957 | 8139 | if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then |
7083c021 | 8140 | # Make sure the rpath contains only unique directories. |
6f57a957 | 8141 | case $temp_rpath: in |
7083c021 | 8142 | *"$absdir:"*) ;; |
08d019eb | 8143 | *) func_append temp_rpath "$absdir:" ;; |
7083c021 AC |
8144 | esac |
8145 | fi | |
8146 | ||
8147 | # Hardcode the library path. | |
8148 | # Skip directories that are in the system default run-time | |
8149 | # search path. | |
8150 | case " $sys_lib_dlsearch_path " in | |
8151 | *" $absdir "*) ;; | |
8152 | *) | |
8153 | case "$compile_rpath " in | |
8154 | *" $absdir "*) ;; | |
08d019eb | 8155 | *) func_append compile_rpath " $absdir" ;; |
7083c021 AC |
8156 | esac |
8157 | ;; | |
8158 | esac | |
8159 | case " $sys_lib_dlsearch_path " in | |
8160 | *" $libdir "*) ;; | |
8161 | *) | |
8162 | case "$finalize_rpath " in | |
8163 | *" $libdir "*) ;; | |
08d019eb | 8164 | *) func_append finalize_rpath " $libdir" ;; |
7083c021 AC |
8165 | esac |
8166 | ;; | |
8167 | esac | |
8168 | fi # $linkmode,$pass = prog,link... | |
8169 | ||
6f57a957 AC |
8170 | if $alldeplibs && |
8171 | { test pass_all = "$deplibs_check_method" || | |
8172 | { test yes = "$build_libtool_libs" && | |
7083c021 AC |
8173 | test -n "$library_names"; }; }; then |
8174 | # We only need to search for static libraries | |
8175 | continue | |
8176 | fi | |
8177 | fi | |
8178 | ||
8179 | link_static=no # Whether the deplib will be linked statically | |
8180 | use_static_libs=$prefer_static_libs | |
6f57a957 | 8181 | if test built = "$use_static_libs" && test yes = "$installed"; then |
7083c021 AC |
8182 | use_static_libs=no |
8183 | fi | |
8184 | if test -n "$library_names" && | |
6f57a957 | 8185 | { test no = "$use_static_libs" || test -z "$old_library"; }; then |
7083c021 | 8186 | case $host in |
6f57a957 | 8187 | *cygwin* | *mingw* | *cegcc* | *os2*) |
7083c021 | 8188 | # No point in relinking DLLs because paths are not encoded |
08d019eb | 8189 | func_append notinst_deplibs " $lib" |
7083c021 AC |
8190 | need_relink=no |
8191 | ;; | |
8192 | *) | |
6f57a957 | 8193 | if test no = "$installed"; then |
08d019eb | 8194 | func_append notinst_deplibs " $lib" |
7083c021 AC |
8195 | need_relink=yes |
8196 | fi | |
8197 | ;; | |
8198 | esac | |
8199 | # This is a shared library | |
8200 | ||
8201 | # Warn about portability, can't link against -module's on some | |
8202 | # systems (darwin). Don't bleat about dlopened modules though! | |
6f57a957 | 8203 | dlopenmodule= |
7083c021 AC |
8204 | for dlpremoduletest in $dlprefiles; do |
8205 | if test "X$dlpremoduletest" = "X$lib"; then | |
6f57a957 | 8206 | dlopenmodule=$dlpremoduletest |
7083c021 AC |
8207 | break |
8208 | fi | |
8209 | done | |
6f57a957 | 8210 | if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then |
08d019eb | 8211 | echo |
6f57a957 | 8212 | if test prog = "$linkmode"; then |
7083c021 AC |
8213 | $ECHO "*** Warning: Linking the executable $output against the loadable module" |
8214 | else | |
8215 | $ECHO "*** Warning: Linking the shared library $output against the loadable module" | |
8216 | fi | |
8217 | $ECHO "*** $linklib is not portable!" | |
8218 | fi | |
6f57a957 AC |
8219 | if test lib = "$linkmode" && |
8220 | test yes = "$hardcode_into_libs"; then | |
7083c021 AC |
8221 | # Hardcode the library path. |
8222 | # Skip directories that are in the system default run-time | |
8223 | # search path. | |
8224 | case " $sys_lib_dlsearch_path " in | |
8225 | *" $absdir "*) ;; | |
8226 | *) | |
8227 | case "$compile_rpath " in | |
8228 | *" $absdir "*) ;; | |
08d019eb | 8229 | *) func_append compile_rpath " $absdir" ;; |
7083c021 AC |
8230 | esac |
8231 | ;; | |
8232 | esac | |
8233 | case " $sys_lib_dlsearch_path " in | |
8234 | *" $libdir "*) ;; | |
8235 | *) | |
8236 | case "$finalize_rpath " in | |
8237 | *" $libdir "*) ;; | |
08d019eb | 8238 | *) func_append finalize_rpath " $libdir" ;; |
7083c021 AC |
8239 | esac |
8240 | ;; | |
8241 | esac | |
8242 | fi | |
8243 | ||
8244 | if test -n "$old_archive_from_expsyms_cmds"; then | |
8245 | # figure out the soname | |
8246 | set dummy $library_names | |
8247 | shift | |
6f57a957 | 8248 | realname=$1 |
7083c021 AC |
8249 | shift |
8250 | libname=`eval "\\$ECHO \"$libname_spec\""` | |
8251 | # use dlname if we got it. it's perfectly good, no? | |
8252 | if test -n "$dlname"; then | |
6f57a957 | 8253 | soname=$dlname |
7083c021 AC |
8254 | elif test -n "$soname_spec"; then |
8255 | # bleh windows | |
8256 | case $host in | |
6f57a957 | 8257 | *cygwin* | mingw* | *cegcc* | *os2*) |
7083c021 AC |
8258 | func_arith $current - $age |
8259 | major=$func_arith_result | |
6f57a957 | 8260 | versuffix=-$major |
7083c021 AC |
8261 | ;; |
8262 | esac | |
8263 | eval soname=\"$soname_spec\" | |
8264 | else | |
6f57a957 | 8265 | soname=$realname |
7083c021 AC |
8266 | fi |
8267 | ||
8268 | # Make a new name for the extract_expsyms_cmds to use | |
6f57a957 | 8269 | soroot=$soname |
7083c021 | 8270 | func_basename "$soroot" |
6f57a957 | 8271 | soname=$func_basename_result |
7083c021 AC |
8272 | func_stripname 'lib' '.dll' "$soname" |
8273 | newlib=libimp-$func_stripname_result.a | |
8274 | ||
8275 | # If the library has no export list, then create one now | |
8276 | if test -f "$output_objdir/$soname-def"; then : | |
8277 | else | |
6f57a957 | 8278 | func_verbose "extracting exported symbol list from '$soname'" |
7083c021 AC |
8279 | func_execute_cmds "$extract_expsyms_cmds" 'exit $?' |
8280 | fi | |
8281 | ||
8282 | # Create $newlib | |
8283 | if test -f "$output_objdir/$newlib"; then :; else | |
6f57a957 | 8284 | func_verbose "generating import library for '$soname'" |
7083c021 AC |
8285 | func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' |
8286 | fi | |
8287 | # make sure the library variables are pointing to the new library | |
8288 | dir=$output_objdir | |
8289 | linklib=$newlib | |
8290 | fi # test -n "$old_archive_from_expsyms_cmds" | |
8291 | ||
6f57a957 | 8292 | if test prog = "$linkmode" || test relink != "$opt_mode"; then |
7083c021 AC |
8293 | add_shlibpath= |
8294 | add_dir= | |
8295 | add= | |
8296 | lib_linked=yes | |
8297 | case $hardcode_action in | |
8298 | immediate | unsupported) | |
6f57a957 AC |
8299 | if test no = "$hardcode_direct"; then |
8300 | add=$dir/$linklib | |
7083c021 | 8301 | case $host in |
6f57a957 AC |
8302 | *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; |
8303 | *-*-sysv4*uw2*) add_dir=-L$dir ;; | |
7083c021 | 8304 | *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ |
6f57a957 | 8305 | *-*-unixware7*) add_dir=-L$dir ;; |
7083c021 | 8306 | *-*-darwin* ) |
6f57a957 | 8307 | # if the lib is a (non-dlopened) module then we cannot |
7083c021 AC |
8308 | # link against it, someone is ignoring the earlier warnings |
8309 | if /usr/bin/file -L $add 2> /dev/null | | |
6f57a957 | 8310 | $GREP ": [^:]* bundle" >/dev/null; then |
7083c021 AC |
8311 | if test "X$dlopenmodule" != "X$lib"; then |
8312 | $ECHO "*** Warning: lib $linklib is a module, not a shared library" | |
6f57a957 | 8313 | if test -z "$old_library"; then |
08d019eb AC |
8314 | echo |
8315 | echo "*** And there doesn't seem to be a static archive available" | |
8316 | echo "*** The link will probably fail, sorry" | |
7083c021 | 8317 | else |
6f57a957 | 8318 | add=$dir/$old_library |
7083c021 AC |
8319 | fi |
8320 | elif test -n "$old_library"; then | |
6f57a957 | 8321 | add=$dir/$old_library |
7083c021 AC |
8322 | fi |
8323 | fi | |
8324 | esac | |
6f57a957 | 8325 | elif test no = "$hardcode_minus_L"; then |
7083c021 | 8326 | case $host in |
6f57a957 | 8327 | *-*-sunos*) add_shlibpath=$dir ;; |
7083c021 | 8328 | esac |
6f57a957 AC |
8329 | add_dir=-L$dir |
8330 | add=-l$name | |
8331 | elif test no = "$hardcode_shlibpath_var"; then | |
8332 | add_shlibpath=$dir | |
8333 | add=-l$name | |
7083c021 AC |
8334 | else |
8335 | lib_linked=no | |
8336 | fi | |
8337 | ;; | |
8338 | relink) | |
6f57a957 AC |
8339 | if test yes = "$hardcode_direct" && |
8340 | test no = "$hardcode_direct_absolute"; then | |
8341 | add=$dir/$linklib | |
8342 | elif test yes = "$hardcode_minus_L"; then | |
8343 | add_dir=-L$absdir | |
7083c021 AC |
8344 | # Try looking first in the location we're being installed to. |
8345 | if test -n "$inst_prefix_dir"; then | |
8346 | case $libdir in | |
8347 | [\\/]*) | |
08d019eb | 8348 | func_append add_dir " -L$inst_prefix_dir$libdir" |
7083c021 AC |
8349 | ;; |
8350 | esac | |
8351 | fi | |
6f57a957 AC |
8352 | add=-l$name |
8353 | elif test yes = "$hardcode_shlibpath_var"; then | |
8354 | add_shlibpath=$dir | |
8355 | add=-l$name | |
7083c021 AC |
8356 | else |
8357 | lib_linked=no | |
8358 | fi | |
8359 | ;; | |
8360 | *) lib_linked=no ;; | |
8361 | esac | |
8362 | ||
6f57a957 | 8363 | if test yes != "$lib_linked"; then |
7083c021 AC |
8364 | func_fatal_configuration "unsupported hardcode properties" |
8365 | fi | |
8366 | ||
8367 | if test -n "$add_shlibpath"; then | |
8368 | case :$compile_shlibpath: in | |
8369 | *":$add_shlibpath:"*) ;; | |
08d019eb | 8370 | *) func_append compile_shlibpath "$add_shlibpath:" ;; |
7083c021 AC |
8371 | esac |
8372 | fi | |
6f57a957 | 8373 | if test prog = "$linkmode"; then |
7083c021 AC |
8374 | test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" |
8375 | test -n "$add" && compile_deplibs="$add $compile_deplibs" | |
8376 | else | |
8377 | test -n "$add_dir" && deplibs="$add_dir $deplibs" | |
8378 | test -n "$add" && deplibs="$add $deplibs" | |
6f57a957 AC |
8379 | if test yes != "$hardcode_direct" && |
8380 | test yes != "$hardcode_minus_L" && | |
8381 | test yes = "$hardcode_shlibpath_var"; then | |
7083c021 AC |
8382 | case :$finalize_shlibpath: in |
8383 | *":$libdir:"*) ;; | |
08d019eb | 8384 | *) func_append finalize_shlibpath "$libdir:" ;; |
7083c021 AC |
8385 | esac |
8386 | fi | |
8387 | fi | |
8388 | fi | |
8389 | ||
6f57a957 | 8390 | if test prog = "$linkmode" || test relink = "$opt_mode"; then |
7083c021 AC |
8391 | add_shlibpath= |
8392 | add_dir= | |
8393 | add= | |
8394 | # Finalize command for both is simple: just hardcode it. | |
6f57a957 AC |
8395 | if test yes = "$hardcode_direct" && |
8396 | test no = "$hardcode_direct_absolute"; then | |
8397 | add=$libdir/$linklib | |
8398 | elif test yes = "$hardcode_minus_L"; then | |
8399 | add_dir=-L$libdir | |
8400 | add=-l$name | |
8401 | elif test yes = "$hardcode_shlibpath_var"; then | |
7083c021 AC |
8402 | case :$finalize_shlibpath: in |
8403 | *":$libdir:"*) ;; | |
08d019eb | 8404 | *) func_append finalize_shlibpath "$libdir:" ;; |
7083c021 | 8405 | esac |
6f57a957 AC |
8406 | add=-l$name |
8407 | elif test yes = "$hardcode_automatic"; then | |
7083c021 | 8408 | if test -n "$inst_prefix_dir" && |
6f57a957 AC |
8409 | test -f "$inst_prefix_dir$libdir/$linklib"; then |
8410 | add=$inst_prefix_dir$libdir/$linklib | |
7083c021 | 8411 | else |
6f57a957 | 8412 | add=$libdir/$linklib |
7083c021 AC |
8413 | fi |
8414 | else | |
8415 | # We cannot seem to hardcode it, guess we'll fake it. | |
6f57a957 | 8416 | add_dir=-L$libdir |
7083c021 AC |
8417 | # Try looking first in the location we're being installed to. |
8418 | if test -n "$inst_prefix_dir"; then | |
8419 | case $libdir in | |
8420 | [\\/]*) | |
08d019eb | 8421 | func_append add_dir " -L$inst_prefix_dir$libdir" |
7083c021 AC |
8422 | ;; |
8423 | esac | |
8424 | fi | |
6f57a957 | 8425 | add=-l$name |
7083c021 AC |
8426 | fi |
8427 | ||
6f57a957 | 8428 | if test prog = "$linkmode"; then |
7083c021 AC |
8429 | test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" |
8430 | test -n "$add" && finalize_deplibs="$add $finalize_deplibs" | |
8431 | else | |
8432 | test -n "$add_dir" && deplibs="$add_dir $deplibs" | |
8433 | test -n "$add" && deplibs="$add $deplibs" | |
8434 | fi | |
8435 | fi | |
6f57a957 | 8436 | elif test prog = "$linkmode"; then |
7083c021 AC |
8437 | # Here we assume that one of hardcode_direct or hardcode_minus_L |
8438 | # is not unsupported. This is valid on all known static and | |
8439 | # shared platforms. | |
6f57a957 AC |
8440 | if test unsupported != "$hardcode_direct"; then |
8441 | test -n "$old_library" && linklib=$old_library | |
7083c021 AC |
8442 | compile_deplibs="$dir/$linklib $compile_deplibs" |
8443 | finalize_deplibs="$dir/$linklib $finalize_deplibs" | |
8444 | else | |
8445 | compile_deplibs="-l$name -L$dir $compile_deplibs" | |
8446 | finalize_deplibs="-l$name -L$dir $finalize_deplibs" | |
8447 | fi | |
6f57a957 | 8448 | elif test yes = "$build_libtool_libs"; then |
7083c021 | 8449 | # Not a shared library |
6f57a957 | 8450 | if test pass_all != "$deplibs_check_method"; then |
7083c021 AC |
8451 | # We're trying link a shared library against a static one |
8452 | # but the system doesn't support it. | |
8453 | ||
8454 | # Just print a warning and add the library to dependency_libs so | |
8455 | # that the program can be linked against the static library. | |
08d019eb | 8456 | echo |
6f57a957 | 8457 | $ECHO "*** Warning: This system cannot link to static lib archive $lib." |
08d019eb AC |
8458 | echo "*** I have the capability to make that library automatically link in when" |
8459 | echo "*** you link to this library. But I can only do this if you have a" | |
8460 | echo "*** shared version of the library, which you do not appear to have." | |
6f57a957 | 8461 | if test yes = "$module"; then |
08d019eb AC |
8462 | echo "*** But as you try to build a module library, libtool will still create " |
8463 | echo "*** a static module, that should work as long as the dlopening application" | |
8464 | echo "*** is linked with the -dlopen flag to resolve symbols at runtime." | |
7083c021 | 8465 | if test -z "$global_symbol_pipe"; then |
08d019eb AC |
8466 | echo |
8467 | echo "*** However, this would only work if libtool was able to extract symbol" | |
6f57a957 | 8468 | echo "*** lists from a program, using 'nm' or equivalent, but libtool could" |
08d019eb | 8469 | echo "*** not find such a program. So, this module is probably useless." |
6f57a957 | 8470 | echo "*** 'nm' from GNU binutils and a full rebuild may help." |
7083c021 | 8471 | fi |
6f57a957 | 8472 | if test no = "$build_old_libs"; then |
7083c021 AC |
8473 | build_libtool_libs=module |
8474 | build_old_libs=yes | |
8475 | else | |
8476 | build_libtool_libs=no | |
8477 | fi | |
8478 | fi | |
8479 | else | |
8480 | deplibs="$dir/$old_library $deplibs" | |
8481 | link_static=yes | |
8482 | fi | |
8483 | fi # link shared/static library? | |
8484 | ||
6f57a957 | 8485 | if test lib = "$linkmode"; then |
7083c021 | 8486 | if test -n "$dependency_libs" && |
6f57a957 AC |
8487 | { test yes != "$hardcode_into_libs" || |
8488 | test yes = "$build_old_libs" || | |
8489 | test yes = "$link_static"; }; then | |
7083c021 AC |
8490 | # Extract -R from dependency_libs |
8491 | temp_deplibs= | |
8492 | for libdir in $dependency_libs; do | |
8493 | case $libdir in | |
8494 | -R*) func_stripname '-R' '' "$libdir" | |
8495 | temp_xrpath=$func_stripname_result | |
8496 | case " $xrpath " in | |
8497 | *" $temp_xrpath "*) ;; | |
08d019eb | 8498 | *) func_append xrpath " $temp_xrpath";; |
7083c021 | 8499 | esac;; |
08d019eb | 8500 | *) func_append temp_deplibs " $libdir";; |
7083c021 AC |
8501 | esac |
8502 | done | |
6f57a957 | 8503 | dependency_libs=$temp_deplibs |
7083c021 AC |
8504 | fi |
8505 | ||
08d019eb | 8506 | func_append newlib_search_path " $absdir" |
7083c021 | 8507 | # Link against this library |
6f57a957 | 8508 | test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" |
7083c021 AC |
8509 | # ... and its dependency_libs |
8510 | tmp_libs= | |
8511 | for deplib in $dependency_libs; do | |
8512 | newdependency_libs="$deplib $newdependency_libs" | |
08d019eb AC |
8513 | case $deplib in |
8514 | -L*) func_stripname '-L' '' "$deplib" | |
8515 | func_resolve_sysroot "$func_stripname_result";; | |
8516 | *) func_resolve_sysroot "$deplib" ;; | |
8517 | esac | |
6f57a957 | 8518 | if $opt_preserve_dup_deps; then |
7083c021 | 8519 | case "$tmp_libs " in |
08d019eb AC |
8520 | *" $func_resolve_sysroot_result "*) |
8521 | func_append specialdeplibs " $func_resolve_sysroot_result" ;; | |
7083c021 AC |
8522 | esac |
8523 | fi | |
08d019eb | 8524 | func_append tmp_libs " $func_resolve_sysroot_result" |
7083c021 AC |
8525 | done |
8526 | ||
6f57a957 | 8527 | if test no != "$link_all_deplibs"; then |
7083c021 AC |
8528 | # Add the search paths of all dependency libraries |
8529 | for deplib in $dependency_libs; do | |
08d019eb | 8530 | path= |
7083c021 | 8531 | case $deplib in |
6f57a957 | 8532 | -L*) path=$deplib ;; |
7083c021 | 8533 | *.la) |
08d019eb AC |
8534 | func_resolve_sysroot "$deplib" |
8535 | deplib=$func_resolve_sysroot_result | |
7083c021 | 8536 | func_dirname "$deplib" "" "." |
08d019eb | 8537 | dir=$func_dirname_result |
7083c021 AC |
8538 | # We need an absolute path. |
8539 | case $dir in | |
6f57a957 | 8540 | [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; |
7083c021 AC |
8541 | *) |
8542 | absdir=`cd "$dir" && pwd` | |
8543 | if test -z "$absdir"; then | |
6f57a957 AC |
8544 | func_warning "cannot determine absolute directory name of '$dir'" |
8545 | absdir=$dir | |
7083c021 AC |
8546 | fi |
8547 | ;; | |
8548 | esac | |
8549 | if $GREP "^installed=no" $deplib > /dev/null; then | |
8550 | case $host in | |
8551 | *-*-darwin*) | |
8552 | depdepl= | |
6f57a957 AC |
8553 | eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` |
8554 | if test -n "$deplibrary_names"; then | |
8555 | for tmp in $deplibrary_names; do | |
7083c021 AC |
8556 | depdepl=$tmp |
8557 | done | |
6f57a957 AC |
8558 | if test -f "$absdir/$objdir/$depdepl"; then |
8559 | depdepl=$absdir/$objdir/$depdepl | |
8560 | darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` | |
7083c021 | 8561 | if test -z "$darwin_install_name"; then |
6f57a957 | 8562 | darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` |
7083c021 | 8563 | fi |
6f57a957 AC |
8564 | func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" |
8565 | func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" | |
7083c021 AC |
8566 | path= |
8567 | fi | |
8568 | fi | |
8569 | ;; | |
8570 | *) | |
6f57a957 | 8571 | path=-L$absdir/$objdir |
7083c021 AC |
8572 | ;; |
8573 | esac | |
8574 | else | |
6f57a957 | 8575 | eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` |
7083c021 | 8576 | test -z "$libdir" && \ |
6f57a957 | 8577 | func_fatal_error "'$deplib' is not a valid libtool archive" |
7083c021 | 8578 | test "$absdir" != "$libdir" && \ |
6f57a957 | 8579 | func_warning "'$deplib' seems to be moved" |
7083c021 | 8580 | |
6f57a957 | 8581 | path=-L$absdir |
7083c021 AC |
8582 | fi |
8583 | ;; | |
8584 | esac | |
8585 | case " $deplibs " in | |
8586 | *" $path "*) ;; | |
8587 | *) deplibs="$path $deplibs" ;; | |
8588 | esac | |
8589 | done | |
8590 | fi # link_all_deplibs != no | |
8591 | fi # linkmode = lib | |
8592 | done # for deplib in $libs | |
6f57a957 AC |
8593 | if test link = "$pass"; then |
8594 | if test prog = "$linkmode"; then | |
7083c021 AC |
8595 | compile_deplibs="$new_inherited_linker_flags $compile_deplibs" |
8596 | finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" | |
8597 | else | |
08d019eb | 8598 | compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` |
7083c021 AC |
8599 | fi |
8600 | fi | |
6f57a957 AC |
8601 | dependency_libs=$newdependency_libs |
8602 | if test dlpreopen = "$pass"; then | |
7083c021 AC |
8603 | # Link the dlpreopened libraries before other libraries |
8604 | for deplib in $save_deplibs; do | |
8605 | deplibs="$deplib $deplibs" | |
8606 | done | |
8607 | fi | |
6f57a957 AC |
8608 | if test dlopen != "$pass"; then |
8609 | test conv = "$pass" || { | |
7083c021 AC |
8610 | # Make sure lib_search_path contains only unique directories. |
8611 | lib_search_path= | |
8612 | for dir in $newlib_search_path; do | |
8613 | case "$lib_search_path " in | |
8614 | *" $dir "*) ;; | |
08d019eb | 8615 | *) func_append lib_search_path " $dir" ;; |
7083c021 AC |
8616 | esac |
8617 | done | |
8618 | newlib_search_path= | |
6f57a957 | 8619 | } |
7083c021 | 8620 | |
6f57a957 | 8621 | if test prog,link = "$linkmode,$pass"; then |
7083c021 | 8622 | vars="compile_deplibs finalize_deplibs" |
6f57a957 AC |
8623 | else |
8624 | vars=deplibs | |
7083c021 AC |
8625 | fi |
8626 | for var in $vars dependency_libs; do | |
8627 | # Add libraries to $var in reverse order | |
8628 | eval tmp_libs=\"\$$var\" | |
8629 | new_libs= | |
8630 | for deplib in $tmp_libs; do | |
8631 | # FIXME: Pedantically, this is the right thing to do, so | |
8632 | # that some nasty dependency loop isn't accidentally | |
8633 | # broken: | |
8634 | #new_libs="$deplib $new_libs" | |
8635 | # Pragmatically, this seems to cause very few problems in | |
8636 | # practice: | |
8637 | case $deplib in | |
8638 | -L*) new_libs="$deplib $new_libs" ;; | |
8639 | -R*) ;; | |
8640 | *) | |
8641 | # And here is the reason: when a library appears more | |
8642 | # than once as an explicit dependence of a library, or | |
8643 | # is implicitly linked in more than once by the | |
8644 | # compiler, it is considered special, and multiple | |
8645 | # occurrences thereof are not removed. Compare this | |
8646 | # with having the same library being listed as a | |
8647 | # dependency of multiple other libraries: in this case, | |
8648 | # we know (pedantically, we assume) the library does not | |
8649 | # need to be listed more than once, so we keep only the | |
8650 | # last copy. This is not always right, but it is rare | |
8651 | # enough that we require users that really mean to play | |
8652 | # such unportable linking tricks to link the library | |
8653 | # using -Wl,-lname, so that libtool does not consider it | |
8654 | # for duplicate removal. | |
8655 | case " $specialdeplibs " in | |
8656 | *" $deplib "*) new_libs="$deplib $new_libs" ;; | |
8657 | *) | |
8658 | case " $new_libs " in | |
8659 | *" $deplib "*) ;; | |
8660 | *) new_libs="$deplib $new_libs" ;; | |
8661 | esac | |
8662 | ;; | |
8663 | esac | |
8664 | ;; | |
8665 | esac | |
8666 | done | |
8667 | tmp_libs= | |
8668 | for deplib in $new_libs; do | |
8669 | case $deplib in | |
8670 | -L*) | |
8671 | case " $tmp_libs " in | |
8672 | *" $deplib "*) ;; | |
08d019eb | 8673 | *) func_append tmp_libs " $deplib" ;; |
7083c021 AC |
8674 | esac |
8675 | ;; | |
08d019eb | 8676 | *) func_append tmp_libs " $deplib" ;; |
7083c021 AC |
8677 | esac |
8678 | done | |
8679 | eval $var=\"$tmp_libs\" | |
8680 | done # for var | |
8681 | fi | |
6f57a957 AC |
8682 | |
8683 | # Add Sun CC postdeps if required: | |
8684 | test CXX = "$tagname" && { | |
8685 | case $host_os in | |
8686 | linux*) | |
8687 | case `$CC -V 2>&1 | sed 5q` in | |
8688 | *Sun\ C*) # Sun C++ 5.9 | |
8689 | func_suncc_cstd_abi | |
8690 | ||
8691 | if test no != "$suncc_use_cstd_abi"; then | |
8692 | func_append postdeps ' -library=Cstd -library=Crun' | |
8693 | fi | |
8694 | ;; | |
8695 | esac | |
8696 | ;; | |
8697 | ||
8698 | solaris*) | |
8699 | func_cc_basename "$CC" | |
8700 | case $func_cc_basename_result in | |
8701 | CC* | sunCC*) | |
8702 | func_suncc_cstd_abi | |
8703 | ||
8704 | if test no != "$suncc_use_cstd_abi"; then | |
8705 | func_append postdeps ' -library=Cstd -library=Crun' | |
8706 | fi | |
8707 | ;; | |
8708 | esac | |
8709 | ;; | |
8710 | esac | |
8711 | } | |
8712 | ||
7083c021 AC |
8713 | # Last step: remove runtime libs from dependency_libs |
8714 | # (they stay in deplibs) | |
8715 | tmp_libs= | |
6f57a957 | 8716 | for i in $dependency_libs; do |
7083c021 AC |
8717 | case " $predeps $postdeps $compiler_lib_search_path " in |
8718 | *" $i "*) | |
6f57a957 | 8719 | i= |
7083c021 AC |
8720 | ;; |
8721 | esac | |
6f57a957 | 8722 | if test -n "$i"; then |
08d019eb | 8723 | func_append tmp_libs " $i" |
7083c021 AC |
8724 | fi |
8725 | done | |
8726 | dependency_libs=$tmp_libs | |
8727 | done # for pass | |
6f57a957 AC |
8728 | if test prog = "$linkmode"; then |
8729 | dlfiles=$newdlfiles | |
7083c021 | 8730 | fi |
6f57a957 AC |
8731 | if test prog = "$linkmode" || test lib = "$linkmode"; then |
8732 | dlprefiles=$newdlprefiles | |
7083c021 AC |
8733 | fi |
8734 | ||
8735 | case $linkmode in | |
8736 | oldlib) | |
6f57a957 AC |
8737 | if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then |
8738 | func_warning "'-dlopen' is ignored for archives" | |
7083c021 AC |
8739 | fi |
8740 | ||
8741 | case " $deplibs" in | |
8742 | *\ -l* | *\ -L*) | |
6f57a957 | 8743 | func_warning "'-l' and '-L' are ignored for archives" ;; |
7083c021 AC |
8744 | esac |
8745 | ||
8746 | test -n "$rpath" && \ | |
6f57a957 | 8747 | func_warning "'-rpath' is ignored for archives" |
7083c021 AC |
8748 | |
8749 | test -n "$xrpath" && \ | |
6f57a957 | 8750 | func_warning "'-R' is ignored for archives" |
7083c021 AC |
8751 | |
8752 | test -n "$vinfo" && \ | |
6f57a957 | 8753 | func_warning "'-version-info/-version-number' is ignored for archives" |
7083c021 AC |
8754 | |
8755 | test -n "$release" && \ | |
6f57a957 | 8756 | func_warning "'-release' is ignored for archives" |
7083c021 AC |
8757 | |
8758 | test -n "$export_symbols$export_symbols_regex" && \ | |
6f57a957 | 8759 | func_warning "'-export-symbols' is ignored for archives" |
7083c021 AC |
8760 | |
8761 | # Now set the variables for building old libraries. | |
8762 | build_libtool_libs=no | |
6f57a957 | 8763 | oldlibs=$output |
08d019eb | 8764 | func_append objs "$old_deplibs" |
7083c021 AC |
8765 | ;; |
8766 | ||
8767 | lib) | |
6f57a957 | 8768 | # Make sure we only generate libraries of the form 'libNAME.la'. |
7083c021 AC |
8769 | case $outputname in |
8770 | lib*) | |
8771 | func_stripname 'lib' '.la' "$outputname" | |
8772 | name=$func_stripname_result | |
8773 | eval shared_ext=\"$shrext_cmds\" | |
8774 | eval libname=\"$libname_spec\" | |
8775 | ;; | |
8776 | *) | |
6f57a957 AC |
8777 | test no = "$module" \ |
8778 | && func_fatal_help "libtool library '$output' must begin with 'lib'" | |
7083c021 | 8779 | |
6f57a957 | 8780 | if test no != "$need_lib_prefix"; then |
7083c021 AC |
8781 | # Add the "lib" prefix for modules if required |
8782 | func_stripname '' '.la' "$outputname" | |
8783 | name=$func_stripname_result | |
8784 | eval shared_ext=\"$shrext_cmds\" | |
8785 | eval libname=\"$libname_spec\" | |
8786 | else | |
8787 | func_stripname '' '.la' "$outputname" | |
8788 | libname=$func_stripname_result | |
8789 | fi | |
8790 | ;; | |
8791 | esac | |
8792 | ||
8793 | if test -n "$objs"; then | |
6f57a957 AC |
8794 | if test pass_all != "$deplibs_check_method"; then |
8795 | func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" | |
7083c021 | 8796 | else |
08d019eb | 8797 | echo |
7083c021 AC |
8798 | $ECHO "*** Warning: Linking the shared library $output against the non-libtool" |
8799 | $ECHO "*** objects $objs is not portable!" | |
08d019eb | 8800 | func_append libobjs " $objs" |
7083c021 AC |
8801 | fi |
8802 | fi | |
8803 | ||
6f57a957 AC |
8804 | test no = "$dlself" \ |
8805 | || func_warning "'-dlopen self' is ignored for libtool libraries" | |
7083c021 AC |
8806 | |
8807 | set dummy $rpath | |
8808 | shift | |
6f57a957 AC |
8809 | test 1 -lt "$#" \ |
8810 | && func_warning "ignoring multiple '-rpath's for a libtool library" | |
7083c021 | 8811 | |
6f57a957 | 8812 | install_libdir=$1 |
7083c021 AC |
8813 | |
8814 | oldlibs= | |
8815 | if test -z "$rpath"; then | |
6f57a957 | 8816 | if test yes = "$build_libtool_libs"; then |
7083c021 | 8817 | # Building a libtool convenience library. |
6f57a957 | 8818 | # Some compilers have problems with a '.al' extension so |
7083c021 AC |
8819 | # convenience libraries should have the same extension an |
8820 | # archive normally would. | |
8821 | oldlibs="$output_objdir/$libname.$libext $oldlibs" | |
8822 | build_libtool_libs=convenience | |
8823 | build_old_libs=yes | |
8824 | fi | |
8825 | ||
8826 | test -n "$vinfo" && \ | |
6f57a957 | 8827 | func_warning "'-version-info/-version-number' is ignored for convenience libraries" |
7083c021 AC |
8828 | |
8829 | test -n "$release" && \ | |
6f57a957 | 8830 | func_warning "'-release' is ignored for convenience libraries" |
7083c021 AC |
8831 | else |
8832 | ||
8833 | # Parse the version information argument. | |
6f57a957 | 8834 | save_ifs=$IFS; IFS=: |
7083c021 AC |
8835 | set dummy $vinfo 0 0 0 |
8836 | shift | |
6f57a957 | 8837 | IFS=$save_ifs |
7083c021 AC |
8838 | |
8839 | test -n "$7" && \ | |
6f57a957 | 8840 | func_fatal_help "too many parameters to '-version-info'" |
7083c021 AC |
8841 | |
8842 | # convert absolute version numbers to libtool ages | |
8843 | # this retains compatibility with .la files and attempts | |
8844 | # to make the code below a bit more comprehensible | |
8845 | ||
8846 | case $vinfo_number in | |
8847 | yes) | |
6f57a957 AC |
8848 | number_major=$1 |
8849 | number_minor=$2 | |
8850 | number_revision=$3 | |
7083c021 AC |
8851 | # |
8852 | # There are really only two kinds -- those that | |
8853 | # use the current revision as the major version | |
8854 | # and those that subtract age and use age as | |
8855 | # a minor version. But, then there is irix | |
6f57a957 | 8856 | # that has an extra 1 added just for fun |
7083c021 AC |
8857 | # |
8858 | case $version_type in | |
54bec06e | 8859 | # correct linux to gnu/linux during the next big refactor |
6f57a957 | 8860 | darwin|freebsd-elf|linux|osf|windows|none) |
7083c021 AC |
8861 | func_arith $number_major + $number_minor |
8862 | current=$func_arith_result | |
6f57a957 AC |
8863 | age=$number_minor |
8864 | revision=$number_revision | |
7083c021 | 8865 | ;; |
6f57a957 AC |
8866 | freebsd-aout|qnx|sunos) |
8867 | current=$number_major | |
8868 | revision=$number_minor | |
8869 | age=0 | |
7083c021 AC |
8870 | ;; |
8871 | irix|nonstopux) | |
8872 | func_arith $number_major + $number_minor | |
8873 | current=$func_arith_result | |
6f57a957 AC |
8874 | age=$number_minor |
8875 | revision=$number_minor | |
7083c021 AC |
8876 | lt_irix_increment=no |
8877 | ;; | |
7083c021 AC |
8878 | esac |
8879 | ;; | |
8880 | no) | |
6f57a957 AC |
8881 | current=$1 |
8882 | revision=$2 | |
8883 | age=$3 | |
7083c021 AC |
8884 | ;; |
8885 | esac | |
8886 | ||
8887 | # Check that each of the things are valid numbers. | |
8888 | case $current in | |
8889 | 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; | |
8890 | *) | |
6f57a957 AC |
8891 | func_error "CURRENT '$current' must be a nonnegative integer" |
8892 | func_fatal_error "'$vinfo' is not valid version information" | |
7083c021 AC |
8893 | ;; |
8894 | esac | |
8895 | ||
8896 | case $revision in | |
8897 | 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; | |
8898 | *) | |
6f57a957 AC |
8899 | func_error "REVISION '$revision' must be a nonnegative integer" |
8900 | func_fatal_error "'$vinfo' is not valid version information" | |
7083c021 AC |
8901 | ;; |
8902 | esac | |
8903 | ||
8904 | case $age in | |
8905 | 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; | |
8906 | *) | |
6f57a957 AC |
8907 | func_error "AGE '$age' must be a nonnegative integer" |
8908 | func_fatal_error "'$vinfo' is not valid version information" | |
7083c021 AC |
8909 | ;; |
8910 | esac | |
8911 | ||
8912 | if test "$age" -gt "$current"; then | |
6f57a957 AC |
8913 | func_error "AGE '$age' is greater than the current interface number '$current'" |
8914 | func_fatal_error "'$vinfo' is not valid version information" | |
7083c021 AC |
8915 | fi |
8916 | ||
8917 | # Calculate the version variables. | |
8918 | major= | |
8919 | versuffix= | |
8920 | verstring= | |
8921 | case $version_type in | |
8922 | none) ;; | |
8923 | ||
8924 | darwin) | |
8925 | # Like Linux, but with the current version available in | |
8926 | # verstring for coding it into the library header | |
8927 | func_arith $current - $age | |
8928 | major=.$func_arith_result | |
6f57a957 | 8929 | versuffix=$major.$age.$revision |
7083c021 AC |
8930 | # Darwin ld doesn't like 0 for these options... |
8931 | func_arith $current + 1 | |
8932 | minor_current=$func_arith_result | |
6f57a957 | 8933 | xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" |
7083c021 | 8934 | verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" |
6f57a957 AC |
8935 | # On Darwin other compilers |
8936 | case $CC in | |
8937 | nagfor*) | |
8938 | verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" | |
8939 | ;; | |
8940 | *) | |
8941 | verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" | |
8942 | ;; | |
8943 | esac | |
7083c021 AC |
8944 | ;; |
8945 | ||
8946 | freebsd-aout) | |
6f57a957 AC |
8947 | major=.$current |
8948 | versuffix=.$current.$revision | |
7083c021 AC |
8949 | ;; |
8950 | ||
8951 | freebsd-elf) | |
6f57a957 AC |
8952 | func_arith $current - $age |
8953 | major=.$func_arith_result | |
8954 | versuffix=$major.$age.$revision | |
7083c021 AC |
8955 | ;; |
8956 | ||
8957 | irix | nonstopux) | |
6f57a957 | 8958 | if test no = "$lt_irix_increment"; then |
7083c021 AC |
8959 | func_arith $current - $age |
8960 | else | |
8961 | func_arith $current - $age + 1 | |
8962 | fi | |
8963 | major=$func_arith_result | |
8964 | ||
8965 | case $version_type in | |
8966 | nonstopux) verstring_prefix=nonstopux ;; | |
8967 | *) verstring_prefix=sgi ;; | |
8968 | esac | |
6f57a957 | 8969 | verstring=$verstring_prefix$major.$revision |
7083c021 AC |
8970 | |
8971 | # Add in all the interfaces that we are compatible with. | |
8972 | loop=$revision | |
6f57a957 | 8973 | while test 0 -ne "$loop"; do |
7083c021 AC |
8974 | func_arith $revision - $loop |
8975 | iface=$func_arith_result | |
8976 | func_arith $loop - 1 | |
8977 | loop=$func_arith_result | |
6f57a957 | 8978 | verstring=$verstring_prefix$major.$iface:$verstring |
7083c021 AC |
8979 | done |
8980 | ||
6f57a957 | 8981 | # Before this point, $major must not contain '.'. |
7083c021 | 8982 | major=.$major |
6f57a957 | 8983 | versuffix=$major.$revision |
7083c021 AC |
8984 | ;; |
8985 | ||
54bec06e | 8986 | linux) # correct to gnu/linux during the next big refactor |
7083c021 AC |
8987 | func_arith $current - $age |
8988 | major=.$func_arith_result | |
6f57a957 | 8989 | versuffix=$major.$age.$revision |
7083c021 AC |
8990 | ;; |
8991 | ||
8992 | osf) | |
8993 | func_arith $current - $age | |
8994 | major=.$func_arith_result | |
6f57a957 AC |
8995 | versuffix=.$current.$age.$revision |
8996 | verstring=$current.$age.$revision | |
7083c021 AC |
8997 | |
8998 | # Add in all the interfaces that we are compatible with. | |
8999 | loop=$age | |
6f57a957 | 9000 | while test 0 -ne "$loop"; do |
7083c021 AC |
9001 | func_arith $current - $loop |
9002 | iface=$func_arith_result | |
9003 | func_arith $loop - 1 | |
9004 | loop=$func_arith_result | |
6f57a957 | 9005 | verstring=$verstring:$iface.0 |
7083c021 AC |
9006 | done |
9007 | ||
9008 | # Make executables depend on our current version. | |
6f57a957 | 9009 | func_append verstring ":$current.0" |
7083c021 AC |
9010 | ;; |
9011 | ||
9012 | qnx) | |
6f57a957 AC |
9013 | major=.$current |
9014 | versuffix=.$current | |
9015 | ;; | |
9016 | ||
9017 | sco) | |
9018 | major=.$current | |
9019 | versuffix=.$current | |
7083c021 AC |
9020 | ;; |
9021 | ||
9022 | sunos) | |
6f57a957 AC |
9023 | major=.$current |
9024 | versuffix=.$current.$revision | |
7083c021 AC |
9025 | ;; |
9026 | ||
9027 | windows) | |
9028 | # Use '-' rather than '.', since we only want one | |
6f57a957 | 9029 | # extension on DOS 8.3 file systems. |
7083c021 AC |
9030 | func_arith $current - $age |
9031 | major=$func_arith_result | |
6f57a957 | 9032 | versuffix=-$major |
7083c021 AC |
9033 | ;; |
9034 | ||
9035 | *) | |
6f57a957 | 9036 | func_fatal_configuration "unknown library version type '$version_type'" |
7083c021 AC |
9037 | ;; |
9038 | esac | |
9039 | ||
9040 | # Clear the version info if we defaulted, and they specified a release. | |
9041 | if test -z "$vinfo" && test -n "$release"; then | |
9042 | major= | |
9043 | case $version_type in | |
9044 | darwin) | |
9045 | # we can't check for "0.0" in archive_cmds due to quoting | |
9046 | # problems, so we reset it completely | |
9047 | verstring= | |
9048 | ;; | |
9049 | *) | |
6f57a957 | 9050 | verstring=0.0 |
7083c021 AC |
9051 | ;; |
9052 | esac | |
6f57a957 | 9053 | if test no = "$need_version"; then |
7083c021 AC |
9054 | versuffix= |
9055 | else | |
6f57a957 | 9056 | versuffix=.0.0 |
7083c021 AC |
9057 | fi |
9058 | fi | |
9059 | ||
9060 | # Remove version info from name if versioning should be avoided | |
6f57a957 | 9061 | if test yes,no = "$avoid_version,$need_version"; then |
7083c021 AC |
9062 | major= |
9063 | versuffix= | |
6f57a957 | 9064 | verstring= |
7083c021 AC |
9065 | fi |
9066 | ||
9067 | # Check to see if the archive will have undefined symbols. | |
6f57a957 AC |
9068 | if test yes = "$allow_undefined"; then |
9069 | if test unsupported = "$allow_undefined_flag"; then | |
9070 | if test yes = "$build_old_libs"; then | |
9071 | func_warning "undefined symbols not allowed in $host shared libraries; building static only" | |
9072 | build_libtool_libs=no | |
9073 | else | |
9074 | func_fatal_error "can't build $host shared library unless -no-undefined is specified" | |
9075 | fi | |
7083c021 AC |
9076 | fi |
9077 | else | |
9078 | # Don't allow undefined symbols. | |
6f57a957 | 9079 | allow_undefined_flag=$no_undefined_flag |
7083c021 AC |
9080 | fi |
9081 | ||
9082 | fi | |
9083 | ||
6f57a957 | 9084 | func_generate_dlsyms "$libname" "$libname" : |
08d019eb | 9085 | func_append libobjs " $symfileobj" |
6f57a957 | 9086 | test " " = "$libobjs" && libobjs= |
7083c021 | 9087 | |
6f57a957 | 9088 | if test relink != "$opt_mode"; then |
7083c021 AC |
9089 | # Remove our outputs, but don't remove object files since they |
9090 | # may have been created when compiling PIC objects. | |
9091 | removelist= | |
9092 | tempremovelist=`$ECHO "$output_objdir/*"` | |
9093 | for p in $tempremovelist; do | |
9094 | case $p in | |
9095 | *.$objext | *.gcno) | |
9096 | ;; | |
6f57a957 AC |
9097 | $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) |
9098 | if test -n "$precious_files_regex"; then | |
7083c021 AC |
9099 | if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 |
9100 | then | |
9101 | continue | |
9102 | fi | |
9103 | fi | |
08d019eb | 9104 | func_append removelist " $p" |
7083c021 AC |
9105 | ;; |
9106 | *) ;; | |
9107 | esac | |
9108 | done | |
9109 | test -n "$removelist" && \ | |
9110 | func_show_eval "${RM}r \$removelist" | |
9111 | fi | |
9112 | ||
9113 | # Now set the variables for building old libraries. | |
6f57a957 | 9114 | if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then |
08d019eb | 9115 | func_append oldlibs " $output_objdir/$libname.$libext" |
7083c021 AC |
9116 | |
9117 | # Transform .lo files to .o files. | |
6f57a957 | 9118 | oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` |
7083c021 AC |
9119 | fi |
9120 | ||
9121 | # Eliminate all temporary directories. | |
9122 | #for path in $notinst_path; do | |
08d019eb AC |
9123 | # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` |
9124 | # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` | |
9125 | # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` | |
7083c021 AC |
9126 | #done |
9127 | ||
9128 | if test -n "$xrpath"; then | |
9129 | # If the user specified any rpath flags, then add them. | |
9130 | temp_xrpath= | |
9131 | for libdir in $xrpath; do | |
08d019eb AC |
9132 | func_replace_sysroot "$libdir" |
9133 | func_append temp_xrpath " -R$func_replace_sysroot_result" | |
7083c021 AC |
9134 | case "$finalize_rpath " in |
9135 | *" $libdir "*) ;; | |
08d019eb | 9136 | *) func_append finalize_rpath " $libdir" ;; |
7083c021 AC |
9137 | esac |
9138 | done | |
6f57a957 | 9139 | if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then |
7083c021 AC |
9140 | dependency_libs="$temp_xrpath $dependency_libs" |
9141 | fi | |
9142 | fi | |
9143 | ||
9144 | # Make sure dlfiles contains only unique files that won't be dlpreopened | |
6f57a957 | 9145 | old_dlfiles=$dlfiles |
7083c021 AC |
9146 | dlfiles= |
9147 | for lib in $old_dlfiles; do | |
9148 | case " $dlprefiles $dlfiles " in | |
9149 | *" $lib "*) ;; | |
08d019eb | 9150 | *) func_append dlfiles " $lib" ;; |
7083c021 AC |
9151 | esac |
9152 | done | |
9153 | ||
9154 | # Make sure dlprefiles contains only unique files | |
6f57a957 | 9155 | old_dlprefiles=$dlprefiles |
7083c021 AC |
9156 | dlprefiles= |
9157 | for lib in $old_dlprefiles; do | |
9158 | case "$dlprefiles " in | |
9159 | *" $lib "*) ;; | |
08d019eb | 9160 | *) func_append dlprefiles " $lib" ;; |
7083c021 AC |
9161 | esac |
9162 | done | |
9163 | ||
6f57a957 | 9164 | if test yes = "$build_libtool_libs"; then |
7083c021 AC |
9165 | if test -n "$rpath"; then |
9166 | case $host in | |
08d019eb | 9167 | *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) |
7083c021 AC |
9168 | # these systems don't actually have a c library (as such)! |
9169 | ;; | |
9170 | *-*-rhapsody* | *-*-darwin1.[012]) | |
9171 | # Rhapsody C library is in the System framework | |
08d019eb | 9172 | func_append deplibs " System.ltframework" |
7083c021 AC |
9173 | ;; |
9174 | *-*-netbsd*) | |
9175 | # Don't link with libc until the a.out ld.so is fixed. | |
9176 | ;; | |
9177 | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) | |
9178 | # Do not include libc due to us having libc/libc_r. | |
9179 | ;; | |
9180 | *-*-sco3.2v5* | *-*-sco5v6*) | |
9181 | # Causes problems with __ctype | |
9182 | ;; | |
9183 | *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) | |
9184 | # Compiler inserts libc in the correct place for threads to work | |
9185 | ;; | |
9186 | *) | |
9187 | # Add libc to deplibs on all other systems if necessary. | |
6f57a957 | 9188 | if test yes = "$build_libtool_need_lc"; then |
08d019eb | 9189 | func_append deplibs " -lc" |
7083c021 AC |
9190 | fi |
9191 | ;; | |
9192 | esac | |
9193 | fi | |
9194 | ||
9195 | # Transform deplibs into only deplibs that can be linked in shared. | |
9196 | name_save=$name | |
9197 | libname_save=$libname | |
9198 | release_save=$release | |
9199 | versuffix_save=$versuffix | |
9200 | major_save=$major | |
9201 | # I'm not sure if I'm treating the release correctly. I think | |
9202 | # release should show up in the -l (ie -lgmp5) so we don't want to | |
9203 | # add it in twice. Is that correct? | |
6f57a957 AC |
9204 | release= |
9205 | versuffix= | |
9206 | major= | |
7083c021 AC |
9207 | newdeplibs= |
9208 | droppeddeps=no | |
9209 | case $deplibs_check_method in | |
9210 | pass_all) | |
9211 | # Don't check for shared/static. Everything works. | |
9212 | # This might be a little naive. We might want to check | |
9213 | # whether the library exists or not. But this is on | |
9214 | # osf3 & osf4 and I'm not really sure... Just | |
9215 | # implementing what was already the behavior. | |
9216 | newdeplibs=$deplibs | |
9217 | ;; | |
9218 | test_compile) | |
9219 | # This code stresses the "libraries are programs" paradigm to its | |
9220 | # limits. Maybe even breaks it. We compile a program, linking it | |
9221 | # against the deplibs as a proxy for the library. Then we can check | |
9222 | # whether they linked in statically or dynamically with ldd. | |
9223 | $opt_dry_run || $RM conftest.c | |
9224 | cat > conftest.c <<EOF | |
9225 | int main() { return 0; } | |
9226 | EOF | |
9227 | $opt_dry_run || $RM conftest | |
9228 | if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then | |
9229 | ldd_output=`ldd conftest` | |
9230 | for i in $deplibs; do | |
9231 | case $i in | |
9232 | -l*) | |
9233 | func_stripname -l '' "$i" | |
9234 | name=$func_stripname_result | |
6f57a957 | 9235 | if test yes = "$allow_libtool_libs_with_static_runtimes"; then |
7083c021 AC |
9236 | case " $predeps $postdeps " in |
9237 | *" $i "*) | |
08d019eb | 9238 | func_append newdeplibs " $i" |
6f57a957 | 9239 | i= |
7083c021 AC |
9240 | ;; |
9241 | esac | |
9242 | fi | |
6f57a957 | 9243 | if test -n "$i"; then |
7083c021 AC |
9244 | libname=`eval "\\$ECHO \"$libname_spec\""` |
9245 | deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` | |
9246 | set dummy $deplib_matches; shift | |
9247 | deplib_match=$1 | |
6f57a957 | 9248 | if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then |
08d019eb | 9249 | func_append newdeplibs " $i" |
7083c021 AC |
9250 | else |
9251 | droppeddeps=yes | |
08d019eb | 9252 | echo |
7083c021 | 9253 | $ECHO "*** Warning: dynamic linker does not accept needed library $i." |
08d019eb AC |
9254 | echo "*** I have the capability to make that library automatically link in when" |
9255 | echo "*** you link to this library. But I can only do this if you have a" | |
9256 | echo "*** shared version of the library, which I believe you do not have" | |
9257 | echo "*** because a test_compile did reveal that the linker did not use it for" | |
9258 | echo "*** its dynamic dependency list that programs get resolved with at runtime." | |
7083c021 AC |
9259 | fi |
9260 | fi | |
9261 | ;; | |
9262 | *) | |
08d019eb | 9263 | func_append newdeplibs " $i" |
7083c021 AC |
9264 | ;; |
9265 | esac | |
9266 | done | |
9267 | else | |
9268 | # Error occurred in the first compile. Let's try to salvage | |
9269 | # the situation: Compile a separate program for each library. | |
9270 | for i in $deplibs; do | |
9271 | case $i in | |
9272 | -l*) | |
9273 | func_stripname -l '' "$i" | |
9274 | name=$func_stripname_result | |
9275 | $opt_dry_run || $RM conftest | |
9276 | if $LTCC $LTCFLAGS -o conftest conftest.c $i; then | |
9277 | ldd_output=`ldd conftest` | |
6f57a957 | 9278 | if test yes = "$allow_libtool_libs_with_static_runtimes"; then |
7083c021 AC |
9279 | case " $predeps $postdeps " in |
9280 | *" $i "*) | |
08d019eb | 9281 | func_append newdeplibs " $i" |
6f57a957 | 9282 | i= |
7083c021 AC |
9283 | ;; |
9284 | esac | |
9285 | fi | |
6f57a957 | 9286 | if test -n "$i"; then |
7083c021 AC |
9287 | libname=`eval "\\$ECHO \"$libname_spec\""` |
9288 | deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` | |
9289 | set dummy $deplib_matches; shift | |
9290 | deplib_match=$1 | |
6f57a957 | 9291 | if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then |
08d019eb | 9292 | func_append newdeplibs " $i" |
7083c021 AC |
9293 | else |
9294 | droppeddeps=yes | |
08d019eb | 9295 | echo |
7083c021 | 9296 | $ECHO "*** Warning: dynamic linker does not accept needed library $i." |
08d019eb AC |
9297 | echo "*** I have the capability to make that library automatically link in when" |
9298 | echo "*** you link to this library. But I can only do this if you have a" | |
9299 | echo "*** shared version of the library, which you do not appear to have" | |
9300 | echo "*** because a test_compile did reveal that the linker did not use this one" | |
9301 | echo "*** as a dynamic dependency that programs can get resolved with at runtime." | |
7083c021 AC |
9302 | fi |
9303 | fi | |
9304 | else | |
9305 | droppeddeps=yes | |
08d019eb | 9306 | echo |
7083c021 | 9307 | $ECHO "*** Warning! Library $i is needed by this library but I was not able to" |
08d019eb AC |
9308 | echo "*** make it link in! You will probably need to install it or some" |
9309 | echo "*** library that it depends on before this library will be fully" | |
9310 | echo "*** functional. Installing it before continuing would be even better." | |
7083c021 AC |
9311 | fi |
9312 | ;; | |
9313 | *) | |
08d019eb | 9314 | func_append newdeplibs " $i" |
7083c021 AC |
9315 | ;; |
9316 | esac | |
9317 | done | |
9318 | fi | |
9319 | ;; | |
9320 | file_magic*) | |
9321 | set dummy $deplibs_check_method; shift | |
9322 | file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` | |
9323 | for a_deplib in $deplibs; do | |
9324 | case $a_deplib in | |
9325 | -l*) | |
9326 | func_stripname -l '' "$a_deplib" | |
9327 | name=$func_stripname_result | |
6f57a957 | 9328 | if test yes = "$allow_libtool_libs_with_static_runtimes"; then |
7083c021 AC |
9329 | case " $predeps $postdeps " in |
9330 | *" $a_deplib "*) | |
08d019eb | 9331 | func_append newdeplibs " $a_deplib" |
6f57a957 | 9332 | a_deplib= |
7083c021 AC |
9333 | ;; |
9334 | esac | |
9335 | fi | |
6f57a957 | 9336 | if test -n "$a_deplib"; then |
7083c021 | 9337 | libname=`eval "\\$ECHO \"$libname_spec\""` |
08d019eb AC |
9338 | if test -n "$file_magic_glob"; then |
9339 | libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` | |
9340 | else | |
9341 | libnameglob=$libname | |
9342 | fi | |
6f57a957 | 9343 | test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` |
7083c021 | 9344 | for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do |
6f57a957 | 9345 | if test yes = "$want_nocaseglob"; then |
08d019eb AC |
9346 | shopt -s nocaseglob |
9347 | potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` | |
9348 | $nocaseglob | |
9349 | else | |
9350 | potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` | |
9351 | fi | |
7083c021 AC |
9352 | for potent_lib in $potential_libs; do |
9353 | # Follow soft links. | |
9354 | if ls -lLd "$potent_lib" 2>/dev/null | | |
9355 | $GREP " -> " >/dev/null; then | |
9356 | continue | |
9357 | fi | |
9358 | # The statement above tries to avoid entering an | |
9359 | # endless loop below, in case of cyclic links. | |
9360 | # We might still enter an endless loop, since a link | |
9361 | # loop can be closed while we follow links, | |
9362 | # but so what? | |
6f57a957 | 9363 | potlib=$potent_lib |
7083c021 | 9364 | while test -h "$potlib" 2>/dev/null; do |
6f57a957 | 9365 | potliblink=`ls -ld $potlib | $SED 's/.* -> //'` |
7083c021 | 9366 | case $potliblink in |
6f57a957 AC |
9367 | [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; |
9368 | *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; | |
7083c021 AC |
9369 | esac |
9370 | done | |
9371 | if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | | |
9372 | $SED -e 10q | | |
9373 | $EGREP "$file_magic_regex" > /dev/null; then | |
08d019eb | 9374 | func_append newdeplibs " $a_deplib" |
6f57a957 | 9375 | a_deplib= |
7083c021 AC |
9376 | break 2 |
9377 | fi | |
9378 | done | |
9379 | done | |
9380 | fi | |
6f57a957 | 9381 | if test -n "$a_deplib"; then |
7083c021 | 9382 | droppeddeps=yes |
08d019eb | 9383 | echo |
7083c021 | 9384 | $ECHO "*** Warning: linker path does not have real file for library $a_deplib." |
08d019eb AC |
9385 | echo "*** I have the capability to make that library automatically link in when" |
9386 | echo "*** you link to this library. But I can only do this if you have a" | |
9387 | echo "*** shared version of the library, which you do not appear to have" | |
9388 | echo "*** because I did check the linker path looking for a file starting" | |
6f57a957 | 9389 | if test -z "$potlib"; then |
7083c021 AC |
9390 | $ECHO "*** with $libname but no candidates were found. (...for file magic test)" |
9391 | else | |
9392 | $ECHO "*** with $libname and none of the candidates passed a file format test" | |
9393 | $ECHO "*** using a file magic. Last file checked: $potlib" | |
9394 | fi | |
9395 | fi | |
9396 | ;; | |
9397 | *) | |
9398 | # Add a -L argument. | |
08d019eb | 9399 | func_append newdeplibs " $a_deplib" |
7083c021 AC |
9400 | ;; |
9401 | esac | |
9402 | done # Gone through all deplibs. | |
9403 | ;; | |
9404 | match_pattern*) | |
9405 | set dummy $deplibs_check_method; shift | |
9406 | match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` | |
9407 | for a_deplib in $deplibs; do | |
9408 | case $a_deplib in | |
9409 | -l*) | |
9410 | func_stripname -l '' "$a_deplib" | |
9411 | name=$func_stripname_result | |
6f57a957 | 9412 | if test yes = "$allow_libtool_libs_with_static_runtimes"; then |
7083c021 AC |
9413 | case " $predeps $postdeps " in |
9414 | *" $a_deplib "*) | |
08d019eb | 9415 | func_append newdeplibs " $a_deplib" |
6f57a957 | 9416 | a_deplib= |
7083c021 AC |
9417 | ;; |
9418 | esac | |
9419 | fi | |
6f57a957 | 9420 | if test -n "$a_deplib"; then |
7083c021 AC |
9421 | libname=`eval "\\$ECHO \"$libname_spec\""` |
9422 | for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do | |
9423 | potential_libs=`ls $i/$libname[.-]* 2>/dev/null` | |
9424 | for potent_lib in $potential_libs; do | |
6f57a957 | 9425 | potlib=$potent_lib # see symlink-check above in file_magic test |
08d019eb | 9426 | if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ |
7083c021 | 9427 | $EGREP "$match_pattern_regex" > /dev/null; then |
08d019eb | 9428 | func_append newdeplibs " $a_deplib" |
6f57a957 | 9429 | a_deplib= |
7083c021 AC |
9430 | break 2 |
9431 | fi | |
9432 | done | |
9433 | done | |
9434 | fi | |
6f57a957 | 9435 | if test -n "$a_deplib"; then |
7083c021 | 9436 | droppeddeps=yes |
08d019eb | 9437 | echo |
7083c021 | 9438 | $ECHO "*** Warning: linker path does not have real file for library $a_deplib." |
08d019eb AC |
9439 | echo "*** I have the capability to make that library automatically link in when" |
9440 | echo "*** you link to this library. But I can only do this if you have a" | |
9441 | echo "*** shared version of the library, which you do not appear to have" | |
9442 | echo "*** because I did check the linker path looking for a file starting" | |
6f57a957 | 9443 | if test -z "$potlib"; then |
7083c021 AC |
9444 | $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" |
9445 | else | |
9446 | $ECHO "*** with $libname and none of the candidates passed a file format test" | |
9447 | $ECHO "*** using a regex pattern. Last file checked: $potlib" | |
9448 | fi | |
9449 | fi | |
9450 | ;; | |
9451 | *) | |
9452 | # Add a -L argument. | |
08d019eb | 9453 | func_append newdeplibs " $a_deplib" |
7083c021 AC |
9454 | ;; |
9455 | esac | |
9456 | done # Gone through all deplibs. | |
9457 | ;; | |
9458 | none | unknown | *) | |
6f57a957 | 9459 | newdeplibs= |
08d019eb | 9460 | tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` |
6f57a957 AC |
9461 | if test yes = "$allow_libtool_libs_with_static_runtimes"; then |
9462 | for i in $predeps $postdeps; do | |
7083c021 | 9463 | # can't use Xsed below, because $i might contain '/' |
6f57a957 | 9464 | tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` |
7083c021 AC |
9465 | done |
9466 | fi | |
08d019eb AC |
9467 | case $tmp_deplibs in |
9468 | *[!\ \ ]*) | |
9469 | echo | |
6f57a957 | 9470 | if test none = "$deplibs_check_method"; then |
08d019eb | 9471 | echo "*** Warning: inter-library dependencies are not supported in this platform." |
7083c021 | 9472 | else |
08d019eb | 9473 | echo "*** Warning: inter-library dependencies are not known to be supported." |
7083c021 | 9474 | fi |
08d019eb | 9475 | echo "*** All declared inter-library dependencies are being dropped." |
7083c021 | 9476 | droppeddeps=yes |
08d019eb AC |
9477 | ;; |
9478 | esac | |
7083c021 AC |
9479 | ;; |
9480 | esac | |
9481 | versuffix=$versuffix_save | |
9482 | major=$major_save | |
9483 | release=$release_save | |
9484 | libname=$libname_save | |
9485 | name=$name_save | |
9486 | ||
9487 | case $host in | |
9488 | *-*-rhapsody* | *-*-darwin1.[012]) | |
9489 | # On Rhapsody replace the C library with the System framework | |
08d019eb | 9490 | newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` |
7083c021 AC |
9491 | ;; |
9492 | esac | |
9493 | ||
6f57a957 AC |
9494 | if test yes = "$droppeddeps"; then |
9495 | if test yes = "$module"; then | |
08d019eb AC |
9496 | echo |
9497 | echo "*** Warning: libtool could not satisfy all declared inter-library" | |
7083c021 | 9498 | $ECHO "*** dependencies of module $libname. Therefore, libtool will create" |
08d019eb AC |
9499 | echo "*** a static module, that should work as long as the dlopening" |
9500 | echo "*** application is linked with the -dlopen flag." | |
7083c021 | 9501 | if test -z "$global_symbol_pipe"; then |
08d019eb AC |
9502 | echo |
9503 | echo "*** However, this would only work if libtool was able to extract symbol" | |
6f57a957 | 9504 | echo "*** lists from a program, using 'nm' or equivalent, but libtool could" |
08d019eb | 9505 | echo "*** not find such a program. So, this module is probably useless." |
6f57a957 | 9506 | echo "*** 'nm' from GNU binutils and a full rebuild may help." |
7083c021 | 9507 | fi |
6f57a957 AC |
9508 | if test no = "$build_old_libs"; then |
9509 | oldlibs=$output_objdir/$libname.$libext | |
7083c021 AC |
9510 | build_libtool_libs=module |
9511 | build_old_libs=yes | |
9512 | else | |
9513 | build_libtool_libs=no | |
9514 | fi | |
9515 | else | |
08d019eb AC |
9516 | echo "*** The inter-library dependencies that have been dropped here will be" |
9517 | echo "*** automatically added whenever a program is linked with this library" | |
9518 | echo "*** or is declared to -dlopen it." | |
7083c021 | 9519 | |
6f57a957 | 9520 | if test no = "$allow_undefined"; then |
08d019eb AC |
9521 | echo |
9522 | echo "*** Since this library must not contain undefined symbols," | |
9523 | echo "*** because either the platform does not support them or" | |
9524 | echo "*** it was explicitly requested with -no-undefined," | |
9525 | echo "*** libtool will only create a static version of it." | |
6f57a957 AC |
9526 | if test no = "$build_old_libs"; then |
9527 | oldlibs=$output_objdir/$libname.$libext | |
7083c021 AC |
9528 | build_libtool_libs=module |
9529 | build_old_libs=yes | |
9530 | else | |
9531 | build_libtool_libs=no | |
9532 | fi | |
9533 | fi | |
9534 | fi | |
9535 | fi | |
9536 | # Done checking deplibs! | |
9537 | deplibs=$newdeplibs | |
9538 | fi | |
9539 | # Time to change all our "foo.ltframework" stuff back to "-framework foo" | |
9540 | case $host in | |
9541 | *-*-darwin*) | |
08d019eb AC |
9542 | newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` |
9543 | new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
9544 | deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
7083c021 AC |
9545 | ;; |
9546 | esac | |
9547 | ||
9548 | # move library search paths that coincide with paths to not yet | |
9549 | # installed libraries to the beginning of the library search list | |
9550 | new_libs= | |
9551 | for path in $notinst_path; do | |
9552 | case " $new_libs " in | |
9553 | *" -L$path/$objdir "*) ;; | |
9554 | *) | |
9555 | case " $deplibs " in | |
9556 | *" -L$path/$objdir "*) | |
08d019eb | 9557 | func_append new_libs " -L$path/$objdir" ;; |
7083c021 AC |
9558 | esac |
9559 | ;; | |
9560 | esac | |
9561 | done | |
9562 | for deplib in $deplibs; do | |
9563 | case $deplib in | |
9564 | -L*) | |
9565 | case " $new_libs " in | |
9566 | *" $deplib "*) ;; | |
08d019eb | 9567 | *) func_append new_libs " $deplib" ;; |
7083c021 AC |
9568 | esac |
9569 | ;; | |
08d019eb | 9570 | *) func_append new_libs " $deplib" ;; |
7083c021 AC |
9571 | esac |
9572 | done | |
6f57a957 | 9573 | deplibs=$new_libs |
7083c021 AC |
9574 | |
9575 | # All the library-specific variables (install_libdir is set above). | |
9576 | library_names= | |
9577 | old_library= | |
9578 | dlname= | |
9579 | ||
9580 | # Test again, we may have decided not to build it any more | |
6f57a957 AC |
9581 | if test yes = "$build_libtool_libs"; then |
9582 | # Remove $wl instances when linking with ld. | |
54bec06e AC |
9583 | # FIXME: should test the right _cmds variable. |
9584 | case $archive_cmds in | |
9585 | *\$LD\ *) wl= ;; | |
9586 | esac | |
6f57a957 | 9587 | if test yes = "$hardcode_into_libs"; then |
7083c021 AC |
9588 | # Hardcode the library paths |
9589 | hardcode_libdirs= | |
9590 | dep_rpath= | |
6f57a957 AC |
9591 | rpath=$finalize_rpath |
9592 | test relink = "$opt_mode" || rpath=$compile_rpath$rpath | |
7083c021 AC |
9593 | for libdir in $rpath; do |
9594 | if test -n "$hardcode_libdir_flag_spec"; then | |
9595 | if test -n "$hardcode_libdir_separator"; then | |
08d019eb AC |
9596 | func_replace_sysroot "$libdir" |
9597 | libdir=$func_replace_sysroot_result | |
7083c021 | 9598 | if test -z "$hardcode_libdirs"; then |
6f57a957 | 9599 | hardcode_libdirs=$libdir |
7083c021 AC |
9600 | else |
9601 | # Just accumulate the unique libdirs. | |
9602 | case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in | |
9603 | *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) | |
9604 | ;; | |
9605 | *) | |
08d019eb | 9606 | func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" |
7083c021 AC |
9607 | ;; |
9608 | esac | |
9609 | fi | |
9610 | else | |
9611 | eval flag=\"$hardcode_libdir_flag_spec\" | |
08d019eb | 9612 | func_append dep_rpath " $flag" |
7083c021 AC |
9613 | fi |
9614 | elif test -n "$runpath_var"; then | |
9615 | case "$perm_rpath " in | |
9616 | *" $libdir "*) ;; | |
54bec06e | 9617 | *) func_append perm_rpath " $libdir" ;; |
7083c021 AC |
9618 | esac |
9619 | fi | |
9620 | done | |
9621 | # Substitute the hardcoded libdirs into the rpath. | |
9622 | if test -n "$hardcode_libdir_separator" && | |
9623 | test -n "$hardcode_libdirs"; then | |
6f57a957 | 9624 | libdir=$hardcode_libdirs |
54bec06e | 9625 | eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" |
7083c021 AC |
9626 | fi |
9627 | if test -n "$runpath_var" && test -n "$perm_rpath"; then | |
9628 | # We should set the runpath_var. | |
9629 | rpath= | |
9630 | for dir in $perm_rpath; do | |
08d019eb | 9631 | func_append rpath "$dir:" |
7083c021 AC |
9632 | done |
9633 | eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" | |
9634 | fi | |
9635 | test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" | |
9636 | fi | |
db137867 | 9637 | |
6f57a957 AC |
9638 | shlibpath=$finalize_shlibpath |
9639 | test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath | |
7083c021 AC |
9640 | if test -n "$shlibpath"; then |
9641 | eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" | |
9642 | fi | |
db137867 | 9643 | |
7083c021 AC |
9644 | # Get the real and link names of the library. |
9645 | eval shared_ext=\"$shrext_cmds\" | |
9646 | eval library_names=\"$library_names_spec\" | |
9647 | set dummy $library_names | |
9648 | shift | |
6f57a957 | 9649 | realname=$1 |
7083c021 | 9650 | shift |
db137867 | 9651 | |
7083c021 AC |
9652 | if test -n "$soname_spec"; then |
9653 | eval soname=\"$soname_spec\" | |
9654 | else | |
6f57a957 | 9655 | soname=$realname |
7083c021 AC |
9656 | fi |
9657 | if test -z "$dlname"; then | |
9658 | dlname=$soname | |
9659 | fi | |
db137867 | 9660 | |
6f57a957 | 9661 | lib=$output_objdir/$realname |
7083c021 AC |
9662 | linknames= |
9663 | for link | |
9664 | do | |
08d019eb | 9665 | func_append linknames " $link" |
7083c021 | 9666 | done |
db137867 | 9667 | |
7083c021 | 9668 | # Use standard objects if they are pic |
08d019eb | 9669 | test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` |
7083c021 | 9670 | test "X$libobjs" = "X " && libobjs= |
db137867 | 9671 | |
7083c021 AC |
9672 | delfiles= |
9673 | if test -n "$export_symbols" && test -n "$include_expsyms"; then | |
9674 | $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" | |
6f57a957 | 9675 | export_symbols=$output_objdir/$libname.uexp |
08d019eb | 9676 | func_append delfiles " $export_symbols" |
7083c021 | 9677 | fi |
db137867 | 9678 | |
7083c021 AC |
9679 | orig_export_symbols= |
9680 | case $host_os in | |
9681 | cygwin* | mingw* | cegcc*) | |
9682 | if test -n "$export_symbols" && test -z "$export_symbols_regex"; then | |
9683 | # exporting using user supplied symfile | |
6f57a957 | 9684 | func_dll_def_p "$export_symbols" || { |
7083c021 AC |
9685 | # and it's NOT already a .def file. Must figure out |
9686 | # which of the given symbols are data symbols and tag | |
9687 | # them as such. So, trigger use of export_symbols_cmds. | |
9688 | # export_symbols gets reassigned inside the "prepare | |
9689 | # the list of exported symbols" if statement, so the | |
9690 | # include_expsyms logic still works. | |
6f57a957 | 9691 | orig_export_symbols=$export_symbols |
7083c021 AC |
9692 | export_symbols= |
9693 | always_export_symbols=yes | |
6f57a957 | 9694 | } |
7083c021 AC |
9695 | fi |
9696 | ;; | |
9697 | esac | |
db137867 | 9698 | |
7083c021 AC |
9699 | # Prepare the list of exported symbols |
9700 | if test -z "$export_symbols"; then | |
6f57a957 AC |
9701 | if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then |
9702 | func_verbose "generating symbol list for '$libname.la'" | |
9703 | export_symbols=$output_objdir/$libname.exp | |
7083c021 AC |
9704 | $opt_dry_run || $RM $export_symbols |
9705 | cmds=$export_symbols_cmds | |
6f57a957 | 9706 | save_ifs=$IFS; IFS='~' |
08d019eb | 9707 | for cmd1 in $cmds; do |
6f57a957 | 9708 | IFS=$save_ifs |
08d019eb AC |
9709 | # Take the normal branch if the nm_file_list_spec branch |
9710 | # doesn't work or if tool conversion is not needed. | |
9711 | case $nm_file_list_spec~$to_tool_file_cmd in | |
9712 | *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) | |
9713 | try_normal_branch=yes | |
9714 | eval cmd=\"$cmd1\" | |
9715 | func_len " $cmd" | |
9716 | len=$func_len_result | |
9717 | ;; | |
9718 | *) | |
9719 | try_normal_branch=no | |
9720 | ;; | |
9721 | esac | |
6f57a957 | 9722 | if test yes = "$try_normal_branch" \ |
08d019eb AC |
9723 | && { test "$len" -lt "$max_cmd_len" \ |
9724 | || test "$max_cmd_len" -le -1; } | |
9725 | then | |
9726 | func_show_eval "$cmd" 'exit $?' | |
9727 | skipped_export=false | |
9728 | elif test -n "$nm_file_list_spec"; then | |
9729 | func_basename "$output" | |
9730 | output_la=$func_basename_result | |
9731 | save_libobjs=$libobjs | |
9732 | save_output=$output | |
6f57a957 | 9733 | output=$output_objdir/$output_la.nm |
08d019eb AC |
9734 | func_to_tool_file "$output" |
9735 | libobjs=$nm_file_list_spec$func_to_tool_file_result | |
9736 | func_append delfiles " $output" | |
9737 | func_verbose "creating $NM input file list: $output" | |
9738 | for obj in $save_libobjs; do | |
9739 | func_to_tool_file "$obj" | |
9740 | $ECHO "$func_to_tool_file_result" | |
9741 | done > "$output" | |
9742 | eval cmd=\"$cmd1\" | |
7083c021 | 9743 | func_show_eval "$cmd" 'exit $?' |
08d019eb AC |
9744 | output=$save_output |
9745 | libobjs=$save_libobjs | |
7083c021 AC |
9746 | skipped_export=false |
9747 | else | |
9748 | # The command line is too long to execute in one step. | |
9749 | func_verbose "using reloadable object file for export list..." | |
9750 | skipped_export=: | |
9751 | # Break out early, otherwise skipped_export may be | |
9752 | # set to false by a later but shorter cmd. | |
9753 | break | |
9754 | fi | |
9755 | done | |
6f57a957 AC |
9756 | IFS=$save_ifs |
9757 | if test -n "$export_symbols_regex" && test : != "$skipped_export"; then | |
7083c021 AC |
9758 | func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' |
9759 | func_show_eval '$MV "${export_symbols}T" "$export_symbols"' | |
9760 | fi | |
9761 | fi | |
db137867 AC |
9762 | fi |
9763 | ||
7083c021 | 9764 | if test -n "$export_symbols" && test -n "$include_expsyms"; then |
6f57a957 AC |
9765 | tmp_export_symbols=$export_symbols |
9766 | test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols | |
08d019eb | 9767 | $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' |
7083c021 | 9768 | fi |
db137867 | 9769 | |
6f57a957 | 9770 | if test : != "$skipped_export" && test -n "$orig_export_symbols"; then |
7083c021 | 9771 | # The given exports_symbols file has to be filtered, so filter it. |
6f57a957 | 9772 | func_verbose "filter symbol list for '$libname.la' to tag DATA exports" |
7083c021 | 9773 | # FIXME: $output_objdir/$libname.filter potentially contains lots of |
6f57a957 | 9774 | # 's' commands, which not all seds can handle. GNU sed should be fine |
7083c021 AC |
9775 | # though. Also, the filter scales superlinearly with the number of |
9776 | # global variables. join(1) would be nice here, but unfortunately | |
9777 | # isn't a blessed tool. | |
9778 | $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter | |
08d019eb | 9779 | func_append delfiles " $export_symbols $output_objdir/$libname.filter" |
7083c021 AC |
9780 | export_symbols=$output_objdir/$libname.def |
9781 | $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols | |
9782 | fi | |
db137867 | 9783 | |
7083c021 AC |
9784 | tmp_deplibs= |
9785 | for test_deplib in $deplibs; do | |
9786 | case " $convenience " in | |
9787 | *" $test_deplib "*) ;; | |
9788 | *) | |
08d019eb | 9789 | func_append tmp_deplibs " $test_deplib" |
7083c021 AC |
9790 | ;; |
9791 | esac | |
9792 | done | |
6f57a957 | 9793 | deplibs=$tmp_deplibs |
db137867 | 9794 | |
7083c021 AC |
9795 | if test -n "$convenience"; then |
9796 | if test -n "$whole_archive_flag_spec" && | |
6f57a957 | 9797 | test yes = "$compiler_needs_object" && |
7083c021 AC |
9798 | test -z "$libobjs"; then |
9799 | # extract the archives, so we have objects to list. | |
9800 | # TODO: could optimize this to just extract one archive. | |
9801 | whole_archive_flag_spec= | |
9802 | fi | |
9803 | if test -n "$whole_archive_flag_spec"; then | |
9804 | save_libobjs=$libobjs | |
9805 | eval libobjs=\"\$libobjs $whole_archive_flag_spec\" | |
9806 | test "X$libobjs" = "X " && libobjs= | |
9807 | else | |
6f57a957 | 9808 | gentop=$output_objdir/${outputname}x |
08d019eb | 9809 | func_append generated " $gentop" |
db137867 | 9810 | |
7083c021 | 9811 | func_extract_archives $gentop $convenience |
08d019eb | 9812 | func_append libobjs " $func_extract_archives_result" |
7083c021 AC |
9813 | test "X$libobjs" = "X " && libobjs= |
9814 | fi | |
db137867 AC |
9815 | fi |
9816 | ||
6f57a957 | 9817 | if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then |
7083c021 | 9818 | eval flag=\"$thread_safe_flag_spec\" |
08d019eb | 9819 | func_append linker_flags " $flag" |
db137867 AC |
9820 | fi |
9821 | ||
7083c021 | 9822 | # Make a backup of the uninstalled library when relinking |
6f57a957 | 9823 | if test relink = "$opt_mode"; then |
7083c021 AC |
9824 | $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? |
9825 | fi | |
db137867 | 9826 | |
7083c021 | 9827 | # Do each of the archive commands. |
6f57a957 | 9828 | if test yes = "$module" && test -n "$module_cmds"; then |
7083c021 AC |
9829 | if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then |
9830 | eval test_cmds=\"$module_expsym_cmds\" | |
9831 | cmds=$module_expsym_cmds | |
9832 | else | |
9833 | eval test_cmds=\"$module_cmds\" | |
9834 | cmds=$module_cmds | |
9835 | fi | |
db137867 | 9836 | else |
7083c021 AC |
9837 | if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then |
9838 | eval test_cmds=\"$archive_expsym_cmds\" | |
9839 | cmds=$archive_expsym_cmds | |
9840 | else | |
9841 | eval test_cmds=\"$archive_cmds\" | |
9842 | cmds=$archive_cmds | |
9843 | fi | |
db137867 | 9844 | fi |
db137867 | 9845 | |
6f57a957 | 9846 | if test : != "$skipped_export" && |
7083c021 AC |
9847 | func_len " $test_cmds" && |
9848 | len=$func_len_result && | |
9849 | test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then | |
9850 | : | |
9851 | else | |
9852 | # The command line is too long to link in one step, link piecewise | |
9853 | # or, if using GNU ld and skipped_export is not :, use a linker | |
9854 | # script. | |
db137867 | 9855 | |
7083c021 AC |
9856 | # Save the value of $output and $libobjs because we want to |
9857 | # use them later. If we have whole_archive_flag_spec, we | |
9858 | # want to use save_libobjs as it was before | |
9859 | # whole_archive_flag_spec was expanded, because we can't | |
9860 | # assume the linker understands whole_archive_flag_spec. | |
9861 | # This may have to be revisited, in case too many | |
9862 | # convenience libraries get linked in and end up exceeding | |
9863 | # the spec. | |
9864 | if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then | |
9865 | save_libobjs=$libobjs | |
9866 | fi | |
9867 | save_output=$output | |
08d019eb AC |
9868 | func_basename "$output" |
9869 | output_la=$func_basename_result | |
db137867 | 9870 | |
7083c021 AC |
9871 | # Clear the reloadable object creation command queue and |
9872 | # initialize k to one. | |
9873 | test_cmds= | |
9874 | concat_cmds= | |
9875 | objlist= | |
9876 | last_robj= | |
9877 | k=1 | |
9878 | ||
6f57a957 AC |
9879 | if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then |
9880 | output=$output_objdir/$output_la.lnkscript | |
7083c021 | 9881 | func_verbose "creating GNU ld script: $output" |
08d019eb | 9882 | echo 'INPUT (' > $output |
7083c021 | 9883 | for obj in $save_libobjs |
db137867 | 9884 | do |
08d019eb AC |
9885 | func_to_tool_file "$obj" |
9886 | $ECHO "$func_to_tool_file_result" >> $output | |
7083c021 | 9887 | done |
08d019eb AC |
9888 | echo ')' >> $output |
9889 | func_append delfiles " $output" | |
9890 | func_to_tool_file "$output" | |
9891 | output=$func_to_tool_file_result | |
6f57a957 AC |
9892 | elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then |
9893 | output=$output_objdir/$output_la.lnk | |
7083c021 AC |
9894 | func_verbose "creating linker input file list: $output" |
9895 | : > $output | |
9896 | set x $save_libobjs | |
9897 | shift | |
9898 | firstobj= | |
6f57a957 | 9899 | if test yes = "$compiler_needs_object"; then |
7083c021 AC |
9900 | firstobj="$1 " |
9901 | shift | |
9902 | fi | |
9903 | for obj | |
9904 | do | |
08d019eb AC |
9905 | func_to_tool_file "$obj" |
9906 | $ECHO "$func_to_tool_file_result" >> $output | |
7083c021 | 9907 | done |
08d019eb AC |
9908 | func_append delfiles " $output" |
9909 | func_to_tool_file "$output" | |
9910 | output=$firstobj\"$file_list_spec$func_to_tool_file_result\" | |
7083c021 AC |
9911 | else |
9912 | if test -n "$save_libobjs"; then | |
9913 | func_verbose "creating reloadable object files..." | |
6f57a957 | 9914 | output=$output_objdir/$output_la-$k.$objext |
7083c021 AC |
9915 | eval test_cmds=\"$reload_cmds\" |
9916 | func_len " $test_cmds" | |
9917 | len0=$func_len_result | |
9918 | len=$len0 | |
9919 | ||
9920 | # Loop over the list of objects to be linked. | |
9921 | for obj in $save_libobjs | |
9922 | do | |
9923 | func_len " $obj" | |
9924 | func_arith $len + $func_len_result | |
9925 | len=$func_arith_result | |
6f57a957 | 9926 | if test -z "$objlist" || |
7083c021 AC |
9927 | test "$len" -lt "$max_cmd_len"; then |
9928 | func_append objlist " $obj" | |
9929 | else | |
9930 | # The command $test_cmds is almost too long, add a | |
9931 | # command to the queue. | |
6f57a957 | 9932 | if test 1 -eq "$k"; then |
7083c021 | 9933 | # The first file doesn't have a previous command to add. |
08d019eb AC |
9934 | reload_objs=$objlist |
9935 | eval concat_cmds=\"$reload_cmds\" | |
7083c021 AC |
9936 | else |
9937 | # All subsequent reloadable object files will link in | |
9938 | # the last one created. | |
08d019eb AC |
9939 | reload_objs="$objlist $last_robj" |
9940 | eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" | |
7083c021 | 9941 | fi |
6f57a957 | 9942 | last_robj=$output_objdir/$output_la-$k.$objext |
7083c021 AC |
9943 | func_arith $k + 1 |
9944 | k=$func_arith_result | |
6f57a957 | 9945 | output=$output_objdir/$output_la-$k.$objext |
08d019eb | 9946 | objlist=" $obj" |
7083c021 AC |
9947 | func_len " $last_robj" |
9948 | func_arith $len0 + $func_len_result | |
9949 | len=$func_arith_result | |
9950 | fi | |
9951 | done | |
9952 | # Handle the remaining objects by creating one last | |
9953 | # reloadable object file. All subsequent reloadable object | |
9954 | # files will link in the last one created. | |
9955 | test -z "$concat_cmds" || concat_cmds=$concat_cmds~ | |
08d019eb | 9956 | reload_objs="$objlist $last_robj" |
6f57a957 | 9957 | eval concat_cmds=\"\$concat_cmds$reload_cmds\" |
7083c021 | 9958 | if test -n "$last_robj"; then |
6f57a957 | 9959 | eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" |
7083c021 | 9960 | fi |
08d019eb | 9961 | func_append delfiles " $output" |
db137867 | 9962 | |
7083c021 AC |
9963 | else |
9964 | output= | |
9965 | fi | |
db137867 | 9966 | |
6f57a957 AC |
9967 | ${skipped_export-false} && { |
9968 | func_verbose "generating symbol list for '$libname.la'" | |
9969 | export_symbols=$output_objdir/$libname.exp | |
7083c021 AC |
9970 | $opt_dry_run || $RM $export_symbols |
9971 | libobjs=$output | |
9972 | # Append the command to create the export file. | |
9973 | test -z "$concat_cmds" || concat_cmds=$concat_cmds~ | |
9974 | eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" | |
9975 | if test -n "$last_robj"; then | |
9976 | eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" | |
9977 | fi | |
6f57a957 | 9978 | } |
db137867 | 9979 | |
7083c021 AC |
9980 | test -n "$save_libobjs" && |
9981 | func_verbose "creating a temporary reloadable object file: $output" | |
db137867 | 9982 | |
7083c021 | 9983 | # Loop through the commands generated above and execute them. |
6f57a957 | 9984 | save_ifs=$IFS; IFS='~' |
7083c021 | 9985 | for cmd in $concat_cmds; do |
6f57a957 AC |
9986 | IFS=$save_ifs |
9987 | $opt_quiet || { | |
7083c021 AC |
9988 | func_quote_for_expand "$cmd" |
9989 | eval "func_echo $func_quote_for_expand_result" | |
9990 | } | |
9991 | $opt_dry_run || eval "$cmd" || { | |
9992 | lt_exit=$? | |
9993 | ||
9994 | # Restore the uninstalled library and exit | |
6f57a957 | 9995 | if test relink = "$opt_mode"; then |
7083c021 AC |
9996 | ( cd "$output_objdir" && \ |
9997 | $RM "${realname}T" && \ | |
9998 | $MV "${realname}U" "$realname" ) | |
9999 | fi | |
db137867 | 10000 | |
7083c021 AC |
10001 | exit $lt_exit |
10002 | } | |
10003 | done | |
6f57a957 | 10004 | IFS=$save_ifs |
db137867 | 10005 | |
7083c021 AC |
10006 | if test -n "$export_symbols_regex" && ${skipped_export-false}; then |
10007 | func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' | |
10008 | func_show_eval '$MV "${export_symbols}T" "$export_symbols"' | |
db137867 | 10009 | fi |
db137867 | 10010 | fi |
db137867 | 10011 | |
6f57a957 | 10012 | ${skipped_export-false} && { |
7083c021 | 10013 | if test -n "$export_symbols" && test -n "$include_expsyms"; then |
6f57a957 AC |
10014 | tmp_export_symbols=$export_symbols |
10015 | test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols | |
08d019eb | 10016 | $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' |
7083c021 | 10017 | fi |
db137867 | 10018 | |
7083c021 AC |
10019 | if test -n "$orig_export_symbols"; then |
10020 | # The given exports_symbols file has to be filtered, so filter it. | |
6f57a957 | 10021 | func_verbose "filter symbol list for '$libname.la' to tag DATA exports" |
7083c021 | 10022 | # FIXME: $output_objdir/$libname.filter potentially contains lots of |
6f57a957 | 10023 | # 's' commands, which not all seds can handle. GNU sed should be fine |
7083c021 AC |
10024 | # though. Also, the filter scales superlinearly with the number of |
10025 | # global variables. join(1) would be nice here, but unfortunately | |
10026 | # isn't a blessed tool. | |
10027 | $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter | |
08d019eb | 10028 | func_append delfiles " $export_symbols $output_objdir/$libname.filter" |
7083c021 AC |
10029 | export_symbols=$output_objdir/$libname.def |
10030 | $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols | |
10031 | fi | |
6f57a957 | 10032 | } |
db137867 | 10033 | |
7083c021 AC |
10034 | libobjs=$output |
10035 | # Restore the value of output. | |
10036 | output=$save_output | |
db137867 | 10037 | |
7083c021 AC |
10038 | if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then |
10039 | eval libobjs=\"\$libobjs $whole_archive_flag_spec\" | |
10040 | test "X$libobjs" = "X " && libobjs= | |
10041 | fi | |
10042 | # Expand the library linking commands again to reset the | |
10043 | # value of $libobjs for piecewise linking. | |
db137867 | 10044 | |
7083c021 | 10045 | # Do each of the archive commands. |
6f57a957 | 10046 | if test yes = "$module" && test -n "$module_cmds"; then |
7083c021 AC |
10047 | if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then |
10048 | cmds=$module_expsym_cmds | |
10049 | else | |
10050 | cmds=$module_cmds | |
db137867 | 10051 | fi |
db137867 | 10052 | else |
7083c021 AC |
10053 | if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then |
10054 | cmds=$archive_expsym_cmds | |
10055 | else | |
10056 | cmds=$archive_cmds | |
10057 | fi | |
db137867 | 10058 | fi |
7083c021 | 10059 | fi |
db137867 | 10060 | |
7083c021 AC |
10061 | if test -n "$delfiles"; then |
10062 | # Append the command to remove temporary files to $cmds. | |
10063 | eval cmds=\"\$cmds~\$RM $delfiles\" | |
10064 | fi | |
db137867 | 10065 | |
7083c021 AC |
10066 | # Add any objects from preloaded convenience libraries |
10067 | if test -n "$dlprefiles"; then | |
6f57a957 | 10068 | gentop=$output_objdir/${outputname}x |
08d019eb | 10069 | func_append generated " $gentop" |
db137867 | 10070 | |
7083c021 | 10071 | func_extract_archives $gentop $dlprefiles |
08d019eb | 10072 | func_append libobjs " $func_extract_archives_result" |
7083c021 AC |
10073 | test "X$libobjs" = "X " && libobjs= |
10074 | fi | |
db137867 | 10075 | |
6f57a957 | 10076 | save_ifs=$IFS; IFS='~' |
7083c021 | 10077 | for cmd in $cmds; do |
6f57a957 | 10078 | IFS=$sp$nl |
7083c021 | 10079 | eval cmd=\"$cmd\" |
6f57a957 AC |
10080 | IFS=$save_ifs |
10081 | $opt_quiet || { | |
7083c021 AC |
10082 | func_quote_for_expand "$cmd" |
10083 | eval "func_echo $func_quote_for_expand_result" | |
10084 | } | |
10085 | $opt_dry_run || eval "$cmd" || { | |
10086 | lt_exit=$? | |
db137867 | 10087 | |
7083c021 | 10088 | # Restore the uninstalled library and exit |
6f57a957 | 10089 | if test relink = "$opt_mode"; then |
7083c021 AC |
10090 | ( cd "$output_objdir" && \ |
10091 | $RM "${realname}T" && \ | |
10092 | $MV "${realname}U" "$realname" ) | |
10093 | fi | |
db137867 | 10094 | |
7083c021 AC |
10095 | exit $lt_exit |
10096 | } | |
10097 | done | |
6f57a957 | 10098 | IFS=$save_ifs |
db137867 | 10099 | |
7083c021 | 10100 | # Restore the uninstalled library and exit |
6f57a957 | 10101 | if test relink = "$opt_mode"; then |
7083c021 | 10102 | $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? |
db137867 | 10103 | |
7083c021 AC |
10104 | if test -n "$convenience"; then |
10105 | if test -z "$whole_archive_flag_spec"; then | |
10106 | func_show_eval '${RM}r "$gentop"' | |
10107 | fi | |
10108 | fi | |
db137867 | 10109 | |
7083c021 AC |
10110 | exit $EXIT_SUCCESS |
10111 | fi | |
10112 | ||
10113 | # Create links to the real library. | |
10114 | for linkname in $linknames; do | |
10115 | if test "$realname" != "$linkname"; then | |
10116 | func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' | |
db137867 AC |
10117 | fi |
10118 | done | |
db137867 | 10119 | |
7083c021 | 10120 | # If -module or -export-dynamic was specified, set the dlname. |
6f57a957 | 10121 | if test yes = "$module" || test yes = "$export_dynamic"; then |
7083c021 | 10122 | # On all known operating systems, these are identical. |
6f57a957 | 10123 | dlname=$soname |
7083c021 AC |
10124 | fi |
10125 | fi | |
db137867 | 10126 | ;; |
db137867 | 10127 | |
7083c021 | 10128 | obj) |
6f57a957 AC |
10129 | if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then |
10130 | func_warning "'-dlopen' is ignored for objects" | |
7083c021 | 10131 | fi |
db137867 | 10132 | |
7083c021 AC |
10133 | case " $deplibs" in |
10134 | *\ -l* | *\ -L*) | |
6f57a957 | 10135 | func_warning "'-l' and '-L' are ignored for objects" ;; |
db137867 | 10136 | esac |
db137867 | 10137 | |
7083c021 | 10138 | test -n "$rpath" && \ |
6f57a957 | 10139 | func_warning "'-rpath' is ignored for objects" |
7083c021 AC |
10140 | |
10141 | test -n "$xrpath" && \ | |
6f57a957 | 10142 | func_warning "'-R' is ignored for objects" |
db137867 | 10143 | |
7083c021 | 10144 | test -n "$vinfo" && \ |
6f57a957 | 10145 | func_warning "'-version-info' is ignored for objects" |
db137867 | 10146 | |
7083c021 | 10147 | test -n "$release" && \ |
6f57a957 | 10148 | func_warning "'-release' is ignored for objects" |
7083c021 AC |
10149 | |
10150 | case $output in | |
10151 | *.lo) | |
10152 | test -n "$objs$old_deplibs" && \ | |
6f57a957 | 10153 | func_fatal_error "cannot build library object '$output' from non-libtool objects" |
7083c021 AC |
10154 | |
10155 | libobj=$output | |
10156 | func_lo2o "$libobj" | |
10157 | obj=$func_lo2o_result | |
db137867 AC |
10158 | ;; |
10159 | *) | |
7083c021 | 10160 | libobj= |
6f57a957 | 10161 | obj=$output |
db137867 AC |
10162 | ;; |
10163 | esac | |
10164 | ||
7083c021 AC |
10165 | # Delete the old objects. |
10166 | $opt_dry_run || $RM $obj $libobj | |
db137867 | 10167 | |
7083c021 AC |
10168 | # Objects from convenience libraries. This assumes |
10169 | # single-version convenience libraries. Whenever we create | |
10170 | # different ones for PIC/non-PIC, this we'll have to duplicate | |
10171 | # the extraction. | |
10172 | reload_conv_objs= | |
10173 | gentop= | |
6f57a957 AC |
10174 | # if reload_cmds runs $LD directly, get rid of -Wl from |
10175 | # whole_archive_flag_spec and hope we can get by with turning comma | |
10176 | # into space. | |
10177 | case $reload_cmds in | |
10178 | *\$LD[\ \$]*) wl= ;; | |
10179 | esac | |
7083c021 AC |
10180 | if test -n "$convenience"; then |
10181 | if test -n "$whole_archive_flag_spec"; then | |
10182 | eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" | |
6f57a957 AC |
10183 | test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` |
10184 | reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags | |
7083c021 | 10185 | else |
6f57a957 | 10186 | gentop=$output_objdir/${obj}x |
08d019eb | 10187 | func_append generated " $gentop" |
db137867 | 10188 | |
7083c021 AC |
10189 | func_extract_archives $gentop $convenience |
10190 | reload_conv_objs="$reload_objs $func_extract_archives_result" | |
10191 | fi | |
db137867 | 10192 | fi |
db137867 | 10193 | |
08d019eb | 10194 | # If we're not building shared, we need to use non_pic_objs |
6f57a957 | 10195 | test yes = "$build_libtool_libs" || libobjs=$non_pic_objects |
08d019eb | 10196 | |
7083c021 | 10197 | # Create the old-style object. |
6f57a957 | 10198 | reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs |
db137867 | 10199 | |
6f57a957 | 10200 | output=$obj |
7083c021 | 10201 | func_execute_cmds "$reload_cmds" 'exit $?' |
db137867 | 10202 | |
7083c021 AC |
10203 | # Exit if we aren't doing a library object file. |
10204 | if test -z "$libobj"; then | |
10205 | if test -n "$gentop"; then | |
10206 | func_show_eval '${RM}r "$gentop"' | |
10207 | fi | |
10208 | ||
10209 | exit $EXIT_SUCCESS | |
db137867 | 10210 | fi |
7083c021 | 10211 | |
6f57a957 | 10212 | test yes = "$build_libtool_libs" || { |
7083c021 AC |
10213 | if test -n "$gentop"; then |
10214 | func_show_eval '${RM}r "$gentop"' | |
10215 | fi | |
10216 | ||
10217 | # Create an invalid libtool object if no PIC, so that we don't | |
10218 | # accidentally link it into a program. | |
10219 | # $show "echo timestamp > $libobj" | |
10220 | # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? | |
10221 | exit $EXIT_SUCCESS | |
6f57a957 | 10222 | } |
7083c021 | 10223 | |
6f57a957 | 10224 | if test -n "$pic_flag" || test default != "$pic_mode"; then |
7083c021 AC |
10225 | # Only do commands if we really have different PIC objects. |
10226 | reload_objs="$libobjs $reload_conv_objs" | |
6f57a957 | 10227 | output=$libobj |
7083c021 AC |
10228 | func_execute_cmds "$reload_cmds" 'exit $?' |
10229 | fi | |
10230 | ||
10231 | if test -n "$gentop"; then | |
10232 | func_show_eval '${RM}r "$gentop"' | |
10233 | fi | |
10234 | ||
10235 | exit $EXIT_SUCCESS | |
db137867 | 10236 | ;; |
db137867 | 10237 | |
7083c021 AC |
10238 | prog) |
10239 | case $host in | |
10240 | *cygwin*) func_stripname '' '.exe' "$output" | |
10241 | output=$func_stripname_result.exe;; | |
10242 | esac | |
10243 | test -n "$vinfo" && \ | |
6f57a957 | 10244 | func_warning "'-version-info' is ignored for programs" |
db137867 | 10245 | |
7083c021 | 10246 | test -n "$release" && \ |
6f57a957 | 10247 | func_warning "'-release' is ignored for programs" |
db137867 | 10248 | |
6f57a957 AC |
10249 | $preload \ |
10250 | && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ | |
10251 | && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." | |
7083c021 AC |
10252 | |
10253 | case $host in | |
10254 | *-*-rhapsody* | *-*-darwin1.[012]) | |
10255 | # On Rhapsody replace the C library is the System framework | |
08d019eb AC |
10256 | compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` |
10257 | finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` | |
db137867 | 10258 | ;; |
7083c021 | 10259 | esac |
db137867 | 10260 | |
7083c021 AC |
10261 | case $host in |
10262 | *-*-darwin*) | |
10263 | # Don't allow lazy linking, it breaks C++ global constructors | |
10264 | # But is supposedly fixed on 10.4 or later (yay!). | |
6f57a957 | 10265 | if test CXX = "$tagname"; then |
7083c021 AC |
10266 | case ${MACOSX_DEPLOYMENT_TARGET-10.0} in |
10267 | 10.[0123]) | |
6f57a957 AC |
10268 | func_append compile_command " $wl-bind_at_load" |
10269 | func_append finalize_command " $wl-bind_at_load" | |
7083c021 AC |
10270 | ;; |
10271 | esac | |
db137867 | 10272 | fi |
7083c021 | 10273 | # Time to change all our "foo.ltframework" stuff back to "-framework foo" |
08d019eb AC |
10274 | compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` |
10275 | finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
7083c021 AC |
10276 | ;; |
10277 | esac | |
db137867 | 10278 | |
db137867 | 10279 | |
7083c021 AC |
10280 | # move library search paths that coincide with paths to not yet |
10281 | # installed libraries to the beginning of the library search list | |
10282 | new_libs= | |
10283 | for path in $notinst_path; do | |
10284 | case " $new_libs " in | |
10285 | *" -L$path/$objdir "*) ;; | |
10286 | *) | |
10287 | case " $compile_deplibs " in | |
10288 | *" -L$path/$objdir "*) | |
08d019eb | 10289 | func_append new_libs " -L$path/$objdir" ;; |
db137867 | 10290 | esac |
7083c021 AC |
10291 | ;; |
10292 | esac | |
10293 | done | |
10294 | for deplib in $compile_deplibs; do | |
10295 | case $deplib in | |
10296 | -L*) | |
10297 | case " $new_libs " in | |
10298 | *" $deplib "*) ;; | |
08d019eb | 10299 | *) func_append new_libs " $deplib" ;; |
db137867 | 10300 | esac |
7083c021 | 10301 | ;; |
08d019eb | 10302 | *) func_append new_libs " $deplib" ;; |
7083c021 AC |
10303 | esac |
10304 | done | |
6f57a957 | 10305 | compile_deplibs=$new_libs |
db137867 | 10306 | |
db137867 | 10307 | |
08d019eb AC |
10308 | func_append compile_command " $compile_deplibs" |
10309 | func_append finalize_command " $finalize_deplibs" | |
db137867 | 10310 | |
7083c021 AC |
10311 | if test -n "$rpath$xrpath"; then |
10312 | # If the user specified any rpath flags, then add them. | |
10313 | for libdir in $rpath $xrpath; do | |
10314 | # This is the magic to use -rpath. | |
10315 | case "$finalize_rpath " in | |
10316 | *" $libdir "*) ;; | |
08d019eb | 10317 | *) func_append finalize_rpath " $libdir" ;; |
7083c021 AC |
10318 | esac |
10319 | done | |
10320 | fi | |
db137867 | 10321 | |
7083c021 AC |
10322 | # Now hardcode the library paths |
10323 | rpath= | |
10324 | hardcode_libdirs= | |
10325 | for libdir in $compile_rpath $finalize_rpath; do | |
10326 | if test -n "$hardcode_libdir_flag_spec"; then | |
10327 | if test -n "$hardcode_libdir_separator"; then | |
10328 | if test -z "$hardcode_libdirs"; then | |
6f57a957 | 10329 | hardcode_libdirs=$libdir |
7083c021 AC |
10330 | else |
10331 | # Just accumulate the unique libdirs. | |
10332 | case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in | |
10333 | *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) | |
10334 | ;; | |
10335 | *) | |
08d019eb | 10336 | func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" |
7083c021 AC |
10337 | ;; |
10338 | esac | |
10339 | fi | |
db137867 | 10340 | else |
7083c021 | 10341 | eval flag=\"$hardcode_libdir_flag_spec\" |
08d019eb | 10342 | func_append rpath " $flag" |
db137867 | 10343 | fi |
7083c021 AC |
10344 | elif test -n "$runpath_var"; then |
10345 | case "$perm_rpath " in | |
10346 | *" $libdir "*) ;; | |
08d019eb | 10347 | *) func_append perm_rpath " $libdir" ;; |
7083c021 AC |
10348 | esac |
10349 | fi | |
10350 | case $host in | |
10351 | *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) | |
6f57a957 | 10352 | testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` |
7083c021 AC |
10353 | case :$dllsearchpath: in |
10354 | *":$libdir:"*) ;; | |
10355 | ::) dllsearchpath=$libdir;; | |
08d019eb | 10356 | *) func_append dllsearchpath ":$libdir";; |
7083c021 AC |
10357 | esac |
10358 | case :$dllsearchpath: in | |
10359 | *":$testbindir:"*) ;; | |
10360 | ::) dllsearchpath=$testbindir;; | |
08d019eb | 10361 | *) func_append dllsearchpath ":$testbindir";; |
7083c021 AC |
10362 | esac |
10363 | ;; | |
10364 | esac | |
10365 | done | |
10366 | # Substitute the hardcoded libdirs into the rpath. | |
10367 | if test -n "$hardcode_libdir_separator" && | |
10368 | test -n "$hardcode_libdirs"; then | |
6f57a957 | 10369 | libdir=$hardcode_libdirs |
7083c021 AC |
10370 | eval rpath=\" $hardcode_libdir_flag_spec\" |
10371 | fi | |
6f57a957 | 10372 | compile_rpath=$rpath |
db137867 | 10373 | |
7083c021 AC |
10374 | rpath= |
10375 | hardcode_libdirs= | |
10376 | for libdir in $finalize_rpath; do | |
10377 | if test -n "$hardcode_libdir_flag_spec"; then | |
10378 | if test -n "$hardcode_libdir_separator"; then | |
10379 | if test -z "$hardcode_libdirs"; then | |
6f57a957 | 10380 | hardcode_libdirs=$libdir |
7083c021 AC |
10381 | else |
10382 | # Just accumulate the unique libdirs. | |
10383 | case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in | |
10384 | *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) | |
10385 | ;; | |
10386 | *) | |
08d019eb | 10387 | func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" |
7083c021 AC |
10388 | ;; |
10389 | esac | |
10390 | fi | |
db137867 | 10391 | else |
7083c021 | 10392 | eval flag=\"$hardcode_libdir_flag_spec\" |
08d019eb | 10393 | func_append rpath " $flag" |
db137867 | 10394 | fi |
7083c021 AC |
10395 | elif test -n "$runpath_var"; then |
10396 | case "$finalize_perm_rpath " in | |
10397 | *" $libdir "*) ;; | |
08d019eb | 10398 | *) func_append finalize_perm_rpath " $libdir" ;; |
7083c021 | 10399 | esac |
db137867 | 10400 | fi |
7083c021 AC |
10401 | done |
10402 | # Substitute the hardcoded libdirs into the rpath. | |
10403 | if test -n "$hardcode_libdir_separator" && | |
10404 | test -n "$hardcode_libdirs"; then | |
6f57a957 | 10405 | libdir=$hardcode_libdirs |
7083c021 AC |
10406 | eval rpath=\" $hardcode_libdir_flag_spec\" |
10407 | fi | |
6f57a957 | 10408 | finalize_rpath=$rpath |
db137867 | 10409 | |
6f57a957 | 10410 | if test -n "$libobjs" && test yes = "$build_old_libs"; then |
7083c021 | 10411 | # Transform all the library objects into standard objects. |
08d019eb AC |
10412 | compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` |
10413 | finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` | |
7083c021 | 10414 | fi |
db137867 | 10415 | |
6f57a957 | 10416 | func_generate_dlsyms "$outputname" "@PROGRAM@" false |
db137867 | 10417 | |
7083c021 AC |
10418 | # template prelinking step |
10419 | if test -n "$prelink_cmds"; then | |
10420 | func_execute_cmds "$prelink_cmds" 'exit $?' | |
10421 | fi | |
db137867 | 10422 | |
6f57a957 | 10423 | wrappers_required=: |
7083c021 | 10424 | case $host in |
08d019eb AC |
10425 | *cegcc* | *mingw32ce*) |
10426 | # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. | |
6f57a957 | 10427 | wrappers_required=false |
08d019eb | 10428 | ;; |
7083c021 | 10429 | *cygwin* | *mingw* ) |
6f57a957 | 10430 | test yes = "$build_libtool_libs" || wrappers_required=false |
7083c021 | 10431 | ;; |
7083c021 | 10432 | *) |
6f57a957 AC |
10433 | if test no = "$need_relink" || test yes != "$build_libtool_libs"; then |
10434 | wrappers_required=false | |
7083c021 AC |
10435 | fi |
10436 | ;; | |
10437 | esac | |
6f57a957 | 10438 | $wrappers_required || { |
7083c021 | 10439 | # Replace the output file specification. |
08d019eb | 10440 | compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` |
6f57a957 | 10441 | link_command=$compile_command$compile_rpath |
db137867 | 10442 | |
7083c021 AC |
10443 | # We have no uninstalled library dependencies, so finalize right now. |
10444 | exit_status=0 | |
10445 | func_show_eval "$link_command" 'exit_status=$?' | |
db137867 | 10446 | |
08d019eb AC |
10447 | if test -n "$postlink_cmds"; then |
10448 | func_to_tool_file "$output" | |
10449 | postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` | |
10450 | func_execute_cmds "$postlink_cmds" 'exit $?' | |
10451 | fi | |
10452 | ||
7083c021 | 10453 | # Delete the generated files. |
6f57a957 AC |
10454 | if test -f "$output_objdir/${outputname}S.$objext"; then |
10455 | func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' | |
db137867 AC |
10456 | fi |
10457 | ||
7083c021 | 10458 | exit $exit_status |
6f57a957 | 10459 | } |
db137867 | 10460 | |
7083c021 AC |
10461 | if test -n "$compile_shlibpath$finalize_shlibpath"; then |
10462 | compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" | |
10463 | fi | |
10464 | if test -n "$finalize_shlibpath"; then | |
10465 | finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" | |
10466 | fi | |
db137867 | 10467 | |
7083c021 AC |
10468 | compile_var= |
10469 | finalize_var= | |
10470 | if test -n "$runpath_var"; then | |
10471 | if test -n "$perm_rpath"; then | |
10472 | # We should set the runpath_var. | |
10473 | rpath= | |
10474 | for dir in $perm_rpath; do | |
08d019eb | 10475 | func_append rpath "$dir:" |
7083c021 AC |
10476 | done |
10477 | compile_var="$runpath_var=\"$rpath\$$runpath_var\" " | |
db137867 | 10478 | fi |
7083c021 AC |
10479 | if test -n "$finalize_perm_rpath"; then |
10480 | # We should set the runpath_var. | |
10481 | rpath= | |
10482 | for dir in $finalize_perm_rpath; do | |
08d019eb | 10483 | func_append rpath "$dir:" |
7083c021 AC |
10484 | done |
10485 | finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " | |
db137867 | 10486 | fi |
7083c021 | 10487 | fi |
db137867 | 10488 | |
6f57a957 | 10489 | if test yes = "$no_install"; then |
7083c021 | 10490 | # We don't need to create a wrapper script. |
6f57a957 | 10491 | link_command=$compile_var$compile_command$compile_rpath |
7083c021 | 10492 | # Replace the output file specification. |
08d019eb | 10493 | link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` |
7083c021 AC |
10494 | # Delete the old output file. |
10495 | $opt_dry_run || $RM $output | |
10496 | # Link the executable and exit | |
10497 | func_show_eval "$link_command" 'exit $?' | |
08d019eb AC |
10498 | |
10499 | if test -n "$postlink_cmds"; then | |
10500 | func_to_tool_file "$output" | |
10501 | postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` | |
10502 | func_execute_cmds "$postlink_cmds" 'exit $?' | |
10503 | fi | |
10504 | ||
db137867 | 10505 | exit $EXIT_SUCCESS |
7083c021 | 10506 | fi |
db137867 | 10507 | |
6f57a957 AC |
10508 | case $hardcode_action,$fast_install in |
10509 | relink,*) | |
10510 | # Fast installation is not supported | |
10511 | link_command=$compile_var$compile_command$compile_rpath | |
10512 | relink_command=$finalize_var$finalize_command$finalize_rpath | |
7083c021 | 10513 | |
6f57a957 AC |
10514 | func_warning "this platform does not like uninstalled shared libraries" |
10515 | func_warning "'$output' will be relinked during installation" | |
10516 | ;; | |
10517 | *,yes) | |
10518 | link_command=$finalize_var$compile_command$finalize_rpath | |
10519 | relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` | |
10520 | ;; | |
10521 | *,no) | |
10522 | link_command=$compile_var$compile_command$compile_rpath | |
10523 | relink_command=$finalize_var$finalize_command$finalize_rpath | |
10524 | ;; | |
10525 | *,needless) | |
10526 | link_command=$finalize_var$compile_command$finalize_rpath | |
10527 | relink_command= | |
10528 | ;; | |
10529 | esac | |
db137867 | 10530 | |
7083c021 | 10531 | # Replace the output file specification. |
08d019eb | 10532 | link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` |
db137867 | 10533 | |
7083c021 AC |
10534 | # Delete the old output files. |
10535 | $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname | |
db137867 | 10536 | |
7083c021 | 10537 | func_show_eval "$link_command" 'exit $?' |
db137867 | 10538 | |
08d019eb AC |
10539 | if test -n "$postlink_cmds"; then |
10540 | func_to_tool_file "$output_objdir/$outputname" | |
10541 | postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` | |
10542 | func_execute_cmds "$postlink_cmds" 'exit $?' | |
10543 | fi | |
10544 | ||
7083c021 AC |
10545 | # Now create the wrapper script. |
10546 | func_verbose "creating $output" | |
db137867 | 10547 | |
7083c021 AC |
10548 | # Quote the relink command for shipping. |
10549 | if test -n "$relink_command"; then | |
10550 | # Preserve any variables that may affect compiler behavior | |
10551 | for var in $variables_saved_for_relink; do | |
10552 | if eval test -z \"\${$var+set}\"; then | |
10553 | relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" | |
10554 | elif eval var_value=\$$var; test -z "$var_value"; then | |
10555 | relink_command="$var=; export $var; $relink_command" | |
db137867 | 10556 | else |
7083c021 AC |
10557 | func_quote_for_eval "$var_value" |
10558 | relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" | |
db137867 | 10559 | fi |
7083c021 | 10560 | done |
fe037171 EM |
10561 | func_quote "(cd `pwd`; $relink_command)" |
10562 | relink_command=$func_quote_result | |
7083c021 AC |
10563 | fi |
10564 | ||
10565 | # Only actually do things if not in dry run mode. | |
10566 | $opt_dry_run || { | |
10567 | # win32 will think the script is a binary if it has | |
10568 | # a .exe suffix, so we strip it off here. | |
10569 | case $output in | |
10570 | *.exe) func_stripname '' '.exe' "$output" | |
10571 | output=$func_stripname_result ;; | |
10572 | esac | |
10573 | # test for cygwin because mv fails w/o .exe extensions | |
10574 | case $host in | |
10575 | *cygwin*) | |
10576 | exeext=.exe | |
10577 | func_stripname '' '.exe' "$outputname" | |
10578 | outputname=$func_stripname_result ;; | |
10579 | *) exeext= ;; | |
db137867 | 10580 | esac |
7083c021 AC |
10581 | case $host in |
10582 | *cygwin* | *mingw* ) | |
10583 | func_dirname_and_basename "$output" "" "." | |
10584 | output_name=$func_basename_result | |
10585 | output_path=$func_dirname_result | |
6f57a957 AC |
10586 | cwrappersource=$output_path/$objdir/lt-$output_name.c |
10587 | cwrapper=$output_path/$output_name.exe | |
7083c021 AC |
10588 | $RM $cwrappersource $cwrapper |
10589 | trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 | |
10590 | ||
10591 | func_emit_cwrapperexe_src > $cwrappersource | |
10592 | ||
10593 | # The wrapper executable is built using the $host compiler, | |
10594 | # because it contains $host paths and files. If cross- | |
10595 | # compiling, it, like the target executable, must be | |
10596 | # executed on the $host or under an emulation environment. | |
10597 | $opt_dry_run || { | |
10598 | $LTCC $LTCFLAGS -o $cwrapper $cwrappersource | |
10599 | $STRIP $cwrapper | |
10600 | } | |
db137867 | 10601 | |
7083c021 AC |
10602 | # Now, create the wrapper script for func_source use: |
10603 | func_ltwrapper_scriptname $cwrapper | |
10604 | $RM $func_ltwrapper_scriptname_result | |
10605 | trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 | |
10606 | $opt_dry_run || { | |
10607 | # note: this script will not be executed, so do not chmod. | |
6f57a957 | 10608 | if test "x$build" = "x$host"; then |
7083c021 AC |
10609 | $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result |
10610 | else | |
10611 | func_emit_wrapper no > $func_ltwrapper_scriptname_result | |
10612 | fi | |
10613 | } | |
10614 | ;; | |
10615 | * ) | |
10616 | $RM $output | |
10617 | trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 | |
db137867 | 10618 | |
7083c021 AC |
10619 | func_emit_wrapper no > $output |
10620 | chmod +x $output | |
10621 | ;; | |
10622 | esac | |
10623 | } | |
10624 | exit $EXIT_SUCCESS | |
10625 | ;; | |
10626 | esac | |
db137867 | 10627 | |
7083c021 AC |
10628 | # See if we need to build an old-fashioned archive. |
10629 | for oldlib in $oldlibs; do | |
db137867 | 10630 | |
6f57a957 AC |
10631 | case $build_libtool_libs in |
10632 | convenience) | |
10633 | oldobjs="$libobjs_save $symfileobj" | |
10634 | addlibs=$convenience | |
7083c021 | 10635 | build_libtool_libs=no |
6f57a957 AC |
10636 | ;; |
10637 | module) | |
10638 | oldobjs=$libobjs_save | |
10639 | addlibs=$old_convenience | |
10640 | build_libtool_libs=no | |
10641 | ;; | |
10642 | *) | |
7083c021 | 10643 | oldobjs="$old_deplibs $non_pic_objects" |
6f57a957 AC |
10644 | $preload && test -f "$symfileobj" \ |
10645 | && func_append oldobjs " $symfileobj" | |
10646 | addlibs=$old_convenience | |
10647 | ;; | |
10648 | esac | |
db137867 | 10649 | |
7083c021 | 10650 | if test -n "$addlibs"; then |
6f57a957 | 10651 | gentop=$output_objdir/${outputname}x |
08d019eb | 10652 | func_append generated " $gentop" |
db137867 | 10653 | |
7083c021 | 10654 | func_extract_archives $gentop $addlibs |
08d019eb | 10655 | func_append oldobjs " $func_extract_archives_result" |
7083c021 | 10656 | fi |
db137867 | 10657 | |
7083c021 | 10658 | # Do each command in the archive commands. |
6f57a957 | 10659 | if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then |
7083c021 AC |
10660 | cmds=$old_archive_from_new_cmds |
10661 | else | |
db137867 | 10662 | |
7083c021 AC |
10663 | # Add any objects from preloaded convenience libraries |
10664 | if test -n "$dlprefiles"; then | |
6f57a957 | 10665 | gentop=$output_objdir/${outputname}x |
08d019eb | 10666 | func_append generated " $gentop" |
db137867 | 10667 | |
7083c021 | 10668 | func_extract_archives $gentop $dlprefiles |
08d019eb | 10669 | func_append oldobjs " $func_extract_archives_result" |
7083c021 | 10670 | fi |
db137867 | 10671 | |
7083c021 AC |
10672 | # POSIX demands no paths to be encoded in archives. We have |
10673 | # to avoid creating archives with duplicate basenames if we | |
10674 | # might have to extract them afterwards, e.g., when creating a | |
10675 | # static archive out of a convenience library, or when linking | |
10676 | # the entirety of a libtool archive into another (currently | |
10677 | # not supported by libtool). | |
10678 | if (for obj in $oldobjs | |
10679 | do | |
10680 | func_basename "$obj" | |
10681 | $ECHO "$func_basename_result" | |
10682 | done | sort | sort -uc >/dev/null 2>&1); then | |
10683 | : | |
10684 | else | |
08d019eb | 10685 | echo "copying selected object files to avoid basename conflicts..." |
6f57a957 | 10686 | gentop=$output_objdir/${outputname}x |
08d019eb | 10687 | func_append generated " $gentop" |
7083c021 AC |
10688 | func_mkdir_p "$gentop" |
10689 | save_oldobjs=$oldobjs | |
10690 | oldobjs= | |
10691 | counter=1 | |
10692 | for obj in $save_oldobjs | |
10693 | do | |
10694 | func_basename "$obj" | |
6f57a957 | 10695 | objbase=$func_basename_result |
7083c021 AC |
10696 | case " $oldobjs " in |
10697 | " ") oldobjs=$obj ;; | |
10698 | *[\ /]"$objbase "*) | |
10699 | while :; do | |
10700 | # Make sure we don't pick an alternate name that also | |
10701 | # overlaps. | |
10702 | newobj=lt$counter-$objbase | |
10703 | func_arith $counter + 1 | |
10704 | counter=$func_arith_result | |
10705 | case " $oldobjs " in | |
10706 | *[\ /]"$newobj "*) ;; | |
10707 | *) if test ! -f "$gentop/$newobj"; then break; fi ;; | |
10708 | esac | |
10709 | done | |
10710 | func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" | |
08d019eb | 10711 | func_append oldobjs " $gentop/$newobj" |
7083c021 | 10712 | ;; |
08d019eb | 10713 | *) func_append oldobjs " $obj" ;; |
7083c021 | 10714 | esac |
db137867 | 10715 | done |
db137867 | 10716 | fi |
54bec06e AC |
10717 | func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 |
10718 | tool_oldlib=$func_to_tool_file_result | |
7083c021 | 10719 | eval cmds=\"$old_archive_cmds\" |
db137867 | 10720 | |
7083c021 AC |
10721 | func_len " $cmds" |
10722 | len=$func_len_result | |
10723 | if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then | |
10724 | cmds=$old_archive_cmds | |
08d019eb AC |
10725 | elif test -n "$archiver_list_spec"; then |
10726 | func_verbose "using command file archive linking..." | |
10727 | for obj in $oldobjs | |
10728 | do | |
10729 | func_to_tool_file "$obj" | |
10730 | $ECHO "$func_to_tool_file_result" | |
10731 | done > $output_objdir/$libname.libcmd | |
10732 | func_to_tool_file "$output_objdir/$libname.libcmd" | |
10733 | oldobjs=" $archiver_list_spec$func_to_tool_file_result" | |
10734 | cmds=$old_archive_cmds | |
7083c021 AC |
10735 | else |
10736 | # the command line is too long to link in one step, link in parts | |
10737 | func_verbose "using piecewise archive linking..." | |
10738 | save_RANLIB=$RANLIB | |
10739 | RANLIB=: | |
10740 | objlist= | |
10741 | concat_cmds= | |
10742 | save_oldobjs=$oldobjs | |
10743 | oldobjs= | |
10744 | # Is there a better way of finding the last object in the list? | |
10745 | for obj in $save_oldobjs | |
10746 | do | |
10747 | last_oldobj=$obj | |
10748 | done | |
10749 | eval test_cmds=\"$old_archive_cmds\" | |
10750 | func_len " $test_cmds" | |
10751 | len0=$func_len_result | |
10752 | len=$len0 | |
10753 | for obj in $save_oldobjs | |
10754 | do | |
10755 | func_len " $obj" | |
10756 | func_arith $len + $func_len_result | |
10757 | len=$func_arith_result | |
10758 | func_append objlist " $obj" | |
10759 | if test "$len" -lt "$max_cmd_len"; then | |
10760 | : | |
10761 | else | |
10762 | # the above command should be used before it gets too long | |
10763 | oldobjs=$objlist | |
6f57a957 | 10764 | if test "$obj" = "$last_oldobj"; then |
7083c021 AC |
10765 | RANLIB=$save_RANLIB |
10766 | fi | |
10767 | test -z "$concat_cmds" || concat_cmds=$concat_cmds~ | |
6f57a957 | 10768 | eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" |
7083c021 AC |
10769 | objlist= |
10770 | len=$len0 | |
10771 | fi | |
10772 | done | |
10773 | RANLIB=$save_RANLIB | |
10774 | oldobjs=$objlist | |
6f57a957 | 10775 | if test -z "$oldobjs"; then |
7083c021 AC |
10776 | eval cmds=\"\$concat_cmds\" |
10777 | else | |
10778 | eval cmds=\"\$concat_cmds~\$old_archive_cmds\" | |
10779 | fi | |
10780 | fi | |
10781 | fi | |
10782 | func_execute_cmds "$cmds" 'exit $?' | |
db137867 | 10783 | done |
db137867 | 10784 | |
7083c021 AC |
10785 | test -n "$generated" && \ |
10786 | func_show_eval "${RM}r$generated" | |
db137867 | 10787 | |
7083c021 AC |
10788 | # Now create the libtool archive. |
10789 | case $output in | |
10790 | *.la) | |
10791 | old_library= | |
6f57a957 | 10792 | test yes = "$build_old_libs" && old_library=$libname.$libext |
7083c021 | 10793 | func_verbose "creating $output" |
db137867 | 10794 | |
7083c021 AC |
10795 | # Preserve any variables that may affect compiler behavior |
10796 | for var in $variables_saved_for_relink; do | |
10797 | if eval test -z \"\${$var+set}\"; then | |
10798 | relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" | |
10799 | elif eval var_value=\$$var; test -z "$var_value"; then | |
10800 | relink_command="$var=; export $var; $relink_command" | |
db137867 | 10801 | else |
7083c021 AC |
10802 | func_quote_for_eval "$var_value" |
10803 | relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" | |
db137867 | 10804 | fi |
7083c021 AC |
10805 | done |
10806 | # Quote the link command for shipping. | |
6f57a957 | 10807 | relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" |
fe037171 EM |
10808 | func_quote "$relink_command" |
10809 | relink_command=$func_quote_result | |
6f57a957 | 10810 | if test yes = "$hardcode_automatic"; then |
7083c021 AC |
10811 | relink_command= |
10812 | fi | |
db137867 | 10813 | |
7083c021 AC |
10814 | # Only create the output if not a dry run. |
10815 | $opt_dry_run || { | |
10816 | for installed in no yes; do | |
6f57a957 | 10817 | if test yes = "$installed"; then |
7083c021 AC |
10818 | if test -z "$install_libdir"; then |
10819 | break | |
10820 | fi | |
6f57a957 | 10821 | output=$output_objdir/${outputname}i |
7083c021 AC |
10822 | # Replace all uninstalled libtool libraries with the installed ones |
10823 | newdependency_libs= | |
10824 | for deplib in $dependency_libs; do | |
10825 | case $deplib in | |
10826 | *.la) | |
10827 | func_basename "$deplib" | |
6f57a957 | 10828 | name=$func_basename_result |
54bec06e | 10829 | func_resolve_sysroot "$deplib" |
6f57a957 | 10830 | eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` |
7083c021 | 10831 | test -z "$libdir" && \ |
6f57a957 | 10832 | func_fatal_error "'$deplib' is not a valid libtool archive" |
08d019eb AC |
10833 | func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" |
10834 | ;; | |
10835 | -L*) | |
10836 | func_stripname -L '' "$deplib" | |
10837 | func_replace_sysroot "$func_stripname_result" | |
10838 | func_append newdependency_libs " -L$func_replace_sysroot_result" | |
7083c021 | 10839 | ;; |
08d019eb AC |
10840 | -R*) |
10841 | func_stripname -R '' "$deplib" | |
10842 | func_replace_sysroot "$func_stripname_result" | |
10843 | func_append newdependency_libs " -R$func_replace_sysroot_result" | |
10844 | ;; | |
10845 | *) func_append newdependency_libs " $deplib" ;; | |
7083c021 AC |
10846 | esac |
10847 | done | |
6f57a957 | 10848 | dependency_libs=$newdependency_libs |
7083c021 AC |
10849 | newdlfiles= |
10850 | ||
10851 | for lib in $dlfiles; do | |
10852 | case $lib in | |
10853 | *.la) | |
10854 | func_basename "$lib" | |
6f57a957 AC |
10855 | name=$func_basename_result |
10856 | eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` | |
7083c021 | 10857 | test -z "$libdir" && \ |
6f57a957 | 10858 | func_fatal_error "'$lib' is not a valid libtool archive" |
08d019eb | 10859 | func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" |
7083c021 | 10860 | ;; |
08d019eb | 10861 | *) func_append newdlfiles " $lib" ;; |
7083c021 AC |
10862 | esac |
10863 | done | |
6f57a957 | 10864 | dlfiles=$newdlfiles |
7083c021 AC |
10865 | newdlprefiles= |
10866 | for lib in $dlprefiles; do | |
10867 | case $lib in | |
10868 | *.la) | |
10869 | # Only pass preopened files to the pseudo-archive (for | |
10870 | # eventual linking with the app. that links it) if we | |
10871 | # didn't already link the preopened objects directly into | |
10872 | # the library: | |
10873 | func_basename "$lib" | |
6f57a957 AC |
10874 | name=$func_basename_result |
10875 | eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` | |
7083c021 | 10876 | test -z "$libdir" && \ |
6f57a957 | 10877 | func_fatal_error "'$lib' is not a valid libtool archive" |
08d019eb | 10878 | func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" |
7083c021 AC |
10879 | ;; |
10880 | esac | |
10881 | done | |
6f57a957 | 10882 | dlprefiles=$newdlprefiles |
7083c021 AC |
10883 | else |
10884 | newdlfiles= | |
10885 | for lib in $dlfiles; do | |
10886 | case $lib in | |
6f57a957 | 10887 | [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; |
7083c021 AC |
10888 | *) abs=`pwd`"/$lib" ;; |
10889 | esac | |
08d019eb | 10890 | func_append newdlfiles " $abs" |
7083c021 | 10891 | done |
6f57a957 | 10892 | dlfiles=$newdlfiles |
7083c021 AC |
10893 | newdlprefiles= |
10894 | for lib in $dlprefiles; do | |
10895 | case $lib in | |
6f57a957 | 10896 | [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; |
7083c021 AC |
10897 | *) abs=`pwd`"/$lib" ;; |
10898 | esac | |
08d019eb | 10899 | func_append newdlprefiles " $abs" |
7083c021 | 10900 | done |
6f57a957 | 10901 | dlprefiles=$newdlprefiles |
7083c021 AC |
10902 | fi |
10903 | $RM $output | |
10904 | # place dlname in correct position for cygwin | |
08d019eb AC |
10905 | # In fact, it would be nice if we could use this code for all target |
10906 | # systems that can't hard-code library paths into their executables | |
10907 | # and that have no shared library path variable independent of PATH, | |
10908 | # but it turns out we can't easily determine that from inspecting | |
10909 | # libtool variables, so we have to hard-code the OSs to which it | |
10910 | # applies here; at the moment, that means platforms that use the PE | |
10911 | # object format with DLL files. See the long comment at the top of | |
10912 | # tests/bindir.at for full details. | |
7083c021 AC |
10913 | tdlname=$dlname |
10914 | case $host,$output,$installed,$module,$dlname in | |
08d019eb AC |
10915 | *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) |
10916 | # If a -bindir argument was supplied, place the dll there. | |
6f57a957 | 10917 | if test -n "$bindir"; then |
08d019eb | 10918 | func_relative_path "$install_libdir" "$bindir" |
6f57a957 | 10919 | tdlname=$func_relative_path_result/$dlname |
08d019eb AC |
10920 | else |
10921 | # Otherwise fall back on heuristic. | |
10922 | tdlname=../bin/$dlname | |
10923 | fi | |
10924 | ;; | |
7083c021 AC |
10925 | esac |
10926 | $ECHO > $output "\ | |
10927 | # $outputname - a libtool library file | |
6f57a957 | 10928 | # Generated by $PROGRAM (GNU $PACKAGE) $VERSION |
7083c021 AC |
10929 | # |
10930 | # Please DO NOT delete this file! | |
10931 | # It is necessary for linking the library. | |
db137867 | 10932 | |
7083c021 AC |
10933 | # The name that we can dlopen(3). |
10934 | dlname='$tdlname' | |
db137867 | 10935 | |
7083c021 AC |
10936 | # Names of this library. |
10937 | library_names='$library_names' | |
db137867 | 10938 | |
7083c021 AC |
10939 | # The name of the static archive. |
10940 | old_library='$old_library' | |
db137867 | 10941 | |
6f57a957 | 10942 | # Linker flags that cannot go in dependency_libs. |
7083c021 | 10943 | inherited_linker_flags='$new_inherited_linker_flags' |
db137867 | 10944 | |
7083c021 AC |
10945 | # Libraries that this one depends upon. |
10946 | dependency_libs='$dependency_libs' | |
db137867 | 10947 | |
7083c021 AC |
10948 | # Names of additional weak libraries provided by this library |
10949 | weak_library_names='$weak_libs' | |
db137867 | 10950 | |
7083c021 AC |
10951 | # Version information for $libname. |
10952 | current=$current | |
10953 | age=$age | |
10954 | revision=$revision | |
db137867 | 10955 | |
7083c021 AC |
10956 | # Is this an already installed library? |
10957 | installed=$installed | |
db137867 | 10958 | |
7083c021 AC |
10959 | # Should we warn about portability when linking against -modules? |
10960 | shouldnotlink=$module | |
db137867 | 10961 | |
7083c021 AC |
10962 | # Files to dlopen/dlpreopen |
10963 | dlopen='$dlfiles' | |
10964 | dlpreopen='$dlprefiles' | |
db137867 | 10965 | |
7083c021 AC |
10966 | # Directory that this library needs to be installed in: |
10967 | libdir='$install_libdir'" | |
6f57a957 | 10968 | if test no,yes = "$installed,$need_relink"; then |
7083c021 AC |
10969 | $ECHO >> $output "\ |
10970 | relink_command=\"$relink_command\"" | |
10971 | fi | |
10972 | done | |
10973 | } | |
db137867 | 10974 | |
7083c021 AC |
10975 | # Do a symbolic link so that the libtool archive can be found in |
10976 | # LD_LIBRARY_PATH before the program is installed. | |
10977 | func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' | |
10978 | ;; | |
10979 | esac | |
10980 | exit $EXIT_SUCCESS | |
10981 | } | |
db137867 | 10982 | |
6f57a957 AC |
10983 | if test link = "$opt_mode" || test relink = "$opt_mode"; then |
10984 | func_mode_link ${1+"$@"} | |
10985 | fi | |
db137867 | 10986 | |
db137867 | 10987 | |
7083c021 AC |
10988 | # func_mode_uninstall arg... |
10989 | func_mode_uninstall () | |
10990 | { | |
6f57a957 AC |
10991 | $debug_cmd |
10992 | ||
10993 | RM=$nonopt | |
db137867 | 10994 | files= |
6f57a957 | 10995 | rmforce=false |
db137867 AC |
10996 | exit_status=0 |
10997 | ||
10998 | # This variable tells wrapper scripts just to set variables rather | |
10999 | # than running their programs. | |
6f57a957 | 11000 | libtool_install_magic=$magic |
db137867 AC |
11001 | |
11002 | for arg | |
11003 | do | |
11004 | case $arg in | |
6f57a957 | 11005 | -f) func_append RM " $arg"; rmforce=: ;; |
08d019eb AC |
11006 | -*) func_append RM " $arg" ;; |
11007 | *) func_append files " $arg" ;; | |
db137867 AC |
11008 | esac |
11009 | done | |
11010 | ||
7083c021 AC |
11011 | test -z "$RM" && \ |
11012 | func_fatal_help "you must specify an RM program" | |
db137867 AC |
11013 | |
11014 | rmdirs= | |
11015 | ||
db137867 | 11016 | for file in $files; do |
7083c021 | 11017 | func_dirname "$file" "" "." |
6f57a957 AC |
11018 | dir=$func_dirname_result |
11019 | if test . = "$dir"; then | |
11020 | odir=$objdir | |
db137867 | 11021 | else |
6f57a957 | 11022 | odir=$dir/$objdir |
db137867 | 11023 | fi |
7083c021 | 11024 | func_basename "$file" |
6f57a957 AC |
11025 | name=$func_basename_result |
11026 | test uninstall = "$opt_mode" && odir=$dir | |
db137867 | 11027 | |
08d019eb | 11028 | # Remember odir for removal later, being careful to avoid duplicates |
6f57a957 | 11029 | if test clean = "$opt_mode"; then |
db137867 | 11030 | case " $rmdirs " in |
08d019eb AC |
11031 | *" $odir "*) ;; |
11032 | *) func_append rmdirs " $odir" ;; | |
db137867 AC |
11033 | esac |
11034 | fi | |
11035 | ||
11036 | # Don't error if the file doesn't exist and rm -f was used. | |
7083c021 AC |
11037 | if { test -L "$file"; } >/dev/null 2>&1 || |
11038 | { test -h "$file"; } >/dev/null 2>&1 || | |
11039 | test -f "$file"; then | |
db137867 AC |
11040 | : |
11041 | elif test -d "$file"; then | |
11042 | exit_status=1 | |
11043 | continue | |
6f57a957 | 11044 | elif $rmforce; then |
db137867 AC |
11045 | continue |
11046 | fi | |
11047 | ||
6f57a957 | 11048 | rmfiles=$file |
db137867 AC |
11049 | |
11050 | case $name in | |
11051 | *.la) | |
11052 | # Possibly a libtool archive, so verify it. | |
7083c021 AC |
11053 | if func_lalib_p "$file"; then |
11054 | func_source $dir/$name | |
db137867 AC |
11055 | |
11056 | # Delete the libtool libraries and symlinks. | |
11057 | for n in $library_names; do | |
08d019eb | 11058 | func_append rmfiles " $odir/$n" |
db137867 | 11059 | done |
08d019eb | 11060 | test -n "$old_library" && func_append rmfiles " $odir/$old_library" |
db137867 | 11061 | |
6f57a957 | 11062 | case $opt_mode in |
db137867 | 11063 | clean) |
08d019eb | 11064 | case " $library_names " in |
db137867 | 11065 | *" $dlname "*) ;; |
08d019eb | 11066 | *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; |
db137867 | 11067 | esac |
08d019eb | 11068 | test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" |
db137867 AC |
11069 | ;; |
11070 | uninstall) | |
11071 | if test -n "$library_names"; then | |
11072 | # Do each command in the postuninstall commands. | |
6f57a957 | 11073 | func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' |
db137867 AC |
11074 | fi |
11075 | ||
11076 | if test -n "$old_library"; then | |
11077 | # Do each command in the old_postuninstall commands. | |
6f57a957 | 11078 | func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' |
db137867 AC |
11079 | fi |
11080 | # FIXME: should reinstall the best remaining shared library. | |
11081 | ;; | |
11082 | esac | |
11083 | fi | |
11084 | ;; | |
11085 | ||
11086 | *.lo) | |
11087 | # Possibly a libtool object, so verify it. | |
7083c021 | 11088 | if func_lalib_p "$file"; then |
db137867 AC |
11089 | |
11090 | # Read the .lo file | |
7083c021 | 11091 | func_source $dir/$name |
db137867 AC |
11092 | |
11093 | # Add PIC object to the list of files to remove. | |
6f57a957 | 11094 | if test -n "$pic_object" && test none != "$pic_object"; then |
08d019eb | 11095 | func_append rmfiles " $dir/$pic_object" |
db137867 AC |
11096 | fi |
11097 | ||
11098 | # Add non-PIC object to the list of files to remove. | |
6f57a957 | 11099 | if test -n "$non_pic_object" && test none != "$non_pic_object"; then |
08d019eb | 11100 | func_append rmfiles " $dir/$non_pic_object" |
db137867 AC |
11101 | fi |
11102 | fi | |
11103 | ;; | |
11104 | ||
11105 | *) | |
6f57a957 | 11106 | if test clean = "$opt_mode"; then |
db137867 AC |
11107 | noexename=$name |
11108 | case $file in | |
11109 | *.exe) | |
7083c021 AC |
11110 | func_stripname '' '.exe' "$file" |
11111 | file=$func_stripname_result | |
11112 | func_stripname '' '.exe' "$name" | |
11113 | noexename=$func_stripname_result | |
db137867 AC |
11114 | # $file with .exe has already been added to rmfiles, |
11115 | # add $file without .exe | |
08d019eb | 11116 | func_append rmfiles " $file" |
db137867 AC |
11117 | ;; |
11118 | esac | |
11119 | # Do a test to see if this is a libtool program. | |
7083c021 AC |
11120 | if func_ltwrapper_p "$file"; then |
11121 | if func_ltwrapper_executable_p "$file"; then | |
11122 | func_ltwrapper_scriptname "$file" | |
11123 | relink_command= | |
11124 | func_source $func_ltwrapper_scriptname_result | |
08d019eb | 11125 | func_append rmfiles " $func_ltwrapper_scriptname_result" |
7083c021 AC |
11126 | else |
11127 | relink_command= | |
11128 | func_source $dir/$noexename | |
11129 | fi | |
db137867 AC |
11130 | |
11131 | # note $name still contains .exe if it was in $file originally | |
11132 | # as does the version of $file that was added into $rmfiles | |
6f57a957 AC |
11133 | func_append rmfiles " $odir/$name $odir/${name}S.$objext" |
11134 | if test yes = "$fast_install" && test -n "$relink_command"; then | |
08d019eb | 11135 | func_append rmfiles " $odir/lt-$name" |
db137867 | 11136 | fi |
6f57a957 AC |
11137 | if test "X$noexename" != "X$name"; then |
11138 | func_append rmfiles " $odir/lt-$noexename.c" | |
db137867 AC |
11139 | fi |
11140 | fi | |
11141 | fi | |
11142 | ;; | |
11143 | esac | |
7083c021 | 11144 | func_show_eval "$RM $rmfiles" 'exit_status=1' |
db137867 | 11145 | done |
db137867 | 11146 | |
6f57a957 | 11147 | # Try to remove the $objdir's in the directories where we deleted files |
db137867 AC |
11148 | for dir in $rmdirs; do |
11149 | if test -d "$dir"; then | |
7083c021 | 11150 | func_show_eval "rmdir $dir >/dev/null 2>&1" |
db137867 AC |
11151 | fi |
11152 | done | |
11153 | ||
11154 | exit $exit_status | |
7083c021 | 11155 | } |
db137867 | 11156 | |
6f57a957 AC |
11157 | if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then |
11158 | func_mode_uninstall ${1+"$@"} | |
11159 | fi | |
db137867 | 11160 | |
08d019eb | 11161 | test -z "$opt_mode" && { |
6f57a957 | 11162 | help=$generic_help |
7083c021 AC |
11163 | func_fatal_help "you must specify a MODE" |
11164 | } | |
11165 | ||
11166 | test -z "$exec_cmd" && \ | |
6f57a957 | 11167 | func_fatal_help "invalid operation mode '$opt_mode'" |
db137867 AC |
11168 | |
11169 | if test -n "$exec_cmd"; then | |
7083c021 | 11170 | eval exec "$exec_cmd" |
db137867 AC |
11171 | exit $EXIT_FAILURE |
11172 | fi | |
11173 | ||
7083c021 | 11174 | exit $exit_status |
db137867 | 11175 | |
db137867 AC |
11176 | |
11177 | # The TAGs below are defined such that we never get into a situation | |
6f57a957 | 11178 | # where we disable both kinds of libraries. Given conflicting |
db137867 AC |
11179 | # choices, we go for a static library, that is the most portable, |
11180 | # since we can't tell whether shared libraries were disabled because | |
11181 | # the user asked for that or because the platform doesn't support | |
11182 | # them. This is particularly important on AIX, because we don't | |
11183 | # support having both static and shared libraries enabled at the same | |
11184 | # time on that platform, so we default to a shared-only configuration. | |
11185 | # If a disable-shared tag is given, we'll fallback to a static-only | |
11186 | # configuration. But we'll never go from static-only to shared-only. | |
11187 | ||
11188 | # ### BEGIN LIBTOOL TAG CONFIG: disable-shared | |
7083c021 AC |
11189 | build_libtool_libs=no |
11190 | build_old_libs=yes | |
db137867 AC |
11191 | # ### END LIBTOOL TAG CONFIG: disable-shared |
11192 | ||
11193 | # ### BEGIN LIBTOOL TAG CONFIG: disable-static | |
7083c021 | 11194 | build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` |
db137867 AC |
11195 | # ### END LIBTOOL TAG CONFIG: disable-static |
11196 | ||
11197 | # Local Variables: | |
11198 | # mode:shell-script | |
11199 | # sh-indentation:2 | |
11200 | # End: |