139
141
# Shell function definitions:
140
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
142
181
# func_win32_libid arg
143
182
# return the library type of file 'arg'
157
196
if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
158
197
$EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
159
198
win32_nmres=`eval $NM -f posix -A $1 | \
160
sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
161
if test "X$win32_nmres" = "Ximport" ; then
162
win32_libid_type="x86 archive import"
164
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";;
1536
1618
# +DA*, +DD* enable 64-bit mode on the HP compiler
1537
1619
# -q* pass through compiler args for the IBM compiler
1538
1620
# -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*)
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*|@*)
1541
1628
# Unknown arguments in both finalize_command and compile_command need
1542
1629
# to be aesthetically quoted because they are evaled later.
2559
2652
if test "$hardcode_direct" = no; then
2560
2653
add="$dir/$linklib"
2562
*-*-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" ;;
2564
2660
# if the lib is a module then we can not link against
2565
2661
# it, someone is ignoring the new warnings I added
2566
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
2567
2664
$echo "** Warning, lib $linklib is a module, not a shared library"
2568
2665
if test -z "$old_library" ; then
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"
4222
4383
compile_command="$compile_command $compile_deplibs"
4223
4384
finalize_command="$finalize_command $finalize_deplibs"
4383
4549
export_symbols="$output_objdir/$outputname.exp"
4384
4550
$run $rm $export_symbols
4385
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"'
4387
$run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4559
$run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4388
4560
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4389
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"'
4505
4683
# Now compile the dynamic symbol file.
4506
$show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4507
$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 $?
4509
4687
# Clean up the generated files.
4510
4688
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4511
4689
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4513
4691
# Transform the symbol file into the correct name.
4514
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4515
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}%"`
4518
4709
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4741
4941
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4742
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 */
4744
4950
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4745
4951
#define XFREE(stale) do { \
4746
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, ...)
4749
4963
const char *program_name = NULL;
4751
4965
void * xmalloc (size_t num);
4752
4966
char * xstrdup (const char *string);
4753
char * basename (const char *name);
4754
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);
4755
4970
char * strendzap(char *str, const char *pat);
4756
4971
void lt_fatal (const char *message, ...);
4761
4976
char **newargz;
4764
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);
4765
4982
newargz = XMALLOC(char *, argc+2);
4768
cat >> $cwrappersource <<EOF
4769
newargz[0] = "$SHELL";
4985
cat >> $cwrappersource <<EOF
4986
newargz[0] = (char *) xstrdup("$SHELL");
4772
cat >> $cwrappersource <<"EOF"
4773
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]);
4774
4994
/* we know the script has the same name, without the .exe */
4775
4995
/* so make sure newargz[1] doesn't end in .exe */
4776
4996
strendzap(newargz[1],".exe");
4777
4997
for (i = 1; i < argc; i++)
4778
4998
newargz[i+1] = xstrdup(argv[i]);
4779
4999
newargz[argc+1] = NULL;
4782
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
4783
5017
execv("$SHELL",newargz);
4786
cat >> $cwrappersource <<"EOF"
5022
cat >> $cwrappersource <<"EOF"
4808
basename (const char *name)
5044
base_name (const char *name)
4810
5046
const char *base;
4812
5048
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4813
5049
/* Skip over the disk name in MSDOS pathnames. */
4814
if (isalpha (name[0]) && name[1] == ':')
5050
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4818
5054
for (base = name; *name; name++)
4819
5055
if (IS_DIR_SEPARATOR (*name))
4820
5056
base = name + 1;
4821
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 */
4825
fnqualify(const char *path)
5088
find_executable (const char* wrapper)
5093
/* static buffer for getcwd */
4829
5094
char tmp[LT_PATHMAX + 1];
4831
assert(path != NULL);
4833
/* Is it qualified already? */
4834
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4835
if (isalpha (path[0]) && path[1] == ':')
4836
return xstrdup (path);
4838
if (IS_DIR_SEPARATOR (path[0]))
4839
return xstrdup (path);
4841
/* prepend the current directory */
4842
/* 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 */
4843
5173
if (getcwd (tmp, LT_PATHMAX) == NULL)
4844
5174
lt_fatal ("getcwd failed");
4845
size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
4846
p = XMALLOC(char, size);
4847
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))
4892
# we should really use a build-platform specific compiler
4893
# here, but OTOH, the wrappers (shell script and this C one)
4894
# are only useful if you want to execute the "real" binary.
4895
# Since the "real" binary is built for $host, then this
4896
# wrapper might as well be built for $host, too.
4897
$run $LTCC -s -o $cwrapper $cwrappersource
4901
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
4903
5239
$echo > $output "\