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
249
# func_extract_an_archive dir oldlib
250
func_extract_an_archive ()
252
f_ex_an_ar_dir="$1"; shift
253
f_ex_an_ar_oldlib="$1"
255
$show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
256
$run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
257
if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
260
$echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
265
# func_extract_archives gentop oldlib ...
266
func_extract_archives ()
268
my_gentop="$1"; shift
276
$show "${rm}r $my_gentop"
277
$run ${rm}r "$my_gentop"
278
$show "$mkdir $my_gentop"
279
$run $mkdir "$my_gentop"
281
if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
285
for my_xlib in $my_oldlibs; do
286
# Extract the objects.
288
[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
289
*) my_xabs=`pwd`"/$my_xlib" ;;
291
my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
292
my_xdir="$my_gentop/$my_xlib"
294
$show "${rm}r $my_xdir"
295
$run ${rm}r "$my_xdir"
296
$show "$mkdir $my_xdir"
297
$run $mkdir "$my_xdir"
299
if test "$status" -ne 0 && test ! -d "$my_xdir"; then
304
$show "Extracting $my_xabs"
305
# Do not bother doing anything if just a dry run
306
if test -z "$run"; then
307
darwin_orig_dir=`pwd`
308
cd $my_xdir || exit $?
309
darwin_archive=$my_xabs
311
darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
312
darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
313
if test -n "$darwin_arches"; then
314
darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
316
$show "$darwin_base_archive has multiple architectures $darwin_arches"
317
for darwin_arch in $darwin_arches ; do
318
mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
319
lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
320
cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
321
func_extract_an_archive "`pwd`" "${darwin_base_archive}"
323
$rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
324
done # $darwin_arches
325
## Okay now we have a bunch of thin objects, gotta fatten them up :)
326
darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
329
for darwin_file in $darwin_filelist; do
330
darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
331
lipo -create -output "$darwin_file" $darwin_files
332
done # $darwin_filelist
334
cd "$darwin_orig_dir"
336
cd "$darwin_orig_dir"
337
func_extract_an_archive "$my_xdir" "$my_xabs"
342
func_extract_an_archive "$my_xdir" "$my_xabs"
345
my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
347
func_extract_archives_result="$my_oldobjs"
238
349
# End of Shell function definitions
239
350
#####################################
1379
# gcc -m* arguments should be passed to the linker via $compiler_flags
1380
# in order to pass architecture information to the linker
1381
# (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
1382
# but this is not reliable with gcc because gcc may use -mfoo to
1383
# select a different linker, different libraries, etc, while
1384
# -Wl,-mfoo simply passes -mfoo to the linker.
1533
# -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1534
# -r[0-9][0-9]* specifies the processor on the SGI compiler
1535
# -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1536
# +DA*, +DD* enable 64-bit mode on the HP compiler
1537
# -q* pass through compiler args for the IBM compiler
1538
# -m* pass through architecture-specific compiler args for GCC
1539
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*)
1386
1541
# Unknown arguments in both finalize_command and compile_command need
1387
1542
# to be aesthetically quoted because they are evaled later.
1388
1543
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
3679
3852
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3681
3854
gentop="$output_objdir/${outputname}x"
3682
$show "${rm}r $gentop"
3683
$run ${rm}r "$gentop"
3684
$show "$mkdir $gentop"
3685
$run $mkdir "$gentop"
3687
if test "$status" -ne 0 && test ! -d "$gentop"; then
3690
3855
generated="$generated $gentop"
3692
for xlib in $convenience; do
3693
# Extract the objects.
3695
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3696
*) xabs=`pwd`"/$xlib" ;;
3698
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3699
xdir="$gentop/$xlib"
3701
$show "${rm}r $xdir"
3703
$show "$mkdir $xdir"
3706
if test "$status" -ne 0 && test ! -d "$xdir"; then
3709
# We will extract separately just the conflicting names and we will no
3710
# longer touch any unique names. It is faster to leave these extract
3711
# automatically by $AR in one run.
3712
$show "(cd $xdir && $AR x $xabs)"
3713
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3714
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
3717
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
3718
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
3719
$AR t "$xabs" | sort | uniq -cd | while read -r count name
3722
while test "$i" -le "$count"
3724
# Put our $i before any first dot (extension)
3725
# Never overwrite any file
3727
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
3729
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
3731
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
3732
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
3738
libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
3857
func_extract_archives $gentop $convenience
3858
libobjs="$libobjs $func_extract_archives_result"
3743
3862
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3744
3863
eval flag=\"$thread_safe_flag_spec\"
3745
3864
linker_flags="$linker_flags $flag"
3977
4115
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
3979
4117
gentop="$output_objdir/${obj}x"
3980
$show "${rm}r $gentop"
3981
$run ${rm}r "$gentop"
3982
$show "$mkdir $gentop"
3983
$run $mkdir "$gentop"
3985
if test "$status" -ne 0 && test ! -d "$gentop"; then
3988
4118
generated="$generated $gentop"
3990
for xlib in $convenience; do
3991
# Extract the objects.
3993
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3994
*) xabs=`pwd`"/$xlib" ;;
3996
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3997
xdir="$gentop/$xlib"
3999
$show "${rm}r $xdir"
4001
$show "$mkdir $xdir"
4004
if test "$status" -ne 0 && test ! -d "$xdir"; then
4007
# We will extract separately just the conflicting names and we will no
4008
# longer touch any unique names. It is faster to leave these extract
4009
# automatically by $AR in one run.
4010
$show "(cd $xdir && $AR x $xabs)"
4011
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
4012
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
4015
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
4016
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
4017
$AR t "$xabs" | sort | uniq -cd | while read -r count name
4020
while test "$i" -le "$count"
4022
# Put our $i before any first dot (extension)
4023
# Never overwrite any file
4025
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
4027
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
4029
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
4030
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
4036
reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4120
func_extract_archives $gentop $convenience
4121
reload_conv_objs="$reload_objs $func_extract_archives_result"
4297
4381
# Prepare the list of exported symbols
4298
4382
if test -z "$export_symbols"; then
4299
export_symbols="$output_objdir/$output.exp"
4383
export_symbols="$output_objdir/$outputname.exp"
4300
4384
$run $rm $export_symbols
4301
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4385
$run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4387
*cygwin* | *mingw* )
4388
$run eval "${SED} -e '1iEXPORTS'"' < "$export_symbols" > "$output_objdir/$outputname.def"'
4303
$run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
4304
$run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
4392
$run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4394
*cygwin* | *mingw* )
4395
$run eval "${SED} -e '1iEXPORTS'"' < "$output_objdir/$outputname.exp" > "$output_objdir/$outputname.def"'
4398
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4305
4399
$run eval 'mv "$nlist"T "$nlist"'
4404
4517
$run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4406
4519
# Clean up the generated files.
4407
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4408
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4520
#$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4521
#$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4410
4523
# Transform the symbol file into the correct name.
4411
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4412
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4525
*cygwin* | *mingw* )
4526
if test -f "$output_objdir/${outputname}.def" ; then
4527
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4528
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4530
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4531
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4535
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4536
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4415
4541
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4638
4774
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4639
4775
#endif /* DIR_SEPARATOR_2 */
4777
#ifndef PATH_SEPARATOR_2
4778
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4779
#else /* PATH_SEPARATOR_2 */
4780
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4781
#endif /* PATH_SEPARATOR_2 */
4641
4783
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4642
4784
#define XFREE(stale) do { \
4643
4785
if (stale) { free ((void *) stale); stale = 0; } \
4788
/* -DDEBUG is fairly common in CFLAGS. */
4790
#if defined DEBUGWRAPPER
4791
# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
4793
# define DEBUG(format, ...)
4646
4796
const char *program_name = NULL;
4648
4798
void * xmalloc (size_t num);
4649
4799
char * xstrdup (const char *string);
4650
char * basename (const char *name);
4651
char * fnqualify(const char *path);
4800
const char * base_name (const char *name);
4801
char * find_executable(const char *wrapper);
4802
int check_executable(const char *path);
4652
4803
char * strendzap(char *str, const char *pat);
4653
4804
void lt_fatal (const char *message, ...);
4658
4809
char **newargz;
4661
program_name = (char *) xstrdup ((char *) basename (argv[0]));
4812
program_name = (char *) xstrdup (base_name (argv[0]));
4813
DEBUG("(main) argv[0] : %s\n",argv[0]);
4814
DEBUG("(main) program_name : %s\n",program_name);
4662
4815
newargz = XMALLOC(char *, argc+2);
4665
cat >> $cwrappersource <<EOF
4666
newargz[0] = "$SHELL";
4818
cat >> $cwrappersource <<EOF
4819
newargz[0] = (char *) xstrdup("$SHELL");
4669
cat >> $cwrappersource <<"EOF"
4670
newargz[1] = fnqualify(argv[0]);
4822
cat >> $cwrappersource <<"EOF"
4823
newargz[1] = find_executable(argv[0]);
4824
if (newargz[1] == NULL)
4825
lt_fatal("Couldn't find %s", argv[0]);
4826
DEBUG("(main) found exe at : %s\n",newargz[1]);
4671
4827
/* we know the script has the same name, without the .exe */
4672
4828
/* so make sure newargz[1] doesn't end in .exe */
4673
4829
strendzap(newargz[1],".exe");
4674
4830
for (i = 1; i < argc; i++)
4675
4831
newargz[i+1] = xstrdup(argv[i]);
4676
4832
newargz[argc+1] = NULL;
4679
cat >> $cwrappersource <<EOF
4834
for (i=0; i<argc+1; i++)
4836
DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
4844
cat >> $cwrappersource <<EOF
4845
execv("$SHELL",(char const **)newargz);
4849
cat >> $cwrappersource <<EOF
4680
4850
execv("$SHELL",newargz);
4683
cat >> $cwrappersource <<"EOF"
4855
cat >> $cwrappersource <<"EOF"
4704
basename (const char *name)
4877
base_name (const char *name)
4706
4879
const char *base;
4708
4881
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4709
4882
/* Skip over the disk name in MSDOS pathnames. */
4710
if (isalpha (name[0]) && name[1] == ':')
4883
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4714
4887
for (base = name; *name; name++)
4715
4888
if (IS_DIR_SEPARATOR (*name))
4716
4889
base = name + 1;
4717
return (char *) base;
4894
check_executable(const char * path)
4898
DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"
4900
if ((!path) || (!*path))
4903
if ((stat (path, &st) >= 0) &&
4905
/* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
4906
#if defined (S_IXOTH)
4907
((st.st_mode & S_IXOTH) == S_IXOTH) ||
4909
#if defined (S_IXGRP)
4910
((st.st_mode & S_IXGRP) == S_IXGRP) ||
4912
((st.st_mode & S_IXUSR) == S_IXUSR))
4919
/* Searches for the full path of the wrapper. Returns
4920
newly allocated full path name if found, NULL otherwise */
4721
fnqualify(const char *path)
4922
find_executable (const char* wrapper)
4927
/* static buffer for getcwd */
4725
4928
char tmp[LT_PATHMAX + 1];
4727
assert(path != NULL);
4729
/* Is it qualified already? */
4730
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4731
if (isalpha (path[0]) && path[1] == ':')
4732
return xstrdup (path);
4734
if (IS_DIR_SEPARATOR (path[0]))
4735
return xstrdup (path);
4737
/* prepend the current directory */
4738
/* doesn't handle '~' */
4932
DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") :
4935
if ((wrapper == NULL) || (*wrapper == '\0'))
4938
/* Absolute path? */
4939
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4940
if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
4942
concat_name = xstrdup (wrapper);
4943
if (check_executable(concat_name))
4950
if (IS_DIR_SEPARATOR (wrapper[0]))
4952
concat_name = xstrdup (wrapper);
4953
if (check_executable(concat_name))
4957
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4961
for (p = wrapper; *p; p++)
4969
/* no slashes; search PATH */
4970
const char* path = getenv ("PATH");
4973
for (p = path; *p; p = p_next)
4977
for (q = p; *q; q++)
4978
if (IS_PATH_SEPARATOR(*q))
4981
p_next = (*q == '\0' ? q : q + 1);
4984
/* empty path: current directory */
4985
if (getcwd (tmp, LT_PATHMAX) == NULL)
4986
lt_fatal ("getcwd failed");
4987
tmp_len = strlen(tmp);
4988
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
4989
memcpy (concat_name, tmp, tmp_len);
4990
concat_name[tmp_len] = '/';
4991
strcpy (concat_name + tmp_len + 1, wrapper);
4995
concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
4996
memcpy (concat_name, p, p_len);
4997
concat_name[p_len] = '/';
4998
strcpy (concat_name + p_len + 1, wrapper);
5000
if (check_executable(concat_name))
5005
/* not found in PATH; assume curdir */
5007
/* Relative path | not found in path: prepend cwd */
4739
5008
if (getcwd (tmp, LT_PATHMAX) == NULL)
4740
5009
lt_fatal ("getcwd failed");
4741
size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
4742
p = XMALLOC(char, size);
4743
sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
5010
tmp_len = strlen(tmp);
5011
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5012
memcpy (concat_name, tmp, tmp_len);
5013
concat_name[tmp_len] = '/';
5014
strcpy (concat_name + tmp_len + 1, wrapper);
5016
if (check_executable(concat_name))
4788
# we should really use a build-platform specific compiler
4789
# here, but OTOH, the wrappers (shell script and this C one)
4790
# are only useful if you want to execute the "real" binary.
4791
# Since the "real" binary is built for $host, then this
4792
# wrapper might as well be built for $host, too.
4793
$run $LTCC -s -o $cwrapper $cwrappersource
4797
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5063
# we should really use a build-platform specific compiler
5064
# here, but OTOH, the wrappers (shell script and this C one)
5065
# are only useful if you want to execute the "real" binary.
5066
# Since the "real" binary is built for $host, then this
5067
# wrapper might as well be built for $host, too.
5068
$run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5072
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
4799
5074
$echo > $output "\
4993
5268
if test -n "$addlibs"; then
4994
5269
gentop="$output_objdir/${outputname}x"
4995
$show "${rm}r $gentop"
4996
$run ${rm}r "$gentop"
4997
$show "$mkdir $gentop"
4998
$run $mkdir "$gentop"
5000
if test "$status" -ne 0 && test ! -d "$gentop"; then
5003
5270
generated="$generated $gentop"
5005
# Add in members from convenience archives.
5006
for xlib in $addlibs; do
5007
# Extract the objects.
5009
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
5010
*) xabs=`pwd`"/$xlib" ;;
5012
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
5013
xdir="$gentop/$xlib"
5015
$show "${rm}r $xdir"
5017
$show "$mkdir $xdir"
5020
if test "$status" -ne 0 && test ! -d "$xdir"; then
5023
# We will extract separately just the conflicting names and we will no
5024
# longer touch any unique names. It is faster to leave these extract
5025
# automatically by $AR in one run.
5026
$show "(cd $xdir && $AR x $xabs)"
5027
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
5028
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
5031
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
5032
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
5033
$AR t "$xabs" | sort | uniq -cd | while read -r count name
5036
while test "$i" -le "$count"
5038
# Put our $i before any first dot (extension)
5039
# Never overwrite any file
5041
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
5043
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
5045
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
5046
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
5052
oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
5272
func_extract_archives $gentop $addlibs
5273
oldobjs="$oldobjs $func_extract_archives_result"
5056
5276
# Do each command in the archive commands.
5057
5277
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5058
5278
cmds=$old_archive_from_new_cmds
5280
# POSIX demands no paths to be encoded in archives. We have
5281
# to avoid creating archives with duplicate basenames if we
5282
# might have to extract them afterwards, e.g., when creating a
5283
# static archive out of a convenience library, or when linking
5284
# the entirety of a libtool archive into another (currently
5285
# not supported by libtool).
5286
if (for obj in $oldobjs
5288
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5289
done | sort | sort -uc >/dev/null 2>&1); then
5292
$echo "copying selected object files to avoid basename conflicts..."
5294
if test -z "$gentop"; then
5295
gentop="$output_objdir/${outputname}x"
5296
generated="$generated $gentop"
5298
$show "${rm}r $gentop"
5299
$run ${rm}r "$gentop"
5300
$show "$mkdir $gentop"
5301
$run $mkdir "$gentop"
5303
if test "$status" -ne 0 && test ! -d "$gentop"; then
5308
save_oldobjs=$oldobjs
5311
for obj in $save_oldobjs
5313
objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5314
case " $oldobjs " in
5315
" ") oldobjs=$obj ;;
5318
# Make sure we don't pick an alternate name that also
5320
newobj=lt$counter-$objbase
5321
counter=`expr $counter + 1`
5322
case " $oldobjs " in
5323
*[\ /]"$newobj "*) ;;
5324
*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5327
$show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5328
$run ln "$obj" "$gentop/$newobj" ||
5329
$run cp "$obj" "$gentop/$newobj"
5330
oldobjs="$oldobjs $gentop/$newobj"
5332
*) oldobjs="$oldobjs $obj" ;;
5060
5337
eval cmds=\"$old_archive_cmds\"
5062
5339
if len=`expr "X$cmds" : ".*"` &&
5639
5918
notinst_deplibs=
5640
5919
relink_command=
5642
# To insure that "foo" is sourced, and not "foo.exe",
5643
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5644
# which disallows the automatic-append-.exe behavior.
5646
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5647
*) wrapperdot=${wrapper} ;;
5921
# Note that it is not necessary on cygwin/mingw to append a dot to
5922
# foo even if both foo and FILE.exe exist: automatic-append-.exe
5923
# behavior happens only for exec(3), not for open(2)! Also, sourcing
5924
# `FILE.' does not work on cygwin managed mounts.
5649
5926
# If there is no directory component, then add one.
5651
*/* | *\\*) . ${wrapperdot} ;;
5652
*) . ./${wrapperdot} ;;
5928
*/* | *\\*) . ${wrapper} ;;
5929
*) . ./${wrapper} ;;
5655
5932
# Check the variables that should have been set.
5679
5956
relink_command=
5680
# To insure that "foo" is sourced, and not "foo.exe",
5681
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5682
# which disallows the automatic-append-.exe behavior.
5684
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5685
*) wrapperdot=${wrapper} ;;
5957
# Note that it is not necessary on cygwin/mingw to append a dot to
5958
# foo even if both foo and FILE.exe exist: automatic-append-.exe
5959
# behavior happens only for exec(3), not for open(2)! Also, sourcing
5960
# `FILE.' does not work on cygwin managed mounts.
5687
5962
# If there is no directory component, then add one.
5689
*/* | *\\*) . ${wrapperdot} ;;
5690
*) . ./${wrapperdot} ;;
5964
*/* | *\\*) . ${wrapper} ;;
5965
*) . ./${wrapper} ;;