Skip to content

Latest commit

 

History

History
6479 lines (5839 loc) · 181 KB

ltmain.sh

File metadata and controls

6479 lines (5839 loc) · 181 KB
 
Apr 26, 2001
Apr 26, 2001
1
# ltmain.sh - Provide generalized library-building support services.
Oct 6, 2003
Oct 6, 2003
2
# NOTE: Changing this file will not affect anything until you rerun configure.
Apr 26, 2001
Apr 26, 2001
3
#
Oct 6, 2003
Oct 6, 2003
4
5
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003
# Free Software Foundation, Inc.
Apr 26, 2001
Apr 26, 2001
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Check that we have a working $echo.
if test "X$1" = X--no-reexec; then
# Discard the --no-reexec flag, and continue.
shift
elif test "X$1" = X--fallback-echo; then
# Avoid inline document here, it may be left over
:
elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
# Yippee, $echo works!
:
else
# Restart under the correct shell, and then maybe $echo will work.
exec $SHELL "$0" --no-reexec ${1+"$@"}
fi
if test "X$1" = X--fallback-echo; then
# used as fallback echo
shift
cat <<EOF
$*
EOF
exit 0
fi
# The name of this program.
Oct 6, 2003
Oct 6, 2003
52
progname=`$echo "$0" | ${SED} 's%^.*/%%'`
Apr 26, 2001
Apr 26, 2001
53
54
55
56
57
modename="$progname"
# Constants.
PROGRAM=ltmain.sh
PACKAGE=libtool
Oct 6, 2003
Oct 6, 2003
58
59
VERSION=1.5
TIMESTAMP=" (1.1220.2.1 2003/04/14 22:48:00)"
Apr 26, 2001
Apr 26, 2001
60
61
62
63
64
65
66
67
68
69
default_mode=
help="Try \`$progname --help' for more information."
magic="%%%MAGIC variable%%%"
mkdir="mkdir"
mv="mv -f"
rm="rm -f"
# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
Oct 6, 2003
Oct 6, 2003
70
Xsed="${SED}"' -e 1s/^X//'
Apr 26, 2001
Apr 26, 2001
71
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
Oct 6, 2003
Oct 6, 2003
72
73
74
75
76
77
78
79
80
81
82
# test EBCDIC or ASCII
case `echo A|od -x` in
*[Cc]1*) # EBCDIC based system
SP2NL="tr '\100' '\n'"
NL2SP="tr '\r\n' '\100\100'"
;;
*) # Assume ASCII based system
SP2NL="tr '\040' '\012'"
NL2SP="tr '\015\012' '\040\040'"
;;
esac
Apr 26, 2001
Apr 26, 2001
83
84
85
86
87
88
89
90
91
92
93
94
95
# NLS nuisances.
# Only set LANG and LC_ALL to C if already set.
# These must not be set unconditionally because not all systems understand
# e.g. LANG=C (notably SCO).
# We save the old values to restore during execute mode.
if test "${LC_ALL+set}" = set; then
save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
fi
if test "${LANG+set}" = set; then
save_LANG="$LANG"; LANG=C; export LANG
fi
Oct 6, 2003
Oct 6, 2003
96
97
# Make sure IFS has a sensible default
: ${IFS=" "}
Apr 26, 2001
Apr 26, 2001
98
99
if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
Oct 6, 2003
Oct 6, 2003
100
101
$echo "$modename: not configured to build any kind of library" 1>&2
$echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
Apr 26, 2001
Apr 26, 2001
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
exit 1
fi
# Global variables.
mode=$default_mode
nonopt=
prev=
prevopt=
run=
show="$echo"
show_help=
execute_dlfiles=
lo2o="s/\\.lo\$/.${objext}/"
o2lo="s/\\.${objext}\$/.lo/"
Oct 6, 2003
Oct 6, 2003
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#####################################
# Shell function definitions:
# This seems to be the best place for them
# Need a lot of goo to handle *both* DLLs and import libs
# Has to be a shell function in order to 'eat' the argument
# that is supplied when $file_magic_command is called.
win32_libid () {
win32_libid_type="unknown"
win32_fileres=`file -L $1 2>/dev/null`
case $win32_fileres in
*ar\ archive\ import\ library*) # definitely import
win32_libid_type="x86 archive import"
;;
*ar\ archive*) # could be an import, or static
if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
grep -E 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
win32_nmres=`eval $NM -f posix -A $1 | \
sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
if test "X$win32_nmres" = "Ximport" ; then
win32_libid_type="x86 archive import"
else
win32_libid_type="x86 archive static"
fi
fi
;;
*DLL*)
win32_libid_type="x86 DLL"
;;
*executable*) # but shell scripts are "executable" too...
case $win32_fileres in
*MS\ Windows\ PE\ Intel*)
win32_libid_type="x86 DLL"
;;
esac
;;
esac
$echo $win32_libid_type
}
# End of Shell function definitions
#####################################
Apr 26, 2001
Apr 26, 2001
160
# Parse our command line options once, thoroughly.
Oct 6, 2003
Oct 6, 2003
161
while test "$#" -gt 0
Apr 26, 2001
Apr 26, 2001
162
163
164
165
do
arg="$1"
shift
Oct 6, 2003
Oct 6, 2003
166
case $arg in
Apr 26, 2001
Apr 26, 2001
167
168
169
170
171
172
-*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
# If the previous option needs an argument, assign it.
if test -n "$prev"; then
Oct 6, 2003
Oct 6, 2003
173
case $prev in
Apr 26, 2001
Apr 26, 2001
174
execute_dlfiles)
Oct 6, 2003
Oct 6, 2003
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
execute_dlfiles="$execute_dlfiles $arg"
;;
tag)
tagname="$arg"
# Check whether tagname contains only valid characters
case $tagname in
*[!-_A-Za-z0-9,/]*)
$echo "$progname: invalid tag name: $tagname" 1>&2
exit 1
;;
esac
case $tagname in
CC)
# Don't test for the "default" C tag, as we know, it's there, but
# not specially marked.
;;
*)
if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then
taglist="$taglist $tagname"
# Evaluate the configuration.
eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $0`"
else
$echo "$progname: ignoring unknown tag $tagname" 1>&2
fi
;;
esac
Apr 26, 2001
Apr 26, 2001
203
204
205
206
207
208
209
210
211
212
213
214
;;
*)
eval "$prev=\$arg"
;;
esac
prev=
prevopt=
continue
fi
# Have we seen a non-optional argument yet?
Oct 6, 2003
Oct 6, 2003
215
case $arg in
Apr 26, 2001
Apr 26, 2001
216
217
218
219
220
--help)
show_help=yes
;;
--version)
Oct 6, 2003
Oct 6, 2003
221
222
223
224
225
$echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
$echo
$echo "Copyright (C) 2003 Free Software Foundation, Inc."
$echo "This is free software; see the source for copying conditions. There is NO"
$echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
Apr 26, 2001
Apr 26, 2001
226
227
228
229
exit 0
;;
--config)
Oct 6, 2003
Oct 6, 2003
230
231
232
233
234
${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
# Now print the configurations for the tags.
for tagname in $taglist; do
${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$0"
done
Apr 26, 2001
Apr 26, 2001
235
236
237
238
exit 0
;;
--debug)
Oct 6, 2003
Oct 6, 2003
239
$echo "$progname: enabling shell trace mode"
Apr 26, 2001
Apr 26, 2001
240
241
242
243
244
245
246
247
set -x
;;
--dry-run | -n)
run=:
;;
--features)
Oct 6, 2003
Oct 6, 2003
248
$echo "host: $host"
Apr 26, 2001
Apr 26, 2001
249
if test "$build_libtool_libs" = yes; then
Oct 6, 2003
Oct 6, 2003
250
$echo "enable shared libraries"
Apr 26, 2001
Apr 26, 2001
251
else
Oct 6, 2003
Oct 6, 2003
252
$echo "disable shared libraries"
Apr 26, 2001
Apr 26, 2001
253
254
fi
if test "$build_old_libs" = yes; then
Oct 6, 2003
Oct 6, 2003
255
$echo "enable static libraries"
Apr 26, 2001
Apr 26, 2001
256
else
Oct 6, 2003
Oct 6, 2003
257
$echo "disable static libraries"
Apr 26, 2001
Apr 26, 2001
258
259
260
261
262
263
264
265
266
fi
exit 0
;;
--finish) mode="finish" ;;
--mode) prevopt="--mode" prev=mode ;;
--mode=*) mode="$optarg" ;;
Oct 6, 2003
Oct 6, 2003
267
268
--preserve-dup-deps) duplicate_deps="yes" ;;
Apr 26, 2001
Apr 26, 2001
269
270
271
272
--quiet | --silent)
show=:
;;
Oct 6, 2003
Oct 6, 2003
273
274
275
276
277
278
279
--tag) prevopt="--tag" prev=tag ;;
--tag=*)
set tag "$optarg" ${1+"$@"}
shift
prev=tag
;;
Apr 26, 2001
Apr 26, 2001
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
-dlopen)
prevopt="-dlopen"
prev=execute_dlfiles
;;
-*)
$echo "$modename: unrecognized option \`$arg'" 1>&2
$echo "$help" 1>&2
exit 1
;;
*)
nonopt="$arg"
break
;;
esac
done
if test -n "$prevopt"; then
$echo "$modename: option \`$prevopt' requires an argument" 1>&2
$echo "$help" 1>&2
exit 1
fi
Oct 6, 2003
Oct 6, 2003
304
305
306
307
308
# If this variable is set in any of the actions, the command in it
# will be execed at the end. This prevents here-documents from being
# left over by shells.
exec_cmd=
Apr 26, 2001
Apr 26, 2001
309
310
311
312
if test -z "$show_help"; then
# Infer the operation mode.
if test -z "$mode"; then
Oct 6, 2003
Oct 6, 2003
313
314
315
316
$echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
$echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
case $nonopt in
*cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
Apr 26, 2001
Apr 26, 2001
317
318
319
mode=link
for arg
do
Oct 6, 2003
Oct 6, 2003
320
case $arg in
Apr 26, 2001
Apr 26, 2001
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
-c)
mode=compile
break
;;
esac
done
;;
*db | *dbx | *strace | *truss)
mode=execute
;;
*install*|cp|mv)
mode=install
;;
*rm)
mode=uninstall
;;
*)
# If we have no mode, but dlfiles were specified, then do execute mode.
test -n "$execute_dlfiles" && mode=execute
# Just use the default operation mode.
if test -z "$mode"; then
if test -n "$nonopt"; then
$echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
else
$echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
fi
fi
;;
esac
fi
# Only execute mode is allowed to have -dlopen flags.
if test -n "$execute_dlfiles" && test "$mode" != execute; then
$echo "$modename: unrecognized option \`-dlopen'" 1>&2
$echo "$help" 1>&2
exit 1
fi
# Change the help message to a mode-specific one.
generic_help="$help"
help="Try \`$modename --help --mode=$mode' for more information."
# These modes are in order of execution frequency so that they run quickly.
Oct 6, 2003
Oct 6, 2003
365
case $mode in
Apr 26, 2001
Apr 26, 2001
366
367
368
369
370
# libtool compile mode
compile)
modename="$modename: compile"
# Get the compilation command and the source file.
base_compile=
Oct 6, 2003
Oct 6, 2003
371
srcfile="$nonopt" # always keep a non-empty value in "srcfile"
Apr 26, 2001
Apr 26, 2001
372
suppress_output=
Oct 6, 2003
Oct 6, 2003
373
374
arg_mode=normal
libobj=
Apr 26, 2001
Apr 26, 2001
375
376
377
for arg
do
Oct 6, 2003
Oct 6, 2003
378
379
380
381
382
case "$arg_mode" in
arg )
# do not "continue". Instead, add this to base_compile
lastarg="$arg"
arg_mode=normal
Apr 26, 2001
Apr 26, 2001
383
384
;;
Oct 6, 2003
Oct 6, 2003
385
target )
Apr 26, 2001
Apr 26, 2001
386
libobj="$arg"
Oct 6, 2003
Oct 6, 2003
387
arg_mode=normal
Apr 26, 2001
Apr 26, 2001
388
389
390
continue
;;
Oct 6, 2003
Oct 6, 2003
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
normal )
# Accept any command-line options.
case $arg in
-o)
if test -n "$libobj" ; then
$echo "$modename: you cannot specify \`-o' more than once" 1>&2
exit 1
fi
arg_mode=target
continue
;;
-static)
build_old_libs=yes
continue
;;
Apr 26, 2001
Apr 26, 2001
407
Oct 6, 2003
Oct 6, 2003
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
-prefer-pic)
pic_mode=yes
continue
;;
-prefer-non-pic)
pic_mode=no
continue
;;
-Xcompiler)
arg_mode=arg # the next one goes into the "base_compile" arg list
continue # The current "srcfile" will either be retained or
;; # replaced later. I would guess that would be a bug.
-Wc,*)
args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
lastarg=
save_ifs="$IFS"; IFS=','
for arg in $args; do
IFS="$save_ifs"
# Double-quote args containing other shell metacharacters.
# Many Bourne shells cannot handle close brackets correctly
# in scan sets, so we specify it separately.
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
arg="\"$arg\""
;;
esac
lastarg="$lastarg $arg"
done
IFS="$save_ifs"
lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
# Add the arguments to base_compile.
base_compile="$base_compile $lastarg"
continue
;;
* )
# Accept the current argument as the source file.
# The previous "srcfile" becomes the current argument.
#
lastarg="$srcfile"
srcfile="$arg"
;;
esac # case $arg
;;
esac # case $arg_mode
Apr 26, 2001
Apr 26, 2001
458
Oct 6, 2003
Oct 6, 2003
459
# Aesthetically quote the previous argument.
Apr 26, 2001
Apr 26, 2001
460
461
lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
Oct 6, 2003
Oct 6, 2003
462
case $lastarg in
Apr 26, 2001
Apr 26, 2001
463
# Double-quote args containing other shell metacharacters.
Oct 6, 2003
Oct 6, 2003
464
465
466
# Many Bourne shells cannot handle close brackets correctly
# in scan sets, so we specify it separately.
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Apr 26, 2001
Apr 26, 2001
467
468
469
470
lastarg="\"$lastarg\""
;;
esac
Oct 6, 2003
Oct 6, 2003
471
472
base_compile="$base_compile $lastarg"
done # for arg
Apr 26, 2001
Apr 26, 2001
473
Oct 6, 2003
Oct 6, 2003
474
475
476
477
case $arg_mode in
arg)
$echo "$modename: you must specify an argument for -Xcompile"
exit 1
Apr 26, 2001
Apr 26, 2001
478
;;
Oct 6, 2003
Oct 6, 2003
479
target)
Apr 26, 2001
Apr 26, 2001
480
481
482
$echo "$modename: you must specify a target with \`-o'" 1>&2
exit 1
;;
Oct 6, 2003
Oct 6, 2003
483
484
485
486
*)
# Get the name of the library object.
[ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
;;
Apr 26, 2001
Apr 26, 2001
487
488
489
490
esac
# Recognize several different file suffixes.
# If the user specifies -o file.o, it is replaced with file.lo
Oct 6, 2003
Oct 6, 2003
491
492
xform='[cCFSifmso]'
case $libobj in
Apr 26, 2001
Apr 26, 2001
493
494
495
496
497
498
*.ada) xform=ada ;;
*.adb) xform=adb ;;
*.ads) xform=ads ;;
*.asm) xform=asm ;;
*.c++) xform=c++ ;;
*.cc) xform=cc ;;
Oct 6, 2003
Oct 6, 2003
499
500
*.ii) xform=ii ;;
*.class) xform=class ;;
Apr 26, 2001
Apr 26, 2001
501
502
503
504
*.cpp) xform=cpp ;;
*.cxx) xform=cxx ;;
*.f90) xform=f90 ;;
*.for) xform=for ;;
Oct 6, 2003
Oct 6, 2003
505
*.java) xform=java ;;
Apr 26, 2001
Apr 26, 2001
506
507
508
509
esac
libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
Oct 6, 2003
Oct 6, 2003
510
case $libobj in
Apr 26, 2001
Apr 26, 2001
511
512
513
514
515
516
517
*.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
*)
$echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
exit 1
;;
esac
Oct 6, 2003
Oct 6, 2003
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
# Infer tagged configuration to use if any are available and
# if one wasn't chosen via the "--tag" command line option.
# Only attempt this if the compiler in the base compile
# command doesn't match the default compiler.
if test -n "$available_tags" && test -z "$tagname"; then
case $base_compile in
# Blanks in the command may have been stripped by the calling shell,
# but not from the CC environment variable when configure was run.
" $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "*) ;;
# Blanks at the start of $base_compile will cause this to fail
# if we don't check for them as well.
*)
for z in $available_tags; do
if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
# Evaluate the configuration.
eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
case "$base_compile " in
"$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
# The compiler in the base compile command matches
# the one in the tagged configuration.
# Assume this is the tagged configuration we want.
tagname=$z
break
;;
esac
fi
done
# If $tagname still isn't set, then no tagged configuration
# was found and let the user know that the "--tag" command
# line option must be used.
if test -z "$tagname"; then
$echo "$modename: unable to infer tagged configuration"
$echo "$modename: specify a tag with \`--tag'" 1>&2
exit 1
# else
# $echo "$modename: using $tagname tagged configuration"
fi
;;
esac
fi
objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
if test "X$xdir" = "X$obj"; then
xdir=
else
xdir=$xdir/
fi
lobj=${xdir}$objdir/$objname
Apr 26, 2001
Apr 26, 2001
568
569
570
571
572
573
574
575
if test -z "$base_compile"; then
$echo "$modename: you must specify a compilation command" 1>&2
$echo "$help" 1>&2
exit 1
fi
# Delete any leftover library objects.
if test "$build_old_libs" = yes; then
Oct 6, 2003
Oct 6, 2003
576
removelist="$obj $lobj $libobj ${libobj}T"
Apr 26, 2001
Apr 26, 2001
577
else
Oct 6, 2003
Oct 6, 2003
578
removelist="$lobj $libobj ${libobj}T"
Apr 26, 2001
Apr 26, 2001
579
580
581
582
583
fi
$run $rm $removelist
trap "$run $rm $removelist; exit 1" 1 2 15
Oct 6, 2003
Oct 6, 2003
584
585
586
587
588
589
590
591
592
593
594
# On Cygwin there's no "real" PIC flag so we must build both object types
case $host_os in
cygwin* | mingw* | pw32* | os2*)
pic_mode=default
;;
esac
if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
# non-PIC code in shared libraries is not supported
pic_mode=default
fi
Apr 26, 2001
Apr 26, 2001
595
596
597
# Calculate the filename of the output object if compiler does
# not support -o with -c
if test "$compiler_c_o" = no; then
Oct 6, 2003
Oct 6, 2003
598
output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
Apr 26, 2001
Apr 26, 2001
599
600
601
602
lockfile="$output_obj.lock"
removelist="$removelist $output_obj $lockfile"
trap "$run $rm $removelist; exit 1" 1 2 15
else
Oct 6, 2003
Oct 6, 2003
603
output_obj=
Apr 26, 2001
Apr 26, 2001
604
605
606
607
608
609
610
need_locks=no
lockfile=
fi
# Lock this critical section if it is needed
# We use this script file to make the link, it avoids creating a new file
if test "$need_locks" = yes; then
Oct 6, 2003
Oct 6, 2003
611
until $run ln "$0" "$lockfile" 2>/dev/null; do
Apr 26, 2001
Apr 26, 2001
612
613
614
615
616
$show "Waiting for $lockfile to be removed"
sleep 2
done
elif test "$need_locks" = warn; then
if test -f "$lockfile"; then
Oct 6, 2003
Oct 6, 2003
617
$echo "\
Apr 26, 2001
Apr 26, 2001
618
619
620
621
622
623
624
625
626
627
628
629
630
*** ERROR, $lockfile exists and contains:
`cat $lockfile 2>/dev/null`
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together. If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
$run $rm $removelist
exit 1
fi
Oct 6, 2003
Oct 6, 2003
631
$echo $srcfile > "$lockfile"
Apr 26, 2001
Apr 26, 2001
632
633
634
635
636
637
fi
if test -n "$fix_srcfile_path"; then
eval srcfile=\"$fix_srcfile_path\"
fi
Oct 6, 2003
Oct 6, 2003
638
639
640
641
642
643
644
645
646
647
648
649
650
651
$run $rm "$libobj" "${libobj}T"
# Create a libtool object file (analogous to a ".la" file),
# but don't create it if we're doing a dry run.
test -z "$run" && cat > ${libobj}T <<EOF
# $libobj - a libtool object file
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# Name of the PIC object.
EOF
Apr 26, 2001
Apr 26, 2001
652
653
654
655
656
# Only build a PIC object if we are building libtool libraries.
if test "$build_libtool_libs" = yes; then
# Without this assignment, base_compile gets emptied.
fbsd_hideous_sh_bug=$base_compile
Oct 6, 2003
Oct 6, 2003
657
658
659
660
661
662
if test "$pic_mode" != no; then
command="$base_compile $srcfile $pic_flag"
else
# Don't build PIC code
command="$base_compile $srcfile"
fi
Apr 26, 2001
Apr 26, 2001
663
Oct 6, 2003
Oct 6, 2003
664
665
666
667
668
669
if test ! -d "${xdir}$objdir"; then
$show "$mkdir ${xdir}$objdir"
$run $mkdir ${xdir}$objdir
status=$?
if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
exit $status
Apr 26, 2001
Apr 26, 2001
670
671
fi
fi
Oct 6, 2003
Oct 6, 2003
672
673
674
675
if test -z "$output_obj"; then
# Place PIC objects in $objdir
command="$command -o $lobj"
Apr 26, 2001
Apr 26, 2001
676
677
fi
Oct 6, 2003
Oct 6, 2003
678
679
$run $rm "$lobj" "$output_obj"
Apr 26, 2001
Apr 26, 2001
680
681
682
683
684
685
686
687
$show "$command"
if $run eval "$command"; then :
else
test -n "$output_obj" && $run $rm $removelist
exit 1
fi
if test "$need_locks" = warn &&
Oct 6, 2003
Oct 6, 2003
688
689
test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
$echo "\
Apr 26, 2001
Apr 26, 2001
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`
but it should contain:
$srcfile
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together. If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
$run $rm $removelist
exit 1
fi
# Just move the object if needed, then go on to compile the next one
Oct 6, 2003
Oct 6, 2003
708
709
710
if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
$show "$mv $output_obj $lobj"
if $run $mv $output_obj $lobj; then :
Apr 26, 2001
Apr 26, 2001
711
712
713
714
715
716
717
else
error=$?
$run $rm $removelist
exit $error
fi
fi
Oct 6, 2003
Oct 6, 2003
718
719
720
# Append the name of the PIC object to the libtool object file.
test -z "$run" && cat >> ${libobj}T <<EOF
pic_object='$objdir/$objname'
Apr 26, 2001
Apr 26, 2001
721
Oct 6, 2003
Oct 6, 2003
722
EOF
Apr 26, 2001
Apr 26, 2001
723
724
725
# Allow error messages only from the first compilation.
suppress_output=' >/dev/null 2>&1'
Oct 6, 2003
Oct 6, 2003
726
727
728
729
730
731
732
else
# No PIC object so indicate it doesn't exist in the libtool
# object file.
test -z "$run" && cat >> ${libobj}T <<EOF
pic_object=none
EOF
Apr 26, 2001
Apr 26, 2001
733
734
735
736
fi
# Only build a position-dependent object if we build old libraries.
if test "$build_old_libs" = yes; then
Oct 6, 2003
Oct 6, 2003
737
738
739
740
741
742
if test "$pic_mode" != yes; then
# Don't build PIC code
command="$base_compile $srcfile"
else
command="$base_compile $srcfile $pic_flag"
fi
Apr 26, 2001
Apr 26, 2001
743
744
745
746
747
748
if test "$compiler_c_o" = yes; then
command="$command -o $obj"
fi
# Suppress compiler output if we already did a PIC compilation.
command="$command$suppress_output"
Oct 6, 2003
Oct 6, 2003
749
$run $rm "$obj" "$output_obj"
Apr 26, 2001
Apr 26, 2001
750
751
752
753
754
755
756
757
$show "$command"
if $run eval "$command"; then :
else
$run $rm $removelist
exit 1
fi
if test "$need_locks" = warn &&
Oct 6, 2003
Oct 6, 2003
758
759
test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
$echo "\
Apr 26, 2001
Apr 26, 2001
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`
but it should contain:
$srcfile
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together. If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
$run $rm $removelist
exit 1
fi
# Just move the object if needed
Oct 6, 2003
Oct 6, 2003
778
if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
Apr 26, 2001
Apr 26, 2001
779
780
781
782
783
784
785
786
787
$show "$mv $output_obj $obj"
if $run $mv $output_obj $obj; then :
else
error=$?
$run $rm $removelist
exit $error
fi
fi
Oct 6, 2003
Oct 6, 2003
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
# Append the name of the non-PIC object the libtool object file.
# Only append if the libtool object file exists.
test -z "$run" && cat >> ${libobj}T <<EOF
# Name of the non-PIC object.
non_pic_object='$objname'
EOF
else
# Append the name of the non-PIC object the libtool object file.
# Only append if the libtool object file exists.
test -z "$run" && cat >> ${libobj}T <<EOF
# Name of the non-PIC object.
non_pic_object=none
EOF
Apr 26, 2001
Apr 26, 2001
803
804
fi
Oct 6, 2003
Oct 6, 2003
805
806
$run $mv "${libobj}T" "${libobj}"
Apr 26, 2001
Apr 26, 2001
807
808
# Unlock the critical section if it was locked
if test "$need_locks" != no; then
Oct 6, 2003
Oct 6, 2003
809
$run $rm "$lockfile"
Apr 26, 2001
Apr 26, 2001
810
811
812
813
814
815
fi
exit 0
;;
# libtool link mode
Oct 6, 2003
Oct 6, 2003
816
link | relink)
Apr 26, 2001
Apr 26, 2001
817
modename="$modename: link"
Oct 6, 2003
Oct 6, 2003
818
819
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
Apr 26, 2001
Apr 26, 2001
820
821
822
# It is impossible to link a dll without this setting, and
# we shouldn't force the makefile maintainer to figure out
# which system we are compiling for in order to pass an extra
Oct 6, 2003
Oct 6, 2003
823
# flag for every libtool invocation.
Apr 26, 2001
Apr 26, 2001
824
825
826
827
828
829
830
831
832
833
834
835
836
# allow_undefined=no
# FIXME: Unfortunately, there are problems with the above when trying
# to make a dll which has undefined symbols, in which case not
# even a static library is built. For now, we need to specify
# -no-undefined on the libtool link line when we can be certain
# that all symbols are satisfied, otherwise we get a static library.
allow_undefined=yes
;;
*)
allow_undefined=yes
;;
esac
Oct 6, 2003
Oct 6, 2003
837
838
libtool_args="$nonopt"
base_compile="$nonopt"
Apr 26, 2001
Apr 26, 2001
839
840
841
842
843
844
845
846
847
848
compile_command="$nonopt"
finalize_command="$nonopt"
compile_rpath=
finalize_rpath=
compile_shlibpath=
finalize_shlibpath=
convenience=
old_convenience=
deplibs=
Oct 6, 2003
Oct 6, 2003
849
850
851
852
853
854
old_deplibs=
compiler_flags=
linker_flags=
dllsearchpath=
lib_search_path=`pwd`
inst_prefix_dir=
Apr 26, 2001
Apr 26, 2001
855
856
857
858
859
860
861
862
863
864
865
866
avoid_version=no
dlfiles=
dlprefiles=
dlself=no
export_dynamic=no
export_symbols=
export_symbols_regex=
generated=
libobjs=
ltlibs=
module=no
Oct 6, 2003
Oct 6, 2003
867
no_install=no
Apr 26, 2001
Apr 26, 2001
868
objs=
Oct 6, 2003
Oct 6, 2003
869
non_pic_objects=
Apr 26, 2001
Apr 26, 2001
870
871
872
873
874
875
876
877
878
879
880
prefer_static_libs=no
preload=no
prev=
prevarg=
release=
rpath=
xrpath=
perm_rpath=
temp_rpath=
thread_safe=no
vinfo=
Oct 6, 2003
Oct 6, 2003
881
vinfo_number=no
Apr 26, 2001
Apr 26, 2001
882
883
884
885
# We need to know -static, to get the right output filenames.
for arg
do
Oct 6, 2003
Oct 6, 2003
886
case $arg in
Apr 26, 2001
Apr 26, 2001
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
-all-static | -static)
if test "X$arg" = "X-all-static"; then
if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
$echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
fi
if test -n "$link_static_flag"; then
dlopen_self=$dlopen_self_static
fi
else
if test -z "$pic_flag" && test -n "$link_static_flag"; then
dlopen_self=$dlopen_self_static
fi
fi
build_libtool_libs=no
build_old_libs=yes
prefer_static_libs=yes
break
;;
esac
done
# See if our shared archives depend on static archives.
test -n "$old_archive_from_new_cmds" && build_old_libs=yes
# Go through the arguments, transforming them on the way.
Oct 6, 2003
Oct 6, 2003
912
while test "$#" -gt 0; do
Apr 26, 2001
Apr 26, 2001
913
arg="$1"
Oct 6, 2003
Oct 6, 2003
914
base_compile="$base_compile $arg"
Apr 26, 2001
Apr 26, 2001
915
shift
Oct 6, 2003
Oct 6, 2003
916
917
918
919
920
921
922
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
;;
*) qarg=$arg ;;
esac
libtool_args="$libtool_args $qarg"
Apr 26, 2001
Apr 26, 2001
923
924
925
# If the previous option needs an argument, assign it.
if test -n "$prev"; then
Oct 6, 2003
Oct 6, 2003
926
case $prev in
Apr 26, 2001
Apr 26, 2001
927
928
929
930
931
932
output)
compile_command="$compile_command @OUTPUT@"
finalize_command="$finalize_command @OUTPUT@"
;;
esac
Oct 6, 2003
Oct 6, 2003
933
case $prev in
Apr 26, 2001
Apr 26, 2001
934
935
936
937
938
939
940
dlfiles|dlprefiles)
if test "$preload" = no; then
# Add the symbol object into the linking commands.
compile_command="$compile_command @SYMFILE@"
finalize_command="$finalize_command @SYMFILE@"
preload=yes
fi
Oct 6, 2003
Oct 6, 2003
941
case $arg in
Apr 26, 2001
Apr 26, 2001
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
*.la | *.lo) ;; # We handle these cases below.
force)
if test "$dlself" = no; then
dlself=needless
export_dynamic=yes
fi
prev=
continue
;;
self)
if test "$prev" = dlprefiles; then
dlself=yes
elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
dlself=yes
else
dlself=needless
export_dynamic=yes
fi
prev=
continue
;;
*)
if test "$prev" = dlfiles; then
dlfiles="$dlfiles $arg"
else
dlprefiles="$dlprefiles $arg"
fi
prev=
Oct 6, 2003
Oct 6, 2003
970
continue
Apr 26, 2001
Apr 26, 2001
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
;;
esac
;;
expsyms)
export_symbols="$arg"
if test ! -f "$arg"; then
$echo "$modename: symbol file \`$arg' does not exist"
exit 1
fi
prev=
continue
;;
expsyms_regex)
export_symbols_regex="$arg"
prev=
continue
;;
Oct 6, 2003
Oct 6, 2003
988
989
inst_prefix)
inst_prefix_dir="$arg"
Jun 1, 2002
Jun 1, 2002
990
991
992
prev=
continue
;;
Apr 26, 2001
Apr 26, 2001
993
994
995
996
997
release)
release="-$arg"
prev=
continue
;;
Oct 6, 2003
Oct 6, 2003
998
999
1000
objectlist)
if test -f "$arg"; then
save_arg=$arg