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
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
5
5
# Free Software Foundation, Inc.
6
6
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
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
135
141
# Shell function definitions:
136
142
# This seems to be the best place for them
144
# func_mktempdir [string]
145
# Make a temporary directory that won't clash with other running
146
# libtool processes, and avoids race conditions if possible. If
147
# given, STRING is the basename for that directory.
150
my_template="${TMPDIR-/tmp}/${1-$progname}"
152
if test "$run" = ":"; then
153
# Return a directory name, but don't create it in dry-run mode
154
my_tmpdir="${my_template}-$$"
157
# If mktemp works, use that first and foremost
158
my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
160
if test ! -d "$my_tmpdir"; then
161
# Failing that, at least try and use $RANDOM to avoid a race
162
my_tmpdir="${my_template}-${RANDOM-0}$$"
164
save_mktempdir_umask=`umask`
167
umask $save_mktempdir_umask
170
# If we're not in dry-run mode, bomb out on failure
171
test -d "$my_tmpdir" || {
172
$echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
177
$echo "X$my_tmpdir" | $Xsed
138
181
# func_win32_libid arg
139
182
# return the library type of file 'arg'
141
184
# Need a lot of goo to handle *both* DLLs and import libs
142
185
# Has to be a shell function in order to 'eat' the argument
143
186
# that is supplied when $file_magic_command is called.
144
func_win32_libid () {
145
189
win32_libid_type="unknown"
146
190
win32_fileres=`file -L $1 2>/dev/null`
147
191
case $win32_fileres in
152
196
if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
153
197
$EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
154
198
win32_nmres=`eval $NM -f posix -A $1 | \
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"
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";;
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"
241
387
# End of Shell function definitions
242
388
#####################################
245
391
eval std_shrext=\"$shrext_cmds\"
247
395
# Parse our command line options once, thoroughly.
248
396
while test "$#" -gt 0
1356
1568
# Rhapsody C and math libraries are in the System framework
1357
1569
deplibs="$deplibs -framework System"
1572
*-*-sco3.2v5* | *-*-sco5v6*)
1573
# Causes problems with __ctype
1574
test "X$arg" = "X-lc" && continue
1576
*-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1577
# Compiler inserts libc in the correct place for threads to work
1578
test "X$arg" = "X-lc" && continue
1360
1581
elif test "X$arg" = "X-lc_r"; then
1362
*-*-openbsd* | *-*-freebsd*)
1583
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1363
1584
# 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.
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*|@*)
1389
1628
# Unknown arguments in both finalize_command and compile_command need
1390
1629
# to be aesthetically quoted because they are evaled later.
1391
1630
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
2386
2652
if test "$hardcode_direct" = no; then
2387
2653
add="$dir/$linklib"
2389
*-*-sco3.2v5* ) add_dir="-L$dir" ;;
2655
*-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2656
*-*-sysv4*uw2*) add_dir="-L$dir" ;;
2657
*-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2658
*-*-unixware7*) add_dir="-L$dir" ;;
2391
2660
# if the lib is a module then we can not link against
2392
2661
# it, someone is ignoring the new warnings I added
2393
if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2662
if /usr/bin/file -L $add 2> /dev/null |
2663
$EGREP ": [^:]* bundle" >/dev/null ; then
2394
2664
$echo "** Warning, lib $linklib is a module, not a shared library"
2395
2665
if test -z "$old_library" ; then
2945
3213
# Check that each of the things are valid numbers.
2946
3214
case $current in
3215
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
3217
$echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
2950
3218
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2951
3219
exit $EXIT_FAILURE
2955
3223
case $revision in
3224
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
3226
$echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
2959
3227
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2960
3228
exit $EXIT_FAILURE
3233
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
3235
$echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
2968
3236
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
2969
3237
exit $EXIT_FAILURE
3678
3984
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3680
3986
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
3987
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`
3989
func_extract_archives $gentop $convenience
3990
libobjs="$libobjs $func_extract_archives_result"
3742
3994
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3743
3995
eval flag=\"$thread_safe_flag_spec\"
3744
3996
linker_flags="$linker_flags $flag"
3976
4247
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
3978
4249
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
4250
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`
4252
func_extract_archives $gentop $convenience
4253
reload_conv_objs="$reload_objs $func_extract_archives_result"
4355
# move library search paths that coincide with paths to not yet
4356
# installed libraries to the beginning of the library search list
4358
for path in $notinst_path; do
4359
case " $new_libs " in
4360
*" -L$path/$objdir "*) ;;
4362
case " $compile_deplibs " in
4363
*" -L$path/$objdir "*)
4364
new_libs="$new_libs -L$path/$objdir" ;;
4369
for deplib in $compile_deplibs; do
4372
case " $new_libs " in
4374
*) new_libs="$new_libs $deplib" ;;
4377
*) new_libs="$new_libs $deplib" ;;
4380
compile_deplibs="$new_libs"
4137
4383
compile_command="$compile_command $compile_deplibs"
4138
4384
finalize_command="$finalize_command $finalize_deplibs"
4296
4547
# Prepare the list of exported symbols
4297
4548
if test -z "$export_symbols"; then
4298
export_symbols="$output_objdir/$output.exp"
4549
export_symbols="$output_objdir/$outputname.exp"
4299
4550
$run $rm $export_symbols
4300
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4551
$run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4553
*cygwin* | *mingw* )
4554
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4555
$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'
4559
$run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4560
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4304
4561
$run eval 'mv "$nlist"T "$nlist"'
4563
*cygwin* | *mingw* )
4564
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4565
$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4401
4683
# 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 $?
4684
$show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4685
$run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4405
4687
# Clean up the generated files.
4406
4688
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4407
4689
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4409
4691
# 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}%"`
4693
*cygwin* | *mingw* )
4694
if test -f "$output_objdir/${outputname}.def" ; then
4695
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4696
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4698
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4699
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4703
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4704
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4414
4709
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4637
4941
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4638
4942
#endif /* DIR_SEPARATOR_2 */
4944
#ifndef PATH_SEPARATOR_2
4945
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4946
#else /* PATH_SEPARATOR_2 */
4947
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4948
#endif /* PATH_SEPARATOR_2 */
4640
4950
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4641
4951
#define XFREE(stale) do { \
4642
4952
if (stale) { free ((void *) stale); stale = 0; } \
4955
/* -DDEBUG is fairly common in CFLAGS. */
4957
#if defined DEBUGWRAPPER
4958
# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
4960
# define DEBUG(format, ...)
4645
4963
const char *program_name = NULL;
4647
4965
void * xmalloc (size_t num);
4648
4966
char * xstrdup (const char *string);
4649
char * basename (const char *name);
4650
char * fnqualify(const char *path);
4967
const char * base_name (const char *name);
4968
char * find_executable(const char *wrapper);
4969
int check_executable(const char *path);
4651
4970
char * strendzap(char *str, const char *pat);
4652
4971
void lt_fatal (const char *message, ...);
4657
4976
char **newargz;
4660
program_name = (char *) xstrdup ((char *) basename (argv[0]));
4979
program_name = (char *) xstrdup (base_name (argv[0]));
4980
DEBUG("(main) argv[0] : %s\n",argv[0]);
4981
DEBUG("(main) program_name : %s\n",program_name);
4661
4982
newargz = XMALLOC(char *, argc+2);
4664
cat >> $cwrappersource <<EOF
4665
newargz[0] = "$SHELL";
4985
cat >> $cwrappersource <<EOF
4986
newargz[0] = (char *) xstrdup("$SHELL");
4668
cat >> $cwrappersource <<"EOF"
4669
newargz[1] = fnqualify(argv[0]);
4989
cat >> $cwrappersource <<"EOF"
4990
newargz[1] = find_executable(argv[0]);
4991
if (newargz[1] == NULL)
4992
lt_fatal("Couldn't find %s", argv[0]);
4993
DEBUG("(main) found exe at : %s\n",newargz[1]);
4670
4994
/* we know the script has the same name, without the .exe */
4671
4995
/* so make sure newargz[1] doesn't end in .exe */
4672
4996
strendzap(newargz[1],".exe");
4673
4997
for (i = 1; i < argc; i++)
4674
4998
newargz[i+1] = xstrdup(argv[i]);
4675
4999
newargz[argc+1] = NULL;
4678
cat >> $cwrappersource <<EOF
5001
for (i=0; i<argc+1; i++)
5003
DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
5011
cat >> $cwrappersource <<EOF
5012
execv("$SHELL",(char const **)newargz);
5016
cat >> $cwrappersource <<EOF
4679
5017
execv("$SHELL",newargz);
4682
cat >> $cwrappersource <<"EOF"
5022
cat >> $cwrappersource <<"EOF"
4703
basename (const char *name)
5044
base_name (const char *name)
4705
5046
const char *base;
4707
5048
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4708
5049
/* Skip over the disk name in MSDOS pathnames. */
4709
if (isalpha (name[0]) && name[1] == ':')
5050
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4713
5054
for (base = name; *name; name++)
4714
5055
if (IS_DIR_SEPARATOR (*name))
4715
5056
base = name + 1;
4716
return (char *) base;
5061
check_executable(const char * path)
5065
DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5066
if ((!path) || (!*path))
5069
if ((stat (path, &st) >= 0) &&
5071
/* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5072
#if defined (S_IXOTH)
5073
((st.st_mode & S_IXOTH) == S_IXOTH) ||
5075
#if defined (S_IXGRP)
5076
((st.st_mode & S_IXGRP) == S_IXGRP) ||
5078
((st.st_mode & S_IXUSR) == S_IXUSR))
5085
/* Searches for the full path of the wrapper. Returns
5086
newly allocated full path name if found, NULL otherwise */
4720
fnqualify(const char *path)
5088
find_executable (const char* wrapper)
5093
/* static buffer for getcwd */
4724
5094
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 '~' */
5098
DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5100
if ((wrapper == NULL) || (*wrapper == '\0'))
5103
/* Absolute path? */
5104
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5105
if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5107
concat_name = xstrdup (wrapper);
5108
if (check_executable(concat_name))
5115
if (IS_DIR_SEPARATOR (wrapper[0]))
5117
concat_name = xstrdup (wrapper);
5118
if (check_executable(concat_name))
5122
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5126
for (p = wrapper; *p; p++)
5134
/* no slashes; search PATH */
5135
const char* path = getenv ("PATH");
5138
for (p = path; *p; p = p_next)
5142
for (q = p; *q; q++)
5143
if (IS_PATH_SEPARATOR(*q))
5146
p_next = (*q == '\0' ? q : q + 1);
5149
/* empty path: current directory */
5150
if (getcwd (tmp, LT_PATHMAX) == NULL)
5151
lt_fatal ("getcwd failed");
5152
tmp_len = strlen(tmp);
5153
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5154
memcpy (concat_name, tmp, tmp_len);
5155
concat_name[tmp_len] = '/';
5156
strcpy (concat_name + tmp_len + 1, wrapper);
5160
concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5161
memcpy (concat_name, p, p_len);
5162
concat_name[p_len] = '/';
5163
strcpy (concat_name + p_len + 1, wrapper);
5165
if (check_executable(concat_name))
5170
/* not found in PATH; assume curdir */
5172
/* Relative path | not found in path: prepend cwd */
4738
5173
if (getcwd (tmp, LT_PATHMAX) == NULL)
4739
5174
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);
5175
tmp_len = strlen(tmp);
5176
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5177
memcpy (concat_name, tmp, tmp_len);
5178
concat_name[tmp_len] = '/';
5179
strcpy (concat_name + tmp_len + 1, wrapper);
5181
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
5228
# we should really use a build-platform specific compiler
5229
# here, but OTOH, the wrappers (shell script and this C one)
5230
# are only useful if you want to execute the "real" binary.
5231
# Since the "real" binary is built for $host, then this
5232
# wrapper might as well be built for $host, too.
5233
$run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5237
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
4798
5239
$echo > $output "\
4992
5433
if test -n "$addlibs"; then
4993
5434
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
5435
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`
5437
func_extract_archives $gentop $addlibs
5438
oldobjs="$oldobjs $func_extract_archives_result"
5055
5441
# Do each command in the archive commands.
5056
5442
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5057
5443
cmds=$old_archive_from_new_cmds
5445
# POSIX demands no paths to be encoded in archives. We have
5446
# to avoid creating archives with duplicate basenames if we
5447
# might have to extract them afterwards, e.g., when creating a
5448
# static archive out of a convenience library, or when linking
5449
# the entirety of a libtool archive into another (currently
5450
# not supported by libtool).
5451
if (for obj in $oldobjs
5453
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5454
done | sort | sort -uc >/dev/null 2>&1); then
5457
$echo "copying selected object files to avoid basename conflicts..."
5459
if test -z "$gentop"; then
5460
gentop="$output_objdir/${outputname}x"
5461
generated="$generated $gentop"
5463
$show "${rm}r $gentop"
5464
$run ${rm}r "$gentop"
5465
$show "$mkdir $gentop"
5466
$run $mkdir "$gentop"
5468
if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5473
save_oldobjs=$oldobjs
5476
for obj in $save_oldobjs
5478
objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5479
case " $oldobjs " in
5480
" ") oldobjs=$obj ;;
5483
# Make sure we don't pick an alternate name that also
5485
newobj=lt$counter-$objbase
5486
counter=`expr $counter + 1`
5487
case " $oldobjs " in
5488
*[\ /]"$newobj "*) ;;
5489
*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5492
$show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5493
$run ln "$obj" "$gentop/$newobj" ||
5494
$run cp "$obj" "$gentop/$newobj"
5495
oldobjs="$oldobjs $gentop/$newobj"
5497
*) oldobjs="$oldobjs $obj" ;;
5059
5502
eval cmds=\"$old_archive_cmds\"
5061
5504
if len=`expr "X$cmds" : ".*"` &&
5638
6083
notinst_deplibs=
5639
6084
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} ;;
6086
# Note that it is not necessary on cygwin/mingw to append a dot to
6087
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6088
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6089
# `FILE.' does not work on cygwin managed mounts.
5648
6091
# If there is no directory component, then add one.
5650
*/* | *\\*) . ${wrapperdot} ;;
5651
*) . ./${wrapperdot} ;;
6093
*/* | *\\*) . ${wrapper} ;;
6094
*) . ./${wrapper} ;;
5654
6097
# Check the variables that should have been set.
5678
6121
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} ;;
6122
# Note that it is not necessary on cygwin/mingw to append a dot to
6123
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6124
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6125
# `FILE.' does not work on cygwin managed mounts.
5686
6127
# If there is no directory component, then add one.
5688
*/* | *\\*) . ${wrapperdot} ;;
5689
*) . ./${wrapperdot} ;;
6129
*/* | *\\*) . ${wrapper} ;;
6130
*) . ./${wrapper} ;;
5693
6134
if test "$fast_install" = no && test -n "$relink_command"; then
5694
6135
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
6136
tmpdir=`func_mktempdir`
5707
6137
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
5708
6138
outputname="$tmpdir/$file"
5709
6139
# Replace the output file specification.