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 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
50
TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42)"
46
VERSION="1.5.24 Debian 1.5.24-1ubuntu1"
47
TIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)"
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
53
63
# Check that we have a working $echo.
54
64
if test "X$1" = X--no-reexec; then
102
113
# These must not be set unconditionally because not all systems understand
103
114
# e.g. LANG=C (notably SCO).
104
115
# We save the old values to restore during execute mode.
105
if test "${LC_ALL+set}" = set; then
106
save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
108
if test "${LANG+set}" = set; then
109
save_LANG="$LANG"; LANG=C; export LANG
116
for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
118
eval "if test \"\${$lt_var+set}\" = set; then
119
save_$lt_var=\$$lt_var
112
125
# Make sure IFS has a sensible default
116
130
if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
117
131
$echo "$modename: not configured to build any kind of library" 1>&2
131
147
lo2o="s/\\.lo\$/.${objext}/"
132
148
o2lo="s/\\.${objext}\$/.lo/"
134
152
#####################################
135
153
# Shell function definitions:
136
154
# This seems to be the best place for them
156
# func_mktempdir [string]
157
# Make a temporary directory that won't clash with other running
158
# libtool processes, and avoids race conditions if possible. If
159
# given, STRING is the basename for that directory.
162
my_template="${TMPDIR-/tmp}/${1-$progname}"
164
if test "$run" = ":"; then
165
# Return a directory name, but don't create it in dry-run mode
166
my_tmpdir="${my_template}-$$"
169
# If mktemp works, use that first and foremost
170
my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
172
if test ! -d "$my_tmpdir"; then
173
# Failing that, at least try and use $RANDOM to avoid a race
174
my_tmpdir="${my_template}-${RANDOM-0}$$"
176
save_mktempdir_umask=`umask`
179
umask $save_mktempdir_umask
182
# If we're not in dry-run mode, bomb out on failure
183
test -d "$my_tmpdir" || {
184
$echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
189
$echo "X$my_tmpdir" | $Xsed
138
193
# func_win32_libid arg
139
194
# return the library type of file 'arg'
141
196
# Need a lot of goo to handle *both* DLLs and import libs
142
197
# Has to be a shell function in order to 'eat' the argument
143
198
# that is supplied when $file_magic_command is called.
144
func_win32_libid () {
145
201
win32_libid_type="unknown"
146
202
win32_fileres=`file -L $1 2>/dev/null`
147
203
case $win32_fileres in
305
# func_extract_an_archive dir oldlib
306
func_extract_an_archive ()
308
f_ex_an_ar_dir="$1"; shift
309
f_ex_an_ar_oldlib="$1"
311
$show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
312
$run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
313
if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
316
$echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
321
# func_extract_archives gentop oldlib ...
322
func_extract_archives ()
324
my_gentop="$1"; shift
332
$show "${rm}r $my_gentop"
333
$run ${rm}r "$my_gentop"
334
$show "$mkdir $my_gentop"
335
$run $mkdir "$my_gentop"
337
if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
341
for my_xlib in $my_oldlibs; do
342
# Extract the objects.
344
[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
345
*) my_xabs=`pwd`"/$my_xlib" ;;
347
my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
350
case " $extracted_archives " in
352
extracted_serial=`expr $extracted_serial + 1`
353
my_xlib_u=lt$extracted_serial-$my_xlib ;;
357
extracted_archives="$extracted_archives $my_xlib_u"
358
my_xdir="$my_gentop/$my_xlib_u"
360
$show "${rm}r $my_xdir"
361
$run ${rm}r "$my_xdir"
362
$show "$mkdir $my_xdir"
363
$run $mkdir "$my_xdir"
365
if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
370
$show "Extracting $my_xabs"
371
# Do not bother doing anything if just a dry run
372
if test -z "$run"; then
373
darwin_orig_dir=`pwd`
374
cd $my_xdir || exit $?
375
darwin_archive=$my_xabs
377
darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
378
darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
379
if test -n "$darwin_arches"; then
380
darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
382
$show "$darwin_base_archive has multiple architectures $darwin_arches"
383
for darwin_arch in $darwin_arches ; do
384
mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
385
lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
386
cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
387
func_extract_an_archive "`pwd`" "${darwin_base_archive}"
389
$rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
390
done # $darwin_arches
391
## Okay now we have a bunch of thin objects, gotta fatten them up :)
392
darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
395
for darwin_file in $darwin_filelist; do
396
darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
397
lipo -create -output "$darwin_file" $darwin_files
398
done # $darwin_filelist
400
cd "$darwin_orig_dir"
402
cd "$darwin_orig_dir"
403
func_extract_an_archive "$my_xdir" "$my_xabs"
408
func_extract_an_archive "$my_xdir" "$my_xabs"
411
my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
413
func_extract_archives_result="$my_oldobjs"
241
415
# End of Shell function definitions
242
416
#####################################
245
419
eval std_shrext=\"$shrext_cmds\"
247
423
# Parse our command line options once, thoroughly.
248
424
while test "$#" -gt 0
960
-all-static | -static)
961
if test "X$arg" = "X-all-static"; then
1171
-all-static | -static | -static-libtool-libs)
962
1174
if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
963
1175
$echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
965
1177
if test -n "$link_static_flag"; then
966
1178
dlopen_self=$dlopen_self_static
969
if test -z "$pic_flag" && test -n "$link_static_flag"; then
970
dlopen_self=$dlopen_self_static
1180
prefer_static_libs=yes
1183
if test -z "$pic_flag" && test -n "$link_static_flag"; then
1184
dlopen_self=$dlopen_self_static
1186
prefer_static_libs=built
1188
-static-libtool-libs)
1189
if test -z "$pic_flag" && test -n "$link_static_flag"; then
1190
dlopen_self=$dlopen_self_static
1192
prefer_static_libs=yes
973
1195
build_libtool_libs=no
974
1196
build_old_libs=yes
975
prefer_static_libs=yes
1356
1607
# Rhapsody C and math libraries are in the System framework
1357
1608
deplibs="$deplibs -framework System"
1611
*-*-sco3.2v5* | *-*-sco5v6*)
1612
# Causes problems with __ctype
1613
test "X$arg" = "X-lc" && continue
1615
*-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1616
# Compiler inserts libc in the correct place for threads to work
1617
test "X$arg" = "X-lc" && continue
1360
1620
elif test "X$arg" = "X-lc_r"; then
1362
*-*-openbsd* | *-*-freebsd*)
1622
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1363
1623
# Do not include libc_r directly, use -pthread flag.
1382
# gcc -m* arguments should be passed to the linker via $compiler_flags
1383
# in order to pass architecture information to the linker
1384
# (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
1385
# but this is not reliable with gcc because gcc may use -mfoo to
1386
# select a different linker, different libraries, etc, while
1387
# -Wl,-mfoo simply passes -mfoo to the linker.
1654
# -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1655
# -r[0-9][0-9]* specifies the processor on the SGI compiler
1656
# -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1657
# +DA*, +DD* enable 64-bit mode on the HP compiler
1658
# -q* pass through compiler args for the IBM compiler
1659
# -m* pass through architecture-specific compiler args for GCC
1660
# -m*, -t[45]*, -txscale* pass through architecture-specific
1661
# compiler args for GCC
1662
# -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
1663
# -F/path gives path to uninstalled frameworks, gcc on darwin
1664
# @file GCC response files
1665
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
1666
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
1389
1668
# Unknown arguments in both finalize_command and compile_command need
1390
1669
# to be aesthetically quoted because they are evaled later.
1391
1670
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
2229
2534
if test "$linkmode,$pass" = "prog,link"; then
2230
2535
if test -n "$library_names" &&
2231
{ test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2536
{ { test "$prefer_static_libs" = no ||
2537
test "$prefer_static_libs,$installed" = "built,yes"; } ||
2538
test -z "$old_library"; }; then
2232
2539
# We need to hardcode the library path
2233
if test -n "$shlibpath_var"; then
2540
if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2234
2541
# Make sure the rpath contains only unique directories.
2235
2542
case "$temp_rpath " in
2237
2544
*" $absdir "*) ;;
2238
*) temp_rpath="$temp_rpath $dir" ;;
2545
*) temp_rpath="$temp_rpath $absdir" ;;
2386
2697
if test "$hardcode_direct" = no; then
2387
2698
add="$dir/$linklib"
2389
*-*-sco3.2v5* ) add_dir="-L$dir" ;;
2700
*-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2701
*-*-sysv4*uw2*) add_dir="-L$dir" ;;
2702
*-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2703
*-*-unixware7*) add_dir="-L$dir" ;;
2391
2705
# if the lib is a module then we can not link against
2392
2706
# it, someone is ignoring the new warnings I added
2393
if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2707
if /usr/bin/file -L $add 2> /dev/null |
2708
$EGREP ": [^:]* bundle" >/dev/null ; then
2394
2709
$echo "** Warning, lib $linklib is a module, not a shared library"
2395
2710
if test -z "$old_library" ; then
2945
3264
# Check that each of the things are valid numbers.
2946
3265
case $current in
3266
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]) ;;
2949
$echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
3268
$echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
2950
3269
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2951
3270
exit $EXIT_FAILURE
2955
3274
case $revision in
3275
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]) ;;
2958
$echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
3277
$echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
2959
3278
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2960
3279
exit $EXIT_FAILURE
3284
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]) ;;
2967
$echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
3286
$echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
2968
3287
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2969
3288
exit $EXIT_FAILURE
3144
3467
# Eliminate all temporary directories.
3145
for path in $notinst_path; do
3146
lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
3147
deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
3148
dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
3468
#for path in $notinst_path; do
3469
# lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
3470
# deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
3471
# dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
3151
3474
if test -n "$xrpath"; then
3152
3475
# If the user specified any rpath flags, then add them.
3283
3610
# Error occurred in the first compile. Let's try to salvage
3284
3611
# the situation: Compile a separate program for each library.
3285
3612
for i in $deplibs; do
3286
name="`expr $i : '-l\(.*\)'`"
3613
name=`expr $i : '-l\(.*\)'`
3287
3614
# If $name is empty we are operating on a -L argument.
3288
3615
if test "$name" != "" && test "$name" != "0"; then
3290
$LTCC -o conftest conftest.c $i
3292
if test "$?" -eq 0 ; then
3617
if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
3293
3618
ldd_output=`ldd conftest`
3294
3619
if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3295
3620
case " $predeps $postdeps " in
3678
4039
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3680
4041
gentop="$output_objdir/${outputname}x"
3681
$show "${rm}r $gentop"
3682
$run ${rm}r "$gentop"
3683
$show "$mkdir $gentop"
3684
$run $mkdir "$gentop"
3686
if test "$status" -ne 0 && test ! -d "$gentop"; then
3689
4042
generated="$generated $gentop"
3691
for xlib in $convenience; do
3692
# Extract the objects.
3694
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3695
*) xabs=`pwd`"/$xlib" ;;
3697
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3698
xdir="$gentop/$xlib"
3700
$show "${rm}r $xdir"
3702
$show "$mkdir $xdir"
3705
if test "$status" -ne 0 && test ! -d "$xdir"; then
3708
# We will extract separately just the conflicting names and we will no
3709
# longer touch any unique names. It is faster to leave these extract
3710
# automatically by $AR in one run.
3711
$show "(cd $xdir && $AR x $xabs)"
3712
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3713
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
3716
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
3717
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
3718
$AR t "$xabs" | sort | uniq -cd | while read -r count name
3721
while test "$i" -le "$count"
3723
# Put our $i before any first dot (extension)
3724
# Never overwrite any file
3726
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
3728
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
3730
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
3731
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
3737
libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4044
func_extract_archives $gentop $convenience
4045
libobjs="$libobjs $func_extract_archives_result"
3742
4049
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3743
4050
eval flag=\"$thread_safe_flag_spec\"
3744
4051
linker_flags="$linker_flags $flag"
3968
4294
reload_conv_objs=
3970
4296
# reload_cmds runs $LD directly, so let us get rid of
3971
# -Wl from whole_archive_flag_spec
4297
# -Wl from whole_archive_flag_spec and hope we can get by with
4298
# turning comma into space..
3974
4301
if test -n "$convenience"; then
3975
4302
if test -n "$whole_archive_flag_spec"; then
3976
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4303
eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
4304
reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
3978
4306
gentop="$output_objdir/${obj}x"
3979
$show "${rm}r $gentop"
3980
$run ${rm}r "$gentop"
3981
$show "$mkdir $gentop"
3982
$run $mkdir "$gentop"
3984
if test "$status" -ne 0 && test ! -d "$gentop"; then
3987
4307
generated="$generated $gentop"
3989
for xlib in $convenience; do
3990
# Extract the objects.
3992
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3993
*) xabs=`pwd`"/$xlib" ;;
3995
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3996
xdir="$gentop/$xlib"
3998
$show "${rm}r $xdir"
4000
$show "$mkdir $xdir"
4003
if test "$status" -ne 0 && test ! -d "$xdir"; then
4006
# We will extract separately just the conflicting names and we will no
4007
# longer touch any unique names. It is faster to leave these extract
4008
# automatically by $AR in one run.
4009
$show "(cd $xdir && $AR x $xabs)"
4010
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
4011
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
4014
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
4015
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
4016
$AR t "$xabs" | sort | uniq -cd | while read -r count name
4019
while test "$i" -le "$count"
4021
# Put our $i before any first dot (extension)
4022
# Never overwrite any file
4024
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
4026
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
4028
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
4029
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
4035
reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4309
func_extract_archives $gentop $convenience
4310
reload_conv_objs="$reload_objs $func_extract_archives_result"
4412
# move library search paths that coincide with paths to not yet
4413
# installed libraries to the beginning of the library search list
4415
for path in $notinst_path; do
4416
case " $new_libs " in
4417
*" -L$path/$objdir "*) ;;
4419
case " $compile_deplibs " in
4420
*" -L$path/$objdir "*)
4421
new_libs="$new_libs -L$path/$objdir" ;;
4426
for deplib in $compile_deplibs; do
4429
case " $new_libs " in
4431
*) new_libs="$new_libs $deplib" ;;
4434
*) new_libs="$new_libs $deplib" ;;
4437
compile_deplibs="$new_libs"
4137
4440
compile_command="$compile_command $compile_deplibs"
4138
4441
finalize_command="$finalize_command $finalize_deplibs"
4296
4604
# Prepare the list of exported symbols
4297
4605
if test -z "$export_symbols"; then
4298
export_symbols="$output_objdir/$output.exp"
4606
export_symbols="$output_objdir/$outputname.exp"
4299
4607
$run $rm $export_symbols
4300
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4608
$run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4610
*cygwin* | *mingw* )
4611
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4612
$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4302
$run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
4303
$run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
4616
$run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4617
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4304
4618
$run eval 'mv "$nlist"T "$nlist"'
4620
*cygwin* | *mingw* )
4621
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4622
$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4401
4740
# Now compile the dynamic symbol file.
4402
$show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4403
$run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4741
$show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4742
$run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4405
4744
# Clean up the generated files.
4406
4745
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4407
4746
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4409
4748
# Transform the symbol file into the correct name.
4410
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4411
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4750
*cygwin* | *mingw* )
4751
if test -f "$output_objdir/${outputname}.def" ; then
4752
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4753
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4755
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4756
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4760
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4761
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4414
4766
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4421
4773
# really was required.
4423
4775
# Nullify the symbol file.
4424
compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
4425
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
4776
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4777
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4428
4780
if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4429
4781
# Replace the output file specification.
4430
compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4782
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
4431
4783
link_command="$compile_command$compile_rpath"
4433
4785
# We have no uninstalled library dependencies, so finalize right now.
4434
4786
$show "$link_command"
4435
4787
$run eval "$link_command"
4438
4790
# Delete the generated files.
4439
4791
if test -n "$dlsyms"; then
4637
4998
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4638
4999
#endif /* DIR_SEPARATOR_2 */
5001
#ifndef PATH_SEPARATOR_2
5002
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5003
#else /* PATH_SEPARATOR_2 */
5004
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5005
#endif /* PATH_SEPARATOR_2 */
4640
5007
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4641
5008
#define XFREE(stale) do { \
4642
5009
if (stale) { free ((void *) stale); stale = 0; } \
5012
/* -DDEBUG is fairly common in CFLAGS. */
5014
#if defined DEBUGWRAPPER
5015
# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
5017
# define DEBUG(format, ...)
4645
5020
const char *program_name = NULL;
4647
5022
void * xmalloc (size_t num);
4648
5023
char * xstrdup (const char *string);
4649
char * basename (const char *name);
4650
char * fnqualify(const char *path);
5024
const char * base_name (const char *name);
5025
char * find_executable(const char *wrapper);
5026
int check_executable(const char *path);
4651
5027
char * strendzap(char *str, const char *pat);
4652
5028
void lt_fatal (const char *message, ...);
4657
5033
char **newargz;
4660
program_name = (char *) xstrdup ((char *) basename (argv[0]));
5036
program_name = (char *) xstrdup (base_name (argv[0]));
5037
DEBUG("(main) argv[0] : %s\n",argv[0]);
5038
DEBUG("(main) program_name : %s\n",program_name);
4661
5039
newargz = XMALLOC(char *, argc+2);
4664
cat >> $cwrappersource <<EOF
4665
newargz[0] = "$SHELL";
5042
cat >> $cwrappersource <<EOF
5043
newargz[0] = (char *) xstrdup("$SHELL");
4668
cat >> $cwrappersource <<"EOF"
4669
newargz[1] = fnqualify(argv[0]);
5046
cat >> $cwrappersource <<"EOF"
5047
newargz[1] = find_executable(argv[0]);
5048
if (newargz[1] == NULL)
5049
lt_fatal("Couldn't find %s", argv[0]);
5050
DEBUG("(main) found exe at : %s\n",newargz[1]);
4670
5051
/* we know the script has the same name, without the .exe */
4671
5052
/* so make sure newargz[1] doesn't end in .exe */
4672
5053
strendzap(newargz[1],".exe");
4673
5054
for (i = 1; i < argc; i++)
4674
5055
newargz[i+1] = xstrdup(argv[i]);
4675
5056
newargz[argc+1] = NULL;
4678
cat >> $cwrappersource <<EOF
5058
for (i=0; i<argc+1; i++)
5060
DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
5068
cat >> $cwrappersource <<EOF
5069
execv("$SHELL",(char const **)newargz);
5073
cat >> $cwrappersource <<EOF
4679
5074
execv("$SHELL",newargz);
4682
cat >> $cwrappersource <<"EOF"
5079
cat >> $cwrappersource <<"EOF"
4703
basename (const char *name)
5101
base_name (const char *name)
4705
5103
const char *base;
4707
5105
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4708
5106
/* Skip over the disk name in MSDOS pathnames. */
4709
if (isalpha (name[0]) && name[1] == ':')
5107
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4713
5111
for (base = name; *name; name++)
4714
5112
if (IS_DIR_SEPARATOR (*name))
4715
5113
base = name + 1;
4716
return (char *) base;
5118
check_executable(const char * path)
5122
DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5123
if ((!path) || (!*path))
5126
if ((stat (path, &st) >= 0) &&
5128
/* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5129
#if defined (S_IXOTH)
5130
((st.st_mode & S_IXOTH) == S_IXOTH) ||
5132
#if defined (S_IXGRP)
5133
((st.st_mode & S_IXGRP) == S_IXGRP) ||
5135
((st.st_mode & S_IXUSR) == S_IXUSR))
5142
/* Searches for the full path of the wrapper. Returns
5143
newly allocated full path name if found, NULL otherwise */
4720
fnqualify(const char *path)
5145
find_executable (const char* wrapper)
5150
/* static buffer for getcwd */
4724
5151
char tmp[LT_PATHMAX + 1];
4726
assert(path != NULL);
4728
/* Is it qualified already? */
4729
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4730
if (isalpha (path[0]) && path[1] == ':')
4731
return xstrdup (path);
4733
if (IS_DIR_SEPARATOR (path[0]))
4734
return xstrdup (path);
4736
/* prepend the current directory */
4737
/* doesn't handle '~' */
5155
DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5157
if ((wrapper == NULL) || (*wrapper == '\0'))
5160
/* Absolute path? */
5161
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5162
if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5164
concat_name = xstrdup (wrapper);
5165
if (check_executable(concat_name))
5172
if (IS_DIR_SEPARATOR (wrapper[0]))
5174
concat_name = xstrdup (wrapper);
5175
if (check_executable(concat_name))
5179
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5183
for (p = wrapper; *p; p++)
5191
/* no slashes; search PATH */
5192
const char* path = getenv ("PATH");
5195
for (p = path; *p; p = p_next)
5199
for (q = p; *q; q++)
5200
if (IS_PATH_SEPARATOR(*q))
5203
p_next = (*q == '\0' ? q : q + 1);
5206
/* empty path: current directory */
5207
if (getcwd (tmp, LT_PATHMAX) == NULL)
5208
lt_fatal ("getcwd failed");
5209
tmp_len = strlen(tmp);
5210
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5211
memcpy (concat_name, tmp, tmp_len);
5212
concat_name[tmp_len] = '/';
5213
strcpy (concat_name + tmp_len + 1, wrapper);
5217
concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5218
memcpy (concat_name, p, p_len);
5219
concat_name[p_len] = '/';
5220
strcpy (concat_name + p_len + 1, wrapper);
5222
if (check_executable(concat_name))
5227
/* not found in PATH; assume curdir */
5229
/* Relative path | not found in path: prepend cwd */
4738
5230
if (getcwd (tmp, LT_PATHMAX) == NULL)
4739
5231
lt_fatal ("getcwd failed");
4740
size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
4741
p = XMALLOC(char, size);
4742
sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
5232
tmp_len = strlen(tmp);
5233
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5234
memcpy (concat_name, tmp, tmp_len);
5235
concat_name[tmp_len] = '/';
5236
strcpy (concat_name + tmp_len + 1, wrapper);
5238
if (check_executable(concat_name))
4787
# we should really use a build-platform specific compiler
4788
# here, but OTOH, the wrappers (shell script and this C one)
4789
# are only useful if you want to execute the "real" binary.
4790
# Since the "real" binary is built for $host, then this
4791
# wrapper might as well be built for $host, too.
4792
$run $LTCC -s -o $cwrapper $cwrappersource
4796
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5285
# we should really use a build-platform specific compiler
5286
# here, but OTOH, the wrappers (shell script and this C one)
5287
# are only useful if you want to execute the "real" binary.
5288
# Since the "real" binary is built for $host, then this
5289
# wrapper might as well be built for $host, too.
5290
$run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5294
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
4798
5296
$echo > $output "\
4812
5310
Xsed='${SED} -e 1s/^X//'
4813
5311
sed_quote_subst='$sed_quote_subst'
5313
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
5314
if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5317
# Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5318
# is contrary to our usage. Disable this feature.
5319
alias -g '\${1+\"\$@\"}'='\"\$@\"'
5320
setopt NO_GLOB_SUBST
5322
case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5324
BIN_SH=xpg4; export BIN_SH # for Tru64
5325
DUALCASE=1; export DUALCASE # for MKS sh
4815
5327
# The HP-UX ksh and POSIX shell print the target directory to stdout
4816
5328
# if CDPATH is set.
4817
if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
5329
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
4819
5331
relink_command=\"$relink_command\"
4943
5455
# Backslashes separate directories on plain windows
4944
5456
*-*-mingw | *-*-os2*)
4945
5457
$echo >> $output "\
4946
exec \$progdir\\\\\$program \${1+\"\$@\"}
5458
exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
4951
5463
$echo >> $output "\
4952
exec \$progdir/\$program \${1+\"\$@\"}
5464
exec \"\$progdir/\$program\" \${1+\"\$@\"}
4956
5468
$echo >> $output "\
4957
\$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
5469
\$echo \"\$0: cannot exec \$program \$*\"
4958
5470
exit $EXIT_FAILURE
4961
5473
# The program doesn't exist.
4962
\$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
5474
\$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4963
5475
\$echo \"This script is just a wrapper for \$program.\" 1>&2
4964
5476
$echo \"See the $PACKAGE documentation for more information.\" 1>&2
4965
5477
exit $EXIT_FAILURE
4992
5504
if test -n "$addlibs"; then
4993
5505
gentop="$output_objdir/${outputname}x"
4994
$show "${rm}r $gentop"
4995
$run ${rm}r "$gentop"
4996
$show "$mkdir $gentop"
4997
$run $mkdir "$gentop"
4999
if test "$status" -ne 0 && test ! -d "$gentop"; then
5002
5506
generated="$generated $gentop"
5004
# Add in members from convenience archives.
5005
for xlib in $addlibs; do
5006
# Extract the objects.
5008
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
5009
*) xabs=`pwd`"/$xlib" ;;
5011
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
5012
xdir="$gentop/$xlib"
5014
$show "${rm}r $xdir"
5016
$show "$mkdir $xdir"
5019
if test "$status" -ne 0 && test ! -d "$xdir"; then
5022
# We will extract separately just the conflicting names and we will no
5023
# longer touch any unique names. It is faster to leave these extract
5024
# automatically by $AR in one run.
5025
$show "(cd $xdir && $AR x $xabs)"
5026
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
5027
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
5030
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
5031
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
5032
$AR t "$xabs" | sort | uniq -cd | while read -r count name
5035
while test "$i" -le "$count"
5037
# Put our $i before any first dot (extension)
5038
# Never overwrite any file
5040
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
5042
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
5044
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
5045
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
5051
oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
5508
func_extract_archives $gentop $addlibs
5509
oldobjs="$oldobjs $func_extract_archives_result"
5055
5512
# Do each command in the archive commands.
5056
5513
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5057
5514
cmds=$old_archive_from_new_cmds
5516
# POSIX demands no paths to be encoded in archives. We have
5517
# to avoid creating archives with duplicate basenames if we
5518
# might have to extract them afterwards, e.g., when creating a
5519
# static archive out of a convenience library, or when linking
5520
# the entirety of a libtool archive into another (currently
5521
# not supported by libtool).
5522
if (for obj in $oldobjs
5524
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5525
done | sort | sort -uc >/dev/null 2>&1); then
5528
$echo "copying selected object files to avoid basename conflicts..."
5530
if test -z "$gentop"; then
5531
gentop="$output_objdir/${outputname}x"
5532
generated="$generated $gentop"
5534
$show "${rm}r $gentop"
5535
$run ${rm}r "$gentop"
5536
$show "$mkdir $gentop"
5537
$run $mkdir "$gentop"
5539
if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5544
save_oldobjs=$oldobjs
5547
for obj in $save_oldobjs
5549
objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5550
case " $oldobjs " in
5551
" ") oldobjs=$obj ;;
5554
# Make sure we don't pick an alternate name that also
5556
newobj=lt$counter-$objbase
5557
counter=`expr $counter + 1`
5558
case " $oldobjs " in
5559
*[\ /]"$newobj "*) ;;
5560
*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5563
$show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5564
$run ln "$obj" "$gentop/$newobj" ||
5565
$run cp "$obj" "$gentop/$newobj"
5566
oldobjs="$oldobjs $gentop/$newobj"
5568
*) oldobjs="$oldobjs $obj" ;;
5059
5573
eval cmds=\"$old_archive_cmds\"
5061
5575
if len=`expr "X$cmds" : ".*"` &&
5638
6154
notinst_deplibs=
5639
6155
relink_command=
5641
# To insure that "foo" is sourced, and not "foo.exe",
5642
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5643
# which disallows the automatic-append-.exe behavior.
5645
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5646
*) wrapperdot=${wrapper} ;;
6157
# Note that it is not necessary on cygwin/mingw to append a dot to
6158
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6159
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6160
# `FILE.' does not work on cygwin managed mounts.
5648
6162
# If there is no directory component, then add one.
5650
*/* | *\\*) . ${wrapperdot} ;;
5651
*) . ./${wrapperdot} ;;
6164
*/* | *\\*) . ${wrapper} ;;
6165
*) . ./${wrapper} ;;
5654
6168
# Check the variables that should have been set.
5678
6192
relink_command=
5679
# To insure that "foo" is sourced, and not "foo.exe",
5680
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5681
# which disallows the automatic-append-.exe behavior.
5683
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5684
*) wrapperdot=${wrapper} ;;
6193
# Note that it is not necessary on cygwin/mingw to append a dot to
6194
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6195
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6196
# `FILE.' does not work on cygwin managed mounts.
5686
6198
# If there is no directory component, then add one.
5688
*/* | *\\*) . ${wrapperdot} ;;
5689
*) . ./${wrapperdot} ;;
6200
*/* | *\\*) . ${wrapper} ;;
6201
*) . ./${wrapper} ;;
5693
6205
if test "$fast_install" = no && test -n "$relink_command"; then
5694
6206
if test "$finalize" = yes && test -z "$run"; then
5696
test -n "$TMPDIR" && tmpdir="$TMPDIR"
5697
tmpdir="$tmpdir/libtool-$$"
5700
if $mkdir "$tmpdir"; then
5704
$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
6207
tmpdir=`func_mktempdir`
5707
6208
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
5708
6209
outputname="$tmpdir/$file"
5709
6210
# Replace the output file specification.
5710
relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
6211
relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
5712
6213
$show "$relink_command"
5713
6214
if $run eval "$relink_command"; then :