1
1
# ltmain.sh - Provide generalized library-building support services.
2
2
# NOTE: Changing this file will not affect anything until you rerun configure.
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
5
5
# Free Software Foundation, Inc.
6
6
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
24
24
# configuration script generated by Autoconf, you may include it under
25
25
# the same distribution terms that you use for the rest of that program.
29
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30
# is ksh but when the shell is invoked as "sh" and the current value of
31
# the _XPG environment variable is not equal to 1 (one), the special
32
# positional parameter $0, within a function call, is the name of the
36
# The name of this program:
37
progname=`echo "$progpath" | $SED $basename`
46
VERSION="1.5.22 Debian 1.5.22-4"
47
TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
49
# See if we are running on zsh, and set the options which allow our
50
# commands through without removal of \ escapes.
51
if test -n "${ZSH_VERSION+set}" ; then
27
55
# Check that we have a working $echo.
28
56
if test "X$1" = X--no-reexec; then
29
57
# Discard the --no-reexec flag, and continue.
118
141
# Shell function definitions:
119
142
# This seems to be the best place for them
144
# func_mktempdir [string]
145
# Make a temporary directory that won't clash with other running
146
# libtool processes, and avoids race conditions if possible. If
147
# given, STRING is the basename for that directory.
150
my_template="${TMPDIR-/tmp}/${1-$progname}"
152
if test "$run" = ":"; then
153
# Return a directory name, but don't create it in dry-run mode
154
my_tmpdir="${my_template}-$$"
157
# If mktemp works, use that first and foremost
158
my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
160
if test ! -d "$my_tmpdir"; then
161
# Failing that, at least try and use $RANDOM to avoid a race
162
my_tmpdir="${my_template}-${RANDOM-0}$$"
164
save_mktempdir_umask=`umask`
167
umask $save_mktempdir_umask
170
# If we're not in dry-run mode, bomb out on failure
171
test -d "$my_tmpdir" || {
172
$echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
177
$echo "X$my_tmpdir" | $Xsed
181
# func_win32_libid arg
182
# return the library type of file 'arg'
121
184
# Need a lot of goo to handle *both* DLLs and import libs
122
185
# Has to be a shell function in order to 'eat' the argument
123
186
# that is supplied when $file_magic_command is called.
125
189
win32_libid_type="unknown"
126
190
win32_fileres=`file -L $1 2>/dev/null`
127
191
case $win32_fileres in
131
195
*ar\ archive*) # could be an import, or static
132
196
if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
133
grep -E 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
197
$EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
134
198
win32_nmres=`eval $NM -f posix -A $1 | \
135
sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
136
if test "X$win32_nmres" = "Ximport" ; then
137
win32_libid_type="x86 archive import"
139
win32_libid_type="x86 archive static"
199
$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
201
import*) win32_libid_type="x86 archive import";;
202
*) win32_libid_type="x86 archive static";;
144
207
win32_libid_type="x86 DLL"
146
209
*executable*) # but shell scripts are "executable" too...
154
217
$echo $win32_libid_type
222
# Infer tagged configuration to use if any are available and
223
# if one wasn't chosen via the "--tag" command line option.
224
# Only attempt this if the compiler in the base compile
225
# command doesn't match the default compiler.
226
# arg is usually of the form 'gcc ...'
229
if test -n "$available_tags" && test -z "$tagname"; then
233
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
237
CC_quoted="$CC_quoted $arg"
240
# Blanks in the command may have been stripped by the calling shell,
241
# but not from the CC environment variable when configure was run.
242
" $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
243
# Blanks at the start of $base_compile will cause this to fail
244
# if we don't check for them as well.
246
for z in $available_tags; do
247
if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
248
# Evaluate the configuration.
249
eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
252
# Double-quote args containing other shell metacharacters.
254
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
258
CC_quoted="$CC_quoted $arg"
261
" $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
262
# The compiler in the base compile command matches
263
# the one in the tagged configuration.
264
# Assume this is the tagged configuration we want.
271
# If $tagname still isn't set, then no tagged configuration
272
# was found and let the user know that the "--tag" command
273
# line option must be used.
274
if test -z "$tagname"; then
275
$echo "$modename: unable to infer tagged configuration"
276
$echo "$modename: specify a tag with \`--tag'" 1>&2
279
# $echo "$modename: using $tagname tagged configuration"
287
# func_extract_an_archive dir oldlib
288
func_extract_an_archive ()
290
f_ex_an_ar_dir="$1"; shift
291
f_ex_an_ar_oldlib="$1"
293
$show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
294
$run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
295
if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
298
$echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
303
# func_extract_archives gentop oldlib ...
304
func_extract_archives ()
306
my_gentop="$1"; shift
314
$show "${rm}r $my_gentop"
315
$run ${rm}r "$my_gentop"
316
$show "$mkdir $my_gentop"
317
$run $mkdir "$my_gentop"
319
if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
323
for my_xlib in $my_oldlibs; do
324
# Extract the objects.
326
[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
327
*) my_xabs=`pwd`"/$my_xlib" ;;
329
my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
330
my_xdir="$my_gentop/$my_xlib"
332
$show "${rm}r $my_xdir"
333
$run ${rm}r "$my_xdir"
334
$show "$mkdir $my_xdir"
335
$run $mkdir "$my_xdir"
337
if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
342
$show "Extracting $my_xabs"
343
# Do not bother doing anything if just a dry run
344
if test -z "$run"; then
345
darwin_orig_dir=`pwd`
346
cd $my_xdir || exit $?
347
darwin_archive=$my_xabs
349
darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
350
darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
351
if test -n "$darwin_arches"; then
352
darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
354
$show "$darwin_base_archive has multiple architectures $darwin_arches"
355
for darwin_arch in $darwin_arches ; do
356
mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
357
lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
358
cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
359
func_extract_an_archive "`pwd`" "${darwin_base_archive}"
361
$rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
362
done # $darwin_arches
363
## Okay now we have a bunch of thin objects, gotta fatten them up :)
364
darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
367
for darwin_file in $darwin_filelist; do
368
darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
369
lipo -create -output "$darwin_file" $darwin_files
370
done # $darwin_filelist
372
cd "$darwin_orig_dir"
374
cd "$darwin_orig_dir"
375
func_extract_an_archive "$my_xdir" "$my_xabs"
380
func_extract_an_archive "$my_xdir" "$my_xabs"
383
my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
385
func_extract_archives_result="$my_oldobjs"
157
387
# End of Shell function definitions
158
388
#####################################
391
eval std_shrext=\"$shrext_cmds\"
160
395
# Parse our command line options once, thoroughly.
161
396
while test "$#" -gt 0
221
457
$echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
223
$echo "Copyright (C) 2003 Free Software Foundation, Inc."
459
$echo "Copyright (C) 2005 Free Software Foundation, Inc."
224
460
$echo "This is free software; see the source for copying conditions. There is NO"
225
461
$echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
230
${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
466
${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
231
467
# Now print the configurations for the tags.
232
468
for tagname in $taglist; do
233
${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$0"
469
${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
239
475
$echo "$progname: enabling shell trace mode"
477
preserve_args="$preserve_args $arg"
511
766
*.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
513
768
$echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
518
# Infer tagged configuration to use if any are available and
519
# if one wasn't chosen via the "--tag" command line option.
520
# Only attempt this if the compiler in the base compile
521
# command doesn't match the default compiler.
522
if test -n "$available_tags" && test -z "$tagname"; then
523
case $base_compile in
524
# Blanks in the command may have been stripped by the calling shell,
525
# but not from the CC environment variable when configure was run.
526
" $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "*) ;;
527
# Blanks at the start of $base_compile will cause this to fail
528
# if we don't check for them as well.
530
for z in $available_tags; do
531
if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
532
# Evaluate the configuration.
533
eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
534
case "$base_compile " in
535
"$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
536
# The compiler in the base compile command matches
537
# the one in the tagged configuration.
538
# Assume this is the tagged configuration we want.
545
# If $tagname still isn't set, then no tagged configuration
546
# was found and let the user know that the "--tag" command
547
# line option must be used.
548
if test -z "$tagname"; then
549
$echo "$modename: unable to infer tagged configuration"
550
$echo "$modename: specify a tag with \`--tag'" 1>&2
553
# $echo "$modename: using $tagname tagged configuration"
773
func_infer_tag $base_compile
775
for arg in $later; do
794
qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
796
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
797
qlibobj="\"$qlibobj\"" ;;
799
test "X$libobj" != "X$qlibobj" \
800
&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \
801
&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
559
802
objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
560
803
xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
561
804
if test "X$xdir" = "X$obj"; then
1273
1553
if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1275
*-*-cygwin* | *-*-pw32* | *-*-beos*)
1555
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1276
1556
# These systems don't actually have a C or math library (as such)
1279
*-*-mingw* | *-*-os2*)
1280
1560
# These systems don't actually have a C library (as such)
1281
1561
test "X$arg" = "X-lc" && continue
1283
*-*-openbsd* | *-*-freebsd*)
1563
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1284
1564
# Do not include libc due to us having libc/libc_r.
1285
1565
test "X$arg" = "X-lc" && continue
1287
1567
*-*-rhapsody* | *-*-darwin1.[012])
1288
1568
# Rhapsody C and math libraries are in the System framework
1289
deplibs="$deplibs System.ltframework"
1569
deplibs="$deplibs -framework System"
1572
*-*-sco3.2v5* | *-*-sco5v6*)
1573
# Causes problems with __ctype
1574
test "X$arg" = "X-lc" && continue
1576
*-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1577
# Compiler inserts libc in the correct place for threads to work
1578
test "X$arg" = "X-lc" && continue
1292
1581
elif test "X$arg" = "X-lc_r"; then
1583
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1295
1584
# Do not include libc_r directly, use -pthread flag.
1593
# Tru64 UNIX uses -model [arg] to determine the layout of C++
1594
# classes, name mangling, and exception handling.
1596
compile_command="$compile_command $arg"
1597
compiler_flags="$compiler_flags $arg"
1598
finalize_command="$finalize_command $arg"
1603
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1604
compiler_flags="$compiler_flags $arg"
1605
compile_command="$compile_command $arg"
1606
finalize_command="$finalize_command $arg"
1309
# gcc -m* arguments should be passed to the linker via $compiler_flags
1310
# in order to pass architecture information to the linker
1311
# (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
1312
# but this is not reliable with gcc because gcc may use -mfoo to
1313
# select a different linker, different libraries, etc, while
1314
# -Wl,-mfoo simply passes -mfoo to the linker.
1615
# -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1616
# -r[0-9][0-9]* specifies the processor on the SGI compiler
1617
# -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1618
# +DA*, +DD* enable 64-bit mode on the HP compiler
1619
# -q* pass through compiler args for the IBM compiler
1620
# -m* pass through architecture-specific compiler args for GCC
1621
# -m*, -t[45]*, -txscale* pass through architecture-specific
1622
# compiler args for GCC
1623
# -pg pass through profiling flag for GCC
1624
# @file GCC response files
1625
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
1626
-t[45]*|-txscale*|@*)
1316
1628
# Unknown arguments in both finalize_command and compile_command need
1317
1629
# to be aesthetically quoted because they are evaled later.
1318
1630
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1637
1950
if test -n "$prev"; then
1638
1951
$echo "$modename: the \`$prevarg' option requires an argument" 1>&2
1639
1952
$echo "$help" 1>&2
1643
# Infer tagged configuration to use if any are available and
1644
# if one wasn't chosen via the "--tag" command line option.
1645
# Only attempt this if the compiler in the base link
1646
# command doesn't match the default compiler.
1647
if test -n "$available_tags" && test -z "$tagname"; then
1648
case $base_compile in
1649
# Blanks in the command may have been stripped by the calling shell,
1650
# but not from the CC environment variable when configure was run.
1651
"$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) ;;
1652
# Blanks at the start of $base_compile will cause this to fail
1653
# if we don't check for them as well.
1655
for z in $available_tags; do
1656
if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
1657
# Evaluate the configuration.
1658
eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
1659
case $base_compile in
1660
"$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
1661
# The compiler in $compile_command matches
1662
# the one in the tagged configuration.
1663
# Assume this is the tagged configuration we want.
1670
# If $tagname still isn't set, then no tagged configuration
1671
# was found and let the user know that the "--tag" command
1672
# line option must be used.
1673
if test -z "$tagname"; then
1674
$echo "$modename: unable to infer tagged configuration"
1675
$echo "$modename: specify a tag with \`--tag'" 1>&2
1678
# $echo "$modename: using $tagname tagged configuration"
1684
1956
if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
1825
2099
case $deplib in
2100
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
2101
if test "$linkmode,$pass" = "prog,link"; then
2102
compile_deplibs="$deplib $compile_deplibs"
2103
finalize_deplibs="$deplib $finalize_deplibs"
2105
compiler_flags="$compiler_flags $deplib"
1827
2110
if test "$linkmode" != lib && test "$linkmode" != prog; then
1828
2111
$echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
1831
if test "$pass" = conv && test "$allow_undefined" = yes; then
1832
deplibs="$deplib $deplibs"
1835
2114
name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
1836
2115
for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
1837
for search_ext in .la $shrext .so .a; do
2116
for search_ext in .la $std_shrext .so .a; do
1838
2117
# Search the libtool library
1839
2118
lib="$searchdir/lib${name}${search_ext}"
1840
2119
if test -f "$lib"; then
2052
2329
if test "$pass" = conv; then
2053
2330
# Only check for convenience libraries
2054
2331
deplibs="$lib $deplibs"
2056
for deplib in $dependency_libs; do
2057
#echo "Adding $deplib to \$deplibs"
2058
deplibs="$deplib $deplibs"
2059
if test "X$duplicate_deps" = "Xyes" ; then
2060
case "$tmp_libs " in
2061
*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2064
tmp_libs="$tmp_libs $deplib"
2066
2332
if test -z "$libdir"; then
2067
2333
if test -z "$old_library"; then
2068
2334
$echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2071
2337
# It is a libtool convenience library, so add in its objects.
2072
2338
convenience="$convenience $ladir/$objdir/$old_library"
2073
2339
old_convenience="$old_convenience $ladir/$objdir/$old_library"
2341
for deplib in $dependency_libs; do
2342
deplibs="$deplib $deplibs"
2343
if test "X$duplicate_deps" = "Xyes" ; then
2344
case "$tmp_libs " in
2345
*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2348
tmp_libs="$tmp_libs $deplib"
2074
2350
elif test "$linkmode" != prog && test "$linkmode" != lib; then
2075
2351
$echo "$modename: \`$lib' is not a convenience library" 1>&2
2079
2355
fi # $pass = conv
2082
2358
# Get the name of the library we link against.
2084
2360
for l in $old_library $library_names; do
2087
2363
if test -z "$linklib"; then
2088
2364
$echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2092
2368
# This library was specified with -dlopen.
2093
2369
if test "$pass" = dlopen; then
2094
2370
if test -z "$libdir"; then
2095
2371
$echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2098
if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2374
if test -z "$dlname" ||
2375
test "$dlopen_support" != yes ||
2376
test "$build_libtool_libs" = no; then
2099
2377
# If there is no dlname, no dlopen support or we're linking
2100
2378
# statically, we need to preload. We also need to preload any
2101
2379
# dependent libraries so libltdl's deplib preloader doesn't
2253
2539
link_static=no # Whether the deplib will be linked statically
2540
use_static_libs=$prefer_static_libs
2541
if test "$use_static_libs" = built && test "$installed" = yes ; then
2254
2544
if test -n "$library_names" &&
2255
{ test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2545
{ test "$use_static_libs" = no || test -z "$old_library"; }; then
2256
2546
if test "$installed" = no; then
2257
2547
notinst_deplibs="$notinst_deplibs $lib"
2258
2548
need_relink=yes
2260
2550
# This is a shared library
2262
# Warn about portability, can't link against -module's on some systems (darwin)
2263
if test "$shouldnotlink" = yes && test "$pass" = link ; then
2552
# Warn about portability, can't link against -module's on
2553
# some systems (darwin)
2554
if test "$shouldnotlink" = yes && test "$pass" = link ; then
2265
2556
if test "$linkmode" = prog; then
2266
2557
$echo "*** Warning: Linking the executable $output against the loadable module"
2268
2559
$echo "*** Warning: Linking the shared library $output against the loadable module"
2270
$echo "*** $linklib is not portable!"
2561
$echo "*** $linklib is not portable!"
2272
2563
if test "$linkmode" = lib &&
2273
2564
test "$hardcode_into_libs" = yes; then
2274
2565
# Hardcode the library path.
2362
2655
if test "$hardcode_direct" = no; then
2363
2656
add="$dir/$linklib"
2365
*-*-sco3.2v5* ) add_dir="-L$dir" ;;
2658
*-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2659
*-*-sysv4*uw2*) add_dir="-L$dir" ;;
2660
*-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2661
*-*-unixware7*) add_dir="-L$dir" ;;
2367
# if the lib is a module then we can not link against it, someone
2368
# is ignoring the new warnings I added
2369
if /usr/bin/file -L $add 2> /dev/null | grep "bundle" >/dev/null ; then
2663
# if the lib is a module then we can not link against
2664
# it, someone is ignoring the new warnings I added
2665
if /usr/bin/file -L $add 2> /dev/null |
2666
$EGREP ": [^:]* bundle" >/dev/null ; then
2370
2667
$echo "** Warning, lib $linklib is a module, not a shared library"
2371
2668
if test -z "$old_library" ; then
2533
convenience="$convenience $dir/$old_library"
2534
old_convenience="$old_convenience $dir/$old_library"
2535
2831
deplibs="$dir/$old_library $deplibs"
2536
2832
link_static=yes
2538
2834
fi # link shared/static library?
2540
2836
if test "$linkmode" = lib; then
2541
#if test -n "$dependency_libs" &&
2542
# { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes ||
2543
# test "$link_static" = yes; }; then
2837
if test -n "$dependency_libs" &&
2838
{ test "$hardcode_into_libs" != yes ||
2839
test "$build_old_libs" = yes ||
2840
test "$link_static" = yes; }; then
2544
2841
# Extract -R from dependency_libs
2546
2843
for libdir in $dependency_libs; do
2596
2893
eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2597
2894
if test -z "$libdir"; then
2598
2895
$echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2601
2898
if test "$absdir" != "$libdir"; then
2602
# Sure, some shells/systems don't implement the -ef.
2603
# Those will have to live with the warning.
2604
test "$absdir" -ef "$libdir" > /dev/null 2>&1 ||
2605
$echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2899
$echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2612
# we do not want to link against static libs, but need to link against shared
2906
# we do not want to link against static libs,
2907
# but need to link against shared
2613
2908
eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2614
2909
if test -n "$deplibrary_names" ; then
2615
2910
for tmp in $deplibrary_names ; do
2618
2913
if test -f "$path/$depdepl" ; then
2619
2914
depdepl="$path/$depdepl"
2621
2916
# do not add paths which are already there
2622
2917
case " $newlib_search_path " in
2623
2918
*" $path "*) ;;
2624
2919
*) newlib_search_path="$newlib_search_path $path";;
2638
# Again, we only want to link against shared libraries
2639
eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2640
for tmp in $newlib_search_path ; do
2641
if test -f "$tmp/lib$tmp_libs.dylib" ; then
2642
eval depdepl="$tmp/lib$tmp_libs.dylib"
2932
# Again, we only want to link against shared libraries
2933
eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2934
for tmp in $newlib_search_path ; do
2935
if test -f "$tmp/lib$tmp_libs.dylib" ; then
2936
eval depdepl="$tmp/lib$tmp_libs.dylib"
2662
2947
case " $deplibs " in
2949
*) deplibs="$path $deplibs" ;;
2951
case " $deplibs " in
2663
2952
*" $depdepl "*) ;;
2664
*) deplibs="$deplibs $depdepl" ;;
2666
case " $deplibs " in
2668
*) deplibs="$deplibs $path" ;;
2953
*) deplibs="$depdepl $deplibs" ;;
2671
2956
fi # link_all_deplibs != no
2812
3098
case $outputname in
2814
3100
name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2815
eval shared_ext=\"$shrext\"
3101
eval shared_ext=\"$shrext_cmds\"
2816
3102
eval libname=\"$libname_spec\"
2819
3105
if test "$module" = no; then
2820
3106
$echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
2821
3107
$echo "$help" 1>&2
2824
3110
if test "$need_lib_prefix" != no; then
2825
3111
# Add the "lib" prefix for modules if required
2826
3112
name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
2827
eval shared_ext=\"$shrext\"
3113
eval shared_ext=\"$shrext_cmds\"
2828
3114
eval libname=\"$libname_spec\"
2830
3116
libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
2930
3221
# Check that each of the things are valid numbers.
2931
3222
case $current in
2932
0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3223
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]) ;;
2934
$echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
3225
$echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
2935
3226
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2940
3231
case $revision in
2941
0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3232
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]) ;;
2943
$echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
3234
$echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
2944
3235
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2950
0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3241
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]) ;;
2952
$echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
3243
$echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
2953
3244
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2958
3249
if test "$age" -gt "$current"; then
2959
3250
$echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
2960
3251
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2964
3255
# Calculate the version variables.
3171
3468
*-*-rhapsody* | *-*-darwin1.[012])
3172
3469
# Rhapsody C library is in the System framework
3173
deplibs="$deplibs System.ltframework"
3470
deplibs="$deplibs -framework System"
3176
3473
# Don't link with libc until the a.out ld.so is fixed.
3178
*-*-openbsd* | *-*-freebsd*)
3475
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
3179
3476
# Do not include libc due to us having libc/libc_r.
3180
test "X$arg" = "X-lc" && continue
3478
*-*-sco3.2v5* | *-*-sco5v6*)
3479
# Causes problems with __ctype
3481
*-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
3482
# Compiler inserts libc in the correct place for threads to work
3183
3485
# Add libc to deplibs on all other systems if necessary.
3663
3992
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3665
3994
gentop="$output_objdir/${outputname}x"
3666
$show "${rm}r $gentop"
3667
$run ${rm}r "$gentop"
3668
$show "$mkdir $gentop"
3669
$run $mkdir "$gentop"
3671
if test "$status" -ne 0 && test ! -d "$gentop"; then
3674
3995
generated="$generated $gentop"
3676
for xlib in $convenience; do
3677
# Extract the objects.
3679
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3680
*) xabs=`pwd`"/$xlib" ;;
3682
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3683
xdir="$gentop/$xlib"
3685
$show "${rm}r $xdir"
3687
$show "$mkdir $xdir"
3690
if test "$status" -ne 0 && test ! -d "$xdir"; then
3693
# We will extract separately just the conflicting names and we will no
3694
# longer touch any unique names. It is faster to leave these extract
3695
# automatically by $AR in one run.
3696
$show "(cd $xdir && $AR x $xabs)"
3697
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3698
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
3701
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
3702
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
3703
$AR t "$xabs" | sort | uniq -cd | while read -r count name
3706
while test "$i" -le "$count"
3708
# Put our $i before any first dot (extension)
3709
# Never overwrite any file
3711
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
3713
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
3715
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
3716
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
3722
libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
3997
func_extract_archives $gentop $convenience
3998
libobjs="$libobjs $func_extract_archives_result"
3727
4002
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3728
4003
eval flag=\"$thread_safe_flag_spec\"
3729
4004
linker_flags="$linker_flags $flag"
3734
4009
$run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
3737
# Add all flags from the command line. We here create a library,
3738
# but those flags were only added to compile_command and
3739
# finalize_command, which are only used when creating executables.
3740
# So do it by hand here.
3741
compiler_flags="$compiler_flags $add_flags"
3742
# Only add it to commands which use CC, instead of LD, i.e.
3743
# only to $compiler_flags
3744
#linker_flags="$linker_flags $add_flags"
3746
4012
# Do each of the archive commands.
3747
4013
if test "$module" = yes && test -n "$module_cmds" ; then
3748
4014
if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
3749
eval cmds=\"$module_expsym_cmds\"
4015
eval test_cmds=\"$module_expsym_cmds\"
4016
cmds=$module_expsym_cmds
3751
eval cmds=\"$module_cmds\"
4018
eval test_cmds=\"$module_cmds\"
3754
4022
if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
3755
eval cmds=\"$archive_expsym_cmds\"
4023
eval test_cmds=\"$archive_expsym_cmds\"
4024
cmds=$archive_expsym_cmds
3757
eval cmds=\"$archive_cmds\"
4026
eval test_cmds=\"$archive_cmds\"
3761
if test "X$skipped_export" != "X:" && len=`expr "X$cmds" : ".*"` &&
4031
if test "X$skipped_export" != "X:" &&
4032
len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
3762
4033
test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3859
4131
# value of $libobjs for piecewise linking.
3861
4133
# Do each of the archive commands.
4134
if test "$module" = yes && test -n "$module_cmds" ; then
4135
if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4136
cmds=$module_expsym_cmds
3862
4141
if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
3863
eval cmds=\"$archive_expsym_cmds\"
4142
cmds=$archive_expsym_cmds
3865
eval cmds=\"$archive_cmds\"
3868
4148
# Append the command to remove the reloadable object files
3869
4149
# to the just-reset $cmds.
3870
eval cmds=\"\$cmds~$rm $delfiles\"
4150
eval cmds=\"\$cmds~\$rm $delfiles\"
3872
4152
save_ifs="$IFS"; IFS='~'
3873
4153
for cmd in $cmds; do
3874
4154
IFS="$save_ifs"
3876
$run eval "$cmd" || exit $?
4157
$run eval "$cmd" || {
4160
# Restore the uninstalled library and exit
4161
if test "$mode" = relink; then
4162
$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
3878
4168
IFS="$save_ifs"
3880
4170
# Restore the uninstalled library and exit
3881
4171
if test "$mode" = relink; then
3882
4172
$run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
4174
if test -n "$convenience"; then
4175
if test -z "$whole_archive_flag_spec"; then
4176
$show "${rm}r $gentop"
4177
$run ${rm}r "$gentop"
3886
4184
# Create links to the real library.
3957
4255
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
3959
4257
gentop="$output_objdir/${obj}x"
3960
$show "${rm}r $gentop"
3961
$run ${rm}r "$gentop"
3962
$show "$mkdir $gentop"
3963
$run $mkdir "$gentop"
3965
if test "$status" -ne 0 && test ! -d "$gentop"; then
3968
4258
generated="$generated $gentop"
3970
for xlib in $convenience; do
3971
# Extract the objects.
3973
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3974
*) xabs=`pwd`"/$xlib" ;;
3976
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3977
xdir="$gentop/$xlib"
3979
$show "${rm}r $xdir"
3981
$show "$mkdir $xdir"
3984
if test "$status" -ne 0 && test ! -d "$xdir"; then
3987
# We will extract separately just the conflicting names and we will no
3988
# longer touch any unique names. It is faster to leave these extract
3989
# automatically by $AR in one run.
3990
$show "(cd $xdir && $AR x $xabs)"
3991
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3992
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
3995
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
3996
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
3997
$AR t "$xabs" | sort | uniq -cd | while read -r count name
4000
while test "$i" -le "$count"
4002
# Put our $i before any first dot (extension)
4003
# Never overwrite any file
4005
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
4007
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
4009
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
4010
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
4016
reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4260
func_extract_archives $gentop $convenience
4261
reload_conv_objs="$reload_objs $func_extract_archives_result"
4099
4345
*-*-rhapsody* | *-*-darwin1.[012])
4100
4346
# On Rhapsody replace the C library is the System framework
4101
compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
4102
finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
4347
compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4348
finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4108
4354
# Don't allow lazy linking, it breaks C++ global constructors
4109
4355
if test "$tagname" = CXX ; then
4110
4356
compile_command="$compile_command ${wl}-bind_at_load"
4111
4357
finalize_command="$finalize_command ${wl}-bind_at_load"
4113
# Time to change all our "foo.ltframework" stuff back to "-framework foo"
4114
compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
4115
finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
4363
# move library search paths that coincide with paths to not yet
4364
# installed libraries to the beginning of the library search list
4366
for path in $notinst_path; do
4367
case " $new_libs " in
4368
*" -L$path/$objdir "*) ;;
4370
case " $compile_deplibs " in
4371
*" -L$path/$objdir "*)
4372
new_libs="$new_libs -L$path/$objdir" ;;
4377
for deplib in $compile_deplibs; do
4380
case " $new_libs " in
4382
*) new_libs="$new_libs $deplib" ;;
4385
*) new_libs="$new_libs $deplib" ;;
4388
compile_deplibs="$new_libs"
4119
4391
compile_command="$compile_command $compile_deplibs"
4120
4392
finalize_command="$finalize_command $finalize_deplibs"
4278
4555
# Prepare the list of exported symbols
4279
4556
if test -z "$export_symbols"; then
4280
export_symbols="$output_objdir/$output.exp"
4557
export_symbols="$output_objdir/$outputname.exp"
4281
4558
$run $rm $export_symbols
4282
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4559
$run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4561
*cygwin* | *mingw* )
4562
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4563
$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4284
$run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
4285
$run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
4567
$run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4568
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4286
4569
$run eval 'mv "$nlist"T "$nlist"'
4571
*cygwin* | *mingw* )
4572
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4573
$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4383
4691
# Now compile the dynamic symbol file.
4384
$show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4385
$run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4692
$show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4693
$run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4387
4695
# Clean up the generated files.
4388
4696
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4389
4697
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4391
4699
# Transform the symbol file into the correct name.
4392
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4393
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4701
*cygwin* | *mingw* )
4702
if test -f "$output_objdir/${outputname}.def" ; then
4703
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4704
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4706
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4707
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4711
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4712
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4396
4717
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4407
4728
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
4410
# AIX runtime linking requires linking programs with -Wl,-brtl and libs with -Wl,-G
4411
# Also add -bnolibpath to the beginning of the link line, to clear the hardcoded runpath.
4412
# Otherwise, things like the -L path to libgcc.a are accidentally hardcoded by ld.
4413
# This does not apply on AIX for ia64, which uses a SysV linker.
4416
*-*-aix4* | *-*-aix5*)
4417
compile_command=`$echo "X$compile_command $wl-brtl" | $Xsed -e "s/\$CC/\$CC $wl-bnolibpath/1"`
4418
finalize_command=`$echo "X$finalize_command $wl-brtl" | $Xsed -e "s/\$CC/\$CC $wl-bnolibpath/1"` ;;
4421
4731
if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4422
4732
# Replace the output file specification.
4423
4733
compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4630
4949
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4631
4950
#endif /* DIR_SEPARATOR_2 */
4952
#ifndef PATH_SEPARATOR_2
4953
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4954
#else /* PATH_SEPARATOR_2 */
4955
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4956
#endif /* PATH_SEPARATOR_2 */
4633
4958
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4634
4959
#define XFREE(stale) do { \
4635
4960
if (stale) { free ((void *) stale); stale = 0; } \
4963
/* -DDEBUG is fairly common in CFLAGS. */
4965
#if defined DEBUGWRAPPER
4966
# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
4968
# define DEBUG(format, ...)
4638
4971
const char *program_name = NULL;
4640
4973
void * xmalloc (size_t num);
4641
4974
char * xstrdup (const char *string);
4642
char * basename (const char *name);
4643
char * fnqualify(const char *path);
4975
const char * base_name (const char *name);
4976
char * find_executable(const char *wrapper);
4977
int check_executable(const char *path);
4644
4978
char * strendzap(char *str, const char *pat);
4645
4979
void lt_fatal (const char *message, ...);
4650
4984
char **newargz;
4653
program_name = (char *) xstrdup ((char *) basename (argv[0]));
4987
program_name = (char *) xstrdup (base_name (argv[0]));
4988
DEBUG("(main) argv[0] : %s\n",argv[0]);
4989
DEBUG("(main) program_name : %s\n",program_name);
4654
4990
newargz = XMALLOC(char *, argc+2);
4657
cat >> $cwrappersource <<EOF
4658
newargz[0] = "$SHELL";
4993
cat >> $cwrappersource <<EOF
4994
newargz[0] = (char *) xstrdup("$SHELL");
4661
cat >> $cwrappersource <<"EOF"
4662
newargz[1] = fnqualify(argv[0]);
4997
cat >> $cwrappersource <<"EOF"
4998
newargz[1] = find_executable(argv[0]);
4999
if (newargz[1] == NULL)
5000
lt_fatal("Couldn't find %s", argv[0]);
5001
DEBUG("(main) found exe at : %s\n",newargz[1]);
4663
5002
/* we know the script has the same name, without the .exe */
4664
5003
/* so make sure newargz[1] doesn't end in .exe */
4665
strendzap(newargz[1],".exe");
5004
strendzap(newargz[1],".exe");
4666
5005
for (i = 1; i < argc; i++)
4667
5006
newargz[i+1] = xstrdup(argv[i]);
4668
5007
newargz[argc+1] = NULL;
4671
cat >> $cwrappersource <<EOF
5009
for (i=0; i<argc+1; i++)
5011
DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
5019
cat >> $cwrappersource <<EOF
5020
execv("$SHELL",(char const **)newargz);
5024
cat >> $cwrappersource <<EOF
4672
5025
execv("$SHELL",newargz);
4675
cat >> $cwrappersource <<"EOF"
5030
cat >> $cwrappersource <<"EOF"
4689
5045
xstrdup (const char *string)
4691
5047
return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
4696
basename (const char *name)
5052
base_name (const char *name)
4698
5054
const char *base;
4700
5056
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4701
5057
/* Skip over the disk name in MSDOS pathnames. */
4702
if (isalpha (name[0]) && name[1] == ':')
5058
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4706
5062
for (base = name; *name; name++)
4707
5063
if (IS_DIR_SEPARATOR (*name))
4708
5064
base = name + 1;
4709
return (char *) base;
4713
fnqualify(const char *path)
5069
check_executable(const char * path)
5073
DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5074
if ((!path) || (!*path))
5077
if ((stat (path, &st) >= 0) &&
5079
/* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5080
#if defined (S_IXOTH)
5081
((st.st_mode & S_IXOTH) == S_IXOTH) ||
5083
#if defined (S_IXGRP)
5084
((st.st_mode & S_IXGRP) == S_IXGRP) ||
5086
((st.st_mode & S_IXUSR) == S_IXUSR))
5093
/* Searches for the full path of the wrapper. Returns
5094
newly allocated full path name if found, NULL otherwise */
5096
find_executable (const char* wrapper)
5101
/* static buffer for getcwd */
4717
5102
char tmp[LT_PATHMAX + 1];
4719
assert(path != NULL);
4721
/* Is it qualified already? */
4722
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4723
if (isalpha (path[0]) && path[1] == ':')
4724
return xstrdup (path);
4726
if (IS_DIR_SEPARATOR (path[0]))
4727
return xstrdup (path);
4729
/* prepend the current directory */
4730
/* doesn't handle '~' */
5106
DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5108
if ((wrapper == NULL) || (*wrapper == '\0'))
5111
/* Absolute path? */
5112
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5113
if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5115
concat_name = xstrdup (wrapper);
5116
if (check_executable(concat_name))
5123
if (IS_DIR_SEPARATOR (wrapper[0]))
5125
concat_name = xstrdup (wrapper);
5126
if (check_executable(concat_name))
5130
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5134
for (p = wrapper; *p; p++)
5142
/* no slashes; search PATH */
5143
const char* path = getenv ("PATH");
5146
for (p = path; *p; p = p_next)
5150
for (q = p; *q; q++)
5151
if (IS_PATH_SEPARATOR(*q))
5154
p_next = (*q == '\0' ? q : q + 1);
5157
/* empty path: current directory */
5158
if (getcwd (tmp, LT_PATHMAX) == NULL)
5159
lt_fatal ("getcwd failed");
5160
tmp_len = strlen(tmp);
5161
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5162
memcpy (concat_name, tmp, tmp_len);
5163
concat_name[tmp_len] = '/';
5164
strcpy (concat_name + tmp_len + 1, wrapper);
5168
concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5169
memcpy (concat_name, p, p_len);
5170
concat_name[p_len] = '/';
5171
strcpy (concat_name + p_len + 1, wrapper);
5173
if (check_executable(concat_name))
5178
/* not found in PATH; assume curdir */
5180
/* Relative path | not found in path: prepend cwd */
4731
5181
if (getcwd (tmp, LT_PATHMAX) == NULL)
4732
5182
lt_fatal ("getcwd failed");
4733
size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
4734
p = XMALLOC(char, size);
4735
sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
5183
tmp_len = strlen(tmp);
5184
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5185
memcpy (concat_name, tmp, tmp_len);
5186
concat_name[tmp_len] = '/';
5187
strcpy (concat_name + tmp_len + 1, wrapper);
5189
if (check_executable(concat_name))
4740
strendzap(char *str, const char *pat)
5196
strendzap(char *str, const char *pat)
4742
5198
size_t len, patlen;
4780
# we should really use a build-platform specific compiler
4781
# here, but OTOH, the wrappers (shell script and this C one)
4782
# are only useful if you want to execute the "real" binary.
4783
# Since the "real" binary is built for $host, then this
4784
# wrapper might as well be built for $host, too.
4785
$run $LTCC -s -o $cwrapper $cwrappersource
4789
trap "$rm $output; exit 1" 1 2 15
5236
# we should really use a build-platform specific compiler
5237
# here, but OTOH, the wrappers (shell script and this C one)
5238
# are only useful if you want to execute the "real" binary.
5239
# Since the "real" binary is built for $host, then this
5240
# wrapper might as well be built for $host, too.
5241
$run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5245
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
4791
5247
$echo > $output "\
4936
5392
# Backslashes separate directories on plain windows
4937
5393
*-*-mingw | *-*-os2*)
4938
5394
$echo >> $output "\
4939
exec \$progdir\\\\\$program \${1+\"\$@\"}
5395
exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
4944
# Need to set LD_LIBRARY_PATH, to the value already
4945
# computed within libtool.
4946
5400
$echo >> $output "\
4947
LD_LIBRARY_PATH=\"$rpath\" exec \$progdir/\$program \${1+\"\$@\"}
5401
exec \"\$progdir/\$program\" \${1+\"\$@\"}
4951
5405
$echo >> $output "\
4952
5406
\$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
4956
5410
# The program doesn't exist.
4957
\$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
5411
\$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4958
5412
\$echo \"This script is just a wrapper for \$program.\" 1>&2
4959
5413
$echo \"See the $PACKAGE documentation for more information.\" 1>&2
4964
5418
chmod +x $output
4987
5441
if test -n "$addlibs"; then
4988
5442
gentop="$output_objdir/${outputname}x"
4989
$show "${rm}r $gentop"
4990
$run ${rm}r "$gentop"
4991
$show "$mkdir $gentop"
4992
$run $mkdir "$gentop"
4994
if test "$status" -ne 0 && test ! -d "$gentop"; then
4997
5443
generated="$generated $gentop"
4999
# Add in members from convenience archives.
5000
for xlib in $addlibs; do
5001
# Extract the objects.
5003
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
5004
*) xabs=`pwd`"/$xlib" ;;
5006
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
5007
xdir="$gentop/$xlib"
5009
$show "${rm}r $xdir"
5011
$show "$mkdir $xdir"
5014
if test "$status" -ne 0 && test ! -d "$xdir"; then
5017
# We will extract separately just the conflicting names and we will no
5018
# longer touch any unique names. It is faster to leave these extract
5019
# automatically by $AR in one run.
5020
$show "(cd $xdir && $AR x $xabs)"
5021
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
5022
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
5025
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
5026
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
5027
$AR t "$xabs" | sort | uniq -cd | while read -r count name
5030
while test "$i" -le "$count"
5032
# Put our $i before any first dot (extension)
5033
# Never overwrite any file
5035
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
5037
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
5039
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
5040
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
5046
oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
5445
func_extract_archives $gentop $addlibs
5446
oldobjs="$oldobjs $func_extract_archives_result"
5050
compiler_flags="$compiler_flags $add_flags"
5052
5449
# Do each command in the archive commands.
5053
5450
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5054
eval cmds=\"$old_archive_from_new_cmds\"
5451
cmds=$old_archive_from_new_cmds
5453
# POSIX demands no paths to be encoded in archives. We have
5454
# to avoid creating archives with duplicate basenames if we
5455
# might have to extract them afterwards, e.g., when creating a
5456
# static archive out of a convenience library, or when linking
5457
# the entirety of a libtool archive into another (currently
5458
# not supported by libtool).
5459
if (for obj in $oldobjs
5461
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5462
done | sort | sort -uc >/dev/null 2>&1); then
5465
$echo "copying selected object files to avoid basename conflicts..."
5467
if test -z "$gentop"; then
5468
gentop="$output_objdir/${outputname}x"
5469
generated="$generated $gentop"
5471
$show "${rm}r $gentop"
5472
$run ${rm}r "$gentop"
5473
$show "$mkdir $gentop"
5474
$run $mkdir "$gentop"
5476
if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5481
save_oldobjs=$oldobjs
5484
for obj in $save_oldobjs
5486
objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5487
case " $oldobjs " in
5488
" ") oldobjs=$obj ;;
5491
# Make sure we don't pick an alternate name that also
5493
newobj=lt$counter-$objbase
5494
counter=`expr $counter + 1`
5495
case " $oldobjs " in
5496
*[\ /]"$newobj "*) ;;
5497
*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5500
$show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5501
$run ln "$obj" "$gentop/$newobj" ||
5502
$run cp "$obj" "$gentop/$newobj"
5503
oldobjs="$oldobjs $gentop/$newobj"
5505
*) oldobjs="$oldobjs $obj" ;;
5056
5510
eval cmds=\"$old_archive_cmds\"
5058
5512
if len=`expr "X$cmds" : ".*"` &&
5059
5513
test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5514
cmds=$old_archive_cmds
5062
5516
# the command line is too long to link in one step, link in parts
5063
5517
$echo "using piecewise archive linking..."
5068
5522
save_oldobjs=$oldobjs
5069
# GNU ar 2.10+ was changed to match POSIX; thus no paths are
5070
# encoded into archives. This makes 'ar r' malfunction in
5071
# this piecewise linking case whenever conflicting object
5072
# names appear in distinct ar calls; check, warn and compensate.
5073
if (for obj in $save_oldobjs
5075
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5076
done | sort | sort -uc >/dev/null 2>&1); then
5079
$echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
5080
$echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
5083
5524
# Is there a better way of finding the last object in the list?
5084
5525
for obj in $save_oldobjs
5086
5527
last_oldobj=$obj
5088
5529
for obj in $save_oldobjs
5090
5531
oldobjs="$objlist $obj"
5091
5532
objlist="$objlist $obj"
5092
5533
eval test_cmds=\"$old_archive_cmds\"
5093
if len=`expr "X$test_cmds" : ".*"` &&
5534
if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5094
5535
test "$len" -le "$max_cmd_len"; then
5503
5969
if test "$#" -gt 0; then
5504
5970
# Delete the old symlinks, and create new ones.
5971
# Try `ln -sf' first, because the `ln' binary might depend on
5972
# the symlink we replace! Solaris /bin/ln does not understand -f,
5973
# so we also need to try rm && ln -s.
5507
5976
if test "$linkname" != "$realname"; then
5508
$show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
5509
$run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
5977
$show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
5978
$run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
5514
5983
# Do each command in the postinstall commands.
5515
5984
lib="$destdir/$realname"
5516
eval cmds=\"$postinstall_cmds\"
5985
cmds=$postinstall_cmds
5517
5986
save_ifs="$IFS"; IFS='~'
5518
5987
for cmd in $cmds; do
5519
5988
IFS="$save_ifs"
5521
$run eval "$cmd" || exit $?
5991
$run eval "$cmd" || {
5994
# Restore the uninstalled library and exit
5995
if test "$mode" = relink; then
5996
$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
5523
6002
IFS="$save_ifs"
5612
6091
notinst_deplibs=
5613
6092
relink_command=
5615
# To insure that "foo" is sourced, and not "foo.exe",
5616
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5617
# which disallows the automatic-append-.exe behavior.
5619
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5620
*) wrapperdot=${wrapper} ;;
6094
# Note that it is not necessary on cygwin/mingw to append a dot to
6095
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6096
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6097
# `FILE.' does not work on cygwin managed mounts.
5622
6099
# If there is no directory component, then add one.
5624
*/* | *\\*) . ${wrapperdot} ;;
5625
*) . ./${wrapperdot} ;;
6101
*/* | *\\*) . ${wrapper} ;;
6102
*) . ./${wrapper} ;;
5628
6105
# Check the variables that should have been set.
5629
6106
if test -z "$notinst_deplibs"; then
5630
6107
$echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
5652
6129
relink_command=
5653
# To insure that "foo" is sourced, and not "foo.exe",
5654
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5655
# which disallows the automatic-append-.exe behavior.
5657
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5658
*) wrapperdot=${wrapper} ;;
6130
# Note that it is not necessary on cygwin/mingw to append a dot to
6131
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6132
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6133
# `FILE.' does not work on cygwin managed mounts.
5660
6135
# If there is no directory component, then add one.
5662
*/* | *\\*) . ${wrapperdot} ;;
5663
*) . ./${wrapperdot} ;;
6137
*/* | *\\*) . ${wrapper} ;;
6138
*) . ./${wrapper} ;;
5667
6142
if test "$fast_install" = no && test -n "$relink_command"; then
5668
6143
if test "$finalize" = yes && test -z "$run"; then
5670
test -n "$TMPDIR" && tmpdir="$TMPDIR"
5671
tmpdir="$tmpdir/libtool-$$"
5672
if $mkdir "$tmpdir" && chmod 700 "$tmpdir"; then :
5674
$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
6144
tmpdir=`func_mktempdir`
5677
6145
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
5678
6146
outputname="$tmpdir/$file"
5679
6147
# Replace the output file specification.