ltmain.sh revision 1.1 1 1.1 riastrad #! /bin/sh
2 1.1 riastrad ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3 1.1 riastrad ## by inline-source v2014-01-03.01
4 1.1 riastrad
5 1.1 riastrad # libtool (GNU libtool) 2.4.6
6 1.1 riastrad # Provide generalized library-building support services.
7 1.1 riastrad # Written by Gordon Matzigkeit <gord (at] gnu.ai.mit.edu>, 1996
8 1.1 riastrad
9 1.1 riastrad # Copyright (C) 1996-2015 Free Software Foundation, Inc.
10 1.1 riastrad # This is free software; see the source for copying conditions. There is NO
11 1.1 riastrad # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 1.1 riastrad
13 1.1 riastrad # GNU Libtool is free software; you can redistribute it and/or modify
14 1.1 riastrad # it under the terms of the GNU General Public License as published by
15 1.1 riastrad # the Free Software Foundation; either version 2 of the License, or
16 1.1 riastrad # (at your option) any later version.
17 1.1 riastrad #
18 1.1 riastrad # As a special exception to the GNU General Public License,
19 1.1 riastrad # if you distribute this file as part of a program or library that
20 1.1 riastrad # is built using GNU Libtool, you may include this file under the
21 1.1 riastrad # same distribution terms that you use for the rest of that program.
22 1.1 riastrad #
23 1.1 riastrad # GNU Libtool is distributed in the hope that it will be useful, but
24 1.1 riastrad # WITHOUT ANY WARRANTY; without even the implied warranty of
25 1.1 riastrad # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 1.1 riastrad # General Public License for more details.
27 1.1 riastrad #
28 1.1 riastrad # You should have received a copy of the GNU General Public License
29 1.1 riastrad # along with this program. If not, see <http://www.gnu.org/licenses/>.
30 1.1 riastrad
31 1.1 riastrad
32 1.1 riastrad PROGRAM=libtool
33 1.1 riastrad PACKAGE=libtool
34 1.1 riastrad VERSION=2.4.6
35 1.1 riastrad package_revision=2.4.6
36 1.1 riastrad
37 1.1 riastrad
38 1.1 riastrad ## ------ ##
39 1.1 riastrad ## Usage. ##
40 1.1 riastrad ## ------ ##
41 1.1 riastrad
42 1.1 riastrad # Run './libtool --help' for help with using this script from the
43 1.1 riastrad # command line.
44 1.1 riastrad
45 1.1 riastrad
46 1.1 riastrad ## ------------------------------- ##
47 1.1 riastrad ## User overridable command paths. ##
48 1.1 riastrad ## ------------------------------- ##
49 1.1 riastrad
50 1.1 riastrad # After configure completes, it has a better idea of some of the
51 1.1 riastrad # shell tools we need than the defaults used by the functions shared
52 1.1 riastrad # with bootstrap, so set those here where they can still be over-
53 1.1 riastrad # ridden by the user, but otherwise take precedence.
54 1.1 riastrad
55 1.1 riastrad : ${AUTOCONF="autoconf"}
56 1.1 riastrad : ${AUTOMAKE="automake"}
57 1.1 riastrad
58 1.1 riastrad
59 1.1 riastrad ## -------------------------- ##
60 1.1 riastrad ## Source external libraries. ##
61 1.1 riastrad ## -------------------------- ##
62 1.1 riastrad
63 1.1 riastrad # Much of our low-level functionality needs to be sourced from external
64 1.1 riastrad # libraries, which are installed to $pkgauxdir.
65 1.1 riastrad
66 1.1 riastrad # Set a version string for this script.
67 1.1 riastrad scriptversion=2015-01-20.17; # UTC
68 1.1 riastrad
69 1.1 riastrad # General shell script boiler plate, and helper functions.
70 1.1 riastrad # Written by Gary V. Vaughan, 2004
71 1.1 riastrad
72 1.1 riastrad # Copyright (C) 2004-2015 Free Software Foundation, Inc.
73 1.1 riastrad # This is free software; see the source for copying conditions. There is NO
74 1.1 riastrad # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
75 1.1 riastrad
76 1.1 riastrad # This program is free software; you can redistribute it and/or modify
77 1.1 riastrad # it under the terms of the GNU General Public License as published by
78 1.1 riastrad # the Free Software Foundation; either version 3 of the License, or
79 1.1 riastrad # (at your option) any later version.
80 1.1 riastrad
81 1.1 riastrad # As a special exception to the GNU General Public License, if you distribute
82 1.1 riastrad # this file as part of a program or library that is built using GNU Libtool,
83 1.1 riastrad # you may include this file under the same distribution terms that you use
84 1.1 riastrad # for the rest of that program.
85 1.1 riastrad
86 1.1 riastrad # This program is distributed in the hope that it will be useful,
87 1.1 riastrad # but WITHOUT ANY WARRANTY; without even the implied warranty of
88 1.1 riastrad # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89 1.1 riastrad # General Public License for more details.
90 1.1 riastrad
91 1.1 riastrad # You should have received a copy of the GNU General Public License
92 1.1 riastrad # along with this program. If not, see <http://www.gnu.org/licenses/>.
93 1.1 riastrad
94 1.1 riastrad # Please report bugs or propose patches to gary (at] gnu.org.
95 1.1 riastrad
96 1.1 riastrad
97 1.1 riastrad ## ------ ##
98 1.1 riastrad ## Usage. ##
99 1.1 riastrad ## ------ ##
100 1.1 riastrad
101 1.1 riastrad # Evaluate this file near the top of your script to gain access to
102 1.1 riastrad # the functions and variables defined here:
103 1.1 riastrad #
104 1.1 riastrad # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
105 1.1 riastrad #
106 1.1 riastrad # If you need to override any of the default environment variable
107 1.1 riastrad # settings, do that before evaluating this file.
108 1.1 riastrad
109 1.1 riastrad
110 1.1 riastrad ## -------------------- ##
111 1.1 riastrad ## Shell normalisation. ##
112 1.1 riastrad ## -------------------- ##
113 1.1 riastrad
114 1.1 riastrad # Some shells need a little help to be as Bourne compatible as possible.
115 1.1 riastrad # Before doing anything else, make sure all that help has been provided!
116 1.1 riastrad
117 1.1 riastrad DUALCASE=1; export DUALCASE # for MKS sh
118 1.1 riastrad if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
119 1.1 riastrad emulate sh
120 1.1 riastrad NULLCMD=:
121 1.1 riastrad # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
122 1.1 riastrad # is contrary to our usage. Disable this feature.
123 1.1 riastrad alias -g '${1+"$@"}'='"$@"'
124 1.1 riastrad setopt NO_GLOB_SUBST
125 1.1 riastrad else
126 1.1 riastrad case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127 1.1 riastrad fi
128 1.1 riastrad
129 1.1 riastrad # NLS nuisances: We save the old values in case they are required later.
130 1.1 riastrad _G_user_locale=
131 1.1 riastrad _G_safe_locale=
132 1.1 riastrad for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
133 1.1 riastrad do
134 1.1 riastrad eval "if test set = \"\${$_G_var+set}\"; then
135 1.1 riastrad save_$_G_var=\$$_G_var
136 1.1 riastrad $_G_var=C
137 1.1 riastrad export $_G_var
138 1.1 riastrad _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139 1.1 riastrad _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
140 1.1 riastrad fi"
141 1.1 riastrad done
142 1.1 riastrad
143 1.1 riastrad # CDPATH.
144 1.1 riastrad (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145 1.1 riastrad
146 1.1 riastrad # Make sure IFS has a sensible default
147 1.1 riastrad sp=' '
148 1.1 riastrad nl='
149 1.1 riastrad '
150 1.1 riastrad IFS="$sp $nl"
151 1.1 riastrad
152 1.1 riastrad # There are apparently some retarded systems that use ';' as a PATH separator!
153 1.1 riastrad if test "${PATH_SEPARATOR+set}" != set; then
154 1.1 riastrad PATH_SEPARATOR=:
155 1.1 riastrad (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156 1.1 riastrad (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
157 1.1 riastrad PATH_SEPARATOR=';'
158 1.1 riastrad }
159 1.1 riastrad fi
160 1.1 riastrad
161 1.1 riastrad
162 1.1 riastrad
163 1.1 riastrad ## ------------------------- ##
164 1.1 riastrad ## Locate command utilities. ##
165 1.1 riastrad ## ------------------------- ##
166 1.1 riastrad
167 1.1 riastrad
168 1.1 riastrad # func_executable_p FILE
169 1.1 riastrad # ----------------------
170 1.1 riastrad # Check that FILE is an executable regular file.
171 1.1 riastrad func_executable_p ()
172 1.1 riastrad {
173 1.1 riastrad test -f "$1" && test -x "$1"
174 1.1 riastrad }
175 1.1 riastrad
176 1.1 riastrad
177 1.1 riastrad # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178 1.1 riastrad # --------------------------------------------
179 1.1 riastrad # Search for either a program that responds to --version with output
180 1.1 riastrad # containing "GNU", or else returned by CHECK_FUNC otherwise, by
181 1.1 riastrad # trying all the directories in PATH with each of the elements of
182 1.1 riastrad # PROGS_LIST.
183 1.1 riastrad #
184 1.1 riastrad # CHECK_FUNC should accept the path to a candidate program, and
185 1.1 riastrad # set $func_check_prog_result if it truncates its output less than
186 1.1 riastrad # $_G_path_prog_max characters.
187 1.1 riastrad func_path_progs ()
188 1.1 riastrad {
189 1.1 riastrad _G_progs_list=$1
190 1.1 riastrad _G_check_func=$2
191 1.1 riastrad _G_PATH=${3-"$PATH"}
192 1.1 riastrad
193 1.1 riastrad _G_path_prog_max=0
194 1.1 riastrad _G_path_prog_found=false
195 1.1 riastrad _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
196 1.1 riastrad for _G_dir in $_G_PATH; do
197 1.1 riastrad IFS=$_G_save_IFS
198 1.1 riastrad test -z "$_G_dir" && _G_dir=.
199 1.1 riastrad for _G_prog_name in $_G_progs_list; do
200 1.1 riastrad for _exeext in '' .EXE; do
201 1.1 riastrad _G_path_prog=$_G_dir/$_G_prog_name$_exeext
202 1.1 riastrad func_executable_p "$_G_path_prog" || continue
203 1.1 riastrad case `"$_G_path_prog" --version 2>&1` in
204 1.1 riastrad *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205 1.1 riastrad *) $_G_check_func $_G_path_prog
206 1.1 riastrad func_path_progs_result=$func_check_prog_result
207 1.1 riastrad ;;
208 1.1 riastrad esac
209 1.1 riastrad $_G_path_prog_found && break 3
210 1.1 riastrad done
211 1.1 riastrad done
212 1.1 riastrad done
213 1.1 riastrad IFS=$_G_save_IFS
214 1.1 riastrad test -z "$func_path_progs_result" && {
215 1.1 riastrad echo "no acceptable sed could be found in \$PATH" >&2
216 1.1 riastrad exit 1
217 1.1 riastrad }
218 1.1 riastrad }
219 1.1 riastrad
220 1.1 riastrad
221 1.1 riastrad # We want to be able to use the functions in this file before configure
222 1.1 riastrad # has figured out where the best binaries are kept, which means we have
223 1.1 riastrad # to search for them ourselves - except when the results are already set
224 1.1 riastrad # where we skip the searches.
225 1.1 riastrad
226 1.1 riastrad # Unless the user overrides by setting SED, search the path for either GNU
227 1.1 riastrad # sed, or the sed that truncates its output the least.
228 1.1 riastrad test -z "$SED" && {
229 1.1 riastrad _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230 1.1 riastrad for _G_i in 1 2 3 4 5 6 7; do
231 1.1 riastrad _G_sed_script=$_G_sed_script$nl$_G_sed_script
232 1.1 riastrad done
233 1.1 riastrad echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
234 1.1 riastrad _G_sed_script=
235 1.1 riastrad
236 1.1 riastrad func_check_prog_sed ()
237 1.1 riastrad {
238 1.1 riastrad _G_path_prog=$1
239 1.1 riastrad
240 1.1 riastrad _G_count=0
241 1.1 riastrad printf 0123456789 >conftest.in
242 1.1 riastrad while :
243 1.1 riastrad do
244 1.1 riastrad cat conftest.in conftest.in >conftest.tmp
245 1.1 riastrad mv conftest.tmp conftest.in
246 1.1 riastrad cp conftest.in conftest.nl
247 1.1 riastrad echo '' >> conftest.nl
248 1.1 riastrad "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249 1.1 riastrad diff conftest.out conftest.nl >/dev/null 2>&1 || break
250 1.1 riastrad _G_count=`expr $_G_count + 1`
251 1.1 riastrad if test "$_G_count" -gt "$_G_path_prog_max"; then
252 1.1 riastrad # Best one so far, save it but keep looking for a better one
253 1.1 riastrad func_check_prog_result=$_G_path_prog
254 1.1 riastrad _G_path_prog_max=$_G_count
255 1.1 riastrad fi
256 1.1 riastrad # 10*(2^10) chars as input seems more than enough
257 1.1 riastrad test 10 -lt "$_G_count" && break
258 1.1 riastrad done
259 1.1 riastrad rm -f conftest.in conftest.tmp conftest.nl conftest.out
260 1.1 riastrad }
261 1.1 riastrad
262 1.1 riastrad func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
263 1.1 riastrad rm -f conftest.sed
264 1.1 riastrad SED=$func_path_progs_result
265 1.1 riastrad }
266 1.1 riastrad
267 1.1 riastrad
268 1.1 riastrad # Unless the user overrides by setting GREP, search the path for either GNU
269 1.1 riastrad # grep, or the grep that truncates its output the least.
270 1.1 riastrad test -z "$GREP" && {
271 1.1 riastrad func_check_prog_grep ()
272 1.1 riastrad {
273 1.1 riastrad _G_path_prog=$1
274 1.1 riastrad
275 1.1 riastrad _G_count=0
276 1.1 riastrad _G_path_prog_max=0
277 1.1 riastrad printf 0123456789 >conftest.in
278 1.1 riastrad while :
279 1.1 riastrad do
280 1.1 riastrad cat conftest.in conftest.in >conftest.tmp
281 1.1 riastrad mv conftest.tmp conftest.in
282 1.1 riastrad cp conftest.in conftest.nl
283 1.1 riastrad echo 'GREP' >> conftest.nl
284 1.1 riastrad "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285 1.1 riastrad diff conftest.out conftest.nl >/dev/null 2>&1 || break
286 1.1 riastrad _G_count=`expr $_G_count + 1`
287 1.1 riastrad if test "$_G_count" -gt "$_G_path_prog_max"; then
288 1.1 riastrad # Best one so far, save it but keep looking for a better one
289 1.1 riastrad func_check_prog_result=$_G_path_prog
290 1.1 riastrad _G_path_prog_max=$_G_count
291 1.1 riastrad fi
292 1.1 riastrad # 10*(2^10) chars as input seems more than enough
293 1.1 riastrad test 10 -lt "$_G_count" && break
294 1.1 riastrad done
295 1.1 riastrad rm -f conftest.in conftest.tmp conftest.nl conftest.out
296 1.1 riastrad }
297 1.1 riastrad
298 1.1 riastrad func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299 1.1 riastrad GREP=$func_path_progs_result
300 1.1 riastrad }
301 1.1 riastrad
302 1.1 riastrad
303 1.1 riastrad ## ------------------------------- ##
304 1.1 riastrad ## User overridable command paths. ##
305 1.1 riastrad ## ------------------------------- ##
306 1.1 riastrad
307 1.1 riastrad # All uppercase variable names are used for environment variables. These
308 1.1 riastrad # variables can be overridden by the user before calling a script that
309 1.1 riastrad # uses them if a suitable command of that name is not already available
310 1.1 riastrad # in the command search PATH.
311 1.1 riastrad
312 1.1 riastrad : ${CP="cp -f"}
313 1.1 riastrad : ${ECHO="printf %s\n"}
314 1.1 riastrad : ${EGREP="$GREP -E"}
315 1.1 riastrad : ${FGREP="$GREP -F"}
316 1.1 riastrad : ${LN_S="ln -s"}
317 1.1 riastrad : ${MAKE="make"}
318 1.1 riastrad : ${MKDIR="mkdir"}
319 1.1 riastrad : ${MV="mv -f"}
320 1.1 riastrad : ${RM="rm -f"}
321 1.1 riastrad : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322 1.1 riastrad
323 1.1 riastrad
324 1.1 riastrad ## -------------------- ##
325 1.1 riastrad ## Useful sed snippets. ##
326 1.1 riastrad ## -------------------- ##
327 1.1 riastrad
328 1.1 riastrad sed_dirname='s|/[^/]*$||'
329 1.1 riastrad sed_basename='s|^.*/||'
330 1.1 riastrad
331 1.1 riastrad # Sed substitution that helps us do robust quoting. It backslashifies
332 1.1 riastrad # metacharacters that are still active within double-quoted strings.
333 1.1 riastrad sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334 1.1 riastrad
335 1.1 riastrad # Same as above, but do not quote variable references.
336 1.1 riastrad sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337 1.1 riastrad
338 1.1 riastrad # Sed substitution that turns a string into a regex matching for the
339 1.1 riastrad # string literally.
340 1.1 riastrad sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341 1.1 riastrad
342 1.1 riastrad # Sed substitution that converts a w32 file name or path
343 1.1 riastrad # that contains forward slashes, into one that contains
344 1.1 riastrad # (escaped) backslashes. A very naive implementation.
345 1.1 riastrad sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
346 1.1 riastrad
347 1.1 riastrad # Re-'\' parameter expansions in output of sed_double_quote_subst that
348 1.1 riastrad # were '\'-ed in input to the same. If an odd number of '\' preceded a
349 1.1 riastrad # '$' in input to sed_double_quote_subst, that '$' was protected from
350 1.1 riastrad # expansion. Since each input '\' is now two '\'s, look for any number
351 1.1 riastrad # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
352 1.1 riastrad _G_bs='\\'
353 1.1 riastrad _G_bs2='\\\\'
354 1.1 riastrad _G_bs4='\\\\\\\\'
355 1.1 riastrad _G_dollar='\$'
356 1.1 riastrad sed_double_backslash="\
357 1.1 riastrad s/$_G_bs4/&\\
358 1.1 riastrad /g
359 1.1 riastrad s/^$_G_bs2$_G_dollar/$_G_bs&/
360 1.1 riastrad s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
361 1.1 riastrad s/\n//g"
362 1.1 riastrad
363 1.1 riastrad
364 1.1 riastrad ## ----------------- ##
365 1.1 riastrad ## Global variables. ##
366 1.1 riastrad ## ----------------- ##
367 1.1 riastrad
368 1.1 riastrad # Except for the global variables explicitly listed below, the following
369 1.1 riastrad # functions in the '^func_' namespace, and the '^require_' namespace
370 1.1 riastrad # variables initialised in the 'Resource management' section, sourcing
371 1.1 riastrad # this file will not pollute your global namespace with anything
372 1.1 riastrad # else. There's no portable way to scope variables in Bourne shell
373 1.1 riastrad # though, so actually running these functions will sometimes place
374 1.1 riastrad # results into a variable named after the function, and often use
375 1.1 riastrad # temporary variables in the '^_G_' namespace. If you are careful to
376 1.1 riastrad # avoid using those namespaces casually in your sourcing script, things
377 1.1 riastrad # should continue to work as you expect. And, of course, you can freely
378 1.1 riastrad # overwrite any of the functions or variables defined here before
379 1.1 riastrad # calling anything to customize them.
380 1.1 riastrad
381 1.1 riastrad EXIT_SUCCESS=0
382 1.1 riastrad EXIT_FAILURE=1
383 1.1 riastrad EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
384 1.1 riastrad EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
385 1.1 riastrad
386 1.1 riastrad # Allow overriding, eg assuming that you follow the convention of
387 1.1 riastrad # putting '$debug_cmd' at the start of all your functions, you can get
388 1.1 riastrad # bash to show function call trace with:
389 1.1 riastrad #
390 1.1 riastrad # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391 1.1 riastrad debug_cmd=${debug_cmd-":"}
392 1.1 riastrad exit_cmd=:
393 1.1 riastrad
394 1.1 riastrad # By convention, finish your script with:
395 1.1 riastrad #
396 1.1 riastrad # exit $exit_status
397 1.1 riastrad #
398 1.1 riastrad # so that you can set exit_status to non-zero if you want to indicate
399 1.1 riastrad # something went wrong during execution without actually bailing out at
400 1.1 riastrad # the point of failure.
401 1.1 riastrad exit_status=$EXIT_SUCCESS
402 1.1 riastrad
403 1.1 riastrad # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404 1.1 riastrad # is ksh but when the shell is invoked as "sh" and the current value of
405 1.1 riastrad # the _XPG environment variable is not equal to 1 (one), the special
406 1.1 riastrad # positional parameter $0, within a function call, is the name of the
407 1.1 riastrad # function.
408 1.1 riastrad progpath=$0
409 1.1 riastrad
410 1.1 riastrad # The name of this program.
411 1.1 riastrad progname=`$ECHO "$progpath" |$SED "$sed_basename"`
412 1.1 riastrad
413 1.1 riastrad # Make sure we have an absolute progpath for reexecution:
414 1.1 riastrad case $progpath in
415 1.1 riastrad [\\/]*|[A-Za-z]:\\*) ;;
416 1.1 riastrad *[\\/]*)
417 1.1 riastrad progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418 1.1 riastrad progdir=`cd "$progdir" && pwd`
419 1.1 riastrad progpath=$progdir/$progname
420 1.1 riastrad ;;
421 1.1 riastrad *)
422 1.1 riastrad _G_IFS=$IFS
423 1.1 riastrad IFS=${PATH_SEPARATOR-:}
424 1.1 riastrad for progdir in $PATH; do
425 1.1 riastrad IFS=$_G_IFS
426 1.1 riastrad test -x "$progdir/$progname" && break
427 1.1 riastrad done
428 1.1 riastrad IFS=$_G_IFS
429 1.1 riastrad test -n "$progdir" || progdir=`pwd`
430 1.1 riastrad progpath=$progdir/$progname
431 1.1 riastrad ;;
432 1.1 riastrad esac
433 1.1 riastrad
434 1.1 riastrad
435 1.1 riastrad ## ----------------- ##
436 1.1 riastrad ## Standard options. ##
437 1.1 riastrad ## ----------------- ##
438 1.1 riastrad
439 1.1 riastrad # The following options affect the operation of the functions defined
440 1.1 riastrad # below, and should be set appropriately depending on run-time para-
441 1.1 riastrad # meters passed on the command line.
442 1.1 riastrad
443 1.1 riastrad opt_dry_run=false
444 1.1 riastrad opt_quiet=false
445 1.1 riastrad opt_verbose=false
446 1.1 riastrad
447 1.1 riastrad # Categories 'all' and 'none' are always available. Append any others
448 1.1 riastrad # you will pass as the first argument to func_warning from your own
449 1.1 riastrad # code.
450 1.1 riastrad warning_categories=
451 1.1 riastrad
452 1.1 riastrad # By default, display warnings according to 'opt_warning_types'. Set
453 1.1 riastrad # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
454 1.1 riastrad # treat the next displayed warning as a fatal error.
455 1.1 riastrad warning_func=func_warn_and_continue
456 1.1 riastrad
457 1.1 riastrad # Set to 'all' to display all warnings, 'none' to suppress all
458 1.1 riastrad # warnings, or a space delimited list of some subset of
459 1.1 riastrad # 'warning_categories' to display only the listed warnings.
460 1.1 riastrad opt_warning_types=all
461 1.1 riastrad
462 1.1 riastrad
463 1.1 riastrad ## -------------------- ##
464 1.1 riastrad ## Resource management. ##
465 1.1 riastrad ## -------------------- ##
466 1.1 riastrad
467 1.1 riastrad # This section contains definitions for functions that each ensure a
468 1.1 riastrad # particular resource (a file, or a non-empty configuration variable for
469 1.1 riastrad # example) is available, and if appropriate to extract default values
470 1.1 riastrad # from pertinent package files. Call them using their associated
471 1.1 riastrad # 'require_*' variable to ensure that they are executed, at most, once.
472 1.1 riastrad #
473 1.1 riastrad # It's entirely deliberate that calling these functions can set
474 1.1 riastrad # variables that don't obey the namespace limitations obeyed by the rest
475 1.1 riastrad # of this file, in order that that they be as useful as possible to
476 1.1 riastrad # callers.
477 1.1 riastrad
478 1.1 riastrad
479 1.1 riastrad # require_term_colors
480 1.1 riastrad # -------------------
481 1.1 riastrad # Allow display of bold text on terminals that support it.
482 1.1 riastrad require_term_colors=func_require_term_colors
483 1.1 riastrad func_require_term_colors ()
484 1.1 riastrad {
485 1.1 riastrad $debug_cmd
486 1.1 riastrad
487 1.1 riastrad test -t 1 && {
488 1.1 riastrad # COLORTERM and USE_ANSI_COLORS environment variables take
489 1.1 riastrad # precedence, because most terminfo databases neglect to describe
490 1.1 riastrad # whether color sequences are supported.
491 1.1 riastrad test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
492 1.1 riastrad
493 1.1 riastrad if test 1 = "$USE_ANSI_COLORS"; then
494 1.1 riastrad # Standard ANSI escape sequences
495 1.1 riastrad tc_reset='[0m'
496 1.1 riastrad tc_bold='[1m'; tc_standout='[7m'
497 1.1 riastrad tc_red='[31m'; tc_green='[32m'
498 1.1 riastrad tc_blue='[34m'; tc_cyan='[36m'
499 1.1 riastrad else
500 1.1 riastrad # Otherwise trust the terminfo database after all.
501 1.1 riastrad test -n "`tput sgr0 2>/dev/null`" && {
502 1.1 riastrad tc_reset=`tput sgr0`
503 1.1 riastrad test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
504 1.1 riastrad tc_standout=$tc_bold
505 1.1 riastrad test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506 1.1 riastrad test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507 1.1 riastrad test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508 1.1 riastrad test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509 1.1 riastrad test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
510 1.1 riastrad }
511 1.1 riastrad fi
512 1.1 riastrad }
513 1.1 riastrad
514 1.1 riastrad require_term_colors=:
515 1.1 riastrad }
516 1.1 riastrad
517 1.1 riastrad
518 1.1 riastrad ## ----------------- ##
519 1.1 riastrad ## Function library. ##
520 1.1 riastrad ## ----------------- ##
521 1.1 riastrad
522 1.1 riastrad # This section contains a variety of useful functions to call in your
523 1.1 riastrad # scripts. Take note of the portable wrappers for features provided by
524 1.1 riastrad # some modern shells, which will fall back to slower equivalents on
525 1.1 riastrad # less featureful shells.
526 1.1 riastrad
527 1.1 riastrad
528 1.1 riastrad # func_append VAR VALUE
529 1.1 riastrad # ---------------------
530 1.1 riastrad # Append VALUE onto the existing contents of VAR.
531 1.1 riastrad
532 1.1 riastrad # We should try to minimise forks, especially on Windows where they are
533 1.1 riastrad # unreasonably slow, so skip the feature probes when bash or zsh are
534 1.1 riastrad # being used:
535 1.1 riastrad if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536 1.1 riastrad : ${_G_HAVE_ARITH_OP="yes"}
537 1.1 riastrad : ${_G_HAVE_XSI_OPS="yes"}
538 1.1 riastrad # The += operator was introduced in bash 3.1
539 1.1 riastrad case $BASH_VERSION in
540 1.1 riastrad [12].* | 3.0 | 3.0*) ;;
541 1.1 riastrad *)
542 1.1 riastrad : ${_G_HAVE_PLUSEQ_OP="yes"}
543 1.1 riastrad ;;
544 1.1 riastrad esac
545 1.1 riastrad fi
546 1.1 riastrad
547 1.1 riastrad # _G_HAVE_PLUSEQ_OP
548 1.1 riastrad # Can be empty, in which case the shell is probed, "yes" if += is
549 1.1 riastrad # useable or anything else if it does not work.
550 1.1 riastrad test -z "$_G_HAVE_PLUSEQ_OP" \
551 1.1 riastrad && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552 1.1 riastrad && _G_HAVE_PLUSEQ_OP=yes
553 1.1 riastrad
554 1.1 riastrad if test yes = "$_G_HAVE_PLUSEQ_OP"
555 1.1 riastrad then
556 1.1 riastrad # This is an XSI compatible shell, allowing a faster implementation...
557 1.1 riastrad eval 'func_append ()
558 1.1 riastrad {
559 1.1 riastrad $debug_cmd
560 1.1 riastrad
561 1.1 riastrad eval "$1+=\$2"
562 1.1 riastrad }'
563 1.1 riastrad else
564 1.1 riastrad # ...otherwise fall back to using expr, which is often a shell builtin.
565 1.1 riastrad func_append ()
566 1.1 riastrad {
567 1.1 riastrad $debug_cmd
568 1.1 riastrad
569 1.1 riastrad eval "$1=\$$1\$2"
570 1.1 riastrad }
571 1.1 riastrad fi
572 1.1 riastrad
573 1.1 riastrad
574 1.1 riastrad # func_append_quoted VAR VALUE
575 1.1 riastrad # ----------------------------
576 1.1 riastrad # Quote VALUE and append to the end of shell variable VAR, separated
577 1.1 riastrad # by a space.
578 1.1 riastrad if test yes = "$_G_HAVE_PLUSEQ_OP"; then
579 1.1 riastrad eval 'func_append_quoted ()
580 1.1 riastrad {
581 1.1 riastrad $debug_cmd
582 1.1 riastrad
583 1.1 riastrad func_quote_for_eval "$2"
584 1.1 riastrad eval "$1+=\\ \$func_quote_for_eval_result"
585 1.1 riastrad }'
586 1.1 riastrad else
587 1.1 riastrad func_append_quoted ()
588 1.1 riastrad {
589 1.1 riastrad $debug_cmd
590 1.1 riastrad
591 1.1 riastrad func_quote_for_eval "$2"
592 1.1 riastrad eval "$1=\$$1\\ \$func_quote_for_eval_result"
593 1.1 riastrad }
594 1.1 riastrad fi
595 1.1 riastrad
596 1.1 riastrad
597 1.1 riastrad # func_append_uniq VAR VALUE
598 1.1 riastrad # --------------------------
599 1.1 riastrad # Append unique VALUE onto the existing contents of VAR, assuming
600 1.1 riastrad # entries are delimited by the first character of VALUE. For example:
601 1.1 riastrad #
602 1.1 riastrad # func_append_uniq options " --another-option option-argument"
603 1.1 riastrad #
604 1.1 riastrad # will only append to $options if " --another-option option-argument "
605 1.1 riastrad # is not already present somewhere in $options already (note spaces at
606 1.1 riastrad # each end implied by leading space in second argument).
607 1.1 riastrad func_append_uniq ()
608 1.1 riastrad {
609 1.1 riastrad $debug_cmd
610 1.1 riastrad
611 1.1 riastrad eval _G_current_value='`$ECHO $'$1'`'
612 1.1 riastrad _G_delim=`expr "$2" : '\(.\)'`
613 1.1 riastrad
614 1.1 riastrad case $_G_delim$_G_current_value$_G_delim in
615 1.1 riastrad *"$2$_G_delim"*) ;;
616 1.1 riastrad *) func_append "$@" ;;
617 1.1 riastrad esac
618 1.1 riastrad }
619 1.1 riastrad
620 1.1 riastrad
621 1.1 riastrad # func_arith TERM...
622 1.1 riastrad # ------------------
623 1.1 riastrad # Set func_arith_result to the result of evaluating TERMs.
624 1.1 riastrad test -z "$_G_HAVE_ARITH_OP" \
625 1.1 riastrad && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626 1.1 riastrad && _G_HAVE_ARITH_OP=yes
627 1.1 riastrad
628 1.1 riastrad if test yes = "$_G_HAVE_ARITH_OP"; then
629 1.1 riastrad eval 'func_arith ()
630 1.1 riastrad {
631 1.1 riastrad $debug_cmd
632 1.1 riastrad
633 1.1 riastrad func_arith_result=$(( $* ))
634 1.1 riastrad }'
635 1.1 riastrad else
636 1.1 riastrad func_arith ()
637 1.1 riastrad {
638 1.1 riastrad $debug_cmd
639 1.1 riastrad
640 1.1 riastrad func_arith_result=`expr "$@"`
641 1.1 riastrad }
642 1.1 riastrad fi
643 1.1 riastrad
644 1.1 riastrad
645 1.1 riastrad # func_basename FILE
646 1.1 riastrad # ------------------
647 1.1 riastrad # Set func_basename_result to FILE with everything up to and including
648 1.1 riastrad # the last / stripped.
649 1.1 riastrad if test yes = "$_G_HAVE_XSI_OPS"; then
650 1.1 riastrad # If this shell supports suffix pattern removal, then use it to avoid
651 1.1 riastrad # forking. Hide the definitions single quotes in case the shell chokes
652 1.1 riastrad # on unsupported syntax...
653 1.1 riastrad _b='func_basename_result=${1##*/}'
654 1.1 riastrad _d='case $1 in
655 1.1 riastrad */*) func_dirname_result=${1%/*}$2 ;;
656 1.1 riastrad * ) func_dirname_result=$3 ;;
657 1.1 riastrad esac'
658 1.1 riastrad
659 1.1 riastrad else
660 1.1 riastrad # ...otherwise fall back to using sed.
661 1.1 riastrad _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662 1.1 riastrad _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
663 1.1 riastrad if test "X$func_dirname_result" = "X$1"; then
664 1.1 riastrad func_dirname_result=$3
665 1.1 riastrad else
666 1.1 riastrad func_append func_dirname_result "$2"
667 1.1 riastrad fi'
668 1.1 riastrad fi
669 1.1 riastrad
670 1.1 riastrad eval 'func_basename ()
671 1.1 riastrad {
672 1.1 riastrad $debug_cmd
673 1.1 riastrad
674 1.1 riastrad '"$_b"'
675 1.1 riastrad }'
676 1.1 riastrad
677 1.1 riastrad
678 1.1 riastrad # func_dirname FILE APPEND NONDIR_REPLACEMENT
679 1.1 riastrad # -------------------------------------------
680 1.1 riastrad # Compute the dirname of FILE. If nonempty, add APPEND to the result,
681 1.1 riastrad # otherwise set result to NONDIR_REPLACEMENT.
682 1.1 riastrad eval 'func_dirname ()
683 1.1 riastrad {
684 1.1 riastrad $debug_cmd
685 1.1 riastrad
686 1.1 riastrad '"$_d"'
687 1.1 riastrad }'
688 1.1 riastrad
689 1.1 riastrad
690 1.1 riastrad # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691 1.1 riastrad # --------------------------------------------------------
692 1.1 riastrad # Perform func_basename and func_dirname in a single function
693 1.1 riastrad # call:
694 1.1 riastrad # dirname: Compute the dirname of FILE. If nonempty,
695 1.1 riastrad # add APPEND to the result, otherwise set result
696 1.1 riastrad # to NONDIR_REPLACEMENT.
697 1.1 riastrad # value returned in "$func_dirname_result"
698 1.1 riastrad # basename: Compute filename of FILE.
699 1.1 riastrad # value retuned in "$func_basename_result"
700 1.1 riastrad # For efficiency, we do not delegate to the functions above but instead
701 1.1 riastrad # duplicate the functionality here.
702 1.1 riastrad eval 'func_dirname_and_basename ()
703 1.1 riastrad {
704 1.1 riastrad $debug_cmd
705 1.1 riastrad
706 1.1 riastrad '"$_b"'
707 1.1 riastrad '"$_d"'
708 1.1 riastrad }'
709 1.1 riastrad
710 1.1 riastrad
711 1.1 riastrad # func_echo ARG...
712 1.1 riastrad # ----------------
713 1.1 riastrad # Echo program name prefixed message.
714 1.1 riastrad func_echo ()
715 1.1 riastrad {
716 1.1 riastrad $debug_cmd
717 1.1 riastrad
718 1.1 riastrad _G_message=$*
719 1.1 riastrad
720 1.1 riastrad func_echo_IFS=$IFS
721 1.1 riastrad IFS=$nl
722 1.1 riastrad for _G_line in $_G_message; do
723 1.1 riastrad IFS=$func_echo_IFS
724 1.1 riastrad $ECHO "$progname: $_G_line"
725 1.1 riastrad done
726 1.1 riastrad IFS=$func_echo_IFS
727 1.1 riastrad }
728 1.1 riastrad
729 1.1 riastrad
730 1.1 riastrad # func_echo_all ARG...
731 1.1 riastrad # --------------------
732 1.1 riastrad # Invoke $ECHO with all args, space-separated.
733 1.1 riastrad func_echo_all ()
734 1.1 riastrad {
735 1.1 riastrad $ECHO "$*"
736 1.1 riastrad }
737 1.1 riastrad
738 1.1 riastrad
739 1.1 riastrad # func_echo_infix_1 INFIX ARG...
740 1.1 riastrad # ------------------------------
741 1.1 riastrad # Echo program name, followed by INFIX on the first line, with any
742 1.1 riastrad # additional lines not showing INFIX.
743 1.1 riastrad func_echo_infix_1 ()
744 1.1 riastrad {
745 1.1 riastrad $debug_cmd
746 1.1 riastrad
747 1.1 riastrad $require_term_colors
748 1.1 riastrad
749 1.1 riastrad _G_infix=$1; shift
750 1.1 riastrad _G_indent=$_G_infix
751 1.1 riastrad _G_prefix="$progname: $_G_infix: "
752 1.1 riastrad _G_message=$*
753 1.1 riastrad
754 1.1 riastrad # Strip color escape sequences before counting printable length
755 1.1 riastrad for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
756 1.1 riastrad do
757 1.1 riastrad test -n "$_G_tc" && {
758 1.1 riastrad _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759 1.1 riastrad _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
760 1.1 riastrad }
761 1.1 riastrad done
762 1.1 riastrad _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
763 1.1 riastrad
764 1.1 riastrad func_echo_infix_1_IFS=$IFS
765 1.1 riastrad IFS=$nl
766 1.1 riastrad for _G_line in $_G_message; do
767 1.1 riastrad IFS=$func_echo_infix_1_IFS
768 1.1 riastrad $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
769 1.1 riastrad _G_prefix=$_G_indent
770 1.1 riastrad done
771 1.1 riastrad IFS=$func_echo_infix_1_IFS
772 1.1 riastrad }
773 1.1 riastrad
774 1.1 riastrad
775 1.1 riastrad # func_error ARG...
776 1.1 riastrad # -----------------
777 1.1 riastrad # Echo program name prefixed message to standard error.
778 1.1 riastrad func_error ()
779 1.1 riastrad {
780 1.1 riastrad $debug_cmd
781 1.1 riastrad
782 1.1 riastrad $require_term_colors
783 1.1 riastrad
784 1.1 riastrad func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
785 1.1 riastrad }
786 1.1 riastrad
787 1.1 riastrad
788 1.1 riastrad # func_fatal_error ARG...
789 1.1 riastrad # -----------------------
790 1.1 riastrad # Echo program name prefixed message to standard error, and exit.
791 1.1 riastrad func_fatal_error ()
792 1.1 riastrad {
793 1.1 riastrad $debug_cmd
794 1.1 riastrad
795 1.1 riastrad func_error "$*"
796 1.1 riastrad exit $EXIT_FAILURE
797 1.1 riastrad }
798 1.1 riastrad
799 1.1 riastrad
800 1.1 riastrad # func_grep EXPRESSION FILENAME
801 1.1 riastrad # -----------------------------
802 1.1 riastrad # Check whether EXPRESSION matches any line of FILENAME, without output.
803 1.1 riastrad func_grep ()
804 1.1 riastrad {
805 1.1 riastrad $debug_cmd
806 1.1 riastrad
807 1.1 riastrad $GREP "$1" "$2" >/dev/null 2>&1
808 1.1 riastrad }
809 1.1 riastrad
810 1.1 riastrad
811 1.1 riastrad # func_len STRING
812 1.1 riastrad # ---------------
813 1.1 riastrad # Set func_len_result to the length of STRING. STRING may not
814 1.1 riastrad # start with a hyphen.
815 1.1 riastrad test -z "$_G_HAVE_XSI_OPS" \
816 1.1 riastrad && (eval 'x=a/b/c;
817 1.1 riastrad test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818 1.1 riastrad && _G_HAVE_XSI_OPS=yes
819 1.1 riastrad
820 1.1 riastrad if test yes = "$_G_HAVE_XSI_OPS"; then
821 1.1 riastrad eval 'func_len ()
822 1.1 riastrad {
823 1.1 riastrad $debug_cmd
824 1.1 riastrad
825 1.1 riastrad func_len_result=${#1}
826 1.1 riastrad }'
827 1.1 riastrad else
828 1.1 riastrad func_len ()
829 1.1 riastrad {
830 1.1 riastrad $debug_cmd
831 1.1 riastrad
832 1.1 riastrad func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
833 1.1 riastrad }
834 1.1 riastrad fi
835 1.1 riastrad
836 1.1 riastrad
837 1.1 riastrad # func_mkdir_p DIRECTORY-PATH
838 1.1 riastrad # ---------------------------
839 1.1 riastrad # Make sure the entire path to DIRECTORY-PATH is available.
840 1.1 riastrad func_mkdir_p ()
841 1.1 riastrad {
842 1.1 riastrad $debug_cmd
843 1.1 riastrad
844 1.1 riastrad _G_directory_path=$1
845 1.1 riastrad _G_dir_list=
846 1.1 riastrad
847 1.1 riastrad if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
848 1.1 riastrad
849 1.1 riastrad # Protect directory names starting with '-'
850 1.1 riastrad case $_G_directory_path in
851 1.1 riastrad -*) _G_directory_path=./$_G_directory_path ;;
852 1.1 riastrad esac
853 1.1 riastrad
854 1.1 riastrad # While some portion of DIR does not yet exist...
855 1.1 riastrad while test ! -d "$_G_directory_path"; do
856 1.1 riastrad # ...make a list in topmost first order. Use a colon delimited
857 1.1 riastrad # list incase some portion of path contains whitespace.
858 1.1 riastrad _G_dir_list=$_G_directory_path:$_G_dir_list
859 1.1 riastrad
860 1.1 riastrad # If the last portion added has no slash in it, the list is done
861 1.1 riastrad case $_G_directory_path in */*) ;; *) break ;; esac
862 1.1 riastrad
863 1.1 riastrad # ...otherwise throw away the child directory and loop
864 1.1 riastrad _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865 1.1 riastrad done
866 1.1 riastrad _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867 1.1 riastrad
868 1.1 riastrad func_mkdir_p_IFS=$IFS; IFS=:
869 1.1 riastrad for _G_dir in $_G_dir_list; do
870 1.1 riastrad IFS=$func_mkdir_p_IFS
871 1.1 riastrad # mkdir can fail with a 'File exist' error if two processes
872 1.1 riastrad # try to create one of the directories concurrently. Don't
873 1.1 riastrad # stop in that case!
874 1.1 riastrad $MKDIR "$_G_dir" 2>/dev/null || :
875 1.1 riastrad done
876 1.1 riastrad IFS=$func_mkdir_p_IFS
877 1.1 riastrad
878 1.1 riastrad # Bail out if we (or some other process) failed to create a directory.
879 1.1 riastrad test -d "$_G_directory_path" || \
880 1.1 riastrad func_fatal_error "Failed to create '$1'"
881 1.1 riastrad fi
882 1.1 riastrad }
883 1.1 riastrad
884 1.1 riastrad
885 1.1 riastrad # func_mktempdir [BASENAME]
886 1.1 riastrad # -------------------------
887 1.1 riastrad # Make a temporary directory that won't clash with other running
888 1.1 riastrad # libtool processes, and avoids race conditions if possible. If
889 1.1 riastrad # given, BASENAME is the basename for that directory.
890 1.1 riastrad func_mktempdir ()
891 1.1 riastrad {
892 1.1 riastrad $debug_cmd
893 1.1 riastrad
894 1.1 riastrad _G_template=${TMPDIR-/tmp}/${1-$progname}
895 1.1 riastrad
896 1.1 riastrad if test : = "$opt_dry_run"; then
897 1.1 riastrad # Return a directory name, but don't create it in dry-run mode
898 1.1 riastrad _G_tmpdir=$_G_template-$$
899 1.1 riastrad else
900 1.1 riastrad
901 1.1 riastrad # If mktemp works, use that first and foremost
902 1.1 riastrad _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903 1.1 riastrad
904 1.1 riastrad if test ! -d "$_G_tmpdir"; then
905 1.1 riastrad # Failing that, at least try and use $RANDOM to avoid a race
906 1.1 riastrad _G_tmpdir=$_G_template-${RANDOM-0}$$
907 1.1 riastrad
908 1.1 riastrad func_mktempdir_umask=`umask`
909 1.1 riastrad umask 0077
910 1.1 riastrad $MKDIR "$_G_tmpdir"
911 1.1 riastrad umask $func_mktempdir_umask
912 1.1 riastrad fi
913 1.1 riastrad
914 1.1 riastrad # If we're not in dry-run mode, bomb out on failure
915 1.1 riastrad test -d "$_G_tmpdir" || \
916 1.1 riastrad func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
917 1.1 riastrad fi
918 1.1 riastrad
919 1.1 riastrad $ECHO "$_G_tmpdir"
920 1.1 riastrad }
921 1.1 riastrad
922 1.1 riastrad
923 1.1 riastrad # func_normal_abspath PATH
924 1.1 riastrad # ------------------------
925 1.1 riastrad # Remove doubled-up and trailing slashes, "." path components,
926 1.1 riastrad # and cancel out any ".." path components in PATH after making
927 1.1 riastrad # it an absolute path.
928 1.1 riastrad func_normal_abspath ()
929 1.1 riastrad {
930 1.1 riastrad $debug_cmd
931 1.1 riastrad
932 1.1 riastrad # These SED scripts presuppose an absolute path with a trailing slash.
933 1.1 riastrad _G_pathcar='s|^/\([^/]*\).*$|\1|'
934 1.1 riastrad _G_pathcdr='s|^/[^/]*||'
935 1.1 riastrad _G_removedotparts=':dotsl
936 1.1 riastrad s|/\./|/|g
937 1.1 riastrad t dotsl
938 1.1 riastrad s|/\.$|/|'
939 1.1 riastrad _G_collapseslashes='s|/\{1,\}|/|g'
940 1.1 riastrad _G_finalslash='s|/*$|/|'
941 1.1 riastrad
942 1.1 riastrad # Start from root dir and reassemble the path.
943 1.1 riastrad func_normal_abspath_result=
944 1.1 riastrad func_normal_abspath_tpath=$1
945 1.1 riastrad func_normal_abspath_altnamespace=
946 1.1 riastrad case $func_normal_abspath_tpath in
947 1.1 riastrad "")
948 1.1 riastrad # Empty path, that just means $cwd.
949 1.1 riastrad func_stripname '' '/' "`pwd`"
950 1.1 riastrad func_normal_abspath_result=$func_stripname_result
951 1.1 riastrad return
952 1.1 riastrad ;;
953 1.1 riastrad # The next three entries are used to spot a run of precisely
954 1.1 riastrad # two leading slashes without using negated character classes;
955 1.1 riastrad # we take advantage of case's first-match behaviour.
956 1.1 riastrad ///*)
957 1.1 riastrad # Unusual form of absolute path, do nothing.
958 1.1 riastrad ;;
959 1.1 riastrad //*)
960 1.1 riastrad # Not necessarily an ordinary path; POSIX reserves leading '//'
961 1.1 riastrad # and for example Cygwin uses it to access remote file shares
962 1.1 riastrad # over CIFS/SMB, so we conserve a leading double slash if found.
963 1.1 riastrad func_normal_abspath_altnamespace=/
964 1.1 riastrad ;;
965 1.1 riastrad /*)
966 1.1 riastrad # Absolute path, do nothing.
967 1.1 riastrad ;;
968 1.1 riastrad *)
969 1.1 riastrad # Relative path, prepend $cwd.
970 1.1 riastrad func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
971 1.1 riastrad ;;
972 1.1 riastrad esac
973 1.1 riastrad
974 1.1 riastrad # Cancel out all the simple stuff to save iterations. We also want
975 1.1 riastrad # the path to end with a slash for ease of parsing, so make sure
976 1.1 riastrad # there is one (and only one) here.
977 1.1 riastrad func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978 1.1 riastrad -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
979 1.1 riastrad while :; do
980 1.1 riastrad # Processed it all yet?
981 1.1 riastrad if test / = "$func_normal_abspath_tpath"; then
982 1.1 riastrad # If we ascended to the root using ".." the result may be empty now.
983 1.1 riastrad if test -z "$func_normal_abspath_result"; then
984 1.1 riastrad func_normal_abspath_result=/
985 1.1 riastrad fi
986 1.1 riastrad break
987 1.1 riastrad fi
988 1.1 riastrad func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
989 1.1 riastrad -e "$_G_pathcar"`
990 1.1 riastrad func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
991 1.1 riastrad -e "$_G_pathcdr"`
992 1.1 riastrad # Figure out what to do with it
993 1.1 riastrad case $func_normal_abspath_tcomponent in
994 1.1 riastrad "")
995 1.1 riastrad # Trailing empty path component, ignore it.
996 1.1 riastrad ;;
997 1.1 riastrad ..)
998 1.1 riastrad # Parent dir; strip last assembled component from result.
999 1.1 riastrad func_dirname "$func_normal_abspath_result"
1000 1.1 riastrad func_normal_abspath_result=$func_dirname_result
1001 1.1 riastrad ;;
1002 1.1 riastrad *)
1003 1.1 riastrad # Actual path component, append it.
1004 1.1 riastrad func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1005 1.1 riastrad ;;
1006 1.1 riastrad esac
1007 1.1 riastrad done
1008 1.1 riastrad # Restore leading double-slash if one was found on entry.
1009 1.1 riastrad func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1010 1.1 riastrad }
1011 1.1 riastrad
1012 1.1 riastrad
1013 1.1 riastrad # func_notquiet ARG...
1014 1.1 riastrad # --------------------
1015 1.1 riastrad # Echo program name prefixed message only when not in quiet mode.
1016 1.1 riastrad func_notquiet ()
1017 1.1 riastrad {
1018 1.1 riastrad $debug_cmd
1019 1.1 riastrad
1020 1.1 riastrad $opt_quiet || func_echo ${1+"$@"}
1021 1.1 riastrad
1022 1.1 riastrad # A bug in bash halts the script if the last line of a function
1023 1.1 riastrad # fails when set -e is in force, so we need another command to
1024 1.1 riastrad # work around that:
1025 1.1 riastrad :
1026 1.1 riastrad }
1027 1.1 riastrad
1028 1.1 riastrad
1029 1.1 riastrad # func_relative_path SRCDIR DSTDIR
1030 1.1 riastrad # --------------------------------
1031 1.1 riastrad # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032 1.1 riastrad func_relative_path ()
1033 1.1 riastrad {
1034 1.1 riastrad $debug_cmd
1035 1.1 riastrad
1036 1.1 riastrad func_relative_path_result=
1037 1.1 riastrad func_normal_abspath "$1"
1038 1.1 riastrad func_relative_path_tlibdir=$func_normal_abspath_result
1039 1.1 riastrad func_normal_abspath "$2"
1040 1.1 riastrad func_relative_path_tbindir=$func_normal_abspath_result
1041 1.1 riastrad
1042 1.1 riastrad # Ascend the tree starting from libdir
1043 1.1 riastrad while :; do
1044 1.1 riastrad # check if we have found a prefix of bindir
1045 1.1 riastrad case $func_relative_path_tbindir in
1046 1.1 riastrad $func_relative_path_tlibdir)
1047 1.1 riastrad # found an exact match
1048 1.1 riastrad func_relative_path_tcancelled=
1049 1.1 riastrad break
1050 1.1 riastrad ;;
1051 1.1 riastrad $func_relative_path_tlibdir*)
1052 1.1 riastrad # found a matching prefix
1053 1.1 riastrad func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054 1.1 riastrad func_relative_path_tcancelled=$func_stripname_result
1055 1.1 riastrad if test -z "$func_relative_path_result"; then
1056 1.1 riastrad func_relative_path_result=.
1057 1.1 riastrad fi
1058 1.1 riastrad break
1059 1.1 riastrad ;;
1060 1.1 riastrad *)
1061 1.1 riastrad func_dirname $func_relative_path_tlibdir
1062 1.1 riastrad func_relative_path_tlibdir=$func_dirname_result
1063 1.1 riastrad if test -z "$func_relative_path_tlibdir"; then
1064 1.1 riastrad # Have to descend all the way to the root!
1065 1.1 riastrad func_relative_path_result=../$func_relative_path_result
1066 1.1 riastrad func_relative_path_tcancelled=$func_relative_path_tbindir
1067 1.1 riastrad break
1068 1.1 riastrad fi
1069 1.1 riastrad func_relative_path_result=../$func_relative_path_result
1070 1.1 riastrad ;;
1071 1.1 riastrad esac
1072 1.1 riastrad done
1073 1.1 riastrad
1074 1.1 riastrad # Now calculate path; take care to avoid doubling-up slashes.
1075 1.1 riastrad func_stripname '' '/' "$func_relative_path_result"
1076 1.1 riastrad func_relative_path_result=$func_stripname_result
1077 1.1 riastrad func_stripname '/' '/' "$func_relative_path_tcancelled"
1078 1.1 riastrad if test -n "$func_stripname_result"; then
1079 1.1 riastrad func_append func_relative_path_result "/$func_stripname_result"
1080 1.1 riastrad fi
1081 1.1 riastrad
1082 1.1 riastrad # Normalisation. If bindir is libdir, return '.' else relative path.
1083 1.1 riastrad if test -n "$func_relative_path_result"; then
1084 1.1 riastrad func_stripname './' '' "$func_relative_path_result"
1085 1.1 riastrad func_relative_path_result=$func_stripname_result
1086 1.1 riastrad fi
1087 1.1 riastrad
1088 1.1 riastrad test -n "$func_relative_path_result" || func_relative_path_result=.
1089 1.1 riastrad
1090 1.1 riastrad :
1091 1.1 riastrad }
1092 1.1 riastrad
1093 1.1 riastrad
1094 1.1 riastrad # func_quote_for_eval ARG...
1095 1.1 riastrad # --------------------------
1096 1.1 riastrad # Aesthetically quote ARGs to be evaled later.
1097 1.1 riastrad # This function returns two values:
1098 1.1 riastrad # i) func_quote_for_eval_result
1099 1.1 riastrad # double-quoted, suitable for a subsequent eval
1100 1.1 riastrad # ii) func_quote_for_eval_unquoted_result
1101 1.1 riastrad # has all characters that are still active within double
1102 1.1 riastrad # quotes backslashified.
1103 1.1 riastrad func_quote_for_eval ()
1104 1.1 riastrad {
1105 1.1 riastrad $debug_cmd
1106 1.1 riastrad
1107 1.1 riastrad func_quote_for_eval_unquoted_result=
1108 1.1 riastrad func_quote_for_eval_result=
1109 1.1 riastrad while test 0 -lt $#; do
1110 1.1 riastrad case $1 in
1111 1.1 riastrad *[\\\`\"\$]*)
1112 1.1 riastrad _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1113 1.1 riastrad *)
1114 1.1 riastrad _G_unquoted_arg=$1 ;;
1115 1.1 riastrad esac
1116 1.1 riastrad if test -n "$func_quote_for_eval_unquoted_result"; then
1117 1.1 riastrad func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1118 1.1 riastrad else
1119 1.1 riastrad func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1120 1.1 riastrad fi
1121 1.1 riastrad
1122 1.1 riastrad case $_G_unquoted_arg in
1123 1.1 riastrad # Double-quote args containing shell metacharacters to delay
1124 1.1 riastrad # word splitting, command substitution and variable expansion
1125 1.1 riastrad # for a subsequent eval.
1126 1.1 riastrad # Many Bourne shells cannot handle close brackets correctly
1127 1.1 riastrad # in scan sets, so we specify it separately.
1128 1.1 riastrad *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1129 1.1 riastrad _G_quoted_arg=\"$_G_unquoted_arg\"
1130 1.1 riastrad ;;
1131 1.1 riastrad *)
1132 1.1 riastrad _G_quoted_arg=$_G_unquoted_arg
1133 1.1 riastrad ;;
1134 1.1 riastrad esac
1135 1.1 riastrad
1136 1.1 riastrad if test -n "$func_quote_for_eval_result"; then
1137 1.1 riastrad func_append func_quote_for_eval_result " $_G_quoted_arg"
1138 1.1 riastrad else
1139 1.1 riastrad func_append func_quote_for_eval_result "$_G_quoted_arg"
1140 1.1 riastrad fi
1141 1.1 riastrad shift
1142 1.1 riastrad done
1143 1.1 riastrad }
1144 1.1 riastrad
1145 1.1 riastrad
1146 1.1 riastrad # func_quote_for_expand ARG
1147 1.1 riastrad # -------------------------
1148 1.1 riastrad # Aesthetically quote ARG to be evaled later; same as above,
1149 1.1 riastrad # but do not quote variable references.
1150 1.1 riastrad func_quote_for_expand ()
1151 1.1 riastrad {
1152 1.1 riastrad $debug_cmd
1153 1.1 riastrad
1154 1.1 riastrad case $1 in
1155 1.1 riastrad *[\\\`\"]*)
1156 1.1 riastrad _G_arg=`$ECHO "$1" | $SED \
1157 1.1 riastrad -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1158 1.1 riastrad *)
1159 1.1 riastrad _G_arg=$1 ;;
1160 1.1 riastrad esac
1161 1.1 riastrad
1162 1.1 riastrad case $_G_arg in
1163 1.1 riastrad # Double-quote args containing shell metacharacters to delay
1164 1.1 riastrad # word splitting and command substitution for a subsequent eval.
1165 1.1 riastrad # Many Bourne shells cannot handle close brackets correctly
1166 1.1 riastrad # in scan sets, so we specify it separately.
1167 1.1 riastrad *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1168 1.1 riastrad _G_arg=\"$_G_arg\"
1169 1.1 riastrad ;;
1170 1.1 riastrad esac
1171 1.1 riastrad
1172 1.1 riastrad func_quote_for_expand_result=$_G_arg
1173 1.1 riastrad }
1174 1.1 riastrad
1175 1.1 riastrad
1176 1.1 riastrad # func_stripname PREFIX SUFFIX NAME
1177 1.1 riastrad # ---------------------------------
1178 1.1 riastrad # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179 1.1 riastrad # PREFIX and SUFFIX must not contain globbing or regex special
1180 1.1 riastrad # characters, hashes, percent signs, but SUFFIX may contain a leading
1181 1.1 riastrad # dot (in which case that matches only a dot).
1182 1.1 riastrad if test yes = "$_G_HAVE_XSI_OPS"; then
1183 1.1 riastrad eval 'func_stripname ()
1184 1.1 riastrad {
1185 1.1 riastrad $debug_cmd
1186 1.1 riastrad
1187 1.1 riastrad # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188 1.1 riastrad # positional parameters, so assign one to ordinary variable first.
1189 1.1 riastrad func_stripname_result=$3
1190 1.1 riastrad func_stripname_result=${func_stripname_result#"$1"}
1191 1.1 riastrad func_stripname_result=${func_stripname_result%"$2"}
1192 1.1 riastrad }'
1193 1.1 riastrad else
1194 1.1 riastrad func_stripname ()
1195 1.1 riastrad {
1196 1.1 riastrad $debug_cmd
1197 1.1 riastrad
1198 1.1 riastrad case $2 in
1199 1.1 riastrad .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200 1.1 riastrad *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1201 1.1 riastrad esac
1202 1.1 riastrad }
1203 1.1 riastrad fi
1204 1.1 riastrad
1205 1.1 riastrad
1206 1.1 riastrad # func_show_eval CMD [FAIL_EXP]
1207 1.1 riastrad # -----------------------------
1208 1.1 riastrad # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1209 1.1 riastrad # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1210 1.1 riastrad # is given, then evaluate it.
1211 1.1 riastrad func_show_eval ()
1212 1.1 riastrad {
1213 1.1 riastrad $debug_cmd
1214 1.1 riastrad
1215 1.1 riastrad _G_cmd=$1
1216 1.1 riastrad _G_fail_exp=${2-':'}
1217 1.1 riastrad
1218 1.1 riastrad func_quote_for_expand "$_G_cmd"
1219 1.1 riastrad eval "func_notquiet $func_quote_for_expand_result"
1220 1.1 riastrad
1221 1.1 riastrad $opt_dry_run || {
1222 1.1 riastrad eval "$_G_cmd"
1223 1.1 riastrad _G_status=$?
1224 1.1 riastrad if test 0 -ne "$_G_status"; then
1225 1.1 riastrad eval "(exit $_G_status); $_G_fail_exp"
1226 1.1 riastrad fi
1227 1.1 riastrad }
1228 1.1 riastrad }
1229 1.1 riastrad
1230 1.1 riastrad
1231 1.1 riastrad # func_show_eval_locale CMD [FAIL_EXP]
1232 1.1 riastrad # ------------------------------------
1233 1.1 riastrad # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1234 1.1 riastrad # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1235 1.1 riastrad # is given, then evaluate it. Use the saved locale for evaluation.
1236 1.1 riastrad func_show_eval_locale ()
1237 1.1 riastrad {
1238 1.1 riastrad $debug_cmd
1239 1.1 riastrad
1240 1.1 riastrad _G_cmd=$1
1241 1.1 riastrad _G_fail_exp=${2-':'}
1242 1.1 riastrad
1243 1.1 riastrad $opt_quiet || {
1244 1.1 riastrad func_quote_for_expand "$_G_cmd"
1245 1.1 riastrad eval "func_echo $func_quote_for_expand_result"
1246 1.1 riastrad }
1247 1.1 riastrad
1248 1.1 riastrad $opt_dry_run || {
1249 1.1 riastrad eval "$_G_user_locale
1250 1.1 riastrad $_G_cmd"
1251 1.1 riastrad _G_status=$?
1252 1.1 riastrad eval "$_G_safe_locale"
1253 1.1 riastrad if test 0 -ne "$_G_status"; then
1254 1.1 riastrad eval "(exit $_G_status); $_G_fail_exp"
1255 1.1 riastrad fi
1256 1.1 riastrad }
1257 1.1 riastrad }
1258 1.1 riastrad
1259 1.1 riastrad
1260 1.1 riastrad # func_tr_sh
1261 1.1 riastrad # ----------
1262 1.1 riastrad # Turn $1 into a string suitable for a shell variable name.
1263 1.1 riastrad # Result is stored in $func_tr_sh_result. All characters
1264 1.1 riastrad # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1265 1.1 riastrad # if $1 begins with a digit, a '_' is prepended as well.
1266 1.1 riastrad func_tr_sh ()
1267 1.1 riastrad {
1268 1.1 riastrad $debug_cmd
1269 1.1 riastrad
1270 1.1 riastrad case $1 in
1271 1.1 riastrad [0-9]* | *[!a-zA-Z0-9_]*)
1272 1.1 riastrad func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1273 1.1 riastrad ;;
1274 1.1 riastrad * )
1275 1.1 riastrad func_tr_sh_result=$1
1276 1.1 riastrad ;;
1277 1.1 riastrad esac
1278 1.1 riastrad }
1279 1.1 riastrad
1280 1.1 riastrad
1281 1.1 riastrad # func_verbose ARG...
1282 1.1 riastrad # -------------------
1283 1.1 riastrad # Echo program name prefixed message in verbose mode only.
1284 1.1 riastrad func_verbose ()
1285 1.1 riastrad {
1286 1.1 riastrad $debug_cmd
1287 1.1 riastrad
1288 1.1 riastrad $opt_verbose && func_echo "$*"
1289 1.1 riastrad
1290 1.1 riastrad :
1291 1.1 riastrad }
1292 1.1 riastrad
1293 1.1 riastrad
1294 1.1 riastrad # func_warn_and_continue ARG...
1295 1.1 riastrad # -----------------------------
1296 1.1 riastrad # Echo program name prefixed warning message to standard error.
1297 1.1 riastrad func_warn_and_continue ()
1298 1.1 riastrad {
1299 1.1 riastrad $debug_cmd
1300 1.1 riastrad
1301 1.1 riastrad $require_term_colors
1302 1.1 riastrad
1303 1.1 riastrad func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1304 1.1 riastrad }
1305 1.1 riastrad
1306 1.1 riastrad
1307 1.1 riastrad # func_warning CATEGORY ARG...
1308 1.1 riastrad # ----------------------------
1309 1.1 riastrad # Echo program name prefixed warning message to standard error. Warning
1310 1.1 riastrad # messages can be filtered according to CATEGORY, where this function
1311 1.1 riastrad # elides messages where CATEGORY is not listed in the global variable
1312 1.1 riastrad # 'opt_warning_types'.
1313 1.1 riastrad func_warning ()
1314 1.1 riastrad {
1315 1.1 riastrad $debug_cmd
1316 1.1 riastrad
1317 1.1 riastrad # CATEGORY must be in the warning_categories list!
1318 1.1 riastrad case " $warning_categories " in
1319 1.1 riastrad *" $1 "*) ;;
1320 1.1 riastrad *) func_internal_error "invalid warning category '$1'" ;;
1321 1.1 riastrad esac
1322 1.1 riastrad
1323 1.1 riastrad _G_category=$1
1324 1.1 riastrad shift
1325 1.1 riastrad
1326 1.1 riastrad case " $opt_warning_types " in
1327 1.1 riastrad *" $_G_category "*) $warning_func ${1+"$@"} ;;
1328 1.1 riastrad esac
1329 1.1 riastrad }
1330 1.1 riastrad
1331 1.1 riastrad
1332 1.1 riastrad # func_sort_ver VER1 VER2
1333 1.1 riastrad # -----------------------
1334 1.1 riastrad # 'sort -V' is not generally available.
1335 1.1 riastrad # Note this deviates from the version comparison in automake
1336 1.1 riastrad # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337 1.1 riastrad # but this should suffice as we won't be specifying old
1338 1.1 riastrad # version formats or redundant trailing .0 in bootstrap.conf.
1339 1.1 riastrad # If we did want full compatibility then we should probably
1340 1.1 riastrad # use m4_version_compare from autoconf.
1341 1.1 riastrad func_sort_ver ()
1342 1.1 riastrad {
1343 1.1 riastrad $debug_cmd
1344 1.1 riastrad
1345 1.1 riastrad printf '%s\n%s\n' "$1" "$2" \
1346 1.1 riastrad | 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 riastrad }
1348 1.1 riastrad
1349 1.1 riastrad # func_lt_ver PREV CURR
1350 1.1 riastrad # ---------------------
1351 1.1 riastrad # Return true if PREV and CURR are in the correct order according to
1352 1.1 riastrad # func_sort_ver, otherwise false. Use it like this:
1353 1.1 riastrad #
1354 1.1 riastrad # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1355 1.1 riastrad func_lt_ver ()
1356 1.1 riastrad {
1357 1.1 riastrad $debug_cmd
1358 1.1 riastrad
1359 1.1 riastrad test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1360 1.1 riastrad }
1361 1.1 riastrad
1362 1.1 riastrad
1363 1.1 riastrad # Local variables:
1364 1.1 riastrad # mode: shell-script
1365 1.1 riastrad # sh-indentation: 2
1366 1.1 riastrad # eval: (add-hook 'before-save-hook 'time-stamp)
1367 1.1 riastrad # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368 1.1 riastrad # time-stamp-time-zone: "UTC"
1369 1.1 riastrad # End:
1370 1.1 riastrad #! /bin/sh
1371 1.1 riastrad
1372 1.1 riastrad # Set a version string for this script.
1373 1.1 riastrad scriptversion=2014-01-07.03; # UTC
1374 1.1 riastrad
1375 1.1 riastrad # A portable, pluggable option parser for Bourne shell.
1376 1.1 riastrad # Written by Gary V. Vaughan, 2010
1377 1.1 riastrad
1378 1.1 riastrad # Copyright (C) 2010-2015 Free Software Foundation, Inc.
1379 1.1 riastrad # This is free software; see the source for copying conditions. There is NO
1380 1.1 riastrad # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1381 1.1 riastrad
1382 1.1 riastrad # This program is free software: you can redistribute it and/or modify
1383 1.1 riastrad # it under the terms of the GNU General Public License as published by
1384 1.1 riastrad # the Free Software Foundation, either version 3 of the License, or
1385 1.1 riastrad # (at your option) any later version.
1386 1.1 riastrad
1387 1.1 riastrad # This program is distributed in the hope that it will be useful,
1388 1.1 riastrad # but WITHOUT ANY WARRANTY; without even the implied warranty of
1389 1.1 riastrad # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1390 1.1 riastrad # GNU General Public License for more details.
1391 1.1 riastrad
1392 1.1 riastrad # You should have received a copy of the GNU General Public License
1393 1.1 riastrad # along with this program. If not, see <http://www.gnu.org/licenses/>.
1394 1.1 riastrad
1395 1.1 riastrad # Please report bugs or propose patches to gary (at] gnu.org.
1396 1.1 riastrad
1397 1.1 riastrad
1398 1.1 riastrad ## ------ ##
1399 1.1 riastrad ## Usage. ##
1400 1.1 riastrad ## ------ ##
1401 1.1 riastrad
1402 1.1 riastrad # This file is a library for parsing options in your shell scripts along
1403 1.1 riastrad # with assorted other useful supporting features that you can make use
1404 1.1 riastrad # of too.
1405 1.1 riastrad #
1406 1.1 riastrad # For the simplest scripts you might need only:
1407 1.1 riastrad #
1408 1.1 riastrad # #!/bin/sh
1409 1.1 riastrad # . relative/path/to/funclib.sh
1410 1.1 riastrad # . relative/path/to/options-parser
1411 1.1 riastrad # scriptversion=1.0
1412 1.1 riastrad # func_options ${1+"$@"}
1413 1.1 riastrad # eval set dummy "$func_options_result"; shift
1414 1.1 riastrad # ...rest of your script...
1415 1.1 riastrad #
1416 1.1 riastrad # In order for the '--version' option to work, you will need to have a
1417 1.1 riastrad # suitably formatted comment like the one at the top of this file
1418 1.1 riastrad # starting with '# Written by ' and ending with '# warranty; '.
1419 1.1 riastrad #
1420 1.1 riastrad # For '-h' and '--help' to work, you will also need a one line
1421 1.1 riastrad # description of your script's purpose in a comment directly above the
1422 1.1 riastrad # '# Written by ' line, like the one at the top of this file.
1423 1.1 riastrad #
1424 1.1 riastrad # The default options also support '--debug', which will turn on shell
1425 1.1 riastrad # execution tracing (see the comment above debug_cmd below for another
1426 1.1 riastrad # use), and '--verbose' and the func_verbose function to allow your script
1427 1.1 riastrad # to display verbose messages only when your user has specified
1428 1.1 riastrad # '--verbose'.
1429 1.1 riastrad #
1430 1.1 riastrad # After sourcing this file, you can plug processing for additional
1431 1.1 riastrad # options by amending the variables from the 'Configuration' section
1432 1.1 riastrad # below, and following the instructions in the 'Option parsing'
1433 1.1 riastrad # section further down.
1434 1.1 riastrad
1435 1.1 riastrad ## -------------- ##
1436 1.1 riastrad ## Configuration. ##
1437 1.1 riastrad ## -------------- ##
1438 1.1 riastrad
1439 1.1 riastrad # You should override these variables in your script after sourcing this
1440 1.1 riastrad # file so that they reflect the customisations you have added to the
1441 1.1 riastrad # option parser.
1442 1.1 riastrad
1443 1.1 riastrad # The usage line for option parsing errors and the start of '-h' and
1444 1.1 riastrad # '--help' output messages. You can embed shell variables for delayed
1445 1.1 riastrad # expansion at the time the message is displayed, but you will need to
1446 1.1 riastrad # quote other shell meta-characters carefully to prevent them being
1447 1.1 riastrad # expanded when the contents are evaled.
1448 1.1 riastrad usage='$progpath [OPTION]...'
1449 1.1 riastrad
1450 1.1 riastrad # Short help message in response to '-h' and '--help'. Add to this or
1451 1.1 riastrad # override it after sourcing this library to reflect the full set of
1452 1.1 riastrad # options your script accepts.
1453 1.1 riastrad usage_message="\
1454 1.1 riastrad --debug enable verbose shell tracing
1455 1.1 riastrad -W, --warnings=CATEGORY
1456 1.1 riastrad report the warnings falling in CATEGORY [all]
1457 1.1 riastrad -v, --verbose verbosely report processing
1458 1.1 riastrad --version print version information and exit
1459 1.1 riastrad -h, --help print short or long help message and exit
1460 1.1 riastrad "
1461 1.1 riastrad
1462 1.1 riastrad # Additional text appended to 'usage_message' in response to '--help'.
1463 1.1 riastrad long_help_message="
1464 1.1 riastrad Warning categories include:
1465 1.1 riastrad 'all' show all warnings
1466 1.1 riastrad 'none' turn off all the warnings
1467 1.1 riastrad 'error' warnings are treated as fatal errors"
1468 1.1 riastrad
1469 1.1 riastrad # Help message printed before fatal option parsing errors.
1470 1.1 riastrad fatal_help="Try '\$progname --help' for more information."
1471 1.1 riastrad
1472 1.1 riastrad
1473 1.1 riastrad
1474 1.1 riastrad ## ------------------------- ##
1475 1.1 riastrad ## Hook function management. ##
1476 1.1 riastrad ## ------------------------- ##
1477 1.1 riastrad
1478 1.1 riastrad # This section contains functions for adding, removing, and running hooks
1479 1.1 riastrad # to the main code. A hook is just a named list of of function, that can
1480 1.1 riastrad # be run in order later on.
1481 1.1 riastrad
1482 1.1 riastrad # func_hookable FUNC_NAME
1483 1.1 riastrad # -----------------------
1484 1.1 riastrad # Declare that FUNC_NAME will run hooks added with
1485 1.1 riastrad # 'func_add_hook FUNC_NAME ...'.
1486 1.1 riastrad func_hookable ()
1487 1.1 riastrad {
1488 1.1 riastrad $debug_cmd
1489 1.1 riastrad
1490 1.1 riastrad func_append hookable_fns " $1"
1491 1.1 riastrad }
1492 1.1 riastrad
1493 1.1 riastrad
1494 1.1 riastrad # func_add_hook FUNC_NAME HOOK_FUNC
1495 1.1 riastrad # ---------------------------------
1496 1.1 riastrad # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1497 1.1 riastrad # first have been declared "hookable" by a call to 'func_hookable'.
1498 1.1 riastrad func_add_hook ()
1499 1.1 riastrad {
1500 1.1 riastrad $debug_cmd
1501 1.1 riastrad
1502 1.1 riastrad case " $hookable_fns " in
1503 1.1 riastrad *" $1 "*) ;;
1504 1.1 riastrad *) func_fatal_error "'$1' does not accept hook functions." ;;
1505 1.1 riastrad esac
1506 1.1 riastrad
1507 1.1 riastrad eval func_append ${1}_hooks '" $2"'
1508 1.1 riastrad }
1509 1.1 riastrad
1510 1.1 riastrad
1511 1.1 riastrad # func_remove_hook FUNC_NAME HOOK_FUNC
1512 1.1 riastrad # ------------------------------------
1513 1.1 riastrad # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1514 1.1 riastrad func_remove_hook ()
1515 1.1 riastrad {
1516 1.1 riastrad $debug_cmd
1517 1.1 riastrad
1518 1.1 riastrad eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1519 1.1 riastrad }
1520 1.1 riastrad
1521 1.1 riastrad
1522 1.1 riastrad # func_run_hooks FUNC_NAME [ARG]...
1523 1.1 riastrad # ---------------------------------
1524 1.1 riastrad # Run all hook functions registered to FUNC_NAME.
1525 1.1 riastrad # It is assumed that the list of hook functions contains nothing more
1526 1.1 riastrad # than a whitespace-delimited list of legal shell function names, and
1527 1.1 riastrad # no effort is wasted trying to catch shell meta-characters or preserve
1528 1.1 riastrad # whitespace.
1529 1.1 riastrad func_run_hooks ()
1530 1.1 riastrad {
1531 1.1 riastrad $debug_cmd
1532 1.1 riastrad
1533 1.1 riastrad case " $hookable_fns " in
1534 1.1 riastrad *" $1 "*) ;;
1535 1.1 riastrad *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1536 1.1 riastrad esac
1537 1.1 riastrad
1538 1.1 riastrad eval _G_hook_fns=\$$1_hooks; shift
1539 1.1 riastrad
1540 1.1 riastrad for _G_hook in $_G_hook_fns; do
1541 1.1 riastrad eval $_G_hook '"$@"'
1542 1.1 riastrad
1543 1.1 riastrad # store returned options list back into positional
1544 1.1 riastrad # parameters for next 'cmd' execution.
1545 1.1 riastrad eval _G_hook_result=\$${_G_hook}_result
1546 1.1 riastrad eval set dummy "$_G_hook_result"; shift
1547 1.1 riastrad done
1548 1.1 riastrad
1549 1.1 riastrad func_quote_for_eval ${1+"$@"}
1550 1.1 riastrad func_run_hooks_result=$func_quote_for_eval_result
1551 1.1 riastrad }
1552 1.1 riastrad
1553 1.1 riastrad
1554 1.1 riastrad
1555 1.1 riastrad ## --------------- ##
1556 1.1 riastrad ## Option parsing. ##
1557 1.1 riastrad ## --------------- ##
1558 1.1 riastrad
1559 1.1 riastrad # In order to add your own option parsing hooks, you must accept the
1560 1.1 riastrad # full positional parameter list in your hook function, remove any
1561 1.1 riastrad # options that you action, and then pass back the remaining unprocessed
1562 1.1 riastrad # options in '<hooked_function_name>_result', escaped suitably for
1563 1.1 riastrad # 'eval'. Like this:
1564 1.1 riastrad #
1565 1.1 riastrad # my_options_prep ()
1566 1.1 riastrad # {
1567 1.1 riastrad # $debug_cmd
1568 1.1 riastrad #
1569 1.1 riastrad # # Extend the existing usage message.
1570 1.1 riastrad # usage_message=$usage_message'
1571 1.1 riastrad # -s, --silent don'\''t print informational messages
1572 1.1 riastrad # '
1573 1.1 riastrad #
1574 1.1 riastrad # func_quote_for_eval ${1+"$@"}
1575 1.1 riastrad # my_options_prep_result=$func_quote_for_eval_result
1576 1.1 riastrad # }
1577 1.1 riastrad # func_add_hook func_options_prep my_options_prep
1578 1.1 riastrad #
1579 1.1 riastrad #
1580 1.1 riastrad # my_silent_option ()
1581 1.1 riastrad # {
1582 1.1 riastrad # $debug_cmd
1583 1.1 riastrad #
1584 1.1 riastrad # # Note that for efficiency, we parse as many options as we can
1585 1.1 riastrad # # recognise in a loop before passing the remainder back to the
1586 1.1 riastrad # # caller on the first unrecognised argument we encounter.
1587 1.1 riastrad # while test $# -gt 0; do
1588 1.1 riastrad # opt=$1; shift
1589 1.1 riastrad # case $opt in
1590 1.1 riastrad # --silent|-s) opt_silent=: ;;
1591 1.1 riastrad # # Separate non-argument short options:
1592 1.1 riastrad # -s*) func_split_short_opt "$_G_opt"
1593 1.1 riastrad # set dummy "$func_split_short_opt_name" \
1594 1.1 riastrad # "-$func_split_short_opt_arg" ${1+"$@"}
1595 1.1 riastrad # shift
1596 1.1 riastrad # ;;
1597 1.1 riastrad # *) set dummy "$_G_opt" "$*"; shift; break ;;
1598 1.1 riastrad # esac
1599 1.1 riastrad # done
1600 1.1 riastrad #
1601 1.1 riastrad # func_quote_for_eval ${1+"$@"}
1602 1.1 riastrad # my_silent_option_result=$func_quote_for_eval_result
1603 1.1 riastrad # }
1604 1.1 riastrad # func_add_hook func_parse_options my_silent_option
1605 1.1 riastrad #
1606 1.1 riastrad #
1607 1.1 riastrad # my_option_validation ()
1608 1.1 riastrad # {
1609 1.1 riastrad # $debug_cmd
1610 1.1 riastrad #
1611 1.1 riastrad # $opt_silent && $opt_verbose && func_fatal_help "\
1612 1.1 riastrad # '--silent' and '--verbose' options are mutually exclusive."
1613 1.1 riastrad #
1614 1.1 riastrad # func_quote_for_eval ${1+"$@"}
1615 1.1 riastrad # my_option_validation_result=$func_quote_for_eval_result
1616 1.1 riastrad # }
1617 1.1 riastrad # func_add_hook func_validate_options my_option_validation
1618 1.1 riastrad #
1619 1.1 riastrad # You'll alse need to manually amend $usage_message to reflect the extra
1620 1.1 riastrad # options you parse. It's preferable to append if you can, so that
1621 1.1 riastrad # multiple option parsing hooks can be added safely.
1622 1.1 riastrad
1623 1.1 riastrad
1624 1.1 riastrad # func_options [ARG]...
1625 1.1 riastrad # ---------------------
1626 1.1 riastrad # All the functions called inside func_options are hookable. See the
1627 1.1 riastrad # individual implementations for details.
1628 1.1 riastrad func_hookable func_options
1629 1.1 riastrad func_options ()
1630 1.1 riastrad {
1631 1.1 riastrad $debug_cmd
1632 1.1 riastrad
1633 1.1 riastrad func_options_prep ${1+"$@"}
1634 1.1 riastrad eval func_parse_options \
1635 1.1 riastrad ${func_options_prep_result+"$func_options_prep_result"}
1636 1.1 riastrad eval func_validate_options \
1637 1.1 riastrad ${func_parse_options_result+"$func_parse_options_result"}
1638 1.1 riastrad
1639 1.1 riastrad eval func_run_hooks func_options \
1640 1.1 riastrad ${func_validate_options_result+"$func_validate_options_result"}
1641 1.1 riastrad
1642 1.1 riastrad # save modified positional parameters for caller
1643 1.1 riastrad func_options_result=$func_run_hooks_result
1644 1.1 riastrad }
1645 1.1 riastrad
1646 1.1 riastrad
1647 1.1 riastrad # func_options_prep [ARG]...
1648 1.1 riastrad # --------------------------
1649 1.1 riastrad # All initialisations required before starting the option parse loop.
1650 1.1 riastrad # Note that when calling hook functions, we pass through the list of
1651 1.1 riastrad # positional parameters. If a hook function modifies that list, and
1652 1.1 riastrad # needs to propogate that back to rest of this script, then the complete
1653 1.1 riastrad # modified list must be put in 'func_run_hooks_result' before
1654 1.1 riastrad # returning.
1655 1.1 riastrad func_hookable func_options_prep
1656 1.1 riastrad func_options_prep ()
1657 1.1 riastrad {
1658 1.1 riastrad $debug_cmd
1659 1.1 riastrad
1660 1.1 riastrad # Option defaults:
1661 1.1 riastrad opt_verbose=false
1662 1.1 riastrad opt_warning_types=
1663 1.1 riastrad
1664 1.1 riastrad func_run_hooks func_options_prep ${1+"$@"}
1665 1.1 riastrad
1666 1.1 riastrad # save modified positional parameters for caller
1667 1.1 riastrad func_options_prep_result=$func_run_hooks_result
1668 1.1 riastrad }
1669 1.1 riastrad
1670 1.1 riastrad
1671 1.1 riastrad # func_parse_options [ARG]...
1672 1.1 riastrad # ---------------------------
1673 1.1 riastrad # The main option parsing loop.
1674 1.1 riastrad func_hookable func_parse_options
1675 1.1 riastrad func_parse_options ()
1676 1.1 riastrad {
1677 1.1 riastrad $debug_cmd
1678 1.1 riastrad
1679 1.1 riastrad func_parse_options_result=
1680 1.1 riastrad
1681 1.1 riastrad # this just eases exit handling
1682 1.1 riastrad while test $# -gt 0; do
1683 1.1 riastrad # Defer to hook functions for initial option parsing, so they
1684 1.1 riastrad # get priority in the event of reusing an option name.
1685 1.1 riastrad func_run_hooks func_parse_options ${1+"$@"}
1686 1.1 riastrad
1687 1.1 riastrad # Adjust func_parse_options positional parameters to match
1688 1.1 riastrad eval set dummy "$func_run_hooks_result"; shift
1689 1.1 riastrad
1690 1.1 riastrad # Break out of the loop if we already parsed every option.
1691 1.1 riastrad test $# -gt 0 || break
1692 1.1 riastrad
1693 1.1 riastrad _G_opt=$1
1694 1.1 riastrad shift
1695 1.1 riastrad case $_G_opt in
1696 1.1 riastrad --debug|-x) debug_cmd='set -x'
1697 1.1 riastrad func_echo "enabling shell trace mode"
1698 1.1 riastrad $debug_cmd
1699 1.1 riastrad ;;
1700 1.1 riastrad
1701 1.1 riastrad --no-warnings|--no-warning|--no-warn)
1702 1.1 riastrad set dummy --warnings none ${1+"$@"}
1703 1.1 riastrad shift
1704 1.1 riastrad ;;
1705 1.1 riastrad
1706 1.1 riastrad --warnings|--warning|-W)
1707 1.1 riastrad test $# = 0 && func_missing_arg $_G_opt && break
1708 1.1 riastrad case " $warning_categories $1" in
1709 1.1 riastrad *" $1 "*)
1710 1.1 riastrad # trailing space prevents matching last $1 above
1711 1.1 riastrad func_append_uniq opt_warning_types " $1"
1712 1.1 riastrad ;;
1713 1.1 riastrad *all)
1714 1.1 riastrad opt_warning_types=$warning_categories
1715 1.1 riastrad ;;
1716 1.1 riastrad *none)
1717 1.1 riastrad opt_warning_types=none
1718 1.1 riastrad warning_func=:
1719 1.1 riastrad ;;
1720 1.1 riastrad *error)
1721 1.1 riastrad opt_warning_types=$warning_categories
1722 1.1 riastrad warning_func=func_fatal_error
1723 1.1 riastrad ;;
1724 1.1 riastrad *)
1725 1.1 riastrad func_fatal_error \
1726 1.1 riastrad "unsupported warning category: '$1'"
1727 1.1 riastrad ;;
1728 1.1 riastrad esac
1729 1.1 riastrad shift
1730 1.1 riastrad ;;
1731 1.1 riastrad
1732 1.1 riastrad --verbose|-v) opt_verbose=: ;;
1733 1.1 riastrad --version) func_version ;;
1734 1.1 riastrad -\?|-h) func_usage ;;
1735 1.1 riastrad --help) func_help ;;
1736 1.1 riastrad
1737 1.1 riastrad # Separate optargs to long options (plugins may need this):
1738 1.1 riastrad --*=*) func_split_equals "$_G_opt"
1739 1.1 riastrad set dummy "$func_split_equals_lhs" \
1740 1.1 riastrad "$func_split_equals_rhs" ${1+"$@"}
1741 1.1 riastrad shift
1742 1.1 riastrad ;;
1743 1.1 riastrad
1744 1.1 riastrad # Separate optargs to short options:
1745 1.1 riastrad -W*)
1746 1.1 riastrad func_split_short_opt "$_G_opt"
1747 1.1 riastrad set dummy "$func_split_short_opt_name" \
1748 1.1 riastrad "$func_split_short_opt_arg" ${1+"$@"}
1749 1.1 riastrad shift
1750 1.1 riastrad ;;
1751 1.1 riastrad
1752 1.1 riastrad # Separate non-argument short options:
1753 1.1 riastrad -\?*|-h*|-v*|-x*)
1754 1.1 riastrad func_split_short_opt "$_G_opt"
1755 1.1 riastrad set dummy "$func_split_short_opt_name" \
1756 1.1 riastrad "-$func_split_short_opt_arg" ${1+"$@"}
1757 1.1 riastrad shift
1758 1.1 riastrad ;;
1759 1.1 riastrad
1760 1.1 riastrad --) break ;;
1761 1.1 riastrad -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
1762 1.1 riastrad *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1763 1.1 riastrad esac
1764 1.1 riastrad done
1765 1.1 riastrad
1766 1.1 riastrad # save modified positional parameters for caller
1767 1.1 riastrad func_quote_for_eval ${1+"$@"}
1768 1.1 riastrad func_parse_options_result=$func_quote_for_eval_result
1769 1.1 riastrad }
1770 1.1 riastrad
1771 1.1 riastrad
1772 1.1 riastrad # func_validate_options [ARG]...
1773 1.1 riastrad # ------------------------------
1774 1.1 riastrad # Perform any sanity checks on option settings and/or unconsumed
1775 1.1 riastrad # arguments.
1776 1.1 riastrad func_hookable func_validate_options
1777 1.1 riastrad func_validate_options ()
1778 1.1 riastrad {
1779 1.1 riastrad $debug_cmd
1780 1.1 riastrad
1781 1.1 riastrad # Display all warnings if -W was not given.
1782 1.1 riastrad test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783 1.1 riastrad
1784 1.1 riastrad func_run_hooks func_validate_options ${1+"$@"}
1785 1.1 riastrad
1786 1.1 riastrad # Bail if the options were screwed!
1787 1.1 riastrad $exit_cmd $EXIT_FAILURE
1788 1.1 riastrad
1789 1.1 riastrad # save modified positional parameters for caller
1790 1.1 riastrad func_validate_options_result=$func_run_hooks_result
1791 1.1 riastrad }
1792 1.1 riastrad
1793 1.1 riastrad
1794 1.1 riastrad
1795 1.1 riastrad ## ----------------- ##
1796 1.1 riastrad ## Helper functions. ##
1797 1.1 riastrad ## ----------------- ##
1798 1.1 riastrad
1799 1.1 riastrad # This section contains the helper functions used by the rest of the
1800 1.1 riastrad # hookable option parser framework in ascii-betical order.
1801 1.1 riastrad
1802 1.1 riastrad
1803 1.1 riastrad # func_fatal_help ARG...
1804 1.1 riastrad # ----------------------
1805 1.1 riastrad # Echo program name prefixed message to standard error, followed by
1806 1.1 riastrad # a help hint, and exit.
1807 1.1 riastrad func_fatal_help ()
1808 1.1 riastrad {
1809 1.1 riastrad $debug_cmd
1810 1.1 riastrad
1811 1.1 riastrad eval \$ECHO \""Usage: $usage"\"
1812 1.1 riastrad eval \$ECHO \""$fatal_help"\"
1813 1.1 riastrad func_error ${1+"$@"}
1814 1.1 riastrad exit $EXIT_FAILURE
1815 1.1 riastrad }
1816 1.1 riastrad
1817 1.1 riastrad
1818 1.1 riastrad # func_help
1819 1.1 riastrad # ---------
1820 1.1 riastrad # Echo long help message to standard output and exit.
1821 1.1 riastrad func_help ()
1822 1.1 riastrad {
1823 1.1 riastrad $debug_cmd
1824 1.1 riastrad
1825 1.1 riastrad func_usage_message
1826 1.1 riastrad $ECHO "$long_help_message"
1827 1.1 riastrad exit 0
1828 1.1 riastrad }
1829 1.1 riastrad
1830 1.1 riastrad
1831 1.1 riastrad # func_missing_arg ARGNAME
1832 1.1 riastrad # ------------------------
1833 1.1 riastrad # Echo program name prefixed message to standard error and set global
1834 1.1 riastrad # exit_cmd.
1835 1.1 riastrad func_missing_arg ()
1836 1.1 riastrad {
1837 1.1 riastrad $debug_cmd
1838 1.1 riastrad
1839 1.1 riastrad func_error "Missing argument for '$1'."
1840 1.1 riastrad exit_cmd=exit
1841 1.1 riastrad }
1842 1.1 riastrad
1843 1.1 riastrad
1844 1.1 riastrad # func_split_equals STRING
1845 1.1 riastrad # ------------------------
1846 1.1 riastrad # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1847 1.1 riastrad # splitting STRING at the '=' sign.
1848 1.1 riastrad test -z "$_G_HAVE_XSI_OPS" \
1849 1.1 riastrad && (eval 'x=a/b/c;
1850 1.1 riastrad test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1851 1.1 riastrad && _G_HAVE_XSI_OPS=yes
1852 1.1 riastrad
1853 1.1 riastrad if test yes = "$_G_HAVE_XSI_OPS"
1854 1.1 riastrad then
1855 1.1 riastrad # This is an XSI compatible shell, allowing a faster implementation...
1856 1.1 riastrad eval 'func_split_equals ()
1857 1.1 riastrad {
1858 1.1 riastrad $debug_cmd
1859 1.1 riastrad
1860 1.1 riastrad func_split_equals_lhs=${1%%=*}
1861 1.1 riastrad func_split_equals_rhs=${1#*=}
1862 1.1 riastrad test "x$func_split_equals_lhs" = "x$1" \
1863 1.1 riastrad && func_split_equals_rhs=
1864 1.1 riastrad }'
1865 1.1 riastrad else
1866 1.1 riastrad # ...otherwise fall back to using expr, which is often a shell builtin.
1867 1.1 riastrad func_split_equals ()
1868 1.1 riastrad {
1869 1.1 riastrad $debug_cmd
1870 1.1 riastrad
1871 1.1 riastrad func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1872 1.1 riastrad func_split_equals_rhs=
1873 1.1 riastrad test "x$func_split_equals_lhs" = "x$1" \
1874 1.1 riastrad || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1875 1.1 riastrad }
1876 1.1 riastrad fi #func_split_equals
1877 1.1 riastrad
1878 1.1 riastrad
1879 1.1 riastrad # func_split_short_opt SHORTOPT
1880 1.1 riastrad # -----------------------------
1881 1.1 riastrad # Set func_split_short_opt_name and func_split_short_opt_arg shell
1882 1.1 riastrad # variables after splitting SHORTOPT after the 2nd character.
1883 1.1 riastrad if test yes = "$_G_HAVE_XSI_OPS"
1884 1.1 riastrad then
1885 1.1 riastrad # This is an XSI compatible shell, allowing a faster implementation...
1886 1.1 riastrad eval 'func_split_short_opt ()
1887 1.1 riastrad {
1888 1.1 riastrad $debug_cmd
1889 1.1 riastrad
1890 1.1 riastrad func_split_short_opt_arg=${1#??}
1891 1.1 riastrad func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1892 1.1 riastrad }'
1893 1.1 riastrad else
1894 1.1 riastrad # ...otherwise fall back to using expr, which is often a shell builtin.
1895 1.1 riastrad func_split_short_opt ()
1896 1.1 riastrad {
1897 1.1 riastrad $debug_cmd
1898 1.1 riastrad
1899 1.1 riastrad func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1900 1.1 riastrad func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1901 1.1 riastrad }
1902 1.1 riastrad fi #func_split_short_opt
1903 1.1 riastrad
1904 1.1 riastrad
1905 1.1 riastrad # func_usage
1906 1.1 riastrad # ----------
1907 1.1 riastrad # Echo short help message to standard output and exit.
1908 1.1 riastrad func_usage ()
1909 1.1 riastrad {
1910 1.1 riastrad $debug_cmd
1911 1.1 riastrad
1912 1.1 riastrad func_usage_message
1913 1.1 riastrad $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1914 1.1 riastrad exit 0
1915 1.1 riastrad }
1916 1.1 riastrad
1917 1.1 riastrad
1918 1.1 riastrad # func_usage_message
1919 1.1 riastrad # ------------------
1920 1.1 riastrad # Echo short help message to standard output.
1921 1.1 riastrad func_usage_message ()
1922 1.1 riastrad {
1923 1.1 riastrad $debug_cmd
1924 1.1 riastrad
1925 1.1 riastrad eval \$ECHO \""Usage: $usage"\"
1926 1.1 riastrad echo
1927 1.1 riastrad $SED -n 's|^# ||
1928 1.1 riastrad /^Written by/{
1929 1.1 riastrad x;p;x
1930 1.1 riastrad }
1931 1.1 riastrad h
1932 1.1 riastrad /^Written by/q' < "$progpath"
1933 1.1 riastrad echo
1934 1.1 riastrad eval \$ECHO \""$usage_message"\"
1935 1.1 riastrad }
1936 1.1 riastrad
1937 1.1 riastrad
1938 1.1 riastrad # func_version
1939 1.1 riastrad # ------------
1940 1.1 riastrad # Echo version message to standard output and exit.
1941 1.1 riastrad func_version ()
1942 1.1 riastrad {
1943 1.1 riastrad $debug_cmd
1944 1.1 riastrad
1945 1.1 riastrad printf '%s\n' "$progname $scriptversion"
1946 1.1 riastrad $SED -n '
1947 1.1 riastrad /(C)/!b go
1948 1.1 riastrad :more
1949 1.1 riastrad /\./!{
1950 1.1 riastrad N
1951 1.1 riastrad s|\n# | |
1952 1.1 riastrad b more
1953 1.1 riastrad }
1954 1.1 riastrad :go
1955 1.1 riastrad /^# Written by /,/# warranty; / {
1956 1.1 riastrad s|^# ||
1957 1.1 riastrad s|^# *$||
1958 1.1 riastrad s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1959 1.1 riastrad p
1960 1.1 riastrad }
1961 1.1 riastrad /^# Written by / {
1962 1.1 riastrad s|^# ||
1963 1.1 riastrad p
1964 1.1 riastrad }
1965 1.1 riastrad /^warranty; /q' < "$progpath"
1966 1.1 riastrad
1967 1.1 riastrad exit $?
1968 1.1 riastrad }
1969 1.1 riastrad
1970 1.1 riastrad
1971 1.1 riastrad # Local variables:
1972 1.1 riastrad # mode: shell-script
1973 1.1 riastrad # sh-indentation: 2
1974 1.1 riastrad # eval: (add-hook 'before-save-hook 'time-stamp)
1975 1.1 riastrad # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1976 1.1 riastrad # time-stamp-time-zone: "UTC"
1977 1.1 riastrad # End:
1978 1.1 riastrad
1979 1.1 riastrad # Set a version string.
1980 1.1 riastrad scriptversion='(GNU libtool) 2.4.6'
1981 1.1 riastrad
1982 1.1 riastrad
1983 1.1 riastrad # func_echo ARG...
1984 1.1 riastrad # ----------------
1985 1.1 riastrad # Libtool also displays the current mode in messages, so override
1986 1.1 riastrad # funclib.sh func_echo with this custom definition.
1987 1.1 riastrad func_echo ()
1988 1.1 riastrad {
1989 1.1 riastrad $debug_cmd
1990 1.1 riastrad
1991 1.1 riastrad _G_message=$*
1992 1.1 riastrad
1993 1.1 riastrad func_echo_IFS=$IFS
1994 1.1 riastrad IFS=$nl
1995 1.1 riastrad for _G_line in $_G_message; do
1996 1.1 riastrad IFS=$func_echo_IFS
1997 1.1 riastrad $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
1998 1.1 riastrad done
1999 1.1 riastrad IFS=$func_echo_IFS
2000 1.1 riastrad }
2001 1.1 riastrad
2002 1.1 riastrad
2003 1.1 riastrad # func_warning ARG...
2004 1.1 riastrad # -------------------
2005 1.1 riastrad # Libtool warnings are not categorized, so override funclib.sh
2006 1.1 riastrad # func_warning with this simpler definition.
2007 1.1 riastrad func_warning ()
2008 1.1 riastrad {
2009 1.1 riastrad $debug_cmd
2010 1.1 riastrad
2011 1.1 riastrad $warning_func ${1+"$@"}
2012 1.1 riastrad }
2013 1.1 riastrad
2014 1.1 riastrad
2015 1.1 riastrad ## ---------------- ##
2016 1.1 riastrad ## Options parsing. ##
2017 1.1 riastrad ## ---------------- ##
2018 1.1 riastrad
2019 1.1 riastrad # Hook in the functions to make sure our own options are parsed during
2020 1.1 riastrad # the option parsing loop.
2021 1.1 riastrad
2022 1.1 riastrad usage='$progpath [OPTION]... [MODE-ARG]...'
2023 1.1 riastrad
2024 1.1 riastrad # Short help message in response to '-h'.
2025 1.1 riastrad usage_message="Options:
2026 1.1 riastrad --config show all configuration variables
2027 1.1 riastrad --debug enable verbose shell tracing
2028 1.1 riastrad -n, --dry-run display commands without modifying any files
2029 1.1 riastrad --features display basic configuration information and exit
2030 1.1 riastrad --mode=MODE use operation mode MODE
2031 1.1 riastrad --no-warnings equivalent to '-Wnone'
2032 1.1 riastrad --preserve-dup-deps don't remove duplicate dependency libraries
2033 1.1 riastrad --quiet, --silent don't print informational messages
2034 1.1 riastrad --tag=TAG use configuration variables from tag TAG
2035 1.1 riastrad -v, --verbose print more informational messages than default
2036 1.1 riastrad --version print version information
2037 1.1 riastrad -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
2038 1.1 riastrad -h, --help, --help-all print short, long, or detailed help message
2039 1.1 riastrad "
2040 1.1 riastrad
2041 1.1 riastrad # Additional text appended to 'usage_message' in response to '--help'.
2042 1.1 riastrad func_help ()
2043 1.1 riastrad {
2044 1.1 riastrad $debug_cmd
2045 1.1 riastrad
2046 1.1 riastrad func_usage_message
2047 1.1 riastrad $ECHO "$long_help_message
2048 1.1 riastrad
2049 1.1 riastrad MODE must be one of the following:
2050 1.1 riastrad
2051 1.1 riastrad clean remove files from the build directory
2052 1.1 riastrad compile compile a source file into a libtool object
2053 1.1 riastrad execute automatically set library path, then run a program
2054 1.1 riastrad finish complete the installation of libtool libraries
2055 1.1 riastrad install install libraries or executables
2056 1.1 riastrad link create a library or an executable
2057 1.1 riastrad uninstall remove libraries from an installed directory
2058 1.1 riastrad
2059 1.1 riastrad MODE-ARGS vary depending on the MODE. When passed as first option,
2060 1.1 riastrad '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2061 1.1 riastrad Try '$progname --help --mode=MODE' for a more detailed description of MODE.
2062 1.1 riastrad
2063 1.1 riastrad When reporting a bug, please describe a test case to reproduce it and
2064 1.1 riastrad include the following information:
2065 1.1 riastrad
2066 1.1 riastrad host-triplet: $host
2067 1.1 riastrad shell: $SHELL
2068 1.1 riastrad compiler: $LTCC
2069 1.1 riastrad compiler flags: $LTCFLAGS
2070 1.1 riastrad linker: $LD (gnu? $with_gnu_ld)
2071 1.1 riastrad version: $progname (GNU libtool) 2.4.6
2072 1.1 riastrad automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2073 1.1 riastrad autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2074 1.1 riastrad
2075 1.1 riastrad Report bugs to <bug-libtool (at] gnu.org>.
2076 1.1 riastrad GNU libtool home page: <http://www.gnu.org/software/libtool/>.
2077 1.1 riastrad General help using GNU software: <http://www.gnu.org/gethelp/>."
2078 1.1 riastrad exit 0
2079 1.1 riastrad }
2080 1.1 riastrad
2081 1.1 riastrad
2082 1.1 riastrad # func_lo2o OBJECT-NAME
2083 1.1 riastrad # ---------------------
2084 1.1 riastrad # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2085 1.1 riastrad # object suffix.
2086 1.1 riastrad
2087 1.1 riastrad lo2o=s/\\.lo\$/.$objext/
2088 1.1 riastrad o2lo=s/\\.$objext\$/.lo/
2089 1.1 riastrad
2090 1.1 riastrad if test yes = "$_G_HAVE_XSI_OPS"; then
2091 1.1 riastrad eval 'func_lo2o ()
2092 1.1 riastrad {
2093 1.1 riastrad case $1 in
2094 1.1 riastrad *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2095 1.1 riastrad * ) func_lo2o_result=$1 ;;
2096 1.1 riastrad esac
2097 1.1 riastrad }'
2098 1.1 riastrad
2099 1.1 riastrad # func_xform LIBOBJ-OR-SOURCE
2100 1.1 riastrad # ---------------------------
2101 1.1 riastrad # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2102 1.1 riastrad # suffix to a '.lo' libtool-object suffix.
2103 1.1 riastrad eval 'func_xform ()
2104 1.1 riastrad {
2105 1.1 riastrad func_xform_result=${1%.*}.lo
2106 1.1 riastrad }'
2107 1.1 riastrad else
2108 1.1 riastrad # ...otherwise fall back to using sed.
2109 1.1 riastrad func_lo2o ()
2110 1.1 riastrad {
2111 1.1 riastrad func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2112 1.1 riastrad }
2113 1.1 riastrad
2114 1.1 riastrad func_xform ()
2115 1.1 riastrad {
2116 1.1 riastrad func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2117 1.1 riastrad }
2118 1.1 riastrad fi
2119 1.1 riastrad
2120 1.1 riastrad
2121 1.1 riastrad # func_fatal_configuration ARG...
2122 1.1 riastrad # -------------------------------
2123 1.1 riastrad # Echo program name prefixed message to standard error, followed by
2124 1.1 riastrad # a configuration failure hint, and exit.
2125 1.1 riastrad func_fatal_configuration ()
2126 1.1 riastrad {
2127 1.1 riastrad func__fatal_error ${1+"$@"} \
2128 1.1 riastrad "See the $PACKAGE documentation for more information." \
2129 1.1 riastrad "Fatal configuration error."
2130 1.1 riastrad }
2131 1.1 riastrad
2132 1.1 riastrad
2133 1.1 riastrad # func_config
2134 1.1 riastrad # -----------
2135 1.1 riastrad # Display the configuration for all the tags in this script.
2136 1.1 riastrad func_config ()
2137 1.1 riastrad {
2138 1.1 riastrad re_begincf='^# ### BEGIN LIBTOOL'
2139 1.1 riastrad re_endcf='^# ### END LIBTOOL'
2140 1.1 riastrad
2141 1.1 riastrad # Default configuration.
2142 1.1 riastrad $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2143 1.1 riastrad
2144 1.1 riastrad # Now print the configurations for the tags.
2145 1.1 riastrad for tagname in $taglist; do
2146 1.1 riastrad $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147 1.1 riastrad done
2148 1.1 riastrad
2149 1.1 riastrad exit $?
2150 1.1 riastrad }
2151 1.1 riastrad
2152 1.1 riastrad
2153 1.1 riastrad # func_features
2154 1.1 riastrad # -------------
2155 1.1 riastrad # Display the features supported by this script.
2156 1.1 riastrad func_features ()
2157 1.1 riastrad {
2158 1.1 riastrad echo "host: $host"
2159 1.1 riastrad if test yes = "$build_libtool_libs"; then
2160 1.1 riastrad echo "enable shared libraries"
2161 1.1 riastrad else
2162 1.1 riastrad echo "disable shared libraries"
2163 1.1 riastrad fi
2164 1.1 riastrad if test yes = "$build_old_libs"; then
2165 1.1 riastrad echo "enable static libraries"
2166 1.1 riastrad else
2167 1.1 riastrad echo "disable static libraries"
2168 1.1 riastrad fi
2169 1.1 riastrad
2170 1.1 riastrad exit $?
2171 1.1 riastrad }
2172 1.1 riastrad
2173 1.1 riastrad
2174 1.1 riastrad # func_enable_tag TAGNAME
2175 1.1 riastrad # -----------------------
2176 1.1 riastrad # Verify that TAGNAME is valid, and either flag an error and exit, or
2177 1.1 riastrad # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
2178 1.1 riastrad # variable here.
2179 1.1 riastrad func_enable_tag ()
2180 1.1 riastrad {
2181 1.1 riastrad # Global variable:
2182 1.1 riastrad tagname=$1
2183 1.1 riastrad
2184 1.1 riastrad re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2185 1.1 riastrad re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2186 1.1 riastrad sed_extractcf=/$re_begincf/,/$re_endcf/p
2187 1.1 riastrad
2188 1.1 riastrad # Validate tagname.
2189 1.1 riastrad case $tagname in
2190 1.1 riastrad *[!-_A-Za-z0-9,/]*)
2191 1.1 riastrad func_fatal_error "invalid tag name: $tagname"
2192 1.1 riastrad ;;
2193 1.1 riastrad esac
2194 1.1 riastrad
2195 1.1 riastrad # Don't test for the "default" C tag, as we know it's
2196 1.1 riastrad # there but not specially marked.
2197 1.1 riastrad case $tagname in
2198 1.1 riastrad CC) ;;
2199 1.1 riastrad *)
2200 1.1 riastrad if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2201 1.1 riastrad taglist="$taglist $tagname"
2202 1.1 riastrad
2203 1.1 riastrad # Evaluate the configuration. Be careful to quote the path
2204 1.1 riastrad # and the sed script, to avoid splitting on whitespace, but
2205 1.1 riastrad # also don't use non-portable quotes within backquotes within
2206 1.1 riastrad # quotes we have to do it in 2 steps:
2207 1.1 riastrad extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2208 1.1 riastrad eval "$extractedcf"
2209 1.1 riastrad else
2210 1.1 riastrad func_error "ignoring unknown tag $tagname"
2211 1.1 riastrad fi
2212 1.1 riastrad ;;
2213 1.1 riastrad esac
2214 1.1 riastrad }
2215 1.1 riastrad
2216 1.1 riastrad
2217 1.1 riastrad # func_check_version_match
2218 1.1 riastrad # ------------------------
2219 1.1 riastrad # Ensure that we are using m4 macros, and libtool script from the same
2220 1.1 riastrad # release of libtool.
2221 1.1 riastrad func_check_version_match ()
2222 1.1 riastrad {
2223 1.1 riastrad if test "$package_revision" != "$macro_revision"; then
2224 1.1 riastrad if test "$VERSION" != "$macro_version"; then
2225 1.1 riastrad if test -z "$macro_version"; then
2226 1.1 riastrad cat >&2 <<_LT_EOF
2227 1.1 riastrad $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2228 1.1 riastrad $progname: definition of this LT_INIT comes from an older release.
2229 1.1 riastrad $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230 1.1 riastrad $progname: and run autoconf again.
2231 1.1 riastrad _LT_EOF
2232 1.1 riastrad else
2233 1.1 riastrad cat >&2 <<_LT_EOF
2234 1.1 riastrad $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2235 1.1 riastrad $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236 1.1 riastrad $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237 1.1 riastrad $progname: and run autoconf again.
2238 1.1 riastrad _LT_EOF
2239 1.1 riastrad fi
2240 1.1 riastrad else
2241 1.1 riastrad cat >&2 <<_LT_EOF
2242 1.1 riastrad $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
2243 1.1 riastrad $progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244 1.1 riastrad $progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245 1.1 riastrad $progname: of $PACKAGE $VERSION and run autoconf again.
2246 1.1 riastrad _LT_EOF
2247 1.1 riastrad fi
2248 1.1 riastrad
2249 1.1 riastrad exit $EXIT_MISMATCH
2250 1.1 riastrad fi
2251 1.1 riastrad }
2252 1.1 riastrad
2253 1.1 riastrad
2254 1.1 riastrad # libtool_options_prep [ARG]...
2255 1.1 riastrad # -----------------------------
2256 1.1 riastrad # Preparation for options parsed by libtool.
2257 1.1 riastrad libtool_options_prep ()
2258 1.1 riastrad {
2259 1.1 riastrad $debug_mode
2260 1.1 riastrad
2261 1.1 riastrad # Option defaults:
2262 1.1 riastrad opt_config=false
2263 1.1 riastrad opt_dlopen=
2264 1.1 riastrad opt_dry_run=false
2265 1.1 riastrad opt_help=false
2266 1.1 riastrad opt_mode=
2267 1.1 riastrad opt_preserve_dup_deps=false
2268 1.1 riastrad opt_quiet=false
2269 1.1 riastrad
2270 1.1 riastrad nonopt=
2271 1.1 riastrad preserve_args=
2272 1.1 riastrad
2273 1.1 riastrad # Shorthand for --mode=foo, only valid as the first argument
2274 1.1 riastrad case $1 in
2275 1.1 riastrad clean|clea|cle|cl)
2276 1.1 riastrad shift; set dummy --mode clean ${1+"$@"}; shift
2277 1.1 riastrad ;;
2278 1.1 riastrad compile|compil|compi|comp|com|co|c)
2279 1.1 riastrad shift; set dummy --mode compile ${1+"$@"}; shift
2280 1.1 riastrad ;;
2281 1.1 riastrad execute|execut|execu|exec|exe|ex|e)
2282 1.1 riastrad shift; set dummy --mode execute ${1+"$@"}; shift
2283 1.1 riastrad ;;
2284 1.1 riastrad finish|finis|fini|fin|fi|f)
2285 1.1 riastrad shift; set dummy --mode finish ${1+"$@"}; shift
2286 1.1 riastrad ;;
2287 1.1 riastrad install|instal|insta|inst|ins|in|i)
2288 1.1 riastrad shift; set dummy --mode install ${1+"$@"}; shift
2289 1.1 riastrad ;;
2290 1.1 riastrad link|lin|li|l)
2291 1.1 riastrad shift; set dummy --mode link ${1+"$@"}; shift
2292 1.1 riastrad ;;
2293 1.1 riastrad uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2294 1.1 riastrad shift; set dummy --mode uninstall ${1+"$@"}; shift
2295 1.1 riastrad ;;
2296 1.1 riastrad esac
2297 1.1 riastrad
2298 1.1 riastrad # Pass back the list of options.
2299 1.1 riastrad func_quote_for_eval ${1+"$@"}
2300 1.1 riastrad libtool_options_prep_result=$func_quote_for_eval_result
2301 1.1 riastrad }
2302 1.1 riastrad func_add_hook func_options_prep libtool_options_prep
2303 1.1 riastrad
2304 1.1 riastrad
2305 1.1 riastrad # libtool_parse_options [ARG]...
2306 1.1 riastrad # ---------------------------------
2307 1.1 riastrad # Provide handling for libtool specific options.
2308 1.1 riastrad libtool_parse_options ()
2309 1.1 riastrad {
2310 1.1 riastrad $debug_cmd
2311 1.1 riastrad
2312 1.1 riastrad # Perform our own loop to consume as many options as possible in
2313 1.1 riastrad # each iteration.
2314 1.1 riastrad while test $# -gt 0; do
2315 1.1 riastrad _G_opt=$1
2316 1.1 riastrad shift
2317 1.1 riastrad case $_G_opt in
2318 1.1 riastrad --dry-run|--dryrun|-n)
2319 1.1 riastrad opt_dry_run=:
2320 1.1 riastrad ;;
2321 1.1 riastrad
2322 1.1 riastrad --config) func_config ;;
2323 1.1 riastrad
2324 1.1 riastrad --dlopen|-dlopen)
2325 1.1 riastrad opt_dlopen="${opt_dlopen+$opt_dlopen
2326 1.1 riastrad }$1"
2327 1.1 riastrad shift
2328 1.1 riastrad ;;
2329 1.1 riastrad
2330 1.1 riastrad --preserve-dup-deps)
2331 1.1 riastrad opt_preserve_dup_deps=: ;;
2332 1.1 riastrad
2333 1.1 riastrad --features) func_features ;;
2334 1.1 riastrad
2335 1.1 riastrad --finish) set dummy --mode finish ${1+"$@"}; shift ;;
2336 1.1 riastrad
2337 1.1 riastrad --help) opt_help=: ;;
2338 1.1 riastrad
2339 1.1 riastrad --help-all) opt_help=': help-all' ;;
2340 1.1 riastrad
2341 1.1 riastrad --mode) test $# = 0 && func_missing_arg $_G_opt && break
2342 1.1 riastrad opt_mode=$1
2343 1.1 riastrad case $1 in
2344 1.1 riastrad # Valid mode arguments:
2345 1.1 riastrad clean|compile|execute|finish|install|link|relink|uninstall) ;;
2346 1.1 riastrad
2347 1.1 riastrad # Catch anything else as an error
2348 1.1 riastrad *) func_error "invalid argument for $_G_opt"
2349 1.1 riastrad exit_cmd=exit
2350 1.1 riastrad break
2351 1.1 riastrad ;;
2352 1.1 riastrad esac
2353 1.1 riastrad shift
2354 1.1 riastrad ;;
2355 1.1 riastrad
2356 1.1 riastrad --no-silent|--no-quiet)
2357 1.1 riastrad opt_quiet=false
2358 1.1 riastrad func_append preserve_args " $_G_opt"
2359 1.1 riastrad ;;
2360 1.1 riastrad
2361 1.1 riastrad --no-warnings|--no-warning|--no-warn)
2362 1.1 riastrad opt_warning=false
2363 1.1 riastrad func_append preserve_args " $_G_opt"
2364 1.1 riastrad ;;
2365 1.1 riastrad
2366 1.1 riastrad --no-verbose)
2367 1.1 riastrad opt_verbose=false
2368 1.1 riastrad func_append preserve_args " $_G_opt"
2369 1.1 riastrad ;;
2370 1.1 riastrad
2371 1.1 riastrad --silent|--quiet)
2372 1.1 riastrad opt_quiet=:
2373 1.1 riastrad opt_verbose=false
2374 1.1 riastrad func_append preserve_args " $_G_opt"
2375 1.1 riastrad ;;
2376 1.1 riastrad
2377 1.1 riastrad --tag) test $# = 0 && func_missing_arg $_G_opt && break
2378 1.1 riastrad opt_tag=$1
2379 1.1 riastrad func_append preserve_args " $_G_opt $1"
2380 1.1 riastrad func_enable_tag "$1"
2381 1.1 riastrad shift
2382 1.1 riastrad ;;
2383 1.1 riastrad
2384 1.1 riastrad --verbose|-v) opt_quiet=false
2385 1.1 riastrad opt_verbose=:
2386 1.1 riastrad func_append preserve_args " $_G_opt"
2387 1.1 riastrad ;;
2388 1.1 riastrad
2389 1.1 riastrad # An option not handled by this hook function:
2390 1.1 riastrad *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
2391 1.1 riastrad esac
2392 1.1 riastrad done
2393 1.1 riastrad
2394 1.1 riastrad
2395 1.1 riastrad # save modified positional parameters for caller
2396 1.1 riastrad func_quote_for_eval ${1+"$@"}
2397 1.1 riastrad libtool_parse_options_result=$func_quote_for_eval_result
2398 1.1 riastrad }
2399 1.1 riastrad func_add_hook func_parse_options libtool_parse_options
2400 1.1 riastrad
2401 1.1 riastrad
2402 1.1 riastrad
2403 1.1 riastrad # libtool_validate_options [ARG]...
2404 1.1 riastrad # ---------------------------------
2405 1.1 riastrad # Perform any sanity checks on option settings and/or unconsumed
2406 1.1 riastrad # arguments.
2407 1.1 riastrad libtool_validate_options ()
2408 1.1 riastrad {
2409 1.1 riastrad # save first non-option argument
2410 1.1 riastrad if test 0 -lt $#; then
2411 1.1 riastrad nonopt=$1
2412 1.1 riastrad shift
2413 1.1 riastrad fi
2414 1.1 riastrad
2415 1.1 riastrad # preserve --debug
2416 1.1 riastrad test : = "$debug_cmd" || func_append preserve_args " --debug"
2417 1.1 riastrad
2418 1.1 riastrad case $host in
2419 1.1 riastrad # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2420 1.1 riastrad # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2421 1.1 riastrad *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2422 1.1 riastrad # don't eliminate duplications in $postdeps and $predeps
2423 1.1 riastrad opt_duplicate_compiler_generated_deps=:
2424 1.1 riastrad ;;
2425 1.1 riastrad *)
2426 1.1 riastrad opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2427 1.1 riastrad ;;
2428 1.1 riastrad esac
2429 1.1 riastrad
2430 1.1 riastrad $opt_help || {
2431 1.1 riastrad # Sanity checks first:
2432 1.1 riastrad func_check_version_match
2433 1.1 riastrad
2434 1.1 riastrad test yes != "$build_libtool_libs" \
2435 1.1 riastrad && test yes != "$build_old_libs" \
2436 1.1 riastrad && func_fatal_configuration "not configured to build any kind of library"
2437 1.1 riastrad
2438 1.1 riastrad # Darwin sucks
2439 1.1 riastrad eval std_shrext=\"$shrext_cmds\"
2440 1.1 riastrad
2441 1.1 riastrad # Only execute mode is allowed to have -dlopen flags.
2442 1.1 riastrad if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2443 1.1 riastrad func_error "unrecognized option '-dlopen'"
2444 1.1 riastrad $ECHO "$help" 1>&2
2445 1.1 riastrad exit $EXIT_FAILURE
2446 1.1 riastrad fi
2447 1.1 riastrad
2448 1.1 riastrad # Change the help message to a mode-specific one.
2449 1.1 riastrad generic_help=$help
2450 1.1 riastrad help="Try '$progname --help --mode=$opt_mode' for more information."
2451 1.1 riastrad }
2452 1.1 riastrad
2453 1.1 riastrad # Pass back the unparsed argument list
2454 1.1 riastrad func_quote_for_eval ${1+"$@"}
2455 1.1 riastrad libtool_validate_options_result=$func_quote_for_eval_result
2456 1.1 riastrad }
2457 1.1 riastrad func_add_hook func_validate_options libtool_validate_options
2458 1.1 riastrad
2459 1.1 riastrad
2460 1.1 riastrad # Process options as early as possible so that --help and --version
2461 1.1 riastrad # can return quickly.
2462 1.1 riastrad func_options ${1+"$@"}
2463 1.1 riastrad eval set dummy "$func_options_result"; shift
2464 1.1 riastrad
2465 1.1 riastrad
2466 1.1 riastrad
2467 1.1 riastrad ## ----------- ##
2468 1.1 riastrad ## Main. ##
2469 1.1 riastrad ## ----------- ##
2470 1.1 riastrad
2471 1.1 riastrad magic='%%%MAGIC variable%%%'
2472 1.1 riastrad magic_exe='%%%MAGIC EXE variable%%%'
2473 1.1 riastrad
2474 1.1 riastrad # Global variables.
2475 1.1 riastrad extracted_archives=
2476 1.1 riastrad extracted_serial=0
2477 1.1 riastrad
2478 1.1 riastrad # If this variable is set in any of the actions, the command in it
2479 1.1 riastrad # will be execed at the end. This prevents here-documents from being
2480 1.1 riastrad # left over by shells.
2481 1.1 riastrad exec_cmd=
2482 1.1 riastrad
2483 1.1 riastrad
2484 1.1 riastrad # A function that is used when there is no print builtin or printf.
2485 1.1 riastrad func_fallback_echo ()
2486 1.1 riastrad {
2487 1.1 riastrad eval 'cat <<_LTECHO_EOF
2488 1.1 riastrad $1
2489 1.1 riastrad _LTECHO_EOF'
2490 1.1 riastrad }
2491 1.1 riastrad
2492 1.1 riastrad # func_generated_by_libtool
2493 1.1 riastrad # True iff stdin has been generated by Libtool. This function is only
2494 1.1 riastrad # a basic sanity check; it will hardly flush out determined imposters.
2495 1.1 riastrad func_generated_by_libtool_p ()
2496 1.1 riastrad {
2497 1.1 riastrad $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2498 1.1 riastrad }
2499 1.1 riastrad
2500 1.1 riastrad # func_lalib_p file
2501 1.1 riastrad # True iff FILE is a libtool '.la' library or '.lo' object file.
2502 1.1 riastrad # This function is only a basic sanity check; it will hardly flush out
2503 1.1 riastrad # determined imposters.
2504 1.1 riastrad func_lalib_p ()
2505 1.1 riastrad {
2506 1.1 riastrad test -f "$1" &&
2507 1.1 riastrad $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2508 1.1 riastrad }
2509 1.1 riastrad
2510 1.1 riastrad # func_lalib_unsafe_p file
2511 1.1 riastrad # True iff FILE is a libtool '.la' library or '.lo' object file.
2512 1.1 riastrad # This function implements the same check as func_lalib_p without
2513 1.1 riastrad # resorting to external programs. To this end, it redirects stdin and
2514 1.1 riastrad # closes it afterwards, without saving the original file descriptor.
2515 1.1 riastrad # As a safety measure, use it only where a negative result would be
2516 1.1 riastrad # fatal anyway. Works if 'file' does not exist.
2517 1.1 riastrad func_lalib_unsafe_p ()
2518 1.1 riastrad {
2519 1.1 riastrad lalib_p=no
2520 1.1 riastrad if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2521 1.1 riastrad for lalib_p_l in 1 2 3 4
2522 1.1 riastrad do
2523 1.1 riastrad read lalib_p_line
2524 1.1 riastrad case $lalib_p_line in
2525 1.1 riastrad \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2526 1.1 riastrad esac
2527 1.1 riastrad done
2528 1.1 riastrad exec 0<&5 5<&-
2529 1.1 riastrad fi
2530 1.1 riastrad test yes = "$lalib_p"
2531 1.1 riastrad }
2532 1.1 riastrad
2533 1.1 riastrad # func_ltwrapper_script_p file
2534 1.1 riastrad # True iff FILE is a libtool wrapper script
2535 1.1 riastrad # This function is only a basic sanity check; it will hardly flush out
2536 1.1 riastrad # determined imposters.
2537 1.1 riastrad func_ltwrapper_script_p ()
2538 1.1 riastrad {
2539 1.1 riastrad test -f "$1" &&
2540 1.1 riastrad $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2541 1.1 riastrad }
2542 1.1 riastrad
2543 1.1 riastrad # func_ltwrapper_executable_p file
2544 1.1 riastrad # True iff FILE is a libtool wrapper executable
2545 1.1 riastrad # This function is only a basic sanity check; it will hardly flush out
2546 1.1 riastrad # determined imposters.
2547 1.1 riastrad func_ltwrapper_executable_p ()
2548 1.1 riastrad {
2549 1.1 riastrad func_ltwrapper_exec_suffix=
2550 1.1 riastrad case $1 in
2551 1.1 riastrad *.exe) ;;
2552 1.1 riastrad *) func_ltwrapper_exec_suffix=.exe ;;
2553 1.1 riastrad esac
2554 1.1 riastrad $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2555 1.1 riastrad }
2556 1.1 riastrad
2557 1.1 riastrad # func_ltwrapper_scriptname file
2558 1.1 riastrad # Assumes file is an ltwrapper_executable
2559 1.1 riastrad # uses $file to determine the appropriate filename for a
2560 1.1 riastrad # temporary ltwrapper_script.
2561 1.1 riastrad func_ltwrapper_scriptname ()
2562 1.1 riastrad {
2563 1.1 riastrad func_dirname_and_basename "$1" "" "."
2564 1.1 riastrad func_stripname '' '.exe' "$func_basename_result"
2565 1.1 riastrad func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2566 1.1 riastrad }
2567 1.1 riastrad
2568 1.1 riastrad # func_ltwrapper_p file
2569 1.1 riastrad # True iff FILE is a libtool wrapper script or wrapper executable
2570 1.1 riastrad # This function is only a basic sanity check; it will hardly flush out
2571 1.1 riastrad # determined imposters.
2572 1.1 riastrad func_ltwrapper_p ()
2573 1.1 riastrad {
2574 1.1 riastrad func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2575 1.1 riastrad }
2576 1.1 riastrad
2577 1.1 riastrad
2578 1.1 riastrad # func_execute_cmds commands fail_cmd
2579 1.1 riastrad # Execute tilde-delimited COMMANDS.
2580 1.1 riastrad # If FAIL_CMD is given, eval that upon failure.
2581 1.1 riastrad # FAIL_CMD may read-access the current command in variable CMD!
2582 1.1 riastrad func_execute_cmds ()
2583 1.1 riastrad {
2584 1.1 riastrad $debug_cmd
2585 1.1 riastrad
2586 1.1 riastrad save_ifs=$IFS; IFS='~'
2587 1.1 riastrad for cmd in $1; do
2588 1.1 riastrad IFS=$sp$nl
2589 1.1 riastrad eval cmd=\"$cmd\"
2590 1.1 riastrad IFS=$save_ifs
2591 1.1 riastrad func_show_eval "$cmd" "${2-:}"
2592 1.1 riastrad done
2593 1.1 riastrad IFS=$save_ifs
2594 1.1 riastrad }
2595 1.1 riastrad
2596 1.1 riastrad
2597 1.1 riastrad # func_source file
2598 1.1 riastrad # Source FILE, adding directory component if necessary.
2599 1.1 riastrad # Note that it is not necessary on cygwin/mingw to append a dot to
2600 1.1 riastrad # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2601 1.1 riastrad # behavior happens only for exec(3), not for open(2)! Also, sourcing
2602 1.1 riastrad # 'FILE.' does not work on cygwin managed mounts.
2603 1.1 riastrad func_source ()
2604 1.1 riastrad {
2605 1.1 riastrad $debug_cmd
2606 1.1 riastrad
2607 1.1 riastrad case $1 in
2608 1.1 riastrad */* | *\\*) . "$1" ;;
2609 1.1 riastrad *) . "./$1" ;;
2610 1.1 riastrad esac
2611 1.1 riastrad }
2612 1.1 riastrad
2613 1.1 riastrad
2614 1.1 riastrad # func_resolve_sysroot PATH
2615 1.1 riastrad # Replace a leading = in PATH with a sysroot. Store the result into
2616 1.1 riastrad # func_resolve_sysroot_result
2617 1.1 riastrad func_resolve_sysroot ()
2618 1.1 riastrad {
2619 1.1 riastrad func_resolve_sysroot_result=$1
2620 1.1 riastrad case $func_resolve_sysroot_result in
2621 1.1 riastrad =*)
2622 1.1 riastrad func_stripname '=' '' "$func_resolve_sysroot_result"
2623 1.1 riastrad func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624 1.1 riastrad ;;
2625 1.1 riastrad esac
2626 1.1 riastrad }
2627 1.1 riastrad
2628 1.1 riastrad # func_replace_sysroot PATH
2629 1.1 riastrad # If PATH begins with the sysroot, replace it with = and
2630 1.1 riastrad # store the result into func_replace_sysroot_result.
2631 1.1 riastrad func_replace_sysroot ()
2632 1.1 riastrad {
2633 1.1 riastrad case $lt_sysroot:$1 in
2634 1.1 riastrad ?*:"$lt_sysroot"*)
2635 1.1 riastrad func_stripname "$lt_sysroot" '' "$1"
2636 1.1 riastrad func_replace_sysroot_result='='$func_stripname_result
2637 1.1 riastrad ;;
2638 1.1 riastrad *)
2639 1.1 riastrad # Including no sysroot.
2640 1.1 riastrad func_replace_sysroot_result=$1
2641 1.1 riastrad ;;
2642 1.1 riastrad esac
2643 1.1 riastrad }
2644 1.1 riastrad
2645 1.1 riastrad # func_infer_tag arg
2646 1.1 riastrad # Infer tagged configuration to use if any are available and
2647 1.1 riastrad # if one wasn't chosen via the "--tag" command line option.
2648 1.1 riastrad # Only attempt this if the compiler in the base compile
2649 1.1 riastrad # command doesn't match the default compiler.
2650 1.1 riastrad # arg is usually of the form 'gcc ...'
2651 1.1 riastrad func_infer_tag ()
2652 1.1 riastrad {
2653 1.1 riastrad $debug_cmd
2654 1.1 riastrad
2655 1.1 riastrad if test -n "$available_tags" && test -z "$tagname"; then
2656 1.1 riastrad CC_quoted=
2657 1.1 riastrad for arg in $CC; do
2658 1.1 riastrad func_append_quoted CC_quoted "$arg"
2659 1.1 riastrad done
2660 1.1 riastrad CC_expanded=`func_echo_all $CC`
2661 1.1 riastrad CC_quoted_expanded=`func_echo_all $CC_quoted`
2662 1.1 riastrad case $@ in
2663 1.1 riastrad # Blanks in the command may have been stripped by the calling shell,
2664 1.1 riastrad # but not from the CC environment variable when configure was run.
2665 1.1 riastrad " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666 1.1 riastrad " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2667 1.1 riastrad # Blanks at the start of $base_compile will cause this to fail
2668 1.1 riastrad # if we don't check for them as well.
2669 1.1 riastrad *)
2670 1.1 riastrad for z in $available_tags; do
2671 1.1 riastrad if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2672 1.1 riastrad # Evaluate the configuration.
2673 1.1 riastrad eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2674 1.1 riastrad CC_quoted=
2675 1.1 riastrad for arg in $CC; do
2676 1.1 riastrad # Double-quote args containing other shell metacharacters.
2677 1.1 riastrad func_append_quoted CC_quoted "$arg"
2678 1.1 riastrad done
2679 1.1 riastrad CC_expanded=`func_echo_all $CC`
2680 1.1 riastrad CC_quoted_expanded=`func_echo_all $CC_quoted`
2681 1.1 riastrad case "$@ " in
2682 1.1 riastrad " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683 1.1 riastrad " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2684 1.1 riastrad # The compiler in the base compile command matches
2685 1.1 riastrad # the one in the tagged configuration.
2686 1.1 riastrad # Assume this is the tagged configuration we want.
2687 1.1 riastrad tagname=$z
2688 1.1 riastrad break
2689 1.1 riastrad ;;
2690 1.1 riastrad esac
2691 1.1 riastrad fi
2692 1.1 riastrad done
2693 1.1 riastrad # If $tagname still isn't set, then no tagged configuration
2694 1.1 riastrad # was found and let the user know that the "--tag" command
2695 1.1 riastrad # line option must be used.
2696 1.1 riastrad if test -z "$tagname"; then
2697 1.1 riastrad func_echo "unable to infer tagged configuration"
2698 1.1 riastrad func_fatal_error "specify a tag with '--tag'"
2699 1.1 riastrad # else
2700 1.1 riastrad # func_verbose "using $tagname tagged configuration"
2701 1.1 riastrad fi
2702 1.1 riastrad ;;
2703 1.1 riastrad esac
2704 1.1 riastrad fi
2705 1.1 riastrad }
2706 1.1 riastrad
2707 1.1 riastrad
2708 1.1 riastrad
2709 1.1 riastrad # func_write_libtool_object output_name pic_name nonpic_name
2710 1.1 riastrad # Create a libtool object file (analogous to a ".la" file),
2711 1.1 riastrad # but don't create it if we're doing a dry run.
2712 1.1 riastrad func_write_libtool_object ()
2713 1.1 riastrad {
2714 1.1 riastrad write_libobj=$1
2715 1.1 riastrad if test yes = "$build_libtool_libs"; then
2716 1.1 riastrad write_lobj=\'$2\'
2717 1.1 riastrad else
2718 1.1 riastrad write_lobj=none
2719 1.1 riastrad fi
2720 1.1 riastrad
2721 1.1 riastrad if test yes = "$build_old_libs"; then
2722 1.1 riastrad write_oldobj=\'$3\'
2723 1.1 riastrad else
2724 1.1 riastrad write_oldobj=none
2725 1.1 riastrad fi
2726 1.1 riastrad
2727 1.1 riastrad $opt_dry_run || {
2728 1.1 riastrad cat >${write_libobj}T <<EOF
2729 1.1 riastrad # $write_libobj - a libtool object file
2730 1.1 riastrad # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731 1.1 riastrad #
2732 1.1 riastrad # Please DO NOT delete this file!
2733 1.1 riastrad # It is necessary for linking the library.
2734 1.1 riastrad
2735 1.1 riastrad # Name of the PIC object.
2736 1.1 riastrad pic_object=$write_lobj
2737 1.1 riastrad
2738 1.1 riastrad # Name of the non-PIC object
2739 1.1 riastrad non_pic_object=$write_oldobj
2740 1.1 riastrad
2741 1.1 riastrad EOF
2742 1.1 riastrad $MV "${write_libobj}T" "$write_libobj"
2743 1.1 riastrad }
2744 1.1 riastrad }
2745 1.1 riastrad
2746 1.1 riastrad
2747 1.1 riastrad ##################################################
2748 1.1 riastrad # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749 1.1 riastrad ##################################################
2750 1.1 riastrad
2751 1.1 riastrad # func_convert_core_file_wine_to_w32 ARG
2752 1.1 riastrad # Helper function used by file name conversion functions when $build is *nix,
2753 1.1 riastrad # and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754 1.1 riastrad # correctly configured wine environment available, with the winepath program
2755 1.1 riastrad # in $build's $PATH.
2756 1.1 riastrad #
2757 1.1 riastrad # ARG is the $build file name to be converted to w32 format.
2758 1.1 riastrad # Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759 1.1 riastrad # be empty on error (or when ARG is empty)
2760 1.1 riastrad func_convert_core_file_wine_to_w32 ()
2761 1.1 riastrad {
2762 1.1 riastrad $debug_cmd
2763 1.1 riastrad
2764 1.1 riastrad func_convert_core_file_wine_to_w32_result=$1
2765 1.1 riastrad if test -n "$1"; then
2766 1.1 riastrad # Unfortunately, winepath does not exit with a non-zero error code, so we
2767 1.1 riastrad # are forced to check the contents of stdout. On the other hand, if the
2768 1.1 riastrad # command is not found, the shell will set an exit code of 127 and print
2769 1.1 riastrad # *an error message* to stdout. So we must check for both error code of
2770 1.1 riastrad # zero AND non-empty stdout, which explains the odd construction:
2771 1.1 riastrad func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2772 1.1 riastrad if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773 1.1 riastrad func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2774 1.1 riastrad $SED -e "$sed_naive_backslashify"`
2775 1.1 riastrad else
2776 1.1 riastrad func_convert_core_file_wine_to_w32_result=
2777 1.1 riastrad fi
2778 1.1 riastrad fi
2779 1.1 riastrad }
2780 1.1 riastrad # end: func_convert_core_file_wine_to_w32
2781 1.1 riastrad
2782 1.1 riastrad
2783 1.1 riastrad # func_convert_core_path_wine_to_w32 ARG
2784 1.1 riastrad # Helper function used by path conversion functions when $build is *nix, and
2785 1.1 riastrad # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786 1.1 riastrad # configured wine environment available, with the winepath program in $build's
2787 1.1 riastrad # $PATH. Assumes ARG has no leading or trailing path separator characters.
2788 1.1 riastrad #
2789 1.1 riastrad # ARG is path to be converted from $build format to win32.
2790 1.1 riastrad # Result is available in $func_convert_core_path_wine_to_w32_result.
2791 1.1 riastrad # Unconvertible file (directory) names in ARG are skipped; if no directory names
2792 1.1 riastrad # are convertible, then the result may be empty.
2793 1.1 riastrad func_convert_core_path_wine_to_w32 ()
2794 1.1 riastrad {
2795 1.1 riastrad $debug_cmd
2796 1.1 riastrad
2797 1.1 riastrad # unfortunately, winepath doesn't convert paths, only file names
2798 1.1 riastrad func_convert_core_path_wine_to_w32_result=
2799 1.1 riastrad if test -n "$1"; then
2800 1.1 riastrad oldIFS=$IFS
2801 1.1 riastrad IFS=:
2802 1.1 riastrad for func_convert_core_path_wine_to_w32_f in $1; do
2803 1.1 riastrad IFS=$oldIFS
2804 1.1 riastrad func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2805 1.1 riastrad if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806 1.1 riastrad if test -z "$func_convert_core_path_wine_to_w32_result"; then
2807 1.1 riastrad func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808 1.1 riastrad else
2809 1.1 riastrad func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810 1.1 riastrad fi
2811 1.1 riastrad fi
2812 1.1 riastrad done
2813 1.1 riastrad IFS=$oldIFS
2814 1.1 riastrad fi
2815 1.1 riastrad }
2816 1.1 riastrad # end: func_convert_core_path_wine_to_w32
2817 1.1 riastrad
2818 1.1 riastrad
2819 1.1 riastrad # func_cygpath ARGS...
2820 1.1 riastrad # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821 1.1 riastrad # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822 1.1 riastrad # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823 1.1 riastrad # (2), returns the Cygwin file name or path in func_cygpath_result (input
2824 1.1 riastrad # file name or path is assumed to be in w32 format, as previously converted
2825 1.1 riastrad # from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826 1.1 riastrad # or path in func_cygpath_result (input file name or path is assumed to be in
2827 1.1 riastrad # Cygwin format). Returns an empty string on error.
2828 1.1 riastrad #
2829 1.1 riastrad # ARGS are passed to cygpath, with the last one being the file name or path to
2830 1.1 riastrad # be converted.
2831 1.1 riastrad #
2832 1.1 riastrad # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833 1.1 riastrad # environment variable; do not put it in $PATH.
2834 1.1 riastrad func_cygpath ()
2835 1.1 riastrad {
2836 1.1 riastrad $debug_cmd
2837 1.1 riastrad
2838 1.1 riastrad if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839 1.1 riastrad func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840 1.1 riastrad if test "$?" -ne 0; then
2841 1.1 riastrad # on failure, ensure result is empty
2842 1.1 riastrad func_cygpath_result=
2843 1.1 riastrad fi
2844 1.1 riastrad else
2845 1.1 riastrad func_cygpath_result=
2846 1.1 riastrad func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847 1.1 riastrad fi
2848 1.1 riastrad }
2849 1.1 riastrad #end: func_cygpath
2850 1.1 riastrad
2851 1.1 riastrad
2852 1.1 riastrad # func_convert_core_msys_to_w32 ARG
2853 1.1 riastrad # Convert file name or path ARG from MSYS format to w32 format. Return
2854 1.1 riastrad # result in func_convert_core_msys_to_w32_result.
2855 1.1 riastrad func_convert_core_msys_to_w32 ()
2856 1.1 riastrad {
2857 1.1 riastrad $debug_cmd
2858 1.1 riastrad
2859 1.1 riastrad # awkward: cmd appends spaces to result
2860 1.1 riastrad func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2861 1.1 riastrad $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862 1.1 riastrad }
2863 1.1 riastrad #end: func_convert_core_msys_to_w32
2864 1.1 riastrad
2865 1.1 riastrad
2866 1.1 riastrad # func_convert_file_check ARG1 ARG2
2867 1.1 riastrad # Verify that ARG1 (a file name in $build format) was converted to $host
2868 1.1 riastrad # format in ARG2. Otherwise, emit an error message, but continue (resetting
2869 1.1 riastrad # func_to_host_file_result to ARG1).
2870 1.1 riastrad func_convert_file_check ()
2871 1.1 riastrad {
2872 1.1 riastrad $debug_cmd
2873 1.1 riastrad
2874 1.1 riastrad if test -z "$2" && test -n "$1"; then
2875 1.1 riastrad func_error "Could not determine host file name corresponding to"
2876 1.1 riastrad func_error " '$1'"
2877 1.1 riastrad func_error "Continuing, but uninstalled executables may not work."
2878 1.1 riastrad # Fallback:
2879 1.1 riastrad func_to_host_file_result=$1
2880 1.1 riastrad fi
2881 1.1 riastrad }
2882 1.1 riastrad # end func_convert_file_check
2883 1.1 riastrad
2884 1.1 riastrad
2885 1.1 riastrad # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886 1.1 riastrad # Verify that FROM_PATH (a path in $build format) was converted to $host
2887 1.1 riastrad # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888 1.1 riastrad # func_to_host_file_result to a simplistic fallback value (see below).
2889 1.1 riastrad func_convert_path_check ()
2890 1.1 riastrad {
2891 1.1 riastrad $debug_cmd
2892 1.1 riastrad
2893 1.1 riastrad if test -z "$4" && test -n "$3"; then
2894 1.1 riastrad func_error "Could not determine the host path corresponding to"
2895 1.1 riastrad func_error " '$3'"
2896 1.1 riastrad func_error "Continuing, but uninstalled executables may not work."
2897 1.1 riastrad # Fallback. This is a deliberately simplistic "conversion" and
2898 1.1 riastrad # should not be "improved". See libtool.info.
2899 1.1 riastrad if test "x$1" != "x$2"; then
2900 1.1 riastrad lt_replace_pathsep_chars="s|$1|$2|g"
2901 1.1 riastrad func_to_host_path_result=`echo "$3" |
2902 1.1 riastrad $SED -e "$lt_replace_pathsep_chars"`
2903 1.1 riastrad else
2904 1.1 riastrad func_to_host_path_result=$3
2905 1.1 riastrad fi
2906 1.1 riastrad fi
2907 1.1 riastrad }
2908 1.1 riastrad # end func_convert_path_check
2909 1.1 riastrad
2910 1.1 riastrad
2911 1.1 riastrad # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912 1.1 riastrad # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913 1.1 riastrad # and appending REPL if ORIG matches BACKPAT.
2914 1.1 riastrad func_convert_path_front_back_pathsep ()
2915 1.1 riastrad {
2916 1.1 riastrad $debug_cmd
2917 1.1 riastrad
2918 1.1 riastrad case $4 in
2919 1.1 riastrad $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920 1.1 riastrad ;;
2921 1.1 riastrad esac
2922 1.1 riastrad case $4 in
2923 1.1 riastrad $2 ) func_append func_to_host_path_result "$3"
2924 1.1 riastrad ;;
2925 1.1 riastrad esac
2926 1.1 riastrad }
2927 1.1 riastrad # end func_convert_path_front_back_pathsep
2928 1.1 riastrad
2929 1.1 riastrad
2930 1.1 riastrad ##################################################
2931 1.1 riastrad # $build to $host FILE NAME CONVERSION FUNCTIONS #
2932 1.1 riastrad ##################################################
2933 1.1 riastrad # invoked via '$to_host_file_cmd ARG'
2934 1.1 riastrad #
2935 1.1 riastrad # In each case, ARG is the path to be converted from $build to $host format.
2936 1.1 riastrad # Result will be available in $func_to_host_file_result.
2937 1.1 riastrad
2938 1.1 riastrad
2939 1.1 riastrad # func_to_host_file ARG
2940 1.1 riastrad # Converts the file name ARG from $build format to $host format. Return result
2941 1.1 riastrad # in func_to_host_file_result.
2942 1.1 riastrad func_to_host_file ()
2943 1.1 riastrad {
2944 1.1 riastrad $debug_cmd
2945 1.1 riastrad
2946 1.1 riastrad $to_host_file_cmd "$1"
2947 1.1 riastrad }
2948 1.1 riastrad # end func_to_host_file
2949 1.1 riastrad
2950 1.1 riastrad
2951 1.1 riastrad # func_to_tool_file ARG LAZY
2952 1.1 riastrad # converts the file name ARG from $build format to toolchain format. Return
2953 1.1 riastrad # result in func_to_tool_file_result. If the conversion in use is listed
2954 1.1 riastrad # in (the comma separated) LAZY, no conversion takes place.
2955 1.1 riastrad func_to_tool_file ()
2956 1.1 riastrad {
2957 1.1 riastrad $debug_cmd
2958 1.1 riastrad
2959 1.1 riastrad case ,$2, in
2960 1.1 riastrad *,"$to_tool_file_cmd",*)
2961 1.1 riastrad func_to_tool_file_result=$1
2962 1.1 riastrad ;;
2963 1.1 riastrad *)
2964 1.1 riastrad $to_tool_file_cmd "$1"
2965 1.1 riastrad func_to_tool_file_result=$func_to_host_file_result
2966 1.1 riastrad ;;
2967 1.1 riastrad esac
2968 1.1 riastrad }
2969 1.1 riastrad # end func_to_tool_file
2970 1.1 riastrad
2971 1.1 riastrad
2972 1.1 riastrad # func_convert_file_noop ARG
2973 1.1 riastrad # Copy ARG to func_to_host_file_result.
2974 1.1 riastrad func_convert_file_noop ()
2975 1.1 riastrad {
2976 1.1 riastrad func_to_host_file_result=$1
2977 1.1 riastrad }
2978 1.1 riastrad # end func_convert_file_noop
2979 1.1 riastrad
2980 1.1 riastrad
2981 1.1 riastrad # func_convert_file_msys_to_w32 ARG
2982 1.1 riastrad # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983 1.1 riastrad # conversion to w32 is not available inside the cwrapper. Returns result in
2984 1.1 riastrad # func_to_host_file_result.
2985 1.1 riastrad func_convert_file_msys_to_w32 ()
2986 1.1 riastrad {
2987 1.1 riastrad $debug_cmd
2988 1.1 riastrad
2989 1.1 riastrad func_to_host_file_result=$1
2990 1.1 riastrad if test -n "$1"; then
2991 1.1 riastrad func_convert_core_msys_to_w32 "$1"
2992 1.1 riastrad func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993 1.1 riastrad fi
2994 1.1 riastrad func_convert_file_check "$1" "$func_to_host_file_result"
2995 1.1 riastrad }
2996 1.1 riastrad # end func_convert_file_msys_to_w32
2997 1.1 riastrad
2998 1.1 riastrad
2999 1.1 riastrad # func_convert_file_cygwin_to_w32 ARG
3000 1.1 riastrad # Convert file name ARG from Cygwin to w32 format. Returns result in
3001 1.1 riastrad # func_to_host_file_result.
3002 1.1 riastrad func_convert_file_cygwin_to_w32 ()
3003 1.1 riastrad {
3004 1.1 riastrad $debug_cmd
3005 1.1 riastrad
3006 1.1 riastrad func_to_host_file_result=$1
3007 1.1 riastrad if test -n "$1"; then
3008 1.1 riastrad # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009 1.1 riastrad # LT_CYGPATH in this case.
3010 1.1 riastrad func_to_host_file_result=`cygpath -m "$1"`
3011 1.1 riastrad fi
3012 1.1 riastrad func_convert_file_check "$1" "$func_to_host_file_result"
3013 1.1 riastrad }
3014 1.1 riastrad # end func_convert_file_cygwin_to_w32
3015 1.1 riastrad
3016 1.1 riastrad
3017 1.1 riastrad # func_convert_file_nix_to_w32 ARG
3018 1.1 riastrad # Convert file name ARG from *nix to w32 format. Requires a wine environment
3019 1.1 riastrad # and a working winepath. Returns result in func_to_host_file_result.
3020 1.1 riastrad func_convert_file_nix_to_w32 ()
3021 1.1 riastrad {
3022 1.1 riastrad $debug_cmd
3023 1.1 riastrad
3024 1.1 riastrad func_to_host_file_result=$1
3025 1.1 riastrad if test -n "$1"; then
3026 1.1 riastrad func_convert_core_file_wine_to_w32 "$1"
3027 1.1 riastrad func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028 1.1 riastrad fi
3029 1.1 riastrad func_convert_file_check "$1" "$func_to_host_file_result"
3030 1.1 riastrad }
3031 1.1 riastrad # end func_convert_file_nix_to_w32
3032 1.1 riastrad
3033 1.1 riastrad
3034 1.1 riastrad # func_convert_file_msys_to_cygwin ARG
3035 1.1 riastrad # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3036 1.1 riastrad # Returns result in func_to_host_file_result.
3037 1.1 riastrad func_convert_file_msys_to_cygwin ()
3038 1.1 riastrad {
3039 1.1 riastrad $debug_cmd
3040 1.1 riastrad
3041 1.1 riastrad func_to_host_file_result=$1
3042 1.1 riastrad if test -n "$1"; then
3043 1.1 riastrad func_convert_core_msys_to_w32 "$1"
3044 1.1 riastrad func_cygpath -u "$func_convert_core_msys_to_w32_result"
3045 1.1 riastrad func_to_host_file_result=$func_cygpath_result
3046 1.1 riastrad fi
3047 1.1 riastrad func_convert_file_check "$1" "$func_to_host_file_result"
3048 1.1 riastrad }
3049 1.1 riastrad # end func_convert_file_msys_to_cygwin
3050 1.1 riastrad
3051 1.1 riastrad
3052 1.1 riastrad # func_convert_file_nix_to_cygwin ARG
3053 1.1 riastrad # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
3054 1.1 riastrad # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
3055 1.1 riastrad # in func_to_host_file_result.
3056 1.1 riastrad func_convert_file_nix_to_cygwin ()
3057 1.1 riastrad {
3058 1.1 riastrad $debug_cmd
3059 1.1 riastrad
3060 1.1 riastrad func_to_host_file_result=$1
3061 1.1 riastrad if test -n "$1"; then
3062 1.1 riastrad # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063 1.1 riastrad func_convert_core_file_wine_to_w32 "$1"
3064 1.1 riastrad func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3065 1.1 riastrad func_to_host_file_result=$func_cygpath_result
3066 1.1 riastrad fi
3067 1.1 riastrad func_convert_file_check "$1" "$func_to_host_file_result"
3068 1.1 riastrad }
3069 1.1 riastrad # end func_convert_file_nix_to_cygwin
3070 1.1 riastrad
3071 1.1 riastrad
3072 1.1 riastrad #############################################
3073 1.1 riastrad # $build to $host PATH CONVERSION FUNCTIONS #
3074 1.1 riastrad #############################################
3075 1.1 riastrad # invoked via '$to_host_path_cmd ARG'
3076 1.1 riastrad #
3077 1.1 riastrad # In each case, ARG is the path to be converted from $build to $host format.
3078 1.1 riastrad # The result will be available in $func_to_host_path_result.
3079 1.1 riastrad #
3080 1.1 riastrad # Path separators are also converted from $build format to $host format. If
3081 1.1 riastrad # ARG begins or ends with a path separator character, it is preserved (but
3082 1.1 riastrad # converted to $host format) on output.
3083 1.1 riastrad #
3084 1.1 riastrad # All path conversion functions are named using the following convention:
3085 1.1 riastrad # file name conversion function : func_convert_file_X_to_Y ()
3086 1.1 riastrad # path conversion function : func_convert_path_X_to_Y ()
3087 1.1 riastrad # where, for any given $build/$host combination the 'X_to_Y' value is the
3088 1.1 riastrad # same. If conversion functions are added for new $build/$host combinations,
3089 1.1 riastrad # the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090 1.1 riastrad # will break.
3091 1.1 riastrad
3092 1.1 riastrad
3093 1.1 riastrad # func_init_to_host_path_cmd
3094 1.1 riastrad # Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095 1.1 riastrad # appropriate value, based on the value of $to_host_file_cmd.
3096 1.1 riastrad to_host_path_cmd=
3097 1.1 riastrad func_init_to_host_path_cmd ()
3098 1.1 riastrad {
3099 1.1 riastrad $debug_cmd
3100 1.1 riastrad
3101 1.1 riastrad if test -z "$to_host_path_cmd"; then
3102 1.1 riastrad func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3103 1.1 riastrad to_host_path_cmd=func_convert_path_$func_stripname_result
3104 1.1 riastrad fi
3105 1.1 riastrad }
3106 1.1 riastrad
3107 1.1 riastrad
3108 1.1 riastrad # func_to_host_path ARG
3109 1.1 riastrad # Converts the path ARG from $build format to $host format. Return result
3110 1.1 riastrad # in func_to_host_path_result.
3111 1.1 riastrad func_to_host_path ()
3112 1.1 riastrad {
3113 1.1 riastrad $debug_cmd
3114 1.1 riastrad
3115 1.1 riastrad func_init_to_host_path_cmd
3116 1.1 riastrad $to_host_path_cmd "$1"
3117 1.1 riastrad }
3118 1.1 riastrad # end func_to_host_path
3119 1.1 riastrad
3120 1.1 riastrad
3121 1.1 riastrad # func_convert_path_noop ARG
3122 1.1 riastrad # Copy ARG to func_to_host_path_result.
3123 1.1 riastrad func_convert_path_noop ()
3124 1.1 riastrad {
3125 1.1 riastrad func_to_host_path_result=$1
3126 1.1 riastrad }
3127 1.1 riastrad # end func_convert_path_noop
3128 1.1 riastrad
3129 1.1 riastrad
3130 1.1 riastrad # func_convert_path_msys_to_w32 ARG
3131 1.1 riastrad # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132 1.1 riastrad # conversion to w32 is not available inside the cwrapper. Returns result in
3133 1.1 riastrad # func_to_host_path_result.
3134 1.1 riastrad func_convert_path_msys_to_w32 ()
3135 1.1 riastrad {
3136 1.1 riastrad $debug_cmd
3137 1.1 riastrad
3138 1.1 riastrad func_to_host_path_result=$1
3139 1.1 riastrad if test -n "$1"; then
3140 1.1 riastrad # Remove leading and trailing path separator characters from ARG. MSYS
3141 1.1 riastrad # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142 1.1 riastrad # and winepath ignores them completely.
3143 1.1 riastrad func_stripname : : "$1"
3144 1.1 riastrad func_to_host_path_tmp1=$func_stripname_result
3145 1.1 riastrad func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3146 1.1 riastrad func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147 1.1 riastrad func_convert_path_check : ";" \
3148 1.1 riastrad "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149 1.1 riastrad func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150 1.1 riastrad fi
3151 1.1 riastrad }
3152 1.1 riastrad # end func_convert_path_msys_to_w32
3153 1.1 riastrad
3154 1.1 riastrad
3155 1.1 riastrad # func_convert_path_cygwin_to_w32 ARG
3156 1.1 riastrad # Convert path ARG from Cygwin to w32 format. Returns result in
3157 1.1 riastrad # func_to_host_file_result.
3158 1.1 riastrad func_convert_path_cygwin_to_w32 ()
3159 1.1 riastrad {
3160 1.1 riastrad $debug_cmd
3161 1.1 riastrad
3162 1.1 riastrad func_to_host_path_result=$1
3163 1.1 riastrad if test -n "$1"; then
3164 1.1 riastrad # See func_convert_path_msys_to_w32:
3165 1.1 riastrad func_stripname : : "$1"
3166 1.1 riastrad func_to_host_path_tmp1=$func_stripname_result
3167 1.1 riastrad func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168 1.1 riastrad func_convert_path_check : ";" \
3169 1.1 riastrad "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170 1.1 riastrad func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171 1.1 riastrad fi
3172 1.1 riastrad }
3173 1.1 riastrad # end func_convert_path_cygwin_to_w32
3174 1.1 riastrad
3175 1.1 riastrad
3176 1.1 riastrad # func_convert_path_nix_to_w32 ARG
3177 1.1 riastrad # Convert path ARG from *nix to w32 format. Requires a wine environment and
3178 1.1 riastrad # a working winepath. Returns result in func_to_host_file_result.
3179 1.1 riastrad func_convert_path_nix_to_w32 ()
3180 1.1 riastrad {
3181 1.1 riastrad $debug_cmd
3182 1.1 riastrad
3183 1.1 riastrad func_to_host_path_result=$1
3184 1.1 riastrad if test -n "$1"; then
3185 1.1 riastrad # See func_convert_path_msys_to_w32:
3186 1.1 riastrad func_stripname : : "$1"
3187 1.1 riastrad func_to_host_path_tmp1=$func_stripname_result
3188 1.1 riastrad func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3189 1.1 riastrad func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190 1.1 riastrad func_convert_path_check : ";" \
3191 1.1 riastrad "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192 1.1 riastrad func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193 1.1 riastrad fi
3194 1.1 riastrad }
3195 1.1 riastrad # end func_convert_path_nix_to_w32
3196 1.1 riastrad
3197 1.1 riastrad
3198 1.1 riastrad # func_convert_path_msys_to_cygwin ARG
3199 1.1 riastrad # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3200 1.1 riastrad # Returns result in func_to_host_file_result.
3201 1.1 riastrad func_convert_path_msys_to_cygwin ()
3202 1.1 riastrad {
3203 1.1 riastrad $debug_cmd
3204 1.1 riastrad
3205 1.1 riastrad func_to_host_path_result=$1
3206 1.1 riastrad if test -n "$1"; then
3207 1.1 riastrad # See func_convert_path_msys_to_w32:
3208 1.1 riastrad func_stripname : : "$1"
3209 1.1 riastrad func_to_host_path_tmp1=$func_stripname_result
3210 1.1 riastrad func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211 1.1 riastrad func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3212 1.1 riastrad func_to_host_path_result=$func_cygpath_result
3213 1.1 riastrad func_convert_path_check : : \
3214 1.1 riastrad "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215 1.1 riastrad func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216 1.1 riastrad fi
3217 1.1 riastrad }
3218 1.1 riastrad # end func_convert_path_msys_to_cygwin
3219 1.1 riastrad
3220 1.1 riastrad
3221 1.1 riastrad # func_convert_path_nix_to_cygwin ARG
3222 1.1 riastrad # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
3223 1.1 riastrad # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
3224 1.1 riastrad # func_to_host_file_result.
3225 1.1 riastrad func_convert_path_nix_to_cygwin ()
3226 1.1 riastrad {
3227 1.1 riastrad $debug_cmd
3228 1.1 riastrad
3229 1.1 riastrad func_to_host_path_result=$1
3230 1.1 riastrad if test -n "$1"; then
3231 1.1 riastrad # Remove leading and trailing path separator characters from
3232 1.1 riastrad # ARG. msys behavior is inconsistent here, cygpath turns them
3233 1.1 riastrad # into '.;' and ';.', and winepath ignores them completely.
3234 1.1 riastrad func_stripname : : "$1"
3235 1.1 riastrad func_to_host_path_tmp1=$func_stripname_result
3236 1.1 riastrad func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237 1.1 riastrad func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3238 1.1 riastrad func_to_host_path_result=$func_cygpath_result
3239 1.1 riastrad func_convert_path_check : : \
3240 1.1 riastrad "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241 1.1 riastrad func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242 1.1 riastrad fi
3243 1.1 riastrad }
3244 1.1 riastrad # end func_convert_path_nix_to_cygwin
3245 1.1 riastrad
3246 1.1 riastrad
3247 1.1 riastrad # func_dll_def_p FILE
3248 1.1 riastrad # True iff FILE is a Windows DLL '.def' file.
3249 1.1 riastrad # Keep in sync with _LT_DLL_DEF_P in libtool.m4
3250 1.1 riastrad func_dll_def_p ()
3251 1.1 riastrad {
3252 1.1 riastrad $debug_cmd
3253 1.1 riastrad
3254 1.1 riastrad func_dll_def_p_tmp=`$SED -n \
3255 1.1 riastrad -e 's/^[ ]*//' \
3256 1.1 riastrad -e '/^\(;.*\)*$/d' \
3257 1.1 riastrad -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
3258 1.1 riastrad -e q \
3259 1.1 riastrad "$1"`
3260 1.1 riastrad test DEF = "$func_dll_def_p_tmp"
3261 1.1 riastrad }
3262 1.1 riastrad
3263 1.1 riastrad
3264 1.1 riastrad # func_mode_compile arg...
3265 1.1 riastrad func_mode_compile ()
3266 1.1 riastrad {
3267 1.1 riastrad $debug_cmd
3268 1.1 riastrad
3269 1.1 riastrad # Get the compilation command and the source file.
3270 1.1 riastrad base_compile=
3271 1.1 riastrad srcfile=$nonopt # always keep a non-empty value in "srcfile"
3272 1.1 riastrad suppress_opt=yes
3273 1.1 riastrad suppress_output=
3274 1.1 riastrad arg_mode=normal
3275 1.1 riastrad libobj=
3276 1.1 riastrad later=
3277 1.1 riastrad pie_flag=
3278 1.1 riastrad
3279 1.1 riastrad for arg
3280 1.1 riastrad do
3281 1.1 riastrad case $arg_mode in
3282 1.1 riastrad arg )
3283 1.1 riastrad # do not "continue". Instead, add this to base_compile
3284 1.1 riastrad lastarg=$arg
3285 1.1 riastrad arg_mode=normal
3286 1.1 riastrad ;;
3287 1.1 riastrad
3288 1.1 riastrad target )
3289 1.1 riastrad libobj=$arg
3290 1.1 riastrad arg_mode=normal
3291 1.1 riastrad continue
3292 1.1 riastrad ;;
3293 1.1 riastrad
3294 1.1 riastrad normal )
3295 1.1 riastrad # Accept any command-line options.
3296 1.1 riastrad case $arg in
3297 1.1 riastrad -o)
3298 1.1 riastrad test -n "$libobj" && \
3299 1.1 riastrad func_fatal_error "you cannot specify '-o' more than once"
3300 1.1 riastrad arg_mode=target
3301 1.1 riastrad continue
3302 1.1 riastrad ;;
3303 1.1 riastrad
3304 1.1 riastrad -pie | -fpie | -fPIE)
3305 1.1 riastrad func_append pie_flag " $arg"
3306 1.1 riastrad continue
3307 1.1 riastrad ;;
3308 1.1 riastrad
3309 1.1 riastrad -shared | -static | -prefer-pic | -prefer-non-pic)
3310 1.1 riastrad func_append later " $arg"
3311 1.1 riastrad continue
3312 1.1 riastrad ;;
3313 1.1 riastrad
3314 1.1 riastrad -no-suppress)
3315 1.1 riastrad suppress_opt=no
3316 1.1 riastrad continue
3317 1.1 riastrad ;;
3318 1.1 riastrad
3319 1.1 riastrad -Xcompiler)
3320 1.1 riastrad arg_mode=arg # the next one goes into the "base_compile" arg list
3321 1.1 riastrad continue # The current "srcfile" will either be retained or
3322 1.1 riastrad ;; # replaced later. I would guess that would be a bug.
3323 1.1 riastrad
3324 1.1 riastrad -Wc,*)
3325 1.1 riastrad func_stripname '-Wc,' '' "$arg"
3326 1.1 riastrad args=$func_stripname_result
3327 1.1 riastrad lastarg=
3328 1.1 riastrad save_ifs=$IFS; IFS=,
3329 1.1 riastrad for arg in $args; do
3330 1.1 riastrad IFS=$save_ifs
3331 1.1 riastrad func_append_quoted lastarg "$arg"
3332 1.1 riastrad done
3333 1.1 riastrad IFS=$save_ifs
3334 1.1 riastrad func_stripname ' ' '' "$lastarg"
3335 1.1 riastrad lastarg=$func_stripname_result
3336 1.1 riastrad
3337 1.1 riastrad # Add the arguments to base_compile.
3338 1.1 riastrad func_append base_compile " $lastarg"
3339 1.1 riastrad continue
3340 1.1 riastrad ;;
3341 1.1 riastrad
3342 1.1 riastrad *)
3343 1.1 riastrad # Accept the current argument as the source file.
3344 1.1 riastrad # The previous "srcfile" becomes the current argument.
3345 1.1 riastrad #
3346 1.1 riastrad lastarg=$srcfile
3347 1.1 riastrad srcfile=$arg
3348 1.1 riastrad ;;
3349 1.1 riastrad esac # case $arg
3350 1.1 riastrad ;;
3351 1.1 riastrad esac # case $arg_mode
3352 1.1 riastrad
3353 1.1 riastrad # Aesthetically quote the previous argument.
3354 1.1 riastrad func_append_quoted base_compile "$lastarg"
3355 1.1 riastrad done # for arg
3356 1.1 riastrad
3357 1.1 riastrad case $arg_mode in
3358 1.1 riastrad arg)
3359 1.1 riastrad func_fatal_error "you must specify an argument for -Xcompile"
3360 1.1 riastrad ;;
3361 1.1 riastrad target)
3362 1.1 riastrad func_fatal_error "you must specify a target with '-o'"
3363 1.1 riastrad ;;
3364 1.1 riastrad *)
3365 1.1 riastrad # Get the name of the library object.
3366 1.1 riastrad test -z "$libobj" && {
3367 1.1 riastrad func_basename "$srcfile"
3368 1.1 riastrad libobj=$func_basename_result
3369 1.1 riastrad }
3370 1.1 riastrad ;;
3371 1.1 riastrad esac
3372 1.1 riastrad
3373 1.1 riastrad # Recognize several different file suffixes.
3374 1.1 riastrad # If the user specifies -o file.o, it is replaced with file.lo
3375 1.1 riastrad case $libobj in
3376 1.1 riastrad *.[cCFSifmso] | \
3377 1.1 riastrad *.ada | *.adb | *.ads | *.asm | \
3378 1.1 riastrad *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3379 1.1 riastrad *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3380 1.1 riastrad func_xform "$libobj"
3381 1.1 riastrad libobj=$func_xform_result
3382 1.1 riastrad ;;
3383 1.1 riastrad esac
3384 1.1 riastrad
3385 1.1 riastrad case $libobj in
3386 1.1 riastrad *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387 1.1 riastrad *)
3388 1.1 riastrad func_fatal_error "cannot determine name of library object from '$libobj'"
3389 1.1 riastrad ;;
3390 1.1 riastrad esac
3391 1.1 riastrad
3392 1.1 riastrad func_infer_tag $base_compile
3393 1.1 riastrad
3394 1.1 riastrad for arg in $later; do
3395 1.1 riastrad case $arg in
3396 1.1 riastrad -shared)
3397 1.1 riastrad test yes = "$build_libtool_libs" \
3398 1.1 riastrad || func_fatal_configuration "cannot build a shared library"
3399 1.1 riastrad build_old_libs=no
3400 1.1 riastrad continue
3401 1.1 riastrad ;;
3402 1.1 riastrad
3403 1.1 riastrad -static)
3404 1.1 riastrad build_libtool_libs=no
3405 1.1 riastrad build_old_libs=yes
3406 1.1 riastrad continue
3407 1.1 riastrad ;;
3408 1.1 riastrad
3409 1.1 riastrad -prefer-pic)
3410 1.1 riastrad pic_mode=yes
3411 1.1 riastrad continue
3412 1.1 riastrad ;;
3413 1.1 riastrad
3414 1.1 riastrad -prefer-non-pic)
3415 1.1 riastrad pic_mode=no
3416 1.1 riastrad continue
3417 1.1 riastrad ;;
3418 1.1 riastrad esac
3419 1.1 riastrad done
3420 1.1 riastrad
3421 1.1 riastrad func_quote_for_eval "$libobj"
3422 1.1 riastrad test "X$libobj" != "X$func_quote_for_eval_result" \
3423 1.1 riastrad && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
3424 1.1 riastrad && func_warning "libobj name '$libobj' may not contain shell special characters."
3425 1.1 riastrad func_dirname_and_basename "$obj" "/" ""
3426 1.1 riastrad objname=$func_basename_result
3427 1.1 riastrad xdir=$func_dirname_result
3428 1.1 riastrad lobj=$xdir$objdir/$objname
3429 1.1 riastrad
3430 1.1 riastrad test -z "$base_compile" && \
3431 1.1 riastrad func_fatal_help "you must specify a compilation command"
3432 1.1 riastrad
3433 1.1 riastrad # Delete any leftover library objects.
3434 1.1 riastrad if test yes = "$build_old_libs"; then
3435 1.1 riastrad removelist="$obj $lobj $libobj ${libobj}T"
3436 1.1 riastrad else
3437 1.1 riastrad removelist="$lobj $libobj ${libobj}T"
3438 1.1 riastrad fi
3439 1.1 riastrad
3440 1.1 riastrad # On Cygwin there's no "real" PIC flag so we must build both object types
3441 1.1 riastrad case $host_os in
3442 1.1 riastrad cygwin* | mingw* | pw32* | os2* | cegcc*)
3443 1.1 riastrad pic_mode=default
3444 1.1 riastrad ;;
3445 1.1 riastrad esac
3446 1.1 riastrad if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447 1.1 riastrad # non-PIC code in shared libraries is not supported
3448 1.1 riastrad pic_mode=default
3449 1.1 riastrad fi
3450 1.1 riastrad
3451 1.1 riastrad # Calculate the filename of the output object if compiler does
3452 1.1 riastrad # not support -o with -c
3453 1.1 riastrad if test no = "$compiler_c_o"; then
3454 1.1 riastrad output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3455 1.1 riastrad lockfile=$output_obj.lock
3456 1.1 riastrad else
3457 1.1 riastrad output_obj=
3458 1.1 riastrad need_locks=no
3459 1.1 riastrad lockfile=
3460 1.1 riastrad fi
3461 1.1 riastrad
3462 1.1 riastrad # Lock this critical section if it is needed
3463 1.1 riastrad # We use this script file to make the link, it avoids creating a new file
3464 1.1 riastrad if test yes = "$need_locks"; then
3465 1.1 riastrad until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3466 1.1 riastrad func_echo "Waiting for $lockfile to be removed"
3467 1.1 riastrad sleep 2
3468 1.1 riastrad done
3469 1.1 riastrad elif test warn = "$need_locks"; then
3470 1.1 riastrad if test -f "$lockfile"; then
3471 1.1 riastrad $ECHO "\
3472 1.1 riastrad *** ERROR, $lockfile exists and contains:
3473 1.1 riastrad `cat $lockfile 2>/dev/null`
3474 1.1 riastrad
3475 1.1 riastrad This indicates that another process is trying to use the same
3476 1.1 riastrad temporary object file, and libtool could not work around it because
3477 1.1 riastrad your compiler does not support '-c' and '-o' together. If you
3478 1.1 riastrad repeat this compilation, it may succeed, by chance, but you had better
3479 1.1 riastrad avoid parallel builds (make -j) in this platform, or get a better
3480 1.1 riastrad compiler."
3481 1.1 riastrad
3482 1.1 riastrad $opt_dry_run || $RM $removelist
3483 1.1 riastrad exit $EXIT_FAILURE
3484 1.1 riastrad fi
3485 1.1 riastrad func_append removelist " $output_obj"
3486 1.1 riastrad $ECHO "$srcfile" > "$lockfile"
3487 1.1 riastrad fi
3488 1.1 riastrad
3489 1.1 riastrad $opt_dry_run || $RM $removelist
3490 1.1 riastrad func_append removelist " $lockfile"
3491 1.1 riastrad trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3492 1.1 riastrad
3493 1.1 riastrad func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494 1.1 riastrad srcfile=$func_to_tool_file_result
3495 1.1 riastrad func_quote_for_eval "$srcfile"
3496 1.1 riastrad qsrcfile=$func_quote_for_eval_result
3497 1.1 riastrad
3498 1.1 riastrad # Only build a PIC object if we are building libtool libraries.
3499 1.1 riastrad if test yes = "$build_libtool_libs"; then
3500 1.1 riastrad # Without this assignment, base_compile gets emptied.
3501 1.1 riastrad fbsd_hideous_sh_bug=$base_compile
3502 1.1 riastrad
3503 1.1 riastrad if test no != "$pic_mode"; then
3504 1.1 riastrad command="$base_compile $qsrcfile $pic_flag"
3505 1.1 riastrad else
3506 1.1 riastrad # Don't build PIC code
3507 1.1 riastrad command="$base_compile $qsrcfile"
3508 1.1 riastrad fi
3509 1.1 riastrad
3510 1.1 riastrad func_mkdir_p "$xdir$objdir"
3511 1.1 riastrad
3512 1.1 riastrad if test -z "$output_obj"; then
3513 1.1 riastrad # Place PIC objects in $objdir
3514 1.1 riastrad func_append command " -o $lobj"
3515 1.1 riastrad fi
3516 1.1 riastrad
3517 1.1 riastrad func_show_eval_locale "$command" \
3518 1.1 riastrad 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519 1.1 riastrad
3520 1.1 riastrad if test warn = "$need_locks" &&
3521 1.1 riastrad test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3522 1.1 riastrad $ECHO "\
3523 1.1 riastrad *** ERROR, $lockfile contains:
3524 1.1 riastrad `cat $lockfile 2>/dev/null`
3525 1.1 riastrad
3526 1.1 riastrad but it should contain:
3527 1.1 riastrad $srcfile
3528 1.1 riastrad
3529 1.1 riastrad This indicates that another process is trying to use the same
3530 1.1 riastrad temporary object file, and libtool could not work around it because
3531 1.1 riastrad your compiler does not support '-c' and '-o' together. If you
3532 1.1 riastrad repeat this compilation, it may succeed, by chance, but you had better
3533 1.1 riastrad avoid parallel builds (make -j) in this platform, or get a better
3534 1.1 riastrad compiler."
3535 1.1 riastrad
3536 1.1 riastrad $opt_dry_run || $RM $removelist
3537 1.1 riastrad exit $EXIT_FAILURE
3538 1.1 riastrad fi
3539 1.1 riastrad
3540 1.1 riastrad # Just move the object if needed, then go on to compile the next one
3541 1.1 riastrad if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3542 1.1 riastrad func_show_eval '$MV "$output_obj" "$lobj"' \
3543 1.1 riastrad 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544 1.1 riastrad fi
3545 1.1 riastrad
3546 1.1 riastrad # Allow error messages only from the first compilation.
3547 1.1 riastrad if test yes = "$suppress_opt"; then
3548 1.1 riastrad suppress_output=' >/dev/null 2>&1'
3549 1.1 riastrad fi
3550 1.1 riastrad fi
3551 1.1 riastrad
3552 1.1 riastrad # Only build a position-dependent object if we build old libraries.
3553 1.1 riastrad if test yes = "$build_old_libs"; then
3554 1.1 riastrad if test yes != "$pic_mode"; then
3555 1.1 riastrad # Don't build PIC code
3556 1.1 riastrad command="$base_compile $qsrcfile$pie_flag"
3557 1.1 riastrad else
3558 1.1 riastrad command="$base_compile $qsrcfile $pic_flag"
3559 1.1 riastrad fi
3560 1.1 riastrad if test yes = "$compiler_c_o"; then
3561 1.1 riastrad func_append command " -o $obj"
3562 1.1 riastrad fi
3563 1.1 riastrad
3564 1.1 riastrad # Suppress compiler output if we already did a PIC compilation.
3565 1.1 riastrad func_append command "$suppress_output"
3566 1.1 riastrad func_show_eval_locale "$command" \
3567 1.1 riastrad '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568 1.1 riastrad
3569 1.1 riastrad if test warn = "$need_locks" &&
3570 1.1 riastrad test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3571 1.1 riastrad $ECHO "\
3572 1.1 riastrad *** ERROR, $lockfile contains:
3573 1.1 riastrad `cat $lockfile 2>/dev/null`
3574 1.1 riastrad
3575 1.1 riastrad but it should contain:
3576 1.1 riastrad $srcfile
3577 1.1 riastrad
3578 1.1 riastrad This indicates that another process is trying to use the same
3579 1.1 riastrad temporary object file, and libtool could not work around it because
3580 1.1 riastrad your compiler does not support '-c' and '-o' together. If you
3581 1.1 riastrad repeat this compilation, it may succeed, by chance, but you had better
3582 1.1 riastrad avoid parallel builds (make -j) in this platform, or get a better
3583 1.1 riastrad compiler."
3584 1.1 riastrad
3585 1.1 riastrad $opt_dry_run || $RM $removelist
3586 1.1 riastrad exit $EXIT_FAILURE
3587 1.1 riastrad fi
3588 1.1 riastrad
3589 1.1 riastrad # Just move the object if needed
3590 1.1 riastrad if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3591 1.1 riastrad func_show_eval '$MV "$output_obj" "$obj"' \
3592 1.1 riastrad 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593 1.1 riastrad fi
3594 1.1 riastrad fi
3595 1.1 riastrad
3596 1.1 riastrad $opt_dry_run || {
3597 1.1 riastrad func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598 1.1 riastrad
3599 1.1 riastrad # Unlock the critical section if it was locked
3600 1.1 riastrad if test no != "$need_locks"; then
3601 1.1 riastrad removelist=$lockfile
3602 1.1 riastrad $RM "$lockfile"
3603 1.1 riastrad fi
3604 1.1 riastrad }
3605 1.1 riastrad
3606 1.1 riastrad exit $EXIT_SUCCESS
3607 1.1 riastrad }
3608 1.1 riastrad
3609 1.1 riastrad $opt_help || {
3610 1.1 riastrad test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3611 1.1 riastrad }
3612 1.1 riastrad
3613 1.1 riastrad func_mode_help ()
3614 1.1 riastrad {
3615 1.1 riastrad # We need to display help for each of the modes.
3616 1.1 riastrad case $opt_mode in
3617 1.1 riastrad "")
3618 1.1 riastrad # Generic help is extracted from the usage comments
3619 1.1 riastrad # at the start of this file.
3620 1.1 riastrad func_help
3621 1.1 riastrad ;;
3622 1.1 riastrad
3623 1.1 riastrad clean)
3624 1.1 riastrad $ECHO \
3625 1.1 riastrad "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626 1.1 riastrad
3627 1.1 riastrad Remove files from the build directory.
3628 1.1 riastrad
3629 1.1 riastrad RM is the name of the program to use to delete files associated with each FILE
3630 1.1 riastrad (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3631 1.1 riastrad to RM.
3632 1.1 riastrad
3633 1.1 riastrad If FILE is a libtool library, object or program, all the files associated
3634 1.1 riastrad with it are deleted. Otherwise, only FILE itself is deleted using RM."
3635 1.1 riastrad ;;
3636 1.1 riastrad
3637 1.1 riastrad compile)
3638 1.1 riastrad $ECHO \
3639 1.1 riastrad "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640 1.1 riastrad
3641 1.1 riastrad Compile a source file into a libtool library object.
3642 1.1 riastrad
3643 1.1 riastrad This mode accepts the following additional options:
3644 1.1 riastrad
3645 1.1 riastrad -o OUTPUT-FILE set the output file name to OUTPUT-FILE
3646 1.1 riastrad -no-suppress do not suppress compiler output for multiple passes
3647 1.1 riastrad -prefer-pic try to build PIC objects only
3648 1.1 riastrad -prefer-non-pic try to build non-PIC objects only
3649 1.1 riastrad -shared do not build a '.o' file suitable for static linking
3650 1.1 riastrad -static only build a '.o' file suitable for static linking
3651 1.1 riastrad -Wc,FLAG pass FLAG directly to the compiler
3652 1.1 riastrad
3653 1.1 riastrad COMPILE-COMMAND is a command to be used in creating a 'standard' object file
3654 1.1 riastrad from the given SOURCEFILE.
3655 1.1 riastrad
3656 1.1 riastrad The output file name is determined by removing the directory component from
3657 1.1 riastrad SOURCEFILE, then substituting the C source code suffix '.c' with the
3658 1.1 riastrad library object suffix, '.lo'."
3659 1.1 riastrad ;;
3660 1.1 riastrad
3661 1.1 riastrad execute)
3662 1.1 riastrad $ECHO \
3663 1.1 riastrad "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664 1.1 riastrad
3665 1.1 riastrad Automatically set library path, then run a program.
3666 1.1 riastrad
3667 1.1 riastrad This mode accepts the following additional options:
3668 1.1 riastrad
3669 1.1 riastrad -dlopen FILE add the directory containing FILE to the library path
3670 1.1 riastrad
3671 1.1 riastrad This mode sets the library path environment variable according to '-dlopen'
3672 1.1 riastrad flags.
3673 1.1 riastrad
3674 1.1 riastrad If any of the ARGS are libtool executable wrappers, then they are translated
3675 1.1 riastrad into their corresponding uninstalled binary, and any of their required library
3676 1.1 riastrad directories are added to the library path.
3677 1.1 riastrad
3678 1.1 riastrad Then, COMMAND is executed, with ARGS as arguments."
3679 1.1 riastrad ;;
3680 1.1 riastrad
3681 1.1 riastrad finish)
3682 1.1 riastrad $ECHO \
3683 1.1 riastrad "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684 1.1 riastrad
3685 1.1 riastrad Complete the installation of libtool libraries.
3686 1.1 riastrad
3687 1.1 riastrad Each LIBDIR is a directory that contains libtool libraries.
3688 1.1 riastrad
3689 1.1 riastrad The commands that this mode executes may require superuser privileges. Use
3690 1.1 riastrad the '--dry-run' option if you just want to see what would be executed."
3691 1.1 riastrad ;;
3692 1.1 riastrad
3693 1.1 riastrad install)
3694 1.1 riastrad $ECHO \
3695 1.1 riastrad "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696 1.1 riastrad
3697 1.1 riastrad Install executables or libraries.
3698 1.1 riastrad
3699 1.1 riastrad INSTALL-COMMAND is the installation command. The first component should be
3700 1.1 riastrad either the 'install' or 'cp' program.
3701 1.1 riastrad
3702 1.1 riastrad The following components of INSTALL-COMMAND are treated specially:
3703 1.1 riastrad
3704 1.1 riastrad -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
3705 1.1 riastrad
3706 1.1 riastrad The rest of the components are interpreted as arguments to that command (only
3707 1.1 riastrad BSD-compatible install options are recognized)."
3708 1.1 riastrad ;;
3709 1.1 riastrad
3710 1.1 riastrad link)
3711 1.1 riastrad $ECHO \
3712 1.1 riastrad "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713 1.1 riastrad
3714 1.1 riastrad Link object files or libraries together to form another library, or to
3715 1.1 riastrad create an executable program.
3716 1.1 riastrad
3717 1.1 riastrad LINK-COMMAND is a command using the C compiler that you would use to create
3718 1.1 riastrad a program from several object files.
3719 1.1 riastrad
3720 1.1 riastrad The following components of LINK-COMMAND are treated specially:
3721 1.1 riastrad
3722 1.1 riastrad -all-static do not do any dynamic linking at all
3723 1.1 riastrad -avoid-version do not add a version suffix if possible
3724 1.1 riastrad -bindir BINDIR specify path to binaries directory (for systems where
3725 1.1 riastrad libraries must be found in the PATH setting at runtime)
3726 1.1 riastrad -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
3727 1.1 riastrad -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
3728 1.1 riastrad -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3729 1.1 riastrad -export-symbols SYMFILE
3730 1.1 riastrad try to export only the symbols listed in SYMFILE
3731 1.1 riastrad -export-symbols-regex REGEX
3732 1.1 riastrad try to export only the symbols matching REGEX
3733 1.1 riastrad -LLIBDIR search LIBDIR for required installed libraries
3734 1.1 riastrad -lNAME OUTPUT-FILE requires the installed library libNAME
3735 1.1 riastrad -module build a library that can dlopened
3736 1.1 riastrad -no-fast-install disable the fast-install mode
3737 1.1 riastrad -no-install link a not-installable executable
3738 1.1 riastrad -no-undefined declare that a library does not refer to external symbols
3739 1.1 riastrad -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
3740 1.1 riastrad -objectlist FILE use a list of object files found in FILE to specify objects
3741 1.1 riastrad -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
3742 1.1 riastrad -precious-files-regex REGEX
3743 1.1 riastrad don't remove output files matching REGEX
3744 1.1 riastrad -release RELEASE specify package release information
3745 1.1 riastrad -rpath LIBDIR the created library will eventually be installed in LIBDIR
3746 1.1 riastrad -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
3747 1.1 riastrad -shared only do dynamic linking of libtool libraries
3748 1.1 riastrad -shrext SUFFIX override the standard shared library file extension
3749 1.1 riastrad -static do not do any dynamic linking of uninstalled libtool libraries
3750 1.1 riastrad -static-libtool-libs
3751 1.1 riastrad do not do any dynamic linking of libtool libraries
3752 1.1 riastrad -version-info CURRENT[:REVISION[:AGE]]
3753 1.1 riastrad specify library version info [each variable defaults to 0]
3754 1.1 riastrad -weak LIBNAME declare that the target provides the LIBNAME interface
3755 1.1 riastrad -Wc,FLAG
3756 1.1 riastrad -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
3757 1.1 riastrad -Wl,FLAG
3758 1.1 riastrad -Xlinker FLAG pass linker-specific FLAG directly to the linker
3759 1.1 riastrad -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
3760 1.1 riastrad
3761 1.1 riastrad All other options (arguments beginning with '-') are ignored.
3762 1.1 riastrad
3763 1.1 riastrad Every other argument is treated as a filename. Files ending in '.la' are
3764 1.1 riastrad treated as uninstalled libtool libraries, other files are standard or library
3765 1.1 riastrad object files.
3766 1.1 riastrad
3767 1.1 riastrad If the OUTPUT-FILE ends in '.la', then a libtool library is created,
3768 1.1 riastrad only library objects ('.lo' files) may be specified, and '-rpath' is
3769 1.1 riastrad required, except when creating a convenience library.
3770 1.1 riastrad
3771 1.1 riastrad If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3772 1.1 riastrad using 'ar' and 'ranlib', or on Windows using 'lib'.
3773 1.1 riastrad
3774 1.1 riastrad If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3775 1.1 riastrad is created, otherwise an executable program is created."
3776 1.1 riastrad ;;
3777 1.1 riastrad
3778 1.1 riastrad uninstall)
3779 1.1 riastrad $ECHO \
3780 1.1 riastrad "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781 1.1 riastrad
3782 1.1 riastrad Remove libraries from an installation directory.
3783 1.1 riastrad
3784 1.1 riastrad RM is the name of the program to use to delete files associated with each FILE
3785 1.1 riastrad (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3786 1.1 riastrad to RM.
3787 1.1 riastrad
3788 1.1 riastrad If FILE is a libtool library, all the files associated with it are deleted.
3789 1.1 riastrad Otherwise, only FILE itself is deleted using RM."
3790 1.1 riastrad ;;
3791 1.1 riastrad
3792 1.1 riastrad *)
3793 1.1 riastrad func_fatal_help "invalid operation mode '$opt_mode'"
3794 1.1 riastrad ;;
3795 1.1 riastrad esac
3796 1.1 riastrad
3797 1.1 riastrad echo
3798 1.1 riastrad $ECHO "Try '$progname --help' for more information about other modes."
3799 1.1 riastrad }
3800 1.1 riastrad
3801 1.1 riastrad # Now that we've collected a possible --mode arg, show help if necessary
3802 1.1 riastrad if $opt_help; then
3803 1.1 riastrad if test : = "$opt_help"; then
3804 1.1 riastrad func_mode_help
3805 1.1 riastrad else
3806 1.1 riastrad {
3807 1.1 riastrad func_help noexit
3808 1.1 riastrad for opt_mode in compile link execute install finish uninstall clean; do
3809 1.1 riastrad func_mode_help
3810 1.1 riastrad done
3811 1.1 riastrad } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
3812 1.1 riastrad {
3813 1.1 riastrad func_help noexit
3814 1.1 riastrad for opt_mode in compile link execute install finish uninstall clean; do
3815 1.1 riastrad echo
3816 1.1 riastrad func_mode_help
3817 1.1 riastrad done
3818 1.1 riastrad } |
3819 1.1 riastrad $SED '1d
3820 1.1 riastrad /^When reporting/,/^Report/{
3821 1.1 riastrad H
3822 1.1 riastrad d
3823 1.1 riastrad }
3824 1.1 riastrad $x
3825 1.1 riastrad /information about other modes/d
3826 1.1 riastrad /more detailed .*MODE/d
3827 1.1 riastrad s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828 1.1 riastrad fi
3829 1.1 riastrad exit $?
3830 1.1 riastrad fi
3831 1.1 riastrad
3832 1.1 riastrad
3833 1.1 riastrad # func_mode_execute arg...
3834 1.1 riastrad func_mode_execute ()
3835 1.1 riastrad {
3836 1.1 riastrad $debug_cmd
3837 1.1 riastrad
3838 1.1 riastrad # The first argument is the command name.
3839 1.1 riastrad cmd=$nonopt
3840 1.1 riastrad test -z "$cmd" && \
3841 1.1 riastrad func_fatal_help "you must specify a COMMAND"
3842 1.1 riastrad
3843 1.1 riastrad # Handle -dlopen flags immediately.
3844 1.1 riastrad for file in $opt_dlopen; do
3845 1.1 riastrad test -f "$file" \
3846 1.1 riastrad || func_fatal_help "'$file' is not a file"
3847 1.1 riastrad
3848 1.1 riastrad dir=
3849 1.1 riastrad case $file in
3850 1.1 riastrad *.la)
3851 1.1 riastrad func_resolve_sysroot "$file"
3852 1.1 riastrad file=$func_resolve_sysroot_result
3853 1.1 riastrad
3854 1.1 riastrad # Check to see that this really is a libtool archive.
3855 1.1 riastrad func_lalib_unsafe_p "$file" \
3856 1.1 riastrad || func_fatal_help "'$lib' is not a valid libtool archive"
3857 1.1 riastrad
3858 1.1 riastrad # Read the libtool library.
3859 1.1 riastrad dlname=
3860 1.1 riastrad library_names=
3861 1.1 riastrad func_source "$file"
3862 1.1 riastrad
3863 1.1 riastrad # Skip this library if it cannot be dlopened.
3864 1.1 riastrad if test -z "$dlname"; then
3865 1.1 riastrad # Warn if it was a shared library.
3866 1.1 riastrad test -n "$library_names" && \
3867 1.1 riastrad func_warning "'$file' was not linked with '-export-dynamic'"
3868 1.1 riastrad continue
3869 1.1 riastrad fi
3870 1.1 riastrad
3871 1.1 riastrad func_dirname "$file" "" "."
3872 1.1 riastrad dir=$func_dirname_result
3873 1.1 riastrad
3874 1.1 riastrad if test -f "$dir/$objdir/$dlname"; then
3875 1.1 riastrad func_append dir "/$objdir"
3876 1.1 riastrad else
3877 1.1 riastrad if test ! -f "$dir/$dlname"; then
3878 1.1 riastrad func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3879 1.1 riastrad fi
3880 1.1 riastrad fi
3881 1.1 riastrad ;;
3882 1.1 riastrad
3883 1.1 riastrad *.lo)
3884 1.1 riastrad # Just add the directory containing the .lo file.
3885 1.1 riastrad func_dirname "$file" "" "."
3886 1.1 riastrad dir=$func_dirname_result
3887 1.1 riastrad ;;
3888 1.1 riastrad
3889 1.1 riastrad *)
3890 1.1 riastrad func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3891 1.1 riastrad continue
3892 1.1 riastrad ;;
3893 1.1 riastrad esac
3894 1.1 riastrad
3895 1.1 riastrad # Get the absolute pathname.
3896 1.1 riastrad absdir=`cd "$dir" && pwd`
3897 1.1 riastrad test -n "$absdir" && dir=$absdir
3898 1.1 riastrad
3899 1.1 riastrad # Now add the directory to shlibpath_var.
3900 1.1 riastrad if eval "test -z \"\$$shlibpath_var\""; then
3901 1.1 riastrad eval "$shlibpath_var=\"\$dir\""
3902 1.1 riastrad else
3903 1.1 riastrad eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3904 1.1 riastrad fi
3905 1.1 riastrad done
3906 1.1 riastrad
3907 1.1 riastrad # This variable tells wrapper scripts just to set shlibpath_var
3908 1.1 riastrad # rather than running their programs.
3909 1.1 riastrad libtool_execute_magic=$magic
3910 1.1 riastrad
3911 1.1 riastrad # Check if any of the arguments is a wrapper script.
3912 1.1 riastrad args=
3913 1.1 riastrad for file
3914 1.1 riastrad do
3915 1.1 riastrad case $file in
3916 1.1 riastrad -* | *.la | *.lo ) ;;
3917 1.1 riastrad *)
3918 1.1 riastrad # Do a test to see if this is really a libtool program.
3919 1.1 riastrad if func_ltwrapper_script_p "$file"; then
3920 1.1 riastrad func_source "$file"
3921 1.1 riastrad # Transform arg to wrapped name.
3922 1.1 riastrad file=$progdir/$program
3923 1.1 riastrad elif func_ltwrapper_executable_p "$file"; then
3924 1.1 riastrad func_ltwrapper_scriptname "$file"
3925 1.1 riastrad func_source "$func_ltwrapper_scriptname_result"
3926 1.1 riastrad # Transform arg to wrapped name.
3927 1.1 riastrad file=$progdir/$program
3928 1.1 riastrad fi
3929 1.1 riastrad ;;
3930 1.1 riastrad esac
3931 1.1 riastrad # Quote arguments (to preserve shell metacharacters).
3932 1.1 riastrad func_append_quoted args "$file"
3933 1.1 riastrad done
3934 1.1 riastrad
3935 1.1 riastrad if $opt_dry_run; then
3936 1.1 riastrad # Display what would be done.
3937 1.1 riastrad if test -n "$shlibpath_var"; then
3938 1.1 riastrad eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3939 1.1 riastrad echo "export $shlibpath_var"
3940 1.1 riastrad fi
3941 1.1 riastrad $ECHO "$cmd$args"
3942 1.1 riastrad exit $EXIT_SUCCESS
3943 1.1 riastrad else
3944 1.1 riastrad if test -n "$shlibpath_var"; then
3945 1.1 riastrad # Export the shlibpath_var.
3946 1.1 riastrad eval "export $shlibpath_var"
3947 1.1 riastrad fi
3948 1.1 riastrad
3949 1.1 riastrad # Restore saved environment variables
3950 1.1 riastrad for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3951 1.1 riastrad do
3952 1.1 riastrad eval "if test \"\${save_$lt_var+set}\" = set; then
3953 1.1 riastrad $lt_var=\$save_$lt_var; export $lt_var
3954 1.1 riastrad else
3955 1.1 riastrad $lt_unset $lt_var
3956 1.1 riastrad fi"
3957 1.1 riastrad done
3958 1.1 riastrad
3959 1.1 riastrad # Now prepare to actually exec the command.
3960 1.1 riastrad exec_cmd=\$cmd$args
3961 1.1 riastrad fi
3962 1.1 riastrad }
3963 1.1 riastrad
3964 1.1 riastrad test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3965 1.1 riastrad
3966 1.1 riastrad
3967 1.1 riastrad # func_mode_finish arg...
3968 1.1 riastrad func_mode_finish ()
3969 1.1 riastrad {
3970 1.1 riastrad $debug_cmd
3971 1.1 riastrad
3972 1.1 riastrad libs=
3973 1.1 riastrad libdirs=
3974 1.1 riastrad admincmds=
3975 1.1 riastrad
3976 1.1 riastrad for opt in "$nonopt" ${1+"$@"}
3977 1.1 riastrad do
3978 1.1 riastrad if test -d "$opt"; then
3979 1.1 riastrad func_append libdirs " $opt"
3980 1.1 riastrad
3981 1.1 riastrad elif test -f "$opt"; then
3982 1.1 riastrad if func_lalib_unsafe_p "$opt"; then
3983 1.1 riastrad func_append libs " $opt"
3984 1.1 riastrad else
3985 1.1 riastrad func_warning "'$opt' is not a valid libtool archive"
3986 1.1 riastrad fi
3987 1.1 riastrad
3988 1.1 riastrad else
3989 1.1 riastrad func_fatal_error "invalid argument '$opt'"
3990 1.1 riastrad fi
3991 1.1 riastrad done
3992 1.1 riastrad
3993 1.1 riastrad if test -n "$libs"; then
3994 1.1 riastrad if test -n "$lt_sysroot"; then
3995 1.1 riastrad sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996 1.1 riastrad sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997 1.1 riastrad else
3998 1.1 riastrad sysroot_cmd=
3999 1.1 riastrad fi
4000 1.1 riastrad
4001 1.1 riastrad # Remove sysroot references
4002 1.1 riastrad if $opt_dry_run; then
4003 1.1 riastrad for lib in $libs; do
4004 1.1 riastrad echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005 1.1 riastrad done
4006 1.1 riastrad else
4007 1.1 riastrad tmpdir=`func_mktempdir`
4008 1.1 riastrad for lib in $libs; do
4009 1.1 riastrad $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010 1.1 riastrad > $tmpdir/tmp-la
4011 1.1 riastrad mv -f $tmpdir/tmp-la $lib
4012 1.1 riastrad done
4013 1.1 riastrad ${RM}r "$tmpdir"
4014 1.1 riastrad fi
4015 1.1 riastrad fi
4016 1.1 riastrad
4017 1.1 riastrad if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4018 1.1 riastrad for libdir in $libdirs; do
4019 1.1 riastrad if test -n "$finish_cmds"; then
4020 1.1 riastrad # Do each command in the finish commands.
4021 1.1 riastrad func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4022 1.1 riastrad '"$cmd"'"'
4023 1.1 riastrad fi
4024 1.1 riastrad if test -n "$finish_eval"; then
4025 1.1 riastrad # Do the single finish_eval.
4026 1.1 riastrad eval cmds=\"$finish_eval\"
4027 1.1 riastrad $opt_dry_run || eval "$cmds" || func_append admincmds "
4028 1.1 riastrad $cmds"
4029 1.1 riastrad fi
4030 1.1 riastrad done
4031 1.1 riastrad fi
4032 1.1 riastrad
4033 1.1 riastrad # Exit here if they wanted silent mode.
4034 1.1 riastrad $opt_quiet && exit $EXIT_SUCCESS
4035 1.1 riastrad
4036 1.1 riastrad if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037 1.1 riastrad echo "----------------------------------------------------------------------"
4038 1.1 riastrad echo "Libraries have been installed in:"
4039 1.1 riastrad for libdir in $libdirs; do
4040 1.1 riastrad $ECHO " $libdir"
4041 1.1 riastrad done
4042 1.1 riastrad echo
4043 1.1 riastrad echo "If you ever happen to want to link against installed libraries"
4044 1.1 riastrad echo "in a given directory, LIBDIR, you must either use libtool, and"
4045 1.1 riastrad echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046 1.1 riastrad echo "flag during linking and do at least one of the following:"
4047 1.1 riastrad if test -n "$shlibpath_var"; then
4048 1.1 riastrad echo " - add LIBDIR to the '$shlibpath_var' environment variable"
4049 1.1 riastrad echo " during execution"
4050 1.1 riastrad fi
4051 1.1 riastrad if test -n "$runpath_var"; then
4052 1.1 riastrad echo " - add LIBDIR to the '$runpath_var' environment variable"
4053 1.1 riastrad echo " during linking"
4054 1.1 riastrad fi
4055 1.1 riastrad if test -n "$hardcode_libdir_flag_spec"; then
4056 1.1 riastrad libdir=LIBDIR
4057 1.1 riastrad eval flag=\"$hardcode_libdir_flag_spec\"
4058 1.1 riastrad
4059 1.1 riastrad $ECHO " - use the '$flag' linker flag"
4060 1.1 riastrad fi
4061 1.1 riastrad if test -n "$admincmds"; then
4062 1.1 riastrad $ECHO " - have your system administrator run these commands:$admincmds"
4063 1.1 riastrad fi
4064 1.1 riastrad if test -f /etc/ld.so.conf; then
4065 1.1 riastrad echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066 1.1 riastrad fi
4067 1.1 riastrad echo
4068 1.1 riastrad
4069 1.1 riastrad echo "See any operating system documentation about shared libraries for"
4070 1.1 riastrad case $host in
4071 1.1 riastrad solaris2.[6789]|solaris2.1[0-9])
4072 1.1 riastrad echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073 1.1 riastrad echo "pages."
4074 1.1 riastrad ;;
4075 1.1 riastrad *)
4076 1.1 riastrad echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077 1.1 riastrad ;;
4078 1.1 riastrad esac
4079 1.1 riastrad echo "----------------------------------------------------------------------"
4080 1.1 riastrad fi
4081 1.1 riastrad exit $EXIT_SUCCESS
4082 1.1 riastrad }
4083 1.1 riastrad
4084 1.1 riastrad test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085 1.1 riastrad
4086 1.1 riastrad
4087 1.1 riastrad # func_mode_install arg...
4088 1.1 riastrad func_mode_install ()
4089 1.1 riastrad {
4090 1.1 riastrad $debug_cmd
4091 1.1 riastrad
4092 1.1 riastrad # There may be an optional sh(1) argument at the beginning of
4093 1.1 riastrad # install_prog (especially on Windows NT).
4094 1.1 riastrad if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4095 1.1 riastrad # Allow the use of GNU shtool's install command.
4096 1.1 riastrad case $nonopt in *shtool*) :;; *) false;; esac
4097 1.1 riastrad then
4098 1.1 riastrad # Aesthetically quote it.
4099 1.1 riastrad func_quote_for_eval "$nonopt"
4100 1.1 riastrad install_prog="$func_quote_for_eval_result "
4101 1.1 riastrad arg=$1
4102 1.1 riastrad shift
4103 1.1 riastrad else
4104 1.1 riastrad install_prog=
4105 1.1 riastrad arg=$nonopt
4106 1.1 riastrad fi
4107 1.1 riastrad
4108 1.1 riastrad # The real first argument should be the name of the installation program.
4109 1.1 riastrad # Aesthetically quote it.
4110 1.1 riastrad func_quote_for_eval "$arg"
4111 1.1 riastrad func_append install_prog "$func_quote_for_eval_result"
4112 1.1 riastrad install_shared_prog=$install_prog
4113 1.1 riastrad case " $install_prog " in
4114 1.1 riastrad *[\\\ /]cp\ *) install_cp=: ;;
4115 1.1 riastrad *) install_cp=false ;;
4116 1.1 riastrad esac
4117 1.1 riastrad
4118 1.1 riastrad # We need to accept at least all the BSD install flags.
4119 1.1 riastrad dest=
4120 1.1 riastrad files=
4121 1.1 riastrad opts=
4122 1.1 riastrad prev=
4123 1.1 riastrad install_type=
4124 1.1 riastrad isdir=false
4125 1.1 riastrad stripme=
4126 1.1 riastrad no_mode=:
4127 1.1 riastrad for arg
4128 1.1 riastrad do
4129 1.1 riastrad arg2=
4130 1.1 riastrad if test -n "$dest"; then
4131 1.1 riastrad func_append files " $dest"
4132 1.1 riastrad dest=$arg
4133 1.1 riastrad continue
4134 1.1 riastrad fi
4135 1.1 riastrad
4136 1.1 riastrad case $arg in
4137 1.1 riastrad -d) isdir=: ;;
4138 1.1 riastrad -f)
4139 1.1 riastrad if $install_cp; then :; else
4140 1.1 riastrad prev=$arg
4141 1.1 riastrad fi
4142 1.1 riastrad ;;
4143 1.1 riastrad -g | -m | -o)
4144 1.1 riastrad prev=$arg
4145 1.1 riastrad ;;
4146 1.1 riastrad -s)
4147 1.1 riastrad stripme=" -s"
4148 1.1 riastrad continue
4149 1.1 riastrad ;;
4150 1.1 riastrad -*)
4151 1.1 riastrad ;;
4152 1.1 riastrad *)
4153 1.1 riastrad # If the previous option needed an argument, then skip it.
4154 1.1 riastrad if test -n "$prev"; then
4155 1.1 riastrad if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156 1.1 riastrad arg2=$install_override_mode
4157 1.1 riastrad no_mode=false
4158 1.1 riastrad fi
4159 1.1 riastrad prev=
4160 1.1 riastrad else
4161 1.1 riastrad dest=$arg
4162 1.1 riastrad continue
4163 1.1 riastrad fi
4164 1.1 riastrad ;;
4165 1.1 riastrad esac
4166 1.1 riastrad
4167 1.1 riastrad # Aesthetically quote the argument.
4168 1.1 riastrad func_quote_for_eval "$arg"
4169 1.1 riastrad func_append install_prog " $func_quote_for_eval_result"
4170 1.1 riastrad if test -n "$arg2"; then
4171 1.1 riastrad func_quote_for_eval "$arg2"
4172 1.1 riastrad fi
4173 1.1 riastrad func_append install_shared_prog " $func_quote_for_eval_result"
4174 1.1 riastrad done
4175 1.1 riastrad
4176 1.1 riastrad test -z "$install_prog" && \
4177 1.1 riastrad func_fatal_help "you must specify an install program"
4178 1.1 riastrad
4179 1.1 riastrad test -n "$prev" && \
4180 1.1 riastrad func_fatal_help "the '$prev' option requires an argument"
4181 1.1 riastrad
4182 1.1 riastrad if test -n "$install_override_mode" && $no_mode; then
4183 1.1 riastrad if $install_cp; then :; else
4184 1.1 riastrad func_quote_for_eval "$install_override_mode"
4185 1.1 riastrad func_append install_shared_prog " -m $func_quote_for_eval_result"
4186 1.1 riastrad fi
4187 1.1 riastrad fi
4188 1.1 riastrad
4189 1.1 riastrad if test -z "$files"; then
4190 1.1 riastrad if test -z "$dest"; then
4191 1.1 riastrad func_fatal_help "no file or destination specified"
4192 1.1 riastrad else
4193 1.1 riastrad func_fatal_help "you must specify a destination"
4194 1.1 riastrad fi
4195 1.1 riastrad fi
4196 1.1 riastrad
4197 1.1 riastrad # Strip any trailing slash from the destination.
4198 1.1 riastrad func_stripname '' '/' "$dest"
4199 1.1 riastrad dest=$func_stripname_result
4200 1.1 riastrad
4201 1.1 riastrad # Check to see that the destination is a directory.
4202 1.1 riastrad test -d "$dest" && isdir=:
4203 1.1 riastrad if $isdir; then
4204 1.1 riastrad destdir=$dest
4205 1.1 riastrad destname=
4206 1.1 riastrad else
4207 1.1 riastrad func_dirname_and_basename "$dest" "" "."
4208 1.1 riastrad destdir=$func_dirname_result
4209 1.1 riastrad destname=$func_basename_result
4210 1.1 riastrad
4211 1.1 riastrad # Not a directory, so check to see that there is only one file specified.
4212 1.1 riastrad set dummy $files; shift
4213 1.1 riastrad test "$#" -gt 1 && \
4214 1.1 riastrad func_fatal_help "'$dest' is not a directory"
4215 1.1 riastrad fi
4216 1.1 riastrad case $destdir in
4217 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) ;;
4218 1.1 riastrad *)
4219 1.1 riastrad for file in $files; do
4220 1.1 riastrad case $file in
4221 1.1 riastrad *.lo) ;;
4222 1.1 riastrad *)
4223 1.1 riastrad func_fatal_help "'$destdir' must be an absolute directory name"
4224 1.1 riastrad ;;
4225 1.1 riastrad esac
4226 1.1 riastrad done
4227 1.1 riastrad ;;
4228 1.1 riastrad esac
4229 1.1 riastrad
4230 1.1 riastrad # This variable tells wrapper scripts just to set variables rather
4231 1.1 riastrad # than running their programs.
4232 1.1 riastrad libtool_install_magic=$magic
4233 1.1 riastrad
4234 1.1 riastrad staticlibs=
4235 1.1 riastrad future_libdirs=
4236 1.1 riastrad current_libdirs=
4237 1.1 riastrad for file in $files; do
4238 1.1 riastrad
4239 1.1 riastrad # Do each installation.
4240 1.1 riastrad case $file in
4241 1.1 riastrad *.$libext)
4242 1.1 riastrad # Do the static libraries later.
4243 1.1 riastrad func_append staticlibs " $file"
4244 1.1 riastrad ;;
4245 1.1 riastrad
4246 1.1 riastrad *.la)
4247 1.1 riastrad func_resolve_sysroot "$file"
4248 1.1 riastrad file=$func_resolve_sysroot_result
4249 1.1 riastrad
4250 1.1 riastrad # Check to see that this really is a libtool archive.
4251 1.1 riastrad func_lalib_unsafe_p "$file" \
4252 1.1 riastrad || func_fatal_help "'$file' is not a valid libtool archive"
4253 1.1 riastrad
4254 1.1 riastrad library_names=
4255 1.1 riastrad old_library=
4256 1.1 riastrad relink_command=
4257 1.1 riastrad func_source "$file"
4258 1.1 riastrad
4259 1.1 riastrad # Add the libdir to current_libdirs if it is the destination.
4260 1.1 riastrad if test "X$destdir" = "X$libdir"; then
4261 1.1 riastrad case "$current_libdirs " in
4262 1.1 riastrad *" $libdir "*) ;;
4263 1.1 riastrad *) func_append current_libdirs " $libdir" ;;
4264 1.1 riastrad esac
4265 1.1 riastrad else
4266 1.1 riastrad # Note the libdir as a future libdir.
4267 1.1 riastrad case "$future_libdirs " in
4268 1.1 riastrad *" $libdir "*) ;;
4269 1.1 riastrad *) func_append future_libdirs " $libdir" ;;
4270 1.1 riastrad esac
4271 1.1 riastrad fi
4272 1.1 riastrad
4273 1.1 riastrad func_dirname "$file" "/" ""
4274 1.1 riastrad dir=$func_dirname_result
4275 1.1 riastrad func_append dir "$objdir"
4276 1.1 riastrad
4277 1.1 riastrad if test -n "$relink_command"; then
4278 1.1 riastrad # Determine the prefix the user has applied to our future dir.
4279 1.1 riastrad inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4280 1.1 riastrad
4281 1.1 riastrad # Don't allow the user to place us outside of our expected
4282 1.1 riastrad # location b/c this prevents finding dependent libraries that
4283 1.1 riastrad # are installed to the same prefix.
4284 1.1 riastrad # At present, this check doesn't affect windows .dll's that
4285 1.1 riastrad # are installed into $libdir/../bin (currently, that works fine)
4286 1.1 riastrad # but it's something to keep an eye on.
4287 1.1 riastrad test "$inst_prefix_dir" = "$destdir" && \
4288 1.1 riastrad func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4289 1.1 riastrad
4290 1.1 riastrad if test -n "$inst_prefix_dir"; then
4291 1.1 riastrad # Stick the inst_prefix_dir data into the link command.
4292 1.1 riastrad relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4293 1.1 riastrad else
4294 1.1 riastrad relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4295 1.1 riastrad fi
4296 1.1 riastrad
4297 1.1 riastrad func_warning "relinking '$file'"
4298 1.1 riastrad func_show_eval "$relink_command" \
4299 1.1 riastrad 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4300 1.1 riastrad fi
4301 1.1 riastrad
4302 1.1 riastrad # See the names of the shared library.
4303 1.1 riastrad set dummy $library_names; shift
4304 1.1 riastrad if test -n "$1"; then
4305 1.1 riastrad realname=$1
4306 1.1 riastrad shift
4307 1.1 riastrad
4308 1.1 riastrad srcname=$realname
4309 1.1 riastrad test -n "$relink_command" && srcname=${realname}T
4310 1.1 riastrad
4311 1.1 riastrad # Install the shared library and build the symlinks.
4312 1.1 riastrad func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4313 1.1 riastrad 'exit $?'
4314 1.1 riastrad tstripme=$stripme
4315 1.1 riastrad case $host_os in
4316 1.1 riastrad cygwin* | mingw* | pw32* | cegcc*)
4317 1.1 riastrad case $realname in
4318 1.1 riastrad *.dll.a)
4319 1.1 riastrad tstripme=
4320 1.1 riastrad ;;
4321 1.1 riastrad esac
4322 1.1 riastrad ;;
4323 1.1 riastrad os2*)
4324 1.1 riastrad case $realname in
4325 1.1 riastrad *_dll.a)
4326 1.1 riastrad tstripme=
4327 1.1 riastrad ;;
4328 1.1 riastrad esac
4329 1.1 riastrad ;;
4330 1.1 riastrad esac
4331 1.1 riastrad if test -n "$tstripme" && test -n "$striplib"; then
4332 1.1 riastrad func_show_eval "$striplib $destdir/$realname" 'exit $?'
4333 1.1 riastrad fi
4334 1.1 riastrad
4335 1.1 riastrad if test "$#" -gt 0; then
4336 1.1 riastrad # Delete the old symlinks, and create new ones.
4337 1.1 riastrad # Try 'ln -sf' first, because the 'ln' binary might depend on
4338 1.1 riastrad # the symlink we replace! Solaris /bin/ln does not understand -f,
4339 1.1 riastrad # so we also need to try rm && ln -s.
4340 1.1 riastrad for linkname
4341 1.1 riastrad do
4342 1.1 riastrad test "$linkname" != "$realname" \
4343 1.1 riastrad && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4344 1.1 riastrad done
4345 1.1 riastrad fi
4346 1.1 riastrad
4347 1.1 riastrad # Do each command in the postinstall commands.
4348 1.1 riastrad lib=$destdir/$realname
4349 1.1 riastrad func_execute_cmds "$postinstall_cmds" 'exit $?'
4350 1.1 riastrad fi
4351 1.1 riastrad
4352 1.1 riastrad # Install the pseudo-library for information purposes.
4353 1.1 riastrad func_basename "$file"
4354 1.1 riastrad name=$func_basename_result
4355 1.1 riastrad instname=$dir/${name}i
4356 1.1 riastrad func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357 1.1 riastrad
4358 1.1 riastrad # Maybe install the static library, too.
4359 1.1 riastrad test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4360 1.1 riastrad ;;
4361 1.1 riastrad
4362 1.1 riastrad *.lo)
4363 1.1 riastrad # Install (i.e. copy) a libtool object.
4364 1.1 riastrad
4365 1.1 riastrad # Figure out destination file name, if it wasn't already specified.
4366 1.1 riastrad if test -n "$destname"; then
4367 1.1 riastrad destfile=$destdir/$destname
4368 1.1 riastrad else
4369 1.1 riastrad func_basename "$file"
4370 1.1 riastrad destfile=$func_basename_result
4371 1.1 riastrad destfile=$destdir/$destfile
4372 1.1 riastrad fi
4373 1.1 riastrad
4374 1.1 riastrad # Deduce the name of the destination old-style object file.
4375 1.1 riastrad case $destfile in
4376 1.1 riastrad *.lo)
4377 1.1 riastrad func_lo2o "$destfile"
4378 1.1 riastrad staticdest=$func_lo2o_result
4379 1.1 riastrad ;;
4380 1.1 riastrad *.$objext)
4381 1.1 riastrad staticdest=$destfile
4382 1.1 riastrad destfile=
4383 1.1 riastrad ;;
4384 1.1 riastrad *)
4385 1.1 riastrad func_fatal_help "cannot copy a libtool object to '$destfile'"
4386 1.1 riastrad ;;
4387 1.1 riastrad esac
4388 1.1 riastrad
4389 1.1 riastrad # Install the libtool object if requested.
4390 1.1 riastrad test -n "$destfile" && \
4391 1.1 riastrad func_show_eval "$install_prog $file $destfile" 'exit $?'
4392 1.1 riastrad
4393 1.1 riastrad # Install the old object if enabled.
4394 1.1 riastrad if test yes = "$build_old_libs"; then
4395 1.1 riastrad # Deduce the name of the old-style object file.
4396 1.1 riastrad func_lo2o "$file"
4397 1.1 riastrad staticobj=$func_lo2o_result
4398 1.1 riastrad func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399 1.1 riastrad fi
4400 1.1 riastrad exit $EXIT_SUCCESS
4401 1.1 riastrad ;;
4402 1.1 riastrad
4403 1.1 riastrad *)
4404 1.1 riastrad # Figure out destination file name, if it wasn't already specified.
4405 1.1 riastrad if test -n "$destname"; then
4406 1.1 riastrad destfile=$destdir/$destname
4407 1.1 riastrad else
4408 1.1 riastrad func_basename "$file"
4409 1.1 riastrad destfile=$func_basename_result
4410 1.1 riastrad destfile=$destdir/$destfile
4411 1.1 riastrad fi
4412 1.1 riastrad
4413 1.1 riastrad # If the file is missing, and there is a .exe on the end, strip it
4414 1.1 riastrad # because it is most likely a libtool script we actually want to
4415 1.1 riastrad # install
4416 1.1 riastrad stripped_ext=
4417 1.1 riastrad case $file in
4418 1.1 riastrad *.exe)
4419 1.1 riastrad if test ! -f "$file"; then
4420 1.1 riastrad func_stripname '' '.exe' "$file"
4421 1.1 riastrad file=$func_stripname_result
4422 1.1 riastrad stripped_ext=.exe
4423 1.1 riastrad fi
4424 1.1 riastrad ;;
4425 1.1 riastrad esac
4426 1.1 riastrad
4427 1.1 riastrad # Do a test to see if this is really a libtool program.
4428 1.1 riastrad case $host in
4429 1.1 riastrad *cygwin* | *mingw*)
4430 1.1 riastrad if func_ltwrapper_executable_p "$file"; then
4431 1.1 riastrad func_ltwrapper_scriptname "$file"
4432 1.1 riastrad wrapper=$func_ltwrapper_scriptname_result
4433 1.1 riastrad else
4434 1.1 riastrad func_stripname '' '.exe' "$file"
4435 1.1 riastrad wrapper=$func_stripname_result
4436 1.1 riastrad fi
4437 1.1 riastrad ;;
4438 1.1 riastrad *)
4439 1.1 riastrad wrapper=$file
4440 1.1 riastrad ;;
4441 1.1 riastrad esac
4442 1.1 riastrad if func_ltwrapper_script_p "$wrapper"; then
4443 1.1 riastrad notinst_deplibs=
4444 1.1 riastrad relink_command=
4445 1.1 riastrad
4446 1.1 riastrad func_source "$wrapper"
4447 1.1 riastrad
4448 1.1 riastrad # Check the variables that should have been set.
4449 1.1 riastrad test -z "$generated_by_libtool_version" && \
4450 1.1 riastrad func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451 1.1 riastrad
4452 1.1 riastrad finalize=:
4453 1.1 riastrad for lib in $notinst_deplibs; do
4454 1.1 riastrad # Check to see that each library is installed.
4455 1.1 riastrad libdir=
4456 1.1 riastrad if test -f "$lib"; then
4457 1.1 riastrad func_source "$lib"
4458 1.1 riastrad fi
4459 1.1 riastrad libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4460 1.1 riastrad if test -n "$libdir" && test ! -f "$libfile"; then
4461 1.1 riastrad func_warning "'$lib' has not been installed in '$libdir'"
4462 1.1 riastrad finalize=false
4463 1.1 riastrad fi
4464 1.1 riastrad done
4465 1.1 riastrad
4466 1.1 riastrad relink_command=
4467 1.1 riastrad func_source "$wrapper"
4468 1.1 riastrad
4469 1.1 riastrad outputname=
4470 1.1 riastrad if test no = "$fast_install" && test -n "$relink_command"; then
4471 1.1 riastrad $opt_dry_run || {
4472 1.1 riastrad if $finalize; then
4473 1.1 riastrad tmpdir=`func_mktempdir`
4474 1.1 riastrad func_basename "$file$stripped_ext"
4475 1.1 riastrad file=$func_basename_result
4476 1.1 riastrad outputname=$tmpdir/$file
4477 1.1 riastrad # Replace the output file specification.
4478 1.1 riastrad relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4479 1.1 riastrad
4480 1.1 riastrad $opt_quiet || {
4481 1.1 riastrad func_quote_for_expand "$relink_command"
4482 1.1 riastrad eval "func_echo $func_quote_for_expand_result"
4483 1.1 riastrad }
4484 1.1 riastrad if eval "$relink_command"; then :
4485 1.1 riastrad else
4486 1.1 riastrad func_error "error: relink '$file' with the above command before installing it"
4487 1.1 riastrad $opt_dry_run || ${RM}r "$tmpdir"
4488 1.1 riastrad continue
4489 1.1 riastrad fi
4490 1.1 riastrad file=$outputname
4491 1.1 riastrad else
4492 1.1 riastrad func_warning "cannot relink '$file'"
4493 1.1 riastrad fi
4494 1.1 riastrad }
4495 1.1 riastrad else
4496 1.1 riastrad # Install the binary that we compiled earlier.
4497 1.1 riastrad file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4498 1.1 riastrad fi
4499 1.1 riastrad fi
4500 1.1 riastrad
4501 1.1 riastrad # remove .exe since cygwin /usr/bin/install will append another
4502 1.1 riastrad # one anyway
4503 1.1 riastrad case $install_prog,$host in
4504 1.1 riastrad */usr/bin/install*,*cygwin*)
4505 1.1 riastrad case $file:$destfile in
4506 1.1 riastrad *.exe:*.exe)
4507 1.1 riastrad # this is ok
4508 1.1 riastrad ;;
4509 1.1 riastrad *.exe:*)
4510 1.1 riastrad destfile=$destfile.exe
4511 1.1 riastrad ;;
4512 1.1 riastrad *:*.exe)
4513 1.1 riastrad func_stripname '' '.exe' "$destfile"
4514 1.1 riastrad destfile=$func_stripname_result
4515 1.1 riastrad ;;
4516 1.1 riastrad esac
4517 1.1 riastrad ;;
4518 1.1 riastrad esac
4519 1.1 riastrad func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4520 1.1 riastrad $opt_dry_run || if test -n "$outputname"; then
4521 1.1 riastrad ${RM}r "$tmpdir"
4522 1.1 riastrad fi
4523 1.1 riastrad ;;
4524 1.1 riastrad esac
4525 1.1 riastrad done
4526 1.1 riastrad
4527 1.1 riastrad for file in $staticlibs; do
4528 1.1 riastrad func_basename "$file"
4529 1.1 riastrad name=$func_basename_result
4530 1.1 riastrad
4531 1.1 riastrad # Set up the ranlib parameters.
4532 1.1 riastrad oldlib=$destdir/$name
4533 1.1 riastrad func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4534 1.1 riastrad tool_oldlib=$func_to_tool_file_result
4535 1.1 riastrad
4536 1.1 riastrad func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4537 1.1 riastrad
4538 1.1 riastrad if test -n "$stripme" && test -n "$old_striplib"; then
4539 1.1 riastrad func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4540 1.1 riastrad fi
4541 1.1 riastrad
4542 1.1 riastrad # Do each command in the postinstall commands.
4543 1.1 riastrad func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4544 1.1 riastrad done
4545 1.1 riastrad
4546 1.1 riastrad test -n "$future_libdirs" && \
4547 1.1 riastrad func_warning "remember to run '$progname --finish$future_libdirs'"
4548 1.1 riastrad
4549 1.1 riastrad if test -n "$current_libdirs"; then
4550 1.1 riastrad # Maybe just do a dry run.
4551 1.1 riastrad $opt_dry_run && current_libdirs=" -n$current_libdirs"
4552 1.1 riastrad exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4553 1.1 riastrad else
4554 1.1 riastrad exit $EXIT_SUCCESS
4555 1.1 riastrad fi
4556 1.1 riastrad }
4557 1.1 riastrad
4558 1.1 riastrad test install = "$opt_mode" && func_mode_install ${1+"$@"}
4559 1.1 riastrad
4560 1.1 riastrad
4561 1.1 riastrad # func_generate_dlsyms outputname originator pic_p
4562 1.1 riastrad # Extract symbols from dlprefiles and create ${outputname}S.o with
4563 1.1 riastrad # a dlpreopen symbol table.
4564 1.1 riastrad func_generate_dlsyms ()
4565 1.1 riastrad {
4566 1.1 riastrad $debug_cmd
4567 1.1 riastrad
4568 1.1 riastrad my_outputname=$1
4569 1.1 riastrad my_originator=$2
4570 1.1 riastrad my_pic_p=${3-false}
4571 1.1 riastrad my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4572 1.1 riastrad my_dlsyms=
4573 1.1 riastrad
4574 1.1 riastrad if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4575 1.1 riastrad if test -n "$NM" && test -n "$global_symbol_pipe"; then
4576 1.1 riastrad my_dlsyms=${my_outputname}S.c
4577 1.1 riastrad else
4578 1.1 riastrad func_error "not configured to extract global symbols from dlpreopened files"
4579 1.1 riastrad fi
4580 1.1 riastrad fi
4581 1.1 riastrad
4582 1.1 riastrad if test -n "$my_dlsyms"; then
4583 1.1 riastrad case $my_dlsyms in
4584 1.1 riastrad "") ;;
4585 1.1 riastrad *.c)
4586 1.1 riastrad # Discover the nlist of each of the dlfiles.
4587 1.1 riastrad nlist=$output_objdir/$my_outputname.nm
4588 1.1 riastrad
4589 1.1 riastrad func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4590 1.1 riastrad
4591 1.1 riastrad # Parse the name list into a source file.
4592 1.1 riastrad func_verbose "creating $output_objdir/$my_dlsyms"
4593 1.1 riastrad
4594 1.1 riastrad $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4595 1.1 riastrad /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4596 1.1 riastrad /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4597 1.1 riastrad
4598 1.1 riastrad #ifdef __cplusplus
4599 1.1 riastrad extern \"C\" {
4600 1.1 riastrad #endif
4601 1.1 riastrad
4602 1.1 riastrad #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603 1.1 riastrad #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604 1.1 riastrad #endif
4605 1.1 riastrad
4606 1.1 riastrad /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
4607 1.1 riastrad #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4608 1.1 riastrad /* DATA imports from DLLs on WIN32 can't be const, because runtime
4609 1.1 riastrad relocations are performed -- see ld's documentation on pseudo-relocs. */
4610 1.1 riastrad # define LT_DLSYM_CONST
4611 1.1 riastrad #elif defined __osf__
4612 1.1 riastrad /* This system does not cope well with relocations in const data. */
4613 1.1 riastrad # define LT_DLSYM_CONST
4614 1.1 riastrad #else
4615 1.1 riastrad # define LT_DLSYM_CONST const
4616 1.1 riastrad #endif
4617 1.1 riastrad
4618 1.1 riastrad #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4619 1.1 riastrad
4620 1.1 riastrad /* External symbol declarations for the compiler. */\
4621 1.1 riastrad "
4622 1.1 riastrad
4623 1.1 riastrad if test yes = "$dlself"; then
4624 1.1 riastrad func_verbose "generating symbol list for '$output'"
4625 1.1 riastrad
4626 1.1 riastrad $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4627 1.1 riastrad
4628 1.1 riastrad # Add our own program objects to the symbol list.
4629 1.1 riastrad progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4630 1.1 riastrad for progfile in $progfiles; do
4631 1.1 riastrad func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4632 1.1 riastrad func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633 1.1 riastrad $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4634 1.1 riastrad done
4635 1.1 riastrad
4636 1.1 riastrad if test -n "$exclude_expsyms"; then
4637 1.1 riastrad $opt_dry_run || {
4638 1.1 riastrad eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4639 1.1 riastrad eval '$MV "$nlist"T "$nlist"'
4640 1.1 riastrad }
4641 1.1 riastrad fi
4642 1.1 riastrad
4643 1.1 riastrad if test -n "$export_symbols_regex"; then
4644 1.1 riastrad $opt_dry_run || {
4645 1.1 riastrad eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4646 1.1 riastrad eval '$MV "$nlist"T "$nlist"'
4647 1.1 riastrad }
4648 1.1 riastrad fi
4649 1.1 riastrad
4650 1.1 riastrad # Prepare the list of exported symbols
4651 1.1 riastrad if test -z "$export_symbols"; then
4652 1.1 riastrad export_symbols=$output_objdir/$outputname.exp
4653 1.1 riastrad $opt_dry_run || {
4654 1.1 riastrad $RM $export_symbols
4655 1.1 riastrad eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4656 1.1 riastrad case $host in
4657 1.1 riastrad *cygwin* | *mingw* | *cegcc* )
4658 1.1 riastrad eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4659 1.1 riastrad eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4660 1.1 riastrad ;;
4661 1.1 riastrad esac
4662 1.1 riastrad }
4663 1.1 riastrad else
4664 1.1 riastrad $opt_dry_run || {
4665 1.1 riastrad eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4666 1.1 riastrad eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4667 1.1 riastrad eval '$MV "$nlist"T "$nlist"'
4668 1.1 riastrad case $host in
4669 1.1 riastrad *cygwin* | *mingw* | *cegcc* )
4670 1.1 riastrad eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4671 1.1 riastrad eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4672 1.1 riastrad ;;
4673 1.1 riastrad esac
4674 1.1 riastrad }
4675 1.1 riastrad fi
4676 1.1 riastrad fi
4677 1.1 riastrad
4678 1.1 riastrad for dlprefile in $dlprefiles; do
4679 1.1 riastrad func_verbose "extracting global C symbols from '$dlprefile'"
4680 1.1 riastrad func_basename "$dlprefile"
4681 1.1 riastrad name=$func_basename_result
4682 1.1 riastrad case $host in
4683 1.1 riastrad *cygwin* | *mingw* | *cegcc* )
4684 1.1 riastrad # if an import library, we need to obtain dlname
4685 1.1 riastrad if func_win32_import_lib_p "$dlprefile"; then
4686 1.1 riastrad func_tr_sh "$dlprefile"
4687 1.1 riastrad eval "curr_lafile=\$libfile_$func_tr_sh_result"
4688 1.1 riastrad dlprefile_dlbasename=
4689 1.1 riastrad if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690 1.1 riastrad # Use subshell, to avoid clobbering current variable values
4691 1.1 riastrad dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4692 1.1 riastrad if test -n "$dlprefile_dlname"; then
4693 1.1 riastrad func_basename "$dlprefile_dlname"
4694 1.1 riastrad dlprefile_dlbasename=$func_basename_result
4695 1.1 riastrad else
4696 1.1 riastrad # no lafile. user explicitly requested -dlpreopen <import library>.
4697 1.1 riastrad $sharedlib_from_linklib_cmd "$dlprefile"
4698 1.1 riastrad dlprefile_dlbasename=$sharedlib_from_linklib_result
4699 1.1 riastrad fi
4700 1.1 riastrad fi
4701 1.1 riastrad $opt_dry_run || {
4702 1.1 riastrad if test -n "$dlprefile_dlbasename"; then
4703 1.1 riastrad eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704 1.1 riastrad else
4705 1.1 riastrad func_warning "Could not compute DLL name from $name"
4706 1.1 riastrad eval '$ECHO ": $name " >> "$nlist"'
4707 1.1 riastrad fi
4708 1.1 riastrad func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709 1.1 riastrad eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710 1.1 riastrad $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711 1.1 riastrad }
4712 1.1 riastrad else # not an import lib
4713 1.1 riastrad $opt_dry_run || {
4714 1.1 riastrad eval '$ECHO ": $name " >> "$nlist"'
4715 1.1 riastrad func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716 1.1 riastrad eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717 1.1 riastrad }
4718 1.1 riastrad fi
4719 1.1 riastrad ;;
4720 1.1 riastrad *)
4721 1.1 riastrad $opt_dry_run || {
4722 1.1 riastrad eval '$ECHO ": $name " >> "$nlist"'
4723 1.1 riastrad func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724 1.1 riastrad eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725 1.1 riastrad }
4726 1.1 riastrad ;;
4727 1.1 riastrad esac
4728 1.1 riastrad done
4729 1.1 riastrad
4730 1.1 riastrad $opt_dry_run || {
4731 1.1 riastrad # Make sure we have at least an empty file.
4732 1.1 riastrad test -f "$nlist" || : > "$nlist"
4733 1.1 riastrad
4734 1.1 riastrad if test -n "$exclude_expsyms"; then
4735 1.1 riastrad $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4736 1.1 riastrad $MV "$nlist"T "$nlist"
4737 1.1 riastrad fi
4738 1.1 riastrad
4739 1.1 riastrad # Try sorting and uniquifying the output.
4740 1.1 riastrad if $GREP -v "^: " < "$nlist" |
4741 1.1 riastrad if sort -k 3 </dev/null >/dev/null 2>&1; then
4742 1.1 riastrad sort -k 3
4743 1.1 riastrad else
4744 1.1 riastrad sort +2
4745 1.1 riastrad fi |
4746 1.1 riastrad uniq > "$nlist"S; then
4747 1.1 riastrad :
4748 1.1 riastrad else
4749 1.1 riastrad $GREP -v "^: " < "$nlist" > "$nlist"S
4750 1.1 riastrad fi
4751 1.1 riastrad
4752 1.1 riastrad if test -f "$nlist"S; then
4753 1.1 riastrad eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4754 1.1 riastrad else
4755 1.1 riastrad echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4756 1.1 riastrad fi
4757 1.1 riastrad
4758 1.1 riastrad func_show_eval '$RM "${nlist}I"'
4759 1.1 riastrad if test -n "$global_symbol_to_import"; then
4760 1.1 riastrad eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4761 1.1 riastrad fi
4762 1.1 riastrad
4763 1.1 riastrad echo >> "$output_objdir/$my_dlsyms" "\
4764 1.1 riastrad
4765 1.1 riastrad /* The mapping between symbol names and symbols. */
4766 1.1 riastrad typedef struct {
4767 1.1 riastrad const char *name;
4768 1.1 riastrad void *address;
4769 1.1 riastrad } lt_dlsymlist;
4770 1.1 riastrad extern LT_DLSYM_CONST lt_dlsymlist
4771 1.1 riastrad lt_${my_prefix}_LTX_preloaded_symbols[];\
4772 1.1 riastrad "
4773 1.1 riastrad
4774 1.1 riastrad if test -s "$nlist"I; then
4775 1.1 riastrad echo >> "$output_objdir/$my_dlsyms" "\
4776 1.1 riastrad static void lt_syminit(void)
4777 1.1 riastrad {
4778 1.1 riastrad LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4779 1.1 riastrad for (; symbol->name; ++symbol)
4780 1.1 riastrad {"
4781 1.1 riastrad $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4782 1.1 riastrad echo >> "$output_objdir/$my_dlsyms" "\
4783 1.1 riastrad }
4784 1.1 riastrad }"
4785 1.1 riastrad fi
4786 1.1 riastrad echo >> "$output_objdir/$my_dlsyms" "\
4787 1.1 riastrad LT_DLSYM_CONST lt_dlsymlist
4788 1.1 riastrad lt_${my_prefix}_LTX_preloaded_symbols[] =
4789 1.1 riastrad { {\"$my_originator\", (void *) 0},"
4790 1.1 riastrad
4791 1.1 riastrad if test -s "$nlist"I; then
4792 1.1 riastrad echo >> "$output_objdir/$my_dlsyms" "\
4793 1.1 riastrad {\"@INIT@\", (void *) <_syminit},"
4794 1.1 riastrad fi
4795 1.1 riastrad
4796 1.1 riastrad case $need_lib_prefix in
4797 1.1 riastrad no)
4798 1.1 riastrad eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4799 1.1 riastrad ;;
4800 1.1 riastrad *)
4801 1.1 riastrad eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4802 1.1 riastrad ;;
4803 1.1 riastrad esac
4804 1.1 riastrad echo >> "$output_objdir/$my_dlsyms" "\
4805 1.1 riastrad {0, (void *) 0}
4806 1.1 riastrad };
4807 1.1 riastrad
4808 1.1 riastrad /* This works around a problem in FreeBSD linker */
4809 1.1 riastrad #ifdef FREEBSD_WORKAROUND
4810 1.1 riastrad static const void *lt_preloaded_setup() {
4811 1.1 riastrad return lt_${my_prefix}_LTX_preloaded_symbols;
4812 1.1 riastrad }
4813 1.1 riastrad #endif
4814 1.1 riastrad
4815 1.1 riastrad #ifdef __cplusplus
4816 1.1 riastrad }
4817 1.1 riastrad #endif\
4818 1.1 riastrad "
4819 1.1 riastrad } # !$opt_dry_run
4820 1.1 riastrad
4821 1.1 riastrad pic_flag_for_symtable=
4822 1.1 riastrad case "$compile_command " in
4823 1.1 riastrad *" -static "*) ;;
4824 1.1 riastrad *)
4825 1.1 riastrad case $host in
4826 1.1 riastrad # compiling the symbol table file with pic_flag works around
4827 1.1 riastrad # a FreeBSD bug that causes programs to crash when -lm is
4828 1.1 riastrad # linked before any other PIC object. But we must not use
4829 1.1 riastrad # pic_flag when linking with -static. The problem exists in
4830 1.1 riastrad # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4831 1.1 riastrad *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4832 1.1 riastrad pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4833 1.1 riastrad *-*-hpux*)
4834 1.1 riastrad pic_flag_for_symtable=" $pic_flag" ;;
4835 1.1 riastrad *)
4836 1.1 riastrad $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4837 1.1 riastrad ;;
4838 1.1 riastrad esac
4839 1.1 riastrad ;;
4840 1.1 riastrad esac
4841 1.1 riastrad symtab_cflags=
4842 1.1 riastrad for arg in $LTCFLAGS; do
4843 1.1 riastrad case $arg in
4844 1.1 riastrad -pie | -fpie | -fPIE) ;;
4845 1.1 riastrad *) func_append symtab_cflags " $arg" ;;
4846 1.1 riastrad esac
4847 1.1 riastrad done
4848 1.1 riastrad
4849 1.1 riastrad # Now compile the dynamic symbol file.
4850 1.1 riastrad func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851 1.1 riastrad
4852 1.1 riastrad # Clean up the generated files.
4853 1.1 riastrad func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4854 1.1 riastrad
4855 1.1 riastrad # Transform the symbol file into the correct name.
4856 1.1 riastrad symfileobj=$output_objdir/${my_outputname}S.$objext
4857 1.1 riastrad case $host in
4858 1.1 riastrad *cygwin* | *mingw* | *cegcc* )
4859 1.1 riastrad if test -f "$output_objdir/$my_outputname.def"; then
4860 1.1 riastrad compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861 1.1 riastrad finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4862 1.1 riastrad else
4863 1.1 riastrad compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864 1.1 riastrad finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4865 1.1 riastrad fi
4866 1.1 riastrad ;;
4867 1.1 riastrad *)
4868 1.1 riastrad compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869 1.1 riastrad finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4870 1.1 riastrad ;;
4871 1.1 riastrad esac
4872 1.1 riastrad ;;
4873 1.1 riastrad *)
4874 1.1 riastrad func_fatal_error "unknown suffix for '$my_dlsyms'"
4875 1.1 riastrad ;;
4876 1.1 riastrad esac
4877 1.1 riastrad else
4878 1.1 riastrad # We keep going just in case the user didn't refer to
4879 1.1 riastrad # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
4880 1.1 riastrad # really was required.
4881 1.1 riastrad
4882 1.1 riastrad # Nullify the symbol file.
4883 1.1 riastrad compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884 1.1 riastrad finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4885 1.1 riastrad fi
4886 1.1 riastrad }
4887 1.1 riastrad
4888 1.1 riastrad # func_cygming_gnu_implib_p ARG
4889 1.1 riastrad # This predicate returns with zero status (TRUE) if
4890 1.1 riastrad # ARG is a GNU/binutils-style import library. Returns
4891 1.1 riastrad # with nonzero status (FALSE) otherwise.
4892 1.1 riastrad func_cygming_gnu_implib_p ()
4893 1.1 riastrad {
4894 1.1 riastrad $debug_cmd
4895 1.1 riastrad
4896 1.1 riastrad func_to_tool_file "$1" func_convert_file_msys_to_w32
4897 1.1 riastrad 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 riastrad test -n "$func_cygming_gnu_implib_tmp"
4899 1.1 riastrad }
4900 1.1 riastrad
4901 1.1 riastrad # func_cygming_ms_implib_p ARG
4902 1.1 riastrad # This predicate returns with zero status (TRUE) if
4903 1.1 riastrad # ARG is an MS-style import library. Returns
4904 1.1 riastrad # with nonzero status (FALSE) otherwise.
4905 1.1 riastrad func_cygming_ms_implib_p ()
4906 1.1 riastrad {
4907 1.1 riastrad $debug_cmd
4908 1.1 riastrad
4909 1.1 riastrad func_to_tool_file "$1" func_convert_file_msys_to_w32
4910 1.1 riastrad func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4911 1.1 riastrad test -n "$func_cygming_ms_implib_tmp"
4912 1.1 riastrad }
4913 1.1 riastrad
4914 1.1 riastrad # func_win32_libid arg
4915 1.1 riastrad # return the library type of file 'arg'
4916 1.1 riastrad #
4917 1.1 riastrad # Need a lot of goo to handle *both* DLLs and import libs
4918 1.1 riastrad # Has to be a shell function in order to 'eat' the argument
4919 1.1 riastrad # that is supplied when $file_magic_command is called.
4920 1.1 riastrad # Despite the name, also deal with 64 bit binaries.
4921 1.1 riastrad func_win32_libid ()
4922 1.1 riastrad {
4923 1.1 riastrad $debug_cmd
4924 1.1 riastrad
4925 1.1 riastrad win32_libid_type=unknown
4926 1.1 riastrad win32_fileres=`file -L $1 2>/dev/null`
4927 1.1 riastrad case $win32_fileres in
4928 1.1 riastrad *ar\ archive\ import\ library*) # definitely import
4929 1.1 riastrad win32_libid_type="x86 archive import"
4930 1.1 riastrad ;;
4931 1.1 riastrad *ar\ archive*) # could be an import, or static
4932 1.1 riastrad # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4933 1.1 riastrad if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934 1.1 riastrad $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4935 1.1 riastrad case $nm_interface in
4936 1.1 riastrad "MS dumpbin")
4937 1.1 riastrad if func_cygming_ms_implib_p "$1" ||
4938 1.1 riastrad func_cygming_gnu_implib_p "$1"
4939 1.1 riastrad then
4940 1.1 riastrad win32_nmres=import
4941 1.1 riastrad else
4942 1.1 riastrad win32_nmres=
4943 1.1 riastrad fi
4944 1.1 riastrad ;;
4945 1.1 riastrad *)
4946 1.1 riastrad func_to_tool_file "$1" func_convert_file_msys_to_w32
4947 1.1 riastrad win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4948 1.1 riastrad $SED -n -e '
4949 1.1 riastrad 1,100{
4950 1.1 riastrad / I /{
4951 1.1 riastrad s|.*|import|
4952 1.1 riastrad p
4953 1.1 riastrad q
4954 1.1 riastrad }
4955 1.1 riastrad }'`
4956 1.1 riastrad ;;
4957 1.1 riastrad esac
4958 1.1 riastrad case $win32_nmres in
4959 1.1 riastrad import*) win32_libid_type="x86 archive import";;
4960 1.1 riastrad *) win32_libid_type="x86 archive static";;
4961 1.1 riastrad esac
4962 1.1 riastrad fi
4963 1.1 riastrad ;;
4964 1.1 riastrad *DLL*)
4965 1.1 riastrad win32_libid_type="x86 DLL"
4966 1.1 riastrad ;;
4967 1.1 riastrad *executable*) # but shell scripts are "executable" too...
4968 1.1 riastrad case $win32_fileres in
4969 1.1 riastrad *MS\ Windows\ PE\ Intel*)
4970 1.1 riastrad win32_libid_type="x86 DLL"
4971 1.1 riastrad ;;
4972 1.1 riastrad esac
4973 1.1 riastrad ;;
4974 1.1 riastrad esac
4975 1.1 riastrad $ECHO "$win32_libid_type"
4976 1.1 riastrad }
4977 1.1 riastrad
4978 1.1 riastrad # func_cygming_dll_for_implib ARG
4979 1.1 riastrad #
4980 1.1 riastrad # Platform-specific function to extract the
4981 1.1 riastrad # name of the DLL associated with the specified
4982 1.1 riastrad # import library ARG.
4983 1.1 riastrad # Invoked by eval'ing the libtool variable
4984 1.1 riastrad # $sharedlib_from_linklib_cmd
4985 1.1 riastrad # Result is available in the variable
4986 1.1 riastrad # $sharedlib_from_linklib_result
4987 1.1 riastrad func_cygming_dll_for_implib ()
4988 1.1 riastrad {
4989 1.1 riastrad $debug_cmd
4990 1.1 riastrad
4991 1.1 riastrad sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992 1.1 riastrad }
4993 1.1 riastrad
4994 1.1 riastrad # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995 1.1 riastrad #
4996 1.1 riastrad # The is the core of a fallback implementation of a
4997 1.1 riastrad # platform-specific function to extract the name of the
4998 1.1 riastrad # DLL associated with the specified import library LIBNAME.
4999 1.1 riastrad #
5000 1.1 riastrad # SECTION_NAME is either .idata$6 or .idata$7, depending
5001 1.1 riastrad # on the platform and compiler that created the implib.
5002 1.1 riastrad #
5003 1.1 riastrad # Echos the name of the DLL associated with the
5004 1.1 riastrad # specified import library.
5005 1.1 riastrad func_cygming_dll_for_implib_fallback_core ()
5006 1.1 riastrad {
5007 1.1 riastrad $debug_cmd
5008 1.1 riastrad
5009 1.1 riastrad match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010 1.1 riastrad $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011 1.1 riastrad $SED '/^Contents of section '"$match_literal"':/{
5012 1.1 riastrad # Place marker at beginning of archive member dllname section
5013 1.1 riastrad s/.*/====MARK====/
5014 1.1 riastrad p
5015 1.1 riastrad d
5016 1.1 riastrad }
5017 1.1 riastrad # These lines can sometimes be longer than 43 characters, but
5018 1.1 riastrad # are always uninteresting
5019 1.1 riastrad /:[ ]*file format pe[i]\{,1\}-/d
5020 1.1 riastrad /^In archive [^:]*:/d
5021 1.1 riastrad # Ensure marker is printed
5022 1.1 riastrad /^====MARK====/p
5023 1.1 riastrad # Remove all lines with less than 43 characters
5024 1.1 riastrad /^.\{43\}/!d
5025 1.1 riastrad # From remaining lines, remove first 43 characters
5026 1.1 riastrad s/^.\{43\}//' |
5027 1.1 riastrad $SED -n '
5028 1.1 riastrad # Join marker and all lines until next marker into a single line
5029 1.1 riastrad /^====MARK====/ b para
5030 1.1 riastrad H
5031 1.1 riastrad $ b para
5032 1.1 riastrad b
5033 1.1 riastrad :para
5034 1.1 riastrad x
5035 1.1 riastrad s/\n//g
5036 1.1 riastrad # Remove the marker
5037 1.1 riastrad s/^====MARK====//
5038 1.1 riastrad # Remove trailing dots and whitespace
5039 1.1 riastrad s/[\. \t]*$//
5040 1.1 riastrad # Print
5041 1.1 riastrad /./p' |
5042 1.1 riastrad # we now have a list, one entry per line, of the stringified
5043 1.1 riastrad # contents of the appropriate section of all members of the
5044 1.1 riastrad # archive that possess that section. Heuristic: eliminate
5045 1.1 riastrad # all those that have a first or second character that is
5046 1.1 riastrad # a '.' (that is, objdump's representation of an unprintable
5047 1.1 riastrad # character.) This should work for all archives with less than
5048 1.1 riastrad # 0x302f exports -- but will fail for DLLs whose name actually
5049 1.1 riastrad # begins with a literal '.' or a single character followed by
5050 1.1 riastrad # a '.'.
5051 1.1 riastrad #
5052 1.1 riastrad # Of those that remain, print the first one.
5053 1.1 riastrad $SED -e '/^\./d;/^.\./d;q'
5054 1.1 riastrad }
5055 1.1 riastrad
5056 1.1 riastrad # func_cygming_dll_for_implib_fallback ARG
5057 1.1 riastrad # Platform-specific function to extract the
5058 1.1 riastrad # name of the DLL associated with the specified
5059 1.1 riastrad # import library ARG.
5060 1.1 riastrad #
5061 1.1 riastrad # This fallback implementation is for use when $DLLTOOL
5062 1.1 riastrad # does not support the --identify-strict option.
5063 1.1 riastrad # Invoked by eval'ing the libtool variable
5064 1.1 riastrad # $sharedlib_from_linklib_cmd
5065 1.1 riastrad # Result is available in the variable
5066 1.1 riastrad # $sharedlib_from_linklib_result
5067 1.1 riastrad func_cygming_dll_for_implib_fallback ()
5068 1.1 riastrad {
5069 1.1 riastrad $debug_cmd
5070 1.1 riastrad
5071 1.1 riastrad if func_cygming_gnu_implib_p "$1"; then
5072 1.1 riastrad # binutils import library
5073 1.1 riastrad sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5074 1.1 riastrad elif func_cygming_ms_implib_p "$1"; then
5075 1.1 riastrad # ms-generated import library
5076 1.1 riastrad sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077 1.1 riastrad else
5078 1.1 riastrad # unknown
5079 1.1 riastrad sharedlib_from_linklib_result=
5080 1.1 riastrad fi
5081 1.1 riastrad }
5082 1.1 riastrad
5083 1.1 riastrad
5084 1.1 riastrad # func_extract_an_archive dir oldlib
5085 1.1 riastrad func_extract_an_archive ()
5086 1.1 riastrad {
5087 1.1 riastrad $debug_cmd
5088 1.1 riastrad
5089 1.1 riastrad f_ex_an_ar_dir=$1; shift
5090 1.1 riastrad f_ex_an_ar_oldlib=$1
5091 1.1 riastrad if test yes = "$lock_old_archive_extraction"; then
5092 1.1 riastrad lockfile=$f_ex_an_ar_oldlib.lock
5093 1.1 riastrad until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094 1.1 riastrad func_echo "Waiting for $lockfile to be removed"
5095 1.1 riastrad sleep 2
5096 1.1 riastrad done
5097 1.1 riastrad fi
5098 1.1 riastrad func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099 1.1 riastrad 'stat=$?; rm -f "$lockfile"; exit $stat'
5100 1.1 riastrad if test yes = "$lock_old_archive_extraction"; then
5101 1.1 riastrad $opt_dry_run || rm -f "$lockfile"
5102 1.1 riastrad fi
5103 1.1 riastrad if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5104 1.1 riastrad :
5105 1.1 riastrad else
5106 1.1 riastrad func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5107 1.1 riastrad fi
5108 1.1 riastrad }
5109 1.1 riastrad
5110 1.1 riastrad
5111 1.1 riastrad # func_extract_archives gentop oldlib ...
5112 1.1 riastrad func_extract_archives ()
5113 1.1 riastrad {
5114 1.1 riastrad $debug_cmd
5115 1.1 riastrad
5116 1.1 riastrad my_gentop=$1; shift
5117 1.1 riastrad my_oldlibs=${1+"$@"}
5118 1.1 riastrad my_oldobjs=
5119 1.1 riastrad my_xlib=
5120 1.1 riastrad my_xabs=
5121 1.1 riastrad my_xdir=
5122 1.1 riastrad
5123 1.1 riastrad for my_xlib in $my_oldlibs; do
5124 1.1 riastrad # Extract the objects.
5125 1.1 riastrad case $my_xlib in
5126 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5127 1.1 riastrad *) my_xabs=`pwd`"/$my_xlib" ;;
5128 1.1 riastrad esac
5129 1.1 riastrad func_basename "$my_xlib"
5130 1.1 riastrad my_xlib=$func_basename_result
5131 1.1 riastrad my_xlib_u=$my_xlib
5132 1.1 riastrad while :; do
5133 1.1 riastrad case " $extracted_archives " in
5134 1.1 riastrad *" $my_xlib_u "*)
5135 1.1 riastrad func_arith $extracted_serial + 1
5136 1.1 riastrad extracted_serial=$func_arith_result
5137 1.1 riastrad my_xlib_u=lt$extracted_serial-$my_xlib ;;
5138 1.1 riastrad *) break ;;
5139 1.1 riastrad esac
5140 1.1 riastrad done
5141 1.1 riastrad extracted_archives="$extracted_archives $my_xlib_u"
5142 1.1 riastrad my_xdir=$my_gentop/$my_xlib_u
5143 1.1 riastrad
5144 1.1 riastrad func_mkdir_p "$my_xdir"
5145 1.1 riastrad
5146 1.1 riastrad case $host in
5147 1.1 riastrad *-darwin*)
5148 1.1 riastrad func_verbose "Extracting $my_xabs"
5149 1.1 riastrad # Do not bother doing anything if just a dry run
5150 1.1 riastrad $opt_dry_run || {
5151 1.1 riastrad darwin_orig_dir=`pwd`
5152 1.1 riastrad cd $my_xdir || exit $?
5153 1.1 riastrad darwin_archive=$my_xabs
5154 1.1 riastrad darwin_curdir=`pwd`
5155 1.1 riastrad func_basename "$darwin_archive"
5156 1.1 riastrad darwin_base_archive=$func_basename_result
5157 1.1 riastrad darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5158 1.1 riastrad if test -n "$darwin_arches"; then
5159 1.1 riastrad darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5160 1.1 riastrad darwin_arch=
5161 1.1 riastrad func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5162 1.1 riastrad for darwin_arch in $darwin_arches; do
5163 1.1 riastrad func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5164 1.1 riastrad $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5165 1.1 riastrad cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5166 1.1 riastrad func_extract_an_archive "`pwd`" "$darwin_base_archive"
5167 1.1 riastrad cd "$darwin_curdir"
5168 1.1 riastrad $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5169 1.1 riastrad done # $darwin_arches
5170 1.1 riastrad ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5171 1.1 riastrad darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5172 1.1 riastrad darwin_file=
5173 1.1 riastrad darwin_files=
5174 1.1 riastrad for darwin_file in $darwin_filelist; do
5175 1.1 riastrad darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5176 1.1 riastrad $LIPO -create -output "$darwin_file" $darwin_files
5177 1.1 riastrad done # $darwin_filelist
5178 1.1 riastrad $RM -rf unfat-$$
5179 1.1 riastrad cd "$darwin_orig_dir"
5180 1.1 riastrad else
5181 1.1 riastrad cd $darwin_orig_dir
5182 1.1 riastrad func_extract_an_archive "$my_xdir" "$my_xabs"
5183 1.1 riastrad fi # $darwin_arches
5184 1.1 riastrad } # !$opt_dry_run
5185 1.1 riastrad ;;
5186 1.1 riastrad *)
5187 1.1 riastrad func_extract_an_archive "$my_xdir" "$my_xabs"
5188 1.1 riastrad ;;
5189 1.1 riastrad esac
5190 1.1 riastrad my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5191 1.1 riastrad done
5192 1.1 riastrad
5193 1.1 riastrad func_extract_archives_result=$my_oldobjs
5194 1.1 riastrad }
5195 1.1 riastrad
5196 1.1 riastrad
5197 1.1 riastrad # func_emit_wrapper [arg=no]
5198 1.1 riastrad #
5199 1.1 riastrad # Emit a libtool wrapper script on stdout.
5200 1.1 riastrad # Don't directly open a file because we may want to
5201 1.1 riastrad # incorporate the script contents within a cygwin/mingw
5202 1.1 riastrad # wrapper executable. Must ONLY be called from within
5203 1.1 riastrad # func_mode_link because it depends on a number of variables
5204 1.1 riastrad # set therein.
5205 1.1 riastrad #
5206 1.1 riastrad # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207 1.1 riastrad # variable will take. If 'yes', then the emitted script
5208 1.1 riastrad # will assume that the directory where it is stored is
5209 1.1 riastrad # the $objdir directory. This is a cygwin/mingw-specific
5210 1.1 riastrad # behavior.
5211 1.1 riastrad func_emit_wrapper ()
5212 1.1 riastrad {
5213 1.1 riastrad func_emit_wrapper_arg1=${1-no}
5214 1.1 riastrad
5215 1.1 riastrad $ECHO "\
5216 1.1 riastrad #! $SHELL
5217 1.1 riastrad
5218 1.1 riastrad # $output - temporary wrapper script for $objdir/$outputname
5219 1.1 riastrad # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5220 1.1 riastrad #
5221 1.1 riastrad # The $output program cannot be directly executed until all the libtool
5222 1.1 riastrad # libraries that it depends on are installed.
5223 1.1 riastrad #
5224 1.1 riastrad # This wrapper script should never be moved out of the build directory.
5225 1.1 riastrad # If it is, it will not operate correctly.
5226 1.1 riastrad
5227 1.1 riastrad # Sed substitution that helps us do robust quoting. It backslashifies
5228 1.1 riastrad # metacharacters that are still active within double-quoted strings.
5229 1.1 riastrad sed_quote_subst='$sed_quote_subst'
5230 1.1 riastrad
5231 1.1 riastrad # Be Bourne compatible
5232 1.1 riastrad if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5233 1.1 riastrad emulate sh
5234 1.1 riastrad NULLCMD=:
5235 1.1 riastrad # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5236 1.1 riastrad # is contrary to our usage. Disable this feature.
5237 1.1 riastrad alias -g '\${1+\"\$@\"}'='\"\$@\"'
5238 1.1 riastrad setopt NO_GLOB_SUBST
5239 1.1 riastrad else
5240 1.1 riastrad case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5241 1.1 riastrad fi
5242 1.1 riastrad BIN_SH=xpg4; export BIN_SH # for Tru64
5243 1.1 riastrad DUALCASE=1; export DUALCASE # for MKS sh
5244 1.1 riastrad
5245 1.1 riastrad # The HP-UX ksh and POSIX shell print the target directory to stdout
5246 1.1 riastrad # if CDPATH is set.
5247 1.1 riastrad (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248 1.1 riastrad
5249 1.1 riastrad relink_command=\"$relink_command\"
5250 1.1 riastrad
5251 1.1 riastrad # This environment variable determines our operation mode.
5252 1.1 riastrad if test \"\$libtool_install_magic\" = \"$magic\"; then
5253 1.1 riastrad # install mode needs the following variables:
5254 1.1 riastrad generated_by_libtool_version='$macro_version'
5255 1.1 riastrad notinst_deplibs='$notinst_deplibs'
5256 1.1 riastrad else
5257 1.1 riastrad # When we are sourced in execute mode, \$file and \$ECHO are already set.
5258 1.1 riastrad if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259 1.1 riastrad file=\"\$0\""
5260 1.1 riastrad
5261 1.1 riastrad qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262 1.1 riastrad $ECHO "\
5263 1.1 riastrad
5264 1.1 riastrad # A function that is used when there is no print builtin or printf.
5265 1.1 riastrad func_fallback_echo ()
5266 1.1 riastrad {
5267 1.1 riastrad eval 'cat <<_LTECHO_EOF
5268 1.1 riastrad \$1
5269 1.1 riastrad _LTECHO_EOF'
5270 1.1 riastrad }
5271 1.1 riastrad ECHO=\"$qECHO\"
5272 1.1 riastrad fi
5273 1.1 riastrad
5274 1.1 riastrad # Very basic option parsing. These options are (a) specific to
5275 1.1 riastrad # the libtool wrapper, (b) are identical between the wrapper
5276 1.1 riastrad # /script/ and the wrapper /executable/ that is used only on
5277 1.1 riastrad # windows platforms, and (c) all begin with the string "--lt-"
5278 1.1 riastrad # (application programs are unlikely to have options that match
5279 1.1 riastrad # this pattern).
5280 1.1 riastrad #
5281 1.1 riastrad # There are only two supported options: --lt-debug and
5282 1.1 riastrad # --lt-dump-script. There is, deliberately, no --lt-help.
5283 1.1 riastrad #
5284 1.1 riastrad # The first argument to this parsing function should be the
5285 1.1 riastrad # script's $0 value, followed by "$@".
5286 1.1 riastrad lt_option_debug=
5287 1.1 riastrad func_parse_lt_options ()
5288 1.1 riastrad {
5289 1.1 riastrad lt_script_arg0=\$0
5290 1.1 riastrad shift
5291 1.1 riastrad for lt_opt
5292 1.1 riastrad do
5293 1.1 riastrad case \"\$lt_opt\" in
5294 1.1 riastrad --lt-debug) lt_option_debug=1 ;;
5295 1.1 riastrad --lt-dump-script)
5296 1.1 riastrad lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297 1.1 riastrad test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298 1.1 riastrad lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299 1.1 riastrad cat \"\$lt_dump_D/\$lt_dump_F\"
5300 1.1 riastrad exit 0
5301 1.1 riastrad ;;
5302 1.1 riastrad --lt-*)
5303 1.1 riastrad \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304 1.1 riastrad exit 1
5305 1.1 riastrad ;;
5306 1.1 riastrad esac
5307 1.1 riastrad done
5308 1.1 riastrad
5309 1.1 riastrad # Print the debug banner immediately:
5310 1.1 riastrad if test -n \"\$lt_option_debug\"; then
5311 1.1 riastrad echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312 1.1 riastrad fi
5313 1.1 riastrad }
5314 1.1 riastrad
5315 1.1 riastrad # Used when --lt-debug. Prints its arguments to stdout
5316 1.1 riastrad # (redirection is the responsibility of the caller)
5317 1.1 riastrad func_lt_dump_args ()
5318 1.1 riastrad {
5319 1.1 riastrad lt_dump_args_N=1;
5320 1.1 riastrad for lt_arg
5321 1.1 riastrad do
5322 1.1 riastrad \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323 1.1 riastrad lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324 1.1 riastrad done
5325 1.1 riastrad }
5326 1.1 riastrad
5327 1.1 riastrad # Core function for launching the target application
5328 1.1 riastrad func_exec_program_core ()
5329 1.1 riastrad {
5330 1.1 riastrad "
5331 1.1 riastrad case $host in
5332 1.1 riastrad # Backslashes separate directories on plain windows
5333 1.1 riastrad *-*-mingw | *-*-os2* | *-cegcc*)
5334 1.1 riastrad $ECHO "\
5335 1.1 riastrad if test -n \"\$lt_option_debug\"; then
5336 1.1 riastrad \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337 1.1 riastrad func_lt_dump_args \${1+\"\$@\"} 1>&2
5338 1.1 riastrad fi
5339 1.1 riastrad exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340 1.1 riastrad "
5341 1.1 riastrad ;;
5342 1.1 riastrad
5343 1.1 riastrad *)
5344 1.1 riastrad $ECHO "\
5345 1.1 riastrad if test -n \"\$lt_option_debug\"; then
5346 1.1 riastrad \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347 1.1 riastrad func_lt_dump_args \${1+\"\$@\"} 1>&2
5348 1.1 riastrad fi
5349 1.1 riastrad exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350 1.1 riastrad "
5351 1.1 riastrad ;;
5352 1.1 riastrad esac
5353 1.1 riastrad $ECHO "\
5354 1.1 riastrad \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355 1.1 riastrad exit 1
5356 1.1 riastrad }
5357 1.1 riastrad
5358 1.1 riastrad # A function to encapsulate launching the target application
5359 1.1 riastrad # Strips options in the --lt-* namespace from \$@ and
5360 1.1 riastrad # launches target application with the remaining arguments.
5361 1.1 riastrad func_exec_program ()
5362 1.1 riastrad {
5363 1.1 riastrad case \" \$* \" in
5364 1.1 riastrad *\\ --lt-*)
5365 1.1 riastrad for lt_wr_arg
5366 1.1 riastrad do
5367 1.1 riastrad case \$lt_wr_arg in
5368 1.1 riastrad --lt-*) ;;
5369 1.1 riastrad *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5370 1.1 riastrad esac
5371 1.1 riastrad shift
5372 1.1 riastrad done ;;
5373 1.1 riastrad esac
5374 1.1 riastrad func_exec_program_core \${1+\"\$@\"}
5375 1.1 riastrad }
5376 1.1 riastrad
5377 1.1 riastrad # Parse options
5378 1.1 riastrad func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379 1.1 riastrad
5380 1.1 riastrad # Find the directory that this script lives in.
5381 1.1 riastrad thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5382 1.1 riastrad test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383 1.1 riastrad
5384 1.1 riastrad # Follow symbolic links until we get to the real thisdir.
5385 1.1 riastrad file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5386 1.1 riastrad while test -n \"\$file\"; do
5387 1.1 riastrad destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388 1.1 riastrad
5389 1.1 riastrad # If there was a directory component, then change thisdir.
5390 1.1 riastrad if test \"x\$destdir\" != \"x\$file\"; then
5391 1.1 riastrad case \"\$destdir\" in
5392 1.1 riastrad [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5393 1.1 riastrad *) thisdir=\"\$thisdir/\$destdir\" ;;
5394 1.1 riastrad esac
5395 1.1 riastrad fi
5396 1.1 riastrad
5397 1.1 riastrad file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398 1.1 riastrad file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5399 1.1 riastrad done
5400 1.1 riastrad
5401 1.1 riastrad # Usually 'no', except on cygwin/mingw when embedded into
5402 1.1 riastrad # the cwrapper.
5403 1.1 riastrad WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5404 1.1 riastrad if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5405 1.1 riastrad # special case for '.'
5406 1.1 riastrad if test \"\$thisdir\" = \".\"; then
5407 1.1 riastrad thisdir=\`pwd\`
5408 1.1 riastrad fi
5409 1.1 riastrad # remove .libs from thisdir
5410 1.1 riastrad case \"\$thisdir\" in
5411 1.1 riastrad *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5412 1.1 riastrad $objdir ) thisdir=. ;;
5413 1.1 riastrad esac
5414 1.1 riastrad fi
5415 1.1 riastrad
5416 1.1 riastrad # Try to get the absolute directory name.
5417 1.1 riastrad absdir=\`cd \"\$thisdir\" && pwd\`
5418 1.1 riastrad test -n \"\$absdir\" && thisdir=\"\$absdir\"
5419 1.1 riastrad "
5420 1.1 riastrad
5421 1.1 riastrad if test yes = "$fast_install"; then
5422 1.1 riastrad $ECHO "\
5423 1.1 riastrad program=lt-'$outputname'$exeext
5424 1.1 riastrad progdir=\"\$thisdir/$objdir\"
5425 1.1 riastrad
5426 1.1 riastrad if test ! -f \"\$progdir/\$program\" ||
5427 1.1 riastrad { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5428 1.1 riastrad test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429 1.1 riastrad
5430 1.1 riastrad file=\"\$\$-\$program\"
5431 1.1 riastrad
5432 1.1 riastrad if test ! -d \"\$progdir\"; then
5433 1.1 riastrad $MKDIR \"\$progdir\"
5434 1.1 riastrad else
5435 1.1 riastrad $RM \"\$progdir/\$file\"
5436 1.1 riastrad fi"
5437 1.1 riastrad
5438 1.1 riastrad $ECHO "\
5439 1.1 riastrad
5440 1.1 riastrad # relink executable if necessary
5441 1.1 riastrad if test -n \"\$relink_command\"; then
5442 1.1 riastrad if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5443 1.1 riastrad else
5444 1.1 riastrad \$ECHO \"\$relink_command_output\" >&2
5445 1.1 riastrad $RM \"\$progdir/\$file\"
5446 1.1 riastrad exit 1
5447 1.1 riastrad fi
5448 1.1 riastrad fi
5449 1.1 riastrad
5450 1.1 riastrad $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5451 1.1 riastrad { $RM \"\$progdir/\$program\";
5452 1.1 riastrad $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5453 1.1 riastrad $RM \"\$progdir/\$file\"
5454 1.1 riastrad fi"
5455 1.1 riastrad else
5456 1.1 riastrad $ECHO "\
5457 1.1 riastrad program='$outputname'
5458 1.1 riastrad progdir=\"\$thisdir/$objdir\"
5459 1.1 riastrad "
5460 1.1 riastrad fi
5461 1.1 riastrad
5462 1.1 riastrad $ECHO "\
5463 1.1 riastrad
5464 1.1 riastrad if test -f \"\$progdir/\$program\"; then"
5465 1.1 riastrad
5466 1.1 riastrad # fixup the dll searchpath if we need to.
5467 1.1 riastrad #
5468 1.1 riastrad # Fix the DLL searchpath if we need to. Do this before prepending
5469 1.1 riastrad # to shlibpath, because on Windows, both are PATH and uninstalled
5470 1.1 riastrad # libraries must come first.
5471 1.1 riastrad if test -n "$dllsearchpath"; then
5472 1.1 riastrad $ECHO "\
5473 1.1 riastrad # Add the dll search path components to the executable PATH
5474 1.1 riastrad PATH=$dllsearchpath:\$PATH
5475 1.1 riastrad "
5476 1.1 riastrad fi
5477 1.1 riastrad
5478 1.1 riastrad # Export our shlibpath_var if we have one.
5479 1.1 riastrad if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5480 1.1 riastrad $ECHO "\
5481 1.1 riastrad # Add our own library path to $shlibpath_var
5482 1.1 riastrad $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483 1.1 riastrad
5484 1.1 riastrad # Some systems cannot cope with colon-terminated $shlibpath_var
5485 1.1 riastrad # The second colon is a workaround for a bug in BeOS R4 sed
5486 1.1 riastrad $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487 1.1 riastrad
5488 1.1 riastrad export $shlibpath_var
5489 1.1 riastrad "
5490 1.1 riastrad fi
5491 1.1 riastrad
5492 1.1 riastrad $ECHO "\
5493 1.1 riastrad if test \"\$libtool_execute_magic\" != \"$magic\"; then
5494 1.1 riastrad # Run the actual program with our arguments.
5495 1.1 riastrad func_exec_program \${1+\"\$@\"}
5496 1.1 riastrad fi
5497 1.1 riastrad else
5498 1.1 riastrad # The program doesn't exist.
5499 1.1 riastrad \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5500 1.1 riastrad \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501 1.1 riastrad \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5502 1.1 riastrad exit 1
5503 1.1 riastrad fi
5504 1.1 riastrad fi\
5505 1.1 riastrad "
5506 1.1 riastrad }
5507 1.1 riastrad
5508 1.1 riastrad
5509 1.1 riastrad # func_emit_cwrapperexe_src
5510 1.1 riastrad # emit the source code for a wrapper executable on stdout
5511 1.1 riastrad # Must ONLY be called from within func_mode_link because
5512 1.1 riastrad # it depends on a number of variable set therein.
5513 1.1 riastrad func_emit_cwrapperexe_src ()
5514 1.1 riastrad {
5515 1.1 riastrad cat <<EOF
5516 1.1 riastrad
5517 1.1 riastrad /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5518 1.1 riastrad Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519 1.1 riastrad
5520 1.1 riastrad The $output program cannot be directly executed until all the libtool
5521 1.1 riastrad libraries that it depends on are installed.
5522 1.1 riastrad
5523 1.1 riastrad This wrapper executable should never be moved out of the build directory.
5524 1.1 riastrad If it is, it will not operate correctly.
5525 1.1 riastrad */
5526 1.1 riastrad EOF
5527 1.1 riastrad cat <<"EOF"
5528 1.1 riastrad #ifdef _MSC_VER
5529 1.1 riastrad # define _CRT_SECURE_NO_DEPRECATE 1
5530 1.1 riastrad #endif
5531 1.1 riastrad #include <stdio.h>
5532 1.1 riastrad #include <stdlib.h>
5533 1.1 riastrad #ifdef _MSC_VER
5534 1.1 riastrad # include <direct.h>
5535 1.1 riastrad # include <process.h>
5536 1.1 riastrad # include <io.h>
5537 1.1 riastrad #else
5538 1.1 riastrad # include <unistd.h>
5539 1.1 riastrad # include <stdint.h>
5540 1.1 riastrad # ifdef __CYGWIN__
5541 1.1 riastrad # include <io.h>
5542 1.1 riastrad # endif
5543 1.1 riastrad #endif
5544 1.1 riastrad #include <malloc.h>
5545 1.1 riastrad #include <stdarg.h>
5546 1.1 riastrad #include <assert.h>
5547 1.1 riastrad #include <string.h>
5548 1.1 riastrad #include <ctype.h>
5549 1.1 riastrad #include <errno.h>
5550 1.1 riastrad #include <fcntl.h>
5551 1.1 riastrad #include <sys/stat.h>
5552 1.1 riastrad
5553 1.1 riastrad #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5554 1.1 riastrad
5555 1.1 riastrad /* declarations of non-ANSI functions */
5556 1.1 riastrad #if defined __MINGW32__
5557 1.1 riastrad # ifdef __STRICT_ANSI__
5558 1.1 riastrad int _putenv (const char *);
5559 1.1 riastrad # endif
5560 1.1 riastrad #elif defined __CYGWIN__
5561 1.1 riastrad # ifdef __STRICT_ANSI__
5562 1.1 riastrad char *realpath (const char *, char *);
5563 1.1 riastrad int putenv (char *);
5564 1.1 riastrad int setenv (const char *, const char *, int);
5565 1.1 riastrad # endif
5566 1.1 riastrad /* #elif defined other_platform || defined ... */
5567 1.1 riastrad #endif
5568 1.1 riastrad
5569 1.1 riastrad /* portability defines, excluding path handling macros */
5570 1.1 riastrad #if defined _MSC_VER
5571 1.1 riastrad # define setmode _setmode
5572 1.1 riastrad # define stat _stat
5573 1.1 riastrad # define chmod _chmod
5574 1.1 riastrad # define getcwd _getcwd
5575 1.1 riastrad # define putenv _putenv
5576 1.1 riastrad # define S_IXUSR _S_IEXEC
5577 1.1 riastrad #elif defined __MINGW32__
5578 1.1 riastrad # define setmode _setmode
5579 1.1 riastrad # define stat _stat
5580 1.1 riastrad # define chmod _chmod
5581 1.1 riastrad # define getcwd _getcwd
5582 1.1 riastrad # define putenv _putenv
5583 1.1 riastrad #elif defined __CYGWIN__
5584 1.1 riastrad # define HAVE_SETENV
5585 1.1 riastrad # define FOPEN_WB "wb"
5586 1.1 riastrad /* #elif defined other platforms ... */
5587 1.1 riastrad #endif
5588 1.1 riastrad
5589 1.1 riastrad #if defined PATH_MAX
5590 1.1 riastrad # define LT_PATHMAX PATH_MAX
5591 1.1 riastrad #elif defined MAXPATHLEN
5592 1.1 riastrad # define LT_PATHMAX MAXPATHLEN
5593 1.1 riastrad #else
5594 1.1 riastrad # define LT_PATHMAX 1024
5595 1.1 riastrad #endif
5596 1.1 riastrad
5597 1.1 riastrad #ifndef S_IXOTH
5598 1.1 riastrad # define S_IXOTH 0
5599 1.1 riastrad #endif
5600 1.1 riastrad #ifndef S_IXGRP
5601 1.1 riastrad # define S_IXGRP 0
5602 1.1 riastrad #endif
5603 1.1 riastrad
5604 1.1 riastrad /* path handling portability macros */
5605 1.1 riastrad #ifndef DIR_SEPARATOR
5606 1.1 riastrad # define DIR_SEPARATOR '/'
5607 1.1 riastrad # define PATH_SEPARATOR ':'
5608 1.1 riastrad #endif
5609 1.1 riastrad
5610 1.1 riastrad #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5611 1.1 riastrad defined __OS2__
5612 1.1 riastrad # define HAVE_DOS_BASED_FILE_SYSTEM
5613 1.1 riastrad # define FOPEN_WB "wb"
5614 1.1 riastrad # ifndef DIR_SEPARATOR_2
5615 1.1 riastrad # define DIR_SEPARATOR_2 '\\'
5616 1.1 riastrad # endif
5617 1.1 riastrad # ifndef PATH_SEPARATOR_2
5618 1.1 riastrad # define PATH_SEPARATOR_2 ';'
5619 1.1 riastrad # endif
5620 1.1 riastrad #endif
5621 1.1 riastrad
5622 1.1 riastrad #ifndef DIR_SEPARATOR_2
5623 1.1 riastrad # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5624 1.1 riastrad #else /* DIR_SEPARATOR_2 */
5625 1.1 riastrad # define IS_DIR_SEPARATOR(ch) \
5626 1.1 riastrad (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5627 1.1 riastrad #endif /* DIR_SEPARATOR_2 */
5628 1.1 riastrad
5629 1.1 riastrad #ifndef PATH_SEPARATOR_2
5630 1.1 riastrad # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5631 1.1 riastrad #else /* PATH_SEPARATOR_2 */
5632 1.1 riastrad # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5633 1.1 riastrad #endif /* PATH_SEPARATOR_2 */
5634 1.1 riastrad
5635 1.1 riastrad #ifndef FOPEN_WB
5636 1.1 riastrad # define FOPEN_WB "w"
5637 1.1 riastrad #endif
5638 1.1 riastrad #ifndef _O_BINARY
5639 1.1 riastrad # define _O_BINARY 0
5640 1.1 riastrad #endif
5641 1.1 riastrad
5642 1.1 riastrad #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
5643 1.1 riastrad #define XFREE(stale) do { \
5644 1.1 riastrad if (stale) { free (stale); stale = 0; } \
5645 1.1 riastrad } while (0)
5646 1.1 riastrad
5647 1.1 riastrad #if defined LT_DEBUGWRAPPER
5648 1.1 riastrad static int lt_debug = 1;
5649 1.1 riastrad #else
5650 1.1 riastrad static int lt_debug = 0;
5651 1.1 riastrad #endif
5652 1.1 riastrad
5653 1.1 riastrad const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654 1.1 riastrad
5655 1.1 riastrad void *xmalloc (size_t num);
5656 1.1 riastrad char *xstrdup (const char *string);
5657 1.1 riastrad const char *base_name (const char *name);
5658 1.1 riastrad char *find_executable (const char *wrapper);
5659 1.1 riastrad char *chase_symlinks (const char *pathspec);
5660 1.1 riastrad int make_executable (const char *path);
5661 1.1 riastrad int check_executable (const char *path);
5662 1.1 riastrad char *strendzap (char *str, const char *pat);
5663 1.1 riastrad void lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664 1.1 riastrad void lt_fatal (const char *file, int line, const char *message, ...);
5665 1.1 riastrad static const char *nonnull (const char *s);
5666 1.1 riastrad static const char *nonempty (const char *s);
5667 1.1 riastrad void lt_setenv (const char *name, const char *value);
5668 1.1 riastrad char *lt_extend_str (const char *orig_value, const char *add, int to_end);
5669 1.1 riastrad void lt_update_exe_path (const char *name, const char *value);
5670 1.1 riastrad void lt_update_lib_path (const char *name, const char *value);
5671 1.1 riastrad char **prepare_spawn (char **argv);
5672 1.1 riastrad void lt_dump_script (FILE *f);
5673 1.1 riastrad EOF
5674 1.1 riastrad
5675 1.1 riastrad cat <<EOF
5676 1.1 riastrad #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5677 1.1 riastrad # define externally_visible volatile
5678 1.1 riastrad #else
5679 1.1 riastrad # define externally_visible __attribute__((externally_visible)) volatile
5680 1.1 riastrad #endif
5681 1.1 riastrad externally_visible const char * MAGIC_EXE = "$magic_exe";
5682 1.1 riastrad const char * LIB_PATH_VARNAME = "$shlibpath_var";
5683 1.1 riastrad EOF
5684 1.1 riastrad
5685 1.1 riastrad if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686 1.1 riastrad func_to_host_path "$temp_rpath"
5687 1.1 riastrad cat <<EOF
5688 1.1 riastrad const char * LIB_PATH_VALUE = "$func_to_host_path_result";
5689 1.1 riastrad EOF
5690 1.1 riastrad else
5691 1.1 riastrad cat <<"EOF"
5692 1.1 riastrad const char * LIB_PATH_VALUE = "";
5693 1.1 riastrad EOF
5694 1.1 riastrad fi
5695 1.1 riastrad
5696 1.1 riastrad if test -n "$dllsearchpath"; then
5697 1.1 riastrad func_to_host_path "$dllsearchpath:"
5698 1.1 riastrad cat <<EOF
5699 1.1 riastrad const char * EXE_PATH_VARNAME = "PATH";
5700 1.1 riastrad const char * EXE_PATH_VALUE = "$func_to_host_path_result";
5701 1.1 riastrad EOF
5702 1.1 riastrad else
5703 1.1 riastrad cat <<"EOF"
5704 1.1 riastrad const char * EXE_PATH_VARNAME = "";
5705 1.1 riastrad const char * EXE_PATH_VALUE = "";
5706 1.1 riastrad EOF
5707 1.1 riastrad fi
5708 1.1 riastrad
5709 1.1 riastrad if test yes = "$fast_install"; then
5710 1.1 riastrad cat <<EOF
5711 1.1 riastrad const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5712 1.1 riastrad EOF
5713 1.1 riastrad else
5714 1.1 riastrad cat <<EOF
5715 1.1 riastrad const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5716 1.1 riastrad EOF
5717 1.1 riastrad fi
5718 1.1 riastrad
5719 1.1 riastrad
5720 1.1 riastrad cat <<"EOF"
5721 1.1 riastrad
5722 1.1 riastrad #define LTWRAPPER_OPTION_PREFIX "--lt-"
5723 1.1 riastrad
5724 1.1 riastrad static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5725 1.1 riastrad static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
5726 1.1 riastrad static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
5727 1.1 riastrad
5728 1.1 riastrad int
5729 1.1 riastrad main (int argc, char *argv[])
5730 1.1 riastrad {
5731 1.1 riastrad char **newargz;
5732 1.1 riastrad int newargc;
5733 1.1 riastrad char *tmp_pathspec;
5734 1.1 riastrad char *actual_cwrapper_path;
5735 1.1 riastrad char *actual_cwrapper_name;
5736 1.1 riastrad char *target_name;
5737 1.1 riastrad char *lt_argv_zero;
5738 1.1 riastrad int rval = 127;
5739 1.1 riastrad
5740 1.1 riastrad int i;
5741 1.1 riastrad
5742 1.1 riastrad program_name = (char *) xstrdup (base_name (argv[0]));
5743 1.1 riastrad newargz = XMALLOC (char *, (size_t) argc + 1);
5744 1.1 riastrad
5745 1.1 riastrad /* very simple arg parsing; don't want to rely on getopt
5746 1.1 riastrad * also, copy all non cwrapper options to newargz, except
5747 1.1 riastrad * argz[0], which is handled differently
5748 1.1 riastrad */
5749 1.1 riastrad newargc=0;
5750 1.1 riastrad for (i = 1; i < argc; i++)
5751 1.1 riastrad {
5752 1.1 riastrad if (STREQ (argv[i], dumpscript_opt))
5753 1.1 riastrad {
5754 1.1 riastrad EOF
5755 1.1 riastrad case $host in
5756 1.1 riastrad *mingw* | *cygwin* )
5757 1.1 riastrad # make stdout use "unix" line endings
5758 1.1 riastrad echo " setmode(1,_O_BINARY);"
5759 1.1 riastrad ;;
5760 1.1 riastrad esac
5761 1.1 riastrad
5762 1.1 riastrad cat <<"EOF"
5763 1.1 riastrad lt_dump_script (stdout);
5764 1.1 riastrad return 0;
5765 1.1 riastrad }
5766 1.1 riastrad if (STREQ (argv[i], debug_opt))
5767 1.1 riastrad {
5768 1.1 riastrad lt_debug = 1;
5769 1.1 riastrad continue;
5770 1.1 riastrad }
5771 1.1 riastrad if (STREQ (argv[i], ltwrapper_option_prefix))
5772 1.1 riastrad {
5773 1.1 riastrad /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774 1.1 riastrad namespace, but it is not one of the ones we know about and
5775 1.1 riastrad have already dealt with, above (inluding dump-script), then
5776 1.1 riastrad report an error. Otherwise, targets might begin to believe
5777 1.1 riastrad they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778 1.1 riastrad namespace. The first time any user complains about this, we'll
5779 1.1 riastrad need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780 1.1 riastrad or a configure.ac-settable value.
5781 1.1 riastrad */
5782 1.1 riastrad lt_fatal (__FILE__, __LINE__,
5783 1.1 riastrad "unrecognized %s option: '%s'",
5784 1.1 riastrad ltwrapper_option_prefix, argv[i]);
5785 1.1 riastrad }
5786 1.1 riastrad /* otherwise ... */
5787 1.1 riastrad newargz[++newargc] = xstrdup (argv[i]);
5788 1.1 riastrad }
5789 1.1 riastrad newargz[++newargc] = NULL;
5790 1.1 riastrad
5791 1.1 riastrad EOF
5792 1.1 riastrad cat <<EOF
5793 1.1 riastrad /* The GNU banner must be the first non-error debug message */
5794 1.1 riastrad lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795 1.1 riastrad EOF
5796 1.1 riastrad cat <<"EOF"
5797 1.1 riastrad lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798 1.1 riastrad lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799 1.1 riastrad
5800 1.1 riastrad tmp_pathspec = find_executable (argv[0]);
5801 1.1 riastrad if (tmp_pathspec == NULL)
5802 1.1 riastrad lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803 1.1 riastrad lt_debugprintf (__FILE__, __LINE__,
5804 1.1 riastrad "(main) found exe (before symlink chase) at: %s\n",
5805 1.1 riastrad tmp_pathspec);
5806 1.1 riastrad
5807 1.1 riastrad actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808 1.1 riastrad lt_debugprintf (__FILE__, __LINE__,
5809 1.1 riastrad "(main) found exe (after symlink chase) at: %s\n",
5810 1.1 riastrad actual_cwrapper_path);
5811 1.1 riastrad XFREE (tmp_pathspec);
5812 1.1 riastrad
5813 1.1 riastrad actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5814 1.1 riastrad strendzap (actual_cwrapper_path, actual_cwrapper_name);
5815 1.1 riastrad
5816 1.1 riastrad /* wrapper name transforms */
5817 1.1 riastrad strendzap (actual_cwrapper_name, ".exe");
5818 1.1 riastrad tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5819 1.1 riastrad XFREE (actual_cwrapper_name);
5820 1.1 riastrad actual_cwrapper_name = tmp_pathspec;
5821 1.1 riastrad tmp_pathspec = 0;
5822 1.1 riastrad
5823 1.1 riastrad /* target_name transforms -- use actual target program name; might have lt- prefix */
5824 1.1 riastrad target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5825 1.1 riastrad strendzap (target_name, ".exe");
5826 1.1 riastrad tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5827 1.1 riastrad XFREE (target_name);
5828 1.1 riastrad target_name = tmp_pathspec;
5829 1.1 riastrad tmp_pathspec = 0;
5830 1.1 riastrad
5831 1.1 riastrad lt_debugprintf (__FILE__, __LINE__,
5832 1.1 riastrad "(main) libtool target name: %s\n",
5833 1.1 riastrad target_name);
5834 1.1 riastrad EOF
5835 1.1 riastrad
5836 1.1 riastrad cat <<EOF
5837 1.1 riastrad newargz[0] =
5838 1.1 riastrad XMALLOC (char, (strlen (actual_cwrapper_path) +
5839 1.1 riastrad strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5840 1.1 riastrad strcpy (newargz[0], actual_cwrapper_path);
5841 1.1 riastrad strcat (newargz[0], "$objdir");
5842 1.1 riastrad strcat (newargz[0], "/");
5843 1.1 riastrad EOF
5844 1.1 riastrad
5845 1.1 riastrad cat <<"EOF"
5846 1.1 riastrad /* stop here, and copy so we don't have to do this twice */
5847 1.1 riastrad tmp_pathspec = xstrdup (newargz[0]);
5848 1.1 riastrad
5849 1.1 riastrad /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5850 1.1 riastrad strcat (newargz[0], actual_cwrapper_name);
5851 1.1 riastrad
5852 1.1 riastrad /* DO want the lt- prefix here if it exists, so use target_name */
5853 1.1 riastrad lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5854 1.1 riastrad XFREE (tmp_pathspec);
5855 1.1 riastrad tmp_pathspec = NULL;
5856 1.1 riastrad EOF
5857 1.1 riastrad
5858 1.1 riastrad case $host_os in
5859 1.1 riastrad mingw*)
5860 1.1 riastrad cat <<"EOF"
5861 1.1 riastrad {
5862 1.1 riastrad char* p;
5863 1.1 riastrad while ((p = strchr (newargz[0], '\\')) != NULL)
5864 1.1 riastrad {
5865 1.1 riastrad *p = '/';
5866 1.1 riastrad }
5867 1.1 riastrad while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5868 1.1 riastrad {
5869 1.1 riastrad *p = '/';
5870 1.1 riastrad }
5871 1.1 riastrad }
5872 1.1 riastrad EOF
5873 1.1 riastrad ;;
5874 1.1 riastrad esac
5875 1.1 riastrad
5876 1.1 riastrad cat <<"EOF"
5877 1.1 riastrad XFREE (target_name);
5878 1.1 riastrad XFREE (actual_cwrapper_path);
5879 1.1 riastrad XFREE (actual_cwrapper_name);
5880 1.1 riastrad
5881 1.1 riastrad lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5882 1.1 riastrad lt_setenv ("DUALCASE", "1"); /* for MSK sh */
5883 1.1 riastrad /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
5884 1.1 riastrad be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885 1.1 riastrad because on Windows, both *_VARNAMEs are PATH but uninstalled
5886 1.1 riastrad libraries must come first. */
5887 1.1 riastrad lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888 1.1 riastrad lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889 1.1 riastrad
5890 1.1 riastrad lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891 1.1 riastrad nonnull (lt_argv_zero));
5892 1.1 riastrad for (i = 0; i < newargc; i++)
5893 1.1 riastrad {
5894 1.1 riastrad lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895 1.1 riastrad i, nonnull (newargz[i]));
5896 1.1 riastrad }
5897 1.1 riastrad
5898 1.1 riastrad EOF
5899 1.1 riastrad
5900 1.1 riastrad case $host_os in
5901 1.1 riastrad mingw*)
5902 1.1 riastrad cat <<"EOF"
5903 1.1 riastrad /* execv doesn't actually work on mingw as expected on unix */
5904 1.1 riastrad newargz = prepare_spawn (newargz);
5905 1.1 riastrad rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5906 1.1 riastrad if (rval == -1)
5907 1.1 riastrad {
5908 1.1 riastrad /* failed to start process */
5909 1.1 riastrad lt_debugprintf (__FILE__, __LINE__,
5910 1.1 riastrad "(main) failed to launch target \"%s\": %s\n",
5911 1.1 riastrad lt_argv_zero, nonnull (strerror (errno)));
5912 1.1 riastrad return 127;
5913 1.1 riastrad }
5914 1.1 riastrad return rval;
5915 1.1 riastrad EOF
5916 1.1 riastrad ;;
5917 1.1 riastrad *)
5918 1.1 riastrad cat <<"EOF"
5919 1.1 riastrad execv (lt_argv_zero, newargz);
5920 1.1 riastrad return rval; /* =127, but avoids unused variable warning */
5921 1.1 riastrad EOF
5922 1.1 riastrad ;;
5923 1.1 riastrad esac
5924 1.1 riastrad
5925 1.1 riastrad cat <<"EOF"
5926 1.1 riastrad }
5927 1.1 riastrad
5928 1.1 riastrad void *
5929 1.1 riastrad xmalloc (size_t num)
5930 1.1 riastrad {
5931 1.1 riastrad void *p = (void *) malloc (num);
5932 1.1 riastrad if (!p)
5933 1.1 riastrad lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934 1.1 riastrad
5935 1.1 riastrad return p;
5936 1.1 riastrad }
5937 1.1 riastrad
5938 1.1 riastrad char *
5939 1.1 riastrad xstrdup (const char *string)
5940 1.1 riastrad {
5941 1.1 riastrad return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5942 1.1 riastrad string) : NULL;
5943 1.1 riastrad }
5944 1.1 riastrad
5945 1.1 riastrad const char *
5946 1.1 riastrad base_name (const char *name)
5947 1.1 riastrad {
5948 1.1 riastrad const char *base;
5949 1.1 riastrad
5950 1.1 riastrad #if defined HAVE_DOS_BASED_FILE_SYSTEM
5951 1.1 riastrad /* Skip over the disk name in MSDOS pathnames. */
5952 1.1 riastrad if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5953 1.1 riastrad name += 2;
5954 1.1 riastrad #endif
5955 1.1 riastrad
5956 1.1 riastrad for (base = name; *name; name++)
5957 1.1 riastrad if (IS_DIR_SEPARATOR (*name))
5958 1.1 riastrad base = name + 1;
5959 1.1 riastrad return base;
5960 1.1 riastrad }
5961 1.1 riastrad
5962 1.1 riastrad int
5963 1.1 riastrad check_executable (const char *path)
5964 1.1 riastrad {
5965 1.1 riastrad struct stat st;
5966 1.1 riastrad
5967 1.1 riastrad lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968 1.1 riastrad nonempty (path));
5969 1.1 riastrad if ((!path) || (!*path))
5970 1.1 riastrad return 0;
5971 1.1 riastrad
5972 1.1 riastrad if ((stat (path, &st) >= 0)
5973 1.1 riastrad && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5974 1.1 riastrad return 1;
5975 1.1 riastrad else
5976 1.1 riastrad return 0;
5977 1.1 riastrad }
5978 1.1 riastrad
5979 1.1 riastrad int
5980 1.1 riastrad make_executable (const char *path)
5981 1.1 riastrad {
5982 1.1 riastrad int rval = 0;
5983 1.1 riastrad struct stat st;
5984 1.1 riastrad
5985 1.1 riastrad lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986 1.1 riastrad nonempty (path));
5987 1.1 riastrad if ((!path) || (!*path))
5988 1.1 riastrad return 0;
5989 1.1 riastrad
5990 1.1 riastrad if (stat (path, &st) >= 0)
5991 1.1 riastrad {
5992 1.1 riastrad rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5993 1.1 riastrad }
5994 1.1 riastrad return rval;
5995 1.1 riastrad }
5996 1.1 riastrad
5997 1.1 riastrad /* Searches for the full path of the wrapper. Returns
5998 1.1 riastrad newly allocated full path name if found, NULL otherwise
5999 1.1 riastrad Does not chase symlinks, even on platforms that support them.
6000 1.1 riastrad */
6001 1.1 riastrad char *
6002 1.1 riastrad find_executable (const char *wrapper)
6003 1.1 riastrad {
6004 1.1 riastrad int has_slash = 0;
6005 1.1 riastrad const char *p;
6006 1.1 riastrad const char *p_next;
6007 1.1 riastrad /* static buffer for getcwd */
6008 1.1 riastrad char tmp[LT_PATHMAX + 1];
6009 1.1 riastrad size_t tmp_len;
6010 1.1 riastrad char *concat_name;
6011 1.1 riastrad
6012 1.1 riastrad lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013 1.1 riastrad nonempty (wrapper));
6014 1.1 riastrad
6015 1.1 riastrad if ((wrapper == NULL) || (*wrapper == '\0'))
6016 1.1 riastrad return NULL;
6017 1.1 riastrad
6018 1.1 riastrad /* Absolute path? */
6019 1.1 riastrad #if defined HAVE_DOS_BASED_FILE_SYSTEM
6020 1.1 riastrad if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6021 1.1 riastrad {
6022 1.1 riastrad concat_name = xstrdup (wrapper);
6023 1.1 riastrad if (check_executable (concat_name))
6024 1.1 riastrad return concat_name;
6025 1.1 riastrad XFREE (concat_name);
6026 1.1 riastrad }
6027 1.1 riastrad else
6028 1.1 riastrad {
6029 1.1 riastrad #endif
6030 1.1 riastrad if (IS_DIR_SEPARATOR (wrapper[0]))
6031 1.1 riastrad {
6032 1.1 riastrad concat_name = xstrdup (wrapper);
6033 1.1 riastrad if (check_executable (concat_name))
6034 1.1 riastrad return concat_name;
6035 1.1 riastrad XFREE (concat_name);
6036 1.1 riastrad }
6037 1.1 riastrad #if defined HAVE_DOS_BASED_FILE_SYSTEM
6038 1.1 riastrad }
6039 1.1 riastrad #endif
6040 1.1 riastrad
6041 1.1 riastrad for (p = wrapper; *p; p++)
6042 1.1 riastrad if (*p == '/')
6043 1.1 riastrad {
6044 1.1 riastrad has_slash = 1;
6045 1.1 riastrad break;
6046 1.1 riastrad }
6047 1.1 riastrad if (!has_slash)
6048 1.1 riastrad {
6049 1.1 riastrad /* no slashes; search PATH */
6050 1.1 riastrad const char *path = getenv ("PATH");
6051 1.1 riastrad if (path != NULL)
6052 1.1 riastrad {
6053 1.1 riastrad for (p = path; *p; p = p_next)
6054 1.1 riastrad {
6055 1.1 riastrad const char *q;
6056 1.1 riastrad size_t p_len;
6057 1.1 riastrad for (q = p; *q; q++)
6058 1.1 riastrad if (IS_PATH_SEPARATOR (*q))
6059 1.1 riastrad break;
6060 1.1 riastrad p_len = (size_t) (q - p);
6061 1.1 riastrad p_next = (*q == '\0' ? q : q + 1);
6062 1.1 riastrad if (p_len == 0)
6063 1.1 riastrad {
6064 1.1 riastrad /* empty path: current directory */
6065 1.1 riastrad if (getcwd (tmp, LT_PATHMAX) == NULL)
6066 1.1 riastrad lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067 1.1 riastrad nonnull (strerror (errno)));
6068 1.1 riastrad tmp_len = strlen (tmp);
6069 1.1 riastrad concat_name =
6070 1.1 riastrad XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6071 1.1 riastrad memcpy (concat_name, tmp, tmp_len);
6072 1.1 riastrad concat_name[tmp_len] = '/';
6073 1.1 riastrad strcpy (concat_name + tmp_len + 1, wrapper);
6074 1.1 riastrad }
6075 1.1 riastrad else
6076 1.1 riastrad {
6077 1.1 riastrad concat_name =
6078 1.1 riastrad XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6079 1.1 riastrad memcpy (concat_name, p, p_len);
6080 1.1 riastrad concat_name[p_len] = '/';
6081 1.1 riastrad strcpy (concat_name + p_len + 1, wrapper);
6082 1.1 riastrad }
6083 1.1 riastrad if (check_executable (concat_name))
6084 1.1 riastrad return concat_name;
6085 1.1 riastrad XFREE (concat_name);
6086 1.1 riastrad }
6087 1.1 riastrad }
6088 1.1 riastrad /* not found in PATH; assume curdir */
6089 1.1 riastrad }
6090 1.1 riastrad /* Relative path | not found in path: prepend cwd */
6091 1.1 riastrad if (getcwd (tmp, LT_PATHMAX) == NULL)
6092 1.1 riastrad lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093 1.1 riastrad nonnull (strerror (errno)));
6094 1.1 riastrad tmp_len = strlen (tmp);
6095 1.1 riastrad concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6096 1.1 riastrad memcpy (concat_name, tmp, tmp_len);
6097 1.1 riastrad concat_name[tmp_len] = '/';
6098 1.1 riastrad strcpy (concat_name + tmp_len + 1, wrapper);
6099 1.1 riastrad
6100 1.1 riastrad if (check_executable (concat_name))
6101 1.1 riastrad return concat_name;
6102 1.1 riastrad XFREE (concat_name);
6103 1.1 riastrad return NULL;
6104 1.1 riastrad }
6105 1.1 riastrad
6106 1.1 riastrad char *
6107 1.1 riastrad chase_symlinks (const char *pathspec)
6108 1.1 riastrad {
6109 1.1 riastrad #ifndef S_ISLNK
6110 1.1 riastrad return xstrdup (pathspec);
6111 1.1 riastrad #else
6112 1.1 riastrad char buf[LT_PATHMAX];
6113 1.1 riastrad struct stat s;
6114 1.1 riastrad char *tmp_pathspec = xstrdup (pathspec);
6115 1.1 riastrad char *p;
6116 1.1 riastrad int has_symlinks = 0;
6117 1.1 riastrad while (strlen (tmp_pathspec) && !has_symlinks)
6118 1.1 riastrad {
6119 1.1 riastrad lt_debugprintf (__FILE__, __LINE__,
6120 1.1 riastrad "checking path component for symlinks: %s\n",
6121 1.1 riastrad tmp_pathspec);
6122 1.1 riastrad if (lstat (tmp_pathspec, &s) == 0)
6123 1.1 riastrad {
6124 1.1 riastrad if (S_ISLNK (s.st_mode) != 0)
6125 1.1 riastrad {
6126 1.1 riastrad has_symlinks = 1;
6127 1.1 riastrad break;
6128 1.1 riastrad }
6129 1.1 riastrad
6130 1.1 riastrad /* search backwards for last DIR_SEPARATOR */
6131 1.1 riastrad p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6132 1.1 riastrad while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6133 1.1 riastrad p--;
6134 1.1 riastrad if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6135 1.1 riastrad {
6136 1.1 riastrad /* no more DIR_SEPARATORS left */
6137 1.1 riastrad break;
6138 1.1 riastrad }
6139 1.1 riastrad *p = '\0';
6140 1.1 riastrad }
6141 1.1 riastrad else
6142 1.1 riastrad {
6143 1.1 riastrad lt_fatal (__FILE__, __LINE__,
6144 1.1 riastrad "error accessing file \"%s\": %s",
6145 1.1 riastrad tmp_pathspec, nonnull (strerror (errno)));
6146 1.1 riastrad }
6147 1.1 riastrad }
6148 1.1 riastrad XFREE (tmp_pathspec);
6149 1.1 riastrad
6150 1.1 riastrad if (!has_symlinks)
6151 1.1 riastrad {
6152 1.1 riastrad return xstrdup (pathspec);
6153 1.1 riastrad }
6154 1.1 riastrad
6155 1.1 riastrad tmp_pathspec = realpath (pathspec, buf);
6156 1.1 riastrad if (tmp_pathspec == 0)
6157 1.1 riastrad {
6158 1.1 riastrad lt_fatal (__FILE__, __LINE__,
6159 1.1 riastrad "could not follow symlinks for %s", pathspec);
6160 1.1 riastrad }
6161 1.1 riastrad return xstrdup (tmp_pathspec);
6162 1.1 riastrad #endif
6163 1.1 riastrad }
6164 1.1 riastrad
6165 1.1 riastrad char *
6166 1.1 riastrad strendzap (char *str, const char *pat)
6167 1.1 riastrad {
6168 1.1 riastrad size_t len, patlen;
6169 1.1 riastrad
6170 1.1 riastrad assert (str != NULL);
6171 1.1 riastrad assert (pat != NULL);
6172 1.1 riastrad
6173 1.1 riastrad len = strlen (str);
6174 1.1 riastrad patlen = strlen (pat);
6175 1.1 riastrad
6176 1.1 riastrad if (patlen <= len)
6177 1.1 riastrad {
6178 1.1 riastrad str += len - patlen;
6179 1.1 riastrad if (STREQ (str, pat))
6180 1.1 riastrad *str = '\0';
6181 1.1 riastrad }
6182 1.1 riastrad return str;
6183 1.1 riastrad }
6184 1.1 riastrad
6185 1.1 riastrad void
6186 1.1 riastrad lt_debugprintf (const char *file, int line, const char *fmt, ...)
6187 1.1 riastrad {
6188 1.1 riastrad va_list args;
6189 1.1 riastrad if (lt_debug)
6190 1.1 riastrad {
6191 1.1 riastrad (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192 1.1 riastrad va_start (args, fmt);
6193 1.1 riastrad (void) vfprintf (stderr, fmt, args);
6194 1.1 riastrad va_end (args);
6195 1.1 riastrad }
6196 1.1 riastrad }
6197 1.1 riastrad
6198 1.1 riastrad static void
6199 1.1 riastrad lt_error_core (int exit_status, const char *file,
6200 1.1 riastrad int line, const char *mode,
6201 1.1 riastrad const char *message, va_list ap)
6202 1.1 riastrad {
6203 1.1 riastrad fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6204 1.1 riastrad vfprintf (stderr, message, ap);
6205 1.1 riastrad fprintf (stderr, ".\n");
6206 1.1 riastrad
6207 1.1 riastrad if (exit_status >= 0)
6208 1.1 riastrad exit (exit_status);
6209 1.1 riastrad }
6210 1.1 riastrad
6211 1.1 riastrad void
6212 1.1 riastrad lt_fatal (const char *file, int line, const char *message, ...)
6213 1.1 riastrad {
6214 1.1 riastrad va_list ap;
6215 1.1 riastrad va_start (ap, message);
6216 1.1 riastrad lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6217 1.1 riastrad va_end (ap);
6218 1.1 riastrad }
6219 1.1 riastrad
6220 1.1 riastrad static const char *
6221 1.1 riastrad nonnull (const char *s)
6222 1.1 riastrad {
6223 1.1 riastrad return s ? s : "(null)";
6224 1.1 riastrad }
6225 1.1 riastrad
6226 1.1 riastrad static const char *
6227 1.1 riastrad nonempty (const char *s)
6228 1.1 riastrad {
6229 1.1 riastrad return (s && !*s) ? "(empty)" : nonnull (s);
6230 1.1 riastrad }
6231 1.1 riastrad
6232 1.1 riastrad void
6233 1.1 riastrad lt_setenv (const char *name, const char *value)
6234 1.1 riastrad {
6235 1.1 riastrad lt_debugprintf (__FILE__, __LINE__,
6236 1.1 riastrad "(lt_setenv) setting '%s' to '%s'\n",
6237 1.1 riastrad nonnull (name), nonnull (value));
6238 1.1 riastrad {
6239 1.1 riastrad #ifdef HAVE_SETENV
6240 1.1 riastrad /* always make a copy, for consistency with !HAVE_SETENV */
6241 1.1 riastrad char *str = xstrdup (value);
6242 1.1 riastrad setenv (name, str, 1);
6243 1.1 riastrad #else
6244 1.1 riastrad size_t len = strlen (name) + 1 + strlen (value) + 1;
6245 1.1 riastrad char *str = XMALLOC (char, len);
6246 1.1 riastrad sprintf (str, "%s=%s", name, value);
6247 1.1 riastrad if (putenv (str) != EXIT_SUCCESS)
6248 1.1 riastrad {
6249 1.1 riastrad XFREE (str);
6250 1.1 riastrad }
6251 1.1 riastrad #endif
6252 1.1 riastrad }
6253 1.1 riastrad }
6254 1.1 riastrad
6255 1.1 riastrad char *
6256 1.1 riastrad lt_extend_str (const char *orig_value, const char *add, int to_end)
6257 1.1 riastrad {
6258 1.1 riastrad char *new_value;
6259 1.1 riastrad if (orig_value && *orig_value)
6260 1.1 riastrad {
6261 1.1 riastrad size_t orig_value_len = strlen (orig_value);
6262 1.1 riastrad size_t add_len = strlen (add);
6263 1.1 riastrad new_value = XMALLOC (char, add_len + orig_value_len + 1);
6264 1.1 riastrad if (to_end)
6265 1.1 riastrad {
6266 1.1 riastrad strcpy (new_value, orig_value);
6267 1.1 riastrad strcpy (new_value + orig_value_len, add);
6268 1.1 riastrad }
6269 1.1 riastrad else
6270 1.1 riastrad {
6271 1.1 riastrad strcpy (new_value, add);
6272 1.1 riastrad strcpy (new_value + add_len, orig_value);
6273 1.1 riastrad }
6274 1.1 riastrad }
6275 1.1 riastrad else
6276 1.1 riastrad {
6277 1.1 riastrad new_value = xstrdup (add);
6278 1.1 riastrad }
6279 1.1 riastrad return new_value;
6280 1.1 riastrad }
6281 1.1 riastrad
6282 1.1 riastrad void
6283 1.1 riastrad lt_update_exe_path (const char *name, const char *value)
6284 1.1 riastrad {
6285 1.1 riastrad lt_debugprintf (__FILE__, __LINE__,
6286 1.1 riastrad "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287 1.1 riastrad nonnull (name), nonnull (value));
6288 1.1 riastrad
6289 1.1 riastrad if (name && *name && value && *value)
6290 1.1 riastrad {
6291 1.1 riastrad char *new_value = lt_extend_str (getenv (name), value, 0);
6292 1.1 riastrad /* some systems can't cope with a ':'-terminated path #' */
6293 1.1 riastrad size_t len = strlen (new_value);
6294 1.1 riastrad while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6295 1.1 riastrad {
6296 1.1 riastrad new_value[--len] = '\0';
6297 1.1 riastrad }
6298 1.1 riastrad lt_setenv (name, new_value);
6299 1.1 riastrad XFREE (new_value);
6300 1.1 riastrad }
6301 1.1 riastrad }
6302 1.1 riastrad
6303 1.1 riastrad void
6304 1.1 riastrad lt_update_lib_path (const char *name, const char *value)
6305 1.1 riastrad {
6306 1.1 riastrad lt_debugprintf (__FILE__, __LINE__,
6307 1.1 riastrad "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308 1.1 riastrad nonnull (name), nonnull (value));
6309 1.1 riastrad
6310 1.1 riastrad if (name && *name && value && *value)
6311 1.1 riastrad {
6312 1.1 riastrad char *new_value = lt_extend_str (getenv (name), value, 0);
6313 1.1 riastrad lt_setenv (name, new_value);
6314 1.1 riastrad XFREE (new_value);
6315 1.1 riastrad }
6316 1.1 riastrad }
6317 1.1 riastrad
6318 1.1 riastrad EOF
6319 1.1 riastrad case $host_os in
6320 1.1 riastrad mingw*)
6321 1.1 riastrad cat <<"EOF"
6322 1.1 riastrad
6323 1.1 riastrad /* Prepares an argument vector before calling spawn().
6324 1.1 riastrad Note that spawn() does not by itself call the command interpreter
6325 1.1 riastrad (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326 1.1 riastrad ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327 1.1 riastrad GetVersionEx(&v);
6328 1.1 riastrad v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329 1.1 riastrad }) ? "cmd.exe" : "command.com").
6330 1.1 riastrad Instead it simply concatenates the arguments, separated by ' ', and calls
6331 1.1 riastrad CreateProcess(). We must quote the arguments since Win32 CreateProcess()
6332 1.1 riastrad interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333 1.1 riastrad special way:
6334 1.1 riastrad - Space and tab are interpreted as delimiters. They are not treated as
6335 1.1 riastrad delimiters if they are surrounded by double quotes: "...".
6336 1.1 riastrad - Unescaped double quotes are removed from the input. Their only effect is
6337 1.1 riastrad that within double quotes, space and tab are treated like normal
6338 1.1 riastrad characters.
6339 1.1 riastrad - Backslashes not followed by double quotes are not special.
6340 1.1 riastrad - But 2*n+1 backslashes followed by a double quote become
6341 1.1 riastrad n backslashes followed by a double quote (n >= 0):
6342 1.1 riastrad \" -> "
6343 1.1 riastrad \\\" -> \"
6344 1.1 riastrad \\\\\" -> \\"
6345 1.1 riastrad */
6346 1.1 riastrad #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 riastrad #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 riastrad char **
6349 1.1 riastrad prepare_spawn (char **argv)
6350 1.1 riastrad {
6351 1.1 riastrad size_t argc;
6352 1.1 riastrad char **new_argv;
6353 1.1 riastrad size_t i;
6354 1.1 riastrad
6355 1.1 riastrad /* Count number of arguments. */
6356 1.1 riastrad for (argc = 0; argv[argc] != NULL; argc++)
6357 1.1 riastrad ;
6358 1.1 riastrad
6359 1.1 riastrad /* Allocate new argument vector. */
6360 1.1 riastrad new_argv = XMALLOC (char *, argc + 1);
6361 1.1 riastrad
6362 1.1 riastrad /* Put quoted arguments into the new argument vector. */
6363 1.1 riastrad for (i = 0; i < argc; i++)
6364 1.1 riastrad {
6365 1.1 riastrad const char *string = argv[i];
6366 1.1 riastrad
6367 1.1 riastrad if (string[0] == '\0')
6368 1.1 riastrad new_argv[i] = xstrdup ("\"\"");
6369 1.1 riastrad else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370 1.1 riastrad {
6371 1.1 riastrad int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372 1.1 riastrad size_t length;
6373 1.1 riastrad unsigned int backslashes;
6374 1.1 riastrad const char *s;
6375 1.1 riastrad char *quoted_string;
6376 1.1 riastrad char *p;
6377 1.1 riastrad
6378 1.1 riastrad length = 0;
6379 1.1 riastrad backslashes = 0;
6380 1.1 riastrad if (quote_around)
6381 1.1 riastrad length++;
6382 1.1 riastrad for (s = string; *s != '\0'; s++)
6383 1.1 riastrad {
6384 1.1 riastrad char c = *s;
6385 1.1 riastrad if (c == '"')
6386 1.1 riastrad length += backslashes + 1;
6387 1.1 riastrad length++;
6388 1.1 riastrad if (c == '\\')
6389 1.1 riastrad backslashes++;
6390 1.1 riastrad else
6391 1.1 riastrad backslashes = 0;
6392 1.1 riastrad }
6393 1.1 riastrad if (quote_around)
6394 1.1 riastrad length += backslashes + 1;
6395 1.1 riastrad
6396 1.1 riastrad quoted_string = XMALLOC (char, length + 1);
6397 1.1 riastrad
6398 1.1 riastrad p = quoted_string;
6399 1.1 riastrad backslashes = 0;
6400 1.1 riastrad if (quote_around)
6401 1.1 riastrad *p++ = '"';
6402 1.1 riastrad for (s = string; *s != '\0'; s++)
6403 1.1 riastrad {
6404 1.1 riastrad char c = *s;
6405 1.1 riastrad if (c == '"')
6406 1.1 riastrad {
6407 1.1 riastrad unsigned int j;
6408 1.1 riastrad for (j = backslashes + 1; j > 0; j--)
6409 1.1 riastrad *p++ = '\\';
6410 1.1 riastrad }
6411 1.1 riastrad *p++ = c;
6412 1.1 riastrad if (c == '\\')
6413 1.1 riastrad backslashes++;
6414 1.1 riastrad else
6415 1.1 riastrad backslashes = 0;
6416 1.1 riastrad }
6417 1.1 riastrad if (quote_around)
6418 1.1 riastrad {
6419 1.1 riastrad unsigned int j;
6420 1.1 riastrad for (j = backslashes; j > 0; j--)
6421 1.1 riastrad *p++ = '\\';
6422 1.1 riastrad *p++ = '"';
6423 1.1 riastrad }
6424 1.1 riastrad *p = '\0';
6425 1.1 riastrad
6426 1.1 riastrad new_argv[i] = quoted_string;
6427 1.1 riastrad }
6428 1.1 riastrad else
6429 1.1 riastrad new_argv[i] = (char *) string;
6430 1.1 riastrad }
6431 1.1 riastrad new_argv[argc] = NULL;
6432 1.1 riastrad
6433 1.1 riastrad return new_argv;
6434 1.1 riastrad }
6435 1.1 riastrad EOF
6436 1.1 riastrad ;;
6437 1.1 riastrad esac
6438 1.1 riastrad
6439 1.1 riastrad cat <<"EOF"
6440 1.1 riastrad void lt_dump_script (FILE* f)
6441 1.1 riastrad {
6442 1.1 riastrad EOF
6443 1.1 riastrad func_emit_wrapper yes |
6444 1.1 riastrad $SED -n -e '
6445 1.1 riastrad s/^\(.\{79\}\)\(..*\)/\1\
6446 1.1 riastrad \2/
6447 1.1 riastrad h
6448 1.1 riastrad s/\([\\"]\)/\\\1/g
6449 1.1 riastrad s/$/\\n/
6450 1.1 riastrad s/\([^\n]*\).*/ fputs ("\1", f);/p
6451 1.1 riastrad g
6452 1.1 riastrad D'
6453 1.1 riastrad cat <<"EOF"
6454 1.1 riastrad }
6455 1.1 riastrad EOF
6456 1.1 riastrad }
6457 1.1 riastrad # end: func_emit_cwrapperexe_src
6458 1.1 riastrad
6459 1.1 riastrad # func_win32_import_lib_p ARG
6460 1.1 riastrad # True if ARG is an import lib, as indicated by $file_magic_cmd
6461 1.1 riastrad func_win32_import_lib_p ()
6462 1.1 riastrad {
6463 1.1 riastrad $debug_cmd
6464 1.1 riastrad
6465 1.1 riastrad case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466 1.1 riastrad *import*) : ;;
6467 1.1 riastrad *) false ;;
6468 1.1 riastrad esac
6469 1.1 riastrad }
6470 1.1 riastrad
6471 1.1 riastrad # func_suncc_cstd_abi
6472 1.1 riastrad # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6473 1.1 riastrad # Several compiler flags select an ABI that is incompatible with the
6474 1.1 riastrad # Cstd library. Avoid specifying it if any are in CXXFLAGS.
6475 1.1 riastrad func_suncc_cstd_abi ()
6476 1.1 riastrad {
6477 1.1 riastrad $debug_cmd
6478 1.1 riastrad
6479 1.1 riastrad case " $compile_command " in
6480 1.1 riastrad *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6481 1.1 riastrad suncc_use_cstd_abi=no
6482 1.1 riastrad ;;
6483 1.1 riastrad *)
6484 1.1 riastrad suncc_use_cstd_abi=yes
6485 1.1 riastrad ;;
6486 1.1 riastrad esac
6487 1.1 riastrad }
6488 1.1 riastrad
6489 1.1 riastrad # func_mode_link arg...
6490 1.1 riastrad func_mode_link ()
6491 1.1 riastrad {
6492 1.1 riastrad $debug_cmd
6493 1.1 riastrad
6494 1.1 riastrad case $host in
6495 1.1 riastrad *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6496 1.1 riastrad # It is impossible to link a dll without this setting, and
6497 1.1 riastrad # we shouldn't force the makefile maintainer to figure out
6498 1.1 riastrad # what system we are compiling for in order to pass an extra
6499 1.1 riastrad # flag for every libtool invocation.
6500 1.1 riastrad # allow_undefined=no
6501 1.1 riastrad
6502 1.1 riastrad # FIXME: Unfortunately, there are problems with the above when trying
6503 1.1 riastrad # to make a dll that has undefined symbols, in which case not
6504 1.1 riastrad # even a static library is built. For now, we need to specify
6505 1.1 riastrad # -no-undefined on the libtool link line when we can be certain
6506 1.1 riastrad # that all symbols are satisfied, otherwise we get a static library.
6507 1.1 riastrad allow_undefined=yes
6508 1.1 riastrad ;;
6509 1.1 riastrad *)
6510 1.1 riastrad allow_undefined=yes
6511 1.1 riastrad ;;
6512 1.1 riastrad esac
6513 1.1 riastrad libtool_args=$nonopt
6514 1.1 riastrad base_compile="$nonopt $@"
6515 1.1 riastrad compile_command=$nonopt
6516 1.1 riastrad finalize_command=$nonopt
6517 1.1 riastrad
6518 1.1 riastrad compile_rpath=
6519 1.1 riastrad finalize_rpath=
6520 1.1 riastrad compile_shlibpath=
6521 1.1 riastrad finalize_shlibpath=
6522 1.1 riastrad convenience=
6523 1.1 riastrad old_convenience=
6524 1.1 riastrad deplibs=
6525 1.1 riastrad old_deplibs=
6526 1.1 riastrad compiler_flags=
6527 1.1 riastrad linker_flags=
6528 1.1 riastrad dllsearchpath=
6529 1.1 riastrad lib_search_path=`pwd`
6530 1.1 riastrad inst_prefix_dir=
6531 1.1 riastrad new_inherited_linker_flags=
6532 1.1 riastrad
6533 1.1 riastrad avoid_version=no
6534 1.1 riastrad bindir=
6535 1.1 riastrad dlfiles=
6536 1.1 riastrad dlprefiles=
6537 1.1 riastrad dlself=no
6538 1.1 riastrad export_dynamic=no
6539 1.1 riastrad export_symbols=
6540 1.1 riastrad export_symbols_regex=
6541 1.1 riastrad generated=
6542 1.1 riastrad libobjs=
6543 1.1 riastrad ltlibs=
6544 1.1 riastrad module=no
6545 1.1 riastrad no_install=no
6546 1.1 riastrad objs=
6547 1.1 riastrad os2dllname=
6548 1.1 riastrad non_pic_objects=
6549 1.1 riastrad precious_files_regex=
6550 1.1 riastrad prefer_static_libs=no
6551 1.1 riastrad preload=false
6552 1.1 riastrad prev=
6553 1.1 riastrad prevarg=
6554 1.1 riastrad release=
6555 1.1 riastrad rpath=
6556 1.1 riastrad xrpath=
6557 1.1 riastrad perm_rpath=
6558 1.1 riastrad temp_rpath=
6559 1.1 riastrad thread_safe=no
6560 1.1 riastrad vinfo=
6561 1.1 riastrad vinfo_number=no
6562 1.1 riastrad weak_libs=
6563 1.1 riastrad single_module=$wl-single_module
6564 1.1 riastrad func_infer_tag $base_compile
6565 1.1 riastrad
6566 1.1 riastrad # We need to know -static, to get the right output filenames.
6567 1.1 riastrad for arg
6568 1.1 riastrad do
6569 1.1 riastrad case $arg in
6570 1.1 riastrad -shared)
6571 1.1 riastrad test yes != "$build_libtool_libs" \
6572 1.1 riastrad && func_fatal_configuration "cannot build a shared library"
6573 1.1 riastrad build_old_libs=no
6574 1.1 riastrad break
6575 1.1 riastrad ;;
6576 1.1 riastrad -all-static | -static | -static-libtool-libs)
6577 1.1 riastrad case $arg in
6578 1.1 riastrad -all-static)
6579 1.1 riastrad if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6580 1.1 riastrad func_warning "complete static linking is impossible in this configuration"
6581 1.1 riastrad fi
6582 1.1 riastrad if test -n "$link_static_flag"; then
6583 1.1 riastrad dlopen_self=$dlopen_self_static
6584 1.1 riastrad fi
6585 1.1 riastrad prefer_static_libs=yes
6586 1.1 riastrad ;;
6587 1.1 riastrad -static)
6588 1.1 riastrad if test -z "$pic_flag" && test -n "$link_static_flag"; then
6589 1.1 riastrad dlopen_self=$dlopen_self_static
6590 1.1 riastrad fi
6591 1.1 riastrad prefer_static_libs=built
6592 1.1 riastrad ;;
6593 1.1 riastrad -static-libtool-libs)
6594 1.1 riastrad if test -z "$pic_flag" && test -n "$link_static_flag"; then
6595 1.1 riastrad dlopen_self=$dlopen_self_static
6596 1.1 riastrad fi
6597 1.1 riastrad prefer_static_libs=yes
6598 1.1 riastrad ;;
6599 1.1 riastrad esac
6600 1.1 riastrad build_libtool_libs=no
6601 1.1 riastrad build_old_libs=yes
6602 1.1 riastrad break
6603 1.1 riastrad ;;
6604 1.1 riastrad esac
6605 1.1 riastrad done
6606 1.1 riastrad
6607 1.1 riastrad # See if our shared archives depend on static archives.
6608 1.1 riastrad test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609 1.1 riastrad
6610 1.1 riastrad # Go through the arguments, transforming them on the way.
6611 1.1 riastrad while test "$#" -gt 0; do
6612 1.1 riastrad arg=$1
6613 1.1 riastrad shift
6614 1.1 riastrad func_quote_for_eval "$arg"
6615 1.1 riastrad qarg=$func_quote_for_eval_unquoted_result
6616 1.1 riastrad func_append libtool_args " $func_quote_for_eval_result"
6617 1.1 riastrad
6618 1.1 riastrad # If the previous option needs an argument, assign it.
6619 1.1 riastrad if test -n "$prev"; then
6620 1.1 riastrad case $prev in
6621 1.1 riastrad output)
6622 1.1 riastrad func_append compile_command " @OUTPUT@"
6623 1.1 riastrad func_append finalize_command " @OUTPUT@"
6624 1.1 riastrad ;;
6625 1.1 riastrad esac
6626 1.1 riastrad
6627 1.1 riastrad case $prev in
6628 1.1 riastrad bindir)
6629 1.1 riastrad bindir=$arg
6630 1.1 riastrad prev=
6631 1.1 riastrad continue
6632 1.1 riastrad ;;
6633 1.1 riastrad dlfiles|dlprefiles)
6634 1.1 riastrad $preload || {
6635 1.1 riastrad # Add the symbol object into the linking commands.
6636 1.1 riastrad func_append compile_command " @SYMFILE@"
6637 1.1 riastrad func_append finalize_command " @SYMFILE@"
6638 1.1 riastrad preload=:
6639 1.1 riastrad }
6640 1.1 riastrad case $arg in
6641 1.1 riastrad *.la | *.lo) ;; # We handle these cases below.
6642 1.1 riastrad force)
6643 1.1 riastrad if test no = "$dlself"; then
6644 1.1 riastrad dlself=needless
6645 1.1 riastrad export_dynamic=yes
6646 1.1 riastrad fi
6647 1.1 riastrad prev=
6648 1.1 riastrad continue
6649 1.1 riastrad ;;
6650 1.1 riastrad self)
6651 1.1 riastrad if test dlprefiles = "$prev"; then
6652 1.1 riastrad dlself=yes
6653 1.1 riastrad elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6654 1.1 riastrad dlself=yes
6655 1.1 riastrad else
6656 1.1 riastrad dlself=needless
6657 1.1 riastrad export_dynamic=yes
6658 1.1 riastrad fi
6659 1.1 riastrad prev=
6660 1.1 riastrad continue
6661 1.1 riastrad ;;
6662 1.1 riastrad *)
6663 1.1 riastrad if test dlfiles = "$prev"; then
6664 1.1 riastrad func_append dlfiles " $arg"
6665 1.1 riastrad else
6666 1.1 riastrad func_append dlprefiles " $arg"
6667 1.1 riastrad fi
6668 1.1 riastrad prev=
6669 1.1 riastrad continue
6670 1.1 riastrad ;;
6671 1.1 riastrad esac
6672 1.1 riastrad ;;
6673 1.1 riastrad expsyms)
6674 1.1 riastrad export_symbols=$arg
6675 1.1 riastrad test -f "$arg" \
6676 1.1 riastrad || func_fatal_error "symbol file '$arg' does not exist"
6677 1.1 riastrad prev=
6678 1.1 riastrad continue
6679 1.1 riastrad ;;
6680 1.1 riastrad expsyms_regex)
6681 1.1 riastrad export_symbols_regex=$arg
6682 1.1 riastrad prev=
6683 1.1 riastrad continue
6684 1.1 riastrad ;;
6685 1.1 riastrad framework)
6686 1.1 riastrad case $host in
6687 1.1 riastrad *-*-darwin*)
6688 1.1 riastrad case "$deplibs " in
6689 1.1 riastrad *" $qarg.ltframework "*) ;;
6690 1.1 riastrad *) func_append deplibs " $qarg.ltframework" # this is fixed later
6691 1.1 riastrad ;;
6692 1.1 riastrad esac
6693 1.1 riastrad ;;
6694 1.1 riastrad esac
6695 1.1 riastrad prev=
6696 1.1 riastrad continue
6697 1.1 riastrad ;;
6698 1.1 riastrad inst_prefix)
6699 1.1 riastrad inst_prefix_dir=$arg
6700 1.1 riastrad prev=
6701 1.1 riastrad continue
6702 1.1 riastrad ;;
6703 1.1 riastrad mllvm)
6704 1.1 riastrad # Clang does not use LLVM to link, so we can simply discard any
6705 1.1 riastrad # '-mllvm $arg' options when doing the link step.
6706 1.1 riastrad prev=
6707 1.1 riastrad continue
6708 1.1 riastrad ;;
6709 1.1 riastrad objectlist)
6710 1.1 riastrad if test -f "$arg"; then
6711 1.1 riastrad save_arg=$arg
6712 1.1 riastrad moreargs=
6713 1.1 riastrad for fil in `cat "$save_arg"`
6714 1.1 riastrad do
6715 1.1 riastrad # func_append moreargs " $fil"
6716 1.1 riastrad arg=$fil
6717 1.1 riastrad # A libtool-controlled object.
6718 1.1 riastrad
6719 1.1 riastrad # Check to see that this really is a libtool object.
6720 1.1 riastrad if func_lalib_unsafe_p "$arg"; then
6721 1.1 riastrad pic_object=
6722 1.1 riastrad non_pic_object=
6723 1.1 riastrad
6724 1.1 riastrad # Read the .lo file
6725 1.1 riastrad func_source "$arg"
6726 1.1 riastrad
6727 1.1 riastrad if test -z "$pic_object" ||
6728 1.1 riastrad test -z "$non_pic_object" ||
6729 1.1 riastrad test none = "$pic_object" &&
6730 1.1 riastrad test none = "$non_pic_object"; then
6731 1.1 riastrad func_fatal_error "cannot find name of object for '$arg'"
6732 1.1 riastrad fi
6733 1.1 riastrad
6734 1.1 riastrad # Extract subdirectory from the argument.
6735 1.1 riastrad func_dirname "$arg" "/" ""
6736 1.1 riastrad xdir=$func_dirname_result
6737 1.1 riastrad
6738 1.1 riastrad if test none != "$pic_object"; then
6739 1.1 riastrad # Prepend the subdirectory the object is found in.
6740 1.1 riastrad pic_object=$xdir$pic_object
6741 1.1 riastrad
6742 1.1 riastrad if test dlfiles = "$prev"; then
6743 1.1 riastrad if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744 1.1 riastrad func_append dlfiles " $pic_object"
6745 1.1 riastrad prev=
6746 1.1 riastrad continue
6747 1.1 riastrad else
6748 1.1 riastrad # If libtool objects are unsupported, then we need to preload.
6749 1.1 riastrad prev=dlprefiles
6750 1.1 riastrad fi
6751 1.1 riastrad fi
6752 1.1 riastrad
6753 1.1 riastrad # CHECK ME: I think I busted this. -Ossama
6754 1.1 riastrad if test dlprefiles = "$prev"; then
6755 1.1 riastrad # Preload the old-style object.
6756 1.1 riastrad func_append dlprefiles " $pic_object"
6757 1.1 riastrad prev=
6758 1.1 riastrad fi
6759 1.1 riastrad
6760 1.1 riastrad # A PIC object.
6761 1.1 riastrad func_append libobjs " $pic_object"
6762 1.1 riastrad arg=$pic_object
6763 1.1 riastrad fi
6764 1.1 riastrad
6765 1.1 riastrad # Non-PIC object.
6766 1.1 riastrad if test none != "$non_pic_object"; then
6767 1.1 riastrad # Prepend the subdirectory the object is found in.
6768 1.1 riastrad non_pic_object=$xdir$non_pic_object
6769 1.1 riastrad
6770 1.1 riastrad # A standard non-PIC object
6771 1.1 riastrad func_append non_pic_objects " $non_pic_object"
6772 1.1 riastrad if test -z "$pic_object" || test none = "$pic_object"; then
6773 1.1 riastrad arg=$non_pic_object
6774 1.1 riastrad fi
6775 1.1 riastrad else
6776 1.1 riastrad # If the PIC object exists, use it instead.
6777 1.1 riastrad # $xdir was prepended to $pic_object above.
6778 1.1 riastrad non_pic_object=$pic_object
6779 1.1 riastrad func_append non_pic_objects " $non_pic_object"
6780 1.1 riastrad fi
6781 1.1 riastrad else
6782 1.1 riastrad # Only an error if not doing a dry-run.
6783 1.1 riastrad if $opt_dry_run; then
6784 1.1 riastrad # Extract subdirectory from the argument.
6785 1.1 riastrad func_dirname "$arg" "/" ""
6786 1.1 riastrad xdir=$func_dirname_result
6787 1.1 riastrad
6788 1.1 riastrad func_lo2o "$arg"
6789 1.1 riastrad pic_object=$xdir$objdir/$func_lo2o_result
6790 1.1 riastrad non_pic_object=$xdir$func_lo2o_result
6791 1.1 riastrad func_append libobjs " $pic_object"
6792 1.1 riastrad func_append non_pic_objects " $non_pic_object"
6793 1.1 riastrad else
6794 1.1 riastrad func_fatal_error "'$arg' is not a valid libtool object"
6795 1.1 riastrad fi
6796 1.1 riastrad fi
6797 1.1 riastrad done
6798 1.1 riastrad else
6799 1.1 riastrad func_fatal_error "link input file '$arg' does not exist"
6800 1.1 riastrad fi
6801 1.1 riastrad arg=$save_arg
6802 1.1 riastrad prev=
6803 1.1 riastrad continue
6804 1.1 riastrad ;;
6805 1.1 riastrad os2dllname)
6806 1.1 riastrad os2dllname=$arg
6807 1.1 riastrad prev=
6808 1.1 riastrad continue
6809 1.1 riastrad ;;
6810 1.1 riastrad precious_regex)
6811 1.1 riastrad precious_files_regex=$arg
6812 1.1 riastrad prev=
6813 1.1 riastrad continue
6814 1.1 riastrad ;;
6815 1.1 riastrad release)
6816 1.1 riastrad release=-$arg
6817 1.1 riastrad prev=
6818 1.1 riastrad continue
6819 1.1 riastrad ;;
6820 1.1 riastrad rpath | xrpath)
6821 1.1 riastrad # We need an absolute path.
6822 1.1 riastrad case $arg in
6823 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) ;;
6824 1.1 riastrad *)
6825 1.1 riastrad func_fatal_error "only absolute run-paths are allowed"
6826 1.1 riastrad ;;
6827 1.1 riastrad esac
6828 1.1 riastrad if test rpath = "$prev"; then
6829 1.1 riastrad case "$rpath " in
6830 1.1 riastrad *" $arg "*) ;;
6831 1.1 riastrad *) func_append rpath " $arg" ;;
6832 1.1 riastrad esac
6833 1.1 riastrad else
6834 1.1 riastrad case "$xrpath " in
6835 1.1 riastrad *" $arg "*) ;;
6836 1.1 riastrad *) func_append xrpath " $arg" ;;
6837 1.1 riastrad esac
6838 1.1 riastrad fi
6839 1.1 riastrad prev=
6840 1.1 riastrad continue
6841 1.1 riastrad ;;
6842 1.1 riastrad shrext)
6843 1.1 riastrad shrext_cmds=$arg
6844 1.1 riastrad prev=
6845 1.1 riastrad continue
6846 1.1 riastrad ;;
6847 1.1 riastrad weak)
6848 1.1 riastrad func_append weak_libs " $arg"
6849 1.1 riastrad prev=
6850 1.1 riastrad continue
6851 1.1 riastrad ;;
6852 1.1 riastrad xcclinker)
6853 1.1 riastrad func_append linker_flags " $qarg"
6854 1.1 riastrad func_append compiler_flags " $qarg"
6855 1.1 riastrad prev=
6856 1.1 riastrad func_append compile_command " $qarg"
6857 1.1 riastrad func_append finalize_command " $qarg"
6858 1.1 riastrad continue
6859 1.1 riastrad ;;
6860 1.1 riastrad xcompiler)
6861 1.1 riastrad func_append compiler_flags " $qarg"
6862 1.1 riastrad prev=
6863 1.1 riastrad func_append compile_command " $qarg"
6864 1.1 riastrad func_append finalize_command " $qarg"
6865 1.1 riastrad continue
6866 1.1 riastrad ;;
6867 1.1 riastrad xlinker)
6868 1.1 riastrad func_append linker_flags " $qarg"
6869 1.1 riastrad func_append compiler_flags " $wl$qarg"
6870 1.1 riastrad prev=
6871 1.1 riastrad func_append compile_command " $wl$qarg"
6872 1.1 riastrad func_append finalize_command " $wl$qarg"
6873 1.1 riastrad continue
6874 1.1 riastrad ;;
6875 1.1 riastrad *)
6876 1.1 riastrad eval "$prev=\"\$arg\""
6877 1.1 riastrad prev=
6878 1.1 riastrad continue
6879 1.1 riastrad ;;
6880 1.1 riastrad esac
6881 1.1 riastrad fi # test -n "$prev"
6882 1.1 riastrad
6883 1.1 riastrad prevarg=$arg
6884 1.1 riastrad
6885 1.1 riastrad case $arg in
6886 1.1 riastrad -all-static)
6887 1.1 riastrad if test -n "$link_static_flag"; then
6888 1.1 riastrad # See comment for -static flag below, for more details.
6889 1.1 riastrad func_append compile_command " $link_static_flag"
6890 1.1 riastrad func_append finalize_command " $link_static_flag"
6891 1.1 riastrad fi
6892 1.1 riastrad continue
6893 1.1 riastrad ;;
6894 1.1 riastrad
6895 1.1 riastrad -allow-undefined)
6896 1.1 riastrad # FIXME: remove this flag sometime in the future.
6897 1.1 riastrad func_fatal_error "'-allow-undefined' must not be used because it is the default"
6898 1.1 riastrad ;;
6899 1.1 riastrad
6900 1.1 riastrad -avoid-version)
6901 1.1 riastrad avoid_version=yes
6902 1.1 riastrad continue
6903 1.1 riastrad ;;
6904 1.1 riastrad
6905 1.1 riastrad -bindir)
6906 1.1 riastrad prev=bindir
6907 1.1 riastrad continue
6908 1.1 riastrad ;;
6909 1.1 riastrad
6910 1.1 riastrad -dlopen)
6911 1.1 riastrad prev=dlfiles
6912 1.1 riastrad continue
6913 1.1 riastrad ;;
6914 1.1 riastrad
6915 1.1 riastrad -dlpreopen)
6916 1.1 riastrad prev=dlprefiles
6917 1.1 riastrad continue
6918 1.1 riastrad ;;
6919 1.1 riastrad
6920 1.1 riastrad -export-dynamic)
6921 1.1 riastrad export_dynamic=yes
6922 1.1 riastrad continue
6923 1.1 riastrad ;;
6924 1.1 riastrad
6925 1.1 riastrad -export-symbols | -export-symbols-regex)
6926 1.1 riastrad if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6927 1.1 riastrad func_fatal_error "more than one -exported-symbols argument is not allowed"
6928 1.1 riastrad fi
6929 1.1 riastrad if test X-export-symbols = "X$arg"; then
6930 1.1 riastrad prev=expsyms
6931 1.1 riastrad else
6932 1.1 riastrad prev=expsyms_regex
6933 1.1 riastrad fi
6934 1.1 riastrad continue
6935 1.1 riastrad ;;
6936 1.1 riastrad
6937 1.1 riastrad -framework)
6938 1.1 riastrad prev=framework
6939 1.1 riastrad continue
6940 1.1 riastrad ;;
6941 1.1 riastrad
6942 1.1 riastrad -inst-prefix-dir)
6943 1.1 riastrad prev=inst_prefix
6944 1.1 riastrad continue
6945 1.1 riastrad ;;
6946 1.1 riastrad
6947 1.1 riastrad # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6948 1.1 riastrad # so, if we see these flags be careful not to treat them like -L
6949 1.1 riastrad -L[A-Z][A-Z]*:*)
6950 1.1 riastrad case $with_gcc/$host in
6951 1.1 riastrad no/*-*-irix* | /*-*-irix*)
6952 1.1 riastrad func_append compile_command " $arg"
6953 1.1 riastrad func_append finalize_command " $arg"
6954 1.1 riastrad ;;
6955 1.1 riastrad esac
6956 1.1 riastrad continue
6957 1.1 riastrad ;;
6958 1.1 riastrad
6959 1.1 riastrad -L*)
6960 1.1 riastrad func_stripname "-L" '' "$arg"
6961 1.1 riastrad if test -z "$func_stripname_result"; then
6962 1.1 riastrad if test "$#" -gt 0; then
6963 1.1 riastrad func_fatal_error "require no space between '-L' and '$1'"
6964 1.1 riastrad else
6965 1.1 riastrad func_fatal_error "need path for '-L' option"
6966 1.1 riastrad fi
6967 1.1 riastrad fi
6968 1.1 riastrad func_resolve_sysroot "$func_stripname_result"
6969 1.1 riastrad dir=$func_resolve_sysroot_result
6970 1.1 riastrad # We need an absolute path.
6971 1.1 riastrad case $dir in
6972 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) ;;
6973 1.1 riastrad *)
6974 1.1 riastrad absdir=`cd "$dir" && pwd`
6975 1.1 riastrad test -z "$absdir" && \
6976 1.1 riastrad func_fatal_error "cannot determine absolute directory name of '$dir'"
6977 1.1 riastrad dir=$absdir
6978 1.1 riastrad ;;
6979 1.1 riastrad esac
6980 1.1 riastrad case "$deplibs " in
6981 1.1 riastrad *" -L$dir "* | *" $arg "*)
6982 1.1 riastrad # Will only happen for absolute or sysroot arguments
6983 1.1 riastrad ;;
6984 1.1 riastrad *)
6985 1.1 riastrad # Preserve sysroot, but never include relative directories
6986 1.1 riastrad case $dir in
6987 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988 1.1 riastrad *) func_append deplibs " -L$dir" ;;
6989 1.1 riastrad esac
6990 1.1 riastrad func_append lib_search_path " $dir"
6991 1.1 riastrad ;;
6992 1.1 riastrad esac
6993 1.1 riastrad case $host in
6994 1.1 riastrad *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995 1.1 riastrad testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6996 1.1 riastrad case :$dllsearchpath: in
6997 1.1 riastrad *":$dir:"*) ;;
6998 1.1 riastrad ::) dllsearchpath=$dir;;
6999 1.1 riastrad *) func_append dllsearchpath ":$dir";;
7000 1.1 riastrad esac
7001 1.1 riastrad case :$dllsearchpath: in
7002 1.1 riastrad *":$testbindir:"*) ;;
7003 1.1 riastrad ::) dllsearchpath=$testbindir;;
7004 1.1 riastrad *) func_append dllsearchpath ":$testbindir";;
7005 1.1 riastrad esac
7006 1.1 riastrad ;;
7007 1.1 riastrad esac
7008 1.1 riastrad continue
7009 1.1 riastrad ;;
7010 1.1 riastrad
7011 1.1 riastrad -l*)
7012 1.1 riastrad if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7013 1.1 riastrad case $host in
7014 1.1 riastrad *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7015 1.1 riastrad # These systems don't actually have a C or math library (as such)
7016 1.1 riastrad continue
7017 1.1 riastrad ;;
7018 1.1 riastrad *-*-os2*)
7019 1.1 riastrad # These systems don't actually have a C library (as such)
7020 1.1 riastrad test X-lc = "X$arg" && continue
7021 1.1 riastrad ;;
7022 1.1 riastrad *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7023 1.1 riastrad # Do not include libc due to us having libc/libc_r.
7024 1.1 riastrad test X-lc = "X$arg" && continue
7025 1.1 riastrad ;;
7026 1.1 riastrad *-*-rhapsody* | *-*-darwin1.[012])
7027 1.1 riastrad # Rhapsody C and math libraries are in the System framework
7028 1.1 riastrad func_append deplibs " System.ltframework"
7029 1.1 riastrad continue
7030 1.1 riastrad ;;
7031 1.1 riastrad *-*-sco3.2v5* | *-*-sco5v6*)
7032 1.1 riastrad # Causes problems with __ctype
7033 1.1 riastrad test X-lc = "X$arg" && continue
7034 1.1 riastrad ;;
7035 1.1 riastrad *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7036 1.1 riastrad # Compiler inserts libc in the correct place for threads to work
7037 1.1 riastrad test X-lc = "X$arg" && continue
7038 1.1 riastrad ;;
7039 1.1 riastrad esac
7040 1.1 riastrad elif test X-lc_r = "X$arg"; then
7041 1.1 riastrad case $host in
7042 1.1 riastrad *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7043 1.1 riastrad # Do not include libc_r directly, use -pthread flag.
7044 1.1 riastrad continue
7045 1.1 riastrad ;;
7046 1.1 riastrad esac
7047 1.1 riastrad fi
7048 1.1 riastrad func_append deplibs " $arg"
7049 1.1 riastrad continue
7050 1.1 riastrad ;;
7051 1.1 riastrad
7052 1.1 riastrad -mllvm)
7053 1.1 riastrad prev=mllvm
7054 1.1 riastrad continue
7055 1.1 riastrad ;;
7056 1.1 riastrad
7057 1.1 riastrad -module)
7058 1.1 riastrad module=yes
7059 1.1 riastrad continue
7060 1.1 riastrad ;;
7061 1.1 riastrad
7062 1.1 riastrad # Tru64 UNIX uses -model [arg] to determine the layout of C++
7063 1.1 riastrad # classes, name mangling, and exception handling.
7064 1.1 riastrad # Darwin uses the -arch flag to determine output architecture.
7065 1.1 riastrad -model|-arch|-isysroot|--sysroot)
7066 1.1 riastrad func_append compiler_flags " $arg"
7067 1.1 riastrad func_append compile_command " $arg"
7068 1.1 riastrad func_append finalize_command " $arg"
7069 1.1 riastrad prev=xcompiler
7070 1.1 riastrad continue
7071 1.1 riastrad ;;
7072 1.1 riastrad
7073 1.1 riastrad -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7074 1.1 riastrad |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075 1.1 riastrad func_append compiler_flags " $arg"
7076 1.1 riastrad func_append compile_command " $arg"
7077 1.1 riastrad func_append finalize_command " $arg"
7078 1.1 riastrad case "$new_inherited_linker_flags " in
7079 1.1 riastrad *" $arg "*) ;;
7080 1.1 riastrad * ) func_append new_inherited_linker_flags " $arg" ;;
7081 1.1 riastrad esac
7082 1.1 riastrad continue
7083 1.1 riastrad ;;
7084 1.1 riastrad
7085 1.1 riastrad -multi_module)
7086 1.1 riastrad single_module=$wl-multi_module
7087 1.1 riastrad continue
7088 1.1 riastrad ;;
7089 1.1 riastrad
7090 1.1 riastrad -no-fast-install)
7091 1.1 riastrad fast_install=no
7092 1.1 riastrad continue
7093 1.1 riastrad ;;
7094 1.1 riastrad
7095 1.1 riastrad -no-install)
7096 1.1 riastrad case $host in
7097 1.1 riastrad *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7098 1.1 riastrad # The PATH hackery in wrapper scripts is required on Windows
7099 1.1 riastrad # and Darwin in order for the loader to find any dlls it needs.
7100 1.1 riastrad func_warning "'-no-install' is ignored for $host"
7101 1.1 riastrad func_warning "assuming '-no-fast-install' instead"
7102 1.1 riastrad fast_install=no
7103 1.1 riastrad ;;
7104 1.1 riastrad *) no_install=yes ;;
7105 1.1 riastrad esac
7106 1.1 riastrad continue
7107 1.1 riastrad ;;
7108 1.1 riastrad
7109 1.1 riastrad -no-undefined)
7110 1.1 riastrad allow_undefined=no
7111 1.1 riastrad continue
7112 1.1 riastrad ;;
7113 1.1 riastrad
7114 1.1 riastrad -objectlist)
7115 1.1 riastrad prev=objectlist
7116 1.1 riastrad continue
7117 1.1 riastrad ;;
7118 1.1 riastrad
7119 1.1 riastrad -os2dllname)
7120 1.1 riastrad prev=os2dllname
7121 1.1 riastrad continue
7122 1.1 riastrad ;;
7123 1.1 riastrad
7124 1.1 riastrad -o) prev=output ;;
7125 1.1 riastrad
7126 1.1 riastrad -precious-files-regex)
7127 1.1 riastrad prev=precious_regex
7128 1.1 riastrad continue
7129 1.1 riastrad ;;
7130 1.1 riastrad
7131 1.1 riastrad -release)
7132 1.1 riastrad prev=release
7133 1.1 riastrad continue
7134 1.1 riastrad ;;
7135 1.1 riastrad
7136 1.1 riastrad -rpath)
7137 1.1 riastrad prev=rpath
7138 1.1 riastrad continue
7139 1.1 riastrad ;;
7140 1.1 riastrad
7141 1.1 riastrad -R)
7142 1.1 riastrad prev=xrpath
7143 1.1 riastrad continue
7144 1.1 riastrad ;;
7145 1.1 riastrad
7146 1.1 riastrad -R*)
7147 1.1 riastrad func_stripname '-R' '' "$arg"
7148 1.1 riastrad dir=$func_stripname_result
7149 1.1 riastrad # We need an absolute path.
7150 1.1 riastrad case $dir in
7151 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) ;;
7152 1.1 riastrad =*)
7153 1.1 riastrad func_stripname '=' '' "$dir"
7154 1.1 riastrad dir=$lt_sysroot$func_stripname_result
7155 1.1 riastrad ;;
7156 1.1 riastrad *)
7157 1.1 riastrad func_fatal_error "only absolute run-paths are allowed"
7158 1.1 riastrad ;;
7159 1.1 riastrad esac
7160 1.1 riastrad case "$xrpath " in
7161 1.1 riastrad *" $dir "*) ;;
7162 1.1 riastrad *) func_append xrpath " $dir" ;;
7163 1.1 riastrad esac
7164 1.1 riastrad continue
7165 1.1 riastrad ;;
7166 1.1 riastrad
7167 1.1 riastrad -shared)
7168 1.1 riastrad # The effects of -shared are defined in a previous loop.
7169 1.1 riastrad continue
7170 1.1 riastrad ;;
7171 1.1 riastrad
7172 1.1 riastrad -shrext)
7173 1.1 riastrad prev=shrext
7174 1.1 riastrad continue
7175 1.1 riastrad ;;
7176 1.1 riastrad
7177 1.1 riastrad -static | -static-libtool-libs)
7178 1.1 riastrad # The effects of -static are defined in a previous loop.
7179 1.1 riastrad # We used to do the same as -all-static on platforms that
7180 1.1 riastrad # didn't have a PIC flag, but the assumption that the effects
7181 1.1 riastrad # would be equivalent was wrong. It would break on at least
7182 1.1 riastrad # Digital Unix and AIX.
7183 1.1 riastrad continue
7184 1.1 riastrad ;;
7185 1.1 riastrad
7186 1.1 riastrad -thread-safe)
7187 1.1 riastrad thread_safe=yes
7188 1.1 riastrad continue
7189 1.1 riastrad ;;
7190 1.1 riastrad
7191 1.1 riastrad -version-info)
7192 1.1 riastrad prev=vinfo
7193 1.1 riastrad continue
7194 1.1 riastrad ;;
7195 1.1 riastrad
7196 1.1 riastrad -version-number)
7197 1.1 riastrad prev=vinfo
7198 1.1 riastrad vinfo_number=yes
7199 1.1 riastrad continue
7200 1.1 riastrad ;;
7201 1.1 riastrad
7202 1.1 riastrad -weak)
7203 1.1 riastrad prev=weak
7204 1.1 riastrad continue
7205 1.1 riastrad ;;
7206 1.1 riastrad
7207 1.1 riastrad -Wc,*)
7208 1.1 riastrad func_stripname '-Wc,' '' "$arg"
7209 1.1 riastrad args=$func_stripname_result
7210 1.1 riastrad arg=
7211 1.1 riastrad save_ifs=$IFS; IFS=,
7212 1.1 riastrad for flag in $args; do
7213 1.1 riastrad IFS=$save_ifs
7214 1.1 riastrad func_quote_for_eval "$flag"
7215 1.1 riastrad func_append arg " $func_quote_for_eval_result"
7216 1.1 riastrad func_append compiler_flags " $func_quote_for_eval_result"
7217 1.1 riastrad done
7218 1.1 riastrad IFS=$save_ifs
7219 1.1 riastrad func_stripname ' ' '' "$arg"
7220 1.1 riastrad arg=$func_stripname_result
7221 1.1 riastrad ;;
7222 1.1 riastrad
7223 1.1 riastrad -Wl,*)
7224 1.1 riastrad func_stripname '-Wl,' '' "$arg"
7225 1.1 riastrad args=$func_stripname_result
7226 1.1 riastrad arg=
7227 1.1 riastrad save_ifs=$IFS; IFS=,
7228 1.1 riastrad for flag in $args; do
7229 1.1 riastrad IFS=$save_ifs
7230 1.1 riastrad func_quote_for_eval "$flag"
7231 1.1 riastrad func_append arg " $wl$func_quote_for_eval_result"
7232 1.1 riastrad func_append compiler_flags " $wl$func_quote_for_eval_result"
7233 1.1 riastrad func_append linker_flags " $func_quote_for_eval_result"
7234 1.1 riastrad done
7235 1.1 riastrad IFS=$save_ifs
7236 1.1 riastrad func_stripname ' ' '' "$arg"
7237 1.1 riastrad arg=$func_stripname_result
7238 1.1 riastrad ;;
7239 1.1 riastrad
7240 1.1 riastrad -Xcompiler)
7241 1.1 riastrad prev=xcompiler
7242 1.1 riastrad continue
7243 1.1 riastrad ;;
7244 1.1 riastrad
7245 1.1 riastrad -Xlinker)
7246 1.1 riastrad prev=xlinker
7247 1.1 riastrad continue
7248 1.1 riastrad ;;
7249 1.1 riastrad
7250 1.1 riastrad -XCClinker)
7251 1.1 riastrad prev=xcclinker
7252 1.1 riastrad continue
7253 1.1 riastrad ;;
7254 1.1 riastrad
7255 1.1 riastrad # -msg_* for osf cc
7256 1.1 riastrad -msg_*)
7257 1.1 riastrad func_quote_for_eval "$arg"
7258 1.1 riastrad arg=$func_quote_for_eval_result
7259 1.1 riastrad ;;
7260 1.1 riastrad
7261 1.1 riastrad # Flags to be passed through unchanged, with rationale:
7262 1.1 riastrad # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
7263 1.1 riastrad # -r[0-9][0-9]* specify processor for the SGI compiler
7264 1.1 riastrad # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265 1.1 riastrad # +DA*, +DD* enable 64-bit mode for the HP compiler
7266 1.1 riastrad # -q* compiler args for the IBM compiler
7267 1.1 riastrad # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268 1.1 riastrad # -F/path path to uninstalled frameworks, gcc on darwin
7269 1.1 riastrad # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
7270 1.1 riastrad # -fstack-protector* stack protector flags for GCC
7271 1.1 riastrad # @file GCC response files
7272 1.1 riastrad # -tp=* Portland pgcc target processor selection
7273 1.1 riastrad # --sysroot=* for sysroot support
7274 1.1 riastrad # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7275 1.1 riastrad # -stdlib=* select c++ std lib with clang
7276 1.1 riastrad -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7277 1.1 riastrad -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7278 1.1 riastrad -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
7279 1.1 riastrad func_quote_for_eval "$arg"
7280 1.1 riastrad arg=$func_quote_for_eval_result
7281 1.1 riastrad func_append compile_command " $arg"
7282 1.1 riastrad func_append finalize_command " $arg"
7283 1.1 riastrad func_append compiler_flags " $arg"
7284 1.1 riastrad continue
7285 1.1 riastrad ;;
7286 1.1 riastrad
7287 1.1 riastrad -Z*)
7288 1.1 riastrad if test os2 = "`expr $host : '.*\(os2\)'`"; then
7289 1.1 riastrad # OS/2 uses -Zxxx to specify OS/2-specific options
7290 1.1 riastrad compiler_flags="$compiler_flags $arg"
7291 1.1 riastrad func_append compile_command " $arg"
7292 1.1 riastrad func_append finalize_command " $arg"
7293 1.1 riastrad case $arg in
7294 1.1 riastrad -Zlinker | -Zstack)
7295 1.1 riastrad prev=xcompiler
7296 1.1 riastrad ;;
7297 1.1 riastrad esac
7298 1.1 riastrad continue
7299 1.1 riastrad else
7300 1.1 riastrad # Otherwise treat like 'Some other compiler flag' below
7301 1.1 riastrad func_quote_for_eval "$arg"
7302 1.1 riastrad arg=$func_quote_for_eval_result
7303 1.1 riastrad fi
7304 1.1 riastrad ;;
7305 1.1 riastrad
7306 1.1 riastrad # Some other compiler flag.
7307 1.1 riastrad -* | +*)
7308 1.1 riastrad func_quote_for_eval "$arg"
7309 1.1 riastrad arg=$func_quote_for_eval_result
7310 1.1 riastrad ;;
7311 1.1 riastrad
7312 1.1 riastrad *.$objext)
7313 1.1 riastrad # A standard object.
7314 1.1 riastrad func_append objs " $arg"
7315 1.1 riastrad ;;
7316 1.1 riastrad
7317 1.1 riastrad *.lo)
7318 1.1 riastrad # A libtool-controlled object.
7319 1.1 riastrad
7320 1.1 riastrad # Check to see that this really is a libtool object.
7321 1.1 riastrad if func_lalib_unsafe_p "$arg"; then
7322 1.1 riastrad pic_object=
7323 1.1 riastrad non_pic_object=
7324 1.1 riastrad
7325 1.1 riastrad # Read the .lo file
7326 1.1 riastrad func_source "$arg"
7327 1.1 riastrad
7328 1.1 riastrad if test -z "$pic_object" ||
7329 1.1 riastrad test -z "$non_pic_object" ||
7330 1.1 riastrad test none = "$pic_object" &&
7331 1.1 riastrad test none = "$non_pic_object"; then
7332 1.1 riastrad func_fatal_error "cannot find name of object for '$arg'"
7333 1.1 riastrad fi
7334 1.1 riastrad
7335 1.1 riastrad # Extract subdirectory from the argument.
7336 1.1 riastrad func_dirname "$arg" "/" ""
7337 1.1 riastrad xdir=$func_dirname_result
7338 1.1 riastrad
7339 1.1 riastrad test none = "$pic_object" || {
7340 1.1 riastrad # Prepend the subdirectory the object is found in.
7341 1.1 riastrad pic_object=$xdir$pic_object
7342 1.1 riastrad
7343 1.1 riastrad if test dlfiles = "$prev"; then
7344 1.1 riastrad if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7345 1.1 riastrad func_append dlfiles " $pic_object"
7346 1.1 riastrad prev=
7347 1.1 riastrad continue
7348 1.1 riastrad else
7349 1.1 riastrad # If libtool objects are unsupported, then we need to preload.
7350 1.1 riastrad prev=dlprefiles
7351 1.1 riastrad fi
7352 1.1 riastrad fi
7353 1.1 riastrad
7354 1.1 riastrad # CHECK ME: I think I busted this. -Ossama
7355 1.1 riastrad if test dlprefiles = "$prev"; then
7356 1.1 riastrad # Preload the old-style object.
7357 1.1 riastrad func_append dlprefiles " $pic_object"
7358 1.1 riastrad prev=
7359 1.1 riastrad fi
7360 1.1 riastrad
7361 1.1 riastrad # A PIC object.
7362 1.1 riastrad func_append libobjs " $pic_object"
7363 1.1 riastrad arg=$pic_object
7364 1.1 riastrad }
7365 1.1 riastrad
7366 1.1 riastrad # Non-PIC object.
7367 1.1 riastrad if test none != "$non_pic_object"; then
7368 1.1 riastrad # Prepend the subdirectory the object is found in.
7369 1.1 riastrad non_pic_object=$xdir$non_pic_object
7370 1.1 riastrad
7371 1.1 riastrad # A standard non-PIC object
7372 1.1 riastrad func_append non_pic_objects " $non_pic_object"
7373 1.1 riastrad if test -z "$pic_object" || test none = "$pic_object"; then
7374 1.1 riastrad arg=$non_pic_object
7375 1.1 riastrad fi
7376 1.1 riastrad else
7377 1.1 riastrad # If the PIC object exists, use it instead.
7378 1.1 riastrad # $xdir was prepended to $pic_object above.
7379 1.1 riastrad non_pic_object=$pic_object
7380 1.1 riastrad func_append non_pic_objects " $non_pic_object"
7381 1.1 riastrad fi
7382 1.1 riastrad else
7383 1.1 riastrad # Only an error if not doing a dry-run.
7384 1.1 riastrad if $opt_dry_run; then
7385 1.1 riastrad # Extract subdirectory from the argument.
7386 1.1 riastrad func_dirname "$arg" "/" ""
7387 1.1 riastrad xdir=$func_dirname_result
7388 1.1 riastrad
7389 1.1 riastrad func_lo2o "$arg"
7390 1.1 riastrad pic_object=$xdir$objdir/$func_lo2o_result
7391 1.1 riastrad non_pic_object=$xdir$func_lo2o_result
7392 1.1 riastrad func_append libobjs " $pic_object"
7393 1.1 riastrad func_append non_pic_objects " $non_pic_object"
7394 1.1 riastrad else
7395 1.1 riastrad func_fatal_error "'$arg' is not a valid libtool object"
7396 1.1 riastrad fi
7397 1.1 riastrad fi
7398 1.1 riastrad ;;
7399 1.1 riastrad
7400 1.1 riastrad *.$libext)
7401 1.1 riastrad # An archive.
7402 1.1 riastrad func_append deplibs " $arg"
7403 1.1 riastrad func_append old_deplibs " $arg"
7404 1.1 riastrad continue
7405 1.1 riastrad ;;
7406 1.1 riastrad
7407 1.1 riastrad *.la)
7408 1.1 riastrad # A libtool-controlled library.
7409 1.1 riastrad
7410 1.1 riastrad func_resolve_sysroot "$arg"
7411 1.1 riastrad if test dlfiles = "$prev"; then
7412 1.1 riastrad # This library was specified with -dlopen.
7413 1.1 riastrad func_append dlfiles " $func_resolve_sysroot_result"
7414 1.1 riastrad prev=
7415 1.1 riastrad elif test dlprefiles = "$prev"; then
7416 1.1 riastrad # The library was specified with -dlpreopen.
7417 1.1 riastrad func_append dlprefiles " $func_resolve_sysroot_result"
7418 1.1 riastrad prev=
7419 1.1 riastrad else
7420 1.1 riastrad func_append deplibs " $func_resolve_sysroot_result"
7421 1.1 riastrad fi
7422 1.1 riastrad continue
7423 1.1 riastrad ;;
7424 1.1 riastrad
7425 1.1 riastrad # Some other compiler argument.
7426 1.1 riastrad *)
7427 1.1 riastrad # Unknown arguments in both finalize_command and compile_command need
7428 1.1 riastrad # to be aesthetically quoted because they are evaled later.
7429 1.1 riastrad func_quote_for_eval "$arg"
7430 1.1 riastrad arg=$func_quote_for_eval_result
7431 1.1 riastrad ;;
7432 1.1 riastrad esac # arg
7433 1.1 riastrad
7434 1.1 riastrad # Now actually substitute the argument into the commands.
7435 1.1 riastrad if test -n "$arg"; then
7436 1.1 riastrad func_append compile_command " $arg"
7437 1.1 riastrad func_append finalize_command " $arg"
7438 1.1 riastrad fi
7439 1.1 riastrad done # argument parsing loop
7440 1.1 riastrad
7441 1.1 riastrad test -n "$prev" && \
7442 1.1 riastrad func_fatal_help "the '$prevarg' option requires an argument"
7443 1.1 riastrad
7444 1.1 riastrad if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7445 1.1 riastrad eval arg=\"$export_dynamic_flag_spec\"
7446 1.1 riastrad func_append compile_command " $arg"
7447 1.1 riastrad func_append finalize_command " $arg"
7448 1.1 riastrad fi
7449 1.1 riastrad
7450 1.1 riastrad oldlibs=
7451 1.1 riastrad # calculate the name of the file, without its directory
7452 1.1 riastrad func_basename "$output"
7453 1.1 riastrad outputname=$func_basename_result
7454 1.1 riastrad libobjs_save=$libobjs
7455 1.1 riastrad
7456 1.1 riastrad if test -n "$shlibpath_var"; then
7457 1.1 riastrad # get the directories listed in $shlibpath_var
7458 1.1 riastrad eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7459 1.1 riastrad else
7460 1.1 riastrad shlib_search_path=
7461 1.1 riastrad fi
7462 1.1 riastrad eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7463 1.1 riastrad eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7464 1.1 riastrad
7465 1.1 riastrad # Definition is injected by LT_CONFIG during libtool generation.
7466 1.1 riastrad func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7467 1.1 riastrad
7468 1.1 riastrad func_dirname "$output" "/" ""
7469 1.1 riastrad output_objdir=$func_dirname_result$objdir
7470 1.1 riastrad func_to_tool_file "$output_objdir/"
7471 1.1 riastrad tool_output_objdir=$func_to_tool_file_result
7472 1.1 riastrad # Create the object directory.
7473 1.1 riastrad func_mkdir_p "$output_objdir"
7474 1.1 riastrad
7475 1.1 riastrad # Determine the type of output
7476 1.1 riastrad case $output in
7477 1.1 riastrad "")
7478 1.1 riastrad func_fatal_help "you must specify an output file"
7479 1.1 riastrad ;;
7480 1.1 riastrad *.$libext) linkmode=oldlib ;;
7481 1.1 riastrad *.lo | *.$objext) linkmode=obj ;;
7482 1.1 riastrad *.la) linkmode=lib ;;
7483 1.1 riastrad *) linkmode=prog ;; # Anything else should be a program.
7484 1.1 riastrad esac
7485 1.1 riastrad
7486 1.1 riastrad specialdeplibs=
7487 1.1 riastrad
7488 1.1 riastrad libs=
7489 1.1 riastrad # Find all interdependent deplibs by searching for libraries
7490 1.1 riastrad # that are linked more than once (e.g. -la -lb -la)
7491 1.1 riastrad for deplib in $deplibs; do
7492 1.1 riastrad if $opt_preserve_dup_deps; then
7493 1.1 riastrad case "$libs " in
7494 1.1 riastrad *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7495 1.1 riastrad esac
7496 1.1 riastrad fi
7497 1.1 riastrad func_append libs " $deplib"
7498 1.1 riastrad done
7499 1.1 riastrad
7500 1.1 riastrad if test lib = "$linkmode"; then
7501 1.1 riastrad libs="$predeps $libs $compiler_lib_search_path $postdeps"
7502 1.1 riastrad
7503 1.1 riastrad # Compute libraries that are listed more than once in $predeps
7504 1.1 riastrad # $postdeps and mark them as special (i.e., whose duplicates are
7505 1.1 riastrad # not to be eliminated).
7506 1.1 riastrad pre_post_deps=
7507 1.1 riastrad if $opt_duplicate_compiler_generated_deps; then
7508 1.1 riastrad for pre_post_dep in $predeps $postdeps; do
7509 1.1 riastrad case "$pre_post_deps " in
7510 1.1 riastrad *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7511 1.1 riastrad esac
7512 1.1 riastrad func_append pre_post_deps " $pre_post_dep"
7513 1.1 riastrad done
7514 1.1 riastrad fi
7515 1.1 riastrad pre_post_deps=
7516 1.1 riastrad fi
7517 1.1 riastrad
7518 1.1 riastrad deplibs=
7519 1.1 riastrad newdependency_libs=
7520 1.1 riastrad newlib_search_path=
7521 1.1 riastrad need_relink=no # whether we're linking any uninstalled libtool libraries
7522 1.1 riastrad notinst_deplibs= # not-installed libtool libraries
7523 1.1 riastrad notinst_path= # paths that contain not-installed libtool libraries
7524 1.1 riastrad
7525 1.1 riastrad case $linkmode in
7526 1.1 riastrad lib)
7527 1.1 riastrad passes="conv dlpreopen link"
7528 1.1 riastrad for file in $dlfiles $dlprefiles; do
7529 1.1 riastrad case $file in
7530 1.1 riastrad *.la) ;;
7531 1.1 riastrad *)
7532 1.1 riastrad func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7533 1.1 riastrad ;;
7534 1.1 riastrad esac
7535 1.1 riastrad done
7536 1.1 riastrad ;;
7537 1.1 riastrad prog)
7538 1.1 riastrad compile_deplibs=
7539 1.1 riastrad finalize_deplibs=
7540 1.1 riastrad alldeplibs=false
7541 1.1 riastrad newdlfiles=
7542 1.1 riastrad newdlprefiles=
7543 1.1 riastrad passes="conv scan dlopen dlpreopen link"
7544 1.1 riastrad ;;
7545 1.1 riastrad *) passes="conv"
7546 1.1 riastrad ;;
7547 1.1 riastrad esac
7548 1.1 riastrad
7549 1.1 riastrad for pass in $passes; do
7550 1.1 riastrad # The preopen pass in lib mode reverses $deplibs; put it back here
7551 1.1 riastrad # so that -L comes before libs that need it for instance...
7552 1.1 riastrad if test lib,link = "$linkmode,$pass"; then
7553 1.1 riastrad ## FIXME: Find the place where the list is rebuilt in the wrong
7554 1.1 riastrad ## order, and fix it there properly
7555 1.1 riastrad tmp_deplibs=
7556 1.1 riastrad for deplib in $deplibs; do
7557 1.1 riastrad tmp_deplibs="$deplib $tmp_deplibs"
7558 1.1 riastrad done
7559 1.1 riastrad deplibs=$tmp_deplibs
7560 1.1 riastrad fi
7561 1.1 riastrad
7562 1.1 riastrad if test lib,link = "$linkmode,$pass" ||
7563 1.1 riastrad test prog,scan = "$linkmode,$pass"; then
7564 1.1 riastrad libs=$deplibs
7565 1.1 riastrad deplibs=
7566 1.1 riastrad fi
7567 1.1 riastrad if test prog = "$linkmode"; then
7568 1.1 riastrad case $pass in
7569 1.1 riastrad dlopen) libs=$dlfiles ;;
7570 1.1 riastrad dlpreopen) libs=$dlprefiles ;;
7571 1.1 riastrad link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7572 1.1 riastrad esac
7573 1.1 riastrad fi
7574 1.1 riastrad if test lib,dlpreopen = "$linkmode,$pass"; then
7575 1.1 riastrad # Collect and forward deplibs of preopened libtool libs
7576 1.1 riastrad for lib in $dlprefiles; do
7577 1.1 riastrad # Ignore non-libtool-libs
7578 1.1 riastrad dependency_libs=
7579 1.1 riastrad func_resolve_sysroot "$lib"
7580 1.1 riastrad case $lib in
7581 1.1 riastrad *.la) func_source "$func_resolve_sysroot_result" ;;
7582 1.1 riastrad esac
7583 1.1 riastrad
7584 1.1 riastrad # Collect preopened libtool deplibs, except any this library
7585 1.1 riastrad # has declared as weak libs
7586 1.1 riastrad for deplib in $dependency_libs; do
7587 1.1 riastrad func_basename "$deplib"
7588 1.1 riastrad deplib_base=$func_basename_result
7589 1.1 riastrad case " $weak_libs " in
7590 1.1 riastrad *" $deplib_base "*) ;;
7591 1.1 riastrad *) func_append deplibs " $deplib" ;;
7592 1.1 riastrad esac
7593 1.1 riastrad done
7594 1.1 riastrad done
7595 1.1 riastrad libs=$dlprefiles
7596 1.1 riastrad fi
7597 1.1 riastrad if test dlopen = "$pass"; then
7598 1.1 riastrad # Collect dlpreopened libraries
7599 1.1 riastrad save_deplibs=$deplibs
7600 1.1 riastrad deplibs=
7601 1.1 riastrad fi
7602 1.1 riastrad
7603 1.1 riastrad for deplib in $libs; do
7604 1.1 riastrad lib=
7605 1.1 riastrad found=false
7606 1.1 riastrad case $deplib in
7607 1.1 riastrad -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7608 1.1 riastrad |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7609 1.1 riastrad if test prog,link = "$linkmode,$pass"; then
7610 1.1 riastrad compile_deplibs="$deplib $compile_deplibs"
7611 1.1 riastrad finalize_deplibs="$deplib $finalize_deplibs"
7612 1.1 riastrad else
7613 1.1 riastrad func_append compiler_flags " $deplib"
7614 1.1 riastrad if test lib = "$linkmode"; then
7615 1.1 riastrad case "$new_inherited_linker_flags " in
7616 1.1 riastrad *" $deplib "*) ;;
7617 1.1 riastrad * ) func_append new_inherited_linker_flags " $deplib" ;;
7618 1.1 riastrad esac
7619 1.1 riastrad fi
7620 1.1 riastrad fi
7621 1.1 riastrad continue
7622 1.1 riastrad ;;
7623 1.1 riastrad -l*)
7624 1.1 riastrad if test lib != "$linkmode" && test prog != "$linkmode"; then
7625 1.1 riastrad func_warning "'-l' is ignored for archives/objects"
7626 1.1 riastrad continue
7627 1.1 riastrad fi
7628 1.1 riastrad func_stripname '-l' '' "$deplib"
7629 1.1 riastrad name=$func_stripname_result
7630 1.1 riastrad if test lib = "$linkmode"; then
7631 1.1 riastrad searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7632 1.1 riastrad else
7633 1.1 riastrad searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7634 1.1 riastrad fi
7635 1.1 riastrad for searchdir in $searchdirs; do
7636 1.1 riastrad for search_ext in .la $std_shrext .so .a; do
7637 1.1 riastrad # Search the libtool library
7638 1.1 riastrad lib=$searchdir/lib$name$search_ext
7639 1.1 riastrad if test -f "$lib"; then
7640 1.1 riastrad if test .la = "$search_ext"; then
7641 1.1 riastrad found=:
7642 1.1 riastrad else
7643 1.1 riastrad found=false
7644 1.1 riastrad fi
7645 1.1 riastrad break 2
7646 1.1 riastrad fi
7647 1.1 riastrad done
7648 1.1 riastrad done
7649 1.1 riastrad if $found; then
7650 1.1 riastrad # deplib is a libtool library
7651 1.1 riastrad # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7652 1.1 riastrad # We need to do some special things here, and not later.
7653 1.1 riastrad if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7654 1.1 riastrad case " $predeps $postdeps " in
7655 1.1 riastrad *" $deplib "*)
7656 1.1 riastrad if func_lalib_p "$lib"; then
7657 1.1 riastrad library_names=
7658 1.1 riastrad old_library=
7659 1.1 riastrad func_source "$lib"
7660 1.1 riastrad for l in $old_library $library_names; do
7661 1.1 riastrad ll=$l
7662 1.1 riastrad done
7663 1.1 riastrad if test "X$ll" = "X$old_library"; then # only static version available
7664 1.1 riastrad found=false
7665 1.1 riastrad func_dirname "$lib" "" "."
7666 1.1 riastrad ladir=$func_dirname_result
7667 1.1 riastrad lib=$ladir/$old_library
7668 1.1 riastrad if test prog,link = "$linkmode,$pass"; then
7669 1.1 riastrad compile_deplibs="$deplib $compile_deplibs"
7670 1.1 riastrad finalize_deplibs="$deplib $finalize_deplibs"
7671 1.1 riastrad else
7672 1.1 riastrad deplibs="$deplib $deplibs"
7673 1.1 riastrad test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7674 1.1 riastrad fi
7675 1.1 riastrad continue
7676 1.1 riastrad fi
7677 1.1 riastrad fi
7678 1.1 riastrad ;;
7679 1.1 riastrad *) ;;
7680 1.1 riastrad esac
7681 1.1 riastrad fi
7682 1.1 riastrad else
7683 1.1 riastrad # deplib doesn't seem to be a libtool library
7684 1.1 riastrad if test prog,link = "$linkmode,$pass"; then
7685 1.1 riastrad compile_deplibs="$deplib $compile_deplibs"
7686 1.1 riastrad finalize_deplibs="$deplib $finalize_deplibs"
7687 1.1 riastrad else
7688 1.1 riastrad deplibs="$deplib $deplibs"
7689 1.1 riastrad test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7690 1.1 riastrad fi
7691 1.1 riastrad continue
7692 1.1 riastrad fi
7693 1.1 riastrad ;; # -l
7694 1.1 riastrad *.ltframework)
7695 1.1 riastrad if test prog,link = "$linkmode,$pass"; then
7696 1.1 riastrad compile_deplibs="$deplib $compile_deplibs"
7697 1.1 riastrad finalize_deplibs="$deplib $finalize_deplibs"
7698 1.1 riastrad else
7699 1.1 riastrad deplibs="$deplib $deplibs"
7700 1.1 riastrad if test lib = "$linkmode"; then
7701 1.1 riastrad case "$new_inherited_linker_flags " in
7702 1.1 riastrad *" $deplib "*) ;;
7703 1.1 riastrad * ) func_append new_inherited_linker_flags " $deplib" ;;
7704 1.1 riastrad esac
7705 1.1 riastrad fi
7706 1.1 riastrad fi
7707 1.1 riastrad continue
7708 1.1 riastrad ;;
7709 1.1 riastrad -L*)
7710 1.1 riastrad case $linkmode in
7711 1.1 riastrad lib)
7712 1.1 riastrad deplibs="$deplib $deplibs"
7713 1.1 riastrad test conv = "$pass" && continue
7714 1.1 riastrad newdependency_libs="$deplib $newdependency_libs"
7715 1.1 riastrad func_stripname '-L' '' "$deplib"
7716 1.1 riastrad func_resolve_sysroot "$func_stripname_result"
7717 1.1 riastrad func_append newlib_search_path " $func_resolve_sysroot_result"
7718 1.1 riastrad ;;
7719 1.1 riastrad prog)
7720 1.1 riastrad if test conv = "$pass"; then
7721 1.1 riastrad deplibs="$deplib $deplibs"
7722 1.1 riastrad continue
7723 1.1 riastrad fi
7724 1.1 riastrad if test scan = "$pass"; then
7725 1.1 riastrad deplibs="$deplib $deplibs"
7726 1.1 riastrad else
7727 1.1 riastrad compile_deplibs="$deplib $compile_deplibs"
7728 1.1 riastrad finalize_deplibs="$deplib $finalize_deplibs"
7729 1.1 riastrad fi
7730 1.1 riastrad func_stripname '-L' '' "$deplib"
7731 1.1 riastrad func_resolve_sysroot "$func_stripname_result"
7732 1.1 riastrad func_append newlib_search_path " $func_resolve_sysroot_result"
7733 1.1 riastrad ;;
7734 1.1 riastrad *)
7735 1.1 riastrad func_warning "'-L' is ignored for archives/objects"
7736 1.1 riastrad ;;
7737 1.1 riastrad esac # linkmode
7738 1.1 riastrad continue
7739 1.1 riastrad ;; # -L
7740 1.1 riastrad -R*)
7741 1.1 riastrad if test link = "$pass"; then
7742 1.1 riastrad func_stripname '-R' '' "$deplib"
7743 1.1 riastrad func_resolve_sysroot "$func_stripname_result"
7744 1.1 riastrad dir=$func_resolve_sysroot_result
7745 1.1 riastrad # Make sure the xrpath contains only unique directories.
7746 1.1 riastrad case "$xrpath " in
7747 1.1 riastrad *" $dir "*) ;;
7748 1.1 riastrad *) func_append xrpath " $dir" ;;
7749 1.1 riastrad esac
7750 1.1 riastrad fi
7751 1.1 riastrad deplibs="$deplib $deplibs"
7752 1.1 riastrad continue
7753 1.1 riastrad ;;
7754 1.1 riastrad *.la)
7755 1.1 riastrad func_resolve_sysroot "$deplib"
7756 1.1 riastrad lib=$func_resolve_sysroot_result
7757 1.1 riastrad ;;
7758 1.1 riastrad *.$libext)
7759 1.1 riastrad if test conv = "$pass"; then
7760 1.1 riastrad deplibs="$deplib $deplibs"
7761 1.1 riastrad continue
7762 1.1 riastrad fi
7763 1.1 riastrad case $linkmode in
7764 1.1 riastrad lib)
7765 1.1 riastrad # Linking convenience modules into shared libraries is allowed,
7766 1.1 riastrad # but linking other static libraries is non-portable.
7767 1.1 riastrad case " $dlpreconveniencelibs " in
7768 1.1 riastrad *" $deplib "*) ;;
7769 1.1 riastrad *)
7770 1.1 riastrad valid_a_lib=false
7771 1.1 riastrad case $deplibs_check_method in
7772 1.1 riastrad match_pattern*)
7773 1.1 riastrad set dummy $deplibs_check_method; shift
7774 1.1 riastrad match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7775 1.1 riastrad if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7776 1.1 riastrad | $EGREP "$match_pattern_regex" > /dev/null; then
7777 1.1 riastrad valid_a_lib=:
7778 1.1 riastrad fi
7779 1.1 riastrad ;;
7780 1.1 riastrad pass_all)
7781 1.1 riastrad valid_a_lib=:
7782 1.1 riastrad ;;
7783 1.1 riastrad esac
7784 1.1 riastrad if $valid_a_lib; then
7785 1.1 riastrad echo
7786 1.1 riastrad $ECHO "*** Warning: Linking the shared library $output against the"
7787 1.1 riastrad $ECHO "*** static library $deplib is not portable!"
7788 1.1 riastrad deplibs="$deplib $deplibs"
7789 1.1 riastrad else
7790 1.1 riastrad echo
7791 1.1 riastrad $ECHO "*** Warning: Trying to link with static lib archive $deplib."
7792 1.1 riastrad echo "*** I have the capability to make that library automatically link in when"
7793 1.1 riastrad echo "*** you link to this library. But I can only do this if you have a"
7794 1.1 riastrad echo "*** shared version of the library, which you do not appear to have"
7795 1.1 riastrad echo "*** because the file extensions .$libext of this argument makes me believe"
7796 1.1 riastrad echo "*** that it is just a static archive that I should not use here."
7797 1.1 riastrad fi
7798 1.1 riastrad ;;
7799 1.1 riastrad esac
7800 1.1 riastrad continue
7801 1.1 riastrad ;;
7802 1.1 riastrad prog)
7803 1.1 riastrad if test link != "$pass"; then
7804 1.1 riastrad deplibs="$deplib $deplibs"
7805 1.1 riastrad else
7806 1.1 riastrad compile_deplibs="$deplib $compile_deplibs"
7807 1.1 riastrad finalize_deplibs="$deplib $finalize_deplibs"
7808 1.1 riastrad fi
7809 1.1 riastrad continue
7810 1.1 riastrad ;;
7811 1.1 riastrad esac # linkmode
7812 1.1 riastrad ;; # *.$libext
7813 1.1 riastrad *.lo | *.$objext)
7814 1.1 riastrad if test conv = "$pass"; then
7815 1.1 riastrad deplibs="$deplib $deplibs"
7816 1.1 riastrad elif test prog = "$linkmode"; then
7817 1.1 riastrad if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7818 1.1 riastrad # If there is no dlopen support or we're linking statically,
7819 1.1 riastrad # we need to preload.
7820 1.1 riastrad func_append newdlprefiles " $deplib"
7821 1.1 riastrad compile_deplibs="$deplib $compile_deplibs"
7822 1.1 riastrad finalize_deplibs="$deplib $finalize_deplibs"
7823 1.1 riastrad else
7824 1.1 riastrad func_append newdlfiles " $deplib"
7825 1.1 riastrad fi
7826 1.1 riastrad fi
7827 1.1 riastrad continue
7828 1.1 riastrad ;;
7829 1.1 riastrad %DEPLIBS%)
7830 1.1 riastrad alldeplibs=:
7831 1.1 riastrad continue
7832 1.1 riastrad ;;
7833 1.1 riastrad esac # case $deplib
7834 1.1 riastrad
7835 1.1 riastrad $found || test -f "$lib" \
7836 1.1 riastrad || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7837 1.1 riastrad
7838 1.1 riastrad # Check to see that this really is a libtool archive.
7839 1.1 riastrad func_lalib_unsafe_p "$lib" \
7840 1.1 riastrad || func_fatal_error "'$lib' is not a valid libtool archive"
7841 1.1 riastrad
7842 1.1 riastrad func_dirname "$lib" "" "."
7843 1.1 riastrad ladir=$func_dirname_result
7844 1.1 riastrad
7845 1.1 riastrad dlname=
7846 1.1 riastrad dlopen=
7847 1.1 riastrad dlpreopen=
7848 1.1 riastrad libdir=
7849 1.1 riastrad library_names=
7850 1.1 riastrad old_library=
7851 1.1 riastrad inherited_linker_flags=
7852 1.1 riastrad # If the library was installed with an old release of libtool,
7853 1.1 riastrad # it will not redefine variables installed, or shouldnotlink
7854 1.1 riastrad installed=yes
7855 1.1 riastrad shouldnotlink=no
7856 1.1 riastrad avoidtemprpath=
7857 1.1 riastrad
7858 1.1 riastrad
7859 1.1 riastrad # Read the .la file
7860 1.1 riastrad func_source "$lib"
7861 1.1 riastrad
7862 1.1 riastrad # Convert "-framework foo" to "foo.ltframework"
7863 1.1 riastrad if test -n "$inherited_linker_flags"; then
7864 1.1 riastrad tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7865 1.1 riastrad for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7866 1.1 riastrad case " $new_inherited_linker_flags " in
7867 1.1 riastrad *" $tmp_inherited_linker_flag "*) ;;
7868 1.1 riastrad *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7869 1.1 riastrad esac
7870 1.1 riastrad done
7871 1.1 riastrad fi
7872 1.1 riastrad dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7873 1.1 riastrad if test lib,link = "$linkmode,$pass" ||
7874 1.1 riastrad test prog,scan = "$linkmode,$pass" ||
7875 1.1 riastrad { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7876 1.1 riastrad test -n "$dlopen" && func_append dlfiles " $dlopen"
7877 1.1 riastrad test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7878 1.1 riastrad fi
7879 1.1 riastrad
7880 1.1 riastrad if test conv = "$pass"; then
7881 1.1 riastrad # Only check for convenience libraries
7882 1.1 riastrad deplibs="$lib $deplibs"
7883 1.1 riastrad if test -z "$libdir"; then
7884 1.1 riastrad if test -z "$old_library"; then
7885 1.1 riastrad func_fatal_error "cannot find name of link library for '$lib'"
7886 1.1 riastrad fi
7887 1.1 riastrad # It is a libtool convenience library, so add in its objects.
7888 1.1 riastrad func_append convenience " $ladir/$objdir/$old_library"
7889 1.1 riastrad func_append old_convenience " $ladir/$objdir/$old_library"
7890 1.1 riastrad elif test prog != "$linkmode" && test lib != "$linkmode"; then
7891 1.1 riastrad func_fatal_error "'$lib' is not a convenience library"
7892 1.1 riastrad fi
7893 1.1 riastrad tmp_libs=
7894 1.1 riastrad for deplib in $dependency_libs; do
7895 1.1 riastrad deplibs="$deplib $deplibs"
7896 1.1 riastrad if $opt_preserve_dup_deps; then
7897 1.1 riastrad case "$tmp_libs " in
7898 1.1 riastrad *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7899 1.1 riastrad esac
7900 1.1 riastrad fi
7901 1.1 riastrad func_append tmp_libs " $deplib"
7902 1.1 riastrad done
7903 1.1 riastrad continue
7904 1.1 riastrad fi # $pass = conv
7905 1.1 riastrad
7906 1.1 riastrad
7907 1.1 riastrad # Get the name of the library we link against.
7908 1.1 riastrad linklib=
7909 1.1 riastrad if test -n "$old_library" &&
7910 1.1 riastrad { test yes = "$prefer_static_libs" ||
7911 1.1 riastrad test built,no = "$prefer_static_libs,$installed"; }; then
7912 1.1 riastrad linklib=$old_library
7913 1.1 riastrad else
7914 1.1 riastrad for l in $old_library $library_names; do
7915 1.1 riastrad linklib=$l
7916 1.1 riastrad done
7917 1.1 riastrad fi
7918 1.1 riastrad if test -z "$linklib"; then
7919 1.1 riastrad func_fatal_error "cannot find name of link library for '$lib'"
7920 1.1 riastrad fi
7921 1.1 riastrad
7922 1.1 riastrad # This library was specified with -dlopen.
7923 1.1 riastrad if test dlopen = "$pass"; then
7924 1.1 riastrad test -z "$libdir" \
7925 1.1 riastrad && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7926 1.1 riastrad if test -z "$dlname" ||
7927 1.1 riastrad test yes != "$dlopen_support" ||
7928 1.1 riastrad test no = "$build_libtool_libs"
7929 1.1 riastrad then
7930 1.1 riastrad # If there is no dlname, no dlopen support or we're linking
7931 1.1 riastrad # statically, we need to preload. We also need to preload any
7932 1.1 riastrad # dependent libraries so libltdl's deplib preloader doesn't
7933 1.1 riastrad # bomb out in the load deplibs phase.
7934 1.1 riastrad func_append dlprefiles " $lib $dependency_libs"
7935 1.1 riastrad else
7936 1.1 riastrad func_append newdlfiles " $lib"
7937 1.1 riastrad fi
7938 1.1 riastrad continue
7939 1.1 riastrad fi # $pass = dlopen
7940 1.1 riastrad
7941 1.1 riastrad # We need an absolute path.
7942 1.1 riastrad case $ladir in
7943 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7944 1.1 riastrad *)
7945 1.1 riastrad abs_ladir=`cd "$ladir" && pwd`
7946 1.1 riastrad if test -z "$abs_ladir"; then
7947 1.1 riastrad func_warning "cannot determine absolute directory name of '$ladir'"
7948 1.1 riastrad func_warning "passing it literally to the linker, although it might fail"
7949 1.1 riastrad abs_ladir=$ladir
7950 1.1 riastrad fi
7951 1.1 riastrad ;;
7952 1.1 riastrad esac
7953 1.1 riastrad func_basename "$lib"
7954 1.1 riastrad laname=$func_basename_result
7955 1.1 riastrad
7956 1.1 riastrad # Find the relevant object directory and library name.
7957 1.1 riastrad if test yes = "$installed"; then
7958 1.1 riastrad if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7959 1.1 riastrad func_warning "library '$lib' was moved."
7960 1.1 riastrad dir=$ladir
7961 1.1 riastrad absdir=$abs_ladir
7962 1.1 riastrad libdir=$abs_ladir
7963 1.1 riastrad else
7964 1.1 riastrad dir=$lt_sysroot$libdir
7965 1.1 riastrad absdir=$lt_sysroot$libdir
7966 1.1 riastrad fi
7967 1.1 riastrad test yes = "$hardcode_automatic" && avoidtemprpath=yes
7968 1.1 riastrad else
7969 1.1 riastrad if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7970 1.1 riastrad dir=$ladir
7971 1.1 riastrad absdir=$abs_ladir
7972 1.1 riastrad # Remove this search path later
7973 1.1 riastrad func_append notinst_path " $abs_ladir"
7974 1.1 riastrad else
7975 1.1 riastrad dir=$ladir/$objdir
7976 1.1 riastrad absdir=$abs_ladir/$objdir
7977 1.1 riastrad # Remove this search path later
7978 1.1 riastrad func_append notinst_path " $abs_ladir"
7979 1.1 riastrad fi
7980 1.1 riastrad fi # $installed = yes
7981 1.1 riastrad func_stripname 'lib' '.la' "$laname"
7982 1.1 riastrad name=$func_stripname_result
7983 1.1 riastrad
7984 1.1 riastrad # This library was specified with -dlpreopen.
7985 1.1 riastrad if test dlpreopen = "$pass"; then
7986 1.1 riastrad if test -z "$libdir" && test prog = "$linkmode"; then
7987 1.1 riastrad func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7988 1.1 riastrad fi
7989 1.1 riastrad case $host in
7990 1.1 riastrad # special handling for platforms with PE-DLLs.
7991 1.1 riastrad *cygwin* | *mingw* | *cegcc* )
7992 1.1 riastrad # Linker will automatically link against shared library if both
7993 1.1 riastrad # static and shared are present. Therefore, ensure we extract
7994 1.1 riastrad # symbols from the import library if a shared library is present
7995 1.1 riastrad # (otherwise, the dlopen module name will be incorrect). We do
7996 1.1 riastrad # this by putting the import library name into $newdlprefiles.
7997 1.1 riastrad # We recover the dlopen module name by 'saving' the la file
7998 1.1 riastrad # name in a special purpose variable, and (later) extracting the
7999 1.1 riastrad # dlname from the la file.
8000 1.1 riastrad if test -n "$dlname"; then
8001 1.1 riastrad func_tr_sh "$dir/$linklib"
8002 1.1 riastrad eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8003 1.1 riastrad func_append newdlprefiles " $dir/$linklib"
8004 1.1 riastrad else
8005 1.1 riastrad func_append newdlprefiles " $dir/$old_library"
8006 1.1 riastrad # Keep a list of preopened convenience libraries to check
8007 1.1 riastrad # that they are being used correctly in the link pass.
8008 1.1 riastrad test -z "$libdir" && \
8009 1.1 riastrad func_append dlpreconveniencelibs " $dir/$old_library"
8010 1.1 riastrad fi
8011 1.1 riastrad ;;
8012 1.1 riastrad * )
8013 1.1 riastrad # Prefer using a static library (so that no silly _DYNAMIC symbols
8014 1.1 riastrad # are required to link).
8015 1.1 riastrad if test -n "$old_library"; then
8016 1.1 riastrad func_append newdlprefiles " $dir/$old_library"
8017 1.1 riastrad # Keep a list of preopened convenience libraries to check
8018 1.1 riastrad # that they are being used correctly in the link pass.
8019 1.1 riastrad test -z "$libdir" && \
8020 1.1 riastrad func_append dlpreconveniencelibs " $dir/$old_library"
8021 1.1 riastrad # Otherwise, use the dlname, so that lt_dlopen finds it.
8022 1.1 riastrad elif test -n "$dlname"; then
8023 1.1 riastrad func_append newdlprefiles " $dir/$dlname"
8024 1.1 riastrad else
8025 1.1 riastrad func_append newdlprefiles " $dir/$linklib"
8026 1.1 riastrad fi
8027 1.1 riastrad ;;
8028 1.1 riastrad esac
8029 1.1 riastrad fi # $pass = dlpreopen
8030 1.1 riastrad
8031 1.1 riastrad if test -z "$libdir"; then
8032 1.1 riastrad # Link the convenience library
8033 1.1 riastrad if test lib = "$linkmode"; then
8034 1.1 riastrad deplibs="$dir/$old_library $deplibs"
8035 1.1 riastrad elif test prog,link = "$linkmode,$pass"; then
8036 1.1 riastrad compile_deplibs="$dir/$old_library $compile_deplibs"
8037 1.1 riastrad finalize_deplibs="$dir/$old_library $finalize_deplibs"
8038 1.1 riastrad else
8039 1.1 riastrad deplibs="$lib $deplibs" # used for prog,scan pass
8040 1.1 riastrad fi
8041 1.1 riastrad continue
8042 1.1 riastrad fi
8043 1.1 riastrad
8044 1.1 riastrad
8045 1.1 riastrad if test prog = "$linkmode" && test link != "$pass"; then
8046 1.1 riastrad func_append newlib_search_path " $ladir"
8047 1.1 riastrad deplibs="$lib $deplibs"
8048 1.1 riastrad
8049 1.1 riastrad linkalldeplibs=false
8050 1.1 riastrad if test no != "$link_all_deplibs" || test -z "$library_names" ||
8051 1.1 riastrad test no = "$build_libtool_libs"; then
8052 1.1 riastrad linkalldeplibs=:
8053 1.1 riastrad fi
8054 1.1 riastrad
8055 1.1 riastrad tmp_libs=
8056 1.1 riastrad for deplib in $dependency_libs; do
8057 1.1 riastrad case $deplib in
8058 1.1 riastrad -L*) func_stripname '-L' '' "$deplib"
8059 1.1 riastrad func_resolve_sysroot "$func_stripname_result"
8060 1.1 riastrad func_append newlib_search_path " $func_resolve_sysroot_result"
8061 1.1 riastrad ;;
8062 1.1 riastrad esac
8063 1.1 riastrad # Need to link against all dependency_libs?
8064 1.1 riastrad if $linkalldeplibs; then
8065 1.1 riastrad deplibs="$deplib $deplibs"
8066 1.1 riastrad else
8067 1.1 riastrad # Need to hardcode shared library paths
8068 1.1 riastrad # or/and link against static libraries
8069 1.1 riastrad newdependency_libs="$deplib $newdependency_libs"
8070 1.1 riastrad fi
8071 1.1 riastrad if $opt_preserve_dup_deps; then
8072 1.1 riastrad case "$tmp_libs " in
8073 1.1 riastrad *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8074 1.1 riastrad esac
8075 1.1 riastrad fi
8076 1.1 riastrad func_append tmp_libs " $deplib"
8077 1.1 riastrad done # for deplib
8078 1.1 riastrad continue
8079 1.1 riastrad fi # $linkmode = prog...
8080 1.1 riastrad
8081 1.1 riastrad if test prog,link = "$linkmode,$pass"; then
8082 1.1 riastrad if test -n "$library_names" &&
8083 1.1 riastrad { { test no = "$prefer_static_libs" ||
8084 1.1 riastrad test built,yes = "$prefer_static_libs,$installed"; } ||
8085 1.1 riastrad test -z "$old_library"; }; then
8086 1.1 riastrad # We need to hardcode the library path
8087 1.1 riastrad if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8088 1.1 riastrad # Make sure the rpath contains only unique directories.
8089 1.1 riastrad case $temp_rpath: in
8090 1.1 riastrad *"$absdir:"*) ;;
8091 1.1 riastrad *) func_append temp_rpath "$absdir:" ;;
8092 1.1 riastrad esac
8093 1.1 riastrad fi
8094 1.1 riastrad
8095 1.1 riastrad # Hardcode the library path.
8096 1.1 riastrad # Skip directories that are in the system default run-time
8097 1.1 riastrad # search path.
8098 1.1 riastrad case " $sys_lib_dlsearch_path " in
8099 1.1 riastrad *" $absdir "*) ;;
8100 1.1 riastrad *)
8101 1.1 riastrad case "$compile_rpath " in
8102 1.1 riastrad *" $absdir "*) ;;
8103 1.1 riastrad *) func_append compile_rpath " $absdir" ;;
8104 1.1 riastrad esac
8105 1.1 riastrad ;;
8106 1.1 riastrad esac
8107 1.1 riastrad case " $sys_lib_dlsearch_path " in
8108 1.1 riastrad *" $libdir "*) ;;
8109 1.1 riastrad *)
8110 1.1 riastrad case "$finalize_rpath " in
8111 1.1 riastrad *" $libdir "*) ;;
8112 1.1 riastrad *) func_append finalize_rpath " $libdir" ;;
8113 1.1 riastrad esac
8114 1.1 riastrad ;;
8115 1.1 riastrad esac
8116 1.1 riastrad fi # $linkmode,$pass = prog,link...
8117 1.1 riastrad
8118 1.1 riastrad if $alldeplibs &&
8119 1.1 riastrad { test pass_all = "$deplibs_check_method" ||
8120 1.1 riastrad { test yes = "$build_libtool_libs" &&
8121 1.1 riastrad test -n "$library_names"; }; }; then
8122 1.1 riastrad # We only need to search for static libraries
8123 1.1 riastrad continue
8124 1.1 riastrad fi
8125 1.1 riastrad fi
8126 1.1 riastrad
8127 1.1 riastrad link_static=no # Whether the deplib will be linked statically
8128 1.1 riastrad use_static_libs=$prefer_static_libs
8129 1.1 riastrad if test built = "$use_static_libs" && test yes = "$installed"; then
8130 1.1 riastrad use_static_libs=no
8131 1.1 riastrad fi
8132 1.1 riastrad if test -n "$library_names" &&
8133 1.1 riastrad { test no = "$use_static_libs" || test -z "$old_library"; }; then
8134 1.1 riastrad case $host in
8135 1.1 riastrad *cygwin* | *mingw* | *cegcc* | *os2*)
8136 1.1 riastrad # No point in relinking DLLs because paths are not encoded
8137 1.1 riastrad func_append notinst_deplibs " $lib"
8138 1.1 riastrad need_relink=no
8139 1.1 riastrad ;;
8140 1.1 riastrad *)
8141 1.1 riastrad if test no = "$installed"; then
8142 1.1 riastrad func_append notinst_deplibs " $lib"
8143 1.1 riastrad need_relink=yes
8144 1.1 riastrad fi
8145 1.1 riastrad ;;
8146 1.1 riastrad esac
8147 1.1 riastrad # This is a shared library
8148 1.1 riastrad
8149 1.1 riastrad # Warn about portability, can't link against -module's on some
8150 1.1 riastrad # systems (darwin). Don't bleat about dlopened modules though!
8151 1.1 riastrad dlopenmodule=
8152 1.1 riastrad for dlpremoduletest in $dlprefiles; do
8153 1.1 riastrad if test "X$dlpremoduletest" = "X$lib"; then
8154 1.1 riastrad dlopenmodule=$dlpremoduletest
8155 1.1 riastrad break
8156 1.1 riastrad fi
8157 1.1 riastrad done
8158 1.1 riastrad if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8159 1.1 riastrad echo
8160 1.1 riastrad if test prog = "$linkmode"; then
8161 1.1 riastrad $ECHO "*** Warning: Linking the executable $output against the loadable module"
8162 1.1 riastrad else
8163 1.1 riastrad $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8164 1.1 riastrad fi
8165 1.1 riastrad $ECHO "*** $linklib is not portable!"
8166 1.1 riastrad fi
8167 1.1 riastrad if test lib = "$linkmode" &&
8168 1.1 riastrad test yes = "$hardcode_into_libs"; then
8169 1.1 riastrad # Hardcode the library path.
8170 1.1 riastrad # Skip directories that are in the system default run-time
8171 1.1 riastrad # search path.
8172 1.1 riastrad case " $sys_lib_dlsearch_path " in
8173 1.1 riastrad *" $absdir "*) ;;
8174 1.1 riastrad *)
8175 1.1 riastrad case "$compile_rpath " in
8176 1.1 riastrad *" $absdir "*) ;;
8177 1.1 riastrad *) func_append compile_rpath " $absdir" ;;
8178 1.1 riastrad esac
8179 1.1 riastrad ;;
8180 1.1 riastrad esac
8181 1.1 riastrad case " $sys_lib_dlsearch_path " in
8182 1.1 riastrad *" $libdir "*) ;;
8183 1.1 riastrad *)
8184 1.1 riastrad case "$finalize_rpath " in
8185 1.1 riastrad *" $libdir "*) ;;
8186 1.1 riastrad *) func_append finalize_rpath " $libdir" ;;
8187 1.1 riastrad esac
8188 1.1 riastrad ;;
8189 1.1 riastrad esac
8190 1.1 riastrad fi
8191 1.1 riastrad
8192 1.1 riastrad if test -n "$old_archive_from_expsyms_cmds"; then
8193 1.1 riastrad # figure out the soname
8194 1.1 riastrad set dummy $library_names
8195 1.1 riastrad shift
8196 1.1 riastrad realname=$1
8197 1.1 riastrad shift
8198 1.1 riastrad libname=`eval "\\$ECHO \"$libname_spec\""`
8199 1.1 riastrad # use dlname if we got it. it's perfectly good, no?
8200 1.1 riastrad if test -n "$dlname"; then
8201 1.1 riastrad soname=$dlname
8202 1.1 riastrad elif test -n "$soname_spec"; then
8203 1.1 riastrad # bleh windows
8204 1.1 riastrad case $host in
8205 1.1 riastrad *cygwin* | mingw* | *cegcc* | *os2*)
8206 1.1 riastrad func_arith $current - $age
8207 1.1 riastrad major=$func_arith_result
8208 1.1 riastrad versuffix=-$major
8209 1.1 riastrad ;;
8210 1.1 riastrad esac
8211 1.1 riastrad eval soname=\"$soname_spec\"
8212 1.1 riastrad else
8213 1.1 riastrad soname=$realname
8214 1.1 riastrad fi
8215 1.1 riastrad
8216 1.1 riastrad # Make a new name for the extract_expsyms_cmds to use
8217 1.1 riastrad soroot=$soname
8218 1.1 riastrad func_basename "$soroot"
8219 1.1 riastrad soname=$func_basename_result
8220 1.1 riastrad func_stripname 'lib' '.dll' "$soname"
8221 1.1 riastrad newlib=libimp-$func_stripname_result.a
8222 1.1 riastrad
8223 1.1 riastrad # If the library has no export list, then create one now
8224 1.1 riastrad if test -f "$output_objdir/$soname-def"; then :
8225 1.1 riastrad else
8226 1.1 riastrad func_verbose "extracting exported symbol list from '$soname'"
8227 1.1 riastrad func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8228 1.1 riastrad fi
8229 1.1 riastrad
8230 1.1 riastrad # Create $newlib
8231 1.1 riastrad if test -f "$output_objdir/$newlib"; then :; else
8232 1.1 riastrad func_verbose "generating import library for '$soname'"
8233 1.1 riastrad func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8234 1.1 riastrad fi
8235 1.1 riastrad # make sure the library variables are pointing to the new library
8236 1.1 riastrad dir=$output_objdir
8237 1.1 riastrad linklib=$newlib
8238 1.1 riastrad fi # test -n "$old_archive_from_expsyms_cmds"
8239 1.1 riastrad
8240 1.1 riastrad if test prog = "$linkmode" || test relink != "$opt_mode"; then
8241 1.1 riastrad add_shlibpath=
8242 1.1 riastrad add_dir=
8243 1.1 riastrad add=
8244 1.1 riastrad lib_linked=yes
8245 1.1 riastrad case $hardcode_action in
8246 1.1 riastrad immediate | unsupported)
8247 1.1 riastrad if test no = "$hardcode_direct"; then
8248 1.1 riastrad add=$dir/$linklib
8249 1.1 riastrad case $host in
8250 1.1 riastrad *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8251 1.1 riastrad *-*-sysv4*uw2*) add_dir=-L$dir ;;
8252 1.1 riastrad *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8253 1.1 riastrad *-*-unixware7*) add_dir=-L$dir ;;
8254 1.1 riastrad *-*-darwin* )
8255 1.1 riastrad # if the lib is a (non-dlopened) module then we cannot
8256 1.1 riastrad # link against it, someone is ignoring the earlier warnings
8257 1.1 riastrad if /usr/bin/file -L $add 2> /dev/null |
8258 1.1 riastrad $GREP ": [^:]* bundle" >/dev/null; then
8259 1.1 riastrad if test "X$dlopenmodule" != "X$lib"; then
8260 1.1 riastrad $ECHO "*** Warning: lib $linklib is a module, not a shared library"
8261 1.1 riastrad if test -z "$old_library"; then
8262 1.1 riastrad echo
8263 1.1 riastrad echo "*** And there doesn't seem to be a static archive available"
8264 1.1 riastrad echo "*** The link will probably fail, sorry"
8265 1.1 riastrad else
8266 1.1 riastrad add=$dir/$old_library
8267 1.1 riastrad fi
8268 1.1 riastrad elif test -n "$old_library"; then
8269 1.1 riastrad add=$dir/$old_library
8270 1.1 riastrad fi
8271 1.1 riastrad fi
8272 1.1 riastrad esac
8273 1.1 riastrad elif test no = "$hardcode_minus_L"; then
8274 1.1 riastrad case $host in
8275 1.1 riastrad *-*-sunos*) add_shlibpath=$dir ;;
8276 1.1 riastrad esac
8277 1.1 riastrad add_dir=-L$dir
8278 1.1 riastrad add=-l$name
8279 1.1 riastrad elif test no = "$hardcode_shlibpath_var"; then
8280 1.1 riastrad add_shlibpath=$dir
8281 1.1 riastrad add=-l$name
8282 1.1 riastrad else
8283 1.1 riastrad lib_linked=no
8284 1.1 riastrad fi
8285 1.1 riastrad ;;
8286 1.1 riastrad relink)
8287 1.1 riastrad if test yes = "$hardcode_direct" &&
8288 1.1 riastrad test no = "$hardcode_direct_absolute"; then
8289 1.1 riastrad add=$dir/$linklib
8290 1.1 riastrad elif test yes = "$hardcode_minus_L"; then
8291 1.1 riastrad add_dir=-L$absdir
8292 1.1 riastrad # Try looking first in the location we're being installed to.
8293 1.1 riastrad if test -n "$inst_prefix_dir"; then
8294 1.1 riastrad case $libdir in
8295 1.1 riastrad [\\/]*)
8296 1.1 riastrad func_append add_dir " -L$inst_prefix_dir$libdir"
8297 1.1 riastrad ;;
8298 1.1 riastrad esac
8299 1.1 riastrad fi
8300 1.1 riastrad add=-l$name
8301 1.1 riastrad elif test yes = "$hardcode_shlibpath_var"; then
8302 1.1 riastrad add_shlibpath=$dir
8303 1.1 riastrad add=-l$name
8304 1.1 riastrad else
8305 1.1 riastrad lib_linked=no
8306 1.1 riastrad fi
8307 1.1 riastrad ;;
8308 1.1 riastrad *) lib_linked=no ;;
8309 1.1 riastrad esac
8310 1.1 riastrad
8311 1.1 riastrad if test yes != "$lib_linked"; then
8312 1.1 riastrad func_fatal_configuration "unsupported hardcode properties"
8313 1.1 riastrad fi
8314 1.1 riastrad
8315 1.1 riastrad if test -n "$add_shlibpath"; then
8316 1.1 riastrad case :$compile_shlibpath: in
8317 1.1 riastrad *":$add_shlibpath:"*) ;;
8318 1.1 riastrad *) func_append compile_shlibpath "$add_shlibpath:" ;;
8319 1.1 riastrad esac
8320 1.1 riastrad fi
8321 1.1 riastrad if test prog = "$linkmode"; then
8322 1.1 riastrad test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8323 1.1 riastrad test -n "$add" && compile_deplibs="$add $compile_deplibs"
8324 1.1 riastrad else
8325 1.1 riastrad test -n "$add_dir" && deplibs="$add_dir $deplibs"
8326 1.1 riastrad test -n "$add" && deplibs="$add $deplibs"
8327 1.1 riastrad if test yes != "$hardcode_direct" &&
8328 1.1 riastrad test yes != "$hardcode_minus_L" &&
8329 1.1 riastrad test yes = "$hardcode_shlibpath_var"; then
8330 1.1 riastrad case :$finalize_shlibpath: in
8331 1.1 riastrad *":$libdir:"*) ;;
8332 1.1 riastrad *) func_append finalize_shlibpath "$libdir:" ;;
8333 1.1 riastrad esac
8334 1.1 riastrad fi
8335 1.1 riastrad fi
8336 1.1 riastrad fi
8337 1.1 riastrad
8338 1.1 riastrad if test prog = "$linkmode" || test relink = "$opt_mode"; then
8339 1.1 riastrad add_shlibpath=
8340 1.1 riastrad add_dir=
8341 1.1 riastrad add=
8342 1.1 riastrad # Finalize command for both is simple: just hardcode it.
8343 1.1 riastrad if test yes = "$hardcode_direct" &&
8344 1.1 riastrad test no = "$hardcode_direct_absolute"; then
8345 1.1 riastrad add=$libdir/$linklib
8346 1.1 riastrad elif test yes = "$hardcode_minus_L"; then
8347 1.1 riastrad add_dir=-L$libdir
8348 1.1 riastrad add=-l$name
8349 1.1 riastrad elif test yes = "$hardcode_shlibpath_var"; then
8350 1.1 riastrad case :$finalize_shlibpath: in
8351 1.1 riastrad *":$libdir:"*) ;;
8352 1.1 riastrad *) func_append finalize_shlibpath "$libdir:" ;;
8353 1.1 riastrad esac
8354 1.1 riastrad add=-l$name
8355 1.1 riastrad elif test yes = "$hardcode_automatic"; then
8356 1.1 riastrad if test -n "$inst_prefix_dir" &&
8357 1.1 riastrad test -f "$inst_prefix_dir$libdir/$linklib"; then
8358 1.1 riastrad add=$inst_prefix_dir$libdir/$linklib
8359 1.1 riastrad else
8360 1.1 riastrad add=$libdir/$linklib
8361 1.1 riastrad fi
8362 1.1 riastrad else
8363 1.1 riastrad # We cannot seem to hardcode it, guess we'll fake it.
8364 1.1 riastrad add_dir=-L$libdir
8365 1.1 riastrad # Try looking first in the location we're being installed to.
8366 1.1 riastrad if test -n "$inst_prefix_dir"; then
8367 1.1 riastrad case $libdir in
8368 1.1 riastrad [\\/]*)
8369 1.1 riastrad func_append add_dir " -L$inst_prefix_dir$libdir"
8370 1.1 riastrad ;;
8371 1.1 riastrad esac
8372 1.1 riastrad fi
8373 1.1 riastrad add=-l$name
8374 1.1 riastrad fi
8375 1.1 riastrad
8376 1.1 riastrad if test prog = "$linkmode"; then
8377 1.1 riastrad test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8378 1.1 riastrad test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8379 1.1 riastrad else
8380 1.1 riastrad test -n "$add_dir" && deplibs="$add_dir $deplibs"
8381 1.1 riastrad test -n "$add" && deplibs="$add $deplibs"
8382 1.1 riastrad fi
8383 1.1 riastrad fi
8384 1.1 riastrad elif test prog = "$linkmode"; then
8385 1.1 riastrad # Here we assume that one of hardcode_direct or hardcode_minus_L
8386 1.1 riastrad # is not unsupported. This is valid on all known static and
8387 1.1 riastrad # shared platforms.
8388 1.1 riastrad if test unsupported != "$hardcode_direct"; then
8389 1.1 riastrad test -n "$old_library" && linklib=$old_library
8390 1.1 riastrad compile_deplibs="$dir/$linklib $compile_deplibs"
8391 1.1 riastrad finalize_deplibs="$dir/$linklib $finalize_deplibs"
8392 1.1 riastrad else
8393 1.1 riastrad compile_deplibs="-l$name -L$dir $compile_deplibs"
8394 1.1 riastrad finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8395 1.1 riastrad fi
8396 1.1 riastrad elif test yes = "$build_libtool_libs"; then
8397 1.1 riastrad # Not a shared library
8398 1.1 riastrad if test pass_all != "$deplibs_check_method"; then
8399 1.1 riastrad # We're trying link a shared library against a static one
8400 1.1 riastrad # but the system doesn't support it.
8401 1.1 riastrad
8402 1.1 riastrad # Just print a warning and add the library to dependency_libs so
8403 1.1 riastrad # that the program can be linked against the static library.
8404 1.1 riastrad echo
8405 1.1 riastrad $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8406 1.1 riastrad echo "*** I have the capability to make that library automatically link in when"
8407 1.1 riastrad echo "*** you link to this library. But I can only do this if you have a"
8408 1.1 riastrad echo "*** shared version of the library, which you do not appear to have."
8409 1.1 riastrad if test yes = "$module"; then
8410 1.1 riastrad echo "*** But as you try to build a module library, libtool will still create "
8411 1.1 riastrad echo "*** a static module, that should work as long as the dlopening application"
8412 1.1 riastrad echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8413 1.1 riastrad if test -z "$global_symbol_pipe"; then
8414 1.1 riastrad echo
8415 1.1 riastrad echo "*** However, this would only work if libtool was able to extract symbol"
8416 1.1 riastrad echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8417 1.1 riastrad echo "*** not find such a program. So, this module is probably useless."
8418 1.1 riastrad echo "*** 'nm' from GNU binutils and a full rebuild may help."
8419 1.1 riastrad fi
8420 1.1 riastrad if test no = "$build_old_libs"; then
8421 1.1 riastrad build_libtool_libs=module
8422 1.1 riastrad build_old_libs=yes
8423 1.1 riastrad else
8424 1.1 riastrad build_libtool_libs=no
8425 1.1 riastrad fi
8426 1.1 riastrad fi
8427 1.1 riastrad else
8428 1.1 riastrad deplibs="$dir/$old_library $deplibs"
8429 1.1 riastrad link_static=yes
8430 1.1 riastrad fi
8431 1.1 riastrad fi # link shared/static library?
8432 1.1 riastrad
8433 1.1 riastrad if test lib = "$linkmode"; then
8434 1.1 riastrad if test -n "$dependency_libs" &&
8435 1.1 riastrad { test yes != "$hardcode_into_libs" ||
8436 1.1 riastrad test yes = "$build_old_libs" ||
8437 1.1 riastrad test yes = "$link_static"; }; then
8438 1.1 riastrad # Extract -R from dependency_libs
8439 1.1 riastrad temp_deplibs=
8440 1.1 riastrad for libdir in $dependency_libs; do
8441 1.1 riastrad case $libdir in
8442 1.1 riastrad -R*) func_stripname '-R' '' "$libdir"
8443 1.1 riastrad temp_xrpath=$func_stripname_result
8444 1.1 riastrad case " $xrpath " in
8445 1.1 riastrad *" $temp_xrpath "*) ;;
8446 1.1 riastrad *) func_append xrpath " $temp_xrpath";;
8447 1.1 riastrad esac;;
8448 1.1 riastrad *) func_append temp_deplibs " $libdir";;
8449 1.1 riastrad esac
8450 1.1 riastrad done
8451 1.1 riastrad dependency_libs=$temp_deplibs
8452 1.1 riastrad fi
8453 1.1 riastrad
8454 1.1 riastrad func_append newlib_search_path " $absdir"
8455 1.1 riastrad # Link against this library
8456 1.1 riastrad test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8457 1.1 riastrad # ... and its dependency_libs
8458 1.1 riastrad tmp_libs=
8459 1.1 riastrad for deplib in $dependency_libs; do
8460 1.1 riastrad newdependency_libs="$deplib $newdependency_libs"
8461 1.1 riastrad case $deplib in
8462 1.1 riastrad -L*) func_stripname '-L' '' "$deplib"
8463 1.1 riastrad func_resolve_sysroot "$func_stripname_result";;
8464 1.1 riastrad *) func_resolve_sysroot "$deplib" ;;
8465 1.1 riastrad esac
8466 1.1 riastrad if $opt_preserve_dup_deps; then
8467 1.1 riastrad case "$tmp_libs " in
8468 1.1 riastrad *" $func_resolve_sysroot_result "*)
8469 1.1 riastrad func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8470 1.1 riastrad esac
8471 1.1 riastrad fi
8472 1.1 riastrad func_append tmp_libs " $func_resolve_sysroot_result"
8473 1.1 riastrad done
8474 1.1 riastrad
8475 1.1 riastrad if test no != "$link_all_deplibs"; then
8476 1.1 riastrad # Add the search paths of all dependency libraries
8477 1.1 riastrad for deplib in $dependency_libs; do
8478 1.1 riastrad path=
8479 1.1 riastrad case $deplib in
8480 1.1 riastrad -L*) path=$deplib ;;
8481 1.1 riastrad *.la)
8482 1.1 riastrad func_resolve_sysroot "$deplib"
8483 1.1 riastrad deplib=$func_resolve_sysroot_result
8484 1.1 riastrad func_dirname "$deplib" "" "."
8485 1.1 riastrad dir=$func_dirname_result
8486 1.1 riastrad # We need an absolute path.
8487 1.1 riastrad case $dir in
8488 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8489 1.1 riastrad *)
8490 1.1 riastrad absdir=`cd "$dir" && pwd`
8491 1.1 riastrad if test -z "$absdir"; then
8492 1.1 riastrad func_warning "cannot determine absolute directory name of '$dir'"
8493 1.1 riastrad absdir=$dir
8494 1.1 riastrad fi
8495 1.1 riastrad ;;
8496 1.1 riastrad esac
8497 1.1 riastrad if $GREP "^installed=no" $deplib > /dev/null; then
8498 1.1 riastrad case $host in
8499 1.1 riastrad *-*-darwin*)
8500 1.1 riastrad depdepl=
8501 1.1 riastrad eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8502 1.1 riastrad if test -n "$deplibrary_names"; then
8503 1.1 riastrad for tmp in $deplibrary_names; do
8504 1.1 riastrad depdepl=$tmp
8505 1.1 riastrad done
8506 1.1 riastrad if test -f "$absdir/$objdir/$depdepl"; then
8507 1.1 riastrad depdepl=$absdir/$objdir/$depdepl
8508 1.1 riastrad darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8509 1.1 riastrad if test -z "$darwin_install_name"; then
8510 1.1 riastrad darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8511 1.1 riastrad fi
8512 1.1 riastrad func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8513 1.1 riastrad func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8514 1.1 riastrad path=
8515 1.1 riastrad fi
8516 1.1 riastrad fi
8517 1.1 riastrad ;;
8518 1.1 riastrad *)
8519 1.1 riastrad path=-L$absdir/$objdir
8520 1.1 riastrad ;;
8521 1.1 riastrad esac
8522 1.1 riastrad else
8523 1.1 riastrad eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8524 1.1 riastrad test -z "$libdir" && \
8525 1.1 riastrad func_fatal_error "'$deplib' is not a valid libtool archive"
8526 1.1 riastrad test "$absdir" != "$libdir" && \
8527 1.1 riastrad func_warning "'$deplib' seems to be moved"
8528 1.1 riastrad
8529 1.1 riastrad path=-L$absdir
8530 1.1 riastrad fi
8531 1.1 riastrad ;;
8532 1.1 riastrad esac
8533 1.1 riastrad case " $deplibs " in
8534 1.1 riastrad *" $path "*) ;;
8535 1.1 riastrad *) deplibs="$path $deplibs" ;;
8536 1.1 riastrad esac
8537 1.1 riastrad done
8538 1.1 riastrad fi # link_all_deplibs != no
8539 1.1 riastrad fi # linkmode = lib
8540 1.1 riastrad done # for deplib in $libs
8541 1.1 riastrad if test link = "$pass"; then
8542 1.1 riastrad if test prog = "$linkmode"; then
8543 1.1 riastrad compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8544 1.1 riastrad finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8545 1.1 riastrad else
8546 1.1 riastrad compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8547 1.1 riastrad fi
8548 1.1 riastrad fi
8549 1.1 riastrad dependency_libs=$newdependency_libs
8550 1.1 riastrad if test dlpreopen = "$pass"; then
8551 1.1 riastrad # Link the dlpreopened libraries before other libraries
8552 1.1 riastrad for deplib in $save_deplibs; do
8553 1.1 riastrad deplibs="$deplib $deplibs"
8554 1.1 riastrad done
8555 1.1 riastrad fi
8556 1.1 riastrad if test dlopen != "$pass"; then
8557 1.1 riastrad test conv = "$pass" || {
8558 1.1 riastrad # Make sure lib_search_path contains only unique directories.
8559 1.1 riastrad lib_search_path=
8560 1.1 riastrad for dir in $newlib_search_path; do
8561 1.1 riastrad case "$lib_search_path " in
8562 1.1 riastrad *" $dir "*) ;;
8563 1.1 riastrad *) func_append lib_search_path " $dir" ;;
8564 1.1 riastrad esac
8565 1.1 riastrad done
8566 1.1 riastrad newlib_search_path=
8567 1.1 riastrad }
8568 1.1 riastrad
8569 1.1 riastrad if test prog,link = "$linkmode,$pass"; then
8570 1.1 riastrad vars="compile_deplibs finalize_deplibs"
8571 1.1 riastrad else
8572 1.1 riastrad vars=deplibs
8573 1.1 riastrad fi
8574 1.1 riastrad for var in $vars dependency_libs; do
8575 1.1 riastrad # Add libraries to $var in reverse order
8576 1.1 riastrad eval tmp_libs=\"\$$var\"
8577 1.1 riastrad new_libs=
8578 1.1 riastrad for deplib in $tmp_libs; do
8579 1.1 riastrad # FIXME: Pedantically, this is the right thing to do, so
8580 1.1 riastrad # that some nasty dependency loop isn't accidentally
8581 1.1 riastrad # broken:
8582 1.1 riastrad #new_libs="$deplib $new_libs"
8583 1.1 riastrad # Pragmatically, this seems to cause very few problems in
8584 1.1 riastrad # practice:
8585 1.1 riastrad case $deplib in
8586 1.1 riastrad -L*) new_libs="$deplib $new_libs" ;;
8587 1.1 riastrad -R*) ;;
8588 1.1 riastrad *)
8589 1.1 riastrad # And here is the reason: when a library appears more
8590 1.1 riastrad # than once as an explicit dependence of a library, or
8591 1.1 riastrad # is implicitly linked in more than once by the
8592 1.1 riastrad # compiler, it is considered special, and multiple
8593 1.1 riastrad # occurrences thereof are not removed. Compare this
8594 1.1 riastrad # with having the same library being listed as a
8595 1.1 riastrad # dependency of multiple other libraries: in this case,
8596 1.1 riastrad # we know (pedantically, we assume) the library does not
8597 1.1 riastrad # need to be listed more than once, so we keep only the
8598 1.1 riastrad # last copy. This is not always right, but it is rare
8599 1.1 riastrad # enough that we require users that really mean to play
8600 1.1 riastrad # such unportable linking tricks to link the library
8601 1.1 riastrad # using -Wl,-lname, so that libtool does not consider it
8602 1.1 riastrad # for duplicate removal.
8603 1.1 riastrad case " $specialdeplibs " in
8604 1.1 riastrad *" $deplib "*) new_libs="$deplib $new_libs" ;;
8605 1.1 riastrad *)
8606 1.1 riastrad case " $new_libs " in
8607 1.1 riastrad *" $deplib "*) ;;
8608 1.1 riastrad *) new_libs="$deplib $new_libs" ;;
8609 1.1 riastrad esac
8610 1.1 riastrad ;;
8611 1.1 riastrad esac
8612 1.1 riastrad ;;
8613 1.1 riastrad esac
8614 1.1 riastrad done
8615 1.1 riastrad tmp_libs=
8616 1.1 riastrad for deplib in $new_libs; do
8617 1.1 riastrad case $deplib in
8618 1.1 riastrad -L*)
8619 1.1 riastrad case " $tmp_libs " in
8620 1.1 riastrad *" $deplib "*) ;;
8621 1.1 riastrad *) func_append tmp_libs " $deplib" ;;
8622 1.1 riastrad esac
8623 1.1 riastrad ;;
8624 1.1 riastrad *) func_append tmp_libs " $deplib" ;;
8625 1.1 riastrad esac
8626 1.1 riastrad done
8627 1.1 riastrad eval $var=\"$tmp_libs\"
8628 1.1 riastrad done # for var
8629 1.1 riastrad fi
8630 1.1 riastrad
8631 1.1 riastrad # Add Sun CC postdeps if required:
8632 1.1 riastrad test CXX = "$tagname" && {
8633 1.1 riastrad case $host_os in
8634 1.1 riastrad linux*)
8635 1.1 riastrad case `$CC -V 2>&1 | sed 5q` in
8636 1.1 riastrad *Sun\ C*) # Sun C++ 5.9
8637 1.1 riastrad func_suncc_cstd_abi
8638 1.1 riastrad
8639 1.1 riastrad if test no != "$suncc_use_cstd_abi"; then
8640 1.1 riastrad func_append postdeps ' -library=Cstd -library=Crun'
8641 1.1 riastrad fi
8642 1.1 riastrad ;;
8643 1.1 riastrad esac
8644 1.1 riastrad ;;
8645 1.1 riastrad
8646 1.1 riastrad solaris*)
8647 1.1 riastrad func_cc_basename "$CC"
8648 1.1 riastrad case $func_cc_basename_result in
8649 1.1 riastrad CC* | sunCC*)
8650 1.1 riastrad func_suncc_cstd_abi
8651 1.1 riastrad
8652 1.1 riastrad if test no != "$suncc_use_cstd_abi"; then
8653 1.1 riastrad func_append postdeps ' -library=Cstd -library=Crun'
8654 1.1 riastrad fi
8655 1.1 riastrad ;;
8656 1.1 riastrad esac
8657 1.1 riastrad ;;
8658 1.1 riastrad esac
8659 1.1 riastrad }
8660 1.1 riastrad
8661 1.1 riastrad # Last step: remove runtime libs from dependency_libs
8662 1.1 riastrad # (they stay in deplibs)
8663 1.1 riastrad tmp_libs=
8664 1.1 riastrad for i in $dependency_libs; do
8665 1.1 riastrad case " $predeps $postdeps $compiler_lib_search_path " in
8666 1.1 riastrad *" $i "*)
8667 1.1 riastrad i=
8668 1.1 riastrad ;;
8669 1.1 riastrad esac
8670 1.1 riastrad if test -n "$i"; then
8671 1.1 riastrad func_append tmp_libs " $i"
8672 1.1 riastrad fi
8673 1.1 riastrad done
8674 1.1 riastrad dependency_libs=$tmp_libs
8675 1.1 riastrad done # for pass
8676 1.1 riastrad if test prog = "$linkmode"; then
8677 1.1 riastrad dlfiles=$newdlfiles
8678 1.1 riastrad fi
8679 1.1 riastrad if test prog = "$linkmode" || test lib = "$linkmode"; then
8680 1.1 riastrad dlprefiles=$newdlprefiles
8681 1.1 riastrad fi
8682 1.1 riastrad
8683 1.1 riastrad case $linkmode in
8684 1.1 riastrad oldlib)
8685 1.1 riastrad if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8686 1.1 riastrad func_warning "'-dlopen' is ignored for archives"
8687 1.1 riastrad fi
8688 1.1 riastrad
8689 1.1 riastrad case " $deplibs" in
8690 1.1 riastrad *\ -l* | *\ -L*)
8691 1.1 riastrad func_warning "'-l' and '-L' are ignored for archives" ;;
8692 1.1 riastrad esac
8693 1.1 riastrad
8694 1.1 riastrad test -n "$rpath" && \
8695 1.1 riastrad func_warning "'-rpath' is ignored for archives"
8696 1.1 riastrad
8697 1.1 riastrad test -n "$xrpath" && \
8698 1.1 riastrad func_warning "'-R' is ignored for archives"
8699 1.1 riastrad
8700 1.1 riastrad test -n "$vinfo" && \
8701 1.1 riastrad func_warning "'-version-info/-version-number' is ignored for archives"
8702 1.1 riastrad
8703 1.1 riastrad test -n "$release" && \
8704 1.1 riastrad func_warning "'-release' is ignored for archives"
8705 1.1 riastrad
8706 1.1 riastrad test -n "$export_symbols$export_symbols_regex" && \
8707 1.1 riastrad func_warning "'-export-symbols' is ignored for archives"
8708 1.1 riastrad
8709 1.1 riastrad # Now set the variables for building old libraries.
8710 1.1 riastrad build_libtool_libs=no
8711 1.1 riastrad oldlibs=$output
8712 1.1 riastrad func_append objs "$old_deplibs"
8713 1.1 riastrad ;;
8714 1.1 riastrad
8715 1.1 riastrad lib)
8716 1.1 riastrad # Make sure we only generate libraries of the form 'libNAME.la'.
8717 1.1 riastrad case $outputname in
8718 1.1 riastrad lib*)
8719 1.1 riastrad func_stripname 'lib' '.la' "$outputname"
8720 1.1 riastrad name=$func_stripname_result
8721 1.1 riastrad eval shared_ext=\"$shrext_cmds\"
8722 1.1 riastrad eval libname=\"$libname_spec\"
8723 1.1 riastrad ;;
8724 1.1 riastrad *)
8725 1.1 riastrad test no = "$module" \
8726 1.1 riastrad && func_fatal_help "libtool library '$output' must begin with 'lib'"
8727 1.1 riastrad
8728 1.1 riastrad if test no != "$need_lib_prefix"; then
8729 1.1 riastrad # Add the "lib" prefix for modules if required
8730 1.1 riastrad func_stripname '' '.la' "$outputname"
8731 1.1 riastrad name=$func_stripname_result
8732 1.1 riastrad eval shared_ext=\"$shrext_cmds\"
8733 1.1 riastrad eval libname=\"$libname_spec\"
8734 1.1 riastrad else
8735 1.1 riastrad func_stripname '' '.la' "$outputname"
8736 1.1 riastrad libname=$func_stripname_result
8737 1.1 riastrad fi
8738 1.1 riastrad ;;
8739 1.1 riastrad esac
8740 1.1 riastrad
8741 1.1 riastrad if test -n "$objs"; then
8742 1.1 riastrad if test pass_all != "$deplibs_check_method"; then
8743 1.1 riastrad func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8744 1.1 riastrad else
8745 1.1 riastrad echo
8746 1.1 riastrad $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8747 1.1 riastrad $ECHO "*** objects $objs is not portable!"
8748 1.1 riastrad func_append libobjs " $objs"
8749 1.1 riastrad fi
8750 1.1 riastrad fi
8751 1.1 riastrad
8752 1.1 riastrad test no = "$dlself" \
8753 1.1 riastrad || func_warning "'-dlopen self' is ignored for libtool libraries"
8754 1.1 riastrad
8755 1.1 riastrad set dummy $rpath
8756 1.1 riastrad shift
8757 1.1 riastrad test 1 -lt "$#" \
8758 1.1 riastrad && func_warning "ignoring multiple '-rpath's for a libtool library"
8759 1.1 riastrad
8760 1.1 riastrad install_libdir=$1
8761 1.1 riastrad
8762 1.1 riastrad oldlibs=
8763 1.1 riastrad if test -z "$rpath"; then
8764 1.1 riastrad if test yes = "$build_libtool_libs"; then
8765 1.1 riastrad # Building a libtool convenience library.
8766 1.1 riastrad # Some compilers have problems with a '.al' extension so
8767 1.1 riastrad # convenience libraries should have the same extension an
8768 1.1 riastrad # archive normally would.
8769 1.1 riastrad oldlibs="$output_objdir/$libname.$libext $oldlibs"
8770 1.1 riastrad build_libtool_libs=convenience
8771 1.1 riastrad build_old_libs=yes
8772 1.1 riastrad fi
8773 1.1 riastrad
8774 1.1 riastrad test -n "$vinfo" && \
8775 1.1 riastrad func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8776 1.1 riastrad
8777 1.1 riastrad test -n "$release" && \
8778 1.1 riastrad func_warning "'-release' is ignored for convenience libraries"
8779 1.1 riastrad else
8780 1.1 riastrad
8781 1.1 riastrad # Parse the version information argument.
8782 1.1 riastrad save_ifs=$IFS; IFS=:
8783 1.1 riastrad set dummy $vinfo 0 0 0
8784 1.1 riastrad shift
8785 1.1 riastrad IFS=$save_ifs
8786 1.1 riastrad
8787 1.1 riastrad test -n "$7" && \
8788 1.1 riastrad func_fatal_help "too many parameters to '-version-info'"
8789 1.1 riastrad
8790 1.1 riastrad # convert absolute version numbers to libtool ages
8791 1.1 riastrad # this retains compatibility with .la files and attempts
8792 1.1 riastrad # to make the code below a bit more comprehensible
8793 1.1 riastrad
8794 1.1 riastrad case $vinfo_number in
8795 1.1 riastrad yes)
8796 1.1 riastrad number_major=$1
8797 1.1 riastrad number_minor=$2
8798 1.1 riastrad number_revision=$3
8799 1.1 riastrad #
8800 1.1 riastrad # There are really only two kinds -- those that
8801 1.1 riastrad # use the current revision as the major version
8802 1.1 riastrad # and those that subtract age and use age as
8803 1.1 riastrad # a minor version. But, then there is irix
8804 1.1 riastrad # that has an extra 1 added just for fun
8805 1.1 riastrad #
8806 1.1 riastrad case $version_type in
8807 1.1 riastrad # correct linux to gnu/linux during the next big refactor
8808 1.1 riastrad darwin|freebsd-elf|linux|osf|windows|none)
8809 1.1 riastrad func_arith $number_major + $number_minor
8810 1.1 riastrad current=$func_arith_result
8811 1.1 riastrad age=$number_minor
8812 1.1 riastrad revision=$number_revision
8813 1.1 riastrad ;;
8814 1.1 riastrad freebsd-aout|qnx|sunos)
8815 1.1 riastrad current=$number_major
8816 1.1 riastrad revision=$number_minor
8817 1.1 riastrad age=0
8818 1.1 riastrad ;;
8819 1.1 riastrad irix|nonstopux)
8820 1.1 riastrad func_arith $number_major + $number_minor
8821 1.1 riastrad current=$func_arith_result
8822 1.1 riastrad age=$number_minor
8823 1.1 riastrad revision=$number_minor
8824 1.1 riastrad lt_irix_increment=no
8825 1.1 riastrad ;;
8826 1.1 riastrad esac
8827 1.1 riastrad ;;
8828 1.1 riastrad no)
8829 1.1 riastrad current=$1
8830 1.1 riastrad revision=$2
8831 1.1 riastrad age=$3
8832 1.1 riastrad ;;
8833 1.1 riastrad esac
8834 1.1 riastrad
8835 1.1 riastrad # Check that each of the things are valid numbers.
8836 1.1 riastrad case $current in
8837 1.1 riastrad 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 riastrad *)
8839 1.1 riastrad func_error "CURRENT '$current' must be a nonnegative integer"
8840 1.1 riastrad func_fatal_error "'$vinfo' is not valid version information"
8841 1.1 riastrad ;;
8842 1.1 riastrad esac
8843 1.1 riastrad
8844 1.1 riastrad case $revision in
8845 1.1 riastrad 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 riastrad *)
8847 1.1 riastrad func_error "REVISION '$revision' must be a nonnegative integer"
8848 1.1 riastrad func_fatal_error "'$vinfo' is not valid version information"
8849 1.1 riastrad ;;
8850 1.1 riastrad esac
8851 1.1 riastrad
8852 1.1 riastrad case $age in
8853 1.1 riastrad 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 riastrad *)
8855 1.1 riastrad func_error "AGE '$age' must be a nonnegative integer"
8856 1.1 riastrad func_fatal_error "'$vinfo' is not valid version information"
8857 1.1 riastrad ;;
8858 1.1 riastrad esac
8859 1.1 riastrad
8860 1.1 riastrad if test "$age" -gt "$current"; then
8861 1.1 riastrad func_error "AGE '$age' is greater than the current interface number '$current'"
8862 1.1 riastrad func_fatal_error "'$vinfo' is not valid version information"
8863 1.1 riastrad fi
8864 1.1 riastrad
8865 1.1 riastrad # Calculate the version variables.
8866 1.1 riastrad major=
8867 1.1 riastrad versuffix=
8868 1.1 riastrad verstring=
8869 1.1 riastrad case $version_type in
8870 1.1 riastrad none) ;;
8871 1.1 riastrad
8872 1.1 riastrad darwin)
8873 1.1 riastrad # Like Linux, but with the current version available in
8874 1.1 riastrad # verstring for coding it into the library header
8875 1.1 riastrad func_arith $current - $age
8876 1.1 riastrad major=.$func_arith_result
8877 1.1 riastrad versuffix=$major.$age.$revision
8878 1.1 riastrad # Darwin ld doesn't like 0 for these options...
8879 1.1 riastrad func_arith $current + 1
8880 1.1 riastrad minor_current=$func_arith_result
8881 1.1 riastrad xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8882 1.1 riastrad verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8883 1.1 riastrad # On Darwin other compilers
8884 1.1 riastrad case $CC in
8885 1.1 riastrad nagfor*)
8886 1.1 riastrad verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8887 1.1 riastrad ;;
8888 1.1 riastrad *)
8889 1.1 riastrad verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8890 1.1 riastrad ;;
8891 1.1 riastrad esac
8892 1.1 riastrad ;;
8893 1.1 riastrad
8894 1.1 riastrad freebsd-aout)
8895 1.1 riastrad major=.$current
8896 1.1 riastrad versuffix=.$current.$revision
8897 1.1 riastrad ;;
8898 1.1 riastrad
8899 1.1 riastrad freebsd-elf)
8900 1.1 riastrad func_arith $current - $age
8901 1.1 riastrad major=.$func_arith_result
8902 1.1 riastrad versuffix=$major.$age.$revision
8903 1.1 riastrad ;;
8904 1.1 riastrad
8905 1.1 riastrad irix | nonstopux)
8906 1.1 riastrad if test no = "$lt_irix_increment"; then
8907 1.1 riastrad func_arith $current - $age
8908 1.1 riastrad else
8909 1.1 riastrad func_arith $current - $age + 1
8910 1.1 riastrad fi
8911 1.1 riastrad major=$func_arith_result
8912 1.1 riastrad
8913 1.1 riastrad case $version_type in
8914 1.1 riastrad nonstopux) verstring_prefix=nonstopux ;;
8915 1.1 riastrad *) verstring_prefix=sgi ;;
8916 1.1 riastrad esac
8917 1.1 riastrad verstring=$verstring_prefix$major.$revision
8918 1.1 riastrad
8919 1.1 riastrad # Add in all the interfaces that we are compatible with.
8920 1.1 riastrad loop=$revision
8921 1.1 riastrad while test 0 -ne "$loop"; do
8922 1.1 riastrad func_arith $revision - $loop
8923 1.1 riastrad iface=$func_arith_result
8924 1.1 riastrad func_arith $loop - 1
8925 1.1 riastrad loop=$func_arith_result
8926 1.1 riastrad verstring=$verstring_prefix$major.$iface:$verstring
8927 1.1 riastrad done
8928 1.1 riastrad
8929 1.1 riastrad # Before this point, $major must not contain '.'.
8930 1.1 riastrad major=.$major
8931 1.1 riastrad versuffix=$major.$revision
8932 1.1 riastrad ;;
8933 1.1 riastrad
8934 1.1 riastrad linux) # correct to gnu/linux during the next big refactor
8935 1.1 riastrad func_arith $current - $age
8936 1.1 riastrad major=.$func_arith_result
8937 1.1 riastrad versuffix=$major.$age.$revision
8938 1.1 riastrad ;;
8939 1.1 riastrad
8940 1.1 riastrad osf)
8941 1.1 riastrad func_arith $current - $age
8942 1.1 riastrad major=.$func_arith_result
8943 1.1 riastrad versuffix=.$current.$age.$revision
8944 1.1 riastrad verstring=$current.$age.$revision
8945 1.1 riastrad
8946 1.1 riastrad # Add in all the interfaces that we are compatible with.
8947 1.1 riastrad loop=$age
8948 1.1 riastrad while test 0 -ne "$loop"; do
8949 1.1 riastrad func_arith $current - $loop
8950 1.1 riastrad iface=$func_arith_result
8951 1.1 riastrad func_arith $loop - 1
8952 1.1 riastrad loop=$func_arith_result
8953 1.1 riastrad verstring=$verstring:$iface.0
8954 1.1 riastrad done
8955 1.1 riastrad
8956 1.1 riastrad # Make executables depend on our current version.
8957 1.1 riastrad func_append verstring ":$current.0"
8958 1.1 riastrad ;;
8959 1.1 riastrad
8960 1.1 riastrad qnx)
8961 1.1 riastrad major=.$current
8962 1.1 riastrad versuffix=.$current
8963 1.1 riastrad ;;
8964 1.1 riastrad
8965 1.1 riastrad sco)
8966 1.1 riastrad major=.$current
8967 1.1 riastrad versuffix=.$current
8968 1.1 riastrad ;;
8969 1.1 riastrad
8970 1.1 riastrad sunos)
8971 1.1 riastrad major=.$current
8972 1.1 riastrad versuffix=.$current.$revision
8973 1.1 riastrad ;;
8974 1.1 riastrad
8975 1.1 riastrad windows)
8976 1.1 riastrad # Use '-' rather than '.', since we only want one
8977 1.1 riastrad # extension on DOS 8.3 file systems.
8978 1.1 riastrad func_arith $current - $age
8979 1.1 riastrad major=$func_arith_result
8980 1.1 riastrad versuffix=-$major
8981 1.1 riastrad ;;
8982 1.1 riastrad
8983 1.1 riastrad *)
8984 1.1 riastrad func_fatal_configuration "unknown library version type '$version_type'"
8985 1.1 riastrad ;;
8986 1.1 riastrad esac
8987 1.1 riastrad
8988 1.1 riastrad # Clear the version info if we defaulted, and they specified a release.
8989 1.1 riastrad if test -z "$vinfo" && test -n "$release"; then
8990 1.1 riastrad major=
8991 1.1 riastrad case $version_type in
8992 1.1 riastrad darwin)
8993 1.1 riastrad # we can't check for "0.0" in archive_cmds due to quoting
8994 1.1 riastrad # problems, so we reset it completely
8995 1.1 riastrad verstring=
8996 1.1 riastrad ;;
8997 1.1 riastrad *)
8998 1.1 riastrad verstring=0.0
8999 1.1 riastrad ;;
9000 1.1 riastrad esac
9001 1.1 riastrad if test no = "$need_version"; then
9002 1.1 riastrad versuffix=
9003 1.1 riastrad else
9004 1.1 riastrad versuffix=.0.0
9005 1.1 riastrad fi
9006 1.1 riastrad fi
9007 1.1 riastrad
9008 1.1 riastrad # Remove version info from name if versioning should be avoided
9009 1.1 riastrad if test yes,no = "$avoid_version,$need_version"; then
9010 1.1 riastrad major=
9011 1.1 riastrad versuffix=
9012 1.1 riastrad verstring=
9013 1.1 riastrad fi
9014 1.1 riastrad
9015 1.1 riastrad # Check to see if the archive will have undefined symbols.
9016 1.1 riastrad if test yes = "$allow_undefined"; then
9017 1.1 riastrad if test unsupported = "$allow_undefined_flag"; then
9018 1.1 riastrad if test yes = "$build_old_libs"; then
9019 1.1 riastrad func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9020 1.1 riastrad build_libtool_libs=no
9021 1.1 riastrad else
9022 1.1 riastrad func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9023 1.1 riastrad fi
9024 1.1 riastrad fi
9025 1.1 riastrad else
9026 1.1 riastrad # Don't allow undefined symbols.
9027 1.1 riastrad allow_undefined_flag=$no_undefined_flag
9028 1.1 riastrad fi
9029 1.1 riastrad
9030 1.1 riastrad fi
9031 1.1 riastrad
9032 1.1 riastrad func_generate_dlsyms "$libname" "$libname" :
9033 1.1 riastrad func_append libobjs " $symfileobj"
9034 1.1 riastrad test " " = "$libobjs" && libobjs=
9035 1.1 riastrad
9036 1.1 riastrad if test relink != "$opt_mode"; then
9037 1.1 riastrad # Remove our outputs, but don't remove object files since they
9038 1.1 riastrad # may have been created when compiling PIC objects.
9039 1.1 riastrad removelist=
9040 1.1 riastrad tempremovelist=`$ECHO "$output_objdir/*"`
9041 1.1 riastrad for p in $tempremovelist; do
9042 1.1 riastrad case $p in
9043 1.1 riastrad *.$objext | *.gcno)
9044 1.1 riastrad ;;
9045 1.1 riastrad $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9046 1.1 riastrad if test -n "$precious_files_regex"; then
9047 1.1 riastrad if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9048 1.1 riastrad then
9049 1.1 riastrad continue
9050 1.1 riastrad fi
9051 1.1 riastrad fi
9052 1.1 riastrad func_append removelist " $p"
9053 1.1 riastrad ;;
9054 1.1 riastrad *) ;;
9055 1.1 riastrad esac
9056 1.1 riastrad done
9057 1.1 riastrad test -n "$removelist" && \
9058 1.1 riastrad func_show_eval "${RM}r \$removelist"
9059 1.1 riastrad fi
9060 1.1 riastrad
9061 1.1 riastrad # Now set the variables for building old libraries.
9062 1.1 riastrad if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9063 1.1 riastrad func_append oldlibs " $output_objdir/$libname.$libext"
9064 1.1 riastrad
9065 1.1 riastrad # Transform .lo files to .o files.
9066 1.1 riastrad oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9067 1.1 riastrad fi
9068 1.1 riastrad
9069 1.1 riastrad # Eliminate all temporary directories.
9070 1.1 riastrad #for path in $notinst_path; do
9071 1.1 riastrad # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9072 1.1 riastrad # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9073 1.1 riastrad # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9074 1.1 riastrad #done
9075 1.1 riastrad
9076 1.1 riastrad if test -n "$xrpath"; then
9077 1.1 riastrad # If the user specified any rpath flags, then add them.
9078 1.1 riastrad temp_xrpath=
9079 1.1 riastrad for libdir in $xrpath; do
9080 1.1 riastrad func_replace_sysroot "$libdir"
9081 1.1 riastrad func_append temp_xrpath " -R$func_replace_sysroot_result"
9082 1.1 riastrad case "$finalize_rpath " in
9083 1.1 riastrad *" $libdir "*) ;;
9084 1.1 riastrad *) func_append finalize_rpath " $libdir" ;;
9085 1.1 riastrad esac
9086 1.1 riastrad done
9087 1.1 riastrad if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9088 1.1 riastrad dependency_libs="$temp_xrpath $dependency_libs"
9089 1.1 riastrad fi
9090 1.1 riastrad fi
9091 1.1 riastrad
9092 1.1 riastrad # Make sure dlfiles contains only unique files that won't be dlpreopened
9093 1.1 riastrad old_dlfiles=$dlfiles
9094 1.1 riastrad dlfiles=
9095 1.1 riastrad for lib in $old_dlfiles; do
9096 1.1 riastrad case " $dlprefiles $dlfiles " in
9097 1.1 riastrad *" $lib "*) ;;
9098 1.1 riastrad *) func_append dlfiles " $lib" ;;
9099 1.1 riastrad esac
9100 1.1 riastrad done
9101 1.1 riastrad
9102 1.1 riastrad # Make sure dlprefiles contains only unique files
9103 1.1 riastrad old_dlprefiles=$dlprefiles
9104 1.1 riastrad dlprefiles=
9105 1.1 riastrad for lib in $old_dlprefiles; do
9106 1.1 riastrad case "$dlprefiles " in
9107 1.1 riastrad *" $lib "*) ;;
9108 1.1 riastrad *) func_append dlprefiles " $lib" ;;
9109 1.1 riastrad esac
9110 1.1 riastrad done
9111 1.1 riastrad
9112 1.1 riastrad if test yes = "$build_libtool_libs"; then
9113 1.1 riastrad if test -n "$rpath"; then
9114 1.1 riastrad case $host in
9115 1.1 riastrad *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9116 1.1 riastrad # these systems don't actually have a c library (as such)!
9117 1.1 riastrad ;;
9118 1.1 riastrad *-*-rhapsody* | *-*-darwin1.[012])
9119 1.1 riastrad # Rhapsody C library is in the System framework
9120 1.1 riastrad func_append deplibs " System.ltframework"
9121 1.1 riastrad ;;
9122 1.1 riastrad *-*-netbsd*)
9123 1.1 riastrad # Don't link with libc until the a.out ld.so is fixed.
9124 1.1 riastrad ;;
9125 1.1 riastrad *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9126 1.1 riastrad # Do not include libc due to us having libc/libc_r.
9127 1.1 riastrad ;;
9128 1.1 riastrad *-*-sco3.2v5* | *-*-sco5v6*)
9129 1.1 riastrad # Causes problems with __ctype
9130 1.1 riastrad ;;
9131 1.1 riastrad *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9132 1.1 riastrad # Compiler inserts libc in the correct place for threads to work
9133 1.1 riastrad ;;
9134 1.1 riastrad *)
9135 1.1 riastrad # Add libc to deplibs on all other systems if necessary.
9136 1.1 riastrad if test yes = "$build_libtool_need_lc"; then
9137 1.1 riastrad func_append deplibs " -lc"
9138 1.1 riastrad fi
9139 1.1 riastrad ;;
9140 1.1 riastrad esac
9141 1.1 riastrad fi
9142 1.1 riastrad
9143 1.1 riastrad # Transform deplibs into only deplibs that can be linked in shared.
9144 1.1 riastrad name_save=$name
9145 1.1 riastrad libname_save=$libname
9146 1.1 riastrad release_save=$release
9147 1.1 riastrad versuffix_save=$versuffix
9148 1.1 riastrad major_save=$major
9149 1.1 riastrad # I'm not sure if I'm treating the release correctly. I think
9150 1.1 riastrad # release should show up in the -l (ie -lgmp5) so we don't want to
9151 1.1 riastrad # add it in twice. Is that correct?
9152 1.1 riastrad release=
9153 1.1 riastrad versuffix=
9154 1.1 riastrad major=
9155 1.1 riastrad newdeplibs=
9156 1.1 riastrad droppeddeps=no
9157 1.1 riastrad case $deplibs_check_method in
9158 1.1 riastrad pass_all)
9159 1.1 riastrad # Don't check for shared/static. Everything works.
9160 1.1 riastrad # This might be a little naive. We might want to check
9161 1.1 riastrad # whether the library exists or not. But this is on
9162 1.1 riastrad # osf3 & osf4 and I'm not really sure... Just
9163 1.1 riastrad # implementing what was already the behavior.
9164 1.1 riastrad newdeplibs=$deplibs
9165 1.1 riastrad ;;
9166 1.1 riastrad test_compile)
9167 1.1 riastrad # This code stresses the "libraries are programs" paradigm to its
9168 1.1 riastrad # limits. Maybe even breaks it. We compile a program, linking it
9169 1.1 riastrad # against the deplibs as a proxy for the library. Then we can check
9170 1.1 riastrad # whether they linked in statically or dynamically with ldd.
9171 1.1 riastrad $opt_dry_run || $RM conftest.c
9172 1.1 riastrad cat > conftest.c <<EOF
9173 1.1 riastrad int main() { return 0; }
9174 1.1 riastrad EOF
9175 1.1 riastrad $opt_dry_run || $RM conftest
9176 1.1 riastrad if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9177 1.1 riastrad ldd_output=`ldd conftest`
9178 1.1 riastrad for i in $deplibs; do
9179 1.1 riastrad case $i in
9180 1.1 riastrad -l*)
9181 1.1 riastrad func_stripname -l '' "$i"
9182 1.1 riastrad name=$func_stripname_result
9183 1.1 riastrad if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9184 1.1 riastrad case " $predeps $postdeps " in
9185 1.1 riastrad *" $i "*)
9186 1.1 riastrad func_append newdeplibs " $i"
9187 1.1 riastrad i=
9188 1.1 riastrad ;;
9189 1.1 riastrad esac
9190 1.1 riastrad fi
9191 1.1 riastrad if test -n "$i"; then
9192 1.1 riastrad libname=`eval "\\$ECHO \"$libname_spec\""`
9193 1.1 riastrad deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9194 1.1 riastrad set dummy $deplib_matches; shift
9195 1.1 riastrad deplib_match=$1
9196 1.1 riastrad if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9197 1.1 riastrad func_append newdeplibs " $i"
9198 1.1 riastrad else
9199 1.1 riastrad droppeddeps=yes
9200 1.1 riastrad echo
9201 1.1 riastrad $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9202 1.1 riastrad echo "*** I have the capability to make that library automatically link in when"
9203 1.1 riastrad echo "*** you link to this library. But I can only do this if you have a"
9204 1.1 riastrad echo "*** shared version of the library, which I believe you do not have"
9205 1.1 riastrad echo "*** because a test_compile did reveal that the linker did not use it for"
9206 1.1 riastrad echo "*** its dynamic dependency list that programs get resolved with at runtime."
9207 1.1 riastrad fi
9208 1.1 riastrad fi
9209 1.1 riastrad ;;
9210 1.1 riastrad *)
9211 1.1 riastrad func_append newdeplibs " $i"
9212 1.1 riastrad ;;
9213 1.1 riastrad esac
9214 1.1 riastrad done
9215 1.1 riastrad else
9216 1.1 riastrad # Error occurred in the first compile. Let's try to salvage
9217 1.1 riastrad # the situation: Compile a separate program for each library.
9218 1.1 riastrad for i in $deplibs; do
9219 1.1 riastrad case $i in
9220 1.1 riastrad -l*)
9221 1.1 riastrad func_stripname -l '' "$i"
9222 1.1 riastrad name=$func_stripname_result
9223 1.1 riastrad $opt_dry_run || $RM conftest
9224 1.1 riastrad if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9225 1.1 riastrad ldd_output=`ldd conftest`
9226 1.1 riastrad if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9227 1.1 riastrad case " $predeps $postdeps " in
9228 1.1 riastrad *" $i "*)
9229 1.1 riastrad func_append newdeplibs " $i"
9230 1.1 riastrad i=
9231 1.1 riastrad ;;
9232 1.1 riastrad esac
9233 1.1 riastrad fi
9234 1.1 riastrad if test -n "$i"; then
9235 1.1 riastrad libname=`eval "\\$ECHO \"$libname_spec\""`
9236 1.1 riastrad deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9237 1.1 riastrad set dummy $deplib_matches; shift
9238 1.1 riastrad deplib_match=$1
9239 1.1 riastrad if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9240 1.1 riastrad func_append newdeplibs " $i"
9241 1.1 riastrad else
9242 1.1 riastrad droppeddeps=yes
9243 1.1 riastrad echo
9244 1.1 riastrad $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9245 1.1 riastrad echo "*** I have the capability to make that library automatically link in when"
9246 1.1 riastrad echo "*** you link to this library. But I can only do this if you have a"
9247 1.1 riastrad echo "*** shared version of the library, which you do not appear to have"
9248 1.1 riastrad echo "*** because a test_compile did reveal that the linker did not use this one"
9249 1.1 riastrad echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9250 1.1 riastrad fi
9251 1.1 riastrad fi
9252 1.1 riastrad else
9253 1.1 riastrad droppeddeps=yes
9254 1.1 riastrad echo
9255 1.1 riastrad $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
9256 1.1 riastrad echo "*** make it link in! You will probably need to install it or some"
9257 1.1 riastrad echo "*** library that it depends on before this library will be fully"
9258 1.1 riastrad echo "*** functional. Installing it before continuing would be even better."
9259 1.1 riastrad fi
9260 1.1 riastrad ;;
9261 1.1 riastrad *)
9262 1.1 riastrad func_append newdeplibs " $i"
9263 1.1 riastrad ;;
9264 1.1 riastrad esac
9265 1.1 riastrad done
9266 1.1 riastrad fi
9267 1.1 riastrad ;;
9268 1.1 riastrad file_magic*)
9269 1.1 riastrad set dummy $deplibs_check_method; shift
9270 1.1 riastrad file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9271 1.1 riastrad for a_deplib in $deplibs; do
9272 1.1 riastrad case $a_deplib in
9273 1.1 riastrad -l*)
9274 1.1 riastrad func_stripname -l '' "$a_deplib"
9275 1.1 riastrad name=$func_stripname_result
9276 1.1 riastrad if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9277 1.1 riastrad case " $predeps $postdeps " in
9278 1.1 riastrad *" $a_deplib "*)
9279 1.1 riastrad func_append newdeplibs " $a_deplib"
9280 1.1 riastrad a_deplib=
9281 1.1 riastrad ;;
9282 1.1 riastrad esac
9283 1.1 riastrad fi
9284 1.1 riastrad if test -n "$a_deplib"; then
9285 1.1 riastrad libname=`eval "\\$ECHO \"$libname_spec\""`
9286 1.1 riastrad if test -n "$file_magic_glob"; then
9287 1.1 riastrad libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9288 1.1 riastrad else
9289 1.1 riastrad libnameglob=$libname
9290 1.1 riastrad fi
9291 1.1 riastrad test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9292 1.1 riastrad for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9293 1.1 riastrad if test yes = "$want_nocaseglob"; then
9294 1.1 riastrad shopt -s nocaseglob
9295 1.1 riastrad potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9296 1.1 riastrad $nocaseglob
9297 1.1 riastrad else
9298 1.1 riastrad potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9299 1.1 riastrad fi
9300 1.1 riastrad for potent_lib in $potential_libs; do
9301 1.1 riastrad # Follow soft links.
9302 1.1 riastrad if ls -lLd "$potent_lib" 2>/dev/null |
9303 1.1 riastrad $GREP " -> " >/dev/null; then
9304 1.1 riastrad continue
9305 1.1 riastrad fi
9306 1.1 riastrad # The statement above tries to avoid entering an
9307 1.1 riastrad # endless loop below, in case of cyclic links.
9308 1.1 riastrad # We might still enter an endless loop, since a link
9309 1.1 riastrad # loop can be closed while we follow links,
9310 1.1 riastrad # but so what?
9311 1.1 riastrad potlib=$potent_lib
9312 1.1 riastrad while test -h "$potlib" 2>/dev/null; do
9313 1.1 riastrad potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9314 1.1 riastrad case $potliblink in
9315 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9316 1.1 riastrad *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9317 1.1 riastrad esac
9318 1.1 riastrad done
9319 1.1 riastrad if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9320 1.1 riastrad $SED -e 10q |
9321 1.1 riastrad $EGREP "$file_magic_regex" > /dev/null; then
9322 1.1 riastrad func_append newdeplibs " $a_deplib"
9323 1.1 riastrad a_deplib=
9324 1.1 riastrad break 2
9325 1.1 riastrad fi
9326 1.1 riastrad done
9327 1.1 riastrad done
9328 1.1 riastrad fi
9329 1.1 riastrad if test -n "$a_deplib"; then
9330 1.1 riastrad droppeddeps=yes
9331 1.1 riastrad echo
9332 1.1 riastrad $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9333 1.1 riastrad echo "*** I have the capability to make that library automatically link in when"
9334 1.1 riastrad echo "*** you link to this library. But I can only do this if you have a"
9335 1.1 riastrad echo "*** shared version of the library, which you do not appear to have"
9336 1.1 riastrad echo "*** because I did check the linker path looking for a file starting"
9337 1.1 riastrad if test -z "$potlib"; then
9338 1.1 riastrad $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9339 1.1 riastrad else
9340 1.1 riastrad $ECHO "*** with $libname and none of the candidates passed a file format test"
9341 1.1 riastrad $ECHO "*** using a file magic. Last file checked: $potlib"
9342 1.1 riastrad fi
9343 1.1 riastrad fi
9344 1.1 riastrad ;;
9345 1.1 riastrad *)
9346 1.1 riastrad # Add a -L argument.
9347 1.1 riastrad func_append newdeplibs " $a_deplib"
9348 1.1 riastrad ;;
9349 1.1 riastrad esac
9350 1.1 riastrad done # Gone through all deplibs.
9351 1.1 riastrad ;;
9352 1.1 riastrad match_pattern*)
9353 1.1 riastrad set dummy $deplibs_check_method; shift
9354 1.1 riastrad match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9355 1.1 riastrad for a_deplib in $deplibs; do
9356 1.1 riastrad case $a_deplib in
9357 1.1 riastrad -l*)
9358 1.1 riastrad func_stripname -l '' "$a_deplib"
9359 1.1 riastrad name=$func_stripname_result
9360 1.1 riastrad if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9361 1.1 riastrad case " $predeps $postdeps " in
9362 1.1 riastrad *" $a_deplib "*)
9363 1.1 riastrad func_append newdeplibs " $a_deplib"
9364 1.1 riastrad a_deplib=
9365 1.1 riastrad ;;
9366 1.1 riastrad esac
9367 1.1 riastrad fi
9368 1.1 riastrad if test -n "$a_deplib"; then
9369 1.1 riastrad libname=`eval "\\$ECHO \"$libname_spec\""`
9370 1.1 riastrad for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9371 1.1 riastrad potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9372 1.1 riastrad for potent_lib in $potential_libs; do
9373 1.1 riastrad potlib=$potent_lib # see symlink-check above in file_magic test
9374 1.1 riastrad if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9375 1.1 riastrad $EGREP "$match_pattern_regex" > /dev/null; then
9376 1.1 riastrad func_append newdeplibs " $a_deplib"
9377 1.1 riastrad a_deplib=
9378 1.1 riastrad break 2
9379 1.1 riastrad fi
9380 1.1 riastrad done
9381 1.1 riastrad done
9382 1.1 riastrad fi
9383 1.1 riastrad if test -n "$a_deplib"; then
9384 1.1 riastrad droppeddeps=yes
9385 1.1 riastrad echo
9386 1.1 riastrad $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9387 1.1 riastrad echo "*** I have the capability to make that library automatically link in when"
9388 1.1 riastrad echo "*** you link to this library. But I can only do this if you have a"
9389 1.1 riastrad echo "*** shared version of the library, which you do not appear to have"
9390 1.1 riastrad echo "*** because I did check the linker path looking for a file starting"
9391 1.1 riastrad if test -z "$potlib"; then
9392 1.1 riastrad $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9393 1.1 riastrad else
9394 1.1 riastrad $ECHO "*** with $libname and none of the candidates passed a file format test"
9395 1.1 riastrad $ECHO "*** using a regex pattern. Last file checked: $potlib"
9396 1.1 riastrad fi
9397 1.1 riastrad fi
9398 1.1 riastrad ;;
9399 1.1 riastrad *)
9400 1.1 riastrad # Add a -L argument.
9401 1.1 riastrad func_append newdeplibs " $a_deplib"
9402 1.1 riastrad ;;
9403 1.1 riastrad esac
9404 1.1 riastrad done # Gone through all deplibs.
9405 1.1 riastrad ;;
9406 1.1 riastrad none | unknown | *)
9407 1.1 riastrad newdeplibs=
9408 1.1 riastrad tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9409 1.1 riastrad if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9410 1.1 riastrad for i in $predeps $postdeps; do
9411 1.1 riastrad # can't use Xsed below, because $i might contain '/'
9412 1.1 riastrad tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9413 1.1 riastrad done
9414 1.1 riastrad fi
9415 1.1 riastrad case $tmp_deplibs in
9416 1.1 riastrad *[!\ \ ]*)
9417 1.1 riastrad echo
9418 1.1 riastrad if test none = "$deplibs_check_method"; then
9419 1.1 riastrad echo "*** Warning: inter-library dependencies are not supported in this platform."
9420 1.1 riastrad else
9421 1.1 riastrad echo "*** Warning: inter-library dependencies are not known to be supported."
9422 1.1 riastrad fi
9423 1.1 riastrad echo "*** All declared inter-library dependencies are being dropped."
9424 1.1 riastrad droppeddeps=yes
9425 1.1 riastrad ;;
9426 1.1 riastrad esac
9427 1.1 riastrad ;;
9428 1.1 riastrad esac
9429 1.1 riastrad versuffix=$versuffix_save
9430 1.1 riastrad major=$major_save
9431 1.1 riastrad release=$release_save
9432 1.1 riastrad libname=$libname_save
9433 1.1 riastrad name=$name_save
9434 1.1 riastrad
9435 1.1 riastrad case $host in
9436 1.1 riastrad *-*-rhapsody* | *-*-darwin1.[012])
9437 1.1 riastrad # On Rhapsody replace the C library with the System framework
9438 1.1 riastrad newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9439 1.1 riastrad ;;
9440 1.1 riastrad esac
9441 1.1 riastrad
9442 1.1 riastrad if test yes = "$droppeddeps"; then
9443 1.1 riastrad if test yes = "$module"; then
9444 1.1 riastrad echo
9445 1.1 riastrad echo "*** Warning: libtool could not satisfy all declared inter-library"
9446 1.1 riastrad $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
9447 1.1 riastrad echo "*** a static module, that should work as long as the dlopening"
9448 1.1 riastrad echo "*** application is linked with the -dlopen flag."
9449 1.1 riastrad if test -z "$global_symbol_pipe"; then
9450 1.1 riastrad echo
9451 1.1 riastrad echo "*** However, this would only work if libtool was able to extract symbol"
9452 1.1 riastrad echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9453 1.1 riastrad echo "*** not find such a program. So, this module is probably useless."
9454 1.1 riastrad echo "*** 'nm' from GNU binutils and a full rebuild may help."
9455 1.1 riastrad fi
9456 1.1 riastrad if test no = "$build_old_libs"; then
9457 1.1 riastrad oldlibs=$output_objdir/$libname.$libext
9458 1.1 riastrad build_libtool_libs=module
9459 1.1 riastrad build_old_libs=yes
9460 1.1 riastrad else
9461 1.1 riastrad build_libtool_libs=no
9462 1.1 riastrad fi
9463 1.1 riastrad else
9464 1.1 riastrad echo "*** The inter-library dependencies that have been dropped here will be"
9465 1.1 riastrad echo "*** automatically added whenever a program is linked with this library"
9466 1.1 riastrad echo "*** or is declared to -dlopen it."
9467 1.1 riastrad
9468 1.1 riastrad if test no = "$allow_undefined"; then
9469 1.1 riastrad echo
9470 1.1 riastrad echo "*** Since this library must not contain undefined symbols,"
9471 1.1 riastrad echo "*** because either the platform does not support them or"
9472 1.1 riastrad echo "*** it was explicitly requested with -no-undefined,"
9473 1.1 riastrad echo "*** libtool will only create a static version of it."
9474 1.1 riastrad if test no = "$build_old_libs"; then
9475 1.1 riastrad oldlibs=$output_objdir/$libname.$libext
9476 1.1 riastrad build_libtool_libs=module
9477 1.1 riastrad build_old_libs=yes
9478 1.1 riastrad else
9479 1.1 riastrad build_libtool_libs=no
9480 1.1 riastrad fi
9481 1.1 riastrad fi
9482 1.1 riastrad fi
9483 1.1 riastrad fi
9484 1.1 riastrad # Done checking deplibs!
9485 1.1 riastrad deplibs=$newdeplibs
9486 1.1 riastrad fi
9487 1.1 riastrad # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9488 1.1 riastrad case $host in
9489 1.1 riastrad *-*-darwin*)
9490 1.1 riastrad newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9491 1.1 riastrad new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9492 1.1 riastrad deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9493 1.1 riastrad ;;
9494 1.1 riastrad esac
9495 1.1 riastrad
9496 1.1 riastrad # move library search paths that coincide with paths to not yet
9497 1.1 riastrad # installed libraries to the beginning of the library search list
9498 1.1 riastrad new_libs=
9499 1.1 riastrad for path in $notinst_path; do
9500 1.1 riastrad case " $new_libs " in
9501 1.1 riastrad *" -L$path/$objdir "*) ;;
9502 1.1 riastrad *)
9503 1.1 riastrad case " $deplibs " in
9504 1.1 riastrad *" -L$path/$objdir "*)
9505 1.1 riastrad func_append new_libs " -L$path/$objdir" ;;
9506 1.1 riastrad esac
9507 1.1 riastrad ;;
9508 1.1 riastrad esac
9509 1.1 riastrad done
9510 1.1 riastrad for deplib in $deplibs; do
9511 1.1 riastrad case $deplib in
9512 1.1 riastrad -L*)
9513 1.1 riastrad case " $new_libs " in
9514 1.1 riastrad *" $deplib "*) ;;
9515 1.1 riastrad *) func_append new_libs " $deplib" ;;
9516 1.1 riastrad esac
9517 1.1 riastrad ;;
9518 1.1 riastrad *) func_append new_libs " $deplib" ;;
9519 1.1 riastrad esac
9520 1.1 riastrad done
9521 1.1 riastrad deplibs=$new_libs
9522 1.1 riastrad
9523 1.1 riastrad # All the library-specific variables (install_libdir is set above).
9524 1.1 riastrad library_names=
9525 1.1 riastrad old_library=
9526 1.1 riastrad dlname=
9527 1.1 riastrad
9528 1.1 riastrad # Test again, we may have decided not to build it any more
9529 1.1 riastrad if test yes = "$build_libtool_libs"; then
9530 1.1 riastrad # Remove $wl instances when linking with ld.
9531 1.1 riastrad # FIXME: should test the right _cmds variable.
9532 1.1 riastrad case $archive_cmds in
9533 1.1 riastrad *\$LD\ *) wl= ;;
9534 1.1 riastrad esac
9535 1.1 riastrad if test yes = "$hardcode_into_libs"; then
9536 1.1 riastrad # Hardcode the library paths
9537 1.1 riastrad hardcode_libdirs=
9538 1.1 riastrad dep_rpath=
9539 1.1 riastrad rpath=$finalize_rpath
9540 1.1 riastrad test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9541 1.1 riastrad for libdir in $rpath; do
9542 1.1 riastrad if test -n "$hardcode_libdir_flag_spec"; then
9543 1.1 riastrad if test -n "$hardcode_libdir_separator"; then
9544 1.1 riastrad func_replace_sysroot "$libdir"
9545 1.1 riastrad libdir=$func_replace_sysroot_result
9546 1.1 riastrad if test -z "$hardcode_libdirs"; then
9547 1.1 riastrad hardcode_libdirs=$libdir
9548 1.1 riastrad else
9549 1.1 riastrad # Just accumulate the unique libdirs.
9550 1.1 riastrad case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9551 1.1 riastrad *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9552 1.1 riastrad ;;
9553 1.1 riastrad *)
9554 1.1 riastrad func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9555 1.1 riastrad ;;
9556 1.1 riastrad esac
9557 1.1 riastrad fi
9558 1.1 riastrad else
9559 1.1 riastrad eval flag=\"$hardcode_libdir_flag_spec\"
9560 1.1 riastrad func_append dep_rpath " $flag"
9561 1.1 riastrad fi
9562 1.1 riastrad elif test -n "$runpath_var"; then
9563 1.1 riastrad case "$perm_rpath " in
9564 1.1 riastrad *" $libdir "*) ;;
9565 1.1 riastrad *) func_append perm_rpath " $libdir" ;;
9566 1.1 riastrad esac
9567 1.1 riastrad fi
9568 1.1 riastrad done
9569 1.1 riastrad # Substitute the hardcoded libdirs into the rpath.
9570 1.1 riastrad if test -n "$hardcode_libdir_separator" &&
9571 1.1 riastrad test -n "$hardcode_libdirs"; then
9572 1.1 riastrad libdir=$hardcode_libdirs
9573 1.1 riastrad eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9574 1.1 riastrad fi
9575 1.1 riastrad if test -n "$runpath_var" && test -n "$perm_rpath"; then
9576 1.1 riastrad # We should set the runpath_var.
9577 1.1 riastrad rpath=
9578 1.1 riastrad for dir in $perm_rpath; do
9579 1.1 riastrad func_append rpath "$dir:"
9580 1.1 riastrad done
9581 1.1 riastrad eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9582 1.1 riastrad fi
9583 1.1 riastrad test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9584 1.1 riastrad fi
9585 1.1 riastrad
9586 1.1 riastrad shlibpath=$finalize_shlibpath
9587 1.1 riastrad test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9588 1.1 riastrad if test -n "$shlibpath"; then
9589 1.1 riastrad eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9590 1.1 riastrad fi
9591 1.1 riastrad
9592 1.1 riastrad # Get the real and link names of the library.
9593 1.1 riastrad eval shared_ext=\"$shrext_cmds\"
9594 1.1 riastrad eval library_names=\"$library_names_spec\"
9595 1.1 riastrad set dummy $library_names
9596 1.1 riastrad shift
9597 1.1 riastrad realname=$1
9598 1.1 riastrad shift
9599 1.1 riastrad
9600 1.1 riastrad if test -n "$soname_spec"; then
9601 1.1 riastrad eval soname=\"$soname_spec\"
9602 1.1 riastrad else
9603 1.1 riastrad soname=$realname
9604 1.1 riastrad fi
9605 1.1 riastrad if test -z "$dlname"; then
9606 1.1 riastrad dlname=$soname
9607 1.1 riastrad fi
9608 1.1 riastrad
9609 1.1 riastrad lib=$output_objdir/$realname
9610 1.1 riastrad linknames=
9611 1.1 riastrad for link
9612 1.1 riastrad do
9613 1.1 riastrad func_append linknames " $link"
9614 1.1 riastrad done
9615 1.1 riastrad
9616 1.1 riastrad # Use standard objects if they are pic
9617 1.1 riastrad test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9618 1.1 riastrad test "X$libobjs" = "X " && libobjs=
9619 1.1 riastrad
9620 1.1 riastrad delfiles=
9621 1.1 riastrad if test -n "$export_symbols" && test -n "$include_expsyms"; then
9622 1.1 riastrad $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9623 1.1 riastrad export_symbols=$output_objdir/$libname.uexp
9624 1.1 riastrad func_append delfiles " $export_symbols"
9625 1.1 riastrad fi
9626 1.1 riastrad
9627 1.1 riastrad orig_export_symbols=
9628 1.1 riastrad case $host_os in
9629 1.1 riastrad cygwin* | mingw* | cegcc*)
9630 1.1 riastrad if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9631 1.1 riastrad # exporting using user supplied symfile
9632 1.1 riastrad func_dll_def_p "$export_symbols" || {
9633 1.1 riastrad # and it's NOT already a .def file. Must figure out
9634 1.1 riastrad # which of the given symbols are data symbols and tag
9635 1.1 riastrad # them as such. So, trigger use of export_symbols_cmds.
9636 1.1 riastrad # export_symbols gets reassigned inside the "prepare
9637 1.1 riastrad # the list of exported symbols" if statement, so the
9638 1.1 riastrad # include_expsyms logic still works.
9639 1.1 riastrad orig_export_symbols=$export_symbols
9640 1.1 riastrad export_symbols=
9641 1.1 riastrad always_export_symbols=yes
9642 1.1 riastrad }
9643 1.1 riastrad fi
9644 1.1 riastrad ;;
9645 1.1 riastrad esac
9646 1.1 riastrad
9647 1.1 riastrad # Prepare the list of exported symbols
9648 1.1 riastrad if test -z "$export_symbols"; then
9649 1.1 riastrad if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9650 1.1 riastrad func_verbose "generating symbol list for '$libname.la'"
9651 1.1 riastrad export_symbols=$output_objdir/$libname.exp
9652 1.1 riastrad $opt_dry_run || $RM $export_symbols
9653 1.1 riastrad cmds=$export_symbols_cmds
9654 1.1 riastrad save_ifs=$IFS; IFS='~'
9655 1.1 riastrad for cmd1 in $cmds; do
9656 1.1 riastrad IFS=$save_ifs
9657 1.1 riastrad # Take the normal branch if the nm_file_list_spec branch
9658 1.1 riastrad # doesn't work or if tool conversion is not needed.
9659 1.1 riastrad case $nm_file_list_spec~$to_tool_file_cmd in
9660 1.1 riastrad *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9661 1.1 riastrad try_normal_branch=yes
9662 1.1 riastrad eval cmd=\"$cmd1\"
9663 1.1 riastrad func_len " $cmd"
9664 1.1 riastrad len=$func_len_result
9665 1.1 riastrad ;;
9666 1.1 riastrad *)
9667 1.1 riastrad try_normal_branch=no
9668 1.1 riastrad ;;
9669 1.1 riastrad esac
9670 1.1 riastrad if test yes = "$try_normal_branch" \
9671 1.1 riastrad && { test "$len" -lt "$max_cmd_len" \
9672 1.1 riastrad || test "$max_cmd_len" -le -1; }
9673 1.1 riastrad then
9674 1.1 riastrad func_show_eval "$cmd" 'exit $?'
9675 1.1 riastrad skipped_export=false
9676 1.1 riastrad elif test -n "$nm_file_list_spec"; then
9677 1.1 riastrad func_basename "$output"
9678 1.1 riastrad output_la=$func_basename_result
9679 1.1 riastrad save_libobjs=$libobjs
9680 1.1 riastrad save_output=$output
9681 1.1 riastrad output=$output_objdir/$output_la.nm
9682 1.1 riastrad func_to_tool_file "$output"
9683 1.1 riastrad libobjs=$nm_file_list_spec$func_to_tool_file_result
9684 1.1 riastrad func_append delfiles " $output"
9685 1.1 riastrad func_verbose "creating $NM input file list: $output"
9686 1.1 riastrad for obj in $save_libobjs; do
9687 1.1 riastrad func_to_tool_file "$obj"
9688 1.1 riastrad $ECHO "$func_to_tool_file_result"
9689 1.1 riastrad done > "$output"
9690 1.1 riastrad eval cmd=\"$cmd1\"
9691 1.1 riastrad func_show_eval "$cmd" 'exit $?'
9692 1.1 riastrad output=$save_output
9693 1.1 riastrad libobjs=$save_libobjs
9694 1.1 riastrad skipped_export=false
9695 1.1 riastrad else
9696 1.1 riastrad # The command line is too long to execute in one step.
9697 1.1 riastrad func_verbose "using reloadable object file for export list..."
9698 1.1 riastrad skipped_export=:
9699 1.1 riastrad # Break out early, otherwise skipped_export may be
9700 1.1 riastrad # set to false by a later but shorter cmd.
9701 1.1 riastrad break
9702 1.1 riastrad fi
9703 1.1 riastrad done
9704 1.1 riastrad IFS=$save_ifs
9705 1.1 riastrad if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9706 1.1 riastrad func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9707 1.1 riastrad func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9708 1.1 riastrad fi
9709 1.1 riastrad fi
9710 1.1 riastrad fi
9711 1.1 riastrad
9712 1.1 riastrad if test -n "$export_symbols" && test -n "$include_expsyms"; then
9713 1.1 riastrad tmp_export_symbols=$export_symbols
9714 1.1 riastrad test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9715 1.1 riastrad $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9716 1.1 riastrad fi
9717 1.1 riastrad
9718 1.1 riastrad if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9719 1.1 riastrad # The given exports_symbols file has to be filtered, so filter it.
9720 1.1 riastrad func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9721 1.1 riastrad # FIXME: $output_objdir/$libname.filter potentially contains lots of
9722 1.1 riastrad # 's' commands, which not all seds can handle. GNU sed should be fine
9723 1.1 riastrad # though. Also, the filter scales superlinearly with the number of
9724 1.1 riastrad # global variables. join(1) would be nice here, but unfortunately
9725 1.1 riastrad # isn't a blessed tool.
9726 1.1 riastrad $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9727 1.1 riastrad func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9728 1.1 riastrad export_symbols=$output_objdir/$libname.def
9729 1.1 riastrad $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9730 1.1 riastrad fi
9731 1.1 riastrad
9732 1.1 riastrad tmp_deplibs=
9733 1.1 riastrad for test_deplib in $deplibs; do
9734 1.1 riastrad case " $convenience " in
9735 1.1 riastrad *" $test_deplib "*) ;;
9736 1.1 riastrad *)
9737 1.1 riastrad func_append tmp_deplibs " $test_deplib"
9738 1.1 riastrad ;;
9739 1.1 riastrad esac
9740 1.1 riastrad done
9741 1.1 riastrad deplibs=$tmp_deplibs
9742 1.1 riastrad
9743 1.1 riastrad if test -n "$convenience"; then
9744 1.1 riastrad if test -n "$whole_archive_flag_spec" &&
9745 1.1 riastrad test yes = "$compiler_needs_object" &&
9746 1.1 riastrad test -z "$libobjs"; then
9747 1.1 riastrad # extract the archives, so we have objects to list.
9748 1.1 riastrad # TODO: could optimize this to just extract one archive.
9749 1.1 riastrad whole_archive_flag_spec=
9750 1.1 riastrad fi
9751 1.1 riastrad if test -n "$whole_archive_flag_spec"; then
9752 1.1 riastrad save_libobjs=$libobjs
9753 1.1 riastrad eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9754 1.1 riastrad test "X$libobjs" = "X " && libobjs=
9755 1.1 riastrad else
9756 1.1 riastrad gentop=$output_objdir/${outputname}x
9757 1.1 riastrad func_append generated " $gentop"
9758 1.1 riastrad
9759 1.1 riastrad func_extract_archives $gentop $convenience
9760 1.1 riastrad func_append libobjs " $func_extract_archives_result"
9761 1.1 riastrad test "X$libobjs" = "X " && libobjs=
9762 1.1 riastrad fi
9763 1.1 riastrad fi
9764 1.1 riastrad
9765 1.1 riastrad if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9766 1.1 riastrad eval flag=\"$thread_safe_flag_spec\"
9767 1.1 riastrad func_append linker_flags " $flag"
9768 1.1 riastrad fi
9769 1.1 riastrad
9770 1.1 riastrad # Make a backup of the uninstalled library when relinking
9771 1.1 riastrad if test relink = "$opt_mode"; then
9772 1.1 riastrad $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9773 1.1 riastrad fi
9774 1.1 riastrad
9775 1.1 riastrad # Do each of the archive commands.
9776 1.1 riastrad if test yes = "$module" && test -n "$module_cmds"; then
9777 1.1 riastrad if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9778 1.1 riastrad eval test_cmds=\"$module_expsym_cmds\"
9779 1.1 riastrad cmds=$module_expsym_cmds
9780 1.1 riastrad else
9781 1.1 riastrad eval test_cmds=\"$module_cmds\"
9782 1.1 riastrad cmds=$module_cmds
9783 1.1 riastrad fi
9784 1.1 riastrad else
9785 1.1 riastrad if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9786 1.1 riastrad eval test_cmds=\"$archive_expsym_cmds\"
9787 1.1 riastrad cmds=$archive_expsym_cmds
9788 1.1 riastrad else
9789 1.1 riastrad eval test_cmds=\"$archive_cmds\"
9790 1.1 riastrad cmds=$archive_cmds
9791 1.1 riastrad fi
9792 1.1 riastrad fi
9793 1.1 riastrad
9794 1.1 riastrad if test : != "$skipped_export" &&
9795 1.1 riastrad func_len " $test_cmds" &&
9796 1.1 riastrad len=$func_len_result &&
9797 1.1 riastrad test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9798 1.1 riastrad :
9799 1.1 riastrad else
9800 1.1 riastrad # The command line is too long to link in one step, link piecewise
9801 1.1 riastrad # or, if using GNU ld and skipped_export is not :, use a linker
9802 1.1 riastrad # script.
9803 1.1 riastrad
9804 1.1 riastrad # Save the value of $output and $libobjs because we want to
9805 1.1 riastrad # use them later. If we have whole_archive_flag_spec, we
9806 1.1 riastrad # want to use save_libobjs as it was before
9807 1.1 riastrad # whole_archive_flag_spec was expanded, because we can't
9808 1.1 riastrad # assume the linker understands whole_archive_flag_spec.
9809 1.1 riastrad # This may have to be revisited, in case too many
9810 1.1 riastrad # convenience libraries get linked in and end up exceeding
9811 1.1 riastrad # the spec.
9812 1.1 riastrad if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9813 1.1 riastrad save_libobjs=$libobjs
9814 1.1 riastrad fi
9815 1.1 riastrad save_output=$output
9816 1.1 riastrad func_basename "$output"
9817 1.1 riastrad output_la=$func_basename_result
9818 1.1 riastrad
9819 1.1 riastrad # Clear the reloadable object creation command queue and
9820 1.1 riastrad # initialize k to one.
9821 1.1 riastrad test_cmds=
9822 1.1 riastrad concat_cmds=
9823 1.1 riastrad objlist=
9824 1.1 riastrad last_robj=
9825 1.1 riastrad k=1
9826 1.1 riastrad
9827 1.1 riastrad if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9828 1.1 riastrad output=$output_objdir/$output_la.lnkscript
9829 1.1 riastrad func_verbose "creating GNU ld script: $output"
9830 1.1 riastrad echo 'INPUT (' > $output
9831 1.1 riastrad for obj in $save_libobjs
9832 1.1 riastrad do
9833 1.1 riastrad func_to_tool_file "$obj"
9834 1.1 riastrad $ECHO "$func_to_tool_file_result" >> $output
9835 1.1 riastrad done
9836 1.1 riastrad echo ')' >> $output
9837 1.1 riastrad func_append delfiles " $output"
9838 1.1 riastrad func_to_tool_file "$output"
9839 1.1 riastrad output=$func_to_tool_file_result
9840 1.1 riastrad elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9841 1.1 riastrad output=$output_objdir/$output_la.lnk
9842 1.1 riastrad func_verbose "creating linker input file list: $output"
9843 1.1 riastrad : > $output
9844 1.1 riastrad set x $save_libobjs
9845 1.1 riastrad shift
9846 1.1 riastrad firstobj=
9847 1.1 riastrad if test yes = "$compiler_needs_object"; then
9848 1.1 riastrad firstobj="$1 "
9849 1.1 riastrad shift
9850 1.1 riastrad fi
9851 1.1 riastrad for obj
9852 1.1 riastrad do
9853 1.1 riastrad func_to_tool_file "$obj"
9854 1.1 riastrad $ECHO "$func_to_tool_file_result" >> $output
9855 1.1 riastrad done
9856 1.1 riastrad func_append delfiles " $output"
9857 1.1 riastrad func_to_tool_file "$output"
9858 1.1 riastrad output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9859 1.1 riastrad else
9860 1.1 riastrad if test -n "$save_libobjs"; then
9861 1.1 riastrad func_verbose "creating reloadable object files..."
9862 1.1 riastrad output=$output_objdir/$output_la-$k.$objext
9863 1.1 riastrad eval test_cmds=\"$reload_cmds\"
9864 1.1 riastrad func_len " $test_cmds"
9865 1.1 riastrad len0=$func_len_result
9866 1.1 riastrad len=$len0
9867 1.1 riastrad
9868 1.1 riastrad # Loop over the list of objects to be linked.
9869 1.1 riastrad for obj in $save_libobjs
9870 1.1 riastrad do
9871 1.1 riastrad func_len " $obj"
9872 1.1 riastrad func_arith $len + $func_len_result
9873 1.1 riastrad len=$func_arith_result
9874 1.1 riastrad if test -z "$objlist" ||
9875 1.1 riastrad test "$len" -lt "$max_cmd_len"; then
9876 1.1 riastrad func_append objlist " $obj"
9877 1.1 riastrad else
9878 1.1 riastrad # The command $test_cmds is almost too long, add a
9879 1.1 riastrad # command to the queue.
9880 1.1 riastrad if test 1 -eq "$k"; then
9881 1.1 riastrad # The first file doesn't have a previous command to add.
9882 1.1 riastrad reload_objs=$objlist
9883 1.1 riastrad eval concat_cmds=\"$reload_cmds\"
9884 1.1 riastrad else
9885 1.1 riastrad # All subsequent reloadable object files will link in
9886 1.1 riastrad # the last one created.
9887 1.1 riastrad reload_objs="$objlist $last_robj"
9888 1.1 riastrad eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9889 1.1 riastrad fi
9890 1.1 riastrad last_robj=$output_objdir/$output_la-$k.$objext
9891 1.1 riastrad func_arith $k + 1
9892 1.1 riastrad k=$func_arith_result
9893 1.1 riastrad output=$output_objdir/$output_la-$k.$objext
9894 1.1 riastrad objlist=" $obj"
9895 1.1 riastrad func_len " $last_robj"
9896 1.1 riastrad func_arith $len0 + $func_len_result
9897 1.1 riastrad len=$func_arith_result
9898 1.1 riastrad fi
9899 1.1 riastrad done
9900 1.1 riastrad # Handle the remaining objects by creating one last
9901 1.1 riastrad # reloadable object file. All subsequent reloadable object
9902 1.1 riastrad # files will link in the last one created.
9903 1.1 riastrad test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9904 1.1 riastrad reload_objs="$objlist $last_robj"
9905 1.1 riastrad eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9906 1.1 riastrad if test -n "$last_robj"; then
9907 1.1 riastrad eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9908 1.1 riastrad fi
9909 1.1 riastrad func_append delfiles " $output"
9910 1.1 riastrad
9911 1.1 riastrad else
9912 1.1 riastrad output=
9913 1.1 riastrad fi
9914 1.1 riastrad
9915 1.1 riastrad ${skipped_export-false} && {
9916 1.1 riastrad func_verbose "generating symbol list for '$libname.la'"
9917 1.1 riastrad export_symbols=$output_objdir/$libname.exp
9918 1.1 riastrad $opt_dry_run || $RM $export_symbols
9919 1.1 riastrad libobjs=$output
9920 1.1 riastrad # Append the command to create the export file.
9921 1.1 riastrad test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9922 1.1 riastrad eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9923 1.1 riastrad if test -n "$last_robj"; then
9924 1.1 riastrad eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9925 1.1 riastrad fi
9926 1.1 riastrad }
9927 1.1 riastrad
9928 1.1 riastrad test -n "$save_libobjs" &&
9929 1.1 riastrad func_verbose "creating a temporary reloadable object file: $output"
9930 1.1 riastrad
9931 1.1 riastrad # Loop through the commands generated above and execute them.
9932 1.1 riastrad save_ifs=$IFS; IFS='~'
9933 1.1 riastrad for cmd in $concat_cmds; do
9934 1.1 riastrad IFS=$save_ifs
9935 1.1 riastrad $opt_quiet || {
9936 1.1 riastrad func_quote_for_expand "$cmd"
9937 1.1 riastrad eval "func_echo $func_quote_for_expand_result"
9938 1.1 riastrad }
9939 1.1 riastrad $opt_dry_run || eval "$cmd" || {
9940 1.1 riastrad lt_exit=$?
9941 1.1 riastrad
9942 1.1 riastrad # Restore the uninstalled library and exit
9943 1.1 riastrad if test relink = "$opt_mode"; then
9944 1.1 riastrad ( cd "$output_objdir" && \
9945 1.1 riastrad $RM "${realname}T" && \
9946 1.1 riastrad $MV "${realname}U" "$realname" )
9947 1.1 riastrad fi
9948 1.1 riastrad
9949 1.1 riastrad exit $lt_exit
9950 1.1 riastrad }
9951 1.1 riastrad done
9952 1.1 riastrad IFS=$save_ifs
9953 1.1 riastrad
9954 1.1 riastrad if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9955 1.1 riastrad func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9956 1.1 riastrad func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9957 1.1 riastrad fi
9958 1.1 riastrad fi
9959 1.1 riastrad
9960 1.1 riastrad ${skipped_export-false} && {
9961 1.1 riastrad if test -n "$export_symbols" && test -n "$include_expsyms"; then
9962 1.1 riastrad tmp_export_symbols=$export_symbols
9963 1.1 riastrad test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9964 1.1 riastrad $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9965 1.1 riastrad fi
9966 1.1 riastrad
9967 1.1 riastrad if test -n "$orig_export_symbols"; then
9968 1.1 riastrad # The given exports_symbols file has to be filtered, so filter it.
9969 1.1 riastrad func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9970 1.1 riastrad # FIXME: $output_objdir/$libname.filter potentially contains lots of
9971 1.1 riastrad # 's' commands, which not all seds can handle. GNU sed should be fine
9972 1.1 riastrad # though. Also, the filter scales superlinearly with the number of
9973 1.1 riastrad # global variables. join(1) would be nice here, but unfortunately
9974 1.1 riastrad # isn't a blessed tool.
9975 1.1 riastrad $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9976 1.1 riastrad func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9977 1.1 riastrad export_symbols=$output_objdir/$libname.def
9978 1.1 riastrad $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9979 1.1 riastrad fi
9980 1.1 riastrad }
9981 1.1 riastrad
9982 1.1 riastrad libobjs=$output
9983 1.1 riastrad # Restore the value of output.
9984 1.1 riastrad output=$save_output
9985 1.1 riastrad
9986 1.1 riastrad if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9987 1.1 riastrad eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9988 1.1 riastrad test "X$libobjs" = "X " && libobjs=
9989 1.1 riastrad fi
9990 1.1 riastrad # Expand the library linking commands again to reset the
9991 1.1 riastrad # value of $libobjs for piecewise linking.
9992 1.1 riastrad
9993 1.1 riastrad # Do each of the archive commands.
9994 1.1 riastrad if test yes = "$module" && test -n "$module_cmds"; then
9995 1.1 riastrad if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9996 1.1 riastrad cmds=$module_expsym_cmds
9997 1.1 riastrad else
9998 1.1 riastrad cmds=$module_cmds
9999 1.1 riastrad fi
10000 1.1 riastrad else
10001 1.1 riastrad if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10002 1.1 riastrad cmds=$archive_expsym_cmds
10003 1.1 riastrad else
10004 1.1 riastrad cmds=$archive_cmds
10005 1.1 riastrad fi
10006 1.1 riastrad fi
10007 1.1 riastrad fi
10008 1.1 riastrad
10009 1.1 riastrad if test -n "$delfiles"; then
10010 1.1 riastrad # Append the command to remove temporary files to $cmds.
10011 1.1 riastrad eval cmds=\"\$cmds~\$RM $delfiles\"
10012 1.1 riastrad fi
10013 1.1 riastrad
10014 1.1 riastrad # Add any objects from preloaded convenience libraries
10015 1.1 riastrad if test -n "$dlprefiles"; then
10016 1.1 riastrad gentop=$output_objdir/${outputname}x
10017 1.1 riastrad func_append generated " $gentop"
10018 1.1 riastrad
10019 1.1 riastrad func_extract_archives $gentop $dlprefiles
10020 1.1 riastrad func_append libobjs " $func_extract_archives_result"
10021 1.1 riastrad test "X$libobjs" = "X " && libobjs=
10022 1.1 riastrad fi
10023 1.1 riastrad
10024 1.1 riastrad save_ifs=$IFS; IFS='~'
10025 1.1 riastrad for cmd in $cmds; do
10026 1.1 riastrad IFS=$sp$nl
10027 1.1 riastrad eval cmd=\"$cmd\"
10028 1.1 riastrad IFS=$save_ifs
10029 1.1 riastrad $opt_quiet || {
10030 1.1 riastrad func_quote_for_expand "$cmd"
10031 1.1 riastrad eval "func_echo $func_quote_for_expand_result"
10032 1.1 riastrad }
10033 1.1 riastrad $opt_dry_run || eval "$cmd" || {
10034 1.1 riastrad lt_exit=$?
10035 1.1 riastrad
10036 1.1 riastrad # Restore the uninstalled library and exit
10037 1.1 riastrad if test relink = "$opt_mode"; then
10038 1.1 riastrad ( cd "$output_objdir" && \
10039 1.1 riastrad $RM "${realname}T" && \
10040 1.1 riastrad $MV "${realname}U" "$realname" )
10041 1.1 riastrad fi
10042 1.1 riastrad
10043 1.1 riastrad exit $lt_exit
10044 1.1 riastrad }
10045 1.1 riastrad done
10046 1.1 riastrad IFS=$save_ifs
10047 1.1 riastrad
10048 1.1 riastrad # Restore the uninstalled library and exit
10049 1.1 riastrad if test relink = "$opt_mode"; then
10050 1.1 riastrad $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10051 1.1 riastrad
10052 1.1 riastrad if test -n "$convenience"; then
10053 1.1 riastrad if test -z "$whole_archive_flag_spec"; then
10054 1.1 riastrad func_show_eval '${RM}r "$gentop"'
10055 1.1 riastrad fi
10056 1.1 riastrad fi
10057 1.1 riastrad
10058 1.1 riastrad exit $EXIT_SUCCESS
10059 1.1 riastrad fi
10060 1.1 riastrad
10061 1.1 riastrad # Create links to the real library.
10062 1.1 riastrad for linkname in $linknames; do
10063 1.1 riastrad if test "$realname" != "$linkname"; then
10064 1.1 riastrad func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10065 1.1 riastrad fi
10066 1.1 riastrad done
10067 1.1 riastrad
10068 1.1 riastrad # If -module or -export-dynamic was specified, set the dlname.
10069 1.1 riastrad if test yes = "$module" || test yes = "$export_dynamic"; then
10070 1.1 riastrad # On all known operating systems, these are identical.
10071 1.1 riastrad dlname=$soname
10072 1.1 riastrad fi
10073 1.1 riastrad fi
10074 1.1 riastrad ;;
10075 1.1 riastrad
10076 1.1 riastrad obj)
10077 1.1 riastrad if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10078 1.1 riastrad func_warning "'-dlopen' is ignored for objects"
10079 1.1 riastrad fi
10080 1.1 riastrad
10081 1.1 riastrad case " $deplibs" in
10082 1.1 riastrad *\ -l* | *\ -L*)
10083 1.1 riastrad func_warning "'-l' and '-L' are ignored for objects" ;;
10084 1.1 riastrad esac
10085 1.1 riastrad
10086 1.1 riastrad test -n "$rpath" && \
10087 1.1 riastrad func_warning "'-rpath' is ignored for objects"
10088 1.1 riastrad
10089 1.1 riastrad test -n "$xrpath" && \
10090 1.1 riastrad func_warning "'-R' is ignored for objects"
10091 1.1 riastrad
10092 1.1 riastrad test -n "$vinfo" && \
10093 1.1 riastrad func_warning "'-version-info' is ignored for objects"
10094 1.1 riastrad
10095 1.1 riastrad test -n "$release" && \
10096 1.1 riastrad func_warning "'-release' is ignored for objects"
10097 1.1 riastrad
10098 1.1 riastrad case $output in
10099 1.1 riastrad *.lo)
10100 1.1 riastrad test -n "$objs$old_deplibs" && \
10101 1.1 riastrad func_fatal_error "cannot build library object '$output' from non-libtool objects"
10102 1.1 riastrad
10103 1.1 riastrad libobj=$output
10104 1.1 riastrad func_lo2o "$libobj"
10105 1.1 riastrad obj=$func_lo2o_result
10106 1.1 riastrad ;;
10107 1.1 riastrad *)
10108 1.1 riastrad libobj=
10109 1.1 riastrad obj=$output
10110 1.1 riastrad ;;
10111 1.1 riastrad esac
10112 1.1 riastrad
10113 1.1 riastrad # Delete the old objects.
10114 1.1 riastrad $opt_dry_run || $RM $obj $libobj
10115 1.1 riastrad
10116 1.1 riastrad # Objects from convenience libraries. This assumes
10117 1.1 riastrad # single-version convenience libraries. Whenever we create
10118 1.1 riastrad # different ones for PIC/non-PIC, this we'll have to duplicate
10119 1.1 riastrad # the extraction.
10120 1.1 riastrad reload_conv_objs=
10121 1.1 riastrad gentop=
10122 1.1 riastrad # if reload_cmds runs $LD directly, get rid of -Wl from
10123 1.1 riastrad # whole_archive_flag_spec and hope we can get by with turning comma
10124 1.1 riastrad # into space.
10125 1.1 riastrad case $reload_cmds in
10126 1.1 riastrad *\$LD[\ \$]*) wl= ;;
10127 1.1 riastrad esac
10128 1.1 riastrad if test -n "$convenience"; then
10129 1.1 riastrad if test -n "$whole_archive_flag_spec"; then
10130 1.1 riastrad eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10131 1.1 riastrad test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10132 1.1 riastrad reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10133 1.1 riastrad else
10134 1.1 riastrad gentop=$output_objdir/${obj}x
10135 1.1 riastrad func_append generated " $gentop"
10136 1.1 riastrad
10137 1.1 riastrad func_extract_archives $gentop $convenience
10138 1.1 riastrad reload_conv_objs="$reload_objs $func_extract_archives_result"
10139 1.1 riastrad fi
10140 1.1 riastrad fi
10141 1.1 riastrad
10142 1.1 riastrad # If we're not building shared, we need to use non_pic_objs
10143 1.1 riastrad test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10144 1.1 riastrad
10145 1.1 riastrad # Create the old-style object.
10146 1.1 riastrad reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10147 1.1 riastrad
10148 1.1 riastrad output=$obj
10149 1.1 riastrad func_execute_cmds "$reload_cmds" 'exit $?'
10150 1.1 riastrad
10151 1.1 riastrad # Exit if we aren't doing a library object file.
10152 1.1 riastrad if test -z "$libobj"; then
10153 1.1 riastrad if test -n "$gentop"; then
10154 1.1 riastrad func_show_eval '${RM}r "$gentop"'
10155 1.1 riastrad fi
10156 1.1 riastrad
10157 1.1 riastrad exit $EXIT_SUCCESS
10158 1.1 riastrad fi
10159 1.1 riastrad
10160 1.1 riastrad test yes = "$build_libtool_libs" || {
10161 1.1 riastrad if test -n "$gentop"; then
10162 1.1 riastrad func_show_eval '${RM}r "$gentop"'
10163 1.1 riastrad fi
10164 1.1 riastrad
10165 1.1 riastrad # Create an invalid libtool object if no PIC, so that we don't
10166 1.1 riastrad # accidentally link it into a program.
10167 1.1 riastrad # $show "echo timestamp > $libobj"
10168 1.1 riastrad # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10169 1.1 riastrad exit $EXIT_SUCCESS
10170 1.1 riastrad }
10171 1.1 riastrad
10172 1.1 riastrad if test -n "$pic_flag" || test default != "$pic_mode"; then
10173 1.1 riastrad # Only do commands if we really have different PIC objects.
10174 1.1 riastrad reload_objs="$libobjs $reload_conv_objs"
10175 1.1 riastrad output=$libobj
10176 1.1 riastrad func_execute_cmds "$reload_cmds" 'exit $?'
10177 1.1 riastrad fi
10178 1.1 riastrad
10179 1.1 riastrad if test -n "$gentop"; then
10180 1.1 riastrad func_show_eval '${RM}r "$gentop"'
10181 1.1 riastrad fi
10182 1.1 riastrad
10183 1.1 riastrad exit $EXIT_SUCCESS
10184 1.1 riastrad ;;
10185 1.1 riastrad
10186 1.1 riastrad prog)
10187 1.1 riastrad case $host in
10188 1.1 riastrad *cygwin*) func_stripname '' '.exe' "$output"
10189 1.1 riastrad output=$func_stripname_result.exe;;
10190 1.1 riastrad esac
10191 1.1 riastrad test -n "$vinfo" && \
10192 1.1 riastrad func_warning "'-version-info' is ignored for programs"
10193 1.1 riastrad
10194 1.1 riastrad test -n "$release" && \
10195 1.1 riastrad func_warning "'-release' is ignored for programs"
10196 1.1 riastrad
10197 1.1 riastrad $preload \
10198 1.1 riastrad && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10199 1.1 riastrad && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10200 1.1 riastrad
10201 1.1 riastrad case $host in
10202 1.1 riastrad *-*-rhapsody* | *-*-darwin1.[012])
10203 1.1 riastrad # On Rhapsody replace the C library is the System framework
10204 1.1 riastrad compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10205 1.1 riastrad finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10206 1.1 riastrad ;;
10207 1.1 riastrad esac
10208 1.1 riastrad
10209 1.1 riastrad case $host in
10210 1.1 riastrad *-*-darwin*)
10211 1.1 riastrad # Don't allow lazy linking, it breaks C++ global constructors
10212 1.1 riastrad # But is supposedly fixed on 10.4 or later (yay!).
10213 1.1 riastrad if test CXX = "$tagname"; then
10214 1.1 riastrad case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10215 1.1 riastrad 10.[0123])
10216 1.1 riastrad func_append compile_command " $wl-bind_at_load"
10217 1.1 riastrad func_append finalize_command " $wl-bind_at_load"
10218 1.1 riastrad ;;
10219 1.1 riastrad esac
10220 1.1 riastrad fi
10221 1.1 riastrad # Time to change all our "foo.ltframework" stuff back to "-framework foo"
10222 1.1 riastrad compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10223 1.1 riastrad finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10224 1.1 riastrad ;;
10225 1.1 riastrad esac
10226 1.1 riastrad
10227 1.1 riastrad
10228 1.1 riastrad # move library search paths that coincide with paths to not yet
10229 1.1 riastrad # installed libraries to the beginning of the library search list
10230 1.1 riastrad new_libs=
10231 1.1 riastrad for path in $notinst_path; do
10232 1.1 riastrad case " $new_libs " in
10233 1.1 riastrad *" -L$path/$objdir "*) ;;
10234 1.1 riastrad *)
10235 1.1 riastrad case " $compile_deplibs " in
10236 1.1 riastrad *" -L$path/$objdir "*)
10237 1.1 riastrad func_append new_libs " -L$path/$objdir" ;;
10238 1.1 riastrad esac
10239 1.1 riastrad ;;
10240 1.1 riastrad esac
10241 1.1 riastrad done
10242 1.1 riastrad for deplib in $compile_deplibs; do
10243 1.1 riastrad case $deplib in
10244 1.1 riastrad -L*)
10245 1.1 riastrad case " $new_libs " in
10246 1.1 riastrad *" $deplib "*) ;;
10247 1.1 riastrad *) func_append new_libs " $deplib" ;;
10248 1.1 riastrad esac
10249 1.1 riastrad ;;
10250 1.1 riastrad *) func_append new_libs " $deplib" ;;
10251 1.1 riastrad esac
10252 1.1 riastrad done
10253 1.1 riastrad compile_deplibs=$new_libs
10254 1.1 riastrad
10255 1.1 riastrad
10256 1.1 riastrad func_append compile_command " $compile_deplibs"
10257 1.1 riastrad func_append finalize_command " $finalize_deplibs"
10258 1.1 riastrad
10259 1.1 riastrad if test -n "$rpath$xrpath"; then
10260 1.1 riastrad # If the user specified any rpath flags, then add them.
10261 1.1 riastrad for libdir in $rpath $xrpath; do
10262 1.1 riastrad # This is the magic to use -rpath.
10263 1.1 riastrad case "$finalize_rpath " in
10264 1.1 riastrad *" $libdir "*) ;;
10265 1.1 riastrad *) func_append finalize_rpath " $libdir" ;;
10266 1.1 riastrad esac
10267 1.1 riastrad done
10268 1.1 riastrad fi
10269 1.1 riastrad
10270 1.1 riastrad # Now hardcode the library paths
10271 1.1 riastrad rpath=
10272 1.1 riastrad hardcode_libdirs=
10273 1.1 riastrad for libdir in $compile_rpath $finalize_rpath; do
10274 1.1 riastrad if test -n "$hardcode_libdir_flag_spec"; then
10275 1.1 riastrad if test -n "$hardcode_libdir_separator"; then
10276 1.1 riastrad if test -z "$hardcode_libdirs"; then
10277 1.1 riastrad hardcode_libdirs=$libdir
10278 1.1 riastrad else
10279 1.1 riastrad # Just accumulate the unique libdirs.
10280 1.1 riastrad case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10281 1.1 riastrad *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10282 1.1 riastrad ;;
10283 1.1 riastrad *)
10284 1.1 riastrad func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10285 1.1 riastrad ;;
10286 1.1 riastrad esac
10287 1.1 riastrad fi
10288 1.1 riastrad else
10289 1.1 riastrad eval flag=\"$hardcode_libdir_flag_spec\"
10290 1.1 riastrad func_append rpath " $flag"
10291 1.1 riastrad fi
10292 1.1 riastrad elif test -n "$runpath_var"; then
10293 1.1 riastrad case "$perm_rpath " in
10294 1.1 riastrad *" $libdir "*) ;;
10295 1.1 riastrad *) func_append perm_rpath " $libdir" ;;
10296 1.1 riastrad esac
10297 1.1 riastrad fi
10298 1.1 riastrad case $host in
10299 1.1 riastrad *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10300 1.1 riastrad testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10301 1.1 riastrad case :$dllsearchpath: in
10302 1.1 riastrad *":$libdir:"*) ;;
10303 1.1 riastrad ::) dllsearchpath=$libdir;;
10304 1.1 riastrad *) func_append dllsearchpath ":$libdir";;
10305 1.1 riastrad esac
10306 1.1 riastrad case :$dllsearchpath: in
10307 1.1 riastrad *":$testbindir:"*) ;;
10308 1.1 riastrad ::) dllsearchpath=$testbindir;;
10309 1.1 riastrad *) func_append dllsearchpath ":$testbindir";;
10310 1.1 riastrad esac
10311 1.1 riastrad ;;
10312 1.1 riastrad esac
10313 1.1 riastrad done
10314 1.1 riastrad # Substitute the hardcoded libdirs into the rpath.
10315 1.1 riastrad if test -n "$hardcode_libdir_separator" &&
10316 1.1 riastrad test -n "$hardcode_libdirs"; then
10317 1.1 riastrad libdir=$hardcode_libdirs
10318 1.1 riastrad eval rpath=\" $hardcode_libdir_flag_spec\"
10319 1.1 riastrad fi
10320 1.1 riastrad compile_rpath=$rpath
10321 1.1 riastrad
10322 1.1 riastrad rpath=
10323 1.1 riastrad hardcode_libdirs=
10324 1.1 riastrad for libdir in $finalize_rpath; do
10325 1.1 riastrad if test -n "$hardcode_libdir_flag_spec"; then
10326 1.1 riastrad if test -n "$hardcode_libdir_separator"; then
10327 1.1 riastrad if test -z "$hardcode_libdirs"; then
10328 1.1 riastrad hardcode_libdirs=$libdir
10329 1.1 riastrad else
10330 1.1 riastrad # Just accumulate the unique libdirs.
10331 1.1 riastrad case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10332 1.1 riastrad *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10333 1.1 riastrad ;;
10334 1.1 riastrad *)
10335 1.1 riastrad func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10336 1.1 riastrad ;;
10337 1.1 riastrad esac
10338 1.1 riastrad fi
10339 1.1 riastrad else
10340 1.1 riastrad eval flag=\"$hardcode_libdir_flag_spec\"
10341 1.1 riastrad func_append rpath " $flag"
10342 1.1 riastrad fi
10343 1.1 riastrad elif test -n "$runpath_var"; then
10344 1.1 riastrad case "$finalize_perm_rpath " in
10345 1.1 riastrad *" $libdir "*) ;;
10346 1.1 riastrad *) func_append finalize_perm_rpath " $libdir" ;;
10347 1.1 riastrad esac
10348 1.1 riastrad fi
10349 1.1 riastrad done
10350 1.1 riastrad # Substitute the hardcoded libdirs into the rpath.
10351 1.1 riastrad if test -n "$hardcode_libdir_separator" &&
10352 1.1 riastrad test -n "$hardcode_libdirs"; then
10353 1.1 riastrad libdir=$hardcode_libdirs
10354 1.1 riastrad eval rpath=\" $hardcode_libdir_flag_spec\"
10355 1.1 riastrad fi
10356 1.1 riastrad finalize_rpath=$rpath
10357 1.1 riastrad
10358 1.1 riastrad if test -n "$libobjs" && test yes = "$build_old_libs"; then
10359 1.1 riastrad # Transform all the library objects into standard objects.
10360 1.1 riastrad compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10361 1.1 riastrad finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10362 1.1 riastrad fi
10363 1.1 riastrad
10364 1.1 riastrad func_generate_dlsyms "$outputname" "@PROGRAM@" false
10365 1.1 riastrad
10366 1.1 riastrad # template prelinking step
10367 1.1 riastrad if test -n "$prelink_cmds"; then
10368 1.1 riastrad func_execute_cmds "$prelink_cmds" 'exit $?'
10369 1.1 riastrad fi
10370 1.1 riastrad
10371 1.1 riastrad wrappers_required=:
10372 1.1 riastrad case $host in
10373 1.1 riastrad *cegcc* | *mingw32ce*)
10374 1.1 riastrad # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10375 1.1 riastrad wrappers_required=false
10376 1.1 riastrad ;;
10377 1.1 riastrad *cygwin* | *mingw* )
10378 1.1 riastrad test yes = "$build_libtool_libs" || wrappers_required=false
10379 1.1 riastrad ;;
10380 1.1 riastrad *)
10381 1.1 riastrad if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10382 1.1 riastrad wrappers_required=false
10383 1.1 riastrad fi
10384 1.1 riastrad ;;
10385 1.1 riastrad esac
10386 1.1 riastrad $wrappers_required || {
10387 1.1 riastrad # Replace the output file specification.
10388 1.1 riastrad compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10389 1.1 riastrad link_command=$compile_command$compile_rpath
10390 1.1 riastrad
10391 1.1 riastrad # We have no uninstalled library dependencies, so finalize right now.
10392 1.1 riastrad exit_status=0
10393 1.1 riastrad func_show_eval "$link_command" 'exit_status=$?'
10394 1.1 riastrad
10395 1.1 riastrad if test -n "$postlink_cmds"; then
10396 1.1 riastrad func_to_tool_file "$output"
10397 1.1 riastrad 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 riastrad func_execute_cmds "$postlink_cmds" 'exit $?'
10399 1.1 riastrad fi
10400 1.1 riastrad
10401 1.1 riastrad # Delete the generated files.
10402 1.1 riastrad if test -f "$output_objdir/${outputname}S.$objext"; then
10403 1.1 riastrad func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10404 1.1 riastrad fi
10405 1.1 riastrad
10406 1.1 riastrad exit $exit_status
10407 1.1 riastrad }
10408 1.1 riastrad
10409 1.1 riastrad if test -n "$compile_shlibpath$finalize_shlibpath"; then
10410 1.1 riastrad compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10411 1.1 riastrad fi
10412 1.1 riastrad if test -n "$finalize_shlibpath"; then
10413 1.1 riastrad finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10414 1.1 riastrad fi
10415 1.1 riastrad
10416 1.1 riastrad compile_var=
10417 1.1 riastrad finalize_var=
10418 1.1 riastrad if test -n "$runpath_var"; then
10419 1.1 riastrad if test -n "$perm_rpath"; then
10420 1.1 riastrad # We should set the runpath_var.
10421 1.1 riastrad rpath=
10422 1.1 riastrad for dir in $perm_rpath; do
10423 1.1 riastrad func_append rpath "$dir:"
10424 1.1 riastrad done
10425 1.1 riastrad compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10426 1.1 riastrad fi
10427 1.1 riastrad if test -n "$finalize_perm_rpath"; then
10428 1.1 riastrad # We should set the runpath_var.
10429 1.1 riastrad rpath=
10430 1.1 riastrad for dir in $finalize_perm_rpath; do
10431 1.1 riastrad func_append rpath "$dir:"
10432 1.1 riastrad done
10433 1.1 riastrad finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10434 1.1 riastrad fi
10435 1.1 riastrad fi
10436 1.1 riastrad
10437 1.1 riastrad if test yes = "$no_install"; then
10438 1.1 riastrad # We don't need to create a wrapper script.
10439 1.1 riastrad link_command=$compile_var$compile_command$compile_rpath
10440 1.1 riastrad # Replace the output file specification.
10441 1.1 riastrad link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10442 1.1 riastrad # Delete the old output file.
10443 1.1 riastrad $opt_dry_run || $RM $output
10444 1.1 riastrad # Link the executable and exit
10445 1.1 riastrad func_show_eval "$link_command" 'exit $?'
10446 1.1 riastrad
10447 1.1 riastrad if test -n "$postlink_cmds"; then
10448 1.1 riastrad func_to_tool_file "$output"
10449 1.1 riastrad 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 riastrad func_execute_cmds "$postlink_cmds" 'exit $?'
10451 1.1 riastrad fi
10452 1.1 riastrad
10453 1.1 riastrad exit $EXIT_SUCCESS
10454 1.1 riastrad fi
10455 1.1 riastrad
10456 1.1 riastrad case $hardcode_action,$fast_install in
10457 1.1 riastrad relink,*)
10458 1.1 riastrad # Fast installation is not supported
10459 1.1 riastrad link_command=$compile_var$compile_command$compile_rpath
10460 1.1 riastrad relink_command=$finalize_var$finalize_command$finalize_rpath
10461 1.1 riastrad
10462 1.1 riastrad func_warning "this platform does not like uninstalled shared libraries"
10463 1.1 riastrad func_warning "'$output' will be relinked during installation"
10464 1.1 riastrad ;;
10465 1.1 riastrad *,yes)
10466 1.1 riastrad link_command=$finalize_var$compile_command$finalize_rpath
10467 1.1 riastrad relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10468 1.1 riastrad ;;
10469 1.1 riastrad *,no)
10470 1.1 riastrad link_command=$compile_var$compile_command$compile_rpath
10471 1.1 riastrad relink_command=$finalize_var$finalize_command$finalize_rpath
10472 1.1 riastrad ;;
10473 1.1 riastrad *,needless)
10474 1.1 riastrad link_command=$finalize_var$compile_command$finalize_rpath
10475 1.1 riastrad relink_command=
10476 1.1 riastrad ;;
10477 1.1 riastrad esac
10478 1.1 riastrad
10479 1.1 riastrad # Replace the output file specification.
10480 1.1 riastrad link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10481 1.1 riastrad
10482 1.1 riastrad # Delete the old output files.
10483 1.1 riastrad $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10484 1.1 riastrad
10485 1.1 riastrad func_show_eval "$link_command" 'exit $?'
10486 1.1 riastrad
10487 1.1 riastrad if test -n "$postlink_cmds"; then
10488 1.1 riastrad func_to_tool_file "$output_objdir/$outputname"
10489 1.1 riastrad 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 riastrad func_execute_cmds "$postlink_cmds" 'exit $?'
10491 1.1 riastrad fi
10492 1.1 riastrad
10493 1.1 riastrad # Now create the wrapper script.
10494 1.1 riastrad func_verbose "creating $output"
10495 1.1 riastrad
10496 1.1 riastrad # Quote the relink command for shipping.
10497 1.1 riastrad if test -n "$relink_command"; then
10498 1.1 riastrad # Preserve any variables that may affect compiler behavior
10499 1.1 riastrad for var in $variables_saved_for_relink; do
10500 1.1 riastrad if eval test -z \"\${$var+set}\"; then
10501 1.1 riastrad relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10502 1.1 riastrad elif eval var_value=\$$var; test -z "$var_value"; then
10503 1.1 riastrad relink_command="$var=; export $var; $relink_command"
10504 1.1 riastrad else
10505 1.1 riastrad func_quote_for_eval "$var_value"
10506 1.1 riastrad relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10507 1.1 riastrad fi
10508 1.1 riastrad done
10509 1.1 riastrad relink_command="(cd `pwd`; $relink_command)"
10510 1.1 riastrad relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10511 1.1 riastrad fi
10512 1.1 riastrad
10513 1.1 riastrad # Only actually do things if not in dry run mode.
10514 1.1 riastrad $opt_dry_run || {
10515 1.1 riastrad # win32 will think the script is a binary if it has
10516 1.1 riastrad # a .exe suffix, so we strip it off here.
10517 1.1 riastrad case $output in
10518 1.1 riastrad *.exe) func_stripname '' '.exe' "$output"
10519 1.1 riastrad output=$func_stripname_result ;;
10520 1.1 riastrad esac
10521 1.1 riastrad # test for cygwin because mv fails w/o .exe extensions
10522 1.1 riastrad case $host in
10523 1.1 riastrad *cygwin*)
10524 1.1 riastrad exeext=.exe
10525 1.1 riastrad func_stripname '' '.exe' "$outputname"
10526 1.1 riastrad outputname=$func_stripname_result ;;
10527 1.1 riastrad *) exeext= ;;
10528 1.1 riastrad esac
10529 1.1 riastrad case $host in
10530 1.1 riastrad *cygwin* | *mingw* )
10531 1.1 riastrad func_dirname_and_basename "$output" "" "."
10532 1.1 riastrad output_name=$func_basename_result
10533 1.1 riastrad output_path=$func_dirname_result
10534 1.1 riastrad cwrappersource=$output_path/$objdir/lt-$output_name.c
10535 1.1 riastrad cwrapper=$output_path/$output_name.exe
10536 1.1 riastrad $RM $cwrappersource $cwrapper
10537 1.1 riastrad trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10538 1.1 riastrad
10539 1.1 riastrad func_emit_cwrapperexe_src > $cwrappersource
10540 1.1 riastrad
10541 1.1 riastrad # The wrapper executable is built using the $host compiler,
10542 1.1 riastrad # because it contains $host paths and files. If cross-
10543 1.1 riastrad # compiling, it, like the target executable, must be
10544 1.1 riastrad # executed on the $host or under an emulation environment.
10545 1.1 riastrad $opt_dry_run || {
10546 1.1 riastrad $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10547 1.1 riastrad $STRIP $cwrapper
10548 1.1 riastrad }
10549 1.1 riastrad
10550 1.1 riastrad # Now, create the wrapper script for func_source use:
10551 1.1 riastrad func_ltwrapper_scriptname $cwrapper
10552 1.1 riastrad $RM $func_ltwrapper_scriptname_result
10553 1.1 riastrad trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10554 1.1 riastrad $opt_dry_run || {
10555 1.1 riastrad # note: this script will not be executed, so do not chmod.
10556 1.1 riastrad if test "x$build" = "x$host"; then
10557 1.1 riastrad $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10558 1.1 riastrad else
10559 1.1 riastrad func_emit_wrapper no > $func_ltwrapper_scriptname_result
10560 1.1 riastrad fi
10561 1.1 riastrad }
10562 1.1 riastrad ;;
10563 1.1 riastrad * )
10564 1.1 riastrad $RM $output
10565 1.1 riastrad trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10566 1.1 riastrad
10567 1.1 riastrad func_emit_wrapper no > $output
10568 1.1 riastrad chmod +x $output
10569 1.1 riastrad ;;
10570 1.1 riastrad esac
10571 1.1 riastrad }
10572 1.1 riastrad exit $EXIT_SUCCESS
10573 1.1 riastrad ;;
10574 1.1 riastrad esac
10575 1.1 riastrad
10576 1.1 riastrad # See if we need to build an old-fashioned archive.
10577 1.1 riastrad for oldlib in $oldlibs; do
10578 1.1 riastrad
10579 1.1 riastrad case $build_libtool_libs in
10580 1.1 riastrad convenience)
10581 1.1 riastrad oldobjs="$libobjs_save $symfileobj"
10582 1.1 riastrad addlibs=$convenience
10583 1.1 riastrad build_libtool_libs=no
10584 1.1 riastrad ;;
10585 1.1 riastrad module)
10586 1.1 riastrad oldobjs=$libobjs_save
10587 1.1 riastrad addlibs=$old_convenience
10588 1.1 riastrad build_libtool_libs=no
10589 1.1 riastrad ;;
10590 1.1 riastrad *)
10591 1.1 riastrad oldobjs="$old_deplibs $non_pic_objects"
10592 1.1 riastrad $preload && test -f "$symfileobj" \
10593 1.1 riastrad && func_append oldobjs " $symfileobj"
10594 1.1 riastrad addlibs=$old_convenience
10595 1.1 riastrad ;;
10596 1.1 riastrad esac
10597 1.1 riastrad
10598 1.1 riastrad if test -n "$addlibs"; then
10599 1.1 riastrad gentop=$output_objdir/${outputname}x
10600 1.1 riastrad func_append generated " $gentop"
10601 1.1 riastrad
10602 1.1 riastrad func_extract_archives $gentop $addlibs
10603 1.1 riastrad func_append oldobjs " $func_extract_archives_result"
10604 1.1 riastrad fi
10605 1.1 riastrad
10606 1.1 riastrad # Do each command in the archive commands.
10607 1.1 riastrad if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10608 1.1 riastrad cmds=$old_archive_from_new_cmds
10609 1.1 riastrad else
10610 1.1 riastrad
10611 1.1 riastrad # Add any objects from preloaded convenience libraries
10612 1.1 riastrad if test -n "$dlprefiles"; then
10613 1.1 riastrad gentop=$output_objdir/${outputname}x
10614 1.1 riastrad func_append generated " $gentop"
10615 1.1 riastrad
10616 1.1 riastrad func_extract_archives $gentop $dlprefiles
10617 1.1 riastrad func_append oldobjs " $func_extract_archives_result"
10618 1.1 riastrad fi
10619 1.1 riastrad
10620 1.1 riastrad # POSIX demands no paths to be encoded in archives. We have
10621 1.1 riastrad # to avoid creating archives with duplicate basenames if we
10622 1.1 riastrad # might have to extract them afterwards, e.g., when creating a
10623 1.1 riastrad # static archive out of a convenience library, or when linking
10624 1.1 riastrad # the entirety of a libtool archive into another (currently
10625 1.1 riastrad # not supported by libtool).
10626 1.1 riastrad if (for obj in $oldobjs
10627 1.1 riastrad do
10628 1.1 riastrad func_basename "$obj"
10629 1.1 riastrad $ECHO "$func_basename_result"
10630 1.1 riastrad done | sort | sort -uc >/dev/null 2>&1); then
10631 1.1 riastrad :
10632 1.1 riastrad else
10633 1.1 riastrad echo "copying selected object files to avoid basename conflicts..."
10634 1.1 riastrad gentop=$output_objdir/${outputname}x
10635 1.1 riastrad func_append generated " $gentop"
10636 1.1 riastrad func_mkdir_p "$gentop"
10637 1.1 riastrad save_oldobjs=$oldobjs
10638 1.1 riastrad oldobjs=
10639 1.1 riastrad counter=1
10640 1.1 riastrad for obj in $save_oldobjs
10641 1.1 riastrad do
10642 1.1 riastrad func_basename "$obj"
10643 1.1 riastrad objbase=$func_basename_result
10644 1.1 riastrad case " $oldobjs " in
10645 1.1 riastrad " ") oldobjs=$obj ;;
10646 1.1 riastrad *[\ /]"$objbase "*)
10647 1.1 riastrad while :; do
10648 1.1 riastrad # Make sure we don't pick an alternate name that also
10649 1.1 riastrad # overlaps.
10650 1.1 riastrad newobj=lt$counter-$objbase
10651 1.1 riastrad func_arith $counter + 1
10652 1.1 riastrad counter=$func_arith_result
10653 1.1 riastrad case " $oldobjs " in
10654 1.1 riastrad *[\ /]"$newobj "*) ;;
10655 1.1 riastrad *) if test ! -f "$gentop/$newobj"; then break; fi ;;
10656 1.1 riastrad esac
10657 1.1 riastrad done
10658 1.1 riastrad func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10659 1.1 riastrad func_append oldobjs " $gentop/$newobj"
10660 1.1 riastrad ;;
10661 1.1 riastrad *) func_append oldobjs " $obj" ;;
10662 1.1 riastrad esac
10663 1.1 riastrad done
10664 1.1 riastrad fi
10665 1.1 riastrad func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10666 1.1 riastrad tool_oldlib=$func_to_tool_file_result
10667 1.1 riastrad eval cmds=\"$old_archive_cmds\"
10668 1.1 riastrad
10669 1.1 riastrad func_len " $cmds"
10670 1.1 riastrad len=$func_len_result
10671 1.1 riastrad if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10672 1.1 riastrad cmds=$old_archive_cmds
10673 1.1 riastrad elif test -n "$archiver_list_spec"; then
10674 1.1 riastrad func_verbose "using command file archive linking..."
10675 1.1 riastrad for obj in $oldobjs
10676 1.1 riastrad do
10677 1.1 riastrad func_to_tool_file "$obj"
10678 1.1 riastrad $ECHO "$func_to_tool_file_result"
10679 1.1 riastrad done > $output_objdir/$libname.libcmd
10680 1.1 riastrad func_to_tool_file "$output_objdir/$libname.libcmd"
10681 1.1 riastrad oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10682 1.1 riastrad cmds=$old_archive_cmds
10683 1.1 riastrad else
10684 1.1 riastrad # the command line is too long to link in one step, link in parts
10685 1.1 riastrad func_verbose "using piecewise archive linking..."
10686 1.1 riastrad save_RANLIB=$RANLIB
10687 1.1 riastrad RANLIB=:
10688 1.1 riastrad objlist=
10689 1.1 riastrad concat_cmds=
10690 1.1 riastrad save_oldobjs=$oldobjs
10691 1.1 riastrad oldobjs=
10692 1.1 riastrad # Is there a better way of finding the last object in the list?
10693 1.1 riastrad for obj in $save_oldobjs
10694 1.1 riastrad do
10695 1.1 riastrad last_oldobj=$obj
10696 1.1 riastrad done
10697 1.1 riastrad eval test_cmds=\"$old_archive_cmds\"
10698 1.1 riastrad func_len " $test_cmds"
10699 1.1 riastrad len0=$func_len_result
10700 1.1 riastrad len=$len0
10701 1.1 riastrad for obj in $save_oldobjs
10702 1.1 riastrad do
10703 1.1 riastrad func_len " $obj"
10704 1.1 riastrad func_arith $len + $func_len_result
10705 1.1 riastrad len=$func_arith_result
10706 1.1 riastrad func_append objlist " $obj"
10707 1.1 riastrad if test "$len" -lt "$max_cmd_len"; then
10708 1.1 riastrad :
10709 1.1 riastrad else
10710 1.1 riastrad # the above command should be used before it gets too long
10711 1.1 riastrad oldobjs=$objlist
10712 1.1 riastrad if test "$obj" = "$last_oldobj"; then
10713 1.1 riastrad RANLIB=$save_RANLIB
10714 1.1 riastrad fi
10715 1.1 riastrad test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10716 1.1 riastrad eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10717 1.1 riastrad objlist=
10718 1.1 riastrad len=$len0
10719 1.1 riastrad fi
10720 1.1 riastrad done
10721 1.1 riastrad RANLIB=$save_RANLIB
10722 1.1 riastrad oldobjs=$objlist
10723 1.1 riastrad if test -z "$oldobjs"; then
10724 1.1 riastrad eval cmds=\"\$concat_cmds\"
10725 1.1 riastrad else
10726 1.1 riastrad eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10727 1.1 riastrad fi
10728 1.1 riastrad fi
10729 1.1 riastrad fi
10730 1.1 riastrad func_execute_cmds "$cmds" 'exit $?'
10731 1.1 riastrad done
10732 1.1 riastrad
10733 1.1 riastrad test -n "$generated" && \
10734 1.1 riastrad func_show_eval "${RM}r$generated"
10735 1.1 riastrad
10736 1.1 riastrad # Now create the libtool archive.
10737 1.1 riastrad case $output in
10738 1.1 riastrad *.la)
10739 1.1 riastrad old_library=
10740 1.1 riastrad test yes = "$build_old_libs" && old_library=$libname.$libext
10741 1.1 riastrad func_verbose "creating $output"
10742 1.1 riastrad
10743 1.1 riastrad # Preserve any variables that may affect compiler behavior
10744 1.1 riastrad for var in $variables_saved_for_relink; do
10745 1.1 riastrad if eval test -z \"\${$var+set}\"; then
10746 1.1 riastrad relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10747 1.1 riastrad elif eval var_value=\$$var; test -z "$var_value"; then
10748 1.1 riastrad relink_command="$var=; export $var; $relink_command"
10749 1.1 riastrad else
10750 1.1 riastrad func_quote_for_eval "$var_value"
10751 1.1 riastrad relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10752 1.1 riastrad fi
10753 1.1 riastrad done
10754 1.1 riastrad # Quote the link command for shipping.
10755 1.1 riastrad relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10756 1.1 riastrad relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10757 1.1 riastrad if test yes = "$hardcode_automatic"; then
10758 1.1 riastrad relink_command=
10759 1.1 riastrad fi
10760 1.1 riastrad
10761 1.1 riastrad # Only create the output if not a dry run.
10762 1.1 riastrad $opt_dry_run || {
10763 1.1 riastrad for installed in no yes; do
10764 1.1 riastrad if test yes = "$installed"; then
10765 1.1 riastrad if test -z "$install_libdir"; then
10766 1.1 riastrad break
10767 1.1 riastrad fi
10768 1.1 riastrad output=$output_objdir/${outputname}i
10769 1.1 riastrad # Replace all uninstalled libtool libraries with the installed ones
10770 1.1 riastrad newdependency_libs=
10771 1.1 riastrad for deplib in $dependency_libs; do
10772 1.1 riastrad case $deplib in
10773 1.1 riastrad *.la)
10774 1.1 riastrad func_basename "$deplib"
10775 1.1 riastrad name=$func_basename_result
10776 1.1 riastrad func_resolve_sysroot "$deplib"
10777 1.1 riastrad eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10778 1.1 riastrad test -z "$libdir" && \
10779 1.1 riastrad func_fatal_error "'$deplib' is not a valid libtool archive"
10780 1.1 riastrad func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10781 1.1 riastrad ;;
10782 1.1 riastrad -L*)
10783 1.1 riastrad func_stripname -L '' "$deplib"
10784 1.1 riastrad func_replace_sysroot "$func_stripname_result"
10785 1.1 riastrad func_append newdependency_libs " -L$func_replace_sysroot_result"
10786 1.1 riastrad ;;
10787 1.1 riastrad -R*)
10788 1.1 riastrad func_stripname -R '' "$deplib"
10789 1.1 riastrad func_replace_sysroot "$func_stripname_result"
10790 1.1 riastrad func_append newdependency_libs " -R$func_replace_sysroot_result"
10791 1.1 riastrad ;;
10792 1.1 riastrad *) func_append newdependency_libs " $deplib" ;;
10793 1.1 riastrad esac
10794 1.1 riastrad done
10795 1.1 riastrad dependency_libs=$newdependency_libs
10796 1.1 riastrad newdlfiles=
10797 1.1 riastrad
10798 1.1 riastrad for lib in $dlfiles; do
10799 1.1 riastrad case $lib in
10800 1.1 riastrad *.la)
10801 1.1 riastrad func_basename "$lib"
10802 1.1 riastrad name=$func_basename_result
10803 1.1 riastrad eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10804 1.1 riastrad test -z "$libdir" && \
10805 1.1 riastrad func_fatal_error "'$lib' is not a valid libtool archive"
10806 1.1 riastrad func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10807 1.1 riastrad ;;
10808 1.1 riastrad *) func_append newdlfiles " $lib" ;;
10809 1.1 riastrad esac
10810 1.1 riastrad done
10811 1.1 riastrad dlfiles=$newdlfiles
10812 1.1 riastrad newdlprefiles=
10813 1.1 riastrad for lib in $dlprefiles; do
10814 1.1 riastrad case $lib in
10815 1.1 riastrad *.la)
10816 1.1 riastrad # Only pass preopened files to the pseudo-archive (for
10817 1.1 riastrad # eventual linking with the app. that links it) if we
10818 1.1 riastrad # didn't already link the preopened objects directly into
10819 1.1 riastrad # the library:
10820 1.1 riastrad func_basename "$lib"
10821 1.1 riastrad name=$func_basename_result
10822 1.1 riastrad eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10823 1.1 riastrad test -z "$libdir" && \
10824 1.1 riastrad func_fatal_error "'$lib' is not a valid libtool archive"
10825 1.1 riastrad func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10826 1.1 riastrad ;;
10827 1.1 riastrad esac
10828 1.1 riastrad done
10829 1.1 riastrad dlprefiles=$newdlprefiles
10830 1.1 riastrad else
10831 1.1 riastrad newdlfiles=
10832 1.1 riastrad for lib in $dlfiles; do
10833 1.1 riastrad case $lib in
10834 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10835 1.1 riastrad *) abs=`pwd`"/$lib" ;;
10836 1.1 riastrad esac
10837 1.1 riastrad func_append newdlfiles " $abs"
10838 1.1 riastrad done
10839 1.1 riastrad dlfiles=$newdlfiles
10840 1.1 riastrad newdlprefiles=
10841 1.1 riastrad for lib in $dlprefiles; do
10842 1.1 riastrad case $lib in
10843 1.1 riastrad [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10844 1.1 riastrad *) abs=`pwd`"/$lib" ;;
10845 1.1 riastrad esac
10846 1.1 riastrad func_append newdlprefiles " $abs"
10847 1.1 riastrad done
10848 1.1 riastrad dlprefiles=$newdlprefiles
10849 1.1 riastrad fi
10850 1.1 riastrad $RM $output
10851 1.1 riastrad # place dlname in correct position for cygwin
10852 1.1 riastrad # In fact, it would be nice if we could use this code for all target
10853 1.1 riastrad # systems that can't hard-code library paths into their executables
10854 1.1 riastrad # and that have no shared library path variable independent of PATH,
10855 1.1 riastrad # but it turns out we can't easily determine that from inspecting
10856 1.1 riastrad # libtool variables, so we have to hard-code the OSs to which it
10857 1.1 riastrad # applies here; at the moment, that means platforms that use the PE
10858 1.1 riastrad # object format with DLL files. See the long comment at the top of
10859 1.1 riastrad # tests/bindir.at for full details.
10860 1.1 riastrad tdlname=$dlname
10861 1.1 riastrad case $host,$output,$installed,$module,$dlname in
10862 1.1 riastrad *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10863 1.1 riastrad # If a -bindir argument was supplied, place the dll there.
10864 1.1 riastrad if test -n "$bindir"; then
10865 1.1 riastrad func_relative_path "$install_libdir" "$bindir"
10866 1.1 riastrad tdlname=$func_relative_path_result/$dlname
10867 1.1 riastrad else
10868 1.1 riastrad # Otherwise fall back on heuristic.
10869 1.1 riastrad tdlname=../bin/$dlname
10870 1.1 riastrad fi
10871 1.1 riastrad ;;
10872 1.1 riastrad esac
10873 1.1 riastrad $ECHO > $output "\
10874 1.1 riastrad # $outputname - a libtool library file
10875 1.1 riastrad # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10876 1.1 riastrad #
10877 1.1 riastrad # Please DO NOT delete this file!
10878 1.1 riastrad # It is necessary for linking the library.
10879 1.1 riastrad
10880 1.1 riastrad # The name that we can dlopen(3).
10881 1.1 riastrad dlname='$tdlname'
10882 1.1 riastrad
10883 1.1 riastrad # Names of this library.
10884 1.1 riastrad library_names='$library_names'
10885 1.1 riastrad
10886 1.1 riastrad # The name of the static archive.
10887 1.1 riastrad old_library='$old_library'
10888 1.1 riastrad
10889 1.1 riastrad # Linker flags that cannot go in dependency_libs.
10890 1.1 riastrad inherited_linker_flags='$new_inherited_linker_flags'
10891 1.1 riastrad
10892 1.1 riastrad # Libraries that this one depends upon.
10893 1.1 riastrad dependency_libs='$dependency_libs'
10894 1.1 riastrad
10895 1.1 riastrad # Names of additional weak libraries provided by this library
10896 1.1 riastrad weak_library_names='$weak_libs'
10897 1.1 riastrad
10898 1.1 riastrad # Version information for $libname.
10899 1.1 riastrad current=$current
10900 1.1 riastrad age=$age
10901 1.1 riastrad revision=$revision
10902 1.1 riastrad
10903 1.1 riastrad # Is this an already installed library?
10904 1.1 riastrad installed=$installed
10905 1.1 riastrad
10906 1.1 riastrad # Should we warn about portability when linking against -modules?
10907 1.1 riastrad shouldnotlink=$module
10908 1.1 riastrad
10909 1.1 riastrad # Files to dlopen/dlpreopen
10910 1.1 riastrad dlopen='$dlfiles'
10911 1.1 riastrad dlpreopen='$dlprefiles'
10912 1.1 riastrad
10913 1.1 riastrad # Directory that this library needs to be installed in:
10914 1.1 riastrad libdir='$install_libdir'"
10915 1.1 riastrad if test no,yes = "$installed,$need_relink"; then
10916 1.1 riastrad $ECHO >> $output "\
10917 1.1 riastrad relink_command=\"$relink_command\""
10918 1.1 riastrad fi
10919 1.1 riastrad done
10920 1.1 riastrad }
10921 1.1 riastrad
10922 1.1 riastrad # Do a symbolic link so that the libtool archive can be found in
10923 1.1 riastrad # LD_LIBRARY_PATH before the program is installed.
10924 1.1 riastrad func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10925 1.1 riastrad ;;
10926 1.1 riastrad esac
10927 1.1 riastrad exit $EXIT_SUCCESS
10928 1.1 riastrad }
10929 1.1 riastrad
10930 1.1 riastrad if test link = "$opt_mode" || test relink = "$opt_mode"; then
10931 1.1 riastrad func_mode_link ${1+"$@"}
10932 1.1 riastrad fi
10933 1.1 riastrad
10934 1.1 riastrad
10935 1.1 riastrad # func_mode_uninstall arg...
10936 1.1 riastrad func_mode_uninstall ()
10937 1.1 riastrad {
10938 1.1 riastrad $debug_cmd
10939 1.1 riastrad
10940 1.1 riastrad RM=$nonopt
10941 1.1 riastrad files=
10942 1.1 riastrad rmforce=false
10943 1.1 riastrad exit_status=0
10944 1.1 riastrad
10945 1.1 riastrad # This variable tells wrapper scripts just to set variables rather
10946 1.1 riastrad # than running their programs.
10947 1.1 riastrad libtool_install_magic=$magic
10948 1.1 riastrad
10949 1.1 riastrad for arg
10950 1.1 riastrad do
10951 1.1 riastrad case $arg in
10952 1.1 riastrad -f) func_append RM " $arg"; rmforce=: ;;
10953 1.1 riastrad -*) func_append RM " $arg" ;;
10954 1.1 riastrad *) func_append files " $arg" ;;
10955 1.1 riastrad esac
10956 1.1 riastrad done
10957 1.1 riastrad
10958 1.1 riastrad test -z "$RM" && \
10959 1.1 riastrad func_fatal_help "you must specify an RM program"
10960 1.1 riastrad
10961 1.1 riastrad rmdirs=
10962 1.1 riastrad
10963 1.1 riastrad for file in $files; do
10964 1.1 riastrad func_dirname "$file" "" "."
10965 1.1 riastrad dir=$func_dirname_result
10966 1.1 riastrad if test . = "$dir"; then
10967 1.1 riastrad odir=$objdir
10968 1.1 riastrad else
10969 1.1 riastrad odir=$dir/$objdir
10970 1.1 riastrad fi
10971 1.1 riastrad func_basename "$file"
10972 1.1 riastrad name=$func_basename_result
10973 1.1 riastrad test uninstall = "$opt_mode" && odir=$dir
10974 1.1 riastrad
10975 1.1 riastrad # Remember odir for removal later, being careful to avoid duplicates
10976 1.1 riastrad if test clean = "$opt_mode"; then
10977 1.1 riastrad case " $rmdirs " in
10978 1.1 riastrad *" $odir "*) ;;
10979 1.1 riastrad *) func_append rmdirs " $odir" ;;
10980 1.1 riastrad esac
10981 1.1 riastrad fi
10982 1.1 riastrad
10983 1.1 riastrad # Don't error if the file doesn't exist and rm -f was used.
10984 1.1 riastrad if { test -L "$file"; } >/dev/null 2>&1 ||
10985 1.1 riastrad { test -h "$file"; } >/dev/null 2>&1 ||
10986 1.1 riastrad test -f "$file"; then
10987 1.1 riastrad :
10988 1.1 riastrad elif test -d "$file"; then
10989 1.1 riastrad exit_status=1
10990 1.1 riastrad continue
10991 1.1 riastrad elif $rmforce; then
10992 1.1 riastrad continue
10993 1.1 riastrad fi
10994 1.1 riastrad
10995 1.1 riastrad rmfiles=$file
10996 1.1 riastrad
10997 1.1 riastrad case $name in
10998 1.1 riastrad *.la)
10999 1.1 riastrad # Possibly a libtool archive, so verify it.
11000 1.1 riastrad if func_lalib_p "$file"; then
11001 1.1 riastrad func_source $dir/$name
11002 1.1 riastrad
11003 1.1 riastrad # Delete the libtool libraries and symlinks.
11004 1.1 riastrad for n in $library_names; do
11005 1.1 riastrad func_append rmfiles " $odir/$n"
11006 1.1 riastrad done
11007 1.1 riastrad test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11008 1.1 riastrad
11009 1.1 riastrad case $opt_mode in
11010 1.1 riastrad clean)
11011 1.1 riastrad case " $library_names " in
11012 1.1 riastrad *" $dlname "*) ;;
11013 1.1 riastrad *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11014 1.1 riastrad esac
11015 1.1 riastrad test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11016 1.1 riastrad ;;
11017 1.1 riastrad uninstall)
11018 1.1 riastrad if test -n "$library_names"; then
11019 1.1 riastrad # Do each command in the postuninstall commands.
11020 1.1 riastrad func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11021 1.1 riastrad fi
11022 1.1 riastrad
11023 1.1 riastrad if test -n "$old_library"; then
11024 1.1 riastrad # Do each command in the old_postuninstall commands.
11025 1.1 riastrad func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11026 1.1 riastrad fi
11027 1.1 riastrad # FIXME: should reinstall the best remaining shared library.
11028 1.1 riastrad ;;
11029 1.1 riastrad esac
11030 1.1 riastrad fi
11031 1.1 riastrad ;;
11032 1.1 riastrad
11033 1.1 riastrad *.lo)
11034 1.1 riastrad # Possibly a libtool object, so verify it.
11035 1.1 riastrad if func_lalib_p "$file"; then
11036 1.1 riastrad
11037 1.1 riastrad # Read the .lo file
11038 1.1 riastrad func_source $dir/$name
11039 1.1 riastrad
11040 1.1 riastrad # Add PIC object to the list of files to remove.
11041 1.1 riastrad if test -n "$pic_object" && test none != "$pic_object"; then
11042 1.1 riastrad func_append rmfiles " $dir/$pic_object"
11043 1.1 riastrad fi
11044 1.1 riastrad
11045 1.1 riastrad # Add non-PIC object to the list of files to remove.
11046 1.1 riastrad if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11047 1.1 riastrad func_append rmfiles " $dir/$non_pic_object"
11048 1.1 riastrad fi
11049 1.1 riastrad fi
11050 1.1 riastrad ;;
11051 1.1 riastrad
11052 1.1 riastrad *)
11053 1.1 riastrad if test clean = "$opt_mode"; then
11054 1.1 riastrad noexename=$name
11055 1.1 riastrad case $file in
11056 1.1 riastrad *.exe)
11057 1.1 riastrad func_stripname '' '.exe' "$file"
11058 1.1 riastrad file=$func_stripname_result
11059 1.1 riastrad func_stripname '' '.exe' "$name"
11060 1.1 riastrad noexename=$func_stripname_result
11061 1.1 riastrad # $file with .exe has already been added to rmfiles,
11062 1.1 riastrad # add $file without .exe
11063 1.1 riastrad func_append rmfiles " $file"
11064 1.1 riastrad ;;
11065 1.1 riastrad esac
11066 1.1 riastrad # Do a test to see if this is a libtool program.
11067 1.1 riastrad if func_ltwrapper_p "$file"; then
11068 1.1 riastrad if func_ltwrapper_executable_p "$file"; then
11069 1.1 riastrad func_ltwrapper_scriptname "$file"
11070 1.1 riastrad relink_command=
11071 1.1 riastrad func_source $func_ltwrapper_scriptname_result
11072 1.1 riastrad func_append rmfiles " $func_ltwrapper_scriptname_result"
11073 1.1 riastrad else
11074 1.1 riastrad relink_command=
11075 1.1 riastrad func_source $dir/$noexename
11076 1.1 riastrad fi
11077 1.1 riastrad
11078 1.1 riastrad # note $name still contains .exe if it was in $file originally
11079 1.1 riastrad # as does the version of $file that was added into $rmfiles
11080 1.1 riastrad func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11081 1.1 riastrad if test yes = "$fast_install" && test -n "$relink_command"; then
11082 1.1 riastrad func_append rmfiles " $odir/lt-$name"
11083 1.1 riastrad fi
11084 1.1 riastrad if test "X$noexename" != "X$name"; then
11085 1.1 riastrad func_append rmfiles " $odir/lt-$noexename.c"
11086 1.1 riastrad fi
11087 1.1 riastrad fi
11088 1.1 riastrad fi
11089 1.1 riastrad ;;
11090 1.1 riastrad esac
11091 1.1 riastrad func_show_eval "$RM $rmfiles" 'exit_status=1'
11092 1.1 riastrad done
11093 1.1 riastrad
11094 1.1 riastrad # Try to remove the $objdir's in the directories where we deleted files
11095 1.1 riastrad for dir in $rmdirs; do
11096 1.1 riastrad if test -d "$dir"; then
11097 1.1 riastrad func_show_eval "rmdir $dir >/dev/null 2>&1"
11098 1.1 riastrad fi
11099 1.1 riastrad done
11100 1.1 riastrad
11101 1.1 riastrad exit $exit_status
11102 1.1 riastrad }
11103 1.1 riastrad
11104 1.1 riastrad if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11105 1.1 riastrad func_mode_uninstall ${1+"$@"}
11106 1.1 riastrad fi
11107 1.1 riastrad
11108 1.1 riastrad test -z "$opt_mode" && {
11109 1.1 riastrad help=$generic_help
11110 1.1 riastrad func_fatal_help "you must specify a MODE"
11111 1.1 riastrad }
11112 1.1 riastrad
11113 1.1 riastrad test -z "$exec_cmd" && \
11114 1.1 riastrad func_fatal_help "invalid operation mode '$opt_mode'"
11115 1.1 riastrad
11116 1.1 riastrad if test -n "$exec_cmd"; then
11117 1.1 riastrad eval exec "$exec_cmd"
11118 1.1 riastrad exit $EXIT_FAILURE
11119 1.1 riastrad fi
11120 1.1 riastrad
11121 1.1 riastrad exit $exit_status
11122 1.1 riastrad
11123 1.1 riastrad
11124 1.1 riastrad # The TAGs below are defined such that we never get into a situation
11125 1.1 riastrad # where we disable both kinds of libraries. Given conflicting
11126 1.1 riastrad # choices, we go for a static library, that is the most portable,
11127 1.1 riastrad # since we can't tell whether shared libraries were disabled because
11128 1.1 riastrad # the user asked for that or because the platform doesn't support
11129 1.1 riastrad # them. This is particularly important on AIX, because we don't
11130 1.1 riastrad # support having both static and shared libraries enabled at the same
11131 1.1 riastrad # time on that platform, so we default to a shared-only configuration.
11132 1.1 riastrad # If a disable-shared tag is given, we'll fallback to a static-only
11133 1.1 riastrad # configuration. But we'll never go from static-only to shared-only.
11134 1.1 riastrad
11135 1.1 riastrad # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11136 1.1 riastrad build_libtool_libs=no
11137 1.1 riastrad build_old_libs=yes
11138 1.1 riastrad # ### END LIBTOOL TAG CONFIG: disable-shared
11139 1.1 riastrad
11140 1.1 riastrad # ### BEGIN LIBTOOL TAG CONFIG: disable-static
11141 1.1 riastrad build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11142 1.1 riastrad # ### END LIBTOOL TAG CONFIG: disable-static
11143 1.1 riastrad
11144 1.1 riastrad # Local Variables:
11145 1.1 riastrad # mode:shell-script
11146 1.1 riastrad # sh-indentation:2
11147 1.1 riastrad # End:
11148