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.
2562
2655
if test "$hardcode_direct" = no; then
2563
2656
add="$dir/$linklib"
2565
*-*-sco3.2v5* ) add_dir="-L$dir" ;;
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" ;;
2567
2663
# if the lib is a module then we can not link against
2568
2664
# it, someone is ignoring the new warnings I added
2569
if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2665
if /usr/bin/file -L $add 2> /dev/null |
2666
$EGREP ": [^:]* bundle" >/dev/null ; then
2570
2667
$echo "** Warning, lib $linklib is a module, not a shared library"
2571
2668
if test -z "$old_library" ; then
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"
4230
4391
compile_command="$compile_command $compile_deplibs"
4231
4392
finalize_command="$finalize_command $finalize_deplibs"
4391
4557
export_symbols="$output_objdir/$outputname.exp"
4392
4558
$run $rm $export_symbols
4393
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"'
4395
$run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4567
$run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4396
4568
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4397
4569
$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"'
4513
4691
# Now compile the dynamic symbol file.
4514
$show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4515
$run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
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 $?
4517
4695
# Clean up the generated files.
4518
4696
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4519
4697
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4521
4699
# Transform the symbol file into the correct name.
4522
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4523
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
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}%"`
4526
4717
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4749
4949
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4750
4950
#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 */
4752
4958
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4753
4959
#define XFREE(stale) do { \
4754
4960
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, ...)
4757
4971
const char *program_name = NULL;
4759
4973
void * xmalloc (size_t num);
4760
4974
char * xstrdup (const char *string);
4761
char * basename (const char *name);
4762
char * fnqualify(const char *path);
4975
const char * base_name (const char *name);
4976
char * find_executable(const char *wrapper);
4977
int check_executable(const char *path);
4763
4978
char * strendzap(char *str, const char *pat);
4764
4979
void lt_fatal (const char *message, ...);
4769
4984
char **newargz;
4772
program_name = (char *) xstrdup ((char *) basename (argv[0]));
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);
4773
4990
newargz = XMALLOC(char *, argc+2);
4776
cat >> $cwrappersource <<EOF
4777
newargz[0] = "$SHELL";
4993
cat >> $cwrappersource <<EOF
4994
newargz[0] = (char *) xstrdup("$SHELL");
4780
cat >> $cwrappersource <<"EOF"
4781
newargz[1] = fnqualify(argv[0]);
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]);
4782
5002
/* we know the script has the same name, without the .exe */
4783
5003
/* so make sure newargz[1] doesn't end in .exe */
4784
5004
strendzap(newargz[1],".exe");
4785
5005
for (i = 1; i < argc; i++)
4786
5006
newargz[i+1] = xstrdup(argv[i]);
4787
5007
newargz[argc+1] = NULL;
4790
cat >> $cwrappersource <<EOF
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
4791
5025
execv("$SHELL",newargz);
4794
cat >> $cwrappersource <<"EOF"
5030
cat >> $cwrappersource <<"EOF"
4816
basename (const char *name)
5052
base_name (const char *name)
4818
5054
const char *base;
4820
5056
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4821
5057
/* Skip over the disk name in MSDOS pathnames. */
4822
if (isalpha (name[0]) && name[1] == ':')
5058
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4826
5062
for (base = name; *name; name++)
4827
5063
if (IS_DIR_SEPARATOR (*name))
4828
5064
base = name + 1;
4829
return (char *) base;
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 */
4833
fnqualify(const char *path)
5096
find_executable (const char* wrapper)
5101
/* static buffer for getcwd */
4837
5102
char tmp[LT_PATHMAX + 1];
4839
assert(path != NULL);
4841
/* Is it qualified already? */
4842
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4843
if (isalpha (path[0]) && path[1] == ':')
4844
return xstrdup (path);
4846
if (IS_DIR_SEPARATOR (path[0]))
4847
return xstrdup (path);
4849
/* prepend the current directory */
4850
/* doesn't handle '~' */
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 */
4851
5181
if (getcwd (tmp, LT_PATHMAX) == NULL)
4852
5182
lt_fatal ("getcwd failed");
4853
size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
4854
p = XMALLOC(char, size);
4855
sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
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))
4900
# we should really use a build-platform specific compiler
4901
# here, but OTOH, the wrappers (shell script and this C one)
4902
# are only useful if you want to execute the "real" binary.
4903
# Since the "real" binary is built for $host, then this
4904
# wrapper might as well be built for $host, too.
4905
$run $LTCC -s -o $cwrapper $cwrappersource
4909
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
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
4911
5247
$echo > $output "\