ltmain.sh revision 1.1 1 1.1 mrg #!/bin/sh
2 1.1 mrg ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3 1.1 mrg ## by inline-source v2014-01-03.01
4 1.1 mrg
5 1.1 mrg # libtool (GNU libtool) 2.4.6
6 1.1 mrg # Provide generalized library-building support services.
7 1.1 mrg # Written by Gordon Matzigkeit <gord (at] gnu.ai.mit.edu>, 1996
8 1.1 mrg
9 1.1 mrg # Copyright (C) 1996-2015 Free Software Foundation, Inc.
10 1.1 mrg # This is free software; see the source for copying conditions. There is NO
11 1.1 mrg # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 1.1 mrg
13 1.1 mrg # GNU Libtool is free software; you can redistribute it and/or modify
14 1.1 mrg # it under the terms of the GNU General Public License as published by
15 1.1 mrg # the Free Software Foundation; either version 2 of the License, or
16 1.1 mrg # (at your option) any later version.
17 1.1 mrg #
18 1.1 mrg # As a special exception to the GNU General Public License,
19 1.1 mrg # if you distribute this file as part of a program or library that
20 1.1 mrg # is built using GNU Libtool, you may include this file under the
21 1.1 mrg # same distribution terms that you use for the rest of that program.
22 1.1 mrg #
23 1.1 mrg # GNU Libtool is distributed in the hope that it will be useful, but
24 1.1 mrg # WITHOUT ANY WARRANTY; without even the implied warranty of
25 1.1 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 1.1 mrg # General Public License for more details.
27 1.1 mrg #
28 1.1 mrg # You should have received a copy of the GNU General Public License
29 1.1 mrg # along with this program. If not, see <http://www.gnu.org/licenses/>.
30 1.1 mrg
31 1.1 mrg
32 1.1 mrg PROGRAM=libtool
33 1.1 mrg PACKAGE=libtool
34 1.1 mrg VERSION=2.4.6
35 1.1 mrg package_revision=2.4.6
36 1.1 mrg
37 1.1 mrg
38 1.1 mrg ## ------ ##
39 1.1 mrg ## Usage. ##
40 1.1 mrg ## ------ ##
41 1.1 mrg
42 1.1 mrg # Run './libtool --help' for help with using this script from the
43 1.1 mrg # command line.
44 1.1 mrg
45 1.1 mrg
46 1.1 mrg ## ------------------------------- ##
47 1.1 mrg ## User overridable command paths. ##
48 1.1 mrg ## ------------------------------- ##
49 1.1 mrg
50 1.1 mrg # After configure completes, it has a better idea of some of the
51 1.1 mrg # shell tools we need than the defaults used by the functions shared
52 1.1 mrg # with bootstrap, so set those here where they can still be over-
53 1.1 mrg # ridden by the user, but otherwise take precedence.
54 1.1 mrg
55 1.1 mrg : ${AUTOCONF="autoconf"}
56 1.1 mrg : ${AUTOMAKE="automake"}
57 1.1 mrg
58 1.1 mrg
59 1.1 mrg ## -------------------------- ##
60 1.1 mrg ## Source external libraries. ##
61 1.1 mrg ## -------------------------- ##
62 1.1 mrg
63 1.1 mrg # Much of our low-level functionality needs to be sourced from external
64 1.1 mrg # libraries, which are installed to $pkgauxdir.
65 1.1 mrg
66 1.1 mrg # Set a version string for this script.
67 1.1 mrg scriptversion=2015-01-20.17; # UTC
68 1.1 mrg
69 1.1 mrg # General shell script boiler plate, and helper functions.
70 1.1 mrg # Written by Gary V. Vaughan, 2004
71 1.1 mrg
72 1.1 mrg # Copyright (C) 2004-2015 Free Software Foundation, Inc.
73 1.1 mrg # This is free software; see the source for copying conditions. There is NO
74 1.1 mrg # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
75 1.1 mrg
76 1.1 mrg # This program is free software; you can redistribute it and/or modify
77 1.1 mrg # it under the terms of the GNU General Public License as published by
78 1.1 mrg # the Free Software Foundation; either version 3 of the License, or
79 1.1 mrg # (at your option) any later version.
80 1.1 mrg
81 1.1 mrg # As a special exception to the GNU General Public License, if you distribute
82 1.1 mrg # this file as part of a program or library that is built using GNU Libtool,
83 1.1 mrg # you may include this file under the same distribution terms that you use
84 1.1 mrg # for the rest of that program.
85 1.1 mrg
86 1.1 mrg # This program is distributed in the hope that it will be useful,
87 1.1 mrg # but WITHOUT ANY WARRANTY; without even the implied warranty of
88 1.1 mrg # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89 1.1 mrg # General Public License for more details.
90 1.1 mrg
91 1.1 mrg # You should have received a copy of the GNU General Public License
92 1.1 mrg # along with this program. If not, see <http://www.gnu.org/licenses/>.
93 1.1 mrg
94 1.1 mrg # Please report bugs or propose patches to gary (at] gnu.org.
95 1.1 mrg
96 1.1 mrg
97 1.1 mrg ## ------ ##
98 1.1 mrg ## Usage. ##
99 1.1 mrg ## ------ ##
100 1.1 mrg
101 1.1 mrg # Evaluate this file near the top of your script to gain access to
102 1.1 mrg # the functions and variables defined here:
103 1.1 mrg #
104 1.1 mrg # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
105 1.1 mrg #
106 1.1 mrg # If you need to override any of the default environment variable
107 1.1 mrg # settings, do that before evaluating this file.
108 1.1 mrg
109 1.1 mrg
110 1.1 mrg ## -------------------- ##
111 1.1 mrg ## Shell normalisation. ##
112 1.1 mrg ## -------------------- ##
113 1.1 mrg
114 1.1 mrg # Some shells need a little help to be as Bourne compatible as possible.
115 1.1 mrg # Before doing anything else, make sure all that help has been provided!
116 1.1 mrg
117 1.1 mrg DUALCASE=1; export DUALCASE # for MKS sh
118 1.1 mrg if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
119 1.1 mrg emulate sh
120 1.1 mrg NULLCMD=:
121 1.1 mrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
122 1.1 mrg # is contrary to our usage. Disable this feature.
123 1.1 mrg alias -g '${1+"$@"}'='"$@"'
124 1.1 mrg setopt NO_GLOB_SUBST
125 1.1 mrg else
126 1.1 mrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127 1.1 mrg fi
128 1.1 mrg
129 1.1 mrg # NLS nuisances: We save the old values in case they are required later.
130 1.1 mrg _G_user_locale=
131 1.1 mrg _G_safe_locale=
132 1.1 mrg for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
133 1.1 mrg do
134 1.1 mrg eval "if test set = \"\${$_G_var+set}\"; then
135 1.1 mrg save_$_G_var=\$$_G_var
136 1.1 mrg $_G_var=C
137 1.1 mrg export $_G_var
138 1.1 mrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139 1.1 mrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
140 1.1 mrg fi"
141 1.1 mrg done
142 1.1 mrg
143 1.1 mrg # CDPATH.
144 1.1 mrg (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145 1.1 mrg
146 1.1 mrg # Make sure IFS has a sensible default
147 1.1 mrg sp=' '
148 1.1 mrg nl='
149 1.1 mrg '
150 1.1 mrg IFS="$sp $nl"
151 1.1 mrg
152 1.1 mrg # There are apparently some retarded systems that use ';' as a PATH separator!
153 1.1 mrg if test "${PATH_SEPARATOR+set}" != set; then
154 1.1 mrg PATH_SEPARATOR=:
155 1.1 mrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156 1.1 mrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
157 1.1 mrg PATH_SEPARATOR=';'
158 1.1 mrg }
159 1.1 mrg fi
160 1.1 mrg
161 1.1 mrg
162 1.1 mrg
163 1.1 mrg ## ------------------------- ##
164 1.1 mrg ## Locate command utilities. ##
165 1.1 mrg ## ------------------------- ##
166 1.1 mrg
167 1.1 mrg
168 1.1 mrg # func_executable_p FILE
169 1.1 mrg # ----------------------
170 1.1 mrg # Check that FILE is an executable regular file.
171 1.1 mrg func_executable_p ()
172 1.1 mrg {
173 1.1 mrg test -f "$1" && test -x "$1"
174 1.1 mrg }
175 1.1 mrg
176 1.1 mrg
177 1.1 mrg # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178 1.1 mrg # --------------------------------------------
179 1.1 mrg # Search for either a program that responds to --version with output
180 1.1 mrg # containing "GNU", or else returned by CHECK_FUNC otherwise, by
181 1.1 mrg # trying all the directories in PATH with each of the elements of
182 1.1 mrg # PROGS_LIST.
183 1.1 mrg #
184 1.1 mrg # CHECK_FUNC should accept the path to a candidate program, and
185 1.1 mrg # set $func_check_prog_result if it truncates its output less than
186 1.1 mrg # $_G_path_prog_max characters.
187 1.1 mrg func_path_progs ()
188 1.1 mrg {
189 1.1 mrg _G_progs_list=$1
190 1.1 mrg _G_check_func=$2
191 1.1 mrg _G_PATH=${3-"$PATH"}
192 1.1 mrg
193 1.1 mrg _G_path_prog_max=0
194 1.1 mrg _G_path_prog_found=false
195 1.1 mrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
196 1.1 mrg for _G_dir in $_G_PATH; do
197 1.1 mrg IFS=$_G_save_IFS
198 1.1 mrg test -z "$_G_dir" && _G_dir=.
199 1.1 mrg for _G_prog_name in $_G_progs_list; do
200 1.1 mrg for _exeext in '' .EXE; do
201 1.1 mrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext
202 1.1 mrg func_executable_p "$_G_path_prog" || continue
203 1.1 mrg case `"$_G_path_prog" --version 2>&1` in
204 1.1 mrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205 1.1 mrg *) $_G_check_func $_G_path_prog
206 1.1 mrg func_path_progs_result=$func_check_prog_result
207 1.1 mrg ;;
208 1.1 mrg esac
209 1.1 mrg $_G_path_prog_found && break 3
210 1.1 mrg done
211 1.1 mrg done
212 1.1 mrg done
213 1.1 mrg IFS=$_G_save_IFS
214 1.1 mrg test -z "$func_path_progs_result" && {
215 1.1 mrg echo "no acceptable sed could be found in \$PATH" >&2
216 1.1 mrg exit 1
217 1.1 mrg }
218 1.1 mrg }
219 1.1 mrg
220 1.1 mrg
221 1.1 mrg # We want to be able to use the functions in this file before configure
222 1.1 mrg # has figured out where the best binaries are kept, which means we have
223 1.1 mrg # to search for them ourselves - except when the results are already set
224 1.1 mrg # where we skip the searches.
225 1.1 mrg
226 1.1 mrg # Unless the user overrides by setting SED, search the path for either GNU
227 1.1 mrg # sed, or the sed that truncates its output the least.
228 1.1 mrg test -z "$SED" && {
229 1.1 mrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230 1.1 mrg for _G_i in 1 2 3 4 5 6 7; do
231 1.1 mrg _G_sed_script=$_G_sed_script$nl$_G_sed_script
232 1.1 mrg done
233 1.1 mrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
234 1.1 mrg _G_sed_script=
235 1.1 mrg
236 1.1 mrg func_check_prog_sed ()
237 1.1 mrg {
238 1.1 mrg _G_path_prog=$1
239 1.1 mrg
240 1.1 mrg _G_count=0
241 1.1 mrg printf 0123456789 >conftest.in
242 1.1 mrg while :
243 1.1 mrg do
244 1.1 mrg cat conftest.in conftest.in >conftest.tmp
245 1.1 mrg mv conftest.tmp conftest.in
246 1.1 mrg cp conftest.in conftest.nl
247 1.1 mrg echo '' >> conftest.nl
248 1.1 mrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249 1.1 mrg diff conftest.out conftest.nl >/dev/null 2>&1 || break
250 1.1 mrg _G_count=`expr $_G_count + 1`
251 1.1 mrg if test "$_G_count" -gt "$_G_path_prog_max"; then
252 1.1 mrg # Best one so far, save it but keep looking for a better one
253 1.1 mrg func_check_prog_result=$_G_path_prog
254 1.1 mrg _G_path_prog_max=$_G_count
255 1.1 mrg fi
256 1.1 mrg # 10*(2^10) chars as input seems more than enough
257 1.1 mrg test 10 -lt "$_G_count" && break
258 1.1 mrg done
259 1.1 mrg rm -f conftest.in conftest.tmp conftest.nl conftest.out
260 1.1 mrg }
261 1.1 mrg
262 1.1 mrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
263 1.1 mrg rm -f conftest.sed
264 1.1 mrg SED=$func_path_progs_result
265 1.1 mrg }
266 1.1 mrg
267 1.1 mrg
268 1.1 mrg # Unless the user overrides by setting GREP, search the path for either GNU
269 1.1 mrg # grep, or the grep that truncates its output the least.
270 1.1 mrg test -z "$GREP" && {
271 1.1 mrg func_check_prog_grep ()
272 1.1 mrg {
273 1.1 mrg _G_path_prog=$1
274 1.1 mrg
275 1.1 mrg _G_count=0
276 1.1 mrg _G_path_prog_max=0
277 1.1 mrg printf 0123456789 >conftest.in
278 1.1 mrg while :
279 1.1 mrg do
280 1.1 mrg cat conftest.in conftest.in >conftest.tmp
281 1.1 mrg mv conftest.tmp conftest.in
282 1.1 mrg cp conftest.in conftest.nl
283 1.1 mrg echo 'GREP' >> conftest.nl
284 1.1 mrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285 1.1 mrg diff conftest.out conftest.nl >/dev/null 2>&1 || break
286 1.1 mrg _G_count=`expr $_G_count + 1`
287 1.1 mrg if test "$_G_count" -gt "$_G_path_prog_max"; then
288 1.1 mrg # Best one so far, save it but keep looking for a better one
289 1.1 mrg func_check_prog_result=$_G_path_prog
290 1.1 mrg _G_path_prog_max=$_G_count
291 1.1 mrg fi
292 1.1 mrg # 10*(2^10) chars as input seems more than enough
293 1.1 mrg test 10 -lt "$_G_count" && break
294 1.1 mrg done
295 1.1 mrg rm -f conftest.in conftest.tmp conftest.nl conftest.out
296 1.1 mrg }
297 1.1 mrg
298 1.1 mrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299 1.1 mrg GREP=$func_path_progs_result
300 1.1 mrg }
301 1.1 mrg
302 1.1 mrg
303 1.1 mrg ## ------------------------------- ##
304 1.1 mrg ## User overridable command paths. ##
305 1.1 mrg ## ------------------------------- ##
306 1.1 mrg
307 1.1 mrg # All uppercase variable names are used for environment variables. These
308 1.1 mrg # variables can be overridden by the user before calling a script that
309 1.1 mrg # uses them if a suitable command of that name is not already available
310 1.1 mrg # in the command search PATH.
311 1.1 mrg
312 1.1 mrg : ${CP="cp -f"}
313 1.1 mrg : ${ECHO="printf %s\n"}
314 1.1 mrg : ${EGREP="$GREP -E"}
315 1.1 mrg : ${FGREP="$GREP -F"}
316 1.1 mrg : ${LN_S="ln -s"}
317 1.1 mrg : ${MAKE="make"}
318 1.1 mrg : ${MKDIR="mkdir"}
319 1.1 mrg : ${MV="mv -f"}
320 1.1 mrg : ${RM="rm -f"}
321 1.1 mrg : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322 1.1 mrg
323 1.1 mrg
324 1.1 mrg ## -------------------- ##
325 1.1 mrg ## Useful sed snippets. ##
326 1.1 mrg ## -------------------- ##
327 1.1 mrg
328 1.1 mrg sed_dirname='s|/[^/]*$||'
329 1.1 mrg sed_basename='s|^.*/||'
330 1.1 mrg
331 1.1 mrg # Sed substitution that helps us do robust quoting. It backslashifies
332 1.1 mrg # metacharacters that are still active within double-quoted strings.
333 1.1 mrg sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334 1.1 mrg
335 1.1 mrg # Same as above, but do not quote variable references.
336 1.1 mrg sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337 1.1 mrg
338 1.1 mrg # Sed substitution that turns a string into a regex matching for the
339 1.1 mrg # string literally.
340 1.1 mrg sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341 1.1 mrg
342 1.1 mrg # Sed substitution that converts a w32 file name or path
343 1.1 mrg # that contains forward slashes, into one that contains
344 1.1 mrg # (escaped) backslashes. A very naive implementation.
345 1.1 mrg sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
346 1.1 mrg
347 1.1 mrg # Re-'\' parameter expansions in output of sed_double_quote_subst that
348 1.1 mrg # were '\'-ed in input to the same. If an odd number of '\' preceded a
349 1.1 mrg # '$' in input to sed_double_quote_subst, that '$' was protected from
350 1.1 mrg # expansion. Since each input '\' is now two '\'s, look for any number
351 1.1 mrg # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
352 1.1 mrg _G_bs='\\'
353 1.1 mrg _G_bs2='\\\\'
354 1.1 mrg _G_bs4='\\\\\\\\'
355 1.1 mrg _G_dollar='\$'
356 1.1 mrg sed_double_backslash="\
357 1.1 mrg s/$_G_bs4/&\\
358 1.1 mrg /g
359 1.1 mrg s/^$_G_bs2$_G_dollar/$_G_bs&/
360 1.1 mrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
361 1.1 mrg s/\n//g"
362 1.1 mrg
363 1.1 mrg
364 1.1 mrg ## ----------------- ##
365 1.1 mrg ## Global variables. ##
366 1.1 mrg ## ----------------- ##
367 1.1 mrg
368 1.1 mrg # Except for the global variables explicitly listed below, the following
369 1.1 mrg # functions in the '^func_' namespace, and the '^require_' namespace
370 1.1 mrg # variables initialised in the 'Resource management' section, sourcing
371 1.1 mrg # this file will not pollute your global namespace with anything
372 1.1 mrg # else. There's no portable way to scope variables in Bourne shell
373 1.1 mrg # though, so actually running these functions will sometimes place
374 1.1 mrg # results into a variable named after the function, and often use
375 1.1 mrg # temporary variables in the '^_G_' namespace. If you are careful to
376 1.1 mrg # avoid using those namespaces casually in your sourcing script, things
377 1.1 mrg # should continue to work as you expect. And, of course, you can freely
378 1.1 mrg # overwrite any of the functions or variables defined here before
379 1.1 mrg # calling anything to customize them.
380 1.1 mrg
381 1.1 mrg EXIT_SUCCESS=0
382 1.1 mrg EXIT_FAILURE=1
383 1.1 mrg EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
384 1.1 mrg EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
385 1.1 mrg
386 1.1 mrg # Allow overriding, eg assuming that you follow the convention of
387 1.1 mrg # putting '$debug_cmd' at the start of all your functions, you can get
388 1.1 mrg # bash to show function call trace with:
389 1.1 mrg #
390 1.1 mrg # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391 1.1 mrg debug_cmd=${debug_cmd-":"}
392 1.1 mrg exit_cmd=:
393 1.1 mrg
394 1.1 mrg # By convention, finish your script with:
395 1.1 mrg #
396 1.1 mrg # exit $exit_status
397 1.1 mrg #
398 1.1 mrg # so that you can set exit_status to non-zero if you want to indicate
399 1.1 mrg # something went wrong during execution without actually bailing out at
400 1.1 mrg # the point of failure.
401 1.1 mrg exit_status=$EXIT_SUCCESS
402 1.1 mrg
403 1.1 mrg # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404 1.1 mrg # is ksh but when the shell is invoked as "sh" and the current value of
405 1.1 mrg # the _XPG environment variable is not equal to 1 (one), the special
406 1.1 mrg # positional parameter $0, within a function call, is the name of the
407 1.1 mrg # function.
408 1.1 mrg progpath=$0
409 1.1 mrg
410 1.1 mrg # The name of this program.
411 1.1 mrg progname=`$ECHO "$progpath" |$SED "$sed_basename"`
412 1.1 mrg
413 1.1 mrg # Make sure we have an absolute progpath for reexecution:
414 1.1 mrg case $progpath in
415 1.1 mrg [\\/]*|[A-Za-z]:\\*) ;;
416 1.1 mrg *[\\/]*)
417 1.1 mrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418 1.1 mrg progdir=`cd "$progdir" && pwd`
419 1.1 mrg progpath=$progdir/$progname
420 1.1 mrg ;;
421 1.1 mrg *)
422 1.1 mrg _G_IFS=$IFS
423 1.1 mrg IFS=${PATH_SEPARATOR-:}
424 1.1 mrg for progdir in $PATH; do
425 1.1 mrg IFS=$_G_IFS
426 1.1 mrg test -x "$progdir/$progname" && break
427 1.1 mrg done
428 1.1 mrg IFS=$_G_IFS
429 1.1 mrg test -n "$progdir" || progdir=`pwd`
430 1.1 mrg progpath=$progdir/$progname
431 1.1 mrg ;;
432 1.1 mrg esac
433 1.1 mrg
434 1.1 mrg
435 1.1 mrg ## ----------------- ##
436 1.1 mrg ## Standard options. ##
437 1.1 mrg ## ----------------- ##
438 1.1 mrg
439 1.1 mrg # The following options affect the operation of the functions defined
440 1.1 mrg # below, and should be set appropriately depending on run-time para-
441 1.1 mrg # meters passed on the command line.
442 1.1 mrg
443 1.1 mrg opt_dry_run=false
444 1.1 mrg opt_quiet=false
445 1.1 mrg opt_verbose=false
446 1.1 mrg
447 1.1 mrg # Categories 'all' and 'none' are always available. Append any others
448 1.1 mrg # you will pass as the first argument to func_warning from your own
449 1.1 mrg # code.
450 1.1 mrg warning_categories=
451 1.1 mrg
452 1.1 mrg # By default, display warnings according to 'opt_warning_types'. Set
453 1.1 mrg # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
454 1.1 mrg # treat the next displayed warning as a fatal error.
455 1.1 mrg warning_func=func_warn_and_continue
456 1.1 mrg
457 1.1 mrg # Set to 'all' to display all warnings, 'none' to suppress all
458 1.1 mrg # warnings, or a space delimited list of some subset of
459 1.1 mrg # 'warning_categories' to display only the listed warnings.
460 1.1 mrg opt_warning_types=all
461 1.1 mrg
462 1.1 mrg
463 1.1 mrg ## -------------------- ##
464 1.1 mrg ## Resource management. ##
465 1.1 mrg ## -------------------- ##
466 1.1 mrg
467 1.1 mrg # This section contains definitions for functions that each ensure a
468 1.1 mrg # particular resource (a file, or a non-empty configuration variable for
469 1.1 mrg # example) is available, and if appropriate to extract default values
470 1.1 mrg # from pertinent package files. Call them using their associated
471 1.1 mrg # 'require_*' variable to ensure that they are executed, at most, once.
472 1.1 mrg #
473 1.1 mrg # It's entirely deliberate that calling these functions can set
474 1.1 mrg # variables that don't obey the namespace limitations obeyed by the rest
475 1.1 mrg # of this file, in order that that they be as useful as possible to
476 1.1 mrg # callers.
477 1.1 mrg
478 1.1 mrg
479 1.1 mrg # require_term_colors
480 1.1 mrg # -------------------
481 1.1 mrg # Allow display of bold text on terminals that support it.
482 1.1 mrg require_term_colors=func_require_term_colors
483 1.1 mrg func_require_term_colors ()
484 1.1 mrg {
485 1.1 mrg $debug_cmd
486 1.1 mrg
487 1.1 mrg test -t 1 && {
488 1.1 mrg # COLORTERM and USE_ANSI_COLORS environment variables take
489 1.1 mrg # precedence, because most terminfo databases neglect to describe
490 1.1 mrg # whether color sequences are supported.
491 1.1 mrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
492 1.1 mrg
493 1.1 mrg if test 1 = "$USE_ANSI_COLORS"; then
494 1.1 mrg # Standard ANSI escape sequences
495 1.1 mrg tc_reset='[0m'
496 1.1 mrg tc_bold='[1m'; tc_standout='[7m'
497 1.1 mrg tc_red='[31m'; tc_green='[32m'
498 1.1 mrg tc_blue='[34m'; tc_cyan='[36m'
499 1.1 mrg else
500 1.1 mrg # Otherwise trust the terminfo database after all.
501 1.1 mrg test -n "`tput sgr0 2>/dev/null`" && {
502 1.1 mrg tc_reset=`tput sgr0`
503 1.1 mrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
504 1.1 mrg tc_standout=$tc_bold
505 1.1 mrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506 1.1 mrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507 1.1 mrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508 1.1 mrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509 1.1 mrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
510 1.1 mrg }
511 1.1 mrg fi
512 1.1 mrg }
513 1.1 mrg
514 1.1 mrg require_term_colors=:
515 1.1 mrg }
516 1.1 mrg
517 1.1 mrg
518 1.1 mrg ## ----------------- ##
519 1.1 mrg ## Function library. ##
520 1.1 mrg ## ----------------- ##
521 1.1 mrg
522 1.1 mrg # This section contains a variety of useful functions to call in your
523 1.1 mrg # scripts. Take note of the portable wrappers for features provided by
524 1.1 mrg # some modern shells, which will fall back to slower equivalents on
525 1.1 mrg # less featureful shells.
526 1.1 mrg
527 1.1 mrg
528 1.1 mrg # func_append VAR VALUE
529 1.1 mrg # ---------------------
530 1.1 mrg # Append VALUE onto the existing contents of VAR.
531 1.1 mrg
532 1.1 mrg # We should try to minimise forks, especially on Windows where they are
533 1.1 mrg # unreasonably slow, so skip the feature probes when bash or zsh are
534 1.1 mrg # being used:
535 1.1 mrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536 1.1 mrg : ${_G_HAVE_ARITH_OP="yes"}
537 1.1 mrg : ${_G_HAVE_XSI_OPS="yes"}
538 1.1 mrg # The += operator was introduced in bash 3.1
539 1.1 mrg case $BASH_VERSION in
540 1.1 mrg [12].* | 3.0 | 3.0*) ;;
541 1.1 mrg *)
542 1.1 mrg : ${_G_HAVE_PLUSEQ_OP="yes"}
543 1.1 mrg ;;
544 1.1 mrg esac
545 1.1 mrg fi
546 1.1 mrg
547 1.1 mrg # _G_HAVE_PLUSEQ_OP
548 1.1 mrg # Can be empty, in which case the shell is probed, "yes" if += is
549 1.1 mrg # useable or anything else if it does not work.
550 1.1 mrg test -z "$_G_HAVE_PLUSEQ_OP" \
551 1.1 mrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552 1.1 mrg && _G_HAVE_PLUSEQ_OP=yes
553 1.1 mrg
554 1.1 mrg if test yes = "$_G_HAVE_PLUSEQ_OP"
555 1.1 mrg then
556 1.1 mrg # This is an XSI compatible shell, allowing a faster implementation...
557 1.1 mrg eval 'func_append ()
558 1.1 mrg {
559 1.1 mrg $debug_cmd
560 1.1 mrg
561 1.1 mrg eval "$1+=\$2"
562 1.1 mrg }'
563 1.1 mrg else
564 1.1 mrg # ...otherwise fall back to using expr, which is often a shell builtin.
565 1.1 mrg func_append ()
566 1.1 mrg {
567 1.1 mrg $debug_cmd
568 1.1 mrg
569 1.1 mrg eval "$1=\$$1\$2"
570 1.1 mrg }
571 1.1 mrg fi
572 1.1 mrg
573 1.1 mrg
574 1.1 mrg # func_append_quoted VAR VALUE
575 1.1 mrg # ----------------------------
576 1.1 mrg # Quote VALUE and append to the end of shell variable VAR, separated
577 1.1 mrg # by a space.
578 1.1 mrg if test yes = "$_G_HAVE_PLUSEQ_OP"; then
579 1.1 mrg eval 'func_append_quoted ()
580 1.1 mrg {
581 1.1 mrg $debug_cmd
582 1.1 mrg
583 1.1 mrg func_quote_for_eval "$2"
584 1.1 mrg eval "$1+=\\ \$func_quote_for_eval_result"
585 1.1 mrg }'
586 1.1 mrg else
587 1.1 mrg func_append_quoted ()
588 1.1 mrg {
589 1.1 mrg $debug_cmd
590 1.1 mrg
591 1.1 mrg func_quote_for_eval "$2"
592 1.1 mrg eval "$1=\$$1\\ \$func_quote_for_eval_result"
593 1.1 mrg }
594 1.1 mrg fi
595 1.1 mrg
596 1.1 mrg
597 1.1 mrg # func_append_uniq VAR VALUE
598 1.1 mrg # --------------------------
599 1.1 mrg # Append unique VALUE onto the existing contents of VAR, assuming
600 1.1 mrg # entries are delimited by the first character of VALUE. For example:
601 1.1 mrg #
602 1.1 mrg # func_append_uniq options " --another-option option-argument"
603 1.1 mrg #
604 1.1 mrg # will only append to $options if " --another-option option-argument "
605 1.1 mrg # is not already present somewhere in $options already (note spaces at
606 1.1 mrg # each end implied by leading space in second argument).
607 1.1 mrg func_append_uniq ()
608 1.1 mrg {
609 1.1 mrg $debug_cmd
610 1.1 mrg
611 1.1 mrg eval _G_current_value='`$ECHO $'$1'`'
612 1.1 mrg _G_delim=`expr "$2" : '\(.\)'`
613 1.1 mrg
614 1.1 mrg case $_G_delim$_G_current_value$_G_delim in
615 1.1 mrg *"$2$_G_delim"*) ;;
616 1.1 mrg *) func_append "$@" ;;
617 1.1 mrg esac
618 1.1 mrg }
619 1.1 mrg
620 1.1 mrg
621 1.1 mrg # func_arith TERM...
622 1.1 mrg # ------------------
623 1.1 mrg # Set func_arith_result to the result of evaluating TERMs.
624 1.1 mrg test -z "$_G_HAVE_ARITH_OP" \
625 1.1 mrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626 1.1 mrg && _G_HAVE_ARITH_OP=yes
627 1.1 mrg
628 1.1 mrg if test yes = "$_G_HAVE_ARITH_OP"; then
629 1.1 mrg eval 'func_arith ()
630 1.1 mrg {
631 1.1 mrg $debug_cmd
632 1.1 mrg
633 1.1 mrg func_arith_result=$(( $* ))
634 1.1 mrg }'
635 1.1 mrg else
636 1.1 mrg func_arith ()
637 1.1 mrg {
638 1.1 mrg $debug_cmd
639 1.1 mrg
640 1.1 mrg func_arith_result=`expr "$@"`
641 1.1 mrg }
642 1.1 mrg fi
643 1.1 mrg
644 1.1 mrg
645 1.1 mrg # func_basename FILE
646 1.1 mrg # ------------------
647 1.1 mrg # Set func_basename_result to FILE with everything up to and including
648 1.1 mrg # the last / stripped.
649 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"; then
650 1.1 mrg # If this shell supports suffix pattern removal, then use it to avoid
651 1.1 mrg # forking. Hide the definitions single quotes in case the shell chokes
652 1.1 mrg # on unsupported syntax...
653 1.1 mrg _b='func_basename_result=${1##*/}'
654 1.1 mrg _d='case $1 in
655 1.1 mrg */*) func_dirname_result=${1%/*}$2 ;;
656 1.1 mrg * ) func_dirname_result=$3 ;;
657 1.1 mrg esac'
658 1.1 mrg
659 1.1 mrg else
660 1.1 mrg # ...otherwise fall back to using sed.
661 1.1 mrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662 1.1 mrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
663 1.1 mrg if test "X$func_dirname_result" = "X$1"; then
664 1.1 mrg func_dirname_result=$3
665 1.1 mrg else
666 1.1 mrg func_append func_dirname_result "$2"
667 1.1 mrg fi'
668 1.1 mrg fi
669 1.1 mrg
670 1.1 mrg eval 'func_basename ()
671 1.1 mrg {
672 1.1 mrg $debug_cmd
673 1.1 mrg
674 1.1 mrg '"$_b"'
675 1.1 mrg }'
676 1.1 mrg
677 1.1 mrg
678 1.1 mrg # func_dirname FILE APPEND NONDIR_REPLACEMENT
679 1.1 mrg # -------------------------------------------
680 1.1 mrg # Compute the dirname of FILE. If nonempty, add APPEND to the result,
681 1.1 mrg # otherwise set result to NONDIR_REPLACEMENT.
682 1.1 mrg eval 'func_dirname ()
683 1.1 mrg {
684 1.1 mrg $debug_cmd
685 1.1 mrg
686 1.1 mrg '"$_d"'
687 1.1 mrg }'
688 1.1 mrg
689 1.1 mrg
690 1.1 mrg # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691 1.1 mrg # --------------------------------------------------------
692 1.1 mrg # Perform func_basename and func_dirname in a single function
693 1.1 mrg # call:
694 1.1 mrg # dirname: Compute the dirname of FILE. If nonempty,
695 1.1 mrg # add APPEND to the result, otherwise set result
696 1.1 mrg # to NONDIR_REPLACEMENT.
697 1.1 mrg # value returned in "$func_dirname_result"
698 1.1 mrg # basename: Compute filename of FILE.
699 1.1 mrg # value retuned in "$func_basename_result"
700 1.1 mrg # For efficiency, we do not delegate to the functions above but instead
701 1.1 mrg # duplicate the functionality here.
702 1.1 mrg eval 'func_dirname_and_basename ()
703 1.1 mrg {
704 1.1 mrg $debug_cmd
705 1.1 mrg
706 1.1 mrg '"$_b"'
707 1.1 mrg '"$_d"'
708 1.1 mrg }'
709 1.1 mrg
710 1.1 mrg
711 1.1 mrg # func_echo ARG...
712 1.1 mrg # ----------------
713 1.1 mrg # Echo program name prefixed message.
714 1.1 mrg func_echo ()
715 1.1 mrg {
716 1.1 mrg $debug_cmd
717 1.1 mrg
718 1.1 mrg _G_message=$*
719 1.1 mrg
720 1.1 mrg func_echo_IFS=$IFS
721 1.1 mrg IFS=$nl
722 1.1 mrg for _G_line in $_G_message; do
723 1.1 mrg IFS=$func_echo_IFS
724 1.1 mrg $ECHO "$progname: $_G_line"
725 1.1 mrg done
726 1.1 mrg IFS=$func_echo_IFS
727 1.1 mrg }
728 1.1 mrg
729 1.1 mrg
730 1.1 mrg # func_echo_all ARG...
731 1.1 mrg # --------------------
732 1.1 mrg # Invoke $ECHO with all args, space-separated.
733 1.1 mrg func_echo_all ()
734 1.1 mrg {
735 1.1 mrg $ECHO "$*"
736 1.1 mrg }
737 1.1 mrg
738 1.1 mrg
739 1.1 mrg # func_echo_infix_1 INFIX ARG...
740 1.1 mrg # ------------------------------
741 1.1 mrg # Echo program name, followed by INFIX on the first line, with any
742 1.1 mrg # additional lines not showing INFIX.
743 1.1 mrg func_echo_infix_1 ()
744 1.1 mrg {
745 1.1 mrg $debug_cmd
746 1.1 mrg
747 1.1 mrg $require_term_colors
748 1.1 mrg
749 1.1 mrg _G_infix=$1; shift
750 1.1 mrg _G_indent=$_G_infix
751 1.1 mrg _G_prefix="$progname: $_G_infix: "
752 1.1 mrg _G_message=$*
753 1.1 mrg
754 1.1 mrg # Strip color escape sequences before counting printable length
755 1.1 mrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
756 1.1 mrg do
757 1.1 mrg test -n "$_G_tc" && {
758 1.1 mrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759 1.1 mrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
760 1.1 mrg }
761 1.1 mrg done
762 1.1 mrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
763 1.1 mrg
764 1.1 mrg func_echo_infix_1_IFS=$IFS
765 1.1 mrg IFS=$nl
766 1.1 mrg for _G_line in $_G_message; do
767 1.1 mrg IFS=$func_echo_infix_1_IFS
768 1.1 mrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
769 1.1 mrg _G_prefix=$_G_indent
770 1.1 mrg done
771 1.1 mrg IFS=$func_echo_infix_1_IFS
772 1.1 mrg }
773 1.1 mrg
774 1.1 mrg
775 1.1 mrg # func_error ARG...
776 1.1 mrg # -----------------
777 1.1 mrg # Echo program name prefixed message to standard error.
778 1.1 mrg func_error ()
779 1.1 mrg {
780 1.1 mrg $debug_cmd
781 1.1 mrg
782 1.1 mrg $require_term_colors
783 1.1 mrg
784 1.1 mrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
785 1.1 mrg }
786 1.1 mrg
787 1.1 mrg
788 1.1 mrg # func_fatal_error ARG...
789 1.1 mrg # -----------------------
790 1.1 mrg # Echo program name prefixed message to standard error, and exit.
791 1.1 mrg func_fatal_error ()
792 1.1 mrg {
793 1.1 mrg $debug_cmd
794 1.1 mrg
795 1.1 mrg func_error "$*"
796 1.1 mrg exit $EXIT_FAILURE
797 1.1 mrg }
798 1.1 mrg
799 1.1 mrg
800 1.1 mrg # func_grep EXPRESSION FILENAME
801 1.1 mrg # -----------------------------
802 1.1 mrg # Check whether EXPRESSION matches any line of FILENAME, without output.
803 1.1 mrg func_grep ()
804 1.1 mrg {
805 1.1 mrg $debug_cmd
806 1.1 mrg
807 1.1 mrg $GREP "$1" "$2" >/dev/null 2>&1
808 1.1 mrg }
809 1.1 mrg
810 1.1 mrg
811 1.1 mrg # func_len STRING
812 1.1 mrg # ---------------
813 1.1 mrg # Set func_len_result to the length of STRING. STRING may not
814 1.1 mrg # start with a hyphen.
815 1.1 mrg test -z "$_G_HAVE_XSI_OPS" \
816 1.1 mrg && (eval 'x=a/b/c;
817 1.1 mrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818 1.1 mrg && _G_HAVE_XSI_OPS=yes
819 1.1 mrg
820 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"; then
821 1.1 mrg eval 'func_len ()
822 1.1 mrg {
823 1.1 mrg $debug_cmd
824 1.1 mrg
825 1.1 mrg func_len_result=${#1}
826 1.1 mrg }'
827 1.1 mrg else
828 1.1 mrg func_len ()
829 1.1 mrg {
830 1.1 mrg $debug_cmd
831 1.1 mrg
832 1.1 mrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
833 1.1 mrg }
834 1.1 mrg fi
835 1.1 mrg
836 1.1 mrg
837 1.1 mrg # func_mkdir_p DIRECTORY-PATH
838 1.1 mrg # ---------------------------
839 1.1 mrg # Make sure the entire path to DIRECTORY-PATH is available.
840 1.1 mrg func_mkdir_p ()
841 1.1 mrg {
842 1.1 mrg $debug_cmd
843 1.1 mrg
844 1.1 mrg _G_directory_path=$1
845 1.1 mrg _G_dir_list=
846 1.1 mrg
847 1.1 mrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
848 1.1 mrg
849 1.1 mrg # Protect directory names starting with '-'
850 1.1 mrg case $_G_directory_path in
851 1.1 mrg -*) _G_directory_path=./$_G_directory_path ;;
852 1.1 mrg esac
853 1.1 mrg
854 1.1 mrg # While some portion of DIR does not yet exist...
855 1.1 mrg while test ! -d "$_G_directory_path"; do
856 1.1 mrg # ...make a list in topmost first order. Use a colon delimited
857 1.1 mrg # list incase some portion of path contains whitespace.
858 1.1 mrg _G_dir_list=$_G_directory_path:$_G_dir_list
859 1.1 mrg
860 1.1 mrg # If the last portion added has no slash in it, the list is done
861 1.1 mrg case $_G_directory_path in */*) ;; *) break ;; esac
862 1.1 mrg
863 1.1 mrg # ...otherwise throw away the child directory and loop
864 1.1 mrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865 1.1 mrg done
866 1.1 mrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867 1.1 mrg
868 1.1 mrg func_mkdir_p_IFS=$IFS; IFS=:
869 1.1 mrg for _G_dir in $_G_dir_list; do
870 1.1 mrg IFS=$func_mkdir_p_IFS
871 1.1 mrg # mkdir can fail with a 'File exist' error if two processes
872 1.1 mrg # try to create one of the directories concurrently. Don't
873 1.1 mrg # stop in that case!
874 1.1 mrg $MKDIR "$_G_dir" 2>/dev/null || :
875 1.1 mrg done
876 1.1 mrg IFS=$func_mkdir_p_IFS
877 1.1 mrg
878 1.1 mrg # Bail out if we (or some other process) failed to create a directory.
879 1.1 mrg test -d "$_G_directory_path" || \
880 1.1 mrg func_fatal_error "Failed to create '$1'"
881 1.1 mrg fi
882 1.1 mrg }
883 1.1 mrg
884 1.1 mrg
885 1.1 mrg # func_mktempdir [BASENAME]
886 1.1 mrg # -------------------------
887 1.1 mrg # Make a temporary directory that won't clash with other running
888 1.1 mrg # libtool processes, and avoids race conditions if possible. If
889 1.1 mrg # given, BASENAME is the basename for that directory.
890 1.1 mrg func_mktempdir ()
891 1.1 mrg {
892 1.1 mrg $debug_cmd
893 1.1 mrg
894 1.1 mrg _G_template=${TMPDIR-/tmp}/${1-$progname}
895 1.1 mrg
896 1.1 mrg if test : = "$opt_dry_run"; then
897 1.1 mrg # Return a directory name, but don't create it in dry-run mode
898 1.1 mrg _G_tmpdir=$_G_template-$$
899 1.1 mrg else
900 1.1 mrg
901 1.1 mrg # If mktemp works, use that first and foremost
902 1.1 mrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903 1.1 mrg
904 1.1 mrg if test ! -d "$_G_tmpdir"; then
905 1.1 mrg # Failing that, at least try and use $RANDOM to avoid a race
906 1.1 mrg _G_tmpdir=$_G_template-${RANDOM-0}$$
907 1.1 mrg
908 1.1 mrg func_mktempdir_umask=`umask`
909 1.1 mrg umask 0077
910 1.1 mrg $MKDIR "$_G_tmpdir"
911 1.1 mrg umask $func_mktempdir_umask
912 1.1 mrg fi
913 1.1 mrg
914 1.1 mrg # If we're not in dry-run mode, bomb out on failure
915 1.1 mrg test -d "$_G_tmpdir" || \
916 1.1 mrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
917 1.1 mrg fi
918 1.1 mrg
919 1.1 mrg $ECHO "$_G_tmpdir"
920 1.1 mrg }
921 1.1 mrg
922 1.1 mrg
923 1.1 mrg # func_normal_abspath PATH
924 1.1 mrg # ------------------------
925 1.1 mrg # Remove doubled-up and trailing slashes, "." path components,
926 1.1 mrg # and cancel out any ".." path components in PATH after making
927 1.1 mrg # it an absolute path.
928 1.1 mrg func_normal_abspath ()
929 1.1 mrg {
930 1.1 mrg $debug_cmd
931 1.1 mrg
932 1.1 mrg # These SED scripts presuppose an absolute path with a trailing slash.
933 1.1 mrg _G_pathcar='s|^/\([^/]*\).*$|\1|'
934 1.1 mrg _G_pathcdr='s|^/[^/]*||'
935 1.1 mrg _G_removedotparts=':dotsl
936 1.1 mrg s|/\./|/|g
937 1.1 mrg t dotsl
938 1.1 mrg s|/\.$|/|'
939 1.1 mrg _G_collapseslashes='s|/\{1,\}|/|g'
940 1.1 mrg _G_finalslash='s|/*$|/|'
941 1.1 mrg
942 1.1 mrg # Start from root dir and reassemble the path.
943 1.1 mrg func_normal_abspath_result=
944 1.1 mrg func_normal_abspath_tpath=$1
945 1.1 mrg func_normal_abspath_altnamespace=
946 1.1 mrg case $func_normal_abspath_tpath in
947 1.1 mrg "")
948 1.1 mrg # Empty path, that just means $cwd.
949 1.1 mrg func_stripname '' '/' "`pwd`"
950 1.1 mrg func_normal_abspath_result=$func_stripname_result
951 1.1 mrg return
952 1.1 mrg ;;
953 1.1 mrg # The next three entries are used to spot a run of precisely
954 1.1 mrg # two leading slashes without using negated character classes;
955 1.1 mrg # we take advantage of case's first-match behaviour.
956 1.1 mrg ///*)
957 1.1 mrg # Unusual form of absolute path, do nothing.
958 1.1 mrg ;;
959 1.1 mrg //*)
960 1.1 mrg # Not necessarily an ordinary path; POSIX reserves leading '//'
961 1.1 mrg # and for example Cygwin uses it to access remote file shares
962 1.1 mrg # over CIFS/SMB, so we conserve a leading double slash if found.
963 1.1 mrg func_normal_abspath_altnamespace=/
964 1.1 mrg ;;
965 1.1 mrg /*)
966 1.1 mrg # Absolute path, do nothing.
967 1.1 mrg ;;
968 1.1 mrg *)
969 1.1 mrg # Relative path, prepend $cwd.
970 1.1 mrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
971 1.1 mrg ;;
972 1.1 mrg esac
973 1.1 mrg
974 1.1 mrg # Cancel out all the simple stuff to save iterations. We also want
975 1.1 mrg # the path to end with a slash for ease of parsing, so make sure
976 1.1 mrg # there is one (and only one) here.
977 1.1 mrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978 1.1 mrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
979 1.1 mrg while :; do
980 1.1 mrg # Processed it all yet?
981 1.1 mrg if test / = "$func_normal_abspath_tpath"; then
982 1.1 mrg # If we ascended to the root using ".." the result may be empty now.
983 1.1 mrg if test -z "$func_normal_abspath_result"; then
984 1.1 mrg func_normal_abspath_result=/
985 1.1 mrg fi
986 1.1 mrg break
987 1.1 mrg fi
988 1.1 mrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
989 1.1 mrg -e "$_G_pathcar"`
990 1.1 mrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
991 1.1 mrg -e "$_G_pathcdr"`
992 1.1 mrg # Figure out what to do with it
993 1.1 mrg case $func_normal_abspath_tcomponent in
994 1.1 mrg "")
995 1.1 mrg # Trailing empty path component, ignore it.
996 1.1 mrg ;;
997 1.1 mrg ..)
998 1.1 mrg # Parent dir; strip last assembled component from result.
999 1.1 mrg func_dirname "$func_normal_abspath_result"
1000 1.1 mrg func_normal_abspath_result=$func_dirname_result
1001 1.1 mrg ;;
1002 1.1 mrg *)
1003 1.1 mrg # Actual path component, append it.
1004 1.1 mrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1005 1.1 mrg ;;
1006 1.1 mrg esac
1007 1.1 mrg done
1008 1.1 mrg # Restore leading double-slash if one was found on entry.
1009 1.1 mrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1010 1.1 mrg }
1011 1.1 mrg
1012 1.1 mrg
1013 1.1 mrg # func_notquiet ARG...
1014 1.1 mrg # --------------------
1015 1.1 mrg # Echo program name prefixed message only when not in quiet mode.
1016 1.1 mrg func_notquiet ()
1017 1.1 mrg {
1018 1.1 mrg $debug_cmd
1019 1.1 mrg
1020 1.1 mrg $opt_quiet || func_echo ${1+"$@"}
1021 1.1 mrg
1022 1.1 mrg # A bug in bash halts the script if the last line of a function
1023 1.1 mrg # fails when set -e is in force, so we need another command to
1024 1.1 mrg # work around that:
1025 1.1 mrg :
1026 1.1 mrg }
1027 1.1 mrg
1028 1.1 mrg
1029 1.1 mrg # func_relative_path SRCDIR DSTDIR
1030 1.1 mrg # --------------------------------
1031 1.1 mrg # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032 1.1 mrg func_relative_path ()
1033 1.1 mrg {
1034 1.1 mrg $debug_cmd
1035 1.1 mrg
1036 1.1 mrg func_relative_path_result=
1037 1.1 mrg func_normal_abspath "$1"
1038 1.1 mrg func_relative_path_tlibdir=$func_normal_abspath_result
1039 1.1 mrg func_normal_abspath "$2"
1040 1.1 mrg func_relative_path_tbindir=$func_normal_abspath_result
1041 1.1 mrg
1042 1.1 mrg # Ascend the tree starting from libdir
1043 1.1 mrg while :; do
1044 1.1 mrg # check if we have found a prefix of bindir
1045 1.1 mrg case $func_relative_path_tbindir in
1046 1.1 mrg $func_relative_path_tlibdir)
1047 1.1 mrg # found an exact match
1048 1.1 mrg func_relative_path_tcancelled=
1049 1.1 mrg break
1050 1.1 mrg ;;
1051 1.1 mrg $func_relative_path_tlibdir*)
1052 1.1 mrg # found a matching prefix
1053 1.1 mrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054 1.1 mrg func_relative_path_tcancelled=$func_stripname_result
1055 1.1 mrg if test -z "$func_relative_path_result"; then
1056 1.1 mrg func_relative_path_result=.
1057 1.1 mrg fi
1058 1.1 mrg break
1059 1.1 mrg ;;
1060 1.1 mrg *)
1061 1.1 mrg func_dirname $func_relative_path_tlibdir
1062 1.1 mrg func_relative_path_tlibdir=$func_dirname_result
1063 1.1 mrg if test -z "$func_relative_path_tlibdir"; then
1064 1.1 mrg # Have to descend all the way to the root!
1065 1.1 mrg func_relative_path_result=../$func_relative_path_result
1066 1.1 mrg func_relative_path_tcancelled=$func_relative_path_tbindir
1067 1.1 mrg break
1068 1.1 mrg fi
1069 1.1 mrg func_relative_path_result=../$func_relative_path_result
1070 1.1 mrg ;;
1071 1.1 mrg esac
1072 1.1 mrg done
1073 1.1 mrg
1074 1.1 mrg # Now calculate path; take care to avoid doubling-up slashes.
1075 1.1 mrg func_stripname '' '/' "$func_relative_path_result"
1076 1.1 mrg func_relative_path_result=$func_stripname_result
1077 1.1 mrg func_stripname '/' '/' "$func_relative_path_tcancelled"
1078 1.1 mrg if test -n "$func_stripname_result"; then
1079 1.1 mrg func_append func_relative_path_result "/$func_stripname_result"
1080 1.1 mrg fi
1081 1.1 mrg
1082 1.1 mrg # Normalisation. If bindir is libdir, return '.' else relative path.
1083 1.1 mrg if test -n "$func_relative_path_result"; then
1084 1.1 mrg func_stripname './' '' "$func_relative_path_result"
1085 1.1 mrg func_relative_path_result=$func_stripname_result
1086 1.1 mrg fi
1087 1.1 mrg
1088 1.1 mrg test -n "$func_relative_path_result" || func_relative_path_result=.
1089 1.1 mrg
1090 1.1 mrg :
1091 1.1 mrg }
1092 1.1 mrg
1093 1.1 mrg
1094 1.1 mrg # func_quote_for_eval ARG...
1095 1.1 mrg # --------------------------
1096 1.1 mrg # Aesthetically quote ARGs to be evaled later.
1097 1.1 mrg # This function returns two values:
1098 1.1 mrg # i) func_quote_for_eval_result
1099 1.1 mrg # double-quoted, suitable for a subsequent eval
1100 1.1 mrg # ii) func_quote_for_eval_unquoted_result
1101 1.1 mrg # has all characters that are still active within double
1102 1.1 mrg # quotes backslashified.
1103 1.1 mrg func_quote_for_eval ()
1104 1.1 mrg {
1105 1.1 mrg $debug_cmd
1106 1.1 mrg
1107 1.1 mrg func_quote_for_eval_unquoted_result=
1108 1.1 mrg func_quote_for_eval_result=
1109 1.1 mrg while test 0 -lt $#; do
1110 1.1 mrg case $1 in
1111 1.1 mrg *[\\\`\"\$]*)
1112 1.1 mrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1113 1.1 mrg *)
1114 1.1 mrg _G_unquoted_arg=$1 ;;
1115 1.1 mrg esac
1116 1.1 mrg if test -n "$func_quote_for_eval_unquoted_result"; then
1117 1.1 mrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1118 1.1 mrg else
1119 1.1 mrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1120 1.1 mrg fi
1121 1.1 mrg
1122 1.1 mrg case $_G_unquoted_arg in
1123 1.1 mrg # Double-quote args containing shell metacharacters to delay
1124 1.1 mrg # word splitting, command substitution and variable expansion
1125 1.1 mrg # for a subsequent eval.
1126 1.1 mrg # Many Bourne shells cannot handle close brackets correctly
1127 1.1 mrg # in scan sets, so we specify it separately.
1128 1.1 mrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1129 1.1 mrg _G_quoted_arg=\"$_G_unquoted_arg\"
1130 1.1 mrg ;;
1131 1.1 mrg *)
1132 1.1 mrg _G_quoted_arg=$_G_unquoted_arg
1133 1.1 mrg ;;
1134 1.1 mrg esac
1135 1.1 mrg
1136 1.1 mrg if test -n "$func_quote_for_eval_result"; then
1137 1.1 mrg func_append func_quote_for_eval_result " $_G_quoted_arg"
1138 1.1 mrg else
1139 1.1 mrg func_append func_quote_for_eval_result "$_G_quoted_arg"
1140 1.1 mrg fi
1141 1.1 mrg shift
1142 1.1 mrg done
1143 1.1 mrg }
1144 1.1 mrg
1145 1.1 mrg
1146 1.1 mrg # func_quote_for_expand ARG
1147 1.1 mrg # -------------------------
1148 1.1 mrg # Aesthetically quote ARG to be evaled later; same as above,
1149 1.1 mrg # but do not quote variable references.
1150 1.1 mrg func_quote_for_expand ()
1151 1.1 mrg {
1152 1.1 mrg $debug_cmd
1153 1.1 mrg
1154 1.1 mrg case $1 in
1155 1.1 mrg *[\\\`\"]*)
1156 1.1 mrg _G_arg=`$ECHO "$1" | $SED \
1157 1.1 mrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1158 1.1 mrg *)
1159 1.1 mrg _G_arg=$1 ;;
1160 1.1 mrg esac
1161 1.1 mrg
1162 1.1 mrg case $_G_arg in
1163 1.1 mrg # Double-quote args containing shell metacharacters to delay
1164 1.1 mrg # word splitting and command substitution for a subsequent eval.
1165 1.1 mrg # Many Bourne shells cannot handle close brackets correctly
1166 1.1 mrg # in scan sets, so we specify it separately.
1167 1.1 mrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1168 1.1 mrg _G_arg=\"$_G_arg\"
1169 1.1 mrg ;;
1170 1.1 mrg esac
1171 1.1 mrg
1172 1.1 mrg func_quote_for_expand_result=$_G_arg
1173 1.1 mrg }
1174 1.1 mrg
1175 1.1 mrg
1176 1.1 mrg # func_stripname PREFIX SUFFIX NAME
1177 1.1 mrg # ---------------------------------
1178 1.1 mrg # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179 1.1 mrg # PREFIX and SUFFIX must not contain globbing or regex special
1180 1.1 mrg # characters, hashes, percent signs, but SUFFIX may contain a leading
1181 1.1 mrg # dot (in which case that matches only a dot).
1182 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"; then
1183 1.1 mrg eval 'func_stripname ()
1184 1.1 mrg {
1185 1.1 mrg $debug_cmd
1186 1.1 mrg
1187 1.1 mrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188 1.1 mrg # positional parameters, so assign one to ordinary variable first.
1189 1.1 mrg func_stripname_result=$3
1190 1.1 mrg func_stripname_result=${func_stripname_result#"$1"}
1191 1.1 mrg func_stripname_result=${func_stripname_result%"$2"}
1192 1.1 mrg }'
1193 1.1 mrg else
1194 1.1 mrg func_stripname ()
1195 1.1 mrg {
1196 1.1 mrg $debug_cmd
1197 1.1 mrg
1198 1.1 mrg case $2 in
1199 1.1 mrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200 1.1 mrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1201 1.1 mrg esac
1202 1.1 mrg }
1203 1.1 mrg fi
1204 1.1 mrg
1205 1.1 mrg
1206 1.1 mrg # func_show_eval CMD [FAIL_EXP]
1207 1.1 mrg # -----------------------------
1208 1.1 mrg # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1209 1.1 mrg # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1210 1.1 mrg # is given, then evaluate it.
1211 1.1 mrg func_show_eval ()
1212 1.1 mrg {
1213 1.1 mrg $debug_cmd
1214 1.1 mrg
1215 1.1 mrg _G_cmd=$1
1216 1.1 mrg _G_fail_exp=${2-':'}
1217 1.1 mrg
1218 1.1 mrg func_quote_for_expand "$_G_cmd"
1219 1.1 mrg eval "func_notquiet $func_quote_for_expand_result"
1220 1.1 mrg
1221 1.1 mrg $opt_dry_run || {
1222 1.1 mrg eval "$_G_cmd"
1223 1.1 mrg _G_status=$?
1224 1.1 mrg if test 0 -ne "$_G_status"; then
1225 1.1 mrg eval "(exit $_G_status); $_G_fail_exp"
1226 1.1 mrg fi
1227 1.1 mrg }
1228 1.1 mrg }
1229 1.1 mrg
1230 1.1 mrg
1231 1.1 mrg # func_show_eval_locale CMD [FAIL_EXP]
1232 1.1 mrg # ------------------------------------
1233 1.1 mrg # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1234 1.1 mrg # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1235 1.1 mrg # is given, then evaluate it. Use the saved locale for evaluation.
1236 1.1 mrg func_show_eval_locale ()
1237 1.1 mrg {
1238 1.1 mrg $debug_cmd
1239 1.1 mrg
1240 1.1 mrg _G_cmd=$1
1241 1.1 mrg _G_fail_exp=${2-':'}
1242 1.1 mrg
1243 1.1 mrg $opt_quiet || {
1244 1.1 mrg func_quote_for_expand "$_G_cmd"
1245 1.1 mrg eval "func_echo $func_quote_for_expand_result"
1246 1.1 mrg }
1247 1.1 mrg
1248 1.1 mrg $opt_dry_run || {
1249 1.1 mrg eval "$_G_user_locale
1250 1.1 mrg $_G_cmd"
1251 1.1 mrg _G_status=$?
1252 1.1 mrg eval "$_G_safe_locale"
1253 1.1 mrg if test 0 -ne "$_G_status"; then
1254 1.1 mrg eval "(exit $_G_status); $_G_fail_exp"
1255 1.1 mrg fi
1256 1.1 mrg }
1257 1.1 mrg }
1258 1.1 mrg
1259 1.1 mrg
1260 1.1 mrg # func_tr_sh
1261 1.1 mrg # ----------
1262 1.1 mrg # Turn $1 into a string suitable for a shell variable name.
1263 1.1 mrg # Result is stored in $func_tr_sh_result. All characters
1264 1.1 mrg # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1265 1.1 mrg # if $1 begins with a digit, a '_' is prepended as well.
1266 1.1 mrg func_tr_sh ()
1267 1.1 mrg {
1268 1.1 mrg $debug_cmd
1269 1.1 mrg
1270 1.1 mrg case $1 in
1271 1.1 mrg [0-9]* | *[!a-zA-Z0-9_]*)
1272 1.1 mrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1273 1.1 mrg ;;
1274 1.1 mrg * )
1275 1.1 mrg func_tr_sh_result=$1
1276 1.1 mrg ;;
1277 1.1 mrg esac
1278 1.1 mrg }
1279 1.1 mrg
1280 1.1 mrg
1281 1.1 mrg # func_verbose ARG...
1282 1.1 mrg # -------------------
1283 1.1 mrg # Echo program name prefixed message in verbose mode only.
1284 1.1 mrg func_verbose ()
1285 1.1 mrg {
1286 1.1 mrg $debug_cmd
1287 1.1 mrg
1288 1.1 mrg $opt_verbose && func_echo "$*"
1289 1.1 mrg
1290 1.1 mrg :
1291 1.1 mrg }
1292 1.1 mrg
1293 1.1 mrg
1294 1.1 mrg # func_warn_and_continue ARG...
1295 1.1 mrg # -----------------------------
1296 1.1 mrg # Echo program name prefixed warning message to standard error.
1297 1.1 mrg func_warn_and_continue ()
1298 1.1 mrg {
1299 1.1 mrg $debug_cmd
1300 1.1 mrg
1301 1.1 mrg $require_term_colors
1302 1.1 mrg
1303 1.1 mrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1304 1.1 mrg }
1305 1.1 mrg
1306 1.1 mrg
1307 1.1 mrg # func_warning CATEGORY ARG...
1308 1.1 mrg # ----------------------------
1309 1.1 mrg # Echo program name prefixed warning message to standard error. Warning
1310 1.1 mrg # messages can be filtered according to CATEGORY, where this function
1311 1.1 mrg # elides messages where CATEGORY is not listed in the global variable
1312 1.1 mrg # 'opt_warning_types'.
1313 1.1 mrg func_warning ()
1314 1.1 mrg {
1315 1.1 mrg $debug_cmd
1316 1.1 mrg
1317 1.1 mrg # CATEGORY must be in the warning_categories list!
1318 1.1 mrg case " $warning_categories " in
1319 1.1 mrg *" $1 "*) ;;
1320 1.1 mrg *) func_internal_error "invalid warning category '$1'" ;;
1321 1.1 mrg esac
1322 1.1 mrg
1323 1.1 mrg _G_category=$1
1324 1.1 mrg shift
1325 1.1 mrg
1326 1.1 mrg case " $opt_warning_types " in
1327 1.1 mrg *" $_G_category "*) $warning_func ${1+"$@"} ;;
1328 1.1 mrg esac
1329 1.1 mrg }
1330 1.1 mrg
1331 1.1 mrg
1332 1.1 mrg # func_sort_ver VER1 VER2
1333 1.1 mrg # -----------------------
1334 1.1 mrg # 'sort -V' is not generally available.
1335 1.1 mrg # Note this deviates from the version comparison in automake
1336 1.1 mrg # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337 1.1 mrg # but this should suffice as we won't be specifying old
1338 1.1 mrg # version formats or redundant trailing .0 in bootstrap.conf.
1339 1.1 mrg # If we did want full compatibility then we should probably
1340 1.1 mrg # use m4_version_compare from autoconf.
1341 1.1 mrg func_sort_ver ()
1342 1.1 mrg {
1343 1.1 mrg $debug_cmd
1344 1.1 mrg
1345 1.1 mrg printf '%s\n%s\n' "$1" "$2" \
1346 1.1 mrg | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
1347 1.1 mrg }
1348 1.1 mrg
1349 1.1 mrg # func_lt_ver PREV CURR
1350 1.1 mrg # ---------------------
1351 1.1 mrg # Return true if PREV and CURR are in the correct order according to
1352 1.1 mrg # func_sort_ver, otherwise false. Use it like this:
1353 1.1 mrg #
1354 1.1 mrg # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1355 1.1 mrg func_lt_ver ()
1356 1.1 mrg {
1357 1.1 mrg $debug_cmd
1358 1.1 mrg
1359 1.1 mrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1360 1.1 mrg }
1361 1.1 mrg
1362 1.1 mrg
1363 1.1 mrg # Local variables:
1364 1.1 mrg # mode: shell-script
1365 1.1 mrg # sh-indentation: 2
1366 1.1 mrg # eval: (add-hook 'before-save-hook 'time-stamp)
1367 1.1 mrg # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368 1.1 mrg # time-stamp-time-zone: "UTC"
1369 1.1 mrg # End:
1370 1.1 mrg #!/bin/sh
1371 1.1 mrg
1372 1.1 mrg # Set a version string for this script.
1373 1.1 mrg scriptversion=2014-01-07.03; # UTC
1374 1.1 mrg
1375 1.1 mrg # A portable, pluggable option parser for Bourne shell.
1376 1.1 mrg # Written by Gary V. Vaughan, 2010
1377 1.1 mrg
1378 1.1 mrg # Copyright (C) 2010-2015 Free Software Foundation, Inc.
1379 1.1 mrg # This is free software; see the source for copying conditions. There is NO
1380 1.1 mrg # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1381 1.1 mrg
1382 1.1 mrg # This program is free software: you can redistribute it and/or modify
1383 1.1 mrg # it under the terms of the GNU General Public License as published by
1384 1.1 mrg # the Free Software Foundation, either version 3 of the License, or
1385 1.1 mrg # (at your option) any later version.
1386 1.1 mrg
1387 1.1 mrg # This program is distributed in the hope that it will be useful,
1388 1.1 mrg # but WITHOUT ANY WARRANTY; without even the implied warranty of
1389 1.1 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1390 1.1 mrg # GNU General Public License for more details.
1391 1.1 mrg
1392 1.1 mrg # You should have received a copy of the GNU General Public License
1393 1.1 mrg # along with this program. If not, see <http://www.gnu.org/licenses/>.
1394 1.1 mrg
1395 1.1 mrg # Please report bugs or propose patches to gary (at] gnu.org.
1396 1.1 mrg
1397 1.1 mrg
1398 1.1 mrg ## ------ ##
1399 1.1 mrg ## Usage. ##
1400 1.1 mrg ## ------ ##
1401 1.1 mrg
1402 1.1 mrg # This file is a library for parsing options in your shell scripts along
1403 1.1 mrg # with assorted other useful supporting features that you can make use
1404 1.1 mrg # of too.
1405 1.1 mrg #
1406 1.1 mrg # For the simplest scripts you might need only:
1407 1.1 mrg #
1408 1.1 mrg # #!/bin/sh
1409 1.1 mrg # . relative/path/to/funclib.sh
1410 1.1 mrg # . relative/path/to/options-parser
1411 1.1 mrg # scriptversion=1.0
1412 1.1 mrg # func_options ${1+"$@"}
1413 1.1 mrg # eval set dummy "$func_options_result"; shift
1414 1.1 mrg # ...rest of your script...
1415 1.1 mrg #
1416 1.1 mrg # In order for the '--version' option to work, you will need to have a
1417 1.1 mrg # suitably formatted comment like the one at the top of this file
1418 1.1 mrg # starting with '# Written by ' and ending with '# warranty; '.
1419 1.1 mrg #
1420 1.1 mrg # For '-h' and '--help' to work, you will also need a one line
1421 1.1 mrg # description of your script's purpose in a comment directly above the
1422 1.1 mrg # '# Written by ' line, like the one at the top of this file.
1423 1.1 mrg #
1424 1.1 mrg # The default options also support '--debug', which will turn on shell
1425 1.1 mrg # execution tracing (see the comment above debug_cmd below for another
1426 1.1 mrg # use), and '--verbose' and the func_verbose function to allow your script
1427 1.1 mrg # to display verbose messages only when your user has specified
1428 1.1 mrg # '--verbose'.
1429 1.1 mrg #
1430 1.1 mrg # After sourcing this file, you can plug processing for additional
1431 1.1 mrg # options by amending the variables from the 'Configuration' section
1432 1.1 mrg # below, and following the instructions in the 'Option parsing'
1433 1.1 mrg # section further down.
1434 1.1 mrg
1435 1.1 mrg ## -------------- ##
1436 1.1 mrg ## Configuration. ##
1437 1.1 mrg ## -------------- ##
1438 1.1 mrg
1439 1.1 mrg # You should override these variables in your script after sourcing this
1440 1.1 mrg # file so that they reflect the customisations you have added to the
1441 1.1 mrg # option parser.
1442 1.1 mrg
1443 1.1 mrg # The usage line for option parsing errors and the start of '-h' and
1444 1.1 mrg # '--help' output messages. You can embed shell variables for delayed
1445 1.1 mrg # expansion at the time the message is displayed, but you will need to
1446 1.1 mrg # quote other shell meta-characters carefully to prevent them being
1447 1.1 mrg # expanded when the contents are evaled.
1448 1.1 mrg usage='$progpath [OPTION]...'
1449 1.1 mrg
1450 1.1 mrg # Short help message in response to '-h' and '--help'. Add to this or
1451 1.1 mrg # override it after sourcing this library to reflect the full set of
1452 1.1 mrg # options your script accepts.
1453 1.1 mrg usage_message="\
1454 1.1 mrg --debug enable verbose shell tracing
1455 1.1 mrg -W, --warnings=CATEGORY
1456 1.1 mrg report the warnings falling in CATEGORY [all]
1457 1.1 mrg -v, --verbose verbosely report processing
1458 1.1 mrg --version print version information and exit
1459 1.1 mrg -h, --help print short or long help message and exit
1460 1.1 mrg "
1461 1.1 mrg
1462 1.1 mrg # Additional text appended to 'usage_message' in response to '--help'.
1463 1.1 mrg long_help_message="
1464 1.1 mrg Warning categories include:
1465 1.1 mrg 'all' show all warnings
1466 1.1 mrg 'none' turn off all the warnings
1467 1.1 mrg 'error' warnings are treated as fatal errors"
1468 1.1 mrg
1469 1.1 mrg # Help message printed before fatal option parsing errors.
1470 1.1 mrg fatal_help="Try '\$progname --help' for more information."
1471 1.1 mrg
1472 1.1 mrg
1473 1.1 mrg
1474 1.1 mrg ## ------------------------- ##
1475 1.1 mrg ## Hook function management. ##
1476 1.1 mrg ## ------------------------- ##
1477 1.1 mrg
1478 1.1 mrg # This section contains functions for adding, removing, and running hooks
1479 1.1 mrg # to the main code. A hook is just a named list of of function, that can
1480 1.1 mrg # be run in order later on.
1481 1.1 mrg
1482 1.1 mrg # func_hookable FUNC_NAME
1483 1.1 mrg # -----------------------
1484 1.1 mrg # Declare that FUNC_NAME will run hooks added with
1485 1.1 mrg # 'func_add_hook FUNC_NAME ...'.
1486 1.1 mrg func_hookable ()
1487 1.1 mrg {
1488 1.1 mrg $debug_cmd
1489 1.1 mrg
1490 1.1 mrg func_append hookable_fns " $1"
1491 1.1 mrg }
1492 1.1 mrg
1493 1.1 mrg
1494 1.1 mrg # func_add_hook FUNC_NAME HOOK_FUNC
1495 1.1 mrg # ---------------------------------
1496 1.1 mrg # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1497 1.1 mrg # first have been declared "hookable" by a call to 'func_hookable'.
1498 1.1 mrg func_add_hook ()
1499 1.1 mrg {
1500 1.1 mrg $debug_cmd
1501 1.1 mrg
1502 1.1 mrg case " $hookable_fns " in
1503 1.1 mrg *" $1 "*) ;;
1504 1.1 mrg *) func_fatal_error "'$1' does not accept hook functions." ;;
1505 1.1 mrg esac
1506 1.1 mrg
1507 1.1 mrg eval func_append ${1}_hooks '" $2"'
1508 1.1 mrg }
1509 1.1 mrg
1510 1.1 mrg
1511 1.1 mrg # func_remove_hook FUNC_NAME HOOK_FUNC
1512 1.1 mrg # ------------------------------------
1513 1.1 mrg # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1514 1.1 mrg func_remove_hook ()
1515 1.1 mrg {
1516 1.1 mrg $debug_cmd
1517 1.1 mrg
1518 1.1 mrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1519 1.1 mrg }
1520 1.1 mrg
1521 1.1 mrg
1522 1.1 mrg # func_run_hooks FUNC_NAME [ARG]...
1523 1.1 mrg # ---------------------------------
1524 1.1 mrg # Run all hook functions registered to FUNC_NAME.
1525 1.1 mrg # It is assumed that the list of hook functions contains nothing more
1526 1.1 mrg # than a whitespace-delimited list of legal shell function names, and
1527 1.1 mrg # no effort is wasted trying to catch shell meta-characters or preserve
1528 1.1 mrg # whitespace.
1529 1.1 mrg func_run_hooks ()
1530 1.1 mrg {
1531 1.1 mrg $debug_cmd
1532 1.1 mrg
1533 1.1 mrg case " $hookable_fns " in
1534 1.1 mrg *" $1 "*) ;;
1535 1.1 mrg *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1536 1.1 mrg esac
1537 1.1 mrg
1538 1.1 mrg eval _G_hook_fns=\$$1_hooks; shift
1539 1.1 mrg
1540 1.1 mrg for _G_hook in $_G_hook_fns; do
1541 1.1 mrg eval $_G_hook '"$@"'
1542 1.1 mrg
1543 1.1 mrg # store returned options list back into positional
1544 1.1 mrg # parameters for next 'cmd' execution.
1545 1.1 mrg eval _G_hook_result=\$${_G_hook}_result
1546 1.1 mrg eval set dummy "$_G_hook_result"; shift
1547 1.1 mrg done
1548 1.1 mrg
1549 1.1 mrg func_quote_for_eval ${1+"$@"}
1550 1.1 mrg func_run_hooks_result=$func_quote_for_eval_result
1551 1.1 mrg }
1552 1.1 mrg
1553 1.1 mrg
1554 1.1 mrg
1555 1.1 mrg ## --------------- ##
1556 1.1 mrg ## Option parsing. ##
1557 1.1 mrg ## --------------- ##
1558 1.1 mrg
1559 1.1 mrg # In order to add your own option parsing hooks, you must accept the
1560 1.1 mrg # full positional parameter list in your hook function, remove any
1561 1.1 mrg # options that you action, and then pass back the remaining unprocessed
1562 1.1 mrg # options in '<hooked_function_name>_result', escaped suitably for
1563 1.1 mrg # 'eval'. Like this:
1564 1.1 mrg #
1565 1.1 mrg # my_options_prep ()
1566 1.1 mrg # {
1567 1.1 mrg # $debug_cmd
1568 1.1 mrg #
1569 1.1 mrg # # Extend the existing usage message.
1570 1.1 mrg # usage_message=$usage_message'
1571 1.1 mrg # -s, --silent don'\''t print informational messages
1572 1.1 mrg # '
1573 1.1 mrg #
1574 1.1 mrg # func_quote_for_eval ${1+"$@"}
1575 1.1 mrg # my_options_prep_result=$func_quote_for_eval_result
1576 1.1 mrg # }
1577 1.1 mrg # func_add_hook func_options_prep my_options_prep
1578 1.1 mrg #
1579 1.1 mrg #
1580 1.1 mrg # my_silent_option ()
1581 1.1 mrg # {
1582 1.1 mrg # $debug_cmd
1583 1.1 mrg #
1584 1.1 mrg # # Note that for efficiency, we parse as many options as we can
1585 1.1 mrg # # recognise in a loop before passing the remainder back to the
1586 1.1 mrg # # caller on the first unrecognised argument we encounter.
1587 1.1 mrg # while test $# -gt 0; do
1588 1.1 mrg # opt=$1; shift
1589 1.1 mrg # case $opt in
1590 1.1 mrg # --silent|-s) opt_silent=: ;;
1591 1.1 mrg # # Separate non-argument short options:
1592 1.1 mrg # -s*) func_split_short_opt "$_G_opt"
1593 1.1 mrg # set dummy "$func_split_short_opt_name" \
1594 1.1 mrg # "-$func_split_short_opt_arg" ${1+"$@"}
1595 1.1 mrg # shift
1596 1.1 mrg # ;;
1597 1.1 mrg # *) set dummy "$_G_opt" "$*"; shift; break ;;
1598 1.1 mrg # esac
1599 1.1 mrg # done
1600 1.1 mrg #
1601 1.1 mrg # func_quote_for_eval ${1+"$@"}
1602 1.1 mrg # my_silent_option_result=$func_quote_for_eval_result
1603 1.1 mrg # }
1604 1.1 mrg # func_add_hook func_parse_options my_silent_option
1605 1.1 mrg #
1606 1.1 mrg #
1607 1.1 mrg # my_option_validation ()
1608 1.1 mrg # {
1609 1.1 mrg # $debug_cmd
1610 1.1 mrg #
1611 1.1 mrg # $opt_silent && $opt_verbose && func_fatal_help "\
1612 1.1 mrg # '--silent' and '--verbose' options are mutually exclusive."
1613 1.1 mrg #
1614 1.1 mrg # func_quote_for_eval ${1+"$@"}
1615 1.1 mrg # my_option_validation_result=$func_quote_for_eval_result
1616 1.1 mrg # }
1617 1.1 mrg # func_add_hook func_validate_options my_option_validation
1618 1.1 mrg #
1619 1.1 mrg # You'll alse need to manually amend $usage_message to reflect the extra
1620 1.1 mrg # options you parse. It's preferable to append if you can, so that
1621 1.1 mrg # multiple option parsing hooks can be added safely.
1622 1.1 mrg
1623 1.1 mrg
1624 1.1 mrg # func_options [ARG]...
1625 1.1 mrg # ---------------------
1626 1.1 mrg # All the functions called inside func_options are hookable. See the
1627 1.1 mrg # individual implementations for details.
1628 1.1 mrg func_hookable func_options
1629 1.1 mrg func_options ()
1630 1.1 mrg {
1631 1.1 mrg $debug_cmd
1632 1.1 mrg
1633 1.1 mrg func_options_prep ${1+"$@"}
1634 1.1 mrg eval func_parse_options \
1635 1.1 mrg ${func_options_prep_result+"$func_options_prep_result"}
1636 1.1 mrg eval func_validate_options \
1637 1.1 mrg ${func_parse_options_result+"$func_parse_options_result"}
1638 1.1 mrg
1639 1.1 mrg eval func_run_hooks func_options \
1640 1.1 mrg ${func_validate_options_result+"$func_validate_options_result"}
1641 1.1 mrg
1642 1.1 mrg # save modified positional parameters for caller
1643 1.1 mrg func_options_result=$func_run_hooks_result
1644 1.1 mrg }
1645 1.1 mrg
1646 1.1 mrg
1647 1.1 mrg # func_options_prep [ARG]...
1648 1.1 mrg # --------------------------
1649 1.1 mrg # All initialisations required before starting the option parse loop.
1650 1.1 mrg # Note that when calling hook functions, we pass through the list of
1651 1.1 mrg # positional parameters. If a hook function modifies that list, and
1652 1.1 mrg # needs to propogate that back to rest of this script, then the complete
1653 1.1 mrg # modified list must be put in 'func_run_hooks_result' before
1654 1.1 mrg # returning.
1655 1.1 mrg func_hookable func_options_prep
1656 1.1 mrg func_options_prep ()
1657 1.1 mrg {
1658 1.1 mrg $debug_cmd
1659 1.1 mrg
1660 1.1 mrg # Option defaults:
1661 1.1 mrg opt_verbose=false
1662 1.1 mrg opt_warning_types=
1663 1.1 mrg
1664 1.1 mrg func_run_hooks func_options_prep ${1+"$@"}
1665 1.1 mrg
1666 1.1 mrg # save modified positional parameters for caller
1667 1.1 mrg func_options_prep_result=$func_run_hooks_result
1668 1.1 mrg }
1669 1.1 mrg
1670 1.1 mrg
1671 1.1 mrg # func_parse_options [ARG]...
1672 1.1 mrg # ---------------------------
1673 1.1 mrg # The main option parsing loop.
1674 1.1 mrg func_hookable func_parse_options
1675 1.1 mrg func_parse_options ()
1676 1.1 mrg {
1677 1.1 mrg $debug_cmd
1678 1.1 mrg
1679 1.1 mrg func_parse_options_result=
1680 1.1 mrg
1681 1.1 mrg # this just eases exit handling
1682 1.1 mrg while test $# -gt 0; do
1683 1.1 mrg # Defer to hook functions for initial option parsing, so they
1684 1.1 mrg # get priority in the event of reusing an option name.
1685 1.1 mrg func_run_hooks func_parse_options ${1+"$@"}
1686 1.1 mrg
1687 1.1 mrg # Adjust func_parse_options positional parameters to match
1688 1.1 mrg eval set dummy "$func_run_hooks_result"; shift
1689 1.1 mrg
1690 1.1 mrg # Break out of the loop if we already parsed every option.
1691 1.1 mrg test $# -gt 0 || break
1692 1.1 mrg
1693 1.1 mrg _G_opt=$1
1694 1.1 mrg shift
1695 1.1 mrg case $_G_opt in
1696 1.1 mrg --debug|-x) debug_cmd='set -x'
1697 1.1 mrg func_echo "enabling shell trace mode"
1698 1.1 mrg $debug_cmd
1699 1.1 mrg ;;
1700 1.1 mrg
1701 1.1 mrg --no-warnings|--no-warning|--no-warn)
1702 1.1 mrg set dummy --warnings none ${1+"$@"}
1703 1.1 mrg shift
1704 1.1 mrg ;;
1705 1.1 mrg
1706 1.1 mrg --warnings|--warning|-W)
1707 1.1 mrg test $# = 0 && func_missing_arg $_G_opt && break
1708 1.1 mrg case " $warning_categories $1" in
1709 1.1 mrg *" $1 "*)
1710 1.1 mrg # trailing space prevents matching last $1 above
1711 1.1 mrg func_append_uniq opt_warning_types " $1"
1712 1.1 mrg ;;
1713 1.1 mrg *all)
1714 1.1 mrg opt_warning_types=$warning_categories
1715 1.1 mrg ;;
1716 1.1 mrg *none)
1717 1.1 mrg opt_warning_types=none
1718 1.1 mrg warning_func=:
1719 1.1 mrg ;;
1720 1.1 mrg *error)
1721 1.1 mrg opt_warning_types=$warning_categories
1722 1.1 mrg warning_func=func_fatal_error
1723 1.1 mrg ;;
1724 1.1 mrg *)
1725 1.1 mrg func_fatal_error \
1726 1.1 mrg "unsupported warning category: '$1'"
1727 1.1 mrg ;;
1728 1.1 mrg esac
1729 1.1 mrg shift
1730 1.1 mrg ;;
1731 1.1 mrg
1732 1.1 mrg --verbose|-v) opt_verbose=: ;;
1733 1.1 mrg --version) func_version ;;
1734 1.1 mrg -\?|-h) func_usage ;;
1735 1.1 mrg --help) func_help ;;
1736 1.1 mrg
1737 1.1 mrg # Separate optargs to long options (plugins may need this):
1738 1.1 mrg --*=*) func_split_equals "$_G_opt"
1739 1.1 mrg set dummy "$func_split_equals_lhs" \
1740 1.1 mrg "$func_split_equals_rhs" ${1+"$@"}
1741 1.1 mrg shift
1742 1.1 mrg ;;
1743 1.1 mrg
1744 1.1 mrg # Separate optargs to short options:
1745 1.1 mrg -W*)
1746 1.1 mrg func_split_short_opt "$_G_opt"
1747 1.1 mrg set dummy "$func_split_short_opt_name" \
1748 1.1 mrg "$func_split_short_opt_arg" ${1+"$@"}
1749 1.1 mrg shift
1750 1.1 mrg ;;
1751 1.1 mrg
1752 1.1 mrg # Separate non-argument short options:
1753 1.1 mrg -\?*|-h*|-v*|-x*)
1754 1.1 mrg func_split_short_opt "$_G_opt"
1755 1.1 mrg set dummy "$func_split_short_opt_name" \
1756 1.1 mrg "-$func_split_short_opt_arg" ${1+"$@"}
1757 1.1 mrg shift
1758 1.1 mrg ;;
1759 1.1 mrg
1760 1.1 mrg --) break ;;
1761 1.1 mrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
1762 1.1 mrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1763 1.1 mrg esac
1764 1.1 mrg done
1765 1.1 mrg
1766 1.1 mrg # save modified positional parameters for caller
1767 1.1 mrg func_quote_for_eval ${1+"$@"}
1768 1.1 mrg func_parse_options_result=$func_quote_for_eval_result
1769 1.1 mrg }
1770 1.1 mrg
1771 1.1 mrg
1772 1.1 mrg # func_validate_options [ARG]...
1773 1.1 mrg # ------------------------------
1774 1.1 mrg # Perform any sanity checks on option settings and/or unconsumed
1775 1.1 mrg # arguments.
1776 1.1 mrg func_hookable func_validate_options
1777 1.1 mrg func_validate_options ()
1778 1.1 mrg {
1779 1.1 mrg $debug_cmd
1780 1.1 mrg
1781 1.1 mrg # Display all warnings if -W was not given.
1782 1.1 mrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783 1.1 mrg
1784 1.1 mrg func_run_hooks func_validate_options ${1+"$@"}
1785 1.1 mrg
1786 1.1 mrg # Bail if the options were screwed!
1787 1.1 mrg $exit_cmd $EXIT_FAILURE
1788 1.1 mrg
1789 1.1 mrg # save modified positional parameters for caller
1790 1.1 mrg func_validate_options_result=$func_run_hooks_result
1791 1.1 mrg }
1792 1.1 mrg
1793 1.1 mrg
1794 1.1 mrg
1795 1.1 mrg ## ----------------- ##
1796 1.1 mrg ## Helper functions. ##
1797 1.1 mrg ## ----------------- ##
1798 1.1 mrg
1799 1.1 mrg # This section contains the helper functions used by the rest of the
1800 1.1 mrg # hookable option parser framework in ascii-betical order.
1801 1.1 mrg
1802 1.1 mrg
1803 1.1 mrg # func_fatal_help ARG...
1804 1.1 mrg # ----------------------
1805 1.1 mrg # Echo program name prefixed message to standard error, followed by
1806 1.1 mrg # a help hint, and exit.
1807 1.1 mrg func_fatal_help ()
1808 1.1 mrg {
1809 1.1 mrg $debug_cmd
1810 1.1 mrg
1811 1.1 mrg eval \$ECHO \""Usage: $usage"\"
1812 1.1 mrg eval \$ECHO \""$fatal_help"\"
1813 1.1 mrg func_error ${1+"$@"}
1814 1.1 mrg exit $EXIT_FAILURE
1815 1.1 mrg }
1816 1.1 mrg
1817 1.1 mrg
1818 1.1 mrg # func_help
1819 1.1 mrg # ---------
1820 1.1 mrg # Echo long help message to standard output and exit.
1821 1.1 mrg func_help ()
1822 1.1 mrg {
1823 1.1 mrg $debug_cmd
1824 1.1 mrg
1825 1.1 mrg func_usage_message
1826 1.1 mrg $ECHO "$long_help_message"
1827 1.1 mrg exit 0
1828 1.1 mrg }
1829 1.1 mrg
1830 1.1 mrg
1831 1.1 mrg # func_missing_arg ARGNAME
1832 1.1 mrg # ------------------------
1833 1.1 mrg # Echo program name prefixed message to standard error and set global
1834 1.1 mrg # exit_cmd.
1835 1.1 mrg func_missing_arg ()
1836 1.1 mrg {
1837 1.1 mrg $debug_cmd
1838 1.1 mrg
1839 1.1 mrg func_error "Missing argument for '$1'."
1840 1.1 mrg exit_cmd=exit
1841 1.1 mrg }
1842 1.1 mrg
1843 1.1 mrg
1844 1.1 mrg # func_split_equals STRING
1845 1.1 mrg # ------------------------
1846 1.1 mrg # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1847 1.1 mrg # splitting STRING at the '=' sign.
1848 1.1 mrg test -z "$_G_HAVE_XSI_OPS" \
1849 1.1 mrg && (eval 'x=a/b/c;
1850 1.1 mrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1851 1.1 mrg && _G_HAVE_XSI_OPS=yes
1852 1.1 mrg
1853 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"
1854 1.1 mrg then
1855 1.1 mrg # This is an XSI compatible shell, allowing a faster implementation...
1856 1.1 mrg eval 'func_split_equals ()
1857 1.1 mrg {
1858 1.1 mrg $debug_cmd
1859 1.1 mrg
1860 1.1 mrg func_split_equals_lhs=${1%%=*}
1861 1.1 mrg func_split_equals_rhs=${1#*=}
1862 1.1 mrg test "x$func_split_equals_lhs" = "x$1" \
1863 1.1 mrg && func_split_equals_rhs=
1864 1.1 mrg }'
1865 1.1 mrg else
1866 1.1 mrg # ...otherwise fall back to using expr, which is often a shell builtin.
1867 1.1 mrg func_split_equals ()
1868 1.1 mrg {
1869 1.1 mrg $debug_cmd
1870 1.1 mrg
1871 1.1 mrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1872 1.1 mrg func_split_equals_rhs=
1873 1.1 mrg test "x$func_split_equals_lhs" = "x$1" \
1874 1.1 mrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1875 1.1 mrg }
1876 1.1 mrg fi #func_split_equals
1877 1.1 mrg
1878 1.1 mrg
1879 1.1 mrg # func_split_short_opt SHORTOPT
1880 1.1 mrg # -----------------------------
1881 1.1 mrg # Set func_split_short_opt_name and func_split_short_opt_arg shell
1882 1.1 mrg # variables after splitting SHORTOPT after the 2nd character.
1883 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"
1884 1.1 mrg then
1885 1.1 mrg # This is an XSI compatible shell, allowing a faster implementation...
1886 1.1 mrg eval 'func_split_short_opt ()
1887 1.1 mrg {
1888 1.1 mrg $debug_cmd
1889 1.1 mrg
1890 1.1 mrg func_split_short_opt_arg=${1#??}
1891 1.1 mrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1892 1.1 mrg }'
1893 1.1 mrg else
1894 1.1 mrg # ...otherwise fall back to using expr, which is often a shell builtin.
1895 1.1 mrg func_split_short_opt ()
1896 1.1 mrg {
1897 1.1 mrg $debug_cmd
1898 1.1 mrg
1899 1.1 mrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1900 1.1 mrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1901 1.1 mrg }
1902 1.1 mrg fi #func_split_short_opt
1903 1.1 mrg
1904 1.1 mrg
1905 1.1 mrg # func_usage
1906 1.1 mrg # ----------
1907 1.1 mrg # Echo short help message to standard output and exit.
1908 1.1 mrg func_usage ()
1909 1.1 mrg {
1910 1.1 mrg $debug_cmd
1911 1.1 mrg
1912 1.1 mrg func_usage_message
1913 1.1 mrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1914 1.1 mrg exit 0
1915 1.1 mrg }
1916 1.1 mrg
1917 1.1 mrg
1918 1.1 mrg # func_usage_message
1919 1.1 mrg # ------------------
1920 1.1 mrg # Echo short help message to standard output.
1921 1.1 mrg func_usage_message ()
1922 1.1 mrg {
1923 1.1 mrg $debug_cmd
1924 1.1 mrg
1925 1.1 mrg eval \$ECHO \""Usage: $usage"\"
1926 1.1 mrg echo
1927 1.1 mrg $SED -n 's|^# ||
1928 1.1 mrg /^Written by/{
1929 1.1 mrg x;p;x
1930 1.1 mrg }
1931 1.1 mrg h
1932 1.1 mrg /^Written by/q' < "$progpath"
1933 1.1 mrg echo
1934 1.1 mrg eval \$ECHO \""$usage_message"\"
1935 1.1 mrg }
1936 1.1 mrg
1937 1.1 mrg
1938 1.1 mrg # func_version
1939 1.1 mrg # ------------
1940 1.1 mrg # Echo version message to standard output and exit.
1941 1.1 mrg func_version ()
1942 1.1 mrg {
1943 1.1 mrg $debug_cmd
1944 1.1 mrg
1945 1.1 mrg printf '%s\n' "$progname $scriptversion"
1946 1.1 mrg $SED -n '
1947 1.1 mrg /(C)/!b go
1948 1.1 mrg :more
1949 1.1 mrg /\./!{
1950 1.1 mrg N
1951 1.1 mrg s|\n# | |
1952 1.1 mrg b more
1953 1.1 mrg }
1954 1.1 mrg :go
1955 1.1 mrg /^# Written by /,/# warranty; / {
1956 1.1 mrg s|^# ||
1957 1.1 mrg s|^# *$||
1958 1.1 mrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1959 1.1 mrg p
1960 1.1 mrg }
1961 1.1 mrg /^# Written by / {
1962 1.1 mrg s|^# ||
1963 1.1 mrg p
1964 1.1 mrg }
1965 1.1 mrg /^warranty; /q' < "$progpath"
1966 1.1 mrg
1967 1.1 mrg exit $?
1968 1.1 mrg }
1969 1.1 mrg
1970 1.1 mrg
1971 1.1 mrg # Local variables:
1972 1.1 mrg # mode: shell-script
1973 1.1 mrg # sh-indentation: 2
1974 1.1 mrg # eval: (add-hook 'before-save-hook 'time-stamp)
1975 1.1 mrg # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1976 1.1 mrg # time-stamp-time-zone: "UTC"
1977 1.1 mrg # End:
1978 1.1 mrg
1979 1.1 mrg # Set a version string.
1980 1.1 mrg scriptversion='(GNU libtool) 2.4.6'
1981 1.1 mrg
1982 1.1 mrg
1983 1.1 mrg # func_echo ARG...
1984 1.1 mrg # ----------------
1985 1.1 mrg # Libtool also displays the current mode in messages, so override
1986 1.1 mrg # funclib.sh func_echo with this custom definition.
1987 1.1 mrg func_echo ()
1988 1.1 mrg {
1989 1.1 mrg $debug_cmd
1990 1.1 mrg
1991 1.1 mrg _G_message=$*
1992 1.1 mrg
1993 1.1 mrg func_echo_IFS=$IFS
1994 1.1 mrg IFS=$nl
1995 1.1 mrg for _G_line in $_G_message; do
1996 1.1 mrg IFS=$func_echo_IFS
1997 1.1 mrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
1998 1.1 mrg done
1999 1.1 mrg IFS=$func_echo_IFS
2000 1.1 mrg }
2001 1.1 mrg
2002 1.1 mrg
2003 1.1 mrg # func_warning ARG...
2004 1.1 mrg # -------------------
2005 1.1 mrg # Libtool warnings are not categorized, so override funclib.sh
2006 1.1 mrg # func_warning with this simpler definition.
2007 1.1 mrg func_warning ()
2008 1.1 mrg {
2009 1.1 mrg $debug_cmd
2010 1.1 mrg
2011 1.1 mrg $warning_func ${1+"$@"}
2012 1.1 mrg }
2013 1.1 mrg
2014 1.1 mrg
2015 1.1 mrg ## ---------------- ##
2016 1.1 mrg ## Options parsing. ##
2017 1.1 mrg ## ---------------- ##
2018 1.1 mrg
2019 1.1 mrg # Hook in the functions to make sure our own options are parsed during
2020 1.1 mrg # the option parsing loop.
2021 1.1 mrg
2022 1.1 mrg usage='$progpath [OPTION]... [MODE-ARG]...'
2023 1.1 mrg
2024 1.1 mrg # Short help message in response to '-h'.
2025 1.1 mrg usage_message="Options:
2026 1.1 mrg --config show all configuration variables
2027 1.1 mrg --debug enable verbose shell tracing
2028 1.1 mrg -n, --dry-run display commands without modifying any files
2029 1.1 mrg --features display basic configuration information and exit
2030 1.1 mrg --mode=MODE use operation mode MODE
2031 1.1 mrg --no-warnings equivalent to '-Wnone'
2032 1.1 mrg --preserve-dup-deps don't remove duplicate dependency libraries
2033 1.1 mrg --quiet, --silent don't print informational messages
2034 1.1 mrg --tag=TAG use configuration variables from tag TAG
2035 1.1 mrg -v, --verbose print more informational messages than default
2036 1.1 mrg --version print version information
2037 1.1 mrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
2038 1.1 mrg -h, --help, --help-all print short, long, or detailed help message
2039 1.1 mrg "
2040 1.1 mrg
2041 1.1 mrg # Additional text appended to 'usage_message' in response to '--help'.
2042 1.1 mrg func_help ()
2043 1.1 mrg {
2044 1.1 mrg $debug_cmd
2045 1.1 mrg
2046 1.1 mrg func_usage_message
2047 1.1 mrg $ECHO "$long_help_message
2048 1.1 mrg
2049 1.1 mrg MODE must be one of the following:
2050 1.1 mrg
2051 1.1 mrg clean remove files from the build directory
2052 1.1 mrg compile compile a source file into a libtool object
2053 1.1 mrg execute automatically set library path, then run a program
2054 1.1 mrg finish complete the installation of libtool libraries
2055 1.1 mrg install install libraries or executables
2056 1.1 mrg link create a library or an executable
2057 1.1 mrg uninstall remove libraries from an installed directory
2058 1.1 mrg
2059 1.1 mrg MODE-ARGS vary depending on the MODE. When passed as first option,
2060 1.1 mrg '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2061 1.1 mrg Try '$progname --help --mode=MODE' for a more detailed description of MODE.
2062 1.1 mrg
2063 1.1 mrg When reporting a bug, please describe a test case to reproduce it and
2064 1.1 mrg include the following information:
2065 1.1 mrg
2066 1.1 mrg host-triplet: $host
2067 1.1 mrg shell: $SHELL
2068 1.1 mrg compiler: $LTCC
2069 1.1 mrg compiler flags: $LTCFLAGS
2070 1.1 mrg linker: $LD (gnu? $with_gnu_ld)
2071 1.1 mrg version: $progname (GNU libtool) 2.4.6
2072 1.1 mrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2073 1.1 mrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2074 1.1 mrg
2075 1.1 mrg Report bugs to <bug-libtool (at] gnu.org>.
2076 1.1 mrg GNU libtool home page: <http://www.gnu.org/software/libtool/>.
2077 1.1 mrg General help using GNU software: <http://www.gnu.org/gethelp/>."
2078 1.1 mrg exit 0
2079 1.1 mrg }
2080 1.1 mrg
2081 1.1 mrg
2082 1.1 mrg # func_lo2o OBJECT-NAME
2083 1.1 mrg # ---------------------
2084 1.1 mrg # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2085 1.1 mrg # object suffix.
2086 1.1 mrg
2087 1.1 mrg lo2o=s/\\.lo\$/.$objext/
2088 1.1 mrg o2lo=s/\\.$objext\$/.lo/
2089 1.1 mrg
2090 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"; then
2091 1.1 mrg eval 'func_lo2o ()
2092 1.1 mrg {
2093 1.1 mrg case $1 in
2094 1.1 mrg *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2095 1.1 mrg * ) func_lo2o_result=$1 ;;
2096 1.1 mrg esac
2097 1.1 mrg }'
2098 1.1 mrg
2099 1.1 mrg # func_xform LIBOBJ-OR-SOURCE
2100 1.1 mrg # ---------------------------
2101 1.1 mrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2102 1.1 mrg # suffix to a '.lo' libtool-object suffix.
2103 1.1 mrg eval 'func_xform ()
2104 1.1 mrg {
2105 1.1 mrg func_xform_result=${1%.*}.lo
2106 1.1 mrg }'
2107 1.1 mrg else
2108 1.1 mrg # ...otherwise fall back to using sed.
2109 1.1 mrg func_lo2o ()
2110 1.1 mrg {
2111 1.1 mrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2112 1.1 mrg }
2113 1.1 mrg
2114 1.1 mrg func_xform ()
2115 1.1 mrg {
2116 1.1 mrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2117 1.1 mrg }
2118 1.1 mrg fi
2119 1.1 mrg
2120 1.1 mrg
2121 1.1 mrg # func_fatal_configuration ARG...
2122 1.1 mrg # -------------------------------
2123 1.1 mrg # Echo program name prefixed message to standard error, followed by
2124 1.1 mrg # a configuration failure hint, and exit.
2125 1.1 mrg func_fatal_configuration ()
2126 1.1 mrg {
2127 1.1 mrg func__fatal_error ${1+"$@"} \
2128 1.1 mrg "See the $PACKAGE documentation for more information." \
2129 1.1 mrg "Fatal configuration error."
2130 1.1 mrg }
2131 1.1 mrg
2132 1.1 mrg
2133 1.1 mrg # func_config
2134 1.1 mrg # -----------
2135 1.1 mrg # Display the configuration for all the tags in this script.
2136 1.1 mrg func_config ()
2137 1.1 mrg {
2138 1.1 mrg re_begincf='^# ### BEGIN LIBTOOL'
2139 1.1 mrg re_endcf='^# ### END LIBTOOL'
2140 1.1 mrg
2141 1.1 mrg # Default configuration.
2142 1.1 mrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2143 1.1 mrg
2144 1.1 mrg # Now print the configurations for the tags.
2145 1.1 mrg for tagname in $taglist; do
2146 1.1 mrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147 1.1 mrg done
2148 1.1 mrg
2149 1.1 mrg exit $?
2150 1.1 mrg }
2151 1.1 mrg
2152 1.1 mrg
2153 1.1 mrg # func_features
2154 1.1 mrg # -------------
2155 1.1 mrg # Display the features supported by this script.
2156 1.1 mrg func_features ()
2157 1.1 mrg {
2158 1.1 mrg echo "host: $host"
2159 1.1 mrg if test yes = "$build_libtool_libs"; then
2160 1.1 mrg echo "enable shared libraries"
2161 1.1 mrg else
2162 1.1 mrg echo "disable shared libraries"
2163 1.1 mrg fi
2164 1.1 mrg if test yes = "$build_old_libs"; then
2165 1.1 mrg echo "enable static libraries"
2166 1.1 mrg else
2167 1.1 mrg echo "disable static libraries"
2168 1.1 mrg fi
2169 1.1 mrg
2170 1.1 mrg exit $?
2171 1.1 mrg }
2172 1.1 mrg
2173 1.1 mrg
2174 1.1 mrg # func_enable_tag TAGNAME
2175 1.1 mrg # -----------------------
2176 1.1 mrg # Verify that TAGNAME is valid, and either flag an error and exit, or
2177 1.1 mrg # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
2178 1.1 mrg # variable here.
2179 1.1 mrg func_enable_tag ()
2180 1.1 mrg {
2181 1.1 mrg # Global variable:
2182 1.1 mrg tagname=$1
2183 1.1 mrg
2184 1.1 mrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2185 1.1 mrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2186 1.1 mrg sed_extractcf=/$re_begincf/,/$re_endcf/p
2187 1.1 mrg
2188 1.1 mrg # Validate tagname.
2189 1.1 mrg case $tagname in
2190 1.1 mrg *[!-_A-Za-z0-9,/]*)
2191 1.1 mrg func_fatal_error "invalid tag name: $tagname"
2192 1.1 mrg ;;
2193 1.1 mrg esac
2194 1.1 mrg
2195 1.1 mrg # Don't test for the "default" C tag, as we know it's
2196 1.1 mrg # there but not specially marked.
2197 1.1 mrg case $tagname in
2198 1.1 mrg CC) ;;
2199 1.1 mrg *)
2200 1.1 mrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2201 1.1 mrg taglist="$taglist $tagname"
2202 1.1 mrg
2203 1.1 mrg # Evaluate the configuration. Be careful to quote the path
2204 1.1 mrg # and the sed script, to avoid splitting on whitespace, but
2205 1.1 mrg # also don't use non-portable quotes within backquotes within
2206 1.1 mrg # quotes we have to do it in 2 steps:
2207 1.1 mrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2208 1.1 mrg eval "$extractedcf"
2209 1.1 mrg else
2210 1.1 mrg func_error "ignoring unknown tag $tagname"
2211 1.1 mrg fi
2212 1.1 mrg ;;
2213 1.1 mrg esac
2214 1.1 mrg }
2215 1.1 mrg
2216 1.1 mrg
2217 1.1 mrg # func_check_version_match
2218 1.1 mrg # ------------------------
2219 1.1 mrg # Ensure that we are using m4 macros, and libtool script from the same
2220 1.1 mrg # release of libtool.
2221 1.1 mrg func_check_version_match ()
2222 1.1 mrg {
2223 1.1 mrg if test "$package_revision" != "$macro_revision"; then
2224 1.1 mrg if test "$VERSION" != "$macro_version"; then
2225 1.1 mrg if test -z "$macro_version"; then
2226 1.1 mrg cat >&2 <<_LT_EOF
2227 1.1 mrg $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2228 1.1 mrg $progname: definition of this LT_INIT comes from an older release.
2229 1.1 mrg $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230 1.1 mrg $progname: and run autoconf again.
2231 1.1 mrg _LT_EOF
2232 1.1 mrg else
2233 1.1 mrg cat >&2 <<_LT_EOF
2234 1.1 mrg $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2235 1.1 mrg $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236 1.1 mrg $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237 1.1 mrg $progname: and run autoconf again.
2238 1.1 mrg _LT_EOF
2239 1.1 mrg fi
2240 1.1 mrg else
2241 1.1 mrg cat >&2 <<_LT_EOF
2242 1.1 mrg $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
2243 1.1 mrg $progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244 1.1 mrg $progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245 1.1 mrg $progname: of $PACKAGE $VERSION and run autoconf again.
2246 1.1 mrg _LT_EOF
2247 1.1 mrg fi
2248 1.1 mrg
2249 1.1 mrg exit $EXIT_MISMATCH
2250 1.1 mrg fi
2251 1.1 mrg }
2252 1.1 mrg
2253 1.1 mrg
2254 1.1 mrg # libtool_options_prep [ARG]...
2255 1.1 mrg # -----------------------------
2256 1.1 mrg # Preparation for options parsed by libtool.
2257 1.1 mrg libtool_options_prep ()
2258 1.1 mrg {
2259 1.1 mrg $debug_mode
2260 1.1 mrg
2261 1.1 mrg # Option defaults:
2262 1.1 mrg opt_config=false
2263 1.1 mrg opt_dlopen=
2264 1.1 mrg opt_dry_run=false
2265 1.1 mrg opt_help=false
2266 1.1 mrg opt_mode=
2267 1.1 mrg opt_preserve_dup_deps=false
2268 1.1 mrg opt_quiet=false
2269 1.1 mrg
2270 1.1 mrg nonopt=
2271 1.1 mrg preserve_args=
2272 1.1 mrg
2273 1.1 mrg # Shorthand for --mode=foo, only valid as the first argument
2274 1.1 mrg case $1 in
2275 1.1 mrg clean|clea|cle|cl)
2276 1.1 mrg shift; set dummy --mode clean ${1+"$@"}; shift
2277 1.1 mrg ;;
2278 1.1 mrg compile|compil|compi|comp|com|co|c)
2279 1.1 mrg shift; set dummy --mode compile ${1+"$@"}; shift
2280 1.1 mrg ;;
2281 1.1 mrg execute|execut|execu|exec|exe|ex|e)
2282 1.1 mrg shift; set dummy --mode execute ${1+"$@"}; shift
2283 1.1 mrg ;;
2284 1.1 mrg finish|finis|fini|fin|fi|f)
2285 1.1 mrg shift; set dummy --mode finish ${1+"$@"}; shift
2286 1.1 mrg ;;
2287 1.1 mrg install|instal|insta|inst|ins|in|i)
2288 1.1 mrg shift; set dummy --mode install ${1+"$@"}; shift
2289 1.1 mrg ;;
2290 1.1 mrg link|lin|li|l)
2291 1.1 mrg shift; set dummy --mode link ${1+"$@"}; shift
2292 1.1 mrg ;;
2293 1.1 mrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2294 1.1 mrg shift; set dummy --mode uninstall ${1+"$@"}; shift
2295 1.1 mrg ;;
2296 1.1 mrg esac
2297 1.1 mrg
2298 1.1 mrg # Pass back the list of options.
2299 1.1 mrg func_quote_for_eval ${1+"$@"}
2300 1.1 mrg libtool_options_prep_result=$func_quote_for_eval_result
2301 1.1 mrg }
2302 1.1 mrg func_add_hook func_options_prep libtool_options_prep
2303 1.1 mrg
2304 1.1 mrg
2305 1.1 mrg # libtool_parse_options [ARG]...
2306 1.1 mrg # ---------------------------------
2307 1.1 mrg # Provide handling for libtool specific options.
2308 1.1 mrg libtool_parse_options ()
2309 1.1 mrg {
2310 1.1 mrg $debug_cmd
2311 1.1 mrg
2312 1.1 mrg # Perform our own loop to consume as many options as possible in
2313 1.1 mrg # each iteration.
2314 1.1 mrg while test $# -gt 0; do
2315 1.1 mrg _G_opt=$1
2316 1.1 mrg shift
2317 1.1 mrg case $_G_opt in
2318 1.1 mrg --dry-run|--dryrun|-n)
2319 1.1 mrg opt_dry_run=:
2320 1.1 mrg ;;
2321 1.1 mrg
2322 1.1 mrg --config) func_config ;;
2323 1.1 mrg
2324 1.1 mrg --dlopen|-dlopen)
2325 1.1 mrg opt_dlopen="${opt_dlopen+$opt_dlopen
2326 1.1 mrg }$1"
2327 1.1 mrg shift
2328 1.1 mrg ;;
2329 1.1 mrg
2330 1.1 mrg --preserve-dup-deps)
2331 1.1 mrg opt_preserve_dup_deps=: ;;
2332 1.1 mrg
2333 1.1 mrg --features) func_features ;;
2334 1.1 mrg
2335 1.1 mrg --finish) set dummy --mode finish ${1+"$@"}; shift ;;
2336 1.1 mrg
2337 1.1 mrg --help) opt_help=: ;;
2338 1.1 mrg
2339 1.1 mrg --help-all) opt_help=': help-all' ;;
2340 1.1 mrg
2341 1.1 mrg --mode) test $# = 0 && func_missing_arg $_G_opt && break
2342 1.1 mrg opt_mode=$1
2343 1.1 mrg case $1 in
2344 1.1 mrg # Valid mode arguments:
2345 1.1 mrg clean|compile|execute|finish|install|link|relink|uninstall) ;;
2346 1.1 mrg
2347 1.1 mrg # Catch anything else as an error
2348 1.1 mrg *) func_error "invalid argument for $_G_opt"
2349 1.1 mrg exit_cmd=exit
2350 1.1 mrg break
2351 1.1 mrg ;;
2352 1.1 mrg esac
2353 1.1 mrg shift
2354 1.1 mrg ;;
2355 1.1 mrg
2356 1.1 mrg --no-silent|--no-quiet)
2357 1.1 mrg opt_quiet=false
2358 1.1 mrg func_append preserve_args " $_G_opt"
2359 1.1 mrg ;;
2360 1.1 mrg
2361 1.1 mrg --no-warnings|--no-warning|--no-warn)
2362 1.1 mrg opt_warning=false
2363 1.1 mrg func_append preserve_args " $_G_opt"
2364 1.1 mrg ;;
2365 1.1 mrg
2366 1.1 mrg --no-verbose)
2367 1.1 mrg opt_verbose=false
2368 1.1 mrg func_append preserve_args " $_G_opt"
2369 1.1 mrg ;;
2370 1.1 mrg
2371 1.1 mrg --silent|--quiet)
2372 1.1 mrg opt_quiet=:
2373 1.1 mrg opt_verbose=false
2374 1.1 mrg func_append preserve_args " $_G_opt"
2375 1.1 mrg ;;
2376 1.1 mrg
2377 1.1 mrg --tag) test $# = 0 && func_missing_arg $_G_opt && break
2378 1.1 mrg opt_tag=$1
2379 1.1 mrg func_append preserve_args " $_G_opt $1"
2380 1.1 mrg func_enable_tag "$1"
2381 1.1 mrg shift
2382 1.1 mrg ;;
2383 1.1 mrg
2384 1.1 mrg --verbose|-v) opt_quiet=false
2385 1.1 mrg opt_verbose=:
2386 1.1 mrg func_append preserve_args " $_G_opt"
2387 1.1 mrg ;;
2388 1.1 mrg
2389 1.1 mrg # An option not handled by this hook function:
2390 1.1 mrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
2391 1.1 mrg esac
2392 1.1 mrg done
2393 1.1 mrg
2394 1.1 mrg
2395 1.1 mrg # save modified positional parameters for caller
2396 1.1 mrg func_quote_for_eval ${1+"$@"}
2397 1.1 mrg libtool_parse_options_result=$func_quote_for_eval_result
2398 1.1 mrg }
2399 1.1 mrg func_add_hook func_parse_options libtool_parse_options
2400 1.1 mrg
2401 1.1 mrg
2402 1.1 mrg
2403 1.1 mrg # libtool_validate_options [ARG]...
2404 1.1 mrg # ---------------------------------
2405 1.1 mrg # Perform any sanity checks on option settings and/or unconsumed
2406 1.1 mrg # arguments.
2407 1.1 mrg libtool_validate_options ()
2408 1.1 mrg {
2409 1.1 mrg # save first non-option argument
2410 1.1 mrg if test 0 -lt $#; then
2411 1.1 mrg nonopt=$1
2412 1.1 mrg shift
2413 1.1 mrg fi
2414 1.1 mrg
2415 1.1 mrg # preserve --debug
2416 1.1 mrg test : = "$debug_cmd" || func_append preserve_args " --debug"
2417 1.1 mrg
2418 1.1 mrg case $host in
2419 1.1 mrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2420 1.1 mrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2421 1.1 mrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2422 1.1 mrg # don't eliminate duplications in $postdeps and $predeps
2423 1.1 mrg opt_duplicate_compiler_generated_deps=:
2424 1.1 mrg ;;
2425 1.1 mrg *)
2426 1.1 mrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2427 1.1 mrg ;;
2428 1.1 mrg esac
2429 1.1 mrg
2430 1.1 mrg $opt_help || {
2431 1.1 mrg # Sanity checks first:
2432 1.1 mrg func_check_version_match
2433 1.1 mrg
2434 1.1 mrg test yes != "$build_libtool_libs" \
2435 1.1 mrg && test yes != "$build_old_libs" \
2436 1.1 mrg && func_fatal_configuration "not configured to build any kind of library"
2437 1.1 mrg
2438 1.1 mrg # Darwin sucks
2439 1.1 mrg eval std_shrext=\"$shrext_cmds\"
2440 1.1 mrg
2441 1.1 mrg # Only execute mode is allowed to have -dlopen flags.
2442 1.1 mrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2443 1.1 mrg func_error "unrecognized option '-dlopen'"
2444 1.1 mrg $ECHO "$help" 1>&2
2445 1.1 mrg exit $EXIT_FAILURE
2446 1.1 mrg fi
2447 1.1 mrg
2448 1.1 mrg # Change the help message to a mode-specific one.
2449 1.1 mrg generic_help=$help
2450 1.1 mrg help="Try '$progname --help --mode=$opt_mode' for more information."
2451 1.1 mrg }
2452 1.1 mrg
2453 1.1 mrg # Pass back the unparsed argument list
2454 1.1 mrg func_quote_for_eval ${1+"$@"}
2455 1.1 mrg libtool_validate_options_result=$func_quote_for_eval_result
2456 1.1 mrg }
2457 1.1 mrg func_add_hook func_validate_options libtool_validate_options
2458 1.1 mrg
2459 1.1 mrg
2460 1.1 mrg # Process options as early as possible so that --help and --version
2461 1.1 mrg # can return quickly.
2462 1.1 mrg func_options ${1+"$@"}
2463 1.1 mrg eval set dummy "$func_options_result"; shift
2464 1.1 mrg
2465 1.1 mrg
2466 1.1 mrg
2467 1.1 mrg ## ----------- ##
2468 1.1 mrg ## Main. ##
2469 1.1 mrg ## ----------- ##
2470 1.1 mrg
2471 1.1 mrg magic='%%%MAGIC variable%%%'
2472 1.1 mrg magic_exe='%%%MAGIC EXE variable%%%'
2473 1.1 mrg
2474 1.1 mrg # Global variables.
2475 1.1 mrg extracted_archives=
2476 1.1 mrg extracted_serial=0
2477 1.1 mrg
2478 1.1 mrg # If this variable is set in any of the actions, the command in it
2479 1.1 mrg # will be execed at the end. This prevents here-documents from being
2480 1.1 mrg # left over by shells.
2481 1.1 mrg exec_cmd=
2482 1.1 mrg
2483 1.1 mrg
2484 1.1 mrg # A function that is used when there is no print builtin or printf.
2485 1.1 mrg func_fallback_echo ()
2486 1.1 mrg {
2487 1.1 mrg eval 'cat <<_LTECHO_EOF
2488 1.1 mrg $1
2489 1.1 mrg _LTECHO_EOF'
2490 1.1 mrg }
2491 1.1 mrg
2492 1.1 mrg # func_generated_by_libtool
2493 1.1 mrg # True iff stdin has been generated by Libtool. This function is only
2494 1.1 mrg # a basic sanity check; it will hardly flush out determined imposters.
2495 1.1 mrg func_generated_by_libtool_p ()
2496 1.1 mrg {
2497 1.1 mrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2498 1.1 mrg }
2499 1.1 mrg
2500 1.1 mrg # func_lalib_p file
2501 1.1 mrg # True iff FILE is a libtool '.la' library or '.lo' object file.
2502 1.1 mrg # This function is only a basic sanity check; it will hardly flush out
2503 1.1 mrg # determined imposters.
2504 1.1 mrg func_lalib_p ()
2505 1.1 mrg {
2506 1.1 mrg test -f "$1" &&
2507 1.1 mrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2508 1.1 mrg }
2509 1.1 mrg
2510 1.1 mrg # func_lalib_unsafe_p file
2511 1.1 mrg # True iff FILE is a libtool '.la' library or '.lo' object file.
2512 1.1 mrg # This function implements the same check as func_lalib_p without
2513 1.1 mrg # resorting to external programs. To this end, it redirects stdin and
2514 1.1 mrg # closes it afterwards, without saving the original file descriptor.
2515 1.1 mrg # As a safety measure, use it only where a negative result would be
2516 1.1 mrg # fatal anyway. Works if 'file' does not exist.
2517 1.1 mrg func_lalib_unsafe_p ()
2518 1.1 mrg {
2519 1.1 mrg lalib_p=no
2520 1.1 mrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2521 1.1 mrg for lalib_p_l in 1 2 3 4
2522 1.1 mrg do
2523 1.1 mrg read lalib_p_line
2524 1.1 mrg case $lalib_p_line in
2525 1.1 mrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2526 1.1 mrg esac
2527 1.1 mrg done
2528 1.1 mrg exec 0<&5 5<&-
2529 1.1 mrg fi
2530 1.1 mrg test yes = "$lalib_p"
2531 1.1 mrg }
2532 1.1 mrg
2533 1.1 mrg # func_ltwrapper_script_p file
2534 1.1 mrg # True iff FILE is a libtool wrapper script
2535 1.1 mrg # This function is only a basic sanity check; it will hardly flush out
2536 1.1 mrg # determined imposters.
2537 1.1 mrg func_ltwrapper_script_p ()
2538 1.1 mrg {
2539 1.1 mrg test -f "$1" &&
2540 1.1 mrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2541 1.1 mrg }
2542 1.1 mrg
2543 1.1 mrg # func_ltwrapper_executable_p file
2544 1.1 mrg # True iff FILE is a libtool wrapper executable
2545 1.1 mrg # This function is only a basic sanity check; it will hardly flush out
2546 1.1 mrg # determined imposters.
2547 1.1 mrg func_ltwrapper_executable_p ()
2548 1.1 mrg {
2549 1.1 mrg func_ltwrapper_exec_suffix=
2550 1.1 mrg case $1 in
2551 1.1 mrg *.exe) ;;
2552 1.1 mrg *) func_ltwrapper_exec_suffix=.exe ;;
2553 1.1 mrg esac
2554 1.1 mrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2555 1.1 mrg }
2556 1.1 mrg
2557 1.1 mrg # func_ltwrapper_scriptname file
2558 1.1 mrg # Assumes file is an ltwrapper_executable
2559 1.1 mrg # uses $file to determine the appropriate filename for a
2560 1.1 mrg # temporary ltwrapper_script.
2561 1.1 mrg func_ltwrapper_scriptname ()
2562 1.1 mrg {
2563 1.1 mrg func_dirname_and_basename "$1" "" "."
2564 1.1 mrg func_stripname '' '.exe' "$func_basename_result"
2565 1.1 mrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2566 1.1 mrg }
2567 1.1 mrg
2568 1.1 mrg # func_ltwrapper_p file
2569 1.1 mrg # True iff FILE is a libtool wrapper script or wrapper executable
2570 1.1 mrg # This function is only a basic sanity check; it will hardly flush out
2571 1.1 mrg # determined imposters.
2572 1.1 mrg func_ltwrapper_p ()
2573 1.1 mrg {
2574 1.1 mrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2575 1.1 mrg }
2576 1.1 mrg
2577 1.1 mrg
2578 1.1 mrg # func_execute_cmds commands fail_cmd
2579 1.1 mrg # Execute tilde-delimited COMMANDS.
2580 1.1 mrg # If FAIL_CMD is given, eval that upon failure.
2581 1.1 mrg # FAIL_CMD may read-access the current command in variable CMD!
2582 1.1 mrg func_execute_cmds ()
2583 1.1 mrg {
2584 1.1 mrg $debug_cmd
2585 1.1 mrg
2586 1.1 mrg save_ifs=$IFS; IFS='~'
2587 1.1 mrg for cmd in $1; do
2588 1.1 mrg IFS=$sp$nl
2589 1.1 mrg eval cmd=\"$cmd\"
2590 1.1 mrg IFS=$save_ifs
2591 1.1 mrg func_show_eval "$cmd" "${2-:}"
2592 1.1 mrg done
2593 1.1 mrg IFS=$save_ifs
2594 1.1 mrg }
2595 1.1 mrg
2596 1.1 mrg
2597 1.1 mrg # func_source file
2598 1.1 mrg # Source FILE, adding directory component if necessary.
2599 1.1 mrg # Note that it is not necessary on cygwin/mingw to append a dot to
2600 1.1 mrg # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2601 1.1 mrg # behavior happens only for exec(3), not for open(2)! Also, sourcing
2602 1.1 mrg # 'FILE.' does not work on cygwin managed mounts.
2603 1.1 mrg func_source ()
2604 1.1 mrg {
2605 1.1 mrg $debug_cmd
2606 1.1 mrg
2607 1.1 mrg case $1 in
2608 1.1 mrg */* | *\\*) . "$1" ;;
2609 1.1 mrg *) . "./$1" ;;
2610 1.1 mrg esac
2611 1.1 mrg }
2612 1.1 mrg
2613 1.1 mrg
2614 1.1 mrg # func_resolve_sysroot PATH
2615 1.1 mrg # Replace a leading = in PATH with a sysroot. Store the result into
2616 1.1 mrg # func_resolve_sysroot_result
2617 1.1 mrg func_resolve_sysroot ()
2618 1.1 mrg {
2619 1.1 mrg func_resolve_sysroot_result=$1
2620 1.1 mrg case $func_resolve_sysroot_result in
2621 1.1 mrg =*)
2622 1.1 mrg func_stripname '=' '' "$func_resolve_sysroot_result"
2623 1.1 mrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624 1.1 mrg ;;
2625 1.1 mrg esac
2626 1.1 mrg }
2627 1.1 mrg
2628 1.1 mrg # func_replace_sysroot PATH
2629 1.1 mrg # If PATH begins with the sysroot, replace it with = and
2630 1.1 mrg # store the result into func_replace_sysroot_result.
2631 1.1 mrg func_replace_sysroot ()
2632 1.1 mrg {
2633 1.1 mrg case $lt_sysroot:$1 in
2634 1.1 mrg ?*:"$lt_sysroot"*)
2635 1.1 mrg func_stripname "$lt_sysroot" '' "$1"
2636 1.1 mrg func_replace_sysroot_result='='$func_stripname_result
2637 1.1 mrg ;;
2638 1.1 mrg *)
2639 1.1 mrg # Including no sysroot.
2640 1.1 mrg func_replace_sysroot_result=$1
2641 1.1 mrg ;;
2642 1.1 mrg esac
2643 1.1 mrg }
2644 1.1 mrg
2645 1.1 mrg # func_infer_tag arg
2646 1.1 mrg # Infer tagged configuration to use if any are available and
2647 1.1 mrg # if one wasn't chosen via the "--tag" command line option.
2648 1.1 mrg # Only attempt this if the compiler in the base compile
2649 1.1 mrg # command doesn't match the default compiler.
2650 1.1 mrg # arg is usually of the form 'gcc ...'
2651 1.1 mrg func_infer_tag ()
2652 1.1 mrg {
2653 1.1 mrg $debug_cmd
2654 1.1 mrg
2655 1.1 mrg if test -n "$available_tags" && test -z "$tagname"; then
2656 1.1 mrg CC_quoted=
2657 1.1 mrg for arg in $CC; do
2658 1.1 mrg func_append_quoted CC_quoted "$arg"
2659 1.1 mrg done
2660 1.1 mrg CC_expanded=`func_echo_all $CC`
2661 1.1 mrg CC_quoted_expanded=`func_echo_all $CC_quoted`
2662 1.1 mrg case $@ in
2663 1.1 mrg # Blanks in the command may have been stripped by the calling shell,
2664 1.1 mrg # but not from the CC environment variable when configure was run.
2665 1.1 mrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666 1.1 mrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2667 1.1 mrg # Blanks at the start of $base_compile will cause this to fail
2668 1.1 mrg # if we don't check for them as well.
2669 1.1 mrg *)
2670 1.1 mrg for z in $available_tags; do
2671 1.1 mrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2672 1.1 mrg # Evaluate the configuration.
2673 1.1 mrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2674 1.1 mrg CC_quoted=
2675 1.1 mrg for arg in $CC; do
2676 1.1 mrg # Double-quote args containing other shell metacharacters.
2677 1.1 mrg func_append_quoted CC_quoted "$arg"
2678 1.1 mrg done
2679 1.1 mrg CC_expanded=`func_echo_all $CC`
2680 1.1 mrg CC_quoted_expanded=`func_echo_all $CC_quoted`
2681 1.1 mrg case "$@ " in
2682 1.1 mrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683 1.1 mrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2684 1.1 mrg # The compiler in the base compile command matches
2685 1.1 mrg # the one in the tagged configuration.
2686 1.1 mrg # Assume this is the tagged configuration we want.
2687 1.1 mrg tagname=$z
2688 1.1 mrg break
2689 1.1 mrg ;;
2690 1.1 mrg esac
2691 1.1 mrg fi
2692 1.1 mrg done
2693 1.1 mrg # If $tagname still isn't set, then no tagged configuration
2694 1.1 mrg # was found and let the user know that the "--tag" command
2695 1.1 mrg # line option must be used.
2696 1.1 mrg if test -z "$tagname"; then
2697 1.1 mrg func_echo "unable to infer tagged configuration"
2698 1.1 mrg func_fatal_error "specify a tag with '--tag'"
2699 1.1 mrg # else
2700 1.1 mrg # func_verbose "using $tagname tagged configuration"
2701 1.1 mrg fi
2702 1.1 mrg ;;
2703 1.1 mrg esac
2704 1.1 mrg fi
2705 1.1 mrg }
2706 1.1 mrg
2707 1.1 mrg
2708 1.1 mrg
2709 1.1 mrg # func_write_libtool_object output_name pic_name nonpic_name
2710 1.1 mrg # Create a libtool object file (analogous to a ".la" file),
2711 1.1 mrg # but don't create it if we're doing a dry run.
2712 1.1 mrg func_write_libtool_object ()
2713 1.1 mrg {
2714 1.1 mrg write_libobj=$1
2715 1.1 mrg if test yes = "$build_libtool_libs"; then
2716 1.1 mrg write_lobj=\'$2\'
2717 1.1 mrg else
2718 1.1 mrg write_lobj=none
2719 1.1 mrg fi
2720 1.1 mrg
2721 1.1 mrg if test yes = "$build_old_libs"; then
2722 1.1 mrg write_oldobj=\'$3\'
2723 1.1 mrg else
2724 1.1 mrg write_oldobj=none
2725 1.1 mrg fi
2726 1.1 mrg
2727 1.1 mrg $opt_dry_run || {
2728 1.1 mrg cat >${write_libobj}T <<EOF
2729 1.1 mrg # $write_libobj - a libtool object file
2730 1.1 mrg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731 1.1 mrg #
2732 1.1 mrg # Please DO NOT delete this file!
2733 1.1 mrg # It is necessary for linking the library.
2734 1.1 mrg
2735 1.1 mrg # Name of the PIC object.
2736 1.1 mrg pic_object=$write_lobj
2737 1.1 mrg
2738 1.1 mrg # Name of the non-PIC object
2739 1.1 mrg non_pic_object=$write_oldobj
2740 1.1 mrg
2741 1.1 mrg EOF
2742 1.1 mrg $MV "${write_libobj}T" "$write_libobj"
2743 1.1 mrg }
2744 1.1 mrg }
2745 1.1 mrg
2746 1.1 mrg
2747 1.1 mrg ##################################################
2748 1.1 mrg # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749 1.1 mrg ##################################################
2750 1.1 mrg
2751 1.1 mrg # func_convert_core_file_wine_to_w32 ARG
2752 1.1 mrg # Helper function used by file name conversion functions when $build is *nix,
2753 1.1 mrg # and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754 1.1 mrg # correctly configured wine environment available, with the winepath program
2755 1.1 mrg # in $build's $PATH.
2756 1.1 mrg #
2757 1.1 mrg # ARG is the $build file name to be converted to w32 format.
2758 1.1 mrg # Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759 1.1 mrg # be empty on error (or when ARG is empty)
2760 1.1 mrg func_convert_core_file_wine_to_w32 ()
2761 1.1 mrg {
2762 1.1 mrg $debug_cmd
2763 1.1 mrg
2764 1.1 mrg func_convert_core_file_wine_to_w32_result=$1
2765 1.1 mrg if test -n "$1"; then
2766 1.1 mrg # Unfortunately, winepath does not exit with a non-zero error code, so we
2767 1.1 mrg # are forced to check the contents of stdout. On the other hand, if the
2768 1.1 mrg # command is not found, the shell will set an exit code of 127 and print
2769 1.1 mrg # *an error message* to stdout. So we must check for both error code of
2770 1.1 mrg # zero AND non-empty stdout, which explains the odd construction:
2771 1.1 mrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2772 1.1 mrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773 1.1 mrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2774 1.1 mrg $SED -e "$sed_naive_backslashify"`
2775 1.1 mrg else
2776 1.1 mrg func_convert_core_file_wine_to_w32_result=
2777 1.1 mrg fi
2778 1.1 mrg fi
2779 1.1 mrg }
2780 1.1 mrg # end: func_convert_core_file_wine_to_w32
2781 1.1 mrg
2782 1.1 mrg
2783 1.1 mrg # func_convert_core_path_wine_to_w32 ARG
2784 1.1 mrg # Helper function used by path conversion functions when $build is *nix, and
2785 1.1 mrg # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786 1.1 mrg # configured wine environment available, with the winepath program in $build's
2787 1.1 mrg # $PATH. Assumes ARG has no leading or trailing path separator characters.
2788 1.1 mrg #
2789 1.1 mrg # ARG is path to be converted from $build format to win32.
2790 1.1 mrg # Result is available in $func_convert_core_path_wine_to_w32_result.
2791 1.1 mrg # Unconvertible file (directory) names in ARG are skipped; if no directory names
2792 1.1 mrg # are convertible, then the result may be empty.
2793 1.1 mrg func_convert_core_path_wine_to_w32 ()
2794 1.1 mrg {
2795 1.1 mrg $debug_cmd
2796 1.1 mrg
2797 1.1 mrg # unfortunately, winepath doesn't convert paths, only file names
2798 1.1 mrg func_convert_core_path_wine_to_w32_result=
2799 1.1 mrg if test -n "$1"; then
2800 1.1 mrg oldIFS=$IFS
2801 1.1 mrg IFS=:
2802 1.1 mrg for func_convert_core_path_wine_to_w32_f in $1; do
2803 1.1 mrg IFS=$oldIFS
2804 1.1 mrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2805 1.1 mrg if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806 1.1 mrg if test -z "$func_convert_core_path_wine_to_w32_result"; then
2807 1.1 mrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808 1.1 mrg else
2809 1.1 mrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810 1.1 mrg fi
2811 1.1 mrg fi
2812 1.1 mrg done
2813 1.1 mrg IFS=$oldIFS
2814 1.1 mrg fi
2815 1.1 mrg }
2816 1.1 mrg # end: func_convert_core_path_wine_to_w32
2817 1.1 mrg
2818 1.1 mrg
2819 1.1 mrg # func_cygpath ARGS...
2820 1.1 mrg # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821 1.1 mrg # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822 1.1 mrg # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823 1.1 mrg # (2), returns the Cygwin file name or path in func_cygpath_result (input
2824 1.1 mrg # file name or path is assumed to be in w32 format, as previously converted
2825 1.1 mrg # from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826 1.1 mrg # or path in func_cygpath_result (input file name or path is assumed to be in
2827 1.1 mrg # Cygwin format). Returns an empty string on error.
2828 1.1 mrg #
2829 1.1 mrg # ARGS are passed to cygpath, with the last one being the file name or path to
2830 1.1 mrg # be converted.
2831 1.1 mrg #
2832 1.1 mrg # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833 1.1 mrg # environment variable; do not put it in $PATH.
2834 1.1 mrg func_cygpath ()
2835 1.1 mrg {
2836 1.1 mrg $debug_cmd
2837 1.1 mrg
2838 1.1 mrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839 1.1 mrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840 1.1 mrg if test "$?" -ne 0; then
2841 1.1 mrg # on failure, ensure result is empty
2842 1.1 mrg func_cygpath_result=
2843 1.1 mrg fi
2844 1.1 mrg else
2845 1.1 mrg func_cygpath_result=
2846 1.1 mrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847 1.1 mrg fi
2848 1.1 mrg }
2849 1.1 mrg #end: func_cygpath
2850 1.1 mrg
2851 1.1 mrg
2852 1.1 mrg # func_convert_core_msys_to_w32 ARG
2853 1.1 mrg # Convert file name or path ARG from MSYS format to w32 format. Return
2854 1.1 mrg # result in func_convert_core_msys_to_w32_result.
2855 1.1 mrg func_convert_core_msys_to_w32 ()
2856 1.1 mrg {
2857 1.1 mrg $debug_cmd
2858 1.1 mrg
2859 1.1 mrg # awkward: cmd appends spaces to result
2860 1.1 mrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2861 1.1 mrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862 1.1 mrg }
2863 1.1 mrg #end: func_convert_core_msys_to_w32
2864 1.1 mrg
2865 1.1 mrg
2866 1.1 mrg # func_convert_file_check ARG1 ARG2
2867 1.1 mrg # Verify that ARG1 (a file name in $build format) was converted to $host
2868 1.1 mrg # format in ARG2. Otherwise, emit an error message, but continue (resetting
2869 1.1 mrg # func_to_host_file_result to ARG1).
2870 1.1 mrg func_convert_file_check ()
2871 1.1 mrg {
2872 1.1 mrg $debug_cmd
2873 1.1 mrg
2874 1.1 mrg if test -z "$2" && test -n "$1"; then
2875 1.1 mrg func_error "Could not determine host file name corresponding to"
2876 1.1 mrg func_error " '$1'"
2877 1.1 mrg func_error "Continuing, but uninstalled executables may not work."
2878 1.1 mrg # Fallback:
2879 1.1 mrg func_to_host_file_result=$1
2880 1.1 mrg fi
2881 1.1 mrg }
2882 1.1 mrg # end func_convert_file_check
2883 1.1 mrg
2884 1.1 mrg
2885 1.1 mrg # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886 1.1 mrg # Verify that FROM_PATH (a path in $build format) was converted to $host
2887 1.1 mrg # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888 1.1 mrg # func_to_host_file_result to a simplistic fallback value (see below).
2889 1.1 mrg func_convert_path_check ()
2890 1.1 mrg {
2891 1.1 mrg $debug_cmd
2892 1.1 mrg
2893 1.1 mrg if test -z "$4" && test -n "$3"; then
2894 1.1 mrg func_error "Could not determine the host path corresponding to"
2895 1.1 mrg func_error " '$3'"
2896 1.1 mrg func_error "Continuing, but uninstalled executables may not work."
2897 1.1 mrg # Fallback. This is a deliberately simplistic "conversion" and
2898 1.1 mrg # should not be "improved". See libtool.info.
2899 1.1 mrg if test "x$1" != "x$2"; then
2900 1.1 mrg lt_replace_pathsep_chars="s|$1|$2|g"
2901 1.1 mrg func_to_host_path_result=`echo "$3" |
2902 1.1 mrg $SED -e "$lt_replace_pathsep_chars"`
2903 1.1 mrg else
2904 1.1 mrg func_to_host_path_result=$3
2905 1.1 mrg fi
2906 1.1 mrg fi
2907 1.1 mrg }
2908 1.1 mrg # end func_convert_path_check
2909 1.1 mrg
2910 1.1 mrg
2911 1.1 mrg # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912 1.1 mrg # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913 1.1 mrg # and appending REPL if ORIG matches BACKPAT.
2914 1.1 mrg func_convert_path_front_back_pathsep ()
2915 1.1 mrg {
2916 1.1 mrg $debug_cmd
2917 1.1 mrg
2918 1.1 mrg case $4 in
2919 1.1 mrg $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920 1.1 mrg ;;
2921 1.1 mrg esac
2922 1.1 mrg case $4 in
2923 1.1 mrg $2 ) func_append func_to_host_path_result "$3"
2924 1.1 mrg ;;
2925 1.1 mrg esac
2926 1.1 mrg }
2927 1.1 mrg # end func_convert_path_front_back_pathsep
2928 1.1 mrg
2929 1.1 mrg
2930 1.1 mrg ##################################################
2931 1.1 mrg # $build to $host FILE NAME CONVERSION FUNCTIONS #
2932 1.1 mrg ##################################################
2933 1.1 mrg # invoked via '$to_host_file_cmd ARG'
2934 1.1 mrg #
2935 1.1 mrg # In each case, ARG is the path to be converted from $build to $host format.
2936 1.1 mrg # Result will be available in $func_to_host_file_result.
2937 1.1 mrg
2938 1.1 mrg
2939 1.1 mrg # func_to_host_file ARG
2940 1.1 mrg # Converts the file name ARG from $build format to $host format. Return result
2941 1.1 mrg # in func_to_host_file_result.
2942 1.1 mrg func_to_host_file ()
2943 1.1 mrg {
2944 1.1 mrg $debug_cmd
2945 1.1 mrg
2946 1.1 mrg $to_host_file_cmd "$1"
2947 1.1 mrg }
2948 1.1 mrg # end func_to_host_file
2949 1.1 mrg
2950 1.1 mrg
2951 1.1 mrg # func_to_tool_file ARG LAZY
2952 1.1 mrg # converts the file name ARG from $build format to toolchain format. Return
2953 1.1 mrg # result in func_to_tool_file_result. If the conversion in use is listed
2954 1.1 mrg # in (the comma separated) LAZY, no conversion takes place.
2955 1.1 mrg func_to_tool_file ()
2956 1.1 mrg {
2957 1.1 mrg $debug_cmd
2958 1.1 mrg
2959 1.1 mrg case ,$2, in
2960 1.1 mrg *,"$to_tool_file_cmd",*)
2961 1.1 mrg func_to_tool_file_result=$1
2962 1.1 mrg ;;
2963 1.1 mrg *)
2964 1.1 mrg $to_tool_file_cmd "$1"
2965 1.1 mrg func_to_tool_file_result=$func_to_host_file_result
2966 1.1 mrg ;;
2967 1.1 mrg esac
2968 1.1 mrg }
2969 1.1 mrg # end func_to_tool_file
2970 1.1 mrg
2971 1.1 mrg
2972 1.1 mrg # func_convert_file_noop ARG
2973 1.1 mrg # Copy ARG to func_to_host_file_result.
2974 1.1 mrg func_convert_file_noop ()
2975 1.1 mrg {
2976 1.1 mrg func_to_host_file_result=$1
2977 1.1 mrg }
2978 1.1 mrg # end func_convert_file_noop
2979 1.1 mrg
2980 1.1 mrg
2981 1.1 mrg # func_convert_file_msys_to_w32 ARG
2982 1.1 mrg # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983 1.1 mrg # conversion to w32 is not available inside the cwrapper. Returns result in
2984 1.1 mrg # func_to_host_file_result.
2985 1.1 mrg func_convert_file_msys_to_w32 ()
2986 1.1 mrg {
2987 1.1 mrg $debug_cmd
2988 1.1 mrg
2989 1.1 mrg func_to_host_file_result=$1
2990 1.1 mrg if test -n "$1"; then
2991 1.1 mrg func_convert_core_msys_to_w32 "$1"
2992 1.1 mrg func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993 1.1 mrg fi
2994 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result"
2995 1.1 mrg }
2996 1.1 mrg # end func_convert_file_msys_to_w32
2997 1.1 mrg
2998 1.1 mrg
2999 1.1 mrg # func_convert_file_cygwin_to_w32 ARG
3000 1.1 mrg # Convert file name ARG from Cygwin to w32 format. Returns result in
3001 1.1 mrg # func_to_host_file_result.
3002 1.1 mrg func_convert_file_cygwin_to_w32 ()
3003 1.1 mrg {
3004 1.1 mrg $debug_cmd
3005 1.1 mrg
3006 1.1 mrg func_to_host_file_result=$1
3007 1.1 mrg if test -n "$1"; then
3008 1.1 mrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009 1.1 mrg # LT_CYGPATH in this case.
3010 1.1 mrg func_to_host_file_result=`cygpath -m "$1"`
3011 1.1 mrg fi
3012 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result"
3013 1.1 mrg }
3014 1.1 mrg # end func_convert_file_cygwin_to_w32
3015 1.1 mrg
3016 1.1 mrg
3017 1.1 mrg # func_convert_file_nix_to_w32 ARG
3018 1.1 mrg # Convert file name ARG from *nix to w32 format. Requires a wine environment
3019 1.1 mrg # and a working winepath. Returns result in func_to_host_file_result.
3020 1.1 mrg func_convert_file_nix_to_w32 ()
3021 1.1 mrg {
3022 1.1 mrg $debug_cmd
3023 1.1 mrg
3024 1.1 mrg func_to_host_file_result=$1
3025 1.1 mrg if test -n "$1"; then
3026 1.1 mrg func_convert_core_file_wine_to_w32 "$1"
3027 1.1 mrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028 1.1 mrg fi
3029 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result"
3030 1.1 mrg }
3031 1.1 mrg # end func_convert_file_nix_to_w32
3032 1.1 mrg
3033 1.1 mrg
3034 1.1 mrg # func_convert_file_msys_to_cygwin ARG
3035 1.1 mrg # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3036 1.1 mrg # Returns result in func_to_host_file_result.
3037 1.1 mrg func_convert_file_msys_to_cygwin ()
3038 1.1 mrg {
3039 1.1 mrg $debug_cmd
3040 1.1 mrg
3041 1.1 mrg func_to_host_file_result=$1
3042 1.1 mrg if test -n "$1"; then
3043 1.1 mrg func_convert_core_msys_to_w32 "$1"
3044 1.1 mrg func_cygpath -u "$func_convert_core_msys_to_w32_result"
3045 1.1 mrg func_to_host_file_result=$func_cygpath_result
3046 1.1 mrg fi
3047 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result"
3048 1.1 mrg }
3049 1.1 mrg # end func_convert_file_msys_to_cygwin
3050 1.1 mrg
3051 1.1 mrg
3052 1.1 mrg # func_convert_file_nix_to_cygwin ARG
3053 1.1 mrg # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
3054 1.1 mrg # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
3055 1.1 mrg # in func_to_host_file_result.
3056 1.1 mrg func_convert_file_nix_to_cygwin ()
3057 1.1 mrg {
3058 1.1 mrg $debug_cmd
3059 1.1 mrg
3060 1.1 mrg func_to_host_file_result=$1
3061 1.1 mrg if test -n "$1"; then
3062 1.1 mrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063 1.1 mrg func_convert_core_file_wine_to_w32 "$1"
3064 1.1 mrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3065 1.1 mrg func_to_host_file_result=$func_cygpath_result
3066 1.1 mrg fi
3067 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result"
3068 1.1 mrg }
3069 1.1 mrg # end func_convert_file_nix_to_cygwin
3070 1.1 mrg
3071 1.1 mrg
3072 1.1 mrg #############################################
3073 1.1 mrg # $build to $host PATH CONVERSION FUNCTIONS #
3074 1.1 mrg #############################################
3075 1.1 mrg # invoked via '$to_host_path_cmd ARG'
3076 1.1 mrg #
3077 1.1 mrg # In each case, ARG is the path to be converted from $build to $host format.
3078 1.1 mrg # The result will be available in $func_to_host_path_result.
3079 1.1 mrg #
3080 1.1 mrg # Path separators are also converted from $build format to $host format. If
3081 1.1 mrg # ARG begins or ends with a path separator character, it is preserved (but
3082 1.1 mrg # converted to $host format) on output.
3083 1.1 mrg #
3084 1.1 mrg # All path conversion functions are named using the following convention:
3085 1.1 mrg # file name conversion function : func_convert_file_X_to_Y ()
3086 1.1 mrg # path conversion function : func_convert_path_X_to_Y ()
3087 1.1 mrg # where, for any given $build/$host combination the 'X_to_Y' value is the
3088 1.1 mrg # same. If conversion functions are added for new $build/$host combinations,
3089 1.1 mrg # the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090 1.1 mrg # will break.
3091 1.1 mrg
3092 1.1 mrg
3093 1.1 mrg # func_init_to_host_path_cmd
3094 1.1 mrg # Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095 1.1 mrg # appropriate value, based on the value of $to_host_file_cmd.
3096 1.1 mrg to_host_path_cmd=
3097 1.1 mrg func_init_to_host_path_cmd ()
3098 1.1 mrg {
3099 1.1 mrg $debug_cmd
3100 1.1 mrg
3101 1.1 mrg if test -z "$to_host_path_cmd"; then
3102 1.1 mrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3103 1.1 mrg to_host_path_cmd=func_convert_path_$func_stripname_result
3104 1.1 mrg fi
3105 1.1 mrg }
3106 1.1 mrg
3107 1.1 mrg
3108 1.1 mrg # func_to_host_path ARG
3109 1.1 mrg # Converts the path ARG from $build format to $host format. Return result
3110 1.1 mrg # in func_to_host_path_result.
3111 1.1 mrg func_to_host_path ()
3112 1.1 mrg {
3113 1.1 mrg $debug_cmd
3114 1.1 mrg
3115 1.1 mrg func_init_to_host_path_cmd
3116 1.1 mrg $to_host_path_cmd "$1"
3117 1.1 mrg }
3118 1.1 mrg # end func_to_host_path
3119 1.1 mrg
3120 1.1 mrg
3121 1.1 mrg # func_convert_path_noop ARG
3122 1.1 mrg # Copy ARG to func_to_host_path_result.
3123 1.1 mrg func_convert_path_noop ()
3124 1.1 mrg {
3125 1.1 mrg func_to_host_path_result=$1
3126 1.1 mrg }
3127 1.1 mrg # end func_convert_path_noop
3128 1.1 mrg
3129 1.1 mrg
3130 1.1 mrg # func_convert_path_msys_to_w32 ARG
3131 1.1 mrg # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132 1.1 mrg # conversion to w32 is not available inside the cwrapper. Returns result in
3133 1.1 mrg # func_to_host_path_result.
3134 1.1 mrg func_convert_path_msys_to_w32 ()
3135 1.1 mrg {
3136 1.1 mrg $debug_cmd
3137 1.1 mrg
3138 1.1 mrg func_to_host_path_result=$1
3139 1.1 mrg if test -n "$1"; then
3140 1.1 mrg # Remove leading and trailing path separator characters from ARG. MSYS
3141 1.1 mrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142 1.1 mrg # and winepath ignores them completely.
3143 1.1 mrg func_stripname : : "$1"
3144 1.1 mrg func_to_host_path_tmp1=$func_stripname_result
3145 1.1 mrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3146 1.1 mrg func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147 1.1 mrg func_convert_path_check : ";" \
3148 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150 1.1 mrg fi
3151 1.1 mrg }
3152 1.1 mrg # end func_convert_path_msys_to_w32
3153 1.1 mrg
3154 1.1 mrg
3155 1.1 mrg # func_convert_path_cygwin_to_w32 ARG
3156 1.1 mrg # Convert path ARG from Cygwin to w32 format. Returns result in
3157 1.1 mrg # func_to_host_file_result.
3158 1.1 mrg func_convert_path_cygwin_to_w32 ()
3159 1.1 mrg {
3160 1.1 mrg $debug_cmd
3161 1.1 mrg
3162 1.1 mrg func_to_host_path_result=$1
3163 1.1 mrg if test -n "$1"; then
3164 1.1 mrg # See func_convert_path_msys_to_w32:
3165 1.1 mrg func_stripname : : "$1"
3166 1.1 mrg func_to_host_path_tmp1=$func_stripname_result
3167 1.1 mrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168 1.1 mrg func_convert_path_check : ";" \
3169 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171 1.1 mrg fi
3172 1.1 mrg }
3173 1.1 mrg # end func_convert_path_cygwin_to_w32
3174 1.1 mrg
3175 1.1 mrg
3176 1.1 mrg # func_convert_path_nix_to_w32 ARG
3177 1.1 mrg # Convert path ARG from *nix to w32 format. Requires a wine environment and
3178 1.1 mrg # a working winepath. Returns result in func_to_host_file_result.
3179 1.1 mrg func_convert_path_nix_to_w32 ()
3180 1.1 mrg {
3181 1.1 mrg $debug_cmd
3182 1.1 mrg
3183 1.1 mrg func_to_host_path_result=$1
3184 1.1 mrg if test -n "$1"; then
3185 1.1 mrg # See func_convert_path_msys_to_w32:
3186 1.1 mrg func_stripname : : "$1"
3187 1.1 mrg func_to_host_path_tmp1=$func_stripname_result
3188 1.1 mrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3189 1.1 mrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190 1.1 mrg func_convert_path_check : ";" \
3191 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193 1.1 mrg fi
3194 1.1 mrg }
3195 1.1 mrg # end func_convert_path_nix_to_w32
3196 1.1 mrg
3197 1.1 mrg
3198 1.1 mrg # func_convert_path_msys_to_cygwin ARG
3199 1.1 mrg # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3200 1.1 mrg # Returns result in func_to_host_file_result.
3201 1.1 mrg func_convert_path_msys_to_cygwin ()
3202 1.1 mrg {
3203 1.1 mrg $debug_cmd
3204 1.1 mrg
3205 1.1 mrg func_to_host_path_result=$1
3206 1.1 mrg if test -n "$1"; then
3207 1.1 mrg # See func_convert_path_msys_to_w32:
3208 1.1 mrg func_stripname : : "$1"
3209 1.1 mrg func_to_host_path_tmp1=$func_stripname_result
3210 1.1 mrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211 1.1 mrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3212 1.1 mrg func_to_host_path_result=$func_cygpath_result
3213 1.1 mrg func_convert_path_check : : \
3214 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216 1.1 mrg fi
3217 1.1 mrg }
3218 1.1 mrg # end func_convert_path_msys_to_cygwin
3219 1.1 mrg
3220 1.1 mrg
3221 1.1 mrg # func_convert_path_nix_to_cygwin ARG
3222 1.1 mrg # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
3223 1.1 mrg # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
3224 1.1 mrg # func_to_host_file_result.
3225 1.1 mrg func_convert_path_nix_to_cygwin ()
3226 1.1 mrg {
3227 1.1 mrg $debug_cmd
3228 1.1 mrg
3229 1.1 mrg func_to_host_path_result=$1
3230 1.1 mrg if test -n "$1"; then
3231 1.1 mrg # Remove leading and trailing path separator characters from
3232 1.1 mrg # ARG. msys behavior is inconsistent here, cygpath turns them
3233 1.1 mrg # into '.;' and ';.', and winepath ignores them completely.
3234 1.1 mrg func_stripname : : "$1"
3235 1.1 mrg func_to_host_path_tmp1=$func_stripname_result
3236 1.1 mrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237 1.1 mrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3238 1.1 mrg func_to_host_path_result=$func_cygpath_result
3239 1.1 mrg func_convert_path_check : : \
3240 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242 1.1 mrg fi
3243 1.1 mrg }
3244 1.1 mrg # end func_convert_path_nix_to_cygwin
3245 1.1 mrg
3246 1.1 mrg
3247 1.1 mrg # func_dll_def_p FILE
3248 1.1 mrg # True iff FILE is a Windows DLL '.def' file.
3249 1.1 mrg # Keep in sync with _LT_DLL_DEF_P in libtool.m4
3250 1.1 mrg func_dll_def_p ()
3251 1.1 mrg {
3252 1.1 mrg $debug_cmd
3253 1.1 mrg
3254 1.1 mrg func_dll_def_p_tmp=`$SED -n \
3255 1.1 mrg -e 's/^[ ]*//' \
3256 1.1 mrg -e '/^\(;.*\)*$/d' \
3257 1.1 mrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
3258 1.1 mrg -e q \
3259 1.1 mrg "$1"`
3260 1.1 mrg test DEF = "$func_dll_def_p_tmp"
3261 1.1 mrg }
3262 1.1 mrg
3263 1.1 mrg
3264 1.1 mrg # func_mode_compile arg...
3265 1.1 mrg func_mode_compile ()
3266 1.1 mrg {
3267 1.1 mrg $debug_cmd
3268 1.1 mrg
3269 1.1 mrg # Get the compilation command and the source file.
3270 1.1 mrg base_compile=
3271 1.1 mrg srcfile=$nonopt # always keep a non-empty value in "srcfile"
3272 1.1 mrg suppress_opt=yes
3273 1.1 mrg suppress_output=
3274 1.1 mrg arg_mode=normal
3275 1.1 mrg libobj=
3276 1.1 mrg later=
3277 1.1 mrg pie_flag=
3278 1.1 mrg
3279 1.1 mrg for arg
3280 1.1 mrg do
3281 1.1 mrg case $arg_mode in
3282 1.1 mrg arg )
3283 1.1 mrg # do not "continue". Instead, add this to base_compile
3284 1.1 mrg lastarg=$arg
3285 1.1 mrg arg_mode=normal
3286 1.1 mrg ;;
3287 1.1 mrg
3288 1.1 mrg target )
3289 1.1 mrg libobj=$arg
3290 1.1 mrg arg_mode=normal
3291 1.1 mrg continue
3292 1.1 mrg ;;
3293 1.1 mrg
3294 1.1 mrg normal )
3295 1.1 mrg # Accept any command-line options.
3296 1.1 mrg case $arg in
3297 1.1 mrg -o)
3298 1.1 mrg test -n "$libobj" && \
3299 1.1 mrg func_fatal_error "you cannot specify '-o' more than once"
3300 1.1 mrg arg_mode=target
3301 1.1 mrg continue
3302 1.1 mrg ;;
3303 1.1 mrg
3304 1.1 mrg -pie | -fpie | -fPIE)
3305 1.1 mrg func_append pie_flag " $arg"
3306 1.1 mrg continue
3307 1.1 mrg ;;
3308 1.1 mrg
3309 1.1 mrg -shared | -static | -prefer-pic | -prefer-non-pic)
3310 1.1 mrg func_append later " $arg"
3311 1.1 mrg continue
3312 1.1 mrg ;;
3313 1.1 mrg
3314 1.1 mrg -no-suppress)
3315 1.1 mrg suppress_opt=no
3316 1.1 mrg continue
3317 1.1 mrg ;;
3318 1.1 mrg
3319 1.1 mrg -Xcompiler)
3320 1.1 mrg arg_mode=arg # the next one goes into the "base_compile" arg list
3321 1.1 mrg continue # The current "srcfile" will either be retained or
3322 1.1 mrg ;; # replaced later. I would guess that would be a bug.
3323 1.1 mrg
3324 1.1 mrg -Wc,*)
3325 1.1 mrg func_stripname '-Wc,' '' "$arg"
3326 1.1 mrg args=$func_stripname_result
3327 1.1 mrg lastarg=
3328 1.1 mrg save_ifs=$IFS; IFS=,
3329 1.1 mrg for arg in $args; do
3330 1.1 mrg IFS=$save_ifs
3331 1.1 mrg func_append_quoted lastarg "$arg"
3332 1.1 mrg done
3333 1.1 mrg IFS=$save_ifs
3334 1.1 mrg func_stripname ' ' '' "$lastarg"
3335 1.1 mrg lastarg=$func_stripname_result
3336 1.1 mrg
3337 1.1 mrg # Add the arguments to base_compile.
3338 1.1 mrg func_append base_compile " $lastarg"
3339 1.1 mrg continue
3340 1.1 mrg ;;
3341 1.1 mrg
3342 1.1 mrg *)
3343 1.1 mrg # Accept the current argument as the source file.
3344 1.1 mrg # The previous "srcfile" becomes the current argument.
3345 1.1 mrg #
3346 1.1 mrg lastarg=$srcfile
3347 1.1 mrg srcfile=$arg
3348 1.1 mrg ;;
3349 1.1 mrg esac # case $arg
3350 1.1 mrg ;;
3351 1.1 mrg esac # case $arg_mode
3352 1.1 mrg
3353 1.1 mrg # Aesthetically quote the previous argument.
3354 1.1 mrg func_append_quoted base_compile "$lastarg"
3355 1.1 mrg done # for arg
3356 1.1 mrg
3357 1.1 mrg case $arg_mode in
3358 1.1 mrg arg)
3359 1.1 mrg func_fatal_error "you must specify an argument for -Xcompile"
3360 1.1 mrg ;;
3361 1.1 mrg target)
3362 1.1 mrg func_fatal_error "you must specify a target with '-o'"
3363 1.1 mrg ;;
3364 1.1 mrg *)
3365 1.1 mrg # Get the name of the library object.
3366 1.1 mrg test -z "$libobj" && {
3367 1.1 mrg func_basename "$srcfile"
3368 1.1 mrg libobj=$func_basename_result
3369 1.1 mrg }
3370 1.1 mrg ;;
3371 1.1 mrg esac
3372 1.1 mrg
3373 1.1 mrg # Recognize several different file suffixes.
3374 1.1 mrg # If the user specifies -o file.o, it is replaced with file.lo
3375 1.1 mrg case $libobj in
3376 1.1 mrg *.[cCFSifmso] | \
3377 1.1 mrg *.ada | *.adb | *.ads | *.asm | \
3378 1.1 mrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3379 1.1 mrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3380 1.1 mrg func_xform "$libobj"
3381 1.1 mrg libobj=$func_xform_result
3382 1.1 mrg ;;
3383 1.1 mrg esac
3384 1.1 mrg
3385 1.1 mrg case $libobj in
3386 1.1 mrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387 1.1 mrg *)
3388 1.1 mrg func_fatal_error "cannot determine name of library object from '$libobj'"
3389 1.1 mrg ;;
3390 1.1 mrg esac
3391 1.1 mrg
3392 1.1 mrg func_infer_tag $base_compile
3393 1.1 mrg
3394 1.1 mrg for arg in $later; do
3395 1.1 mrg case $arg in
3396 1.1 mrg -shared)
3397 1.1 mrg test yes = "$build_libtool_libs" \
3398 1.1 mrg || func_fatal_configuration "cannot build a shared library"
3399 1.1 mrg build_old_libs=no
3400 1.1 mrg continue
3401 1.1 mrg ;;
3402 1.1 mrg
3403 1.1 mrg -static)
3404 1.1 mrg build_libtool_libs=no
3405 1.1 mrg build_old_libs=yes
3406 1.1 mrg continue
3407 1.1 mrg ;;
3408 1.1 mrg
3409 1.1 mrg -prefer-pic)
3410 1.1 mrg pic_mode=yes
3411 1.1 mrg continue
3412 1.1 mrg ;;
3413 1.1 mrg
3414 1.1 mrg -prefer-non-pic)
3415 1.1 mrg pic_mode=no
3416 1.1 mrg continue
3417 1.1 mrg ;;
3418 1.1 mrg esac
3419 1.1 mrg done
3420 1.1 mrg
3421 1.1 mrg func_quote_for_eval "$libobj"
3422 1.1 mrg test "X$libobj" != "X$func_quote_for_eval_result" \
3423 1.1 mrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
3424 1.1 mrg && func_warning "libobj name '$libobj' may not contain shell special characters."
3425 1.1 mrg func_dirname_and_basename "$obj" "/" ""
3426 1.1 mrg objname=$func_basename_result
3427 1.1 mrg xdir=$func_dirname_result
3428 1.1 mrg lobj=$xdir$objdir/$objname
3429 1.1 mrg
3430 1.1 mrg test -z "$base_compile" && \
3431 1.1 mrg func_fatal_help "you must specify a compilation command"
3432 1.1 mrg
3433 1.1 mrg # Delete any leftover library objects.
3434 1.1 mrg if test yes = "$build_old_libs"; then
3435 1.1 mrg removelist="$obj $lobj $libobj ${libobj}T"
3436 1.1 mrg else
3437 1.1 mrg removelist="$lobj $libobj ${libobj}T"
3438 1.1 mrg fi
3439 1.1 mrg
3440 1.1 mrg # On Cygwin there's no "real" PIC flag so we must build both object types
3441 1.1 mrg case $host_os in
3442 1.1 mrg cygwin* | mingw* | pw32* | os2* | cegcc*)
3443 1.1 mrg pic_mode=default
3444 1.1 mrg ;;
3445 1.1 mrg esac
3446 1.1 mrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447 1.1 mrg # non-PIC code in shared libraries is not supported
3448 1.1 mrg pic_mode=default
3449 1.1 mrg fi
3450 1.1 mrg
3451 1.1 mrg # Calculate the filename of the output object if compiler does
3452 1.1 mrg # not support -o with -c
3453 1.1 mrg if test no = "$compiler_c_o"; then
3454 1.1 mrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3455 1.1 mrg lockfile=$output_obj.lock
3456 1.1 mrg else
3457 1.1 mrg output_obj=
3458 1.1 mrg need_locks=no
3459 1.1 mrg lockfile=
3460 1.1 mrg fi
3461 1.1 mrg
3462 1.1 mrg # Lock this critical section if it is needed
3463 1.1 mrg # We use this script file to make the link, it avoids creating a new file
3464 1.1 mrg if test yes = "$need_locks"; then
3465 1.1 mrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3466 1.1 mrg func_echo "Waiting for $lockfile to be removed"
3467 1.1 mrg sleep 2
3468 1.1 mrg done
3469 1.1 mrg elif test warn = "$need_locks"; then
3470 1.1 mrg if test -f "$lockfile"; then
3471 1.1 mrg $ECHO "\
3472 1.1 mrg *** ERROR, $lockfile exists and contains:
3473 1.1 mrg `cat $lockfile 2>/dev/null`
3474 1.1 mrg
3475 1.1 mrg This indicates that another process is trying to use the same
3476 1.1 mrg temporary object file, and libtool could not work around it because
3477 1.1 mrg your compiler does not support '-c' and '-o' together. If you
3478 1.1 mrg repeat this compilation, it may succeed, by chance, but you had better
3479 1.1 mrg avoid parallel builds (make -j) in this platform, or get a better
3480 1.1 mrg compiler."
3481 1.1 mrg
3482 1.1 mrg $opt_dry_run || $RM $removelist
3483 1.1 mrg exit $EXIT_FAILURE
3484 1.1 mrg fi
3485 1.1 mrg func_append removelist " $output_obj"
3486 1.1 mrg $ECHO "$srcfile" > "$lockfile"
3487 1.1 mrg fi
3488 1.1 mrg
3489 1.1 mrg $opt_dry_run || $RM $removelist
3490 1.1 mrg func_append removelist " $lockfile"
3491 1.1 mrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3492 1.1 mrg
3493 1.1 mrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494 1.1 mrg srcfile=$func_to_tool_file_result
3495 1.1 mrg func_quote_for_eval "$srcfile"
3496 1.1 mrg qsrcfile=$func_quote_for_eval_result
3497 1.1 mrg
3498 1.1 mrg # Only build a PIC object if we are building libtool libraries.
3499 1.1 mrg if test yes = "$build_libtool_libs"; then
3500 1.1 mrg # Without this assignment, base_compile gets emptied.
3501 1.1 mrg fbsd_hideous_sh_bug=$base_compile
3502 1.1 mrg
3503 1.1 mrg if test no != "$pic_mode"; then
3504 1.1 mrg command="$base_compile $qsrcfile $pic_flag"
3505 1.1 mrg else
3506 1.1 mrg # Don't build PIC code
3507 1.1 mrg command="$base_compile $qsrcfile"
3508 1.1 mrg fi
3509 1.1 mrg
3510 1.1 mrg func_mkdir_p "$xdir$objdir"
3511 1.1 mrg
3512 1.1 mrg if test -z "$output_obj"; then
3513 1.1 mrg # Place PIC objects in $objdir
3514 1.1 mrg func_append command " -o $lobj"
3515 1.1 mrg fi
3516 1.1 mrg
3517 1.1 mrg func_show_eval_locale "$command" \
3518 1.1 mrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519 1.1 mrg
3520 1.1 mrg if test warn = "$need_locks" &&
3521 1.1 mrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3522 1.1 mrg $ECHO "\
3523 1.1 mrg *** ERROR, $lockfile contains:
3524 1.1 mrg `cat $lockfile 2>/dev/null`
3525 1.1 mrg
3526 1.1 mrg but it should contain:
3527 1.1 mrg $srcfile
3528 1.1 mrg
3529 1.1 mrg This indicates that another process is trying to use the same
3530 1.1 mrg temporary object file, and libtool could not work around it because
3531 1.1 mrg your compiler does not support '-c' and '-o' together. If you
3532 1.1 mrg repeat this compilation, it may succeed, by chance, but you had better
3533 1.1 mrg avoid parallel builds (make -j) in this platform, or get a better
3534 1.1 mrg compiler."
3535 1.1 mrg
3536 1.1 mrg $opt_dry_run || $RM $removelist
3537 1.1 mrg exit $EXIT_FAILURE
3538 1.1 mrg fi
3539 1.1 mrg
3540 1.1 mrg # Just move the object if needed, then go on to compile the next one
3541 1.1 mrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3542 1.1 mrg func_show_eval '$MV "$output_obj" "$lobj"' \
3543 1.1 mrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544 1.1 mrg fi
3545 1.1 mrg
3546 1.1 mrg # Allow error messages only from the first compilation.
3547 1.1 mrg if test yes = "$suppress_opt"; then
3548 1.1 mrg suppress_output=' >/dev/null 2>&1'
3549 1.1 mrg fi
3550 1.1 mrg fi
3551 1.1 mrg
3552 1.1 mrg # Only build a position-dependent object if we build old libraries.
3553 1.1 mrg if test yes = "$build_old_libs"; then
3554 1.1 mrg if test yes != "$pic_mode"; then
3555 1.1 mrg # Don't build PIC code
3556 1.1 mrg command="$base_compile $qsrcfile$pie_flag"
3557 1.1 mrg else
3558 1.1 mrg command="$base_compile $qsrcfile $pic_flag"
3559 1.1 mrg fi
3560 1.1 mrg if test yes = "$compiler_c_o"; then
3561 1.1 mrg func_append command " -o $obj"
3562 1.1 mrg fi
3563 1.1 mrg
3564 1.1 mrg # Suppress compiler output if we already did a PIC compilation.
3565 1.1 mrg func_append command "$suppress_output"
3566 1.1 mrg func_show_eval_locale "$command" \
3567 1.1 mrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568 1.1 mrg
3569 1.1 mrg if test warn = "$need_locks" &&
3570 1.1 mrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3571 1.1 mrg $ECHO "\
3572 1.1 mrg *** ERROR, $lockfile contains:
3573 1.1 mrg `cat $lockfile 2>/dev/null`
3574 1.1 mrg
3575 1.1 mrg but it should contain:
3576 1.1 mrg $srcfile
3577 1.1 mrg
3578 1.1 mrg This indicates that another process is trying to use the same
3579 1.1 mrg temporary object file, and libtool could not work around it because
3580 1.1 mrg your compiler does not support '-c' and '-o' together. If you
3581 1.1 mrg repeat this compilation, it may succeed, by chance, but you had better
3582 1.1 mrg avoid parallel builds (make -j) in this platform, or get a better
3583 1.1 mrg compiler."
3584 1.1 mrg
3585 1.1 mrg $opt_dry_run || $RM $removelist
3586 1.1 mrg exit $EXIT_FAILURE
3587 1.1 mrg fi
3588 1.1 mrg
3589 1.1 mrg # Just move the object if needed
3590 1.1 mrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3591 1.1 mrg func_show_eval '$MV "$output_obj" "$obj"' \
3592 1.1 mrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593 1.1 mrg fi
3594 1.1 mrg fi
3595 1.1 mrg
3596 1.1 mrg $opt_dry_run || {
3597 1.1 mrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598 1.1 mrg
3599 1.1 mrg # Unlock the critical section if it was locked
3600 1.1 mrg if test no != "$need_locks"; then
3601 1.1 mrg removelist=$lockfile
3602 1.1 mrg $RM "$lockfile"
3603 1.1 mrg fi
3604 1.1 mrg }
3605 1.1 mrg
3606 1.1 mrg exit $EXIT_SUCCESS
3607 1.1 mrg }
3608 1.1 mrg
3609 1.1 mrg $opt_help || {
3610 1.1 mrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3611 1.1 mrg }
3612 1.1 mrg
3613 1.1 mrg func_mode_help ()
3614 1.1 mrg {
3615 1.1 mrg # We need to display help for each of the modes.
3616 1.1 mrg case $opt_mode in
3617 1.1 mrg "")
3618 1.1 mrg # Generic help is extracted from the usage comments
3619 1.1 mrg # at the start of this file.
3620 1.1 mrg func_help
3621 1.1 mrg ;;
3622 1.1 mrg
3623 1.1 mrg clean)
3624 1.1 mrg $ECHO \
3625 1.1 mrg "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626 1.1 mrg
3627 1.1 mrg Remove files from the build directory.
3628 1.1 mrg
3629 1.1 mrg RM is the name of the program to use to delete files associated with each FILE
3630 1.1 mrg (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3631 1.1 mrg to RM.
3632 1.1 mrg
3633 1.1 mrg If FILE is a libtool library, object or program, all the files associated
3634 1.1 mrg with it are deleted. Otherwise, only FILE itself is deleted using RM."
3635 1.1 mrg ;;
3636 1.1 mrg
3637 1.1 mrg compile)
3638 1.1 mrg $ECHO \
3639 1.1 mrg "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640 1.1 mrg
3641 1.1 mrg Compile a source file into a libtool library object.
3642 1.1 mrg
3643 1.1 mrg This mode accepts the following additional options:
3644 1.1 mrg
3645 1.1 mrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE
3646 1.1 mrg -no-suppress do not suppress compiler output for multiple passes
3647 1.1 mrg -prefer-pic try to build PIC objects only
3648 1.1 mrg -prefer-non-pic try to build non-PIC objects only
3649 1.1 mrg -shared do not build a '.o' file suitable for static linking
3650 1.1 mrg -static only build a '.o' file suitable for static linking
3651 1.1 mrg -Wc,FLAG pass FLAG directly to the compiler
3652 1.1 mrg
3653 1.1 mrg COMPILE-COMMAND is a command to be used in creating a 'standard' object file
3654 1.1 mrg from the given SOURCEFILE.
3655 1.1 mrg
3656 1.1 mrg The output file name is determined by removing the directory component from
3657 1.1 mrg SOURCEFILE, then substituting the C source code suffix '.c' with the
3658 1.1 mrg library object suffix, '.lo'."
3659 1.1 mrg ;;
3660 1.1 mrg
3661 1.1 mrg execute)
3662 1.1 mrg $ECHO \
3663 1.1 mrg "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664 1.1 mrg
3665 1.1 mrg Automatically set library path, then run a program.
3666 1.1 mrg
3667 1.1 mrg This mode accepts the following additional options:
3668 1.1 mrg
3669 1.1 mrg -dlopen FILE add the directory containing FILE to the library path
3670 1.1 mrg
3671 1.1 mrg This mode sets the library path environment variable according to '-dlopen'
3672 1.1 mrg flags.
3673 1.1 mrg
3674 1.1 mrg If any of the ARGS are libtool executable wrappers, then they are translated
3675 1.1 mrg into their corresponding uninstalled binary, and any of their required library
3676 1.1 mrg directories are added to the library path.
3677 1.1 mrg
3678 1.1 mrg Then, COMMAND is executed, with ARGS as arguments."
3679 1.1 mrg ;;
3680 1.1 mrg
3681 1.1 mrg finish)
3682 1.1 mrg $ECHO \
3683 1.1 mrg "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684 1.1 mrg
3685 1.1 mrg Complete the installation of libtool libraries.
3686 1.1 mrg
3687 1.1 mrg Each LIBDIR is a directory that contains libtool libraries.
3688 1.1 mrg
3689 1.1 mrg The commands that this mode executes may require superuser privileges. Use
3690 1.1 mrg the '--dry-run' option if you just want to see what would be executed."
3691 1.1 mrg ;;
3692 1.1 mrg
3693 1.1 mrg install)
3694 1.1 mrg $ECHO \
3695 1.1 mrg "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696 1.1 mrg
3697 1.1 mrg Install executables or libraries.
3698 1.1 mrg
3699 1.1 mrg INSTALL-COMMAND is the installation command. The first component should be
3700 1.1 mrg either the 'install' or 'cp' program.
3701 1.1 mrg
3702 1.1 mrg The following components of INSTALL-COMMAND are treated specially:
3703 1.1 mrg
3704 1.1 mrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
3705 1.1 mrg
3706 1.1 mrg The rest of the components are interpreted as arguments to that command (only
3707 1.1 mrg BSD-compatible install options are recognized)."
3708 1.1 mrg ;;
3709 1.1 mrg
3710 1.1 mrg link)
3711 1.1 mrg $ECHO \
3712 1.1 mrg "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713 1.1 mrg
3714 1.1 mrg Link object files or libraries together to form another library, or to
3715 1.1 mrg create an executable program.
3716 1.1 mrg
3717 1.1 mrg LINK-COMMAND is a command using the C compiler that you would use to create
3718 1.1 mrg a program from several object files.
3719 1.1 mrg
3720 1.1 mrg The following components of LINK-COMMAND are treated specially:
3721 1.1 mrg
3722 1.1 mrg -all-static do not do any dynamic linking at all
3723 1.1 mrg -avoid-version do not add a version suffix if possible
3724 1.1 mrg -bindir BINDIR specify path to binaries directory (for systems where
3725 1.1 mrg libraries must be found in the PATH setting at runtime)
3726 1.1 mrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
3727 1.1 mrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
3728 1.1 mrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3729 1.1 mrg -export-symbols SYMFILE
3730 1.1 mrg try to export only the symbols listed in SYMFILE
3731 1.1 mrg -export-symbols-regex REGEX
3732 1.1 mrg try to export only the symbols matching REGEX
3733 1.1 mrg -LLIBDIR search LIBDIR for required installed libraries
3734 1.1 mrg -lNAME OUTPUT-FILE requires the installed library libNAME
3735 1.1 mrg -module build a library that can dlopened
3736 1.1 mrg -no-fast-install disable the fast-install mode
3737 1.1 mrg -no-install link a not-installable executable
3738 1.1 mrg -no-undefined declare that a library does not refer to external symbols
3739 1.1 mrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
3740 1.1 mrg -objectlist FILE use a list of object files found in FILE to specify objects
3741 1.1 mrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
3742 1.1 mrg -precious-files-regex REGEX
3743 1.1 mrg don't remove output files matching REGEX
3744 1.1 mrg -release RELEASE specify package release information
3745 1.1 mrg -rpath LIBDIR the created library will eventually be installed in LIBDIR
3746 1.1 mrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
3747 1.1 mrg -shared only do dynamic linking of libtool libraries
3748 1.1 mrg -shrext SUFFIX override the standard shared library file extension
3749 1.1 mrg -static do not do any dynamic linking of uninstalled libtool libraries
3750 1.1 mrg -static-libtool-libs
3751 1.1 mrg do not do any dynamic linking of libtool libraries
3752 1.1 mrg -version-info CURRENT[:REVISION[:AGE]]
3753 1.1 mrg specify library version info [each variable defaults to 0]
3754 1.1 mrg -weak LIBNAME declare that the target provides the LIBNAME interface
3755 1.1 mrg -Wc,FLAG
3756 1.1 mrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
3757 1.1 mrg -Wl,FLAG
3758 1.1 mrg -Xlinker FLAG pass linker-specific FLAG directly to the linker
3759 1.1 mrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
3760 1.1 mrg
3761 1.1 mrg All other options (arguments beginning with '-') are ignored.
3762 1.1 mrg
3763 1.1 mrg Every other argument is treated as a filename. Files ending in '.la' are
3764 1.1 mrg treated as uninstalled libtool libraries, other files are standard or library
3765 1.1 mrg object files.
3766 1.1 mrg
3767 1.1 mrg If the OUTPUT-FILE ends in '.la', then a libtool library is created,
3768 1.1 mrg only library objects ('.lo' files) may be specified, and '-rpath' is
3769 1.1 mrg required, except when creating a convenience library.
3770 1.1 mrg
3771 1.1 mrg If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3772 1.1 mrg using 'ar' and 'ranlib', or on Windows using 'lib'.
3773 1.1 mrg
3774 1.1 mrg If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3775 1.1 mrg is created, otherwise an executable program is created."
3776 1.1 mrg ;;
3777 1.1 mrg
3778 1.1 mrg uninstall)
3779 1.1 mrg $ECHO \
3780 1.1 mrg "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781 1.1 mrg
3782 1.1 mrg Remove libraries from an installation directory.
3783 1.1 mrg
3784 1.1 mrg RM is the name of the program to use to delete files associated with each FILE
3785 1.1 mrg (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3786 1.1 mrg to RM.
3787 1.1 mrg
3788 1.1 mrg If FILE is a libtool library, all the files associated with it are deleted.
3789 1.1 mrg Otherwise, only FILE itself is deleted using RM."
3790 1.1 mrg ;;
3791 1.1 mrg
3792 1.1 mrg *)
3793 1.1 mrg func_fatal_help "invalid operation mode '$opt_mode'"
3794 1.1 mrg ;;
3795 1.1 mrg esac
3796 1.1 mrg
3797 1.1 mrg echo
3798 1.1 mrg $ECHO "Try '$progname --help' for more information about other modes."
3799 1.1 mrg }
3800 1.1 mrg
3801 1.1 mrg # Now that we've collected a possible --mode arg, show help if necessary
3802 1.1 mrg if $opt_help; then
3803 1.1 mrg if test : = "$opt_help"; then
3804 1.1 mrg func_mode_help
3805 1.1 mrg else
3806 1.1 mrg {
3807 1.1 mrg func_help noexit
3808 1.1 mrg for opt_mode in compile link execute install finish uninstall clean; do
3809 1.1 mrg func_mode_help
3810 1.1 mrg done
3811 1.1 mrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
3812 1.1 mrg {
3813 1.1 mrg func_help noexit
3814 1.1 mrg for opt_mode in compile link execute install finish uninstall clean; do
3815 1.1 mrg echo
3816 1.1 mrg func_mode_help
3817 1.1 mrg done
3818 1.1 mrg } |
3819 1.1 mrg $SED '1d
3820 1.1 mrg /^When reporting/,/^Report/{
3821 1.1 mrg H
3822 1.1 mrg d
3823 1.1 mrg }
3824 1.1 mrg $x
3825 1.1 mrg /information about other modes/d
3826 1.1 mrg /more detailed .*MODE/d
3827 1.1 mrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828 1.1 mrg fi
3829 1.1 mrg exit $?
3830 1.1 mrg fi
3831 1.1 mrg
3832 1.1 mrg
3833 1.1 mrg # func_mode_execute arg...
3834 1.1 mrg func_mode_execute ()
3835 1.1 mrg {
3836 1.1 mrg $debug_cmd
3837 1.1 mrg
3838 1.1 mrg # The first argument is the command name.
3839 1.1 mrg cmd=$nonopt
3840 1.1 mrg test -z "$cmd" && \
3841 1.1 mrg func_fatal_help "you must specify a COMMAND"
3842 1.1 mrg
3843 1.1 mrg # Handle -dlopen flags immediately.
3844 1.1 mrg for file in $opt_dlopen; do
3845 1.1 mrg test -f "$file" \
3846 1.1 mrg || func_fatal_help "'$file' is not a file"
3847 1.1 mrg
3848 1.1 mrg dir=
3849 1.1 mrg case $file in
3850 1.1 mrg *.la)
3851 1.1 mrg func_resolve_sysroot "$file"
3852 1.1 mrg file=$func_resolve_sysroot_result
3853 1.1 mrg
3854 1.1 mrg # Check to see that this really is a libtool archive.
3855 1.1 mrg func_lalib_unsafe_p "$file" \
3856 1.1 mrg || func_fatal_help "'$lib' is not a valid libtool archive"
3857 1.1 mrg
3858 1.1 mrg # Read the libtool library.
3859 1.1 mrg dlname=
3860 1.1 mrg library_names=
3861 1.1 mrg func_source "$file"
3862 1.1 mrg
3863 1.1 mrg # Skip this library if it cannot be dlopened.
3864 1.1 mrg if test -z "$dlname"; then
3865 1.1 mrg # Warn if it was a shared library.
3866 1.1 mrg test -n "$library_names" && \
3867 1.1 mrg func_warning "'$file' was not linked with '-export-dynamic'"
3868 1.1 mrg continue
3869 1.1 mrg fi
3870 1.1 mrg
3871 1.1 mrg func_dirname "$file" "" "."
3872 1.1 mrg dir=$func_dirname_result
3873 1.1 mrg
3874 1.1 mrg if test -f "$dir/$objdir/$dlname"; then
3875 1.1 mrg func_append dir "/$objdir"
3876 1.1 mrg else
3877 1.1 mrg if test ! -f "$dir/$dlname"; then
3878 1.1 mrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3879 1.1 mrg fi
3880 1.1 mrg fi
3881 1.1 mrg ;;
3882 1.1 mrg
3883 1.1 mrg *.lo)
3884 1.1 mrg # Just add the directory containing the .lo file.
3885 1.1 mrg func_dirname "$file" "" "."
3886 1.1 mrg dir=$func_dirname_result
3887 1.1 mrg ;;
3888 1.1 mrg
3889 1.1 mrg *)
3890 1.1 mrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3891 1.1 mrg continue
3892 1.1 mrg ;;
3893 1.1 mrg esac
3894 1.1 mrg
3895 1.1 mrg # Get the absolute pathname.
3896 1.1 mrg absdir=`cd "$dir" && pwd`
3897 1.1 mrg test -n "$absdir" && dir=$absdir
3898 1.1 mrg
3899 1.1 mrg # Now add the directory to shlibpath_var.
3900 1.1 mrg if eval "test -z \"\$$shlibpath_var\""; then
3901 1.1 mrg eval "$shlibpath_var=\"\$dir\""
3902 1.1 mrg else
3903 1.1 mrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3904 1.1 mrg fi
3905 1.1 mrg done
3906 1.1 mrg
3907 1.1 mrg # This variable tells wrapper scripts just to set shlibpath_var
3908 1.1 mrg # rather than running their programs.
3909 1.1 mrg libtool_execute_magic=$magic
3910 1.1 mrg
3911 1.1 mrg # Check if any of the arguments is a wrapper script.
3912 1.1 mrg args=
3913 1.1 mrg for file
3914 1.1 mrg do
3915 1.1 mrg case $file in
3916 1.1 mrg -* | *.la | *.lo ) ;;
3917 1.1 mrg *)
3918 1.1 mrg # Do a test to see if this is really a libtool program.
3919 1.1 mrg if func_ltwrapper_script_p "$file"; then
3920 1.1 mrg func_source "$file"
3921 1.1 mrg # Transform arg to wrapped name.
3922 1.1 mrg file=$progdir/$program
3923 1.1 mrg elif func_ltwrapper_executable_p "$file"; then
3924 1.1 mrg func_ltwrapper_scriptname "$file"
3925 1.1 mrg func_source "$func_ltwrapper_scriptname_result"
3926 1.1 mrg # Transform arg to wrapped name.
3927 1.1 mrg file=$progdir/$program
3928 1.1 mrg fi
3929 1.1 mrg ;;
3930 1.1 mrg esac
3931 1.1 mrg # Quote arguments (to preserve shell metacharacters).
3932 1.1 mrg func_append_quoted args "$file"
3933 1.1 mrg done
3934 1.1 mrg
3935 1.1 mrg if $opt_dry_run; then
3936 1.1 mrg # Display what would be done.
3937 1.1 mrg if test -n "$shlibpath_var"; then
3938 1.1 mrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3939 1.1 mrg echo "export $shlibpath_var"
3940 1.1 mrg fi
3941 1.1 mrg $ECHO "$cmd$args"
3942 1.1 mrg exit $EXIT_SUCCESS
3943 1.1 mrg else
3944 1.1 mrg if test -n "$shlibpath_var"; then
3945 1.1 mrg # Export the shlibpath_var.
3946 1.1 mrg eval "export $shlibpath_var"
3947 1.1 mrg fi
3948 1.1 mrg
3949 1.1 mrg # Restore saved environment variables
3950 1.1 mrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3951 1.1 mrg do
3952 1.1 mrg eval "if test \"\${save_$lt_var+set}\" = set; then
3953 1.1 mrg $lt_var=\$save_$lt_var; export $lt_var
3954 1.1 mrg else
3955 1.1 mrg $lt_unset $lt_var
3956 1.1 mrg fi"
3957 1.1 mrg done
3958 1.1 mrg
3959 1.1 mrg # Now prepare to actually exec the command.
3960 1.1 mrg exec_cmd=\$cmd$args
3961 1.1 mrg fi
3962 1.1 mrg }
3963 1.1 mrg
3964 1.1 mrg test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3965 1.1 mrg
3966 1.1 mrg
3967 1.1 mrg # func_mode_finish arg...
3968 1.1 mrg func_mode_finish ()
3969 1.1 mrg {
3970 1.1 mrg $debug_cmd
3971 1.1 mrg
3972 1.1 mrg libs=
3973 1.1 mrg libdirs=
3974 1.1 mrg admincmds=
3975 1.1 mrg
3976 1.1 mrg for opt in "$nonopt" ${1+"$@"}
3977 1.1 mrg do
3978 1.1 mrg if test -d "$opt"; then
3979 1.1 mrg func_append libdirs " $opt"
3980 1.1 mrg
3981 1.1 mrg elif test -f "$opt"; then
3982 1.1 mrg if func_lalib_unsafe_p "$opt"; then
3983 1.1 mrg func_append libs " $opt"
3984 1.1 mrg else
3985 1.1 mrg func_warning "'$opt' is not a valid libtool archive"
3986 1.1 mrg fi
3987 1.1 mrg
3988 1.1 mrg else
3989 1.1 mrg func_fatal_error "invalid argument '$opt'"
3990 1.1 mrg fi
3991 1.1 mrg done
3992 1.1 mrg
3993 1.1 mrg if test -n "$libs"; then
3994 1.1 mrg if test -n "$lt_sysroot"; then
3995 1.1 mrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996 1.1 mrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997 1.1 mrg else
3998 1.1 mrg sysroot_cmd=
3999 1.1 mrg fi
4000 1.1 mrg
4001 1.1 mrg # Remove sysroot references
4002 1.1 mrg if $opt_dry_run; then
4003 1.1 mrg for lib in $libs; do
4004 1.1 mrg echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005 1.1 mrg done
4006 1.1 mrg else
4007 1.1 mrg tmpdir=`func_mktempdir`
4008 1.1 mrg for lib in $libs; do
4009 1.1 mrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010 1.1 mrg > $tmpdir/tmp-la
4011 1.1 mrg mv -f $tmpdir/tmp-la $lib
4012 1.1 mrg done
4013 1.1 mrg ${RM}r "$tmpdir"
4014 1.1 mrg fi
4015 1.1 mrg fi
4016 1.1 mrg
4017 1.1 mrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4018 1.1 mrg for libdir in $libdirs; do
4019 1.1 mrg if test -n "$finish_cmds"; then
4020 1.1 mrg # Do each command in the finish commands.
4021 1.1 mrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4022 1.1 mrg '"$cmd"'"'
4023 1.1 mrg fi
4024 1.1 mrg if test -n "$finish_eval"; then
4025 1.1 mrg # Do the single finish_eval.
4026 1.1 mrg eval cmds=\"$finish_eval\"
4027 1.1 mrg $opt_dry_run || eval "$cmds" || func_append admincmds "
4028 1.1 mrg $cmds"
4029 1.1 mrg fi
4030 1.1 mrg done
4031 1.1 mrg fi
4032 1.1 mrg
4033 1.1 mrg # Exit here if they wanted silent mode.
4034 1.1 mrg $opt_quiet && exit $EXIT_SUCCESS
4035 1.1 mrg
4036 1.1 mrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037 1.1 mrg echo "----------------------------------------------------------------------"
4038 1.1 mrg echo "Libraries have been installed in:"
4039 1.1 mrg for libdir in $libdirs; do
4040 1.1 mrg $ECHO " $libdir"
4041 1.1 mrg done
4042 1.1 mrg echo
4043 1.1 mrg echo "If you ever happen to want to link against installed libraries"
4044 1.1 mrg echo "in a given directory, LIBDIR, you must either use libtool, and"
4045 1.1 mrg echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046 1.1 mrg echo "flag during linking and do at least one of the following:"
4047 1.1 mrg if test -n "$shlibpath_var"; then
4048 1.1 mrg echo " - add LIBDIR to the '$shlibpath_var' environment variable"
4049 1.1 mrg echo " during execution"
4050 1.1 mrg fi
4051 1.1 mrg if test -n "$runpath_var"; then
4052 1.1 mrg echo " - add LIBDIR to the '$runpath_var' environment variable"
4053 1.1 mrg echo " during linking"
4054 1.1 mrg fi
4055 1.1 mrg if test -n "$hardcode_libdir_flag_spec"; then
4056 1.1 mrg libdir=LIBDIR
4057 1.1 mrg eval flag=\"$hardcode_libdir_flag_spec\"
4058 1.1 mrg
4059 1.1 mrg $ECHO " - use the '$flag' linker flag"
4060 1.1 mrg fi
4061 1.1 mrg if test -n "$admincmds"; then
4062 1.1 mrg $ECHO " - have your system administrator run these commands:$admincmds"
4063 1.1 mrg fi
4064 1.1 mrg if test -f /etc/ld.so.conf; then
4065 1.1 mrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066 1.1 mrg fi
4067 1.1 mrg echo
4068 1.1 mrg
4069 1.1 mrg echo "See any operating system documentation about shared libraries for"
4070 1.1 mrg case $host in
4071 1.1 mrg solaris2.[6789]|solaris2.1[0-9])
4072 1.1 mrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073 1.1 mrg echo "pages."
4074 1.1 mrg ;;
4075 1.1 mrg *)
4076 1.1 mrg echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077 1.1 mrg ;;
4078 1.1 mrg esac
4079 1.1 mrg echo "----------------------------------------------------------------------"
4080 1.1 mrg fi
4081 1.1 mrg exit $EXIT_SUCCESS
4082 1.1 mrg }
4083 1.1 mrg
4084 1.1 mrg test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085 1.1 mrg
4086 1.1 mrg
4087 1.1 mrg # func_mode_install arg...
4088 1.1 mrg func_mode_install ()
4089 1.1 mrg {
4090 1.1 mrg $debug_cmd
4091 1.1 mrg
4092 1.1 mrg # There may be an optional sh(1) argument at the beginning of
4093 1.1 mrg # install_prog (especially on Windows NT).
4094 1.1 mrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4095 1.1 mrg # Allow the use of GNU shtool's install command.
4096 1.1 mrg case $nonopt in *shtool*) :;; *) false;; esac
4097 1.1 mrg then
4098 1.1 mrg # Aesthetically quote it.
4099 1.1 mrg func_quote_for_eval "$nonopt"
4100 1.1 mrg install_prog="$func_quote_for_eval_result "
4101 1.1 mrg arg=$1
4102 1.1 mrg shift
4103 1.1 mrg else
4104 1.1 mrg install_prog=
4105 1.1 mrg arg=$nonopt
4106 1.1 mrg fi
4107 1.1 mrg
4108 1.1 mrg # The real first argument should be the name of the installation program.
4109 1.1 mrg # Aesthetically quote it.
4110 1.1 mrg func_quote_for_eval "$arg"
4111 1.1 mrg func_append install_prog "$func_quote_for_eval_result"
4112 1.1 mrg install_shared_prog=$install_prog
4113 1.1 mrg case " $install_prog " in
4114 1.1 mrg *[\\\ /]cp\ *) install_cp=: ;;
4115 1.1 mrg *) install_cp=false ;;
4116 1.1 mrg esac
4117 1.1 mrg
4118 1.1 mrg # We need to accept at least all the BSD install flags.
4119 1.1 mrg dest=
4120 1.1 mrg files=
4121 1.1 mrg opts=
4122 1.1 mrg prev=
4123 1.1 mrg install_type=
4124 1.1 mrg isdir=false
4125 1.1 mrg stripme=
4126 1.1 mrg no_mode=:
4127 1.1 mrg for arg
4128 1.1 mrg do
4129 1.1 mrg arg2=
4130 1.1 mrg if test -n "$dest"; then
4131 1.1 mrg func_append files " $dest"
4132 1.1 mrg dest=$arg
4133 1.1 mrg continue
4134 1.1 mrg fi
4135 1.1 mrg
4136 1.1 mrg case $arg in
4137 1.1 mrg -d) isdir=: ;;
4138 1.1 mrg -f)
4139 1.1 mrg if $install_cp; then :; else
4140 1.1 mrg prev=$arg
4141 1.1 mrg fi
4142 1.1 mrg ;;
4143 1.1 mrg -g | -m | -o)
4144 1.1 mrg prev=$arg
4145 1.1 mrg ;;
4146 1.1 mrg -s)
4147 1.1 mrg stripme=" -s"
4148 1.1 mrg continue
4149 1.1 mrg ;;
4150 1.1 mrg -*)
4151 1.1 mrg ;;
4152 1.1 mrg *)
4153 1.1 mrg # If the previous option needed an argument, then skip it.
4154 1.1 mrg if test -n "$prev"; then
4155 1.1 mrg if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156 1.1 mrg arg2=$install_override_mode
4157 1.1 mrg no_mode=false
4158 1.1 mrg fi
4159 1.1 mrg prev=
4160 1.1 mrg else
4161 1.1 mrg dest=$arg
4162 1.1 mrg continue
4163 1.1 mrg fi
4164 1.1 mrg ;;
4165 1.1 mrg esac
4166 1.1 mrg
4167 1.1 mrg # Aesthetically quote the argument.
4168 1.1 mrg func_quote_for_eval "$arg"
4169 1.1 mrg func_append install_prog " $func_quote_for_eval_result"
4170 1.1 mrg if test -n "$arg2"; then
4171 1.1 mrg func_quote_for_eval "$arg2"
4172 1.1 mrg fi
4173 1.1 mrg func_append install_shared_prog " $func_quote_for_eval_result"
4174 1.1 mrg done
4175 1.1 mrg
4176 1.1 mrg test -z "$install_prog" && \
4177 1.1 mrg func_fatal_help "you must specify an install program"
4178 1.1 mrg
4179 1.1 mrg test -n "$prev" && \
4180 1.1 mrg func_fatal_help "the '$prev' option requires an argument"
4181 1.1 mrg
4182 1.1 mrg if test -n "$install_override_mode" && $no_mode; then
4183 1.1 mrg if $install_cp; then :; else
4184 1.1 mrg func_quote_for_eval "$install_override_mode"
4185 1.1 mrg func_append install_shared_prog " -m $func_quote_for_eval_result"
4186 1.1 mrg fi
4187 1.1 mrg fi
4188 1.1 mrg
4189 1.1 mrg if test -z "$files"; then
4190 1.1 mrg if test -z "$dest"; then
4191 1.1 mrg func_fatal_help "no file or destination specified"
4192 1.1 mrg else
4193 1.1 mrg func_fatal_help "you must specify a destination"
4194 1.1 mrg fi
4195 1.1 mrg fi
4196 1.1 mrg
4197 1.1 mrg # Strip any trailing slash from the destination.
4198 1.1 mrg func_stripname '' '/' "$dest"
4199 1.1 mrg dest=$func_stripname_result
4200 1.1 mrg
4201 1.1 mrg # Check to see that the destination is a directory.
4202 1.1 mrg test -d "$dest" && isdir=:
4203 1.1 mrg if $isdir; then
4204 1.1 mrg destdir=$dest
4205 1.1 mrg destname=
4206 1.1 mrg else
4207 1.1 mrg func_dirname_and_basename "$dest" "" "."
4208 1.1 mrg destdir=$func_dirname_result
4209 1.1 mrg destname=$func_basename_result
4210 1.1 mrg
4211 1.1 mrg # Not a directory, so check to see that there is only one file specified.
4212 1.1 mrg set dummy $files; shift
4213 1.1 mrg test "$#" -gt 1 && \
4214 1.1 mrg func_fatal_help "'$dest' is not a directory"
4215 1.1 mrg fi
4216 1.1 mrg case $destdir in
4217 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) ;;
4218 1.1 mrg *)
4219 1.1 mrg for file in $files; do
4220 1.1 mrg case $file in
4221 1.1 mrg *.lo) ;;
4222 1.1 mrg *)
4223 1.1 mrg func_fatal_help "'$destdir' must be an absolute directory name"
4224 1.1 mrg ;;
4225 1.1 mrg esac
4226 1.1 mrg done
4227 1.1 mrg ;;
4228 1.1 mrg esac
4229 1.1 mrg
4230 1.1 mrg # This variable tells wrapper scripts just to set variables rather
4231 1.1 mrg # than running their programs.
4232 1.1 mrg libtool_install_magic=$magic
4233 1.1 mrg
4234 1.1 mrg staticlibs=
4235 1.1 mrg future_libdirs=
4236 1.1 mrg current_libdirs=
4237 1.1 mrg for file in $files; do
4238 1.1 mrg
4239 1.1 mrg # Do each installation.
4240 1.1 mrg case $file in
4241 1.1 mrg *.$libext)
4242 1.1 mrg # Do the static libraries later.
4243 1.1 mrg func_append staticlibs " $file"
4244 1.1 mrg ;;
4245 1.1 mrg
4246 1.1 mrg *.la)
4247 1.1 mrg func_resolve_sysroot "$file"
4248 1.1 mrg file=$func_resolve_sysroot_result
4249 1.1 mrg
4250 1.1 mrg # Check to see that this really is a libtool archive.
4251 1.1 mrg func_lalib_unsafe_p "$file" \
4252 1.1 mrg || func_fatal_help "'$file' is not a valid libtool archive"
4253 1.1 mrg
4254 1.1 mrg library_names=
4255 1.1 mrg old_library=
4256 1.1 mrg relink_command=
4257 1.1 mrg func_source "$file"
4258 1.1 mrg
4259 1.1 mrg # Add the libdir to current_libdirs if it is the destination.
4260 1.1 mrg if test "X$destdir" = "X$libdir"; then
4261 1.1 mrg case "$current_libdirs " in
4262 1.1 mrg *" $libdir "*) ;;
4263 1.1 mrg *) func_append current_libdirs " $libdir" ;;
4264 1.1 mrg esac
4265 1.1 mrg else
4266 1.1 mrg # Note the libdir as a future libdir.
4267 1.1 mrg case "$future_libdirs " in
4268 1.1 mrg *" $libdir "*) ;;
4269 1.1 mrg *) func_append future_libdirs " $libdir" ;;
4270 1.1 mrg esac
4271 1.1 mrg fi
4272 1.1 mrg
4273 1.1 mrg func_dirname "$file" "/" ""
4274 1.1 mrg dir=$func_dirname_result
4275 1.1 mrg func_append dir "$objdir"
4276 1.1 mrg
4277 1.1 mrg if test -n "$relink_command"; then
4278 1.1 mrg # Determine the prefix the user has applied to our future dir.
4279 1.1 mrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4280 1.1 mrg
4281 1.1 mrg # Don't allow the user to place us outside of our expected
4282 1.1 mrg # location b/c this prevents finding dependent libraries that
4283 1.1 mrg # are installed to the same prefix.
4284 1.1 mrg # At present, this check doesn't affect windows .dll's that
4285 1.1 mrg # are installed into $libdir/../bin (currently, that works fine)
4286 1.1 mrg # but it's something to keep an eye on.
4287 1.1 mrg test "$inst_prefix_dir" = "$destdir" && \
4288 1.1 mrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4289 1.1 mrg
4290 1.1 mrg if test -n "$inst_prefix_dir"; then
4291 1.1 mrg # Stick the inst_prefix_dir data into the link command.
4292 1.1 mrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4293 1.1 mrg else
4294 1.1 mrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4295 1.1 mrg fi
4296 1.1 mrg
4297 1.1 mrg func_warning "relinking '$file'"
4298 1.1 mrg func_show_eval "$relink_command" \
4299 1.1 mrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4300 1.1 mrg fi
4301 1.1 mrg
4302 1.1 mrg # See the names of the shared library.
4303 1.1 mrg set dummy $library_names; shift
4304 1.1 mrg if test -n "$1"; then
4305 1.1 mrg realname=$1
4306 1.1 mrg shift
4307 1.1 mrg
4308 1.1 mrg srcname=$realname
4309 1.1 mrg test -n "$relink_command" && srcname=${realname}T
4310 1.1 mrg
4311 1.1 mrg # Install the shared library and build the symlinks.
4312 1.1 mrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4313 1.1 mrg 'exit $?'
4314 1.1 mrg tstripme=$stripme
4315 1.1 mrg case $host_os in
4316 1.1 mrg cygwin* | mingw* | pw32* | cegcc*)
4317 1.1 mrg case $realname in
4318 1.1 mrg *.dll.a)
4319 1.1 mrg tstripme=
4320 1.1 mrg ;;
4321 1.1 mrg esac
4322 1.1 mrg ;;
4323 1.1 mrg os2*)
4324 1.1 mrg case $realname in
4325 1.1 mrg *_dll.a)
4326 1.1 mrg tstripme=
4327 1.1 mrg ;;
4328 1.1 mrg esac
4329 1.1 mrg ;;
4330 1.1 mrg esac
4331 1.1 mrg if test -n "$tstripme" && test -n "$striplib"; then
4332 1.1 mrg func_show_eval "$striplib $destdir/$realname" 'exit $?'
4333 1.1 mrg fi
4334 1.1 mrg
4335 1.1 mrg if test "$#" -gt 0; then
4336 1.1 mrg # Delete the old symlinks, and create new ones.
4337 1.1 mrg # Try 'ln -sf' first, because the 'ln' binary might depend on
4338 1.1 mrg # the symlink we replace! Solaris /bin/ln does not understand -f,
4339 1.1 mrg # so we also need to try rm && ln -s.
4340 1.1 mrg for linkname
4341 1.1 mrg do
4342 1.1 mrg test "$linkname" != "$realname" \
4343 1.1 mrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4344 1.1 mrg done
4345 1.1 mrg fi
4346 1.1 mrg
4347 1.1 mrg # Do each command in the postinstall commands.
4348 1.1 mrg lib=$destdir/$realname
4349 1.1 mrg func_execute_cmds "$postinstall_cmds" 'exit $?'
4350 1.1 mrg fi
4351 1.1 mrg
4352 1.1 mrg # Install the pseudo-library for information purposes.
4353 1.1 mrg func_basename "$file"
4354 1.1 mrg name=$func_basename_result
4355 1.1 mrg instname=$dir/${name}i
4356 1.1 mrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357 1.1 mrg
4358 1.1 mrg # Maybe install the static library, too.
4359 1.1 mrg test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4360 1.1 mrg ;;
4361 1.1 mrg
4362 1.1 mrg *.lo)
4363 1.1 mrg # Install (i.e. copy) a libtool object.
4364 1.1 mrg
4365 1.1 mrg # Figure out destination file name, if it wasn't already specified.
4366 1.1 mrg if test -n "$destname"; then
4367 1.1 mrg destfile=$destdir/$destname
4368 1.1 mrg else
4369 1.1 mrg func_basename "$file"
4370 1.1 mrg destfile=$func_basename_result
4371 1.1 mrg destfile=$destdir/$destfile
4372 1.1 mrg fi
4373 1.1 mrg
4374 1.1 mrg # Deduce the name of the destination old-style object file.
4375 1.1 mrg case $destfile in
4376 1.1 mrg *.lo)
4377 1.1 mrg func_lo2o "$destfile"
4378 1.1 mrg staticdest=$func_lo2o_result
4379 1.1 mrg ;;
4380 1.1 mrg *.$objext)
4381 1.1 mrg staticdest=$destfile
4382 1.1 mrg destfile=
4383 1.1 mrg ;;
4384 1.1 mrg *)
4385 1.1 mrg func_fatal_help "cannot copy a libtool object to '$destfile'"
4386 1.1 mrg ;;
4387 1.1 mrg esac
4388 1.1 mrg
4389 1.1 mrg # Install the libtool object if requested.
4390 1.1 mrg test -n "$destfile" && \
4391 1.1 mrg func_show_eval "$install_prog $file $destfile" 'exit $?'
4392 1.1 mrg
4393 1.1 mrg # Install the old object if enabled.
4394 1.1 mrg if test yes = "$build_old_libs"; then
4395 1.1 mrg # Deduce the name of the old-style object file.
4396 1.1 mrg func_lo2o "$file"
4397 1.1 mrg staticobj=$func_lo2o_result
4398 1.1 mrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399 1.1 mrg fi
4400 1.1 mrg exit $EXIT_SUCCESS
4401 1.1 mrg ;;
4402 1.1 mrg
4403 1.1 mrg *)
4404 1.1 mrg # Figure out destination file name, if it wasn't already specified.
4405 1.1 mrg if test -n "$destname"; then
4406 1.1 mrg destfile=$destdir/$destname
4407 1.1 mrg else
4408 1.1 mrg func_basename "$file"
4409 1.1 mrg destfile=$func_basename_result
4410 1.1 mrg destfile=$destdir/$destfile
4411 1.1 mrg fi
4412 1.1 mrg
4413 1.1 mrg # If the file is missing, and there is a .exe on the end, strip it
4414 1.1 mrg # because it is most likely a libtool script we actually want to
4415 1.1 mrg # install
4416 1.1 mrg stripped_ext=
4417 1.1 mrg case $file in
4418 1.1 mrg *.exe)
4419 1.1 mrg if test ! -f "$file"; then
4420 1.1 mrg func_stripname '' '.exe' "$file"
4421 1.1 mrg file=$func_stripname_result
4422 1.1 mrg stripped_ext=.exe
4423 1.1 mrg fi
4424 1.1 mrg ;;
4425 1.1 mrg esac
4426 1.1 mrg
4427 1.1 mrg # Do a test to see if this is really a libtool program.
4428 1.1 mrg case $host in
4429 1.1 mrg *cygwin* | *mingw*)
4430 1.1 mrg if func_ltwrapper_executable_p "$file"; then
4431 1.1 mrg func_ltwrapper_scriptname "$file"
4432 1.1 mrg wrapper=$func_ltwrapper_scriptname_result
4433 1.1 mrg else
4434 1.1 mrg func_stripname '' '.exe' "$file"
4435 1.1 mrg wrapper=$func_stripname_result
4436 1.1 mrg fi
4437 1.1 mrg ;;
4438 1.1 mrg *)
4439 1.1 mrg wrapper=$file
4440 1.1 mrg ;;
4441 1.1 mrg esac
4442 1.1 mrg if func_ltwrapper_script_p "$wrapper"; then
4443 1.1 mrg notinst_deplibs=
4444 1.1 mrg relink_command=
4445 1.1 mrg
4446 1.1 mrg func_source "$wrapper"
4447 1.1 mrg
4448 1.1 mrg # Check the variables that should have been set.
4449 1.1 mrg test -z "$generated_by_libtool_version" && \
4450 1.1 mrg func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451 1.1 mrg
4452 1.1 mrg finalize=:
4453 1.1 mrg for lib in $notinst_deplibs; do
4454 1.1 mrg # Check to see that each library is installed.
4455 1.1 mrg libdir=
4456 1.1 mrg if test -f "$lib"; then
4457 1.1 mrg func_source "$lib"
4458 1.1 mrg fi
4459 1.1 mrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4460 1.1 mrg if test -n "$libdir" && test ! -f "$libfile"; then
4461 1.1 mrg func_warning "'$lib' has not been installed in '$libdir'"
4462 1.1 mrg finalize=false
4463 1.1 mrg fi
4464 1.1 mrg done
4465 1.1 mrg
4466 1.1 mrg relink_command=
4467 1.1 mrg func_source "$wrapper"
4468 1.1 mrg
4469 1.1 mrg outputname=
4470 1.1 mrg if test no = "$fast_install" && test -n "$relink_command"; then
4471 1.1 mrg $opt_dry_run || {
4472 1.1 mrg if $finalize; then
4473 1.1 mrg tmpdir=`func_mktempdir`
4474 1.1 mrg func_basename "$file$stripped_ext"
4475 1.1 mrg file=$func_basename_result
4476 1.1 mrg outputname=$tmpdir/$file
4477 1.1 mrg # Replace the output file specification.
4478 1.1 mrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4479 1.1 mrg
4480 1.1 mrg $opt_quiet || {
4481 1.1 mrg func_quote_for_expand "$relink_command"
4482 1.1 mrg eval "func_echo $func_quote_for_expand_result"
4483 1.1 mrg }
4484 1.1 mrg if eval "$relink_command"; then :
4485 1.1 mrg else
4486 1.1 mrg func_error "error: relink '$file' with the above command before installing it"
4487 1.1 mrg $opt_dry_run || ${RM}r "$tmpdir"
4488 1.1 mrg continue
4489 1.1 mrg fi
4490 1.1 mrg file=$outputname
4491 1.1 mrg else
4492 1.1 mrg func_warning "cannot relink '$file'"
4493 1.1 mrg fi
4494 1.1 mrg }
4495 1.1 mrg else
4496 1.1 mrg # Install the binary that we compiled earlier.
4497 1.1 mrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4498 1.1 mrg fi
4499 1.1 mrg fi
4500 1.1 mrg
4501 1.1 mrg # remove .exe since cygwin /usr/bin/install will append another
4502 1.1 mrg # one anyway
4503 1.1 mrg case $install_prog,$host in
4504 1.1 mrg */usr/bin/install*,*cygwin*)
4505 1.1 mrg case $file:$destfile in
4506 1.1 mrg *.exe:*.exe)
4507 1.1 mrg # this is ok
4508 1.1 mrg ;;
4509 1.1 mrg *.exe:*)
4510 1.1 mrg destfile=$destfile.exe
4511 1.1 mrg ;;
4512 1.1 mrg *:*.exe)
4513 1.1 mrg func_stripname '' '.exe' "$destfile"
4514 1.1 mrg destfile=$func_stripname_result
4515 1.1 mrg ;;
4516 1.1 mrg esac
4517 1.1 mrg ;;
4518 1.1 mrg esac
4519 1.1 mrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4520 1.1 mrg $opt_dry_run || if test -n "$outputname"; then
4521 1.1 mrg ${RM}r "$tmpdir"
4522 1.1 mrg fi
4523 1.1 mrg ;;
4524 1.1 mrg esac
4525 1.1 mrg done
4526 1.1 mrg
4527 1.1 mrg for file in $staticlibs; do
4528 1.1 mrg func_basename "$file"
4529 1.1 mrg name=$func_basename_result
4530 1.1 mrg
4531 1.1 mrg # Set up the ranlib parameters.
4532 1.1 mrg oldlib=$destdir/$name
4533 1.1 mrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4534 1.1 mrg tool_oldlib=$func_to_tool_file_result
4535 1.1 mrg
4536 1.1 mrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4537 1.1 mrg
4538 1.1 mrg if test -n "$stripme" && test -n "$old_striplib"; then
4539 1.1 mrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4540 1.1 mrg fi
4541 1.1 mrg
4542 1.1 mrg # Do each command in the postinstall commands.
4543 1.1 mrg func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4544 1.1 mrg done
4545 1.1 mrg
4546 1.1 mrg test -n "$future_libdirs" && \
4547 1.1 mrg func_warning "remember to run '$progname --finish$future_libdirs'"
4548 1.1 mrg
4549 1.1 mrg if test -n "$current_libdirs"; then
4550 1.1 mrg # Maybe just do a dry run.
4551 1.1 mrg $opt_dry_run && current_libdirs=" -n$current_libdirs"
4552 1.1 mrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4553 1.1 mrg else
4554 1.1 mrg exit $EXIT_SUCCESS
4555 1.1 mrg fi
4556 1.1 mrg }
4557 1.1 mrg
4558 1.1 mrg test install = "$opt_mode" && func_mode_install ${1+"$@"}
4559 1.1 mrg
4560 1.1 mrg
4561 1.1 mrg # func_generate_dlsyms outputname originator pic_p
4562 1.1 mrg # Extract symbols from dlprefiles and create ${outputname}S.o with
4563 1.1 mrg # a dlpreopen symbol table.
4564 1.1 mrg func_generate_dlsyms ()
4565 1.1 mrg {
4566 1.1 mrg $debug_cmd
4567 1.1 mrg
4568 1.1 mrg my_outputname=$1
4569 1.1 mrg my_originator=$2
4570 1.1 mrg my_pic_p=${3-false}
4571 1.1 mrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4572 1.1 mrg my_dlsyms=
4573 1.1 mrg
4574 1.1 mrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4575 1.1 mrg if test -n "$NM" && test -n "$global_symbol_pipe"; then
4576 1.1 mrg my_dlsyms=${my_outputname}S.c
4577 1.1 mrg else
4578 1.1 mrg func_error "not configured to extract global symbols from dlpreopened files"
4579 1.1 mrg fi
4580 1.1 mrg fi
4581 1.1 mrg
4582 1.1 mrg if test -n "$my_dlsyms"; then
4583 1.1 mrg case $my_dlsyms in
4584 1.1 mrg "") ;;
4585 1.1 mrg *.c)
4586 1.1 mrg # Discover the nlist of each of the dlfiles.
4587 1.1 mrg nlist=$output_objdir/$my_outputname.nm
4588 1.1 mrg
4589 1.1 mrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4590 1.1 mrg
4591 1.1 mrg # Parse the name list into a source file.
4592 1.1 mrg func_verbose "creating $output_objdir/$my_dlsyms"
4593 1.1 mrg
4594 1.1 mrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4595 1.1 mrg /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4596 1.1 mrg /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4597 1.1 mrg
4598 1.1 mrg #ifdef __cplusplus
4599 1.1 mrg extern \"C\" {
4600 1.1 mrg #endif
4601 1.1 mrg
4602 1.1 mrg #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603 1.1 mrg #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604 1.1 mrg #endif
4605 1.1 mrg
4606 1.1 mrg /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
4607 1.1 mrg #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4608 1.1 mrg /* DATA imports from DLLs on WIN32 can't be const, because runtime
4609 1.1 mrg relocations are performed -- see ld's documentation on pseudo-relocs. */
4610 1.1 mrg # define LT_DLSYM_CONST
4611 1.1 mrg #elif defined __osf__
4612 1.1 mrg /* This system does not cope well with relocations in const data. */
4613 1.1 mrg # define LT_DLSYM_CONST
4614 1.1 mrg #else
4615 1.1 mrg # define LT_DLSYM_CONST const
4616 1.1 mrg #endif
4617 1.1 mrg
4618 1.1 mrg #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4619 1.1 mrg
4620 1.1 mrg /* External symbol declarations for the compiler. */\
4621 1.1 mrg "
4622 1.1 mrg
4623 1.1 mrg if test yes = "$dlself"; then
4624 1.1 mrg func_verbose "generating symbol list for '$output'"
4625 1.1 mrg
4626 1.1 mrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4627 1.1 mrg
4628 1.1 mrg # Add our own program objects to the symbol list.
4629 1.1 mrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4630 1.1 mrg for progfile in $progfiles; do
4631 1.1 mrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4632 1.1 mrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633 1.1 mrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4634 1.1 mrg done
4635 1.1 mrg
4636 1.1 mrg if test -n "$exclude_expsyms"; then
4637 1.1 mrg $opt_dry_run || {
4638 1.1 mrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4639 1.1 mrg eval '$MV "$nlist"T "$nlist"'
4640 1.1 mrg }
4641 1.1 mrg fi
4642 1.1 mrg
4643 1.1 mrg if test -n "$export_symbols_regex"; then
4644 1.1 mrg $opt_dry_run || {
4645 1.1 mrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4646 1.1 mrg eval '$MV "$nlist"T "$nlist"'
4647 1.1 mrg }
4648 1.1 mrg fi
4649 1.1 mrg
4650 1.1 mrg # Prepare the list of exported symbols
4651 1.1 mrg if test -z "$export_symbols"; then
4652 1.1 mrg export_symbols=$output_objdir/$outputname.exp
4653 1.1 mrg $opt_dry_run || {
4654 1.1 mrg $RM $export_symbols
4655 1.1 mrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4656 1.1 mrg case $host in
4657 1.1 mrg *cygwin* | *mingw* | *cegcc* )
4658 1.1 mrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4659 1.1 mrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4660 1.1 mrg ;;
4661 1.1 mrg esac
4662 1.1 mrg }
4663 1.1 mrg else
4664 1.1 mrg $opt_dry_run || {
4665 1.1 mrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4666 1.1 mrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4667 1.1 mrg eval '$MV "$nlist"T "$nlist"'
4668 1.1 mrg case $host in
4669 1.1 mrg *cygwin* | *mingw* | *cegcc* )
4670 1.1 mrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4671 1.1 mrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4672 1.1 mrg ;;
4673 1.1 mrg esac
4674 1.1 mrg }
4675 1.1 mrg fi
4676 1.1 mrg fi
4677 1.1 mrg
4678 1.1 mrg for dlprefile in $dlprefiles; do
4679 1.1 mrg func_verbose "extracting global C symbols from '$dlprefile'"
4680 1.1 mrg func_basename "$dlprefile"
4681 1.1 mrg name=$func_basename_result
4682 1.1 mrg case $host in
4683 1.1 mrg *cygwin* | *mingw* | *cegcc* )
4684 1.1 mrg # if an import library, we need to obtain dlname
4685 1.1 mrg if func_win32_import_lib_p "$dlprefile"; then
4686 1.1 mrg func_tr_sh "$dlprefile"
4687 1.1 mrg eval "curr_lafile=\$libfile_$func_tr_sh_result"
4688 1.1 mrg dlprefile_dlbasename=
4689 1.1 mrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690 1.1 mrg # Use subshell, to avoid clobbering current variable values
4691 1.1 mrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4692 1.1 mrg if test -n "$dlprefile_dlname"; then
4693 1.1 mrg func_basename "$dlprefile_dlname"
4694 1.1 mrg dlprefile_dlbasename=$func_basename_result
4695 1.1 mrg else
4696 1.1 mrg # no lafile. user explicitly requested -dlpreopen <import library>.
4697 1.1 mrg $sharedlib_from_linklib_cmd "$dlprefile"
4698 1.1 mrg dlprefile_dlbasename=$sharedlib_from_linklib_result
4699 1.1 mrg fi
4700 1.1 mrg fi
4701 1.1 mrg $opt_dry_run || {
4702 1.1 mrg if test -n "$dlprefile_dlbasename"; then
4703 1.1 mrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704 1.1 mrg else
4705 1.1 mrg func_warning "Could not compute DLL name from $name"
4706 1.1 mrg eval '$ECHO ": $name " >> "$nlist"'
4707 1.1 mrg fi
4708 1.1 mrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709 1.1 mrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710 1.1 mrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711 1.1 mrg }
4712 1.1 mrg else # not an import lib
4713 1.1 mrg $opt_dry_run || {
4714 1.1 mrg eval '$ECHO ": $name " >> "$nlist"'
4715 1.1 mrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716 1.1 mrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717 1.1 mrg }
4718 1.1 mrg fi
4719 1.1 mrg ;;
4720 1.1 mrg *)
4721 1.1 mrg $opt_dry_run || {
4722 1.1 mrg eval '$ECHO ": $name " >> "$nlist"'
4723 1.1 mrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724 1.1 mrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725 1.1 mrg }
4726 1.1 mrg ;;
4727 1.1 mrg esac
4728 1.1 mrg done
4729 1.1 mrg
4730 1.1 mrg $opt_dry_run || {
4731 1.1 mrg # Make sure we have at least an empty file.
4732 1.1 mrg test -f "$nlist" || : > "$nlist"
4733 1.1 mrg
4734 1.1 mrg if test -n "$exclude_expsyms"; then
4735 1.1 mrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4736 1.1 mrg $MV "$nlist"T "$nlist"
4737 1.1 mrg fi
4738 1.1 mrg
4739 1.1 mrg # Try sorting and uniquifying the output.
4740 1.1 mrg if $GREP -v "^: " < "$nlist" |
4741 1.1 mrg if sort -k 3 </dev/null >/dev/null 2>&1; then
4742 1.1 mrg sort -k 3
4743 1.1 mrg else
4744 1.1 mrg sort +2
4745 1.1 mrg fi |
4746 1.1 mrg uniq > "$nlist"S; then
4747 1.1 mrg :
4748 1.1 mrg else
4749 1.1 mrg $GREP -v "^: " < "$nlist" > "$nlist"S
4750 1.1 mrg fi
4751 1.1 mrg
4752 1.1 mrg if test -f "$nlist"S; then
4753 1.1 mrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4754 1.1 mrg else
4755 1.1 mrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4756 1.1 mrg fi
4757 1.1 mrg
4758 1.1 mrg func_show_eval '$RM "${nlist}I"'
4759 1.1 mrg if test -n "$global_symbol_to_import"; then
4760 1.1 mrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4761 1.1 mrg fi
4762 1.1 mrg
4763 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\
4764 1.1 mrg
4765 1.1 mrg /* The mapping between symbol names and symbols. */
4766 1.1 mrg typedef struct {
4767 1.1 mrg const char *name;
4768 1.1 mrg void *address;
4769 1.1 mrg } lt_dlsymlist;
4770 1.1 mrg extern LT_DLSYM_CONST lt_dlsymlist
4771 1.1 mrg lt_${my_prefix}_LTX_preloaded_symbols[];\
4772 1.1 mrg "
4773 1.1 mrg
4774 1.1 mrg if test -s "$nlist"I; then
4775 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\
4776 1.1 mrg static void lt_syminit(void)
4777 1.1 mrg {
4778 1.1 mrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4779 1.1 mrg for (; symbol->name; ++symbol)
4780 1.1 mrg {"
4781 1.1 mrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4782 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\
4783 1.1 mrg }
4784 1.1 mrg }"
4785 1.1 mrg fi
4786 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\
4787 1.1 mrg LT_DLSYM_CONST lt_dlsymlist
4788 1.1 mrg lt_${my_prefix}_LTX_preloaded_symbols[] =
4789 1.1 mrg { {\"$my_originator\", (void *) 0},"
4790 1.1 mrg
4791 1.1 mrg if test -s "$nlist"I; then
4792 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\
4793 1.1 mrg {\"@INIT@\", (void *) <_syminit},"
4794 1.1 mrg fi
4795 1.1 mrg
4796 1.1 mrg case $need_lib_prefix in
4797 1.1 mrg no)
4798 1.1 mrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4799 1.1 mrg ;;
4800 1.1 mrg *)
4801 1.1 mrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4802 1.1 mrg ;;
4803 1.1 mrg esac
4804 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\
4805 1.1 mrg {0, (void *) 0}
4806 1.1 mrg };
4807 1.1 mrg
4808 1.1 mrg /* This works around a problem in FreeBSD linker */
4809 1.1 mrg #ifdef FREEBSD_WORKAROUND
4810 1.1 mrg static const void *lt_preloaded_setup() {
4811 1.1 mrg return lt_${my_prefix}_LTX_preloaded_symbols;
4812 1.1 mrg }
4813 1.1 mrg #endif
4814 1.1 mrg
4815 1.1 mrg #ifdef __cplusplus
4816 1.1 mrg }
4817 1.1 mrg #endif\
4818 1.1 mrg "
4819 1.1 mrg } # !$opt_dry_run
4820 1.1 mrg
4821 1.1 mrg pic_flag_for_symtable=
4822 1.1 mrg case "$compile_command " in
4823 1.1 mrg *" -static "*) ;;
4824 1.1 mrg *)
4825 1.1 mrg case $host in
4826 1.1 mrg # compiling the symbol table file with pic_flag works around
4827 1.1 mrg # a FreeBSD bug that causes programs to crash when -lm is
4828 1.1 mrg # linked before any other PIC object. But we must not use
4829 1.1 mrg # pic_flag when linking with -static. The problem exists in
4830 1.1 mrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4831 1.1 mrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4832 1.1 mrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4833 1.1 mrg *-*-hpux*)
4834 1.1 mrg pic_flag_for_symtable=" $pic_flag" ;;
4835 1.1 mrg *)
4836 1.1 mrg $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4837 1.1 mrg ;;
4838 1.1 mrg esac
4839 1.1 mrg ;;
4840 1.1 mrg esac
4841 1.1 mrg symtab_cflags=
4842 1.1 mrg for arg in $LTCFLAGS; do
4843 1.1 mrg case $arg in
4844 1.1 mrg -pie | -fpie | -fPIE) ;;
4845 1.1 mrg *) func_append symtab_cflags " $arg" ;;
4846 1.1 mrg esac
4847 1.1 mrg done
4848 1.1 mrg
4849 1.1 mrg # Now compile the dynamic symbol file.
4850 1.1 mrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851 1.1 mrg
4852 1.1 mrg # Clean up the generated files.
4853 1.1 mrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4854 1.1 mrg
4855 1.1 mrg # Transform the symbol file into the correct name.
4856 1.1 mrg symfileobj=$output_objdir/${my_outputname}S.$objext
4857 1.1 mrg case $host in
4858 1.1 mrg *cygwin* | *mingw* | *cegcc* )
4859 1.1 mrg if test -f "$output_objdir/$my_outputname.def"; then
4860 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4862 1.1 mrg else
4863 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4865 1.1 mrg fi
4866 1.1 mrg ;;
4867 1.1 mrg *)
4868 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4870 1.1 mrg ;;
4871 1.1 mrg esac
4872 1.1 mrg ;;
4873 1.1 mrg *)
4874 1.1 mrg func_fatal_error "unknown suffix for '$my_dlsyms'"
4875 1.1 mrg ;;
4876 1.1 mrg esac
4877 1.1 mrg else
4878 1.1 mrg # We keep going just in case the user didn't refer to
4879 1.1 mrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
4880 1.1 mrg # really was required.
4881 1.1 mrg
4882 1.1 mrg # Nullify the symbol file.
4883 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4885 1.1 mrg fi
4886 1.1 mrg }
4887 1.1 mrg
4888 1.1 mrg # func_cygming_gnu_implib_p ARG
4889 1.1 mrg # This predicate returns with zero status (TRUE) if
4890 1.1 mrg # ARG is a GNU/binutils-style import library. Returns
4891 1.1 mrg # with nonzero status (FALSE) otherwise.
4892 1.1 mrg func_cygming_gnu_implib_p ()
4893 1.1 mrg {
4894 1.1 mrg $debug_cmd
4895 1.1 mrg
4896 1.1 mrg func_to_tool_file "$1" func_convert_file_msys_to_w32
4897 1.1 mrg 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)$'`
4898 1.1 mrg test -n "$func_cygming_gnu_implib_tmp"
4899 1.1 mrg }
4900 1.1 mrg
4901 1.1 mrg # func_cygming_ms_implib_p ARG
4902 1.1 mrg # This predicate returns with zero status (TRUE) if
4903 1.1 mrg # ARG is an MS-style import library. Returns
4904 1.1 mrg # with nonzero status (FALSE) otherwise.
4905 1.1 mrg func_cygming_ms_implib_p ()
4906 1.1 mrg {
4907 1.1 mrg $debug_cmd
4908 1.1 mrg
4909 1.1 mrg func_to_tool_file "$1" func_convert_file_msys_to_w32
4910 1.1 mrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4911 1.1 mrg test -n "$func_cygming_ms_implib_tmp"
4912 1.1 mrg }
4913 1.1 mrg
4914 1.1 mrg # func_win32_libid arg
4915 1.1 mrg # return the library type of file 'arg'
4916 1.1 mrg #
4917 1.1 mrg # Need a lot of goo to handle *both* DLLs and import libs
4918 1.1 mrg # Has to be a shell function in order to 'eat' the argument
4919 1.1 mrg # that is supplied when $file_magic_command is called.
4920 1.1 mrg # Despite the name, also deal with 64 bit binaries.
4921 1.1 mrg func_win32_libid ()
4922 1.1 mrg {
4923 1.1 mrg $debug_cmd
4924 1.1 mrg
4925 1.1 mrg win32_libid_type=unknown
4926 1.1 mrg win32_fileres=`file -L $1 2>/dev/null`
4927 1.1 mrg case $win32_fileres in
4928 1.1 mrg *ar\ archive\ import\ library*) # definitely import
4929 1.1 mrg win32_libid_type="x86 archive import"
4930 1.1 mrg ;;
4931 1.1 mrg *ar\ archive*) # could be an import, or static
4932 1.1 mrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4933 1.1 mrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934 1.1 mrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4935 1.1 mrg case $nm_interface in
4936 1.1 mrg "MS dumpbin")
4937 1.1 mrg if func_cygming_ms_implib_p "$1" ||
4938 1.1 mrg func_cygming_gnu_implib_p "$1"
4939 1.1 mrg then
4940 1.1 mrg win32_nmres=import
4941 1.1 mrg else
4942 1.1 mrg win32_nmres=
4943 1.1 mrg fi
4944 1.1 mrg ;;
4945 1.1 mrg *)
4946 1.1 mrg func_to_tool_file "$1" func_convert_file_msys_to_w32
4947 1.1 mrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4948 1.1 mrg $SED -n -e '
4949 1.1 mrg 1,100{
4950 1.1 mrg / I /{
4951 1.1 mrg s|.*|import|
4952 1.1 mrg p
4953 1.1 mrg q
4954 1.1 mrg }
4955 1.1 mrg }'`
4956 1.1 mrg ;;
4957 1.1 mrg esac
4958 1.1 mrg case $win32_nmres in
4959 1.1 mrg import*) win32_libid_type="x86 archive import";;
4960 1.1 mrg *) win32_libid_type="x86 archive static";;
4961 1.1 mrg esac
4962 1.1 mrg fi
4963 1.1 mrg ;;
4964 1.1 mrg *DLL*)
4965 1.1 mrg win32_libid_type="x86 DLL"
4966 1.1 mrg ;;
4967 1.1 mrg *executable*) # but shell scripts are "executable" too...
4968 1.1 mrg case $win32_fileres in
4969 1.1 mrg *MS\ Windows\ PE\ Intel*)
4970 1.1 mrg win32_libid_type="x86 DLL"
4971 1.1 mrg ;;
4972 1.1 mrg esac
4973 1.1 mrg ;;
4974 1.1 mrg esac
4975 1.1 mrg $ECHO "$win32_libid_type"
4976 1.1 mrg }
4977 1.1 mrg
4978 1.1 mrg # func_cygming_dll_for_implib ARG
4979 1.1 mrg #
4980 1.1 mrg # Platform-specific function to extract the
4981 1.1 mrg # name of the DLL associated with the specified
4982 1.1 mrg # import library ARG.
4983 1.1 mrg # Invoked by eval'ing the libtool variable
4984 1.1 mrg # $sharedlib_from_linklib_cmd
4985 1.1 mrg # Result is available in the variable
4986 1.1 mrg # $sharedlib_from_linklib_result
4987 1.1 mrg func_cygming_dll_for_implib ()
4988 1.1 mrg {
4989 1.1 mrg $debug_cmd
4990 1.1 mrg
4991 1.1 mrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992 1.1 mrg }
4993 1.1 mrg
4994 1.1 mrg # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995 1.1 mrg #
4996 1.1 mrg # The is the core of a fallback implementation of a
4997 1.1 mrg # platform-specific function to extract the name of the
4998 1.1 mrg # DLL associated with the specified import library LIBNAME.
4999 1.1 mrg #
5000 1.1 mrg # SECTION_NAME is either .idata$6 or .idata$7, depending
5001 1.1 mrg # on the platform and compiler that created the implib.
5002 1.1 mrg #
5003 1.1 mrg # Echos the name of the DLL associated with the
5004 1.1 mrg # specified import library.
5005 1.1 mrg func_cygming_dll_for_implib_fallback_core ()
5006 1.1 mrg {
5007 1.1 mrg $debug_cmd
5008 1.1 mrg
5009 1.1 mrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010 1.1 mrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011 1.1 mrg $SED '/^Contents of section '"$match_literal"':/{
5012 1.1 mrg # Place marker at beginning of archive member dllname section
5013 1.1 mrg s/.*/====MARK====/
5014 1.1 mrg p
5015 1.1 mrg d
5016 1.1 mrg }
5017 1.1 mrg # These lines can sometimes be longer than 43 characters, but
5018 1.1 mrg # are always uninteresting
5019 1.1 mrg /:[ ]*file format pe[i]\{,1\}-/d
5020 1.1 mrg /^In archive [^:]*:/d
5021 1.1 mrg # Ensure marker is printed
5022 1.1 mrg /^====MARK====/p
5023 1.1 mrg # Remove all lines with less than 43 characters
5024 1.1 mrg /^.\{43\}/!d
5025 1.1 mrg # From remaining lines, remove first 43 characters
5026 1.1 mrg s/^.\{43\}//' |
5027 1.1 mrg $SED -n '
5028 1.1 mrg # Join marker and all lines until next marker into a single line
5029 1.1 mrg /^====MARK====/ b para
5030 1.1 mrg H
5031 1.1 mrg $ b para
5032 1.1 mrg b
5033 1.1 mrg :para
5034 1.1 mrg x
5035 1.1 mrg s/\n//g
5036 1.1 mrg # Remove the marker
5037 1.1 mrg s/^====MARK====//
5038 1.1 mrg # Remove trailing dots and whitespace
5039 1.1 mrg s/[\. \t]*$//
5040 1.1 mrg # Print
5041 1.1 mrg /./p' |
5042 1.1 mrg # we now have a list, one entry per line, of the stringified
5043 1.1 mrg # contents of the appropriate section of all members of the
5044 1.1 mrg # archive that possess that section. Heuristic: eliminate
5045 1.1 mrg # all those that have a first or second character that is
5046 1.1 mrg # a '.' (that is, objdump's representation of an unprintable
5047 1.1 mrg # character.) This should work for all archives with less than
5048 1.1 mrg # 0x302f exports -- but will fail for DLLs whose name actually
5049 1.1 mrg # begins with a literal '.' or a single character followed by
5050 1.1 mrg # a '.'.
5051 1.1 mrg #
5052 1.1 mrg # Of those that remain, print the first one.
5053 1.1 mrg $SED -e '/^\./d;/^.\./d;q'
5054 1.1 mrg }
5055 1.1 mrg
5056 1.1 mrg # func_cygming_dll_for_implib_fallback ARG
5057 1.1 mrg # Platform-specific function to extract the
5058 1.1 mrg # name of the DLL associated with the specified
5059 1.1 mrg # import library ARG.
5060 1.1 mrg #
5061 1.1 mrg # This fallback implementation is for use when $DLLTOOL
5062 1.1 mrg # does not support the --identify-strict option.
5063 1.1 mrg # Invoked by eval'ing the libtool variable
5064 1.1 mrg # $sharedlib_from_linklib_cmd
5065 1.1 mrg # Result is available in the variable
5066 1.1 mrg # $sharedlib_from_linklib_result
5067 1.1 mrg func_cygming_dll_for_implib_fallback ()
5068 1.1 mrg {
5069 1.1 mrg $debug_cmd
5070 1.1 mrg
5071 1.1 mrg if func_cygming_gnu_implib_p "$1"; then
5072 1.1 mrg # binutils import library
5073 1.1 mrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5074 1.1 mrg elif func_cygming_ms_implib_p "$1"; then
5075 1.1 mrg # ms-generated import library
5076 1.1 mrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077 1.1 mrg else
5078 1.1 mrg # unknown
5079 1.1 mrg sharedlib_from_linklib_result=
5080 1.1 mrg fi
5081 1.1 mrg }
5082 1.1 mrg
5083 1.1 mrg
5084 1.1 mrg # func_extract_an_archive dir oldlib
5085 1.1 mrg func_extract_an_archive ()
5086 1.1 mrg {
5087 1.1 mrg $debug_cmd
5088 1.1 mrg
5089 1.1 mrg f_ex_an_ar_dir=$1; shift
5090 1.1 mrg f_ex_an_ar_oldlib=$1
5091 1.1 mrg if test yes = "$lock_old_archive_extraction"; then
5092 1.1 mrg lockfile=$f_ex_an_ar_oldlib.lock
5093 1.1 mrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094 1.1 mrg func_echo "Waiting for $lockfile to be removed"
5095 1.1 mrg sleep 2
5096 1.1 mrg done
5097 1.1 mrg fi
5098 1.1 mrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099 1.1 mrg 'stat=$?; rm -f "$lockfile"; exit $stat'
5100 1.1 mrg if test yes = "$lock_old_archive_extraction"; then
5101 1.1 mrg $opt_dry_run || rm -f "$lockfile"
5102 1.1 mrg fi
5103 1.1 mrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5104 1.1 mrg :
5105 1.1 mrg else
5106 1.1 mrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5107 1.1 mrg fi
5108 1.1 mrg }
5109 1.1 mrg
5110 1.1 mrg
5111 1.1 mrg # func_extract_archives gentop oldlib ...
5112 1.1 mrg func_extract_archives ()
5113 1.1 mrg {
5114 1.1 mrg $debug_cmd
5115 1.1 mrg
5116 1.1 mrg my_gentop=$1; shift
5117 1.1 mrg my_oldlibs=${1+"$@"}
5118 1.1 mrg my_oldobjs=
5119 1.1 mrg my_xlib=
5120 1.1 mrg my_xabs=
5121 1.1 mrg my_xdir=
5122 1.1 mrg
5123 1.1 mrg for my_xlib in $my_oldlibs; do
5124 1.1 mrg # Extract the objects.
5125 1.1 mrg case $my_xlib in
5126 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5127 1.1 mrg *) my_xabs=`pwd`"/$my_xlib" ;;
5128 1.1 mrg esac
5129 1.1 mrg func_basename "$my_xlib"
5130 1.1 mrg my_xlib=$func_basename_result
5131 1.1 mrg my_xlib_u=$my_xlib
5132 1.1 mrg while :; do
5133 1.1 mrg case " $extracted_archives " in
5134 1.1 mrg *" $my_xlib_u "*)
5135 1.1 mrg func_arith $extracted_serial + 1
5136 1.1 mrg extracted_serial=$func_arith_result
5137 1.1 mrg my_xlib_u=lt$extracted_serial-$my_xlib ;;
5138 1.1 mrg *) break ;;
5139 1.1 mrg esac
5140 1.1 mrg done
5141 1.1 mrg extracted_archives="$extracted_archives $my_xlib_u"
5142 1.1 mrg my_xdir=$my_gentop/$my_xlib_u
5143 1.1 mrg
5144 1.1 mrg func_mkdir_p "$my_xdir"
5145 1.1 mrg
5146 1.1 mrg case $host in
5147 1.1 mrg *-darwin*)
5148 1.1 mrg func_verbose "Extracting $my_xabs"
5149 1.1 mrg # Do not bother doing anything if just a dry run
5150 1.1 mrg $opt_dry_run || {
5151 1.1 mrg darwin_orig_dir=`pwd`
5152 1.1 mrg cd $my_xdir || exit $?
5153 1.1 mrg darwin_archive=$my_xabs
5154 1.1 mrg darwin_curdir=`pwd`
5155 1.1 mrg func_basename "$darwin_archive"
5156 1.1 mrg darwin_base_archive=$func_basename_result
5157 1.1 mrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5158 1.1 mrg if test -n "$darwin_arches"; then
5159 1.1 mrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5160 1.1 mrg darwin_arch=
5161 1.1 mrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5162 1.1 mrg for darwin_arch in $darwin_arches; do
5163 1.1 mrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5164 1.1 mrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5165 1.1 mrg cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5166 1.1 mrg func_extract_an_archive "`pwd`" "$darwin_base_archive"
5167 1.1 mrg cd "$darwin_curdir"
5168 1.1 mrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5169 1.1 mrg done # $darwin_arches
5170 1.1 mrg ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5171 1.1 mrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5172 1.1 mrg darwin_file=
5173 1.1 mrg darwin_files=
5174 1.1 mrg for darwin_file in $darwin_filelist; do
5175 1.1 mrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5176 1.1 mrg $LIPO -create -output "$darwin_file" $darwin_files
5177 1.1 mrg done # $darwin_filelist
5178 1.1 mrg $RM -rf unfat-$$
5179 1.1 mrg cd "$darwin_orig_dir"
5180 1.1 mrg else
5181 1.1 mrg cd $darwin_orig_dir
5182 1.1 mrg func_extract_an_archive "$my_xdir" "$my_xabs"
5183 1.1 mrg fi # $darwin_arches
5184 1.1 mrg } # !$opt_dry_run
5185 1.1 mrg ;;
5186 1.1 mrg *)
5187 1.1 mrg func_extract_an_archive "$my_xdir" "$my_xabs"
5188 1.1 mrg ;;
5189 1.1 mrg esac
5190 1.1 mrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5191 1.1 mrg done
5192 1.1 mrg
5193 1.1 mrg func_extract_archives_result=$my_oldobjs
5194 1.1 mrg }
5195 1.1 mrg
5196 1.1 mrg
5197 1.1 mrg # func_emit_wrapper [arg=no]
5198 1.1 mrg #
5199 1.1 mrg # Emit a libtool wrapper script on stdout.
5200 1.1 mrg # Don't directly open a file because we may want to
5201 1.1 mrg # incorporate the script contents within a cygwin/mingw
5202 1.1 mrg # wrapper executable. Must ONLY be called from within
5203 1.1 mrg # func_mode_link because it depends on a number of variables
5204 1.1 mrg # set therein.
5205 1.1 mrg #
5206 1.1 mrg # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207 1.1 mrg # variable will take. If 'yes', then the emitted script
5208 1.1 mrg # will assume that the directory where it is stored is
5209 1.1 mrg # the $objdir directory. This is a cygwin/mingw-specific
5210 1.1 mrg # behavior.
5211 1.1 mrg func_emit_wrapper ()
5212 1.1 mrg {
5213 1.1 mrg func_emit_wrapper_arg1=${1-no}
5214 1.1 mrg
5215 1.1 mrg $ECHO "\
5216 1.1 mrg #! $SHELL
5217 1.1 mrg
5218 1.1 mrg # $output - temporary wrapper script for $objdir/$outputname
5219 1.1 mrg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5220 1.1 mrg #
5221 1.1 mrg # The $output program cannot be directly executed until all the libtool
5222 1.1 mrg # libraries that it depends on are installed.
5223 1.1 mrg #
5224 1.1 mrg # This wrapper script should never be moved out of the build directory.
5225 1.1 mrg # If it is, it will not operate correctly.
5226 1.1 mrg
5227 1.1 mrg # Sed substitution that helps us do robust quoting. It backslashifies
5228 1.1 mrg # metacharacters that are still active within double-quoted strings.
5229 1.1 mrg sed_quote_subst='$sed_quote_subst'
5230 1.1 mrg
5231 1.1 mrg # Be Bourne compatible
5232 1.1 mrg if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5233 1.1 mrg emulate sh
5234 1.1 mrg NULLCMD=:
5235 1.1 mrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5236 1.1 mrg # is contrary to our usage. Disable this feature.
5237 1.1 mrg alias -g '\${1+\"\$@\"}'='\"\$@\"'
5238 1.1 mrg setopt NO_GLOB_SUBST
5239 1.1 mrg else
5240 1.1 mrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5241 1.1 mrg fi
5242 1.1 mrg BIN_SH=xpg4; export BIN_SH # for Tru64
5243 1.1 mrg DUALCASE=1; export DUALCASE # for MKS sh
5244 1.1 mrg
5245 1.1 mrg # The HP-UX ksh and POSIX shell print the target directory to stdout
5246 1.1 mrg # if CDPATH is set.
5247 1.1 mrg (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248 1.1 mrg
5249 1.1 mrg relink_command=\"$relink_command\"
5250 1.1 mrg
5251 1.1 mrg # This environment variable determines our operation mode.
5252 1.1 mrg if test \"\$libtool_install_magic\" = \"$magic\"; then
5253 1.1 mrg # install mode needs the following variables:
5254 1.1 mrg generated_by_libtool_version='$macro_version'
5255 1.1 mrg notinst_deplibs='$notinst_deplibs'
5256 1.1 mrg else
5257 1.1 mrg # When we are sourced in execute mode, \$file and \$ECHO are already set.
5258 1.1 mrg if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259 1.1 mrg file=\"\$0\""
5260 1.1 mrg
5261 1.1 mrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262 1.1 mrg $ECHO "\
5263 1.1 mrg
5264 1.1 mrg # A function that is used when there is no print builtin or printf.
5265 1.1 mrg func_fallback_echo ()
5266 1.1 mrg {
5267 1.1 mrg eval 'cat <<_LTECHO_EOF
5268 1.1 mrg \$1
5269 1.1 mrg _LTECHO_EOF'
5270 1.1 mrg }
5271 1.1 mrg ECHO=\"$qECHO\"
5272 1.1 mrg fi
5273 1.1 mrg
5274 1.1 mrg # Very basic option parsing. These options are (a) specific to
5275 1.1 mrg # the libtool wrapper, (b) are identical between the wrapper
5276 1.1 mrg # /script/ and the wrapper /executable/ that is used only on
5277 1.1 mrg # windows platforms, and (c) all begin with the string "--lt-"
5278 1.1 mrg # (application programs are unlikely to have options that match
5279 1.1 mrg # this pattern).
5280 1.1 mrg #
5281 1.1 mrg # There are only two supported options: --lt-debug and
5282 1.1 mrg # --lt-dump-script. There is, deliberately, no --lt-help.
5283 1.1 mrg #
5284 1.1 mrg # The first argument to this parsing function should be the
5285 1.1 mrg # script's $0 value, followed by "$@".
5286 1.1 mrg lt_option_debug=
5287 1.1 mrg func_parse_lt_options ()
5288 1.1 mrg {
5289 1.1 mrg lt_script_arg0=\$0
5290 1.1 mrg shift
5291 1.1 mrg for lt_opt
5292 1.1 mrg do
5293 1.1 mrg case \"\$lt_opt\" in
5294 1.1 mrg --lt-debug) lt_option_debug=1 ;;
5295 1.1 mrg --lt-dump-script)
5296 1.1 mrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297 1.1 mrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298 1.1 mrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299 1.1 mrg cat \"\$lt_dump_D/\$lt_dump_F\"
5300 1.1 mrg exit 0
5301 1.1 mrg ;;
5302 1.1 mrg --lt-*)
5303 1.1 mrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304 1.1 mrg exit 1
5305 1.1 mrg ;;
5306 1.1 mrg esac
5307 1.1 mrg done
5308 1.1 mrg
5309 1.1 mrg # Print the debug banner immediately:
5310 1.1 mrg if test -n \"\$lt_option_debug\"; then
5311 1.1 mrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312 1.1 mrg fi
5313 1.1 mrg }
5314 1.1 mrg
5315 1.1 mrg # Used when --lt-debug. Prints its arguments to stdout
5316 1.1 mrg # (redirection is the responsibility of the caller)
5317 1.1 mrg func_lt_dump_args ()
5318 1.1 mrg {
5319 1.1 mrg lt_dump_args_N=1;
5320 1.1 mrg for lt_arg
5321 1.1 mrg do
5322 1.1 mrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323 1.1 mrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324 1.1 mrg done
5325 1.1 mrg }
5326 1.1 mrg
5327 1.1 mrg # Core function for launching the target application
5328 1.1 mrg func_exec_program_core ()
5329 1.1 mrg {
5330 1.1 mrg "
5331 1.1 mrg case $host in
5332 1.1 mrg # Backslashes separate directories on plain windows
5333 1.1 mrg *-*-mingw | *-*-os2* | *-cegcc*)
5334 1.1 mrg $ECHO "\
5335 1.1 mrg if test -n \"\$lt_option_debug\"; then
5336 1.1 mrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337 1.1 mrg func_lt_dump_args \${1+\"\$@\"} 1>&2
5338 1.1 mrg fi
5339 1.1 mrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340 1.1 mrg "
5341 1.1 mrg ;;
5342 1.1 mrg
5343 1.1 mrg *)
5344 1.1 mrg $ECHO "\
5345 1.1 mrg if test -n \"\$lt_option_debug\"; then
5346 1.1 mrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347 1.1 mrg func_lt_dump_args \${1+\"\$@\"} 1>&2
5348 1.1 mrg fi
5349 1.1 mrg exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350 1.1 mrg "
5351 1.1 mrg ;;
5352 1.1 mrg esac
5353 1.1 mrg $ECHO "\
5354 1.1 mrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355 1.1 mrg exit 1
5356 1.1 mrg }
5357 1.1 mrg
5358 1.1 mrg # A function to encapsulate launching the target application
5359 1.1 mrg # Strips options in the --lt-* namespace from \$@ and
5360 1.1 mrg # launches target application with the remaining arguments.
5361 1.1 mrg func_exec_program ()
5362 1.1 mrg {
5363 1.1 mrg case \" \$* \" in
5364 1.1 mrg *\\ --lt-*)
5365 1.1 mrg for lt_wr_arg
5366 1.1 mrg do
5367 1.1 mrg case \$lt_wr_arg in
5368 1.1 mrg --lt-*) ;;
5369 1.1 mrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5370 1.1 mrg esac
5371 1.1 mrg shift
5372 1.1 mrg done ;;
5373 1.1 mrg esac
5374 1.1 mrg func_exec_program_core \${1+\"\$@\"}
5375 1.1 mrg }
5376 1.1 mrg
5377 1.1 mrg # Parse options
5378 1.1 mrg func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379 1.1 mrg
5380 1.1 mrg # Find the directory that this script lives in.
5381 1.1 mrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5382 1.1 mrg test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383 1.1 mrg
5384 1.1 mrg # Follow symbolic links until we get to the real thisdir.
5385 1.1 mrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5386 1.1 mrg while test -n \"\$file\"; do
5387 1.1 mrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388 1.1 mrg
5389 1.1 mrg # If there was a directory component, then change thisdir.
5390 1.1 mrg if test \"x\$destdir\" != \"x\$file\"; then
5391 1.1 mrg case \"\$destdir\" in
5392 1.1 mrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5393 1.1 mrg *) thisdir=\"\$thisdir/\$destdir\" ;;
5394 1.1 mrg esac
5395 1.1 mrg fi
5396 1.1 mrg
5397 1.1 mrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398 1.1 mrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5399 1.1 mrg done
5400 1.1 mrg
5401 1.1 mrg # Usually 'no', except on cygwin/mingw when embedded into
5402 1.1 mrg # the cwrapper.
5403 1.1 mrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5404 1.1 mrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5405 1.1 mrg # special case for '.'
5406 1.1 mrg if test \"\$thisdir\" = \".\"; then
5407 1.1 mrg thisdir=\`pwd\`
5408 1.1 mrg fi
5409 1.1 mrg # remove .libs from thisdir
5410 1.1 mrg case \"\$thisdir\" in
5411 1.1 mrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5412 1.1 mrg $objdir ) thisdir=. ;;
5413 1.1 mrg esac
5414 1.1 mrg fi
5415 1.1 mrg
5416 1.1 mrg # Try to get the absolute directory name.
5417 1.1 mrg absdir=\`cd \"\$thisdir\" && pwd\`
5418 1.1 mrg test -n \"\$absdir\" && thisdir=\"\$absdir\"
5419 1.1 mrg "
5420 1.1 mrg
5421 1.1 mrg if test yes = "$fast_install"; then
5422 1.1 mrg $ECHO "\
5423 1.1 mrg program=lt-'$outputname'$exeext
5424 1.1 mrg progdir=\"\$thisdir/$objdir\"
5425 1.1 mrg
5426 1.1 mrg if test ! -f \"\$progdir/\$program\" ||
5427 1.1 mrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5428 1.1 mrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429 1.1 mrg
5430 1.1 mrg file=\"\$\$-\$program\"
5431 1.1 mrg
5432 1.1 mrg if test ! -d \"\$progdir\"; then
5433 1.1 mrg $MKDIR \"\$progdir\"
5434 1.1 mrg else
5435 1.1 mrg $RM \"\$progdir/\$file\"
5436 1.1 mrg fi"
5437 1.1 mrg
5438 1.1 mrg $ECHO "\
5439 1.1 mrg
5440 1.1 mrg # relink executable if necessary
5441 1.1 mrg if test -n \"\$relink_command\"; then
5442 1.1 mrg if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5443 1.1 mrg else
5444 1.1 mrg \$ECHO \"\$relink_command_output\" >&2
5445 1.1 mrg $RM \"\$progdir/\$file\"
5446 1.1 mrg exit 1
5447 1.1 mrg fi
5448 1.1 mrg fi
5449 1.1 mrg
5450 1.1 mrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5451 1.1 mrg { $RM \"\$progdir/\$program\";
5452 1.1 mrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5453 1.1 mrg $RM \"\$progdir/\$file\"
5454 1.1 mrg fi"
5455 1.1 mrg else
5456 1.1 mrg $ECHO "\
5457 1.1 mrg program='$outputname'
5458 1.1 mrg progdir=\"\$thisdir/$objdir\"
5459 1.1 mrg "
5460 1.1 mrg fi
5461 1.1 mrg
5462 1.1 mrg $ECHO "\
5463 1.1 mrg
5464 1.1 mrg if test -f \"\$progdir/\$program\"; then"
5465 1.1 mrg
5466 1.1 mrg # fixup the dll searchpath if we need to.
5467 1.1 mrg #
5468 1.1 mrg # Fix the DLL searchpath if we need to. Do this before prepending
5469 1.1 mrg # to shlibpath, because on Windows, both are PATH and uninstalled
5470 1.1 mrg # libraries must come first.
5471 1.1 mrg if test -n "$dllsearchpath"; then
5472 1.1 mrg $ECHO "\
5473 1.1 mrg # Add the dll search path components to the executable PATH
5474 1.1 mrg PATH=$dllsearchpath:\$PATH
5475 1.1 mrg "
5476 1.1 mrg fi
5477 1.1 mrg
5478 1.1 mrg # Export our shlibpath_var if we have one.
5479 1.1 mrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5480 1.1 mrg $ECHO "\
5481 1.1 mrg # Add our own library path to $shlibpath_var
5482 1.1 mrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483 1.1 mrg
5484 1.1 mrg # Some systems cannot cope with colon-terminated $shlibpath_var
5485 1.1 mrg # The second colon is a workaround for a bug in BeOS R4 sed
5486 1.1 mrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487 1.1 mrg
5488 1.1 mrg export $shlibpath_var
5489 1.1 mrg "
5490 1.1 mrg fi
5491 1.1 mrg
5492 1.1 mrg $ECHO "\
5493 1.1 mrg if test \"\$libtool_execute_magic\" != \"$magic\"; then
5494 1.1 mrg # Run the actual program with our arguments.
5495 1.1 mrg func_exec_program \${1+\"\$@\"}
5496 1.1 mrg fi
5497 1.1 mrg else
5498 1.1 mrg # The program doesn't exist.
5499 1.1 mrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5500 1.1 mrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501 1.1 mrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5502 1.1 mrg exit 1
5503 1.1 mrg fi
5504 1.1 mrg fi\
5505 1.1 mrg "
5506 1.1 mrg }
5507 1.1 mrg
5508 1.1 mrg
5509 1.1 mrg # func_emit_cwrapperexe_src
5510 1.1 mrg # emit the source code for a wrapper executable on stdout
5511 1.1 mrg # Must ONLY be called from within func_mode_link because
5512 1.1 mrg # it depends on a number of variable set therein.
5513 1.1 mrg func_emit_cwrapperexe_src ()
5514 1.1 mrg {
5515 1.1 mrg cat <<EOF
5516 1.1 mrg
5517 1.1 mrg /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5518 1.1 mrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519 1.1 mrg
5520 1.1 mrg The $output program cannot be directly executed until all the libtool
5521 1.1 mrg libraries that it depends on are installed.
5522 1.1 mrg
5523 1.1 mrg This wrapper executable should never be moved out of the build directory.
5524 1.1 mrg If it is, it will not operate correctly.
5525 1.1 mrg */
5526 1.1 mrg EOF
5527 1.1 mrg cat <<"EOF"
5528 1.1 mrg #ifdef _MSC_VER
5529 1.1 mrg # define _CRT_SECURE_NO_DEPRECATE 1
5530 1.1 mrg #endif
5531 1.1 mrg #include <stdio.h>
5532 1.1 mrg #include <stdlib.h>
5533 1.1 mrg #ifdef _MSC_VER
5534 1.1 mrg # include <direct.h>
5535 1.1 mrg # include <process.h>
5536 1.1 mrg # include <io.h>
5537 1.1 mrg #else
5538 1.1 mrg # include <unistd.h>
5539 1.1 mrg # include <stdint.h>
5540 1.1 mrg # ifdef __CYGWIN__
5541 1.1 mrg # include <io.h>
5542 1.1 mrg # endif
5543 1.1 mrg #endif
5544 1.1 mrg #include <malloc.h>
5545 1.1 mrg #include <stdarg.h>
5546 1.1 mrg #include <assert.h>
5547 1.1 mrg #include <string.h>
5548 1.1 mrg #include <ctype.h>
5549 1.1 mrg #include <errno.h>
5550 1.1 mrg #include <fcntl.h>
5551 1.1 mrg #include <sys/stat.h>
5552 1.1 mrg
5553 1.1 mrg #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5554 1.1 mrg
5555 1.1 mrg /* declarations of non-ANSI functions */
5556 1.1 mrg #if defined __MINGW32__
5557 1.1 mrg # ifdef __STRICT_ANSI__
5558 1.1 mrg int _putenv (const char *);
5559 1.1 mrg # endif
5560 1.1 mrg #elif defined __CYGWIN__
5561 1.1 mrg # ifdef __STRICT_ANSI__
5562 1.1 mrg char *realpath (const char *, char *);
5563 1.1 mrg int putenv (char *);
5564 1.1 mrg int setenv (const char *, const char *, int);
5565 1.1 mrg # endif
5566 1.1 mrg /* #elif defined other_platform || defined ... */
5567 1.1 mrg #endif
5568 1.1 mrg
5569 1.1 mrg /* portability defines, excluding path handling macros */
5570 1.1 mrg #if defined _MSC_VER
5571 1.1 mrg # define setmode _setmode
5572 1.1 mrg # define stat _stat
5573 1.1 mrg # define chmod _chmod
5574 1.1 mrg # define getcwd _getcwd
5575 1.1 mrg # define putenv _putenv
5576 1.1 mrg # define S_IXUSR _S_IEXEC
5577 1.1 mrg #elif defined __MINGW32__
5578 1.1 mrg # define setmode _setmode
5579 1.1 mrg # define stat _stat
5580 1.1 mrg # define chmod _chmod
5581 1.1 mrg # define getcwd _getcwd
5582 1.1 mrg # define putenv _putenv
5583 1.1 mrg #elif defined __CYGWIN__
5584 1.1 mrg # define HAVE_SETENV
5585 1.1 mrg # define FOPEN_WB "wb"
5586 1.1 mrg /* #elif defined other platforms ... */
5587 1.1 mrg #endif
5588 1.1 mrg
5589 1.1 mrg #if defined PATH_MAX
5590 1.1 mrg # define LT_PATHMAX PATH_MAX
5591 1.1 mrg #elif defined MAXPATHLEN
5592 1.1 mrg # define LT_PATHMAX MAXPATHLEN
5593 1.1 mrg #else
5594 1.1 mrg # define LT_PATHMAX 1024
5595 1.1 mrg #endif
5596 1.1 mrg
5597 1.1 mrg #ifndef S_IXOTH
5598 1.1 mrg # define S_IXOTH 0
5599 1.1 mrg #endif
5600 1.1 mrg #ifndef S_IXGRP
5601 1.1 mrg # define S_IXGRP 0
5602 1.1 mrg #endif
5603 1.1 mrg
5604 1.1 mrg /* path handling portability macros */
5605 1.1 mrg #ifndef DIR_SEPARATOR
5606 1.1 mrg # define DIR_SEPARATOR '/'
5607 1.1 mrg # define PATH_SEPARATOR ':'
5608 1.1 mrg #endif
5609 1.1 mrg
5610 1.1 mrg #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5611 1.1 mrg defined __OS2__
5612 1.1 mrg # define HAVE_DOS_BASED_FILE_SYSTEM
5613 1.1 mrg # define FOPEN_WB "wb"
5614 1.1 mrg # ifndef DIR_SEPARATOR_2
5615 1.1 mrg # define DIR_SEPARATOR_2 '\\'
5616 1.1 mrg # endif
5617 1.1 mrg # ifndef PATH_SEPARATOR_2
5618 1.1 mrg # define PATH_SEPARATOR_2 ';'
5619 1.1 mrg # endif
5620 1.1 mrg #endif
5621 1.1 mrg
5622 1.1 mrg #ifndef DIR_SEPARATOR_2
5623 1.1 mrg # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5624 1.1 mrg #else /* DIR_SEPARATOR_2 */
5625 1.1 mrg # define IS_DIR_SEPARATOR(ch) \
5626 1.1 mrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5627 1.1 mrg #endif /* DIR_SEPARATOR_2 */
5628 1.1 mrg
5629 1.1 mrg #ifndef PATH_SEPARATOR_2
5630 1.1 mrg # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5631 1.1 mrg #else /* PATH_SEPARATOR_2 */
5632 1.1 mrg # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5633 1.1 mrg #endif /* PATH_SEPARATOR_2 */
5634 1.1 mrg
5635 1.1 mrg #ifndef FOPEN_WB
5636 1.1 mrg # define FOPEN_WB "w"
5637 1.1 mrg #endif
5638 1.1 mrg #ifndef _O_BINARY
5639 1.1 mrg # define _O_BINARY 0
5640 1.1 mrg #endif
5641 1.1 mrg
5642 1.1 mrg #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
5643 1.1 mrg #define XFREE(stale) do { \
5644 1.1 mrg if (stale) { free (stale); stale = 0; } \
5645 1.1 mrg } while (0)
5646 1.1 mrg
5647 1.1 mrg #if defined LT_DEBUGWRAPPER
5648 1.1 mrg static int lt_debug = 1;
5649 1.1 mrg #else
5650 1.1 mrg static int lt_debug = 0;
5651 1.1 mrg #endif
5652 1.1 mrg
5653 1.1 mrg const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654 1.1 mrg
5655 1.1 mrg void *xmalloc (size_t num);
5656 1.1 mrg char *xstrdup (const char *string);
5657 1.1 mrg const char *base_name (const char *name);
5658 1.1 mrg char *find_executable (const char *wrapper);
5659 1.1 mrg char *chase_symlinks (const char *pathspec);
5660 1.1 mrg int make_executable (const char *path);
5661 1.1 mrg int check_executable (const char *path);
5662 1.1 mrg char *strendzap (char *str, const char *pat);
5663 1.1 mrg void lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664 1.1 mrg void lt_fatal (const char *file, int line, const char *message, ...);
5665 1.1 mrg static const char *nonnull (const char *s);
5666 1.1 mrg static const char *nonempty (const char *s);
5667 1.1 mrg void lt_setenv (const char *name, const char *value);
5668 1.1 mrg char *lt_extend_str (const char *orig_value, const char *add, int to_end);
5669 1.1 mrg void lt_update_exe_path (const char *name, const char *value);
5670 1.1 mrg void lt_update_lib_path (const char *name, const char *value);
5671 1.1 mrg char **prepare_spawn (char **argv);
5672 1.1 mrg void lt_dump_script (FILE *f);
5673 1.1 mrg EOF
5674 1.1 mrg
5675 1.1 mrg cat <<EOF
5676 1.1 mrg #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5677 1.1 mrg # define externally_visible volatile
5678 1.1 mrg #else
5679 1.1 mrg # define externally_visible __attribute__((externally_visible)) volatile
5680 1.1 mrg #endif
5681 1.1 mrg externally_visible const char * MAGIC_EXE = "$magic_exe";
5682 1.1 mrg const char * LIB_PATH_VARNAME = "$shlibpath_var";
5683 1.1 mrg EOF
5684 1.1 mrg
5685 1.1 mrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686 1.1 mrg func_to_host_path "$temp_rpath"
5687 1.1 mrg cat <<EOF
5688 1.1 mrg const char * LIB_PATH_VALUE = "$func_to_host_path_result";
5689 1.1 mrg EOF
5690 1.1 mrg else
5691 1.1 mrg cat <<"EOF"
5692 1.1 mrg const char * LIB_PATH_VALUE = "";
5693 1.1 mrg EOF
5694 1.1 mrg fi
5695 1.1 mrg
5696 1.1 mrg if test -n "$dllsearchpath"; then
5697 1.1 mrg func_to_host_path "$dllsearchpath:"
5698 1.1 mrg cat <<EOF
5699 1.1 mrg const char * EXE_PATH_VARNAME = "PATH";
5700 1.1 mrg const char * EXE_PATH_VALUE = "$func_to_host_path_result";
5701 1.1 mrg EOF
5702 1.1 mrg else
5703 1.1 mrg cat <<"EOF"
5704 1.1 mrg const char * EXE_PATH_VARNAME = "";
5705 1.1 mrg const char * EXE_PATH_VALUE = "";
5706 1.1 mrg EOF
5707 1.1 mrg fi
5708 1.1 mrg
5709 1.1 mrg if test yes = "$fast_install"; then
5710 1.1 mrg cat <<EOF
5711 1.1 mrg const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5712 1.1 mrg EOF
5713 1.1 mrg else
5714 1.1 mrg cat <<EOF
5715 1.1 mrg const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5716 1.1 mrg EOF
5717 1.1 mrg fi
5718 1.1 mrg
5719 1.1 mrg
5720 1.1 mrg cat <<"EOF"
5721 1.1 mrg
5722 1.1 mrg #define LTWRAPPER_OPTION_PREFIX "--lt-"
5723 1.1 mrg
5724 1.1 mrg static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5725 1.1 mrg static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
5726 1.1 mrg static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
5727 1.1 mrg
5728 1.1 mrg int
5729 1.1 mrg main (int argc, char *argv[])
5730 1.1 mrg {
5731 1.1 mrg char **newargz;
5732 1.1 mrg int newargc;
5733 1.1 mrg char *tmp_pathspec;
5734 1.1 mrg char *actual_cwrapper_path;
5735 1.1 mrg char *actual_cwrapper_name;
5736 1.1 mrg char *target_name;
5737 1.1 mrg char *lt_argv_zero;
5738 1.1 mrg int rval = 127;
5739 1.1 mrg
5740 1.1 mrg int i;
5741 1.1 mrg
5742 1.1 mrg program_name = (char *) xstrdup (base_name (argv[0]));
5743 1.1 mrg newargz = XMALLOC (char *, (size_t) argc + 1);
5744 1.1 mrg
5745 1.1 mrg /* very simple arg parsing; don't want to rely on getopt
5746 1.1 mrg * also, copy all non cwrapper options to newargz, except
5747 1.1 mrg * argz[0], which is handled differently
5748 1.1 mrg */
5749 1.1 mrg newargc=0;
5750 1.1 mrg for (i = 1; i < argc; i++)
5751 1.1 mrg {
5752 1.1 mrg if (STREQ (argv[i], dumpscript_opt))
5753 1.1 mrg {
5754 1.1 mrg EOF
5755 1.1 mrg case $host in
5756 1.1 mrg *mingw* | *cygwin* )
5757 1.1 mrg # make stdout use "unix" line endings
5758 1.1 mrg echo " setmode(1,_O_BINARY);"
5759 1.1 mrg ;;
5760 1.1 mrg esac
5761 1.1 mrg
5762 1.1 mrg cat <<"EOF"
5763 1.1 mrg lt_dump_script (stdout);
5764 1.1 mrg return 0;
5765 1.1 mrg }
5766 1.1 mrg if (STREQ (argv[i], debug_opt))
5767 1.1 mrg {
5768 1.1 mrg lt_debug = 1;
5769 1.1 mrg continue;
5770 1.1 mrg }
5771 1.1 mrg if (STREQ (argv[i], ltwrapper_option_prefix))
5772 1.1 mrg {
5773 1.1 mrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774 1.1 mrg namespace, but it is not one of the ones we know about and
5775 1.1 mrg have already dealt with, above (inluding dump-script), then
5776 1.1 mrg report an error. Otherwise, targets might begin to believe
5777 1.1 mrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778 1.1 mrg namespace. The first time any user complains about this, we'll
5779 1.1 mrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780 1.1 mrg or a configure.ac-settable value.
5781 1.1 mrg */
5782 1.1 mrg lt_fatal (__FILE__, __LINE__,
5783 1.1 mrg "unrecognized %s option: '%s'",
5784 1.1 mrg ltwrapper_option_prefix, argv[i]);
5785 1.1 mrg }
5786 1.1 mrg /* otherwise ... */
5787 1.1 mrg newargz[++newargc] = xstrdup (argv[i]);
5788 1.1 mrg }
5789 1.1 mrg newargz[++newargc] = NULL;
5790 1.1 mrg
5791 1.1 mrg EOF
5792 1.1 mrg cat <<EOF
5793 1.1 mrg /* The GNU banner must be the first non-error debug message */
5794 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795 1.1 mrg EOF
5796 1.1 mrg cat <<"EOF"
5797 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799 1.1 mrg
5800 1.1 mrg tmp_pathspec = find_executable (argv[0]);
5801 1.1 mrg if (tmp_pathspec == NULL)
5802 1.1 mrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803 1.1 mrg lt_debugprintf (__FILE__, __LINE__,
5804 1.1 mrg "(main) found exe (before symlink chase) at: %s\n",
5805 1.1 mrg tmp_pathspec);
5806 1.1 mrg
5807 1.1 mrg actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808 1.1 mrg lt_debugprintf (__FILE__, __LINE__,
5809 1.1 mrg "(main) found exe (after symlink chase) at: %s\n",
5810 1.1 mrg actual_cwrapper_path);
5811 1.1 mrg XFREE (tmp_pathspec);
5812 1.1 mrg
5813 1.1 mrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5814 1.1 mrg strendzap (actual_cwrapper_path, actual_cwrapper_name);
5815 1.1 mrg
5816 1.1 mrg /* wrapper name transforms */
5817 1.1 mrg strendzap (actual_cwrapper_name, ".exe");
5818 1.1 mrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5819 1.1 mrg XFREE (actual_cwrapper_name);
5820 1.1 mrg actual_cwrapper_name = tmp_pathspec;
5821 1.1 mrg tmp_pathspec = 0;
5822 1.1 mrg
5823 1.1 mrg /* target_name transforms -- use actual target program name; might have lt- prefix */
5824 1.1 mrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5825 1.1 mrg strendzap (target_name, ".exe");
5826 1.1 mrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5827 1.1 mrg XFREE (target_name);
5828 1.1 mrg target_name = tmp_pathspec;
5829 1.1 mrg tmp_pathspec = 0;
5830 1.1 mrg
5831 1.1 mrg lt_debugprintf (__FILE__, __LINE__,
5832 1.1 mrg "(main) libtool target name: %s\n",
5833 1.1 mrg target_name);
5834 1.1 mrg EOF
5835 1.1 mrg
5836 1.1 mrg cat <<EOF
5837 1.1 mrg newargz[0] =
5838 1.1 mrg XMALLOC (char, (strlen (actual_cwrapper_path) +
5839 1.1 mrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5840 1.1 mrg strcpy (newargz[0], actual_cwrapper_path);
5841 1.1 mrg strcat (newargz[0], "$objdir");
5842 1.1 mrg strcat (newargz[0], "/");
5843 1.1 mrg EOF
5844 1.1 mrg
5845 1.1 mrg cat <<"EOF"
5846 1.1 mrg /* stop here, and copy so we don't have to do this twice */
5847 1.1 mrg tmp_pathspec = xstrdup (newargz[0]);
5848 1.1 mrg
5849 1.1 mrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5850 1.1 mrg strcat (newargz[0], actual_cwrapper_name);
5851 1.1 mrg
5852 1.1 mrg /* DO want the lt- prefix here if it exists, so use target_name */
5853 1.1 mrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5854 1.1 mrg XFREE (tmp_pathspec);
5855 1.1 mrg tmp_pathspec = NULL;
5856 1.1 mrg EOF
5857 1.1 mrg
5858 1.1 mrg case $host_os in
5859 1.1 mrg mingw*)
5860 1.1 mrg cat <<"EOF"
5861 1.1 mrg {
5862 1.1 mrg char* p;
5863 1.1 mrg while ((p = strchr (newargz[0], '\\')) != NULL)
5864 1.1 mrg {
5865 1.1 mrg *p = '/';
5866 1.1 mrg }
5867 1.1 mrg while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5868 1.1 mrg {
5869 1.1 mrg *p = '/';
5870 1.1 mrg }
5871 1.1 mrg }
5872 1.1 mrg EOF
5873 1.1 mrg ;;
5874 1.1 mrg esac
5875 1.1 mrg
5876 1.1 mrg cat <<"EOF"
5877 1.1 mrg XFREE (target_name);
5878 1.1 mrg XFREE (actual_cwrapper_path);
5879 1.1 mrg XFREE (actual_cwrapper_name);
5880 1.1 mrg
5881 1.1 mrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5882 1.1 mrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */
5883 1.1 mrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
5884 1.1 mrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885 1.1 mrg because on Windows, both *_VARNAMEs are PATH but uninstalled
5886 1.1 mrg libraries must come first. */
5887 1.1 mrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888 1.1 mrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889 1.1 mrg
5890 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891 1.1 mrg nonnull (lt_argv_zero));
5892 1.1 mrg for (i = 0; i < newargc; i++)
5893 1.1 mrg {
5894 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895 1.1 mrg i, nonnull (newargz[i]));
5896 1.1 mrg }
5897 1.1 mrg
5898 1.1 mrg EOF
5899 1.1 mrg
5900 1.1 mrg case $host_os in
5901 1.1 mrg mingw*)
5902 1.1 mrg cat <<"EOF"
5903 1.1 mrg /* execv doesn't actually work on mingw as expected on unix */
5904 1.1 mrg newargz = prepare_spawn (newargz);
5905 1.1 mrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5906 1.1 mrg if (rval == -1)
5907 1.1 mrg {
5908 1.1 mrg /* failed to start process */
5909 1.1 mrg lt_debugprintf (__FILE__, __LINE__,
5910 1.1 mrg "(main) failed to launch target \"%s\": %s\n",
5911 1.1 mrg lt_argv_zero, nonnull (strerror (errno)));
5912 1.1 mrg return 127;
5913 1.1 mrg }
5914 1.1 mrg return rval;
5915 1.1 mrg EOF
5916 1.1 mrg ;;
5917 1.1 mrg *)
5918 1.1 mrg cat <<"EOF"
5919 1.1 mrg execv (lt_argv_zero, newargz);
5920 1.1 mrg return rval; /* =127, but avoids unused variable warning */
5921 1.1 mrg EOF
5922 1.1 mrg ;;
5923 1.1 mrg esac
5924 1.1 mrg
5925 1.1 mrg cat <<"EOF"
5926 1.1 mrg }
5927 1.1 mrg
5928 1.1 mrg void *
5929 1.1 mrg xmalloc (size_t num)
5930 1.1 mrg {
5931 1.1 mrg void *p = (void *) malloc (num);
5932 1.1 mrg if (!p)
5933 1.1 mrg lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934 1.1 mrg
5935 1.1 mrg return p;
5936 1.1 mrg }
5937 1.1 mrg
5938 1.1 mrg char *
5939 1.1 mrg xstrdup (const char *string)
5940 1.1 mrg {
5941 1.1 mrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5942 1.1 mrg string) : NULL;
5943 1.1 mrg }
5944 1.1 mrg
5945 1.1 mrg const char *
5946 1.1 mrg base_name (const char *name)
5947 1.1 mrg {
5948 1.1 mrg const char *base;
5949 1.1 mrg
5950 1.1 mrg #if defined HAVE_DOS_BASED_FILE_SYSTEM
5951 1.1 mrg /* Skip over the disk name in MSDOS pathnames. */
5952 1.1 mrg if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5953 1.1 mrg name += 2;
5954 1.1 mrg #endif
5955 1.1 mrg
5956 1.1 mrg for (base = name; *name; name++)
5957 1.1 mrg if (IS_DIR_SEPARATOR (*name))
5958 1.1 mrg base = name + 1;
5959 1.1 mrg return base;
5960 1.1 mrg }
5961 1.1 mrg
5962 1.1 mrg int
5963 1.1 mrg check_executable (const char *path)
5964 1.1 mrg {
5965 1.1 mrg struct stat st;
5966 1.1 mrg
5967 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968 1.1 mrg nonempty (path));
5969 1.1 mrg if ((!path) || (!*path))
5970 1.1 mrg return 0;
5971 1.1 mrg
5972 1.1 mrg if ((stat (path, &st) >= 0)
5973 1.1 mrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5974 1.1 mrg return 1;
5975 1.1 mrg else
5976 1.1 mrg return 0;
5977 1.1 mrg }
5978 1.1 mrg
5979 1.1 mrg int
5980 1.1 mrg make_executable (const char *path)
5981 1.1 mrg {
5982 1.1 mrg int rval = 0;
5983 1.1 mrg struct stat st;
5984 1.1 mrg
5985 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986 1.1 mrg nonempty (path));
5987 1.1 mrg if ((!path) || (!*path))
5988 1.1 mrg return 0;
5989 1.1 mrg
5990 1.1 mrg if (stat (path, &st) >= 0)
5991 1.1 mrg {
5992 1.1 mrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5993 1.1 mrg }
5994 1.1 mrg return rval;
5995 1.1 mrg }
5996 1.1 mrg
5997 1.1 mrg /* Searches for the full path of the wrapper. Returns
5998 1.1 mrg newly allocated full path name if found, NULL otherwise
5999 1.1 mrg Does not chase symlinks, even on platforms that support them.
6000 1.1 mrg */
6001 1.1 mrg char *
6002 1.1 mrg find_executable (const char *wrapper)
6003 1.1 mrg {
6004 1.1 mrg int has_slash = 0;
6005 1.1 mrg const char *p;
6006 1.1 mrg const char *p_next;
6007 1.1 mrg /* static buffer for getcwd */
6008 1.1 mrg char tmp[LT_PATHMAX + 1];
6009 1.1 mrg size_t tmp_len;
6010 1.1 mrg char *concat_name;
6011 1.1 mrg
6012 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013 1.1 mrg nonempty (wrapper));
6014 1.1 mrg
6015 1.1 mrg if ((wrapper == NULL) || (*wrapper == '\0'))
6016 1.1 mrg return NULL;
6017 1.1 mrg
6018 1.1 mrg /* Absolute path? */
6019 1.1 mrg #if defined HAVE_DOS_BASED_FILE_SYSTEM
6020 1.1 mrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6021 1.1 mrg {
6022 1.1 mrg concat_name = xstrdup (wrapper);
6023 1.1 mrg if (check_executable (concat_name))
6024 1.1 mrg return concat_name;
6025 1.1 mrg XFREE (concat_name);
6026 1.1 mrg }
6027 1.1 mrg else
6028 1.1 mrg {
6029 1.1 mrg #endif
6030 1.1 mrg if (IS_DIR_SEPARATOR (wrapper[0]))
6031 1.1 mrg {
6032 1.1 mrg concat_name = xstrdup (wrapper);
6033 1.1 mrg if (check_executable (concat_name))
6034 1.1 mrg return concat_name;
6035 1.1 mrg XFREE (concat_name);
6036 1.1 mrg }
6037 1.1 mrg #if defined HAVE_DOS_BASED_FILE_SYSTEM
6038 1.1 mrg }
6039 1.1 mrg #endif
6040 1.1 mrg
6041 1.1 mrg for (p = wrapper; *p; p++)
6042 1.1 mrg if (*p == '/')
6043 1.1 mrg {
6044 1.1 mrg has_slash = 1;
6045 1.1 mrg break;
6046 1.1 mrg }
6047 1.1 mrg if (!has_slash)
6048 1.1 mrg {
6049 1.1 mrg /* no slashes; search PATH */
6050 1.1 mrg const char *path = getenv ("PATH");
6051 1.1 mrg if (path != NULL)
6052 1.1 mrg {
6053 1.1 mrg for (p = path; *p; p = p_next)
6054 1.1 mrg {
6055 1.1 mrg const char *q;
6056 1.1 mrg size_t p_len;
6057 1.1 mrg for (q = p; *q; q++)
6058 1.1 mrg if (IS_PATH_SEPARATOR (*q))
6059 1.1 mrg break;
6060 1.1 mrg p_len = (size_t) (q - p);
6061 1.1 mrg p_next = (*q == '\0' ? q : q + 1);
6062 1.1 mrg if (p_len == 0)
6063 1.1 mrg {
6064 1.1 mrg /* empty path: current directory */
6065 1.1 mrg if (getcwd (tmp, LT_PATHMAX) == NULL)
6066 1.1 mrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067 1.1 mrg nonnull (strerror (errno)));
6068 1.1 mrg tmp_len = strlen (tmp);
6069 1.1 mrg concat_name =
6070 1.1 mrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6071 1.1 mrg memcpy (concat_name, tmp, tmp_len);
6072 1.1 mrg concat_name[tmp_len] = '/';
6073 1.1 mrg strcpy (concat_name + tmp_len + 1, wrapper);
6074 1.1 mrg }
6075 1.1 mrg else
6076 1.1 mrg {
6077 1.1 mrg concat_name =
6078 1.1 mrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6079 1.1 mrg memcpy (concat_name, p, p_len);
6080 1.1 mrg concat_name[p_len] = '/';
6081 1.1 mrg strcpy (concat_name + p_len + 1, wrapper);
6082 1.1 mrg }
6083 1.1 mrg if (check_executable (concat_name))
6084 1.1 mrg return concat_name;
6085 1.1 mrg XFREE (concat_name);
6086 1.1 mrg }
6087 1.1 mrg }
6088 1.1 mrg /* not found in PATH; assume curdir */
6089 1.1 mrg }
6090 1.1 mrg /* Relative path | not found in path: prepend cwd */
6091 1.1 mrg if (getcwd (tmp, LT_PATHMAX) == NULL)
6092 1.1 mrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093 1.1 mrg nonnull (strerror (errno)));
6094 1.1 mrg tmp_len = strlen (tmp);
6095 1.1 mrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6096 1.1 mrg memcpy (concat_name, tmp, tmp_len);
6097 1.1 mrg concat_name[tmp_len] = '/';
6098 1.1 mrg strcpy (concat_name + tmp_len + 1, wrapper);
6099 1.1 mrg
6100 1.1 mrg if (check_executable (concat_name))
6101 1.1 mrg return concat_name;
6102 1.1 mrg XFREE (concat_name);
6103 1.1 mrg return NULL;
6104 1.1 mrg }
6105 1.1 mrg
6106 1.1 mrg char *
6107 1.1 mrg chase_symlinks (const char *pathspec)
6108 1.1 mrg {
6109 1.1 mrg #ifndef S_ISLNK
6110 1.1 mrg return xstrdup (pathspec);
6111 1.1 mrg #else
6112 1.1 mrg char buf[LT_PATHMAX];
6113 1.1 mrg struct stat s;
6114 1.1 mrg char *tmp_pathspec = xstrdup (pathspec);
6115 1.1 mrg char *p;
6116 1.1 mrg int has_symlinks = 0;
6117 1.1 mrg while (strlen (tmp_pathspec) && !has_symlinks)
6118 1.1 mrg {
6119 1.1 mrg lt_debugprintf (__FILE__, __LINE__,
6120 1.1 mrg "checking path component for symlinks: %s\n",
6121 1.1 mrg tmp_pathspec);
6122 1.1 mrg if (lstat (tmp_pathspec, &s) == 0)
6123 1.1 mrg {
6124 1.1 mrg if (S_ISLNK (s.st_mode) != 0)
6125 1.1 mrg {
6126 1.1 mrg has_symlinks = 1;
6127 1.1 mrg break;
6128 1.1 mrg }
6129 1.1 mrg
6130 1.1 mrg /* search backwards for last DIR_SEPARATOR */
6131 1.1 mrg p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6132 1.1 mrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6133 1.1 mrg p--;
6134 1.1 mrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6135 1.1 mrg {
6136 1.1 mrg /* no more DIR_SEPARATORS left */
6137 1.1 mrg break;
6138 1.1 mrg }
6139 1.1 mrg *p = '\0';
6140 1.1 mrg }
6141 1.1 mrg else
6142 1.1 mrg {
6143 1.1 mrg lt_fatal (__FILE__, __LINE__,
6144 1.1 mrg "error accessing file \"%s\": %s",
6145 1.1 mrg tmp_pathspec, nonnull (strerror (errno)));
6146 1.1 mrg }
6147 1.1 mrg }
6148 1.1 mrg XFREE (tmp_pathspec);
6149 1.1 mrg
6150 1.1 mrg if (!has_symlinks)
6151 1.1 mrg {
6152 1.1 mrg return xstrdup (pathspec);
6153 1.1 mrg }
6154 1.1 mrg
6155 1.1 mrg tmp_pathspec = realpath (pathspec, buf);
6156 1.1 mrg if (tmp_pathspec == 0)
6157 1.1 mrg {
6158 1.1 mrg lt_fatal (__FILE__, __LINE__,
6159 1.1 mrg "could not follow symlinks for %s", pathspec);
6160 1.1 mrg }
6161 1.1 mrg return xstrdup (tmp_pathspec);
6162 1.1 mrg #endif
6163 1.1 mrg }
6164 1.1 mrg
6165 1.1 mrg char *
6166 1.1 mrg strendzap (char *str, const char *pat)
6167 1.1 mrg {
6168 1.1 mrg size_t len, patlen;
6169 1.1 mrg
6170 1.1 mrg assert (str != NULL);
6171 1.1 mrg assert (pat != NULL);
6172 1.1 mrg
6173 1.1 mrg len = strlen (str);
6174 1.1 mrg patlen = strlen (pat);
6175 1.1 mrg
6176 1.1 mrg if (patlen <= len)
6177 1.1 mrg {
6178 1.1 mrg str += len - patlen;
6179 1.1 mrg if (STREQ (str, pat))
6180 1.1 mrg *str = '\0';
6181 1.1 mrg }
6182 1.1 mrg return str;
6183 1.1 mrg }
6184 1.1 mrg
6185 1.1 mrg void
6186 1.1 mrg lt_debugprintf (const char *file, int line, const char *fmt, ...)
6187 1.1 mrg {
6188 1.1 mrg va_list args;
6189 1.1 mrg if (lt_debug)
6190 1.1 mrg {
6191 1.1 mrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192 1.1 mrg va_start (args, fmt);
6193 1.1 mrg (void) vfprintf (stderr, fmt, args);
6194 1.1 mrg va_end (args);
6195 1.1 mrg }
6196 1.1 mrg }
6197 1.1 mrg
6198 1.1 mrg static void
6199 1.1 mrg lt_error_core (int exit_status, const char *file,
6200 1.1 mrg int line, const char *mode,
6201 1.1 mrg const char *message, va_list ap)
6202 1.1 mrg {
6203 1.1 mrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6204 1.1 mrg vfprintf (stderr, message, ap);
6205 1.1 mrg fprintf (stderr, ".\n");
6206 1.1 mrg
6207 1.1 mrg if (exit_status >= 0)
6208 1.1 mrg exit (exit_status);
6209 1.1 mrg }
6210 1.1 mrg
6211 1.1 mrg void
6212 1.1 mrg lt_fatal (const char *file, int line, const char *message, ...)
6213 1.1 mrg {
6214 1.1 mrg va_list ap;
6215 1.1 mrg va_start (ap, message);
6216 1.1 mrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6217 1.1 mrg va_end (ap);
6218 1.1 mrg }
6219 1.1 mrg
6220 1.1 mrg static const char *
6221 1.1 mrg nonnull (const char *s)
6222 1.1 mrg {
6223 1.1 mrg return s ? s : "(null)";
6224 1.1 mrg }
6225 1.1 mrg
6226 1.1 mrg static const char *
6227 1.1 mrg nonempty (const char *s)
6228 1.1 mrg {
6229 1.1 mrg return (s && !*s) ? "(empty)" : nonnull (s);
6230 1.1 mrg }
6231 1.1 mrg
6232 1.1 mrg void
6233 1.1 mrg lt_setenv (const char *name, const char *value)
6234 1.1 mrg {
6235 1.1 mrg lt_debugprintf (__FILE__, __LINE__,
6236 1.1 mrg "(lt_setenv) setting '%s' to '%s'\n",
6237 1.1 mrg nonnull (name), nonnull (value));
6238 1.1 mrg {
6239 1.1 mrg #ifdef HAVE_SETENV
6240 1.1 mrg /* always make a copy, for consistency with !HAVE_SETENV */
6241 1.1 mrg char *str = xstrdup (value);
6242 1.1 mrg setenv (name, str, 1);
6243 1.1 mrg #else
6244 1.1 mrg size_t len = strlen (name) + 1 + strlen (value) + 1;
6245 1.1 mrg char *str = XMALLOC (char, len);
6246 1.1 mrg sprintf (str, "%s=%s", name, value);
6247 1.1 mrg if (putenv (str) != EXIT_SUCCESS)
6248 1.1 mrg {
6249 1.1 mrg XFREE (str);
6250 1.1 mrg }
6251 1.1 mrg #endif
6252 1.1 mrg }
6253 1.1 mrg }
6254 1.1 mrg
6255 1.1 mrg char *
6256 1.1 mrg lt_extend_str (const char *orig_value, const char *add, int to_end)
6257 1.1 mrg {
6258 1.1 mrg char *new_value;
6259 1.1 mrg if (orig_value && *orig_value)
6260 1.1 mrg {
6261 1.1 mrg size_t orig_value_len = strlen (orig_value);
6262 1.1 mrg size_t add_len = strlen (add);
6263 1.1 mrg new_value = XMALLOC (char, add_len + orig_value_len + 1);
6264 1.1 mrg if (to_end)
6265 1.1 mrg {
6266 1.1 mrg strcpy (new_value, orig_value);
6267 1.1 mrg strcpy (new_value + orig_value_len, add);
6268 1.1 mrg }
6269 1.1 mrg else
6270 1.1 mrg {
6271 1.1 mrg strcpy (new_value, add);
6272 1.1 mrg strcpy (new_value + add_len, orig_value);
6273 1.1 mrg }
6274 1.1 mrg }
6275 1.1 mrg else
6276 1.1 mrg {
6277 1.1 mrg new_value = xstrdup (add);
6278 1.1 mrg }
6279 1.1 mrg return new_value;
6280 1.1 mrg }
6281 1.1 mrg
6282 1.1 mrg void
6283 1.1 mrg lt_update_exe_path (const char *name, const char *value)
6284 1.1 mrg {
6285 1.1 mrg lt_debugprintf (__FILE__, __LINE__,
6286 1.1 mrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287 1.1 mrg nonnull (name), nonnull (value));
6288 1.1 mrg
6289 1.1 mrg if (name && *name && value && *value)
6290 1.1 mrg {
6291 1.1 mrg char *new_value = lt_extend_str (getenv (name), value, 0);
6292 1.1 mrg /* some systems can't cope with a ':'-terminated path #' */
6293 1.1 mrg size_t len = strlen (new_value);
6294 1.1 mrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6295 1.1 mrg {
6296 1.1 mrg new_value[--len] = '\0';
6297 1.1 mrg }
6298 1.1 mrg lt_setenv (name, new_value);
6299 1.1 mrg XFREE (new_value);
6300 1.1 mrg }
6301 1.1 mrg }
6302 1.1 mrg
6303 1.1 mrg void
6304 1.1 mrg lt_update_lib_path (const char *name, const char *value)
6305 1.1 mrg {
6306 1.1 mrg lt_debugprintf (__FILE__, __LINE__,
6307 1.1 mrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308 1.1 mrg nonnull (name), nonnull (value));
6309 1.1 mrg
6310 1.1 mrg if (name && *name && value && *value)
6311 1.1 mrg {
6312 1.1 mrg char *new_value = lt_extend_str (getenv (name), value, 0);
6313 1.1 mrg lt_setenv (name, new_value);
6314 1.1 mrg XFREE (new_value);
6315 1.1 mrg }
6316 1.1 mrg }
6317 1.1 mrg
6318 1.1 mrg EOF
6319 1.1 mrg case $host_os in
6320 1.1 mrg mingw*)
6321 1.1 mrg cat <<"EOF"
6322 1.1 mrg
6323 1.1 mrg /* Prepares an argument vector before calling spawn().
6324 1.1 mrg Note that spawn() does not by itself call the command interpreter
6325 1.1 mrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326 1.1 mrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327 1.1 mrg GetVersionEx(&v);
6328 1.1 mrg v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329 1.1 mrg }) ? "cmd.exe" : "command.com").
6330 1.1 mrg Instead it simply concatenates the arguments, separated by ' ', and calls
6331 1.1 mrg CreateProcess(). We must quote the arguments since Win32 CreateProcess()
6332 1.1 mrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333 1.1 mrg special way:
6334 1.1 mrg - Space and tab are interpreted as delimiters. They are not treated as
6335 1.1 mrg delimiters if they are surrounded by double quotes: "...".
6336 1.1 mrg - Unescaped double quotes are removed from the input. Their only effect is
6337 1.1 mrg that within double quotes, space and tab are treated like normal
6338 1.1 mrg characters.
6339 1.1 mrg - Backslashes not followed by double quotes are not special.
6340 1.1 mrg - But 2*n+1 backslashes followed by a double quote become
6341 1.1 mrg n backslashes followed by a double quote (n >= 0):
6342 1.1 mrg \" -> "
6343 1.1 mrg \\\" -> \"
6344 1.1 mrg \\\\\" -> \\"
6345 1.1 mrg */
6346 1.1 mrg #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"
6347 1.1 mrg #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"
6348 1.1 mrg char **
6349 1.1 mrg prepare_spawn (char **argv)
6350 1.1 mrg {
6351 1.1 mrg size_t argc;
6352 1.1 mrg char **new_argv;
6353 1.1 mrg size_t i;
6354 1.1 mrg
6355 1.1 mrg /* Count number of arguments. */
6356 1.1 mrg for (argc = 0; argv[argc] != NULL; argc++)
6357 1.1 mrg ;
6358 1.1 mrg
6359 1.1 mrg /* Allocate new argument vector. */
6360 1.1 mrg new_argv = XMALLOC (char *, argc + 1);
6361 1.1 mrg
6362 1.1 mrg /* Put quoted arguments into the new argument vector. */
6363 1.1 mrg for (i = 0; i < argc; i++)
6364 1.1 mrg {
6365 1.1 mrg const char *string = argv[i];
6366 1.1 mrg
6367 1.1 mrg if (string[0] == '\0')
6368 1.1 mrg new_argv[i] = xstrdup ("\"\"");
6369 1.1 mrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370 1.1 mrg {
6371 1.1 mrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372 1.1 mrg size_t length;
6373 1.1 mrg unsigned int backslashes;
6374 1.1 mrg const char *s;
6375 1.1 mrg char *quoted_string;
6376 1.1 mrg char *p;
6377 1.1 mrg
6378 1.1 mrg length = 0;
6379 1.1 mrg backslashes = 0;
6380 1.1 mrg if (quote_around)
6381 1.1 mrg length++;
6382 1.1 mrg for (s = string; *s != '\0'; s++)
6383 1.1 mrg {
6384 1.1 mrg char c = *s;
6385 1.1 mrg if (c == '"')
6386 1.1 mrg length += backslashes + 1;
6387 1.1 mrg length++;
6388 1.1 mrg if (c == '\\')
6389 1.1 mrg backslashes++;
6390 1.1 mrg else
6391 1.1 mrg backslashes = 0;
6392 1.1 mrg }
6393 1.1 mrg if (quote_around)
6394 1.1 mrg length += backslashes + 1;
6395 1.1 mrg
6396 1.1 mrg quoted_string = XMALLOC (char, length + 1);
6397 1.1 mrg
6398 1.1 mrg p = quoted_string;
6399 1.1 mrg backslashes = 0;
6400 1.1 mrg if (quote_around)
6401 1.1 mrg *p++ = '"';
6402 1.1 mrg for (s = string; *s != '\0'; s++)
6403 1.1 mrg {
6404 1.1 mrg char c = *s;
6405 1.1 mrg if (c == '"')
6406 1.1 mrg {
6407 1.1 mrg unsigned int j;
6408 1.1 mrg for (j = backslashes + 1; j > 0; j--)
6409 1.1 mrg *p++ = '\\';
6410 1.1 mrg }
6411 1.1 mrg *p++ = c;
6412 1.1 mrg if (c == '\\')
6413 1.1 mrg backslashes++;
6414 1.1 mrg else
6415 1.1 mrg backslashes = 0;
6416 1.1 mrg }
6417 1.1 mrg if (quote_around)
6418 1.1 mrg {
6419 1.1 mrg unsigned int j;
6420 1.1 mrg for (j = backslashes; j > 0; j--)
6421 1.1 mrg *p++ = '\\';
6422 1.1 mrg *p++ = '"';
6423 1.1 mrg }
6424 1.1 mrg *p = '\0';
6425 1.1 mrg
6426 1.1 mrg new_argv[i] = quoted_string;
6427 1.1 mrg }
6428 1.1 mrg else
6429 1.1 mrg new_argv[i] = (char *) string;
6430 1.1 mrg }
6431 1.1 mrg new_argv[argc] = NULL;
6432 1.1 mrg
6433 1.1 mrg return new_argv;
6434 1.1 mrg }
6435 1.1 mrg EOF
6436 1.1 mrg ;;
6437 1.1 mrg esac
6438 1.1 mrg
6439 1.1 mrg cat <<"EOF"
6440 1.1 mrg void lt_dump_script (FILE* f)
6441 1.1 mrg {
6442 1.1 mrg EOF
6443 1.1 mrg func_emit_wrapper yes |
6444 1.1 mrg $SED -n -e '
6445 1.1 mrg s/^\(.\{79\}\)\(..*\)/\1\
6446 1.1 mrg \2/
6447 1.1 mrg h
6448 1.1 mrg s/\([\\"]\)/\\\1/g
6449 1.1 mrg s/$/\\n/
6450 1.1 mrg s/\([^\n]*\).*/ fputs ("\1", f);/p
6451 1.1 mrg g
6452 1.1 mrg D'
6453 1.1 mrg cat <<"EOF"
6454 1.1 mrg }
6455 1.1 mrg EOF
6456 1.1 mrg }
6457 1.1 mrg # end: func_emit_cwrapperexe_src
6458 1.1 mrg
6459 1.1 mrg # func_win32_import_lib_p ARG
6460 1.1 mrg # True if ARG is an import lib, as indicated by $file_magic_cmd
6461 1.1 mrg func_win32_import_lib_p ()
6462 1.1 mrg {
6463 1.1 mrg $debug_cmd
6464 1.1 mrg
6465 1.1 mrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466 1.1 mrg *import*) : ;;
6467 1.1 mrg *) false ;;
6468 1.1 mrg esac
6469 1.1 mrg }
6470 1.1 mrg
6471 1.1 mrg # func_suncc_cstd_abi
6472 1.1 mrg # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6473 1.1 mrg # Several compiler flags select an ABI that is incompatible with the
6474 1.1 mrg # Cstd library. Avoid specifying it if any are in CXXFLAGS.
6475 1.1 mrg func_suncc_cstd_abi ()
6476 1.1 mrg {
6477 1.1 mrg $debug_cmd
6478 1.1 mrg
6479 1.1 mrg case " $compile_command " in
6480 1.1 mrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6481 1.1 mrg suncc_use_cstd_abi=no
6482 1.1 mrg ;;
6483 1.1 mrg *)
6484 1.1 mrg suncc_use_cstd_abi=yes
6485 1.1 mrg ;;
6486 1.1 mrg esac
6487 1.1 mrg }
6488 1.1 mrg
6489 1.1 mrg # func_mode_link arg...
6490 1.1 mrg func_mode_link ()
6491 1.1 mrg {
6492 1.1 mrg $debug_cmd
6493 1.1 mrg
6494 1.1 mrg case $host in
6495 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6496 1.1 mrg # It is impossible to link a dll without this setting, and
6497 1.1 mrg # we shouldn't force the makefile maintainer to figure out
6498 1.1 mrg # what system we are compiling for in order to pass an extra
6499 1.1 mrg # flag for every libtool invocation.
6500 1.1 mrg # allow_undefined=no
6501 1.1 mrg
6502 1.1 mrg # FIXME: Unfortunately, there are problems with the above when trying
6503 1.1 mrg # to make a dll that has undefined symbols, in which case not
6504 1.1 mrg # even a static library is built. For now, we need to specify
6505 1.1 mrg # -no-undefined on the libtool link line when we can be certain
6506 1.1 mrg # that all symbols are satisfied, otherwise we get a static library.
6507 1.1 mrg allow_undefined=yes
6508 1.1 mrg ;;
6509 1.1 mrg *)
6510 1.1 mrg allow_undefined=yes
6511 1.1 mrg ;;
6512 1.1 mrg esac
6513 1.1 mrg libtool_args=$nonopt
6514 1.1 mrg base_compile="$nonopt $@"
6515 1.1 mrg compile_command=$nonopt
6516 1.1 mrg finalize_command=$nonopt
6517 1.1 mrg
6518 1.1 mrg compile_rpath=
6519 1.1 mrg finalize_rpath=
6520 1.1 mrg compile_shlibpath=
6521 1.1 mrg finalize_shlibpath=
6522 1.1 mrg convenience=
6523 1.1 mrg old_convenience=
6524 1.1 mrg deplibs=
6525 1.1 mrg old_deplibs=
6526 1.1 mrg compiler_flags=
6527 1.1 mrg linker_flags=
6528 1.1 mrg dllsearchpath=
6529 1.1 mrg lib_search_path=`pwd`
6530 1.1 mrg inst_prefix_dir=
6531 1.1 mrg new_inherited_linker_flags=
6532 1.1 mrg
6533 1.1 mrg avoid_version=no
6534 1.1 mrg bindir=
6535 1.1 mrg dlfiles=
6536 1.1 mrg dlprefiles=
6537 1.1 mrg dlself=no
6538 1.1 mrg export_dynamic=no
6539 1.1 mrg export_symbols=
6540 1.1 mrg export_symbols_regex=
6541 1.1 mrg generated=
6542 1.1 mrg libobjs=
6543 1.1 mrg ltlibs=
6544 1.1 mrg module=no
6545 1.1 mrg no_install=no
6546 1.1 mrg objs=
6547 1.1 mrg os2dllname=
6548 1.1 mrg non_pic_objects=
6549 1.1 mrg precious_files_regex=
6550 1.1 mrg prefer_static_libs=no
6551 1.1 mrg preload=false
6552 1.1 mrg prev=
6553 1.1 mrg prevarg=
6554 1.1 mrg release=
6555 1.1 mrg rpath=
6556 1.1 mrg xrpath=
6557 1.1 mrg perm_rpath=
6558 1.1 mrg temp_rpath=
6559 1.1 mrg thread_safe=no
6560 1.1 mrg vinfo=
6561 1.1 mrg vinfo_number=no
6562 1.1 mrg weak_libs=
6563 1.1 mrg single_module=$wl-single_module
6564 1.1 mrg func_infer_tag $base_compile
6565 1.1 mrg
6566 1.1 mrg # We need to know -static, to get the right output filenames.
6567 1.1 mrg for arg
6568 1.1 mrg do
6569 1.1 mrg case $arg in
6570 1.1 mrg -shared)
6571 1.1 mrg test yes != "$build_libtool_libs" \
6572 1.1 mrg && func_fatal_configuration "cannot build a shared library"
6573 1.1 mrg build_old_libs=no
6574 1.1 mrg break
6575 1.1 mrg ;;
6576 1.1 mrg -all-static | -static | -static-libtool-libs)
6577 1.1 mrg case $arg in
6578 1.1 mrg -all-static)
6579 1.1 mrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6580 1.1 mrg func_warning "complete static linking is impossible in this configuration"
6581 1.1 mrg fi
6582 1.1 mrg if test -n "$link_static_flag"; then
6583 1.1 mrg dlopen_self=$dlopen_self_static
6584 1.1 mrg fi
6585 1.1 mrg prefer_static_libs=yes
6586 1.1 mrg ;;
6587 1.1 mrg -static)
6588 1.1 mrg if test -z "$pic_flag" && test -n "$link_static_flag"; then
6589 1.1 mrg dlopen_self=$dlopen_self_static
6590 1.1 mrg fi
6591 1.1 mrg prefer_static_libs=built
6592 1.1 mrg ;;
6593 1.1 mrg -static-libtool-libs)
6594 1.1 mrg if test -z "$pic_flag" && test -n "$link_static_flag"; then
6595 1.1 mrg dlopen_self=$dlopen_self_static
6596 1.1 mrg fi
6597 1.1 mrg prefer_static_libs=yes
6598 1.1 mrg ;;
6599 1.1 mrg esac
6600 1.1 mrg build_libtool_libs=no
6601 1.1 mrg build_old_libs=yes
6602 1.1 mrg break
6603 1.1 mrg ;;
6604 1.1 mrg esac
6605 1.1 mrg done
6606 1.1 mrg
6607 1.1 mrg # See if our shared archives depend on static archives.
6608 1.1 mrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609 1.1 mrg
6610 1.1 mrg # Go through the arguments, transforming them on the way.
6611 1.1 mrg while test "$#" -gt 0; do
6612 1.1 mrg arg=$1
6613 1.1 mrg shift
6614 1.1 mrg func_quote_for_eval "$arg"
6615 1.1 mrg qarg=$func_quote_for_eval_unquoted_result
6616 1.1 mrg func_append libtool_args " $func_quote_for_eval_result"
6617 1.1 mrg
6618 1.1 mrg # If the previous option needs an argument, assign it.
6619 1.1 mrg if test -n "$prev"; then
6620 1.1 mrg case $prev in
6621 1.1 mrg output)
6622 1.1 mrg func_append compile_command " @OUTPUT@"
6623 1.1 mrg func_append finalize_command " @OUTPUT@"
6624 1.1 mrg ;;
6625 1.1 mrg esac
6626 1.1 mrg
6627 1.1 mrg case $prev in
6628 1.1 mrg bindir)
6629 1.1 mrg bindir=$arg
6630 1.1 mrg prev=
6631 1.1 mrg continue
6632 1.1 mrg ;;
6633 1.1 mrg dlfiles|dlprefiles)
6634 1.1 mrg $preload || {
6635 1.1 mrg # Add the symbol object into the linking commands.
6636 1.1 mrg func_append compile_command " @SYMFILE@"
6637 1.1 mrg func_append finalize_command " @SYMFILE@"
6638 1.1 mrg preload=:
6639 1.1 mrg }
6640 1.1 mrg case $arg in
6641 1.1 mrg *.la | *.lo) ;; # We handle these cases below.
6642 1.1 mrg force)
6643 1.1 mrg if test no = "$dlself"; then
6644 1.1 mrg dlself=needless
6645 1.1 mrg export_dynamic=yes
6646 1.1 mrg fi
6647 1.1 mrg prev=
6648 1.1 mrg continue
6649 1.1 mrg ;;
6650 1.1 mrg self)
6651 1.1 mrg if test dlprefiles = "$prev"; then
6652 1.1 mrg dlself=yes
6653 1.1 mrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6654 1.1 mrg dlself=yes
6655 1.1 mrg else
6656 1.1 mrg dlself=needless
6657 1.1 mrg export_dynamic=yes
6658 1.1 mrg fi
6659 1.1 mrg prev=
6660 1.1 mrg continue
6661 1.1 mrg ;;
6662 1.1 mrg *)
6663 1.1 mrg if test dlfiles = "$prev"; then
6664 1.1 mrg func_append dlfiles " $arg"
6665 1.1 mrg else
6666 1.1 mrg func_append dlprefiles " $arg"
6667 1.1 mrg fi
6668 1.1 mrg prev=
6669 1.1 mrg continue
6670 1.1 mrg ;;
6671 1.1 mrg esac
6672 1.1 mrg ;;
6673 1.1 mrg expsyms)
6674 1.1 mrg export_symbols=$arg
6675 1.1 mrg test -f "$arg" \
6676 1.1 mrg || func_fatal_error "symbol file '$arg' does not exist"
6677 1.1 mrg prev=
6678 1.1 mrg continue
6679 1.1 mrg ;;
6680 1.1 mrg expsyms_regex)
6681 1.1 mrg export_symbols_regex=$arg
6682 1.1 mrg prev=
6683 1.1 mrg continue
6684 1.1 mrg ;;
6685 1.1 mrg framework)
6686 1.1 mrg case $host in
6687 1.1 mrg *-*-darwin*)
6688 1.1 mrg case "$deplibs " in
6689 1.1 mrg *" $qarg.ltframework "*) ;;
6690 1.1 mrg *) func_append deplibs " $qarg.ltframework" # this is fixed later
6691 1.1 mrg ;;
6692 1.1 mrg esac
6693 1.1 mrg ;;
6694 1.1 mrg esac
6695 1.1 mrg prev=
6696 1.1 mrg continue
6697 1.1 mrg ;;
6698 1.1 mrg inst_prefix)
6699 1.1 mrg inst_prefix_dir=$arg
6700 1.1 mrg prev=
6701 1.1 mrg continue
6702 1.1 mrg ;;
6703 1.1 mrg mllvm)
6704 1.1 mrg # Clang does not use LLVM to link, so we can simply discard any
6705 1.1 mrg # '-mllvm $arg' options when doing the link step.
6706 1.1 mrg prev=
6707 1.1 mrg continue
6708 1.1 mrg ;;
6709 1.1 mrg objectlist)
6710 1.1 mrg if test -f "$arg"; then
6711 1.1 mrg save_arg=$arg
6712 1.1 mrg moreargs=
6713 1.1 mrg for fil in `cat "$save_arg"`
6714 1.1 mrg do
6715 1.1 mrg # func_append moreargs " $fil"
6716 1.1 mrg arg=$fil
6717 1.1 mrg # A libtool-controlled object.
6718 1.1 mrg
6719 1.1 mrg # Check to see that this really is a libtool object.
6720 1.1 mrg if func_lalib_unsafe_p "$arg"; then
6721 1.1 mrg pic_object=
6722 1.1 mrg non_pic_object=
6723 1.1 mrg
6724 1.1 mrg # Read the .lo file
6725 1.1 mrg func_source "$arg"
6726 1.1 mrg
6727 1.1 mrg if test -z "$pic_object" ||
6728 1.1 mrg test -z "$non_pic_object" ||
6729 1.1 mrg test none = "$pic_object" &&
6730 1.1 mrg test none = "$non_pic_object"; then
6731 1.1 mrg func_fatal_error "cannot find name of object for '$arg'"
6732 1.1 mrg fi
6733 1.1 mrg
6734 1.1 mrg # Extract subdirectory from the argument.
6735 1.1 mrg func_dirname "$arg" "/" ""
6736 1.1 mrg xdir=$func_dirname_result
6737 1.1 mrg
6738 1.1 mrg if test none != "$pic_object"; then
6739 1.1 mrg # Prepend the subdirectory the object is found in.
6740 1.1 mrg pic_object=$xdir$pic_object
6741 1.1 mrg
6742 1.1 mrg if test dlfiles = "$prev"; then
6743 1.1 mrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744 1.1 mrg func_append dlfiles " $pic_object"
6745 1.1 mrg prev=
6746 1.1 mrg continue
6747 1.1 mrg else
6748 1.1 mrg # If libtool objects are unsupported, then we need to preload.
6749 1.1 mrg prev=dlprefiles
6750 1.1 mrg fi
6751 1.1 mrg fi
6752 1.1 mrg
6753 1.1 mrg # CHECK ME: I think I busted this. -Ossama
6754 1.1 mrg if test dlprefiles = "$prev"; then
6755 1.1 mrg # Preload the old-style object.
6756 1.1 mrg func_append dlprefiles " $pic_object"
6757 1.1 mrg prev=
6758 1.1 mrg fi
6759 1.1 mrg
6760 1.1 mrg # A PIC object.
6761 1.1 mrg func_append libobjs " $pic_object"
6762 1.1 mrg arg=$pic_object
6763 1.1 mrg fi
6764 1.1 mrg
6765 1.1 mrg # Non-PIC object.
6766 1.1 mrg if test none != "$non_pic_object"; then
6767 1.1 mrg # Prepend the subdirectory the object is found in.
6768 1.1 mrg non_pic_object=$xdir$non_pic_object
6769 1.1 mrg
6770 1.1 mrg # A standard non-PIC object
6771 1.1 mrg func_append non_pic_objects " $non_pic_object"
6772 1.1 mrg if test -z "$pic_object" || test none = "$pic_object"; then
6773 1.1 mrg arg=$non_pic_object
6774 1.1 mrg fi
6775 1.1 mrg else
6776 1.1 mrg # If the PIC object exists, use it instead.
6777 1.1 mrg # $xdir was prepended to $pic_object above.
6778 1.1 mrg non_pic_object=$pic_object
6779 1.1 mrg func_append non_pic_objects " $non_pic_object"
6780 1.1 mrg fi
6781 1.1 mrg else
6782 1.1 mrg # Only an error if not doing a dry-run.
6783 1.1 mrg if $opt_dry_run; then
6784 1.1 mrg # Extract subdirectory from the argument.
6785 1.1 mrg func_dirname "$arg" "/" ""
6786 1.1 mrg xdir=$func_dirname_result
6787 1.1 mrg
6788 1.1 mrg func_lo2o "$arg"
6789 1.1 mrg pic_object=$xdir$objdir/$func_lo2o_result
6790 1.1 mrg non_pic_object=$xdir$func_lo2o_result
6791 1.1 mrg func_append libobjs " $pic_object"
6792 1.1 mrg func_append non_pic_objects " $non_pic_object"
6793 1.1 mrg else
6794 1.1 mrg func_fatal_error "'$arg' is not a valid libtool object"
6795 1.1 mrg fi
6796 1.1 mrg fi
6797 1.1 mrg done
6798 1.1 mrg else
6799 1.1 mrg func_fatal_error "link input file '$arg' does not exist"
6800 1.1 mrg fi
6801 1.1 mrg arg=$save_arg
6802 1.1 mrg prev=
6803 1.1 mrg continue
6804 1.1 mrg ;;
6805 1.1 mrg os2dllname)
6806 1.1 mrg os2dllname=$arg
6807 1.1 mrg prev=
6808 1.1 mrg continue
6809 1.1 mrg ;;
6810 1.1 mrg precious_regex)
6811 1.1 mrg precious_files_regex=$arg
6812 1.1 mrg prev=
6813 1.1 mrg continue
6814 1.1 mrg ;;
6815 1.1 mrg release)
6816 1.1 mrg release=-$arg
6817 1.1 mrg prev=
6818 1.1 mrg continue
6819 1.1 mrg ;;
6820 1.1 mrg rpath | xrpath)
6821 1.1 mrg # We need an absolute path.
6822 1.1 mrg case $arg in
6823 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) ;;
6824 1.1 mrg *)
6825 1.1 mrg func_fatal_error "only absolute run-paths are allowed"
6826 1.1 mrg ;;
6827 1.1 mrg esac
6828 1.1 mrg if test rpath = "$prev"; then
6829 1.1 mrg case "$rpath " in
6830 1.1 mrg *" $arg "*) ;;
6831 1.1 mrg *) func_append rpath " $arg" ;;
6832 1.1 mrg esac
6833 1.1 mrg else
6834 1.1 mrg case "$xrpath " in
6835 1.1 mrg *" $arg "*) ;;
6836 1.1 mrg *) func_append xrpath " $arg" ;;
6837 1.1 mrg esac
6838 1.1 mrg fi
6839 1.1 mrg prev=
6840 1.1 mrg continue
6841 1.1 mrg ;;
6842 1.1 mrg shrext)
6843 1.1 mrg shrext_cmds=$arg
6844 1.1 mrg prev=
6845 1.1 mrg continue
6846 1.1 mrg ;;
6847 1.1 mrg weak)
6848 1.1 mrg func_append weak_libs " $arg"
6849 1.1 mrg prev=
6850 1.1 mrg continue
6851 1.1 mrg ;;
6852 1.1 mrg xcclinker)
6853 1.1 mrg func_append linker_flags " $qarg"
6854 1.1 mrg func_append compiler_flags " $qarg"
6855 1.1 mrg prev=
6856 1.1 mrg func_append compile_command " $qarg"
6857 1.1 mrg func_append finalize_command " $qarg"
6858 1.1 mrg continue
6859 1.1 mrg ;;
6860 1.1 mrg xcompiler)
6861 1.1 mrg func_append compiler_flags " $qarg"
6862 1.1 mrg prev=
6863 1.1 mrg func_append compile_command " $qarg"
6864 1.1 mrg func_append finalize_command " $qarg"
6865 1.1 mrg continue
6866 1.1 mrg ;;
6867 1.1 mrg xlinker)
6868 1.1 mrg func_append linker_flags " $qarg"
6869 1.1 mrg func_append compiler_flags " $wl$qarg"
6870 1.1 mrg prev=
6871 1.1 mrg func_append compile_command " $wl$qarg"
6872 1.1 mrg func_append finalize_command " $wl$qarg"
6873 1.1 mrg continue
6874 1.1 mrg ;;
6875 1.1 mrg *)
6876 1.1 mrg eval "$prev=\"\$arg\""
6877 1.1 mrg prev=
6878 1.1 mrg continue
6879 1.1 mrg ;;
6880 1.1 mrg esac
6881 1.1 mrg fi # test -n "$prev"
6882 1.1 mrg
6883 1.1 mrg prevarg=$arg
6884 1.1 mrg
6885 1.1 mrg case $arg in
6886 1.1 mrg -all-static)
6887 1.1 mrg if test -n "$link_static_flag"; then
6888 1.1 mrg # See comment for -static flag below, for more details.
6889 1.1 mrg func_append compile_command " $link_static_flag"
6890 1.1 mrg func_append finalize_command " $link_static_flag"
6891 1.1 mrg fi
6892 1.1 mrg continue
6893 1.1 mrg ;;
6894 1.1 mrg
6895 1.1 mrg -allow-undefined)
6896 1.1 mrg # FIXME: remove this flag sometime in the future.
6897 1.1 mrg func_fatal_error "'-allow-undefined' must not be used because it is the default"
6898 1.1 mrg ;;
6899 1.1 mrg
6900 1.1 mrg -avoid-version)
6901 1.1 mrg avoid_version=yes
6902 1.1 mrg continue
6903 1.1 mrg ;;
6904 1.1 mrg
6905 1.1 mrg -bindir)
6906 1.1 mrg prev=bindir
6907 1.1 mrg continue
6908 1.1 mrg ;;
6909 1.1 mrg
6910 1.1 mrg -dlopen)
6911 1.1 mrg prev=dlfiles
6912 1.1 mrg continue
6913 1.1 mrg ;;
6914 1.1 mrg
6915 1.1 mrg -dlpreopen)
6916 1.1 mrg prev=dlprefiles
6917 1.1 mrg continue
6918 1.1 mrg ;;
6919 1.1 mrg
6920 1.1 mrg -export-dynamic)
6921 1.1 mrg export_dynamic=yes
6922 1.1 mrg continue
6923 1.1 mrg ;;
6924 1.1 mrg
6925 1.1 mrg -export-symbols | -export-symbols-regex)
6926 1.1 mrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6927 1.1 mrg func_fatal_error "more than one -exported-symbols argument is not allowed"
6928 1.1 mrg fi
6929 1.1 mrg if test X-export-symbols = "X$arg"; then
6930 1.1 mrg prev=expsyms
6931 1.1 mrg else
6932 1.1 mrg prev=expsyms_regex
6933 1.1 mrg fi
6934 1.1 mrg continue
6935 1.1 mrg ;;
6936 1.1 mrg
6937 1.1 mrg -framework)
6938 1.1 mrg prev=framework
6939 1.1 mrg continue
6940 1.1 mrg ;;
6941 1.1 mrg
6942 1.1 mrg -inst-prefix-dir)
6943 1.1 mrg prev=inst_prefix
6944 1.1 mrg continue
6945 1.1 mrg ;;
6946 1.1 mrg
6947 1.1 mrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6948 1.1 mrg # so, if we see these flags be careful not to treat them like -L
6949 1.1 mrg -L[A-Z][A-Z]*:*)
6950 1.1 mrg case $with_gcc/$host in
6951 1.1 mrg no/*-*-irix* | /*-*-irix*)
6952 1.1 mrg func_append compile_command " $arg"
6953 1.1 mrg func_append finalize_command " $arg"
6954 1.1 mrg ;;
6955 1.1 mrg esac
6956 1.1 mrg continue
6957 1.1 mrg ;;
6958 1.1 mrg
6959 1.1 mrg -L*)
6960 1.1 mrg func_stripname "-L" '' "$arg"
6961 1.1 mrg if test -z "$func_stripname_result"; then
6962 1.1 mrg if test "$#" -gt 0; then
6963 1.1 mrg func_fatal_error "require no space between '-L' and '$1'"
6964 1.1 mrg else
6965 1.1 mrg func_fatal_error "need path for '-L' option"
6966 1.1 mrg fi
6967 1.1 mrg fi
6968 1.1 mrg func_resolve_sysroot "$func_stripname_result"
6969 1.1 mrg dir=$func_resolve_sysroot_result
6970 1.1 mrg # We need an absolute path.
6971 1.1 mrg case $dir in
6972 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) ;;
6973 1.1 mrg *)
6974 1.1 mrg absdir=`cd "$dir" && pwd`
6975 1.1 mrg test -z "$absdir" && \
6976 1.1 mrg func_fatal_error "cannot determine absolute directory name of '$dir'"
6977 1.1 mrg dir=$absdir
6978 1.1 mrg ;;
6979 1.1 mrg esac
6980 1.1 mrg case "$deplibs " in
6981 1.1 mrg *" -L$dir "* | *" $arg "*)
6982 1.1 mrg # Will only happen for absolute or sysroot arguments
6983 1.1 mrg ;;
6984 1.1 mrg *)
6985 1.1 mrg # Preserve sysroot, but never include relative directories
6986 1.1 mrg case $dir in
6987 1.1 mrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988 1.1 mrg *) func_append deplibs " -L$dir" ;;
6989 1.1 mrg esac
6990 1.1 mrg func_append lib_search_path " $dir"
6991 1.1 mrg ;;
6992 1.1 mrg esac
6993 1.1 mrg case $host in
6994 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995 1.1 mrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6996 1.1 mrg case :$dllsearchpath: in
6997 1.1 mrg *":$dir:"*) ;;
6998 1.1 mrg ::) dllsearchpath=$dir;;
6999 1.1 mrg *) func_append dllsearchpath ":$dir";;
7000 1.1 mrg esac
7001 1.1 mrg case :$dllsearchpath: in
7002 1.1 mrg *":$testbindir:"*) ;;
7003 1.1 mrg ::) dllsearchpath=$testbindir;;
7004 1.1 mrg *) func_append dllsearchpath ":$testbindir";;
7005 1.1 mrg esac
7006 1.1 mrg ;;
7007 1.1 mrg esac
7008 1.1 mrg continue
7009 1.1 mrg ;;
7010 1.1 mrg
7011 1.1 mrg -l*)
7012 1.1 mrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7013 1.1 mrg case $host in
7014 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7015 1.1 mrg # These systems don't actually have a C or math library (as such)
7016 1.1 mrg continue
7017 1.1 mrg ;;
7018 1.1 mrg *-*-os2*)
7019 1.1 mrg # These systems don't actually have a C library (as such)
7020 1.1 mrg test X-lc = "X$arg" && continue
7021 1.1 mrg ;;
7022 1.1 mrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7023 1.1 mrg # Do not include libc due to us having libc/libc_r.
7024 1.1 mrg test X-lc = "X$arg" && continue
7025 1.1 mrg ;;
7026 1.1 mrg *-*-rhapsody* | *-*-darwin1.[012])
7027 1.1 mrg # Rhapsody C and math libraries are in the System framework
7028 1.1 mrg func_append deplibs " System.ltframework"
7029 1.1 mrg continue
7030 1.1 mrg ;;
7031 1.1 mrg *-*-sco3.2v5* | *-*-sco5v6*)
7032 1.1 mrg # Causes problems with __ctype
7033 1.1 mrg test X-lc = "X$arg" && continue
7034 1.1 mrg ;;
7035 1.1 mrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7036 1.1 mrg # Compiler inserts libc in the correct place for threads to work
7037 1.1 mrg test X-lc = "X$arg" && continue
7038 1.1 mrg ;;
7039 1.1 mrg esac
7040 1.1 mrg elif test X-lc_r = "X$arg"; then
7041 1.1 mrg case $host in
7042 1.1 mrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7043 1.1 mrg # Do not include libc_r directly, use -pthread flag.
7044 1.1 mrg continue
7045 1.1 mrg ;;
7046 1.1 mrg esac
7047 1.1 mrg fi
7048 1.1 mrg func_append deplibs " $arg"
7049 1.1 mrg continue
7050 1.1 mrg ;;
7051 1.1 mrg
7052 1.1 mrg -mllvm)
7053 1.1 mrg prev=mllvm
7054 1.1 mrg continue
7055 1.1 mrg ;;
7056 1.1 mrg
7057 1.1 mrg -module)
7058 1.1 mrg module=yes
7059 1.1 mrg continue
7060 1.1 mrg ;;
7061 1.1 mrg
7062 1.1 mrg # Tru64 UNIX uses -model [arg] to determine the layout of C++
7063 1.1 mrg # classes, name mangling, and exception handling.
7064 1.1 mrg # Darwin uses the -arch flag to determine output architecture.
7065 1.1 mrg -model|-arch|-isysroot|--sysroot)
7066 1.1 mrg func_append compiler_flags " $arg"
7067 1.1 mrg func_append compile_command " $arg"
7068 1.1 mrg func_append finalize_command " $arg"
7069 1.1 mrg prev=xcompiler
7070 1.1 mrg continue
7071 1.1 mrg ;;
7072 1.1 mrg
7073 1.1 mrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7074 1.1 mrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075 1.1 mrg func_append compiler_flags " $arg"
7076 1.1 mrg func_append compile_command " $arg"
7077 1.1 mrg func_append finalize_command " $arg"
7078 1.1 mrg case "$new_inherited_linker_flags " in
7079 1.1 mrg *" $arg "*) ;;
7080 1.1 mrg * ) func_append new_inherited_linker_flags " $arg" ;;
7081 1.1 mrg esac
7082 1.1 mrg continue
7083 1.1 mrg ;;
7084 1.1 mrg
7085 1.1 mrg -multi_module)
7086 1.1 mrg single_module=$wl-multi_module
7087 1.1 mrg continue
7088 1.1 mrg ;;
7089 1.1 mrg
7090 1.1 mrg -no-fast-install)
7091 1.1 mrg fast_install=no
7092 1.1 mrg continue
7093 1.1 mrg ;;
7094 1.1 mrg
7095 1.1 mrg -no-install)
7096 1.1 mrg case $host in
7097 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7098 1.1 mrg # The PATH hackery in wrapper scripts is required on Windows
7099 1.1 mrg # and Darwin in order for the loader to find any dlls it needs.
7100 1.1 mrg func_warning "'-no-install' is ignored for $host"
7101 1.1 mrg func_warning "assuming '-no-fast-install' instead"
7102 1.1 mrg fast_install=no
7103 1.1 mrg ;;
7104 1.1 mrg *) no_install=yes ;;
7105 1.1 mrg esac
7106 1.1 mrg continue
7107 1.1 mrg ;;
7108 1.1 mrg
7109 1.1 mrg -no-undefined)
7110 1.1 mrg allow_undefined=no
7111 1.1 mrg continue
7112 1.1 mrg ;;
7113 1.1 mrg
7114 1.1 mrg -objectlist)
7115 1.1 mrg prev=objectlist
7116 1.1 mrg continue
7117 1.1 mrg ;;
7118 1.1 mrg
7119 1.1 mrg -os2dllname)
7120 1.1 mrg prev=os2dllname
7121 1.1 mrg continue
7122 1.1 mrg ;;
7123 1.1 mrg
7124 1.1 mrg -o) prev=output ;;
7125 1.1 mrg
7126 1.1 mrg -precious-files-regex)
7127 1.1 mrg prev=precious_regex
7128 1.1 mrg continue
7129 1.1 mrg ;;
7130 1.1 mrg
7131 1.1 mrg -release)
7132 1.1 mrg prev=release
7133 1.1 mrg continue
7134 1.1 mrg ;;
7135 1.1 mrg
7136 1.1 mrg -rpath)
7137 1.1 mrg prev=rpath
7138 1.1 mrg continue
7139 1.1 mrg ;;
7140 1.1 mrg
7141 1.1 mrg -R)
7142 1.1 mrg prev=xrpath
7143 1.1 mrg continue
7144 1.1 mrg ;;
7145 1.1 mrg
7146 1.1 mrg -R*)
7147 1.1 mrg func_stripname '-R' '' "$arg"
7148 1.1 mrg dir=$func_stripname_result
7149 1.1 mrg # We need an absolute path.
7150 1.1 mrg case $dir in
7151 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) ;;
7152 1.1 mrg =*)
7153 1.1 mrg func_stripname '=' '' "$dir"
7154 1.1 mrg dir=$lt_sysroot$func_stripname_result
7155 1.1 mrg ;;
7156 1.1 mrg *)
7157 1.1 mrg func_fatal_error "only absolute run-paths are allowed"
7158 1.1 mrg ;;
7159 1.1 mrg esac
7160 1.1 mrg case "$xrpath " in
7161 1.1 mrg *" $dir "*) ;;
7162 1.1 mrg *) func_append xrpath " $dir" ;;
7163 1.1 mrg esac
7164 1.1 mrg continue
7165 1.1 mrg ;;
7166 1.1 mrg
7167 1.1 mrg -shared)
7168 1.1 mrg # The effects of -shared are defined in a previous loop.
7169 1.1 mrg continue
7170 1.1 mrg ;;
7171 1.1 mrg
7172 1.1 mrg -shrext)
7173 1.1 mrg prev=shrext
7174 1.1 mrg continue
7175 1.1 mrg ;;
7176 1.1 mrg
7177 1.1 mrg -static | -static-libtool-libs)
7178 1.1 mrg # The effects of -static are defined in a previous loop.
7179 1.1 mrg # We used to do the same as -all-static on platforms that
7180 1.1 mrg # didn't have a PIC flag, but the assumption that the effects
7181 1.1 mrg # would be equivalent was wrong. It would break on at least
7182 1.1 mrg # Digital Unix and AIX.
7183 1.1 mrg continue
7184 1.1 mrg ;;
7185 1.1 mrg
7186 1.1 mrg -thread-safe)
7187 1.1 mrg thread_safe=yes
7188 1.1 mrg continue
7189 1.1 mrg ;;
7190 1.1 mrg
7191 1.1 mrg -version-info)
7192 1.1 mrg prev=vinfo
7193 1.1 mrg continue
7194 1.1 mrg ;;
7195 1.1 mrg
7196 1.1 mrg -version-number)
7197 1.1 mrg prev=vinfo
7198 1.1 mrg vinfo_number=yes
7199 1.1 mrg continue
7200 1.1 mrg ;;
7201 1.1 mrg
7202 1.1 mrg -weak)
7203 1.1 mrg prev=weak
7204 1.1 mrg continue
7205 1.1 mrg ;;
7206 1.1 mrg
7207 1.1 mrg -Wc,*)
7208 1.1 mrg func_stripname '-Wc,' '' "$arg"
7209 1.1 mrg args=$func_stripname_result
7210 1.1 mrg arg=
7211 1.1 mrg save_ifs=$IFS; IFS=,
7212 1.1 mrg for flag in $args; do
7213 1.1 mrg IFS=$save_ifs
7214 1.1 mrg func_quote_for_eval "$flag"
7215 1.1 mrg func_append arg " $func_quote_for_eval_result"
7216 1.1 mrg func_append compiler_flags " $func_quote_for_eval_result"
7217 1.1 mrg done
7218 1.1 mrg IFS=$save_ifs
7219 1.1 mrg func_stripname ' ' '' "$arg"
7220 1.1 mrg arg=$func_stripname_result
7221 1.1 mrg ;;
7222 1.1 mrg
7223 1.1 mrg -Wl,*)
7224 1.1 mrg func_stripname '-Wl,' '' "$arg"
7225 1.1 mrg args=$func_stripname_result
7226 1.1 mrg arg=
7227 1.1 mrg save_ifs=$IFS; IFS=,
7228 1.1 mrg for flag in $args; do
7229 1.1 mrg IFS=$save_ifs
7230 1.1 mrg func_quote_for_eval "$flag"
7231 1.1 mrg func_append arg " $wl$func_quote_for_eval_result"
7232 1.1 mrg func_append compiler_flags " $wl$func_quote_for_eval_result"
7233 1.1 mrg func_append linker_flags " $func_quote_for_eval_result"
7234 1.1 mrg done
7235 1.1 mrg IFS=$save_ifs
7236 1.1 mrg func_stripname ' ' '' "$arg"
7237 1.1 mrg arg=$func_stripname_result
7238 1.1 mrg ;;
7239 1.1 mrg
7240 1.1 mrg -Xcompiler)
7241 1.1 mrg prev=xcompiler
7242 1.1 mrg continue
7243 1.1 mrg ;;
7244 1.1 mrg
7245 1.1 mrg -Xlinker)
7246 1.1 mrg prev=xlinker
7247 1.1 mrg continue
7248 1.1 mrg ;;
7249 1.1 mrg
7250 1.1 mrg -XCClinker)
7251 1.1 mrg prev=xcclinker
7252 1.1 mrg continue
7253 1.1 mrg ;;
7254 1.1 mrg
7255 1.1 mrg # -msg_* for osf cc
7256 1.1 mrg -msg_*)
7257 1.1 mrg func_quote_for_eval "$arg"
7258 1.1 mrg arg=$func_quote_for_eval_result
7259 1.1 mrg ;;
7260 1.1 mrg
7261 1.1 mrg # Flags to be passed through unchanged, with rationale:
7262 1.1 mrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
7263 1.1 mrg # -r[0-9][0-9]* specify processor for the SGI compiler
7264 1.1 mrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265 1.1 mrg # +DA*, +DD* enable 64-bit mode for the HP compiler
7266 1.1 mrg # -q* compiler args for the IBM compiler
7267 1.1 mrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268 1.1 mrg # -F/path path to uninstalled frameworks, gcc on darwin
7269 1.1 mrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
7270 1.1 mrg # -fstack-protector* stack protector flags for GCC
7271 1.1 mrg # @file GCC response files
7272 1.1 mrg # -tp=* Portland pgcc target processor selection
7273 1.1 mrg # --sysroot=* for sysroot support
7274 1.1 mrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7275 1.1 mrg # -stdlib=* select c++ std lib with clang
7276 1.1 mrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7277 1.1 mrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7278 1.1 mrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
7279 1.1 mrg func_quote_for_eval "$arg"
7280 1.1 mrg arg=$func_quote_for_eval_result
7281 1.1 mrg func_append compile_command " $arg"
7282 1.1 mrg func_append finalize_command " $arg"
7283 1.1 mrg func_append compiler_flags " $arg"
7284 1.1 mrg continue
7285 1.1 mrg ;;
7286 1.1 mrg
7287 1.1 mrg -Z*)
7288 1.1 mrg if test os2 = "`expr $host : '.*\(os2\)'`"; then
7289 1.1 mrg # OS/2 uses -Zxxx to specify OS/2-specific options
7290 1.1 mrg compiler_flags="$compiler_flags $arg"
7291 1.1 mrg func_append compile_command " $arg"
7292 1.1 mrg func_append finalize_command " $arg"
7293 1.1 mrg case $arg in
7294 1.1 mrg -Zlinker | -Zstack)
7295 1.1 mrg prev=xcompiler
7296 1.1 mrg ;;
7297 1.1 mrg esac
7298 1.1 mrg continue
7299 1.1 mrg else
7300 1.1 mrg # Otherwise treat like 'Some other compiler flag' below
7301 1.1 mrg func_quote_for_eval "$arg"
7302 1.1 mrg arg=$func_quote_for_eval_result
7303 1.1 mrg fi
7304 1.1 mrg ;;
7305 1.1 mrg
7306 1.1 mrg # Some other compiler flag.
7307 1.1 mrg -* | +*)
7308 1.1 mrg func_quote_for_eval "$arg"
7309 1.1 mrg arg=$func_quote_for_eval_result
7310 1.1 mrg ;;
7311 1.1 mrg
7312 1.1 mrg *.$objext)
7313 1.1 mrg # A standard object.
7314 1.1 mrg func_append objs " $arg"
7315 1.1 mrg ;;
7316 1.1 mrg
7317 1.1 mrg *.lo)
7318 1.1 mrg # A libtool-controlled object.
7319 1.1 mrg
7320 1.1 mrg # Check to see that this really is a libtool object.
7321 1.1 mrg if func_lalib_unsafe_p "$arg"; then
7322 1.1 mrg pic_object=
7323 1.1 mrg non_pic_object=
7324 1.1 mrg
7325 1.1 mrg # Read the .lo file
7326 1.1 mrg func_source "$arg"
7327 1.1 mrg
7328 1.1 mrg if test -z "$pic_object" ||
7329 1.1 mrg test -z "$non_pic_object" ||
7330 1.1 mrg test none = "$pic_object" &&
7331 1.1 mrg test none = "$non_pic_object"; then
7332 1.1 mrg func_fatal_error "cannot find name of object for '$arg'"
7333 1.1 mrg fi
7334 1.1 mrg
7335 1.1 mrg # Extract subdirectory from the argument.
7336 1.1 mrg func_dirname "$arg" "/" ""
7337 1.1 mrg xdir=$func_dirname_result
7338 1.1 mrg
7339 1.1 mrg test none = "$pic_object" || {
7340 1.1 mrg # Prepend the subdirectory the object is found in.
7341 1.1 mrg pic_object=$xdir$pic_object
7342 1.1 mrg
7343 1.1 mrg if test dlfiles = "$prev"; then
7344 1.1 mrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7345 1.1 mrg func_append dlfiles " $pic_object"
7346 1.1 mrg prev=
7347 1.1 mrg continue
7348 1.1 mrg else
7349 1.1 mrg # If libtool objects are unsupported, then we need to preload.
7350 1.1 mrg prev=dlprefiles
7351 1.1 mrg fi
7352 1.1 mrg fi
7353 1.1 mrg
7354 1.1 mrg # CHECK ME: I think I busted this. -Ossama
7355 1.1 mrg if test dlprefiles = "$prev"; then
7356 1.1 mrg # Preload the old-style object.
7357 1.1 mrg func_append dlprefiles " $pic_object"
7358 1.1 mrg prev=
7359 1.1 mrg fi
7360 1.1 mrg
7361 1.1 mrg # A PIC object.
7362 1.1 mrg func_append libobjs " $pic_object"
7363 1.1 mrg arg=$pic_object
7364 1.1 mrg }
7365 1.1 mrg
7366 1.1 mrg # Non-PIC object.
7367 1.1 mrg if test none != "$non_pic_object"; then
7368 1.1 mrg # Prepend the subdirectory the object is found in.
7369 1.1 mrg non_pic_object=$xdir$non_pic_object
7370 1.1 mrg
7371 1.1 mrg # A standard non-PIC object
7372 1.1 mrg func_append non_pic_objects " $non_pic_object"
7373 1.1 mrg if test -z "$pic_object" || test none = "$pic_object"; then
7374 1.1 mrg arg=$non_pic_object
7375 1.1 mrg fi
7376 1.1 mrg else
7377 1.1 mrg # If the PIC object exists, use it instead.
7378 1.1 mrg # $xdir was prepended to $pic_object above.
7379 1.1 mrg non_pic_object=$pic_object
7380 1.1 mrg func_append non_pic_objects " $non_pic_object"
7381 1.1 mrg fi
7382 1.1 mrg else
7383 1.1 mrg # Only an error if not doing a dry-run.
7384 1.1 mrg if $opt_dry_run; then
7385 1.1 mrg # Extract subdirectory from the argument.
7386 1.1 mrg func_dirname "$arg" "/" ""
7387 1.1 mrg xdir=$func_dirname_result
7388 1.1 mrg
7389 1.1 mrg func_lo2o "$arg"
7390 1.1 mrg pic_object=$xdir$objdir/$func_lo2o_result
7391 1.1 mrg non_pic_object=$xdir$func_lo2o_result
7392 1.1 mrg func_append libobjs " $pic_object"
7393 1.1 mrg func_append non_pic_objects " $non_pic_object"
7394 1.1 mrg else
7395 1.1 mrg func_fatal_error "'$arg' is not a valid libtool object"
7396 1.1 mrg fi
7397 1.1 mrg fi
7398 1.1 mrg ;;
7399 1.1 mrg
7400 1.1 mrg *.$libext)
7401 1.1 mrg # An archive.
7402 1.1 mrg func_append deplibs " $arg"
7403 1.1 mrg func_append old_deplibs " $arg"
7404 1.1 mrg continue
7405 1.1 mrg ;;
7406 1.1 mrg
7407 1.1 mrg *.la)
7408 1.1 mrg # A libtool-controlled library.
7409 1.1 mrg
7410 1.1 mrg func_resolve_sysroot "$arg"
7411 1.1 mrg if test dlfiles = "$prev"; then
7412 1.1 mrg # This library was specified with -dlopen.
7413 1.1 mrg func_append dlfiles " $func_resolve_sysroot_result"
7414 1.1 mrg prev=
7415 1.1 mrg elif test dlprefiles = "$prev"; then
7416 1.1 mrg # The library was specified with -dlpreopen.
7417 1.1 mrg func_append dlprefiles " $func_resolve_sysroot_result"
7418 1.1 mrg prev=
7419 1.1 mrg else
7420 1.1 mrg func_append deplibs " $func_resolve_sysroot_result"
7421 1.1 mrg fi
7422 1.1 mrg continue
7423 1.1 mrg ;;
7424 1.1 mrg
7425 1.1 mrg # Some other compiler argument.
7426 1.1 mrg *)
7427 1.1 mrg # Unknown arguments in both finalize_command and compile_command need
7428 1.1 mrg # to be aesthetically quoted because they are evaled later.
7429 1.1 mrg func_quote_for_eval "$arg"
7430 1.1 mrg arg=$func_quote_for_eval_result
7431 1.1 mrg ;;
7432 1.1 mrg esac # arg
7433 1.1 mrg
7434 1.1 mrg # Now actually substitute the argument into the commands.
7435 1.1 mrg if test -n "$arg"; then
7436 1.1 mrg func_append compile_command " $arg"
7437 1.1 mrg func_append finalize_command " $arg"
7438 1.1 mrg fi
7439 1.1 mrg done # argument parsing loop
7440 1.1 mrg
7441 1.1 mrg test -n "$prev" && \
7442 1.1 mrg func_fatal_help "the '$prevarg' option requires an argument"
7443 1.1 mrg
7444 1.1 mrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7445 1.1 mrg eval arg=\"$export_dynamic_flag_spec\"
7446 1.1 mrg func_append compile_command " $arg"
7447 1.1 mrg func_append finalize_command " $arg"
7448 1.1 mrg fi
7449 1.1 mrg
7450 1.1 mrg oldlibs=
7451 1.1 mrg # calculate the name of the file, without its directory
7452 1.1 mrg func_basename "$output"
7453 1.1 mrg outputname=$func_basename_result
7454 1.1 mrg libobjs_save=$libobjs
7455 1.1 mrg
7456 1.1 mrg if test -n "$shlibpath_var"; then
7457 1.1 mrg # get the directories listed in $shlibpath_var
7458 1.1 mrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7459 1.1 mrg else
7460 1.1 mrg shlib_search_path=
7461 1.1 mrg fi
7462 1.1 mrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7463 1.1 mrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7464 1.1 mrg
7465 1.1 mrg # Definition is injected by LT_CONFIG during libtool generation.
7466 1.1 mrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7467 1.1 mrg
7468 1.1 mrg func_dirname "$output" "/" ""
7469 1.1 mrg output_objdir=$func_dirname_result$objdir
7470 1.1 mrg func_to_tool_file "$output_objdir/"
7471 1.1 mrg tool_output_objdir=$func_to_tool_file_result
7472 1.1 mrg # Create the object directory.
7473 1.1 mrg func_mkdir_p "$output_objdir"
7474 1.1 mrg
7475 1.1 mrg # Determine the type of output
7476 1.1 mrg case $output in
7477 1.1 mrg "")
7478 1.1 mrg func_fatal_help "you must specify an output file"
7479 1.1 mrg ;;
7480 1.1 mrg *.$libext) linkmode=oldlib ;;
7481 1.1 mrg *.lo | *.$objext) linkmode=obj ;;
7482 1.1 mrg *.la) linkmode=lib ;;
7483 1.1 mrg *) linkmode=prog ;; # Anything else should be a program.
7484 1.1 mrg esac
7485 1.1 mrg
7486 1.1 mrg specialdeplibs=
7487 1.1 mrg
7488 1.1 mrg libs=
7489 1.1 mrg # Find all interdependent deplibs by searching for libraries
7490 1.1 mrg # that are linked more than once (e.g. -la -lb -la)
7491 1.1 mrg for deplib in $deplibs; do
7492 1.1 mrg if $opt_preserve_dup_deps; then
7493 1.1 mrg case "$libs " in
7494 1.1 mrg *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7495 1.1 mrg esac
7496 1.1 mrg fi
7497 1.1 mrg func_append libs " $deplib"
7498 1.1 mrg done
7499 1.1 mrg
7500 1.1 mrg if test lib = "$linkmode"; then
7501 1.1 mrg libs="$predeps $libs $compiler_lib_search_path $postdeps"
7502 1.1 mrg
7503 1.1 mrg # Compute libraries that are listed more than once in $predeps
7504 1.1 mrg # $postdeps and mark them as special (i.e., whose duplicates are
7505 1.1 mrg # not to be eliminated).
7506 1.1 mrg pre_post_deps=
7507 1.1 mrg if $opt_duplicate_compiler_generated_deps; then
7508 1.1 mrg for pre_post_dep in $predeps $postdeps; do
7509 1.1 mrg case "$pre_post_deps " in
7510 1.1 mrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7511 1.1 mrg esac
7512 1.1 mrg func_append pre_post_deps " $pre_post_dep"
7513 1.1 mrg done
7514 1.1 mrg fi
7515 1.1 mrg pre_post_deps=
7516 1.1 mrg fi
7517 1.1 mrg
7518 1.1 mrg deplibs=
7519 1.1 mrg newdependency_libs=
7520 1.1 mrg newlib_search_path=
7521 1.1 mrg need_relink=no # whether we're linking any uninstalled libtool libraries
7522 1.1 mrg notinst_deplibs= # not-installed libtool libraries
7523 1.1 mrg notinst_path= # paths that contain not-installed libtool libraries
7524 1.1 mrg
7525 1.1 mrg case $linkmode in
7526 1.1 mrg lib)
7527 1.1 mrg passes="conv dlpreopen link"
7528 1.1 mrg for file in $dlfiles $dlprefiles; do
7529 1.1 mrg case $file in
7530 1.1 mrg *.la) ;;
7531 1.1 mrg *)
7532 1.1 mrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7533 1.1 mrg ;;
7534 1.1 mrg esac
7535 1.1 mrg done
7536 1.1 mrg ;;
7537 1.1 mrg prog)
7538 1.1 mrg compile_deplibs=
7539 1.1 mrg finalize_deplibs=
7540 1.1 mrg alldeplibs=false
7541 1.1 mrg newdlfiles=
7542 1.1 mrg newdlprefiles=
7543 1.1 mrg passes="conv scan dlopen dlpreopen link"
7544 1.1 mrg ;;
7545 1.1 mrg *) passes="conv"
7546 1.1 mrg ;;
7547 1.1 mrg esac
7548 1.1 mrg
7549 1.1 mrg for pass in $passes; do
7550 1.1 mrg # The preopen pass in lib mode reverses $deplibs; put it back here
7551 1.1 mrg # so that -L comes before libs that need it for instance...
7552 1.1 mrg if test lib,link = "$linkmode,$pass"; then
7553 1.1 mrg ## FIXME: Find the place where the list is rebuilt in the wrong
7554 1.1 mrg ## order, and fix it there properly
7555 1.1 mrg tmp_deplibs=
7556 1.1 mrg for deplib in $deplibs; do
7557 1.1 mrg tmp_deplibs="$deplib $tmp_deplibs"
7558 1.1 mrg done
7559 1.1 mrg deplibs=$tmp_deplibs
7560 1.1 mrg fi
7561 1.1 mrg
7562 1.1 mrg if test lib,link = "$linkmode,$pass" ||
7563 1.1 mrg test prog,scan = "$linkmode,$pass"; then
7564 1.1 mrg libs=$deplibs
7565 1.1 mrg deplibs=
7566 1.1 mrg fi
7567 1.1 mrg if test prog = "$linkmode"; then
7568 1.1 mrg case $pass in
7569 1.1 mrg dlopen) libs=$dlfiles ;;
7570 1.1 mrg dlpreopen) libs=$dlprefiles ;;
7571 1.1 mrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7572 1.1 mrg esac
7573 1.1 mrg fi
7574 1.1 mrg if test lib,dlpreopen = "$linkmode,$pass"; then
7575 1.1 mrg # Collect and forward deplibs of preopened libtool libs
7576 1.1 mrg for lib in $dlprefiles; do
7577 1.1 mrg # Ignore non-libtool-libs
7578 1.1 mrg dependency_libs=
7579 1.1 mrg func_resolve_sysroot "$lib"
7580 1.1 mrg case $lib in
7581 1.1 mrg *.la) func_source "$func_resolve_sysroot_result" ;;
7582 1.1 mrg esac
7583 1.1 mrg
7584 1.1 mrg # Collect preopened libtool deplibs, except any this library
7585 1.1 mrg # has declared as weak libs
7586 1.1 mrg for deplib in $dependency_libs; do
7587 1.1 mrg func_basename "$deplib"
7588 1.1 mrg deplib_base=$func_basename_result
7589 1.1 mrg case " $weak_libs " in
7590 1.1 mrg *" $deplib_base "*) ;;
7591 1.1 mrg *) func_append deplibs " $deplib" ;;
7592 1.1 mrg esac
7593 1.1 mrg done
7594 1.1 mrg done
7595 1.1 mrg libs=$dlprefiles
7596 1.1 mrg fi
7597 1.1 mrg if test dlopen = "$pass"; then
7598 1.1 mrg # Collect dlpreopened libraries
7599 1.1 mrg save_deplibs=$deplibs
7600 1.1 mrg deplibs=
7601 1.1 mrg fi
7602 1.1 mrg
7603 1.1 mrg for deplib in $libs; do
7604 1.1 mrg lib=
7605 1.1 mrg found=false
7606 1.1 mrg case $deplib in
7607 1.1 mrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7608 1.1 mrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7609 1.1 mrg if test prog,link = "$linkmode,$pass"; then
7610 1.1 mrg compile_deplibs="$deplib $compile_deplibs"
7611 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs"
7612 1.1 mrg else
7613 1.1 mrg func_append compiler_flags " $deplib"
7614 1.1 mrg if test lib = "$linkmode"; then
7615 1.1 mrg case "$new_inherited_linker_flags " in
7616 1.1 mrg *" $deplib "*) ;;
7617 1.1 mrg * ) func_append new_inherited_linker_flags " $deplib" ;;
7618 1.1 mrg esac
7619 1.1 mrg fi
7620 1.1 mrg fi
7621 1.1 mrg continue
7622 1.1 mrg ;;
7623 1.1 mrg -l*)
7624 1.1 mrg if test lib != "$linkmode" && test prog != "$linkmode"; then
7625 1.1 mrg func_warning "'-l' is ignored for archives/objects"
7626 1.1 mrg continue
7627 1.1 mrg fi
7628 1.1 mrg func_stripname '-l' '' "$deplib"
7629 1.1 mrg name=$func_stripname_result
7630 1.1 mrg if test lib = "$linkmode"; then
7631 1.1 mrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7632 1.1 mrg else
7633 1.1 mrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7634 1.1 mrg fi
7635 1.1 mrg for searchdir in $searchdirs; do
7636 1.1 mrg for search_ext in .la $std_shrext .so .a; do
7637 1.1 mrg # Search the libtool library
7638 1.1 mrg lib=$searchdir/lib$name$search_ext
7639 1.1 mrg if test -f "$lib"; then
7640 1.1 mrg if test .la = "$search_ext"; then
7641 1.1 mrg found=:
7642 1.1 mrg else
7643 1.1 mrg found=false
7644 1.1 mrg fi
7645 1.1 mrg break 2
7646 1.1 mrg fi
7647 1.1 mrg done
7648 1.1 mrg done
7649 1.1 mrg if $found; then
7650 1.1 mrg # deplib is a libtool library
7651 1.1 mrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7652 1.1 mrg # We need to do some special things here, and not later.
7653 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7654 1.1 mrg case " $predeps $postdeps " in
7655 1.1 mrg *" $deplib "*)
7656 1.1 mrg if func_lalib_p "$lib"; then
7657 1.1 mrg library_names=
7658 1.1 mrg old_library=
7659 1.1 mrg func_source "$lib"
7660 1.1 mrg for l in $old_library $library_names; do
7661 1.1 mrg ll=$l
7662 1.1 mrg done
7663 1.1 mrg if test "X$ll" = "X$old_library"; then # only static version available
7664 1.1 mrg found=false
7665 1.1 mrg func_dirname "$lib" "" "."
7666 1.1 mrg ladir=$func_dirname_result
7667 1.1 mrg lib=$ladir/$old_library
7668 1.1 mrg if test prog,link = "$linkmode,$pass"; then
7669 1.1 mrg compile_deplibs="$deplib $compile_deplibs"
7670 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs"
7671 1.1 mrg else
7672 1.1 mrg deplibs="$deplib $deplibs"
7673 1.1 mrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7674 1.1 mrg fi
7675 1.1 mrg continue
7676 1.1 mrg fi
7677 1.1 mrg fi
7678 1.1 mrg ;;
7679 1.1 mrg *) ;;
7680 1.1 mrg esac
7681 1.1 mrg fi
7682 1.1 mrg else
7683 1.1 mrg # deplib doesn't seem to be a libtool library
7684 1.1 mrg if test prog,link = "$linkmode,$pass"; then
7685 1.1 mrg compile_deplibs="$deplib $compile_deplibs"
7686 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs"
7687 1.1 mrg else
7688 1.1 mrg deplibs="$deplib $deplibs"
7689 1.1 mrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7690 1.1 mrg fi
7691 1.1 mrg continue
7692 1.1 mrg fi
7693 1.1 mrg ;; # -l
7694 1.1 mrg *.ltframework)
7695 1.1 mrg if test prog,link = "$linkmode,$pass"; then
7696 1.1 mrg compile_deplibs="$deplib $compile_deplibs"
7697 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs"
7698 1.1 mrg else
7699 1.1 mrg deplibs="$deplib $deplibs"
7700 1.1 mrg if test lib = "$linkmode"; then
7701 1.1 mrg case "$new_inherited_linker_flags " in
7702 1.1 mrg *" $deplib "*) ;;
7703 1.1 mrg * ) func_append new_inherited_linker_flags " $deplib" ;;
7704 1.1 mrg esac
7705 1.1 mrg fi
7706 1.1 mrg fi
7707 1.1 mrg continue
7708 1.1 mrg ;;
7709 1.1 mrg -L*)
7710 1.1 mrg case $linkmode in
7711 1.1 mrg lib)
7712 1.1 mrg deplibs="$deplib $deplibs"
7713 1.1 mrg test conv = "$pass" && continue
7714 1.1 mrg newdependency_libs="$deplib $newdependency_libs"
7715 1.1 mrg func_stripname '-L' '' "$deplib"
7716 1.1 mrg func_resolve_sysroot "$func_stripname_result"
7717 1.1 mrg func_append newlib_search_path " $func_resolve_sysroot_result"
7718 1.1 mrg ;;
7719 1.1 mrg prog)
7720 1.1 mrg if test conv = "$pass"; then
7721 1.1 mrg deplibs="$deplib $deplibs"
7722 1.1 mrg continue
7723 1.1 mrg fi
7724 1.1 mrg if test scan = "$pass"; then
7725 1.1 mrg deplibs="$deplib $deplibs"
7726 1.1 mrg else
7727 1.1 mrg compile_deplibs="$deplib $compile_deplibs"
7728 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs"
7729 1.1 mrg fi
7730 1.1 mrg func_stripname '-L' '' "$deplib"
7731 1.1 mrg func_resolve_sysroot "$func_stripname_result"
7732 1.1 mrg func_append newlib_search_path " $func_resolve_sysroot_result"
7733 1.1 mrg ;;
7734 1.1 mrg *)
7735 1.1 mrg func_warning "'-L' is ignored for archives/objects"
7736 1.1 mrg ;;
7737 1.1 mrg esac # linkmode
7738 1.1 mrg continue
7739 1.1 mrg ;; # -L
7740 1.1 mrg -R*)
7741 1.1 mrg if test link = "$pass"; then
7742 1.1 mrg func_stripname '-R' '' "$deplib"
7743 1.1 mrg func_resolve_sysroot "$func_stripname_result"
7744 1.1 mrg dir=$func_resolve_sysroot_result
7745 1.1 mrg # Make sure the xrpath contains only unique directories.
7746 1.1 mrg case "$xrpath " in
7747 1.1 mrg *" $dir "*) ;;
7748 1.1 mrg *) func_append xrpath " $dir" ;;
7749 1.1 mrg esac
7750 1.1 mrg fi
7751 1.1 mrg deplibs="$deplib $deplibs"
7752 1.1 mrg continue
7753 1.1 mrg ;;
7754 1.1 mrg *.la)
7755 1.1 mrg func_resolve_sysroot "$deplib"
7756 1.1 mrg lib=$func_resolve_sysroot_result
7757 1.1 mrg ;;
7758 1.1 mrg *.$libext)
7759 1.1 mrg if test conv = "$pass"; then
7760 1.1 mrg deplibs="$deplib $deplibs"
7761 1.1 mrg continue
7762 1.1 mrg fi
7763 1.1 mrg case $linkmode in
7764 1.1 mrg lib)
7765 1.1 mrg # Linking convenience modules into shared libraries is allowed,
7766 1.1 mrg # but linking other static libraries is non-portable.
7767 1.1 mrg case " $dlpreconveniencelibs " in
7768 1.1 mrg *" $deplib "*) ;;
7769 1.1 mrg *)
7770 1.1 mrg valid_a_lib=false
7771 1.1 mrg case $deplibs_check_method in
7772 1.1 mrg match_pattern*)
7773 1.1 mrg set dummy $deplibs_check_method; shift
7774 1.1 mrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7775 1.1 mrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7776 1.1 mrg | $EGREP "$match_pattern_regex" > /dev/null; then
7777 1.1 mrg valid_a_lib=:
7778 1.1 mrg fi
7779 1.1 mrg ;;
7780 1.1 mrg pass_all)
7781 1.1 mrg valid_a_lib=:
7782 1.1 mrg ;;
7783 1.1 mrg esac
7784 1.1 mrg if $valid_a_lib; then
7785 1.1 mrg echo
7786 1.1 mrg $ECHO "*** Warning: Linking the shared library $output against the"
7787 1.1 mrg $ECHO "*** static library $deplib is not portable!"
7788 1.1 mrg deplibs="$deplib $deplibs"
7789 1.1 mrg else
7790 1.1 mrg echo
7791 1.1 mrg $ECHO "*** Warning: Trying to link with static lib archive $deplib."
7792 1.1 mrg echo "*** I have the capability to make that library automatically link in when"
7793 1.1 mrg echo "*** you link to this library. But I can only do this if you have a"
7794 1.1 mrg echo "*** shared version of the library, which you do not appear to have"
7795 1.1 mrg echo "*** because the file extensions .$libext of this argument makes me believe"
7796 1.1 mrg echo "*** that it is just a static archive that I should not use here."
7797 1.1 mrg fi
7798 1.1 mrg ;;
7799 1.1 mrg esac
7800 1.1 mrg continue
7801 1.1 mrg ;;
7802 1.1 mrg prog)
7803 1.1 mrg if test link != "$pass"; then
7804 1.1 mrg deplibs="$deplib $deplibs"
7805 1.1 mrg else
7806 1.1 mrg compile_deplibs="$deplib $compile_deplibs"
7807 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs"
7808 1.1 mrg fi
7809 1.1 mrg continue
7810 1.1 mrg ;;
7811 1.1 mrg esac # linkmode
7812 1.1 mrg ;; # *.$libext
7813 1.1 mrg *.lo | *.$objext)
7814 1.1 mrg if test conv = "$pass"; then
7815 1.1 mrg deplibs="$deplib $deplibs"
7816 1.1 mrg elif test prog = "$linkmode"; then
7817 1.1 mrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7818 1.1 mrg # If there is no dlopen support or we're linking statically,
7819 1.1 mrg # we need to preload.
7820 1.1 mrg func_append newdlprefiles " $deplib"
7821 1.1 mrg compile_deplibs="$deplib $compile_deplibs"
7822 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs"
7823 1.1 mrg else
7824 1.1 mrg func_append newdlfiles " $deplib"
7825 1.1 mrg fi
7826 1.1 mrg fi
7827 1.1 mrg continue
7828 1.1 mrg ;;
7829 1.1 mrg %DEPLIBS%)
7830 1.1 mrg alldeplibs=:
7831 1.1 mrg continue
7832 1.1 mrg ;;
7833 1.1 mrg esac # case $deplib
7834 1.1 mrg
7835 1.1 mrg $found || test -f "$lib" \
7836 1.1 mrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7837 1.1 mrg
7838 1.1 mrg # Check to see that this really is a libtool archive.
7839 1.1 mrg func_lalib_unsafe_p "$lib" \
7840 1.1 mrg || func_fatal_error "'$lib' is not a valid libtool archive"
7841 1.1 mrg
7842 1.1 mrg func_dirname "$lib" "" "."
7843 1.1 mrg ladir=$func_dirname_result
7844 1.1 mrg
7845 1.1 mrg dlname=
7846 1.1 mrg dlopen=
7847 1.1 mrg dlpreopen=
7848 1.1 mrg libdir=
7849 1.1 mrg library_names=
7850 1.1 mrg old_library=
7851 1.1 mrg inherited_linker_flags=
7852 1.1 mrg # If the library was installed with an old release of libtool,
7853 1.1 mrg # it will not redefine variables installed, or shouldnotlink
7854 1.1 mrg installed=yes
7855 1.1 mrg shouldnotlink=no
7856 1.1 mrg avoidtemprpath=
7857 1.1 mrg
7858 1.1 mrg
7859 1.1 mrg # Read the .la file
7860 1.1 mrg func_source "$lib"
7861 1.1 mrg
7862 1.1 mrg # Convert "-framework foo" to "foo.ltframework"
7863 1.1 mrg if test -n "$inherited_linker_flags"; then
7864 1.1 mrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7865 1.1 mrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7866 1.1 mrg case " $new_inherited_linker_flags " in
7867 1.1 mrg *" $tmp_inherited_linker_flag "*) ;;
7868 1.1 mrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7869 1.1 mrg esac
7870 1.1 mrg done
7871 1.1 mrg fi
7872 1.1 mrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7873 1.1 mrg if test lib,link = "$linkmode,$pass" ||
7874 1.1 mrg test prog,scan = "$linkmode,$pass" ||
7875 1.1 mrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7876 1.1 mrg test -n "$dlopen" && func_append dlfiles " $dlopen"
7877 1.1 mrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7878 1.1 mrg fi
7879 1.1 mrg
7880 1.1 mrg if test conv = "$pass"; then
7881 1.1 mrg # Only check for convenience libraries
7882 1.1 mrg deplibs="$lib $deplibs"
7883 1.1 mrg if test -z "$libdir"; then
7884 1.1 mrg if test -z "$old_library"; then
7885 1.1 mrg func_fatal_error "cannot find name of link library for '$lib'"
7886 1.1 mrg fi
7887 1.1 mrg # It is a libtool convenience library, so add in its objects.
7888 1.1 mrg func_append convenience " $ladir/$objdir/$old_library"
7889 1.1 mrg func_append old_convenience " $ladir/$objdir/$old_library"
7890 1.1 mrg elif test prog != "$linkmode" && test lib != "$linkmode"; then
7891 1.1 mrg func_fatal_error "'$lib' is not a convenience library"
7892 1.1 mrg fi
7893 1.1 mrg tmp_libs=
7894 1.1 mrg for deplib in $dependency_libs; do
7895 1.1 mrg deplibs="$deplib $deplibs"
7896 1.1 mrg if $opt_preserve_dup_deps; then
7897 1.1 mrg case "$tmp_libs " in
7898 1.1 mrg *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7899 1.1 mrg esac
7900 1.1 mrg fi
7901 1.1 mrg func_append tmp_libs " $deplib"
7902 1.1 mrg done
7903 1.1 mrg continue
7904 1.1 mrg fi # $pass = conv
7905 1.1 mrg
7906 1.1 mrg
7907 1.1 mrg # Get the name of the library we link against.
7908 1.1 mrg linklib=
7909 1.1 mrg if test -n "$old_library" &&
7910 1.1 mrg { test yes = "$prefer_static_libs" ||
7911 1.1 mrg test built,no = "$prefer_static_libs,$installed"; }; then
7912 1.1 mrg linklib=$old_library
7913 1.1 mrg else
7914 1.1 mrg for l in $old_library $library_names; do
7915 1.1 mrg linklib=$l
7916 1.1 mrg done
7917 1.1 mrg fi
7918 1.1 mrg if test -z "$linklib"; then
7919 1.1 mrg func_fatal_error "cannot find name of link library for '$lib'"
7920 1.1 mrg fi
7921 1.1 mrg
7922 1.1 mrg # This library was specified with -dlopen.
7923 1.1 mrg if test dlopen = "$pass"; then
7924 1.1 mrg test -z "$libdir" \
7925 1.1 mrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7926 1.1 mrg if test -z "$dlname" ||
7927 1.1 mrg test yes != "$dlopen_support" ||
7928 1.1 mrg test no = "$build_libtool_libs"
7929 1.1 mrg then
7930 1.1 mrg # If there is no dlname, no dlopen support or we're linking
7931 1.1 mrg # statically, we need to preload. We also need to preload any
7932 1.1 mrg # dependent libraries so libltdl's deplib preloader doesn't
7933 1.1 mrg # bomb out in the load deplibs phase.
7934 1.1 mrg func_append dlprefiles " $lib $dependency_libs"
7935 1.1 mrg else
7936 1.1 mrg func_append newdlfiles " $lib"
7937 1.1 mrg fi
7938 1.1 mrg continue
7939 1.1 mrg fi # $pass = dlopen
7940 1.1 mrg
7941 1.1 mrg # We need an absolute path.
7942 1.1 mrg case $ladir in
7943 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7944 1.1 mrg *)
7945 1.1 mrg abs_ladir=`cd "$ladir" && pwd`
7946 1.1 mrg if test -z "$abs_ladir"; then
7947 1.1 mrg func_warning "cannot determine absolute directory name of '$ladir'"
7948 1.1 mrg func_warning "passing it literally to the linker, although it might fail"
7949 1.1 mrg abs_ladir=$ladir
7950 1.1 mrg fi
7951 1.1 mrg ;;
7952 1.1 mrg esac
7953 1.1 mrg func_basename "$lib"
7954 1.1 mrg laname=$func_basename_result
7955 1.1 mrg
7956 1.1 mrg # Find the relevant object directory and library name.
7957 1.1 mrg if test yes = "$installed"; then
7958 1.1 mrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7959 1.1 mrg func_warning "library '$lib' was moved."
7960 1.1 mrg dir=$ladir
7961 1.1 mrg absdir=$abs_ladir
7962 1.1 mrg libdir=$abs_ladir
7963 1.1 mrg else
7964 1.1 mrg dir=$lt_sysroot$libdir
7965 1.1 mrg absdir=$lt_sysroot$libdir
7966 1.1 mrg fi
7967 1.1 mrg test yes = "$hardcode_automatic" && avoidtemprpath=yes
7968 1.1 mrg else
7969 1.1 mrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7970 1.1 mrg dir=$ladir
7971 1.1 mrg absdir=$abs_ladir
7972 1.1 mrg # Remove this search path later
7973 1.1 mrg func_append notinst_path " $abs_ladir"
7974 1.1 mrg else
7975 1.1 mrg dir=$ladir/$objdir
7976 1.1 mrg absdir=$abs_ladir/$objdir
7977 1.1 mrg # Remove this search path later
7978 1.1 mrg func_append notinst_path " $abs_ladir"
7979 1.1 mrg fi
7980 1.1 mrg fi # $installed = yes
7981 1.1 mrg func_stripname 'lib' '.la' "$laname"
7982 1.1 mrg name=$func_stripname_result
7983 1.1 mrg
7984 1.1 mrg # This library was specified with -dlpreopen.
7985 1.1 mrg if test dlpreopen = "$pass"; then
7986 1.1 mrg if test -z "$libdir" && test prog = "$linkmode"; then
7987 1.1 mrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7988 1.1 mrg fi
7989 1.1 mrg case $host in
7990 1.1 mrg # special handling for platforms with PE-DLLs.
7991 1.1 mrg *cygwin* | *mingw* | *cegcc* )
7992 1.1 mrg # Linker will automatically link against shared library if both
7993 1.1 mrg # static and shared are present. Therefore, ensure we extract
7994 1.1 mrg # symbols from the import library if a shared library is present
7995 1.1 mrg # (otherwise, the dlopen module name will be incorrect). We do
7996 1.1 mrg # this by putting the import library name into $newdlprefiles.
7997 1.1 mrg # We recover the dlopen module name by 'saving' the la file
7998 1.1 mrg # name in a special purpose variable, and (later) extracting the
7999 1.1 mrg # dlname from the la file.
8000 1.1 mrg if test -n "$dlname"; then
8001 1.1 mrg func_tr_sh "$dir/$linklib"
8002 1.1 mrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8003 1.1 mrg func_append newdlprefiles " $dir/$linklib"
8004 1.1 mrg else
8005 1.1 mrg func_append newdlprefiles " $dir/$old_library"
8006 1.1 mrg # Keep a list of preopened convenience libraries to check
8007 1.1 mrg # that they are being used correctly in the link pass.
8008 1.1 mrg test -z "$libdir" && \
8009 1.1 mrg func_append dlpreconveniencelibs " $dir/$old_library"
8010 1.1 mrg fi
8011 1.1 mrg ;;
8012 1.1 mrg * )
8013 1.1 mrg # Prefer using a static library (so that no silly _DYNAMIC symbols
8014 1.1 mrg # are required to link).
8015 1.1 mrg if test -n "$old_library"; then
8016 1.1 mrg func_append newdlprefiles " $dir/$old_library"
8017 1.1 mrg # Keep a list of preopened convenience libraries to check
8018 1.1 mrg # that they are being used correctly in the link pass.
8019 1.1 mrg test -z "$libdir" && \
8020 1.1 mrg func_append dlpreconveniencelibs " $dir/$old_library"
8021 1.1 mrg # Otherwise, use the dlname, so that lt_dlopen finds it.
8022 1.1 mrg elif test -n "$dlname"; then
8023 1.1 mrg func_append newdlprefiles " $dir/$dlname"
8024 1.1 mrg else
8025 1.1 mrg func_append newdlprefiles " $dir/$linklib"
8026 1.1 mrg fi
8027 1.1 mrg ;;
8028 1.1 mrg esac
8029 1.1 mrg fi # $pass = dlpreopen
8030 1.1 mrg
8031 1.1 mrg if test -z "$libdir"; then
8032 1.1 mrg # Link the convenience library
8033 1.1 mrg if test lib = "$linkmode"; then
8034 1.1 mrg deplibs="$dir/$old_library $deplibs"
8035 1.1 mrg elif test prog,link = "$linkmode,$pass"; then
8036 1.1 mrg compile_deplibs="$dir/$old_library $compile_deplibs"
8037 1.1 mrg finalize_deplibs="$dir/$old_library $finalize_deplibs"
8038 1.1 mrg else
8039 1.1 mrg deplibs="$lib $deplibs" # used for prog,scan pass
8040 1.1 mrg fi
8041 1.1 mrg continue
8042 1.1 mrg fi
8043 1.1 mrg
8044 1.1 mrg
8045 1.1 mrg if test prog = "$linkmode" && test link != "$pass"; then
8046 1.1 mrg func_append newlib_search_path " $ladir"
8047 1.1 mrg deplibs="$lib $deplibs"
8048 1.1 mrg
8049 1.1 mrg linkalldeplibs=false
8050 1.1 mrg if test no != "$link_all_deplibs" || test -z "$library_names" ||
8051 1.1 mrg test no = "$build_libtool_libs"; then
8052 1.1 mrg linkalldeplibs=:
8053 1.1 mrg fi
8054 1.1 mrg
8055 1.1 mrg tmp_libs=
8056 1.1 mrg for deplib in $dependency_libs; do
8057 1.1 mrg case $deplib in
8058 1.1 mrg -L*) func_stripname '-L' '' "$deplib"
8059 1.1 mrg func_resolve_sysroot "$func_stripname_result"
8060 1.1 mrg func_append newlib_search_path " $func_resolve_sysroot_result"
8061 1.1 mrg ;;
8062 1.1 mrg esac
8063 1.1 mrg # Need to link against all dependency_libs?
8064 1.1 mrg if $linkalldeplibs; then
8065 1.1 mrg deplibs="$deplib $deplibs"
8066 1.1 mrg else
8067 1.1 mrg # Need to hardcode shared library paths
8068 1.1 mrg # or/and link against static libraries
8069 1.1 mrg newdependency_libs="$deplib $newdependency_libs"
8070 1.1 mrg fi
8071 1.1 mrg if $opt_preserve_dup_deps; then
8072 1.1 mrg case "$tmp_libs " in
8073 1.1 mrg *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8074 1.1 mrg esac
8075 1.1 mrg fi
8076 1.1 mrg func_append tmp_libs " $deplib"
8077 1.1 mrg done # for deplib
8078 1.1 mrg continue
8079 1.1 mrg fi # $linkmode = prog...
8080 1.1 mrg
8081 1.1 mrg if test prog,link = "$linkmode,$pass"; then
8082 1.1 mrg if test -n "$library_names" &&
8083 1.1 mrg { { test no = "$prefer_static_libs" ||
8084 1.1 mrg test built,yes = "$prefer_static_libs,$installed"; } ||
8085 1.1 mrg test -z "$old_library"; }; then
8086 1.1 mrg # We need to hardcode the library path
8087 1.1 mrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8088 1.1 mrg # Make sure the rpath contains only unique directories.
8089 1.1 mrg case $temp_rpath: in
8090 1.1 mrg *"$absdir:"*) ;;
8091 1.1 mrg *) func_append temp_rpath "$absdir:" ;;
8092 1.1 mrg esac
8093 1.1 mrg fi
8094 1.1 mrg
8095 1.1 mrg # Hardcode the library path.
8096 1.1 mrg # Skip directories that are in the system default run-time
8097 1.1 mrg # search path.
8098 1.1 mrg case " $sys_lib_dlsearch_path " in
8099 1.1 mrg *" $absdir "*) ;;
8100 1.1 mrg *)
8101 1.1 mrg case "$compile_rpath " in
8102 1.1 mrg *" $absdir "*) ;;
8103 1.1 mrg *) func_append compile_rpath " $absdir" ;;
8104 1.1 mrg esac
8105 1.1 mrg ;;
8106 1.1 mrg esac
8107 1.1 mrg case " $sys_lib_dlsearch_path " in
8108 1.1 mrg *" $libdir "*) ;;
8109 1.1 mrg *)
8110 1.1 mrg case "$finalize_rpath " in
8111 1.1 mrg *" $libdir "*) ;;
8112 1.1 mrg *) func_append finalize_rpath " $libdir" ;;
8113 1.1 mrg esac
8114 1.1 mrg ;;
8115 1.1 mrg esac
8116 1.1 mrg fi # $linkmode,$pass = prog,link...
8117 1.1 mrg
8118 1.1 mrg if $alldeplibs &&
8119 1.1 mrg { test pass_all = "$deplibs_check_method" ||
8120 1.1 mrg { test yes = "$build_libtool_libs" &&
8121 1.1 mrg test -n "$library_names"; }; }; then
8122 1.1 mrg # We only need to search for static libraries
8123 1.1 mrg continue
8124 1.1 mrg fi
8125 1.1 mrg fi
8126 1.1 mrg
8127 1.1 mrg link_static=no # Whether the deplib will be linked statically
8128 1.1 mrg use_static_libs=$prefer_static_libs
8129 1.1 mrg if test built = "$use_static_libs" && test yes = "$installed"; then
8130 1.1 mrg use_static_libs=no
8131 1.1 mrg fi
8132 1.1 mrg if test -n "$library_names" &&
8133 1.1 mrg { test no = "$use_static_libs" || test -z "$old_library"; }; then
8134 1.1 mrg case $host in
8135 1.1 mrg *cygwin* | *mingw* | *cegcc* | *os2*)
8136 1.1 mrg # No point in relinking DLLs because paths are not encoded
8137 1.1 mrg func_append notinst_deplibs " $lib"
8138 1.1 mrg need_relink=no
8139 1.1 mrg ;;
8140 1.1 mrg *)
8141 1.1 mrg if test no = "$installed"; then
8142 1.1 mrg func_append notinst_deplibs " $lib"
8143 1.1 mrg need_relink=yes
8144 1.1 mrg fi
8145 1.1 mrg ;;
8146 1.1 mrg esac
8147 1.1 mrg # This is a shared library
8148 1.1 mrg
8149 1.1 mrg # Warn about portability, can't link against -module's on some
8150 1.1 mrg # systems (darwin). Don't bleat about dlopened modules though!
8151 1.1 mrg dlopenmodule=
8152 1.1 mrg for dlpremoduletest in $dlprefiles; do
8153 1.1 mrg if test "X$dlpremoduletest" = "X$lib"; then
8154 1.1 mrg dlopenmodule=$dlpremoduletest
8155 1.1 mrg break
8156 1.1 mrg fi
8157 1.1 mrg done
8158 1.1 mrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8159 1.1 mrg echo
8160 1.1 mrg if test prog = "$linkmode"; then
8161 1.1 mrg $ECHO "*** Warning: Linking the executable $output against the loadable module"
8162 1.1 mrg else
8163 1.1 mrg $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8164 1.1 mrg fi
8165 1.1 mrg $ECHO "*** $linklib is not portable!"
8166 1.1 mrg fi
8167 1.1 mrg if test lib = "$linkmode" &&
8168 1.1 mrg test yes = "$hardcode_into_libs"; then
8169 1.1 mrg # Hardcode the library path.
8170 1.1 mrg # Skip directories that are in the system default run-time
8171 1.1 mrg # search path.
8172 1.1 mrg case " $sys_lib_dlsearch_path " in
8173 1.1 mrg *" $absdir "*) ;;
8174 1.1 mrg *)
8175 1.1 mrg case "$compile_rpath " in
8176 1.1 mrg *" $absdir "*) ;;
8177 1.1 mrg *) func_append compile_rpath " $absdir" ;;
8178 1.1 mrg esac
8179 1.1 mrg ;;
8180 1.1 mrg esac
8181 1.1 mrg case " $sys_lib_dlsearch_path " in
8182 1.1 mrg *" $libdir "*) ;;
8183 1.1 mrg *)
8184 1.1 mrg case "$finalize_rpath " in
8185 1.1 mrg *" $libdir "*) ;;
8186 1.1 mrg *) func_append finalize_rpath " $libdir" ;;
8187 1.1 mrg esac
8188 1.1 mrg ;;
8189 1.1 mrg esac
8190 1.1 mrg fi
8191 1.1 mrg
8192 1.1 mrg if test -n "$old_archive_from_expsyms_cmds"; then
8193 1.1 mrg # figure out the soname
8194 1.1 mrg set dummy $library_names
8195 1.1 mrg shift
8196 1.1 mrg realname=$1
8197 1.1 mrg shift
8198 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""`
8199 1.1 mrg # use dlname if we got it. it's perfectly good, no?
8200 1.1 mrg if test -n "$dlname"; then
8201 1.1 mrg soname=$dlname
8202 1.1 mrg elif test -n "$soname_spec"; then
8203 1.1 mrg # bleh windows
8204 1.1 mrg case $host in
8205 1.1 mrg *cygwin* | mingw* | *cegcc* | *os2*)
8206 1.1 mrg func_arith $current - $age
8207 1.1 mrg major=$func_arith_result
8208 1.1 mrg versuffix=-$major
8209 1.1 mrg ;;
8210 1.1 mrg esac
8211 1.1 mrg eval soname=\"$soname_spec\"
8212 1.1 mrg else
8213 1.1 mrg soname=$realname
8214 1.1 mrg fi
8215 1.1 mrg
8216 1.1 mrg # Make a new name for the extract_expsyms_cmds to use
8217 1.1 mrg soroot=$soname
8218 1.1 mrg func_basename "$soroot"
8219 1.1 mrg soname=$func_basename_result
8220 1.1 mrg func_stripname 'lib' '.dll' "$soname"
8221 1.1 mrg newlib=libimp-$func_stripname_result.a
8222 1.1 mrg
8223 1.1 mrg # If the library has no export list, then create one now
8224 1.1 mrg if test -f "$output_objdir/$soname-def"; then :
8225 1.1 mrg else
8226 1.1 mrg func_verbose "extracting exported symbol list from '$soname'"
8227 1.1 mrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8228 1.1 mrg fi
8229 1.1 mrg
8230 1.1 mrg # Create $newlib
8231 1.1 mrg if test -f "$output_objdir/$newlib"; then :; else
8232 1.1 mrg func_verbose "generating import library for '$soname'"
8233 1.1 mrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8234 1.1 mrg fi
8235 1.1 mrg # make sure the library variables are pointing to the new library
8236 1.1 mrg dir=$output_objdir
8237 1.1 mrg linklib=$newlib
8238 1.1 mrg fi # test -n "$old_archive_from_expsyms_cmds"
8239 1.1 mrg
8240 1.1 mrg if test prog = "$linkmode" || test relink != "$opt_mode"; then
8241 1.1 mrg add_shlibpath=
8242 1.1 mrg add_dir=
8243 1.1 mrg add=
8244 1.1 mrg lib_linked=yes
8245 1.1 mrg case $hardcode_action in
8246 1.1 mrg immediate | unsupported)
8247 1.1 mrg if test no = "$hardcode_direct"; then
8248 1.1 mrg add=$dir/$linklib
8249 1.1 mrg case $host in
8250 1.1 mrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8251 1.1 mrg *-*-sysv4*uw2*) add_dir=-L$dir ;;
8252 1.1 mrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8253 1.1 mrg *-*-unixware7*) add_dir=-L$dir ;;
8254 1.1 mrg *-*-darwin* )
8255 1.1 mrg # if the lib is a (non-dlopened) module then we cannot
8256 1.1 mrg # link against it, someone is ignoring the earlier warnings
8257 1.1 mrg if /usr/bin/file -L $add 2> /dev/null |
8258 1.1 mrg $GREP ": [^:]* bundle" >/dev/null; then
8259 1.1 mrg if test "X$dlopenmodule" != "X$lib"; then
8260 1.1 mrg $ECHO "*** Warning: lib $linklib is a module, not a shared library"
8261 1.1 mrg if test -z "$old_library"; then
8262 1.1 mrg echo
8263 1.1 mrg echo "*** And there doesn't seem to be a static archive available"
8264 1.1 mrg echo "*** The link will probably fail, sorry"
8265 1.1 mrg else
8266 1.1 mrg add=$dir/$old_library
8267 1.1 mrg fi
8268 1.1 mrg elif test -n "$old_library"; then
8269 1.1 mrg add=$dir/$old_library
8270 1.1 mrg fi
8271 1.1 mrg fi
8272 1.1 mrg esac
8273 1.1 mrg elif test no = "$hardcode_minus_L"; then
8274 1.1 mrg case $host in
8275 1.1 mrg *-*-sunos*) add_shlibpath=$dir ;;
8276 1.1 mrg esac
8277 1.1 mrg add_dir=-L$dir
8278 1.1 mrg add=-l$name
8279 1.1 mrg elif test no = "$hardcode_shlibpath_var"; then
8280 1.1 mrg add_shlibpath=$dir
8281 1.1 mrg add=-l$name
8282 1.1 mrg else
8283 1.1 mrg lib_linked=no
8284 1.1 mrg fi
8285 1.1 mrg ;;
8286 1.1 mrg relink)
8287 1.1 mrg if test yes = "$hardcode_direct" &&
8288 1.1 mrg test no = "$hardcode_direct_absolute"; then
8289 1.1 mrg add=$dir/$linklib
8290 1.1 mrg elif test yes = "$hardcode_minus_L"; then
8291 1.1 mrg add_dir=-L$absdir
8292 1.1 mrg # Try looking first in the location we're being installed to.
8293 1.1 mrg if test -n "$inst_prefix_dir"; then
8294 1.1 mrg case $libdir in
8295 1.1 mrg [\\/]*)
8296 1.1 mrg func_append add_dir " -L$inst_prefix_dir$libdir"
8297 1.1 mrg ;;
8298 1.1 mrg esac
8299 1.1 mrg fi
8300 1.1 mrg add=-l$name
8301 1.1 mrg elif test yes = "$hardcode_shlibpath_var"; then
8302 1.1 mrg add_shlibpath=$dir
8303 1.1 mrg add=-l$name
8304 1.1 mrg else
8305 1.1 mrg lib_linked=no
8306 1.1 mrg fi
8307 1.1 mrg ;;
8308 1.1 mrg *) lib_linked=no ;;
8309 1.1 mrg esac
8310 1.1 mrg
8311 1.1 mrg if test yes != "$lib_linked"; then
8312 1.1 mrg func_fatal_configuration "unsupported hardcode properties"
8313 1.1 mrg fi
8314 1.1 mrg
8315 1.1 mrg if test -n "$add_shlibpath"; then
8316 1.1 mrg case :$compile_shlibpath: in
8317 1.1 mrg *":$add_shlibpath:"*) ;;
8318 1.1 mrg *) func_append compile_shlibpath "$add_shlibpath:" ;;
8319 1.1 mrg esac
8320 1.1 mrg fi
8321 1.1 mrg if test prog = "$linkmode"; then
8322 1.1 mrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8323 1.1 mrg test -n "$add" && compile_deplibs="$add $compile_deplibs"
8324 1.1 mrg else
8325 1.1 mrg test -n "$add_dir" && deplibs="$add_dir $deplibs"
8326 1.1 mrg test -n "$add" && deplibs="$add $deplibs"
8327 1.1 mrg if test yes != "$hardcode_direct" &&
8328 1.1 mrg test yes != "$hardcode_minus_L" &&
8329 1.1 mrg test yes = "$hardcode_shlibpath_var"; then
8330 1.1 mrg case :$finalize_shlibpath: in
8331 1.1 mrg *":$libdir:"*) ;;
8332 1.1 mrg *) func_append finalize_shlibpath "$libdir:" ;;
8333 1.1 mrg esac
8334 1.1 mrg fi
8335 1.1 mrg fi
8336 1.1 mrg fi
8337 1.1 mrg
8338 1.1 mrg if test prog = "$linkmode" || test relink = "$opt_mode"; then
8339 1.1 mrg add_shlibpath=
8340 1.1 mrg add_dir=
8341 1.1 mrg add=
8342 1.1 mrg # Finalize command for both is simple: just hardcode it.
8343 1.1 mrg if test yes = "$hardcode_direct" &&
8344 1.1 mrg test no = "$hardcode_direct_absolute"; then
8345 1.1 mrg add=$libdir/$linklib
8346 1.1 mrg elif test yes = "$hardcode_minus_L"; then
8347 1.1 mrg add_dir=-L$libdir
8348 1.1 mrg add=-l$name
8349 1.1 mrg elif test yes = "$hardcode_shlibpath_var"; then
8350 1.1 mrg case :$finalize_shlibpath: in
8351 1.1 mrg *":$libdir:"*) ;;
8352 1.1 mrg *) func_append finalize_shlibpath "$libdir:" ;;
8353 1.1 mrg esac
8354 1.1 mrg add=-l$name
8355 1.1 mrg elif test yes = "$hardcode_automatic"; then
8356 1.1 mrg if test -n "$inst_prefix_dir" &&
8357 1.1 mrg test -f "$inst_prefix_dir$libdir/$linklib"; then
8358 1.1 mrg add=$inst_prefix_dir$libdir/$linklib
8359 1.1 mrg else
8360 1.1 mrg add=$libdir/$linklib
8361 1.1 mrg fi
8362 1.1 mrg else
8363 1.1 mrg # We cannot seem to hardcode it, guess we'll fake it.
8364 1.1 mrg add_dir=-L$libdir
8365 1.1 mrg # Try looking first in the location we're being installed to.
8366 1.1 mrg if test -n "$inst_prefix_dir"; then
8367 1.1 mrg case $libdir in
8368 1.1 mrg [\\/]*)
8369 1.1 mrg func_append add_dir " -L$inst_prefix_dir$libdir"
8370 1.1 mrg ;;
8371 1.1 mrg esac
8372 1.1 mrg fi
8373 1.1 mrg add=-l$name
8374 1.1 mrg fi
8375 1.1 mrg
8376 1.1 mrg if test prog = "$linkmode"; then
8377 1.1 mrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8378 1.1 mrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8379 1.1 mrg else
8380 1.1 mrg test -n "$add_dir" && deplibs="$add_dir $deplibs"
8381 1.1 mrg test -n "$add" && deplibs="$add $deplibs"
8382 1.1 mrg fi
8383 1.1 mrg fi
8384 1.1 mrg elif test prog = "$linkmode"; then
8385 1.1 mrg # Here we assume that one of hardcode_direct or hardcode_minus_L
8386 1.1 mrg # is not unsupported. This is valid on all known static and
8387 1.1 mrg # shared platforms.
8388 1.1 mrg if test unsupported != "$hardcode_direct"; then
8389 1.1 mrg test -n "$old_library" && linklib=$old_library
8390 1.1 mrg compile_deplibs="$dir/$linklib $compile_deplibs"
8391 1.1 mrg finalize_deplibs="$dir/$linklib $finalize_deplibs"
8392 1.1 mrg else
8393 1.1 mrg compile_deplibs="-l$name -L$dir $compile_deplibs"
8394 1.1 mrg finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8395 1.1 mrg fi
8396 1.1 mrg elif test yes = "$build_libtool_libs"; then
8397 1.1 mrg # Not a shared library
8398 1.1 mrg if test pass_all != "$deplibs_check_method"; then
8399 1.1 mrg # We're trying link a shared library against a static one
8400 1.1 mrg # but the system doesn't support it.
8401 1.1 mrg
8402 1.1 mrg # Just print a warning and add the library to dependency_libs so
8403 1.1 mrg # that the program can be linked against the static library.
8404 1.1 mrg echo
8405 1.1 mrg $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8406 1.1 mrg echo "*** I have the capability to make that library automatically link in when"
8407 1.1 mrg echo "*** you link to this library. But I can only do this if you have a"
8408 1.1 mrg echo "*** shared version of the library, which you do not appear to have."
8409 1.1 mrg if test yes = "$module"; then
8410 1.1 mrg echo "*** But as you try to build a module library, libtool will still create "
8411 1.1 mrg echo "*** a static module, that should work as long as the dlopening application"
8412 1.1 mrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8413 1.1 mrg if test -z "$global_symbol_pipe"; then
8414 1.1 mrg echo
8415 1.1 mrg echo "*** However, this would only work if libtool was able to extract symbol"
8416 1.1 mrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8417 1.1 mrg echo "*** not find such a program. So, this module is probably useless."
8418 1.1 mrg echo "*** 'nm' from GNU binutils and a full rebuild may help."
8419 1.1 mrg fi
8420 1.1 mrg if test no = "$build_old_libs"; then
8421 1.1 mrg build_libtool_libs=module
8422 1.1 mrg build_old_libs=yes
8423 1.1 mrg else
8424 1.1 mrg build_libtool_libs=no
8425 1.1 mrg fi
8426 1.1 mrg fi
8427 1.1 mrg else
8428 1.1 mrg deplibs="$dir/$old_library $deplibs"
8429 1.1 mrg link_static=yes
8430 1.1 mrg fi
8431 1.1 mrg fi # link shared/static library?
8432 1.1 mrg
8433 1.1 mrg if test lib = "$linkmode"; then
8434 1.1 mrg if test -n "$dependency_libs" &&
8435 1.1 mrg { test yes != "$hardcode_into_libs" ||
8436 1.1 mrg test yes = "$build_old_libs" ||
8437 1.1 mrg test yes = "$link_static"; }; then
8438 1.1 mrg # Extract -R from dependency_libs
8439 1.1 mrg temp_deplibs=
8440 1.1 mrg for libdir in $dependency_libs; do
8441 1.1 mrg case $libdir in
8442 1.1 mrg -R*) func_stripname '-R' '' "$libdir"
8443 1.1 mrg temp_xrpath=$func_stripname_result
8444 1.1 mrg case " $xrpath " in
8445 1.1 mrg *" $temp_xrpath "*) ;;
8446 1.1 mrg *) func_append xrpath " $temp_xrpath";;
8447 1.1 mrg esac;;
8448 1.1 mrg *) func_append temp_deplibs " $libdir";;
8449 1.1 mrg esac
8450 1.1 mrg done
8451 1.1 mrg dependency_libs=$temp_deplibs
8452 1.1 mrg fi
8453 1.1 mrg
8454 1.1 mrg func_append newlib_search_path " $absdir"
8455 1.1 mrg # Link against this library
8456 1.1 mrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8457 1.1 mrg # ... and its dependency_libs
8458 1.1 mrg tmp_libs=
8459 1.1 mrg for deplib in $dependency_libs; do
8460 1.1 mrg newdependency_libs="$deplib $newdependency_libs"
8461 1.1 mrg case $deplib in
8462 1.1 mrg -L*) func_stripname '-L' '' "$deplib"
8463 1.1 mrg func_resolve_sysroot "$func_stripname_result";;
8464 1.1 mrg *) func_resolve_sysroot "$deplib" ;;
8465 1.1 mrg esac
8466 1.1 mrg if $opt_preserve_dup_deps; then
8467 1.1 mrg case "$tmp_libs " in
8468 1.1 mrg *" $func_resolve_sysroot_result "*)
8469 1.1 mrg func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8470 1.1 mrg esac
8471 1.1 mrg fi
8472 1.1 mrg func_append tmp_libs " $func_resolve_sysroot_result"
8473 1.1 mrg done
8474 1.1 mrg
8475 1.1 mrg if test no != "$link_all_deplibs"; then
8476 1.1 mrg # Add the search paths of all dependency libraries
8477 1.1 mrg for deplib in $dependency_libs; do
8478 1.1 mrg path=
8479 1.1 mrg case $deplib in
8480 1.1 mrg -L*) path=$deplib ;;
8481 1.1 mrg *.la)
8482 1.1 mrg func_resolve_sysroot "$deplib"
8483 1.1 mrg deplib=$func_resolve_sysroot_result
8484 1.1 mrg func_dirname "$deplib" "" "."
8485 1.1 mrg dir=$func_dirname_result
8486 1.1 mrg # We need an absolute path.
8487 1.1 mrg case $dir in
8488 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8489 1.1 mrg *)
8490 1.1 mrg absdir=`cd "$dir" && pwd`
8491 1.1 mrg if test -z "$absdir"; then
8492 1.1 mrg func_warning "cannot determine absolute directory name of '$dir'"
8493 1.1 mrg absdir=$dir
8494 1.1 mrg fi
8495 1.1 mrg ;;
8496 1.1 mrg esac
8497 1.1 mrg if $GREP "^installed=no" $deplib > /dev/null; then
8498 1.1 mrg case $host in
8499 1.1 mrg *-*-darwin*)
8500 1.1 mrg depdepl=
8501 1.1 mrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8502 1.1 mrg if test -n "$deplibrary_names"; then
8503 1.1 mrg for tmp in $deplibrary_names; do
8504 1.1 mrg depdepl=$tmp
8505 1.1 mrg done
8506 1.1 mrg if test -f "$absdir/$objdir/$depdepl"; then
8507 1.1 mrg depdepl=$absdir/$objdir/$depdepl
8508 1.1 mrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8509 1.1 mrg if test -z "$darwin_install_name"; then
8510 1.1 mrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8511 1.1 mrg fi
8512 1.1 mrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8513 1.1 mrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8514 1.1 mrg path=
8515 1.1 mrg fi
8516 1.1 mrg fi
8517 1.1 mrg ;;
8518 1.1 mrg *)
8519 1.1 mrg path=-L$absdir/$objdir
8520 1.1 mrg ;;
8521 1.1 mrg esac
8522 1.1 mrg else
8523 1.1 mrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8524 1.1 mrg test -z "$libdir" && \
8525 1.1 mrg func_fatal_error "'$deplib' is not a valid libtool archive"
8526 1.1 mrg test "$absdir" != "$libdir" && \
8527 1.1 mrg func_warning "'$deplib' seems to be moved"
8528 1.1 mrg
8529 1.1 mrg path=-L$absdir
8530 1.1 mrg fi
8531 1.1 mrg ;;
8532 1.1 mrg esac
8533 1.1 mrg case " $deplibs " in
8534 1.1 mrg *" $path "*) ;;
8535 1.1 mrg *) deplibs="$path $deplibs" ;;
8536 1.1 mrg esac
8537 1.1 mrg done
8538 1.1 mrg fi # link_all_deplibs != no
8539 1.1 mrg fi # linkmode = lib
8540 1.1 mrg done # for deplib in $libs
8541 1.1 mrg if test link = "$pass"; then
8542 1.1 mrg if test prog = "$linkmode"; then
8543 1.1 mrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8544 1.1 mrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8545 1.1 mrg else
8546 1.1 mrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8547 1.1 mrg fi
8548 1.1 mrg fi
8549 1.1 mrg dependency_libs=$newdependency_libs
8550 1.1 mrg if test dlpreopen = "$pass"; then
8551 1.1 mrg # Link the dlpreopened libraries before other libraries
8552 1.1 mrg for deplib in $save_deplibs; do
8553 1.1 mrg deplibs="$deplib $deplibs"
8554 1.1 mrg done
8555 1.1 mrg fi
8556 1.1 mrg if test dlopen != "$pass"; then
8557 1.1 mrg test conv = "$pass" || {
8558 1.1 mrg # Make sure lib_search_path contains only unique directories.
8559 1.1 mrg lib_search_path=
8560 1.1 mrg for dir in $newlib_search_path; do
8561 1.1 mrg case "$lib_search_path " in
8562 1.1 mrg *" $dir "*) ;;
8563 1.1 mrg *) func_append lib_search_path " $dir" ;;
8564 1.1 mrg esac
8565 1.1 mrg done
8566 1.1 mrg newlib_search_path=
8567 1.1 mrg }
8568 1.1 mrg
8569 1.1 mrg if test prog,link = "$linkmode,$pass"; then
8570 1.1 mrg vars="compile_deplibs finalize_deplibs"
8571 1.1 mrg else
8572 1.1 mrg vars=deplibs
8573 1.1 mrg fi
8574 1.1 mrg for var in $vars dependency_libs; do
8575 1.1 mrg # Add libraries to $var in reverse order
8576 1.1 mrg eval tmp_libs=\"\$$var\"
8577 1.1 mrg new_libs=
8578 1.1 mrg for deplib in $tmp_libs; do
8579 1.1 mrg # FIXME: Pedantically, this is the right thing to do, so
8580 1.1 mrg # that some nasty dependency loop isn't accidentally
8581 1.1 mrg # broken:
8582 1.1 mrg #new_libs="$deplib $new_libs"
8583 1.1 mrg # Pragmatically, this seems to cause very few problems in
8584 1.1 mrg # practice:
8585 1.1 mrg case $deplib in
8586 1.1 mrg -L*) new_libs="$deplib $new_libs" ;;
8587 1.1 mrg -R*) ;;
8588 1.1 mrg *)
8589 1.1 mrg # And here is the reason: when a library appears more
8590 1.1 mrg # than once as an explicit dependence of a library, or
8591 1.1 mrg # is implicitly linked in more than once by the
8592 1.1 mrg # compiler, it is considered special, and multiple
8593 1.1 mrg # occurrences thereof are not removed. Compare this
8594 1.1 mrg # with having the same library being listed as a
8595 1.1 mrg # dependency of multiple other libraries: in this case,
8596 1.1 mrg # we know (pedantically, we assume) the library does not
8597 1.1 mrg # need to be listed more than once, so we keep only the
8598 1.1 mrg # last copy. This is not always right, but it is rare
8599 1.1 mrg # enough that we require users that really mean to play
8600 1.1 mrg # such unportable linking tricks to link the library
8601 1.1 mrg # using -Wl,-lname, so that libtool does not consider it
8602 1.1 mrg # for duplicate removal.
8603 1.1 mrg case " $specialdeplibs " in
8604 1.1 mrg *" $deplib "*) new_libs="$deplib $new_libs" ;;
8605 1.1 mrg *)
8606 1.1 mrg case " $new_libs " in
8607 1.1 mrg *" $deplib "*) ;;
8608 1.1 mrg *) new_libs="$deplib $new_libs" ;;
8609 1.1 mrg esac
8610 1.1 mrg ;;
8611 1.1 mrg esac
8612 1.1 mrg ;;
8613 1.1 mrg esac
8614 1.1 mrg done
8615 1.1 mrg tmp_libs=
8616 1.1 mrg for deplib in $new_libs; do
8617 1.1 mrg case $deplib in
8618 1.1 mrg -L*)
8619 1.1 mrg case " $tmp_libs " in
8620 1.1 mrg *" $deplib "*) ;;
8621 1.1 mrg *) func_append tmp_libs " $deplib" ;;
8622 1.1 mrg esac
8623 1.1 mrg ;;
8624 1.1 mrg *) func_append tmp_libs " $deplib" ;;
8625 1.1 mrg esac
8626 1.1 mrg done
8627 1.1 mrg eval $var=\"$tmp_libs\"
8628 1.1 mrg done # for var
8629 1.1 mrg fi
8630 1.1 mrg
8631 1.1 mrg # Add Sun CC postdeps if required:
8632 1.1 mrg test CXX = "$tagname" && {
8633 1.1 mrg case $host_os in
8634 1.1 mrg linux*)
8635 1.1 mrg case `$CC -V 2>&1 | sed 5q` in
8636 1.1 mrg *Sun\ C*) # Sun C++ 5.9
8637 1.1 mrg func_suncc_cstd_abi
8638 1.1 mrg
8639 1.1 mrg if test no != "$suncc_use_cstd_abi"; then
8640 1.1 mrg func_append postdeps ' -library=Cstd -library=Crun'
8641 1.1 mrg fi
8642 1.1 mrg ;;
8643 1.1 mrg esac
8644 1.1 mrg ;;
8645 1.1 mrg
8646 1.1 mrg solaris*)
8647 1.1 mrg func_cc_basename "$CC"
8648 1.1 mrg case $func_cc_basename_result in
8649 1.1 mrg CC* | sunCC*)
8650 1.1 mrg func_suncc_cstd_abi
8651 1.1 mrg
8652 1.1 mrg if test no != "$suncc_use_cstd_abi"; then
8653 1.1 mrg func_append postdeps ' -library=Cstd -library=Crun'
8654 1.1 mrg fi
8655 1.1 mrg ;;
8656 1.1 mrg esac
8657 1.1 mrg ;;
8658 1.1 mrg esac
8659 1.1 mrg }
8660 1.1 mrg
8661 1.1 mrg # Last step: remove runtime libs from dependency_libs
8662 1.1 mrg # (they stay in deplibs)
8663 1.1 mrg tmp_libs=
8664 1.1 mrg for i in $dependency_libs; do
8665 1.1 mrg case " $predeps $postdeps $compiler_lib_search_path " in
8666 1.1 mrg *" $i "*)
8667 1.1 mrg i=
8668 1.1 mrg ;;
8669 1.1 mrg esac
8670 1.1 mrg if test -n "$i"; then
8671 1.1 mrg func_append tmp_libs " $i"
8672 1.1 mrg fi
8673 1.1 mrg done
8674 1.1 mrg dependency_libs=$tmp_libs
8675 1.1 mrg done # for pass
8676 1.1 mrg if test prog = "$linkmode"; then
8677 1.1 mrg dlfiles=$newdlfiles
8678 1.1 mrg fi
8679 1.1 mrg if test prog = "$linkmode" || test lib = "$linkmode"; then
8680 1.1 mrg dlprefiles=$newdlprefiles
8681 1.1 mrg fi
8682 1.1 mrg
8683 1.1 mrg case $linkmode in
8684 1.1 mrg oldlib)
8685 1.1 mrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8686 1.1 mrg func_warning "'-dlopen' is ignored for archives"
8687 1.1 mrg fi
8688 1.1 mrg
8689 1.1 mrg case " $deplibs" in
8690 1.1 mrg *\ -l* | *\ -L*)
8691 1.1 mrg func_warning "'-l' and '-L' are ignored for archives" ;;
8692 1.1 mrg esac
8693 1.1 mrg
8694 1.1 mrg test -n "$rpath" && \
8695 1.1 mrg func_warning "'-rpath' is ignored for archives"
8696 1.1 mrg
8697 1.1 mrg test -n "$xrpath" && \
8698 1.1 mrg func_warning "'-R' is ignored for archives"
8699 1.1 mrg
8700 1.1 mrg test -n "$vinfo" && \
8701 1.1 mrg func_warning "'-version-info/-version-number' is ignored for archives"
8702 1.1 mrg
8703 1.1 mrg test -n "$release" && \
8704 1.1 mrg func_warning "'-release' is ignored for archives"
8705 1.1 mrg
8706 1.1 mrg test -n "$export_symbols$export_symbols_regex" && \
8707 1.1 mrg func_warning "'-export-symbols' is ignored for archives"
8708 1.1 mrg
8709 1.1 mrg # Now set the variables for building old libraries.
8710 1.1 mrg build_libtool_libs=no
8711 1.1 mrg oldlibs=$output
8712 1.1 mrg func_append objs "$old_deplibs"
8713 1.1 mrg ;;
8714 1.1 mrg
8715 1.1 mrg lib)
8716 1.1 mrg # Make sure we only generate libraries of the form 'libNAME.la'.
8717 1.1 mrg case $outputname in
8718 1.1 mrg lib*)
8719 1.1 mrg func_stripname 'lib' '.la' "$outputname"
8720 1.1 mrg name=$func_stripname_result
8721 1.1 mrg eval shared_ext=\"$shrext_cmds\"
8722 1.1 mrg eval libname=\"$libname_spec\"
8723 1.1 mrg ;;
8724 1.1 mrg *)
8725 1.1 mrg test no = "$module" \
8726 1.1 mrg && func_fatal_help "libtool library '$output' must begin with 'lib'"
8727 1.1 mrg
8728 1.1 mrg if test no != "$need_lib_prefix"; then
8729 1.1 mrg # Add the "lib" prefix for modules if required
8730 1.1 mrg func_stripname '' '.la' "$outputname"
8731 1.1 mrg name=$func_stripname_result
8732 1.1 mrg eval shared_ext=\"$shrext_cmds\"
8733 1.1 mrg eval libname=\"$libname_spec\"
8734 1.1 mrg else
8735 1.1 mrg func_stripname '' '.la' "$outputname"
8736 1.1 mrg libname=$func_stripname_result
8737 1.1 mrg fi
8738 1.1 mrg ;;
8739 1.1 mrg esac
8740 1.1 mrg
8741 1.1 mrg if test -n "$objs"; then
8742 1.1 mrg if test pass_all != "$deplibs_check_method"; then
8743 1.1 mrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8744 1.1 mrg else
8745 1.1 mrg echo
8746 1.1 mrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8747 1.1 mrg $ECHO "*** objects $objs is not portable!"
8748 1.1 mrg func_append libobjs " $objs"
8749 1.1 mrg fi
8750 1.1 mrg fi
8751 1.1 mrg
8752 1.1 mrg test no = "$dlself" \
8753 1.1 mrg || func_warning "'-dlopen self' is ignored for libtool libraries"
8754 1.1 mrg
8755 1.1 mrg set dummy $rpath
8756 1.1 mrg shift
8757 1.1 mrg test 1 -lt "$#" \
8758 1.1 mrg && func_warning "ignoring multiple '-rpath's for a libtool library"
8759 1.1 mrg
8760 1.1 mrg install_libdir=$1
8761 1.1 mrg
8762 1.1 mrg oldlibs=
8763 1.1 mrg if test -z "$rpath"; then
8764 1.1 mrg if test yes = "$build_libtool_libs"; then
8765 1.1 mrg # Building a libtool convenience library.
8766 1.1 mrg # Some compilers have problems with a '.al' extension so
8767 1.1 mrg # convenience libraries should have the same extension an
8768 1.1 mrg # archive normally would.
8769 1.1 mrg oldlibs="$output_objdir/$libname.$libext $oldlibs"
8770 1.1 mrg build_libtool_libs=convenience
8771 1.1 mrg build_old_libs=yes
8772 1.1 mrg fi
8773 1.1 mrg
8774 1.1 mrg test -n "$vinfo" && \
8775 1.1 mrg func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8776 1.1 mrg
8777 1.1 mrg test -n "$release" && \
8778 1.1 mrg func_warning "'-release' is ignored for convenience libraries"
8779 1.1 mrg else
8780 1.1 mrg
8781 1.1 mrg # Parse the version information argument.
8782 1.1 mrg save_ifs=$IFS; IFS=:
8783 1.1 mrg set dummy $vinfo 0 0 0
8784 1.1 mrg shift
8785 1.1 mrg IFS=$save_ifs
8786 1.1 mrg
8787 1.1 mrg test -n "$7" && \
8788 1.1 mrg func_fatal_help "too many parameters to '-version-info'"
8789 1.1 mrg
8790 1.1 mrg # convert absolute version numbers to libtool ages
8791 1.1 mrg # this retains compatibility with .la files and attempts
8792 1.1 mrg # to make the code below a bit more comprehensible
8793 1.1 mrg
8794 1.1 mrg case $vinfo_number in
8795 1.1 mrg yes)
8796 1.1 mrg number_major=$1
8797 1.1 mrg number_minor=$2
8798 1.1 mrg number_revision=$3
8799 1.1 mrg #
8800 1.1 mrg # There are really only two kinds -- those that
8801 1.1 mrg # use the current revision as the major version
8802 1.1 mrg # and those that subtract age and use age as
8803 1.1 mrg # a minor version. But, then there is irix
8804 1.1 mrg # that has an extra 1 added just for fun
8805 1.1 mrg #
8806 1.1 mrg case $version_type in
8807 1.1 mrg # correct linux to gnu/linux during the next big refactor
8808 1.1 mrg darwin|freebsd-elf|linux|osf|windows|none)
8809 1.1 mrg func_arith $number_major + $number_minor
8810 1.1 mrg current=$func_arith_result
8811 1.1 mrg age=$number_minor
8812 1.1 mrg revision=$number_revision
8813 1.1 mrg ;;
8814 1.1 mrg freebsd-aout|qnx|sunos)
8815 1.1 mrg current=$number_major
8816 1.1 mrg revision=$number_minor
8817 1.1 mrg age=0
8818 1.1 mrg ;;
8819 1.1 mrg irix|nonstopux)
8820 1.1 mrg func_arith $number_major + $number_minor
8821 1.1 mrg current=$func_arith_result
8822 1.1 mrg age=$number_minor
8823 1.1 mrg revision=$number_minor
8824 1.1 mrg lt_irix_increment=no
8825 1.1 mrg ;;
8826 1.1 mrg esac
8827 1.1 mrg ;;
8828 1.1 mrg no)
8829 1.1 mrg current=$1
8830 1.1 mrg revision=$2
8831 1.1 mrg age=$3
8832 1.1 mrg ;;
8833 1.1 mrg esac
8834 1.1 mrg
8835 1.1 mrg # Check that each of the things are valid numbers.
8836 1.1 mrg case $current in
8837 1.1 mrg 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]) ;;
8838 1.1 mrg *)
8839 1.1 mrg func_error "CURRENT '$current' must be a nonnegative integer"
8840 1.1 mrg func_fatal_error "'$vinfo' is not valid version information"
8841 1.1 mrg ;;
8842 1.1 mrg esac
8843 1.1 mrg
8844 1.1 mrg case $revision in
8845 1.1 mrg 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]) ;;
8846 1.1 mrg *)
8847 1.1 mrg func_error "REVISION '$revision' must be a nonnegative integer"
8848 1.1 mrg func_fatal_error "'$vinfo' is not valid version information"
8849 1.1 mrg ;;
8850 1.1 mrg esac
8851 1.1 mrg
8852 1.1 mrg case $age in
8853 1.1 mrg 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]) ;;
8854 1.1 mrg *)
8855 1.1 mrg func_error "AGE '$age' must be a nonnegative integer"
8856 1.1 mrg func_fatal_error "'$vinfo' is not valid version information"
8857 1.1 mrg ;;
8858 1.1 mrg esac
8859 1.1 mrg
8860 1.1 mrg if test "$age" -gt "$current"; then
8861 1.1 mrg func_error "AGE '$age' is greater than the current interface number '$current'"
8862 1.1 mrg func_fatal_error "'$vinfo' is not valid version information"
8863 1.1 mrg fi
8864 1.1 mrg
8865 1.1 mrg # Calculate the version variables.
8866 1.1 mrg major=
8867 1.1 mrg versuffix=
8868 1.1 mrg verstring=
8869 1.1 mrg case $version_type in
8870 1.1 mrg none) ;;
8871 1.1 mrg
8872 1.1 mrg darwin)
8873 1.1 mrg # Like Linux, but with the current version available in
8874 1.1 mrg # verstring for coding it into the library header
8875 1.1 mrg func_arith $current - $age
8876 1.1 mrg major=.$func_arith_result
8877 1.1 mrg versuffix=$major.$age.$revision
8878 1.1 mrg # Darwin ld doesn't like 0 for these options...
8879 1.1 mrg func_arith $current + 1
8880 1.1 mrg minor_current=$func_arith_result
8881 1.1 mrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8882 1.1 mrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8883 1.1 mrg # On Darwin other compilers
8884 1.1 mrg case $CC in
8885 1.1 mrg nagfor*)
8886 1.1 mrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8887 1.1 mrg ;;
8888 1.1 mrg *)
8889 1.1 mrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8890 1.1 mrg ;;
8891 1.1 mrg esac
8892 1.1 mrg ;;
8893 1.1 mrg
8894 1.1 mrg freebsd-aout)
8895 1.1 mrg major=.$current
8896 1.1 mrg versuffix=.$current.$revision
8897 1.1 mrg ;;
8898 1.1 mrg
8899 1.1 mrg freebsd-elf)
8900 1.1 mrg func_arith $current - $age
8901 1.1 mrg major=.$func_arith_result
8902 1.1 mrg versuffix=$major.$age.$revision
8903 1.1 mrg ;;
8904 1.1 mrg
8905 1.1 mrg irix | nonstopux)
8906 1.1 mrg if test no = "$lt_irix_increment"; then
8907 1.1 mrg func_arith $current - $age
8908 1.1 mrg else
8909 1.1 mrg func_arith $current - $age + 1
8910 1.1 mrg fi
8911 1.1 mrg major=$func_arith_result
8912 1.1 mrg
8913 1.1 mrg case $version_type in
8914 1.1 mrg nonstopux) verstring_prefix=nonstopux ;;
8915 1.1 mrg *) verstring_prefix=sgi ;;
8916 1.1 mrg esac
8917 1.1 mrg verstring=$verstring_prefix$major.$revision
8918 1.1 mrg
8919 1.1 mrg # Add in all the interfaces that we are compatible with.
8920 1.1 mrg loop=$revision
8921 1.1 mrg while test 0 -ne "$loop"; do
8922 1.1 mrg func_arith $revision - $loop
8923 1.1 mrg iface=$func_arith_result
8924 1.1 mrg func_arith $loop - 1
8925 1.1 mrg loop=$func_arith_result
8926 1.1 mrg verstring=$verstring_prefix$major.$iface:$verstring
8927 1.1 mrg done
8928 1.1 mrg
8929 1.1 mrg # Before this point, $major must not contain '.'.
8930 1.1 mrg major=.$major
8931 1.1 mrg versuffix=$major.$revision
8932 1.1 mrg ;;
8933 1.1 mrg
8934 1.1 mrg linux) # correct to gnu/linux during the next big refactor
8935 1.1 mrg func_arith $current - $age
8936 1.1 mrg major=.$func_arith_result
8937 1.1 mrg versuffix=$major.$age.$revision
8938 1.1 mrg ;;
8939 1.1 mrg
8940 1.1 mrg osf)
8941 1.1 mrg func_arith $current - $age
8942 1.1 mrg major=.$func_arith_result
8943 1.1 mrg versuffix=.$current.$age.$revision
8944 1.1 mrg verstring=$current.$age.$revision
8945 1.1 mrg
8946 1.1 mrg # Add in all the interfaces that we are compatible with.
8947 1.1 mrg loop=$age
8948 1.1 mrg while test 0 -ne "$loop"; do
8949 1.1 mrg func_arith $current - $loop
8950 1.1 mrg iface=$func_arith_result
8951 1.1 mrg func_arith $loop - 1
8952 1.1 mrg loop=$func_arith_result
8953 1.1 mrg verstring=$verstring:$iface.0
8954 1.1 mrg done
8955 1.1 mrg
8956 1.1 mrg # Make executables depend on our current version.
8957 1.1 mrg func_append verstring ":$current.0"
8958 1.1 mrg ;;
8959 1.1 mrg
8960 1.1 mrg qnx)
8961 1.1 mrg major=.$current
8962 1.1 mrg versuffix=.$current
8963 1.1 mrg ;;
8964 1.1 mrg
8965 1.1 mrg sco)
8966 1.1 mrg major=.$current
8967 1.1 mrg versuffix=.$current
8968 1.1 mrg ;;
8969 1.1 mrg
8970 1.1 mrg sunos)
8971 1.1 mrg major=.$current
8972 1.1 mrg versuffix=.$current.$revision
8973 1.1 mrg ;;
8974 1.1 mrg
8975 1.1 mrg windows)
8976 1.1 mrg # Use '-' rather than '.', since we only want one
8977 1.1 mrg # extension on DOS 8.3 file systems.
8978 1.1 mrg func_arith $current - $age
8979 1.1 mrg major=$func_arith_result
8980 1.1 mrg versuffix=-$major
8981 1.1 mrg ;;
8982 1.1 mrg
8983 1.1 mrg *)
8984 1.1 mrg func_fatal_configuration "unknown library version type '$version_type'"
8985 1.1 mrg ;;
8986 1.1 mrg esac
8987 1.1 mrg
8988 1.1 mrg # Clear the version info if we defaulted, and they specified a release.
8989 1.1 mrg if test -z "$vinfo" && test -n "$release"; then
8990 1.1 mrg major=
8991 1.1 mrg case $version_type in
8992 1.1 mrg darwin)
8993 1.1 mrg # we can't check for "0.0" in archive_cmds due to quoting
8994 1.1 mrg # problems, so we reset it completely
8995 1.1 mrg verstring=
8996 1.1 mrg ;;
8997 1.1 mrg *)
8998 1.1 mrg verstring=0.0
8999 1.1 mrg ;;
9000 1.1 mrg esac
9001 1.1 mrg if test no = "$need_version"; then
9002 1.1 mrg versuffix=
9003 1.1 mrg else
9004 1.1 mrg versuffix=.0.0
9005 1.1 mrg fi
9006 1.1 mrg fi
9007 1.1 mrg
9008 1.1 mrg # Remove version info from name if versioning should be avoided
9009 1.1 mrg if test yes,no = "$avoid_version,$need_version"; then
9010 1.1 mrg major=
9011 1.1 mrg versuffix=
9012 1.1 mrg verstring=
9013 1.1 mrg fi
9014 1.1 mrg
9015 1.1 mrg # Check to see if the archive will have undefined symbols.
9016 1.1 mrg if test yes = "$allow_undefined"; then
9017 1.1 mrg if test unsupported = "$allow_undefined_flag"; then
9018 1.1 mrg if test yes = "$build_old_libs"; then
9019 1.1 mrg func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9020 1.1 mrg build_libtool_libs=no
9021 1.1 mrg else
9022 1.1 mrg func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9023 1.1 mrg fi
9024 1.1 mrg fi
9025 1.1 mrg else
9026 1.1 mrg # Don't allow undefined symbols.
9027 1.1 mrg allow_undefined_flag=$no_undefined_flag
9028 1.1 mrg fi
9029 1.1 mrg
9030 1.1 mrg fi
9031 1.1 mrg
9032 1.1 mrg func_generate_dlsyms "$libname" "$libname" :
9033 1.1 mrg func_append libobjs " $symfileobj"
9034 1.1 mrg test " " = "$libobjs" && libobjs=
9035 1.1 mrg
9036 1.1 mrg if test relink != "$opt_mode"; then
9037 1.1 mrg # Remove our outputs, but don't remove object files since they
9038 1.1 mrg # may have been created when compiling PIC objects.
9039 1.1 mrg removelist=
9040 1.1 mrg tempremovelist=`$ECHO "$output_objdir/*"`
9041 1.1 mrg for p in $tempremovelist; do
9042 1.1 mrg case $p in
9043 1.1 mrg *.$objext | *.gcno)
9044 1.1 mrg ;;
9045 1.1 mrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9046 1.1 mrg if test -n "$precious_files_regex"; then
9047 1.1 mrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9048 1.1 mrg then
9049 1.1 mrg continue
9050 1.1 mrg fi
9051 1.1 mrg fi
9052 1.1 mrg func_append removelist " $p"
9053 1.1 mrg ;;
9054 1.1 mrg *) ;;
9055 1.1 mrg esac
9056 1.1 mrg done
9057 1.1 mrg test -n "$removelist" && \
9058 1.1 mrg func_show_eval "${RM}r \$removelist"
9059 1.1 mrg fi
9060 1.1 mrg
9061 1.1 mrg # Now set the variables for building old libraries.
9062 1.1 mrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9063 1.1 mrg func_append oldlibs " $output_objdir/$libname.$libext"
9064 1.1 mrg
9065 1.1 mrg # Transform .lo files to .o files.
9066 1.1 mrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9067 1.1 mrg fi
9068 1.1 mrg
9069 1.1 mrg # Eliminate all temporary directories.
9070 1.1 mrg #for path in $notinst_path; do
9071 1.1 mrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9072 1.1 mrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9073 1.1 mrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9074 1.1 mrg #done
9075 1.1 mrg
9076 1.1 mrg if test -n "$xrpath"; then
9077 1.1 mrg # If the user specified any rpath flags, then add them.
9078 1.1 mrg temp_xrpath=
9079 1.1 mrg for libdir in $xrpath; do
9080 1.1 mrg func_replace_sysroot "$libdir"
9081 1.1 mrg func_append temp_xrpath " -R$func_replace_sysroot_result"
9082 1.1 mrg case "$finalize_rpath " in
9083 1.1 mrg *" $libdir "*) ;;
9084 1.1 mrg *) func_append finalize_rpath " $libdir" ;;
9085 1.1 mrg esac
9086 1.1 mrg done
9087 1.1 mrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9088 1.1 mrg dependency_libs="$temp_xrpath $dependency_libs"
9089 1.1 mrg fi
9090 1.1 mrg fi
9091 1.1 mrg
9092 1.1 mrg # Make sure dlfiles contains only unique files that won't be dlpreopened
9093 1.1 mrg old_dlfiles=$dlfiles
9094 1.1 mrg dlfiles=
9095 1.1 mrg for lib in $old_dlfiles; do
9096 1.1 mrg case " $dlprefiles $dlfiles " in
9097 1.1 mrg *" $lib "*) ;;
9098 1.1 mrg *) func_append dlfiles " $lib" ;;
9099 1.1 mrg esac
9100 1.1 mrg done
9101 1.1 mrg
9102 1.1 mrg # Make sure dlprefiles contains only unique files
9103 1.1 mrg old_dlprefiles=$dlprefiles
9104 1.1 mrg dlprefiles=
9105 1.1 mrg for lib in $old_dlprefiles; do
9106 1.1 mrg case "$dlprefiles " in
9107 1.1 mrg *" $lib "*) ;;
9108 1.1 mrg *) func_append dlprefiles " $lib" ;;
9109 1.1 mrg esac
9110 1.1 mrg done
9111 1.1 mrg
9112 1.1 mrg if test yes = "$build_libtool_libs"; then
9113 1.1 mrg if test -n "$rpath"; then
9114 1.1 mrg case $host in
9115 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9116 1.1 mrg # these systems don't actually have a c library (as such)!
9117 1.1 mrg ;;
9118 1.1 mrg *-*-rhapsody* | *-*-darwin1.[012])
9119 1.1 mrg # Rhapsody C library is in the System framework
9120 1.1 mrg func_append deplibs " System.ltframework"
9121 1.1 mrg ;;
9122 1.1 mrg *-*-netbsd*)
9123 1.1 mrg # Don't link with libc until the a.out ld.so is fixed.
9124 1.1 mrg ;;
9125 1.1 mrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9126 1.1 mrg # Do not include libc due to us having libc/libc_r.
9127 1.1 mrg ;;
9128 1.1 mrg *-*-sco3.2v5* | *-*-sco5v6*)
9129 1.1 mrg # Causes problems with __ctype
9130 1.1 mrg ;;
9131 1.1 mrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9132 1.1 mrg # Compiler inserts libc in the correct place for threads to work
9133 1.1 mrg ;;
9134 1.1 mrg *)
9135 1.1 mrg # Add libc to deplibs on all other systems if necessary.
9136 1.1 mrg if test yes = "$build_libtool_need_lc"; then
9137 1.1 mrg func_append deplibs " -lc"
9138 1.1 mrg fi
9139 1.1 mrg ;;
9140 1.1 mrg esac
9141 1.1 mrg fi
9142 1.1 mrg
9143 1.1 mrg # Transform deplibs into only deplibs that can be linked in shared.
9144 1.1 mrg name_save=$name
9145 1.1 mrg libname_save=$libname
9146 1.1 mrg release_save=$release
9147 1.1 mrg versuffix_save=$versuffix
9148 1.1 mrg major_save=$major
9149 1.1 mrg # I'm not sure if I'm treating the release correctly. I think
9150 1.1 mrg # release should show up in the -l (ie -lgmp5) so we don't want to
9151 1.1 mrg # add it in twice. Is that correct?
9152 1.1 mrg release=
9153 1.1 mrg versuffix=
9154 1.1 mrg major=
9155 1.1 mrg newdeplibs=
9156 1.1 mrg droppeddeps=no
9157 1.1 mrg case $deplibs_check_method in
9158 1.1 mrg pass_all)
9159 1.1 mrg # Don't check for shared/static. Everything works.
9160 1.1 mrg # This might be a little naive. We might want to check
9161 1.1 mrg # whether the library exists or not. But this is on
9162 1.1 mrg # osf3 & osf4 and I'm not really sure... Just
9163 1.1 mrg # implementing what was already the behavior.
9164 1.1 mrg newdeplibs=$deplibs
9165 1.1 mrg ;;
9166 1.1 mrg test_compile)
9167 1.1 mrg # This code stresses the "libraries are programs" paradigm to its
9168 1.1 mrg # limits. Maybe even breaks it. We compile a program, linking it
9169 1.1 mrg # against the deplibs as a proxy for the library. Then we can check
9170 1.1 mrg # whether they linked in statically or dynamically with ldd.
9171 1.1 mrg $opt_dry_run || $RM conftest.c
9172 1.1 mrg cat > conftest.c <<EOF
9173 1.1 mrg int main() { return 0; }
9174 1.1 mrg EOF
9175 1.1 mrg $opt_dry_run || $RM conftest
9176 1.1 mrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9177 1.1 mrg ldd_output=`ldd conftest`
9178 1.1 mrg for i in $deplibs; do
9179 1.1 mrg case $i in
9180 1.1 mrg -l*)
9181 1.1 mrg func_stripname -l '' "$i"
9182 1.1 mrg name=$func_stripname_result
9183 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9184 1.1 mrg case " $predeps $postdeps " in
9185 1.1 mrg *" $i "*)
9186 1.1 mrg func_append newdeplibs " $i"
9187 1.1 mrg i=
9188 1.1 mrg ;;
9189 1.1 mrg esac
9190 1.1 mrg fi
9191 1.1 mrg if test -n "$i"; then
9192 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""`
9193 1.1 mrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9194 1.1 mrg set dummy $deplib_matches; shift
9195 1.1 mrg deplib_match=$1
9196 1.1 mrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9197 1.1 mrg func_append newdeplibs " $i"
9198 1.1 mrg else
9199 1.1 mrg droppeddeps=yes
9200 1.1 mrg echo
9201 1.1 mrg $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9202 1.1 mrg echo "*** I have the capability to make that library automatically link in when"
9203 1.1 mrg echo "*** you link to this library. But I can only do this if you have a"
9204 1.1 mrg echo "*** shared version of the library, which I believe you do not have"
9205 1.1 mrg echo "*** because a test_compile did reveal that the linker did not use it for"
9206 1.1 mrg echo "*** its dynamic dependency list that programs get resolved with at runtime."
9207 1.1 mrg fi
9208 1.1 mrg fi
9209 1.1 mrg ;;
9210 1.1 mrg *)
9211 1.1 mrg func_append newdeplibs " $i"
9212 1.1 mrg ;;
9213 1.1 mrg esac
9214 1.1 mrg done
9215 1.1 mrg else
9216 1.1 mrg # Error occurred in the first compile. Let's try to salvage
9217 1.1 mrg # the situation: Compile a separate program for each library.
9218 1.1 mrg for i in $deplibs; do
9219 1.1 mrg case $i in
9220 1.1 mrg -l*)
9221 1.1 mrg func_stripname -l '' "$i"
9222 1.1 mrg name=$func_stripname_result
9223 1.1 mrg $opt_dry_run || $RM conftest
9224 1.1 mrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9225 1.1 mrg ldd_output=`ldd conftest`
9226 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9227 1.1 mrg case " $predeps $postdeps " in
9228 1.1 mrg *" $i "*)
9229 1.1 mrg func_append newdeplibs " $i"
9230 1.1 mrg i=
9231 1.1 mrg ;;
9232 1.1 mrg esac
9233 1.1 mrg fi
9234 1.1 mrg if test -n "$i"; then
9235 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""`
9236 1.1 mrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9237 1.1 mrg set dummy $deplib_matches; shift
9238 1.1 mrg deplib_match=$1
9239 1.1 mrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9240 1.1 mrg func_append newdeplibs " $i"
9241 1.1 mrg else
9242 1.1 mrg droppeddeps=yes
9243 1.1 mrg echo
9244 1.1 mrg $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9245 1.1 mrg echo "*** I have the capability to make that library automatically link in when"
9246 1.1 mrg echo "*** you link to this library. But I can only do this if you have a"
9247 1.1 mrg echo "*** shared version of the library, which you do not appear to have"
9248 1.1 mrg echo "*** because a test_compile did reveal that the linker did not use this one"
9249 1.1 mrg echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9250 1.1 mrg fi
9251 1.1 mrg fi
9252 1.1 mrg else
9253 1.1 mrg droppeddeps=yes
9254 1.1 mrg echo
9255 1.1 mrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
9256 1.1 mrg echo "*** make it link in! You will probably need to install it or some"
9257 1.1 mrg echo "*** library that it depends on before this library will be fully"
9258 1.1 mrg echo "*** functional. Installing it before continuing would be even better."
9259 1.1 mrg fi
9260 1.1 mrg ;;
9261 1.1 mrg *)
9262 1.1 mrg func_append newdeplibs " $i"
9263 1.1 mrg ;;
9264 1.1 mrg esac
9265 1.1 mrg done
9266 1.1 mrg fi
9267 1.1 mrg ;;
9268 1.1 mrg file_magic*)
9269 1.1 mrg set dummy $deplibs_check_method; shift
9270 1.1 mrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9271 1.1 mrg for a_deplib in $deplibs; do
9272 1.1 mrg case $a_deplib in
9273 1.1 mrg -l*)
9274 1.1 mrg func_stripname -l '' "$a_deplib"
9275 1.1 mrg name=$func_stripname_result
9276 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9277 1.1 mrg case " $predeps $postdeps " in
9278 1.1 mrg *" $a_deplib "*)
9279 1.1 mrg func_append newdeplibs " $a_deplib"
9280 1.1 mrg a_deplib=
9281 1.1 mrg ;;
9282 1.1 mrg esac
9283 1.1 mrg fi
9284 1.1 mrg if test -n "$a_deplib"; then
9285 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""`
9286 1.1 mrg if test -n "$file_magic_glob"; then
9287 1.1 mrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9288 1.1 mrg else
9289 1.1 mrg libnameglob=$libname
9290 1.1 mrg fi
9291 1.1 mrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9292 1.1 mrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9293 1.1 mrg if test yes = "$want_nocaseglob"; then
9294 1.1 mrg shopt -s nocaseglob
9295 1.1 mrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9296 1.1 mrg $nocaseglob
9297 1.1 mrg else
9298 1.1 mrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9299 1.1 mrg fi
9300 1.1 mrg for potent_lib in $potential_libs; do
9301 1.1 mrg # Follow soft links.
9302 1.1 mrg if ls -lLd "$potent_lib" 2>/dev/null |
9303 1.1 mrg $GREP " -> " >/dev/null; then
9304 1.1 mrg continue
9305 1.1 mrg fi
9306 1.1 mrg # The statement above tries to avoid entering an
9307 1.1 mrg # endless loop below, in case of cyclic links.
9308 1.1 mrg # We might still enter an endless loop, since a link
9309 1.1 mrg # loop can be closed while we follow links,
9310 1.1 mrg # but so what?
9311 1.1 mrg potlib=$potent_lib
9312 1.1 mrg while test -h "$potlib" 2>/dev/null; do
9313 1.1 mrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9314 1.1 mrg case $potliblink in
9315 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9316 1.1 mrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9317 1.1 mrg esac
9318 1.1 mrg done
9319 1.1 mrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9320 1.1 mrg $SED -e 10q |
9321 1.1 mrg $EGREP "$file_magic_regex" > /dev/null; then
9322 1.1 mrg func_append newdeplibs " $a_deplib"
9323 1.1 mrg a_deplib=
9324 1.1 mrg break 2
9325 1.1 mrg fi
9326 1.1 mrg done
9327 1.1 mrg done
9328 1.1 mrg fi
9329 1.1 mrg if test -n "$a_deplib"; then
9330 1.1 mrg droppeddeps=yes
9331 1.1 mrg echo
9332 1.1 mrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9333 1.1 mrg echo "*** I have the capability to make that library automatically link in when"
9334 1.1 mrg echo "*** you link to this library. But I can only do this if you have a"
9335 1.1 mrg echo "*** shared version of the library, which you do not appear to have"
9336 1.1 mrg echo "*** because I did check the linker path looking for a file starting"
9337 1.1 mrg if test -z "$potlib"; then
9338 1.1 mrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9339 1.1 mrg else
9340 1.1 mrg $ECHO "*** with $libname and none of the candidates passed a file format test"
9341 1.1 mrg $ECHO "*** using a file magic. Last file checked: $potlib"
9342 1.1 mrg fi
9343 1.1 mrg fi
9344 1.1 mrg ;;
9345 1.1 mrg *)
9346 1.1 mrg # Add a -L argument.
9347 1.1 mrg func_append newdeplibs " $a_deplib"
9348 1.1 mrg ;;
9349 1.1 mrg esac
9350 1.1 mrg done # Gone through all deplibs.
9351 1.1 mrg ;;
9352 1.1 mrg match_pattern*)
9353 1.1 mrg set dummy $deplibs_check_method; shift
9354 1.1 mrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9355 1.1 mrg for a_deplib in $deplibs; do
9356 1.1 mrg case $a_deplib in
9357 1.1 mrg -l*)
9358 1.1 mrg func_stripname -l '' "$a_deplib"
9359 1.1 mrg name=$func_stripname_result
9360 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9361 1.1 mrg case " $predeps $postdeps " in
9362 1.1 mrg *" $a_deplib "*)
9363 1.1 mrg func_append newdeplibs " $a_deplib"
9364 1.1 mrg a_deplib=
9365 1.1 mrg ;;
9366 1.1 mrg esac
9367 1.1 mrg fi
9368 1.1 mrg if test -n "$a_deplib"; then
9369 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""`
9370 1.1 mrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9371 1.1 mrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9372 1.1 mrg for potent_lib in $potential_libs; do
9373 1.1 mrg potlib=$potent_lib # see symlink-check above in file_magic test
9374 1.1 mrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9375 1.1 mrg $EGREP "$match_pattern_regex" > /dev/null; then
9376 1.1 mrg func_append newdeplibs " $a_deplib"
9377 1.1 mrg a_deplib=
9378 1.1 mrg break 2
9379 1.1 mrg fi
9380 1.1 mrg done
9381 1.1 mrg done
9382 1.1 mrg fi
9383 1.1 mrg if test -n "$a_deplib"; then
9384 1.1 mrg droppeddeps=yes
9385 1.1 mrg echo
9386 1.1 mrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9387 1.1 mrg echo "*** I have the capability to make that library automatically link in when"
9388 1.1 mrg echo "*** you link to this library. But I can only do this if you have a"
9389 1.1 mrg echo "*** shared version of the library, which you do not appear to have"
9390 1.1 mrg echo "*** because I did check the linker path looking for a file starting"
9391 1.1 mrg if test -z "$potlib"; then
9392 1.1 mrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9393 1.1 mrg else
9394 1.1 mrg $ECHO "*** with $libname and none of the candidates passed a file format test"
9395 1.1 mrg $ECHO "*** using a regex pattern. Last file checked: $potlib"
9396 1.1 mrg fi
9397 1.1 mrg fi
9398 1.1 mrg ;;
9399 1.1 mrg *)
9400 1.1 mrg # Add a -L argument.
9401 1.1 mrg func_append newdeplibs " $a_deplib"
9402 1.1 mrg ;;
9403 1.1 mrg esac
9404 1.1 mrg done # Gone through all deplibs.
9405 1.1 mrg ;;
9406 1.1 mrg none | unknown | *)
9407 1.1 mrg newdeplibs=
9408 1.1 mrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9409 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9410 1.1 mrg for i in $predeps $postdeps; do
9411 1.1 mrg # can't use Xsed below, because $i might contain '/'
9412 1.1 mrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9413 1.1 mrg done
9414 1.1 mrg fi
9415 1.1 mrg case $tmp_deplibs in
9416 1.1 mrg *[!\ \ ]*)
9417 1.1 mrg echo
9418 1.1 mrg if test none = "$deplibs_check_method"; then
9419 1.1 mrg echo "*** Warning: inter-library dependencies are not supported in this platform."
9420 1.1 mrg else
9421 1.1 mrg echo "*** Warning: inter-library dependencies are not known to be supported."
9422 1.1 mrg fi
9423 1.1 mrg echo "*** All declared inter-library dependencies are being dropped."
9424 1.1 mrg droppeddeps=yes
9425 1.1 mrg ;;
9426 1.1 mrg esac
9427 1.1 mrg ;;
9428 1.1 mrg esac
9429 1.1 mrg versuffix=$versuffix_save
9430 1.1 mrg major=$major_save
9431 1.1 mrg release=$release_save
9432 1.1 mrg libname=$libname_save
9433 1.1 mrg name=$name_save
9434 1.1 mrg
9435 1.1 mrg case $host in
9436 1.1 mrg *-*-rhapsody* | *-*-darwin1.[012])
9437 1.1 mrg # On Rhapsody replace the C library with the System framework
9438 1.1 mrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9439 1.1 mrg ;;
9440 1.1 mrg esac
9441 1.1 mrg
9442 1.1 mrg if test yes = "$droppeddeps"; then
9443 1.1 mrg if test yes = "$module"; then
9444 1.1 mrg echo
9445 1.1 mrg echo "*** Warning: libtool could not satisfy all declared inter-library"
9446 1.1 mrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
9447 1.1 mrg echo "*** a static module, that should work as long as the dlopening"
9448 1.1 mrg echo "*** application is linked with the -dlopen flag."
9449 1.1 mrg if test -z "$global_symbol_pipe"; then
9450 1.1 mrg echo
9451 1.1 mrg echo "*** However, this would only work if libtool was able to extract symbol"
9452 1.1 mrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9453 1.1 mrg echo "*** not find such a program. So, this module is probably useless."
9454 1.1 mrg echo "*** 'nm' from GNU binutils and a full rebuild may help."
9455 1.1 mrg fi
9456 1.1 mrg if test no = "$build_old_libs"; then
9457 1.1 mrg oldlibs=$output_objdir/$libname.$libext
9458 1.1 mrg build_libtool_libs=module
9459 1.1 mrg build_old_libs=yes
9460 1.1 mrg else
9461 1.1 mrg build_libtool_libs=no
9462 1.1 mrg fi
9463 1.1 mrg else
9464 1.1 mrg echo "*** The inter-library dependencies that have been dropped here will be"
9465 1.1 mrg echo "*** automatically added whenever a program is linked with this library"
9466 1.1 mrg echo "*** or is declared to -dlopen it."
9467 1.1 mrg
9468 1.1 mrg if test no = "$allow_undefined"; then
9469 1.1 mrg echo
9470 1.1 mrg echo "*** Since this library must not contain undefined symbols,"
9471 1.1 mrg echo "*** because either the platform does not support them or"
9472 1.1 mrg echo "*** it was explicitly requested with -no-undefined,"
9473 1.1 mrg echo "*** libtool will only create a static version of it."
9474 1.1 mrg if test no = "$build_old_libs"; then
9475 1.1 mrg oldlibs=$output_objdir/$libname.$libext
9476 1.1 mrg build_libtool_libs=module
9477 1.1 mrg build_old_libs=yes
9478 1.1 mrg else
9479 1.1 mrg build_libtool_libs=no
9480 1.1 mrg fi
9481 1.1 mrg fi
9482 1.1 mrg fi
9483 1.1 mrg fi
9484 1.1 mrg # Done checking deplibs!
9485 1.1 mrg deplibs=$newdeplibs
9486 1.1 mrg fi
9487 1.1 mrg # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9488 1.1 mrg case $host in
9489 1.1 mrg *-*-darwin*)
9490 1.1 mrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9491 1.1 mrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9492 1.1 mrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9493 1.1 mrg ;;
9494 1.1 mrg esac
9495 1.1 mrg
9496 1.1 mrg # move library search paths that coincide with paths to not yet
9497 1.1 mrg # installed libraries to the beginning of the library search list
9498 1.1 mrg new_libs=
9499 1.1 mrg for path in $notinst_path; do
9500 1.1 mrg case " $new_libs " in
9501 1.1 mrg *" -L$path/$objdir "*) ;;
9502 1.1 mrg *)
9503 1.1 mrg case " $deplibs " in
9504 1.1 mrg *" -L$path/$objdir "*)
9505 1.1 mrg func_append new_libs " -L$path/$objdir" ;;
9506 1.1 mrg esac
9507 1.1 mrg ;;
9508 1.1 mrg esac
9509 1.1 mrg done
9510 1.1 mrg for deplib in $deplibs; do
9511 1.1 mrg case $deplib in
9512 1.1 mrg -L*)
9513 1.1 mrg case " $new_libs " in
9514 1.1 mrg *" $deplib "*) ;;
9515 1.1 mrg *) func_append new_libs " $deplib" ;;
9516 1.1 mrg esac
9517 1.1 mrg ;;
9518 1.1 mrg *) func_append new_libs " $deplib" ;;
9519 1.1 mrg esac
9520 1.1 mrg done
9521 1.1 mrg deplibs=$new_libs
9522 1.1 mrg
9523 1.1 mrg # All the library-specific variables (install_libdir is set above).
9524 1.1 mrg library_names=
9525 1.1 mrg old_library=
9526 1.1 mrg dlname=
9527 1.1 mrg
9528 1.1 mrg # Test again, we may have decided not to build it any more
9529 1.1 mrg if test yes = "$build_libtool_libs"; then
9530 1.1 mrg # Remove $wl instances when linking with ld.
9531 1.1 mrg # FIXME: should test the right _cmds variable.
9532 1.1 mrg case $archive_cmds in
9533 1.1 mrg *\$LD\ *) wl= ;;
9534 1.1 mrg esac
9535 1.1 mrg if test yes = "$hardcode_into_libs"; then
9536 1.1 mrg # Hardcode the library paths
9537 1.1 mrg hardcode_libdirs=
9538 1.1 mrg dep_rpath=
9539 1.1 mrg rpath=$finalize_rpath
9540 1.1 mrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9541 1.1 mrg for libdir in $rpath; do
9542 1.1 mrg if test -n "$hardcode_libdir_flag_spec"; then
9543 1.1 mrg if test -n "$hardcode_libdir_separator"; then
9544 1.1 mrg func_replace_sysroot "$libdir"
9545 1.1 mrg libdir=$func_replace_sysroot_result
9546 1.1 mrg if test -z "$hardcode_libdirs"; then
9547 1.1 mrg hardcode_libdirs=$libdir
9548 1.1 mrg else
9549 1.1 mrg # Just accumulate the unique libdirs.
9550 1.1 mrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9551 1.1 mrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9552 1.1 mrg ;;
9553 1.1 mrg *)
9554 1.1 mrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9555 1.1 mrg ;;
9556 1.1 mrg esac
9557 1.1 mrg fi
9558 1.1 mrg else
9559 1.1 mrg eval flag=\"$hardcode_libdir_flag_spec\"
9560 1.1 mrg func_append dep_rpath " $flag"
9561 1.1 mrg fi
9562 1.1 mrg elif test -n "$runpath_var"; then
9563 1.1 mrg case "$perm_rpath " in
9564 1.1 mrg *" $libdir "*) ;;
9565 1.1 mrg *) func_append perm_rpath " $libdir" ;;
9566 1.1 mrg esac
9567 1.1 mrg fi
9568 1.1 mrg done
9569 1.1 mrg # Substitute the hardcoded libdirs into the rpath.
9570 1.1 mrg if test -n "$hardcode_libdir_separator" &&
9571 1.1 mrg test -n "$hardcode_libdirs"; then
9572 1.1 mrg libdir=$hardcode_libdirs
9573 1.1 mrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9574 1.1 mrg fi
9575 1.1 mrg if test -n "$runpath_var" && test -n "$perm_rpath"; then
9576 1.1 mrg # We should set the runpath_var.
9577 1.1 mrg rpath=
9578 1.1 mrg for dir in $perm_rpath; do
9579 1.1 mrg func_append rpath "$dir:"
9580 1.1 mrg done
9581 1.1 mrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9582 1.1 mrg fi
9583 1.1 mrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9584 1.1 mrg fi
9585 1.1 mrg
9586 1.1 mrg shlibpath=$finalize_shlibpath
9587 1.1 mrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9588 1.1 mrg if test -n "$shlibpath"; then
9589 1.1 mrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9590 1.1 mrg fi
9591 1.1 mrg
9592 1.1 mrg # Get the real and link names of the library.
9593 1.1 mrg eval shared_ext=\"$shrext_cmds\"
9594 1.1 mrg eval library_names=\"$library_names_spec\"
9595 1.1 mrg set dummy $library_names
9596 1.1 mrg shift
9597 1.1 mrg realname=$1
9598 1.1 mrg shift
9599 1.1 mrg
9600 1.1 mrg if test -n "$soname_spec"; then
9601 1.1 mrg eval soname=\"$soname_spec\"
9602 1.1 mrg else
9603 1.1 mrg soname=$realname
9604 1.1 mrg fi
9605 1.1 mrg if test -z "$dlname"; then
9606 1.1 mrg dlname=$soname
9607 1.1 mrg fi
9608 1.1 mrg
9609 1.1 mrg lib=$output_objdir/$realname
9610 1.1 mrg linknames=
9611 1.1 mrg for link
9612 1.1 mrg do
9613 1.1 mrg func_append linknames " $link"
9614 1.1 mrg done
9615 1.1 mrg
9616 1.1 mrg # Use standard objects if they are pic
9617 1.1 mrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9618 1.1 mrg test "X$libobjs" = "X " && libobjs=
9619 1.1 mrg
9620 1.1 mrg delfiles=
9621 1.1 mrg if test -n "$export_symbols" && test -n "$include_expsyms"; then
9622 1.1 mrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9623 1.1 mrg export_symbols=$output_objdir/$libname.uexp
9624 1.1 mrg func_append delfiles " $export_symbols"
9625 1.1 mrg fi
9626 1.1 mrg
9627 1.1 mrg orig_export_symbols=
9628 1.1 mrg case $host_os in
9629 1.1 mrg cygwin* | mingw* | cegcc*)
9630 1.1 mrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9631 1.1 mrg # exporting using user supplied symfile
9632 1.1 mrg func_dll_def_p "$export_symbols" || {
9633 1.1 mrg # and it's NOT already a .def file. Must figure out
9634 1.1 mrg # which of the given symbols are data symbols and tag
9635 1.1 mrg # them as such. So, trigger use of export_symbols_cmds.
9636 1.1 mrg # export_symbols gets reassigned inside the "prepare
9637 1.1 mrg # the list of exported symbols" if statement, so the
9638 1.1 mrg # include_expsyms logic still works.
9639 1.1 mrg orig_export_symbols=$export_symbols
9640 1.1 mrg export_symbols=
9641 1.1 mrg always_export_symbols=yes
9642 1.1 mrg }
9643 1.1 mrg fi
9644 1.1 mrg ;;
9645 1.1 mrg esac
9646 1.1 mrg
9647 1.1 mrg # Prepare the list of exported symbols
9648 1.1 mrg if test -z "$export_symbols"; then
9649 1.1 mrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9650 1.1 mrg func_verbose "generating symbol list for '$libname.la'"
9651 1.1 mrg export_symbols=$output_objdir/$libname.exp
9652 1.1 mrg $opt_dry_run || $RM $export_symbols
9653 1.1 mrg cmds=$export_symbols_cmds
9654 1.1 mrg save_ifs=$IFS; IFS='~'
9655 1.1 mrg for cmd1 in $cmds; do
9656 1.1 mrg IFS=$save_ifs
9657 1.1 mrg # Take the normal branch if the nm_file_list_spec branch
9658 1.1 mrg # doesn't work or if tool conversion is not needed.
9659 1.1 mrg case $nm_file_list_spec~$to_tool_file_cmd in
9660 1.1 mrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9661 1.1 mrg try_normal_branch=yes
9662 1.1 mrg eval cmd=\"$cmd1\"
9663 1.1 mrg func_len " $cmd"
9664 1.1 mrg len=$func_len_result
9665 1.1 mrg ;;
9666 1.1 mrg *)
9667 1.1 mrg try_normal_branch=no
9668 1.1 mrg ;;
9669 1.1 mrg esac
9670 1.1 mrg if test yes = "$try_normal_branch" \
9671 1.1 mrg && { test "$len" -lt "$max_cmd_len" \
9672 1.1 mrg || test "$max_cmd_len" -le -1; }
9673 1.1 mrg then
9674 1.1 mrg func_show_eval "$cmd" 'exit $?'
9675 1.1 mrg skipped_export=false
9676 1.1 mrg elif test -n "$nm_file_list_spec"; then
9677 1.1 mrg func_basename "$output"
9678 1.1 mrg output_la=$func_basename_result
9679 1.1 mrg save_libobjs=$libobjs
9680 1.1 mrg save_output=$output
9681 1.1 mrg output=$output_objdir/$output_la.nm
9682 1.1 mrg func_to_tool_file "$output"
9683 1.1 mrg libobjs=$nm_file_list_spec$func_to_tool_file_result
9684 1.1 mrg func_append delfiles " $output"
9685 1.1 mrg func_verbose "creating $NM input file list: $output"
9686 1.1 mrg for obj in $save_libobjs; do
9687 1.1 mrg func_to_tool_file "$obj"
9688 1.1 mrg $ECHO "$func_to_tool_file_result"
9689 1.1 mrg done > "$output"
9690 1.1 mrg eval cmd=\"$cmd1\"
9691 1.1 mrg func_show_eval "$cmd" 'exit $?'
9692 1.1 mrg output=$save_output
9693 1.1 mrg libobjs=$save_libobjs
9694 1.1 mrg skipped_export=false
9695 1.1 mrg else
9696 1.1 mrg # The command line is too long to execute in one step.
9697 1.1 mrg func_verbose "using reloadable object file for export list..."
9698 1.1 mrg skipped_export=:
9699 1.1 mrg # Break out early, otherwise skipped_export may be
9700 1.1 mrg # set to false by a later but shorter cmd.
9701 1.1 mrg break
9702 1.1 mrg fi
9703 1.1 mrg done
9704 1.1 mrg IFS=$save_ifs
9705 1.1 mrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9706 1.1 mrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9707 1.1 mrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9708 1.1 mrg fi
9709 1.1 mrg fi
9710 1.1 mrg fi
9711 1.1 mrg
9712 1.1 mrg if test -n "$export_symbols" && test -n "$include_expsyms"; then
9713 1.1 mrg tmp_export_symbols=$export_symbols
9714 1.1 mrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9715 1.1 mrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9716 1.1 mrg fi
9717 1.1 mrg
9718 1.1 mrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9719 1.1 mrg # The given exports_symbols file has to be filtered, so filter it.
9720 1.1 mrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9721 1.1 mrg # FIXME: $output_objdir/$libname.filter potentially contains lots of
9722 1.1 mrg # 's' commands, which not all seds can handle. GNU sed should be fine
9723 1.1 mrg # though. Also, the filter scales superlinearly with the number of
9724 1.1 mrg # global variables. join(1) would be nice here, but unfortunately
9725 1.1 mrg # isn't a blessed tool.
9726 1.1 mrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9727 1.1 mrg func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9728 1.1 mrg export_symbols=$output_objdir/$libname.def
9729 1.1 mrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9730 1.1 mrg fi
9731 1.1 mrg
9732 1.1 mrg tmp_deplibs=
9733 1.1 mrg for test_deplib in $deplibs; do
9734 1.1 mrg case " $convenience " in
9735 1.1 mrg *" $test_deplib "*) ;;
9736 1.1 mrg *)
9737 1.1 mrg func_append tmp_deplibs " $test_deplib"
9738 1.1 mrg ;;
9739 1.1 mrg esac
9740 1.1 mrg done
9741 1.1 mrg deplibs=$tmp_deplibs
9742 1.1 mrg
9743 1.1 mrg if test -n "$convenience"; then
9744 1.1 mrg if test -n "$whole_archive_flag_spec" &&
9745 1.1 mrg test yes = "$compiler_needs_object" &&
9746 1.1 mrg test -z "$libobjs"; then
9747 1.1 mrg # extract the archives, so we have objects to list.
9748 1.1 mrg # TODO: could optimize this to just extract one archive.
9749 1.1 mrg whole_archive_flag_spec=
9750 1.1 mrg fi
9751 1.1 mrg if test -n "$whole_archive_flag_spec"; then
9752 1.1 mrg save_libobjs=$libobjs
9753 1.1 mrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9754 1.1 mrg test "X$libobjs" = "X " && libobjs=
9755 1.1 mrg else
9756 1.1 mrg gentop=$output_objdir/${outputname}x
9757 1.1 mrg func_append generated " $gentop"
9758 1.1 mrg
9759 1.1 mrg func_extract_archives $gentop $convenience
9760 1.1 mrg func_append libobjs " $func_extract_archives_result"
9761 1.1 mrg test "X$libobjs" = "X " && libobjs=
9762 1.1 mrg fi
9763 1.1 mrg fi
9764 1.1 mrg
9765 1.1 mrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9766 1.1 mrg eval flag=\"$thread_safe_flag_spec\"
9767 1.1 mrg func_append linker_flags " $flag"
9768 1.1 mrg fi
9769 1.1 mrg
9770 1.1 mrg # Make a backup of the uninstalled library when relinking
9771 1.1 mrg if test relink = "$opt_mode"; then
9772 1.1 mrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9773 1.1 mrg fi
9774 1.1 mrg
9775 1.1 mrg # Do each of the archive commands.
9776 1.1 mrg if test yes = "$module" && test -n "$module_cmds"; then
9777 1.1 mrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9778 1.1 mrg eval test_cmds=\"$module_expsym_cmds\"
9779 1.1 mrg cmds=$module_expsym_cmds
9780 1.1 mrg else
9781 1.1 mrg eval test_cmds=\"$module_cmds\"
9782 1.1 mrg cmds=$module_cmds
9783 1.1 mrg fi
9784 1.1 mrg else
9785 1.1 mrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9786 1.1 mrg eval test_cmds=\"$archive_expsym_cmds\"
9787 1.1 mrg cmds=$archive_expsym_cmds
9788 1.1 mrg else
9789 1.1 mrg eval test_cmds=\"$archive_cmds\"
9790 1.1 mrg cmds=$archive_cmds
9791 1.1 mrg fi
9792 1.1 mrg fi
9793 1.1 mrg
9794 1.1 mrg if test : != "$skipped_export" &&
9795 1.1 mrg func_len " $test_cmds" &&
9796 1.1 mrg len=$func_len_result &&
9797 1.1 mrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9798 1.1 mrg :
9799 1.1 mrg else
9800 1.1 mrg # The command line is too long to link in one step, link piecewise
9801 1.1 mrg # or, if using GNU ld and skipped_export is not :, use a linker
9802 1.1 mrg # script.
9803 1.1 mrg
9804 1.1 mrg # Save the value of $output and $libobjs because we want to
9805 1.1 mrg # use them later. If we have whole_archive_flag_spec, we
9806 1.1 mrg # want to use save_libobjs as it was before
9807 1.1 mrg # whole_archive_flag_spec was expanded, because we can't
9808 1.1 mrg # assume the linker understands whole_archive_flag_spec.
9809 1.1 mrg # This may have to be revisited, in case too many
9810 1.1 mrg # convenience libraries get linked in and end up exceeding
9811 1.1 mrg # the spec.
9812 1.1 mrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9813 1.1 mrg save_libobjs=$libobjs
9814 1.1 mrg fi
9815 1.1 mrg save_output=$output
9816 1.1 mrg func_basename "$output"
9817 1.1 mrg output_la=$func_basename_result
9818 1.1 mrg
9819 1.1 mrg # Clear the reloadable object creation command queue and
9820 1.1 mrg # initialize k to one.
9821 1.1 mrg test_cmds=
9822 1.1 mrg concat_cmds=
9823 1.1 mrg objlist=
9824 1.1 mrg last_robj=
9825 1.1 mrg k=1
9826 1.1 mrg
9827 1.1 mrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9828 1.1 mrg output=$output_objdir/$output_la.lnkscript
9829 1.1 mrg func_verbose "creating GNU ld script: $output"
9830 1.1 mrg echo 'INPUT (' > $output
9831 1.1 mrg for obj in $save_libobjs
9832 1.1 mrg do
9833 1.1 mrg func_to_tool_file "$obj"
9834 1.1 mrg $ECHO "$func_to_tool_file_result" >> $output
9835 1.1 mrg done
9836 1.1 mrg echo ')' >> $output
9837 1.1 mrg func_append delfiles " $output"
9838 1.1 mrg func_to_tool_file "$output"
9839 1.1 mrg output=$func_to_tool_file_result
9840 1.1 mrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9841 1.1 mrg output=$output_objdir/$output_la.lnk
9842 1.1 mrg func_verbose "creating linker input file list: $output"
9843 1.1 mrg : > $output
9844 1.1 mrg set x $save_libobjs
9845 1.1 mrg shift
9846 1.1 mrg firstobj=
9847 1.1 mrg if test yes = "$compiler_needs_object"; then
9848 1.1 mrg firstobj="$1 "
9849 1.1 mrg shift
9850 1.1 mrg fi
9851 1.1 mrg for obj
9852 1.1 mrg do
9853 1.1 mrg func_to_tool_file "$obj"
9854 1.1 mrg $ECHO "$func_to_tool_file_result" >> $output
9855 1.1 mrg done
9856 1.1 mrg func_append delfiles " $output"
9857 1.1 mrg func_to_tool_file "$output"
9858 1.1 mrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9859 1.1 mrg else
9860 1.1 mrg if test -n "$save_libobjs"; then
9861 1.1 mrg func_verbose "creating reloadable object files..."
9862 1.1 mrg output=$output_objdir/$output_la-$k.$objext
9863 1.1 mrg eval test_cmds=\"$reload_cmds\"
9864 1.1 mrg func_len " $test_cmds"
9865 1.1 mrg len0=$func_len_result
9866 1.1 mrg len=$len0
9867 1.1 mrg
9868 1.1 mrg # Loop over the list of objects to be linked.
9869 1.1 mrg for obj in $save_libobjs
9870 1.1 mrg do
9871 1.1 mrg func_len " $obj"
9872 1.1 mrg func_arith $len + $func_len_result
9873 1.1 mrg len=$func_arith_result
9874 1.1 mrg if test -z "$objlist" ||
9875 1.1 mrg test "$len" -lt "$max_cmd_len"; then
9876 1.1 mrg func_append objlist " $obj"
9877 1.1 mrg else
9878 1.1 mrg # The command $test_cmds is almost too long, add a
9879 1.1 mrg # command to the queue.
9880 1.1 mrg if test 1 -eq "$k"; then
9881 1.1 mrg # The first file doesn't have a previous command to add.
9882 1.1 mrg reload_objs=$objlist
9883 1.1 mrg eval concat_cmds=\"$reload_cmds\"
9884 1.1 mrg else
9885 1.1 mrg # All subsequent reloadable object files will link in
9886 1.1 mrg # the last one created.
9887 1.1 mrg reload_objs="$objlist $last_robj"
9888 1.1 mrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9889 1.1 mrg fi
9890 1.1 mrg last_robj=$output_objdir/$output_la-$k.$objext
9891 1.1 mrg func_arith $k + 1
9892 1.1 mrg k=$func_arith_result
9893 1.1 mrg output=$output_objdir/$output_la-$k.$objext
9894 1.1 mrg objlist=" $obj"
9895 1.1 mrg func_len " $last_robj"
9896 1.1 mrg func_arith $len0 + $func_len_result
9897 1.1 mrg len=$func_arith_result
9898 1.1 mrg fi
9899 1.1 mrg done
9900 1.1 mrg # Handle the remaining objects by creating one last
9901 1.1 mrg # reloadable object file. All subsequent reloadable object
9902 1.1 mrg # files will link in the last one created.
9903 1.1 mrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9904 1.1 mrg reload_objs="$objlist $last_robj"
9905 1.1 mrg eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9906 1.1 mrg if test -n "$last_robj"; then
9907 1.1 mrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9908 1.1 mrg fi
9909 1.1 mrg func_append delfiles " $output"
9910 1.1 mrg
9911 1.1 mrg else
9912 1.1 mrg output=
9913 1.1 mrg fi
9914 1.1 mrg
9915 1.1 mrg ${skipped_export-false} && {
9916 1.1 mrg func_verbose "generating symbol list for '$libname.la'"
9917 1.1 mrg export_symbols=$output_objdir/$libname.exp
9918 1.1 mrg $opt_dry_run || $RM $export_symbols
9919 1.1 mrg libobjs=$output
9920 1.1 mrg # Append the command to create the export file.
9921 1.1 mrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9922 1.1 mrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9923 1.1 mrg if test -n "$last_robj"; then
9924 1.1 mrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9925 1.1 mrg fi
9926 1.1 mrg }
9927 1.1 mrg
9928 1.1 mrg test -n "$save_libobjs" &&
9929 1.1 mrg func_verbose "creating a temporary reloadable object file: $output"
9930 1.1 mrg
9931 1.1 mrg # Loop through the commands generated above and execute them.
9932 1.1 mrg save_ifs=$IFS; IFS='~'
9933 1.1 mrg for cmd in $concat_cmds; do
9934 1.1 mrg IFS=$save_ifs
9935 1.1 mrg $opt_quiet || {
9936 1.1 mrg func_quote_for_expand "$cmd"
9937 1.1 mrg eval "func_echo $func_quote_for_expand_result"
9938 1.1 mrg }
9939 1.1 mrg $opt_dry_run || eval "$cmd" || {
9940 1.1 mrg lt_exit=$?
9941 1.1 mrg
9942 1.1 mrg # Restore the uninstalled library and exit
9943 1.1 mrg if test relink = "$opt_mode"; then
9944 1.1 mrg ( cd "$output_objdir" && \
9945 1.1 mrg $RM "${realname}T" && \
9946 1.1 mrg $MV "${realname}U" "$realname" )
9947 1.1 mrg fi
9948 1.1 mrg
9949 1.1 mrg exit $lt_exit
9950 1.1 mrg }
9951 1.1 mrg done
9952 1.1 mrg IFS=$save_ifs
9953 1.1 mrg
9954 1.1 mrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9955 1.1 mrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9956 1.1 mrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9957 1.1 mrg fi
9958 1.1 mrg fi
9959 1.1 mrg
9960 1.1 mrg ${skipped_export-false} && {
9961 1.1 mrg if test -n "$export_symbols" && test -n "$include_expsyms"; then
9962 1.1 mrg tmp_export_symbols=$export_symbols
9963 1.1 mrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9964 1.1 mrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9965 1.1 mrg fi
9966 1.1 mrg
9967 1.1 mrg if test -n "$orig_export_symbols"; then
9968 1.1 mrg # The given exports_symbols file has to be filtered, so filter it.
9969 1.1 mrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9970 1.1 mrg # FIXME: $output_objdir/$libname.filter potentially contains lots of
9971 1.1 mrg # 's' commands, which not all seds can handle. GNU sed should be fine
9972 1.1 mrg # though. Also, the filter scales superlinearly with the number of
9973 1.1 mrg # global variables. join(1) would be nice here, but unfortunately
9974 1.1 mrg # isn't a blessed tool.
9975 1.1 mrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9976 1.1 mrg func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9977 1.1 mrg export_symbols=$output_objdir/$libname.def
9978 1.1 mrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9979 1.1 mrg fi
9980 1.1 mrg }
9981 1.1 mrg
9982 1.1 mrg libobjs=$output
9983 1.1 mrg # Restore the value of output.
9984 1.1 mrg output=$save_output
9985 1.1 mrg
9986 1.1 mrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9987 1.1 mrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9988 1.1 mrg test "X$libobjs" = "X " && libobjs=
9989 1.1 mrg fi
9990 1.1 mrg # Expand the library linking commands again to reset the
9991 1.1 mrg # value of $libobjs for piecewise linking.
9992 1.1 mrg
9993 1.1 mrg # Do each of the archive commands.
9994 1.1 mrg if test yes = "$module" && test -n "$module_cmds"; then
9995 1.1 mrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9996 1.1 mrg cmds=$module_expsym_cmds
9997 1.1 mrg else
9998 1.1 mrg cmds=$module_cmds
9999 1.1 mrg fi
10000 1.1 mrg else
10001 1.1 mrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10002 1.1 mrg cmds=$archive_expsym_cmds
10003 1.1 mrg else
10004 1.1 mrg cmds=$archive_cmds
10005 1.1 mrg fi
10006 1.1 mrg fi
10007 1.1 mrg fi
10008 1.1 mrg
10009 1.1 mrg if test -n "$delfiles"; then
10010 1.1 mrg # Append the command to remove temporary files to $cmds.
10011 1.1 mrg eval cmds=\"\$cmds~\$RM $delfiles\"
10012 1.1 mrg fi
10013 1.1 mrg
10014 1.1 mrg # Add any objects from preloaded convenience libraries
10015 1.1 mrg if test -n "$dlprefiles"; then
10016 1.1 mrg gentop=$output_objdir/${outputname}x
10017 1.1 mrg func_append generated " $gentop"
10018 1.1 mrg
10019 1.1 mrg func_extract_archives $gentop $dlprefiles
10020 1.1 mrg func_append libobjs " $func_extract_archives_result"
10021 1.1 mrg test "X$libobjs" = "X " && libobjs=
10022 1.1 mrg fi
10023 1.1 mrg
10024 1.1 mrg save_ifs=$IFS; IFS='~'
10025 1.1 mrg for cmd in $cmds; do
10026 1.1 mrg IFS=$sp$nl
10027 1.1 mrg eval cmd=\"$cmd\"
10028 1.1 mrg IFS=$save_ifs
10029 1.1 mrg $opt_quiet || {
10030 1.1 mrg func_quote_for_expand "$cmd"
10031 1.1 mrg eval "func_echo $func_quote_for_expand_result"
10032 1.1 mrg }
10033 1.1 mrg $opt_dry_run || eval "$cmd" || {
10034 1.1 mrg lt_exit=$?
10035 1.1 mrg
10036 1.1 mrg # Restore the uninstalled library and exit
10037 1.1 mrg if test relink = "$opt_mode"; then
10038 1.1 mrg ( cd "$output_objdir" && \
10039 1.1 mrg $RM "${realname}T" && \
10040 1.1 mrg $MV "${realname}U" "$realname" )
10041 1.1 mrg fi
10042 1.1 mrg
10043 1.1 mrg exit $lt_exit
10044 1.1 mrg }
10045 1.1 mrg done
10046 1.1 mrg IFS=$save_ifs
10047 1.1 mrg
10048 1.1 mrg # Restore the uninstalled library and exit
10049 1.1 mrg if test relink = "$opt_mode"; then
10050 1.1 mrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10051 1.1 mrg
10052 1.1 mrg if test -n "$convenience"; then
10053 1.1 mrg if test -z "$whole_archive_flag_spec"; then
10054 1.1 mrg func_show_eval '${RM}r "$gentop"'
10055 1.1 mrg fi
10056 1.1 mrg fi
10057 1.1 mrg
10058 1.1 mrg exit $EXIT_SUCCESS
10059 1.1 mrg fi
10060 1.1 mrg
10061 1.1 mrg # Create links to the real library.
10062 1.1 mrg for linkname in $linknames; do
10063 1.1 mrg if test "$realname" != "$linkname"; then
10064 1.1 mrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10065 1.1 mrg fi
10066 1.1 mrg done
10067 1.1 mrg
10068 1.1 mrg # If -module or -export-dynamic was specified, set the dlname.
10069 1.1 mrg if test yes = "$module" || test yes = "$export_dynamic"; then
10070 1.1 mrg # On all known operating systems, these are identical.
10071 1.1 mrg dlname=$soname
10072 1.1 mrg fi
10073 1.1 mrg fi
10074 1.1 mrg ;;
10075 1.1 mrg
10076 1.1 mrg obj)
10077 1.1 mrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10078 1.1 mrg func_warning "'-dlopen' is ignored for objects"
10079 1.1 mrg fi
10080 1.1 mrg
10081 1.1 mrg case " $deplibs" in
10082 1.1 mrg *\ -l* | *\ -L*)
10083 1.1 mrg func_warning "'-l' and '-L' are ignored for objects" ;;
10084 1.1 mrg esac
10085 1.1 mrg
10086 1.1 mrg test -n "$rpath" && \
10087 1.1 mrg func_warning "'-rpath' is ignored for objects"
10088 1.1 mrg
10089 1.1 mrg test -n "$xrpath" && \
10090 1.1 mrg func_warning "'-R' is ignored for objects"
10091 1.1 mrg
10092 1.1 mrg test -n "$vinfo" && \
10093 1.1 mrg func_warning "'-version-info' is ignored for objects"
10094 1.1 mrg
10095 1.1 mrg test -n "$release" && \
10096 1.1 mrg func_warning "'-release' is ignored for objects"
10097 1.1 mrg
10098 1.1 mrg case $output in
10099 1.1 mrg *.lo)
10100 1.1 mrg test -n "$objs$old_deplibs" && \
10101 1.1 mrg func_fatal_error "cannot build library object '$output' from non-libtool objects"
10102 1.1 mrg
10103 1.1 mrg libobj=$output
10104 1.1 mrg func_lo2o "$libobj"
10105 1.1 mrg obj=$func_lo2o_result
10106 1.1 mrg ;;
10107 1.1 mrg *)
10108 1.1 mrg libobj=
10109 1.1 mrg obj=$output
10110 1.1 mrg ;;
10111 1.1 mrg esac
10112 1.1 mrg
10113 1.1 mrg # Delete the old objects.
10114 1.1 mrg $opt_dry_run || $RM $obj $libobj
10115 1.1 mrg
10116 1.1 mrg # Objects from convenience libraries. This assumes
10117 1.1 mrg # single-version convenience libraries. Whenever we create
10118 1.1 mrg # different ones for PIC/non-PIC, this we'll have to duplicate
10119 1.1 mrg # the extraction.
10120 1.1 mrg reload_conv_objs=
10121 1.1 mrg gentop=
10122 1.1 mrg # if reload_cmds runs $LD directly, get rid of -Wl from
10123 1.1 mrg # whole_archive_flag_spec and hope we can get by with turning comma
10124 1.1 mrg # into space.
10125 1.1 mrg case $reload_cmds in
10126 1.1 mrg *\$LD[\ \$]*) wl= ;;
10127 1.1 mrg esac
10128 1.1 mrg if test -n "$convenience"; then
10129 1.1 mrg if test -n "$whole_archive_flag_spec"; then
10130 1.1 mrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10131 1.1 mrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10132 1.1 mrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10133 1.1 mrg else
10134 1.1 mrg gentop=$output_objdir/${obj}x
10135 1.1 mrg func_append generated " $gentop"
10136 1.1 mrg
10137 1.1 mrg func_extract_archives $gentop $convenience
10138 1.1 mrg reload_conv_objs="$reload_objs $func_extract_archives_result"
10139 1.1 mrg fi
10140 1.1 mrg fi
10141 1.1 mrg
10142 1.1 mrg # If we're not building shared, we need to use non_pic_objs
10143 1.1 mrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10144 1.1 mrg
10145 1.1 mrg # Create the old-style object.
10146 1.1 mrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10147 1.1 mrg
10148 1.1 mrg output=$obj
10149 1.1 mrg func_execute_cmds "$reload_cmds" 'exit $?'
10150 1.1 mrg
10151 1.1 mrg # Exit if we aren't doing a library object file.
10152 1.1 mrg if test -z "$libobj"; then
10153 1.1 mrg if test -n "$gentop"; then
10154 1.1 mrg func_show_eval '${RM}r "$gentop"'
10155 1.1 mrg fi
10156 1.1 mrg
10157 1.1 mrg exit $EXIT_SUCCESS
10158 1.1 mrg fi
10159 1.1 mrg
10160 1.1 mrg test yes = "$build_libtool_libs" || {
10161 1.1 mrg if test -n "$gentop"; then
10162 1.1 mrg func_show_eval '${RM}r "$gentop"'
10163 1.1 mrg fi
10164 1.1 mrg
10165 1.1 mrg # Create an invalid libtool object if no PIC, so that we don't
10166 1.1 mrg # accidentally link it into a program.
10167 1.1 mrg # $show "echo timestamp > $libobj"
10168 1.1 mrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10169 1.1 mrg exit $EXIT_SUCCESS
10170 1.1 mrg }
10171 1.1 mrg
10172 1.1 mrg if test -n "$pic_flag" || test default != "$pic_mode"; then
10173 1.1 mrg # Only do commands if we really have different PIC objects.
10174 1.1 mrg reload_objs="$libobjs $reload_conv_objs"
10175 1.1 mrg output=$libobj
10176 1.1 mrg func_execute_cmds "$reload_cmds" 'exit $?'
10177 1.1 mrg fi
10178 1.1 mrg
10179 1.1 mrg if test -n "$gentop"; then
10180 1.1 mrg func_show_eval '${RM}r "$gentop"'
10181 1.1 mrg fi
10182 1.1 mrg
10183 1.1 mrg exit $EXIT_SUCCESS
10184 1.1 mrg ;;
10185 1.1 mrg
10186 1.1 mrg prog)
10187 1.1 mrg case $host in
10188 1.1 mrg *cygwin*) func_stripname '' '.exe' "$output"
10189 1.1 mrg output=$func_stripname_result.exe;;
10190 1.1 mrg esac
10191 1.1 mrg test -n "$vinfo" && \
10192 1.1 mrg func_warning "'-version-info' is ignored for programs"
10193 1.1 mrg
10194 1.1 mrg test -n "$release" && \
10195 1.1 mrg func_warning "'-release' is ignored for programs"
10196 1.1 mrg
10197 1.1 mrg $preload \
10198 1.1 mrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10199 1.1 mrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10200 1.1 mrg
10201 1.1 mrg case $host in
10202 1.1 mrg *-*-rhapsody* | *-*-darwin1.[012])
10203 1.1 mrg # On Rhapsody replace the C library is the System framework
10204 1.1 mrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10205 1.1 mrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10206 1.1 mrg ;;
10207 1.1 mrg esac
10208 1.1 mrg
10209 1.1 mrg case $host in
10210 1.1 mrg *-*-darwin*)
10211 1.1 mrg # Don't allow lazy linking, it breaks C++ global constructors
10212 1.1 mrg # But is supposedly fixed on 10.4 or later (yay!).
10213 1.1 mrg if test CXX = "$tagname"; then
10214 1.1 mrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10215 1.1 mrg 10.[0123])
10216 1.1 mrg func_append compile_command " $wl-bind_at_load"
10217 1.1 mrg func_append finalize_command " $wl-bind_at_load"
10218 1.1 mrg ;;
10219 1.1 mrg esac
10220 1.1 mrg fi
10221 1.1 mrg # Time to change all our "foo.ltframework" stuff back to "-framework foo"
10222 1.1 mrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10223 1.1 mrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10224 1.1 mrg ;;
10225 1.1 mrg esac
10226 1.1 mrg
10227 1.1 mrg
10228 1.1 mrg # move library search paths that coincide with paths to not yet
10229 1.1 mrg # installed libraries to the beginning of the library search list
10230 1.1 mrg new_libs=
10231 1.1 mrg for path in $notinst_path; do
10232 1.1 mrg case " $new_libs " in
10233 1.1 mrg *" -L$path/$objdir "*) ;;
10234 1.1 mrg *)
10235 1.1 mrg case " $compile_deplibs " in
10236 1.1 mrg *" -L$path/$objdir "*)
10237 1.1 mrg func_append new_libs " -L$path/$objdir" ;;
10238 1.1 mrg esac
10239 1.1 mrg ;;
10240 1.1 mrg esac
10241 1.1 mrg done
10242 1.1 mrg for deplib in $compile_deplibs; do
10243 1.1 mrg case $deplib in
10244 1.1 mrg -L*)
10245 1.1 mrg case " $new_libs " in
10246 1.1 mrg *" $deplib "*) ;;
10247 1.1 mrg *) func_append new_libs " $deplib" ;;
10248 1.1 mrg esac
10249 1.1 mrg ;;
10250 1.1 mrg *) func_append new_libs " $deplib" ;;
10251 1.1 mrg esac
10252 1.1 mrg done
10253 1.1 mrg compile_deplibs=$new_libs
10254 1.1 mrg
10255 1.1 mrg
10256 1.1 mrg func_append compile_command " $compile_deplibs"
10257 1.1 mrg func_append finalize_command " $finalize_deplibs"
10258 1.1 mrg
10259 1.1 mrg if test -n "$rpath$xrpath"; then
10260 1.1 mrg # If the user specified any rpath flags, then add them.
10261 1.1 mrg for libdir in $rpath $xrpath; do
10262 1.1 mrg # This is the magic to use -rpath.
10263 1.1 mrg case "$finalize_rpath " in
10264 1.1 mrg *" $libdir "*) ;;
10265 1.1 mrg *) func_append finalize_rpath " $libdir" ;;
10266 1.1 mrg esac
10267 1.1 mrg done
10268 1.1 mrg fi
10269 1.1 mrg
10270 1.1 mrg # Now hardcode the library paths
10271 1.1 mrg rpath=
10272 1.1 mrg hardcode_libdirs=
10273 1.1 mrg for libdir in $compile_rpath $finalize_rpath; do
10274 1.1 mrg if test -n "$hardcode_libdir_flag_spec"; then
10275 1.1 mrg if test -n "$hardcode_libdir_separator"; then
10276 1.1 mrg if test -z "$hardcode_libdirs"; then
10277 1.1 mrg hardcode_libdirs=$libdir
10278 1.1 mrg else
10279 1.1 mrg # Just accumulate the unique libdirs.
10280 1.1 mrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10281 1.1 mrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10282 1.1 mrg ;;
10283 1.1 mrg *)
10284 1.1 mrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10285 1.1 mrg ;;
10286 1.1 mrg esac
10287 1.1 mrg fi
10288 1.1 mrg else
10289 1.1 mrg eval flag=\"$hardcode_libdir_flag_spec\"
10290 1.1 mrg func_append rpath " $flag"
10291 1.1 mrg fi
10292 1.1 mrg elif test -n "$runpath_var"; then
10293 1.1 mrg case "$perm_rpath " in
10294 1.1 mrg *" $libdir "*) ;;
10295 1.1 mrg *) func_append perm_rpath " $libdir" ;;
10296 1.1 mrg esac
10297 1.1 mrg fi
10298 1.1 mrg case $host in
10299 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10300 1.1 mrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10301 1.1 mrg case :$dllsearchpath: in
10302 1.1 mrg *":$libdir:"*) ;;
10303 1.1 mrg ::) dllsearchpath=$libdir;;
10304 1.1 mrg *) func_append dllsearchpath ":$libdir";;
10305 1.1 mrg esac
10306 1.1 mrg case :$dllsearchpath: in
10307 1.1 mrg *":$testbindir:"*) ;;
10308 1.1 mrg ::) dllsearchpath=$testbindir;;
10309 1.1 mrg *) func_append dllsearchpath ":$testbindir";;
10310 1.1 mrg esac
10311 1.1 mrg ;;
10312 1.1 mrg esac
10313 1.1 mrg done
10314 1.1 mrg # Substitute the hardcoded libdirs into the rpath.
10315 1.1 mrg if test -n "$hardcode_libdir_separator" &&
10316 1.1 mrg test -n "$hardcode_libdirs"; then
10317 1.1 mrg libdir=$hardcode_libdirs
10318 1.1 mrg eval rpath=\" $hardcode_libdir_flag_spec\"
10319 1.1 mrg fi
10320 1.1 mrg compile_rpath=$rpath
10321 1.1 mrg
10322 1.1 mrg rpath=
10323 1.1 mrg hardcode_libdirs=
10324 1.1 mrg for libdir in $finalize_rpath; do
10325 1.1 mrg if test -n "$hardcode_libdir_flag_spec"; then
10326 1.1 mrg if test -n "$hardcode_libdir_separator"; then
10327 1.1 mrg if test -z "$hardcode_libdirs"; then
10328 1.1 mrg hardcode_libdirs=$libdir
10329 1.1 mrg else
10330 1.1 mrg # Just accumulate the unique libdirs.
10331 1.1 mrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10332 1.1 mrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10333 1.1 mrg ;;
10334 1.1 mrg *)
10335 1.1 mrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10336 1.1 mrg ;;
10337 1.1 mrg esac
10338 1.1 mrg fi
10339 1.1 mrg else
10340 1.1 mrg eval flag=\"$hardcode_libdir_flag_spec\"
10341 1.1 mrg func_append rpath " $flag"
10342 1.1 mrg fi
10343 1.1 mrg elif test -n "$runpath_var"; then
10344 1.1 mrg case "$finalize_perm_rpath " in
10345 1.1 mrg *" $libdir "*) ;;
10346 1.1 mrg *) func_append finalize_perm_rpath " $libdir" ;;
10347 1.1 mrg esac
10348 1.1 mrg fi
10349 1.1 mrg done
10350 1.1 mrg # Substitute the hardcoded libdirs into the rpath.
10351 1.1 mrg if test -n "$hardcode_libdir_separator" &&
10352 1.1 mrg test -n "$hardcode_libdirs"; then
10353 1.1 mrg libdir=$hardcode_libdirs
10354 1.1 mrg eval rpath=\" $hardcode_libdir_flag_spec\"
10355 1.1 mrg fi
10356 1.1 mrg finalize_rpath=$rpath
10357 1.1 mrg
10358 1.1 mrg if test -n "$libobjs" && test yes = "$build_old_libs"; then
10359 1.1 mrg # Transform all the library objects into standard objects.
10360 1.1 mrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10361 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10362 1.1 mrg fi
10363 1.1 mrg
10364 1.1 mrg func_generate_dlsyms "$outputname" "@PROGRAM@" false
10365 1.1 mrg
10366 1.1 mrg # template prelinking step
10367 1.1 mrg if test -n "$prelink_cmds"; then
10368 1.1 mrg func_execute_cmds "$prelink_cmds" 'exit $?'
10369 1.1 mrg fi
10370 1.1 mrg
10371 1.1 mrg wrappers_required=:
10372 1.1 mrg case $host in
10373 1.1 mrg *cegcc* | *mingw32ce*)
10374 1.1 mrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10375 1.1 mrg wrappers_required=false
10376 1.1 mrg ;;
10377 1.1 mrg *cygwin* | *mingw* )
10378 1.1 mrg test yes = "$build_libtool_libs" || wrappers_required=false
10379 1.1 mrg ;;
10380 1.1 mrg *)
10381 1.1 mrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10382 1.1 mrg wrappers_required=false
10383 1.1 mrg fi
10384 1.1 mrg ;;
10385 1.1 mrg esac
10386 1.1 mrg $wrappers_required || {
10387 1.1 mrg # Replace the output file specification.
10388 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10389 1.1 mrg link_command=$compile_command$compile_rpath
10390 1.1 mrg
10391 1.1 mrg # We have no uninstalled library dependencies, so finalize right now.
10392 1.1 mrg exit_status=0
10393 1.1 mrg func_show_eval "$link_command" 'exit_status=$?'
10394 1.1 mrg
10395 1.1 mrg if test -n "$postlink_cmds"; then
10396 1.1 mrg func_to_tool_file "$output"
10397 1.1 mrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10398 1.1 mrg func_execute_cmds "$postlink_cmds" 'exit $?'
10399 1.1 mrg fi
10400 1.1 mrg
10401 1.1 mrg # Delete the generated files.
10402 1.1 mrg if test -f "$output_objdir/${outputname}S.$objext"; then
10403 1.1 mrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10404 1.1 mrg fi
10405 1.1 mrg
10406 1.1 mrg exit $exit_status
10407 1.1 mrg }
10408 1.1 mrg
10409 1.1 mrg if test -n "$compile_shlibpath$finalize_shlibpath"; then
10410 1.1 mrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10411 1.1 mrg fi
10412 1.1 mrg if test -n "$finalize_shlibpath"; then
10413 1.1 mrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10414 1.1 mrg fi
10415 1.1 mrg
10416 1.1 mrg compile_var=
10417 1.1 mrg finalize_var=
10418 1.1 mrg if test -n "$runpath_var"; then
10419 1.1 mrg if test -n "$perm_rpath"; then
10420 1.1 mrg # We should set the runpath_var.
10421 1.1 mrg rpath=
10422 1.1 mrg for dir in $perm_rpath; do
10423 1.1 mrg func_append rpath "$dir:"
10424 1.1 mrg done
10425 1.1 mrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10426 1.1 mrg fi
10427 1.1 mrg if test -n "$finalize_perm_rpath"; then
10428 1.1 mrg # We should set the runpath_var.
10429 1.1 mrg rpath=
10430 1.1 mrg for dir in $finalize_perm_rpath; do
10431 1.1 mrg func_append rpath "$dir:"
10432 1.1 mrg done
10433 1.1 mrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10434 1.1 mrg fi
10435 1.1 mrg fi
10436 1.1 mrg
10437 1.1 mrg if test yes = "$no_install"; then
10438 1.1 mrg # We don't need to create a wrapper script.
10439 1.1 mrg link_command=$compile_var$compile_command$compile_rpath
10440 1.1 mrg # Replace the output file specification.
10441 1.1 mrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10442 1.1 mrg # Delete the old output file.
10443 1.1 mrg $opt_dry_run || $RM $output
10444 1.1 mrg # Link the executable and exit
10445 1.1 mrg func_show_eval "$link_command" 'exit $?'
10446 1.1 mrg
10447 1.1 mrg if test -n "$postlink_cmds"; then
10448 1.1 mrg func_to_tool_file "$output"
10449 1.1 mrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10450 1.1 mrg func_execute_cmds "$postlink_cmds" 'exit $?'
10451 1.1 mrg fi
10452 1.1 mrg
10453 1.1 mrg exit $EXIT_SUCCESS
10454 1.1 mrg fi
10455 1.1 mrg
10456 1.1 mrg case $hardcode_action,$fast_install in
10457 1.1 mrg relink,*)
10458 1.1 mrg # Fast installation is not supported
10459 1.1 mrg link_command=$compile_var$compile_command$compile_rpath
10460 1.1 mrg relink_command=$finalize_var$finalize_command$finalize_rpath
10461 1.1 mrg
10462 1.1 mrg func_warning "this platform does not like uninstalled shared libraries"
10463 1.1 mrg func_warning "'$output' will be relinked during installation"
10464 1.1 mrg ;;
10465 1.1 mrg *,yes)
10466 1.1 mrg link_command=$finalize_var$compile_command$finalize_rpath
10467 1.1 mrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10468 1.1 mrg ;;
10469 1.1 mrg *,no)
10470 1.1 mrg link_command=$compile_var$compile_command$compile_rpath
10471 1.1 mrg relink_command=$finalize_var$finalize_command$finalize_rpath
10472 1.1 mrg ;;
10473 1.1 mrg *,needless)
10474 1.1 mrg link_command=$finalize_var$compile_command$finalize_rpath
10475 1.1 mrg relink_command=
10476 1.1 mrg ;;
10477 1.1 mrg esac
10478 1.1 mrg
10479 1.1 mrg # Replace the output file specification.
10480 1.1 mrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10481 1.1 mrg
10482 1.1 mrg # Delete the old output files.
10483 1.1 mrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10484 1.1 mrg
10485 1.1 mrg func_show_eval "$link_command" 'exit $?'
10486 1.1 mrg
10487 1.1 mrg if test -n "$postlink_cmds"; then
10488 1.1 mrg func_to_tool_file "$output_objdir/$outputname"
10489 1.1 mrg 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'`
10490 1.1 mrg func_execute_cmds "$postlink_cmds" 'exit $?'
10491 1.1 mrg fi
10492 1.1 mrg
10493 1.1 mrg # Now create the wrapper script.
10494 1.1 mrg func_verbose "creating $output"
10495 1.1 mrg
10496 1.1 mrg # Quote the relink command for shipping.
10497 1.1 mrg if test -n "$relink_command"; then
10498 1.1 mrg # Preserve any variables that may affect compiler behavior
10499 1.1 mrg for var in $variables_saved_for_relink; do
10500 1.1 mrg if eval test -z \"\${$var+set}\"; then
10501 1.1 mrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10502 1.1 mrg elif eval var_value=\$$var; test -z "$var_value"; then
10503 1.1 mrg relink_command="$var=; export $var; $relink_command"
10504 1.1 mrg else
10505 1.1 mrg func_quote_for_eval "$var_value"
10506 1.1 mrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10507 1.1 mrg fi
10508 1.1 mrg done
10509 1.1 mrg relink_command="(cd `pwd`; $relink_command)"
10510 1.1 mrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10511 1.1 mrg fi
10512 1.1 mrg
10513 1.1 mrg # Only actually do things if not in dry run mode.
10514 1.1 mrg $opt_dry_run || {
10515 1.1 mrg # win32 will think the script is a binary if it has
10516 1.1 mrg # a .exe suffix, so we strip it off here.
10517 1.1 mrg case $output in
10518 1.1 mrg *.exe) func_stripname '' '.exe' "$output"
10519 1.1 mrg output=$func_stripname_result ;;
10520 1.1 mrg esac
10521 1.1 mrg # test for cygwin because mv fails w/o .exe extensions
10522 1.1 mrg case $host in
10523 1.1 mrg *cygwin*)
10524 1.1 mrg exeext=.exe
10525 1.1 mrg func_stripname '' '.exe' "$outputname"
10526 1.1 mrg outputname=$func_stripname_result ;;
10527 1.1 mrg *) exeext= ;;
10528 1.1 mrg esac
10529 1.1 mrg case $host in
10530 1.1 mrg *cygwin* | *mingw* )
10531 1.1 mrg func_dirname_and_basename "$output" "" "."
10532 1.1 mrg output_name=$func_basename_result
10533 1.1 mrg output_path=$func_dirname_result
10534 1.1 mrg cwrappersource=$output_path/$objdir/lt-$output_name.c
10535 1.1 mrg cwrapper=$output_path/$output_name.exe
10536 1.1 mrg $RM $cwrappersource $cwrapper
10537 1.1 mrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10538 1.1 mrg
10539 1.1 mrg func_emit_cwrapperexe_src > $cwrappersource
10540 1.1 mrg
10541 1.1 mrg # The wrapper executable is built using the $host compiler,
10542 1.1 mrg # because it contains $host paths and files. If cross-
10543 1.1 mrg # compiling, it, like the target executable, must be
10544 1.1 mrg # executed on the $host or under an emulation environment.
10545 1.1 mrg $opt_dry_run || {
10546 1.1 mrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10547 1.1 mrg $STRIP $cwrapper
10548 1.1 mrg }
10549 1.1 mrg
10550 1.1 mrg # Now, create the wrapper script for func_source use:
10551 1.1 mrg func_ltwrapper_scriptname $cwrapper
10552 1.1 mrg $RM $func_ltwrapper_scriptname_result
10553 1.1 mrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10554 1.1 mrg $opt_dry_run || {
10555 1.1 mrg # note: this script will not be executed, so do not chmod.
10556 1.1 mrg if test "x$build" = "x$host"; then
10557 1.1 mrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10558 1.1 mrg else
10559 1.1 mrg func_emit_wrapper no > $func_ltwrapper_scriptname_result
10560 1.1 mrg fi
10561 1.1 mrg }
10562 1.1 mrg ;;
10563 1.1 mrg * )
10564 1.1 mrg $RM $output
10565 1.1 mrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10566 1.1 mrg
10567 1.1 mrg func_emit_wrapper no > $output
10568 1.1 mrg chmod +x $output
10569 1.1 mrg ;;
10570 1.1 mrg esac
10571 1.1 mrg }
10572 1.1 mrg exit $EXIT_SUCCESS
10573 1.1 mrg ;;
10574 1.1 mrg esac
10575 1.1 mrg
10576 1.1 mrg # See if we need to build an old-fashioned archive.
10577 1.1 mrg for oldlib in $oldlibs; do
10578 1.1 mrg
10579 1.1 mrg case $build_libtool_libs in
10580 1.1 mrg convenience)
10581 1.1 mrg oldobjs="$libobjs_save $symfileobj"
10582 1.1 mrg addlibs=$convenience
10583 1.1 mrg build_libtool_libs=no
10584 1.1 mrg ;;
10585 1.1 mrg module)
10586 1.1 mrg oldobjs=$libobjs_save
10587 1.1 mrg addlibs=$old_convenience
10588 1.1 mrg build_libtool_libs=no
10589 1.1 mrg ;;
10590 1.1 mrg *)
10591 1.1 mrg oldobjs="$old_deplibs $non_pic_objects"
10592 1.1 mrg $preload && test -f "$symfileobj" \
10593 1.1 mrg && func_append oldobjs " $symfileobj"
10594 1.1 mrg addlibs=$old_convenience
10595 1.1 mrg ;;
10596 1.1 mrg esac
10597 1.1 mrg
10598 1.1 mrg if test -n "$addlibs"; then
10599 1.1 mrg gentop=$output_objdir/${outputname}x
10600 1.1 mrg func_append generated " $gentop"
10601 1.1 mrg
10602 1.1 mrg func_extract_archives $gentop $addlibs
10603 1.1 mrg func_append oldobjs " $func_extract_archives_result"
10604 1.1 mrg fi
10605 1.1 mrg
10606 1.1 mrg # Do each command in the archive commands.
10607 1.1 mrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10608 1.1 mrg cmds=$old_archive_from_new_cmds
10609 1.1 mrg else
10610 1.1 mrg
10611 1.1 mrg # Add any objects from preloaded convenience libraries
10612 1.1 mrg if test -n "$dlprefiles"; then
10613 1.1 mrg gentop=$output_objdir/${outputname}x
10614 1.1 mrg func_append generated " $gentop"
10615 1.1 mrg
10616 1.1 mrg func_extract_archives $gentop $dlprefiles
10617 1.1 mrg func_append oldobjs " $func_extract_archives_result"
10618 1.1 mrg fi
10619 1.1 mrg
10620 1.1 mrg # POSIX demands no paths to be encoded in archives. We have
10621 1.1 mrg # to avoid creating archives with duplicate basenames if we
10622 1.1 mrg # might have to extract them afterwards, e.g., when creating a
10623 1.1 mrg # static archive out of a convenience library, or when linking
10624 1.1 mrg # the entirety of a libtool archive into another (currently
10625 1.1 mrg # not supported by libtool).
10626 1.1 mrg if (for obj in $oldobjs
10627 1.1 mrg do
10628 1.1 mrg func_basename "$obj"
10629 1.1 mrg $ECHO "$func_basename_result"
10630 1.1 mrg done | sort | sort -uc >/dev/null 2>&1); then
10631 1.1 mrg :
10632 1.1 mrg else
10633 1.1 mrg echo "copying selected object files to avoid basename conflicts..."
10634 1.1 mrg gentop=$output_objdir/${outputname}x
10635 1.1 mrg func_append generated " $gentop"
10636 1.1 mrg func_mkdir_p "$gentop"
10637 1.1 mrg save_oldobjs=$oldobjs
10638 1.1 mrg oldobjs=
10639 1.1 mrg counter=1
10640 1.1 mrg for obj in $save_oldobjs
10641 1.1 mrg do
10642 1.1 mrg func_basename "$obj"
10643 1.1 mrg objbase=$func_basename_result
10644 1.1 mrg case " $oldobjs " in
10645 1.1 mrg " ") oldobjs=$obj ;;
10646 1.1 mrg *[\ /]"$objbase "*)
10647 1.1 mrg while :; do
10648 1.1 mrg # Make sure we don't pick an alternate name that also
10649 1.1 mrg # overlaps.
10650 1.1 mrg newobj=lt$counter-$objbase
10651 1.1 mrg func_arith $counter + 1
10652 1.1 mrg counter=$func_arith_result
10653 1.1 mrg case " $oldobjs " in
10654 1.1 mrg *[\ /]"$newobj "*) ;;
10655 1.1 mrg *) if test ! -f "$gentop/$newobj"; then break; fi ;;
10656 1.1 mrg esac
10657 1.1 mrg done
10658 1.1 mrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10659 1.1 mrg func_append oldobjs " $gentop/$newobj"
10660 1.1 mrg ;;
10661 1.1 mrg *) func_append oldobjs " $obj" ;;
10662 1.1 mrg esac
10663 1.1 mrg done
10664 1.1 mrg fi
10665 1.1 mrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10666 1.1 mrg tool_oldlib=$func_to_tool_file_result
10667 1.1 mrg eval cmds=\"$old_archive_cmds\"
10668 1.1 mrg
10669 1.1 mrg func_len " $cmds"
10670 1.1 mrg len=$func_len_result
10671 1.1 mrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10672 1.1 mrg cmds=$old_archive_cmds
10673 1.1 mrg elif test -n "$archiver_list_spec"; then
10674 1.1 mrg func_verbose "using command file archive linking..."
10675 1.1 mrg for obj in $oldobjs
10676 1.1 mrg do
10677 1.1 mrg func_to_tool_file "$obj"
10678 1.1 mrg $ECHO "$func_to_tool_file_result"
10679 1.1 mrg done > $output_objdir/$libname.libcmd
10680 1.1 mrg func_to_tool_file "$output_objdir/$libname.libcmd"
10681 1.1 mrg oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10682 1.1 mrg cmds=$old_archive_cmds
10683 1.1 mrg else
10684 1.1 mrg # the command line is too long to link in one step, link in parts
10685 1.1 mrg func_verbose "using piecewise archive linking..."
10686 1.1 mrg save_RANLIB=$RANLIB
10687 1.1 mrg RANLIB=:
10688 1.1 mrg objlist=
10689 1.1 mrg concat_cmds=
10690 1.1 mrg save_oldobjs=$oldobjs
10691 1.1 mrg oldobjs=
10692 1.1 mrg # Is there a better way of finding the last object in the list?
10693 1.1 mrg for obj in $save_oldobjs
10694 1.1 mrg do
10695 1.1 mrg last_oldobj=$obj
10696 1.1 mrg done
10697 1.1 mrg eval test_cmds=\"$old_archive_cmds\"
10698 1.1 mrg func_len " $test_cmds"
10699 1.1 mrg len0=$func_len_result
10700 1.1 mrg len=$len0
10701 1.1 mrg for obj in $save_oldobjs
10702 1.1 mrg do
10703 1.1 mrg func_len " $obj"
10704 1.1 mrg func_arith $len + $func_len_result
10705 1.1 mrg len=$func_arith_result
10706 1.1 mrg func_append objlist " $obj"
10707 1.1 mrg if test "$len" -lt "$max_cmd_len"; then
10708 1.1 mrg :
10709 1.1 mrg else
10710 1.1 mrg # the above command should be used before it gets too long
10711 1.1 mrg oldobjs=$objlist
10712 1.1 mrg if test "$obj" = "$last_oldobj"; then
10713 1.1 mrg RANLIB=$save_RANLIB
10714 1.1 mrg fi
10715 1.1 mrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10716 1.1 mrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10717 1.1 mrg objlist=
10718 1.1 mrg len=$len0
10719 1.1 mrg fi
10720 1.1 mrg done
10721 1.1 mrg RANLIB=$save_RANLIB
10722 1.1 mrg oldobjs=$objlist
10723 1.1 mrg if test -z "$oldobjs"; then
10724 1.1 mrg eval cmds=\"\$concat_cmds\"
10725 1.1 mrg else
10726 1.1 mrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10727 1.1 mrg fi
10728 1.1 mrg fi
10729 1.1 mrg fi
10730 1.1 mrg func_execute_cmds "$cmds" 'exit $?'
10731 1.1 mrg done
10732 1.1 mrg
10733 1.1 mrg test -n "$generated" && \
10734 1.1 mrg func_show_eval "${RM}r$generated"
10735 1.1 mrg
10736 1.1 mrg # Now create the libtool archive.
10737 1.1 mrg case $output in
10738 1.1 mrg *.la)
10739 1.1 mrg old_library=
10740 1.1 mrg test yes = "$build_old_libs" && old_library=$libname.$libext
10741 1.1 mrg func_verbose "creating $output"
10742 1.1 mrg
10743 1.1 mrg # Preserve any variables that may affect compiler behavior
10744 1.1 mrg for var in $variables_saved_for_relink; do
10745 1.1 mrg if eval test -z \"\${$var+set}\"; then
10746 1.1 mrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10747 1.1 mrg elif eval var_value=\$$var; test -z "$var_value"; then
10748 1.1 mrg relink_command="$var=; export $var; $relink_command"
10749 1.1 mrg else
10750 1.1 mrg func_quote_for_eval "$var_value"
10751 1.1 mrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10752 1.1 mrg fi
10753 1.1 mrg done
10754 1.1 mrg # Quote the link command for shipping.
10755 1.1 mrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10756 1.1 mrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10757 1.1 mrg if test yes = "$hardcode_automatic"; then
10758 1.1 mrg relink_command=
10759 1.1 mrg fi
10760 1.1 mrg
10761 1.1 mrg # Only create the output if not a dry run.
10762 1.1 mrg $opt_dry_run || {
10763 1.1 mrg for installed in no yes; do
10764 1.1 mrg if test yes = "$installed"; then
10765 1.1 mrg if test -z "$install_libdir"; then
10766 1.1 mrg break
10767 1.1 mrg fi
10768 1.1 mrg output=$output_objdir/${outputname}i
10769 1.1 mrg # Replace all uninstalled libtool libraries with the installed ones
10770 1.1 mrg newdependency_libs=
10771 1.1 mrg for deplib in $dependency_libs; do
10772 1.1 mrg case $deplib in
10773 1.1 mrg *.la)
10774 1.1 mrg func_basename "$deplib"
10775 1.1 mrg name=$func_basename_result
10776 1.1 mrg func_resolve_sysroot "$deplib"
10777 1.1 mrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10778 1.1 mrg test -z "$libdir" && \
10779 1.1 mrg func_fatal_error "'$deplib' is not a valid libtool archive"
10780 1.1 mrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10781 1.1 mrg ;;
10782 1.1 mrg -L*)
10783 1.1 mrg func_stripname -L '' "$deplib"
10784 1.1 mrg func_replace_sysroot "$func_stripname_result"
10785 1.1 mrg func_append newdependency_libs " -L$func_replace_sysroot_result"
10786 1.1 mrg ;;
10787 1.1 mrg -R*)
10788 1.1 mrg func_stripname -R '' "$deplib"
10789 1.1 mrg func_replace_sysroot "$func_stripname_result"
10790 1.1 mrg func_append newdependency_libs " -R$func_replace_sysroot_result"
10791 1.1 mrg ;;
10792 1.1 mrg *) func_append newdependency_libs " $deplib" ;;
10793 1.1 mrg esac
10794 1.1 mrg done
10795 1.1 mrg dependency_libs=$newdependency_libs
10796 1.1 mrg newdlfiles=
10797 1.1 mrg
10798 1.1 mrg for lib in $dlfiles; do
10799 1.1 mrg case $lib in
10800 1.1 mrg *.la)
10801 1.1 mrg func_basename "$lib"
10802 1.1 mrg name=$func_basename_result
10803 1.1 mrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10804 1.1 mrg test -z "$libdir" && \
10805 1.1 mrg func_fatal_error "'$lib' is not a valid libtool archive"
10806 1.1 mrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10807 1.1 mrg ;;
10808 1.1 mrg *) func_append newdlfiles " $lib" ;;
10809 1.1 mrg esac
10810 1.1 mrg done
10811 1.1 mrg dlfiles=$newdlfiles
10812 1.1 mrg newdlprefiles=
10813 1.1 mrg for lib in $dlprefiles; do
10814 1.1 mrg case $lib in
10815 1.1 mrg *.la)
10816 1.1 mrg # Only pass preopened files to the pseudo-archive (for
10817 1.1 mrg # eventual linking with the app. that links it) if we
10818 1.1 mrg # didn't already link the preopened objects directly into
10819 1.1 mrg # the library:
10820 1.1 mrg func_basename "$lib"
10821 1.1 mrg name=$func_basename_result
10822 1.1 mrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10823 1.1 mrg test -z "$libdir" && \
10824 1.1 mrg func_fatal_error "'$lib' is not a valid libtool archive"
10825 1.1 mrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10826 1.1 mrg ;;
10827 1.1 mrg esac
10828 1.1 mrg done
10829 1.1 mrg dlprefiles=$newdlprefiles
10830 1.1 mrg else
10831 1.1 mrg newdlfiles=
10832 1.1 mrg for lib in $dlfiles; do
10833 1.1 mrg case $lib in
10834 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10835 1.1 mrg *) abs=`pwd`"/$lib" ;;
10836 1.1 mrg esac
10837 1.1 mrg func_append newdlfiles " $abs"
10838 1.1 mrg done
10839 1.1 mrg dlfiles=$newdlfiles
10840 1.1 mrg newdlprefiles=
10841 1.1 mrg for lib in $dlprefiles; do
10842 1.1 mrg case $lib in
10843 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10844 1.1 mrg *) abs=`pwd`"/$lib" ;;
10845 1.1 mrg esac
10846 1.1 mrg func_append newdlprefiles " $abs"
10847 1.1 mrg done
10848 1.1 mrg dlprefiles=$newdlprefiles
10849 1.1 mrg fi
10850 1.1 mrg $RM $output
10851 1.1 mrg # place dlname in correct position for cygwin
10852 1.1 mrg # In fact, it would be nice if we could use this code for all target
10853 1.1 mrg # systems that can't hard-code library paths into their executables
10854 1.1 mrg # and that have no shared library path variable independent of PATH,
10855 1.1 mrg # but it turns out we can't easily determine that from inspecting
10856 1.1 mrg # libtool variables, so we have to hard-code the OSs to which it
10857 1.1 mrg # applies here; at the moment, that means platforms that use the PE
10858 1.1 mrg # object format with DLL files. See the long comment at the top of
10859 1.1 mrg # tests/bindir.at for full details.
10860 1.1 mrg tdlname=$dlname
10861 1.1 mrg case $host,$output,$installed,$module,$dlname in
10862 1.1 mrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10863 1.1 mrg # If a -bindir argument was supplied, place the dll there.
10864 1.1 mrg if test -n "$bindir"; then
10865 1.1 mrg func_relative_path "$install_libdir" "$bindir"
10866 1.1 mrg tdlname=$func_relative_path_result/$dlname
10867 1.1 mrg else
10868 1.1 mrg # Otherwise fall back on heuristic.
10869 1.1 mrg tdlname=../bin/$dlname
10870 1.1 mrg fi
10871 1.1 mrg ;;
10872 1.1 mrg esac
10873 1.1 mrg $ECHO > $output "\
10874 1.1 mrg # $outputname - a libtool library file
10875 1.1 mrg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10876 1.1 mrg #
10877 1.1 mrg # Please DO NOT delete this file!
10878 1.1 mrg # It is necessary for linking the library.
10879 1.1 mrg
10880 1.1 mrg # The name that we can dlopen(3).
10881 1.1 mrg dlname='$tdlname'
10882 1.1 mrg
10883 1.1 mrg # Names of this library.
10884 1.1 mrg library_names='$library_names'
10885 1.1 mrg
10886 1.1 mrg # The name of the static archive.
10887 1.1 mrg old_library='$old_library'
10888 1.1 mrg
10889 1.1 mrg # Linker flags that cannot go in dependency_libs.
10890 1.1 mrg inherited_linker_flags='$new_inherited_linker_flags'
10891 1.1 mrg
10892 1.1 mrg # Libraries that this one depends upon.
10893 1.1 mrg dependency_libs='$dependency_libs'
10894 1.1 mrg
10895 1.1 mrg # Names of additional weak libraries provided by this library
10896 1.1 mrg weak_library_names='$weak_libs'
10897 1.1 mrg
10898 1.1 mrg # Version information for $libname.
10899 1.1 mrg current=$current
10900 1.1 mrg age=$age
10901 1.1 mrg revision=$revision
10902 1.1 mrg
10903 1.1 mrg # Is this an already installed library?
10904 1.1 mrg installed=$installed
10905 1.1 mrg
10906 1.1 mrg # Should we warn about portability when linking against -modules?
10907 1.1 mrg shouldnotlink=$module
10908 1.1 mrg
10909 1.1 mrg # Files to dlopen/dlpreopen
10910 1.1 mrg dlopen='$dlfiles'
10911 1.1 mrg dlpreopen='$dlprefiles'
10912 1.1 mrg
10913 1.1 mrg # Directory that this library needs to be installed in:
10914 1.1 mrg libdir='$install_libdir'"
10915 1.1 mrg if test no,yes = "$installed,$need_relink"; then
10916 1.1 mrg $ECHO >> $output "\
10917 1.1 mrg relink_command=\"$relink_command\""
10918 1.1 mrg fi
10919 1.1 mrg done
10920 1.1 mrg }
10921 1.1 mrg
10922 1.1 mrg # Do a symbolic link so that the libtool archive can be found in
10923 1.1 mrg # LD_LIBRARY_PATH before the program is installed.
10924 1.1 mrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10925 1.1 mrg ;;
10926 1.1 mrg esac
10927 1.1 mrg exit $EXIT_SUCCESS
10928 1.1 mrg }
10929 1.1 mrg
10930 1.1 mrg if test link = "$opt_mode" || test relink = "$opt_mode"; then
10931 1.1 mrg func_mode_link ${1+"$@"}
10932 1.1 mrg fi
10933 1.1 mrg
10934 1.1 mrg
10935 1.1 mrg # func_mode_uninstall arg...
10936 1.1 mrg func_mode_uninstall ()
10937 1.1 mrg {
10938 1.1 mrg $debug_cmd
10939 1.1 mrg
10940 1.1 mrg RM=$nonopt
10941 1.1 mrg files=
10942 1.1 mrg rmforce=false
10943 1.1 mrg exit_status=0
10944 1.1 mrg
10945 1.1 mrg # This variable tells wrapper scripts just to set variables rather
10946 1.1 mrg # than running their programs.
10947 1.1 mrg libtool_install_magic=$magic
10948 1.1 mrg
10949 1.1 mrg for arg
10950 1.1 mrg do
10951 1.1 mrg case $arg in
10952 1.1 mrg -f) func_append RM " $arg"; rmforce=: ;;
10953 1.1 mrg -*) func_append RM " $arg" ;;
10954 1.1 mrg *) func_append files " $arg" ;;
10955 1.1 mrg esac
10956 1.1 mrg done
10957 1.1 mrg
10958 1.1 mrg test -z "$RM" && \
10959 1.1 mrg func_fatal_help "you must specify an RM program"
10960 1.1 mrg
10961 1.1 mrg rmdirs=
10962 1.1 mrg
10963 1.1 mrg for file in $files; do
10964 1.1 mrg func_dirname "$file" "" "."
10965 1.1 mrg dir=$func_dirname_result
10966 1.1 mrg if test . = "$dir"; then
10967 1.1 mrg odir=$objdir
10968 1.1 mrg else
10969 1.1 mrg odir=$dir/$objdir
10970 1.1 mrg fi
10971 1.1 mrg func_basename "$file"
10972 1.1 mrg name=$func_basename_result
10973 1.1 mrg test uninstall = "$opt_mode" && odir=$dir
10974 1.1 mrg
10975 1.1 mrg # Remember odir for removal later, being careful to avoid duplicates
10976 1.1 mrg if test clean = "$opt_mode"; then
10977 1.1 mrg case " $rmdirs " in
10978 1.1 mrg *" $odir "*) ;;
10979 1.1 mrg *) func_append rmdirs " $odir" ;;
10980 1.1 mrg esac
10981 1.1 mrg fi
10982 1.1 mrg
10983 1.1 mrg # Don't error if the file doesn't exist and rm -f was used.
10984 1.1 mrg if { test -L "$file"; } >/dev/null 2>&1 ||
10985 1.1 mrg { test -h "$file"; } >/dev/null 2>&1 ||
10986 1.1 mrg test -f "$file"; then
10987 1.1 mrg :
10988 1.1 mrg elif test -d "$file"; then
10989 1.1 mrg exit_status=1
10990 1.1 mrg continue
10991 1.1 mrg elif $rmforce; then
10992 1.1 mrg continue
10993 1.1 mrg fi
10994 1.1 mrg
10995 1.1 mrg rmfiles=$file
10996 1.1 mrg
10997 1.1 mrg case $name in
10998 1.1 mrg *.la)
10999 1.1 mrg # Possibly a libtool archive, so verify it.
11000 1.1 mrg if func_lalib_p "$file"; then
11001 1.1 mrg func_source $dir/$name
11002 1.1 mrg
11003 1.1 mrg # Delete the libtool libraries and symlinks.
11004 1.1 mrg for n in $library_names; do
11005 1.1 mrg func_append rmfiles " $odir/$n"
11006 1.1 mrg done
11007 1.1 mrg test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11008 1.1 mrg
11009 1.1 mrg case $opt_mode in
11010 1.1 mrg clean)
11011 1.1 mrg case " $library_names " in
11012 1.1 mrg *" $dlname "*) ;;
11013 1.1 mrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11014 1.1 mrg esac
11015 1.1 mrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11016 1.1 mrg ;;
11017 1.1 mrg uninstall)
11018 1.1 mrg if test -n "$library_names"; then
11019 1.1 mrg # Do each command in the postuninstall commands.
11020 1.1 mrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11021 1.1 mrg fi
11022 1.1 mrg
11023 1.1 mrg if test -n "$old_library"; then
11024 1.1 mrg # Do each command in the old_postuninstall commands.
11025 1.1 mrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11026 1.1 mrg fi
11027 1.1 mrg # FIXME: should reinstall the best remaining shared library.
11028 1.1 mrg ;;
11029 1.1 mrg esac
11030 1.1 mrg fi
11031 1.1 mrg ;;
11032 1.1 mrg
11033 1.1 mrg *.lo)
11034 1.1 mrg # Possibly a libtool object, so verify it.
11035 1.1 mrg if func_lalib_p "$file"; then
11036 1.1 mrg
11037 1.1 mrg # Read the .lo file
11038 1.1 mrg func_source $dir/$name
11039 1.1 mrg
11040 1.1 mrg # Add PIC object to the list of files to remove.
11041 1.1 mrg if test -n "$pic_object" && test none != "$pic_object"; then
11042 1.1 mrg func_append rmfiles " $dir/$pic_object"
11043 1.1 mrg fi
11044 1.1 mrg
11045 1.1 mrg # Add non-PIC object to the list of files to remove.
11046 1.1 mrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11047 1.1 mrg func_append rmfiles " $dir/$non_pic_object"
11048 1.1 mrg fi
11049 1.1 mrg fi
11050 1.1 mrg ;;
11051 1.1 mrg
11052 1.1 mrg *)
11053 1.1 mrg if test clean = "$opt_mode"; then
11054 1.1 mrg noexename=$name
11055 1.1 mrg case $file in
11056 1.1 mrg *.exe)
11057 1.1 mrg func_stripname '' '.exe' "$file"
11058 1.1 mrg file=$func_stripname_result
11059 1.1 mrg func_stripname '' '.exe' "$name"
11060 1.1 mrg noexename=$func_stripname_result
11061 1.1 mrg # $file with .exe has already been added to rmfiles,
11062 1.1 mrg # add $file without .exe
11063 1.1 mrg func_append rmfiles " $file"
11064 1.1 mrg ;;
11065 1.1 mrg esac
11066 1.1 mrg # Do a test to see if this is a libtool program.
11067 1.1 mrg if func_ltwrapper_p "$file"; then
11068 1.1 mrg if func_ltwrapper_executable_p "$file"; then
11069 1.1 mrg func_ltwrapper_scriptname "$file"
11070 1.1 mrg relink_command=
11071 1.1 mrg func_source $func_ltwrapper_scriptname_result
11072 1.1 mrg func_append rmfiles " $func_ltwrapper_scriptname_result"
11073 1.1 mrg else
11074 1.1 mrg relink_command=
11075 1.1 mrg func_source $dir/$noexename
11076 1.1 mrg fi
11077 1.1 mrg
11078 1.1 mrg # note $name still contains .exe if it was in $file originally
11079 1.1 mrg # as does the version of $file that was added into $rmfiles
11080 1.1 mrg func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11081 1.1 mrg if test yes = "$fast_install" && test -n "$relink_command"; then
11082 1.1 mrg func_append rmfiles " $odir/lt-$name"
11083 1.1 mrg fi
11084 1.1 mrg if test "X$noexename" != "X$name"; then
11085 1.1 mrg func_append rmfiles " $odir/lt-$noexename.c"
11086 1.1 mrg fi
11087 1.1 mrg fi
11088 1.1 mrg fi
11089 1.1 mrg ;;
11090 1.1 mrg esac
11091 1.1 mrg func_show_eval "$RM $rmfiles" 'exit_status=1'
11092 1.1 mrg done
11093 1.1 mrg
11094 1.1 mrg # Try to remove the $objdir's in the directories where we deleted files
11095 1.1 mrg for dir in $rmdirs; do
11096 1.1 mrg if test -d "$dir"; then
11097 1.1 mrg func_show_eval "rmdir $dir >/dev/null 2>&1"
11098 1.1 mrg fi
11099 1.1 mrg done
11100 1.1 mrg
11101 1.1 mrg exit $exit_status
11102 1.1 mrg }
11103 1.1 mrg
11104 1.1 mrg if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11105 1.1 mrg func_mode_uninstall ${1+"$@"}
11106 1.1 mrg fi
11107 1.1 mrg
11108 1.1 mrg test -z "$opt_mode" && {
11109 1.1 mrg help=$generic_help
11110 1.1 mrg func_fatal_help "you must specify a MODE"
11111 1.1 mrg }
11112 1.1 mrg
11113 1.1 mrg test -z "$exec_cmd" && \
11114 1.1 mrg func_fatal_help "invalid operation mode '$opt_mode'"
11115 1.1 mrg
11116 1.1 mrg if test -n "$exec_cmd"; then
11117 1.1 mrg eval exec "$exec_cmd"
11118 1.1 mrg exit $EXIT_FAILURE
11119 1.1 mrg fi
11120 1.1 mrg
11121 1.1 mrg exit $exit_status
11122 1.1 mrg
11123 1.1 mrg
11124 1.1 mrg # The TAGs below are defined such that we never get into a situation
11125 1.1 mrg # where we disable both kinds of libraries. Given conflicting
11126 1.1 mrg # choices, we go for a static library, that is the most portable,
11127 1.1 mrg # since we can't tell whether shared libraries were disabled because
11128 1.1 mrg # the user asked for that or because the platform doesn't support
11129 1.1 mrg # them. This is particularly important on AIX, because we don't
11130 1.1 mrg # support having both static and shared libraries enabled at the same
11131 1.1 mrg # time on that platform, so we default to a shared-only configuration.
11132 1.1 mrg # If a disable-shared tag is given, we'll fallback to a static-only
11133 1.1 mrg # configuration. But we'll never go from static-only to shared-only.
11134 1.1 mrg
11135 1.1 mrg # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11136 1.1 mrg build_libtool_libs=no
11137 1.1 mrg build_old_libs=yes
11138 1.1 mrg # ### END LIBTOOL TAG CONFIG: disable-shared
11139 1.1 mrg
11140 1.1 mrg # ### BEGIN LIBTOOL TAG CONFIG: disable-static
11141 1.1 mrg build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11142 1.1 mrg # ### END LIBTOOL TAG CONFIG: disable-static
11143 1.1 mrg
11144 1.1 mrg # Local Variables:
11145 1.1 mrg # mode:shell-script
11146 1.1 mrg # sh-indentation:2
11147 1.1 mrg # End:
11148