ltmain.sh revision 1.1 1 1.1 christos #! /bin/sh
2 1.1 christos ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3 1.1 christos ## by inline-source v2014-01-03.01
4 1.1 christos
5 1.1 christos # libtool (GNU libtool) 2.4.6
6 1.1 christos # Provide generalized library-building support services.
7 1.1 christos # Written by Gordon Matzigkeit <gord (at] gnu.ai.mit.edu>, 1996
8 1.1 christos
9 1.1 christos # Copyright (C) 1996-2015 Free Software Foundation, Inc.
10 1.1 christos # This is free software; see the source for copying conditions. There is NO
11 1.1 christos # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 1.1 christos
13 1.1 christos # GNU Libtool is free software; you can redistribute it and/or modify
14 1.1 christos # it under the terms of the GNU General Public License as published by
15 1.1 christos # the Free Software Foundation; either version 2 of the License, or
16 1.1 christos # (at your option) any later version.
17 1.1 christos #
18 1.1 christos # As a special exception to the GNU General Public License,
19 1.1 christos # if you distribute this file as part of a program or library that
20 1.1 christos # is built using GNU Libtool, you may include this file under the
21 1.1 christos # same distribution terms that you use for the rest of that program.
22 1.1 christos #
23 1.1 christos # GNU Libtool is distributed in the hope that it will be useful, but
24 1.1 christos # WITHOUT ANY WARRANTY; without even the implied warranty of
25 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 1.1 christos # General Public License for more details.
27 1.1 christos #
28 1.1 christos # You should have received a copy of the GNU General Public License
29 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
30 1.1 christos
31 1.1 christos
32 1.1 christos PROGRAM=libtool
33 1.1 christos PACKAGE=libtool
34 1.1 christos VERSION=2.4.6
35 1.1 christos package_revision=2.4.6
36 1.1 christos
37 1.1 christos
38 1.1 christos ## ------ ##
39 1.1 christos ## Usage. ##
40 1.1 christos ## ------ ##
41 1.1 christos
42 1.1 christos # Run './libtool --help' for help with using this script from the
43 1.1 christos # command line.
44 1.1 christos
45 1.1 christos
46 1.1 christos ## ------------------------------- ##
47 1.1 christos ## User overridable command paths. ##
48 1.1 christos ## ------------------------------- ##
49 1.1 christos
50 1.1 christos # After configure completes, it has a better idea of some of the
51 1.1 christos # shell tools we need than the defaults used by the functions shared
52 1.1 christos # with bootstrap, so set those here where they can still be over-
53 1.1 christos # ridden by the user, but otherwise take precedence.
54 1.1 christos
55 1.1 christos : ${AUTOCONF="autoconf"}
56 1.1 christos : ${AUTOMAKE="automake"}
57 1.1 christos
58 1.1 christos
59 1.1 christos ## -------------------------- ##
60 1.1 christos ## Source external libraries. ##
61 1.1 christos ## -------------------------- ##
62 1.1 christos
63 1.1 christos # Much of our low-level functionality needs to be sourced from external
64 1.1 christos # libraries, which are installed to $pkgauxdir.
65 1.1 christos
66 1.1 christos # Set a version string for this script.
67 1.1 christos scriptversion=2015-01-20.17; # UTC
68 1.1 christos
69 1.1 christos # General shell script boiler plate, and helper functions.
70 1.1 christos # Written by Gary V. Vaughan, 2004
71 1.1 christos
72 1.1 christos # Copyright (C) 2004-2015 Free Software Foundation, Inc.
73 1.1 christos # This is free software; see the source for copying conditions. There is NO
74 1.1 christos # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
75 1.1 christos
76 1.1 christos # This program is free software; you can redistribute it and/or modify
77 1.1 christos # it under the terms of the GNU General Public License as published by
78 1.1 christos # the Free Software Foundation; either version 3 of the License, or
79 1.1 christos # (at your option) any later version.
80 1.1 christos
81 1.1 christos # As a special exception to the GNU General Public License, if you distribute
82 1.1 christos # this file as part of a program or library that is built using GNU Libtool,
83 1.1 christos # you may include this file under the same distribution terms that you use
84 1.1 christos # for the rest of that program.
85 1.1 christos
86 1.1 christos # This program is distributed in the hope that it will be useful,
87 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
88 1.1 christos # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89 1.1 christos # General Public License for more details.
90 1.1 christos
91 1.1 christos # You should have received a copy of the GNU General Public License
92 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
93 1.1 christos
94 1.1 christos # Please report bugs or propose patches to gary (at] gnu.org.
95 1.1 christos
96 1.1 christos
97 1.1 christos ## ------ ##
98 1.1 christos ## Usage. ##
99 1.1 christos ## ------ ##
100 1.1 christos
101 1.1 christos # Evaluate this file near the top of your script to gain access to
102 1.1 christos # the functions and variables defined here:
103 1.1 christos #
104 1.1 christos # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
105 1.1 christos #
106 1.1 christos # If you need to override any of the default environment variable
107 1.1 christos # settings, do that before evaluating this file.
108 1.1 christos
109 1.1 christos
110 1.1 christos ## -------------------- ##
111 1.1 christos ## Shell normalisation. ##
112 1.1 christos ## -------------------- ##
113 1.1 christos
114 1.1 christos # Some shells need a little help to be as Bourne compatible as possible.
115 1.1 christos # Before doing anything else, make sure all that help has been provided!
116 1.1 christos
117 1.1 christos DUALCASE=1; export DUALCASE # for MKS sh
118 1.1 christos if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
119 1.1 christos emulate sh
120 1.1 christos NULLCMD=:
121 1.1 christos # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
122 1.1 christos # is contrary to our usage. Disable this feature.
123 1.1 christos alias -g '${1+"$@"}'='"$@"'
124 1.1 christos setopt NO_GLOB_SUBST
125 1.1 christos else
126 1.1 christos case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127 1.1 christos fi
128 1.1 christos
129 1.1 christos # NLS nuisances: We save the old values in case they are required later.
130 1.1 christos _G_user_locale=
131 1.1 christos _G_safe_locale=
132 1.1 christos for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
133 1.1 christos do
134 1.1 christos eval "if test set = \"\${$_G_var+set}\"; then
135 1.1 christos save_$_G_var=\$$_G_var
136 1.1 christos $_G_var=C
137 1.1 christos export $_G_var
138 1.1 christos _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139 1.1 christos _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
140 1.1 christos fi"
141 1.1 christos done
142 1.1 christos
143 1.1 christos # CDPATH.
144 1.1 christos (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145 1.1 christos
146 1.1 christos # Make sure IFS has a sensible default
147 1.1 christos sp=' '
148 1.1 christos nl='
149 1.1 christos '
150 1.1 christos IFS="$sp $nl"
151 1.1 christos
152 1.1 christos # There are apparently some retarded systems that use ';' as a PATH separator!
153 1.1 christos if test "${PATH_SEPARATOR+set}" != set; then
154 1.1 christos PATH_SEPARATOR=:
155 1.1 christos (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156 1.1 christos (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
157 1.1 christos PATH_SEPARATOR=';'
158 1.1 christos }
159 1.1 christos fi
160 1.1 christos
161 1.1 christos
162 1.1 christos
163 1.1 christos ## ------------------------- ##
164 1.1 christos ## Locate command utilities. ##
165 1.1 christos ## ------------------------- ##
166 1.1 christos
167 1.1 christos
168 1.1 christos # func_executable_p FILE
169 1.1 christos # ----------------------
170 1.1 christos # Check that FILE is an executable regular file.
171 1.1 christos func_executable_p ()
172 1.1 christos {
173 1.1 christos test -f "$1" && test -x "$1"
174 1.1 christos }
175 1.1 christos
176 1.1 christos
177 1.1 christos # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178 1.1 christos # --------------------------------------------
179 1.1 christos # Search for either a program that responds to --version with output
180 1.1 christos # containing "GNU", or else returned by CHECK_FUNC otherwise, by
181 1.1 christos # trying all the directories in PATH with each of the elements of
182 1.1 christos # PROGS_LIST.
183 1.1 christos #
184 1.1 christos # CHECK_FUNC should accept the path to a candidate program, and
185 1.1 christos # set $func_check_prog_result if it truncates its output less than
186 1.1 christos # $_G_path_prog_max characters.
187 1.1 christos func_path_progs ()
188 1.1 christos {
189 1.1 christos _G_progs_list=$1
190 1.1 christos _G_check_func=$2
191 1.1 christos _G_PATH=${3-"$PATH"}
192 1.1 christos
193 1.1 christos _G_path_prog_max=0
194 1.1 christos _G_path_prog_found=false
195 1.1 christos _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
196 1.1 christos for _G_dir in $_G_PATH; do
197 1.1 christos IFS=$_G_save_IFS
198 1.1 christos test -z "$_G_dir" && _G_dir=.
199 1.1 christos for _G_prog_name in $_G_progs_list; do
200 1.1 christos for _exeext in '' .EXE; do
201 1.1 christos _G_path_prog=$_G_dir/$_G_prog_name$_exeext
202 1.1 christos func_executable_p "$_G_path_prog" || continue
203 1.1 christos case `"$_G_path_prog" --version 2>&1` in
204 1.1 christos *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205 1.1 christos *) $_G_check_func $_G_path_prog
206 1.1 christos func_path_progs_result=$func_check_prog_result
207 1.1 christos ;;
208 1.1 christos esac
209 1.1 christos $_G_path_prog_found && break 3
210 1.1 christos done
211 1.1 christos done
212 1.1 christos done
213 1.1 christos IFS=$_G_save_IFS
214 1.1 christos test -z "$func_path_progs_result" && {
215 1.1 christos echo "no acceptable sed could be found in \$PATH" >&2
216 1.1 christos exit 1
217 1.1 christos }
218 1.1 christos }
219 1.1 christos
220 1.1 christos
221 1.1 christos # We want to be able to use the functions in this file before configure
222 1.1 christos # has figured out where the best binaries are kept, which means we have
223 1.1 christos # to search for them ourselves - except when the results are already set
224 1.1 christos # where we skip the searches.
225 1.1 christos
226 1.1 christos # Unless the user overrides by setting SED, search the path for either GNU
227 1.1 christos # sed, or the sed that truncates its output the least.
228 1.1 christos test -z "$SED" && {
229 1.1 christos _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230 1.1 christos for _G_i in 1 2 3 4 5 6 7; do
231 1.1 christos _G_sed_script=$_G_sed_script$nl$_G_sed_script
232 1.1 christos done
233 1.1 christos echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
234 1.1 christos _G_sed_script=
235 1.1 christos
236 1.1 christos func_check_prog_sed ()
237 1.1 christos {
238 1.1 christos _G_path_prog=$1
239 1.1 christos
240 1.1 christos _G_count=0
241 1.1 christos printf 0123456789 >conftest.in
242 1.1 christos while :
243 1.1 christos do
244 1.1 christos cat conftest.in conftest.in >conftest.tmp
245 1.1 christos mv conftest.tmp conftest.in
246 1.1 christos cp conftest.in conftest.nl
247 1.1 christos echo '' >> conftest.nl
248 1.1 christos "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249 1.1 christos diff conftest.out conftest.nl >/dev/null 2>&1 || break
250 1.1 christos _G_count=`expr $_G_count + 1`
251 1.1 christos if test "$_G_count" -gt "$_G_path_prog_max"; then
252 1.1 christos # Best one so far, save it but keep looking for a better one
253 1.1 christos func_check_prog_result=$_G_path_prog
254 1.1 christos _G_path_prog_max=$_G_count
255 1.1 christos fi
256 1.1 christos # 10*(2^10) chars as input seems more than enough
257 1.1 christos test 10 -lt "$_G_count" && break
258 1.1 christos done
259 1.1 christos rm -f conftest.in conftest.tmp conftest.nl conftest.out
260 1.1 christos }
261 1.1 christos
262 1.1 christos func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
263 1.1 christos rm -f conftest.sed
264 1.1 christos SED=$func_path_progs_result
265 1.1 christos }
266 1.1 christos
267 1.1 christos
268 1.1 christos # Unless the user overrides by setting GREP, search the path for either GNU
269 1.1 christos # grep, or the grep that truncates its output the least.
270 1.1 christos test -z "$GREP" && {
271 1.1 christos func_check_prog_grep ()
272 1.1 christos {
273 1.1 christos _G_path_prog=$1
274 1.1 christos
275 1.1 christos _G_count=0
276 1.1 christos _G_path_prog_max=0
277 1.1 christos printf 0123456789 >conftest.in
278 1.1 christos while :
279 1.1 christos do
280 1.1 christos cat conftest.in conftest.in >conftest.tmp
281 1.1 christos mv conftest.tmp conftest.in
282 1.1 christos cp conftest.in conftest.nl
283 1.1 christos echo 'GREP' >> conftest.nl
284 1.1 christos "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285 1.1 christos diff conftest.out conftest.nl >/dev/null 2>&1 || break
286 1.1 christos _G_count=`expr $_G_count + 1`
287 1.1 christos if test "$_G_count" -gt "$_G_path_prog_max"; then
288 1.1 christos # Best one so far, save it but keep looking for a better one
289 1.1 christos func_check_prog_result=$_G_path_prog
290 1.1 christos _G_path_prog_max=$_G_count
291 1.1 christos fi
292 1.1 christos # 10*(2^10) chars as input seems more than enough
293 1.1 christos test 10 -lt "$_G_count" && break
294 1.1 christos done
295 1.1 christos rm -f conftest.in conftest.tmp conftest.nl conftest.out
296 1.1 christos }
297 1.1 christos
298 1.1 christos func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299 1.1 christos GREP=$func_path_progs_result
300 1.1 christos }
301 1.1 christos
302 1.1 christos
303 1.1 christos ## ------------------------------- ##
304 1.1 christos ## User overridable command paths. ##
305 1.1 christos ## ------------------------------- ##
306 1.1 christos
307 1.1 christos # All uppercase variable names are used for environment variables. These
308 1.1 christos # variables can be overridden by the user before calling a script that
309 1.1 christos # uses them if a suitable command of that name is not already available
310 1.1 christos # in the command search PATH.
311 1.1 christos
312 1.1 christos : ${CP="cp -f"}
313 1.1 christos : ${ECHO="printf %s\n"}
314 1.1 christos : ${EGREP="$GREP -E"}
315 1.1 christos : ${FGREP="$GREP -F"}
316 1.1 christos : ${LN_S="ln -s"}
317 1.1 christos : ${MAKE="make"}
318 1.1 christos : ${MKDIR="mkdir"}
319 1.1 christos : ${MV="mv -f"}
320 1.1 christos : ${RM="rm -f"}
321 1.1 christos : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322 1.1 christos
323 1.1 christos
324 1.1 christos ## -------------------- ##
325 1.1 christos ## Useful sed snippets. ##
326 1.1 christos ## -------------------- ##
327 1.1 christos
328 1.1 christos sed_dirname='s|/[^/]*$||'
329 1.1 christos sed_basename='s|^.*/||'
330 1.1 christos
331 1.1 christos # Sed substitution that helps us do robust quoting. It backslashifies
332 1.1 christos # metacharacters that are still active within double-quoted strings.
333 1.1 christos sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334 1.1 christos
335 1.1 christos # Same as above, but do not quote variable references.
336 1.1 christos sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337 1.1 christos
338 1.1 christos # Sed substitution that turns a string into a regex matching for the
339 1.1 christos # string literally.
340 1.1 christos sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341 1.1 christos
342 1.1 christos # Sed substitution that converts a w32 file name or path
343 1.1 christos # that contains forward slashes, into one that contains
344 1.1 christos # (escaped) backslashes. A very naive implementation.
345 1.1 christos sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
346 1.1 christos
347 1.1 christos # Re-'\' parameter expansions in output of sed_double_quote_subst that
348 1.1 christos # were '\'-ed in input to the same. If an odd number of '\' preceded a
349 1.1 christos # '$' in input to sed_double_quote_subst, that '$' was protected from
350 1.1 christos # expansion. Since each input '\' is now two '\'s, look for any number
351 1.1 christos # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
352 1.1 christos _G_bs='\\'
353 1.1 christos _G_bs2='\\\\'
354 1.1 christos _G_bs4='\\\\\\\\'
355 1.1 christos _G_dollar='\$'
356 1.1 christos sed_double_backslash="\
357 1.1 christos s/$_G_bs4/&\\
358 1.1 christos /g
359 1.1 christos s/^$_G_bs2$_G_dollar/$_G_bs&/
360 1.1 christos s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
361 1.1 christos s/\n//g"
362 1.1 christos
363 1.1 christos
364 1.1 christos ## ----------------- ##
365 1.1 christos ## Global variables. ##
366 1.1 christos ## ----------------- ##
367 1.1 christos
368 1.1 christos # Except for the global variables explicitly listed below, the following
369 1.1 christos # functions in the '^func_' namespace, and the '^require_' namespace
370 1.1 christos # variables initialised in the 'Resource management' section, sourcing
371 1.1 christos # this file will not pollute your global namespace with anything
372 1.1 christos # else. There's no portable way to scope variables in Bourne shell
373 1.1 christos # though, so actually running these functions will sometimes place
374 1.1 christos # results into a variable named after the function, and often use
375 1.1 christos # temporary variables in the '^_G_' namespace. If you are careful to
376 1.1 christos # avoid using those namespaces casually in your sourcing script, things
377 1.1 christos # should continue to work as you expect. And, of course, you can freely
378 1.1 christos # overwrite any of the functions or variables defined here before
379 1.1 christos # calling anything to customize them.
380 1.1 christos
381 1.1 christos EXIT_SUCCESS=0
382 1.1 christos EXIT_FAILURE=1
383 1.1 christos EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
384 1.1 christos EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
385 1.1 christos
386 1.1 christos # Allow overriding, eg assuming that you follow the convention of
387 1.1 christos # putting '$debug_cmd' at the start of all your functions, you can get
388 1.1 christos # bash to show function call trace with:
389 1.1 christos #
390 1.1 christos # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391 1.1 christos debug_cmd=${debug_cmd-":"}
392 1.1 christos exit_cmd=:
393 1.1 christos
394 1.1 christos # By convention, finish your script with:
395 1.1 christos #
396 1.1 christos # exit $exit_status
397 1.1 christos #
398 1.1 christos # so that you can set exit_status to non-zero if you want to indicate
399 1.1 christos # something went wrong during execution without actually bailing out at
400 1.1 christos # the point of failure.
401 1.1 christos exit_status=$EXIT_SUCCESS
402 1.1 christos
403 1.1 christos # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404 1.1 christos # is ksh but when the shell is invoked as "sh" and the current value of
405 1.1 christos # the _XPG environment variable is not equal to 1 (one), the special
406 1.1 christos # positional parameter $0, within a function call, is the name of the
407 1.1 christos # function.
408 1.1 christos progpath=$0
409 1.1 christos
410 1.1 christos # The name of this program.
411 1.1 christos progname=`$ECHO "$progpath" |$SED "$sed_basename"`
412 1.1 christos
413 1.1 christos # Make sure we have an absolute progpath for reexecution:
414 1.1 christos case $progpath in
415 1.1 christos [\\/]*|[A-Za-z]:\\*) ;;
416 1.1 christos *[\\/]*)
417 1.1 christos progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418 1.1 christos progdir=`cd "$progdir" && pwd`
419 1.1 christos progpath=$progdir/$progname
420 1.1 christos ;;
421 1.1 christos *)
422 1.1 christos _G_IFS=$IFS
423 1.1 christos IFS=${PATH_SEPARATOR-:}
424 1.1 christos for progdir in $PATH; do
425 1.1 christos IFS=$_G_IFS
426 1.1 christos test -x "$progdir/$progname" && break
427 1.1 christos done
428 1.1 christos IFS=$_G_IFS
429 1.1 christos test -n "$progdir" || progdir=`pwd`
430 1.1 christos progpath=$progdir/$progname
431 1.1 christos ;;
432 1.1 christos esac
433 1.1 christos
434 1.1 christos
435 1.1 christos ## ----------------- ##
436 1.1 christos ## Standard options. ##
437 1.1 christos ## ----------------- ##
438 1.1 christos
439 1.1 christos # The following options affect the operation of the functions defined
440 1.1 christos # below, and should be set appropriately depending on run-time para-
441 1.1 christos # meters passed on the command line.
442 1.1 christos
443 1.1 christos opt_dry_run=false
444 1.1 christos opt_quiet=false
445 1.1 christos opt_verbose=false
446 1.1 christos
447 1.1 christos # Categories 'all' and 'none' are always available. Append any others
448 1.1 christos # you will pass as the first argument to func_warning from your own
449 1.1 christos # code.
450 1.1 christos warning_categories=
451 1.1 christos
452 1.1 christos # By default, display warnings according to 'opt_warning_types'. Set
453 1.1 christos # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
454 1.1 christos # treat the next displayed warning as a fatal error.
455 1.1 christos warning_func=func_warn_and_continue
456 1.1 christos
457 1.1 christos # Set to 'all' to display all warnings, 'none' to suppress all
458 1.1 christos # warnings, or a space delimited list of some subset of
459 1.1 christos # 'warning_categories' to display only the listed warnings.
460 1.1 christos opt_warning_types=all
461 1.1 christos
462 1.1 christos
463 1.1 christos ## -------------------- ##
464 1.1 christos ## Resource management. ##
465 1.1 christos ## -------------------- ##
466 1.1 christos
467 1.1 christos # This section contains definitions for functions that each ensure a
468 1.1 christos # particular resource (a file, or a non-empty configuration variable for
469 1.1 christos # example) is available, and if appropriate to extract default values
470 1.1 christos # from pertinent package files. Call them using their associated
471 1.1 christos # 'require_*' variable to ensure that they are executed, at most, once.
472 1.1 christos #
473 1.1 christos # It's entirely deliberate that calling these functions can set
474 1.1 christos # variables that don't obey the namespace limitations obeyed by the rest
475 1.1 christos # of this file, in order that that they be as useful as possible to
476 1.1 christos # callers.
477 1.1 christos
478 1.1 christos
479 1.1 christos # require_term_colors
480 1.1 christos # -------------------
481 1.1 christos # Allow display of bold text on terminals that support it.
482 1.1 christos require_term_colors=func_require_term_colors
483 1.1 christos func_require_term_colors ()
484 1.1 christos {
485 1.1 christos $debug_cmd
486 1.1 christos
487 1.1 christos test -t 1 && {
488 1.1 christos # COLORTERM and USE_ANSI_COLORS environment variables take
489 1.1 christos # precedence, because most terminfo databases neglect to describe
490 1.1 christos # whether color sequences are supported.
491 1.1 christos test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
492 1.1 christos
493 1.1 christos if test 1 = "$USE_ANSI_COLORS"; then
494 1.1 christos # Standard ANSI escape sequences
495 1.1 christos tc_reset='[0m'
496 1.1 christos tc_bold='[1m'; tc_standout='[7m'
497 1.1 christos tc_red='[31m'; tc_green='[32m'
498 1.1 christos tc_blue='[34m'; tc_cyan='[36m'
499 1.1 christos else
500 1.1 christos # Otherwise trust the terminfo database after all.
501 1.1 christos test -n "`tput sgr0 2>/dev/null`" && {
502 1.1 christos tc_reset=`tput sgr0`
503 1.1 christos test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
504 1.1 christos tc_standout=$tc_bold
505 1.1 christos test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506 1.1 christos test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507 1.1 christos test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508 1.1 christos test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509 1.1 christos test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
510 1.1 christos }
511 1.1 christos fi
512 1.1 christos }
513 1.1 christos
514 1.1 christos require_term_colors=:
515 1.1 christos }
516 1.1 christos
517 1.1 christos
518 1.1 christos ## ----------------- ##
519 1.1 christos ## Function library. ##
520 1.1 christos ## ----------------- ##
521 1.1 christos
522 1.1 christos # This section contains a variety of useful functions to call in your
523 1.1 christos # scripts. Take note of the portable wrappers for features provided by
524 1.1 christos # some modern shells, which will fall back to slower equivalents on
525 1.1 christos # less featureful shells.
526 1.1 christos
527 1.1 christos
528 1.1 christos # func_append VAR VALUE
529 1.1 christos # ---------------------
530 1.1 christos # Append VALUE onto the existing contents of VAR.
531 1.1 christos
532 1.1 christos # We should try to minimise forks, especially on Windows where they are
533 1.1 christos # unreasonably slow, so skip the feature probes when bash or zsh are
534 1.1 christos # being used:
535 1.1 christos if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536 1.1 christos : ${_G_HAVE_ARITH_OP="yes"}
537 1.1 christos : ${_G_HAVE_XSI_OPS="yes"}
538 1.1 christos # The += operator was introduced in bash 3.1
539 1.1 christos case $BASH_VERSION in
540 1.1 christos [12].* | 3.0 | 3.0*) ;;
541 1.1 christos *)
542 1.1 christos : ${_G_HAVE_PLUSEQ_OP="yes"}
543 1.1 christos ;;
544 1.1 christos esac
545 1.1 christos fi
546 1.1 christos
547 1.1 christos # _G_HAVE_PLUSEQ_OP
548 1.1 christos # Can be empty, in which case the shell is probed, "yes" if += is
549 1.1 christos # useable or anything else if it does not work.
550 1.1 christos test -z "$_G_HAVE_PLUSEQ_OP" \
551 1.1 christos && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552 1.1 christos && _G_HAVE_PLUSEQ_OP=yes
553 1.1 christos
554 1.1 christos if test yes = "$_G_HAVE_PLUSEQ_OP"
555 1.1 christos then
556 1.1 christos # This is an XSI compatible shell, allowing a faster implementation...
557 1.1 christos eval 'func_append ()
558 1.1 christos {
559 1.1 christos $debug_cmd
560 1.1 christos
561 1.1 christos eval "$1+=\$2"
562 1.1 christos }'
563 1.1 christos else
564 1.1 christos # ...otherwise fall back to using expr, which is often a shell builtin.
565 1.1 christos func_append ()
566 1.1 christos {
567 1.1 christos $debug_cmd
568 1.1 christos
569 1.1 christos eval "$1=\$$1\$2"
570 1.1 christos }
571 1.1 christos fi
572 1.1 christos
573 1.1 christos
574 1.1 christos # func_append_quoted VAR VALUE
575 1.1 christos # ----------------------------
576 1.1 christos # Quote VALUE and append to the end of shell variable VAR, separated
577 1.1 christos # by a space.
578 1.1 christos if test yes = "$_G_HAVE_PLUSEQ_OP"; then
579 1.1 christos eval 'func_append_quoted ()
580 1.1 christos {
581 1.1 christos $debug_cmd
582 1.1 christos
583 1.1 christos func_quote_for_eval "$2"
584 1.1 christos eval "$1+=\\ \$func_quote_for_eval_result"
585 1.1 christos }'
586 1.1 christos else
587 1.1 christos func_append_quoted ()
588 1.1 christos {
589 1.1 christos $debug_cmd
590 1.1 christos
591 1.1 christos func_quote_for_eval "$2"
592 1.1 christos eval "$1=\$$1\\ \$func_quote_for_eval_result"
593 1.1 christos }
594 1.1 christos fi
595 1.1 christos
596 1.1 christos
597 1.1 christos # func_append_uniq VAR VALUE
598 1.1 christos # --------------------------
599 1.1 christos # Append unique VALUE onto the existing contents of VAR, assuming
600 1.1 christos # entries are delimited by the first character of VALUE. For example:
601 1.1 christos #
602 1.1 christos # func_append_uniq options " --another-option option-argument"
603 1.1 christos #
604 1.1 christos # will only append to $options if " --another-option option-argument "
605 1.1 christos # is not already present somewhere in $options already (note spaces at
606 1.1 christos # each end implied by leading space in second argument).
607 1.1 christos func_append_uniq ()
608 1.1 christos {
609 1.1 christos $debug_cmd
610 1.1 christos
611 1.1 christos eval _G_current_value='`$ECHO $'$1'`'
612 1.1 christos _G_delim=`expr "$2" : '\(.\)'`
613 1.1 christos
614 1.1 christos case $_G_delim$_G_current_value$_G_delim in
615 1.1 christos *"$2$_G_delim"*) ;;
616 1.1 christos *) func_append "$@" ;;
617 1.1 christos esac
618 1.1 christos }
619 1.1 christos
620 1.1 christos
621 1.1 christos # func_arith TERM...
622 1.1 christos # ------------------
623 1.1 christos # Set func_arith_result to the result of evaluating TERMs.
624 1.1 christos test -z "$_G_HAVE_ARITH_OP" \
625 1.1 christos && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626 1.1 christos && _G_HAVE_ARITH_OP=yes
627 1.1 christos
628 1.1 christos if test yes = "$_G_HAVE_ARITH_OP"; then
629 1.1 christos eval 'func_arith ()
630 1.1 christos {
631 1.1 christos $debug_cmd
632 1.1 christos
633 1.1 christos func_arith_result=$(( $* ))
634 1.1 christos }'
635 1.1 christos else
636 1.1 christos func_arith ()
637 1.1 christos {
638 1.1 christos $debug_cmd
639 1.1 christos
640 1.1 christos func_arith_result=`expr "$@"`
641 1.1 christos }
642 1.1 christos fi
643 1.1 christos
644 1.1 christos
645 1.1 christos # func_basename FILE
646 1.1 christos # ------------------
647 1.1 christos # Set func_basename_result to FILE with everything up to and including
648 1.1 christos # the last / stripped.
649 1.1 christos if test yes = "$_G_HAVE_XSI_OPS"; then
650 1.1 christos # If this shell supports suffix pattern removal, then use it to avoid
651 1.1 christos # forking. Hide the definitions single quotes in case the shell chokes
652 1.1 christos # on unsupported syntax...
653 1.1 christos _b='func_basename_result=${1##*/}'
654 1.1 christos _d='case $1 in
655 1.1 christos */*) func_dirname_result=${1%/*}$2 ;;
656 1.1 christos * ) func_dirname_result=$3 ;;
657 1.1 christos esac'
658 1.1 christos
659 1.1 christos else
660 1.1 christos # ...otherwise fall back to using sed.
661 1.1 christos _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662 1.1 christos _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
663 1.1 christos if test "X$func_dirname_result" = "X$1"; then
664 1.1 christos func_dirname_result=$3
665 1.1 christos else
666 1.1 christos func_append func_dirname_result "$2"
667 1.1 christos fi'
668 1.1 christos fi
669 1.1 christos
670 1.1 christos eval 'func_basename ()
671 1.1 christos {
672 1.1 christos $debug_cmd
673 1.1 christos
674 1.1 christos '"$_b"'
675 1.1 christos }'
676 1.1 christos
677 1.1 christos
678 1.1 christos # func_dirname FILE APPEND NONDIR_REPLACEMENT
679 1.1 christos # -------------------------------------------
680 1.1 christos # Compute the dirname of FILE. If nonempty, add APPEND to the result,
681 1.1 christos # otherwise set result to NONDIR_REPLACEMENT.
682 1.1 christos eval 'func_dirname ()
683 1.1 christos {
684 1.1 christos $debug_cmd
685 1.1 christos
686 1.1 christos '"$_d"'
687 1.1 christos }'
688 1.1 christos
689 1.1 christos
690 1.1 christos # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691 1.1 christos # --------------------------------------------------------
692 1.1 christos # Perform func_basename and func_dirname in a single function
693 1.1 christos # call:
694 1.1 christos # dirname: Compute the dirname of FILE. If nonempty,
695 1.1 christos # add APPEND to the result, otherwise set result
696 1.1 christos # to NONDIR_REPLACEMENT.
697 1.1 christos # value returned in "$func_dirname_result"
698 1.1 christos # basename: Compute filename of FILE.
699 1.1 christos # value retuned in "$func_basename_result"
700 1.1 christos # For efficiency, we do not delegate to the functions above but instead
701 1.1 christos # duplicate the functionality here.
702 1.1 christos eval 'func_dirname_and_basename ()
703 1.1 christos {
704 1.1 christos $debug_cmd
705 1.1 christos
706 1.1 christos '"$_b"'
707 1.1 christos '"$_d"'
708 1.1 christos }'
709 1.1 christos
710 1.1 christos
711 1.1 christos # func_echo ARG...
712 1.1 christos # ----------------
713 1.1 christos # Echo program name prefixed message.
714 1.1 christos func_echo ()
715 1.1 christos {
716 1.1 christos $debug_cmd
717 1.1 christos
718 1.1 christos _G_message=$*
719 1.1 christos
720 1.1 christos func_echo_IFS=$IFS
721 1.1 christos IFS=$nl
722 1.1 christos for _G_line in $_G_message; do
723 1.1 christos IFS=$func_echo_IFS
724 1.1 christos $ECHO "$progname: $_G_line"
725 1.1 christos done
726 1.1 christos IFS=$func_echo_IFS
727 1.1 christos }
728 1.1 christos
729 1.1 christos
730 1.1 christos # func_echo_all ARG...
731 1.1 christos # --------------------
732 1.1 christos # Invoke $ECHO with all args, space-separated.
733 1.1 christos func_echo_all ()
734 1.1 christos {
735 1.1 christos $ECHO "$*"
736 1.1 christos }
737 1.1 christos
738 1.1 christos
739 1.1 christos # func_echo_infix_1 INFIX ARG...
740 1.1 christos # ------------------------------
741 1.1 christos # Echo program name, followed by INFIX on the first line, with any
742 1.1 christos # additional lines not showing INFIX.
743 1.1 christos func_echo_infix_1 ()
744 1.1 christos {
745 1.1 christos $debug_cmd
746 1.1 christos
747 1.1 christos $require_term_colors
748 1.1 christos
749 1.1 christos _G_infix=$1; shift
750 1.1 christos _G_indent=$_G_infix
751 1.1 christos _G_prefix="$progname: $_G_infix: "
752 1.1 christos _G_message=$*
753 1.1 christos
754 1.1 christos # Strip color escape sequences before counting printable length
755 1.1 christos for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
756 1.1 christos do
757 1.1 christos test -n "$_G_tc" && {
758 1.1 christos _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759 1.1 christos _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
760 1.1 christos }
761 1.1 christos done
762 1.1 christos _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
763 1.1 christos
764 1.1 christos func_echo_infix_1_IFS=$IFS
765 1.1 christos IFS=$nl
766 1.1 christos for _G_line in $_G_message; do
767 1.1 christos IFS=$func_echo_infix_1_IFS
768 1.1 christos $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
769 1.1 christos _G_prefix=$_G_indent
770 1.1 christos done
771 1.1 christos IFS=$func_echo_infix_1_IFS
772 1.1 christos }
773 1.1 christos
774 1.1 christos
775 1.1 christos # func_error ARG...
776 1.1 christos # -----------------
777 1.1 christos # Echo program name prefixed message to standard error.
778 1.1 christos func_error ()
779 1.1 christos {
780 1.1 christos $debug_cmd
781 1.1 christos
782 1.1 christos $require_term_colors
783 1.1 christos
784 1.1 christos func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
785 1.1 christos }
786 1.1 christos
787 1.1 christos
788 1.1 christos # func_fatal_error ARG...
789 1.1 christos # -----------------------
790 1.1 christos # Echo program name prefixed message to standard error, and exit.
791 1.1 christos func_fatal_error ()
792 1.1 christos {
793 1.1 christos $debug_cmd
794 1.1 christos
795 1.1 christos func_error "$*"
796 1.1 christos exit $EXIT_FAILURE
797 1.1 christos }
798 1.1 christos
799 1.1 christos
800 1.1 christos # func_grep EXPRESSION FILENAME
801 1.1 christos # -----------------------------
802 1.1 christos # Check whether EXPRESSION matches any line of FILENAME, without output.
803 1.1 christos func_grep ()
804 1.1 christos {
805 1.1 christos $debug_cmd
806 1.1 christos
807 1.1 christos $GREP "$1" "$2" >/dev/null 2>&1
808 1.1 christos }
809 1.1 christos
810 1.1 christos
811 1.1 christos # func_len STRING
812 1.1 christos # ---------------
813 1.1 christos # Set func_len_result to the length of STRING. STRING may not
814 1.1 christos # start with a hyphen.
815 1.1 christos test -z "$_G_HAVE_XSI_OPS" \
816 1.1 christos && (eval 'x=a/b/c;
817 1.1 christos test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818 1.1 christos && _G_HAVE_XSI_OPS=yes
819 1.1 christos
820 1.1 christos if test yes = "$_G_HAVE_XSI_OPS"; then
821 1.1 christos eval 'func_len ()
822 1.1 christos {
823 1.1 christos $debug_cmd
824 1.1 christos
825 1.1 christos func_len_result=${#1}
826 1.1 christos }'
827 1.1 christos else
828 1.1 christos func_len ()
829 1.1 christos {
830 1.1 christos $debug_cmd
831 1.1 christos
832 1.1 christos func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
833 1.1 christos }
834 1.1 christos fi
835 1.1 christos
836 1.1 christos
837 1.1 christos # func_mkdir_p DIRECTORY-PATH
838 1.1 christos # ---------------------------
839 1.1 christos # Make sure the entire path to DIRECTORY-PATH is available.
840 1.1 christos func_mkdir_p ()
841 1.1 christos {
842 1.1 christos $debug_cmd
843 1.1 christos
844 1.1 christos _G_directory_path=$1
845 1.1 christos _G_dir_list=
846 1.1 christos
847 1.1 christos if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
848 1.1 christos
849 1.1 christos # Protect directory names starting with '-'
850 1.1 christos case $_G_directory_path in
851 1.1 christos -*) _G_directory_path=./$_G_directory_path ;;
852 1.1 christos esac
853 1.1 christos
854 1.1 christos # While some portion of DIR does not yet exist...
855 1.1 christos while test ! -d "$_G_directory_path"; do
856 1.1 christos # ...make a list in topmost first order. Use a colon delimited
857 1.1 christos # list incase some portion of path contains whitespace.
858 1.1 christos _G_dir_list=$_G_directory_path:$_G_dir_list
859 1.1 christos
860 1.1 christos # If the last portion added has no slash in it, the list is done
861 1.1 christos case $_G_directory_path in */*) ;; *) break ;; esac
862 1.1 christos
863 1.1 christos # ...otherwise throw away the child directory and loop
864 1.1 christos _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865 1.1 christos done
866 1.1 christos _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867 1.1 christos
868 1.1 christos func_mkdir_p_IFS=$IFS; IFS=:
869 1.1 christos for _G_dir in $_G_dir_list; do
870 1.1 christos IFS=$func_mkdir_p_IFS
871 1.1 christos # mkdir can fail with a 'File exist' error if two processes
872 1.1 christos # try to create one of the directories concurrently. Don't
873 1.1 christos # stop in that case!
874 1.1 christos $MKDIR "$_G_dir" 2>/dev/null || :
875 1.1 christos done
876 1.1 christos IFS=$func_mkdir_p_IFS
877 1.1 christos
878 1.1 christos # Bail out if we (or some other process) failed to create a directory.
879 1.1 christos test -d "$_G_directory_path" || \
880 1.1 christos func_fatal_error "Failed to create '$1'"
881 1.1 christos fi
882 1.1 christos }
883 1.1 christos
884 1.1 christos
885 1.1 christos # func_mktempdir [BASENAME]
886 1.1 christos # -------------------------
887 1.1 christos # Make a temporary directory that won't clash with other running
888 1.1 christos # libtool processes, and avoids race conditions if possible. If
889 1.1 christos # given, BASENAME is the basename for that directory.
890 1.1 christos func_mktempdir ()
891 1.1 christos {
892 1.1 christos $debug_cmd
893 1.1 christos
894 1.1 christos _G_template=${TMPDIR-/tmp}/${1-$progname}
895 1.1 christos
896 1.1 christos if test : = "$opt_dry_run"; then
897 1.1 christos # Return a directory name, but don't create it in dry-run mode
898 1.1 christos _G_tmpdir=$_G_template-$$
899 1.1 christos else
900 1.1 christos
901 1.1 christos # If mktemp works, use that first and foremost
902 1.1 christos _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903 1.1 christos
904 1.1 christos if test ! -d "$_G_tmpdir"; then
905 1.1 christos # Failing that, at least try and use $RANDOM to avoid a race
906 1.1 christos _G_tmpdir=$_G_template-${RANDOM-0}$$
907 1.1 christos
908 1.1 christos func_mktempdir_umask=`umask`
909 1.1 christos umask 0077
910 1.1 christos $MKDIR "$_G_tmpdir"
911 1.1 christos umask $func_mktempdir_umask
912 1.1 christos fi
913 1.1 christos
914 1.1 christos # If we're not in dry-run mode, bomb out on failure
915 1.1 christos test -d "$_G_tmpdir" || \
916 1.1 christos func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
917 1.1 christos fi
918 1.1 christos
919 1.1 christos $ECHO "$_G_tmpdir"
920 1.1 christos }
921 1.1 christos
922 1.1 christos
923 1.1 christos # func_normal_abspath PATH
924 1.1 christos # ------------------------
925 1.1 christos # Remove doubled-up and trailing slashes, "." path components,
926 1.1 christos # and cancel out any ".." path components in PATH after making
927 1.1 christos # it an absolute path.
928 1.1 christos func_normal_abspath ()
929 1.1 christos {
930 1.1 christos $debug_cmd
931 1.1 christos
932 1.1 christos # These SED scripts presuppose an absolute path with a trailing slash.
933 1.1 christos _G_pathcar='s|^/\([^/]*\).*$|\1|'
934 1.1 christos _G_pathcdr='s|^/[^/]*||'
935 1.1 christos _G_removedotparts=':dotsl
936 1.1 christos s|/\./|/|g
937 1.1 christos t dotsl
938 1.1 christos s|/\.$|/|'
939 1.1 christos _G_collapseslashes='s|/\{1,\}|/|g'
940 1.1 christos _G_finalslash='s|/*$|/|'
941 1.1 christos
942 1.1 christos # Start from root dir and reassemble the path.
943 1.1 christos func_normal_abspath_result=
944 1.1 christos func_normal_abspath_tpath=$1
945 1.1 christos func_normal_abspath_altnamespace=
946 1.1 christos case $func_normal_abspath_tpath in
947 1.1 christos "")
948 1.1 christos # Empty path, that just means $cwd.
949 1.1 christos func_stripname '' '/' "`pwd`"
950 1.1 christos func_normal_abspath_result=$func_stripname_result
951 1.1 christos return
952 1.1 christos ;;
953 1.1 christos # The next three entries are used to spot a run of precisely
954 1.1 christos # two leading slashes without using negated character classes;
955 1.1 christos # we take advantage of case's first-match behaviour.
956 1.1 christos ///*)
957 1.1 christos # Unusual form of absolute path, do nothing.
958 1.1 christos ;;
959 1.1 christos //*)
960 1.1 christos # Not necessarily an ordinary path; POSIX reserves leading '//'
961 1.1 christos # and for example Cygwin uses it to access remote file shares
962 1.1 christos # over CIFS/SMB, so we conserve a leading double slash if found.
963 1.1 christos func_normal_abspath_altnamespace=/
964 1.1 christos ;;
965 1.1 christos /*)
966 1.1 christos # Absolute path, do nothing.
967 1.1 christos ;;
968 1.1 christos *)
969 1.1 christos # Relative path, prepend $cwd.
970 1.1 christos func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
971 1.1 christos ;;
972 1.1 christos esac
973 1.1 christos
974 1.1 christos # Cancel out all the simple stuff to save iterations. We also want
975 1.1 christos # the path to end with a slash for ease of parsing, so make sure
976 1.1 christos # there is one (and only one) here.
977 1.1 christos func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978 1.1 christos -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
979 1.1 christos while :; do
980 1.1 christos # Processed it all yet?
981 1.1 christos if test / = "$func_normal_abspath_tpath"; then
982 1.1 christos # If we ascended to the root using ".." the result may be empty now.
983 1.1 christos if test -z "$func_normal_abspath_result"; then
984 1.1 christos func_normal_abspath_result=/
985 1.1 christos fi
986 1.1 christos break
987 1.1 christos fi
988 1.1 christos func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
989 1.1 christos -e "$_G_pathcar"`
990 1.1 christos func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
991 1.1 christos -e "$_G_pathcdr"`
992 1.1 christos # Figure out what to do with it
993 1.1 christos case $func_normal_abspath_tcomponent in
994 1.1 christos "")
995 1.1 christos # Trailing empty path component, ignore it.
996 1.1 christos ;;
997 1.1 christos ..)
998 1.1 christos # Parent dir; strip last assembled component from result.
999 1.1 christos func_dirname "$func_normal_abspath_result"
1000 1.1 christos func_normal_abspath_result=$func_dirname_result
1001 1.1 christos ;;
1002 1.1 christos *)
1003 1.1 christos # Actual path component, append it.
1004 1.1 christos func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1005 1.1 christos ;;
1006 1.1 christos esac
1007 1.1 christos done
1008 1.1 christos # Restore leading double-slash if one was found on entry.
1009 1.1 christos func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1010 1.1 christos }
1011 1.1 christos
1012 1.1 christos
1013 1.1 christos # func_notquiet ARG...
1014 1.1 christos # --------------------
1015 1.1 christos # Echo program name prefixed message only when not in quiet mode.
1016 1.1 christos func_notquiet ()
1017 1.1 christos {
1018 1.1 christos $debug_cmd
1019 1.1 christos
1020 1.1 christos $opt_quiet || func_echo ${1+"$@"}
1021 1.1 christos
1022 1.1 christos # A bug in bash halts the script if the last line of a function
1023 1.1 christos # fails when set -e is in force, so we need another command to
1024 1.1 christos # work around that:
1025 1.1 christos :
1026 1.1 christos }
1027 1.1 christos
1028 1.1 christos
1029 1.1 christos # func_relative_path SRCDIR DSTDIR
1030 1.1 christos # --------------------------------
1031 1.1 christos # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032 1.1 christos func_relative_path ()
1033 1.1 christos {
1034 1.1 christos $debug_cmd
1035 1.1 christos
1036 1.1 christos func_relative_path_result=
1037 1.1 christos func_normal_abspath "$1"
1038 1.1 christos func_relative_path_tlibdir=$func_normal_abspath_result
1039 1.1 christos func_normal_abspath "$2"
1040 1.1 christos func_relative_path_tbindir=$func_normal_abspath_result
1041 1.1 christos
1042 1.1 christos # Ascend the tree starting from libdir
1043 1.1 christos while :; do
1044 1.1 christos # check if we have found a prefix of bindir
1045 1.1 christos case $func_relative_path_tbindir in
1046 1.1 christos $func_relative_path_tlibdir)
1047 1.1 christos # found an exact match
1048 1.1 christos func_relative_path_tcancelled=
1049 1.1 christos break
1050 1.1 christos ;;
1051 1.1 christos $func_relative_path_tlibdir*)
1052 1.1 christos # found a matching prefix
1053 1.1 christos func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054 1.1 christos func_relative_path_tcancelled=$func_stripname_result
1055 1.1 christos if test -z "$func_relative_path_result"; then
1056 1.1 christos func_relative_path_result=.
1057 1.1 christos fi
1058 1.1 christos break
1059 1.1 christos ;;
1060 1.1 christos *)
1061 1.1 christos func_dirname $func_relative_path_tlibdir
1062 1.1 christos func_relative_path_tlibdir=$func_dirname_result
1063 1.1 christos if test -z "$func_relative_path_tlibdir"; then
1064 1.1 christos # Have to descend all the way to the root!
1065 1.1 christos func_relative_path_result=../$func_relative_path_result
1066 1.1 christos func_relative_path_tcancelled=$func_relative_path_tbindir
1067 1.1 christos break
1068 1.1 christos fi
1069 1.1 christos func_relative_path_result=../$func_relative_path_result
1070 1.1 christos ;;
1071 1.1 christos esac
1072 1.1 christos done
1073 1.1 christos
1074 1.1 christos # Now calculate path; take care to avoid doubling-up slashes.
1075 1.1 christos func_stripname '' '/' "$func_relative_path_result"
1076 1.1 christos func_relative_path_result=$func_stripname_result
1077 1.1 christos func_stripname '/' '/' "$func_relative_path_tcancelled"
1078 1.1 christos if test -n "$func_stripname_result"; then
1079 1.1 christos func_append func_relative_path_result "/$func_stripname_result"
1080 1.1 christos fi
1081 1.1 christos
1082 1.1 christos # Normalisation. If bindir is libdir, return '.' else relative path.
1083 1.1 christos if test -n "$func_relative_path_result"; then
1084 1.1 christos func_stripname './' '' "$func_relative_path_result"
1085 1.1 christos func_relative_path_result=$func_stripname_result
1086 1.1 christos fi
1087 1.1 christos
1088 1.1 christos test -n "$func_relative_path_result" || func_relative_path_result=.
1089 1.1 christos
1090 1.1 christos :
1091 1.1 christos }
1092 1.1 christos
1093 1.1 christos
1094 1.1 christos # func_quote_for_eval ARG...
1095 1.1 christos # --------------------------
1096 1.1 christos # Aesthetically quote ARGs to be evaled later.
1097 1.1 christos # This function returns two values:
1098 1.1 christos # i) func_quote_for_eval_result
1099 1.1 christos # double-quoted, suitable for a subsequent eval
1100 1.1 christos # ii) func_quote_for_eval_unquoted_result
1101 1.1 christos # has all characters that are still active within double
1102 1.1 christos # quotes backslashified.
1103 1.1 christos func_quote_for_eval ()
1104 1.1 christos {
1105 1.1 christos $debug_cmd
1106 1.1 christos
1107 1.1 christos func_quote_for_eval_unquoted_result=
1108 1.1 christos func_quote_for_eval_result=
1109 1.1 christos while test 0 -lt $#; do
1110 1.1 christos case $1 in
1111 1.1 christos *[\\\`\"\$]*)
1112 1.1 christos _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1113 1.1 christos *)
1114 1.1 christos _G_unquoted_arg=$1 ;;
1115 1.1 christos esac
1116 1.1 christos if test -n "$func_quote_for_eval_unquoted_result"; then
1117 1.1 christos func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1118 1.1 christos else
1119 1.1 christos func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1120 1.1 christos fi
1121 1.1 christos
1122 1.1 christos case $_G_unquoted_arg in
1123 1.1 christos # Double-quote args containing shell metacharacters to delay
1124 1.1 christos # word splitting, command substitution and variable expansion
1125 1.1 christos # for a subsequent eval.
1126 1.1 christos # Many Bourne shells cannot handle close brackets correctly
1127 1.1 christos # in scan sets, so we specify it separately.
1128 1.1 christos *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1129 1.1 christos _G_quoted_arg=\"$_G_unquoted_arg\"
1130 1.1 christos ;;
1131 1.1 christos *)
1132 1.1 christos _G_quoted_arg=$_G_unquoted_arg
1133 1.1 christos ;;
1134 1.1 christos esac
1135 1.1 christos
1136 1.1 christos if test -n "$func_quote_for_eval_result"; then
1137 1.1 christos func_append func_quote_for_eval_result " $_G_quoted_arg"
1138 1.1 christos else
1139 1.1 christos func_append func_quote_for_eval_result "$_G_quoted_arg"
1140 1.1 christos fi
1141 1.1 christos shift
1142 1.1 christos done
1143 1.1 christos }
1144 1.1 christos
1145 1.1 christos
1146 1.1 christos # func_quote_for_expand ARG
1147 1.1 christos # -------------------------
1148 1.1 christos # Aesthetically quote ARG to be evaled later; same as above,
1149 1.1 christos # but do not quote variable references.
1150 1.1 christos func_quote_for_expand ()
1151 1.1 christos {
1152 1.1 christos $debug_cmd
1153 1.1 christos
1154 1.1 christos case $1 in
1155 1.1 christos *[\\\`\"]*)
1156 1.1 christos _G_arg=`$ECHO "$1" | $SED \
1157 1.1 christos -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1158 1.1 christos *)
1159 1.1 christos _G_arg=$1 ;;
1160 1.1 christos esac
1161 1.1 christos
1162 1.1 christos case $_G_arg in
1163 1.1 christos # Double-quote args containing shell metacharacters to delay
1164 1.1 christos # word splitting and command substitution for a subsequent eval.
1165 1.1 christos # Many Bourne shells cannot handle close brackets correctly
1166 1.1 christos # in scan sets, so we specify it separately.
1167 1.1 christos *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1168 1.1 christos _G_arg=\"$_G_arg\"
1169 1.1 christos ;;
1170 1.1 christos esac
1171 1.1 christos
1172 1.1 christos func_quote_for_expand_result=$_G_arg
1173 1.1 christos }
1174 1.1 christos
1175 1.1 christos
1176 1.1 christos # func_stripname PREFIX SUFFIX NAME
1177 1.1 christos # ---------------------------------
1178 1.1 christos # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179 1.1 christos # PREFIX and SUFFIX must not contain globbing or regex special
1180 1.1 christos # characters, hashes, percent signs, but SUFFIX may contain a leading
1181 1.1 christos # dot (in which case that matches only a dot).
1182 1.1 christos if test yes = "$_G_HAVE_XSI_OPS"; then
1183 1.1 christos eval 'func_stripname ()
1184 1.1 christos {
1185 1.1 christos $debug_cmd
1186 1.1 christos
1187 1.1 christos # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188 1.1 christos # positional parameters, so assign one to ordinary variable first.
1189 1.1 christos func_stripname_result=$3
1190 1.1 christos func_stripname_result=${func_stripname_result#"$1"}
1191 1.1 christos func_stripname_result=${func_stripname_result%"$2"}
1192 1.1 christos }'
1193 1.1 christos else
1194 1.1 christos func_stripname ()
1195 1.1 christos {
1196 1.1 christos $debug_cmd
1197 1.1 christos
1198 1.1 christos case $2 in
1199 1.1 christos .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200 1.1 christos *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1201 1.1 christos esac
1202 1.1 christos }
1203 1.1 christos fi
1204 1.1 christos
1205 1.1 christos
1206 1.1 christos # func_show_eval CMD [FAIL_EXP]
1207 1.1 christos # -----------------------------
1208 1.1 christos # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1209 1.1 christos # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1210 1.1 christos # is given, then evaluate it.
1211 1.1 christos func_show_eval ()
1212 1.1 christos {
1213 1.1 christos $debug_cmd
1214 1.1 christos
1215 1.1 christos _G_cmd=$1
1216 1.1 christos _G_fail_exp=${2-':'}
1217 1.1 christos
1218 1.1 christos func_quote_for_expand "$_G_cmd"
1219 1.1 christos eval "func_notquiet $func_quote_for_expand_result"
1220 1.1 christos
1221 1.1 christos $opt_dry_run || {
1222 1.1 christos eval "$_G_cmd"
1223 1.1 christos _G_status=$?
1224 1.1 christos if test 0 -ne "$_G_status"; then
1225 1.1 christos eval "(exit $_G_status); $_G_fail_exp"
1226 1.1 christos fi
1227 1.1 christos }
1228 1.1 christos }
1229 1.1 christos
1230 1.1 christos
1231 1.1 christos # func_show_eval_locale CMD [FAIL_EXP]
1232 1.1 christos # ------------------------------------
1233 1.1 christos # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1234 1.1 christos # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1235 1.1 christos # is given, then evaluate it. Use the saved locale for evaluation.
1236 1.1 christos func_show_eval_locale ()
1237 1.1 christos {
1238 1.1 christos $debug_cmd
1239 1.1 christos
1240 1.1 christos _G_cmd=$1
1241 1.1 christos _G_fail_exp=${2-':'}
1242 1.1 christos
1243 1.1 christos $opt_quiet || {
1244 1.1 christos func_quote_for_expand "$_G_cmd"
1245 1.1 christos eval "func_echo $func_quote_for_expand_result"
1246 1.1 christos }
1247 1.1 christos
1248 1.1 christos $opt_dry_run || {
1249 1.1 christos eval "$_G_user_locale
1250 1.1 christos $_G_cmd"
1251 1.1 christos _G_status=$?
1252 1.1 christos eval "$_G_safe_locale"
1253 1.1 christos if test 0 -ne "$_G_status"; then
1254 1.1 christos eval "(exit $_G_status); $_G_fail_exp"
1255 1.1 christos fi
1256 1.1 christos }
1257 1.1 christos }
1258 1.1 christos
1259 1.1 christos
1260 1.1 christos # func_tr_sh
1261 1.1 christos # ----------
1262 1.1 christos # Turn $1 into a string suitable for a shell variable name.
1263 1.1 christos # Result is stored in $func_tr_sh_result. All characters
1264 1.1 christos # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1265 1.1 christos # if $1 begins with a digit, a '_' is prepended as well.
1266 1.1 christos func_tr_sh ()
1267 1.1 christos {
1268 1.1 christos $debug_cmd
1269 1.1 christos
1270 1.1 christos case $1 in
1271 1.1 christos [0-9]* | *[!a-zA-Z0-9_]*)
1272 1.1 christos func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1273 1.1 christos ;;
1274 1.1 christos * )
1275 1.1 christos func_tr_sh_result=$1
1276 1.1 christos ;;
1277 1.1 christos esac
1278 1.1 christos }
1279 1.1 christos
1280 1.1 christos
1281 1.1 christos # func_verbose ARG...
1282 1.1 christos # -------------------
1283 1.1 christos # Echo program name prefixed message in verbose mode only.
1284 1.1 christos func_verbose ()
1285 1.1 christos {
1286 1.1 christos $debug_cmd
1287 1.1 christos
1288 1.1 christos $opt_verbose && func_echo "$*"
1289 1.1 christos
1290 1.1 christos :
1291 1.1 christos }
1292 1.1 christos
1293 1.1 christos
1294 1.1 christos # func_warn_and_continue ARG...
1295 1.1 christos # -----------------------------
1296 1.1 christos # Echo program name prefixed warning message to standard error.
1297 1.1 christos func_warn_and_continue ()
1298 1.1 christos {
1299 1.1 christos $debug_cmd
1300 1.1 christos
1301 1.1 christos $require_term_colors
1302 1.1 christos
1303 1.1 christos func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1304 1.1 christos }
1305 1.1 christos
1306 1.1 christos
1307 1.1 christos # func_warning CATEGORY ARG...
1308 1.1 christos # ----------------------------
1309 1.1 christos # Echo program name prefixed warning message to standard error. Warning
1310 1.1 christos # messages can be filtered according to CATEGORY, where this function
1311 1.1 christos # elides messages where CATEGORY is not listed in the global variable
1312 1.1 christos # 'opt_warning_types'.
1313 1.1 christos func_warning ()
1314 1.1 christos {
1315 1.1 christos $debug_cmd
1316 1.1 christos
1317 1.1 christos # CATEGORY must be in the warning_categories list!
1318 1.1 christos case " $warning_categories " in
1319 1.1 christos *" $1 "*) ;;
1320 1.1 christos *) func_internal_error "invalid warning category '$1'" ;;
1321 1.1 christos esac
1322 1.1 christos
1323 1.1 christos _G_category=$1
1324 1.1 christos shift
1325 1.1 christos
1326 1.1 christos case " $opt_warning_types " in
1327 1.1 christos *" $_G_category "*) $warning_func ${1+"$@"} ;;
1328 1.1 christos esac
1329 1.1 christos }
1330 1.1 christos
1331 1.1 christos
1332 1.1 christos # func_sort_ver VER1 VER2
1333 1.1 christos # -----------------------
1334 1.1 christos # 'sort -V' is not generally available.
1335 1.1 christos # Note this deviates from the version comparison in automake
1336 1.1 christos # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337 1.1 christos # but this should suffice as we won't be specifying old
1338 1.1 christos # version formats or redundant trailing .0 in bootstrap.conf.
1339 1.1 christos # If we did want full compatibility then we should probably
1340 1.1 christos # use m4_version_compare from autoconf.
1341 1.1 christos func_sort_ver ()
1342 1.1 christos {
1343 1.1 christos $debug_cmd
1344 1.1 christos
1345 1.1 christos printf '%s\n%s\n' "$1" "$2" \
1346 1.1 christos | 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 christos }
1348 1.1 christos
1349 1.1 christos # func_lt_ver PREV CURR
1350 1.1 christos # ---------------------
1351 1.1 christos # Return true if PREV and CURR are in the correct order according to
1352 1.1 christos # func_sort_ver, otherwise false. Use it like this:
1353 1.1 christos #
1354 1.1 christos # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1355 1.1 christos func_lt_ver ()
1356 1.1 christos {
1357 1.1 christos $debug_cmd
1358 1.1 christos
1359 1.1 christos test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1360 1.1 christos }
1361 1.1 christos
1362 1.1 christos
1363 1.1 christos # Local variables:
1364 1.1 christos # mode: shell-script
1365 1.1 christos # sh-indentation: 2
1366 1.1 christos # eval: (add-hook 'before-save-hook 'time-stamp)
1367 1.1 christos # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368 1.1 christos # time-stamp-time-zone: "UTC"
1369 1.1 christos # End:
1370 1.1 christos #! /bin/sh
1371 1.1 christos
1372 1.1 christos # Set a version string for this script.
1373 1.1 christos scriptversion=2014-01-07.03; # UTC
1374 1.1 christos
1375 1.1 christos # A portable, pluggable option parser for Bourne shell.
1376 1.1 christos # Written by Gary V. Vaughan, 2010
1377 1.1 christos
1378 1.1 christos # Copyright (C) 2010-2015 Free Software Foundation, Inc.
1379 1.1 christos # This is free software; see the source for copying conditions. There is NO
1380 1.1 christos # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1381 1.1 christos
1382 1.1 christos # This program is free software: you can redistribute it and/or modify
1383 1.1 christos # it under the terms of the GNU General Public License as published by
1384 1.1 christos # the Free Software Foundation, either version 3 of the License, or
1385 1.1 christos # (at your option) any later version.
1386 1.1 christos
1387 1.1 christos # This program is distributed in the hope that it will be useful,
1388 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
1389 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1390 1.1 christos # GNU General Public License for more details.
1391 1.1 christos
1392 1.1 christos # You should have received a copy of the GNU General Public License
1393 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
1394 1.1 christos
1395 1.1 christos # Please report bugs or propose patches to gary (at] gnu.org.
1396 1.1 christos
1397 1.1 christos
1398 1.1 christos ## ------ ##
1399 1.1 christos ## Usage. ##
1400 1.1 christos ## ------ ##
1401 1.1 christos
1402 1.1 christos # This file is a library for parsing options in your shell scripts along
1403 1.1 christos # with assorted other useful supporting features that you can make use
1404 1.1 christos # of too.
1405 1.1 christos #
1406 1.1 christos # For the simplest scripts you might need only:
1407 1.1 christos #
1408 1.1 christos # #!/bin/sh
1409 1.1 christos # . relative/path/to/funclib.sh
1410 1.1 christos # . relative/path/to/options-parser
1411 1.1 christos # scriptversion=1.0
1412 1.1 christos # func_options ${1+"$@"}
1413 1.1 christos # eval set dummy "$func_options_result"; shift
1414 1.1 christos # ...rest of your script...
1415 1.1 christos #
1416 1.1 christos # In order for the '--version' option to work, you will need to have a
1417 1.1 christos # suitably formatted comment like the one at the top of this file
1418 1.1 christos # starting with '# Written by ' and ending with '# warranty; '.
1419 1.1 christos #
1420 1.1 christos # For '-h' and '--help' to work, you will also need a one line
1421 1.1 christos # description of your script's purpose in a comment directly above the
1422 1.1 christos # '# Written by ' line, like the one at the top of this file.
1423 1.1 christos #
1424 1.1 christos # The default options also support '--debug', which will turn on shell
1425 1.1 christos # execution tracing (see the comment above debug_cmd below for another
1426 1.1 christos # use), and '--verbose' and the func_verbose function to allow your script
1427 1.1 christos # to display verbose messages only when your user has specified
1428 1.1 christos # '--verbose'.
1429 1.1 christos #
1430 1.1 christos # After sourcing this file, you can plug processing for additional
1431 1.1 christos # options by amending the variables from the 'Configuration' section
1432 1.1 christos # below, and following the instructions in the 'Option parsing'
1433 1.1 christos # section further down.
1434 1.1 christos
1435 1.1 christos ## -------------- ##
1436 1.1 christos ## Configuration. ##
1437 1.1 christos ## -------------- ##
1438 1.1 christos
1439 1.1 christos # You should override these variables in your script after sourcing this
1440 1.1 christos # file so that they reflect the customisations you have added to the
1441 1.1 christos # option parser.
1442 1.1 christos
1443 1.1 christos # The usage line for option parsing errors and the start of '-h' and
1444 1.1 christos # '--help' output messages. You can embed shell variables for delayed
1445 1.1 christos # expansion at the time the message is displayed, but you will need to
1446 1.1 christos # quote other shell meta-characters carefully to prevent them being
1447 1.1 christos # expanded when the contents are evaled.
1448 1.1 christos usage='$progpath [OPTION]...'
1449 1.1 christos
1450 1.1 christos # Short help message in response to '-h' and '--help'. Add to this or
1451 1.1 christos # override it after sourcing this library to reflect the full set of
1452 1.1 christos # options your script accepts.
1453 1.1 christos usage_message="\
1454 1.1 christos --debug enable verbose shell tracing
1455 1.1 christos -W, --warnings=CATEGORY
1456 1.1 christos report the warnings falling in CATEGORY [all]
1457 1.1 christos -v, --verbose verbosely report processing
1458 1.1 christos --version print version information and exit
1459 1.1 christos -h, --help print short or long help message and exit
1460 1.1 christos "
1461 1.1 christos
1462 1.1 christos # Additional text appended to 'usage_message' in response to '--help'.
1463 1.1 christos long_help_message="
1464 1.1 christos Warning categories include:
1465 1.1 christos 'all' show all warnings
1466 1.1 christos 'none' turn off all the warnings
1467 1.1 christos 'error' warnings are treated as fatal errors"
1468 1.1 christos
1469 1.1 christos # Help message printed before fatal option parsing errors.
1470 1.1 christos fatal_help="Try '\$progname --help' for more information."
1471 1.1 christos
1472 1.1 christos
1473 1.1 christos
1474 1.1 christos ## ------------------------- ##
1475 1.1 christos ## Hook function management. ##
1476 1.1 christos ## ------------------------- ##
1477 1.1 christos
1478 1.1 christos # This section contains functions for adding, removing, and running hooks
1479 1.1 christos # to the main code. A hook is just a named list of of function, that can
1480 1.1 christos # be run in order later on.
1481 1.1 christos
1482 1.1 christos # func_hookable FUNC_NAME
1483 1.1 christos # -----------------------
1484 1.1 christos # Declare that FUNC_NAME will run hooks added with
1485 1.1 christos # 'func_add_hook FUNC_NAME ...'.
1486 1.1 christos func_hookable ()
1487 1.1 christos {
1488 1.1 christos $debug_cmd
1489 1.1 christos
1490 1.1 christos func_append hookable_fns " $1"
1491 1.1 christos }
1492 1.1 christos
1493 1.1 christos
1494 1.1 christos # func_add_hook FUNC_NAME HOOK_FUNC
1495 1.1 christos # ---------------------------------
1496 1.1 christos # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1497 1.1 christos # first have been declared "hookable" by a call to 'func_hookable'.
1498 1.1 christos func_add_hook ()
1499 1.1 christos {
1500 1.1 christos $debug_cmd
1501 1.1 christos
1502 1.1 christos case " $hookable_fns " in
1503 1.1 christos *" $1 "*) ;;
1504 1.1 christos *) func_fatal_error "'$1' does not accept hook functions." ;;
1505 1.1 christos esac
1506 1.1 christos
1507 1.1 christos eval func_append ${1}_hooks '" $2"'
1508 1.1 christos }
1509 1.1 christos
1510 1.1 christos
1511 1.1 christos # func_remove_hook FUNC_NAME HOOK_FUNC
1512 1.1 christos # ------------------------------------
1513 1.1 christos # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1514 1.1 christos func_remove_hook ()
1515 1.1 christos {
1516 1.1 christos $debug_cmd
1517 1.1 christos
1518 1.1 christos eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1519 1.1 christos }
1520 1.1 christos
1521 1.1 christos
1522 1.1 christos # func_run_hooks FUNC_NAME [ARG]...
1523 1.1 christos # ---------------------------------
1524 1.1 christos # Run all hook functions registered to FUNC_NAME.
1525 1.1 christos # It is assumed that the list of hook functions contains nothing more
1526 1.1 christos # than a whitespace-delimited list of legal shell function names, and
1527 1.1 christos # no effort is wasted trying to catch shell meta-characters or preserve
1528 1.1 christos # whitespace.
1529 1.1 christos func_run_hooks ()
1530 1.1 christos {
1531 1.1 christos $debug_cmd
1532 1.1 christos
1533 1.1 christos case " $hookable_fns " in
1534 1.1 christos *" $1 "*) ;;
1535 1.1 christos *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1536 1.1 christos esac
1537 1.1 christos
1538 1.1 christos eval _G_hook_fns=\$$1_hooks; shift
1539 1.1 christos
1540 1.1 christos for _G_hook in $_G_hook_fns; do
1541 1.1 christos eval $_G_hook '"$@"'
1542 1.1 christos
1543 1.1 christos # store returned options list back into positional
1544 1.1 christos # parameters for next 'cmd' execution.
1545 1.1 christos eval _G_hook_result=\$${_G_hook}_result
1546 1.1 christos eval set dummy "$_G_hook_result"; shift
1547 1.1 christos done
1548 1.1 christos
1549 1.1 christos func_quote_for_eval ${1+"$@"}
1550 1.1 christos func_run_hooks_result=$func_quote_for_eval_result
1551 1.1 christos }
1552 1.1 christos
1553 1.1 christos
1554 1.1 christos
1555 1.1 christos ## --------------- ##
1556 1.1 christos ## Option parsing. ##
1557 1.1 christos ## --------------- ##
1558 1.1 christos
1559 1.1 christos # In order to add your own option parsing hooks, you must accept the
1560 1.1 christos # full positional parameter list in your hook function, remove any
1561 1.1 christos # options that you action, and then pass back the remaining unprocessed
1562 1.1 christos # options in '<hooked_function_name>_result', escaped suitably for
1563 1.1 christos # 'eval'. Like this:
1564 1.1 christos #
1565 1.1 christos # my_options_prep ()
1566 1.1 christos # {
1567 1.1 christos # $debug_cmd
1568 1.1 christos #
1569 1.1 christos # # Extend the existing usage message.
1570 1.1 christos # usage_message=$usage_message'
1571 1.1 christos # -s, --silent don'\''t print informational messages
1572 1.1 christos # '
1573 1.1 christos #
1574 1.1 christos # func_quote_for_eval ${1+"$@"}
1575 1.1 christos # my_options_prep_result=$func_quote_for_eval_result
1576 1.1 christos # }
1577 1.1 christos # func_add_hook func_options_prep my_options_prep
1578 1.1 christos #
1579 1.1 christos #
1580 1.1 christos # my_silent_option ()
1581 1.1 christos # {
1582 1.1 christos # $debug_cmd
1583 1.1 christos #
1584 1.1 christos # # Note that for efficiency, we parse as many options as we can
1585 1.1 christos # # recognise in a loop before passing the remainder back to the
1586 1.1 christos # # caller on the first unrecognised argument we encounter.
1587 1.1 christos # while test $# -gt 0; do
1588 1.1 christos # opt=$1; shift
1589 1.1 christos # case $opt in
1590 1.1 christos # --silent|-s) opt_silent=: ;;
1591 1.1 christos # # Separate non-argument short options:
1592 1.1 christos # -s*) func_split_short_opt "$_G_opt"
1593 1.1 christos # set dummy "$func_split_short_opt_name" \
1594 1.1 christos # "-$func_split_short_opt_arg" ${1+"$@"}
1595 1.1 christos # shift
1596 1.1 christos # ;;
1597 1.1 christos # *) set dummy "$_G_opt" "$*"; shift; break ;;
1598 1.1 christos # esac
1599 1.1 christos # done
1600 1.1 christos #
1601 1.1 christos # func_quote_for_eval ${1+"$@"}
1602 1.1 christos # my_silent_option_result=$func_quote_for_eval_result
1603 1.1 christos # }
1604 1.1 christos # func_add_hook func_parse_options my_silent_option
1605 1.1 christos #
1606 1.1 christos #
1607 1.1 christos # my_option_validation ()
1608 1.1 christos # {
1609 1.1 christos # $debug_cmd
1610 1.1 christos #
1611 1.1 christos # $opt_silent && $opt_verbose && func_fatal_help "\
1612 1.1 christos # '--silent' and '--verbose' options are mutually exclusive."
1613 1.1 christos #
1614 1.1 christos # func_quote_for_eval ${1+"$@"}
1615 1.1 christos # my_option_validation_result=$func_quote_for_eval_result
1616 1.1 christos # }
1617 1.1 christos # func_add_hook func_validate_options my_option_validation
1618 1.1 christos #
1619 1.1 christos # You'll alse need to manually amend $usage_message to reflect the extra
1620 1.1 christos # options you parse. It's preferable to append if you can, so that
1621 1.1 christos # multiple option parsing hooks can be added safely.
1622 1.1 christos
1623 1.1 christos
1624 1.1 christos # func_options [ARG]...
1625 1.1 christos # ---------------------
1626 1.1 christos # All the functions called inside func_options are hookable. See the
1627 1.1 christos # individual implementations for details.
1628 1.1 christos func_hookable func_options
1629 1.1 christos func_options ()
1630 1.1 christos {
1631 1.1 christos $debug_cmd
1632 1.1 christos
1633 1.1 christos func_options_prep ${1+"$@"}
1634 1.1 christos eval func_parse_options \
1635 1.1 christos ${func_options_prep_result+"$func_options_prep_result"}
1636 1.1 christos eval func_validate_options \
1637 1.1 christos ${func_parse_options_result+"$func_parse_options_result"}
1638 1.1 christos
1639 1.1 christos eval func_run_hooks func_options \
1640 1.1 christos ${func_validate_options_result+"$func_validate_options_result"}
1641 1.1 christos
1642 1.1 christos # save modified positional parameters for caller
1643 1.1 christos func_options_result=$func_run_hooks_result
1644 1.1 christos }
1645 1.1 christos
1646 1.1 christos
1647 1.1 christos # func_options_prep [ARG]...
1648 1.1 christos # --------------------------
1649 1.1 christos # All initialisations required before starting the option parse loop.
1650 1.1 christos # Note that when calling hook functions, we pass through the list of
1651 1.1 christos # positional parameters. If a hook function modifies that list, and
1652 1.1 christos # needs to propogate that back to rest of this script, then the complete
1653 1.1 christos # modified list must be put in 'func_run_hooks_result' before
1654 1.1 christos # returning.
1655 1.1 christos func_hookable func_options_prep
1656 1.1 christos func_options_prep ()
1657 1.1 christos {
1658 1.1 christos $debug_cmd
1659 1.1 christos
1660 1.1 christos # Option defaults:
1661 1.1 christos opt_verbose=false
1662 1.1 christos opt_warning_types=
1663 1.1 christos
1664 1.1 christos func_run_hooks func_options_prep ${1+"$@"}
1665 1.1 christos
1666 1.1 christos # save modified positional parameters for caller
1667 1.1 christos func_options_prep_result=$func_run_hooks_result
1668 1.1 christos }
1669 1.1 christos
1670 1.1 christos
1671 1.1 christos # func_parse_options [ARG]...
1672 1.1 christos # ---------------------------
1673 1.1 christos # The main option parsing loop.
1674 1.1 christos func_hookable func_parse_options
1675 1.1 christos func_parse_options ()
1676 1.1 christos {
1677 1.1 christos $debug_cmd
1678 1.1 christos
1679 1.1 christos func_parse_options_result=
1680 1.1 christos
1681 1.1 christos # this just eases exit handling
1682 1.1 christos while test $# -gt 0; do
1683 1.1 christos # Defer to hook functions for initial option parsing, so they
1684 1.1 christos # get priority in the event of reusing an option name.
1685 1.1 christos func_run_hooks func_parse_options ${1+"$@"}
1686 1.1 christos
1687 1.1 christos # Adjust func_parse_options positional parameters to match
1688 1.1 christos eval set dummy "$func_run_hooks_result"; shift
1689 1.1 christos
1690 1.1 christos # Break out of the loop if we already parsed every option.
1691 1.1 christos test $# -gt 0 || break
1692 1.1 christos
1693 1.1 christos _G_opt=$1
1694 1.1 christos shift
1695 1.1 christos case $_G_opt in
1696 1.1 christos --debug|-x) debug_cmd='set -x'
1697 1.1 christos func_echo "enabling shell trace mode"
1698 1.1 christos $debug_cmd
1699 1.1 christos ;;
1700 1.1 christos
1701 1.1 christos --no-warnings|--no-warning|--no-warn)
1702 1.1 christos set dummy --warnings none ${1+"$@"}
1703 1.1 christos shift
1704 1.1 christos ;;
1705 1.1 christos
1706 1.1 christos --warnings|--warning|-W)
1707 1.1 christos test $# = 0 && func_missing_arg $_G_opt && break
1708 1.1 christos case " $warning_categories $1" in
1709 1.1 christos *" $1 "*)
1710 1.1 christos # trailing space prevents matching last $1 above
1711 1.1 christos func_append_uniq opt_warning_types " $1"
1712 1.1 christos ;;
1713 1.1 christos *all)
1714 1.1 christos opt_warning_types=$warning_categories
1715 1.1 christos ;;
1716 1.1 christos *none)
1717 1.1 christos opt_warning_types=none
1718 1.1 christos warning_func=:
1719 1.1 christos ;;
1720 1.1 christos *error)
1721 1.1 christos opt_warning_types=$warning_categories
1722 1.1 christos warning_func=func_fatal_error
1723 1.1 christos ;;
1724 1.1 christos *)
1725 1.1 christos func_fatal_error \
1726 1.1 christos "unsupported warning category: '$1'"
1727 1.1 christos ;;
1728 1.1 christos esac
1729 1.1 christos shift
1730 1.1 christos ;;
1731 1.1 christos
1732 1.1 christos --verbose|-v) opt_verbose=: ;;
1733 1.1 christos --version) func_version ;;
1734 1.1 christos -\?|-h) func_usage ;;
1735 1.1 christos --help) func_help ;;
1736 1.1 christos
1737 1.1 christos # Separate optargs to long options (plugins may need this):
1738 1.1 christos --*=*) func_split_equals "$_G_opt"
1739 1.1 christos set dummy "$func_split_equals_lhs" \
1740 1.1 christos "$func_split_equals_rhs" ${1+"$@"}
1741 1.1 christos shift
1742 1.1 christos ;;
1743 1.1 christos
1744 1.1 christos # Separate optargs to short options:
1745 1.1 christos -W*)
1746 1.1 christos func_split_short_opt "$_G_opt"
1747 1.1 christos set dummy "$func_split_short_opt_name" \
1748 1.1 christos "$func_split_short_opt_arg" ${1+"$@"}
1749 1.1 christos shift
1750 1.1 christos ;;
1751 1.1 christos
1752 1.1 christos # Separate non-argument short options:
1753 1.1 christos -\?*|-h*|-v*|-x*)
1754 1.1 christos func_split_short_opt "$_G_opt"
1755 1.1 christos set dummy "$func_split_short_opt_name" \
1756 1.1 christos "-$func_split_short_opt_arg" ${1+"$@"}
1757 1.1 christos shift
1758 1.1 christos ;;
1759 1.1 christos
1760 1.1 christos --) break ;;
1761 1.1 christos -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
1762 1.1 christos *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1763 1.1 christos esac
1764 1.1 christos done
1765 1.1 christos
1766 1.1 christos # save modified positional parameters for caller
1767 1.1 christos func_quote_for_eval ${1+"$@"}
1768 1.1 christos func_parse_options_result=$func_quote_for_eval_result
1769 1.1 christos }
1770 1.1 christos
1771 1.1 christos
1772 1.1 christos # func_validate_options [ARG]...
1773 1.1 christos # ------------------------------
1774 1.1 christos # Perform any sanity checks on option settings and/or unconsumed
1775 1.1 christos # arguments.
1776 1.1 christos func_hookable func_validate_options
1777 1.1 christos func_validate_options ()
1778 1.1 christos {
1779 1.1 christos $debug_cmd
1780 1.1 christos
1781 1.1 christos # Display all warnings if -W was not given.
1782 1.1 christos test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783 1.1 christos
1784 1.1 christos func_run_hooks func_validate_options ${1+"$@"}
1785 1.1 christos
1786 1.1 christos # Bail if the options were screwed!
1787 1.1 christos $exit_cmd $EXIT_FAILURE
1788 1.1 christos
1789 1.1 christos # save modified positional parameters for caller
1790 1.1 christos func_validate_options_result=$func_run_hooks_result
1791 1.1 christos }
1792 1.1 christos
1793 1.1 christos
1794 1.1 christos
1795 1.1 christos ## ----------------- ##
1796 1.1 christos ## Helper functions. ##
1797 1.1 christos ## ----------------- ##
1798 1.1 christos
1799 1.1 christos # This section contains the helper functions used by the rest of the
1800 1.1 christos # hookable option parser framework in ascii-betical order.
1801 1.1 christos
1802 1.1 christos
1803 1.1 christos # func_fatal_help ARG...
1804 1.1 christos # ----------------------
1805 1.1 christos # Echo program name prefixed message to standard error, followed by
1806 1.1 christos # a help hint, and exit.
1807 1.1 christos func_fatal_help ()
1808 1.1 christos {
1809 1.1 christos $debug_cmd
1810 1.1 christos
1811 1.1 christos eval \$ECHO \""Usage: $usage"\"
1812 1.1 christos eval \$ECHO \""$fatal_help"\"
1813 1.1 christos func_error ${1+"$@"}
1814 1.1 christos exit $EXIT_FAILURE
1815 1.1 christos }
1816 1.1 christos
1817 1.1 christos
1818 1.1 christos # func_help
1819 1.1 christos # ---------
1820 1.1 christos # Echo long help message to standard output and exit.
1821 1.1 christos func_help ()
1822 1.1 christos {
1823 1.1 christos $debug_cmd
1824 1.1 christos
1825 1.1 christos func_usage_message
1826 1.1 christos $ECHO "$long_help_message"
1827 1.1 christos exit 0
1828 1.1 christos }
1829 1.1 christos
1830 1.1 christos
1831 1.1 christos # func_missing_arg ARGNAME
1832 1.1 christos # ------------------------
1833 1.1 christos # Echo program name prefixed message to standard error and set global
1834 1.1 christos # exit_cmd.
1835 1.1 christos func_missing_arg ()
1836 1.1 christos {
1837 1.1 christos $debug_cmd
1838 1.1 christos
1839 1.1 christos func_error "Missing argument for '$1'."
1840 1.1 christos exit_cmd=exit
1841 1.1 christos }
1842 1.1 christos
1843 1.1 christos
1844 1.1 christos # func_split_equals STRING
1845 1.1 christos # ------------------------
1846 1.1 christos # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1847 1.1 christos # splitting STRING at the '=' sign.
1848 1.1 christos test -z "$_G_HAVE_XSI_OPS" \
1849 1.1 christos && (eval 'x=a/b/c;
1850 1.1 christos test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1851 1.1 christos && _G_HAVE_XSI_OPS=yes
1852 1.1 christos
1853 1.1 christos if test yes = "$_G_HAVE_XSI_OPS"
1854 1.1 christos then
1855 1.1 christos # This is an XSI compatible shell, allowing a faster implementation...
1856 1.1 christos eval 'func_split_equals ()
1857 1.1 christos {
1858 1.1 christos $debug_cmd
1859 1.1 christos
1860 1.1 christos func_split_equals_lhs=${1%%=*}
1861 1.1 christos func_split_equals_rhs=${1#*=}
1862 1.1 christos test "x$func_split_equals_lhs" = "x$1" \
1863 1.1 christos && func_split_equals_rhs=
1864 1.1 christos }'
1865 1.1 christos else
1866 1.1 christos # ...otherwise fall back to using expr, which is often a shell builtin.
1867 1.1 christos func_split_equals ()
1868 1.1 christos {
1869 1.1 christos $debug_cmd
1870 1.1 christos
1871 1.1 christos func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1872 1.1 christos func_split_equals_rhs=
1873 1.1 christos test "x$func_split_equals_lhs" = "x$1" \
1874 1.1 christos || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1875 1.1 christos }
1876 1.1 christos fi #func_split_equals
1877 1.1 christos
1878 1.1 christos
1879 1.1 christos # func_split_short_opt SHORTOPT
1880 1.1 christos # -----------------------------
1881 1.1 christos # Set func_split_short_opt_name and func_split_short_opt_arg shell
1882 1.1 christos # variables after splitting SHORTOPT after the 2nd character.
1883 1.1 christos if test yes = "$_G_HAVE_XSI_OPS"
1884 1.1 christos then
1885 1.1 christos # This is an XSI compatible shell, allowing a faster implementation...
1886 1.1 christos eval 'func_split_short_opt ()
1887 1.1 christos {
1888 1.1 christos $debug_cmd
1889 1.1 christos
1890 1.1 christos func_split_short_opt_arg=${1#??}
1891 1.1 christos func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1892 1.1 christos }'
1893 1.1 christos else
1894 1.1 christos # ...otherwise fall back to using expr, which is often a shell builtin.
1895 1.1 christos func_split_short_opt ()
1896 1.1 christos {
1897 1.1 christos $debug_cmd
1898 1.1 christos
1899 1.1 christos func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1900 1.1 christos func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1901 1.1 christos }
1902 1.1 christos fi #func_split_short_opt
1903 1.1 christos
1904 1.1 christos
1905 1.1 christos # func_usage
1906 1.1 christos # ----------
1907 1.1 christos # Echo short help message to standard output and exit.
1908 1.1 christos func_usage ()
1909 1.1 christos {
1910 1.1 christos $debug_cmd
1911 1.1 christos
1912 1.1 christos func_usage_message
1913 1.1 christos $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1914 1.1 christos exit 0
1915 1.1 christos }
1916 1.1 christos
1917 1.1 christos
1918 1.1 christos # func_usage_message
1919 1.1 christos # ------------------
1920 1.1 christos # Echo short help message to standard output.
1921 1.1 christos func_usage_message ()
1922 1.1 christos {
1923 1.1 christos $debug_cmd
1924 1.1 christos
1925 1.1 christos eval \$ECHO \""Usage: $usage"\"
1926 1.1 christos echo
1927 1.1 christos $SED -n 's|^# ||
1928 1.1 christos /^Written by/{
1929 1.1 christos x;p;x
1930 1.1 christos }
1931 1.1 christos h
1932 1.1 christos /^Written by/q' < "$progpath"
1933 1.1 christos echo
1934 1.1 christos eval \$ECHO \""$usage_message"\"
1935 1.1 christos }
1936 1.1 christos
1937 1.1 christos
1938 1.1 christos # func_version
1939 1.1 christos # ------------
1940 1.1 christos # Echo version message to standard output and exit.
1941 1.1 christos func_version ()
1942 1.1 christos {
1943 1.1 christos $debug_cmd
1944 1.1 christos
1945 1.1 christos printf '%s\n' "$progname $scriptversion"
1946 1.1 christos $SED -n '
1947 1.1 christos /(C)/!b go
1948 1.1 christos :more
1949 1.1 christos /\./!{
1950 1.1 christos N
1951 1.1 christos s|\n# | |
1952 1.1 christos b more
1953 1.1 christos }
1954 1.1 christos :go
1955 1.1 christos /^# Written by /,/# warranty; / {
1956 1.1 christos s|^# ||
1957 1.1 christos s|^# *$||
1958 1.1 christos s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1959 1.1 christos p
1960 1.1 christos }
1961 1.1 christos /^# Written by / {
1962 1.1 christos s|^# ||
1963 1.1 christos p
1964 1.1 christos }
1965 1.1 christos /^warranty; /q' < "$progpath"
1966 1.1 christos
1967 1.1 christos exit $?
1968 1.1 christos }
1969 1.1 christos
1970 1.1 christos
1971 1.1 christos # Local variables:
1972 1.1 christos # mode: shell-script
1973 1.1 christos # sh-indentation: 2
1974 1.1 christos # eval: (add-hook 'before-save-hook 'time-stamp)
1975 1.1 christos # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1976 1.1 christos # time-stamp-time-zone: "UTC"
1977 1.1 christos # End:
1978 1.1 christos
1979 1.1 christos # Set a version string.
1980 1.1 christos scriptversion='(GNU libtool) 2.4.6'
1981 1.1 christos
1982 1.1 christos
1983 1.1 christos # func_echo ARG...
1984 1.1 christos # ----------------
1985 1.1 christos # Libtool also displays the current mode in messages, so override
1986 1.1 christos # funclib.sh func_echo with this custom definition.
1987 1.1 christos func_echo ()
1988 1.1 christos {
1989 1.1 christos $debug_cmd
1990 1.1 christos
1991 1.1 christos _G_message=$*
1992 1.1 christos
1993 1.1 christos func_echo_IFS=$IFS
1994 1.1 christos IFS=$nl
1995 1.1 christos for _G_line in $_G_message; do
1996 1.1 christos IFS=$func_echo_IFS
1997 1.1 christos $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
1998 1.1 christos done
1999 1.1 christos IFS=$func_echo_IFS
2000 1.1 christos }
2001 1.1 christos
2002 1.1 christos
2003 1.1 christos # func_warning ARG...
2004 1.1 christos # -------------------
2005 1.1 christos # Libtool warnings are not categorized, so override funclib.sh
2006 1.1 christos # func_warning with this simpler definition.
2007 1.1 christos func_warning ()
2008 1.1 christos {
2009 1.1 christos $debug_cmd
2010 1.1 christos
2011 1.1 christos $warning_func ${1+"$@"}
2012 1.1 christos }
2013 1.1 christos
2014 1.1 christos
2015 1.1 christos ## ---------------- ##
2016 1.1 christos ## Options parsing. ##
2017 1.1 christos ## ---------------- ##
2018 1.1 christos
2019 1.1 christos # Hook in the functions to make sure our own options are parsed during
2020 1.1 christos # the option parsing loop.
2021 1.1 christos
2022 1.1 christos usage='$progpath [OPTION]... [MODE-ARG]...'
2023 1.1 christos
2024 1.1 christos # Short help message in response to '-h'.
2025 1.1 christos usage_message="Options:
2026 1.1 christos --config show all configuration variables
2027 1.1 christos --debug enable verbose shell tracing
2028 1.1 christos -n, --dry-run display commands without modifying any files
2029 1.1 christos --features display basic configuration information and exit
2030 1.1 christos --mode=MODE use operation mode MODE
2031 1.1 christos --no-warnings equivalent to '-Wnone'
2032 1.1 christos --preserve-dup-deps don't remove duplicate dependency libraries
2033 1.1 christos --quiet, --silent don't print informational messages
2034 1.1 christos --tag=TAG use configuration variables from tag TAG
2035 1.1 christos -v, --verbose print more informational messages than default
2036 1.1 christos --version print version information
2037 1.1 christos -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
2038 1.1 christos -h, --help, --help-all print short, long, or detailed help message
2039 1.1 christos "
2040 1.1 christos
2041 1.1 christos # Additional text appended to 'usage_message' in response to '--help'.
2042 1.1 christos func_help ()
2043 1.1 christos {
2044 1.1 christos $debug_cmd
2045 1.1 christos
2046 1.1 christos func_usage_message
2047 1.1 christos $ECHO "$long_help_message
2048 1.1 christos
2049 1.1 christos MODE must be one of the following:
2050 1.1 christos
2051 1.1 christos clean remove files from the build directory
2052 1.1 christos compile compile a source file into a libtool object
2053 1.1 christos execute automatically set library path, then run a program
2054 1.1 christos finish complete the installation of libtool libraries
2055 1.1 christos install install libraries or executables
2056 1.1 christos link create a library or an executable
2057 1.1 christos uninstall remove libraries from an installed directory
2058 1.1 christos
2059 1.1 christos MODE-ARGS vary depending on the MODE. When passed as first option,
2060 1.1 christos '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2061 1.1 christos Try '$progname --help --mode=MODE' for a more detailed description of MODE.
2062 1.1 christos
2063 1.1 christos When reporting a bug, please describe a test case to reproduce it and
2064 1.1 christos include the following information:
2065 1.1 christos
2066 1.1 christos host-triplet: $host
2067 1.1 christos shell: $SHELL
2068 1.1 christos compiler: $LTCC
2069 1.1 christos compiler flags: $LTCFLAGS
2070 1.1 christos linker: $LD (gnu? $with_gnu_ld)
2071 1.1 christos version: $progname (GNU libtool) 2.4.6
2072 1.1 christos automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2073 1.1 christos autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2074 1.1 christos
2075 1.1 christos Report bugs to <bug-libtool (at] gnu.org>.
2076 1.1 christos GNU libtool home page: <http://www.gnu.org/software/libtool/>.
2077 1.1 christos General help using GNU software: <http://www.gnu.org/gethelp/>."
2078 1.1 christos exit 0
2079 1.1 christos }
2080 1.1 christos
2081 1.1 christos
2082 1.1 christos # func_lo2o OBJECT-NAME
2083 1.1 christos # ---------------------
2084 1.1 christos # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2085 1.1 christos # object suffix.
2086 1.1 christos
2087 1.1 christos lo2o=s/\\.lo\$/.$objext/
2088 1.1 christos o2lo=s/\\.$objext\$/.lo/
2089 1.1 christos
2090 1.1 christos if test yes = "$_G_HAVE_XSI_OPS"; then
2091 1.1 christos eval 'func_lo2o ()
2092 1.1 christos {
2093 1.1 christos case $1 in
2094 1.1 christos *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2095 1.1 christos * ) func_lo2o_result=$1 ;;
2096 1.1 christos esac
2097 1.1 christos }'
2098 1.1 christos
2099 1.1 christos # func_xform LIBOBJ-OR-SOURCE
2100 1.1 christos # ---------------------------
2101 1.1 christos # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2102 1.1 christos # suffix to a '.lo' libtool-object suffix.
2103 1.1 christos eval 'func_xform ()
2104 1.1 christos {
2105 1.1 christos func_xform_result=${1%.*}.lo
2106 1.1 christos }'
2107 1.1 christos else
2108 1.1 christos # ...otherwise fall back to using sed.
2109 1.1 christos func_lo2o ()
2110 1.1 christos {
2111 1.1 christos func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2112 1.1 christos }
2113 1.1 christos
2114 1.1 christos func_xform ()
2115 1.1 christos {
2116 1.1 christos func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2117 1.1 christos }
2118 1.1 christos fi
2119 1.1 christos
2120 1.1 christos
2121 1.1 christos # func_fatal_configuration ARG...
2122 1.1 christos # -------------------------------
2123 1.1 christos # Echo program name prefixed message to standard error, followed by
2124 1.1 christos # a configuration failure hint, and exit.
2125 1.1 christos func_fatal_configuration ()
2126 1.1 christos {
2127 1.1 christos func__fatal_error ${1+"$@"} \
2128 1.1 christos "See the $PACKAGE documentation for more information." \
2129 1.1 christos "Fatal configuration error."
2130 1.1 christos }
2131 1.1 christos
2132 1.1 christos
2133 1.1 christos # func_config
2134 1.1 christos # -----------
2135 1.1 christos # Display the configuration for all the tags in this script.
2136 1.1 christos func_config ()
2137 1.1 christos {
2138 1.1 christos re_begincf='^# ### BEGIN LIBTOOL'
2139 1.1 christos re_endcf='^# ### END LIBTOOL'
2140 1.1 christos
2141 1.1 christos # Default configuration.
2142 1.1 christos $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2143 1.1 christos
2144 1.1 christos # Now print the configurations for the tags.
2145 1.1 christos for tagname in $taglist; do
2146 1.1 christos $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147 1.1 christos done
2148 1.1 christos
2149 1.1 christos exit $?
2150 1.1 christos }
2151 1.1 christos
2152 1.1 christos
2153 1.1 christos # func_features
2154 1.1 christos # -------------
2155 1.1 christos # Display the features supported by this script.
2156 1.1 christos func_features ()
2157 1.1 christos {
2158 1.1 christos echo "host: $host"
2159 1.1 christos if test yes = "$build_libtool_libs"; then
2160 1.1 christos echo "enable shared libraries"
2161 1.1 christos else
2162 1.1 christos echo "disable shared libraries"
2163 1.1 christos fi
2164 1.1 christos if test yes = "$build_old_libs"; then
2165 1.1 christos echo "enable static libraries"
2166 1.1 christos else
2167 1.1 christos echo "disable static libraries"
2168 1.1 christos fi
2169 1.1 christos
2170 1.1 christos exit $?
2171 1.1 christos }
2172 1.1 christos
2173 1.1 christos
2174 1.1 christos # func_enable_tag TAGNAME
2175 1.1 christos # -----------------------
2176 1.1 christos # Verify that TAGNAME is valid, and either flag an error and exit, or
2177 1.1 christos # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
2178 1.1 christos # variable here.
2179 1.1 christos func_enable_tag ()
2180 1.1 christos {
2181 1.1 christos # Global variable:
2182 1.1 christos tagname=$1
2183 1.1 christos
2184 1.1 christos re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2185 1.1 christos re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2186 1.1 christos sed_extractcf=/$re_begincf/,/$re_endcf/p
2187 1.1 christos
2188 1.1 christos # Validate tagname.
2189 1.1 christos case $tagname in
2190 1.1 christos *[!-_A-Za-z0-9,/]*)
2191 1.1 christos func_fatal_error "invalid tag name: $tagname"
2192 1.1 christos ;;
2193 1.1 christos esac
2194 1.1 christos
2195 1.1 christos # Don't test for the "default" C tag, as we know it's
2196 1.1 christos # there but not specially marked.
2197 1.1 christos case $tagname in
2198 1.1 christos CC) ;;
2199 1.1 christos *)
2200 1.1 christos if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2201 1.1 christos taglist="$taglist $tagname"
2202 1.1 christos
2203 1.1 christos # Evaluate the configuration. Be careful to quote the path
2204 1.1 christos # and the sed script, to avoid splitting on whitespace, but
2205 1.1 christos # also don't use non-portable quotes within backquotes within
2206 1.1 christos # quotes we have to do it in 2 steps:
2207 1.1 christos extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2208 1.1 christos eval "$extractedcf"
2209 1.1 christos else
2210 1.1 christos func_error "ignoring unknown tag $tagname"
2211 1.1 christos fi
2212 1.1 christos ;;
2213 1.1 christos esac
2214 1.1 christos }
2215 1.1 christos
2216 1.1 christos
2217 1.1 christos # func_check_version_match
2218 1.1 christos # ------------------------
2219 1.1 christos # Ensure that we are using m4 macros, and libtool script from the same
2220 1.1 christos # release of libtool.
2221 1.1 christos func_check_version_match ()
2222 1.1 christos {
2223 1.1 christos if test "$package_revision" != "$macro_revision"; then
2224 1.1 christos if test "$VERSION" != "$macro_version"; then
2225 1.1 christos if test -z "$macro_version"; then
2226 1.1 christos cat >&2 <<_LT_EOF
2227 1.1 christos $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2228 1.1 christos $progname: definition of this LT_INIT comes from an older release.
2229 1.1 christos $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230 1.1 christos $progname: and run autoconf again.
2231 1.1 christos _LT_EOF
2232 1.1 christos else
2233 1.1 christos cat >&2 <<_LT_EOF
2234 1.1 christos $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2235 1.1 christos $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236 1.1 christos $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237 1.1 christos $progname: and run autoconf again.
2238 1.1 christos _LT_EOF
2239 1.1 christos fi
2240 1.1 christos else
2241 1.1 christos cat >&2 <<_LT_EOF
2242 1.1 christos $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
2243 1.1 christos $progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244 1.1 christos $progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245 1.1 christos $progname: of $PACKAGE $VERSION and run autoconf again.
2246 1.1 christos _LT_EOF
2247 1.1 christos fi
2248 1.1 christos
2249 1.1 christos exit $EXIT_MISMATCH
2250 1.1 christos fi
2251 1.1 christos }
2252 1.1 christos
2253 1.1 christos
2254 1.1 christos # libtool_options_prep [ARG]...
2255 1.1 christos # -----------------------------
2256 1.1 christos # Preparation for options parsed by libtool.
2257 1.1 christos libtool_options_prep ()
2258 1.1 christos {
2259 1.1 christos $debug_mode
2260 1.1 christos
2261 1.1 christos # Option defaults:
2262 1.1 christos opt_config=false
2263 1.1 christos opt_dlopen=
2264 1.1 christos opt_dry_run=false
2265 1.1 christos opt_help=false
2266 1.1 christos opt_mode=
2267 1.1 christos opt_preserve_dup_deps=false
2268 1.1 christos opt_quiet=false
2269 1.1 christos
2270 1.1 christos nonopt=
2271 1.1 christos preserve_args=
2272 1.1 christos
2273 1.1 christos # Shorthand for --mode=foo, only valid as the first argument
2274 1.1 christos case $1 in
2275 1.1 christos clean|clea|cle|cl)
2276 1.1 christos shift; set dummy --mode clean ${1+"$@"}; shift
2277 1.1 christos ;;
2278 1.1 christos compile|compil|compi|comp|com|co|c)
2279 1.1 christos shift; set dummy --mode compile ${1+"$@"}; shift
2280 1.1 christos ;;
2281 1.1 christos execute|execut|execu|exec|exe|ex|e)
2282 1.1 christos shift; set dummy --mode execute ${1+"$@"}; shift
2283 1.1 christos ;;
2284 1.1 christos finish|finis|fini|fin|fi|f)
2285 1.1 christos shift; set dummy --mode finish ${1+"$@"}; shift
2286 1.1 christos ;;
2287 1.1 christos install|instal|insta|inst|ins|in|i)
2288 1.1 christos shift; set dummy --mode install ${1+"$@"}; shift
2289 1.1 christos ;;
2290 1.1 christos link|lin|li|l)
2291 1.1 christos shift; set dummy --mode link ${1+"$@"}; shift
2292 1.1 christos ;;
2293 1.1 christos uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2294 1.1 christos shift; set dummy --mode uninstall ${1+"$@"}; shift
2295 1.1 christos ;;
2296 1.1 christos esac
2297 1.1 christos
2298 1.1 christos # Pass back the list of options.
2299 1.1 christos func_quote_for_eval ${1+"$@"}
2300 1.1 christos libtool_options_prep_result=$func_quote_for_eval_result
2301 1.1 christos }
2302 1.1 christos func_add_hook func_options_prep libtool_options_prep
2303 1.1 christos
2304 1.1 christos
2305 1.1 christos # libtool_parse_options [ARG]...
2306 1.1 christos # ---------------------------------
2307 1.1 christos # Provide handling for libtool specific options.
2308 1.1 christos libtool_parse_options ()
2309 1.1 christos {
2310 1.1 christos $debug_cmd
2311 1.1 christos
2312 1.1 christos # Perform our own loop to consume as many options as possible in
2313 1.1 christos # each iteration.
2314 1.1 christos while test $# -gt 0; do
2315 1.1 christos _G_opt=$1
2316 1.1 christos shift
2317 1.1 christos case $_G_opt in
2318 1.1 christos --dry-run|--dryrun|-n)
2319 1.1 christos opt_dry_run=:
2320 1.1 christos ;;
2321 1.1 christos
2322 1.1 christos --config) func_config ;;
2323 1.1 christos
2324 1.1 christos --dlopen|-dlopen)
2325 1.1 christos opt_dlopen="${opt_dlopen+$opt_dlopen
2326 1.1 christos }$1"
2327 1.1 christos shift
2328 1.1 christos ;;
2329 1.1 christos
2330 1.1 christos --preserve-dup-deps)
2331 1.1 christos opt_preserve_dup_deps=: ;;
2332 1.1 christos
2333 1.1 christos --features) func_features ;;
2334 1.1 christos
2335 1.1 christos --finish) set dummy --mode finish ${1+"$@"}; shift ;;
2336 1.1 christos
2337 1.1 christos --help) opt_help=: ;;
2338 1.1 christos
2339 1.1 christos --help-all) opt_help=': help-all' ;;
2340 1.1 christos
2341 1.1 christos --mode) test $# = 0 && func_missing_arg $_G_opt && break
2342 1.1 christos opt_mode=$1
2343 1.1 christos case $1 in
2344 1.1 christos # Valid mode arguments:
2345 1.1 christos clean|compile|execute|finish|install|link|relink|uninstall) ;;
2346 1.1 christos
2347 1.1 christos # Catch anything else as an error
2348 1.1 christos *) func_error "invalid argument for $_G_opt"
2349 1.1 christos exit_cmd=exit
2350 1.1 christos break
2351 1.1 christos ;;
2352 1.1 christos esac
2353 1.1 christos shift
2354 1.1 christos ;;
2355 1.1 christos
2356 1.1 christos --no-silent|--no-quiet)
2357 1.1 christos opt_quiet=false
2358 1.1 christos func_append preserve_args " $_G_opt"
2359 1.1 christos ;;
2360 1.1 christos
2361 1.1 christos --no-warnings|--no-warning|--no-warn)
2362 1.1 christos opt_warning=false
2363 1.1 christos func_append preserve_args " $_G_opt"
2364 1.1 christos ;;
2365 1.1 christos
2366 1.1 christos --no-verbose)
2367 1.1 christos opt_verbose=false
2368 1.1 christos func_append preserve_args " $_G_opt"
2369 1.1 christos ;;
2370 1.1 christos
2371 1.1 christos --silent|--quiet)
2372 1.1 christos opt_quiet=:
2373 1.1 christos opt_verbose=false
2374 1.1 christos func_append preserve_args " $_G_opt"
2375 1.1 christos ;;
2376 1.1 christos
2377 1.1 christos --tag) test $# = 0 && func_missing_arg $_G_opt && break
2378 1.1 christos opt_tag=$1
2379 1.1 christos func_append preserve_args " $_G_opt $1"
2380 1.1 christos func_enable_tag "$1"
2381 1.1 christos shift
2382 1.1 christos ;;
2383 1.1 christos
2384 1.1 christos --verbose|-v) opt_quiet=false
2385 1.1 christos opt_verbose=:
2386 1.1 christos func_append preserve_args " $_G_opt"
2387 1.1 christos ;;
2388 1.1 christos
2389 1.1 christos # An option not handled by this hook function:
2390 1.1 christos *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
2391 1.1 christos esac
2392 1.1 christos done
2393 1.1 christos
2394 1.1 christos
2395 1.1 christos # save modified positional parameters for caller
2396 1.1 christos func_quote_for_eval ${1+"$@"}
2397 1.1 christos libtool_parse_options_result=$func_quote_for_eval_result
2398 1.1 christos }
2399 1.1 christos func_add_hook func_parse_options libtool_parse_options
2400 1.1 christos
2401 1.1 christos
2402 1.1 christos
2403 1.1 christos # libtool_validate_options [ARG]...
2404 1.1 christos # ---------------------------------
2405 1.1 christos # Perform any sanity checks on option settings and/or unconsumed
2406 1.1 christos # arguments.
2407 1.1 christos libtool_validate_options ()
2408 1.1 christos {
2409 1.1 christos # save first non-option argument
2410 1.1 christos if test 0 -lt $#; then
2411 1.1 christos nonopt=$1
2412 1.1 christos shift
2413 1.1 christos fi
2414 1.1 christos
2415 1.1 christos # preserve --debug
2416 1.1 christos test : = "$debug_cmd" || func_append preserve_args " --debug"
2417 1.1 christos
2418 1.1 christos case $host in
2419 1.1 christos # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2420 1.1 christos # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2421 1.1 christos *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2422 1.1 christos # don't eliminate duplications in $postdeps and $predeps
2423 1.1 christos opt_duplicate_compiler_generated_deps=:
2424 1.1 christos ;;
2425 1.1 christos *)
2426 1.1 christos opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2427 1.1 christos ;;
2428 1.1 christos esac
2429 1.1 christos
2430 1.1 christos $opt_help || {
2431 1.1 christos # Sanity checks first:
2432 1.1 christos func_check_version_match
2433 1.1 christos
2434 1.1 christos test yes != "$build_libtool_libs" \
2435 1.1 christos && test yes != "$build_old_libs" \
2436 1.1 christos && func_fatal_configuration "not configured to build any kind of library"
2437 1.1 christos
2438 1.1 christos # Darwin sucks
2439 1.1 christos eval std_shrext=\"$shrext_cmds\"
2440 1.1 christos
2441 1.1 christos # Only execute mode is allowed to have -dlopen flags.
2442 1.1 christos if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2443 1.1 christos func_error "unrecognized option '-dlopen'"
2444 1.1 christos $ECHO "$help" 1>&2
2445 1.1 christos exit $EXIT_FAILURE
2446 1.1 christos fi
2447 1.1 christos
2448 1.1 christos # Change the help message to a mode-specific one.
2449 1.1 christos generic_help=$help
2450 1.1 christos help="Try '$progname --help --mode=$opt_mode' for more information."
2451 1.1 christos }
2452 1.1 christos
2453 1.1 christos # Pass back the unparsed argument list
2454 1.1 christos func_quote_for_eval ${1+"$@"}
2455 1.1 christos libtool_validate_options_result=$func_quote_for_eval_result
2456 1.1 christos }
2457 1.1 christos func_add_hook func_validate_options libtool_validate_options
2458 1.1 christos
2459 1.1 christos
2460 1.1 christos # Process options as early as possible so that --help and --version
2461 1.1 christos # can return quickly.
2462 1.1 christos func_options ${1+"$@"}
2463 1.1 christos eval set dummy "$func_options_result"; shift
2464 1.1 christos
2465 1.1 christos
2466 1.1 christos
2467 1.1 christos ## ----------- ##
2468 1.1 christos ## Main. ##
2469 1.1 christos ## ----------- ##
2470 1.1 christos
2471 1.1 christos magic='%%%MAGIC variable%%%'
2472 1.1 christos magic_exe='%%%MAGIC EXE variable%%%'
2473 1.1 christos
2474 1.1 christos # Global variables.
2475 1.1 christos extracted_archives=
2476 1.1 christos extracted_serial=0
2477 1.1 christos
2478 1.1 christos # If this variable is set in any of the actions, the command in it
2479 1.1 christos # will be execed at the end. This prevents here-documents from being
2480 1.1 christos # left over by shells.
2481 1.1 christos exec_cmd=
2482 1.1 christos
2483 1.1 christos
2484 1.1 christos # A function that is used when there is no print builtin or printf.
2485 1.1 christos func_fallback_echo ()
2486 1.1 christos {
2487 1.1 christos eval 'cat <<_LTECHO_EOF
2488 1.1 christos $1
2489 1.1 christos _LTECHO_EOF'
2490 1.1 christos }
2491 1.1 christos
2492 1.1 christos # func_generated_by_libtool
2493 1.1 christos # True iff stdin has been generated by Libtool. This function is only
2494 1.1 christos # a basic sanity check; it will hardly flush out determined imposters.
2495 1.1 christos func_generated_by_libtool_p ()
2496 1.1 christos {
2497 1.1 christos $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2498 1.1 christos }
2499 1.1 christos
2500 1.1 christos # func_lalib_p file
2501 1.1 christos # True iff FILE is a libtool '.la' library or '.lo' object file.
2502 1.1 christos # This function is only a basic sanity check; it will hardly flush out
2503 1.1 christos # determined imposters.
2504 1.1 christos func_lalib_p ()
2505 1.1 christos {
2506 1.1 christos test -f "$1" &&
2507 1.1 christos $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2508 1.1 christos }
2509 1.1 christos
2510 1.1 christos # func_lalib_unsafe_p file
2511 1.1 christos # True iff FILE is a libtool '.la' library or '.lo' object file.
2512 1.1 christos # This function implements the same check as func_lalib_p without
2513 1.1 christos # resorting to external programs. To this end, it redirects stdin and
2514 1.1 christos # closes it afterwards, without saving the original file descriptor.
2515 1.1 christos # As a safety measure, use it only where a negative result would be
2516 1.1 christos # fatal anyway. Works if 'file' does not exist.
2517 1.1 christos func_lalib_unsafe_p ()
2518 1.1 christos {
2519 1.1 christos lalib_p=no
2520 1.1 christos if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2521 1.1 christos for lalib_p_l in 1 2 3 4
2522 1.1 christos do
2523 1.1 christos read lalib_p_line
2524 1.1 christos case $lalib_p_line in
2525 1.1 christos \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2526 1.1 christos esac
2527 1.1 christos done
2528 1.1 christos exec 0<&5 5<&-
2529 1.1 christos fi
2530 1.1 christos test yes = "$lalib_p"
2531 1.1 christos }
2532 1.1 christos
2533 1.1 christos # func_ltwrapper_script_p file
2534 1.1 christos # True iff FILE is a libtool wrapper script
2535 1.1 christos # This function is only a basic sanity check; it will hardly flush out
2536 1.1 christos # determined imposters.
2537 1.1 christos func_ltwrapper_script_p ()
2538 1.1 christos {
2539 1.1 christos test -f "$1" &&
2540 1.1 christos $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2541 1.1 christos }
2542 1.1 christos
2543 1.1 christos # func_ltwrapper_executable_p file
2544 1.1 christos # True iff FILE is a libtool wrapper executable
2545 1.1 christos # This function is only a basic sanity check; it will hardly flush out
2546 1.1 christos # determined imposters.
2547 1.1 christos func_ltwrapper_executable_p ()
2548 1.1 christos {
2549 1.1 christos func_ltwrapper_exec_suffix=
2550 1.1 christos case $1 in
2551 1.1 christos *.exe) ;;
2552 1.1 christos *) func_ltwrapper_exec_suffix=.exe ;;
2553 1.1 christos esac
2554 1.1 christos $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2555 1.1 christos }
2556 1.1 christos
2557 1.1 christos # func_ltwrapper_scriptname file
2558 1.1 christos # Assumes file is an ltwrapper_executable
2559 1.1 christos # uses $file to determine the appropriate filename for a
2560 1.1 christos # temporary ltwrapper_script.
2561 1.1 christos func_ltwrapper_scriptname ()
2562 1.1 christos {
2563 1.1 christos func_dirname_and_basename "$1" "" "."
2564 1.1 christos func_stripname '' '.exe' "$func_basename_result"
2565 1.1 christos func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2566 1.1 christos }
2567 1.1 christos
2568 1.1 christos # func_ltwrapper_p file
2569 1.1 christos # True iff FILE is a libtool wrapper script or wrapper executable
2570 1.1 christos # This function is only a basic sanity check; it will hardly flush out
2571 1.1 christos # determined imposters.
2572 1.1 christos func_ltwrapper_p ()
2573 1.1 christos {
2574 1.1 christos func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2575 1.1 christos }
2576 1.1 christos
2577 1.1 christos
2578 1.1 christos # func_execute_cmds commands fail_cmd
2579 1.1 christos # Execute tilde-delimited COMMANDS.
2580 1.1 christos # If FAIL_CMD is given, eval that upon failure.
2581 1.1 christos # FAIL_CMD may read-access the current command in variable CMD!
2582 1.1 christos func_execute_cmds ()
2583 1.1 christos {
2584 1.1 christos $debug_cmd
2585 1.1 christos
2586 1.1 christos save_ifs=$IFS; IFS='~'
2587 1.1 christos for cmd in $1; do
2588 1.1 christos IFS=$sp$nl
2589 1.1 christos eval cmd=\"$cmd\"
2590 1.1 christos IFS=$save_ifs
2591 1.1 christos func_show_eval "$cmd" "${2-:}"
2592 1.1 christos done
2593 1.1 christos IFS=$save_ifs
2594 1.1 christos }
2595 1.1 christos
2596 1.1 christos
2597 1.1 christos # func_source file
2598 1.1 christos # Source FILE, adding directory component if necessary.
2599 1.1 christos # Note that it is not necessary on cygwin/mingw to append a dot to
2600 1.1 christos # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2601 1.1 christos # behavior happens only for exec(3), not for open(2)! Also, sourcing
2602 1.1 christos # 'FILE.' does not work on cygwin managed mounts.
2603 1.1 christos func_source ()
2604 1.1 christos {
2605 1.1 christos $debug_cmd
2606 1.1 christos
2607 1.1 christos case $1 in
2608 1.1 christos */* | *\\*) . "$1" ;;
2609 1.1 christos *) . "./$1" ;;
2610 1.1 christos esac
2611 1.1 christos }
2612 1.1 christos
2613 1.1 christos
2614 1.1 christos # func_resolve_sysroot PATH
2615 1.1 christos # Replace a leading = in PATH with a sysroot. Store the result into
2616 1.1 christos # func_resolve_sysroot_result
2617 1.1 christos func_resolve_sysroot ()
2618 1.1 christos {
2619 1.1 christos func_resolve_sysroot_result=$1
2620 1.1 christos case $func_resolve_sysroot_result in
2621 1.1 christos =*)
2622 1.1 christos func_stripname '=' '' "$func_resolve_sysroot_result"
2623 1.1 christos func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624 1.1 christos ;;
2625 1.1 christos esac
2626 1.1 christos }
2627 1.1 christos
2628 1.1 christos # func_replace_sysroot PATH
2629 1.1 christos # If PATH begins with the sysroot, replace it with = and
2630 1.1 christos # store the result into func_replace_sysroot_result.
2631 1.1 christos func_replace_sysroot ()
2632 1.1 christos {
2633 1.1 christos case $lt_sysroot:$1 in
2634 1.1 christos ?*:"$lt_sysroot"*)
2635 1.1 christos func_stripname "$lt_sysroot" '' "$1"
2636 1.1 christos func_replace_sysroot_result='='$func_stripname_result
2637 1.1 christos ;;
2638 1.1 christos *)
2639 1.1 christos # Including no sysroot.
2640 1.1 christos func_replace_sysroot_result=$1
2641 1.1 christos ;;
2642 1.1 christos esac
2643 1.1 christos }
2644 1.1 christos
2645 1.1 christos # func_infer_tag arg
2646 1.1 christos # Infer tagged configuration to use if any are available and
2647 1.1 christos # if one wasn't chosen via the "--tag" command line option.
2648 1.1 christos # Only attempt this if the compiler in the base compile
2649 1.1 christos # command doesn't match the default compiler.
2650 1.1 christos # arg is usually of the form 'gcc ...'
2651 1.1 christos func_infer_tag ()
2652 1.1 christos {
2653 1.1 christos $debug_cmd
2654 1.1 christos
2655 1.1 christos if test -n "$available_tags" && test -z "$tagname"; then
2656 1.1 christos CC_quoted=
2657 1.1 christos for arg in $CC; do
2658 1.1 christos func_append_quoted CC_quoted "$arg"
2659 1.1 christos done
2660 1.1 christos CC_expanded=`func_echo_all $CC`
2661 1.1 christos CC_quoted_expanded=`func_echo_all $CC_quoted`
2662 1.1 christos case $@ in
2663 1.1 christos # Blanks in the command may have been stripped by the calling shell,
2664 1.1 christos # but not from the CC environment variable when configure was run.
2665 1.1 christos " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666 1.1 christos " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2667 1.1 christos # Blanks at the start of $base_compile will cause this to fail
2668 1.1 christos # if we don't check for them as well.
2669 1.1 christos *)
2670 1.1 christos for z in $available_tags; do
2671 1.1 christos if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2672 1.1 christos # Evaluate the configuration.
2673 1.1 christos eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2674 1.1 christos CC_quoted=
2675 1.1 christos for arg in $CC; do
2676 1.1 christos # Double-quote args containing other shell metacharacters.
2677 1.1 christos func_append_quoted CC_quoted "$arg"
2678 1.1 christos done
2679 1.1 christos CC_expanded=`func_echo_all $CC`
2680 1.1 christos CC_quoted_expanded=`func_echo_all $CC_quoted`
2681 1.1 christos case "$@ " in
2682 1.1 christos " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683 1.1 christos " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2684 1.1 christos # The compiler in the base compile command matches
2685 1.1 christos # the one in the tagged configuration.
2686 1.1 christos # Assume this is the tagged configuration we want.
2687 1.1 christos tagname=$z
2688 1.1 christos break
2689 1.1 christos ;;
2690 1.1 christos esac
2691 1.1 christos fi
2692 1.1 christos done
2693 1.1 christos # If $tagname still isn't set, then no tagged configuration
2694 1.1 christos # was found and let the user know that the "--tag" command
2695 1.1 christos # line option must be used.
2696 1.1 christos if test -z "$tagname"; then
2697 1.1 christos func_echo "unable to infer tagged configuration"
2698 1.1 christos func_fatal_error "specify a tag with '--tag'"
2699 1.1 christos # else
2700 1.1 christos # func_verbose "using $tagname tagged configuration"
2701 1.1 christos fi
2702 1.1 christos ;;
2703 1.1 christos esac
2704 1.1 christos fi
2705 1.1 christos }
2706 1.1 christos
2707 1.1 christos
2708 1.1 christos
2709 1.1 christos # func_write_libtool_object output_name pic_name nonpic_name
2710 1.1 christos # Create a libtool object file (analogous to a ".la" file),
2711 1.1 christos # but don't create it if we're doing a dry run.
2712 1.1 christos func_write_libtool_object ()
2713 1.1 christos {
2714 1.1 christos write_libobj=$1
2715 1.1 christos if test yes = "$build_libtool_libs"; then
2716 1.1 christos write_lobj=\'$2\'
2717 1.1 christos else
2718 1.1 christos write_lobj=none
2719 1.1 christos fi
2720 1.1 christos
2721 1.1 christos if test yes = "$build_old_libs"; then
2722 1.1 christos write_oldobj=\'$3\'
2723 1.1 christos else
2724 1.1 christos write_oldobj=none
2725 1.1 christos fi
2726 1.1 christos
2727 1.1 christos $opt_dry_run || {
2728 1.1 christos cat >${write_libobj}T <<EOF
2729 1.1 christos # $write_libobj - a libtool object file
2730 1.1 christos # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731 1.1 christos #
2732 1.1 christos # Please DO NOT delete this file!
2733 1.1 christos # It is necessary for linking the library.
2734 1.1 christos
2735 1.1 christos # Name of the PIC object.
2736 1.1 christos pic_object=$write_lobj
2737 1.1 christos
2738 1.1 christos # Name of the non-PIC object
2739 1.1 christos non_pic_object=$write_oldobj
2740 1.1 christos
2741 1.1 christos EOF
2742 1.1 christos $MV "${write_libobj}T" "$write_libobj"
2743 1.1 christos }
2744 1.1 christos }
2745 1.1 christos
2746 1.1 christos
2747 1.1 christos ##################################################
2748 1.1 christos # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749 1.1 christos ##################################################
2750 1.1 christos
2751 1.1 christos # func_convert_core_file_wine_to_w32 ARG
2752 1.1 christos # Helper function used by file name conversion functions when $build is *nix,
2753 1.1 christos # and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754 1.1 christos # correctly configured wine environment available, with the winepath program
2755 1.1 christos # in $build's $PATH.
2756 1.1 christos #
2757 1.1 christos # ARG is the $build file name to be converted to w32 format.
2758 1.1 christos # Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759 1.1 christos # be empty on error (or when ARG is empty)
2760 1.1 christos func_convert_core_file_wine_to_w32 ()
2761 1.1 christos {
2762 1.1 christos $debug_cmd
2763 1.1 christos
2764 1.1 christos func_convert_core_file_wine_to_w32_result=$1
2765 1.1 christos if test -n "$1"; then
2766 1.1 christos # Unfortunately, winepath does not exit with a non-zero error code, so we
2767 1.1 christos # are forced to check the contents of stdout. On the other hand, if the
2768 1.1 christos # command is not found, the shell will set an exit code of 127 and print
2769 1.1 christos # *an error message* to stdout. So we must check for both error code of
2770 1.1 christos # zero AND non-empty stdout, which explains the odd construction:
2771 1.1 christos func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2772 1.1 christos if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773 1.1 christos func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2774 1.1 christos $SED -e "$sed_naive_backslashify"`
2775 1.1 christos else
2776 1.1 christos func_convert_core_file_wine_to_w32_result=
2777 1.1 christos fi
2778 1.1 christos fi
2779 1.1 christos }
2780 1.1 christos # end: func_convert_core_file_wine_to_w32
2781 1.1 christos
2782 1.1 christos
2783 1.1 christos # func_convert_core_path_wine_to_w32 ARG
2784 1.1 christos # Helper function used by path conversion functions when $build is *nix, and
2785 1.1 christos # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786 1.1 christos # configured wine environment available, with the winepath program in $build's
2787 1.1 christos # $PATH. Assumes ARG has no leading or trailing path separator characters.
2788 1.1 christos #
2789 1.1 christos # ARG is path to be converted from $build format to win32.
2790 1.1 christos # Result is available in $func_convert_core_path_wine_to_w32_result.
2791 1.1 christos # Unconvertible file (directory) names in ARG are skipped; if no directory names
2792 1.1 christos # are convertible, then the result may be empty.
2793 1.1 christos func_convert_core_path_wine_to_w32 ()
2794 1.1 christos {
2795 1.1 christos $debug_cmd
2796 1.1 christos
2797 1.1 christos # unfortunately, winepath doesn't convert paths, only file names
2798 1.1 christos func_convert_core_path_wine_to_w32_result=
2799 1.1 christos if test -n "$1"; then
2800 1.1 christos oldIFS=$IFS
2801 1.1 christos IFS=:
2802 1.1 christos for func_convert_core_path_wine_to_w32_f in $1; do
2803 1.1 christos IFS=$oldIFS
2804 1.1 christos func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2805 1.1 christos if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806 1.1 christos if test -z "$func_convert_core_path_wine_to_w32_result"; then
2807 1.1 christos func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808 1.1 christos else
2809 1.1 christos func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810 1.1 christos fi
2811 1.1 christos fi
2812 1.1 christos done
2813 1.1 christos IFS=$oldIFS
2814 1.1 christos fi
2815 1.1 christos }
2816 1.1 christos # end: func_convert_core_path_wine_to_w32
2817 1.1 christos
2818 1.1 christos
2819 1.1 christos # func_cygpath ARGS...
2820 1.1 christos # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821 1.1 christos # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822 1.1 christos # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823 1.1 christos # (2), returns the Cygwin file name or path in func_cygpath_result (input
2824 1.1 christos # file name or path is assumed to be in w32 format, as previously converted
2825 1.1 christos # from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826 1.1 christos # or path in func_cygpath_result (input file name or path is assumed to be in
2827 1.1 christos # Cygwin format). Returns an empty string on error.
2828 1.1 christos #
2829 1.1 christos # ARGS are passed to cygpath, with the last one being the file name or path to
2830 1.1 christos # be converted.
2831 1.1 christos #
2832 1.1 christos # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833 1.1 christos # environment variable; do not put it in $PATH.
2834 1.1 christos func_cygpath ()
2835 1.1 christos {
2836 1.1 christos $debug_cmd
2837 1.1 christos
2838 1.1 christos if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839 1.1 christos func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840 1.1 christos if test "$?" -ne 0; then
2841 1.1 christos # on failure, ensure result is empty
2842 1.1 christos func_cygpath_result=
2843 1.1 christos fi
2844 1.1 christos else
2845 1.1 christos func_cygpath_result=
2846 1.1 christos func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847 1.1 christos fi
2848 1.1 christos }
2849 1.1 christos #end: func_cygpath
2850 1.1 christos
2851 1.1 christos
2852 1.1 christos # func_convert_core_msys_to_w32 ARG
2853 1.1 christos # Convert file name or path ARG from MSYS format to w32 format. Return
2854 1.1 christos # result in func_convert_core_msys_to_w32_result.
2855 1.1 christos func_convert_core_msys_to_w32 ()
2856 1.1 christos {
2857 1.1 christos $debug_cmd
2858 1.1 christos
2859 1.1 christos # awkward: cmd appends spaces to result
2860 1.1 christos func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2861 1.1 christos $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862 1.1 christos }
2863 1.1 christos #end: func_convert_core_msys_to_w32
2864 1.1 christos
2865 1.1 christos
2866 1.1 christos # func_convert_file_check ARG1 ARG2
2867 1.1 christos # Verify that ARG1 (a file name in $build format) was converted to $host
2868 1.1 christos # format in ARG2. Otherwise, emit an error message, but continue (resetting
2869 1.1 christos # func_to_host_file_result to ARG1).
2870 1.1 christos func_convert_file_check ()
2871 1.1 christos {
2872 1.1 christos $debug_cmd
2873 1.1 christos
2874 1.1 christos if test -z "$2" && test -n "$1"; then
2875 1.1 christos func_error "Could not determine host file name corresponding to"
2876 1.1 christos func_error " '$1'"
2877 1.1 christos func_error "Continuing, but uninstalled executables may not work."
2878 1.1 christos # Fallback:
2879 1.1 christos func_to_host_file_result=$1
2880 1.1 christos fi
2881 1.1 christos }
2882 1.1 christos # end func_convert_file_check
2883 1.1 christos
2884 1.1 christos
2885 1.1 christos # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886 1.1 christos # Verify that FROM_PATH (a path in $build format) was converted to $host
2887 1.1 christos # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888 1.1 christos # func_to_host_file_result to a simplistic fallback value (see below).
2889 1.1 christos func_convert_path_check ()
2890 1.1 christos {
2891 1.1 christos $debug_cmd
2892 1.1 christos
2893 1.1 christos if test -z "$4" && test -n "$3"; then
2894 1.1 christos func_error "Could not determine the host path corresponding to"
2895 1.1 christos func_error " '$3'"
2896 1.1 christos func_error "Continuing, but uninstalled executables may not work."
2897 1.1 christos # Fallback. This is a deliberately simplistic "conversion" and
2898 1.1 christos # should not be "improved". See libtool.info.
2899 1.1 christos if test "x$1" != "x$2"; then
2900 1.1 christos lt_replace_pathsep_chars="s|$1|$2|g"
2901 1.1 christos func_to_host_path_result=`echo "$3" |
2902 1.1 christos $SED -e "$lt_replace_pathsep_chars"`
2903 1.1 christos else
2904 1.1 christos func_to_host_path_result=$3
2905 1.1 christos fi
2906 1.1 christos fi
2907 1.1 christos }
2908 1.1 christos # end func_convert_path_check
2909 1.1 christos
2910 1.1 christos
2911 1.1 christos # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912 1.1 christos # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913 1.1 christos # and appending REPL if ORIG matches BACKPAT.
2914 1.1 christos func_convert_path_front_back_pathsep ()
2915 1.1 christos {
2916 1.1 christos $debug_cmd
2917 1.1 christos
2918 1.1 christos case $4 in
2919 1.1 christos $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920 1.1 christos ;;
2921 1.1 christos esac
2922 1.1 christos case $4 in
2923 1.1 christos $2 ) func_append func_to_host_path_result "$3"
2924 1.1 christos ;;
2925 1.1 christos esac
2926 1.1 christos }
2927 1.1 christos # end func_convert_path_front_back_pathsep
2928 1.1 christos
2929 1.1 christos
2930 1.1 christos ##################################################
2931 1.1 christos # $build to $host FILE NAME CONVERSION FUNCTIONS #
2932 1.1 christos ##################################################
2933 1.1 christos # invoked via '$to_host_file_cmd ARG'
2934 1.1 christos #
2935 1.1 christos # In each case, ARG is the path to be converted from $build to $host format.
2936 1.1 christos # Result will be available in $func_to_host_file_result.
2937 1.1 christos
2938 1.1 christos
2939 1.1 christos # func_to_host_file ARG
2940 1.1 christos # Converts the file name ARG from $build format to $host format. Return result
2941 1.1 christos # in func_to_host_file_result.
2942 1.1 christos func_to_host_file ()
2943 1.1 christos {
2944 1.1 christos $debug_cmd
2945 1.1 christos
2946 1.1 christos $to_host_file_cmd "$1"
2947 1.1 christos }
2948 1.1 christos # end func_to_host_file
2949 1.1 christos
2950 1.1 christos
2951 1.1 christos # func_to_tool_file ARG LAZY
2952 1.1 christos # converts the file name ARG from $build format to toolchain format. Return
2953 1.1 christos # result in func_to_tool_file_result. If the conversion in use is listed
2954 1.1 christos # in (the comma separated) LAZY, no conversion takes place.
2955 1.1 christos func_to_tool_file ()
2956 1.1 christos {
2957 1.1 christos $debug_cmd
2958 1.1 christos
2959 1.1 christos case ,$2, in
2960 1.1 christos *,"$to_tool_file_cmd",*)
2961 1.1 christos func_to_tool_file_result=$1
2962 1.1 christos ;;
2963 1.1 christos *)
2964 1.1 christos $to_tool_file_cmd "$1"
2965 1.1 christos func_to_tool_file_result=$func_to_host_file_result
2966 1.1 christos ;;
2967 1.1 christos esac
2968 1.1 christos }
2969 1.1 christos # end func_to_tool_file
2970 1.1 christos
2971 1.1 christos
2972 1.1 christos # func_convert_file_noop ARG
2973 1.1 christos # Copy ARG to func_to_host_file_result.
2974 1.1 christos func_convert_file_noop ()
2975 1.1 christos {
2976 1.1 christos func_to_host_file_result=$1
2977 1.1 christos }
2978 1.1 christos # end func_convert_file_noop
2979 1.1 christos
2980 1.1 christos
2981 1.1 christos # func_convert_file_msys_to_w32 ARG
2982 1.1 christos # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983 1.1 christos # conversion to w32 is not available inside the cwrapper. Returns result in
2984 1.1 christos # func_to_host_file_result.
2985 1.1 christos func_convert_file_msys_to_w32 ()
2986 1.1 christos {
2987 1.1 christos $debug_cmd
2988 1.1 christos
2989 1.1 christos func_to_host_file_result=$1
2990 1.1 christos if test -n "$1"; then
2991 1.1 christos func_convert_core_msys_to_w32 "$1"
2992 1.1 christos func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993 1.1 christos fi
2994 1.1 christos func_convert_file_check "$1" "$func_to_host_file_result"
2995 1.1 christos }
2996 1.1 christos # end func_convert_file_msys_to_w32
2997 1.1 christos
2998 1.1 christos
2999 1.1 christos # func_convert_file_cygwin_to_w32 ARG
3000 1.1 christos # Convert file name ARG from Cygwin to w32 format. Returns result in
3001 1.1 christos # func_to_host_file_result.
3002 1.1 christos func_convert_file_cygwin_to_w32 ()
3003 1.1 christos {
3004 1.1 christos $debug_cmd
3005 1.1 christos
3006 1.1 christos func_to_host_file_result=$1
3007 1.1 christos if test -n "$1"; then
3008 1.1 christos # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009 1.1 christos # LT_CYGPATH in this case.
3010 1.1 christos func_to_host_file_result=`cygpath -m "$1"`
3011 1.1 christos fi
3012 1.1 christos func_convert_file_check "$1" "$func_to_host_file_result"
3013 1.1 christos }
3014 1.1 christos # end func_convert_file_cygwin_to_w32
3015 1.1 christos
3016 1.1 christos
3017 1.1 christos # func_convert_file_nix_to_w32 ARG
3018 1.1 christos # Convert file name ARG from *nix to w32 format. Requires a wine environment
3019 1.1 christos # and a working winepath. Returns result in func_to_host_file_result.
3020 1.1 christos func_convert_file_nix_to_w32 ()
3021 1.1 christos {
3022 1.1 christos $debug_cmd
3023 1.1 christos
3024 1.1 christos func_to_host_file_result=$1
3025 1.1 christos if test -n "$1"; then
3026 1.1 christos func_convert_core_file_wine_to_w32 "$1"
3027 1.1 christos func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028 1.1 christos fi
3029 1.1 christos func_convert_file_check "$1" "$func_to_host_file_result"
3030 1.1 christos }
3031 1.1 christos # end func_convert_file_nix_to_w32
3032 1.1 christos
3033 1.1 christos
3034 1.1 christos # func_convert_file_msys_to_cygwin ARG
3035 1.1 christos # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3036 1.1 christos # Returns result in func_to_host_file_result.
3037 1.1 christos func_convert_file_msys_to_cygwin ()
3038 1.1 christos {
3039 1.1 christos $debug_cmd
3040 1.1 christos
3041 1.1 christos func_to_host_file_result=$1
3042 1.1 christos if test -n "$1"; then
3043 1.1 christos func_convert_core_msys_to_w32 "$1"
3044 1.1 christos func_cygpath -u "$func_convert_core_msys_to_w32_result"
3045 1.1 christos func_to_host_file_result=$func_cygpath_result
3046 1.1 christos fi
3047 1.1 christos func_convert_file_check "$1" "$func_to_host_file_result"
3048 1.1 christos }
3049 1.1 christos # end func_convert_file_msys_to_cygwin
3050 1.1 christos
3051 1.1 christos
3052 1.1 christos # func_convert_file_nix_to_cygwin ARG
3053 1.1 christos # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
3054 1.1 christos # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
3055 1.1 christos # in func_to_host_file_result.
3056 1.1 christos func_convert_file_nix_to_cygwin ()
3057 1.1 christos {
3058 1.1 christos $debug_cmd
3059 1.1 christos
3060 1.1 christos func_to_host_file_result=$1
3061 1.1 christos if test -n "$1"; then
3062 1.1 christos # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063 1.1 christos func_convert_core_file_wine_to_w32 "$1"
3064 1.1 christos func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3065 1.1 christos func_to_host_file_result=$func_cygpath_result
3066 1.1 christos fi
3067 1.1 christos func_convert_file_check "$1" "$func_to_host_file_result"
3068 1.1 christos }
3069 1.1 christos # end func_convert_file_nix_to_cygwin
3070 1.1 christos
3071 1.1 christos
3072 1.1 christos #############################################
3073 1.1 christos # $build to $host PATH CONVERSION FUNCTIONS #
3074 1.1 christos #############################################
3075 1.1 christos # invoked via '$to_host_path_cmd ARG'
3076 1.1 christos #
3077 1.1 christos # In each case, ARG is the path to be converted from $build to $host format.
3078 1.1 christos # The result will be available in $func_to_host_path_result.
3079 1.1 christos #
3080 1.1 christos # Path separators are also converted from $build format to $host format. If
3081 1.1 christos # ARG begins or ends with a path separator character, it is preserved (but
3082 1.1 christos # converted to $host format) on output.
3083 1.1 christos #
3084 1.1 christos # All path conversion functions are named using the following convention:
3085 1.1 christos # file name conversion function : func_convert_file_X_to_Y ()
3086 1.1 christos # path conversion function : func_convert_path_X_to_Y ()
3087 1.1 christos # where, for any given $build/$host combination the 'X_to_Y' value is the
3088 1.1 christos # same. If conversion functions are added for new $build/$host combinations,
3089 1.1 christos # the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090 1.1 christos # will break.
3091 1.1 christos
3092 1.1 christos
3093 1.1 christos # func_init_to_host_path_cmd
3094 1.1 christos # Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095 1.1 christos # appropriate value, based on the value of $to_host_file_cmd.
3096 1.1 christos to_host_path_cmd=
3097 1.1 christos func_init_to_host_path_cmd ()
3098 1.1 christos {
3099 1.1 christos $debug_cmd
3100 1.1 christos
3101 1.1 christos if test -z "$to_host_path_cmd"; then
3102 1.1 christos func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3103 1.1 christos to_host_path_cmd=func_convert_path_$func_stripname_result
3104 1.1 christos fi
3105 1.1 christos }
3106 1.1 christos
3107 1.1 christos
3108 1.1 christos # func_to_host_path ARG
3109 1.1 christos # Converts the path ARG from $build format to $host format. Return result
3110 1.1 christos # in func_to_host_path_result.
3111 1.1 christos func_to_host_path ()
3112 1.1 christos {
3113 1.1 christos $debug_cmd
3114 1.1 christos
3115 1.1 christos func_init_to_host_path_cmd
3116 1.1 christos $to_host_path_cmd "$1"
3117 1.1 christos }
3118 1.1 christos # end func_to_host_path
3119 1.1 christos
3120 1.1 christos
3121 1.1 christos # func_convert_path_noop ARG
3122 1.1 christos # Copy ARG to func_to_host_path_result.
3123 1.1 christos func_convert_path_noop ()
3124 1.1 christos {
3125 1.1 christos func_to_host_path_result=$1
3126 1.1 christos }
3127 1.1 christos # end func_convert_path_noop
3128 1.1 christos
3129 1.1 christos
3130 1.1 christos # func_convert_path_msys_to_w32 ARG
3131 1.1 christos # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132 1.1 christos # conversion to w32 is not available inside the cwrapper. Returns result in
3133 1.1 christos # func_to_host_path_result.
3134 1.1 christos func_convert_path_msys_to_w32 ()
3135 1.1 christos {
3136 1.1 christos $debug_cmd
3137 1.1 christos
3138 1.1 christos func_to_host_path_result=$1
3139 1.1 christos if test -n "$1"; then
3140 1.1 christos # Remove leading and trailing path separator characters from ARG. MSYS
3141 1.1 christos # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142 1.1 christos # and winepath ignores them completely.
3143 1.1 christos func_stripname : : "$1"
3144 1.1 christos func_to_host_path_tmp1=$func_stripname_result
3145 1.1 christos func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3146 1.1 christos func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147 1.1 christos func_convert_path_check : ";" \
3148 1.1 christos "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149 1.1 christos func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150 1.1 christos fi
3151 1.1 christos }
3152 1.1 christos # end func_convert_path_msys_to_w32
3153 1.1 christos
3154 1.1 christos
3155 1.1 christos # func_convert_path_cygwin_to_w32 ARG
3156 1.1 christos # Convert path ARG from Cygwin to w32 format. Returns result in
3157 1.1 christos # func_to_host_file_result.
3158 1.1 christos func_convert_path_cygwin_to_w32 ()
3159 1.1 christos {
3160 1.1 christos $debug_cmd
3161 1.1 christos
3162 1.1 christos func_to_host_path_result=$1
3163 1.1 christos if test -n "$1"; then
3164 1.1 christos # See func_convert_path_msys_to_w32:
3165 1.1 christos func_stripname : : "$1"
3166 1.1 christos func_to_host_path_tmp1=$func_stripname_result
3167 1.1 christos func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168 1.1 christos func_convert_path_check : ";" \
3169 1.1 christos "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170 1.1 christos func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171 1.1 christos fi
3172 1.1 christos }
3173 1.1 christos # end func_convert_path_cygwin_to_w32
3174 1.1 christos
3175 1.1 christos
3176 1.1 christos # func_convert_path_nix_to_w32 ARG
3177 1.1 christos # Convert path ARG from *nix to w32 format. Requires a wine environment and
3178 1.1 christos # a working winepath. Returns result in func_to_host_file_result.
3179 1.1 christos func_convert_path_nix_to_w32 ()
3180 1.1 christos {
3181 1.1 christos $debug_cmd
3182 1.1 christos
3183 1.1 christos func_to_host_path_result=$1
3184 1.1 christos if test -n "$1"; then
3185 1.1 christos # See func_convert_path_msys_to_w32:
3186 1.1 christos func_stripname : : "$1"
3187 1.1 christos func_to_host_path_tmp1=$func_stripname_result
3188 1.1 christos func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3189 1.1 christos func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190 1.1 christos func_convert_path_check : ";" \
3191 1.1 christos "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192 1.1 christos func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193 1.1 christos fi
3194 1.1 christos }
3195 1.1 christos # end func_convert_path_nix_to_w32
3196 1.1 christos
3197 1.1 christos
3198 1.1 christos # func_convert_path_msys_to_cygwin ARG
3199 1.1 christos # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3200 1.1 christos # Returns result in func_to_host_file_result.
3201 1.1 christos func_convert_path_msys_to_cygwin ()
3202 1.1 christos {
3203 1.1 christos $debug_cmd
3204 1.1 christos
3205 1.1 christos func_to_host_path_result=$1
3206 1.1 christos if test -n "$1"; then
3207 1.1 christos # See func_convert_path_msys_to_w32:
3208 1.1 christos func_stripname : : "$1"
3209 1.1 christos func_to_host_path_tmp1=$func_stripname_result
3210 1.1 christos func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211 1.1 christos func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3212 1.1 christos func_to_host_path_result=$func_cygpath_result
3213 1.1 christos func_convert_path_check : : \
3214 1.1 christos "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215 1.1 christos func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216 1.1 christos fi
3217 1.1 christos }
3218 1.1 christos # end func_convert_path_msys_to_cygwin
3219 1.1 christos
3220 1.1 christos
3221 1.1 christos # func_convert_path_nix_to_cygwin ARG
3222 1.1 christos # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
3223 1.1 christos # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
3224 1.1 christos # func_to_host_file_result.
3225 1.1 christos func_convert_path_nix_to_cygwin ()
3226 1.1 christos {
3227 1.1 christos $debug_cmd
3228 1.1 christos
3229 1.1 christos func_to_host_path_result=$1
3230 1.1 christos if test -n "$1"; then
3231 1.1 christos # Remove leading and trailing path separator characters from
3232 1.1 christos # ARG. msys behavior is inconsistent here, cygpath turns them
3233 1.1 christos # into '.;' and ';.', and winepath ignores them completely.
3234 1.1 christos func_stripname : : "$1"
3235 1.1 christos func_to_host_path_tmp1=$func_stripname_result
3236 1.1 christos func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237 1.1 christos func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3238 1.1 christos func_to_host_path_result=$func_cygpath_result
3239 1.1 christos func_convert_path_check : : \
3240 1.1 christos "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241 1.1 christos func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242 1.1 christos fi
3243 1.1 christos }
3244 1.1 christos # end func_convert_path_nix_to_cygwin
3245 1.1 christos
3246 1.1 christos
3247 1.1 christos # func_dll_def_p FILE
3248 1.1 christos # True iff FILE is a Windows DLL '.def' file.
3249 1.1 christos # Keep in sync with _LT_DLL_DEF_P in libtool.m4
3250 1.1 christos func_dll_def_p ()
3251 1.1 christos {
3252 1.1 christos $debug_cmd
3253 1.1 christos
3254 1.1 christos func_dll_def_p_tmp=`$SED -n \
3255 1.1 christos -e 's/^[ ]*//' \
3256 1.1 christos -e '/^\(;.*\)*$/d' \
3257 1.1 christos -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
3258 1.1 christos -e q \
3259 1.1 christos "$1"`
3260 1.1 christos test DEF = "$func_dll_def_p_tmp"
3261 1.1 christos }
3262 1.1 christos
3263 1.1 christos
3264 1.1 christos # func_mode_compile arg...
3265 1.1 christos func_mode_compile ()
3266 1.1 christos {
3267 1.1 christos $debug_cmd
3268 1.1 christos
3269 1.1 christos # Get the compilation command and the source file.
3270 1.1 christos base_compile=
3271 1.1 christos srcfile=$nonopt # always keep a non-empty value in "srcfile"
3272 1.1 christos suppress_opt=yes
3273 1.1 christos suppress_output=
3274 1.1 christos arg_mode=normal
3275 1.1 christos libobj=
3276 1.1 christos later=
3277 1.1 christos pie_flag=
3278 1.1 christos
3279 1.1 christos for arg
3280 1.1 christos do
3281 1.1 christos case $arg_mode in
3282 1.1 christos arg )
3283 1.1 christos # do not "continue". Instead, add this to base_compile
3284 1.1 christos lastarg=$arg
3285 1.1 christos arg_mode=normal
3286 1.1 christos ;;
3287 1.1 christos
3288 1.1 christos target )
3289 1.1 christos libobj=$arg
3290 1.1 christos arg_mode=normal
3291 1.1 christos continue
3292 1.1 christos ;;
3293 1.1 christos
3294 1.1 christos normal )
3295 1.1 christos # Accept any command-line options.
3296 1.1 christos case $arg in
3297 1.1 christos -o)
3298 1.1 christos test -n "$libobj" && \
3299 1.1 christos func_fatal_error "you cannot specify '-o' more than once"
3300 1.1 christos arg_mode=target
3301 1.1 christos continue
3302 1.1 christos ;;
3303 1.1 christos
3304 1.1 christos -pie | -fpie | -fPIE)
3305 1.1 christos func_append pie_flag " $arg"
3306 1.1 christos continue
3307 1.1 christos ;;
3308 1.1 christos
3309 1.1 christos -shared | -static | -prefer-pic | -prefer-non-pic)
3310 1.1 christos func_append later " $arg"
3311 1.1 christos continue
3312 1.1 christos ;;
3313 1.1 christos
3314 1.1 christos -no-suppress)
3315 1.1 christos suppress_opt=no
3316 1.1 christos continue
3317 1.1 christos ;;
3318 1.1 christos
3319 1.1 christos -Xcompiler)
3320 1.1 christos arg_mode=arg # the next one goes into the "base_compile" arg list
3321 1.1 christos continue # The current "srcfile" will either be retained or
3322 1.1 christos ;; # replaced later. I would guess that would be a bug.
3323 1.1 christos
3324 1.1 christos -Wc,*)
3325 1.1 christos func_stripname '-Wc,' '' "$arg"
3326 1.1 christos args=$func_stripname_result
3327 1.1 christos lastarg=
3328 1.1 christos save_ifs=$IFS; IFS=,
3329 1.1 christos for arg in $args; do
3330 1.1 christos IFS=$save_ifs
3331 1.1 christos func_append_quoted lastarg "$arg"
3332 1.1 christos done
3333 1.1 christos IFS=$save_ifs
3334 1.1 christos func_stripname ' ' '' "$lastarg"
3335 1.1 christos lastarg=$func_stripname_result
3336 1.1 christos
3337 1.1 christos # Add the arguments to base_compile.
3338 1.1 christos func_append base_compile " $lastarg"
3339 1.1 christos continue
3340 1.1 christos ;;
3341 1.1 christos
3342 1.1 christos *)
3343 1.1 christos # Accept the current argument as the source file.
3344 1.1 christos # The previous "srcfile" becomes the current argument.
3345 1.1 christos #
3346 1.1 christos lastarg=$srcfile
3347 1.1 christos srcfile=$arg
3348 1.1 christos ;;
3349 1.1 christos esac # case $arg
3350 1.1 christos ;;
3351 1.1 christos esac # case $arg_mode
3352 1.1 christos
3353 1.1 christos # Aesthetically quote the previous argument.
3354 1.1 christos func_append_quoted base_compile "$lastarg"
3355 1.1 christos done # for arg
3356 1.1 christos
3357 1.1 christos case $arg_mode in
3358 1.1 christos arg)
3359 1.1 christos func_fatal_error "you must specify an argument for -Xcompile"
3360 1.1 christos ;;
3361 1.1 christos target)
3362 1.1 christos func_fatal_error "you must specify a target with '-o'"
3363 1.1 christos ;;
3364 1.1 christos *)
3365 1.1 christos # Get the name of the library object.
3366 1.1 christos test -z "$libobj" && {
3367 1.1 christos func_basename "$srcfile"
3368 1.1 christos libobj=$func_basename_result
3369 1.1 christos }
3370 1.1 christos ;;
3371 1.1 christos esac
3372 1.1 christos
3373 1.1 christos # Recognize several different file suffixes.
3374 1.1 christos # If the user specifies -o file.o, it is replaced with file.lo
3375 1.1 christos case $libobj in
3376 1.1 christos *.[cCFSifmso] | \
3377 1.1 christos *.ada | *.adb | *.ads | *.asm | \
3378 1.1 christos *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3379 1.1 christos *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3380 1.1 christos func_xform "$libobj"
3381 1.1 christos libobj=$func_xform_result
3382 1.1 christos ;;
3383 1.1 christos esac
3384 1.1 christos
3385 1.1 christos case $libobj in
3386 1.1 christos *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387 1.1 christos *)
3388 1.1 christos func_fatal_error "cannot determine name of library object from '$libobj'"
3389 1.1 christos ;;
3390 1.1 christos esac
3391 1.1 christos
3392 1.1 christos func_infer_tag $base_compile
3393 1.1 christos
3394 1.1 christos for arg in $later; do
3395 1.1 christos case $arg in
3396 1.1 christos -shared)
3397 1.1 christos test yes = "$build_libtool_libs" \
3398 1.1 christos || func_fatal_configuration "cannot build a shared library"
3399 1.1 christos build_old_libs=no
3400 1.1 christos continue
3401 1.1 christos ;;
3402 1.1 christos
3403 1.1 christos -static)
3404 1.1 christos build_libtool_libs=no
3405 1.1 christos build_old_libs=yes
3406 1.1 christos continue
3407 1.1 christos ;;
3408 1.1 christos
3409 1.1 christos -prefer-pic)
3410 1.1 christos pic_mode=yes
3411 1.1 christos continue
3412 1.1 christos ;;
3413 1.1 christos
3414 1.1 christos -prefer-non-pic)
3415 1.1 christos pic_mode=no
3416 1.1 christos continue
3417 1.1 christos ;;
3418 1.1 christos esac
3419 1.1 christos done
3420 1.1 christos
3421 1.1 christos func_quote_for_eval "$libobj"
3422 1.1 christos test "X$libobj" != "X$func_quote_for_eval_result" \
3423 1.1 christos && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
3424 1.1 christos && func_warning "libobj name '$libobj' may not contain shell special characters."
3425 1.1 christos func_dirname_and_basename "$obj" "/" ""
3426 1.1 christos objname=$func_basename_result
3427 1.1 christos xdir=$func_dirname_result
3428 1.1 christos lobj=$xdir$objdir/$objname
3429 1.1 christos
3430 1.1 christos test -z "$base_compile" && \
3431 1.1 christos func_fatal_help "you must specify a compilation command"
3432 1.1 christos
3433 1.1 christos # Delete any leftover library objects.
3434 1.1 christos if test yes = "$build_old_libs"; then
3435 1.1 christos removelist="$obj $lobj $libobj ${libobj}T"
3436 1.1 christos else
3437 1.1 christos removelist="$lobj $libobj ${libobj}T"
3438 1.1 christos fi
3439 1.1 christos
3440 1.1 christos # On Cygwin there's no "real" PIC flag so we must build both object types
3441 1.1 christos case $host_os in
3442 1.1 christos cygwin* | mingw* | pw32* | os2* | cegcc*)
3443 1.1 christos pic_mode=default
3444 1.1 christos ;;
3445 1.1 christos esac
3446 1.1 christos if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447 1.1 christos # non-PIC code in shared libraries is not supported
3448 1.1 christos pic_mode=default
3449 1.1 christos fi
3450 1.1 christos
3451 1.1 christos # Calculate the filename of the output object if compiler does
3452 1.1 christos # not support -o with -c
3453 1.1 christos if test no = "$compiler_c_o"; then
3454 1.1 christos output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3455 1.1 christos lockfile=$output_obj.lock
3456 1.1 christos else
3457 1.1 christos output_obj=
3458 1.1 christos need_locks=no
3459 1.1 christos lockfile=
3460 1.1 christos fi
3461 1.1 christos
3462 1.1 christos # Lock this critical section if it is needed
3463 1.1 christos # We use this script file to make the link, it avoids creating a new file
3464 1.1 christos if test yes = "$need_locks"; then
3465 1.1 christos until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3466 1.1 christos func_echo "Waiting for $lockfile to be removed"
3467 1.1 christos sleep 2
3468 1.1 christos done
3469 1.1 christos elif test warn = "$need_locks"; then
3470 1.1 christos if test -f "$lockfile"; then
3471 1.1 christos $ECHO "\
3472 1.1 christos *** ERROR, $lockfile exists and contains:
3473 1.1 christos `cat $lockfile 2>/dev/null`
3474 1.1 christos
3475 1.1 christos This indicates that another process is trying to use the same
3476 1.1 christos temporary object file, and libtool could not work around it because
3477 1.1 christos your compiler does not support '-c' and '-o' together. If you
3478 1.1 christos repeat this compilation, it may succeed, by chance, but you had better
3479 1.1 christos avoid parallel builds (make -j) in this platform, or get a better
3480 1.1 christos compiler."
3481 1.1 christos
3482 1.1 christos $opt_dry_run || $RM $removelist
3483 1.1 christos exit $EXIT_FAILURE
3484 1.1 christos fi
3485 1.1 christos func_append removelist " $output_obj"
3486 1.1 christos $ECHO "$srcfile" > "$lockfile"
3487 1.1 christos fi
3488 1.1 christos
3489 1.1 christos $opt_dry_run || $RM $removelist
3490 1.1 christos func_append removelist " $lockfile"
3491 1.1 christos trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3492 1.1 christos
3493 1.1 christos func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494 1.1 christos srcfile=$func_to_tool_file_result
3495 1.1 christos func_quote_for_eval "$srcfile"
3496 1.1 christos qsrcfile=$func_quote_for_eval_result
3497 1.1 christos
3498 1.1 christos # Only build a PIC object if we are building libtool libraries.
3499 1.1 christos if test yes = "$build_libtool_libs"; then
3500 1.1 christos # Without this assignment, base_compile gets emptied.
3501 1.1 christos fbsd_hideous_sh_bug=$base_compile
3502 1.1 christos
3503 1.1 christos if test no != "$pic_mode"; then
3504 1.1 christos command="$base_compile $qsrcfile $pic_flag"
3505 1.1 christos else
3506 1.1 christos # Don't build PIC code
3507 1.1 christos command="$base_compile $qsrcfile"
3508 1.1 christos fi
3509 1.1 christos
3510 1.1 christos func_mkdir_p "$xdir$objdir"
3511 1.1 christos
3512 1.1 christos if test -z "$output_obj"; then
3513 1.1 christos # Place PIC objects in $objdir
3514 1.1 christos func_append command " -o $lobj"
3515 1.1 christos fi
3516 1.1 christos
3517 1.1 christos func_show_eval_locale "$command" \
3518 1.1 christos 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519 1.1 christos
3520 1.1 christos if test warn = "$need_locks" &&
3521 1.1 christos test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3522 1.1 christos $ECHO "\
3523 1.1 christos *** ERROR, $lockfile contains:
3524 1.1 christos `cat $lockfile 2>/dev/null`
3525 1.1 christos
3526 1.1 christos but it should contain:
3527 1.1 christos $srcfile
3528 1.1 christos
3529 1.1 christos This indicates that another process is trying to use the same
3530 1.1 christos temporary object file, and libtool could not work around it because
3531 1.1 christos your compiler does not support '-c' and '-o' together. If you
3532 1.1 christos repeat this compilation, it may succeed, by chance, but you had better
3533 1.1 christos avoid parallel builds (make -j) in this platform, or get a better
3534 1.1 christos compiler."
3535 1.1 christos
3536 1.1 christos $opt_dry_run || $RM $removelist
3537 1.1 christos exit $EXIT_FAILURE
3538 1.1 christos fi
3539 1.1 christos
3540 1.1 christos # Just move the object if needed, then go on to compile the next one
3541 1.1 christos if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3542 1.1 christos func_show_eval '$MV "$output_obj" "$lobj"' \
3543 1.1 christos 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544 1.1 christos fi
3545 1.1 christos
3546 1.1 christos # Allow error messages only from the first compilation.
3547 1.1 christos if test yes = "$suppress_opt"; then
3548 1.1 christos suppress_output=' >/dev/null 2>&1'
3549 1.1 christos fi
3550 1.1 christos fi
3551 1.1 christos
3552 1.1 christos # Only build a position-dependent object if we build old libraries.
3553 1.1 christos if test yes = "$build_old_libs"; then
3554 1.1 christos if test yes != "$pic_mode"; then
3555 1.1 christos # Don't build PIC code
3556 1.1 christos command="$base_compile $qsrcfile$pie_flag"
3557 1.1 christos else
3558 1.1 christos command="$base_compile $qsrcfile $pic_flag"
3559 1.1 christos fi
3560 1.1 christos if test yes = "$compiler_c_o"; then
3561 1.1 christos func_append command " -o $obj"
3562 1.1 christos fi
3563 1.1 christos
3564 1.1 christos # Suppress compiler output if we already did a PIC compilation.
3565 1.1 christos func_append command "$suppress_output"
3566 1.1 christos func_show_eval_locale "$command" \
3567 1.1 christos '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568 1.1 christos
3569 1.1 christos if test warn = "$need_locks" &&
3570 1.1 christos test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3571 1.1 christos $ECHO "\
3572 1.1 christos *** ERROR, $lockfile contains:
3573 1.1 christos `cat $lockfile 2>/dev/null`
3574 1.1 christos
3575 1.1 christos but it should contain:
3576 1.1 christos $srcfile
3577 1.1 christos
3578 1.1 christos This indicates that another process is trying to use the same
3579 1.1 christos temporary object file, and libtool could not work around it because
3580 1.1 christos your compiler does not support '-c' and '-o' together. If you
3581 1.1 christos repeat this compilation, it may succeed, by chance, but you had better
3582 1.1 christos avoid parallel builds (make -j) in this platform, or get a better
3583 1.1 christos compiler."
3584 1.1 christos
3585 1.1 christos $opt_dry_run || $RM $removelist
3586 1.1 christos exit $EXIT_FAILURE
3587 1.1 christos fi
3588 1.1 christos
3589 1.1 christos # Just move the object if needed
3590 1.1 christos if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3591 1.1 christos func_show_eval '$MV "$output_obj" "$obj"' \
3592 1.1 christos 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593 1.1 christos fi
3594 1.1 christos fi
3595 1.1 christos
3596 1.1 christos $opt_dry_run || {
3597 1.1 christos func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598 1.1 christos
3599 1.1 christos # Unlock the critical section if it was locked
3600 1.1 christos if test no != "$need_locks"; then
3601 1.1 christos removelist=$lockfile
3602 1.1 christos $RM "$lockfile"
3603 1.1 christos fi
3604 1.1 christos }
3605 1.1 christos
3606 1.1 christos exit $EXIT_SUCCESS
3607 1.1 christos }
3608 1.1 christos
3609 1.1 christos $opt_help || {
3610 1.1 christos test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3611 1.1 christos }
3612 1.1 christos
3613 1.1 christos func_mode_help ()
3614 1.1 christos {
3615 1.1 christos # We need to display help for each of the modes.
3616 1.1 christos case $opt_mode in
3617 1.1 christos "")
3618 1.1 christos # Generic help is extracted from the usage comments
3619 1.1 christos # at the start of this file.
3620 1.1 christos func_help
3621 1.1 christos ;;
3622 1.1 christos
3623 1.1 christos clean)
3624 1.1 christos $ECHO \
3625 1.1 christos "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626 1.1 christos
3627 1.1 christos Remove files from the build directory.
3628 1.1 christos
3629 1.1 christos RM is the name of the program to use to delete files associated with each FILE
3630 1.1 christos (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3631 1.1 christos to RM.
3632 1.1 christos
3633 1.1 christos If FILE is a libtool library, object or program, all the files associated
3634 1.1 christos with it are deleted. Otherwise, only FILE itself is deleted using RM."
3635 1.1 christos ;;
3636 1.1 christos
3637 1.1 christos compile)
3638 1.1 christos $ECHO \
3639 1.1 christos "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640 1.1 christos
3641 1.1 christos Compile a source file into a libtool library object.
3642 1.1 christos
3643 1.1 christos This mode accepts the following additional options:
3644 1.1 christos
3645 1.1 christos -o OUTPUT-FILE set the output file name to OUTPUT-FILE
3646 1.1 christos -no-suppress do not suppress compiler output for multiple passes
3647 1.1 christos -prefer-pic try to build PIC objects only
3648 1.1 christos -prefer-non-pic try to build non-PIC objects only
3649 1.1 christos -shared do not build a '.o' file suitable for static linking
3650 1.1 christos -static only build a '.o' file suitable for static linking
3651 1.1 christos -Wc,FLAG pass FLAG directly to the compiler
3652 1.1 christos
3653 1.1 christos COMPILE-COMMAND is a command to be used in creating a 'standard' object file
3654 1.1 christos from the given SOURCEFILE.
3655 1.1 christos
3656 1.1 christos The output file name is determined by removing the directory component from
3657 1.1 christos SOURCEFILE, then substituting the C source code suffix '.c' with the
3658 1.1 christos library object suffix, '.lo'."
3659 1.1 christos ;;
3660 1.1 christos
3661 1.1 christos execute)
3662 1.1 christos $ECHO \
3663 1.1 christos "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664 1.1 christos
3665 1.1 christos Automatically set library path, then run a program.
3666 1.1 christos
3667 1.1 christos This mode accepts the following additional options:
3668 1.1 christos
3669 1.1 christos -dlopen FILE add the directory containing FILE to the library path
3670 1.1 christos
3671 1.1 christos This mode sets the library path environment variable according to '-dlopen'
3672 1.1 christos flags.
3673 1.1 christos
3674 1.1 christos If any of the ARGS are libtool executable wrappers, then they are translated
3675 1.1 christos into their corresponding uninstalled binary, and any of their required library
3676 1.1 christos directories are added to the library path.
3677 1.1 christos
3678 1.1 christos Then, COMMAND is executed, with ARGS as arguments."
3679 1.1 christos ;;
3680 1.1 christos
3681 1.1 christos finish)
3682 1.1 christos $ECHO \
3683 1.1 christos "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684 1.1 christos
3685 1.1 christos Complete the installation of libtool libraries.
3686 1.1 christos
3687 1.1 christos Each LIBDIR is a directory that contains libtool libraries.
3688 1.1 christos
3689 1.1 christos The commands that this mode executes may require superuser privileges. Use
3690 1.1 christos the '--dry-run' option if you just want to see what would be executed."
3691 1.1 christos ;;
3692 1.1 christos
3693 1.1 christos install)
3694 1.1 christos $ECHO \
3695 1.1 christos "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696 1.1 christos
3697 1.1 christos Install executables or libraries.
3698 1.1 christos
3699 1.1 christos INSTALL-COMMAND is the installation command. The first component should be
3700 1.1 christos either the 'install' or 'cp' program.
3701 1.1 christos
3702 1.1 christos The following components of INSTALL-COMMAND are treated specially:
3703 1.1 christos
3704 1.1 christos -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
3705 1.1 christos
3706 1.1 christos The rest of the components are interpreted as arguments to that command (only
3707 1.1 christos BSD-compatible install options are recognized)."
3708 1.1 christos ;;
3709 1.1 christos
3710 1.1 christos link)
3711 1.1 christos $ECHO \
3712 1.1 christos "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713 1.1 christos
3714 1.1 christos Link object files or libraries together to form another library, or to
3715 1.1 christos create an executable program.
3716 1.1 christos
3717 1.1 christos LINK-COMMAND is a command using the C compiler that you would use to create
3718 1.1 christos a program from several object files.
3719 1.1 christos
3720 1.1 christos The following components of LINK-COMMAND are treated specially:
3721 1.1 christos
3722 1.1 christos -all-static do not do any dynamic linking at all
3723 1.1 christos -avoid-version do not add a version suffix if possible
3724 1.1 christos -bindir BINDIR specify path to binaries directory (for systems where
3725 1.1 christos libraries must be found in the PATH setting at runtime)
3726 1.1 christos -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
3727 1.1 christos -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
3728 1.1 christos -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3729 1.1 christos -export-symbols SYMFILE
3730 1.1 christos try to export only the symbols listed in SYMFILE
3731 1.1 christos -export-symbols-regex REGEX
3732 1.1 christos try to export only the symbols matching REGEX
3733 1.1 christos -LLIBDIR search LIBDIR for required installed libraries
3734 1.1 christos -lNAME OUTPUT-FILE requires the installed library libNAME
3735 1.1 christos -module build a library that can dlopened
3736 1.1 christos -no-fast-install disable the fast-install mode
3737 1.1 christos -no-install link a not-installable executable
3738 1.1 christos -no-undefined declare that a library does not refer to external symbols
3739 1.1 christos -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
3740 1.1 christos -objectlist FILE use a list of object files found in FILE to specify objects
3741 1.1 christos -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
3742 1.1 christos -precious-files-regex REGEX
3743 1.1 christos don't remove output files matching REGEX
3744 1.1 christos -release RELEASE specify package release information
3745 1.1 christos -rpath LIBDIR the created library will eventually be installed in LIBDIR
3746 1.1 christos -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
3747 1.1 christos -shared only do dynamic linking of libtool libraries
3748 1.1 christos -shrext SUFFIX override the standard shared library file extension
3749 1.1 christos -static do not do any dynamic linking of uninstalled libtool libraries
3750 1.1 christos -static-libtool-libs
3751 1.1 christos do not do any dynamic linking of libtool libraries
3752 1.1 christos -version-info CURRENT[:REVISION[:AGE]]
3753 1.1 christos specify library version info [each variable defaults to 0]
3754 1.1 christos -weak LIBNAME declare that the target provides the LIBNAME interface
3755 1.1 christos -Wc,FLAG
3756 1.1 christos -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
3757 1.1 christos -Wl,FLAG
3758 1.1 christos -Xlinker FLAG pass linker-specific FLAG directly to the linker
3759 1.1 christos -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
3760 1.1 christos
3761 1.1 christos All other options (arguments beginning with '-') are ignored.
3762 1.1 christos
3763 1.1 christos Every other argument is treated as a filename. Files ending in '.la' are
3764 1.1 christos treated as uninstalled libtool libraries, other files are standard or library
3765 1.1 christos object files.
3766 1.1 christos
3767 1.1 christos If the OUTPUT-FILE ends in '.la', then a libtool library is created,
3768 1.1 christos only library objects ('.lo' files) may be specified, and '-rpath' is
3769 1.1 christos required, except when creating a convenience library.
3770 1.1 christos
3771 1.1 christos If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3772 1.1 christos using 'ar' and 'ranlib', or on Windows using 'lib'.
3773 1.1 christos
3774 1.1 christos If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3775 1.1 christos is created, otherwise an executable program is created."
3776 1.1 christos ;;
3777 1.1 christos
3778 1.1 christos uninstall)
3779 1.1 christos $ECHO \
3780 1.1 christos "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781 1.1 christos
3782 1.1 christos Remove libraries from an installation directory.
3783 1.1 christos
3784 1.1 christos RM is the name of the program to use to delete files associated with each FILE
3785 1.1 christos (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3786 1.1 christos to RM.
3787 1.1 christos
3788 1.1 christos If FILE is a libtool library, all the files associated with it are deleted.
3789 1.1 christos Otherwise, only FILE itself is deleted using RM."
3790 1.1 christos ;;
3791 1.1 christos
3792 1.1 christos *)
3793 1.1 christos func_fatal_help "invalid operation mode '$opt_mode'"
3794 1.1 christos ;;
3795 1.1 christos esac
3796 1.1 christos
3797 1.1 christos echo
3798 1.1 christos $ECHO "Try '$progname --help' for more information about other modes."
3799 1.1 christos }
3800 1.1 christos
3801 1.1 christos # Now that we've collected a possible --mode arg, show help if necessary
3802 1.1 christos if $opt_help; then
3803 1.1 christos if test : = "$opt_help"; then
3804 1.1 christos func_mode_help
3805 1.1 christos else
3806 1.1 christos {
3807 1.1 christos func_help noexit
3808 1.1 christos for opt_mode in compile link execute install finish uninstall clean; do
3809 1.1 christos func_mode_help
3810 1.1 christos done
3811 1.1 christos } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
3812 1.1 christos {
3813 1.1 christos func_help noexit
3814 1.1 christos for opt_mode in compile link execute install finish uninstall clean; do
3815 1.1 christos echo
3816 1.1 christos func_mode_help
3817 1.1 christos done
3818 1.1 christos } |
3819 1.1 christos $SED '1d
3820 1.1 christos /^When reporting/,/^Report/{
3821 1.1 christos H
3822 1.1 christos d
3823 1.1 christos }
3824 1.1 christos $x
3825 1.1 christos /information about other modes/d
3826 1.1 christos /more detailed .*MODE/d
3827 1.1 christos s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828 1.1 christos fi
3829 1.1 christos exit $?
3830 1.1 christos fi
3831 1.1 christos
3832 1.1 christos
3833 1.1 christos # func_mode_execute arg...
3834 1.1 christos func_mode_execute ()
3835 1.1 christos {
3836 1.1 christos $debug_cmd
3837 1.1 christos
3838 1.1 christos # The first argument is the command name.
3839 1.1 christos cmd=$nonopt
3840 1.1 christos test -z "$cmd" && \
3841 1.1 christos func_fatal_help "you must specify a COMMAND"
3842 1.1 christos
3843 1.1 christos # Handle -dlopen flags immediately.
3844 1.1 christos for file in $opt_dlopen; do
3845 1.1 christos test -f "$file" \
3846 1.1 christos || func_fatal_help "'$file' is not a file"
3847 1.1 christos
3848 1.1 christos dir=
3849 1.1 christos case $file in
3850 1.1 christos *.la)
3851 1.1 christos func_resolve_sysroot "$file"
3852 1.1 christos file=$func_resolve_sysroot_result
3853 1.1 christos
3854 1.1 christos # Check to see that this really is a libtool archive.
3855 1.1 christos func_lalib_unsafe_p "$file" \
3856 1.1 christos || func_fatal_help "'$lib' is not a valid libtool archive"
3857 1.1 christos
3858 1.1 christos # Read the libtool library.
3859 1.1 christos dlname=
3860 1.1 christos library_names=
3861 1.1 christos func_source "$file"
3862 1.1 christos
3863 1.1 christos # Skip this library if it cannot be dlopened.
3864 1.1 christos if test -z "$dlname"; then
3865 1.1 christos # Warn if it was a shared library.
3866 1.1 christos test -n "$library_names" && \
3867 1.1 christos func_warning "'$file' was not linked with '-export-dynamic'"
3868 1.1 christos continue
3869 1.1 christos fi
3870 1.1 christos
3871 1.1 christos func_dirname "$file" "" "."
3872 1.1 christos dir=$func_dirname_result
3873 1.1 christos
3874 1.1 christos if test -f "$dir/$objdir/$dlname"; then
3875 1.1 christos func_append dir "/$objdir"
3876 1.1 christos else
3877 1.1 christos if test ! -f "$dir/$dlname"; then
3878 1.1 christos func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3879 1.1 christos fi
3880 1.1 christos fi
3881 1.1 christos ;;
3882 1.1 christos
3883 1.1 christos *.lo)
3884 1.1 christos # Just add the directory containing the .lo file.
3885 1.1 christos func_dirname "$file" "" "."
3886 1.1 christos dir=$func_dirname_result
3887 1.1 christos ;;
3888 1.1 christos
3889 1.1 christos *)
3890 1.1 christos func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3891 1.1 christos continue
3892 1.1 christos ;;
3893 1.1 christos esac
3894 1.1 christos
3895 1.1 christos # Get the absolute pathname.
3896 1.1 christos absdir=`cd "$dir" && pwd`
3897 1.1 christos test -n "$absdir" && dir=$absdir
3898 1.1 christos
3899 1.1 christos # Now add the directory to shlibpath_var.
3900 1.1 christos if eval "test -z \"\$$shlibpath_var\""; then
3901 1.1 christos eval "$shlibpath_var=\"\$dir\""
3902 1.1 christos else
3903 1.1 christos eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3904 1.1 christos fi
3905 1.1 christos done
3906 1.1 christos
3907 1.1 christos # This variable tells wrapper scripts just to set shlibpath_var
3908 1.1 christos # rather than running their programs.
3909 1.1 christos libtool_execute_magic=$magic
3910 1.1 christos
3911 1.1 christos # Check if any of the arguments is a wrapper script.
3912 1.1 christos args=
3913 1.1 christos for file
3914 1.1 christos do
3915 1.1 christos case $file in
3916 1.1 christos -* | *.la | *.lo ) ;;
3917 1.1 christos *)
3918 1.1 christos # Do a test to see if this is really a libtool program.
3919 1.1 christos if func_ltwrapper_script_p "$file"; then
3920 1.1 christos func_source "$file"
3921 1.1 christos # Transform arg to wrapped name.
3922 1.1 christos file=$progdir/$program
3923 1.1 christos elif func_ltwrapper_executable_p "$file"; then
3924 1.1 christos func_ltwrapper_scriptname "$file"
3925 1.1 christos func_source "$func_ltwrapper_scriptname_result"
3926 1.1 christos # Transform arg to wrapped name.
3927 1.1 christos file=$progdir/$program
3928 1.1 christos fi
3929 1.1 christos ;;
3930 1.1 christos esac
3931 1.1 christos # Quote arguments (to preserve shell metacharacters).
3932 1.1 christos func_append_quoted args "$file"
3933 1.1 christos done
3934 1.1 christos
3935 1.1 christos if $opt_dry_run; then
3936 1.1 christos # Display what would be done.
3937 1.1 christos if test -n "$shlibpath_var"; then
3938 1.1 christos eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3939 1.1 christos echo "export $shlibpath_var"
3940 1.1 christos fi
3941 1.1 christos $ECHO "$cmd$args"
3942 1.1 christos exit $EXIT_SUCCESS
3943 1.1 christos else
3944 1.1 christos if test -n "$shlibpath_var"; then
3945 1.1 christos # Export the shlibpath_var.
3946 1.1 christos eval "export $shlibpath_var"
3947 1.1 christos fi
3948 1.1 christos
3949 1.1 christos # Restore saved environment variables
3950 1.1 christos for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3951 1.1 christos do
3952 1.1 christos eval "if test \"\${save_$lt_var+set}\" = set; then
3953 1.1 christos $lt_var=\$save_$lt_var; export $lt_var
3954 1.1 christos else
3955 1.1 christos $lt_unset $lt_var
3956 1.1 christos fi"
3957 1.1 christos done
3958 1.1 christos
3959 1.1 christos # Now prepare to actually exec the command.
3960 1.1 christos exec_cmd=\$cmd$args
3961 1.1 christos fi
3962 1.1 christos }
3963 1.1 christos
3964 1.1 christos test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3965 1.1 christos
3966 1.1 christos
3967 1.1 christos # func_mode_finish arg...
3968 1.1 christos func_mode_finish ()
3969 1.1 christos {
3970 1.1 christos $debug_cmd
3971 1.1 christos
3972 1.1 christos libs=
3973 1.1 christos libdirs=
3974 1.1 christos admincmds=
3975 1.1 christos
3976 1.1 christos for opt in "$nonopt" ${1+"$@"}
3977 1.1 christos do
3978 1.1 christos if test -d "$opt"; then
3979 1.1 christos func_append libdirs " $opt"
3980 1.1 christos
3981 1.1 christos elif test -f "$opt"; then
3982 1.1 christos if func_lalib_unsafe_p "$opt"; then
3983 1.1 christos func_append libs " $opt"
3984 1.1 christos else
3985 1.1 christos func_warning "'$opt' is not a valid libtool archive"
3986 1.1 christos fi
3987 1.1 christos
3988 1.1 christos else
3989 1.1 christos func_fatal_error "invalid argument '$opt'"
3990 1.1 christos fi
3991 1.1 christos done
3992 1.1 christos
3993 1.1 christos if test -n "$libs"; then
3994 1.1 christos if test -n "$lt_sysroot"; then
3995 1.1 christos sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996 1.1 christos sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997 1.1 christos else
3998 1.1 christos sysroot_cmd=
3999 1.1 christos fi
4000 1.1 christos
4001 1.1 christos # Remove sysroot references
4002 1.1 christos if $opt_dry_run; then
4003 1.1 christos for lib in $libs; do
4004 1.1 christos echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005 1.1 christos done
4006 1.1 christos else
4007 1.1 christos tmpdir=`func_mktempdir`
4008 1.1 christos for lib in $libs; do
4009 1.1 christos $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010 1.1 christos > $tmpdir/tmp-la
4011 1.1 christos mv -f $tmpdir/tmp-la $lib
4012 1.1 christos done
4013 1.1 christos ${RM}r "$tmpdir"
4014 1.1 christos fi
4015 1.1 christos fi
4016 1.1 christos
4017 1.1 christos if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4018 1.1 christos for libdir in $libdirs; do
4019 1.1 christos if test -n "$finish_cmds"; then
4020 1.1 christos # Do each command in the finish commands.
4021 1.1 christos func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4022 1.1 christos '"$cmd"'"'
4023 1.1 christos fi
4024 1.1 christos if test -n "$finish_eval"; then
4025 1.1 christos # Do the single finish_eval.
4026 1.1 christos eval cmds=\"$finish_eval\"
4027 1.1 christos $opt_dry_run || eval "$cmds" || func_append admincmds "
4028 1.1 christos $cmds"
4029 1.1 christos fi
4030 1.1 christos done
4031 1.1 christos fi
4032 1.1 christos
4033 1.1 christos # Exit here if they wanted silent mode.
4034 1.1 christos $opt_quiet && exit $EXIT_SUCCESS
4035 1.1 christos
4036 1.1 christos if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037 1.1 christos echo "----------------------------------------------------------------------"
4038 1.1 christos echo "Libraries have been installed in:"
4039 1.1 christos for libdir in $libdirs; do
4040 1.1 christos $ECHO " $libdir"
4041 1.1 christos done
4042 1.1 christos echo
4043 1.1 christos echo "If you ever happen to want to link against installed libraries"
4044 1.1 christos echo "in a given directory, LIBDIR, you must either use libtool, and"
4045 1.1 christos echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046 1.1 christos echo "flag during linking and do at least one of the following:"
4047 1.1 christos if test -n "$shlibpath_var"; then
4048 1.1 christos echo " - add LIBDIR to the '$shlibpath_var' environment variable"
4049 1.1 christos echo " during execution"
4050 1.1 christos fi
4051 1.1 christos if test -n "$runpath_var"; then
4052 1.1 christos echo " - add LIBDIR to the '$runpath_var' environment variable"
4053 1.1 christos echo " during linking"
4054 1.1 christos fi
4055 1.1 christos if test -n "$hardcode_libdir_flag_spec"; then
4056 1.1 christos libdir=LIBDIR
4057 1.1 christos eval flag=\"$hardcode_libdir_flag_spec\"
4058 1.1 christos
4059 1.1 christos $ECHO " - use the '$flag' linker flag"
4060 1.1 christos fi
4061 1.1 christos if test -n "$admincmds"; then
4062 1.1 christos $ECHO " - have your system administrator run these commands:$admincmds"
4063 1.1 christos fi
4064 1.1 christos if test -f /etc/ld.so.conf; then
4065 1.1 christos echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066 1.1 christos fi
4067 1.1 christos echo
4068 1.1 christos
4069 1.1 christos echo "See any operating system documentation about shared libraries for"
4070 1.1 christos case $host in
4071 1.1 christos solaris2.[6789]|solaris2.1[0-9])
4072 1.1 christos echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073 1.1 christos echo "pages."
4074 1.1 christos ;;
4075 1.1 christos *)
4076 1.1 christos echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077 1.1 christos ;;
4078 1.1 christos esac
4079 1.1 christos echo "----------------------------------------------------------------------"
4080 1.1 christos fi
4081 1.1 christos exit $EXIT_SUCCESS
4082 1.1 christos }
4083 1.1 christos
4084 1.1 christos test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085 1.1 christos
4086 1.1 christos
4087 1.1 christos # func_mode_install arg...
4088 1.1 christos func_mode_install ()
4089 1.1 christos {
4090 1.1 christos $debug_cmd
4091 1.1 christos
4092 1.1 christos # There may be an optional sh(1) argument at the beginning of
4093 1.1 christos # install_prog (especially on Windows NT).
4094 1.1 christos if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4095 1.1 christos # Allow the use of GNU shtool's install command.
4096 1.1 christos case $nonopt in *shtool*) :;; *) false;; esac
4097 1.1 christos then
4098 1.1 christos # Aesthetically quote it.
4099 1.1 christos func_quote_for_eval "$nonopt"
4100 1.1 christos install_prog="$func_quote_for_eval_result "
4101 1.1 christos arg=$1
4102 1.1 christos shift
4103 1.1 christos else
4104 1.1 christos install_prog=
4105 1.1 christos arg=$nonopt
4106 1.1 christos fi
4107 1.1 christos
4108 1.1 christos # The real first argument should be the name of the installation program.
4109 1.1 christos # Aesthetically quote it.
4110 1.1 christos func_quote_for_eval "$arg"
4111 1.1 christos func_append install_prog "$func_quote_for_eval_result"
4112 1.1 christos install_shared_prog=$install_prog
4113 1.1 christos case " $install_prog " in
4114 1.1 christos *[\\\ /]cp\ *) install_cp=: ;;
4115 1.1 christos *) install_cp=false ;;
4116 1.1 christos esac
4117 1.1 christos
4118 1.1 christos # We need to accept at least all the BSD install flags.
4119 1.1 christos dest=
4120 1.1 christos files=
4121 1.1 christos opts=
4122 1.1 christos prev=
4123 1.1 christos install_type=
4124 1.1 christos isdir=false
4125 1.1 christos stripme=
4126 1.1 christos no_mode=:
4127 1.1 christos for arg
4128 1.1 christos do
4129 1.1 christos arg2=
4130 1.1 christos if test -n "$dest"; then
4131 1.1 christos func_append files " $dest"
4132 1.1 christos dest=$arg
4133 1.1 christos continue
4134 1.1 christos fi
4135 1.1 christos
4136 1.1 christos case $arg in
4137 1.1 christos -d) isdir=: ;;
4138 1.1 christos -f)
4139 1.1 christos if $install_cp; then :; else
4140 1.1 christos prev=$arg
4141 1.1 christos fi
4142 1.1 christos ;;
4143 1.1 christos -g | -m | -o)
4144 1.1 christos prev=$arg
4145 1.1 christos ;;
4146 1.1 christos -s)
4147 1.1 christos stripme=" -s"
4148 1.1 christos continue
4149 1.1 christos ;;
4150 1.1 christos -*)
4151 1.1 christos ;;
4152 1.1 christos *)
4153 1.1 christos # If the previous option needed an argument, then skip it.
4154 1.1 christos if test -n "$prev"; then
4155 1.1 christos if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156 1.1 christos arg2=$install_override_mode
4157 1.1 christos no_mode=false
4158 1.1 christos fi
4159 1.1 christos prev=
4160 1.1 christos else
4161 1.1 christos dest=$arg
4162 1.1 christos continue
4163 1.1 christos fi
4164 1.1 christos ;;
4165 1.1 christos esac
4166 1.1 christos
4167 1.1 christos # Aesthetically quote the argument.
4168 1.1 christos func_quote_for_eval "$arg"
4169 1.1 christos func_append install_prog " $func_quote_for_eval_result"
4170 1.1 christos if test -n "$arg2"; then
4171 1.1 christos func_quote_for_eval "$arg2"
4172 1.1 christos fi
4173 1.1 christos func_append install_shared_prog " $func_quote_for_eval_result"
4174 1.1 christos done
4175 1.1 christos
4176 1.1 christos test -z "$install_prog" && \
4177 1.1 christos func_fatal_help "you must specify an install program"
4178 1.1 christos
4179 1.1 christos test -n "$prev" && \
4180 1.1 christos func_fatal_help "the '$prev' option requires an argument"
4181 1.1 christos
4182 1.1 christos if test -n "$install_override_mode" && $no_mode; then
4183 1.1 christos if $install_cp; then :; else
4184 1.1 christos func_quote_for_eval "$install_override_mode"
4185 1.1 christos func_append install_shared_prog " -m $func_quote_for_eval_result"
4186 1.1 christos fi
4187 1.1 christos fi
4188 1.1 christos
4189 1.1 christos if test -z "$files"; then
4190 1.1 christos if test -z "$dest"; then
4191 1.1 christos func_fatal_help "no file or destination specified"
4192 1.1 christos else
4193 1.1 christos func_fatal_help "you must specify a destination"
4194 1.1 christos fi
4195 1.1 christos fi
4196 1.1 christos
4197 1.1 christos # Strip any trailing slash from the destination.
4198 1.1 christos func_stripname '' '/' "$dest"
4199 1.1 christos dest=$func_stripname_result
4200 1.1 christos
4201 1.1 christos # Check to see that the destination is a directory.
4202 1.1 christos test -d "$dest" && isdir=:
4203 1.1 christos if $isdir; then
4204 1.1 christos destdir=$dest
4205 1.1 christos destname=
4206 1.1 christos else
4207 1.1 christos func_dirname_and_basename "$dest" "" "."
4208 1.1 christos destdir=$func_dirname_result
4209 1.1 christos destname=$func_basename_result
4210 1.1 christos
4211 1.1 christos # Not a directory, so check to see that there is only one file specified.
4212 1.1 christos set dummy $files; shift
4213 1.1 christos test "$#" -gt 1 && \
4214 1.1 christos func_fatal_help "'$dest' is not a directory"
4215 1.1 christos fi
4216 1.1 christos case $destdir in
4217 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) ;;
4218 1.1 christos *)
4219 1.1 christos for file in $files; do
4220 1.1 christos case $file in
4221 1.1 christos *.lo) ;;
4222 1.1 christos *)
4223 1.1 christos func_fatal_help "'$destdir' must be an absolute directory name"
4224 1.1 christos ;;
4225 1.1 christos esac
4226 1.1 christos done
4227 1.1 christos ;;
4228 1.1 christos esac
4229 1.1 christos
4230 1.1 christos # This variable tells wrapper scripts just to set variables rather
4231 1.1 christos # than running their programs.
4232 1.1 christos libtool_install_magic=$magic
4233 1.1 christos
4234 1.1 christos staticlibs=
4235 1.1 christos future_libdirs=
4236 1.1 christos current_libdirs=
4237 1.1 christos for file in $files; do
4238 1.1 christos
4239 1.1 christos # Do each installation.
4240 1.1 christos case $file in
4241 1.1 christos *.$libext)
4242 1.1 christos # Do the static libraries later.
4243 1.1 christos func_append staticlibs " $file"
4244 1.1 christos ;;
4245 1.1 christos
4246 1.1 christos *.la)
4247 1.1 christos func_resolve_sysroot "$file"
4248 1.1 christos file=$func_resolve_sysroot_result
4249 1.1 christos
4250 1.1 christos # Check to see that this really is a libtool archive.
4251 1.1 christos func_lalib_unsafe_p "$file" \
4252 1.1 christos || func_fatal_help "'$file' is not a valid libtool archive"
4253 1.1 christos
4254 1.1 christos library_names=
4255 1.1 christos old_library=
4256 1.1 christos relink_command=
4257 1.1 christos func_source "$file"
4258 1.1 christos
4259 1.1 christos # Add the libdir to current_libdirs if it is the destination.
4260 1.1 christos if test "X$destdir" = "X$libdir"; then
4261 1.1 christos case "$current_libdirs " in
4262 1.1 christos *" $libdir "*) ;;
4263 1.1 christos *) func_append current_libdirs " $libdir" ;;
4264 1.1 christos esac
4265 1.1 christos else
4266 1.1 christos # Note the libdir as a future libdir.
4267 1.1 christos case "$future_libdirs " in
4268 1.1 christos *" $libdir "*) ;;
4269 1.1 christos *) func_append future_libdirs " $libdir" ;;
4270 1.1 christos esac
4271 1.1 christos fi
4272 1.1 christos
4273 1.1 christos func_dirname "$file" "/" ""
4274 1.1 christos dir=$func_dirname_result
4275 1.1 christos func_append dir "$objdir"
4276 1.1 christos
4277 1.1 christos if test -n "$relink_command"; then
4278 1.1 christos # Determine the prefix the user has applied to our future dir.
4279 1.1 christos inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4280 1.1 christos
4281 1.1 christos # Don't allow the user to place us outside of our expected
4282 1.1 christos # location b/c this prevents finding dependent libraries that
4283 1.1 christos # are installed to the same prefix.
4284 1.1 christos # At present, this check doesn't affect windows .dll's that
4285 1.1 christos # are installed into $libdir/../bin (currently, that works fine)
4286 1.1 christos # but it's something to keep an eye on.
4287 1.1 christos test "$inst_prefix_dir" = "$destdir" && \
4288 1.1 christos func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4289 1.1 christos
4290 1.1 christos if test -n "$inst_prefix_dir"; then
4291 1.1 christos # Stick the inst_prefix_dir data into the link command.
4292 1.1 christos relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4293 1.1 christos else
4294 1.1 christos relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4295 1.1 christos fi
4296 1.1 christos
4297 1.1 christos func_warning "relinking '$file'"
4298 1.1 christos func_show_eval "$relink_command" \
4299 1.1 christos 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4300 1.1 christos fi
4301 1.1 christos
4302 1.1 christos # See the names of the shared library.
4303 1.1 christos set dummy $library_names; shift
4304 1.1 christos if test -n "$1"; then
4305 1.1 christos realname=$1
4306 1.1 christos shift
4307 1.1 christos
4308 1.1 christos srcname=$realname
4309 1.1 christos test -n "$relink_command" && srcname=${realname}T
4310 1.1 christos
4311 1.1 christos # Install the shared library and build the symlinks.
4312 1.1 christos func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4313 1.1 christos 'exit $?'
4314 1.1 christos tstripme=$stripme
4315 1.1 christos case $host_os in
4316 1.1 christos cygwin* | mingw* | pw32* | cegcc*)
4317 1.1 christos case $realname in
4318 1.1 christos *.dll.a)
4319 1.1 christos tstripme=
4320 1.1 christos ;;
4321 1.1 christos esac
4322 1.1 christos ;;
4323 1.1 christos os2*)
4324 1.1 christos case $realname in
4325 1.1 christos *_dll.a)
4326 1.1 christos tstripme=
4327 1.1 christos ;;
4328 1.1 christos esac
4329 1.1 christos ;;
4330 1.1 christos esac
4331 1.1 christos if test -n "$tstripme" && test -n "$striplib"; then
4332 1.1 christos func_show_eval "$striplib $destdir/$realname" 'exit $?'
4333 1.1 christos fi
4334 1.1 christos
4335 1.1 christos if test "$#" -gt 0; then
4336 1.1 christos # Delete the old symlinks, and create new ones.
4337 1.1 christos # Try 'ln -sf' first, because the 'ln' binary might depend on
4338 1.1 christos # the symlink we replace! Solaris /bin/ln does not understand -f,
4339 1.1 christos # so we also need to try rm && ln -s.
4340 1.1 christos for linkname
4341 1.1 christos do
4342 1.1 christos test "$linkname" != "$realname" \
4343 1.1 christos && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4344 1.1 christos done
4345 1.1 christos fi
4346 1.1 christos
4347 1.1 christos # Do each command in the postinstall commands.
4348 1.1 christos lib=$destdir/$realname
4349 1.1 christos func_execute_cmds "$postinstall_cmds" 'exit $?'
4350 1.1 christos fi
4351 1.1 christos
4352 1.1 christos # Install the pseudo-library for information purposes.
4353 1.1 christos func_basename "$file"
4354 1.1 christos name=$func_basename_result
4355 1.1 christos instname=$dir/${name}i
4356 1.1 christos func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357 1.1 christos
4358 1.1 christos # Maybe install the static library, too.
4359 1.1 christos test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4360 1.1 christos ;;
4361 1.1 christos
4362 1.1 christos *.lo)
4363 1.1 christos # Install (i.e. copy) a libtool object.
4364 1.1 christos
4365 1.1 christos # Figure out destination file name, if it wasn't already specified.
4366 1.1 christos if test -n "$destname"; then
4367 1.1 christos destfile=$destdir/$destname
4368 1.1 christos else
4369 1.1 christos func_basename "$file"
4370 1.1 christos destfile=$func_basename_result
4371 1.1 christos destfile=$destdir/$destfile
4372 1.1 christos fi
4373 1.1 christos
4374 1.1 christos # Deduce the name of the destination old-style object file.
4375 1.1 christos case $destfile in
4376 1.1 christos *.lo)
4377 1.1 christos func_lo2o "$destfile"
4378 1.1 christos staticdest=$func_lo2o_result
4379 1.1 christos ;;
4380 1.1 christos *.$objext)
4381 1.1 christos staticdest=$destfile
4382 1.1 christos destfile=
4383 1.1 christos ;;
4384 1.1 christos *)
4385 1.1 christos func_fatal_help "cannot copy a libtool object to '$destfile'"
4386 1.1 christos ;;
4387 1.1 christos esac
4388 1.1 christos
4389 1.1 christos # Install the libtool object if requested.
4390 1.1 christos test -n "$destfile" && \
4391 1.1 christos func_show_eval "$install_prog $file $destfile" 'exit $?'
4392 1.1 christos
4393 1.1 christos # Install the old object if enabled.
4394 1.1 christos if test yes = "$build_old_libs"; then
4395 1.1 christos # Deduce the name of the old-style object file.
4396 1.1 christos func_lo2o "$file"
4397 1.1 christos staticobj=$func_lo2o_result
4398 1.1 christos func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399 1.1 christos fi
4400 1.1 christos exit $EXIT_SUCCESS
4401 1.1 christos ;;
4402 1.1 christos
4403 1.1 christos *)
4404 1.1 christos # Figure out destination file name, if it wasn't already specified.
4405 1.1 christos if test -n "$destname"; then
4406 1.1 christos destfile=$destdir/$destname
4407 1.1 christos else
4408 1.1 christos func_basename "$file"
4409 1.1 christos destfile=$func_basename_result
4410 1.1 christos destfile=$destdir/$destfile
4411 1.1 christos fi
4412 1.1 christos
4413 1.1 christos # If the file is missing, and there is a .exe on the end, strip it
4414 1.1 christos # because it is most likely a libtool script we actually want to
4415 1.1 christos # install
4416 1.1 christos stripped_ext=
4417 1.1 christos case $file in
4418 1.1 christos *.exe)
4419 1.1 christos if test ! -f "$file"; then
4420 1.1 christos func_stripname '' '.exe' "$file"
4421 1.1 christos file=$func_stripname_result
4422 1.1 christos stripped_ext=.exe
4423 1.1 christos fi
4424 1.1 christos ;;
4425 1.1 christos esac
4426 1.1 christos
4427 1.1 christos # Do a test to see if this is really a libtool program.
4428 1.1 christos case $host in
4429 1.1 christos *cygwin* | *mingw*)
4430 1.1 christos if func_ltwrapper_executable_p "$file"; then
4431 1.1 christos func_ltwrapper_scriptname "$file"
4432 1.1 christos wrapper=$func_ltwrapper_scriptname_result
4433 1.1 christos else
4434 1.1 christos func_stripname '' '.exe' "$file"
4435 1.1 christos wrapper=$func_stripname_result
4436 1.1 christos fi
4437 1.1 christos ;;
4438 1.1 christos *)
4439 1.1 christos wrapper=$file
4440 1.1 christos ;;
4441 1.1 christos esac
4442 1.1 christos if func_ltwrapper_script_p "$wrapper"; then
4443 1.1 christos notinst_deplibs=
4444 1.1 christos relink_command=
4445 1.1 christos
4446 1.1 christos func_source "$wrapper"
4447 1.1 christos
4448 1.1 christos # Check the variables that should have been set.
4449 1.1 christos test -z "$generated_by_libtool_version" && \
4450 1.1 christos func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451 1.1 christos
4452 1.1 christos finalize=:
4453 1.1 christos for lib in $notinst_deplibs; do
4454 1.1 christos # Check to see that each library is installed.
4455 1.1 christos libdir=
4456 1.1 christos if test -f "$lib"; then
4457 1.1 christos func_source "$lib"
4458 1.1 christos fi
4459 1.1 christos libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4460 1.1 christos if test -n "$libdir" && test ! -f "$libfile"; then
4461 1.1 christos func_warning "'$lib' has not been installed in '$libdir'"
4462 1.1 christos finalize=false
4463 1.1 christos fi
4464 1.1 christos done
4465 1.1 christos
4466 1.1 christos relink_command=
4467 1.1 christos func_source "$wrapper"
4468 1.1 christos
4469 1.1 christos outputname=
4470 1.1 christos if test no = "$fast_install" && test -n "$relink_command"; then
4471 1.1 christos $opt_dry_run || {
4472 1.1 christos if $finalize; then
4473 1.1 christos tmpdir=`func_mktempdir`
4474 1.1 christos func_basename "$file$stripped_ext"
4475 1.1 christos file=$func_basename_result
4476 1.1 christos outputname=$tmpdir/$file
4477 1.1 christos # Replace the output file specification.
4478 1.1 christos relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4479 1.1 christos
4480 1.1 christos $opt_quiet || {
4481 1.1 christos func_quote_for_expand "$relink_command"
4482 1.1 christos eval "func_echo $func_quote_for_expand_result"
4483 1.1 christos }
4484 1.1 christos if eval "$relink_command"; then :
4485 1.1 christos else
4486 1.1 christos func_error "error: relink '$file' with the above command before installing it"
4487 1.1 christos $opt_dry_run || ${RM}r "$tmpdir"
4488 1.1 christos continue
4489 1.1 christos fi
4490 1.1 christos file=$outputname
4491 1.1 christos else
4492 1.1 christos func_warning "cannot relink '$file'"
4493 1.1 christos fi
4494 1.1 christos }
4495 1.1 christos else
4496 1.1 christos # Install the binary that we compiled earlier.
4497 1.1 christos file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4498 1.1 christos fi
4499 1.1 christos fi
4500 1.1 christos
4501 1.1 christos # remove .exe since cygwin /usr/bin/install will append another
4502 1.1 christos # one anyway
4503 1.1 christos case $install_prog,$host in
4504 1.1 christos */usr/bin/install*,*cygwin*)
4505 1.1 christos case $file:$destfile in
4506 1.1 christos *.exe:*.exe)
4507 1.1 christos # this is ok
4508 1.1 christos ;;
4509 1.1 christos *.exe:*)
4510 1.1 christos destfile=$destfile.exe
4511 1.1 christos ;;
4512 1.1 christos *:*.exe)
4513 1.1 christos func_stripname '' '.exe' "$destfile"
4514 1.1 christos destfile=$func_stripname_result
4515 1.1 christos ;;
4516 1.1 christos esac
4517 1.1 christos ;;
4518 1.1 christos esac
4519 1.1 christos func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4520 1.1 christos $opt_dry_run || if test -n "$outputname"; then
4521 1.1 christos ${RM}r "$tmpdir"
4522 1.1 christos fi
4523 1.1 christos ;;
4524 1.1 christos esac
4525 1.1 christos done
4526 1.1 christos
4527 1.1 christos for file in $staticlibs; do
4528 1.1 christos func_basename "$file"
4529 1.1 christos name=$func_basename_result
4530 1.1 christos
4531 1.1 christos # Set up the ranlib parameters.
4532 1.1 christos oldlib=$destdir/$name
4533 1.1 christos func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4534 1.1 christos tool_oldlib=$func_to_tool_file_result
4535 1.1 christos
4536 1.1 christos func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4537 1.1 christos
4538 1.1 christos if test -n "$stripme" && test -n "$old_striplib"; then
4539 1.1 christos func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4540 1.1 christos fi
4541 1.1 christos
4542 1.1 christos # Do each command in the postinstall commands.
4543 1.1 christos func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4544 1.1 christos done
4545 1.1 christos
4546 1.1 christos test -n "$future_libdirs" && \
4547 1.1 christos func_warning "remember to run '$progname --finish$future_libdirs'"
4548 1.1 christos
4549 1.1 christos if test -n "$current_libdirs"; then
4550 1.1 christos # Maybe just do a dry run.
4551 1.1 christos $opt_dry_run && current_libdirs=" -n$current_libdirs"
4552 1.1 christos exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4553 1.1 christos else
4554 1.1 christos exit $EXIT_SUCCESS
4555 1.1 christos fi
4556 1.1 christos }
4557 1.1 christos
4558 1.1 christos test install = "$opt_mode" && func_mode_install ${1+"$@"}
4559 1.1 christos
4560 1.1 christos
4561 1.1 christos # func_generate_dlsyms outputname originator pic_p
4562 1.1 christos # Extract symbols from dlprefiles and create ${outputname}S.o with
4563 1.1 christos # a dlpreopen symbol table.
4564 1.1 christos func_generate_dlsyms ()
4565 1.1 christos {
4566 1.1 christos $debug_cmd
4567 1.1 christos
4568 1.1 christos my_outputname=$1
4569 1.1 christos my_originator=$2
4570 1.1 christos my_pic_p=${3-false}
4571 1.1 christos my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4572 1.1 christos my_dlsyms=
4573 1.1 christos
4574 1.1 christos if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4575 1.1 christos if test -n "$NM" && test -n "$global_symbol_pipe"; then
4576 1.1 christos my_dlsyms=${my_outputname}S.c
4577 1.1 christos else
4578 1.1 christos func_error "not configured to extract global symbols from dlpreopened files"
4579 1.1 christos fi
4580 1.1 christos fi
4581 1.1 christos
4582 1.1 christos if test -n "$my_dlsyms"; then
4583 1.1 christos case $my_dlsyms in
4584 1.1 christos "") ;;
4585 1.1 christos *.c)
4586 1.1 christos # Discover the nlist of each of the dlfiles.
4587 1.1 christos nlist=$output_objdir/$my_outputname.nm
4588 1.1 christos
4589 1.1 christos func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4590 1.1 christos
4591 1.1 christos # Parse the name list into a source file.
4592 1.1 christos func_verbose "creating $output_objdir/$my_dlsyms"
4593 1.1 christos
4594 1.1 christos $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4595 1.1 christos /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4596 1.1 christos /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4597 1.1 christos
4598 1.1 christos #ifdef __cplusplus
4599 1.1 christos extern \"C\" {
4600 1.1 christos #endif
4601 1.1 christos
4602 1.1 christos #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603 1.1 christos #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604 1.1 christos #endif
4605 1.1 christos
4606 1.1 christos /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
4607 1.1 christos #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4608 1.1 christos /* DATA imports from DLLs on WIN32 can't be const, because runtime
4609 1.1 christos relocations are performed -- see ld's documentation on pseudo-relocs. */
4610 1.1 christos # define LT_DLSYM_CONST
4611 1.1 christos #elif defined __osf__
4612 1.1 christos /* This system does not cope well with relocations in const data. */
4613 1.1 christos # define LT_DLSYM_CONST
4614 1.1 christos #else
4615 1.1 christos # define LT_DLSYM_CONST const
4616 1.1 christos #endif
4617 1.1 christos
4618 1.1 christos #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4619 1.1 christos
4620 1.1 christos /* External symbol declarations for the compiler. */\
4621 1.1 christos "
4622 1.1 christos
4623 1.1 christos if test yes = "$dlself"; then
4624 1.1 christos func_verbose "generating symbol list for '$output'"
4625 1.1 christos
4626 1.1 christos $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4627 1.1 christos
4628 1.1 christos # Add our own program objects to the symbol list.
4629 1.1 christos progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4630 1.1 christos for progfile in $progfiles; do
4631 1.1 christos func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4632 1.1 christos func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633 1.1 christos $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4634 1.1 christos done
4635 1.1 christos
4636 1.1 christos if test -n "$exclude_expsyms"; then
4637 1.1 christos $opt_dry_run || {
4638 1.1 christos eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4639 1.1 christos eval '$MV "$nlist"T "$nlist"'
4640 1.1 christos }
4641 1.1 christos fi
4642 1.1 christos
4643 1.1 christos if test -n "$export_symbols_regex"; then
4644 1.1 christos $opt_dry_run || {
4645 1.1 christos eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4646 1.1 christos eval '$MV "$nlist"T "$nlist"'
4647 1.1 christos }
4648 1.1 christos fi
4649 1.1 christos
4650 1.1 christos # Prepare the list of exported symbols
4651 1.1 christos if test -z "$export_symbols"; then
4652 1.1 christos export_symbols=$output_objdir/$outputname.exp
4653 1.1 christos $opt_dry_run || {
4654 1.1 christos $RM $export_symbols
4655 1.1 christos eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4656 1.1 christos case $host in
4657 1.1 christos *cygwin* | *mingw* | *cegcc* )
4658 1.1 christos eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4659 1.1 christos eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4660 1.1 christos ;;
4661 1.1 christos esac
4662 1.1 christos }
4663 1.1 christos else
4664 1.1 christos $opt_dry_run || {
4665 1.1 christos eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4666 1.1 christos eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4667 1.1 christos eval '$MV "$nlist"T "$nlist"'
4668 1.1 christos case $host in
4669 1.1 christos *cygwin* | *mingw* | *cegcc* )
4670 1.1 christos eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4671 1.1 christos eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4672 1.1 christos ;;
4673 1.1 christos esac
4674 1.1 christos }
4675 1.1 christos fi
4676 1.1 christos fi
4677 1.1 christos
4678 1.1 christos for dlprefile in $dlprefiles; do
4679 1.1 christos func_verbose "extracting global C symbols from '$dlprefile'"
4680 1.1 christos func_basename "$dlprefile"
4681 1.1 christos name=$func_basename_result
4682 1.1 christos case $host in
4683 1.1 christos *cygwin* | *mingw* | *cegcc* )
4684 1.1 christos # if an import library, we need to obtain dlname
4685 1.1 christos if func_win32_import_lib_p "$dlprefile"; then
4686 1.1 christos func_tr_sh "$dlprefile"
4687 1.1 christos eval "curr_lafile=\$libfile_$func_tr_sh_result"
4688 1.1 christos dlprefile_dlbasename=
4689 1.1 christos if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690 1.1 christos # Use subshell, to avoid clobbering current variable values
4691 1.1 christos dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4692 1.1 christos if test -n "$dlprefile_dlname"; then
4693 1.1 christos func_basename "$dlprefile_dlname"
4694 1.1 christos dlprefile_dlbasename=$func_basename_result
4695 1.1 christos else
4696 1.1 christos # no lafile. user explicitly requested -dlpreopen <import library>.
4697 1.1 christos $sharedlib_from_linklib_cmd "$dlprefile"
4698 1.1 christos dlprefile_dlbasename=$sharedlib_from_linklib_result
4699 1.1 christos fi
4700 1.1 christos fi
4701 1.1 christos $opt_dry_run || {
4702 1.1 christos if test -n "$dlprefile_dlbasename"; then
4703 1.1 christos eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704 1.1 christos else
4705 1.1 christos func_warning "Could not compute DLL name from $name"
4706 1.1 christos eval '$ECHO ": $name " >> "$nlist"'
4707 1.1 christos fi
4708 1.1 christos func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709 1.1 christos eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710 1.1 christos $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711 1.1 christos }
4712 1.1 christos else # not an import lib
4713 1.1 christos $opt_dry_run || {
4714 1.1 christos eval '$ECHO ": $name " >> "$nlist"'
4715 1.1 christos func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716 1.1 christos eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717 1.1 christos }
4718 1.1 christos fi
4719 1.1 christos ;;
4720 1.1 christos *)
4721 1.1 christos $opt_dry_run || {
4722 1.1 christos eval '$ECHO ": $name " >> "$nlist"'
4723 1.1 christos func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724 1.1 christos eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725 1.1 christos }
4726 1.1 christos ;;
4727 1.1 christos esac
4728 1.1 christos done
4729 1.1 christos
4730 1.1 christos $opt_dry_run || {
4731 1.1 christos # Make sure we have at least an empty file.
4732 1.1 christos test -f "$nlist" || : > "$nlist"
4733 1.1 christos
4734 1.1 christos if test -n "$exclude_expsyms"; then
4735 1.1 christos $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4736 1.1 christos $MV "$nlist"T "$nlist"
4737 1.1 christos fi
4738 1.1 christos
4739 1.1 christos # Try sorting and uniquifying the output.
4740 1.1 christos if $GREP -v "^: " < "$nlist" |
4741 1.1 christos if sort -k 3 </dev/null >/dev/null 2>&1; then
4742 1.1 christos sort -k 3
4743 1.1 christos else
4744 1.1 christos sort +2
4745 1.1 christos fi |
4746 1.1 christos uniq > "$nlist"S; then
4747 1.1 christos :
4748 1.1 christos else
4749 1.1 christos $GREP -v "^: " < "$nlist" > "$nlist"S
4750 1.1 christos fi
4751 1.1 christos
4752 1.1 christos if test -f "$nlist"S; then
4753 1.1 christos eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4754 1.1 christos else
4755 1.1 christos echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4756 1.1 christos fi
4757 1.1 christos
4758 1.1 christos func_show_eval '$RM "${nlist}I"'
4759 1.1 christos if test -n "$global_symbol_to_import"; then
4760 1.1 christos eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4761 1.1 christos fi
4762 1.1 christos
4763 1.1 christos echo >> "$output_objdir/$my_dlsyms" "\
4764 1.1 christos
4765 1.1 christos /* The mapping between symbol names and symbols. */
4766 1.1 christos typedef struct {
4767 1.1 christos const char *name;
4768 1.1 christos void *address;
4769 1.1 christos } lt_dlsymlist;
4770 1.1 christos extern LT_DLSYM_CONST lt_dlsymlist
4771 1.1 christos lt_${my_prefix}_LTX_preloaded_symbols[];\
4772 1.1 christos "
4773 1.1 christos
4774 1.1 christos if test -s "$nlist"I; then
4775 1.1 christos echo >> "$output_objdir/$my_dlsyms" "\
4776 1.1 christos static void lt_syminit(void)
4777 1.1 christos {
4778 1.1 christos LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4779 1.1 christos for (; symbol->name; ++symbol)
4780 1.1 christos {"
4781 1.1 christos $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4782 1.1 christos echo >> "$output_objdir/$my_dlsyms" "\
4783 1.1 christos }
4784 1.1 christos }"
4785 1.1 christos fi
4786 1.1 christos echo >> "$output_objdir/$my_dlsyms" "\
4787 1.1 christos LT_DLSYM_CONST lt_dlsymlist
4788 1.1 christos lt_${my_prefix}_LTX_preloaded_symbols[] =
4789 1.1 christos { {\"$my_originator\", (void *) 0},"
4790 1.1 christos
4791 1.1 christos if test -s "$nlist"I; then
4792 1.1 christos echo >> "$output_objdir/$my_dlsyms" "\
4793 1.1 christos {\"@INIT@\", (void *) <_syminit},"
4794 1.1 christos fi
4795 1.1 christos
4796 1.1 christos case $need_lib_prefix in
4797 1.1 christos no)
4798 1.1 christos eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4799 1.1 christos ;;
4800 1.1 christos *)
4801 1.1 christos eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4802 1.1 christos ;;
4803 1.1 christos esac
4804 1.1 christos echo >> "$output_objdir/$my_dlsyms" "\
4805 1.1 christos {0, (void *) 0}
4806 1.1 christos };
4807 1.1 christos
4808 1.1 christos /* This works around a problem in FreeBSD linker */
4809 1.1 christos #ifdef FREEBSD_WORKAROUND
4810 1.1 christos static const void *lt_preloaded_setup() {
4811 1.1 christos return lt_${my_prefix}_LTX_preloaded_symbols;
4812 1.1 christos }
4813 1.1 christos #endif
4814 1.1 christos
4815 1.1 christos #ifdef __cplusplus
4816 1.1 christos }
4817 1.1 christos #endif\
4818 1.1 christos "
4819 1.1 christos } # !$opt_dry_run
4820 1.1 christos
4821 1.1 christos pic_flag_for_symtable=
4822 1.1 christos case "$compile_command " in
4823 1.1 christos *" -static "*) ;;
4824 1.1 christos *)
4825 1.1 christos case $host in
4826 1.1 christos # compiling the symbol table file with pic_flag works around
4827 1.1 christos # a FreeBSD bug that causes programs to crash when -lm is
4828 1.1 christos # linked before any other PIC object. But we must not use
4829 1.1 christos # pic_flag when linking with -static. The problem exists in
4830 1.1 christos # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4831 1.1 christos *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4832 1.1 christos pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4833 1.1 christos *-*-hpux*)
4834 1.1 christos pic_flag_for_symtable=" $pic_flag" ;;
4835 1.1 christos *)
4836 1.1 christos $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4837 1.1 christos ;;
4838 1.1 christos esac
4839 1.1 christos ;;
4840 1.1 christos esac
4841 1.1 christos symtab_cflags=
4842 1.1 christos for arg in $LTCFLAGS; do
4843 1.1 christos case $arg in
4844 1.1 christos -pie | -fpie | -fPIE) ;;
4845 1.1 christos *) func_append symtab_cflags " $arg" ;;
4846 1.1 christos esac
4847 1.1 christos done
4848 1.1 christos
4849 1.1 christos # Now compile the dynamic symbol file.
4850 1.1 christos func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851 1.1 christos
4852 1.1 christos # Clean up the generated files.
4853 1.1 christos func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4854 1.1 christos
4855 1.1 christos # Transform the symbol file into the correct name.
4856 1.1 christos symfileobj=$output_objdir/${my_outputname}S.$objext
4857 1.1 christos case $host in
4858 1.1 christos *cygwin* | *mingw* | *cegcc* )
4859 1.1 christos if test -f "$output_objdir/$my_outputname.def"; then
4860 1.1 christos compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861 1.1 christos finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4862 1.1 christos else
4863 1.1 christos compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864 1.1 christos finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4865 1.1 christos fi
4866 1.1 christos ;;
4867 1.1 christos *)
4868 1.1 christos compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869 1.1 christos finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4870 1.1 christos ;;
4871 1.1 christos esac
4872 1.1 christos ;;
4873 1.1 christos *)
4874 1.1 christos func_fatal_error "unknown suffix for '$my_dlsyms'"
4875 1.1 christos ;;
4876 1.1 christos esac
4877 1.1 christos else
4878 1.1 christos # We keep going just in case the user didn't refer to
4879 1.1 christos # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
4880 1.1 christos # really was required.
4881 1.1 christos
4882 1.1 christos # Nullify the symbol file.
4883 1.1 christos compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884 1.1 christos finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4885 1.1 christos fi
4886 1.1 christos }
4887 1.1 christos
4888 1.1 christos # func_cygming_gnu_implib_p ARG
4889 1.1 christos # This predicate returns with zero status (TRUE) if
4890 1.1 christos # ARG is a GNU/binutils-style import library. Returns
4891 1.1 christos # with nonzero status (FALSE) otherwise.
4892 1.1 christos func_cygming_gnu_implib_p ()
4893 1.1 christos {
4894 1.1 christos $debug_cmd
4895 1.1 christos
4896 1.1 christos func_to_tool_file "$1" func_convert_file_msys_to_w32
4897 1.1 christos 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 christos test -n "$func_cygming_gnu_implib_tmp"
4899 1.1 christos }
4900 1.1 christos
4901 1.1 christos # func_cygming_ms_implib_p ARG
4902 1.1 christos # This predicate returns with zero status (TRUE) if
4903 1.1 christos # ARG is an MS-style import library. Returns
4904 1.1 christos # with nonzero status (FALSE) otherwise.
4905 1.1 christos func_cygming_ms_implib_p ()
4906 1.1 christos {
4907 1.1 christos $debug_cmd
4908 1.1 christos
4909 1.1 christos func_to_tool_file "$1" func_convert_file_msys_to_w32
4910 1.1 christos func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4911 1.1 christos test -n "$func_cygming_ms_implib_tmp"
4912 1.1 christos }
4913 1.1 christos
4914 1.1 christos # func_win32_libid arg
4915 1.1 christos # return the library type of file 'arg'
4916 1.1 christos #
4917 1.1 christos # Need a lot of goo to handle *both* DLLs and import libs
4918 1.1 christos # Has to be a shell function in order to 'eat' the argument
4919 1.1 christos # that is supplied when $file_magic_command is called.
4920 1.1 christos # Despite the name, also deal with 64 bit binaries.
4921 1.1 christos func_win32_libid ()
4922 1.1 christos {
4923 1.1 christos $debug_cmd
4924 1.1 christos
4925 1.1 christos win32_libid_type=unknown
4926 1.1 christos win32_fileres=`file -L $1 2>/dev/null`
4927 1.1 christos case $win32_fileres in
4928 1.1 christos *ar\ archive\ import\ library*) # definitely import
4929 1.1 christos win32_libid_type="x86 archive import"
4930 1.1 christos ;;
4931 1.1 christos *ar\ archive*) # could be an import, or static
4932 1.1 christos # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4933 1.1 christos if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934 1.1 christos $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4935 1.1 christos case $nm_interface in
4936 1.1 christos "MS dumpbin")
4937 1.1 christos if func_cygming_ms_implib_p "$1" ||
4938 1.1 christos func_cygming_gnu_implib_p "$1"
4939 1.1 christos then
4940 1.1 christos win32_nmres=import
4941 1.1 christos else
4942 1.1 christos win32_nmres=
4943 1.1 christos fi
4944 1.1 christos ;;
4945 1.1 christos *)
4946 1.1 christos func_to_tool_file "$1" func_convert_file_msys_to_w32
4947 1.1 christos win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4948 1.1 christos $SED -n -e '
4949 1.1 christos 1,100{
4950 1.1 christos / I /{
4951 1.1 christos s|.*|import|
4952 1.1 christos p
4953 1.1 christos q
4954 1.1 christos }
4955 1.1 christos }'`
4956 1.1 christos ;;
4957 1.1 christos esac
4958 1.1 christos case $win32_nmres in
4959 1.1 christos import*) win32_libid_type="x86 archive import";;
4960 1.1 christos *) win32_libid_type="x86 archive static";;
4961 1.1 christos esac
4962 1.1 christos fi
4963 1.1 christos ;;
4964 1.1 christos *DLL*)
4965 1.1 christos win32_libid_type="x86 DLL"
4966 1.1 christos ;;
4967 1.1 christos *executable*) # but shell scripts are "executable" too...
4968 1.1 christos case $win32_fileres in
4969 1.1 christos *MS\ Windows\ PE\ Intel*)
4970 1.1 christos win32_libid_type="x86 DLL"
4971 1.1 christos ;;
4972 1.1 christos esac
4973 1.1 christos ;;
4974 1.1 christos esac
4975 1.1 christos $ECHO "$win32_libid_type"
4976 1.1 christos }
4977 1.1 christos
4978 1.1 christos # func_cygming_dll_for_implib ARG
4979 1.1 christos #
4980 1.1 christos # Platform-specific function to extract the
4981 1.1 christos # name of the DLL associated with the specified
4982 1.1 christos # import library ARG.
4983 1.1 christos # Invoked by eval'ing the libtool variable
4984 1.1 christos # $sharedlib_from_linklib_cmd
4985 1.1 christos # Result is available in the variable
4986 1.1 christos # $sharedlib_from_linklib_result
4987 1.1 christos func_cygming_dll_for_implib ()
4988 1.1 christos {
4989 1.1 christos $debug_cmd
4990 1.1 christos
4991 1.1 christos sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992 1.1 christos }
4993 1.1 christos
4994 1.1 christos # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995 1.1 christos #
4996 1.1 christos # The is the core of a fallback implementation of a
4997 1.1 christos # platform-specific function to extract the name of the
4998 1.1 christos # DLL associated with the specified import library LIBNAME.
4999 1.1 christos #
5000 1.1 christos # SECTION_NAME is either .idata$6 or .idata$7, depending
5001 1.1 christos # on the platform and compiler that created the implib.
5002 1.1 christos #
5003 1.1 christos # Echos the name of the DLL associated with the
5004 1.1 christos # specified import library.
5005 1.1 christos func_cygming_dll_for_implib_fallback_core ()
5006 1.1 christos {
5007 1.1 christos $debug_cmd
5008 1.1 christos
5009 1.1 christos match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010 1.1 christos $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011 1.1 christos $SED '/^Contents of section '"$match_literal"':/{
5012 1.1 christos # Place marker at beginning of archive member dllname section
5013 1.1 christos s/.*/====MARK====/
5014 1.1 christos p
5015 1.1 christos d
5016 1.1 christos }
5017 1.1 christos # These lines can sometimes be longer than 43 characters, but
5018 1.1 christos # are always uninteresting
5019 1.1 christos /:[ ]*file format pe[i]\{,1\}-/d
5020 1.1 christos /^In archive [^:]*:/d
5021 1.1 christos # Ensure marker is printed
5022 1.1 christos /^====MARK====/p
5023 1.1 christos # Remove all lines with less than 43 characters
5024 1.1 christos /^.\{43\}/!d
5025 1.1 christos # From remaining lines, remove first 43 characters
5026 1.1 christos s/^.\{43\}//' |
5027 1.1 christos $SED -n '
5028 1.1 christos # Join marker and all lines until next marker into a single line
5029 1.1 christos /^====MARK====/ b para
5030 1.1 christos H
5031 1.1 christos $ b para
5032 1.1 christos b
5033 1.1 christos :para
5034 1.1 christos x
5035 1.1 christos s/\n//g
5036 1.1 christos # Remove the marker
5037 1.1 christos s/^====MARK====//
5038 1.1 christos # Remove trailing dots and whitespace
5039 1.1 christos s/[\. \t]*$//
5040 1.1 christos # Print
5041 1.1 christos /./p' |
5042 1.1 christos # we now have a list, one entry per line, of the stringified
5043 1.1 christos # contents of the appropriate section of all members of the
5044 1.1 christos # archive that possess that section. Heuristic: eliminate
5045 1.1 christos # all those that have a first or second character that is
5046 1.1 christos # a '.' (that is, objdump's representation of an unprintable
5047 1.1 christos # character.) This should work for all archives with less than
5048 1.1 christos # 0x302f exports -- but will fail for DLLs whose name actually
5049 1.1 christos # begins with a literal '.' or a single character followed by
5050 1.1 christos # a '.'.
5051 1.1 christos #
5052 1.1 christos # Of those that remain, print the first one.
5053 1.1 christos $SED -e '/^\./d;/^.\./d;q'
5054 1.1 christos }
5055 1.1 christos
5056 1.1 christos # func_cygming_dll_for_implib_fallback ARG
5057 1.1 christos # Platform-specific function to extract the
5058 1.1 christos # name of the DLL associated with the specified
5059 1.1 christos # import library ARG.
5060 1.1 christos #
5061 1.1 christos # This fallback implementation is for use when $DLLTOOL
5062 1.1 christos # does not support the --identify-strict option.
5063 1.1 christos # Invoked by eval'ing the libtool variable
5064 1.1 christos # $sharedlib_from_linklib_cmd
5065 1.1 christos # Result is available in the variable
5066 1.1 christos # $sharedlib_from_linklib_result
5067 1.1 christos func_cygming_dll_for_implib_fallback ()
5068 1.1 christos {
5069 1.1 christos $debug_cmd
5070 1.1 christos
5071 1.1 christos if func_cygming_gnu_implib_p "$1"; then
5072 1.1 christos # binutils import library
5073 1.1 christos sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5074 1.1 christos elif func_cygming_ms_implib_p "$1"; then
5075 1.1 christos # ms-generated import library
5076 1.1 christos sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077 1.1 christos else
5078 1.1 christos # unknown
5079 1.1 christos sharedlib_from_linklib_result=
5080 1.1 christos fi
5081 1.1 christos }
5082 1.1 christos
5083 1.1 christos
5084 1.1 christos # func_extract_an_archive dir oldlib
5085 1.1 christos func_extract_an_archive ()
5086 1.1 christos {
5087 1.1 christos $debug_cmd
5088 1.1 christos
5089 1.1 christos f_ex_an_ar_dir=$1; shift
5090 1.1 christos f_ex_an_ar_oldlib=$1
5091 1.1 christos if test yes = "$lock_old_archive_extraction"; then
5092 1.1 christos lockfile=$f_ex_an_ar_oldlib.lock
5093 1.1 christos until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094 1.1 christos func_echo "Waiting for $lockfile to be removed"
5095 1.1 christos sleep 2
5096 1.1 christos done
5097 1.1 christos fi
5098 1.1 christos func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099 1.1 christos 'stat=$?; rm -f "$lockfile"; exit $stat'
5100 1.1 christos if test yes = "$lock_old_archive_extraction"; then
5101 1.1 christos $opt_dry_run || rm -f "$lockfile"
5102 1.1 christos fi
5103 1.1 christos if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5104 1.1 christos :
5105 1.1 christos else
5106 1.1 christos func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5107 1.1 christos fi
5108 1.1 christos }
5109 1.1 christos
5110 1.1 christos
5111 1.1 christos # func_extract_archives gentop oldlib ...
5112 1.1 christos func_extract_archives ()
5113 1.1 christos {
5114 1.1 christos $debug_cmd
5115 1.1 christos
5116 1.1 christos my_gentop=$1; shift
5117 1.1 christos my_oldlibs=${1+"$@"}
5118 1.1 christos my_oldobjs=
5119 1.1 christos my_xlib=
5120 1.1 christos my_xabs=
5121 1.1 christos my_xdir=
5122 1.1 christos
5123 1.1 christos for my_xlib in $my_oldlibs; do
5124 1.1 christos # Extract the objects.
5125 1.1 christos case $my_xlib in
5126 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5127 1.1 christos *) my_xabs=`pwd`"/$my_xlib" ;;
5128 1.1 christos esac
5129 1.1 christos func_basename "$my_xlib"
5130 1.1 christos my_xlib=$func_basename_result
5131 1.1 christos my_xlib_u=$my_xlib
5132 1.1 christos while :; do
5133 1.1 christos case " $extracted_archives " in
5134 1.1 christos *" $my_xlib_u "*)
5135 1.1 christos func_arith $extracted_serial + 1
5136 1.1 christos extracted_serial=$func_arith_result
5137 1.1 christos my_xlib_u=lt$extracted_serial-$my_xlib ;;
5138 1.1 christos *) break ;;
5139 1.1 christos esac
5140 1.1 christos done
5141 1.1 christos extracted_archives="$extracted_archives $my_xlib_u"
5142 1.1 christos my_xdir=$my_gentop/$my_xlib_u
5143 1.1 christos
5144 1.1 christos func_mkdir_p "$my_xdir"
5145 1.1 christos
5146 1.1 christos case $host in
5147 1.1 christos *-darwin*)
5148 1.1 christos func_verbose "Extracting $my_xabs"
5149 1.1 christos # Do not bother doing anything if just a dry run
5150 1.1 christos $opt_dry_run || {
5151 1.1 christos darwin_orig_dir=`pwd`
5152 1.1 christos cd $my_xdir || exit $?
5153 1.1 christos darwin_archive=$my_xabs
5154 1.1 christos darwin_curdir=`pwd`
5155 1.1 christos func_basename "$darwin_archive"
5156 1.1 christos darwin_base_archive=$func_basename_result
5157 1.1 christos darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5158 1.1 christos if test -n "$darwin_arches"; then
5159 1.1 christos darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5160 1.1 christos darwin_arch=
5161 1.1 christos func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5162 1.1 christos for darwin_arch in $darwin_arches; do
5163 1.1 christos func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5164 1.1 christos $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5165 1.1 christos cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5166 1.1 christos func_extract_an_archive "`pwd`" "$darwin_base_archive"
5167 1.1 christos cd "$darwin_curdir"
5168 1.1 christos $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5169 1.1 christos done # $darwin_arches
5170 1.1 christos ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5171 1.1 christos darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5172 1.1 christos darwin_file=
5173 1.1 christos darwin_files=
5174 1.1 christos for darwin_file in $darwin_filelist; do
5175 1.1 christos darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5176 1.1 christos $LIPO -create -output "$darwin_file" $darwin_files
5177 1.1 christos done # $darwin_filelist
5178 1.1 christos $RM -rf unfat-$$
5179 1.1 christos cd "$darwin_orig_dir"
5180 1.1 christos else
5181 1.1 christos cd $darwin_orig_dir
5182 1.1 christos func_extract_an_archive "$my_xdir" "$my_xabs"
5183 1.1 christos fi # $darwin_arches
5184 1.1 christos } # !$opt_dry_run
5185 1.1 christos ;;
5186 1.1 christos *)
5187 1.1 christos func_extract_an_archive "$my_xdir" "$my_xabs"
5188 1.1 christos ;;
5189 1.1 christos esac
5190 1.1 christos my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5191 1.1 christos done
5192 1.1 christos
5193 1.1 christos func_extract_archives_result=$my_oldobjs
5194 1.1 christos }
5195 1.1 christos
5196 1.1 christos
5197 1.1 christos # func_emit_wrapper [arg=no]
5198 1.1 christos #
5199 1.1 christos # Emit a libtool wrapper script on stdout.
5200 1.1 christos # Don't directly open a file because we may want to
5201 1.1 christos # incorporate the script contents within a cygwin/mingw
5202 1.1 christos # wrapper executable. Must ONLY be called from within
5203 1.1 christos # func_mode_link because it depends on a number of variables
5204 1.1 christos # set therein.
5205 1.1 christos #
5206 1.1 christos # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207 1.1 christos # variable will take. If 'yes', then the emitted script
5208 1.1 christos # will assume that the directory where it is stored is
5209 1.1 christos # the $objdir directory. This is a cygwin/mingw-specific
5210 1.1 christos # behavior.
5211 1.1 christos func_emit_wrapper ()
5212 1.1 christos {
5213 1.1 christos func_emit_wrapper_arg1=${1-no}
5214 1.1 christos
5215 1.1 christos $ECHO "\
5216 1.1 christos #! $SHELL
5217 1.1 christos
5218 1.1 christos # $output - temporary wrapper script for $objdir/$outputname
5219 1.1 christos # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5220 1.1 christos #
5221 1.1 christos # The $output program cannot be directly executed until all the libtool
5222 1.1 christos # libraries that it depends on are installed.
5223 1.1 christos #
5224 1.1 christos # This wrapper script should never be moved out of the build directory.
5225 1.1 christos # If it is, it will not operate correctly.
5226 1.1 christos
5227 1.1 christos # Sed substitution that helps us do robust quoting. It backslashifies
5228 1.1 christos # metacharacters that are still active within double-quoted strings.
5229 1.1 christos sed_quote_subst='$sed_quote_subst'
5230 1.1 christos
5231 1.1 christos # Be Bourne compatible
5232 1.1 christos if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5233 1.1 christos emulate sh
5234 1.1 christos NULLCMD=:
5235 1.1 christos # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5236 1.1 christos # is contrary to our usage. Disable this feature.
5237 1.1 christos alias -g '\${1+\"\$@\"}'='\"\$@\"'
5238 1.1 christos setopt NO_GLOB_SUBST
5239 1.1 christos else
5240 1.1 christos case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5241 1.1 christos fi
5242 1.1 christos BIN_SH=xpg4; export BIN_SH # for Tru64
5243 1.1 christos DUALCASE=1; export DUALCASE # for MKS sh
5244 1.1 christos
5245 1.1 christos # The HP-UX ksh and POSIX shell print the target directory to stdout
5246 1.1 christos # if CDPATH is set.
5247 1.1 christos (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248 1.1 christos
5249 1.1 christos relink_command=\"$relink_command\"
5250 1.1 christos
5251 1.1 christos # This environment variable determines our operation mode.
5252 1.1 christos if test \"\$libtool_install_magic\" = \"$magic\"; then
5253 1.1 christos # install mode needs the following variables:
5254 1.1 christos generated_by_libtool_version='$macro_version'
5255 1.1 christos notinst_deplibs='$notinst_deplibs'
5256 1.1 christos else
5257 1.1 christos # When we are sourced in execute mode, \$file and \$ECHO are already set.
5258 1.1 christos if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259 1.1 christos file=\"\$0\""
5260 1.1 christos
5261 1.1 christos qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262 1.1 christos $ECHO "\
5263 1.1 christos
5264 1.1 christos # A function that is used when there is no print builtin or printf.
5265 1.1 christos func_fallback_echo ()
5266 1.1 christos {
5267 1.1 christos eval 'cat <<_LTECHO_EOF
5268 1.1 christos \$1
5269 1.1 christos _LTECHO_EOF'
5270 1.1 christos }
5271 1.1 christos ECHO=\"$qECHO\"
5272 1.1 christos fi
5273 1.1 christos
5274 1.1 christos # Very basic option parsing. These options are (a) specific to
5275 1.1 christos # the libtool wrapper, (b) are identical between the wrapper
5276 1.1 christos # /script/ and the wrapper /executable/ that is used only on
5277 1.1 christos # windows platforms, and (c) all begin with the string "--lt-"
5278 1.1 christos # (application programs are unlikely to have options that match
5279 1.1 christos # this pattern).
5280 1.1 christos #
5281 1.1 christos # There are only two supported options: --lt-debug and
5282 1.1 christos # --lt-dump-script. There is, deliberately, no --lt-help.
5283 1.1 christos #
5284 1.1 christos # The first argument to this parsing function should be the
5285 1.1 christos # script's $0 value, followed by "$@".
5286 1.1 christos lt_option_debug=
5287 1.1 christos func_parse_lt_options ()
5288 1.1 christos {
5289 1.1 christos lt_script_arg0=\$0
5290 1.1 christos shift
5291 1.1 christos for lt_opt
5292 1.1 christos do
5293 1.1 christos case \"\$lt_opt\" in
5294 1.1 christos --lt-debug) lt_option_debug=1 ;;
5295 1.1 christos --lt-dump-script)
5296 1.1 christos lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297 1.1 christos test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298 1.1 christos lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299 1.1 christos cat \"\$lt_dump_D/\$lt_dump_F\"
5300 1.1 christos exit 0
5301 1.1 christos ;;
5302 1.1 christos --lt-*)
5303 1.1 christos \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304 1.1 christos exit 1
5305 1.1 christos ;;
5306 1.1 christos esac
5307 1.1 christos done
5308 1.1 christos
5309 1.1 christos # Print the debug banner immediately:
5310 1.1 christos if test -n \"\$lt_option_debug\"; then
5311 1.1 christos echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312 1.1 christos fi
5313 1.1 christos }
5314 1.1 christos
5315 1.1 christos # Used when --lt-debug. Prints its arguments to stdout
5316 1.1 christos # (redirection is the responsibility of the caller)
5317 1.1 christos func_lt_dump_args ()
5318 1.1 christos {
5319 1.1 christos lt_dump_args_N=1;
5320 1.1 christos for lt_arg
5321 1.1 christos do
5322 1.1 christos \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323 1.1 christos lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324 1.1 christos done
5325 1.1 christos }
5326 1.1 christos
5327 1.1 christos # Core function for launching the target application
5328 1.1 christos func_exec_program_core ()
5329 1.1 christos {
5330 1.1 christos "
5331 1.1 christos case $host in
5332 1.1 christos # Backslashes separate directories on plain windows
5333 1.1 christos *-*-mingw | *-*-os2* | *-cegcc*)
5334 1.1 christos $ECHO "\
5335 1.1 christos if test -n \"\$lt_option_debug\"; then
5336 1.1 christos \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337 1.1 christos func_lt_dump_args \${1+\"\$@\"} 1>&2
5338 1.1 christos fi
5339 1.1 christos exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340 1.1 christos "
5341 1.1 christos ;;
5342 1.1 christos
5343 1.1 christos *)
5344 1.1 christos $ECHO "\
5345 1.1 christos if test -n \"\$lt_option_debug\"; then
5346 1.1 christos \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347 1.1 christos func_lt_dump_args \${1+\"\$@\"} 1>&2
5348 1.1 christos fi
5349 1.1 christos exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350 1.1 christos "
5351 1.1 christos ;;
5352 1.1 christos esac
5353 1.1 christos $ECHO "\
5354 1.1 christos \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355 1.1 christos exit 1
5356 1.1 christos }
5357 1.1 christos
5358 1.1 christos # A function to encapsulate launching the target application
5359 1.1 christos # Strips options in the --lt-* namespace from \$@ and
5360 1.1 christos # launches target application with the remaining arguments.
5361 1.1 christos func_exec_program ()
5362 1.1 christos {
5363 1.1 christos case \" \$* \" in
5364 1.1 christos *\\ --lt-*)
5365 1.1 christos for lt_wr_arg
5366 1.1 christos do
5367 1.1 christos case \$lt_wr_arg in
5368 1.1 christos --lt-*) ;;
5369 1.1 christos *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5370 1.1 christos esac
5371 1.1 christos shift
5372 1.1 christos done ;;
5373 1.1 christos esac
5374 1.1 christos func_exec_program_core \${1+\"\$@\"}
5375 1.1 christos }
5376 1.1 christos
5377 1.1 christos # Parse options
5378 1.1 christos func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379 1.1 christos
5380 1.1 christos # Find the directory that this script lives in.
5381 1.1 christos thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5382 1.1 christos test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383 1.1 christos
5384 1.1 christos # Follow symbolic links until we get to the real thisdir.
5385 1.1 christos file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5386 1.1 christos while test -n \"\$file\"; do
5387 1.1 christos destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388 1.1 christos
5389 1.1 christos # If there was a directory component, then change thisdir.
5390 1.1 christos if test \"x\$destdir\" != \"x\$file\"; then
5391 1.1 christos case \"\$destdir\" in
5392 1.1 christos [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5393 1.1 christos *) thisdir=\"\$thisdir/\$destdir\" ;;
5394 1.1 christos esac
5395 1.1 christos fi
5396 1.1 christos
5397 1.1 christos file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398 1.1 christos file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5399 1.1 christos done
5400 1.1 christos
5401 1.1 christos # Usually 'no', except on cygwin/mingw when embedded into
5402 1.1 christos # the cwrapper.
5403 1.1 christos WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5404 1.1 christos if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5405 1.1 christos # special case for '.'
5406 1.1 christos if test \"\$thisdir\" = \".\"; then
5407 1.1 christos thisdir=\`pwd\`
5408 1.1 christos fi
5409 1.1 christos # remove .libs from thisdir
5410 1.1 christos case \"\$thisdir\" in
5411 1.1 christos *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5412 1.1 christos $objdir ) thisdir=. ;;
5413 1.1 christos esac
5414 1.1 christos fi
5415 1.1 christos
5416 1.1 christos # Try to get the absolute directory name.
5417 1.1 christos absdir=\`cd \"\$thisdir\" && pwd\`
5418 1.1 christos test -n \"\$absdir\" && thisdir=\"\$absdir\"
5419 1.1 christos "
5420 1.1 christos
5421 1.1 christos if test yes = "$fast_install"; then
5422 1.1 christos $ECHO "\
5423 1.1 christos program=lt-'$outputname'$exeext
5424 1.1 christos progdir=\"\$thisdir/$objdir\"
5425 1.1 christos
5426 1.1 christos if test ! -f \"\$progdir/\$program\" ||
5427 1.1 christos { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5428 1.1 christos test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429 1.1 christos
5430 1.1 christos file=\"\$\$-\$program\"
5431 1.1 christos
5432 1.1 christos if test ! -d \"\$progdir\"; then
5433 1.1 christos $MKDIR \"\$progdir\"
5434 1.1 christos else
5435 1.1 christos $RM \"\$progdir/\$file\"
5436 1.1 christos fi"
5437 1.1 christos
5438 1.1 christos $ECHO "\
5439 1.1 christos
5440 1.1 christos # relink executable if necessary
5441 1.1 christos if test -n \"\$relink_command\"; then
5442 1.1 christos if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5443 1.1 christos else
5444 1.1 christos \$ECHO \"\$relink_command_output\" >&2
5445 1.1 christos $RM \"\$progdir/\$file\"
5446 1.1 christos exit 1
5447 1.1 christos fi
5448 1.1 christos fi
5449 1.1 christos
5450 1.1 christos $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5451 1.1 christos { $RM \"\$progdir/\$program\";
5452 1.1 christos $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5453 1.1 christos $RM \"\$progdir/\$file\"
5454 1.1 christos fi"
5455 1.1 christos else
5456 1.1 christos $ECHO "\
5457 1.1 christos program='$outputname'
5458 1.1 christos progdir=\"\$thisdir/$objdir\"
5459 1.1 christos "
5460 1.1 christos fi
5461 1.1 christos
5462 1.1 christos $ECHO "\
5463 1.1 christos
5464 1.1 christos if test -f \"\$progdir/\$program\"; then"
5465 1.1 christos
5466 1.1 christos # fixup the dll searchpath if we need to.
5467 1.1 christos #
5468 1.1 christos # Fix the DLL searchpath if we need to. Do this before prepending
5469 1.1 christos # to shlibpath, because on Windows, both are PATH and uninstalled
5470 1.1 christos # libraries must come first.
5471 1.1 christos if test -n "$dllsearchpath"; then
5472 1.1 christos $ECHO "\
5473 1.1 christos # Add the dll search path components to the executable PATH
5474 1.1 christos PATH=$dllsearchpath:\$PATH
5475 1.1 christos "
5476 1.1 christos fi
5477 1.1 christos
5478 1.1 christos # Export our shlibpath_var if we have one.
5479 1.1 christos if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5480 1.1 christos $ECHO "\
5481 1.1 christos # Add our own library path to $shlibpath_var
5482 1.1 christos $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483 1.1 christos
5484 1.1 christos # Some systems cannot cope with colon-terminated $shlibpath_var
5485 1.1 christos # The second colon is a workaround for a bug in BeOS R4 sed
5486 1.1 christos $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487 1.1 christos
5488 1.1 christos export $shlibpath_var
5489 1.1 christos "
5490 1.1 christos fi
5491 1.1 christos
5492 1.1 christos $ECHO "\
5493 1.1 christos if test \"\$libtool_execute_magic\" != \"$magic\"; then
5494 1.1 christos # Run the actual program with our arguments.
5495 1.1 christos func_exec_program \${1+\"\$@\"}
5496 1.1 christos fi
5497 1.1 christos else
5498 1.1 christos # The program doesn't exist.
5499 1.1 christos \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5500 1.1 christos \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501 1.1 christos \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5502 1.1 christos exit 1
5503 1.1 christos fi
5504 1.1 christos fi\
5505 1.1 christos "
5506 1.1 christos }
5507 1.1 christos
5508 1.1 christos
5509 1.1 christos # func_emit_cwrapperexe_src
5510 1.1 christos # emit the source code for a wrapper executable on stdout
5511 1.1 christos # Must ONLY be called from within func_mode_link because
5512 1.1 christos # it depends on a number of variable set therein.
5513 1.1 christos func_emit_cwrapperexe_src ()
5514 1.1 christos {
5515 1.1 christos cat <<EOF
5516 1.1 christos
5517 1.1 christos /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5518 1.1 christos Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519 1.1 christos
5520 1.1 christos The $output program cannot be directly executed until all the libtool
5521 1.1 christos libraries that it depends on are installed.
5522 1.1 christos
5523 1.1 christos This wrapper executable should never be moved out of the build directory.
5524 1.1 christos If it is, it will not operate correctly.
5525 1.1 christos */
5526 1.1 christos EOF
5527 1.1 christos cat <<"EOF"
5528 1.1 christos #ifdef _MSC_VER
5529 1.1 christos # define _CRT_SECURE_NO_DEPRECATE 1
5530 1.1 christos #endif
5531 1.1 christos #include <stdio.h>
5532 1.1 christos #include <stdlib.h>
5533 1.1 christos #ifdef _MSC_VER
5534 1.1 christos # include <direct.h>
5535 1.1 christos # include <process.h>
5536 1.1 christos # include <io.h>
5537 1.1 christos #else
5538 1.1 christos # include <unistd.h>
5539 1.1 christos # include <stdint.h>
5540 1.1 christos # ifdef __CYGWIN__
5541 1.1 christos # include <io.h>
5542 1.1 christos # endif
5543 1.1 christos #endif
5544 1.1 christos #include <malloc.h>
5545 1.1 christos #include <stdarg.h>
5546 1.1 christos #include <assert.h>
5547 1.1 christos #include <string.h>
5548 1.1 christos #include <ctype.h>
5549 1.1 christos #include <errno.h>
5550 1.1 christos #include <fcntl.h>
5551 1.1 christos #include <sys/stat.h>
5552 1.1 christos
5553 1.1 christos #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5554 1.1 christos
5555 1.1 christos /* declarations of non-ANSI functions */
5556 1.1 christos #if defined __MINGW32__
5557 1.1 christos # ifdef __STRICT_ANSI__
5558 1.1 christos int _putenv (const char *);
5559 1.1 christos # endif
5560 1.1 christos #elif defined __CYGWIN__
5561 1.1 christos # ifdef __STRICT_ANSI__
5562 1.1 christos char *realpath (const char *, char *);
5563 1.1 christos int putenv (char *);
5564 1.1 christos int setenv (const char *, const char *, int);
5565 1.1 christos # endif
5566 1.1 christos /* #elif defined other_platform || defined ... */
5567 1.1 christos #endif
5568 1.1 christos
5569 1.1 christos /* portability defines, excluding path handling macros */
5570 1.1 christos #if defined _MSC_VER
5571 1.1 christos # define setmode _setmode
5572 1.1 christos # define stat _stat
5573 1.1 christos # define chmod _chmod
5574 1.1 christos # define getcwd _getcwd
5575 1.1 christos # define putenv _putenv
5576 1.1 christos # define S_IXUSR _S_IEXEC
5577 1.1 christos #elif defined __MINGW32__
5578 1.1 christos # define setmode _setmode
5579 1.1 christos # define stat _stat
5580 1.1 christos # define chmod _chmod
5581 1.1 christos # define getcwd _getcwd
5582 1.1 christos # define putenv _putenv
5583 1.1 christos #elif defined __CYGWIN__
5584 1.1 christos # define HAVE_SETENV
5585 1.1 christos # define FOPEN_WB "wb"
5586 1.1 christos /* #elif defined other platforms ... */
5587 1.1 christos #endif
5588 1.1 christos
5589 1.1 christos #if defined PATH_MAX
5590 1.1 christos # define LT_PATHMAX PATH_MAX
5591 1.1 christos #elif defined MAXPATHLEN
5592 1.1 christos # define LT_PATHMAX MAXPATHLEN
5593 1.1 christos #else
5594 1.1 christos # define LT_PATHMAX 1024
5595 1.1 christos #endif
5596 1.1 christos
5597 1.1 christos #ifndef S_IXOTH
5598 1.1 christos # define S_IXOTH 0
5599 1.1 christos #endif
5600 1.1 christos #ifndef S_IXGRP
5601 1.1 christos # define S_IXGRP 0
5602 1.1 christos #endif
5603 1.1 christos
5604 1.1 christos /* path handling portability macros */
5605 1.1 christos #ifndef DIR_SEPARATOR
5606 1.1 christos # define DIR_SEPARATOR '/'
5607 1.1 christos # define PATH_SEPARATOR ':'
5608 1.1 christos #endif
5609 1.1 christos
5610 1.1 christos #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5611 1.1 christos defined __OS2__
5612 1.1 christos # define HAVE_DOS_BASED_FILE_SYSTEM
5613 1.1 christos # define FOPEN_WB "wb"
5614 1.1 christos # ifndef DIR_SEPARATOR_2
5615 1.1 christos # define DIR_SEPARATOR_2 '\\'
5616 1.1 christos # endif
5617 1.1 christos # ifndef PATH_SEPARATOR_2
5618 1.1 christos # define PATH_SEPARATOR_2 ';'
5619 1.1 christos # endif
5620 1.1 christos #endif
5621 1.1 christos
5622 1.1 christos #ifndef DIR_SEPARATOR_2
5623 1.1 christos # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5624 1.1 christos #else /* DIR_SEPARATOR_2 */
5625 1.1 christos # define IS_DIR_SEPARATOR(ch) \
5626 1.1 christos (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5627 1.1 christos #endif /* DIR_SEPARATOR_2 */
5628 1.1 christos
5629 1.1 christos #ifndef PATH_SEPARATOR_2
5630 1.1 christos # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5631 1.1 christos #else /* PATH_SEPARATOR_2 */
5632 1.1 christos # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5633 1.1 christos #endif /* PATH_SEPARATOR_2 */
5634 1.1 christos
5635 1.1 christos #ifndef FOPEN_WB
5636 1.1 christos # define FOPEN_WB "w"
5637 1.1 christos #endif
5638 1.1 christos #ifndef _O_BINARY
5639 1.1 christos # define _O_BINARY 0
5640 1.1 christos #endif
5641 1.1 christos
5642 1.1 christos #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
5643 1.1 christos #define XFREE(stale) do { \
5644 1.1 christos if (stale) { free (stale); stale = 0; } \
5645 1.1 christos } while (0)
5646 1.1 christos
5647 1.1 christos #if defined LT_DEBUGWRAPPER
5648 1.1 christos static int lt_debug = 1;
5649 1.1 christos #else
5650 1.1 christos static int lt_debug = 0;
5651 1.1 christos #endif
5652 1.1 christos
5653 1.1 christos const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654 1.1 christos
5655 1.1 christos void *xmalloc (size_t num);
5656 1.1 christos char *xstrdup (const char *string);
5657 1.1 christos const char *base_name (const char *name);
5658 1.1 christos char *find_executable (const char *wrapper);
5659 1.1 christos char *chase_symlinks (const char *pathspec);
5660 1.1 christos int make_executable (const char *path);
5661 1.1 christos int check_executable (const char *path);
5662 1.1 christos char *strendzap (char *str, const char *pat);
5663 1.1 christos void lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664 1.1 christos void lt_fatal (const char *file, int line, const char *message, ...);
5665 1.1 christos static const char *nonnull (const char *s);
5666 1.1 christos static const char *nonempty (const char *s);
5667 1.1 christos void lt_setenv (const char *name, const char *value);
5668 1.1 christos char *lt_extend_str (const char *orig_value, const char *add, int to_end);
5669 1.1 christos void lt_update_exe_path (const char *name, const char *value);
5670 1.1 christos void lt_update_lib_path (const char *name, const char *value);
5671 1.1 christos char **prepare_spawn (char **argv);
5672 1.1 christos void lt_dump_script (FILE *f);
5673 1.1 christos EOF
5674 1.1 christos
5675 1.1 christos cat <<EOF
5676 1.1 christos #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5677 1.1 christos # define externally_visible volatile
5678 1.1 christos #else
5679 1.1 christos # define externally_visible __attribute__((externally_visible)) volatile
5680 1.1 christos #endif
5681 1.1 christos externally_visible const char * MAGIC_EXE = "$magic_exe";
5682 1.1 christos const char * LIB_PATH_VARNAME = "$shlibpath_var";
5683 1.1 christos EOF
5684 1.1 christos
5685 1.1 christos if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686 1.1 christos func_to_host_path "$temp_rpath"
5687 1.1 christos cat <<EOF
5688 1.1 christos const char * LIB_PATH_VALUE = "$func_to_host_path_result";
5689 1.1 christos EOF
5690 1.1 christos else
5691 1.1 christos cat <<"EOF"
5692 1.1 christos const char * LIB_PATH_VALUE = "";
5693 1.1 christos EOF
5694 1.1 christos fi
5695 1.1 christos
5696 1.1 christos if test -n "$dllsearchpath"; then
5697 1.1 christos func_to_host_path "$dllsearchpath:"
5698 1.1 christos cat <<EOF
5699 1.1 christos const char * EXE_PATH_VARNAME = "PATH";
5700 1.1 christos const char * EXE_PATH_VALUE = "$func_to_host_path_result";
5701 1.1 christos EOF
5702 1.1 christos else
5703 1.1 christos cat <<"EOF"
5704 1.1 christos const char * EXE_PATH_VARNAME = "";
5705 1.1 christos const char * EXE_PATH_VALUE = "";
5706 1.1 christos EOF
5707 1.1 christos fi
5708 1.1 christos
5709 1.1 christos if test yes = "$fast_install"; then
5710 1.1 christos cat <<EOF
5711 1.1 christos const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5712 1.1 christos EOF
5713 1.1 christos else
5714 1.1 christos cat <<EOF
5715 1.1 christos const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5716 1.1 christos EOF
5717 1.1 christos fi
5718 1.1 christos
5719 1.1 christos
5720 1.1 christos cat <<"EOF"
5721 1.1 christos
5722 1.1 christos #define LTWRAPPER_OPTION_PREFIX "--lt-"
5723 1.1 christos
5724 1.1 christos static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5725 1.1 christos static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
5726 1.1 christos static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
5727 1.1 christos
5728 1.1 christos int
5729 1.1 christos main (int argc, char *argv[])
5730 1.1 christos {
5731 1.1 christos char **newargz;
5732 1.1 christos int newargc;
5733 1.1 christos char *tmp_pathspec;
5734 1.1 christos char *actual_cwrapper_path;
5735 1.1 christos char *actual_cwrapper_name;
5736 1.1 christos char *target_name;
5737 1.1 christos char *lt_argv_zero;
5738 1.1 christos int rval = 127;
5739 1.1 christos
5740 1.1 christos int i;
5741 1.1 christos
5742 1.1 christos program_name = (char *) xstrdup (base_name (argv[0]));
5743 1.1 christos newargz = XMALLOC (char *, (size_t) argc + 1);
5744 1.1 christos
5745 1.1 christos /* very simple arg parsing; don't want to rely on getopt
5746 1.1 christos * also, copy all non cwrapper options to newargz, except
5747 1.1 christos * argz[0], which is handled differently
5748 1.1 christos */
5749 1.1 christos newargc=0;
5750 1.1 christos for (i = 1; i < argc; i++)
5751 1.1 christos {
5752 1.1 christos if (STREQ (argv[i], dumpscript_opt))
5753 1.1 christos {
5754 1.1 christos EOF
5755 1.1 christos case $host in
5756 1.1 christos *mingw* | *cygwin* )
5757 1.1 christos # make stdout use "unix" line endings
5758 1.1 christos echo " setmode(1,_O_BINARY);"
5759 1.1 christos ;;
5760 1.1 christos esac
5761 1.1 christos
5762 1.1 christos cat <<"EOF"
5763 1.1 christos lt_dump_script (stdout);
5764 1.1 christos return 0;
5765 1.1 christos }
5766 1.1 christos if (STREQ (argv[i], debug_opt))
5767 1.1 christos {
5768 1.1 christos lt_debug = 1;
5769 1.1 christos continue;
5770 1.1 christos }
5771 1.1 christos if (STREQ (argv[i], ltwrapper_option_prefix))
5772 1.1 christos {
5773 1.1 christos /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774 1.1 christos namespace, but it is not one of the ones we know about and
5775 1.1 christos have already dealt with, above (inluding dump-script), then
5776 1.1 christos report an error. Otherwise, targets might begin to believe
5777 1.1 christos they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778 1.1 christos namespace. The first time any user complains about this, we'll
5779 1.1 christos need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780 1.1 christos or a configure.ac-settable value.
5781 1.1 christos */
5782 1.1 christos lt_fatal (__FILE__, __LINE__,
5783 1.1 christos "unrecognized %s option: '%s'",
5784 1.1 christos ltwrapper_option_prefix, argv[i]);
5785 1.1 christos }
5786 1.1 christos /* otherwise ... */
5787 1.1 christos newargz[++newargc] = xstrdup (argv[i]);
5788 1.1 christos }
5789 1.1 christos newargz[++newargc] = NULL;
5790 1.1 christos
5791 1.1 christos EOF
5792 1.1 christos cat <<EOF
5793 1.1 christos /* The GNU banner must be the first non-error debug message */
5794 1.1 christos lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795 1.1 christos EOF
5796 1.1 christos cat <<"EOF"
5797 1.1 christos lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798 1.1 christos lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799 1.1 christos
5800 1.1 christos tmp_pathspec = find_executable (argv[0]);
5801 1.1 christos if (tmp_pathspec == NULL)
5802 1.1 christos lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803 1.1 christos lt_debugprintf (__FILE__, __LINE__,
5804 1.1 christos "(main) found exe (before symlink chase) at: %s\n",
5805 1.1 christos tmp_pathspec);
5806 1.1 christos
5807 1.1 christos actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808 1.1 christos lt_debugprintf (__FILE__, __LINE__,
5809 1.1 christos "(main) found exe (after symlink chase) at: %s\n",
5810 1.1 christos actual_cwrapper_path);
5811 1.1 christos XFREE (tmp_pathspec);
5812 1.1 christos
5813 1.1 christos actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5814 1.1 christos strendzap (actual_cwrapper_path, actual_cwrapper_name);
5815 1.1 christos
5816 1.1 christos /* wrapper name transforms */
5817 1.1 christos strendzap (actual_cwrapper_name, ".exe");
5818 1.1 christos tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5819 1.1 christos XFREE (actual_cwrapper_name);
5820 1.1 christos actual_cwrapper_name = tmp_pathspec;
5821 1.1 christos tmp_pathspec = 0;
5822 1.1 christos
5823 1.1 christos /* target_name transforms -- use actual target program name; might have lt- prefix */
5824 1.1 christos target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5825 1.1 christos strendzap (target_name, ".exe");
5826 1.1 christos tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5827 1.1 christos XFREE (target_name);
5828 1.1 christos target_name = tmp_pathspec;
5829 1.1 christos tmp_pathspec = 0;
5830 1.1 christos
5831 1.1 christos lt_debugprintf (__FILE__, __LINE__,
5832 1.1 christos "(main) libtool target name: %s\n",
5833 1.1 christos target_name);
5834 1.1 christos EOF
5835 1.1 christos
5836 1.1 christos cat <<EOF
5837 1.1 christos newargz[0] =
5838 1.1 christos XMALLOC (char, (strlen (actual_cwrapper_path) +
5839 1.1 christos strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5840 1.1 christos strcpy (newargz[0], actual_cwrapper_path);
5841 1.1 christos strcat (newargz[0], "$objdir");
5842 1.1 christos strcat (newargz[0], "/");
5843 1.1 christos EOF
5844 1.1 christos
5845 1.1 christos cat <<"EOF"
5846 1.1 christos /* stop here, and copy so we don't have to do this twice */
5847 1.1 christos tmp_pathspec = xstrdup (newargz[0]);
5848 1.1 christos
5849 1.1 christos /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5850 1.1 christos strcat (newargz[0], actual_cwrapper_name);
5851 1.1 christos
5852 1.1 christos /* DO want the lt- prefix here if it exists, so use target_name */
5853 1.1 christos lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5854 1.1 christos XFREE (tmp_pathspec);
5855 1.1 christos tmp_pathspec = NULL;
5856 1.1 christos EOF
5857 1.1 christos
5858 1.1 christos case $host_os in
5859 1.1 christos mingw*)
5860 1.1 christos cat <<"EOF"
5861 1.1 christos {
5862 1.1 christos char* p;
5863 1.1 christos while ((p = strchr (newargz[0], '\\')) != NULL)
5864 1.1 christos {
5865 1.1 christos *p = '/';
5866 1.1 christos }
5867 1.1 christos while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5868 1.1 christos {
5869 1.1 christos *p = '/';
5870 1.1 christos }
5871 1.1 christos }
5872 1.1 christos EOF
5873 1.1 christos ;;
5874 1.1 christos esac
5875 1.1 christos
5876 1.1 christos cat <<"EOF"
5877 1.1 christos XFREE (target_name);
5878 1.1 christos XFREE (actual_cwrapper_path);
5879 1.1 christos XFREE (actual_cwrapper_name);
5880 1.1 christos
5881 1.1 christos lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5882 1.1 christos lt_setenv ("DUALCASE", "1"); /* for MSK sh */
5883 1.1 christos /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
5884 1.1 christos be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885 1.1 christos because on Windows, both *_VARNAMEs are PATH but uninstalled
5886 1.1 christos libraries must come first. */
5887 1.1 christos lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888 1.1 christos lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889 1.1 christos
5890 1.1 christos lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891 1.1 christos nonnull (lt_argv_zero));
5892 1.1 christos for (i = 0; i < newargc; i++)
5893 1.1 christos {
5894 1.1 christos lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895 1.1 christos i, nonnull (newargz[i]));
5896 1.1 christos }
5897 1.1 christos
5898 1.1 christos EOF
5899 1.1 christos
5900 1.1 christos case $host_os in
5901 1.1 christos mingw*)
5902 1.1 christos cat <<"EOF"
5903 1.1 christos /* execv doesn't actually work on mingw as expected on unix */
5904 1.1 christos newargz = prepare_spawn (newargz);
5905 1.1 christos rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5906 1.1 christos if (rval == -1)
5907 1.1 christos {
5908 1.1 christos /* failed to start process */
5909 1.1 christos lt_debugprintf (__FILE__, __LINE__,
5910 1.1 christos "(main) failed to launch target \"%s\": %s\n",
5911 1.1 christos lt_argv_zero, nonnull (strerror (errno)));
5912 1.1 christos return 127;
5913 1.1 christos }
5914 1.1 christos return rval;
5915 1.1 christos EOF
5916 1.1 christos ;;
5917 1.1 christos *)
5918 1.1 christos cat <<"EOF"
5919 1.1 christos execv (lt_argv_zero, newargz);
5920 1.1 christos return rval; /* =127, but avoids unused variable warning */
5921 1.1 christos EOF
5922 1.1 christos ;;
5923 1.1 christos esac
5924 1.1 christos
5925 1.1 christos cat <<"EOF"
5926 1.1 christos }
5927 1.1 christos
5928 1.1 christos void *
5929 1.1 christos xmalloc (size_t num)
5930 1.1 christos {
5931 1.1 christos void *p = (void *) malloc (num);
5932 1.1 christos if (!p)
5933 1.1 christos lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934 1.1 christos
5935 1.1 christos return p;
5936 1.1 christos }
5937 1.1 christos
5938 1.1 christos char *
5939 1.1 christos xstrdup (const char *string)
5940 1.1 christos {
5941 1.1 christos return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5942 1.1 christos string) : NULL;
5943 1.1 christos }
5944 1.1 christos
5945 1.1 christos const char *
5946 1.1 christos base_name (const char *name)
5947 1.1 christos {
5948 1.1 christos const char *base;
5949 1.1 christos
5950 1.1 christos #if defined HAVE_DOS_BASED_FILE_SYSTEM
5951 1.1 christos /* Skip over the disk name in MSDOS pathnames. */
5952 1.1 christos if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5953 1.1 christos name += 2;
5954 1.1 christos #endif
5955 1.1 christos
5956 1.1 christos for (base = name; *name; name++)
5957 1.1 christos if (IS_DIR_SEPARATOR (*name))
5958 1.1 christos base = name + 1;
5959 1.1 christos return base;
5960 1.1 christos }
5961 1.1 christos
5962 1.1 christos int
5963 1.1 christos check_executable (const char *path)
5964 1.1 christos {
5965 1.1 christos struct stat st;
5966 1.1 christos
5967 1.1 christos lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968 1.1 christos nonempty (path));
5969 1.1 christos if ((!path) || (!*path))
5970 1.1 christos return 0;
5971 1.1 christos
5972 1.1 christos if ((stat (path, &st) >= 0)
5973 1.1 christos && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5974 1.1 christos return 1;
5975 1.1 christos else
5976 1.1 christos return 0;
5977 1.1 christos }
5978 1.1 christos
5979 1.1 christos int
5980 1.1 christos make_executable (const char *path)
5981 1.1 christos {
5982 1.1 christos int rval = 0;
5983 1.1 christos struct stat st;
5984 1.1 christos
5985 1.1 christos lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986 1.1 christos nonempty (path));
5987 1.1 christos if ((!path) || (!*path))
5988 1.1 christos return 0;
5989 1.1 christos
5990 1.1 christos if (stat (path, &st) >= 0)
5991 1.1 christos {
5992 1.1 christos rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5993 1.1 christos }
5994 1.1 christos return rval;
5995 1.1 christos }
5996 1.1 christos
5997 1.1 christos /* Searches for the full path of the wrapper. Returns
5998 1.1 christos newly allocated full path name if found, NULL otherwise
5999 1.1 christos Does not chase symlinks, even on platforms that support them.
6000 1.1 christos */
6001 1.1 christos char *
6002 1.1 christos find_executable (const char *wrapper)
6003 1.1 christos {
6004 1.1 christos int has_slash = 0;
6005 1.1 christos const char *p;
6006 1.1 christos const char *p_next;
6007 1.1 christos /* static buffer for getcwd */
6008 1.1 christos char tmp[LT_PATHMAX + 1];
6009 1.1 christos size_t tmp_len;
6010 1.1 christos char *concat_name;
6011 1.1 christos
6012 1.1 christos lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013 1.1 christos nonempty (wrapper));
6014 1.1 christos
6015 1.1 christos if ((wrapper == NULL) || (*wrapper == '\0'))
6016 1.1 christos return NULL;
6017 1.1 christos
6018 1.1 christos /* Absolute path? */
6019 1.1 christos #if defined HAVE_DOS_BASED_FILE_SYSTEM
6020 1.1 christos if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6021 1.1 christos {
6022 1.1 christos concat_name = xstrdup (wrapper);
6023 1.1 christos if (check_executable (concat_name))
6024 1.1 christos return concat_name;
6025 1.1 christos XFREE (concat_name);
6026 1.1 christos }
6027 1.1 christos else
6028 1.1 christos {
6029 1.1 christos #endif
6030 1.1 christos if (IS_DIR_SEPARATOR (wrapper[0]))
6031 1.1 christos {
6032 1.1 christos concat_name = xstrdup (wrapper);
6033 1.1 christos if (check_executable (concat_name))
6034 1.1 christos return concat_name;
6035 1.1 christos XFREE (concat_name);
6036 1.1 christos }
6037 1.1 christos #if defined HAVE_DOS_BASED_FILE_SYSTEM
6038 1.1 christos }
6039 1.1 christos #endif
6040 1.1 christos
6041 1.1 christos for (p = wrapper; *p; p++)
6042 1.1 christos if (*p == '/')
6043 1.1 christos {
6044 1.1 christos has_slash = 1;
6045 1.1 christos break;
6046 1.1 christos }
6047 1.1 christos if (!has_slash)
6048 1.1 christos {
6049 1.1 christos /* no slashes; search PATH */
6050 1.1 christos const char *path = getenv ("PATH");
6051 1.1 christos if (path != NULL)
6052 1.1 christos {
6053 1.1 christos for (p = path; *p; p = p_next)
6054 1.1 christos {
6055 1.1 christos const char *q;
6056 1.1 christos size_t p_len;
6057 1.1 christos for (q = p; *q; q++)
6058 1.1 christos if (IS_PATH_SEPARATOR (*q))
6059 1.1 christos break;
6060 1.1 christos p_len = (size_t) (q - p);
6061 1.1 christos p_next = (*q == '\0' ? q : q + 1);
6062 1.1 christos if (p_len == 0)
6063 1.1 christos {
6064 1.1 christos /* empty path: current directory */
6065 1.1 christos if (getcwd (tmp, LT_PATHMAX) == NULL)
6066 1.1 christos lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067 1.1 christos nonnull (strerror (errno)));
6068 1.1 christos tmp_len = strlen (tmp);
6069 1.1 christos concat_name =
6070 1.1 christos XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6071 1.1 christos memcpy (concat_name, tmp, tmp_len);
6072 1.1 christos concat_name[tmp_len] = '/';
6073 1.1 christos strcpy (concat_name + tmp_len + 1, wrapper);
6074 1.1 christos }
6075 1.1 christos else
6076 1.1 christos {
6077 1.1 christos concat_name =
6078 1.1 christos XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6079 1.1 christos memcpy (concat_name, p, p_len);
6080 1.1 christos concat_name[p_len] = '/';
6081 1.1 christos strcpy (concat_name + p_len + 1, wrapper);
6082 1.1 christos }
6083 1.1 christos if (check_executable (concat_name))
6084 1.1 christos return concat_name;
6085 1.1 christos XFREE (concat_name);
6086 1.1 christos }
6087 1.1 christos }
6088 1.1 christos /* not found in PATH; assume curdir */
6089 1.1 christos }
6090 1.1 christos /* Relative path | not found in path: prepend cwd */
6091 1.1 christos if (getcwd (tmp, LT_PATHMAX) == NULL)
6092 1.1 christos lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093 1.1 christos nonnull (strerror (errno)));
6094 1.1 christos tmp_len = strlen (tmp);
6095 1.1 christos concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6096 1.1 christos memcpy (concat_name, tmp, tmp_len);
6097 1.1 christos concat_name[tmp_len] = '/';
6098 1.1 christos strcpy (concat_name + tmp_len + 1, wrapper);
6099 1.1 christos
6100 1.1 christos if (check_executable (concat_name))
6101 1.1 christos return concat_name;
6102 1.1 christos XFREE (concat_name);
6103 1.1 christos return NULL;
6104 1.1 christos }
6105 1.1 christos
6106 1.1 christos char *
6107 1.1 christos chase_symlinks (const char *pathspec)
6108 1.1 christos {
6109 1.1 christos #ifndef S_ISLNK
6110 1.1 christos return xstrdup (pathspec);
6111 1.1 christos #else
6112 1.1 christos char buf[LT_PATHMAX];
6113 1.1 christos struct stat s;
6114 1.1 christos char *tmp_pathspec = xstrdup (pathspec);
6115 1.1 christos char *p;
6116 1.1 christos int has_symlinks = 0;
6117 1.1 christos while (strlen (tmp_pathspec) && !has_symlinks)
6118 1.1 christos {
6119 1.1 christos lt_debugprintf (__FILE__, __LINE__,
6120 1.1 christos "checking path component for symlinks: %s\n",
6121 1.1 christos tmp_pathspec);
6122 1.1 christos if (lstat (tmp_pathspec, &s) == 0)
6123 1.1 christos {
6124 1.1 christos if (S_ISLNK (s.st_mode) != 0)
6125 1.1 christos {
6126 1.1 christos has_symlinks = 1;
6127 1.1 christos break;
6128 1.1 christos }
6129 1.1 christos
6130 1.1 christos /* search backwards for last DIR_SEPARATOR */
6131 1.1 christos p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6132 1.1 christos while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6133 1.1 christos p--;
6134 1.1 christos if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6135 1.1 christos {
6136 1.1 christos /* no more DIR_SEPARATORS left */
6137 1.1 christos break;
6138 1.1 christos }
6139 1.1 christos *p = '\0';
6140 1.1 christos }
6141 1.1 christos else
6142 1.1 christos {
6143 1.1 christos lt_fatal (__FILE__, __LINE__,
6144 1.1 christos "error accessing file \"%s\": %s",
6145 1.1 christos tmp_pathspec, nonnull (strerror (errno)));
6146 1.1 christos }
6147 1.1 christos }
6148 1.1 christos XFREE (tmp_pathspec);
6149 1.1 christos
6150 1.1 christos if (!has_symlinks)
6151 1.1 christos {
6152 1.1 christos return xstrdup (pathspec);
6153 1.1 christos }
6154 1.1 christos
6155 1.1 christos tmp_pathspec = realpath (pathspec, buf);
6156 1.1 christos if (tmp_pathspec == 0)
6157 1.1 christos {
6158 1.1 christos lt_fatal (__FILE__, __LINE__,
6159 1.1 christos "could not follow symlinks for %s", pathspec);
6160 1.1 christos }
6161 1.1 christos return xstrdup (tmp_pathspec);
6162 1.1 christos #endif
6163 1.1 christos }
6164 1.1 christos
6165 1.1 christos char *
6166 1.1 christos strendzap (char *str, const char *pat)
6167 1.1 christos {
6168 1.1 christos size_t len, patlen;
6169 1.1 christos
6170 1.1 christos assert (str != NULL);
6171 1.1 christos assert (pat != NULL);
6172 1.1 christos
6173 1.1 christos len = strlen (str);
6174 1.1 christos patlen = strlen (pat);
6175 1.1 christos
6176 1.1 christos if (patlen <= len)
6177 1.1 christos {
6178 1.1 christos str += len - patlen;
6179 1.1 christos if (STREQ (str, pat))
6180 1.1 christos *str = '\0';
6181 1.1 christos }
6182 1.1 christos return str;
6183 1.1 christos }
6184 1.1 christos
6185 1.1 christos void
6186 1.1 christos lt_debugprintf (const char *file, int line, const char *fmt, ...)
6187 1.1 christos {
6188 1.1 christos va_list args;
6189 1.1 christos if (lt_debug)
6190 1.1 christos {
6191 1.1 christos (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192 1.1 christos va_start (args, fmt);
6193 1.1 christos (void) vfprintf (stderr, fmt, args);
6194 1.1 christos va_end (args);
6195 1.1 christos }
6196 1.1 christos }
6197 1.1 christos
6198 1.1 christos static void
6199 1.1 christos lt_error_core (int exit_status, const char *file,
6200 1.1 christos int line, const char *mode,
6201 1.1 christos const char *message, va_list ap)
6202 1.1 christos {
6203 1.1 christos fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6204 1.1 christos vfprintf (stderr, message, ap);
6205 1.1 christos fprintf (stderr, ".\n");
6206 1.1 christos
6207 1.1 christos if (exit_status >= 0)
6208 1.1 christos exit (exit_status);
6209 1.1 christos }
6210 1.1 christos
6211 1.1 christos void
6212 1.1 christos lt_fatal (const char *file, int line, const char *message, ...)
6213 1.1 christos {
6214 1.1 christos va_list ap;
6215 1.1 christos va_start (ap, message);
6216 1.1 christos lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6217 1.1 christos va_end (ap);
6218 1.1 christos }
6219 1.1 christos
6220 1.1 christos static const char *
6221 1.1 christos nonnull (const char *s)
6222 1.1 christos {
6223 1.1 christos return s ? s : "(null)";
6224 1.1 christos }
6225 1.1 christos
6226 1.1 christos static const char *
6227 1.1 christos nonempty (const char *s)
6228 1.1 christos {
6229 1.1 christos return (s && !*s) ? "(empty)" : nonnull (s);
6230 1.1 christos }
6231 1.1 christos
6232 1.1 christos void
6233 1.1 christos lt_setenv (const char *name, const char *value)
6234 1.1 christos {
6235 1.1 christos lt_debugprintf (__FILE__, __LINE__,
6236 1.1 christos "(lt_setenv) setting '%s' to '%s'\n",
6237 1.1 christos nonnull (name), nonnull (value));
6238 1.1 christos {
6239 1.1 christos #ifdef HAVE_SETENV
6240 1.1 christos /* always make a copy, for consistency with !HAVE_SETENV */
6241 1.1 christos char *str = xstrdup (value);
6242 1.1 christos setenv (name, str, 1);
6243 1.1 christos #else
6244 1.1 christos size_t len = strlen (name) + 1 + strlen (value) + 1;
6245 1.1 christos char *str = XMALLOC (char, len);
6246 1.1 christos sprintf (str, "%s=%s", name, value);
6247 1.1 christos if (putenv (str) != EXIT_SUCCESS)
6248 1.1 christos {
6249 1.1 christos XFREE (str);
6250 1.1 christos }
6251 1.1 christos #endif
6252 1.1 christos }
6253 1.1 christos }
6254 1.1 christos
6255 1.1 christos char *
6256 1.1 christos lt_extend_str (const char *orig_value, const char *add, int to_end)
6257 1.1 christos {
6258 1.1 christos char *new_value;
6259 1.1 christos if (orig_value && *orig_value)
6260 1.1 christos {
6261 1.1 christos size_t orig_value_len = strlen (orig_value);
6262 1.1 christos size_t add_len = strlen (add);
6263 1.1 christos new_value = XMALLOC (char, add_len + orig_value_len + 1);
6264 1.1 christos if (to_end)
6265 1.1 christos {
6266 1.1 christos strcpy (new_value, orig_value);
6267 1.1 christos strcpy (new_value + orig_value_len, add);
6268 1.1 christos }
6269 1.1 christos else
6270 1.1 christos {
6271 1.1 christos strcpy (new_value, add);
6272 1.1 christos strcpy (new_value + add_len, orig_value);
6273 1.1 christos }
6274 1.1 christos }
6275 1.1 christos else
6276 1.1 christos {
6277 1.1 christos new_value = xstrdup (add);
6278 1.1 christos }
6279 1.1 christos return new_value;
6280 1.1 christos }
6281 1.1 christos
6282 1.1 christos void
6283 1.1 christos lt_update_exe_path (const char *name, const char *value)
6284 1.1 christos {
6285 1.1 christos lt_debugprintf (__FILE__, __LINE__,
6286 1.1 christos "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287 1.1 christos nonnull (name), nonnull (value));
6288 1.1 christos
6289 1.1 christos if (name && *name && value && *value)
6290 1.1 christos {
6291 1.1 christos char *new_value = lt_extend_str (getenv (name), value, 0);
6292 1.1 christos /* some systems can't cope with a ':'-terminated path #' */
6293 1.1 christos size_t len = strlen (new_value);
6294 1.1 christos while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6295 1.1 christos {
6296 1.1 christos new_value[--len] = '\0';
6297 1.1 christos }
6298 1.1 christos lt_setenv (name, new_value);
6299 1.1 christos XFREE (new_value);
6300 1.1 christos }
6301 1.1 christos }
6302 1.1 christos
6303 1.1 christos void
6304 1.1 christos lt_update_lib_path (const char *name, const char *value)
6305 1.1 christos {
6306 1.1 christos lt_debugprintf (__FILE__, __LINE__,
6307 1.1 christos "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308 1.1 christos nonnull (name), nonnull (value));
6309 1.1 christos
6310 1.1 christos if (name && *name && value && *value)
6311 1.1 christos {
6312 1.1 christos char *new_value = lt_extend_str (getenv (name), value, 0);
6313 1.1 christos lt_setenv (name, new_value);
6314 1.1 christos XFREE (new_value);
6315 1.1 christos }
6316 1.1 christos }
6317 1.1 christos
6318 1.1 christos EOF
6319 1.1 christos case $host_os in
6320 1.1 christos mingw*)
6321 1.1 christos cat <<"EOF"
6322 1.1 christos
6323 1.1 christos /* Prepares an argument vector before calling spawn().
6324 1.1 christos Note that spawn() does not by itself call the command interpreter
6325 1.1 christos (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326 1.1 christos ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327 1.1 christos GetVersionEx(&v);
6328 1.1 christos v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329 1.1 christos }) ? "cmd.exe" : "command.com").
6330 1.1 christos Instead it simply concatenates the arguments, separated by ' ', and calls
6331 1.1 christos CreateProcess(). We must quote the arguments since Win32 CreateProcess()
6332 1.1 christos interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333 1.1 christos special way:
6334 1.1 christos - Space and tab are interpreted as delimiters. They are not treated as
6335 1.1 christos delimiters if they are surrounded by double quotes: "...".
6336 1.1 christos - Unescaped double quotes are removed from the input. Their only effect is
6337 1.1 christos that within double quotes, space and tab are treated like normal
6338 1.1 christos characters.
6339 1.1 christos - Backslashes not followed by double quotes are not special.
6340 1.1 christos - But 2*n+1 backslashes followed by a double quote become
6341 1.1 christos n backslashes followed by a double quote (n >= 0):
6342 1.1 christos \" -> "
6343 1.1 christos \\\" -> \"
6344 1.1 christos \\\\\" -> \\"
6345 1.1 christos */
6346 1.1 christos #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 christos #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 christos char **
6349 1.1 christos prepare_spawn (char **argv)
6350 1.1 christos {
6351 1.1 christos size_t argc;
6352 1.1 christos char **new_argv;
6353 1.1 christos size_t i;
6354 1.1 christos
6355 1.1 christos /* Count number of arguments. */
6356 1.1 christos for (argc = 0; argv[argc] != NULL; argc++)
6357 1.1 christos ;
6358 1.1 christos
6359 1.1 christos /* Allocate new argument vector. */
6360 1.1 christos new_argv = XMALLOC (char *, argc + 1);
6361 1.1 christos
6362 1.1 christos /* Put quoted arguments into the new argument vector. */
6363 1.1 christos for (i = 0; i < argc; i++)
6364 1.1 christos {
6365 1.1 christos const char *string = argv[i];
6366 1.1 christos
6367 1.1 christos if (string[0] == '\0')
6368 1.1 christos new_argv[i] = xstrdup ("\"\"");
6369 1.1 christos else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370 1.1 christos {
6371 1.1 christos int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372 1.1 christos size_t length;
6373 1.1 christos unsigned int backslashes;
6374 1.1 christos const char *s;
6375 1.1 christos char *quoted_string;
6376 1.1 christos char *p;
6377 1.1 christos
6378 1.1 christos length = 0;
6379 1.1 christos backslashes = 0;
6380 1.1 christos if (quote_around)
6381 1.1 christos length++;
6382 1.1 christos for (s = string; *s != '\0'; s++)
6383 1.1 christos {
6384 1.1 christos char c = *s;
6385 1.1 christos if (c == '"')
6386 1.1 christos length += backslashes + 1;
6387 1.1 christos length++;
6388 1.1 christos if (c == '\\')
6389 1.1 christos backslashes++;
6390 1.1 christos else
6391 1.1 christos backslashes = 0;
6392 1.1 christos }
6393 1.1 christos if (quote_around)
6394 1.1 christos length += backslashes + 1;
6395 1.1 christos
6396 1.1 christos quoted_string = XMALLOC (char, length + 1);
6397 1.1 christos
6398 1.1 christos p = quoted_string;
6399 1.1 christos backslashes = 0;
6400 1.1 christos if (quote_around)
6401 1.1 christos *p++ = '"';
6402 1.1 christos for (s = string; *s != '\0'; s++)
6403 1.1 christos {
6404 1.1 christos char c = *s;
6405 1.1 christos if (c == '"')
6406 1.1 christos {
6407 1.1 christos unsigned int j;
6408 1.1 christos for (j = backslashes + 1; j > 0; j--)
6409 1.1 christos *p++ = '\\';
6410 1.1 christos }
6411 1.1 christos *p++ = c;
6412 1.1 christos if (c == '\\')
6413 1.1 christos backslashes++;
6414 1.1 christos else
6415 1.1 christos backslashes = 0;
6416 1.1 christos }
6417 1.1 christos if (quote_around)
6418 1.1 christos {
6419 1.1 christos unsigned int j;
6420 1.1 christos for (j = backslashes; j > 0; j--)
6421 1.1 christos *p++ = '\\';
6422 1.1 christos *p++ = '"';
6423 1.1 christos }
6424 1.1 christos *p = '\0';
6425 1.1 christos
6426 1.1 christos new_argv[i] = quoted_string;
6427 1.1 christos }
6428 1.1 christos else
6429 1.1 christos new_argv[i] = (char *) string;
6430 1.1 christos }
6431 1.1 christos new_argv[argc] = NULL;
6432 1.1 christos
6433 1.1 christos return new_argv;
6434 1.1 christos }
6435 1.1 christos EOF
6436 1.1 christos ;;
6437 1.1 christos esac
6438 1.1 christos
6439 1.1 christos cat <<"EOF"
6440 1.1 christos void lt_dump_script (FILE* f)
6441 1.1 christos {
6442 1.1 christos EOF
6443 1.1 christos func_emit_wrapper yes |
6444 1.1 christos $SED -n -e '
6445 1.1 christos s/^\(.\{79\}\)\(..*\)/\1\
6446 1.1 christos \2/
6447 1.1 christos h
6448 1.1 christos s/\([\\"]\)/\\\1/g
6449 1.1 christos s/$/\\n/
6450 1.1 christos s/\([^\n]*\).*/ fputs ("\1", f);/p
6451 1.1 christos g
6452 1.1 christos D'
6453 1.1 christos cat <<"EOF"
6454 1.1 christos }
6455 1.1 christos EOF
6456 1.1 christos }
6457 1.1 christos # end: func_emit_cwrapperexe_src
6458 1.1 christos
6459 1.1 christos # func_win32_import_lib_p ARG
6460 1.1 christos # True if ARG is an import lib, as indicated by $file_magic_cmd
6461 1.1 christos func_win32_import_lib_p ()
6462 1.1 christos {
6463 1.1 christos $debug_cmd
6464 1.1 christos
6465 1.1 christos case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466 1.1 christos *import*) : ;;
6467 1.1 christos *) false ;;
6468 1.1 christos esac
6469 1.1 christos }
6470 1.1 christos
6471 1.1 christos # func_suncc_cstd_abi
6472 1.1 christos # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6473 1.1 christos # Several compiler flags select an ABI that is incompatible with the
6474 1.1 christos # Cstd library. Avoid specifying it if any are in CXXFLAGS.
6475 1.1 christos func_suncc_cstd_abi ()
6476 1.1 christos {
6477 1.1 christos $debug_cmd
6478 1.1 christos
6479 1.1 christos case " $compile_command " in
6480 1.1 christos *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6481 1.1 christos suncc_use_cstd_abi=no
6482 1.1 christos ;;
6483 1.1 christos *)
6484 1.1 christos suncc_use_cstd_abi=yes
6485 1.1 christos ;;
6486 1.1 christos esac
6487 1.1 christos }
6488 1.1 christos
6489 1.1 christos # func_mode_link arg...
6490 1.1 christos func_mode_link ()
6491 1.1 christos {
6492 1.1 christos $debug_cmd
6493 1.1 christos
6494 1.1 christos case $host in
6495 1.1 christos *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6496 1.1 christos # It is impossible to link a dll without this setting, and
6497 1.1 christos # we shouldn't force the makefile maintainer to figure out
6498 1.1 christos # what system we are compiling for in order to pass an extra
6499 1.1 christos # flag for every libtool invocation.
6500 1.1 christos # allow_undefined=no
6501 1.1 christos
6502 1.1 christos # FIXME: Unfortunately, there are problems with the above when trying
6503 1.1 christos # to make a dll that has undefined symbols, in which case not
6504 1.1 christos # even a static library is built. For now, we need to specify
6505 1.1 christos # -no-undefined on the libtool link line when we can be certain
6506 1.1 christos # that all symbols are satisfied, otherwise we get a static library.
6507 1.1 christos allow_undefined=yes
6508 1.1 christos ;;
6509 1.1 christos *)
6510 1.1 christos allow_undefined=yes
6511 1.1 christos ;;
6512 1.1 christos esac
6513 1.1 christos libtool_args=$nonopt
6514 1.1 christos base_compile="$nonopt $@"
6515 1.1 christos compile_command=$nonopt
6516 1.1 christos finalize_command=$nonopt
6517 1.1 christos
6518 1.1 christos compile_rpath=
6519 1.1 christos finalize_rpath=
6520 1.1 christos compile_shlibpath=
6521 1.1 christos finalize_shlibpath=
6522 1.1 christos convenience=
6523 1.1 christos old_convenience=
6524 1.1 christos deplibs=
6525 1.1 christos old_deplibs=
6526 1.1 christos compiler_flags=
6527 1.1 christos linker_flags=
6528 1.1 christos dllsearchpath=
6529 1.1 christos lib_search_path=`pwd`
6530 1.1 christos inst_prefix_dir=
6531 1.1 christos new_inherited_linker_flags=
6532 1.1 christos
6533 1.1 christos avoid_version=no
6534 1.1 christos bindir=
6535 1.1 christos dlfiles=
6536 1.1 christos dlprefiles=
6537 1.1 christos dlself=no
6538 1.1 christos export_dynamic=no
6539 1.1 christos export_symbols=
6540 1.1 christos export_symbols_regex=
6541 1.1 christos generated=
6542 1.1 christos libobjs=
6543 1.1 christos ltlibs=
6544 1.1 christos module=no
6545 1.1 christos no_install=no
6546 1.1 christos objs=
6547 1.1 christos os2dllname=
6548 1.1 christos non_pic_objects=
6549 1.1 christos precious_files_regex=
6550 1.1 christos prefer_static_libs=no
6551 1.1 christos preload=false
6552 1.1 christos prev=
6553 1.1 christos prevarg=
6554 1.1 christos release=
6555 1.1 christos rpath=
6556 1.1 christos xrpath=
6557 1.1 christos perm_rpath=
6558 1.1 christos temp_rpath=
6559 1.1 christos thread_safe=no
6560 1.1 christos vinfo=
6561 1.1 christos vinfo_number=no
6562 1.1 christos weak_libs=
6563 1.1 christos single_module=$wl-single_module
6564 1.1 christos func_infer_tag $base_compile
6565 1.1 christos
6566 1.1 christos # We need to know -static, to get the right output filenames.
6567 1.1 christos for arg
6568 1.1 christos do
6569 1.1 christos case $arg in
6570 1.1 christos -shared)
6571 1.1 christos test yes != "$build_libtool_libs" \
6572 1.1 christos && func_fatal_configuration "cannot build a shared library"
6573 1.1 christos build_old_libs=no
6574 1.1 christos break
6575 1.1 christos ;;
6576 1.1 christos -all-static | -static | -static-libtool-libs)
6577 1.1 christos case $arg in
6578 1.1 christos -all-static)
6579 1.1 christos if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6580 1.1 christos func_warning "complete static linking is impossible in this configuration"
6581 1.1 christos fi
6582 1.1 christos if test -n "$link_static_flag"; then
6583 1.1 christos dlopen_self=$dlopen_self_static
6584 1.1 christos fi
6585 1.1 christos prefer_static_libs=yes
6586 1.1 christos ;;
6587 1.1 christos -static)
6588 1.1 christos if test -z "$pic_flag" && test -n "$link_static_flag"; then
6589 1.1 christos dlopen_self=$dlopen_self_static
6590 1.1 christos fi
6591 1.1 christos prefer_static_libs=built
6592 1.1 christos ;;
6593 1.1 christos -static-libtool-libs)
6594 1.1 christos if test -z "$pic_flag" && test -n "$link_static_flag"; then
6595 1.1 christos dlopen_self=$dlopen_self_static
6596 1.1 christos fi
6597 1.1 christos prefer_static_libs=yes
6598 1.1 christos ;;
6599 1.1 christos esac
6600 1.1 christos build_libtool_libs=no
6601 1.1 christos build_old_libs=yes
6602 1.1 christos break
6603 1.1 christos ;;
6604 1.1 christos esac
6605 1.1 christos done
6606 1.1 christos
6607 1.1 christos # See if our shared archives depend on static archives.
6608 1.1 christos test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609 1.1 christos
6610 1.1 christos # Go through the arguments, transforming them on the way.
6611 1.1 christos while test "$#" -gt 0; do
6612 1.1 christos arg=$1
6613 1.1 christos shift
6614 1.1 christos func_quote_for_eval "$arg"
6615 1.1 christos qarg=$func_quote_for_eval_unquoted_result
6616 1.1 christos func_append libtool_args " $func_quote_for_eval_result"
6617 1.1 christos
6618 1.1 christos # If the previous option needs an argument, assign it.
6619 1.1 christos if test -n "$prev"; then
6620 1.1 christos case $prev in
6621 1.1 christos output)
6622 1.1 christos func_append compile_command " @OUTPUT@"
6623 1.1 christos func_append finalize_command " @OUTPUT@"
6624 1.1 christos ;;
6625 1.1 christos esac
6626 1.1 christos
6627 1.1 christos case $prev in
6628 1.1 christos bindir)
6629 1.1 christos bindir=$arg
6630 1.1 christos prev=
6631 1.1 christos continue
6632 1.1 christos ;;
6633 1.1 christos dlfiles|dlprefiles)
6634 1.1 christos $preload || {
6635 1.1 christos # Add the symbol object into the linking commands.
6636 1.1 christos func_append compile_command " @SYMFILE@"
6637 1.1 christos func_append finalize_command " @SYMFILE@"
6638 1.1 christos preload=:
6639 1.1 christos }
6640 1.1 christos case $arg in
6641 1.1 christos *.la | *.lo) ;; # We handle these cases below.
6642 1.1 christos force)
6643 1.1 christos if test no = "$dlself"; then
6644 1.1 christos dlself=needless
6645 1.1 christos export_dynamic=yes
6646 1.1 christos fi
6647 1.1 christos prev=
6648 1.1 christos continue
6649 1.1 christos ;;
6650 1.1 christos self)
6651 1.1 christos if test dlprefiles = "$prev"; then
6652 1.1 christos dlself=yes
6653 1.1 christos elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6654 1.1 christos dlself=yes
6655 1.1 christos else
6656 1.1 christos dlself=needless
6657 1.1 christos export_dynamic=yes
6658 1.1 christos fi
6659 1.1 christos prev=
6660 1.1 christos continue
6661 1.1 christos ;;
6662 1.1 christos *)
6663 1.1 christos if test dlfiles = "$prev"; then
6664 1.1 christos func_append dlfiles " $arg"
6665 1.1 christos else
6666 1.1 christos func_append dlprefiles " $arg"
6667 1.1 christos fi
6668 1.1 christos prev=
6669 1.1 christos continue
6670 1.1 christos ;;
6671 1.1 christos esac
6672 1.1 christos ;;
6673 1.1 christos expsyms)
6674 1.1 christos export_symbols=$arg
6675 1.1 christos test -f "$arg" \
6676 1.1 christos || func_fatal_error "symbol file '$arg' does not exist"
6677 1.1 christos prev=
6678 1.1 christos continue
6679 1.1 christos ;;
6680 1.1 christos expsyms_regex)
6681 1.1 christos export_symbols_regex=$arg
6682 1.1 christos prev=
6683 1.1 christos continue
6684 1.1 christos ;;
6685 1.1 christos framework)
6686 1.1 christos case $host in
6687 1.1 christos *-*-darwin*)
6688 1.1 christos case "$deplibs " in
6689 1.1 christos *" $qarg.ltframework "*) ;;
6690 1.1 christos *) func_append deplibs " $qarg.ltframework" # this is fixed later
6691 1.1 christos ;;
6692 1.1 christos esac
6693 1.1 christos ;;
6694 1.1 christos esac
6695 1.1 christos prev=
6696 1.1 christos continue
6697 1.1 christos ;;
6698 1.1 christos inst_prefix)
6699 1.1 christos inst_prefix_dir=$arg
6700 1.1 christos prev=
6701 1.1 christos continue
6702 1.1 christos ;;
6703 1.1 christos mllvm)
6704 1.1 christos # Clang does not use LLVM to link, so we can simply discard any
6705 1.1 christos # '-mllvm $arg' options when doing the link step.
6706 1.1 christos prev=
6707 1.1 christos continue
6708 1.1 christos ;;
6709 1.1 christos objectlist)
6710 1.1 christos if test -f "$arg"; then
6711 1.1 christos save_arg=$arg
6712 1.1 christos moreargs=
6713 1.1 christos for fil in `cat "$save_arg"`
6714 1.1 christos do
6715 1.1 christos # func_append moreargs " $fil"
6716 1.1 christos arg=$fil
6717 1.1 christos # A libtool-controlled object.
6718 1.1 christos
6719 1.1 christos # Check to see that this really is a libtool object.
6720 1.1 christos if func_lalib_unsafe_p "$arg"; then
6721 1.1 christos pic_object=
6722 1.1 christos non_pic_object=
6723 1.1 christos
6724 1.1 christos # Read the .lo file
6725 1.1 christos func_source "$arg"
6726 1.1 christos
6727 1.1 christos if test -z "$pic_object" ||
6728 1.1 christos test -z "$non_pic_object" ||
6729 1.1 christos test none = "$pic_object" &&
6730 1.1 christos test none = "$non_pic_object"; then
6731 1.1 christos func_fatal_error "cannot find name of object for '$arg'"
6732 1.1 christos fi
6733 1.1 christos
6734 1.1 christos # Extract subdirectory from the argument.
6735 1.1 christos func_dirname "$arg" "/" ""
6736 1.1 christos xdir=$func_dirname_result
6737 1.1 christos
6738 1.1 christos if test none != "$pic_object"; then
6739 1.1 christos # Prepend the subdirectory the object is found in.
6740 1.1 christos pic_object=$xdir$pic_object
6741 1.1 christos
6742 1.1 christos if test dlfiles = "$prev"; then
6743 1.1 christos if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744 1.1 christos func_append dlfiles " $pic_object"
6745 1.1 christos prev=
6746 1.1 christos continue
6747 1.1 christos else
6748 1.1 christos # If libtool objects are unsupported, then we need to preload.
6749 1.1 christos prev=dlprefiles
6750 1.1 christos fi
6751 1.1 christos fi
6752 1.1 christos
6753 1.1 christos # CHECK ME: I think I busted this. -Ossama
6754 1.1 christos if test dlprefiles = "$prev"; then
6755 1.1 christos # Preload the old-style object.
6756 1.1 christos func_append dlprefiles " $pic_object"
6757 1.1 christos prev=
6758 1.1 christos fi
6759 1.1 christos
6760 1.1 christos # A PIC object.
6761 1.1 christos func_append libobjs " $pic_object"
6762 1.1 christos arg=$pic_object
6763 1.1 christos fi
6764 1.1 christos
6765 1.1 christos # Non-PIC object.
6766 1.1 christos if test none != "$non_pic_object"; then
6767 1.1 christos # Prepend the subdirectory the object is found in.
6768 1.1 christos non_pic_object=$xdir$non_pic_object
6769 1.1 christos
6770 1.1 christos # A standard non-PIC object
6771 1.1 christos func_append non_pic_objects " $non_pic_object"
6772 1.1 christos if test -z "$pic_object" || test none = "$pic_object"; then
6773 1.1 christos arg=$non_pic_object
6774 1.1 christos fi
6775 1.1 christos else
6776 1.1 christos # If the PIC object exists, use it instead.
6777 1.1 christos # $xdir was prepended to $pic_object above.
6778 1.1 christos non_pic_object=$pic_object
6779 1.1 christos func_append non_pic_objects " $non_pic_object"
6780 1.1 christos fi
6781 1.1 christos else
6782 1.1 christos # Only an error if not doing a dry-run.
6783 1.1 christos if $opt_dry_run; then
6784 1.1 christos # Extract subdirectory from the argument.
6785 1.1 christos func_dirname "$arg" "/" ""
6786 1.1 christos xdir=$func_dirname_result
6787 1.1 christos
6788 1.1 christos func_lo2o "$arg"
6789 1.1 christos pic_object=$xdir$objdir/$func_lo2o_result
6790 1.1 christos non_pic_object=$xdir$func_lo2o_result
6791 1.1 christos func_append libobjs " $pic_object"
6792 1.1 christos func_append non_pic_objects " $non_pic_object"
6793 1.1 christos else
6794 1.1 christos func_fatal_error "'$arg' is not a valid libtool object"
6795 1.1 christos fi
6796 1.1 christos fi
6797 1.1 christos done
6798 1.1 christos else
6799 1.1 christos func_fatal_error "link input file '$arg' does not exist"
6800 1.1 christos fi
6801 1.1 christos arg=$save_arg
6802 1.1 christos prev=
6803 1.1 christos continue
6804 1.1 christos ;;
6805 1.1 christos os2dllname)
6806 1.1 christos os2dllname=$arg
6807 1.1 christos prev=
6808 1.1 christos continue
6809 1.1 christos ;;
6810 1.1 christos precious_regex)
6811 1.1 christos precious_files_regex=$arg
6812 1.1 christos prev=
6813 1.1 christos continue
6814 1.1 christos ;;
6815 1.1 christos release)
6816 1.1 christos release=-$arg
6817 1.1 christos prev=
6818 1.1 christos continue
6819 1.1 christos ;;
6820 1.1 christos rpath | xrpath)
6821 1.1 christos # We need an absolute path.
6822 1.1 christos case $arg in
6823 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) ;;
6824 1.1 christos *)
6825 1.1 christos func_fatal_error "only absolute run-paths are allowed"
6826 1.1 christos ;;
6827 1.1 christos esac
6828 1.1 christos if test rpath = "$prev"; then
6829 1.1 christos case "$rpath " in
6830 1.1 christos *" $arg "*) ;;
6831 1.1 christos *) func_append rpath " $arg" ;;
6832 1.1 christos esac
6833 1.1 christos else
6834 1.1 christos case "$xrpath " in
6835 1.1 christos *" $arg "*) ;;
6836 1.1 christos *) func_append xrpath " $arg" ;;
6837 1.1 christos esac
6838 1.1 christos fi
6839 1.1 christos prev=
6840 1.1 christos continue
6841 1.1 christos ;;
6842 1.1 christos shrext)
6843 1.1 christos shrext_cmds=$arg
6844 1.1 christos prev=
6845 1.1 christos continue
6846 1.1 christos ;;
6847 1.1 christos weak)
6848 1.1 christos func_append weak_libs " $arg"
6849 1.1 christos prev=
6850 1.1 christos continue
6851 1.1 christos ;;
6852 1.1 christos xcclinker)
6853 1.1 christos func_append linker_flags " $qarg"
6854 1.1 christos func_append compiler_flags " $qarg"
6855 1.1 christos prev=
6856 1.1 christos func_append compile_command " $qarg"
6857 1.1 christos func_append finalize_command " $qarg"
6858 1.1 christos continue
6859 1.1 christos ;;
6860 1.1 christos xcompiler)
6861 1.1 christos func_append compiler_flags " $qarg"
6862 1.1 christos prev=
6863 1.1 christos func_append compile_command " $qarg"
6864 1.1 christos func_append finalize_command " $qarg"
6865 1.1 christos continue
6866 1.1 christos ;;
6867 1.1 christos xlinker)
6868 1.1 christos func_append linker_flags " $qarg"
6869 1.1 christos func_append compiler_flags " $wl$qarg"
6870 1.1 christos prev=
6871 1.1 christos func_append compile_command " $wl$qarg"
6872 1.1 christos func_append finalize_command " $wl$qarg"
6873 1.1 christos continue
6874 1.1 christos ;;
6875 1.1 christos *)
6876 1.1 christos eval "$prev=\"\$arg\""
6877 1.1 christos prev=
6878 1.1 christos continue
6879 1.1 christos ;;
6880 1.1 christos esac
6881 1.1 christos fi # test -n "$prev"
6882 1.1 christos
6883 1.1 christos prevarg=$arg
6884 1.1 christos
6885 1.1 christos case $arg in
6886 1.1 christos -all-static)
6887 1.1 christos if test -n "$link_static_flag"; then
6888 1.1 christos # See comment for -static flag below, for more details.
6889 1.1 christos func_append compile_command " $link_static_flag"
6890 1.1 christos func_append finalize_command " $link_static_flag"
6891 1.1 christos fi
6892 1.1 christos continue
6893 1.1 christos ;;
6894 1.1 christos
6895 1.1 christos -allow-undefined)
6896 1.1 christos # FIXME: remove this flag sometime in the future.
6897 1.1 christos func_fatal_error "'-allow-undefined' must not be used because it is the default"
6898 1.1 christos ;;
6899 1.1 christos
6900 1.1 christos -avoid-version)
6901 1.1 christos avoid_version=yes
6902 1.1 christos continue
6903 1.1 christos ;;
6904 1.1 christos
6905 1.1 christos -bindir)
6906 1.1 christos prev=bindir
6907 1.1 christos continue
6908 1.1 christos ;;
6909 1.1 christos
6910 1.1 christos -dlopen)
6911 1.1 christos prev=dlfiles
6912 1.1 christos continue
6913 1.1 christos ;;
6914 1.1 christos
6915 1.1 christos -dlpreopen)
6916 1.1 christos prev=dlprefiles
6917 1.1 christos continue
6918 1.1 christos ;;
6919 1.1 christos
6920 1.1 christos -export-dynamic)
6921 1.1 christos export_dynamic=yes
6922 1.1 christos continue
6923 1.1 christos ;;
6924 1.1 christos
6925 1.1 christos -export-symbols | -export-symbols-regex)
6926 1.1 christos if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6927 1.1 christos func_fatal_error "more than one -exported-symbols argument is not allowed"
6928 1.1 christos fi
6929 1.1 christos if test X-export-symbols = "X$arg"; then
6930 1.1 christos prev=expsyms
6931 1.1 christos else
6932 1.1 christos prev=expsyms_regex
6933 1.1 christos fi
6934 1.1 christos continue
6935 1.1 christos ;;
6936 1.1 christos
6937 1.1 christos -framework)
6938 1.1 christos prev=framework
6939 1.1 christos continue
6940 1.1 christos ;;
6941 1.1 christos
6942 1.1 christos -inst-prefix-dir)
6943 1.1 christos prev=inst_prefix
6944 1.1 christos continue
6945 1.1 christos ;;
6946 1.1 christos
6947 1.1 christos # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6948 1.1 christos # so, if we see these flags be careful not to treat them like -L
6949 1.1 christos -L[A-Z][A-Z]*:*)
6950 1.1 christos case $with_gcc/$host in
6951 1.1 christos no/*-*-irix* | /*-*-irix*)
6952 1.1 christos func_append compile_command " $arg"
6953 1.1 christos func_append finalize_command " $arg"
6954 1.1 christos ;;
6955 1.1 christos esac
6956 1.1 christos continue
6957 1.1 christos ;;
6958 1.1 christos
6959 1.1 christos -L*)
6960 1.1 christos func_stripname "-L" '' "$arg"
6961 1.1 christos if test -z "$func_stripname_result"; then
6962 1.1 christos if test "$#" -gt 0; then
6963 1.1 christos func_fatal_error "require no space between '-L' and '$1'"
6964 1.1 christos else
6965 1.1 christos func_fatal_error "need path for '-L' option"
6966 1.1 christos fi
6967 1.1 christos fi
6968 1.1 christos func_resolve_sysroot "$func_stripname_result"
6969 1.1 christos dir=$func_resolve_sysroot_result
6970 1.1 christos # We need an absolute path.
6971 1.1 christos case $dir in
6972 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) ;;
6973 1.1 christos *)
6974 1.1 christos absdir=`cd "$dir" && pwd`
6975 1.1 christos test -z "$absdir" && \
6976 1.1 christos func_fatal_error "cannot determine absolute directory name of '$dir'"
6977 1.1 christos dir=$absdir
6978 1.1 christos ;;
6979 1.1 christos esac
6980 1.1 christos case "$deplibs " in
6981 1.1 christos *" -L$dir "* | *" $arg "*)
6982 1.1 christos # Will only happen for absolute or sysroot arguments
6983 1.1 christos ;;
6984 1.1 christos *)
6985 1.1 christos # Preserve sysroot, but never include relative directories
6986 1.1 christos case $dir in
6987 1.1 christos [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988 1.1 christos *) func_append deplibs " -L$dir" ;;
6989 1.1 christos esac
6990 1.1 christos func_append lib_search_path " $dir"
6991 1.1 christos ;;
6992 1.1 christos esac
6993 1.1 christos case $host in
6994 1.1 christos *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995 1.1 christos testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6996 1.1 christos case :$dllsearchpath: in
6997 1.1 christos *":$dir:"*) ;;
6998 1.1 christos ::) dllsearchpath=$dir;;
6999 1.1 christos *) func_append dllsearchpath ":$dir";;
7000 1.1 christos esac
7001 1.1 christos case :$dllsearchpath: in
7002 1.1 christos *":$testbindir:"*) ;;
7003 1.1 christos ::) dllsearchpath=$testbindir;;
7004 1.1 christos *) func_append dllsearchpath ":$testbindir";;
7005 1.1 christos esac
7006 1.1 christos ;;
7007 1.1 christos esac
7008 1.1 christos continue
7009 1.1 christos ;;
7010 1.1 christos
7011 1.1 christos -l*)
7012 1.1 christos if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7013 1.1 christos case $host in
7014 1.1 christos *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7015 1.1 christos # These systems don't actually have a C or math library (as such)
7016 1.1 christos continue
7017 1.1 christos ;;
7018 1.1 christos *-*-os2*)
7019 1.1 christos # These systems don't actually have a C library (as such)
7020 1.1 christos test X-lc = "X$arg" && continue
7021 1.1 christos ;;
7022 1.1 christos *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7023 1.1 christos # Do not include libc due to us having libc/libc_r.
7024 1.1 christos test X-lc = "X$arg" && continue
7025 1.1 christos ;;
7026 1.1 christos *-*-rhapsody* | *-*-darwin1.[012])
7027 1.1 christos # Rhapsody C and math libraries are in the System framework
7028 1.1 christos func_append deplibs " System.ltframework"
7029 1.1 christos continue
7030 1.1 christos ;;
7031 1.1 christos *-*-sco3.2v5* | *-*-sco5v6*)
7032 1.1 christos # Causes problems with __ctype
7033 1.1 christos test X-lc = "X$arg" && continue
7034 1.1 christos ;;
7035 1.1 christos *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7036 1.1 christos # Compiler inserts libc in the correct place for threads to work
7037 1.1 christos test X-lc = "X$arg" && continue
7038 1.1 christos ;;
7039 1.1 christos esac
7040 1.1 christos elif test X-lc_r = "X$arg"; then
7041 1.1 christos case $host in
7042 1.1 christos *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7043 1.1 christos # Do not include libc_r directly, use -pthread flag.
7044 1.1 christos continue
7045 1.1 christos ;;
7046 1.1 christos esac
7047 1.1 christos fi
7048 1.1 christos func_append deplibs " $arg"
7049 1.1 christos continue
7050 1.1 christos ;;
7051 1.1 christos
7052 1.1 christos -mllvm)
7053 1.1 christos prev=mllvm
7054 1.1 christos continue
7055 1.1 christos ;;
7056 1.1 christos
7057 1.1 christos -module)
7058 1.1 christos module=yes
7059 1.1 christos continue
7060 1.1 christos ;;
7061 1.1 christos
7062 1.1 christos # Tru64 UNIX uses -model [arg] to determine the layout of C++
7063 1.1 christos # classes, name mangling, and exception handling.
7064 1.1 christos # Darwin uses the -arch flag to determine output architecture.
7065 1.1 christos -model|-arch|-isysroot|--sysroot)
7066 1.1 christos func_append compiler_flags " $arg"
7067 1.1 christos func_append compile_command " $arg"
7068 1.1 christos func_append finalize_command " $arg"
7069 1.1 christos prev=xcompiler
7070 1.1 christos continue
7071 1.1 christos ;;
7072 1.1 christos
7073 1.1 christos -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7074 1.1 christos |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075 1.1 christos func_append compiler_flags " $arg"
7076 1.1 christos func_append compile_command " $arg"
7077 1.1 christos func_append finalize_command " $arg"
7078 1.1 christos case "$new_inherited_linker_flags " in
7079 1.1 christos *" $arg "*) ;;
7080 1.1 christos * ) func_append new_inherited_linker_flags " $arg" ;;
7081 1.1 christos esac
7082 1.1 christos continue
7083 1.1 christos ;;
7084 1.1 christos
7085 1.1 christos -multi_module)
7086 1.1 christos single_module=$wl-multi_module
7087 1.1 christos continue
7088 1.1 christos ;;
7089 1.1 christos
7090 1.1 christos -no-fast-install)
7091 1.1 christos fast_install=no
7092 1.1 christos continue
7093 1.1 christos ;;
7094 1.1 christos
7095 1.1 christos -no-install)
7096 1.1 christos case $host in
7097 1.1 christos *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7098 1.1 christos # The PATH hackery in wrapper scripts is required on Windows
7099 1.1 christos # and Darwin in order for the loader to find any dlls it needs.
7100 1.1 christos func_warning "'-no-install' is ignored for $host"
7101 1.1 christos func_warning "assuming '-no-fast-install' instead"
7102 1.1 christos fast_install=no
7103 1.1 christos ;;
7104 1.1 christos *) no_install=yes ;;
7105 1.1 christos esac
7106 1.1 christos continue
7107 1.1 christos ;;
7108 1.1 christos
7109 1.1 christos -no-undefined)
7110 1.1 christos allow_undefined=no
7111 1.1 christos continue
7112 1.1 christos ;;
7113 1.1 christos
7114 1.1 christos -objectlist)
7115 1.1 christos prev=objectlist
7116 1.1 christos continue
7117 1.1 christos ;;
7118 1.1 christos
7119 1.1 christos -os2dllname)
7120 1.1 christos prev=os2dllname
7121 1.1 christos continue
7122 1.1 christos ;;
7123 1.1 christos
7124 1.1 christos -o) prev=output ;;
7125 1.1 christos
7126 1.1 christos -precious-files-regex)
7127 1.1 christos prev=precious_regex
7128 1.1 christos continue
7129 1.1 christos ;;
7130 1.1 christos
7131 1.1 christos -release)
7132 1.1 christos prev=release
7133 1.1 christos continue
7134 1.1 christos ;;
7135 1.1 christos
7136 1.1 christos -rpath)
7137 1.1 christos prev=rpath
7138 1.1 christos continue
7139 1.1 christos ;;
7140 1.1 christos
7141 1.1 christos -R)
7142 1.1 christos prev=xrpath
7143 1.1 christos continue
7144 1.1 christos ;;
7145 1.1 christos
7146 1.1 christos -R*)
7147 1.1 christos func_stripname '-R' '' "$arg"
7148 1.1 christos dir=$func_stripname_result
7149 1.1 christos # We need an absolute path.
7150 1.1 christos case $dir in
7151 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) ;;
7152 1.1 christos =*)
7153 1.1 christos func_stripname '=' '' "$dir"
7154 1.1 christos dir=$lt_sysroot$func_stripname_result
7155 1.1 christos ;;
7156 1.1 christos *)
7157 1.1 christos func_fatal_error "only absolute run-paths are allowed"
7158 1.1 christos ;;
7159 1.1 christos esac
7160 1.1 christos case "$xrpath " in
7161 1.1 christos *" $dir "*) ;;
7162 1.1 christos *) func_append xrpath " $dir" ;;
7163 1.1 christos esac
7164 1.1 christos continue
7165 1.1 christos ;;
7166 1.1 christos
7167 1.1 christos -shared)
7168 1.1 christos # The effects of -shared are defined in a previous loop.
7169 1.1 christos continue
7170 1.1 christos ;;
7171 1.1 christos
7172 1.1 christos -shrext)
7173 1.1 christos prev=shrext
7174 1.1 christos continue
7175 1.1 christos ;;
7176 1.1 christos
7177 1.1 christos -static | -static-libtool-libs)
7178 1.1 christos # The effects of -static are defined in a previous loop.
7179 1.1 christos # We used to do the same as -all-static on platforms that
7180 1.1 christos # didn't have a PIC flag, but the assumption that the effects
7181 1.1 christos # would be equivalent was wrong. It would break on at least
7182 1.1 christos # Digital Unix and AIX.
7183 1.1 christos continue
7184 1.1 christos ;;
7185 1.1 christos
7186 1.1 christos -thread-safe)
7187 1.1 christos thread_safe=yes
7188 1.1 christos continue
7189 1.1 christos ;;
7190 1.1 christos
7191 1.1 christos -version-info)
7192 1.1 christos prev=vinfo
7193 1.1 christos continue
7194 1.1 christos ;;
7195 1.1 christos
7196 1.1 christos -version-number)
7197 1.1 christos prev=vinfo
7198 1.1 christos vinfo_number=yes
7199 1.1 christos continue
7200 1.1 christos ;;
7201 1.1 christos
7202 1.1 christos -weak)
7203 1.1 christos prev=weak
7204 1.1 christos continue
7205 1.1 christos ;;
7206 1.1 christos
7207 1.1 christos -Wc,*)
7208 1.1 christos func_stripname '-Wc,' '' "$arg"
7209 1.1 christos args=$func_stripname_result
7210 1.1 christos arg=
7211 1.1 christos save_ifs=$IFS; IFS=,
7212 1.1 christos for flag in $args; do
7213 1.1 christos IFS=$save_ifs
7214 1.1 christos func_quote_for_eval "$flag"
7215 1.1 christos func_append arg " $func_quote_for_eval_result"
7216 1.1 christos func_append compiler_flags " $func_quote_for_eval_result"
7217 1.1 christos done
7218 1.1 christos IFS=$save_ifs
7219 1.1 christos func_stripname ' ' '' "$arg"
7220 1.1 christos arg=$func_stripname_result
7221 1.1 christos ;;
7222 1.1 christos
7223 1.1 christos -Wl,*)
7224 1.1 christos func_stripname '-Wl,' '' "$arg"
7225 1.1 christos args=$func_stripname_result
7226 1.1 christos arg=
7227 1.1 christos save_ifs=$IFS; IFS=,
7228 1.1 christos for flag in $args; do
7229 1.1 christos IFS=$save_ifs
7230 1.1 christos func_quote_for_eval "$flag"
7231 1.1 christos func_append arg " $wl$func_quote_for_eval_result"
7232 1.1 christos func_append compiler_flags " $wl$func_quote_for_eval_result"
7233 1.1 christos func_append linker_flags " $func_quote_for_eval_result"
7234 1.1 christos done
7235 1.1 christos IFS=$save_ifs
7236 1.1 christos func_stripname ' ' '' "$arg"
7237 1.1 christos arg=$func_stripname_result
7238 1.1 christos ;;
7239 1.1 christos
7240 1.1 christos -Xcompiler)
7241 1.1 christos prev=xcompiler
7242 1.1 christos continue
7243 1.1 christos ;;
7244 1.1 christos
7245 1.1 christos -Xlinker)
7246 1.1 christos prev=xlinker
7247 1.1 christos continue
7248 1.1 christos ;;
7249 1.1 christos
7250 1.1 christos -XCClinker)
7251 1.1 christos prev=xcclinker
7252 1.1 christos continue
7253 1.1 christos ;;
7254 1.1 christos
7255 1.1 christos # -msg_* for osf cc
7256 1.1 christos -msg_*)
7257 1.1 christos func_quote_for_eval "$arg"
7258 1.1 christos arg=$func_quote_for_eval_result
7259 1.1 christos ;;
7260 1.1 christos
7261 1.1 christos # Flags to be passed through unchanged, with rationale:
7262 1.1 christos # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
7263 1.1 christos # -r[0-9][0-9]* specify processor for the SGI compiler
7264 1.1 christos # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265 1.1 christos # +DA*, +DD* enable 64-bit mode for the HP compiler
7266 1.1 christos # -q* compiler args for the IBM compiler
7267 1.1 christos # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268 1.1 christos # -F/path path to uninstalled frameworks, gcc on darwin
7269 1.1 christos # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
7270 1.1 christos # -fstack-protector* stack protector flags for GCC
7271 1.1 christos # @file GCC response files
7272 1.1 christos # -tp=* Portland pgcc target processor selection
7273 1.1 christos # --sysroot=* for sysroot support
7274 1.1 christos # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7275 1.1 christos # -stdlib=* select c++ std lib with clang
7276 1.1 christos -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7277 1.1 christos -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7278 1.1 christos -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
7279 1.1 christos func_quote_for_eval "$arg"
7280 1.1 christos arg=$func_quote_for_eval_result
7281 1.1 christos func_append compile_command " $arg"
7282 1.1 christos func_append finalize_command " $arg"
7283 1.1 christos func_append compiler_flags " $arg"
7284 1.1 christos continue
7285 1.1 christos ;;
7286 1.1 christos
7287 1.1 christos -Z*)
7288 1.1 christos if test os2 = "`expr $host : '.*\(os2\)'`"; then
7289 1.1 christos # OS/2 uses -Zxxx to specify OS/2-specific options
7290 1.1 christos compiler_flags="$compiler_flags $arg"
7291 1.1 christos func_append compile_command " $arg"
7292 1.1 christos func_append finalize_command " $arg"
7293 1.1 christos case $arg in
7294 1.1 christos -Zlinker | -Zstack)
7295 1.1 christos prev=xcompiler
7296 1.1 christos ;;
7297 1.1 christos esac
7298 1.1 christos continue
7299 1.1 christos else
7300 1.1 christos # Otherwise treat like 'Some other compiler flag' below
7301 1.1 christos func_quote_for_eval "$arg"
7302 1.1 christos arg=$func_quote_for_eval_result
7303 1.1 christos fi
7304 1.1 christos ;;
7305 1.1 christos
7306 1.1 christos # Some other compiler flag.
7307 1.1 christos -* | +*)
7308 1.1 christos func_quote_for_eval "$arg"
7309 1.1 christos arg=$func_quote_for_eval_result
7310 1.1 christos ;;
7311 1.1 christos
7312 1.1 christos *.$objext)
7313 1.1 christos # A standard object.
7314 1.1 christos func_append objs " $arg"
7315 1.1 christos ;;
7316 1.1 christos
7317 1.1 christos *.lo)
7318 1.1 christos # A libtool-controlled object.
7319 1.1 christos
7320 1.1 christos # Check to see that this really is a libtool object.
7321 1.1 christos if func_lalib_unsafe_p "$arg"; then
7322 1.1 christos pic_object=
7323 1.1 christos non_pic_object=
7324 1.1 christos
7325 1.1 christos # Read the .lo file
7326 1.1 christos func_source "$arg"
7327 1.1 christos
7328 1.1 christos if test -z "$pic_object" ||
7329 1.1 christos test -z "$non_pic_object" ||
7330 1.1 christos test none = "$pic_object" &&
7331 1.1 christos test none = "$non_pic_object"; then
7332 1.1 christos func_fatal_error "cannot find name of object for '$arg'"
7333 1.1 christos fi
7334 1.1 christos
7335 1.1 christos # Extract subdirectory from the argument.
7336 1.1 christos func_dirname "$arg" "/" ""
7337 1.1 christos xdir=$func_dirname_result
7338 1.1 christos
7339 1.1 christos test none = "$pic_object" || {
7340 1.1 christos # Prepend the subdirectory the object is found in.
7341 1.1 christos pic_object=$xdir$pic_object
7342 1.1 christos
7343 1.1 christos if test dlfiles = "$prev"; then
7344 1.1 christos if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7345 1.1 christos func_append dlfiles " $pic_object"
7346 1.1 christos prev=
7347 1.1 christos continue
7348 1.1 christos else
7349 1.1 christos # If libtool objects are unsupported, then we need to preload.
7350 1.1 christos prev=dlprefiles
7351 1.1 christos fi
7352 1.1 christos fi
7353 1.1 christos
7354 1.1 christos # CHECK ME: I think I busted this. -Ossama
7355 1.1 christos if test dlprefiles = "$prev"; then
7356 1.1 christos # Preload the old-style object.
7357 1.1 christos func_append dlprefiles " $pic_object"
7358 1.1 christos prev=
7359 1.1 christos fi
7360 1.1 christos
7361 1.1 christos # A PIC object.
7362 1.1 christos func_append libobjs " $pic_object"
7363 1.1 christos arg=$pic_object
7364 1.1 christos }
7365 1.1 christos
7366 1.1 christos # Non-PIC object.
7367 1.1 christos if test none != "$non_pic_object"; then
7368 1.1 christos # Prepend the subdirectory the object is found in.
7369 1.1 christos non_pic_object=$xdir$non_pic_object
7370 1.1 christos
7371 1.1 christos # A standard non-PIC object
7372 1.1 christos func_append non_pic_objects " $non_pic_object"
7373 1.1 christos if test -z "$pic_object" || test none = "$pic_object"; then
7374 1.1 christos arg=$non_pic_object
7375 1.1 christos fi
7376 1.1 christos else
7377 1.1 christos # If the PIC object exists, use it instead.
7378 1.1 christos # $xdir was prepended to $pic_object above.
7379 1.1 christos non_pic_object=$pic_object
7380 1.1 christos func_append non_pic_objects " $non_pic_object"
7381 1.1 christos fi
7382 1.1 christos else
7383 1.1 christos # Only an error if not doing a dry-run.
7384 1.1 christos if $opt_dry_run; then
7385 1.1 christos # Extract subdirectory from the argument.
7386 1.1 christos func_dirname "$arg" "/" ""
7387 1.1 christos xdir=$func_dirname_result
7388 1.1 christos
7389 1.1 christos func_lo2o "$arg"
7390 1.1 christos pic_object=$xdir$objdir/$func_lo2o_result
7391 1.1 christos non_pic_object=$xdir$func_lo2o_result
7392 1.1 christos func_append libobjs " $pic_object"
7393 1.1 christos func_append non_pic_objects " $non_pic_object"
7394 1.1 christos else
7395 1.1 christos func_fatal_error "'$arg' is not a valid libtool object"
7396 1.1 christos fi
7397 1.1 christos fi
7398 1.1 christos ;;
7399 1.1 christos
7400 1.1 christos *.$libext)
7401 1.1 christos # An archive.
7402 1.1 christos func_append deplibs " $arg"
7403 1.1 christos func_append old_deplibs " $arg"
7404 1.1 christos continue
7405 1.1 christos ;;
7406 1.1 christos
7407 1.1 christos *.la)
7408 1.1 christos # A libtool-controlled library.
7409 1.1 christos
7410 1.1 christos func_resolve_sysroot "$arg"
7411 1.1 christos if test dlfiles = "$prev"; then
7412 1.1 christos # This library was specified with -dlopen.
7413 1.1 christos func_append dlfiles " $func_resolve_sysroot_result"
7414 1.1 christos prev=
7415 1.1 christos elif test dlprefiles = "$prev"; then
7416 1.1 christos # The library was specified with -dlpreopen.
7417 1.1 christos func_append dlprefiles " $func_resolve_sysroot_result"
7418 1.1 christos prev=
7419 1.1 christos else
7420 1.1 christos func_append deplibs " $func_resolve_sysroot_result"
7421 1.1 christos fi
7422 1.1 christos continue
7423 1.1 christos ;;
7424 1.1 christos
7425 1.1 christos # Some other compiler argument.
7426 1.1 christos *)
7427 1.1 christos # Unknown arguments in both finalize_command and compile_command need
7428 1.1 christos # to be aesthetically quoted because they are evaled later.
7429 1.1 christos func_quote_for_eval "$arg"
7430 1.1 christos arg=$func_quote_for_eval_result
7431 1.1 christos ;;
7432 1.1 christos esac # arg
7433 1.1 christos
7434 1.1 christos # Now actually substitute the argument into the commands.
7435 1.1 christos if test -n "$arg"; then
7436 1.1 christos func_append compile_command " $arg"
7437 1.1 christos func_append finalize_command " $arg"
7438 1.1 christos fi
7439 1.1 christos done # argument parsing loop
7440 1.1 christos
7441 1.1 christos test -n "$prev" && \
7442 1.1 christos func_fatal_help "the '$prevarg' option requires an argument"
7443 1.1 christos
7444 1.1 christos if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7445 1.1 christos eval arg=\"$export_dynamic_flag_spec\"
7446 1.1 christos func_append compile_command " $arg"
7447 1.1 christos func_append finalize_command " $arg"
7448 1.1 christos fi
7449 1.1 christos
7450 1.1 christos oldlibs=
7451 1.1 christos # calculate the name of the file, without its directory
7452 1.1 christos func_basename "$output"
7453 1.1 christos outputname=$func_basename_result
7454 1.1 christos libobjs_save=$libobjs
7455 1.1 christos
7456 1.1 christos if test -n "$shlibpath_var"; then
7457 1.1 christos # get the directories listed in $shlibpath_var
7458 1.1 christos eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7459 1.1 christos else
7460 1.1 christos shlib_search_path=
7461 1.1 christos fi
7462 1.1 christos eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7463 1.1 christos eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7464 1.1 christos
7465 1.1 christos # Definition is injected by LT_CONFIG during libtool generation.
7466 1.1 christos func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7467 1.1 christos
7468 1.1 christos func_dirname "$output" "/" ""
7469 1.1 christos output_objdir=$func_dirname_result$objdir
7470 1.1 christos func_to_tool_file "$output_objdir/"
7471 1.1 christos tool_output_objdir=$func_to_tool_file_result
7472 1.1 christos # Create the object directory.
7473 1.1 christos func_mkdir_p "$output_objdir"
7474 1.1 christos
7475 1.1 christos # Determine the type of output
7476 1.1 christos case $output in
7477 1.1 christos "")
7478 1.1 christos func_fatal_help "you must specify an output file"
7479 1.1 christos ;;
7480 1.1 christos *.$libext) linkmode=oldlib ;;
7481 1.1 christos *.lo | *.$objext) linkmode=obj ;;
7482 1.1 christos *.la) linkmode=lib ;;
7483 1.1 christos *) linkmode=prog ;; # Anything else should be a program.
7484 1.1 christos esac
7485 1.1 christos
7486 1.1 christos specialdeplibs=
7487 1.1 christos
7488 1.1 christos libs=
7489 1.1 christos # Find all interdependent deplibs by searching for libraries
7490 1.1 christos # that are linked more than once (e.g. -la -lb -la)
7491 1.1 christos for deplib in $deplibs; do
7492 1.1 christos if $opt_preserve_dup_deps; then
7493 1.1 christos case "$libs " in
7494 1.1 christos *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7495 1.1 christos esac
7496 1.1 christos fi
7497 1.1 christos func_append libs " $deplib"
7498 1.1 christos done
7499 1.1 christos
7500 1.1 christos if test lib = "$linkmode"; then
7501 1.1 christos libs="$predeps $libs $compiler_lib_search_path $postdeps"
7502 1.1 christos
7503 1.1 christos # Compute libraries that are listed more than once in $predeps
7504 1.1 christos # $postdeps and mark them as special (i.e., whose duplicates are
7505 1.1 christos # not to be eliminated).
7506 1.1 christos pre_post_deps=
7507 1.1 christos if $opt_duplicate_compiler_generated_deps; then
7508 1.1 christos for pre_post_dep in $predeps $postdeps; do
7509 1.1 christos case "$pre_post_deps " in
7510 1.1 christos *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7511 1.1 christos esac
7512 1.1 christos func_append pre_post_deps " $pre_post_dep"
7513 1.1 christos done
7514 1.1 christos fi
7515 1.1 christos pre_post_deps=
7516 1.1 christos fi
7517 1.1 christos
7518 1.1 christos deplibs=
7519 1.1 christos newdependency_libs=
7520 1.1 christos newlib_search_path=
7521 1.1 christos need_relink=no # whether we're linking any uninstalled libtool libraries
7522 1.1 christos notinst_deplibs= # not-installed libtool libraries
7523 1.1 christos notinst_path= # paths that contain not-installed libtool libraries
7524 1.1 christos
7525 1.1 christos case $linkmode in
7526 1.1 christos lib)
7527 1.1 christos passes="conv dlpreopen link"
7528 1.1 christos for file in $dlfiles $dlprefiles; do
7529 1.1 christos case $file in
7530 1.1 christos *.la) ;;
7531 1.1 christos *)
7532 1.1 christos func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7533 1.1 christos ;;
7534 1.1 christos esac
7535 1.1 christos done
7536 1.1 christos ;;
7537 1.1 christos prog)
7538 1.1 christos compile_deplibs=
7539 1.1 christos finalize_deplibs=
7540 1.1 christos alldeplibs=false
7541 1.1 christos newdlfiles=
7542 1.1 christos newdlprefiles=
7543 1.1 christos passes="conv scan dlopen dlpreopen link"
7544 1.1 christos ;;
7545 1.1 christos *) passes="conv"
7546 1.1 christos ;;
7547 1.1 christos esac
7548 1.1 christos
7549 1.1 christos for pass in $passes; do
7550 1.1 christos # The preopen pass in lib mode reverses $deplibs; put it back here
7551 1.1 christos # so that -L comes before libs that need it for instance...
7552 1.1 christos if test lib,link = "$linkmode,$pass"; then
7553 1.1 christos ## FIXME: Find the place where the list is rebuilt in the wrong
7554 1.1 christos ## order, and fix it there properly
7555 1.1 christos tmp_deplibs=
7556 1.1 christos for deplib in $deplibs; do
7557 1.1 christos tmp_deplibs="$deplib $tmp_deplibs"
7558 1.1 christos done
7559 1.1 christos deplibs=$tmp_deplibs
7560 1.1 christos fi
7561 1.1 christos
7562 1.1 christos if test lib,link = "$linkmode,$pass" ||
7563 1.1 christos test prog,scan = "$linkmode,$pass"; then
7564 1.1 christos libs=$deplibs
7565 1.1 christos deplibs=
7566 1.1 christos fi
7567 1.1 christos if test prog = "$linkmode"; then
7568 1.1 christos case $pass in
7569 1.1 christos dlopen) libs=$dlfiles ;;
7570 1.1 christos dlpreopen) libs=$dlprefiles ;;
7571 1.1 christos link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7572 1.1 christos esac
7573 1.1 christos fi
7574 1.1 christos if test lib,dlpreopen = "$linkmode,$pass"; then
7575 1.1 christos # Collect and forward deplibs of preopened libtool libs
7576 1.1 christos for lib in $dlprefiles; do
7577 1.1 christos # Ignore non-libtool-libs
7578 1.1 christos dependency_libs=
7579 1.1 christos func_resolve_sysroot "$lib"
7580 1.1 christos case $lib in
7581 1.1 christos *.la) func_source "$func_resolve_sysroot_result" ;;
7582 1.1 christos esac
7583 1.1 christos
7584 1.1 christos # Collect preopened libtool deplibs, except any this library
7585 1.1 christos # has declared as weak libs
7586 1.1 christos for deplib in $dependency_libs; do
7587 1.1 christos func_basename "$deplib"
7588 1.1 christos deplib_base=$func_basename_result
7589 1.1 christos case " $weak_libs " in
7590 1.1 christos *" $deplib_base "*) ;;
7591 1.1 christos *) func_append deplibs " $deplib" ;;
7592 1.1 christos esac
7593 1.1 christos done
7594 1.1 christos done
7595 1.1 christos libs=$dlprefiles
7596 1.1 christos fi
7597 1.1 christos if test dlopen = "$pass"; then
7598 1.1 christos # Collect dlpreopened libraries
7599 1.1 christos save_deplibs=$deplibs
7600 1.1 christos deplibs=
7601 1.1 christos fi
7602 1.1 christos
7603 1.1 christos for deplib in $libs; do
7604 1.1 christos lib=
7605 1.1 christos found=false
7606 1.1 christos case $deplib in
7607 1.1 christos -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7608 1.1 christos |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7609 1.1 christos if test prog,link = "$linkmode,$pass"; then
7610 1.1 christos compile_deplibs="$deplib $compile_deplibs"
7611 1.1 christos finalize_deplibs="$deplib $finalize_deplibs"
7612 1.1 christos else
7613 1.1 christos func_append compiler_flags " $deplib"
7614 1.1 christos if test lib = "$linkmode"; then
7615 1.1 christos case "$new_inherited_linker_flags " in
7616 1.1 christos *" $deplib "*) ;;
7617 1.1 christos * ) func_append new_inherited_linker_flags " $deplib" ;;
7618 1.1 christos esac
7619 1.1 christos fi
7620 1.1 christos fi
7621 1.1 christos continue
7622 1.1 christos ;;
7623 1.1 christos -l*)
7624 1.1 christos if test lib != "$linkmode" && test prog != "$linkmode"; then
7625 1.1 christos func_warning "'-l' is ignored for archives/objects"
7626 1.1 christos continue
7627 1.1 christos fi
7628 1.1 christos func_stripname '-l' '' "$deplib"
7629 1.1 christos name=$func_stripname_result
7630 1.1 christos if test lib = "$linkmode"; then
7631 1.1 christos searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7632 1.1 christos else
7633 1.1 christos searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7634 1.1 christos fi
7635 1.1 christos for searchdir in $searchdirs; do
7636 1.1 christos for search_ext in .la $std_shrext .so .a; do
7637 1.1 christos # Search the libtool library
7638 1.1 christos lib=$searchdir/lib$name$search_ext
7639 1.1 christos if test -f "$lib"; then
7640 1.1 christos if test .la = "$search_ext"; then
7641 1.1 christos found=:
7642 1.1 christos else
7643 1.1 christos found=false
7644 1.1 christos fi
7645 1.1 christos break 2
7646 1.1 christos fi
7647 1.1 christos done
7648 1.1 christos done
7649 1.1 christos if $found; then
7650 1.1 christos # deplib is a libtool library
7651 1.1 christos # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7652 1.1 christos # We need to do some special things here, and not later.
7653 1.1 christos if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7654 1.1 christos case " $predeps $postdeps " in
7655 1.1 christos *" $deplib "*)
7656 1.1 christos if func_lalib_p "$lib"; then
7657 1.1 christos library_names=
7658 1.1 christos old_library=
7659 1.1 christos func_source "$lib"
7660 1.1 christos for l in $old_library $library_names; do
7661 1.1 christos ll=$l
7662 1.1 christos done
7663 1.1 christos if test "X$ll" = "X$old_library"; then # only static version available
7664 1.1 christos found=false
7665 1.1 christos func_dirname "$lib" "" "."
7666 1.1 christos ladir=$func_dirname_result
7667 1.1 christos lib=$ladir/$old_library
7668 1.1 christos if test prog,link = "$linkmode,$pass"; then
7669 1.1 christos compile_deplibs="$deplib $compile_deplibs"
7670 1.1 christos finalize_deplibs="$deplib $finalize_deplibs"
7671 1.1 christos else
7672 1.1 christos deplibs="$deplib $deplibs"
7673 1.1 christos test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7674 1.1 christos fi
7675 1.1 christos continue
7676 1.1 christos fi
7677 1.1 christos fi
7678 1.1 christos ;;
7679 1.1 christos *) ;;
7680 1.1 christos esac
7681 1.1 christos fi
7682 1.1 christos else
7683 1.1 christos # deplib doesn't seem to be a libtool library
7684 1.1 christos if test prog,link = "$linkmode,$pass"; then
7685 1.1 christos compile_deplibs="$deplib $compile_deplibs"
7686 1.1 christos finalize_deplibs="$deplib $finalize_deplibs"
7687 1.1 christos else
7688 1.1 christos deplibs="$deplib $deplibs"
7689 1.1 christos test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7690 1.1 christos fi
7691 1.1 christos continue
7692 1.1 christos fi
7693 1.1 christos ;; # -l
7694 1.1 christos *.ltframework)
7695 1.1 christos if test prog,link = "$linkmode,$pass"; then
7696 1.1 christos compile_deplibs="$deplib $compile_deplibs"
7697 1.1 christos finalize_deplibs="$deplib $finalize_deplibs"
7698 1.1 christos else
7699 1.1 christos deplibs="$deplib $deplibs"
7700 1.1 christos if test lib = "$linkmode"; then
7701 1.1 christos case "$new_inherited_linker_flags " in
7702 1.1 christos *" $deplib "*) ;;
7703 1.1 christos * ) func_append new_inherited_linker_flags " $deplib" ;;
7704 1.1 christos esac
7705 1.1 christos fi
7706 1.1 christos fi
7707 1.1 christos continue
7708 1.1 christos ;;
7709 1.1 christos -L*)
7710 1.1 christos case $linkmode in
7711 1.1 christos lib)
7712 1.1 christos deplibs="$deplib $deplibs"
7713 1.1 christos test conv = "$pass" && continue
7714 1.1 christos newdependency_libs="$deplib $newdependency_libs"
7715 1.1 christos func_stripname '-L' '' "$deplib"
7716 1.1 christos func_resolve_sysroot "$func_stripname_result"
7717 1.1 christos func_append newlib_search_path " $func_resolve_sysroot_result"
7718 1.1 christos ;;
7719 1.1 christos prog)
7720 1.1 christos if test conv = "$pass"; then
7721 1.1 christos deplibs="$deplib $deplibs"
7722 1.1 christos continue
7723 1.1 christos fi
7724 1.1 christos if test scan = "$pass"; then
7725 1.1 christos deplibs="$deplib $deplibs"
7726 1.1 christos else
7727 1.1 christos compile_deplibs="$deplib $compile_deplibs"
7728 1.1 christos finalize_deplibs="$deplib $finalize_deplibs"
7729 1.1 christos fi
7730 1.1 christos func_stripname '-L' '' "$deplib"
7731 1.1 christos func_resolve_sysroot "$func_stripname_result"
7732 1.1 christos func_append newlib_search_path " $func_resolve_sysroot_result"
7733 1.1 christos ;;
7734 1.1 christos *)
7735 1.1 christos func_warning "'-L' is ignored for archives/objects"
7736 1.1 christos ;;
7737 1.1 christos esac # linkmode
7738 1.1 christos continue
7739 1.1 christos ;; # -L
7740 1.1 christos -R*)
7741 1.1 christos if test link = "$pass"; then
7742 1.1 christos func_stripname '-R' '' "$deplib"
7743 1.1 christos func_resolve_sysroot "$func_stripname_result"
7744 1.1 christos dir=$func_resolve_sysroot_result
7745 1.1 christos # Make sure the xrpath contains only unique directories.
7746 1.1 christos case "$xrpath " in
7747 1.1 christos *" $dir "*) ;;
7748 1.1 christos *) func_append xrpath " $dir" ;;
7749 1.1 christos esac
7750 1.1 christos fi
7751 1.1 christos deplibs="$deplib $deplibs"
7752 1.1 christos continue
7753 1.1 christos ;;
7754 1.1 christos *.la)
7755 1.1 christos func_resolve_sysroot "$deplib"
7756 1.1 christos lib=$func_resolve_sysroot_result
7757 1.1 christos ;;
7758 1.1 christos *.$libext)
7759 1.1 christos if test conv = "$pass"; then
7760 1.1 christos deplibs="$deplib $deplibs"
7761 1.1 christos continue
7762 1.1 christos fi
7763 1.1 christos case $linkmode in
7764 1.1 christos lib)
7765 1.1 christos # Linking convenience modules into shared libraries is allowed,
7766 1.1 christos # but linking other static libraries is non-portable.
7767 1.1 christos case " $dlpreconveniencelibs " in
7768 1.1 christos *" $deplib "*) ;;
7769 1.1 christos *)
7770 1.1 christos valid_a_lib=false
7771 1.1 christos case $deplibs_check_method in
7772 1.1 christos match_pattern*)
7773 1.1 christos set dummy $deplibs_check_method; shift
7774 1.1 christos match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7775 1.1 christos if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7776 1.1 christos | $EGREP "$match_pattern_regex" > /dev/null; then
7777 1.1 christos valid_a_lib=:
7778 1.1 christos fi
7779 1.1 christos ;;
7780 1.1 christos pass_all)
7781 1.1 christos valid_a_lib=:
7782 1.1 christos ;;
7783 1.1 christos esac
7784 1.1 christos if $valid_a_lib; then
7785 1.1 christos echo
7786 1.1 christos $ECHO "*** Warning: Linking the shared library $output against the"
7787 1.1 christos $ECHO "*** static library $deplib is not portable!"
7788 1.1 christos deplibs="$deplib $deplibs"
7789 1.1 christos else
7790 1.1 christos echo
7791 1.1 christos $ECHO "*** Warning: Trying to link with static lib archive $deplib."
7792 1.1 christos echo "*** I have the capability to make that library automatically link in when"
7793 1.1 christos echo "*** you link to this library. But I can only do this if you have a"
7794 1.1 christos echo "*** shared version of the library, which you do not appear to have"
7795 1.1 christos echo "*** because the file extensions .$libext of this argument makes me believe"
7796 1.1 christos echo "*** that it is just a static archive that I should not use here."
7797 1.1 christos fi
7798 1.1 christos ;;
7799 1.1 christos esac
7800 1.1 christos continue
7801 1.1 christos ;;
7802 1.1 christos prog)
7803 1.1 christos if test link != "$pass"; then
7804 1.1 christos deplibs="$deplib $deplibs"
7805 1.1 christos else
7806 1.1 christos compile_deplibs="$deplib $compile_deplibs"
7807 1.1 christos finalize_deplibs="$deplib $finalize_deplibs"
7808 1.1 christos fi
7809 1.1 christos continue
7810 1.1 christos ;;
7811 1.1 christos esac # linkmode
7812 1.1 christos ;; # *.$libext
7813 1.1 christos *.lo | *.$objext)
7814 1.1 christos if test conv = "$pass"; then
7815 1.1 christos deplibs="$deplib $deplibs"
7816 1.1 christos elif test prog = "$linkmode"; then
7817 1.1 christos if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7818 1.1 christos # If there is no dlopen support or we're linking statically,
7819 1.1 christos # we need to preload.
7820 1.1 christos func_append newdlprefiles " $deplib"
7821 1.1 christos compile_deplibs="$deplib $compile_deplibs"
7822 1.1 christos finalize_deplibs="$deplib $finalize_deplibs"
7823 1.1 christos else
7824 1.1 christos func_append newdlfiles " $deplib"
7825 1.1 christos fi
7826 1.1 christos fi
7827 1.1 christos continue
7828 1.1 christos ;;
7829 1.1 christos %DEPLIBS%)
7830 1.1 christos alldeplibs=:
7831 1.1 christos continue
7832 1.1 christos ;;
7833 1.1 christos esac # case $deplib
7834 1.1 christos
7835 1.1 christos $found || test -f "$lib" \
7836 1.1 christos || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7837 1.1 christos
7838 1.1 christos # Check to see that this really is a libtool archive.
7839 1.1 christos func_lalib_unsafe_p "$lib" \
7840 1.1 christos || func_fatal_error "'$lib' is not a valid libtool archive"
7841 1.1 christos
7842 1.1 christos func_dirname "$lib" "" "."
7843 1.1 christos ladir=$func_dirname_result
7844 1.1 christos
7845 1.1 christos dlname=
7846 1.1 christos dlopen=
7847 1.1 christos dlpreopen=
7848 1.1 christos libdir=
7849 1.1 christos library_names=
7850 1.1 christos old_library=
7851 1.1 christos inherited_linker_flags=
7852 1.1 christos # If the library was installed with an old release of libtool,
7853 1.1 christos # it will not redefine variables installed, or shouldnotlink
7854 1.1 christos installed=yes
7855 1.1 christos shouldnotlink=no
7856 1.1 christos avoidtemprpath=
7857 1.1 christos
7858 1.1 christos
7859 1.1 christos # Read the .la file
7860 1.1 christos func_source "$lib"
7861 1.1 christos
7862 1.1 christos # Convert "-framework foo" to "foo.ltframework"
7863 1.1 christos if test -n "$inherited_linker_flags"; then
7864 1.1 christos tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7865 1.1 christos for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7866 1.1 christos case " $new_inherited_linker_flags " in
7867 1.1 christos *" $tmp_inherited_linker_flag "*) ;;
7868 1.1 christos *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7869 1.1 christos esac
7870 1.1 christos done
7871 1.1 christos fi
7872 1.1 christos dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7873 1.1 christos if test lib,link = "$linkmode,$pass" ||
7874 1.1 christos test prog,scan = "$linkmode,$pass" ||
7875 1.1 christos { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7876 1.1 christos test -n "$dlopen" && func_append dlfiles " $dlopen"
7877 1.1 christos test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7878 1.1 christos fi
7879 1.1 christos
7880 1.1 christos if test conv = "$pass"; then
7881 1.1 christos # Only check for convenience libraries
7882 1.1 christos deplibs="$lib $deplibs"
7883 1.1 christos if test -z "$libdir"; then
7884 1.1 christos if test -z "$old_library"; then
7885 1.1 christos func_fatal_error "cannot find name of link library for '$lib'"
7886 1.1 christos fi
7887 1.1 christos # It is a libtool convenience library, so add in its objects.
7888 1.1 christos func_append convenience " $ladir/$objdir/$old_library"
7889 1.1 christos func_append old_convenience " $ladir/$objdir/$old_library"
7890 1.1 christos elif test prog != "$linkmode" && test lib != "$linkmode"; then
7891 1.1 christos func_fatal_error "'$lib' is not a convenience library"
7892 1.1 christos fi
7893 1.1 christos tmp_libs=
7894 1.1 christos for deplib in $dependency_libs; do
7895 1.1 christos deplibs="$deplib $deplibs"
7896 1.1 christos if $opt_preserve_dup_deps; then
7897 1.1 christos case "$tmp_libs " in
7898 1.1 christos *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7899 1.1 christos esac
7900 1.1 christos fi
7901 1.1 christos func_append tmp_libs " $deplib"
7902 1.1 christos done
7903 1.1 christos continue
7904 1.1 christos fi # $pass = conv
7905 1.1 christos
7906 1.1 christos
7907 1.1 christos # Get the name of the library we link against.
7908 1.1 christos linklib=
7909 1.1 christos if test -n "$old_library" &&
7910 1.1 christos { test yes = "$prefer_static_libs" ||
7911 1.1 christos test built,no = "$prefer_static_libs,$installed"; }; then
7912 1.1 christos linklib=$old_library
7913 1.1 christos else
7914 1.1 christos for l in $old_library $library_names; do
7915 1.1 christos linklib=$l
7916 1.1 christos done
7917 1.1 christos fi
7918 1.1 christos if test -z "$linklib"; then
7919 1.1 christos func_fatal_error "cannot find name of link library for '$lib'"
7920 1.1 christos fi
7921 1.1 christos
7922 1.1 christos # This library was specified with -dlopen.
7923 1.1 christos if test dlopen = "$pass"; then
7924 1.1 christos test -z "$libdir" \
7925 1.1 christos && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7926 1.1 christos if test -z "$dlname" ||
7927 1.1 christos test yes != "$dlopen_support" ||
7928 1.1 christos test no = "$build_libtool_libs"
7929 1.1 christos then
7930 1.1 christos # If there is no dlname, no dlopen support or we're linking
7931 1.1 christos # statically, we need to preload. We also need to preload any
7932 1.1 christos # dependent libraries so libltdl's deplib preloader doesn't
7933 1.1 christos # bomb out in the load deplibs phase.
7934 1.1 christos func_append dlprefiles " $lib $dependency_libs"
7935 1.1 christos else
7936 1.1 christos func_append newdlfiles " $lib"
7937 1.1 christos fi
7938 1.1 christos continue
7939 1.1 christos fi # $pass = dlopen
7940 1.1 christos
7941 1.1 christos # We need an absolute path.
7942 1.1 christos case $ladir in
7943 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7944 1.1 christos *)
7945 1.1 christos abs_ladir=`cd "$ladir" && pwd`
7946 1.1 christos if test -z "$abs_ladir"; then
7947 1.1 christos func_warning "cannot determine absolute directory name of '$ladir'"
7948 1.1 christos func_warning "passing it literally to the linker, although it might fail"
7949 1.1 christos abs_ladir=$ladir
7950 1.1 christos fi
7951 1.1 christos ;;
7952 1.1 christos esac
7953 1.1 christos func_basename "$lib"
7954 1.1 christos laname=$func_basename_result
7955 1.1 christos
7956 1.1 christos # Find the relevant object directory and library name.
7957 1.1 christos if test yes = "$installed"; then
7958 1.1 christos if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7959 1.1 christos func_warning "library '$lib' was moved."
7960 1.1 christos dir=$ladir
7961 1.1 christos absdir=$abs_ladir
7962 1.1 christos libdir=$abs_ladir
7963 1.1 christos else
7964 1.1 christos dir=$lt_sysroot$libdir
7965 1.1 christos absdir=$lt_sysroot$libdir
7966 1.1 christos fi
7967 1.1 christos test yes = "$hardcode_automatic" && avoidtemprpath=yes
7968 1.1 christos else
7969 1.1 christos if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7970 1.1 christos dir=$ladir
7971 1.1 christos absdir=$abs_ladir
7972 1.1 christos # Remove this search path later
7973 1.1 christos func_append notinst_path " $abs_ladir"
7974 1.1 christos else
7975 1.1 christos dir=$ladir/$objdir
7976 1.1 christos absdir=$abs_ladir/$objdir
7977 1.1 christos # Remove this search path later
7978 1.1 christos func_append notinst_path " $abs_ladir"
7979 1.1 christos fi
7980 1.1 christos fi # $installed = yes
7981 1.1 christos func_stripname 'lib' '.la' "$laname"
7982 1.1 christos name=$func_stripname_result
7983 1.1 christos
7984 1.1 christos # This library was specified with -dlpreopen.
7985 1.1 christos if test dlpreopen = "$pass"; then
7986 1.1 christos if test -z "$libdir" && test prog = "$linkmode"; then
7987 1.1 christos func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7988 1.1 christos fi
7989 1.1 christos case $host in
7990 1.1 christos # special handling for platforms with PE-DLLs.
7991 1.1 christos *cygwin* | *mingw* | *cegcc* )
7992 1.1 christos # Linker will automatically link against shared library if both
7993 1.1 christos # static and shared are present. Therefore, ensure we extract
7994 1.1 christos # symbols from the import library if a shared library is present
7995 1.1 christos # (otherwise, the dlopen module name will be incorrect). We do
7996 1.1 christos # this by putting the import library name into $newdlprefiles.
7997 1.1 christos # We recover the dlopen module name by 'saving' the la file
7998 1.1 christos # name in a special purpose variable, and (later) extracting the
7999 1.1 christos # dlname from the la file.
8000 1.1 christos if test -n "$dlname"; then
8001 1.1 christos func_tr_sh "$dir/$linklib"
8002 1.1 christos eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8003 1.1 christos func_append newdlprefiles " $dir/$linklib"
8004 1.1 christos else
8005 1.1 christos func_append newdlprefiles " $dir/$old_library"
8006 1.1 christos # Keep a list of preopened convenience libraries to check
8007 1.1 christos # that they are being used correctly in the link pass.
8008 1.1 christos test -z "$libdir" && \
8009 1.1 christos func_append dlpreconveniencelibs " $dir/$old_library"
8010 1.1 christos fi
8011 1.1 christos ;;
8012 1.1 christos * )
8013 1.1 christos # Prefer using a static library (so that no silly _DYNAMIC symbols
8014 1.1 christos # are required to link).
8015 1.1 christos if test -n "$old_library"; then
8016 1.1 christos func_append newdlprefiles " $dir/$old_library"
8017 1.1 christos # Keep a list of preopened convenience libraries to check
8018 1.1 christos # that they are being used correctly in the link pass.
8019 1.1 christos test -z "$libdir" && \
8020 1.1 christos func_append dlpreconveniencelibs " $dir/$old_library"
8021 1.1 christos # Otherwise, use the dlname, so that lt_dlopen finds it.
8022 1.1 christos elif test -n "$dlname"; then
8023 1.1 christos func_append newdlprefiles " $dir/$dlname"
8024 1.1 christos else
8025 1.1 christos func_append newdlprefiles " $dir/$linklib"
8026 1.1 christos fi
8027 1.1 christos ;;
8028 1.1 christos esac
8029 1.1 christos fi # $pass = dlpreopen
8030 1.1 christos
8031 1.1 christos if test -z "$libdir"; then
8032 1.1 christos # Link the convenience library
8033 1.1 christos if test lib = "$linkmode"; then
8034 1.1 christos deplibs="$dir/$old_library $deplibs"
8035 1.1 christos elif test prog,link = "$linkmode,$pass"; then
8036 1.1 christos compile_deplibs="$dir/$old_library $compile_deplibs"
8037 1.1 christos finalize_deplibs="$dir/$old_library $finalize_deplibs"
8038 1.1 christos else
8039 1.1 christos deplibs="$lib $deplibs" # used for prog,scan pass
8040 1.1 christos fi
8041 1.1 christos continue
8042 1.1 christos fi
8043 1.1 christos
8044 1.1 christos
8045 1.1 christos if test prog = "$linkmode" && test link != "$pass"; then
8046 1.1 christos func_append newlib_search_path " $ladir"
8047 1.1 christos deplibs="$lib $deplibs"
8048 1.1 christos
8049 1.1 christos linkalldeplibs=false
8050 1.1 christos if test no != "$link_all_deplibs" || test -z "$library_names" ||
8051 1.1 christos test no = "$build_libtool_libs"; then
8052 1.1 christos linkalldeplibs=:
8053 1.1 christos fi
8054 1.1 christos
8055 1.1 christos tmp_libs=
8056 1.1 christos for deplib in $dependency_libs; do
8057 1.1 christos case $deplib in
8058 1.1 christos -L*) func_stripname '-L' '' "$deplib"
8059 1.1 christos func_resolve_sysroot "$func_stripname_result"
8060 1.1 christos func_append newlib_search_path " $func_resolve_sysroot_result"
8061 1.1 christos ;;
8062 1.1 christos esac
8063 1.1 christos # Need to link against all dependency_libs?
8064 1.1 christos if $linkalldeplibs; then
8065 1.1 christos deplibs="$deplib $deplibs"
8066 1.1 christos else
8067 1.1 christos # Need to hardcode shared library paths
8068 1.1 christos # or/and link against static libraries
8069 1.1 christos newdependency_libs="$deplib $newdependency_libs"
8070 1.1 christos fi
8071 1.1 christos if $opt_preserve_dup_deps; then
8072 1.1 christos case "$tmp_libs " in
8073 1.1 christos *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8074 1.1 christos esac
8075 1.1 christos fi
8076 1.1 christos func_append tmp_libs " $deplib"
8077 1.1 christos done # for deplib
8078 1.1 christos continue
8079 1.1 christos fi # $linkmode = prog...
8080 1.1 christos
8081 1.1 christos if test prog,link = "$linkmode,$pass"; then
8082 1.1 christos if test -n "$library_names" &&
8083 1.1 christos { { test no = "$prefer_static_libs" ||
8084 1.1 christos test built,yes = "$prefer_static_libs,$installed"; } ||
8085 1.1 christos test -z "$old_library"; }; then
8086 1.1 christos # We need to hardcode the library path
8087 1.1 christos if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8088 1.1 christos # Make sure the rpath contains only unique directories.
8089 1.1 christos case $temp_rpath: in
8090 1.1 christos *"$absdir:"*) ;;
8091 1.1 christos *) func_append temp_rpath "$absdir:" ;;
8092 1.1 christos esac
8093 1.1 christos fi
8094 1.1 christos
8095 1.1 christos # Hardcode the library path.
8096 1.1 christos # Skip directories that are in the system default run-time
8097 1.1 christos # search path.
8098 1.1 christos case " $sys_lib_dlsearch_path " in
8099 1.1 christos *" $absdir "*) ;;
8100 1.1 christos *)
8101 1.1 christos case "$compile_rpath " in
8102 1.1 christos *" $absdir "*) ;;
8103 1.1 christos *) func_append compile_rpath " $absdir" ;;
8104 1.1 christos esac
8105 1.1 christos ;;
8106 1.1 christos esac
8107 1.1 christos case " $sys_lib_dlsearch_path " in
8108 1.1 christos *" $libdir "*) ;;
8109 1.1 christos *)
8110 1.1 christos case "$finalize_rpath " in
8111 1.1 christos *" $libdir "*) ;;
8112 1.1 christos *) func_append finalize_rpath " $libdir" ;;
8113 1.1 christos esac
8114 1.1 christos ;;
8115 1.1 christos esac
8116 1.1 christos fi # $linkmode,$pass = prog,link...
8117 1.1 christos
8118 1.1 christos if $alldeplibs &&
8119 1.1 christos { test pass_all = "$deplibs_check_method" ||
8120 1.1 christos { test yes = "$build_libtool_libs" &&
8121 1.1 christos test -n "$library_names"; }; }; then
8122 1.1 christos # We only need to search for static libraries
8123 1.1 christos continue
8124 1.1 christos fi
8125 1.1 christos fi
8126 1.1 christos
8127 1.1 christos link_static=no # Whether the deplib will be linked statically
8128 1.1 christos use_static_libs=$prefer_static_libs
8129 1.1 christos if test built = "$use_static_libs" && test yes = "$installed"; then
8130 1.1 christos use_static_libs=no
8131 1.1 christos fi
8132 1.1 christos if test -n "$library_names" &&
8133 1.1 christos { test no = "$use_static_libs" || test -z "$old_library"; }; then
8134 1.1 christos case $host in
8135 1.1 christos *cygwin* | *mingw* | *cegcc* | *os2*)
8136 1.1 christos # No point in relinking DLLs because paths are not encoded
8137 1.1 christos func_append notinst_deplibs " $lib"
8138 1.1 christos need_relink=no
8139 1.1 christos ;;
8140 1.1 christos *)
8141 1.1 christos if test no = "$installed"; then
8142 1.1 christos func_append notinst_deplibs " $lib"
8143 1.1 christos need_relink=yes
8144 1.1 christos fi
8145 1.1 christos ;;
8146 1.1 christos esac
8147 1.1 christos # This is a shared library
8148 1.1 christos
8149 1.1 christos # Warn about portability, can't link against -module's on some
8150 1.1 christos # systems (darwin). Don't bleat about dlopened modules though!
8151 1.1 christos dlopenmodule=
8152 1.1 christos for dlpremoduletest in $dlprefiles; do
8153 1.1 christos if test "X$dlpremoduletest" = "X$lib"; then
8154 1.1 christos dlopenmodule=$dlpremoduletest
8155 1.1 christos break
8156 1.1 christos fi
8157 1.1 christos done
8158 1.1 christos if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8159 1.1 christos echo
8160 1.1 christos if test prog = "$linkmode"; then
8161 1.1 christos $ECHO "*** Warning: Linking the executable $output against the loadable module"
8162 1.1 christos else
8163 1.1 christos $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8164 1.1 christos fi
8165 1.1 christos $ECHO "*** $linklib is not portable!"
8166 1.1 christos fi
8167 1.1 christos if test lib = "$linkmode" &&
8168 1.1 christos test yes = "$hardcode_into_libs"; then
8169 1.1 christos # Hardcode the library path.
8170 1.1 christos # Skip directories that are in the system default run-time
8171 1.1 christos # search path.
8172 1.1 christos case " $sys_lib_dlsearch_path " in
8173 1.1 christos *" $absdir "*) ;;
8174 1.1 christos *)
8175 1.1 christos case "$compile_rpath " in
8176 1.1 christos *" $absdir "*) ;;
8177 1.1 christos *) func_append compile_rpath " $absdir" ;;
8178 1.1 christos esac
8179 1.1 christos ;;
8180 1.1 christos esac
8181 1.1 christos case " $sys_lib_dlsearch_path " in
8182 1.1 christos *" $libdir "*) ;;
8183 1.1 christos *)
8184 1.1 christos case "$finalize_rpath " in
8185 1.1 christos *" $libdir "*) ;;
8186 1.1 christos *) func_append finalize_rpath " $libdir" ;;
8187 1.1 christos esac
8188 1.1 christos ;;
8189 1.1 christos esac
8190 1.1 christos fi
8191 1.1 christos
8192 1.1 christos if test -n "$old_archive_from_expsyms_cmds"; then
8193 1.1 christos # figure out the soname
8194 1.1 christos set dummy $library_names
8195 1.1 christos shift
8196 1.1 christos realname=$1
8197 1.1 christos shift
8198 1.1 christos libname=`eval "\\$ECHO \"$libname_spec\""`
8199 1.1 christos # use dlname if we got it. it's perfectly good, no?
8200 1.1 christos if test -n "$dlname"; then
8201 1.1 christos soname=$dlname
8202 1.1 christos elif test -n "$soname_spec"; then
8203 1.1 christos # bleh windows
8204 1.1 christos case $host in
8205 1.1 christos *cygwin* | mingw* | *cegcc* | *os2*)
8206 1.1 christos func_arith $current - $age
8207 1.1 christos major=$func_arith_result
8208 1.1 christos versuffix=-$major
8209 1.1 christos ;;
8210 1.1 christos esac
8211 1.1 christos eval soname=\"$soname_spec\"
8212 1.1 christos else
8213 1.1 christos soname=$realname
8214 1.1 christos fi
8215 1.1 christos
8216 1.1 christos # Make a new name for the extract_expsyms_cmds to use
8217 1.1 christos soroot=$soname
8218 1.1 christos func_basename "$soroot"
8219 1.1 christos soname=$func_basename_result
8220 1.1 christos func_stripname 'lib' '.dll' "$soname"
8221 1.1 christos newlib=libimp-$func_stripname_result.a
8222 1.1 christos
8223 1.1 christos # If the library has no export list, then create one now
8224 1.1 christos if test -f "$output_objdir/$soname-def"; then :
8225 1.1 christos else
8226 1.1 christos func_verbose "extracting exported symbol list from '$soname'"
8227 1.1 christos func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8228 1.1 christos fi
8229 1.1 christos
8230 1.1 christos # Create $newlib
8231 1.1 christos if test -f "$output_objdir/$newlib"; then :; else
8232 1.1 christos func_verbose "generating import library for '$soname'"
8233 1.1 christos func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8234 1.1 christos fi
8235 1.1 christos # make sure the library variables are pointing to the new library
8236 1.1 christos dir=$output_objdir
8237 1.1 christos linklib=$newlib
8238 1.1 christos fi # test -n "$old_archive_from_expsyms_cmds"
8239 1.1 christos
8240 1.1 christos if test prog = "$linkmode" || test relink != "$opt_mode"; then
8241 1.1 christos add_shlibpath=
8242 1.1 christos add_dir=
8243 1.1 christos add=
8244 1.1 christos lib_linked=yes
8245 1.1 christos case $hardcode_action in
8246 1.1 christos immediate | unsupported)
8247 1.1 christos if test no = "$hardcode_direct"; then
8248 1.1 christos add=$dir/$linklib
8249 1.1 christos case $host in
8250 1.1 christos *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8251 1.1 christos *-*-sysv4*uw2*) add_dir=-L$dir ;;
8252 1.1 christos *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8253 1.1 christos *-*-unixware7*) add_dir=-L$dir ;;
8254 1.1 christos *-*-darwin* )
8255 1.1 christos # if the lib is a (non-dlopened) module then we cannot
8256 1.1 christos # link against it, someone is ignoring the earlier warnings
8257 1.1 christos if /usr/bin/file -L $add 2> /dev/null |
8258 1.1 christos $GREP ": [^:]* bundle" >/dev/null; then
8259 1.1 christos if test "X$dlopenmodule" != "X$lib"; then
8260 1.1 christos $ECHO "*** Warning: lib $linklib is a module, not a shared library"
8261 1.1 christos if test -z "$old_library"; then
8262 1.1 christos echo
8263 1.1 christos echo "*** And there doesn't seem to be a static archive available"
8264 1.1 christos echo "*** The link will probably fail, sorry"
8265 1.1 christos else
8266 1.1 christos add=$dir/$old_library
8267 1.1 christos fi
8268 1.1 christos elif test -n "$old_library"; then
8269 1.1 christos add=$dir/$old_library
8270 1.1 christos fi
8271 1.1 christos fi
8272 1.1 christos esac
8273 1.1 christos elif test no = "$hardcode_minus_L"; then
8274 1.1 christos case $host in
8275 1.1 christos *-*-sunos*) add_shlibpath=$dir ;;
8276 1.1 christos esac
8277 1.1 christos add_dir=-L$dir
8278 1.1 christos add=-l$name
8279 1.1 christos elif test no = "$hardcode_shlibpath_var"; then
8280 1.1 christos add_shlibpath=$dir
8281 1.1 christos add=-l$name
8282 1.1 christos else
8283 1.1 christos lib_linked=no
8284 1.1 christos fi
8285 1.1 christos ;;
8286 1.1 christos relink)
8287 1.1 christos if test yes = "$hardcode_direct" &&
8288 1.1 christos test no = "$hardcode_direct_absolute"; then
8289 1.1 christos add=$dir/$linklib
8290 1.1 christos elif test yes = "$hardcode_minus_L"; then
8291 1.1 christos add_dir=-L$absdir
8292 1.1 christos # Try looking first in the location we're being installed to.
8293 1.1 christos if test -n "$inst_prefix_dir"; then
8294 1.1 christos case $libdir in
8295 1.1 christos [\\/]*)
8296 1.1 christos func_append add_dir " -L$inst_prefix_dir$libdir"
8297 1.1 christos ;;
8298 1.1 christos esac
8299 1.1 christos fi
8300 1.1 christos add=-l$name
8301 1.1 christos elif test yes = "$hardcode_shlibpath_var"; then
8302 1.1 christos add_shlibpath=$dir
8303 1.1 christos add=-l$name
8304 1.1 christos else
8305 1.1 christos lib_linked=no
8306 1.1 christos fi
8307 1.1 christos ;;
8308 1.1 christos *) lib_linked=no ;;
8309 1.1 christos esac
8310 1.1 christos
8311 1.1 christos if test yes != "$lib_linked"; then
8312 1.1 christos func_fatal_configuration "unsupported hardcode properties"
8313 1.1 christos fi
8314 1.1 christos
8315 1.1 christos if test -n "$add_shlibpath"; then
8316 1.1 christos case :$compile_shlibpath: in
8317 1.1 christos *":$add_shlibpath:"*) ;;
8318 1.1 christos *) func_append compile_shlibpath "$add_shlibpath:" ;;
8319 1.1 christos esac
8320 1.1 christos fi
8321 1.1 christos if test prog = "$linkmode"; then
8322 1.1 christos test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8323 1.1 christos test -n "$add" && compile_deplibs="$add $compile_deplibs"
8324 1.1 christos else
8325 1.1 christos test -n "$add_dir" && deplibs="$add_dir $deplibs"
8326 1.1 christos test -n "$add" && deplibs="$add $deplibs"
8327 1.1 christos if test yes != "$hardcode_direct" &&
8328 1.1 christos test yes != "$hardcode_minus_L" &&
8329 1.1 christos test yes = "$hardcode_shlibpath_var"; then
8330 1.1 christos case :$finalize_shlibpath: in
8331 1.1 christos *":$libdir:"*) ;;
8332 1.1 christos *) func_append finalize_shlibpath "$libdir:" ;;
8333 1.1 christos esac
8334 1.1 christos fi
8335 1.1 christos fi
8336 1.1 christos fi
8337 1.1 christos
8338 1.1 christos if test prog = "$linkmode" || test relink = "$opt_mode"; then
8339 1.1 christos add_shlibpath=
8340 1.1 christos add_dir=
8341 1.1 christos add=
8342 1.1 christos # Finalize command for both is simple: just hardcode it.
8343 1.1 christos if test yes = "$hardcode_direct" &&
8344 1.1 christos test no = "$hardcode_direct_absolute"; then
8345 1.1 christos add=$libdir/$linklib
8346 1.1 christos elif test yes = "$hardcode_minus_L"; then
8347 1.1 christos add_dir=-L$libdir
8348 1.1 christos add=-l$name
8349 1.1 christos elif test yes = "$hardcode_shlibpath_var"; then
8350 1.1 christos case :$finalize_shlibpath: in
8351 1.1 christos *":$libdir:"*) ;;
8352 1.1 christos *) func_append finalize_shlibpath "$libdir:" ;;
8353 1.1 christos esac
8354 1.1 christos add=-l$name
8355 1.1 christos elif test yes = "$hardcode_automatic"; then
8356 1.1 christos if test -n "$inst_prefix_dir" &&
8357 1.1 christos test -f "$inst_prefix_dir$libdir/$linklib"; then
8358 1.1 christos add=$inst_prefix_dir$libdir/$linklib
8359 1.1 christos else
8360 1.1 christos add=$libdir/$linklib
8361 1.1 christos fi
8362 1.1 christos else
8363 1.1 christos # We cannot seem to hardcode it, guess we'll fake it.
8364 1.1 christos add_dir=-L$libdir
8365 1.1 christos # Try looking first in the location we're being installed to.
8366 1.1 christos if test -n "$inst_prefix_dir"; then
8367 1.1 christos case $libdir in
8368 1.1 christos [\\/]*)
8369 1.1 christos func_append add_dir " -L$inst_prefix_dir$libdir"
8370 1.1 christos ;;
8371 1.1 christos esac
8372 1.1 christos fi
8373 1.1 christos add=-l$name
8374 1.1 christos fi
8375 1.1 christos
8376 1.1 christos if test prog = "$linkmode"; then
8377 1.1 christos test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8378 1.1 christos test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8379 1.1 christos else
8380 1.1 christos test -n "$add_dir" && deplibs="$add_dir $deplibs"
8381 1.1 christos test -n "$add" && deplibs="$add $deplibs"
8382 1.1 christos fi
8383 1.1 christos fi
8384 1.1 christos elif test prog = "$linkmode"; then
8385 1.1 christos # Here we assume that one of hardcode_direct or hardcode_minus_L
8386 1.1 christos # is not unsupported. This is valid on all known static and
8387 1.1 christos # shared platforms.
8388 1.1 christos if test unsupported != "$hardcode_direct"; then
8389 1.1 christos test -n "$old_library" && linklib=$old_library
8390 1.1 christos compile_deplibs="$dir/$linklib $compile_deplibs"
8391 1.1 christos finalize_deplibs="$dir/$linklib $finalize_deplibs"
8392 1.1 christos else
8393 1.1 christos compile_deplibs="-l$name -L$dir $compile_deplibs"
8394 1.1 christos finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8395 1.1 christos fi
8396 1.1 christos elif test yes = "$build_libtool_libs"; then
8397 1.1 christos # Not a shared library
8398 1.1 christos if test pass_all != "$deplibs_check_method"; then
8399 1.1 christos # We're trying link a shared library against a static one
8400 1.1 christos # but the system doesn't support it.
8401 1.1 christos
8402 1.1 christos # Just print a warning and add the library to dependency_libs so
8403 1.1 christos # that the program can be linked against the static library.
8404 1.1 christos echo
8405 1.1 christos $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8406 1.1 christos echo "*** I have the capability to make that library automatically link in when"
8407 1.1 christos echo "*** you link to this library. But I can only do this if you have a"
8408 1.1 christos echo "*** shared version of the library, which you do not appear to have."
8409 1.1 christos if test yes = "$module"; then
8410 1.1 christos echo "*** But as you try to build a module library, libtool will still create "
8411 1.1 christos echo "*** a static module, that should work as long as the dlopening application"
8412 1.1 christos echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8413 1.1 christos if test -z "$global_symbol_pipe"; then
8414 1.1 christos echo
8415 1.1 christos echo "*** However, this would only work if libtool was able to extract symbol"
8416 1.1 christos echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8417 1.1 christos echo "*** not find such a program. So, this module is probably useless."
8418 1.1 christos echo "*** 'nm' from GNU binutils and a full rebuild may help."
8419 1.1 christos fi
8420 1.1 christos if test no = "$build_old_libs"; then
8421 1.1 christos build_libtool_libs=module
8422 1.1 christos build_old_libs=yes
8423 1.1 christos else
8424 1.1 christos build_libtool_libs=no
8425 1.1 christos fi
8426 1.1 christos fi
8427 1.1 christos else
8428 1.1 christos deplibs="$dir/$old_library $deplibs"
8429 1.1 christos link_static=yes
8430 1.1 christos fi
8431 1.1 christos fi # link shared/static library?
8432 1.1 christos
8433 1.1 christos if test lib = "$linkmode"; then
8434 1.1 christos if test -n "$dependency_libs" &&
8435 1.1 christos { test yes != "$hardcode_into_libs" ||
8436 1.1 christos test yes = "$build_old_libs" ||
8437 1.1 christos test yes = "$link_static"; }; then
8438 1.1 christos # Extract -R from dependency_libs
8439 1.1 christos temp_deplibs=
8440 1.1 christos for libdir in $dependency_libs; do
8441 1.1 christos case $libdir in
8442 1.1 christos -R*) func_stripname '-R' '' "$libdir"
8443 1.1 christos temp_xrpath=$func_stripname_result
8444 1.1 christos case " $xrpath " in
8445 1.1 christos *" $temp_xrpath "*) ;;
8446 1.1 christos *) func_append xrpath " $temp_xrpath";;
8447 1.1 christos esac;;
8448 1.1 christos *) func_append temp_deplibs " $libdir";;
8449 1.1 christos esac
8450 1.1 christos done
8451 1.1 christos dependency_libs=$temp_deplibs
8452 1.1 christos fi
8453 1.1 christos
8454 1.1 christos func_append newlib_search_path " $absdir"
8455 1.1 christos # Link against this library
8456 1.1 christos test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8457 1.1 christos # ... and its dependency_libs
8458 1.1 christos tmp_libs=
8459 1.1 christos for deplib in $dependency_libs; do
8460 1.1 christos newdependency_libs="$deplib $newdependency_libs"
8461 1.1 christos case $deplib in
8462 1.1 christos -L*) func_stripname '-L' '' "$deplib"
8463 1.1 christos func_resolve_sysroot "$func_stripname_result";;
8464 1.1 christos *) func_resolve_sysroot "$deplib" ;;
8465 1.1 christos esac
8466 1.1 christos if $opt_preserve_dup_deps; then
8467 1.1 christos case "$tmp_libs " in
8468 1.1 christos *" $func_resolve_sysroot_result "*)
8469 1.1 christos func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8470 1.1 christos esac
8471 1.1 christos fi
8472 1.1 christos func_append tmp_libs " $func_resolve_sysroot_result"
8473 1.1 christos done
8474 1.1 christos
8475 1.1 christos if test no != "$link_all_deplibs"; then
8476 1.1 christos # Add the search paths of all dependency libraries
8477 1.1 christos for deplib in $dependency_libs; do
8478 1.1 christos path=
8479 1.1 christos case $deplib in
8480 1.1 christos -L*) path=$deplib ;;
8481 1.1 christos *.la)
8482 1.1 christos func_resolve_sysroot "$deplib"
8483 1.1 christos deplib=$func_resolve_sysroot_result
8484 1.1 christos func_dirname "$deplib" "" "."
8485 1.1 christos dir=$func_dirname_result
8486 1.1 christos # We need an absolute path.
8487 1.1 christos case $dir in
8488 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8489 1.1 christos *)
8490 1.1 christos absdir=`cd "$dir" && pwd`
8491 1.1 christos if test -z "$absdir"; then
8492 1.1 christos func_warning "cannot determine absolute directory name of '$dir'"
8493 1.1 christos absdir=$dir
8494 1.1 christos fi
8495 1.1 christos ;;
8496 1.1 christos esac
8497 1.1 christos if $GREP "^installed=no" $deplib > /dev/null; then
8498 1.1 christos case $host in
8499 1.1 christos *-*-darwin*)
8500 1.1 christos depdepl=
8501 1.1 christos eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8502 1.1 christos if test -n "$deplibrary_names"; then
8503 1.1 christos for tmp in $deplibrary_names; do
8504 1.1 christos depdepl=$tmp
8505 1.1 christos done
8506 1.1 christos if test -f "$absdir/$objdir/$depdepl"; then
8507 1.1 christos depdepl=$absdir/$objdir/$depdepl
8508 1.1 christos darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8509 1.1 christos if test -z "$darwin_install_name"; then
8510 1.1 christos darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8511 1.1 christos fi
8512 1.1 christos func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8513 1.1 christos func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8514 1.1 christos path=
8515 1.1 christos fi
8516 1.1 christos fi
8517 1.1 christos ;;
8518 1.1 christos *)
8519 1.1 christos path=-L$absdir/$objdir
8520 1.1 christos ;;
8521 1.1 christos esac
8522 1.1 christos else
8523 1.1 christos eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8524 1.1 christos test -z "$libdir" && \
8525 1.1 christos func_fatal_error "'$deplib' is not a valid libtool archive"
8526 1.1 christos test "$absdir" != "$libdir" && \
8527 1.1 christos func_warning "'$deplib' seems to be moved"
8528 1.1 christos
8529 1.1 christos path=-L$absdir
8530 1.1 christos fi
8531 1.1 christos ;;
8532 1.1 christos esac
8533 1.1 christos case " $deplibs " in
8534 1.1 christos *" $path "*) ;;
8535 1.1 christos *) deplibs="$path $deplibs" ;;
8536 1.1 christos esac
8537 1.1 christos done
8538 1.1 christos fi # link_all_deplibs != no
8539 1.1 christos fi # linkmode = lib
8540 1.1 christos done # for deplib in $libs
8541 1.1 christos if test link = "$pass"; then
8542 1.1 christos if test prog = "$linkmode"; then
8543 1.1 christos compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8544 1.1 christos finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8545 1.1 christos else
8546 1.1 christos compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8547 1.1 christos fi
8548 1.1 christos fi
8549 1.1 christos dependency_libs=$newdependency_libs
8550 1.1 christos if test dlpreopen = "$pass"; then
8551 1.1 christos # Link the dlpreopened libraries before other libraries
8552 1.1 christos for deplib in $save_deplibs; do
8553 1.1 christos deplibs="$deplib $deplibs"
8554 1.1 christos done
8555 1.1 christos fi
8556 1.1 christos if test dlopen != "$pass"; then
8557 1.1 christos test conv = "$pass" || {
8558 1.1 christos # Make sure lib_search_path contains only unique directories.
8559 1.1 christos lib_search_path=
8560 1.1 christos for dir in $newlib_search_path; do
8561 1.1 christos case "$lib_search_path " in
8562 1.1 christos *" $dir "*) ;;
8563 1.1 christos *) func_append lib_search_path " $dir" ;;
8564 1.1 christos esac
8565 1.1 christos done
8566 1.1 christos newlib_search_path=
8567 1.1 christos }
8568 1.1 christos
8569 1.1 christos if test prog,link = "$linkmode,$pass"; then
8570 1.1 christos vars="compile_deplibs finalize_deplibs"
8571 1.1 christos else
8572 1.1 christos vars=deplibs
8573 1.1 christos fi
8574 1.1 christos for var in $vars dependency_libs; do
8575 1.1 christos # Add libraries to $var in reverse order
8576 1.1 christos eval tmp_libs=\"\$$var\"
8577 1.1 christos new_libs=
8578 1.1 christos for deplib in $tmp_libs; do
8579 1.1 christos # FIXME: Pedantically, this is the right thing to do, so
8580 1.1 christos # that some nasty dependency loop isn't accidentally
8581 1.1 christos # broken:
8582 1.1 christos #new_libs="$deplib $new_libs"
8583 1.1 christos # Pragmatically, this seems to cause very few problems in
8584 1.1 christos # practice:
8585 1.1 christos case $deplib in
8586 1.1 christos -L*) new_libs="$deplib $new_libs" ;;
8587 1.1 christos -R*) ;;
8588 1.1 christos *)
8589 1.1 christos # And here is the reason: when a library appears more
8590 1.1 christos # than once as an explicit dependence of a library, or
8591 1.1 christos # is implicitly linked in more than once by the
8592 1.1 christos # compiler, it is considered special, and multiple
8593 1.1 christos # occurrences thereof are not removed. Compare this
8594 1.1 christos # with having the same library being listed as a
8595 1.1 christos # dependency of multiple other libraries: in this case,
8596 1.1 christos # we know (pedantically, we assume) the library does not
8597 1.1 christos # need to be listed more than once, so we keep only the
8598 1.1 christos # last copy. This is not always right, but it is rare
8599 1.1 christos # enough that we require users that really mean to play
8600 1.1 christos # such unportable linking tricks to link the library
8601 1.1 christos # using -Wl,-lname, so that libtool does not consider it
8602 1.1 christos # for duplicate removal.
8603 1.1 christos case " $specialdeplibs " in
8604 1.1 christos *" $deplib "*) new_libs="$deplib $new_libs" ;;
8605 1.1 christos *)
8606 1.1 christos case " $new_libs " in
8607 1.1 christos *" $deplib "*) ;;
8608 1.1 christos *) new_libs="$deplib $new_libs" ;;
8609 1.1 christos esac
8610 1.1 christos ;;
8611 1.1 christos esac
8612 1.1 christos ;;
8613 1.1 christos esac
8614 1.1 christos done
8615 1.1 christos tmp_libs=
8616 1.1 christos for deplib in $new_libs; do
8617 1.1 christos case $deplib in
8618 1.1 christos -L*)
8619 1.1 christos case " $tmp_libs " in
8620 1.1 christos *" $deplib "*) ;;
8621 1.1 christos *) func_append tmp_libs " $deplib" ;;
8622 1.1 christos esac
8623 1.1 christos ;;
8624 1.1 christos *) func_append tmp_libs " $deplib" ;;
8625 1.1 christos esac
8626 1.1 christos done
8627 1.1 christos eval $var=\"$tmp_libs\"
8628 1.1 christos done # for var
8629 1.1 christos fi
8630 1.1 christos
8631 1.1 christos # Add Sun CC postdeps if required:
8632 1.1 christos test CXX = "$tagname" && {
8633 1.1 christos case $host_os in
8634 1.1 christos linux*)
8635 1.1 christos case `$CC -V 2>&1 | sed 5q` in
8636 1.1 christos *Sun\ C*) # Sun C++ 5.9
8637 1.1 christos func_suncc_cstd_abi
8638 1.1 christos
8639 1.1 christos if test no != "$suncc_use_cstd_abi"; then
8640 1.1 christos func_append postdeps ' -library=Cstd -library=Crun'
8641 1.1 christos fi
8642 1.1 christos ;;
8643 1.1 christos esac
8644 1.1 christos ;;
8645 1.1 christos
8646 1.1 christos solaris*)
8647 1.1 christos func_cc_basename "$CC"
8648 1.1 christos case $func_cc_basename_result in
8649 1.1 christos CC* | sunCC*)
8650 1.1 christos func_suncc_cstd_abi
8651 1.1 christos
8652 1.1 christos if test no != "$suncc_use_cstd_abi"; then
8653 1.1 christos func_append postdeps ' -library=Cstd -library=Crun'
8654 1.1 christos fi
8655 1.1 christos ;;
8656 1.1 christos esac
8657 1.1 christos ;;
8658 1.1 christos esac
8659 1.1 christos }
8660 1.1 christos
8661 1.1 christos # Last step: remove runtime libs from dependency_libs
8662 1.1 christos # (they stay in deplibs)
8663 1.1 christos tmp_libs=
8664 1.1 christos for i in $dependency_libs; do
8665 1.1 christos case " $predeps $postdeps $compiler_lib_search_path " in
8666 1.1 christos *" $i "*)
8667 1.1 christos i=
8668 1.1 christos ;;
8669 1.1 christos esac
8670 1.1 christos if test -n "$i"; then
8671 1.1 christos func_append tmp_libs " $i"
8672 1.1 christos fi
8673 1.1 christos done
8674 1.1 christos dependency_libs=$tmp_libs
8675 1.1 christos done # for pass
8676 1.1 christos if test prog = "$linkmode"; then
8677 1.1 christos dlfiles=$newdlfiles
8678 1.1 christos fi
8679 1.1 christos if test prog = "$linkmode" || test lib = "$linkmode"; then
8680 1.1 christos dlprefiles=$newdlprefiles
8681 1.1 christos fi
8682 1.1 christos
8683 1.1 christos case $linkmode in
8684 1.1 christos oldlib)
8685 1.1 christos if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8686 1.1 christos func_warning "'-dlopen' is ignored for archives"
8687 1.1 christos fi
8688 1.1 christos
8689 1.1 christos case " $deplibs" in
8690 1.1 christos *\ -l* | *\ -L*)
8691 1.1 christos func_warning "'-l' and '-L' are ignored for archives" ;;
8692 1.1 christos esac
8693 1.1 christos
8694 1.1 christos test -n "$rpath" && \
8695 1.1 christos func_warning "'-rpath' is ignored for archives"
8696 1.1 christos
8697 1.1 christos test -n "$xrpath" && \
8698 1.1 christos func_warning "'-R' is ignored for archives"
8699 1.1 christos
8700 1.1 christos test -n "$vinfo" && \
8701 1.1 christos func_warning "'-version-info/-version-number' is ignored for archives"
8702 1.1 christos
8703 1.1 christos test -n "$release" && \
8704 1.1 christos func_warning "'-release' is ignored for archives"
8705 1.1 christos
8706 1.1 christos test -n "$export_symbols$export_symbols_regex" && \
8707 1.1 christos func_warning "'-export-symbols' is ignored for archives"
8708 1.1 christos
8709 1.1 christos # Now set the variables for building old libraries.
8710 1.1 christos build_libtool_libs=no
8711 1.1 christos oldlibs=$output
8712 1.1 christos func_append objs "$old_deplibs"
8713 1.1 christos ;;
8714 1.1 christos
8715 1.1 christos lib)
8716 1.1 christos # Make sure we only generate libraries of the form 'libNAME.la'.
8717 1.1 christos case $outputname in
8718 1.1 christos lib*)
8719 1.1 christos func_stripname 'lib' '.la' "$outputname"
8720 1.1 christos name=$func_stripname_result
8721 1.1 christos eval shared_ext=\"$shrext_cmds\"
8722 1.1 christos eval libname=\"$libname_spec\"
8723 1.1 christos ;;
8724 1.1 christos *)
8725 1.1 christos test no = "$module" \
8726 1.1 christos && func_fatal_help "libtool library '$output' must begin with 'lib'"
8727 1.1 christos
8728 1.1 christos if test no != "$need_lib_prefix"; then
8729 1.1 christos # Add the "lib" prefix for modules if required
8730 1.1 christos func_stripname '' '.la' "$outputname"
8731 1.1 christos name=$func_stripname_result
8732 1.1 christos eval shared_ext=\"$shrext_cmds\"
8733 1.1 christos eval libname=\"$libname_spec\"
8734 1.1 christos else
8735 1.1 christos func_stripname '' '.la' "$outputname"
8736 1.1 christos libname=$func_stripname_result
8737 1.1 christos fi
8738 1.1 christos ;;
8739 1.1 christos esac
8740 1.1 christos
8741 1.1 christos if test -n "$objs"; then
8742 1.1 christos if test pass_all != "$deplibs_check_method"; then
8743 1.1 christos func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8744 1.1 christos else
8745 1.1 christos echo
8746 1.1 christos $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8747 1.1 christos $ECHO "*** objects $objs is not portable!"
8748 1.1 christos func_append libobjs " $objs"
8749 1.1 christos fi
8750 1.1 christos fi
8751 1.1 christos
8752 1.1 christos test no = "$dlself" \
8753 1.1 christos || func_warning "'-dlopen self' is ignored for libtool libraries"
8754 1.1 christos
8755 1.1 christos set dummy $rpath
8756 1.1 christos shift
8757 1.1 christos test 1 -lt "$#" \
8758 1.1 christos && func_warning "ignoring multiple '-rpath's for a libtool library"
8759 1.1 christos
8760 1.1 christos install_libdir=$1
8761 1.1 christos
8762 1.1 christos oldlibs=
8763 1.1 christos if test -z "$rpath"; then
8764 1.1 christos if test yes = "$build_libtool_libs"; then
8765 1.1 christos # Building a libtool convenience library.
8766 1.1 christos # Some compilers have problems with a '.al' extension so
8767 1.1 christos # convenience libraries should have the same extension an
8768 1.1 christos # archive normally would.
8769 1.1 christos oldlibs="$output_objdir/$libname.$libext $oldlibs"
8770 1.1 christos build_libtool_libs=convenience
8771 1.1 christos build_old_libs=yes
8772 1.1 christos fi
8773 1.1 christos
8774 1.1 christos test -n "$vinfo" && \
8775 1.1 christos func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8776 1.1 christos
8777 1.1 christos test -n "$release" && \
8778 1.1 christos func_warning "'-release' is ignored for convenience libraries"
8779 1.1 christos else
8780 1.1 christos
8781 1.1 christos # Parse the version information argument.
8782 1.1 christos save_ifs=$IFS; IFS=:
8783 1.1 christos set dummy $vinfo 0 0 0
8784 1.1 christos shift
8785 1.1 christos IFS=$save_ifs
8786 1.1 christos
8787 1.1 christos test -n "$7" && \
8788 1.1 christos func_fatal_help "too many parameters to '-version-info'"
8789 1.1 christos
8790 1.1 christos # convert absolute version numbers to libtool ages
8791 1.1 christos # this retains compatibility with .la files and attempts
8792 1.1 christos # to make the code below a bit more comprehensible
8793 1.1 christos
8794 1.1 christos case $vinfo_number in
8795 1.1 christos yes)
8796 1.1 christos number_major=$1
8797 1.1 christos number_minor=$2
8798 1.1 christos number_revision=$3
8799 1.1 christos #
8800 1.1 christos # There are really only two kinds -- those that
8801 1.1 christos # use the current revision as the major version
8802 1.1 christos # and those that subtract age and use age as
8803 1.1 christos # a minor version. But, then there is irix
8804 1.1 christos # that has an extra 1 added just for fun
8805 1.1 christos #
8806 1.1 christos case $version_type in
8807 1.1 christos # correct linux to gnu/linux during the next big refactor
8808 1.1 christos darwin|freebsd-elf|linux|osf|windows|none)
8809 1.1 christos func_arith $number_major + $number_minor
8810 1.1 christos current=$func_arith_result
8811 1.1 christos age=$number_minor
8812 1.1 christos revision=$number_revision
8813 1.1 christos ;;
8814 1.1 christos freebsd-aout|qnx|sunos)
8815 1.1 christos current=$number_major
8816 1.1 christos revision=$number_minor
8817 1.1 christos age=0
8818 1.1 christos ;;
8819 1.1 christos irix|nonstopux)
8820 1.1 christos func_arith $number_major + $number_minor
8821 1.1 christos current=$func_arith_result
8822 1.1 christos age=$number_minor
8823 1.1 christos revision=$number_minor
8824 1.1 christos lt_irix_increment=no
8825 1.1 christos ;;
8826 1.1 christos esac
8827 1.1 christos ;;
8828 1.1 christos no)
8829 1.1 christos current=$1
8830 1.1 christos revision=$2
8831 1.1 christos age=$3
8832 1.1 christos ;;
8833 1.1 christos esac
8834 1.1 christos
8835 1.1 christos # Check that each of the things are valid numbers.
8836 1.1 christos case $current in
8837 1.1 christos 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 christos *)
8839 1.1 christos func_error "CURRENT '$current' must be a nonnegative integer"
8840 1.1 christos func_fatal_error "'$vinfo' is not valid version information"
8841 1.1 christos ;;
8842 1.1 christos esac
8843 1.1 christos
8844 1.1 christos case $revision in
8845 1.1 christos 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 christos *)
8847 1.1 christos func_error "REVISION '$revision' must be a nonnegative integer"
8848 1.1 christos func_fatal_error "'$vinfo' is not valid version information"
8849 1.1 christos ;;
8850 1.1 christos esac
8851 1.1 christos
8852 1.1 christos case $age in
8853 1.1 christos 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 christos *)
8855 1.1 christos func_error "AGE '$age' must be a nonnegative integer"
8856 1.1 christos func_fatal_error "'$vinfo' is not valid version information"
8857 1.1 christos ;;
8858 1.1 christos esac
8859 1.1 christos
8860 1.1 christos if test "$age" -gt "$current"; then
8861 1.1 christos func_error "AGE '$age' is greater than the current interface number '$current'"
8862 1.1 christos func_fatal_error "'$vinfo' is not valid version information"
8863 1.1 christos fi
8864 1.1 christos
8865 1.1 christos # Calculate the version variables.
8866 1.1 christos major=
8867 1.1 christos versuffix=
8868 1.1 christos verstring=
8869 1.1 christos case $version_type in
8870 1.1 christos none) ;;
8871 1.1 christos
8872 1.1 christos darwin)
8873 1.1 christos # Like Linux, but with the current version available in
8874 1.1 christos # verstring for coding it into the library header
8875 1.1 christos func_arith $current - $age
8876 1.1 christos major=.$func_arith_result
8877 1.1 christos versuffix=$major.$age.$revision
8878 1.1 christos # Darwin ld doesn't like 0 for these options...
8879 1.1 christos func_arith $current + 1
8880 1.1 christos minor_current=$func_arith_result
8881 1.1 christos xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8882 1.1 christos verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8883 1.1 christos # On Darwin other compilers
8884 1.1 christos case $CC in
8885 1.1 christos nagfor*)
8886 1.1 christos verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8887 1.1 christos ;;
8888 1.1 christos *)
8889 1.1 christos verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8890 1.1 christos ;;
8891 1.1 christos esac
8892 1.1 christos ;;
8893 1.1 christos
8894 1.1 christos freebsd-aout)
8895 1.1 christos major=.$current
8896 1.1 christos versuffix=.$current.$revision
8897 1.1 christos ;;
8898 1.1 christos
8899 1.1 christos freebsd-elf)
8900 1.1 christos func_arith $current - $age
8901 1.1 christos major=.$func_arith_result
8902 1.1 christos versuffix=$major.$age.$revision
8903 1.1 christos ;;
8904 1.1 christos
8905 1.1 christos irix | nonstopux)
8906 1.1 christos if test no = "$lt_irix_increment"; then
8907 1.1 christos func_arith $current - $age
8908 1.1 christos else
8909 1.1 christos func_arith $current - $age + 1
8910 1.1 christos fi
8911 1.1 christos major=$func_arith_result
8912 1.1 christos
8913 1.1 christos case $version_type in
8914 1.1 christos nonstopux) verstring_prefix=nonstopux ;;
8915 1.1 christos *) verstring_prefix=sgi ;;
8916 1.1 christos esac
8917 1.1 christos verstring=$verstring_prefix$major.$revision
8918 1.1 christos
8919 1.1 christos # Add in all the interfaces that we are compatible with.
8920 1.1 christos loop=$revision
8921 1.1 christos while test 0 -ne "$loop"; do
8922 1.1 christos func_arith $revision - $loop
8923 1.1 christos iface=$func_arith_result
8924 1.1 christos func_arith $loop - 1
8925 1.1 christos loop=$func_arith_result
8926 1.1 christos verstring=$verstring_prefix$major.$iface:$verstring
8927 1.1 christos done
8928 1.1 christos
8929 1.1 christos # Before this point, $major must not contain '.'.
8930 1.1 christos major=.$major
8931 1.1 christos versuffix=$major.$revision
8932 1.1 christos ;;
8933 1.1 christos
8934 1.1 christos linux) # correct to gnu/linux during the next big refactor
8935 1.1 christos func_arith $current - $age
8936 1.1 christos major=.$func_arith_result
8937 1.1 christos versuffix=$major.$age.$revision
8938 1.1 christos ;;
8939 1.1 christos
8940 1.1 christos osf)
8941 1.1 christos func_arith $current - $age
8942 1.1 christos major=.$func_arith_result
8943 1.1 christos versuffix=.$current.$age.$revision
8944 1.1 christos verstring=$current.$age.$revision
8945 1.1 christos
8946 1.1 christos # Add in all the interfaces that we are compatible with.
8947 1.1 christos loop=$age
8948 1.1 christos while test 0 -ne "$loop"; do
8949 1.1 christos func_arith $current - $loop
8950 1.1 christos iface=$func_arith_result
8951 1.1 christos func_arith $loop - 1
8952 1.1 christos loop=$func_arith_result
8953 1.1 christos verstring=$verstring:$iface.0
8954 1.1 christos done
8955 1.1 christos
8956 1.1 christos # Make executables depend on our current version.
8957 1.1 christos func_append verstring ":$current.0"
8958 1.1 christos ;;
8959 1.1 christos
8960 1.1 christos qnx)
8961 1.1 christos major=.$current
8962 1.1 christos versuffix=.$current
8963 1.1 christos ;;
8964 1.1 christos
8965 1.1 christos sco)
8966 1.1 christos major=.$current
8967 1.1 christos versuffix=.$current
8968 1.1 christos ;;
8969 1.1 christos
8970 1.1 christos sunos)
8971 1.1 christos major=.$current
8972 1.1 christos versuffix=.$current.$revision
8973 1.1 christos ;;
8974 1.1 christos
8975 1.1 christos windows)
8976 1.1 christos # Use '-' rather than '.', since we only want one
8977 1.1 christos # extension on DOS 8.3 file systems.
8978 1.1 christos func_arith $current - $age
8979 1.1 christos major=$func_arith_result
8980 1.1 christos versuffix=-$major
8981 1.1 christos ;;
8982 1.1 christos
8983 1.1 christos *)
8984 1.1 christos func_fatal_configuration "unknown library version type '$version_type'"
8985 1.1 christos ;;
8986 1.1 christos esac
8987 1.1 christos
8988 1.1 christos # Clear the version info if we defaulted, and they specified a release.
8989 1.1 christos if test -z "$vinfo" && test -n "$release"; then
8990 1.1 christos major=
8991 1.1 christos case $version_type in
8992 1.1 christos darwin)
8993 1.1 christos # we can't check for "0.0" in archive_cmds due to quoting
8994 1.1 christos # problems, so we reset it completely
8995 1.1 christos verstring=
8996 1.1 christos ;;
8997 1.1 christos *)
8998 1.1 christos verstring=0.0
8999 1.1 christos ;;
9000 1.1 christos esac
9001 1.1 christos if test no = "$need_version"; then
9002 1.1 christos versuffix=
9003 1.1 christos else
9004 1.1 christos versuffix=.0.0
9005 1.1 christos fi
9006 1.1 christos fi
9007 1.1 christos
9008 1.1 christos # Remove version info from name if versioning should be avoided
9009 1.1 christos if test yes,no = "$avoid_version,$need_version"; then
9010 1.1 christos major=
9011 1.1 christos versuffix=
9012 1.1 christos verstring=
9013 1.1 christos fi
9014 1.1 christos
9015 1.1 christos # Check to see if the archive will have undefined symbols.
9016 1.1 christos if test yes = "$allow_undefined"; then
9017 1.1 christos if test unsupported = "$allow_undefined_flag"; then
9018 1.1 christos if test yes = "$build_old_libs"; then
9019 1.1 christos func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9020 1.1 christos build_libtool_libs=no
9021 1.1 christos else
9022 1.1 christos func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9023 1.1 christos fi
9024 1.1 christos fi
9025 1.1 christos else
9026 1.1 christos # Don't allow undefined symbols.
9027 1.1 christos allow_undefined_flag=$no_undefined_flag
9028 1.1 christos fi
9029 1.1 christos
9030 1.1 christos fi
9031 1.1 christos
9032 1.1 christos func_generate_dlsyms "$libname" "$libname" :
9033 1.1 christos func_append libobjs " $symfileobj"
9034 1.1 christos test " " = "$libobjs" && libobjs=
9035 1.1 christos
9036 1.1 christos if test relink != "$opt_mode"; then
9037 1.1 christos # Remove our outputs, but don't remove object files since they
9038 1.1 christos # may have been created when compiling PIC objects.
9039 1.1 christos removelist=
9040 1.1 christos tempremovelist=`$ECHO "$output_objdir/*"`
9041 1.1 christos for p in $tempremovelist; do
9042 1.1 christos case $p in
9043 1.1 christos *.$objext | *.gcno)
9044 1.1 christos ;;
9045 1.1 christos $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9046 1.1 christos if test -n "$precious_files_regex"; then
9047 1.1 christos if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9048 1.1 christos then
9049 1.1 christos continue
9050 1.1 christos fi
9051 1.1 christos fi
9052 1.1 christos func_append removelist " $p"
9053 1.1 christos ;;
9054 1.1 christos *) ;;
9055 1.1 christos esac
9056 1.1 christos done
9057 1.1 christos test -n "$removelist" && \
9058 1.1 christos func_show_eval "${RM}r \$removelist"
9059 1.1 christos fi
9060 1.1 christos
9061 1.1 christos # Now set the variables for building old libraries.
9062 1.1 christos if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9063 1.1 christos func_append oldlibs " $output_objdir/$libname.$libext"
9064 1.1 christos
9065 1.1 christos # Transform .lo files to .o files.
9066 1.1 christos oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9067 1.1 christos fi
9068 1.1 christos
9069 1.1 christos # Eliminate all temporary directories.
9070 1.1 christos #for path in $notinst_path; do
9071 1.1 christos # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9072 1.1 christos # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9073 1.1 christos # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9074 1.1 christos #done
9075 1.1 christos
9076 1.1 christos if test -n "$xrpath"; then
9077 1.1 christos # If the user specified any rpath flags, then add them.
9078 1.1 christos temp_xrpath=
9079 1.1 christos for libdir in $xrpath; do
9080 1.1 christos func_replace_sysroot "$libdir"
9081 1.1 christos func_append temp_xrpath " -R$func_replace_sysroot_result"
9082 1.1 christos case "$finalize_rpath " in
9083 1.1 christos *" $libdir "*) ;;
9084 1.1 christos *) func_append finalize_rpath " $libdir" ;;
9085 1.1 christos esac
9086 1.1 christos done
9087 1.1 christos if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9088 1.1 christos dependency_libs="$temp_xrpath $dependency_libs"
9089 1.1 christos fi
9090 1.1 christos fi
9091 1.1 christos
9092 1.1 christos # Make sure dlfiles contains only unique files that won't be dlpreopened
9093 1.1 christos old_dlfiles=$dlfiles
9094 1.1 christos dlfiles=
9095 1.1 christos for lib in $old_dlfiles; do
9096 1.1 christos case " $dlprefiles $dlfiles " in
9097 1.1 christos *" $lib "*) ;;
9098 1.1 christos *) func_append dlfiles " $lib" ;;
9099 1.1 christos esac
9100 1.1 christos done
9101 1.1 christos
9102 1.1 christos # Make sure dlprefiles contains only unique files
9103 1.1 christos old_dlprefiles=$dlprefiles
9104 1.1 christos dlprefiles=
9105 1.1 christos for lib in $old_dlprefiles; do
9106 1.1 christos case "$dlprefiles " in
9107 1.1 christos *" $lib "*) ;;
9108 1.1 christos *) func_append dlprefiles " $lib" ;;
9109 1.1 christos esac
9110 1.1 christos done
9111 1.1 christos
9112 1.1 christos if test yes = "$build_libtool_libs"; then
9113 1.1 christos if test -n "$rpath"; then
9114 1.1 christos case $host in
9115 1.1 christos *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9116 1.1 christos # these systems don't actually have a c library (as such)!
9117 1.1 christos ;;
9118 1.1 christos *-*-rhapsody* | *-*-darwin1.[012])
9119 1.1 christos # Rhapsody C library is in the System framework
9120 1.1 christos func_append deplibs " System.ltframework"
9121 1.1 christos ;;
9122 1.1 christos *-*-netbsd*)
9123 1.1 christos # Don't link with libc until the a.out ld.so is fixed.
9124 1.1 christos ;;
9125 1.1 christos *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9126 1.1 christos # Do not include libc due to us having libc/libc_r.
9127 1.1 christos ;;
9128 1.1 christos *-*-sco3.2v5* | *-*-sco5v6*)
9129 1.1 christos # Causes problems with __ctype
9130 1.1 christos ;;
9131 1.1 christos *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9132 1.1 christos # Compiler inserts libc in the correct place for threads to work
9133 1.1 christos ;;
9134 1.1 christos *)
9135 1.1 christos # Add libc to deplibs on all other systems if necessary.
9136 1.1 christos if test yes = "$build_libtool_need_lc"; then
9137 1.1 christos func_append deplibs " -lc"
9138 1.1 christos fi
9139 1.1 christos ;;
9140 1.1 christos esac
9141 1.1 christos fi
9142 1.1 christos
9143 1.1 christos # Transform deplibs into only deplibs that can be linked in shared.
9144 1.1 christos name_save=$name
9145 1.1 christos libname_save=$libname
9146 1.1 christos release_save=$release
9147 1.1 christos versuffix_save=$versuffix
9148 1.1 christos major_save=$major
9149 1.1 christos # I'm not sure if I'm treating the release correctly. I think
9150 1.1 christos # release should show up in the -l (ie -lgmp5) so we don't want to
9151 1.1 christos # add it in twice. Is that correct?
9152 1.1 christos release=
9153 1.1 christos versuffix=
9154 1.1 christos major=
9155 1.1 christos newdeplibs=
9156 1.1 christos droppeddeps=no
9157 1.1 christos case $deplibs_check_method in
9158 1.1 christos pass_all)
9159 1.1 christos # Don't check for shared/static. Everything works.
9160 1.1 christos # This might be a little naive. We might want to check
9161 1.1 christos # whether the library exists or not. But this is on
9162 1.1 christos # osf3 & osf4 and I'm not really sure... Just
9163 1.1 christos # implementing what was already the behavior.
9164 1.1 christos newdeplibs=$deplibs
9165 1.1 christos ;;
9166 1.1 christos test_compile)
9167 1.1 christos # This code stresses the "libraries are programs" paradigm to its
9168 1.1 christos # limits. Maybe even breaks it. We compile a program, linking it
9169 1.1 christos # against the deplibs as a proxy for the library. Then we can check
9170 1.1 christos # whether they linked in statically or dynamically with ldd.
9171 1.1 christos $opt_dry_run || $RM conftest.c
9172 1.1 christos cat > conftest.c <<EOF
9173 1.1 christos int main() { return 0; }
9174 1.1 christos EOF
9175 1.1 christos $opt_dry_run || $RM conftest
9176 1.1 christos if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9177 1.1 christos ldd_output=`ldd conftest`
9178 1.1 christos for i in $deplibs; do
9179 1.1 christos case $i in
9180 1.1 christos -l*)
9181 1.1 christos func_stripname -l '' "$i"
9182 1.1 christos name=$func_stripname_result
9183 1.1 christos if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9184 1.1 christos case " $predeps $postdeps " in
9185 1.1 christos *" $i "*)
9186 1.1 christos func_append newdeplibs " $i"
9187 1.1 christos i=
9188 1.1 christos ;;
9189 1.1 christos esac
9190 1.1 christos fi
9191 1.1 christos if test -n "$i"; then
9192 1.1 christos libname=`eval "\\$ECHO \"$libname_spec\""`
9193 1.1 christos deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9194 1.1 christos set dummy $deplib_matches; shift
9195 1.1 christos deplib_match=$1
9196 1.1 christos if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9197 1.1 christos func_append newdeplibs " $i"
9198 1.1 christos else
9199 1.1 christos droppeddeps=yes
9200 1.1 christos echo
9201 1.1 christos $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9202 1.1 christos echo "*** I have the capability to make that library automatically link in when"
9203 1.1 christos echo "*** you link to this library. But I can only do this if you have a"
9204 1.1 christos echo "*** shared version of the library, which I believe you do not have"
9205 1.1 christos echo "*** because a test_compile did reveal that the linker did not use it for"
9206 1.1 christos echo "*** its dynamic dependency list that programs get resolved with at runtime."
9207 1.1 christos fi
9208 1.1 christos fi
9209 1.1 christos ;;
9210 1.1 christos *)
9211 1.1 christos func_append newdeplibs " $i"
9212 1.1 christos ;;
9213 1.1 christos esac
9214 1.1 christos done
9215 1.1 christos else
9216 1.1 christos # Error occurred in the first compile. Let's try to salvage
9217 1.1 christos # the situation: Compile a separate program for each library.
9218 1.1 christos for i in $deplibs; do
9219 1.1 christos case $i in
9220 1.1 christos -l*)
9221 1.1 christos func_stripname -l '' "$i"
9222 1.1 christos name=$func_stripname_result
9223 1.1 christos $opt_dry_run || $RM conftest
9224 1.1 christos if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9225 1.1 christos ldd_output=`ldd conftest`
9226 1.1 christos if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9227 1.1 christos case " $predeps $postdeps " in
9228 1.1 christos *" $i "*)
9229 1.1 christos func_append newdeplibs " $i"
9230 1.1 christos i=
9231 1.1 christos ;;
9232 1.1 christos esac
9233 1.1 christos fi
9234 1.1 christos if test -n "$i"; then
9235 1.1 christos libname=`eval "\\$ECHO \"$libname_spec\""`
9236 1.1 christos deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9237 1.1 christos set dummy $deplib_matches; shift
9238 1.1 christos deplib_match=$1
9239 1.1 christos if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9240 1.1 christos func_append newdeplibs " $i"
9241 1.1 christos else
9242 1.1 christos droppeddeps=yes
9243 1.1 christos echo
9244 1.1 christos $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9245 1.1 christos echo "*** I have the capability to make that library automatically link in when"
9246 1.1 christos echo "*** you link to this library. But I can only do this if you have a"
9247 1.1 christos echo "*** shared version of the library, which you do not appear to have"
9248 1.1 christos echo "*** because a test_compile did reveal that the linker did not use this one"
9249 1.1 christos echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9250 1.1 christos fi
9251 1.1 christos fi
9252 1.1 christos else
9253 1.1 christos droppeddeps=yes
9254 1.1 christos echo
9255 1.1 christos $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
9256 1.1 christos echo "*** make it link in! You will probably need to install it or some"
9257 1.1 christos echo "*** library that it depends on before this library will be fully"
9258 1.1 christos echo "*** functional. Installing it before continuing would be even better."
9259 1.1 christos fi
9260 1.1 christos ;;
9261 1.1 christos *)
9262 1.1 christos func_append newdeplibs " $i"
9263 1.1 christos ;;
9264 1.1 christos esac
9265 1.1 christos done
9266 1.1 christos fi
9267 1.1 christos ;;
9268 1.1 christos file_magic*)
9269 1.1 christos set dummy $deplibs_check_method; shift
9270 1.1 christos file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9271 1.1 christos for a_deplib in $deplibs; do
9272 1.1 christos case $a_deplib in
9273 1.1 christos -l*)
9274 1.1 christos func_stripname -l '' "$a_deplib"
9275 1.1 christos name=$func_stripname_result
9276 1.1 christos if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9277 1.1 christos case " $predeps $postdeps " in
9278 1.1 christos *" $a_deplib "*)
9279 1.1 christos func_append newdeplibs " $a_deplib"
9280 1.1 christos a_deplib=
9281 1.1 christos ;;
9282 1.1 christos esac
9283 1.1 christos fi
9284 1.1 christos if test -n "$a_deplib"; then
9285 1.1 christos libname=`eval "\\$ECHO \"$libname_spec\""`
9286 1.1 christos if test -n "$file_magic_glob"; then
9287 1.1 christos libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9288 1.1 christos else
9289 1.1 christos libnameglob=$libname
9290 1.1 christos fi
9291 1.1 christos test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9292 1.1 christos for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9293 1.1 christos if test yes = "$want_nocaseglob"; then
9294 1.1 christos shopt -s nocaseglob
9295 1.1 christos potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9296 1.1 christos $nocaseglob
9297 1.1 christos else
9298 1.1 christos potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9299 1.1 christos fi
9300 1.1 christos for potent_lib in $potential_libs; do
9301 1.1 christos # Follow soft links.
9302 1.1 christos if ls -lLd "$potent_lib" 2>/dev/null |
9303 1.1 christos $GREP " -> " >/dev/null; then
9304 1.1 christos continue
9305 1.1 christos fi
9306 1.1 christos # The statement above tries to avoid entering an
9307 1.1 christos # endless loop below, in case of cyclic links.
9308 1.1 christos # We might still enter an endless loop, since a link
9309 1.1 christos # loop can be closed while we follow links,
9310 1.1 christos # but so what?
9311 1.1 christos potlib=$potent_lib
9312 1.1 christos while test -h "$potlib" 2>/dev/null; do
9313 1.1 christos potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9314 1.1 christos case $potliblink in
9315 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9316 1.1 christos *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9317 1.1 christos esac
9318 1.1 christos done
9319 1.1 christos if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9320 1.1 christos $SED -e 10q |
9321 1.1 christos $EGREP "$file_magic_regex" > /dev/null; then
9322 1.1 christos func_append newdeplibs " $a_deplib"
9323 1.1 christos a_deplib=
9324 1.1 christos break 2
9325 1.1 christos fi
9326 1.1 christos done
9327 1.1 christos done
9328 1.1 christos fi
9329 1.1 christos if test -n "$a_deplib"; then
9330 1.1 christos droppeddeps=yes
9331 1.1 christos echo
9332 1.1 christos $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9333 1.1 christos echo "*** I have the capability to make that library automatically link in when"
9334 1.1 christos echo "*** you link to this library. But I can only do this if you have a"
9335 1.1 christos echo "*** shared version of the library, which you do not appear to have"
9336 1.1 christos echo "*** because I did check the linker path looking for a file starting"
9337 1.1 christos if test -z "$potlib"; then
9338 1.1 christos $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9339 1.1 christos else
9340 1.1 christos $ECHO "*** with $libname and none of the candidates passed a file format test"
9341 1.1 christos $ECHO "*** using a file magic. Last file checked: $potlib"
9342 1.1 christos fi
9343 1.1 christos fi
9344 1.1 christos ;;
9345 1.1 christos *)
9346 1.1 christos # Add a -L argument.
9347 1.1 christos func_append newdeplibs " $a_deplib"
9348 1.1 christos ;;
9349 1.1 christos esac
9350 1.1 christos done # Gone through all deplibs.
9351 1.1 christos ;;
9352 1.1 christos match_pattern*)
9353 1.1 christos set dummy $deplibs_check_method; shift
9354 1.1 christos match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9355 1.1 christos for a_deplib in $deplibs; do
9356 1.1 christos case $a_deplib in
9357 1.1 christos -l*)
9358 1.1 christos func_stripname -l '' "$a_deplib"
9359 1.1 christos name=$func_stripname_result
9360 1.1 christos if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9361 1.1 christos case " $predeps $postdeps " in
9362 1.1 christos *" $a_deplib "*)
9363 1.1 christos func_append newdeplibs " $a_deplib"
9364 1.1 christos a_deplib=
9365 1.1 christos ;;
9366 1.1 christos esac
9367 1.1 christos fi
9368 1.1 christos if test -n "$a_deplib"; then
9369 1.1 christos libname=`eval "\\$ECHO \"$libname_spec\""`
9370 1.1 christos for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9371 1.1 christos potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9372 1.1 christos for potent_lib in $potential_libs; do
9373 1.1 christos potlib=$potent_lib # see symlink-check above in file_magic test
9374 1.1 christos if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9375 1.1 christos $EGREP "$match_pattern_regex" > /dev/null; then
9376 1.1 christos func_append newdeplibs " $a_deplib"
9377 1.1 christos a_deplib=
9378 1.1 christos break 2
9379 1.1 christos fi
9380 1.1 christos done
9381 1.1 christos done
9382 1.1 christos fi
9383 1.1 christos if test -n "$a_deplib"; then
9384 1.1 christos droppeddeps=yes
9385 1.1 christos echo
9386 1.1 christos $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9387 1.1 christos echo "*** I have the capability to make that library automatically link in when"
9388 1.1 christos echo "*** you link to this library. But I can only do this if you have a"
9389 1.1 christos echo "*** shared version of the library, which you do not appear to have"
9390 1.1 christos echo "*** because I did check the linker path looking for a file starting"
9391 1.1 christos if test -z "$potlib"; then
9392 1.1 christos $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9393 1.1 christos else
9394 1.1 christos $ECHO "*** with $libname and none of the candidates passed a file format test"
9395 1.1 christos $ECHO "*** using a regex pattern. Last file checked: $potlib"
9396 1.1 christos fi
9397 1.1 christos fi
9398 1.1 christos ;;
9399 1.1 christos *)
9400 1.1 christos # Add a -L argument.
9401 1.1 christos func_append newdeplibs " $a_deplib"
9402 1.1 christos ;;
9403 1.1 christos esac
9404 1.1 christos done # Gone through all deplibs.
9405 1.1 christos ;;
9406 1.1 christos none | unknown | *)
9407 1.1 christos newdeplibs=
9408 1.1 christos tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9409 1.1 christos if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9410 1.1 christos for i in $predeps $postdeps; do
9411 1.1 christos # can't use Xsed below, because $i might contain '/'
9412 1.1 christos tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9413 1.1 christos done
9414 1.1 christos fi
9415 1.1 christos case $tmp_deplibs in
9416 1.1 christos *[!\ \ ]*)
9417 1.1 christos echo
9418 1.1 christos if test none = "$deplibs_check_method"; then
9419 1.1 christos echo "*** Warning: inter-library dependencies are not supported in this platform."
9420 1.1 christos else
9421 1.1 christos echo "*** Warning: inter-library dependencies are not known to be supported."
9422 1.1 christos fi
9423 1.1 christos echo "*** All declared inter-library dependencies are being dropped."
9424 1.1 christos droppeddeps=yes
9425 1.1 christos ;;
9426 1.1 christos esac
9427 1.1 christos ;;
9428 1.1 christos esac
9429 1.1 christos versuffix=$versuffix_save
9430 1.1 christos major=$major_save
9431 1.1 christos release=$release_save
9432 1.1 christos libname=$libname_save
9433 1.1 christos name=$name_save
9434 1.1 christos
9435 1.1 christos case $host in
9436 1.1 christos *-*-rhapsody* | *-*-darwin1.[012])
9437 1.1 christos # On Rhapsody replace the C library with the System framework
9438 1.1 christos newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9439 1.1 christos ;;
9440 1.1 christos esac
9441 1.1 christos
9442 1.1 christos if test yes = "$droppeddeps"; then
9443 1.1 christos if test yes = "$module"; then
9444 1.1 christos echo
9445 1.1 christos echo "*** Warning: libtool could not satisfy all declared inter-library"
9446 1.1 christos $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
9447 1.1 christos echo "*** a static module, that should work as long as the dlopening"
9448 1.1 christos echo "*** application is linked with the -dlopen flag."
9449 1.1 christos if test -z "$global_symbol_pipe"; then
9450 1.1 christos echo
9451 1.1 christos echo "*** However, this would only work if libtool was able to extract symbol"
9452 1.1 christos echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9453 1.1 christos echo "*** not find such a program. So, this module is probably useless."
9454 1.1 christos echo "*** 'nm' from GNU binutils and a full rebuild may help."
9455 1.1 christos fi
9456 1.1 christos if test no = "$build_old_libs"; then
9457 1.1 christos oldlibs=$output_objdir/$libname.$libext
9458 1.1 christos build_libtool_libs=module
9459 1.1 christos build_old_libs=yes
9460 1.1 christos else
9461 1.1 christos build_libtool_libs=no
9462 1.1 christos fi
9463 1.1 christos else
9464 1.1 christos echo "*** The inter-library dependencies that have been dropped here will be"
9465 1.1 christos echo "*** automatically added whenever a program is linked with this library"
9466 1.1 christos echo "*** or is declared to -dlopen it."
9467 1.1 christos
9468 1.1 christos if test no = "$allow_undefined"; then
9469 1.1 christos echo
9470 1.1 christos echo "*** Since this library must not contain undefined symbols,"
9471 1.1 christos echo "*** because either the platform does not support them or"
9472 1.1 christos echo "*** it was explicitly requested with -no-undefined,"
9473 1.1 christos echo "*** libtool will only create a static version of it."
9474 1.1 christos if test no = "$build_old_libs"; then
9475 1.1 christos oldlibs=$output_objdir/$libname.$libext
9476 1.1 christos build_libtool_libs=module
9477 1.1 christos build_old_libs=yes
9478 1.1 christos else
9479 1.1 christos build_libtool_libs=no
9480 1.1 christos fi
9481 1.1 christos fi
9482 1.1 christos fi
9483 1.1 christos fi
9484 1.1 christos # Done checking deplibs!
9485 1.1 christos deplibs=$newdeplibs
9486 1.1 christos fi
9487 1.1 christos # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9488 1.1 christos case $host in
9489 1.1 christos *-*-darwin*)
9490 1.1 christos newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9491 1.1 christos new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9492 1.1 christos deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9493 1.1 christos ;;
9494 1.1 christos esac
9495 1.1 christos
9496 1.1 christos # move library search paths that coincide with paths to not yet
9497 1.1 christos # installed libraries to the beginning of the library search list
9498 1.1 christos new_libs=
9499 1.1 christos for path in $notinst_path; do
9500 1.1 christos case " $new_libs " in
9501 1.1 christos *" -L$path/$objdir "*) ;;
9502 1.1 christos *)
9503 1.1 christos case " $deplibs " in
9504 1.1 christos *" -L$path/$objdir "*)
9505 1.1 christos func_append new_libs " -L$path/$objdir" ;;
9506 1.1 christos esac
9507 1.1 christos ;;
9508 1.1 christos esac
9509 1.1 christos done
9510 1.1 christos for deplib in $deplibs; do
9511 1.1 christos case $deplib in
9512 1.1 christos -L*)
9513 1.1 christos case " $new_libs " in
9514 1.1 christos *" $deplib "*) ;;
9515 1.1 christos *) func_append new_libs " $deplib" ;;
9516 1.1 christos esac
9517 1.1 christos ;;
9518 1.1 christos *) func_append new_libs " $deplib" ;;
9519 1.1 christos esac
9520 1.1 christos done
9521 1.1 christos deplibs=$new_libs
9522 1.1 christos
9523 1.1 christos # All the library-specific variables (install_libdir is set above).
9524 1.1 christos library_names=
9525 1.1 christos old_library=
9526 1.1 christos dlname=
9527 1.1 christos
9528 1.1 christos # Test again, we may have decided not to build it any more
9529 1.1 christos if test yes = "$build_libtool_libs"; then
9530 1.1 christos # Remove $wl instances when linking with ld.
9531 1.1 christos # FIXME: should test the right _cmds variable.
9532 1.1 christos case $archive_cmds in
9533 1.1 christos *\$LD\ *) wl= ;;
9534 1.1 christos esac
9535 1.1 christos if test yes = "$hardcode_into_libs"; then
9536 1.1 christos # Hardcode the library paths
9537 1.1 christos hardcode_libdirs=
9538 1.1 christos dep_rpath=
9539 1.1 christos rpath=$finalize_rpath
9540 1.1 christos test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9541 1.1 christos for libdir in $rpath; do
9542 1.1 christos if test -n "$hardcode_libdir_flag_spec"; then
9543 1.1 christos if test -n "$hardcode_libdir_separator"; then
9544 1.1 christos func_replace_sysroot "$libdir"
9545 1.1 christos libdir=$func_replace_sysroot_result
9546 1.1 christos if test -z "$hardcode_libdirs"; then
9547 1.1 christos hardcode_libdirs=$libdir
9548 1.1 christos else
9549 1.1 christos # Just accumulate the unique libdirs.
9550 1.1 christos case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9551 1.1 christos *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9552 1.1 christos ;;
9553 1.1 christos *)
9554 1.1 christos func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9555 1.1 christos ;;
9556 1.1 christos esac
9557 1.1 christos fi
9558 1.1 christos else
9559 1.1 christos eval flag=\"$hardcode_libdir_flag_spec\"
9560 1.1 christos func_append dep_rpath " $flag"
9561 1.1 christos fi
9562 1.1 christos elif test -n "$runpath_var"; then
9563 1.1 christos case "$perm_rpath " in
9564 1.1 christos *" $libdir "*) ;;
9565 1.1 christos *) func_append perm_rpath " $libdir" ;;
9566 1.1 christos esac
9567 1.1 christos fi
9568 1.1 christos done
9569 1.1 christos # Substitute the hardcoded libdirs into the rpath.
9570 1.1 christos if test -n "$hardcode_libdir_separator" &&
9571 1.1 christos test -n "$hardcode_libdirs"; then
9572 1.1 christos libdir=$hardcode_libdirs
9573 1.1 christos eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9574 1.1 christos fi
9575 1.1 christos if test -n "$runpath_var" && test -n "$perm_rpath"; then
9576 1.1 christos # We should set the runpath_var.
9577 1.1 christos rpath=
9578 1.1 christos for dir in $perm_rpath; do
9579 1.1 christos func_append rpath "$dir:"
9580 1.1 christos done
9581 1.1 christos eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9582 1.1 christos fi
9583 1.1 christos test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9584 1.1 christos fi
9585 1.1 christos
9586 1.1 christos shlibpath=$finalize_shlibpath
9587 1.1 christos test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9588 1.1 christos if test -n "$shlibpath"; then
9589 1.1 christos eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9590 1.1 christos fi
9591 1.1 christos
9592 1.1 christos # Get the real and link names of the library.
9593 1.1 christos eval shared_ext=\"$shrext_cmds\"
9594 1.1 christos eval library_names=\"$library_names_spec\"
9595 1.1 christos set dummy $library_names
9596 1.1 christos shift
9597 1.1 christos realname=$1
9598 1.1 christos shift
9599 1.1 christos
9600 1.1 christos if test -n "$soname_spec"; then
9601 1.1 christos eval soname=\"$soname_spec\"
9602 1.1 christos else
9603 1.1 christos soname=$realname
9604 1.1 christos fi
9605 1.1 christos if test -z "$dlname"; then
9606 1.1 christos dlname=$soname
9607 1.1 christos fi
9608 1.1 christos
9609 1.1 christos lib=$output_objdir/$realname
9610 1.1 christos linknames=
9611 1.1 christos for link
9612 1.1 christos do
9613 1.1 christos func_append linknames " $link"
9614 1.1 christos done
9615 1.1 christos
9616 1.1 christos # Use standard objects if they are pic
9617 1.1 christos test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9618 1.1 christos test "X$libobjs" = "X " && libobjs=
9619 1.1 christos
9620 1.1 christos delfiles=
9621 1.1 christos if test -n "$export_symbols" && test -n "$include_expsyms"; then
9622 1.1 christos $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9623 1.1 christos export_symbols=$output_objdir/$libname.uexp
9624 1.1 christos func_append delfiles " $export_symbols"
9625 1.1 christos fi
9626 1.1 christos
9627 1.1 christos orig_export_symbols=
9628 1.1 christos case $host_os in
9629 1.1 christos cygwin* | mingw* | cegcc*)
9630 1.1 christos if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9631 1.1 christos # exporting using user supplied symfile
9632 1.1 christos func_dll_def_p "$export_symbols" || {
9633 1.1 christos # and it's NOT already a .def file. Must figure out
9634 1.1 christos # which of the given symbols are data symbols and tag
9635 1.1 christos # them as such. So, trigger use of export_symbols_cmds.
9636 1.1 christos # export_symbols gets reassigned inside the "prepare
9637 1.1 christos # the list of exported symbols" if statement, so the
9638 1.1 christos # include_expsyms logic still works.
9639 1.1 christos orig_export_symbols=$export_symbols
9640 1.1 christos export_symbols=
9641 1.1 christos always_export_symbols=yes
9642 1.1 christos }
9643 1.1 christos fi
9644 1.1 christos ;;
9645 1.1 christos esac
9646 1.1 christos
9647 1.1 christos # Prepare the list of exported symbols
9648 1.1 christos if test -z "$export_symbols"; then
9649 1.1 christos if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9650 1.1 christos func_verbose "generating symbol list for '$libname.la'"
9651 1.1 christos export_symbols=$output_objdir/$libname.exp
9652 1.1 christos $opt_dry_run || $RM $export_symbols
9653 1.1 christos cmds=$export_symbols_cmds
9654 1.1 christos save_ifs=$IFS; IFS='~'
9655 1.1 christos for cmd1 in $cmds; do
9656 1.1 christos IFS=$save_ifs
9657 1.1 christos # Take the normal branch if the nm_file_list_spec branch
9658 1.1 christos # doesn't work or if tool conversion is not needed.
9659 1.1 christos case $nm_file_list_spec~$to_tool_file_cmd in
9660 1.1 christos *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9661 1.1 christos try_normal_branch=yes
9662 1.1 christos eval cmd=\"$cmd1\"
9663 1.1 christos func_len " $cmd"
9664 1.1 christos len=$func_len_result
9665 1.1 christos ;;
9666 1.1 christos *)
9667 1.1 christos try_normal_branch=no
9668 1.1 christos ;;
9669 1.1 christos esac
9670 1.1 christos if test yes = "$try_normal_branch" \
9671 1.1 christos && { test "$len" -lt "$max_cmd_len" \
9672 1.1 christos || test "$max_cmd_len" -le -1; }
9673 1.1 christos then
9674 1.1 christos func_show_eval "$cmd" 'exit $?'
9675 1.1 christos skipped_export=false
9676 1.1 christos elif test -n "$nm_file_list_spec"; then
9677 1.1 christos func_basename "$output"
9678 1.1 christos output_la=$func_basename_result
9679 1.1 christos save_libobjs=$libobjs
9680 1.1 christos save_output=$output
9681 1.1 christos output=$output_objdir/$output_la.nm
9682 1.1 christos func_to_tool_file "$output"
9683 1.1 christos libobjs=$nm_file_list_spec$func_to_tool_file_result
9684 1.1 christos func_append delfiles " $output"
9685 1.1 christos func_verbose "creating $NM input file list: $output"
9686 1.1 christos for obj in $save_libobjs; do
9687 1.1 christos func_to_tool_file "$obj"
9688 1.1 christos $ECHO "$func_to_tool_file_result"
9689 1.1 christos done > "$output"
9690 1.1 christos eval cmd=\"$cmd1\"
9691 1.1 christos func_show_eval "$cmd" 'exit $?'
9692 1.1 christos output=$save_output
9693 1.1 christos libobjs=$save_libobjs
9694 1.1 christos skipped_export=false
9695 1.1 christos else
9696 1.1 christos # The command line is too long to execute in one step.
9697 1.1 christos func_verbose "using reloadable object file for export list..."
9698 1.1 christos skipped_export=:
9699 1.1 christos # Break out early, otherwise skipped_export may be
9700 1.1 christos # set to false by a later but shorter cmd.
9701 1.1 christos break
9702 1.1 christos fi
9703 1.1 christos done
9704 1.1 christos IFS=$save_ifs
9705 1.1 christos if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9706 1.1 christos func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9707 1.1 christos func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9708 1.1 christos fi
9709 1.1 christos fi
9710 1.1 christos fi
9711 1.1 christos
9712 1.1 christos if test -n "$export_symbols" && test -n "$include_expsyms"; then
9713 1.1 christos tmp_export_symbols=$export_symbols
9714 1.1 christos test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9715 1.1 christos $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9716 1.1 christos fi
9717 1.1 christos
9718 1.1 christos if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9719 1.1 christos # The given exports_symbols file has to be filtered, so filter it.
9720 1.1 christos func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9721 1.1 christos # FIXME: $output_objdir/$libname.filter potentially contains lots of
9722 1.1 christos # 's' commands, which not all seds can handle. GNU sed should be fine
9723 1.1 christos # though. Also, the filter scales superlinearly with the number of
9724 1.1 christos # global variables. join(1) would be nice here, but unfortunately
9725 1.1 christos # isn't a blessed tool.
9726 1.1 christos $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9727 1.1 christos func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9728 1.1 christos export_symbols=$output_objdir/$libname.def
9729 1.1 christos $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9730 1.1 christos fi
9731 1.1 christos
9732 1.1 christos tmp_deplibs=
9733 1.1 christos for test_deplib in $deplibs; do
9734 1.1 christos case " $convenience " in
9735 1.1 christos *" $test_deplib "*) ;;
9736 1.1 christos *)
9737 1.1 christos func_append tmp_deplibs " $test_deplib"
9738 1.1 christos ;;
9739 1.1 christos esac
9740 1.1 christos done
9741 1.1 christos deplibs=$tmp_deplibs
9742 1.1 christos
9743 1.1 christos if test -n "$convenience"; then
9744 1.1 christos if test -n "$whole_archive_flag_spec" &&
9745 1.1 christos test yes = "$compiler_needs_object" &&
9746 1.1 christos test -z "$libobjs"; then
9747 1.1 christos # extract the archives, so we have objects to list.
9748 1.1 christos # TODO: could optimize this to just extract one archive.
9749 1.1 christos whole_archive_flag_spec=
9750 1.1 christos fi
9751 1.1 christos if test -n "$whole_archive_flag_spec"; then
9752 1.1 christos save_libobjs=$libobjs
9753 1.1 christos eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9754 1.1 christos test "X$libobjs" = "X " && libobjs=
9755 1.1 christos else
9756 1.1 christos gentop=$output_objdir/${outputname}x
9757 1.1 christos func_append generated " $gentop"
9758 1.1 christos
9759 1.1 christos func_extract_archives $gentop $convenience
9760 1.1 christos func_append libobjs " $func_extract_archives_result"
9761 1.1 christos test "X$libobjs" = "X " && libobjs=
9762 1.1 christos fi
9763 1.1 christos fi
9764 1.1 christos
9765 1.1 christos if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9766 1.1 christos eval flag=\"$thread_safe_flag_spec\"
9767 1.1 christos func_append linker_flags " $flag"
9768 1.1 christos fi
9769 1.1 christos
9770 1.1 christos # Make a backup of the uninstalled library when relinking
9771 1.1 christos if test relink = "$opt_mode"; then
9772 1.1 christos $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9773 1.1 christos fi
9774 1.1 christos
9775 1.1 christos # Do each of the archive commands.
9776 1.1 christos if test yes = "$module" && test -n "$module_cmds"; then
9777 1.1 christos if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9778 1.1 christos eval test_cmds=\"$module_expsym_cmds\"
9779 1.1 christos cmds=$module_expsym_cmds
9780 1.1 christos else
9781 1.1 christos eval test_cmds=\"$module_cmds\"
9782 1.1 christos cmds=$module_cmds
9783 1.1 christos fi
9784 1.1 christos else
9785 1.1 christos if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9786 1.1 christos eval test_cmds=\"$archive_expsym_cmds\"
9787 1.1 christos cmds=$archive_expsym_cmds
9788 1.1 christos else
9789 1.1 christos eval test_cmds=\"$archive_cmds\"
9790 1.1 christos cmds=$archive_cmds
9791 1.1 christos fi
9792 1.1 christos fi
9793 1.1 christos
9794 1.1 christos if test : != "$skipped_export" &&
9795 1.1 christos func_len " $test_cmds" &&
9796 1.1 christos len=$func_len_result &&
9797 1.1 christos test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9798 1.1 christos :
9799 1.1 christos else
9800 1.1 christos # The command line is too long to link in one step, link piecewise
9801 1.1 christos # or, if using GNU ld and skipped_export is not :, use a linker
9802 1.1 christos # script.
9803 1.1 christos
9804 1.1 christos # Save the value of $output and $libobjs because we want to
9805 1.1 christos # use them later. If we have whole_archive_flag_spec, we
9806 1.1 christos # want to use save_libobjs as it was before
9807 1.1 christos # whole_archive_flag_spec was expanded, because we can't
9808 1.1 christos # assume the linker understands whole_archive_flag_spec.
9809 1.1 christos # This may have to be revisited, in case too many
9810 1.1 christos # convenience libraries get linked in and end up exceeding
9811 1.1 christos # the spec.
9812 1.1 christos if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9813 1.1 christos save_libobjs=$libobjs
9814 1.1 christos fi
9815 1.1 christos save_output=$output
9816 1.1 christos func_basename "$output"
9817 1.1 christos output_la=$func_basename_result
9818 1.1 christos
9819 1.1 christos # Clear the reloadable object creation command queue and
9820 1.1 christos # initialize k to one.
9821 1.1 christos test_cmds=
9822 1.1 christos concat_cmds=
9823 1.1 christos objlist=
9824 1.1 christos last_robj=
9825 1.1 christos k=1
9826 1.1 christos
9827 1.1 christos if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9828 1.1 christos output=$output_objdir/$output_la.lnkscript
9829 1.1 christos func_verbose "creating GNU ld script: $output"
9830 1.1 christos echo 'INPUT (' > $output
9831 1.1 christos for obj in $save_libobjs
9832 1.1 christos do
9833 1.1 christos func_to_tool_file "$obj"
9834 1.1 christos $ECHO "$func_to_tool_file_result" >> $output
9835 1.1 christos done
9836 1.1 christos echo ')' >> $output
9837 1.1 christos func_append delfiles " $output"
9838 1.1 christos func_to_tool_file "$output"
9839 1.1 christos output=$func_to_tool_file_result
9840 1.1 christos elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9841 1.1 christos output=$output_objdir/$output_la.lnk
9842 1.1 christos func_verbose "creating linker input file list: $output"
9843 1.1 christos : > $output
9844 1.1 christos set x $save_libobjs
9845 1.1 christos shift
9846 1.1 christos firstobj=
9847 1.1 christos if test yes = "$compiler_needs_object"; then
9848 1.1 christos firstobj="$1 "
9849 1.1 christos shift
9850 1.1 christos fi
9851 1.1 christos for obj
9852 1.1 christos do
9853 1.1 christos func_to_tool_file "$obj"
9854 1.1 christos $ECHO "$func_to_tool_file_result" >> $output
9855 1.1 christos done
9856 1.1 christos func_append delfiles " $output"
9857 1.1 christos func_to_tool_file "$output"
9858 1.1 christos output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9859 1.1 christos else
9860 1.1 christos if test -n "$save_libobjs"; then
9861 1.1 christos func_verbose "creating reloadable object files..."
9862 1.1 christos output=$output_objdir/$output_la-$k.$objext
9863 1.1 christos eval test_cmds=\"$reload_cmds\"
9864 1.1 christos func_len " $test_cmds"
9865 1.1 christos len0=$func_len_result
9866 1.1 christos len=$len0
9867 1.1 christos
9868 1.1 christos # Loop over the list of objects to be linked.
9869 1.1 christos for obj in $save_libobjs
9870 1.1 christos do
9871 1.1 christos func_len " $obj"
9872 1.1 christos func_arith $len + $func_len_result
9873 1.1 christos len=$func_arith_result
9874 1.1 christos if test -z "$objlist" ||
9875 1.1 christos test "$len" -lt "$max_cmd_len"; then
9876 1.1 christos func_append objlist " $obj"
9877 1.1 christos else
9878 1.1 christos # The command $test_cmds is almost too long, add a
9879 1.1 christos # command to the queue.
9880 1.1 christos if test 1 -eq "$k"; then
9881 1.1 christos # The first file doesn't have a previous command to add.
9882 1.1 christos reload_objs=$objlist
9883 1.1 christos eval concat_cmds=\"$reload_cmds\"
9884 1.1 christos else
9885 1.1 christos # All subsequent reloadable object files will link in
9886 1.1 christos # the last one created.
9887 1.1 christos reload_objs="$objlist $last_robj"
9888 1.1 christos eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9889 1.1 christos fi
9890 1.1 christos last_robj=$output_objdir/$output_la-$k.$objext
9891 1.1 christos func_arith $k + 1
9892 1.1 christos k=$func_arith_result
9893 1.1 christos output=$output_objdir/$output_la-$k.$objext
9894 1.1 christos objlist=" $obj"
9895 1.1 christos func_len " $last_robj"
9896 1.1 christos func_arith $len0 + $func_len_result
9897 1.1 christos len=$func_arith_result
9898 1.1 christos fi
9899 1.1 christos done
9900 1.1 christos # Handle the remaining objects by creating one last
9901 1.1 christos # reloadable object file. All subsequent reloadable object
9902 1.1 christos # files will link in the last one created.
9903 1.1 christos test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9904 1.1 christos reload_objs="$objlist $last_robj"
9905 1.1 christos eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9906 1.1 christos if test -n "$last_robj"; then
9907 1.1 christos eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9908 1.1 christos fi
9909 1.1 christos func_append delfiles " $output"
9910 1.1 christos
9911 1.1 christos else
9912 1.1 christos output=
9913 1.1 christos fi
9914 1.1 christos
9915 1.1 christos ${skipped_export-false} && {
9916 1.1 christos func_verbose "generating symbol list for '$libname.la'"
9917 1.1 christos export_symbols=$output_objdir/$libname.exp
9918 1.1 christos $opt_dry_run || $RM $export_symbols
9919 1.1 christos libobjs=$output
9920 1.1 christos # Append the command to create the export file.
9921 1.1 christos test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9922 1.1 christos eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9923 1.1 christos if test -n "$last_robj"; then
9924 1.1 christos eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9925 1.1 christos fi
9926 1.1 christos }
9927 1.1 christos
9928 1.1 christos test -n "$save_libobjs" &&
9929 1.1 christos func_verbose "creating a temporary reloadable object file: $output"
9930 1.1 christos
9931 1.1 christos # Loop through the commands generated above and execute them.
9932 1.1 christos save_ifs=$IFS; IFS='~'
9933 1.1 christos for cmd in $concat_cmds; do
9934 1.1 christos IFS=$save_ifs
9935 1.1 christos $opt_quiet || {
9936 1.1 christos func_quote_for_expand "$cmd"
9937 1.1 christos eval "func_echo $func_quote_for_expand_result"
9938 1.1 christos }
9939 1.1 christos $opt_dry_run || eval "$cmd" || {
9940 1.1 christos lt_exit=$?
9941 1.1 christos
9942 1.1 christos # Restore the uninstalled library and exit
9943 1.1 christos if test relink = "$opt_mode"; then
9944 1.1 christos ( cd "$output_objdir" && \
9945 1.1 christos $RM "${realname}T" && \
9946 1.1 christos $MV "${realname}U" "$realname" )
9947 1.1 christos fi
9948 1.1 christos
9949 1.1 christos exit $lt_exit
9950 1.1 christos }
9951 1.1 christos done
9952 1.1 christos IFS=$save_ifs
9953 1.1 christos
9954 1.1 christos if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9955 1.1 christos func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9956 1.1 christos func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9957 1.1 christos fi
9958 1.1 christos fi
9959 1.1 christos
9960 1.1 christos ${skipped_export-false} && {
9961 1.1 christos if test -n "$export_symbols" && test -n "$include_expsyms"; then
9962 1.1 christos tmp_export_symbols=$export_symbols
9963 1.1 christos test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9964 1.1 christos $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9965 1.1 christos fi
9966 1.1 christos
9967 1.1 christos if test -n "$orig_export_symbols"; then
9968 1.1 christos # The given exports_symbols file has to be filtered, so filter it.
9969 1.1 christos func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9970 1.1 christos # FIXME: $output_objdir/$libname.filter potentially contains lots of
9971 1.1 christos # 's' commands, which not all seds can handle. GNU sed should be fine
9972 1.1 christos # though. Also, the filter scales superlinearly with the number of
9973 1.1 christos # global variables. join(1) would be nice here, but unfortunately
9974 1.1 christos # isn't a blessed tool.
9975 1.1 christos $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9976 1.1 christos func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9977 1.1 christos export_symbols=$output_objdir/$libname.def
9978 1.1 christos $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9979 1.1 christos fi
9980 1.1 christos }
9981 1.1 christos
9982 1.1 christos libobjs=$output
9983 1.1 christos # Restore the value of output.
9984 1.1 christos output=$save_output
9985 1.1 christos
9986 1.1 christos if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9987 1.1 christos eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9988 1.1 christos test "X$libobjs" = "X " && libobjs=
9989 1.1 christos fi
9990 1.1 christos # Expand the library linking commands again to reset the
9991 1.1 christos # value of $libobjs for piecewise linking.
9992 1.1 christos
9993 1.1 christos # Do each of the archive commands.
9994 1.1 christos if test yes = "$module" && test -n "$module_cmds"; then
9995 1.1 christos if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9996 1.1 christos cmds=$module_expsym_cmds
9997 1.1 christos else
9998 1.1 christos cmds=$module_cmds
9999 1.1 christos fi
10000 1.1 christos else
10001 1.1 christos if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10002 1.1 christos cmds=$archive_expsym_cmds
10003 1.1 christos else
10004 1.1 christos cmds=$archive_cmds
10005 1.1 christos fi
10006 1.1 christos fi
10007 1.1 christos fi
10008 1.1 christos
10009 1.1 christos if test -n "$delfiles"; then
10010 1.1 christos # Append the command to remove temporary files to $cmds.
10011 1.1 christos eval cmds=\"\$cmds~\$RM $delfiles\"
10012 1.1 christos fi
10013 1.1 christos
10014 1.1 christos # Add any objects from preloaded convenience libraries
10015 1.1 christos if test -n "$dlprefiles"; then
10016 1.1 christos gentop=$output_objdir/${outputname}x
10017 1.1 christos func_append generated " $gentop"
10018 1.1 christos
10019 1.1 christos func_extract_archives $gentop $dlprefiles
10020 1.1 christos func_append libobjs " $func_extract_archives_result"
10021 1.1 christos test "X$libobjs" = "X " && libobjs=
10022 1.1 christos fi
10023 1.1 christos
10024 1.1 christos save_ifs=$IFS; IFS='~'
10025 1.1 christos for cmd in $cmds; do
10026 1.1 christos IFS=$sp$nl
10027 1.1 christos eval cmd=\"$cmd\"
10028 1.1 christos IFS=$save_ifs
10029 1.1 christos $opt_quiet || {
10030 1.1 christos func_quote_for_expand "$cmd"
10031 1.1 christos eval "func_echo $func_quote_for_expand_result"
10032 1.1 christos }
10033 1.1 christos $opt_dry_run || eval "$cmd" || {
10034 1.1 christos lt_exit=$?
10035 1.1 christos
10036 1.1 christos # Restore the uninstalled library and exit
10037 1.1 christos if test relink = "$opt_mode"; then
10038 1.1 christos ( cd "$output_objdir" && \
10039 1.1 christos $RM "${realname}T" && \
10040 1.1 christos $MV "${realname}U" "$realname" )
10041 1.1 christos fi
10042 1.1 christos
10043 1.1 christos exit $lt_exit
10044 1.1 christos }
10045 1.1 christos done
10046 1.1 christos IFS=$save_ifs
10047 1.1 christos
10048 1.1 christos # Restore the uninstalled library and exit
10049 1.1 christos if test relink = "$opt_mode"; then
10050 1.1 christos $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10051 1.1 christos
10052 1.1 christos if test -n "$convenience"; then
10053 1.1 christos if test -z "$whole_archive_flag_spec"; then
10054 1.1 christos func_show_eval '${RM}r "$gentop"'
10055 1.1 christos fi
10056 1.1 christos fi
10057 1.1 christos
10058 1.1 christos exit $EXIT_SUCCESS
10059 1.1 christos fi
10060 1.1 christos
10061 1.1 christos # Create links to the real library.
10062 1.1 christos for linkname in $linknames; do
10063 1.1 christos if test "$realname" != "$linkname"; then
10064 1.1 christos func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10065 1.1 christos fi
10066 1.1 christos done
10067 1.1 christos
10068 1.1 christos # If -module or -export-dynamic was specified, set the dlname.
10069 1.1 christos if test yes = "$module" || test yes = "$export_dynamic"; then
10070 1.1 christos # On all known operating systems, these are identical.
10071 1.1 christos dlname=$soname
10072 1.1 christos fi
10073 1.1 christos fi
10074 1.1 christos ;;
10075 1.1 christos
10076 1.1 christos obj)
10077 1.1 christos if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10078 1.1 christos func_warning "'-dlopen' is ignored for objects"
10079 1.1 christos fi
10080 1.1 christos
10081 1.1 christos case " $deplibs" in
10082 1.1 christos *\ -l* | *\ -L*)
10083 1.1 christos func_warning "'-l' and '-L' are ignored for objects" ;;
10084 1.1 christos esac
10085 1.1 christos
10086 1.1 christos test -n "$rpath" && \
10087 1.1 christos func_warning "'-rpath' is ignored for objects"
10088 1.1 christos
10089 1.1 christos test -n "$xrpath" && \
10090 1.1 christos func_warning "'-R' is ignored for objects"
10091 1.1 christos
10092 1.1 christos test -n "$vinfo" && \
10093 1.1 christos func_warning "'-version-info' is ignored for objects"
10094 1.1 christos
10095 1.1 christos test -n "$release" && \
10096 1.1 christos func_warning "'-release' is ignored for objects"
10097 1.1 christos
10098 1.1 christos case $output in
10099 1.1 christos *.lo)
10100 1.1 christos test -n "$objs$old_deplibs" && \
10101 1.1 christos func_fatal_error "cannot build library object '$output' from non-libtool objects"
10102 1.1 christos
10103 1.1 christos libobj=$output
10104 1.1 christos func_lo2o "$libobj"
10105 1.1 christos obj=$func_lo2o_result
10106 1.1 christos ;;
10107 1.1 christos *)
10108 1.1 christos libobj=
10109 1.1 christos obj=$output
10110 1.1 christos ;;
10111 1.1 christos esac
10112 1.1 christos
10113 1.1 christos # Delete the old objects.
10114 1.1 christos $opt_dry_run || $RM $obj $libobj
10115 1.1 christos
10116 1.1 christos # Objects from convenience libraries. This assumes
10117 1.1 christos # single-version convenience libraries. Whenever we create
10118 1.1 christos # different ones for PIC/non-PIC, this we'll have to duplicate
10119 1.1 christos # the extraction.
10120 1.1 christos reload_conv_objs=
10121 1.1 christos gentop=
10122 1.1 christos # if reload_cmds runs $LD directly, get rid of -Wl from
10123 1.1 christos # whole_archive_flag_spec and hope we can get by with turning comma
10124 1.1 christos # into space.
10125 1.1 christos case $reload_cmds in
10126 1.1 christos *\$LD[\ \$]*) wl= ;;
10127 1.1 christos esac
10128 1.1 christos if test -n "$convenience"; then
10129 1.1 christos if test -n "$whole_archive_flag_spec"; then
10130 1.1 christos eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10131 1.1 christos test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10132 1.1 christos reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10133 1.1 christos else
10134 1.1 christos gentop=$output_objdir/${obj}x
10135 1.1 christos func_append generated " $gentop"
10136 1.1 christos
10137 1.1 christos func_extract_archives $gentop $convenience
10138 1.1 christos reload_conv_objs="$reload_objs $func_extract_archives_result"
10139 1.1 christos fi
10140 1.1 christos fi
10141 1.1 christos
10142 1.1 christos # If we're not building shared, we need to use non_pic_objs
10143 1.1 christos test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10144 1.1 christos
10145 1.1 christos # Create the old-style object.
10146 1.1 christos reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10147 1.1 christos
10148 1.1 christos output=$obj
10149 1.1 christos func_execute_cmds "$reload_cmds" 'exit $?'
10150 1.1 christos
10151 1.1 christos # Exit if we aren't doing a library object file.
10152 1.1 christos if test -z "$libobj"; then
10153 1.1 christos if test -n "$gentop"; then
10154 1.1 christos func_show_eval '${RM}r "$gentop"'
10155 1.1 christos fi
10156 1.1 christos
10157 1.1 christos exit $EXIT_SUCCESS
10158 1.1 christos fi
10159 1.1 christos
10160 1.1 christos test yes = "$build_libtool_libs" || {
10161 1.1 christos if test -n "$gentop"; then
10162 1.1 christos func_show_eval '${RM}r "$gentop"'
10163 1.1 christos fi
10164 1.1 christos
10165 1.1 christos # Create an invalid libtool object if no PIC, so that we don't
10166 1.1 christos # accidentally link it into a program.
10167 1.1 christos # $show "echo timestamp > $libobj"
10168 1.1 christos # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10169 1.1 christos exit $EXIT_SUCCESS
10170 1.1 christos }
10171 1.1 christos
10172 1.1 christos if test -n "$pic_flag" || test default != "$pic_mode"; then
10173 1.1 christos # Only do commands if we really have different PIC objects.
10174 1.1 christos reload_objs="$libobjs $reload_conv_objs"
10175 1.1 christos output=$libobj
10176 1.1 christos func_execute_cmds "$reload_cmds" 'exit $?'
10177 1.1 christos fi
10178 1.1 christos
10179 1.1 christos if test -n "$gentop"; then
10180 1.1 christos func_show_eval '${RM}r "$gentop"'
10181 1.1 christos fi
10182 1.1 christos
10183 1.1 christos exit $EXIT_SUCCESS
10184 1.1 christos ;;
10185 1.1 christos
10186 1.1 christos prog)
10187 1.1 christos case $host in
10188 1.1 christos *cygwin*) func_stripname '' '.exe' "$output"
10189 1.1 christos output=$func_stripname_result.exe;;
10190 1.1 christos esac
10191 1.1 christos test -n "$vinfo" && \
10192 1.1 christos func_warning "'-version-info' is ignored for programs"
10193 1.1 christos
10194 1.1 christos test -n "$release" && \
10195 1.1 christos func_warning "'-release' is ignored for programs"
10196 1.1 christos
10197 1.1 christos $preload \
10198 1.1 christos && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10199 1.1 christos && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10200 1.1 christos
10201 1.1 christos case $host in
10202 1.1 christos *-*-rhapsody* | *-*-darwin1.[012])
10203 1.1 christos # On Rhapsody replace the C library is the System framework
10204 1.1 christos compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10205 1.1 christos finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10206 1.1 christos ;;
10207 1.1 christos esac
10208 1.1 christos
10209 1.1 christos case $host in
10210 1.1 christos *-*-darwin*)
10211 1.1 christos # Don't allow lazy linking, it breaks C++ global constructors
10212 1.1 christos # But is supposedly fixed on 10.4 or later (yay!).
10213 1.1 christos if test CXX = "$tagname"; then
10214 1.1 christos case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10215 1.1 christos 10.[0123])
10216 1.1 christos func_append compile_command " $wl-bind_at_load"
10217 1.1 christos func_append finalize_command " $wl-bind_at_load"
10218 1.1 christos ;;
10219 1.1 christos esac
10220 1.1 christos fi
10221 1.1 christos # Time to change all our "foo.ltframework" stuff back to "-framework foo"
10222 1.1 christos compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10223 1.1 christos finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10224 1.1 christos ;;
10225 1.1 christos esac
10226 1.1 christos
10227 1.1 christos
10228 1.1 christos # move library search paths that coincide with paths to not yet
10229 1.1 christos # installed libraries to the beginning of the library search list
10230 1.1 christos new_libs=
10231 1.1 christos for path in $notinst_path; do
10232 1.1 christos case " $new_libs " in
10233 1.1 christos *" -L$path/$objdir "*) ;;
10234 1.1 christos *)
10235 1.1 christos case " $compile_deplibs " in
10236 1.1 christos *" -L$path/$objdir "*)
10237 1.1 christos func_append new_libs " -L$path/$objdir" ;;
10238 1.1 christos esac
10239 1.1 christos ;;
10240 1.1 christos esac
10241 1.1 christos done
10242 1.1 christos for deplib in $compile_deplibs; do
10243 1.1 christos case $deplib in
10244 1.1 christos -L*)
10245 1.1 christos case " $new_libs " in
10246 1.1 christos *" $deplib "*) ;;
10247 1.1 christos *) func_append new_libs " $deplib" ;;
10248 1.1 christos esac
10249 1.1 christos ;;
10250 1.1 christos *) func_append new_libs " $deplib" ;;
10251 1.1 christos esac
10252 1.1 christos done
10253 1.1 christos compile_deplibs=$new_libs
10254 1.1 christos
10255 1.1 christos
10256 1.1 christos func_append compile_command " $compile_deplibs"
10257 1.1 christos func_append finalize_command " $finalize_deplibs"
10258 1.1 christos
10259 1.1 christos if test -n "$rpath$xrpath"; then
10260 1.1 christos # If the user specified any rpath flags, then add them.
10261 1.1 christos for libdir in $rpath $xrpath; do
10262 1.1 christos # This is the magic to use -rpath.
10263 1.1 christos case "$finalize_rpath " in
10264 1.1 christos *" $libdir "*) ;;
10265 1.1 christos *) func_append finalize_rpath " $libdir" ;;
10266 1.1 christos esac
10267 1.1 christos done
10268 1.1 christos fi
10269 1.1 christos
10270 1.1 christos # Now hardcode the library paths
10271 1.1 christos rpath=
10272 1.1 christos hardcode_libdirs=
10273 1.1 christos for libdir in $compile_rpath $finalize_rpath; do
10274 1.1 christos if test -n "$hardcode_libdir_flag_spec"; then
10275 1.1 christos if test -n "$hardcode_libdir_separator"; then
10276 1.1 christos if test -z "$hardcode_libdirs"; then
10277 1.1 christos hardcode_libdirs=$libdir
10278 1.1 christos else
10279 1.1 christos # Just accumulate the unique libdirs.
10280 1.1 christos case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10281 1.1 christos *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10282 1.1 christos ;;
10283 1.1 christos *)
10284 1.1 christos func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10285 1.1 christos ;;
10286 1.1 christos esac
10287 1.1 christos fi
10288 1.1 christos else
10289 1.1 christos eval flag=\"$hardcode_libdir_flag_spec\"
10290 1.1 christos func_append rpath " $flag"
10291 1.1 christos fi
10292 1.1 christos elif test -n "$runpath_var"; then
10293 1.1 christos case "$perm_rpath " in
10294 1.1 christos *" $libdir "*) ;;
10295 1.1 christos *) func_append perm_rpath " $libdir" ;;
10296 1.1 christos esac
10297 1.1 christos fi
10298 1.1 christos case $host in
10299 1.1 christos *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10300 1.1 christos testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10301 1.1 christos case :$dllsearchpath: in
10302 1.1 christos *":$libdir:"*) ;;
10303 1.1 christos ::) dllsearchpath=$libdir;;
10304 1.1 christos *) func_append dllsearchpath ":$libdir";;
10305 1.1 christos esac
10306 1.1 christos case :$dllsearchpath: in
10307 1.1 christos *":$testbindir:"*) ;;
10308 1.1 christos ::) dllsearchpath=$testbindir;;
10309 1.1 christos *) func_append dllsearchpath ":$testbindir";;
10310 1.1 christos esac
10311 1.1 christos ;;
10312 1.1 christos esac
10313 1.1 christos done
10314 1.1 christos # Substitute the hardcoded libdirs into the rpath.
10315 1.1 christos if test -n "$hardcode_libdir_separator" &&
10316 1.1 christos test -n "$hardcode_libdirs"; then
10317 1.1 christos libdir=$hardcode_libdirs
10318 1.1 christos eval rpath=\" $hardcode_libdir_flag_spec\"
10319 1.1 christos fi
10320 1.1 christos compile_rpath=$rpath
10321 1.1 christos
10322 1.1 christos rpath=
10323 1.1 christos hardcode_libdirs=
10324 1.1 christos for libdir in $finalize_rpath; do
10325 1.1 christos if test -n "$hardcode_libdir_flag_spec"; then
10326 1.1 christos if test -n "$hardcode_libdir_separator"; then
10327 1.1 christos if test -z "$hardcode_libdirs"; then
10328 1.1 christos hardcode_libdirs=$libdir
10329 1.1 christos else
10330 1.1 christos # Just accumulate the unique libdirs.
10331 1.1 christos case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10332 1.1 christos *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10333 1.1 christos ;;
10334 1.1 christos *)
10335 1.1 christos func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10336 1.1 christos ;;
10337 1.1 christos esac
10338 1.1 christos fi
10339 1.1 christos else
10340 1.1 christos eval flag=\"$hardcode_libdir_flag_spec\"
10341 1.1 christos func_append rpath " $flag"
10342 1.1 christos fi
10343 1.1 christos elif test -n "$runpath_var"; then
10344 1.1 christos case "$finalize_perm_rpath " in
10345 1.1 christos *" $libdir "*) ;;
10346 1.1 christos *) func_append finalize_perm_rpath " $libdir" ;;
10347 1.1 christos esac
10348 1.1 christos fi
10349 1.1 christos done
10350 1.1 christos # Substitute the hardcoded libdirs into the rpath.
10351 1.1 christos if test -n "$hardcode_libdir_separator" &&
10352 1.1 christos test -n "$hardcode_libdirs"; then
10353 1.1 christos libdir=$hardcode_libdirs
10354 1.1 christos eval rpath=\" $hardcode_libdir_flag_spec\"
10355 1.1 christos fi
10356 1.1 christos finalize_rpath=$rpath
10357 1.1 christos
10358 1.1 christos if test -n "$libobjs" && test yes = "$build_old_libs"; then
10359 1.1 christos # Transform all the library objects into standard objects.
10360 1.1 christos compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10361 1.1 christos finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10362 1.1 christos fi
10363 1.1 christos
10364 1.1 christos func_generate_dlsyms "$outputname" "@PROGRAM@" false
10365 1.1 christos
10366 1.1 christos # template prelinking step
10367 1.1 christos if test -n "$prelink_cmds"; then
10368 1.1 christos func_execute_cmds "$prelink_cmds" 'exit $?'
10369 1.1 christos fi
10370 1.1 christos
10371 1.1 christos wrappers_required=:
10372 1.1 christos case $host in
10373 1.1 christos *cegcc* | *mingw32ce*)
10374 1.1 christos # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10375 1.1 christos wrappers_required=false
10376 1.1 christos ;;
10377 1.1 christos *cygwin* | *mingw* )
10378 1.1 christos test yes = "$build_libtool_libs" || wrappers_required=false
10379 1.1 christos ;;
10380 1.1 christos *)
10381 1.1 christos if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10382 1.1 christos wrappers_required=false
10383 1.1 christos fi
10384 1.1 christos ;;
10385 1.1 christos esac
10386 1.1 christos $wrappers_required || {
10387 1.1 christos # Replace the output file specification.
10388 1.1 christos compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10389 1.1 christos link_command=$compile_command$compile_rpath
10390 1.1 christos
10391 1.1 christos # We have no uninstalled library dependencies, so finalize right now.
10392 1.1 christos exit_status=0
10393 1.1 christos func_show_eval "$link_command" 'exit_status=$?'
10394 1.1 christos
10395 1.1 christos if test -n "$postlink_cmds"; then
10396 1.1 christos func_to_tool_file "$output"
10397 1.1 christos 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 christos func_execute_cmds "$postlink_cmds" 'exit $?'
10399 1.1 christos fi
10400 1.1 christos
10401 1.1 christos # Delete the generated files.
10402 1.1 christos if test -f "$output_objdir/${outputname}S.$objext"; then
10403 1.1 christos func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10404 1.1 christos fi
10405 1.1 christos
10406 1.1 christos exit $exit_status
10407 1.1 christos }
10408 1.1 christos
10409 1.1 christos if test -n "$compile_shlibpath$finalize_shlibpath"; then
10410 1.1 christos compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10411 1.1 christos fi
10412 1.1 christos if test -n "$finalize_shlibpath"; then
10413 1.1 christos finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10414 1.1 christos fi
10415 1.1 christos
10416 1.1 christos compile_var=
10417 1.1 christos finalize_var=
10418 1.1 christos if test -n "$runpath_var"; then
10419 1.1 christos if test -n "$perm_rpath"; then
10420 1.1 christos # We should set the runpath_var.
10421 1.1 christos rpath=
10422 1.1 christos for dir in $perm_rpath; do
10423 1.1 christos func_append rpath "$dir:"
10424 1.1 christos done
10425 1.1 christos compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10426 1.1 christos fi
10427 1.1 christos if test -n "$finalize_perm_rpath"; then
10428 1.1 christos # We should set the runpath_var.
10429 1.1 christos rpath=
10430 1.1 christos for dir in $finalize_perm_rpath; do
10431 1.1 christos func_append rpath "$dir:"
10432 1.1 christos done
10433 1.1 christos finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10434 1.1 christos fi
10435 1.1 christos fi
10436 1.1 christos
10437 1.1 christos if test yes = "$no_install"; then
10438 1.1 christos # We don't need to create a wrapper script.
10439 1.1 christos link_command=$compile_var$compile_command$compile_rpath
10440 1.1 christos # Replace the output file specification.
10441 1.1 christos link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10442 1.1 christos # Delete the old output file.
10443 1.1 christos $opt_dry_run || $RM $output
10444 1.1 christos # Link the executable and exit
10445 1.1 christos func_show_eval "$link_command" 'exit $?'
10446 1.1 christos
10447 1.1 christos if test -n "$postlink_cmds"; then
10448 1.1 christos func_to_tool_file "$output"
10449 1.1 christos 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 christos func_execute_cmds "$postlink_cmds" 'exit $?'
10451 1.1 christos fi
10452 1.1 christos
10453 1.1 christos exit $EXIT_SUCCESS
10454 1.1 christos fi
10455 1.1 christos
10456 1.1 christos case $hardcode_action,$fast_install in
10457 1.1 christos relink,*)
10458 1.1 christos # Fast installation is not supported
10459 1.1 christos link_command=$compile_var$compile_command$compile_rpath
10460 1.1 christos relink_command=$finalize_var$finalize_command$finalize_rpath
10461 1.1 christos
10462 1.1 christos func_warning "this platform does not like uninstalled shared libraries"
10463 1.1 christos func_warning "'$output' will be relinked during installation"
10464 1.1 christos ;;
10465 1.1 christos *,yes)
10466 1.1 christos link_command=$finalize_var$compile_command$finalize_rpath
10467 1.1 christos relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10468 1.1 christos ;;
10469 1.1 christos *,no)
10470 1.1 christos link_command=$compile_var$compile_command$compile_rpath
10471 1.1 christos relink_command=$finalize_var$finalize_command$finalize_rpath
10472 1.1 christos ;;
10473 1.1 christos *,needless)
10474 1.1 christos link_command=$finalize_var$compile_command$finalize_rpath
10475 1.1 christos relink_command=
10476 1.1 christos ;;
10477 1.1 christos esac
10478 1.1 christos
10479 1.1 christos # Replace the output file specification.
10480 1.1 christos link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10481 1.1 christos
10482 1.1 christos # Delete the old output files.
10483 1.1 christos $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10484 1.1 christos
10485 1.1 christos func_show_eval "$link_command" 'exit $?'
10486 1.1 christos
10487 1.1 christos if test -n "$postlink_cmds"; then
10488 1.1 christos func_to_tool_file "$output_objdir/$outputname"
10489 1.1 christos 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 christos func_execute_cmds "$postlink_cmds" 'exit $?'
10491 1.1 christos fi
10492 1.1 christos
10493 1.1 christos # Now create the wrapper script.
10494 1.1 christos func_verbose "creating $output"
10495 1.1 christos
10496 1.1 christos # Quote the relink command for shipping.
10497 1.1 christos if test -n "$relink_command"; then
10498 1.1 christos # Preserve any variables that may affect compiler behavior
10499 1.1 christos for var in $variables_saved_for_relink; do
10500 1.1 christos if eval test -z \"\${$var+set}\"; then
10501 1.1 christos relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10502 1.1 christos elif eval var_value=\$$var; test -z "$var_value"; then
10503 1.1 christos relink_command="$var=; export $var; $relink_command"
10504 1.1 christos else
10505 1.1 christos func_quote_for_eval "$var_value"
10506 1.1 christos relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10507 1.1 christos fi
10508 1.1 christos done
10509 1.1 christos relink_command="(cd `pwd`; $relink_command)"
10510 1.1 christos relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10511 1.1 christos fi
10512 1.1 christos
10513 1.1 christos # Only actually do things if not in dry run mode.
10514 1.1 christos $opt_dry_run || {
10515 1.1 christos # win32 will think the script is a binary if it has
10516 1.1 christos # a .exe suffix, so we strip it off here.
10517 1.1 christos case $output in
10518 1.1 christos *.exe) func_stripname '' '.exe' "$output"
10519 1.1 christos output=$func_stripname_result ;;
10520 1.1 christos esac
10521 1.1 christos # test for cygwin because mv fails w/o .exe extensions
10522 1.1 christos case $host in
10523 1.1 christos *cygwin*)
10524 1.1 christos exeext=.exe
10525 1.1 christos func_stripname '' '.exe' "$outputname"
10526 1.1 christos outputname=$func_stripname_result ;;
10527 1.1 christos *) exeext= ;;
10528 1.1 christos esac
10529 1.1 christos case $host in
10530 1.1 christos *cygwin* | *mingw* )
10531 1.1 christos func_dirname_and_basename "$output" "" "."
10532 1.1 christos output_name=$func_basename_result
10533 1.1 christos output_path=$func_dirname_result
10534 1.1 christos cwrappersource=$output_path/$objdir/lt-$output_name.c
10535 1.1 christos cwrapper=$output_path/$output_name.exe
10536 1.1 christos $RM $cwrappersource $cwrapper
10537 1.1 christos trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10538 1.1 christos
10539 1.1 christos func_emit_cwrapperexe_src > $cwrappersource
10540 1.1 christos
10541 1.1 christos # The wrapper executable is built using the $host compiler,
10542 1.1 christos # because it contains $host paths and files. If cross-
10543 1.1 christos # compiling, it, like the target executable, must be
10544 1.1 christos # executed on the $host or under an emulation environment.
10545 1.1 christos $opt_dry_run || {
10546 1.1 christos $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10547 1.1 christos $STRIP $cwrapper
10548 1.1 christos }
10549 1.1 christos
10550 1.1 christos # Now, create the wrapper script for func_source use:
10551 1.1 christos func_ltwrapper_scriptname $cwrapper
10552 1.1 christos $RM $func_ltwrapper_scriptname_result
10553 1.1 christos trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10554 1.1 christos $opt_dry_run || {
10555 1.1 christos # note: this script will not be executed, so do not chmod.
10556 1.1 christos if test "x$build" = "x$host"; then
10557 1.1 christos $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10558 1.1 christos else
10559 1.1 christos func_emit_wrapper no > $func_ltwrapper_scriptname_result
10560 1.1 christos fi
10561 1.1 christos }
10562 1.1 christos ;;
10563 1.1 christos * )
10564 1.1 christos $RM $output
10565 1.1 christos trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10566 1.1 christos
10567 1.1 christos func_emit_wrapper no > $output
10568 1.1 christos chmod +x $output
10569 1.1 christos ;;
10570 1.1 christos esac
10571 1.1 christos }
10572 1.1 christos exit $EXIT_SUCCESS
10573 1.1 christos ;;
10574 1.1 christos esac
10575 1.1 christos
10576 1.1 christos # See if we need to build an old-fashioned archive.
10577 1.1 christos for oldlib in $oldlibs; do
10578 1.1 christos
10579 1.1 christos case $build_libtool_libs in
10580 1.1 christos convenience)
10581 1.1 christos oldobjs="$libobjs_save $symfileobj"
10582 1.1 christos addlibs=$convenience
10583 1.1 christos build_libtool_libs=no
10584 1.1 christos ;;
10585 1.1 christos module)
10586 1.1 christos oldobjs=$libobjs_save
10587 1.1 christos addlibs=$old_convenience
10588 1.1 christos build_libtool_libs=no
10589 1.1 christos ;;
10590 1.1 christos *)
10591 1.1 christos oldobjs="$old_deplibs $non_pic_objects"
10592 1.1 christos $preload && test -f "$symfileobj" \
10593 1.1 christos && func_append oldobjs " $symfileobj"
10594 1.1 christos addlibs=$old_convenience
10595 1.1 christos ;;
10596 1.1 christos esac
10597 1.1 christos
10598 1.1 christos if test -n "$addlibs"; then
10599 1.1 christos gentop=$output_objdir/${outputname}x
10600 1.1 christos func_append generated " $gentop"
10601 1.1 christos
10602 1.1 christos func_extract_archives $gentop $addlibs
10603 1.1 christos func_append oldobjs " $func_extract_archives_result"
10604 1.1 christos fi
10605 1.1 christos
10606 1.1 christos # Do each command in the archive commands.
10607 1.1 christos if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10608 1.1 christos cmds=$old_archive_from_new_cmds
10609 1.1 christos else
10610 1.1 christos
10611 1.1 christos # Add any objects from preloaded convenience libraries
10612 1.1 christos if test -n "$dlprefiles"; then
10613 1.1 christos gentop=$output_objdir/${outputname}x
10614 1.1 christos func_append generated " $gentop"
10615 1.1 christos
10616 1.1 christos func_extract_archives $gentop $dlprefiles
10617 1.1 christos func_append oldobjs " $func_extract_archives_result"
10618 1.1 christos fi
10619 1.1 christos
10620 1.1 christos # POSIX demands no paths to be encoded in archives. We have
10621 1.1 christos # to avoid creating archives with duplicate basenames if we
10622 1.1 christos # might have to extract them afterwards, e.g., when creating a
10623 1.1 christos # static archive out of a convenience library, or when linking
10624 1.1 christos # the entirety of a libtool archive into another (currently
10625 1.1 christos # not supported by libtool).
10626 1.1 christos if (for obj in $oldobjs
10627 1.1 christos do
10628 1.1 christos func_basename "$obj"
10629 1.1 christos $ECHO "$func_basename_result"
10630 1.1 christos done | sort | sort -uc >/dev/null 2>&1); then
10631 1.1 christos :
10632 1.1 christos else
10633 1.1 christos echo "copying selected object files to avoid basename conflicts..."
10634 1.1 christos gentop=$output_objdir/${outputname}x
10635 1.1 christos func_append generated " $gentop"
10636 1.1 christos func_mkdir_p "$gentop"
10637 1.1 christos save_oldobjs=$oldobjs
10638 1.1 christos oldobjs=
10639 1.1 christos counter=1
10640 1.1 christos for obj in $save_oldobjs
10641 1.1 christos do
10642 1.1 christos func_basename "$obj"
10643 1.1 christos objbase=$func_basename_result
10644 1.1 christos case " $oldobjs " in
10645 1.1 christos " ") oldobjs=$obj ;;
10646 1.1 christos *[\ /]"$objbase "*)
10647 1.1 christos while :; do
10648 1.1 christos # Make sure we don't pick an alternate name that also
10649 1.1 christos # overlaps.
10650 1.1 christos newobj=lt$counter-$objbase
10651 1.1 christos func_arith $counter + 1
10652 1.1 christos counter=$func_arith_result
10653 1.1 christos case " $oldobjs " in
10654 1.1 christos *[\ /]"$newobj "*) ;;
10655 1.1 christos *) if test ! -f "$gentop/$newobj"; then break; fi ;;
10656 1.1 christos esac
10657 1.1 christos done
10658 1.1 christos func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10659 1.1 christos func_append oldobjs " $gentop/$newobj"
10660 1.1 christos ;;
10661 1.1 christos *) func_append oldobjs " $obj" ;;
10662 1.1 christos esac
10663 1.1 christos done
10664 1.1 christos fi
10665 1.1 christos func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10666 1.1 christos tool_oldlib=$func_to_tool_file_result
10667 1.1 christos eval cmds=\"$old_archive_cmds\"
10668 1.1 christos
10669 1.1 christos func_len " $cmds"
10670 1.1 christos len=$func_len_result
10671 1.1 christos if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10672 1.1 christos cmds=$old_archive_cmds
10673 1.1 christos elif test -n "$archiver_list_spec"; then
10674 1.1 christos func_verbose "using command file archive linking..."
10675 1.1 christos for obj in $oldobjs
10676 1.1 christos do
10677 1.1 christos func_to_tool_file "$obj"
10678 1.1 christos $ECHO "$func_to_tool_file_result"
10679 1.1 christos done > $output_objdir/$libname.libcmd
10680 1.1 christos func_to_tool_file "$output_objdir/$libname.libcmd"
10681 1.1 christos oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10682 1.1 christos cmds=$old_archive_cmds
10683 1.1 christos else
10684 1.1 christos # the command line is too long to link in one step, link in parts
10685 1.1 christos func_verbose "using piecewise archive linking..."
10686 1.1 christos save_RANLIB=$RANLIB
10687 1.1 christos RANLIB=:
10688 1.1 christos objlist=
10689 1.1 christos concat_cmds=
10690 1.1 christos save_oldobjs=$oldobjs
10691 1.1 christos oldobjs=
10692 1.1 christos # Is there a better way of finding the last object in the list?
10693 1.1 christos for obj in $save_oldobjs
10694 1.1 christos do
10695 1.1 christos last_oldobj=$obj
10696 1.1 christos done
10697 1.1 christos eval test_cmds=\"$old_archive_cmds\"
10698 1.1 christos func_len " $test_cmds"
10699 1.1 christos len0=$func_len_result
10700 1.1 christos len=$len0
10701 1.1 christos for obj in $save_oldobjs
10702 1.1 christos do
10703 1.1 christos func_len " $obj"
10704 1.1 christos func_arith $len + $func_len_result
10705 1.1 christos len=$func_arith_result
10706 1.1 christos func_append objlist " $obj"
10707 1.1 christos if test "$len" -lt "$max_cmd_len"; then
10708 1.1 christos :
10709 1.1 christos else
10710 1.1 christos # the above command should be used before it gets too long
10711 1.1 christos oldobjs=$objlist
10712 1.1 christos if test "$obj" = "$last_oldobj"; then
10713 1.1 christos RANLIB=$save_RANLIB
10714 1.1 christos fi
10715 1.1 christos test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10716 1.1 christos eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10717 1.1 christos objlist=
10718 1.1 christos len=$len0
10719 1.1 christos fi
10720 1.1 christos done
10721 1.1 christos RANLIB=$save_RANLIB
10722 1.1 christos oldobjs=$objlist
10723 1.1 christos if test -z "$oldobjs"; then
10724 1.1 christos eval cmds=\"\$concat_cmds\"
10725 1.1 christos else
10726 1.1 christos eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10727 1.1 christos fi
10728 1.1 christos fi
10729 1.1 christos fi
10730 1.1 christos func_execute_cmds "$cmds" 'exit $?'
10731 1.1 christos done
10732 1.1 christos
10733 1.1 christos test -n "$generated" && \
10734 1.1 christos func_show_eval "${RM}r$generated"
10735 1.1 christos
10736 1.1 christos # Now create the libtool archive.
10737 1.1 christos case $output in
10738 1.1 christos *.la)
10739 1.1 christos old_library=
10740 1.1 christos test yes = "$build_old_libs" && old_library=$libname.$libext
10741 1.1 christos func_verbose "creating $output"
10742 1.1 christos
10743 1.1 christos # Preserve any variables that may affect compiler behavior
10744 1.1 christos for var in $variables_saved_for_relink; do
10745 1.1 christos if eval test -z \"\${$var+set}\"; then
10746 1.1 christos relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10747 1.1 christos elif eval var_value=\$$var; test -z "$var_value"; then
10748 1.1 christos relink_command="$var=; export $var; $relink_command"
10749 1.1 christos else
10750 1.1 christos func_quote_for_eval "$var_value"
10751 1.1 christos relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10752 1.1 christos fi
10753 1.1 christos done
10754 1.1 christos # Quote the link command for shipping.
10755 1.1 christos relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10756 1.1 christos relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10757 1.1 christos if test yes = "$hardcode_automatic"; then
10758 1.1 christos relink_command=
10759 1.1 christos fi
10760 1.1 christos
10761 1.1 christos # Only create the output if not a dry run.
10762 1.1 christos $opt_dry_run || {
10763 1.1 christos for installed in no yes; do
10764 1.1 christos if test yes = "$installed"; then
10765 1.1 christos if test -z "$install_libdir"; then
10766 1.1 christos break
10767 1.1 christos fi
10768 1.1 christos output=$output_objdir/${outputname}i
10769 1.1 christos # Replace all uninstalled libtool libraries with the installed ones
10770 1.1 christos newdependency_libs=
10771 1.1 christos for deplib in $dependency_libs; do
10772 1.1 christos case $deplib in
10773 1.1 christos *.la)
10774 1.1 christos func_basename "$deplib"
10775 1.1 christos name=$func_basename_result
10776 1.1 christos func_resolve_sysroot "$deplib"
10777 1.1 christos eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10778 1.1 christos test -z "$libdir" && \
10779 1.1 christos func_fatal_error "'$deplib' is not a valid libtool archive"
10780 1.1 christos func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10781 1.1 christos ;;
10782 1.1 christos -L*)
10783 1.1 christos func_stripname -L '' "$deplib"
10784 1.1 christos func_replace_sysroot "$func_stripname_result"
10785 1.1 christos func_append newdependency_libs " -L$func_replace_sysroot_result"
10786 1.1 christos ;;
10787 1.1 christos -R*)
10788 1.1 christos func_stripname -R '' "$deplib"
10789 1.1 christos func_replace_sysroot "$func_stripname_result"
10790 1.1 christos func_append newdependency_libs " -R$func_replace_sysroot_result"
10791 1.1 christos ;;
10792 1.1 christos *) func_append newdependency_libs " $deplib" ;;
10793 1.1 christos esac
10794 1.1 christos done
10795 1.1 christos dependency_libs=$newdependency_libs
10796 1.1 christos newdlfiles=
10797 1.1 christos
10798 1.1 christos for lib in $dlfiles; do
10799 1.1 christos case $lib in
10800 1.1 christos *.la)
10801 1.1 christos func_basename "$lib"
10802 1.1 christos name=$func_basename_result
10803 1.1 christos eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10804 1.1 christos test -z "$libdir" && \
10805 1.1 christos func_fatal_error "'$lib' is not a valid libtool archive"
10806 1.1 christos func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10807 1.1 christos ;;
10808 1.1 christos *) func_append newdlfiles " $lib" ;;
10809 1.1 christos esac
10810 1.1 christos done
10811 1.1 christos dlfiles=$newdlfiles
10812 1.1 christos newdlprefiles=
10813 1.1 christos for lib in $dlprefiles; do
10814 1.1 christos case $lib in
10815 1.1 christos *.la)
10816 1.1 christos # Only pass preopened files to the pseudo-archive (for
10817 1.1 christos # eventual linking with the app. that links it) if we
10818 1.1 christos # didn't already link the preopened objects directly into
10819 1.1 christos # the library:
10820 1.1 christos func_basename "$lib"
10821 1.1 christos name=$func_basename_result
10822 1.1 christos eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10823 1.1 christos test -z "$libdir" && \
10824 1.1 christos func_fatal_error "'$lib' is not a valid libtool archive"
10825 1.1 christos func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10826 1.1 christos ;;
10827 1.1 christos esac
10828 1.1 christos done
10829 1.1 christos dlprefiles=$newdlprefiles
10830 1.1 christos else
10831 1.1 christos newdlfiles=
10832 1.1 christos for lib in $dlfiles; do
10833 1.1 christos case $lib in
10834 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10835 1.1 christos *) abs=`pwd`"/$lib" ;;
10836 1.1 christos esac
10837 1.1 christos func_append newdlfiles " $abs"
10838 1.1 christos done
10839 1.1 christos dlfiles=$newdlfiles
10840 1.1 christos newdlprefiles=
10841 1.1 christos for lib in $dlprefiles; do
10842 1.1 christos case $lib in
10843 1.1 christos [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10844 1.1 christos *) abs=`pwd`"/$lib" ;;
10845 1.1 christos esac
10846 1.1 christos func_append newdlprefiles " $abs"
10847 1.1 christos done
10848 1.1 christos dlprefiles=$newdlprefiles
10849 1.1 christos fi
10850 1.1 christos $RM $output
10851 1.1 christos # place dlname in correct position for cygwin
10852 1.1 christos # In fact, it would be nice if we could use this code for all target
10853 1.1 christos # systems that can't hard-code library paths into their executables
10854 1.1 christos # and that have no shared library path variable independent of PATH,
10855 1.1 christos # but it turns out we can't easily determine that from inspecting
10856 1.1 christos # libtool variables, so we have to hard-code the OSs to which it
10857 1.1 christos # applies here; at the moment, that means platforms that use the PE
10858 1.1 christos # object format with DLL files. See the long comment at the top of
10859 1.1 christos # tests/bindir.at for full details.
10860 1.1 christos tdlname=$dlname
10861 1.1 christos case $host,$output,$installed,$module,$dlname in
10862 1.1 christos *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10863 1.1 christos # If a -bindir argument was supplied, place the dll there.
10864 1.1 christos if test -n "$bindir"; then
10865 1.1 christos func_relative_path "$install_libdir" "$bindir"
10866 1.1 christos tdlname=$func_relative_path_result/$dlname
10867 1.1 christos else
10868 1.1 christos # Otherwise fall back on heuristic.
10869 1.1 christos tdlname=../bin/$dlname
10870 1.1 christos fi
10871 1.1 christos ;;
10872 1.1 christos esac
10873 1.1 christos $ECHO > $output "\
10874 1.1 christos # $outputname - a libtool library file
10875 1.1 christos # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10876 1.1 christos #
10877 1.1 christos # Please DO NOT delete this file!
10878 1.1 christos # It is necessary for linking the library.
10879 1.1 christos
10880 1.1 christos # The name that we can dlopen(3).
10881 1.1 christos dlname='$tdlname'
10882 1.1 christos
10883 1.1 christos # Names of this library.
10884 1.1 christos library_names='$library_names'
10885 1.1 christos
10886 1.1 christos # The name of the static archive.
10887 1.1 christos old_library='$old_library'
10888 1.1 christos
10889 1.1 christos # Linker flags that cannot go in dependency_libs.
10890 1.1 christos inherited_linker_flags='$new_inherited_linker_flags'
10891 1.1 christos
10892 1.1 christos # Libraries that this one depends upon.
10893 1.1 christos dependency_libs='$dependency_libs'
10894 1.1 christos
10895 1.1 christos # Names of additional weak libraries provided by this library
10896 1.1 christos weak_library_names='$weak_libs'
10897 1.1 christos
10898 1.1 christos # Version information for $libname.
10899 1.1 christos current=$current
10900 1.1 christos age=$age
10901 1.1 christos revision=$revision
10902 1.1 christos
10903 1.1 christos # Is this an already installed library?
10904 1.1 christos installed=$installed
10905 1.1 christos
10906 1.1 christos # Should we warn about portability when linking against -modules?
10907 1.1 christos shouldnotlink=$module
10908 1.1 christos
10909 1.1 christos # Files to dlopen/dlpreopen
10910 1.1 christos dlopen='$dlfiles'
10911 1.1 christos dlpreopen='$dlprefiles'
10912 1.1 christos
10913 1.1 christos # Directory that this library needs to be installed in:
10914 1.1 christos libdir='$install_libdir'"
10915 1.1 christos if test no,yes = "$installed,$need_relink"; then
10916 1.1 christos $ECHO >> $output "\
10917 1.1 christos relink_command=\"$relink_command\""
10918 1.1 christos fi
10919 1.1 christos done
10920 1.1 christos }
10921 1.1 christos
10922 1.1 christos # Do a symbolic link so that the libtool archive can be found in
10923 1.1 christos # LD_LIBRARY_PATH before the program is installed.
10924 1.1 christos func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10925 1.1 christos ;;
10926 1.1 christos esac
10927 1.1 christos exit $EXIT_SUCCESS
10928 1.1 christos }
10929 1.1 christos
10930 1.1 christos if test link = "$opt_mode" || test relink = "$opt_mode"; then
10931 1.1 christos func_mode_link ${1+"$@"}
10932 1.1 christos fi
10933 1.1 christos
10934 1.1 christos
10935 1.1 christos # func_mode_uninstall arg...
10936 1.1 christos func_mode_uninstall ()
10937 1.1 christos {
10938 1.1 christos $debug_cmd
10939 1.1 christos
10940 1.1 christos RM=$nonopt
10941 1.1 christos files=
10942 1.1 christos rmforce=false
10943 1.1 christos exit_status=0
10944 1.1 christos
10945 1.1 christos # This variable tells wrapper scripts just to set variables rather
10946 1.1 christos # than running their programs.
10947 1.1 christos libtool_install_magic=$magic
10948 1.1 christos
10949 1.1 christos for arg
10950 1.1 christos do
10951 1.1 christos case $arg in
10952 1.1 christos -f) func_append RM " $arg"; rmforce=: ;;
10953 1.1 christos -*) func_append RM " $arg" ;;
10954 1.1 christos *) func_append files " $arg" ;;
10955 1.1 christos esac
10956 1.1 christos done
10957 1.1 christos
10958 1.1 christos test -z "$RM" && \
10959 1.1 christos func_fatal_help "you must specify an RM program"
10960 1.1 christos
10961 1.1 christos rmdirs=
10962 1.1 christos
10963 1.1 christos for file in $files; do
10964 1.1 christos func_dirname "$file" "" "."
10965 1.1 christos dir=$func_dirname_result
10966 1.1 christos if test . = "$dir"; then
10967 1.1 christos odir=$objdir
10968 1.1 christos else
10969 1.1 christos odir=$dir/$objdir
10970 1.1 christos fi
10971 1.1 christos func_basename "$file"
10972 1.1 christos name=$func_basename_result
10973 1.1 christos test uninstall = "$opt_mode" && odir=$dir
10974 1.1 christos
10975 1.1 christos # Remember odir for removal later, being careful to avoid duplicates
10976 1.1 christos if test clean = "$opt_mode"; then
10977 1.1 christos case " $rmdirs " in
10978 1.1 christos *" $odir "*) ;;
10979 1.1 christos *) func_append rmdirs " $odir" ;;
10980 1.1 christos esac
10981 1.1 christos fi
10982 1.1 christos
10983 1.1 christos # Don't error if the file doesn't exist and rm -f was used.
10984 1.1 christos if { test -L "$file"; } >/dev/null 2>&1 ||
10985 1.1 christos { test -h "$file"; } >/dev/null 2>&1 ||
10986 1.1 christos test -f "$file"; then
10987 1.1 christos :
10988 1.1 christos elif test -d "$file"; then
10989 1.1 christos exit_status=1
10990 1.1 christos continue
10991 1.1 christos elif $rmforce; then
10992 1.1 christos continue
10993 1.1 christos fi
10994 1.1 christos
10995 1.1 christos rmfiles=$file
10996 1.1 christos
10997 1.1 christos case $name in
10998 1.1 christos *.la)
10999 1.1 christos # Possibly a libtool archive, so verify it.
11000 1.1 christos if func_lalib_p "$file"; then
11001 1.1 christos func_source $dir/$name
11002 1.1 christos
11003 1.1 christos # Delete the libtool libraries and symlinks.
11004 1.1 christos for n in $library_names; do
11005 1.1 christos func_append rmfiles " $odir/$n"
11006 1.1 christos done
11007 1.1 christos test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11008 1.1 christos
11009 1.1 christos case $opt_mode in
11010 1.1 christos clean)
11011 1.1 christos case " $library_names " in
11012 1.1 christos *" $dlname "*) ;;
11013 1.1 christos *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11014 1.1 christos esac
11015 1.1 christos test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11016 1.1 christos ;;
11017 1.1 christos uninstall)
11018 1.1 christos if test -n "$library_names"; then
11019 1.1 christos # Do each command in the postuninstall commands.
11020 1.1 christos func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11021 1.1 christos fi
11022 1.1 christos
11023 1.1 christos if test -n "$old_library"; then
11024 1.1 christos # Do each command in the old_postuninstall commands.
11025 1.1 christos func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11026 1.1 christos fi
11027 1.1 christos # FIXME: should reinstall the best remaining shared library.
11028 1.1 christos ;;
11029 1.1 christos esac
11030 1.1 christos fi
11031 1.1 christos ;;
11032 1.1 christos
11033 1.1 christos *.lo)
11034 1.1 christos # Possibly a libtool object, so verify it.
11035 1.1 christos if func_lalib_p "$file"; then
11036 1.1 christos
11037 1.1 christos # Read the .lo file
11038 1.1 christos func_source $dir/$name
11039 1.1 christos
11040 1.1 christos # Add PIC object to the list of files to remove.
11041 1.1 christos if test -n "$pic_object" && test none != "$pic_object"; then
11042 1.1 christos func_append rmfiles " $dir/$pic_object"
11043 1.1 christos fi
11044 1.1 christos
11045 1.1 christos # Add non-PIC object to the list of files to remove.
11046 1.1 christos if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11047 1.1 christos func_append rmfiles " $dir/$non_pic_object"
11048 1.1 christos fi
11049 1.1 christos fi
11050 1.1 christos ;;
11051 1.1 christos
11052 1.1 christos *)
11053 1.1 christos if test clean = "$opt_mode"; then
11054 1.1 christos noexename=$name
11055 1.1 christos case $file in
11056 1.1 christos *.exe)
11057 1.1 christos func_stripname '' '.exe' "$file"
11058 1.1 christos file=$func_stripname_result
11059 1.1 christos func_stripname '' '.exe' "$name"
11060 1.1 christos noexename=$func_stripname_result
11061 1.1 christos # $file with .exe has already been added to rmfiles,
11062 1.1 christos # add $file without .exe
11063 1.1 christos func_append rmfiles " $file"
11064 1.1 christos ;;
11065 1.1 christos esac
11066 1.1 christos # Do a test to see if this is a libtool program.
11067 1.1 christos if func_ltwrapper_p "$file"; then
11068 1.1 christos if func_ltwrapper_executable_p "$file"; then
11069 1.1 christos func_ltwrapper_scriptname "$file"
11070 1.1 christos relink_command=
11071 1.1 christos func_source $func_ltwrapper_scriptname_result
11072 1.1 christos func_append rmfiles " $func_ltwrapper_scriptname_result"
11073 1.1 christos else
11074 1.1 christos relink_command=
11075 1.1 christos func_source $dir/$noexename
11076 1.1 christos fi
11077 1.1 christos
11078 1.1 christos # note $name still contains .exe if it was in $file originally
11079 1.1 christos # as does the version of $file that was added into $rmfiles
11080 1.1 christos func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11081 1.1 christos if test yes = "$fast_install" && test -n "$relink_command"; then
11082 1.1 christos func_append rmfiles " $odir/lt-$name"
11083 1.1 christos fi
11084 1.1 christos if test "X$noexename" != "X$name"; then
11085 1.1 christos func_append rmfiles " $odir/lt-$noexename.c"
11086 1.1 christos fi
11087 1.1 christos fi
11088 1.1 christos fi
11089 1.1 christos ;;
11090 1.1 christos esac
11091 1.1 christos func_show_eval "$RM $rmfiles" 'exit_status=1'
11092 1.1 christos done
11093 1.1 christos
11094 1.1 christos # Try to remove the $objdir's in the directories where we deleted files
11095 1.1 christos for dir in $rmdirs; do
11096 1.1 christos if test -d "$dir"; then
11097 1.1 christos func_show_eval "rmdir $dir >/dev/null 2>&1"
11098 1.1 christos fi
11099 1.1 christos done
11100 1.1 christos
11101 1.1 christos exit $exit_status
11102 1.1 christos }
11103 1.1 christos
11104 1.1 christos if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11105 1.1 christos func_mode_uninstall ${1+"$@"}
11106 1.1 christos fi
11107 1.1 christos
11108 1.1 christos test -z "$opt_mode" && {
11109 1.1 christos help=$generic_help
11110 1.1 christos func_fatal_help "you must specify a MODE"
11111 1.1 christos }
11112 1.1 christos
11113 1.1 christos test -z "$exec_cmd" && \
11114 1.1 christos func_fatal_help "invalid operation mode '$opt_mode'"
11115 1.1 christos
11116 1.1 christos if test -n "$exec_cmd"; then
11117 1.1 christos eval exec "$exec_cmd"
11118 1.1 christos exit $EXIT_FAILURE
11119 1.1 christos fi
11120 1.1 christos
11121 1.1 christos exit $exit_status
11122 1.1 christos
11123 1.1 christos
11124 1.1 christos # The TAGs below are defined such that we never get into a situation
11125 1.1 christos # where we disable both kinds of libraries. Given conflicting
11126 1.1 christos # choices, we go for a static library, that is the most portable,
11127 1.1 christos # since we can't tell whether shared libraries were disabled because
11128 1.1 christos # the user asked for that or because the platform doesn't support
11129 1.1 christos # them. This is particularly important on AIX, because we don't
11130 1.1 christos # support having both static and shared libraries enabled at the same
11131 1.1 christos # time on that platform, so we default to a shared-only configuration.
11132 1.1 christos # If a disable-shared tag is given, we'll fallback to a static-only
11133 1.1 christos # configuration. But we'll never go from static-only to shared-only.
11134 1.1 christos
11135 1.1 christos # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11136 1.1 christos build_libtool_libs=no
11137 1.1 christos build_old_libs=yes
11138 1.1 christos # ### END LIBTOOL TAG CONFIG: disable-shared
11139 1.1 christos
11140 1.1 christos # ### BEGIN LIBTOOL TAG CONFIG: disable-static
11141 1.1 christos build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11142 1.1 christos # ### END LIBTOOL TAG CONFIG: disable-static
11143 1.1 christos
11144 1.1 christos # Local Variables:
11145 1.1 christos # mode:shell-script
11146 1.1 christos # sh-indentation:2
11147 1.1 christos # End:
11148