245
# func_extract_archives gentop oldlib ...
246
func_extract_archives () {
247
my_gentop="$1"; shift
255
$show "${rm}r $my_gentop"
256
$run ${rm}r "$my_gentop"
257
$show "$mkdir $my_gentop"
258
$run $mkdir "$my_gentop"
260
if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
264
for my_xlib in $my_oldlibs; do
265
# Extract the objects.
267
[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
268
*) my_xabs=`pwd`"/$my_xlib" ;;
270
my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
271
my_xdir="$my_gentop/$my_xlib"
273
$show "${rm}r $my_xdir"
274
$run ${rm}r "$my_xdir"
275
$show "$mkdir $my_xdir"
276
$run $mkdir "$my_xdir"
278
if test "$status" -ne 0 && test ! -d "$my_xdir"; then
283
$show "Extracting $my_xabs"
284
# Do not bother doing anything if just a dry run
285
if test -z "$run"; then
286
darwin_orig_dir=`pwd`
287
cd $my_xdir || exit $?
288
darwin_archive=$my_xabs
290
darwin_base_archive=`basename $darwin_archive`
291
darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
292
if test -n "$darwin_arches"; then
293
darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
295
$show "$darwin_base_archive has multiple architectures $darwin_arches"
296
for darwin_arch in $darwin_arches ; do
297
mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
298
lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
299
# Remove the table of contents from the thin files.
300
$AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF 2>/dev/null || true
301
$AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF\ SORTED 2>/dev/null || true
302
cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
303
$AR -xo "${darwin_base_archive}"
304
rm "${darwin_base_archive}"
306
done # $darwin_arches
307
## Okay now we have a bunch of thin objects, gotta fatten them up :)
308
darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP`
311
for darwin_file in $darwin_filelist; do
312
darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
313
lipo -create -output "$darwin_file" $darwin_files
314
done # $darwin_filelist
316
cd "$darwin_orig_dir"
319
(cd $my_xdir && $AR x $my_xabs) || exit $?
324
# We will extract separately just the conflicting names and we will
325
# no longer touch any unique names. It is faster to leave these
326
# extract automatically by $AR in one run.
327
$show "(cd $my_xdir && $AR x $my_xabs)"
328
$run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $?
329
if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then
332
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
333
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
334
$AR t "$my_xabs" | sort | uniq -cd | while read -r count name
337
while test "$i" -le "$count"
339
# Put our $i before any first dot (extension)
340
# Never overwrite any file
342
while test "X$name_to" = "X$name" || test -f "$my_xdir/$name_to"
344
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
346
$show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' '$name_to')"
347
$run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv '$name' '$name_to')" || exit $?
354
my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
357
func_extract_archives_result="$my_oldobjs"
359
238
# End of Shell function definitions
360
239
#####################################
2287
2150
absdir="$libdir"
2290
if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2293
# Remove this search path later
2294
notinst_path="$notinst_path $abs_ladir"
2296
dir="$ladir/$objdir"
2297
absdir="$abs_ladir/$objdir"
2298
# Remove this search path later
2299
notinst_path="$notinst_path $abs_ladir"
2153
dir="$ladir/$objdir"
2154
absdir="$abs_ladir/$objdir"
2155
# Remove this search path later
2156
notinst_path="$notinst_path $abs_ladir"
2301
2157
fi # $installed = yes
2302
2158
name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3818
3679
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3820
3681
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
3821
3690
generated="$generated $gentop"
3823
func_extract_archives $gentop $convenience
3824
libobjs="$libobjs $func_extract_archives_result"
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`
3828
3743
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3829
3744
eval flag=\"$thread_safe_flag_spec\"
3830
3745
linker_flags="$linker_flags $flag"
4062
3977
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4064
3979
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
4065
3988
generated="$generated $gentop"
4067
func_extract_archives $gentop $convenience
4068
reload_conv_objs="$reload_objs $func_extract_archives_result"
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`
4464
4404
$run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4466
4406
# Clean up the generated files.
4467
#$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4468
#$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4407
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4408
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4470
4410
# Transform the symbol file into the correct name.
4472
*cygwin* | *mingw* )
4473
if test -f "$output_objdir/${outputname}.def" ; then
4474
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4475
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4477
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4478
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4482
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4483
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
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}%"`
4488
4415
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4699
4622
#ifndef DIR_SEPARATOR
4700
# define DIR_SEPARATOR '/'
4701
# define PATH_SEPARATOR ':'
4623
#define DIR_SEPARATOR '/'
4704
4626
#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4705
4627
defined (__OS2__)
4706
# define HAVE_DOS_BASED_FILE_SYSTEM
4707
# ifndef DIR_SEPARATOR_2
4708
# define DIR_SEPARATOR_2 '\\'
4710
# ifndef PATH_SEPARATOR_2
4711
# define PATH_SEPARATOR_2 ';'
4628
#define HAVE_DOS_BASED_FILE_SYSTEM
4629
#ifndef DIR_SEPARATOR_2
4630
#define DIR_SEPARATOR_2 '\\'
4715
4634
#ifndef DIR_SEPARATOR_2
4719
4638
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4720
4639
#endif /* DIR_SEPARATOR_2 */
4722
#ifndef PATH_SEPARATOR_2
4723
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4724
#else /* PATH_SEPARATOR_2 */
4725
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4726
#endif /* PATH_SEPARATOR_2 */
4728
4641
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4729
4642
#define XFREE(stale) do { \
4730
4643
if (stale) { free ((void *) stale); stale = 0; } \
4733
#if defined DEBUGWRAPPER
4734
# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
4736
# define DEBUG(format, ...)
4739
4646
const char *program_name = NULL;
4741
4648
void * xmalloc (size_t num);
4742
4649
char * xstrdup (const char *string);
4743
4650
char * basename (const char *name);
4744
char * find_executable(const char *wrapper);
4745
int check_executable(const char *path);
4651
char * fnqualify(const char *path);
4746
4652
char * strendzap(char *str, const char *pat);
4747
4653
void lt_fatal (const char *message, ...);
4765
4669
cat >> $cwrappersource <<"EOF"
4766
newargz[1] = find_executable(argv[0]);
4767
if (newargz[1] == NULL)
4768
lt_fatal("Couldn't find %s", argv[0]);
4769
DEBUG("(main) found exe at : %s\n",newargz[1]);
4670
newargz[1] = fnqualify(argv[0]);
4770
4671
/* we know the script has the same name, without the .exe */
4771
4672
/* so make sure newargz[1] doesn't end in .exe */
4772
4673
strendzap(newargz[1],".exe");
4773
4674
for (i = 1; i < argc; i++)
4774
4675
newargz[i+1] = xstrdup(argv[i]);
4775
4676
newargz[argc+1] = NULL;
4777
for (i=0; i<argc+1; i++)
4779
DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
4785
4679
cat >> $cwrappersource <<EOF
4823
4717
return (char *) base;
4827
check_executable(const char * path)
4831
DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
4832
if ((!path) || (!*path))
4835
if ((stat (path, &st) >= 0) &&
4836
(((st.st_mode & S_IXOTH) == S_IXOTH) ||
4837
((st.st_mode & S_IXGRP) == S_IXGRP) ||
4838
((st.st_mode & S_IXUSR) == S_IXUSR)))
4844
/* Searches for the full path of the wrapper. Returns
4845
newly allocated full path name if found, NULL otherwise */
4847
find_executable (const char* wrapper)
4721
fnqualify(const char *path)
4853
/* static buffer for getcwd */
4854
4725
char tmp[LT_PATHMAX + 1];
4858
DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
4860
if ((wrapper == NULL) || (*wrapper == '\0'))
4863
/* Absolute path? */
4864
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4865
if (isalpha (wrapper[0]) && wrapper[1] == ':')
4867
concat_name = xstrdup (wrapper);
4868
if (check_executable(concat_name))
4875
if (IS_DIR_SEPARATOR (wrapper[0]))
4877
concat_name = xstrdup (wrapper);
4878
if (check_executable(concat_name))
4882
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4886
for (p = wrapper; *p; p++)
4894
/* no slashes; search PATH */
4895
const char* path = getenv ("PATH");
4898
for (p = path; *p; p = p_next)
4902
for (q = p; *q; q++)
4903
if (IS_PATH_SEPARATOR(*q))
4906
p_next = (*q == '\0' ? q : q + 1);
4909
/* empty path: current directory */
4910
if (getcwd (tmp, LT_PATHMAX) == NULL)
4911
lt_fatal ("getcwd failed");
4912
tmp_len = strlen(tmp);
4913
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
4914
memcpy (concat_name, tmp, tmp_len);
4915
concat_name[tmp_len] = '/';
4916
strcpy (concat_name + tmp_len + 1, wrapper);
4920
concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
4921
memcpy (concat_name, p, p_len);
4922
concat_name[p_len] = '/';
4923
strcpy (concat_name + p_len + 1, wrapper);
4925
if (check_executable(concat_name))
4930
/* not found in PATH; assume curdir */
4932
/* Relative path | not found in path: prepend cwd */
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 '~' */
4933
4739
if (getcwd (tmp, LT_PATHMAX) == NULL)
4934
4740
lt_fatal ("getcwd failed");
4935
tmp_len = strlen(tmp);
4936
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
4937
memcpy (concat_name, tmp, tmp_len);
4938
concat_name[tmp_len] = '/';
4939
strcpy (concat_name + tmp_len + 1, wrapper);
4941
if (check_executable(concat_name))
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);
5193
4993
if test -n "$addlibs"; then
5194
4994
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
5195
5003
generated="$generated $gentop"
5197
func_extract_archives $gentop $addlibs
5198
oldobjs="$oldobjs $func_extract_archives_result"
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`
5201
5056
# Do each command in the archive commands.