134
137
lo2o="s/\\.lo\$/.${objext}/"
135
138
o2lo="s/\\.${objext}\$/.lo/"
136
quote_scanset='[[~#^*{};<>?'"'"' ]'
138
140
#####################################
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";;
738
794
qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
740
*$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
796
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
741
797
qlibobj="\"$qlibobj\"" ;;
743
if test "X$libobj" != "X$qlibobj"; then
744
$echo "$modename: libobj name \`$libobj' may not contain shell special characters."
799
test "X$libobj" != "X$qlibobj" \
800
&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \
801
&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
747
802
objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
748
803
xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
749
804
if test "X$xdir" = "X$obj"; then
1537
1618
# +DA*, +DD* enable 64-bit mode on the HP compiler
1538
1619
# -q* pass through compiler args for the IBM compiler
1539
1620
# -m* pass through architecture-specific compiler args for GCC
1540
-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*|@*)
1542
1628
# Unknown arguments in both finalize_command and compile_command need
1543
1629
# to be aesthetically quoted because they are evaled later.
1544
1630
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1546
*$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
1632
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1550
1636
compile_command="$compile_command $arg"
1551
1637
finalize_command="$finalize_command $arg"
1552
if test "$with_gcc" = "yes" ; then
1553
compiler_flags="$compiler_flags $arg"
1638
compiler_flags="$compiler_flags $arg"
2560
2655
if test "$hardcode_direct" = no; then
2561
2656
add="$dir/$linklib"
2563
*-*-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" ;;
2565
2663
# if the lib is a module then we can not link against
2566
2664
# it, someone is ignoring the new warnings I added
2567
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
2568
2667
$echo "** Warning, lib $linklib is a module, not a shared library"
2569
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"
4204
4391
compile_command="$compile_command $compile_deplibs"
4205
4392
finalize_command="$finalize_command $finalize_deplibs"
4364
4556
if test -z "$export_symbols"; then
4365
4557
export_symbols="$output_objdir/$outputname.exp"
4366
4558
$run $rm $export_symbols
4367
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$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"'
4369
$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"'
4370
4568
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4371
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"'
4487
4691
# Now compile the dynamic symbol file.
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 $?
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 $?
4491
4695
# Clean up the generated files.
4492
4696
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4493
4697
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4495
4699
# Transform the symbol file into the correct name.
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}%"`
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}%"`
4500
4717
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4723
4949
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4724
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 */
4726
4958
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4727
4959
#define XFREE(stale) do { \
4728
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, ...)
4731
4971
const char *program_name = NULL;
4733
4973
void * xmalloc (size_t num);
4734
4974
char * xstrdup (const char *string);
4735
char * basename (const char *name);
4736
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);
4737
4978
char * strendzap(char *str, const char *pat);
4738
4979
void lt_fatal (const char *message, ...);
4743
4984
char **newargz;
4746
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);
4747
4990
newargz = XMALLOC(char *, argc+2);
4750
cat >> $cwrappersource <<EOF
4751
newargz[0] = "$SHELL";
4993
cat >> $cwrappersource <<EOF
4994
newargz[0] = (char *) xstrdup("$SHELL");
4754
cat >> $cwrappersource <<"EOF"
4755
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]);
4756
5002
/* we know the script has the same name, without the .exe */
4757
5003
/* so make sure newargz[1] doesn't end in .exe */
4758
5004
strendzap(newargz[1],".exe");
4759
5005
for (i = 1; i < argc; i++)
4760
5006
newargz[i+1] = xstrdup(argv[i]);
4761
5007
newargz[argc+1] = NULL;
4764
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
4765
5025
execv("$SHELL",newargz);
4768
cat >> $cwrappersource <<"EOF"
5030
cat >> $cwrappersource <<"EOF"
4789
basename (const char *name)
5052
base_name (const char *name)
4791
5054
const char *base;
4793
5056
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4794
5057
/* Skip over the disk name in MSDOS pathnames. */
4795
if (isalpha (name[0]) && name[1] == ':')
5058
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4799
5062
for (base = name; *name; name++)
4800
5063
if (IS_DIR_SEPARATOR (*name))
4801
5064
base = name + 1;
4802
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 */
4806
fnqualify(const char *path)
5096
find_executable (const char* wrapper)
5101
/* static buffer for getcwd */
4810
5102
char tmp[LT_PATHMAX + 1];
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 '~' */
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 */
4824
5181
if (getcwd (tmp, LT_PATHMAX) == NULL)
4825
5182
lt_fatal ("getcwd failed");
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);
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))
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
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
4884
5247
$echo > $output "\
5713
6091
notinst_deplibs=
5714
6092
relink_command=
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} ;;
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.
5723
6099
# If there is no directory component, then add one.
5725
*/* | *\\*) . ${wrapperdot} ;;
5726
*) . ./${wrapperdot} ;;
6101
*/* | *\\*) . ${wrapper} ;;
6102
*) . ./${wrapper} ;;
5729
6105
# Check the variables that should have been set.
5753
6129
relink_command=
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} ;;
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.
5761
6135
# If there is no directory component, then add one.
5763
*/* | *\\*) . ${wrapperdot} ;;
5764
*) . ./${wrapperdot} ;;
6137
*/* | *\\*) . ${wrapper} ;;
6138
*) . ./${wrapper} ;;
5768
6142
if test "$fast_install" = no && test -n "$relink_command"; then
5769
6143
if test "$finalize" = yes && test -z "$run"; then
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
6144
tmpdir=`func_mktempdir`
5782
6145
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
5783
6146
outputname="$tmpdir/$file"
5784
6147
# Replace the output file specification.