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, 2005
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
5
5
# Free Software Foundation, Inc.
6
6
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
141
135
# Shell function definitions:
142
136
# 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
138
# func_win32_libid arg
182
139
# return the library type of file 'arg'
184
141
# Need a lot of goo to handle *both* DLLs and import libs
185
142
# Has to be a shell function in order to 'eat' the argument
186
143
# that is supplied when $file_magic_command is called.
144
func_win32_libid () {
189
145
win32_libid_type="unknown"
190
146
win32_fileres=`file -L $1 2>/dev/null`
191
147
case $win32_fileres in
196
152
if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
197
153
$EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
198
154
win32_nmres=`eval $NM -f posix -A $1 | \
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";;
155
sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
156
if test "X$win32_nmres" = "Ximport" ; then
157
win32_libid_type="x86 archive import"
159
win32_libid_type="x86 archive static"
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"
387
241
# End of Shell function definitions
388
242
#####################################
391
245
eval std_shrext=\"$shrext_cmds\"
395
247
# Parse our command line options once, thoroughly.
396
248
while test "$#" -gt 0
1568
1356
# Rhapsody C and math libraries are in the System framework
1569
1357
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
1581
1360
elif test "X$arg" = "X-lc_r"; then
1583
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1362
*-*-openbsd* | *-*-freebsd*)
1584
1363
# Do not include libc_r directly, use -pthread flag.
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*|@*)
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.
1628
1389
# Unknown arguments in both finalize_command and compile_command need
1629
1390
# to be aesthetically quoted because they are evaled later.
1630
1391
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
2655
2386
if test "$hardcode_direct" = no; then
2656
2387
add="$dir/$linklib"
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" ;;
2389
*-*-sco3.2v5* ) add_dir="-L$dir" ;;
2663
2391
# if the lib is a module then we can not link against
2664
2392
# 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
2393
if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2667
2394
$echo "** Warning, lib $linklib is a module, not a shared library"
2668
2395
if test -z "$old_library" ; then
3221
2945
# Check that each of the things are valid numbers.
3222
2946
case $current in
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]) ;;
3225
$echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
2949
$echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
3226
2950
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
3227
2951
exit $EXIT_FAILURE
3231
2955
case $revision in
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]) ;;
3234
$echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
2958
$echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
3235
2959
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
3236
2960
exit $EXIT_FAILURE
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]) ;;
3243
$echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
2967
$echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
3244
2968
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
3245
2969
exit $EXIT_FAILURE
3992
3678
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3994
3680
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
3995
3689
generated="$generated $gentop"
3997
func_extract_archives $gentop $convenience
3998
libobjs="$libobjs $func_extract_archives_result"
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`
4002
3742
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
4003
3743
eval flag=\"$thread_safe_flag_spec\"
4004
3744
linker_flags="$linker_flags $flag"
4255
3976
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4257
3978
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
4258
3987
generated="$generated $gentop"
4260
func_extract_archives $gentop $convenience
4261
reload_conv_objs="$reload_objs $func_extract_archives_result"
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`
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"
4391
4137
compile_command="$compile_command $compile_deplibs"
4392
4138
finalize_command="$finalize_command $finalize_deplibs"
4555
4296
# Prepare the list of exported symbols
4556
4297
if test -z "$export_symbols"; then
4557
export_symbols="$output_objdir/$outputname.exp"
4298
export_symbols="$output_objdir/$output.exp"
4558
4299
$run $rm $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"'
4300
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
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'
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'
4569
4304
$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"'
4691
4401
# Now compile the dynamic symbol file.
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 $?
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 $?
4695
4405
# Clean up the generated files.
4696
4406
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4697
4407
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4699
4409
# Transform the symbol file into the correct name.
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}%"`
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}%"`
4717
4414
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4949
4637
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4950
4638
#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 */
4958
4640
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4959
4641
#define XFREE(stale) do { \
4960
4642
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, ...)
4971
4645
const char *program_name = NULL;
4973
4647
void * xmalloc (size_t num);
4974
4648
char * xstrdup (const char *string);
4975
const char * base_name (const char *name);
4976
char * find_executable(const char *wrapper);
4977
int check_executable(const char *path);
4649
char * basename (const char *name);
4650
char * fnqualify(const char *path);
4978
4651
char * strendzap(char *str, const char *pat);
4979
4652
void lt_fatal (const char *message, ...);
4984
4657
char **newargz;
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);
4660
program_name = (char *) xstrdup ((char *) basename (argv[0]));
4990
4661
newargz = XMALLOC(char *, argc+2);
4993
cat >> $cwrappersource <<EOF
4994
newargz[0] = (char *) xstrdup("$SHELL");
4664
cat >> $cwrappersource <<EOF
4665
newargz[0] = "$SHELL";
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]);
4668
cat >> $cwrappersource <<"EOF"
4669
newargz[1] = fnqualify(argv[0]);
5002
4670
/* we know the script has the same name, without the .exe */
5003
4671
/* so make sure newargz[1] doesn't end in .exe */
5004
4672
strendzap(newargz[1],".exe");
5005
4673
for (i = 1; i < argc; i++)
5006
4674
newargz[i+1] = xstrdup(argv[i]);
5007
4675
newargz[argc+1] = NULL;
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
4678
cat >> $cwrappersource <<EOF
5025
4679
execv("$SHELL",newargz);
5030
cat >> $cwrappersource <<"EOF"
4682
cat >> $cwrappersource <<"EOF"
5052
base_name (const char *name)
4703
basename (const char *name)
5054
4705
const char *base;
5056
4707
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5057
4708
/* Skip over the disk name in MSDOS pathnames. */
5058
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4709
if (isalpha (name[0]) && name[1] == ':')
5062
4713
for (base = name; *name; name++)
5063
4714
if (IS_DIR_SEPARATOR (*name))
5064
4715
base = name + 1;
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 */
4716
return (char *) base;
5096
find_executable (const char* wrapper)
4720
fnqualify(const char *path)
5101
/* static buffer for getcwd */
5102
4724
char tmp[LT_PATHMAX + 1];
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 */
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 '~' */
5181
4738
if (getcwd (tmp, LT_PATHMAX) == NULL)
5182
4739
lt_fatal ("getcwd failed");
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
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);
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
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
5247
4798
$echo > $output "\
5441
4992
if test -n "$addlibs"; then
5442
4993
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
5443
5002
generated="$generated $gentop"
5445
func_extract_archives $gentop $addlibs
5446
oldobjs="$oldobjs $func_extract_archives_result"
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`
5449
5055
# Do each command in the archive commands.
5450
5056
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5451
5057
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" ;;
5510
5059
eval cmds=\"$old_archive_cmds\"
5512
5061
if len=`expr "X$cmds" : ".*"` &&
6091
5638
notinst_deplibs=
6092
5639
relink_command=
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.
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} ;;
6099
5648
# If there is no directory component, then add one.
6101
*/* | *\\*) . ${wrapper} ;;
6102
*) . ./${wrapper} ;;
5650
*/* | *\\*) . ${wrapperdot} ;;
5651
*) . ./${wrapperdot} ;;
6105
5654
# Check the variables that should have been set.
6129
5678
relink_command=
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.
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} ;;
6135
5686
# If there is no directory component, then add one.
6137
*/* | *\\*) . ${wrapper} ;;
6138
*) . ./${wrapper} ;;
5688
*/* | *\\*) . ${wrapperdot} ;;
5689
*) . ./${wrapperdot} ;;
6142
5693
if test "$fast_install" = no && test -n "$relink_command"; then
6143
5694
if test "$finalize" = yes && test -z "$run"; then
6144
tmpdir=`func_mktempdir`
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
6145
5707
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
6146
5708
outputname="$tmpdir/$file"
6147
5709
# Replace the output file specification.