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, 2004
5
# Free Software Foundation, Inc.
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
5
# 2007, 2008 Free Software Foundation, Inc.
6
6
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8
8
# This program is free software; you can redistribute it and/or modify
18
18
# You should have received a copy of the GNU General Public License
19
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
22
# As a special exception to the GNU General Public License, if you
23
23
# distribute this file as part of a program that contains a
47
TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42) Debian$Rev: 224 $"
46
VERSION="1.5.26 Debian 1.5.26-1ubuntu1"
47
TIMESTAMP=" (1.1220.2.493 2008/02/01 16:58:18)"
49
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
50
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
53
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
54
# is contrary to our usage. Disable this feature.
55
alias -g '${1+"$@"}'='"$@"'
58
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
60
BIN_SH=xpg4; export BIN_SH # for Tru64
61
DUALCASE=1; export DUALCASE # for MKS sh
50
63
# Check that we have a working $echo.
51
64
if test "X$1" = X--no-reexec; then
99
113
# These must not be set unconditionally because not all systems understand
100
114
# e.g. LANG=C (notably SCO).
101
115
# We save the old values to restore during execute mode.
102
if test "${LC_ALL+set}" = set; then
103
save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
105
if test "${LANG+set}" = set; then
106
save_LANG="$LANG"; LANG=C; export LANG
117
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
119
eval "if test \"\${$lt_var+set}\" = set; then
120
save_$lt_var=\$$lt_var
121
lt_env=\"$lt_var=\$$lt_var \$lt_env\"
127
if test -n "$lt_env"; then
109
131
# Make sure IFS has a sensible default
113
136
if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
114
137
$echo "$modename: not configured to build any kind of library" 1>&2
128
153
lo2o="s/\\.lo\$/.${objext}/"
129
154
o2lo="s/\\.${objext}\$/.lo/"
131
158
#####################################
132
159
# Shell function definitions:
133
160
# This seems to be the best place for them
162
# func_mktempdir [string]
163
# Make a temporary directory that won't clash with other running
164
# libtool processes, and avoids race conditions if possible. If
165
# given, STRING is the basename for that directory.
168
my_template="${TMPDIR-/tmp}/${1-$progname}"
170
if test "$run" = ":"; then
171
# Return a directory name, but don't create it in dry-run mode
172
my_tmpdir="${my_template}-$$"
175
# If mktemp works, use that first and foremost
176
my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
178
if test ! -d "$my_tmpdir"; then
179
# Failing that, at least try and use $RANDOM to avoid a race
180
my_tmpdir="${my_template}-${RANDOM-0}$$"
182
save_mktempdir_umask=`umask`
185
umask $save_mktempdir_umask
188
# If we're not in dry-run mode, bomb out on failure
189
test -d "$my_tmpdir" || {
190
$echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
195
$echo "X$my_tmpdir" | $Xsed
135
199
# func_win32_libid arg
136
200
# return the library type of file 'arg'
138
202
# Need a lot of goo to handle *both* DLLs and import libs
139
203
# Has to be a shell function in order to 'eat' the argument
140
204
# that is supplied when $file_magic_command is called.
141
func_win32_libid () {
142
207
win32_libid_type="unknown"
143
208
win32_fileres=`file -L $1 2>/dev/null`
144
209
case $win32_fileres in
311
# func_extract_an_archive dir oldlib
312
func_extract_an_archive ()
314
f_ex_an_ar_dir="$1"; shift
315
f_ex_an_ar_oldlib="$1"
317
$show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
318
$run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
319
if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
322
$echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
327
# func_extract_archives gentop oldlib ...
328
func_extract_archives ()
330
my_gentop="$1"; shift
338
$show "${rm}r $my_gentop"
339
$run ${rm}r "$my_gentop"
340
$show "$mkdir $my_gentop"
341
$run $mkdir "$my_gentop"
343
if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
347
for my_xlib in $my_oldlibs; do
348
# Extract the objects.
350
[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
351
*) my_xabs=`pwd`"/$my_xlib" ;;
353
my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
356
case " $extracted_archives " in
358
extracted_serial=`expr $extracted_serial + 1`
359
my_xlib_u=lt$extracted_serial-$my_xlib ;;
363
extracted_archives="$extracted_archives $my_xlib_u"
364
my_xdir="$my_gentop/$my_xlib_u"
366
$show "${rm}r $my_xdir"
367
$run ${rm}r "$my_xdir"
368
$show "$mkdir $my_xdir"
369
$run $mkdir "$my_xdir"
371
if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
376
$show "Extracting $my_xabs"
377
# Do not bother doing anything if just a dry run
378
if test -z "$run"; then
379
darwin_orig_dir=`pwd`
380
cd $my_xdir || exit $?
381
darwin_archive=$my_xabs
383
darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
384
darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
385
if test -n "$darwin_arches"; then
386
darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
388
$show "$darwin_base_archive has multiple architectures $darwin_arches"
389
for darwin_arch in $darwin_arches ; do
390
mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
391
lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
392
cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
393
func_extract_an_archive "`pwd`" "${darwin_base_archive}"
395
$rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
396
done # $darwin_arches
397
## Okay now we have a bunch of thin objects, gotta fatten them up :)
398
darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
401
for darwin_file in $darwin_filelist; do
402
darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
403
lipo -create -output "$darwin_file" $darwin_files
404
done # $darwin_filelist
406
cd "$darwin_orig_dir"
408
cd "$darwin_orig_dir"
409
func_extract_an_archive "$my_xdir" "$my_xabs"
414
func_extract_an_archive "$my_xdir" "$my_xabs"
417
my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
419
func_extract_archives_result="$my_oldobjs"
238
421
# End of Shell function definitions
239
422
#####################################
242
425
eval std_shrext=\"$shrext_cmds\"
244
429
# Parse our command line options once, thoroughly.
245
430
while test "$#" -gt 0
957
-all-static | -static)
958
if test "X$arg" = "X-all-static"; then
1179
-all-static | -static | -static-libtool-libs)
959
1182
if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
960
1183
$echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
962
1185
if test -n "$link_static_flag"; then
963
1186
dlopen_self=$dlopen_self_static
966
if test -z "$pic_flag" && test -n "$link_static_flag"; then
967
dlopen_self=$dlopen_self_static
1188
prefer_static_libs=yes
1191
if test -z "$pic_flag" && test -n "$link_static_flag"; then
1192
dlopen_self=$dlopen_self_static
1194
prefer_static_libs=built
1196
-static-libtool-libs)
1197
if test -z "$pic_flag" && test -n "$link_static_flag"; then
1198
dlopen_self=$dlopen_self_static
1200
prefer_static_libs=yes
970
1203
build_libtool_libs=no
971
1204
build_old_libs=yes
972
prefer_static_libs=yes
1353
1615
# Rhapsody C and math libraries are in the System framework
1354
1616
deplibs="$deplibs -framework System"
1619
*-*-sco3.2v5* | *-*-sco5v6*)
1620
# Causes problems with __ctype
1621
test "X$arg" = "X-lc" && continue
1623
*-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1624
# Compiler inserts libc in the correct place for threads to work
1625
test "X$arg" = "X-lc" && continue
1357
1628
elif test "X$arg" = "X-lc_r"; then
1359
*-*-openbsd* | *-*-freebsd*)
1630
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1360
1631
# Do not include libc_r directly, use -pthread flag.
1369
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1370
deplibs="$deplibs $arg"
1640
# Tru64 UNIX uses -model [arg] to determine the layout of C++
1641
# classes, name mangling, and exception handling.
1643
compile_command="$compile_command $arg"
1644
compiler_flags="$compiler_flags $arg"
1645
finalize_command="$finalize_command $arg"
1650
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
1651
compiler_flags="$compiler_flags $arg"
1652
compile_command="$compile_command $arg"
1653
finalize_command="$finalize_command $arg"
1658
single_module="${wl}-multi_module"
1379
# gcc -m* arguments should be passed to the linker via $compiler_flags
1380
# in order to pass architecture information to the linker
1381
# (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
1382
# but this is not reliable with gcc because gcc may use -mfoo to
1383
# select a different linker, different libraries, etc, while
1384
# -Wl,-mfoo simply passes -mfoo to the linker.
1667
# -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1668
# -r[0-9][0-9]* specifies the processor on the SGI compiler
1669
# -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1670
# +DA*, +DD* enable 64-bit mode on the HP compiler
1671
# -q* pass through compiler args for the IBM compiler
1672
# -m* pass through architecture-specific compiler args for GCC
1673
# -m*, -t[45]*, -txscale* pass through architecture-specific
1674
# compiler args for GCC
1675
# -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
1676
# -F/path gives path to uninstalled frameworks, gcc on darwin
1677
# @file GCC response files
1678
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
1679
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
1386
1681
# Unknown arguments in both finalize_command and compile_command need
1387
1682
# to be aesthetically quoted because they are evaled later.
1388
1683
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
2225
2552
if test "$linkmode,$pass" = "prog,link"; then
2226
2553
if test -n "$library_names" &&
2227
{ test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2554
{ { test "$prefer_static_libs" = no ||
2555
test "$prefer_static_libs,$installed" = "built,yes"; } ||
2556
test -z "$old_library"; }; then
2228
2557
# We need to hardcode the library path
2229
if test -n "$shlibpath_var"; then
2558
if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2230
2559
# Make sure the rpath contains only unique directories.
2231
2560
case "$temp_rpath " in
2233
2562
*" $absdir "*) ;;
2234
*) temp_rpath="$temp_rpath $dir" ;;
2563
*) temp_rpath="$temp_rpath $absdir" ;;
2382
2715
if test "$hardcode_direct" = no; then
2383
2716
add="$dir/$linklib"
2385
*-*-sco3.2v5* ) add_dir="-L$dir" ;;
2718
*-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2719
*-*-sysv4*uw2*) add_dir="-L$dir" ;;
2720
*-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2721
*-*-unixware7*) add_dir="-L$dir" ;;
2387
2723
# if the lib is a module then we can not link against
2388
2724
# it, someone is ignoring the new warnings I added
2389
if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2725
if /usr/bin/file -L $add 2> /dev/null |
2726
$EGREP ": [^:]* bundle" >/dev/null ; then
2390
2727
$echo "** Warning, lib $linklib is a module, not a shared library"
2391
2728
if test -z "$old_library" ; then
2631
2966
# we do not want to link against static libs,
2632
2967
# but need to link against shared
2633
2968
eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2969
eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2634
2970
if test -n "$deplibrary_names" ; then
2635
2971
for tmp in $deplibrary_names ; do
2638
if test -f "$path/$depdepl" ; then
2974
if test -f "$deplibdir/$depdepl" ; then
2975
depdepl="$deplibdir/$depdepl"
2976
elif test -f "$path/$depdepl" ; then
2639
2977
depdepl="$path/$depdepl"
2979
# Can't find it, oh well...
2641
2982
# do not add paths which are already there
2642
2983
case " $newlib_search_path " in
3145
3492
# Eliminate all temporary directories.
3146
for path in $notinst_path; do
3147
lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
3148
deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
3149
dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
3493
#for path in $notinst_path; do
3494
# lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
3495
# deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
3496
# dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
3152
3499
if test -n "$xrpath"; then
3153
3500
# If the user specified any rpath flags, then add them.
3284
3635
# Error occurred in the first compile. Let's try to salvage
3285
3636
# the situation: Compile a separate program for each library.
3286
3637
for i in $deplibs; do
3287
name="`expr $i : '-l\(.*\)'`"
3638
name=`expr $i : '-l\(.*\)'`
3288
3639
# If $name is empty we are operating on a -L argument.
3289
3640
if test "$name" != "" && test "$name" != "0"; then
3291
$LTCC -o conftest conftest.c $i
3293
if test "$?" -eq 0 ; then
3642
if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
3294
3643
ldd_output=`ldd conftest`
3295
3644
if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3296
3645
case " $predeps $postdeps " in
3679
4064
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3681
4066
gentop="$output_objdir/${outputname}x"
3682
$show "${rm}r $gentop"
3683
$run ${rm}r "$gentop"
3684
$show "$mkdir $gentop"
3685
$run $mkdir "$gentop"
3687
if test "$status" -ne 0 && test ! -d "$gentop"; then
3690
4067
generated="$generated $gentop"
3692
for xlib in $convenience; do
3693
# Extract the objects.
3695
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3696
*) xabs=`pwd`"/$xlib" ;;
3698
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3699
xdir="$gentop/$xlib"
3701
$show "${rm}r $xdir"
3703
$show "$mkdir $xdir"
3706
if test "$status" -ne 0 && test ! -d "$xdir"; then
3709
# We will extract separately just the conflicting names and we will no
3710
# longer touch any unique names. It is faster to leave these extract
3711
# automatically by $AR in one run.
3712
$show "(cd $xdir && $AR x $xabs)"
3713
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3714
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
3717
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
3718
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
3719
$AR t "$xabs" | sort | uniq -cd | while read -r count name
3722
while test "$i" -le "$count"
3724
# Put our $i before any first dot (extension)
3725
# Never overwrite any file
3727
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
3729
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
3731
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
3732
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
3738
libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4069
func_extract_archives $gentop $convenience
4070
libobjs="$libobjs $func_extract_archives_result"
3743
4074
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3744
4075
eval flag=\"$thread_safe_flag_spec\"
3745
4076
linker_flags="$linker_flags $flag"
3969
4320
reload_conv_objs=
3971
4322
# reload_cmds runs $LD directly, so let us get rid of
3972
# -Wl from whole_archive_flag_spec
4323
# -Wl from whole_archive_flag_spec and hope we can get by with
4324
# turning comma into space..
3975
4327
if test -n "$convenience"; then
3976
4328
if test -n "$whole_archive_flag_spec"; then
3977
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4329
eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
4330
reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
3979
4332
gentop="$output_objdir/${obj}x"
3980
$show "${rm}r $gentop"
3981
$run ${rm}r "$gentop"
3982
$show "$mkdir $gentop"
3983
$run $mkdir "$gentop"
3985
if test "$status" -ne 0 && test ! -d "$gentop"; then
3988
4333
generated="$generated $gentop"
3990
for xlib in $convenience; do
3991
# Extract the objects.
3993
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3994
*) xabs=`pwd`"/$xlib" ;;
3996
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3997
xdir="$gentop/$xlib"
3999
$show "${rm}r $xdir"
4001
$show "$mkdir $xdir"
4004
if test "$status" -ne 0 && test ! -d "$xdir"; then
4007
# We will extract separately just the conflicting names and we will no
4008
# longer touch any unique names. It is faster to leave these extract
4009
# automatically by $AR in one run.
4010
$show "(cd $xdir && $AR x $xabs)"
4011
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
4012
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
4015
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
4016
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
4017
$AR t "$xabs" | sort | uniq -cd | while read -r count name
4020
while test "$i" -le "$count"
4022
# Put our $i before any first dot (extension)
4023
# Never overwrite any file
4025
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
4027
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
4029
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
4030
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
4036
reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4335
func_extract_archives $gentop $convenience
4336
reload_conv_objs="$reload_objs $func_extract_archives_result"
4438
# move library search paths that coincide with paths to not yet
4439
# installed libraries to the beginning of the library search list
4441
for path in $notinst_path; do
4442
case " $new_libs " in
4443
*" -L$path/$objdir "*) ;;
4445
case " $compile_deplibs " in
4446
*" -L$path/$objdir "*)
4447
new_libs="$new_libs -L$path/$objdir" ;;
4452
for deplib in $compile_deplibs; do
4455
case " $new_libs " in
4457
*) new_libs="$new_libs $deplib" ;;
4460
*) new_libs="$new_libs $deplib" ;;
4463
compile_deplibs="$new_libs"
4138
4466
compile_command="$compile_command $compile_deplibs"
4139
4467
finalize_command="$finalize_command $finalize_deplibs"
4297
4630
# Prepare the list of exported symbols
4298
4631
if test -z "$export_symbols"; then
4299
export_symbols="$output_objdir/$output.exp"
4632
export_symbols="$output_objdir/$outputname.exp"
4300
4633
$run $rm $export_symbols
4301
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4634
$run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4636
*cygwin* | *mingw* )
4637
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4638
$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4303
$run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
4304
$run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
4642
$run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4643
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4305
4644
$run eval 'mv "$nlist"T "$nlist"'
4646
*cygwin* | *mingw* )
4647
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4648
$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4402
4766
# Now compile the dynamic symbol file.
4403
$show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4404
$run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4767
$show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4768
$run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4406
4770
# Clean up the generated files.
4407
4771
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4408
4772
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4410
4774
# Transform the symbol file into the correct name.
4411
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4412
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4776
*cygwin* | *mingw* )
4777
if test -f "$output_objdir/${outputname}.def" ; then
4778
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4779
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4781
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4782
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4786
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4787
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4415
4792
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4422
4799
# really was required.
4424
4801
# Nullify the symbol file.
4425
compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
4426
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
4802
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4803
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4429
4806
if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4430
4807
# Replace the output file specification.
4431
compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4808
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
4432
4809
link_command="$compile_command$compile_rpath"
4434
4811
# We have no uninstalled library dependencies, so finalize right now.
4435
4812
$show "$link_command"
4436
4813
$run eval "$link_command"
4439
4816
# Delete the generated files.
4440
4817
if test -n "$dlsyms"; then
4638
5024
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4639
5025
#endif /* DIR_SEPARATOR_2 */
5027
#ifndef PATH_SEPARATOR_2
5028
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5029
#else /* PATH_SEPARATOR_2 */
5030
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5031
#endif /* PATH_SEPARATOR_2 */
4641
5033
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4642
5034
#define XFREE(stale) do { \
4643
5035
if (stale) { free ((void *) stale); stale = 0; } \
5038
/* -DDEBUG is fairly common in CFLAGS. */
5040
#if defined DEBUGWRAPPER
5041
# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
5043
# define DEBUG(format, ...)
4646
5046
const char *program_name = NULL;
4648
5048
void * xmalloc (size_t num);
4649
5049
char * xstrdup (const char *string);
4650
char * basename (const char *name);
4651
char * fnqualify(const char *path);
5050
const char * base_name (const char *name);
5051
char * find_executable(const char *wrapper);
5052
int check_executable(const char *path);
4652
5053
char * strendzap(char *str, const char *pat);
4653
5054
void lt_fatal (const char *message, ...);
4658
5059
char **newargz;
4661
program_name = (char *) xstrdup ((char *) basename (argv[0]));
5062
program_name = (char *) xstrdup (base_name (argv[0]));
5063
DEBUG("(main) argv[0] : %s\n",argv[0]);
5064
DEBUG("(main) program_name : %s\n",program_name);
4662
5065
newargz = XMALLOC(char *, argc+2);
4665
cat >> $cwrappersource <<EOF
4666
newargz[0] = "$SHELL";
5068
cat >> $cwrappersource <<EOF
5069
newargz[0] = (char *) xstrdup("$SHELL");
4669
cat >> $cwrappersource <<"EOF"
4670
newargz[1] = fnqualify(argv[0]);
5072
cat >> $cwrappersource <<"EOF"
5073
newargz[1] = find_executable(argv[0]);
5074
if (newargz[1] == NULL)
5075
lt_fatal("Couldn't find %s", argv[0]);
5076
DEBUG("(main) found exe at : %s\n",newargz[1]);
4671
5077
/* we know the script has the same name, without the .exe */
4672
5078
/* so make sure newargz[1] doesn't end in .exe */
4673
5079
strendzap(newargz[1],".exe");
4674
5080
for (i = 1; i < argc; i++)
4675
5081
newargz[i+1] = xstrdup(argv[i]);
4676
5082
newargz[argc+1] = NULL;
4679
cat >> $cwrappersource <<EOF
5084
for (i=0; i<argc+1; i++)
5086
DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
5094
cat >> $cwrappersource <<EOF
5095
execv("$SHELL",(char const **)newargz);
5099
cat >> $cwrappersource <<EOF
4680
5100
execv("$SHELL",newargz);
4683
cat >> $cwrappersource <<"EOF"
5105
cat >> $cwrappersource <<"EOF"
4704
basename (const char *name)
5127
base_name (const char *name)
4706
5129
const char *base;
4708
5131
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4709
5132
/* Skip over the disk name in MSDOS pathnames. */
4710
if (isalpha (name[0]) && name[1] == ':')
5133
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4714
5137
for (base = name; *name; name++)
4715
5138
if (IS_DIR_SEPARATOR (*name))
4716
5139
base = name + 1;
4717
return (char *) base;
5144
check_executable(const char * path)
5148
DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5149
if ((!path) || (!*path))
5152
if ((stat (path, &st) >= 0) &&
5154
/* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5155
#if defined (S_IXOTH)
5156
((st.st_mode & S_IXOTH) == S_IXOTH) ||
5158
#if defined (S_IXGRP)
5159
((st.st_mode & S_IXGRP) == S_IXGRP) ||
5161
((st.st_mode & S_IXUSR) == S_IXUSR))
5168
/* Searches for the full path of the wrapper. Returns
5169
newly allocated full path name if found, NULL otherwise */
4721
fnqualify(const char *path)
5171
find_executable (const char* wrapper)
5176
/* static buffer for getcwd */
4725
5177
char tmp[LT_PATHMAX + 1];
4727
assert(path != NULL);
4729
/* Is it qualified already? */
4730
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4731
if (isalpha (path[0]) && path[1] == ':')
4732
return xstrdup (path);
4734
if (IS_DIR_SEPARATOR (path[0]))
4735
return xstrdup (path);
4737
/* prepend the current directory */
4738
/* doesn't handle '~' */
5181
DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5183
if ((wrapper == NULL) || (*wrapper == '\0'))
5186
/* Absolute path? */
5187
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5188
if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5190
concat_name = xstrdup (wrapper);
5191
if (check_executable(concat_name))
5198
if (IS_DIR_SEPARATOR (wrapper[0]))
5200
concat_name = xstrdup (wrapper);
5201
if (check_executable(concat_name))
5205
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5209
for (p = wrapper; *p; p++)
5217
/* no slashes; search PATH */
5218
const char* path = getenv ("PATH");
5221
for (p = path; *p; p = p_next)
5225
for (q = p; *q; q++)
5226
if (IS_PATH_SEPARATOR(*q))
5229
p_next = (*q == '\0' ? q : q + 1);
5232
/* empty path: current directory */
5233
if (getcwd (tmp, LT_PATHMAX) == NULL)
5234
lt_fatal ("getcwd failed");
5235
tmp_len = strlen(tmp);
5236
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5237
memcpy (concat_name, tmp, tmp_len);
5238
concat_name[tmp_len] = '/';
5239
strcpy (concat_name + tmp_len + 1, wrapper);
5243
concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5244
memcpy (concat_name, p, p_len);
5245
concat_name[p_len] = '/';
5246
strcpy (concat_name + p_len + 1, wrapper);
5248
if (check_executable(concat_name))
5253
/* not found in PATH; assume curdir */
5255
/* Relative path | not found in path: prepend cwd */
4739
5256
if (getcwd (tmp, LT_PATHMAX) == NULL)
4740
5257
lt_fatal ("getcwd failed");
4741
size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
4742
p = XMALLOC(char, size);
4743
sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
5258
tmp_len = strlen(tmp);
5259
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5260
memcpy (concat_name, tmp, tmp_len);
5261
concat_name[tmp_len] = '/';
5262
strcpy (concat_name + tmp_len + 1, wrapper);
5264
if (check_executable(concat_name))
4788
# we should really use a build-platform specific compiler
4789
# here, but OTOH, the wrappers (shell script and this C one)
4790
# are only useful if you want to execute the "real" binary.
4791
# Since the "real" binary is built for $host, then this
4792
# wrapper might as well be built for $host, too.
4793
$run $LTCC -s -o $cwrapper $cwrappersource
4797
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5311
# we should really use a build-platform specific compiler
5312
# here, but OTOH, the wrappers (shell script and this C one)
5313
# are only useful if you want to execute the "real" binary.
5314
# Since the "real" binary is built for $host, then this
5315
# wrapper might as well be built for $host, too.
5316
$run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5320
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
4799
5322
$echo > $output "\
4813
5336
Xsed='${SED} -e 1s/^X//'
4814
5337
sed_quote_subst='$sed_quote_subst'
5339
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
5340
if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5343
# Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5344
# is contrary to our usage. Disable this feature.
5345
alias -g '\${1+\"\$@\"}'='\"\$@\"'
5346
setopt NO_GLOB_SUBST
5348
case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5350
BIN_SH=xpg4; export BIN_SH # for Tru64
5351
DUALCASE=1; export DUALCASE # for MKS sh
4816
5353
# The HP-UX ksh and POSIX shell print the target directory to stdout
4817
5354
# if CDPATH is set.
4818
if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
5355
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
4820
5357
relink_command=\"$relink_command\"
4944
5481
# Backslashes separate directories on plain windows
4945
5482
*-*-mingw | *-*-os2*)
4946
5483
$echo >> $output "\
4947
exec \$progdir\\\\\$program \${1+\"\$@\"}
5484
exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
4952
5489
$echo >> $output "\
4953
exec \$progdir/\$program \${1+\"\$@\"}
5490
exec \"\$progdir/\$program\" \${1+\"\$@\"}
4957
5494
$echo >> $output "\
4958
\$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
5495
\$echo \"\$0: cannot exec \$program \$*\"
4959
5496
exit $EXIT_FAILURE
4962
5499
# The program doesn't exist.
4963
\$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
5500
\$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4964
5501
\$echo \"This script is just a wrapper for \$program.\" 1>&2
4965
5502
$echo \"See the $PACKAGE documentation for more information.\" 1>&2
4966
5503
exit $EXIT_FAILURE
4993
5530
if test -n "$addlibs"; then
4994
5531
gentop="$output_objdir/${outputname}x"
4995
$show "${rm}r $gentop"
4996
$run ${rm}r "$gentop"
4997
$show "$mkdir $gentop"
4998
$run $mkdir "$gentop"
5000
if test "$status" -ne 0 && test ! -d "$gentop"; then
5003
5532
generated="$generated $gentop"
5005
# Add in members from convenience archives.
5006
for xlib in $addlibs; do
5007
# Extract the objects.
5009
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
5010
*) xabs=`pwd`"/$xlib" ;;
5012
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
5013
xdir="$gentop/$xlib"
5015
$show "${rm}r $xdir"
5017
$show "$mkdir $xdir"
5020
if test "$status" -ne 0 && test ! -d "$xdir"; then
5023
# We will extract separately just the conflicting names and we will no
5024
# longer touch any unique names. It is faster to leave these extract
5025
# automatically by $AR in one run.
5026
$show "(cd $xdir && $AR x $xabs)"
5027
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
5028
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
5031
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
5032
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
5033
$AR t "$xabs" | sort | uniq -cd | while read -r count name
5036
while test "$i" -le "$count"
5038
# Put our $i before any first dot (extension)
5039
# Never overwrite any file
5041
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
5043
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
5045
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
5046
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
5052
oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
5534
func_extract_archives $gentop $addlibs
5535
oldobjs="$oldobjs $func_extract_archives_result"
5056
5538
# Do each command in the archive commands.
5057
5539
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5058
5540
cmds=$old_archive_from_new_cmds
5542
# POSIX demands no paths to be encoded in archives. We have
5543
# to avoid creating archives with duplicate basenames if we
5544
# might have to extract them afterwards, e.g., when creating a
5545
# static archive out of a convenience library, or when linking
5546
# the entirety of a libtool archive into another (currently
5547
# not supported by libtool).
5548
if (for obj in $oldobjs
5550
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5551
done | sort | sort -uc >/dev/null 2>&1); then
5554
$echo "copying selected object files to avoid basename conflicts..."
5556
if test -z "$gentop"; then
5557
gentop="$output_objdir/${outputname}x"
5558
generated="$generated $gentop"
5560
$show "${rm}r $gentop"
5561
$run ${rm}r "$gentop"
5562
$show "$mkdir $gentop"
5563
$run $mkdir "$gentop"
5565
if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5570
save_oldobjs=$oldobjs
5573
for obj in $save_oldobjs
5575
objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5576
case " $oldobjs " in
5577
" ") oldobjs=$obj ;;
5580
# Make sure we don't pick an alternate name that also
5582
newobj=lt$counter-$objbase
5583
counter=`expr $counter + 1`
5584
case " $oldobjs " in
5585
*[\ /]"$newobj "*) ;;
5586
*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5589
$show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5590
$run ln "$obj" "$gentop/$newobj" ||
5591
$run cp "$obj" "$gentop/$newobj"
5592
oldobjs="$oldobjs $gentop/$newobj"
5594
*) oldobjs="$oldobjs $obj" ;;
5060
5599
eval cmds=\"$old_archive_cmds\"
5062
5601
if len=`expr "X$cmds" : ".*"` &&
5639
6180
notinst_deplibs=
5640
6181
relink_command=
5642
# To insure that "foo" is sourced, and not "foo.exe",
5643
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5644
# which disallows the automatic-append-.exe behavior.
5646
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5647
*) wrapperdot=${wrapper} ;;
6183
# Note that it is not necessary on cygwin/mingw to append a dot to
6184
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6185
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6186
# `FILE.' does not work on cygwin managed mounts.
5649
6188
# If there is no directory component, then add one.
5651
*/* | *\\*) . ${wrapperdot} ;;
5652
*) . ./${wrapperdot} ;;
6190
*/* | *\\*) . ${wrapper} ;;
6191
*) . ./${wrapper} ;;
5655
6194
# Check the variables that should have been set.
5679
6218
relink_command=
5680
# To insure that "foo" is sourced, and not "foo.exe",
5681
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5682
# which disallows the automatic-append-.exe behavior.
5684
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5685
*) wrapperdot=${wrapper} ;;
6219
# Note that it is not necessary on cygwin/mingw to append a dot to
6220
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6221
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6222
# `FILE.' does not work on cygwin managed mounts.
5687
6224
# If there is no directory component, then add one.
5689
*/* | *\\*) . ${wrapperdot} ;;
5690
*) . ./${wrapperdot} ;;
6226
*/* | *\\*) . ${wrapper} ;;
6227
*) . ./${wrapper} ;;
5694
6231
if test "$fast_install" = no && test -n "$relink_command"; then
5695
6232
if test "$finalize" = yes && test -z "$run"; then
5697
test -n "$TMPDIR" && tmpdir="$TMPDIR"
5698
tmpdir="$tmpdir/libtool-$$"
5701
if $mkdir "$tmpdir"; then
5705
$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
6233
tmpdir=`func_mktempdir`
5708
6234
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
5709
6235
outputname="$tmpdir/$file"
5710
6236
# Replace the output file specification.
5711
relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
6237
relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
5713
6239
$show "$relink_command"
5714
6240
if $run eval "$relink_command"; then :