137
134
lo2o="s/\\.lo\$/.${objext}/"
138
135
o2lo="s/\\.${objext}\$/.lo/"
136
quote_scanset='[[~#^*{};<>?'"'"' ]'
140
138
#####################################
141
139
# Shell function definitions:
142
140
# 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
181
142
# func_win32_libid arg
182
143
# return the library type of file 'arg'
196
157
if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
197
158
$EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
198
159
win32_nmres=`eval $NM -f posix -A $1 | \
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";;
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"
794
738
qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
796
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
740
*$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
797
741
qlibobj="\"$qlibobj\"" ;;
799
test "X$libobj" != "X$qlibobj" \
800
&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \
801
&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
743
if test "X$libobj" != "X$qlibobj"; then
744
$echo "$modename: libobj name \`$libobj' may not contain shell special characters."
802
747
objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
803
748
xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
804
749
if test "X$xdir" = "X$obj"; then
1618
1537
# +DA*, +DD* enable 64-bit mode on the HP compiler
1619
1538
# -q* pass through compiler args for the IBM compiler
1620
1539
# -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*|@*)
1540
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*)
1628
1542
# Unknown arguments in both finalize_command and compile_command need
1629
1543
# to be aesthetically quoted because they are evaled later.
1630
1544
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1632
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1546
*$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
1636
1550
compile_command="$compile_command $arg"
1637
1551
finalize_command="$finalize_command $arg"
1638
compiler_flags="$compiler_flags $arg"
1552
if test "$with_gcc" = "yes" ; then
1553
compiler_flags="$compiler_flags $arg"
2655
2560
if test "$hardcode_direct" = no; then
2656
2561
add="$dir/$linklib"
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" ;;
2563
*-*-sco3.2v5* ) add_dir="-L$dir" ;;
2663
2565
# if the lib is a module then we can not link against
2664
2566
# it, someone is ignoring the new warnings I added
2665
if /usr/bin/file -L $add 2> /dev/null |
2666
$EGREP ": [^:]* bundle" >/dev/null ; then
2567
if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2667
2568
$echo "** Warning, lib $linklib is a module, not a shared library"
2668
2569
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"
4391
4204
compile_command="$compile_command $compile_deplibs"
4392
4205
finalize_command="$finalize_command $finalize_deplibs"
4556
4364
if test -z "$export_symbols"; then
4557
4365
export_symbols="$output_objdir/$outputname.exp"
4558
4366
$run $rm $export_symbols
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"'
4367
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4567
$run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4369
$run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4568
4370
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4569
4371
$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"'
4691
4487
# Now compile the dynamic symbol file.
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 $?
4488
$show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4489
$run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4695
4491
# Clean up the generated files.
4696
4492
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4697
4493
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4699
4495
# Transform the symbol file into the correct name.
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}%"`
4496
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4497
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4717
4500
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4949
4723
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4950
4724
#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 */
4958
4726
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4959
4727
#define XFREE(stale) do { \
4960
4728
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, ...)
4971
4731
const char *program_name = NULL;
4973
4733
void * xmalloc (size_t num);
4974
4734
char * xstrdup (const char *string);
4975
const char * base_name (const char *name);
4976
char * find_executable(const char *wrapper);
4977
int check_executable(const char *path);
4735
char * basename (const char *name);
4736
char * fnqualify(const char *path);
4978
4737
char * strendzap(char *str, const char *pat);
4979
4738
void lt_fatal (const char *message, ...);
4984
4743
char **newargz;
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);
4746
program_name = (char *) xstrdup ((char *) basename (argv[0]));
4990
4747
newargz = XMALLOC(char *, argc+2);
4993
cat >> $cwrappersource <<EOF
4994
newargz[0] = (char *) xstrdup("$SHELL");
4750
cat >> $cwrappersource <<EOF
4751
newargz[0] = "$SHELL";
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]);
4754
cat >> $cwrappersource <<"EOF"
4755
newargz[1] = fnqualify(argv[0]);
5002
4756
/* we know the script has the same name, without the .exe */
5003
4757
/* so make sure newargz[1] doesn't end in .exe */
5004
4758
strendzap(newargz[1],".exe");
5005
4759
for (i = 1; i < argc; i++)
5006
4760
newargz[i+1] = xstrdup(argv[i]);
5007
4761
newargz[argc+1] = NULL;
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
4764
cat >> $cwrappersource <<EOF
5025
4765
execv("$SHELL",newargz);
5030
cat >> $cwrappersource <<"EOF"
4768
cat >> $cwrappersource <<"EOF"
5052
base_name (const char *name)
4789
basename (const char *name)
5054
4791
const char *base;
5056
4793
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5057
4794
/* Skip over the disk name in MSDOS pathnames. */
5058
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4795
if (isalpha (name[0]) && name[1] == ':')
5062
4799
for (base = name; *name; name++)
5063
4800
if (IS_DIR_SEPARATOR (*name))
5064
4801
base = name + 1;
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 */
4802
return (char *) base;
5096
find_executable (const char* wrapper)
4806
fnqualify(const char *path)
5101
/* static buffer for getcwd */
5102
4810
char tmp[LT_PATHMAX + 1];
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 */
4812
assert(path != NULL);
4814
/* Is it qualified already? */
4815
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4816
if (isalpha (path[0]) && path[1] == ':')
4817
return xstrdup (path);
4819
if (IS_DIR_SEPARATOR (path[0]))
4820
return xstrdup (path);
4822
/* prepend the current directory */
4823
/* doesn't handle '~' */
5181
4824
if (getcwd (tmp, LT_PATHMAX) == NULL)
5182
4825
lt_fatal ("getcwd failed");
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))
4826
size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
4827
p = XMALLOC(char, size);
4828
sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
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
4873
# we should really use a build-platform specific compiler
4874
# here, but OTOH, the wrappers (shell script and this C one)
4875
# are only useful if you want to execute the "real" binary.
4876
# Since the "real" binary is built for $host, then this
4877
# wrapper might as well be built for $host, too.
4878
$run $LTCC -s -o $cwrapper $cwrappersource
4882
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5247
4884
$echo > $output "\
6091
5713
notinst_deplibs=
6092
5714
relink_command=
6094
# Note that it is not necessary on cygwin/mingw to append a dot to
6095
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6096
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6097
# `FILE.' does not work on cygwin managed mounts.
5716
# To insure that "foo" is sourced, and not "foo.exe",
5717
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5718
# which disallows the automatic-append-.exe behavior.
5720
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5721
*) wrapperdot=${wrapper} ;;
6099
5723
# If there is no directory component, then add one.
6101
*/* | *\\*) . ${wrapper} ;;
6102
*) . ./${wrapper} ;;
5725
*/* | *\\*) . ${wrapperdot} ;;
5726
*) . ./${wrapperdot} ;;
6105
5729
# Check the variables that should have been set.
6129
5753
relink_command=
6130
# Note that it is not necessary on cygwin/mingw to append a dot to
6131
# foo even if both foo and FILE.exe exist: automatic-append-.exe
6132
# behavior happens only for exec(3), not for open(2)! Also, sourcing
6133
# `FILE.' does not work on cygwin managed mounts.
5754
# To insure that "foo" is sourced, and not "foo.exe",
5755
# finese the cygwin/MSYS system by explicitly sourcing "foo."
5756
# which disallows the automatic-append-.exe behavior.
5758
*cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5759
*) wrapperdot=${wrapper} ;;
6135
5761
# If there is no directory component, then add one.
6137
*/* | *\\*) . ${wrapper} ;;
6138
*) . ./${wrapper} ;;
5763
*/* | *\\*) . ${wrapperdot} ;;
5764
*) . ./${wrapperdot} ;;
6142
5768
if test "$fast_install" = no && test -n "$relink_command"; then
6143
5769
if test "$finalize" = yes && test -z "$run"; then
6144
tmpdir=`func_mktempdir`
5771
test -n "$TMPDIR" && tmpdir="$TMPDIR"
5772
tmpdir="$tmpdir/libtool-$$"
5775
if $mkdir "$tmpdir"; then
5779
$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
6145
5782
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
6146
5783
outputname="$tmpdir/$file"
6147
5784
# Replace the output file specification.