1
1
# ltmain.sh - Provide generalized library-building support services.
2
2
# NOTE: Changing this file will not affect anything until you rerun configure.
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
5
# Free Software Foundation, Inc.
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
5
# 2007 Free Software Foundation, Inc.
6
6
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8
8
# This program is free software; you can redistribute it and/or modify
46
VERSION="1.5.20 Debian 1.5.20-2"
47
TIMESTAMP=" (1.1220.2.287 2005/08/31 18:54:15)"
46
VERSION="1.5.24 Debian 1.5.24-2"
47
TIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)"
49
# See if we are running on zsh, and set the options which allow our
50
# commands through without removal of \ escapes.
51
if test -n "${ZSH_VERSION+set}" ; then
49
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
50
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
53
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
54
# is contrary to our usage. Disable this feature.
55
alias -g '${1+"$@"}'='"$@"'
52
56
setopt NO_GLOB_SUBST
58
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
60
BIN_SH=xpg4; export BIN_SH # for Tru64
61
DUALCASE=1; export DUALCASE # for MKS sh
55
63
# Check that we have a working $echo.
56
64
if test "X$1" = X--no-reexec; then
135
147
lo2o="s/\\.lo\$/.${objext}/"
136
148
o2lo="s/\\.${objext}\$/.lo/"
138
152
#####################################
139
153
# Shell function definitions:
140
154
# This seems to be the best place for them
156
# func_mktempdir [string]
157
# Make a temporary directory that won't clash with other running
158
# libtool processes, and avoids race conditions if possible. If
159
# given, STRING is the basename for that directory.
162
my_template="${TMPDIR-/tmp}/${1-$progname}"
164
if test "$run" = ":"; then
165
# Return a directory name, but don't create it in dry-run mode
166
my_tmpdir="${my_template}-$$"
169
# If mktemp works, use that first and foremost
170
my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
172
if test ! -d "$my_tmpdir"; then
173
# Failing that, at least try and use $RANDOM to avoid a race
174
my_tmpdir="${my_template}-${RANDOM-0}$$"
176
save_mktempdir_umask=`umask`
179
umask $save_mktempdir_umask
182
# If we're not in dry-run mode, bomb out on failure
183
test -d "$my_tmpdir" || {
184
$echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
189
$echo "X$my_tmpdir" | $Xsed
142
193
# func_win32_libid arg
143
194
# return the library type of file 'arg'
1084
-all-static | -static)
1085
if test "X$arg" = "X-all-static"; then
1171
-all-static | -static | -static-libtool-libs)
1086
1174
if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1087
1175
$echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1089
1177
if test -n "$link_static_flag"; then
1090
1178
dlopen_self=$dlopen_self_static
1093
if test -z "$pic_flag" && test -n "$link_static_flag"; then
1094
dlopen_self=$dlopen_self_static
1180
prefer_static_libs=yes
1183
if test -z "$pic_flag" && test -n "$link_static_flag"; then
1184
dlopen_self=$dlopen_self_static
1186
prefer_static_libs=built
1188
-static-libtool-libs)
1189
if test -z "$pic_flag" && test -n "$link_static_flag"; then
1190
dlopen_self=$dlopen_self_static
1192
prefer_static_libs=yes
1097
1195
build_libtool_libs=no
1098
1196
build_old_libs=yes
1099
prefer_static_libs=yes
1536
1657
# +DA*, +DD* enable 64-bit mode on the HP compiler
1537
1658
# -q* pass through compiler args for the IBM compiler
1538
1659
# -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*)
1660
# -m*, -t[45]*, -txscale* pass through architecture-specific
1661
# compiler args for GCC
1662
# -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
1663
# -F/path gives path to uninstalled frameworks, gcc on darwin
1664
# @file GCC response files
1665
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
1666
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
1541
1668
# Unknown arguments in both finalize_command and compile_command need
1542
1669
# to be aesthetically quoted because they are evaled later.
2562
2697
if test "$hardcode_direct" = no; then
2563
2698
add="$dir/$linklib"
2565
*-*-sco3.2v5* ) add_dir="-L$dir" ;;
2700
*-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2701
*-*-sysv4*uw2*) add_dir="-L$dir" ;;
2702
*-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2703
*-*-unixware7*) add_dir="-L$dir" ;;
2567
2705
# if the lib is a module then we can not link against
2568
2706
# it, someone is ignoring the new warnings I added
2569
if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2707
if /usr/bin/file -L $add 2> /dev/null |
2708
$EGREP ": [^:]* bundle" >/dev/null ; then
2570
2709
$echo "** Warning, lib $linklib is a module, not a shared library"
2571
2710
if test -z "$old_library" ; then
3323
3467
# Eliminate all temporary directories.
3324
for path in $notinst_path; do
3325
lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
3326
deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
3327
dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
3468
#for path in $notinst_path; do
3469
# lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
3470
# deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
3471
# dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
3330
3474
if test -n "$xrpath"; then
3331
3475
# If the user specified any rpath flags, then add them.
4115
4294
reload_conv_objs=
4117
4296
# reload_cmds runs $LD directly, so let us get rid of
4118
# -Wl from whole_archive_flag_spec
4297
# -Wl from whole_archive_flag_spec and hope we can get by with
4298
# turning comma into space..
4121
4301
if test -n "$convenience"; then
4122
4302
if test -n "$whole_archive_flag_spec"; then
4123
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4303
eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
4304
reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
4125
4306
gentop="$output_objdir/${obj}x"
4126
4307
generated="$generated $gentop"
4412
# move library search paths that coincide with paths to not yet
4413
# installed libraries to the beginning of the library search list
4415
for path in $notinst_path; do
4416
case " $new_libs " in
4417
*" -L$path/$objdir "*) ;;
4419
case " $compile_deplibs " in
4420
*" -L$path/$objdir "*)
4421
new_libs="$new_libs -L$path/$objdir" ;;
4426
for deplib in $compile_deplibs; do
4429
case " $new_libs " in
4431
*) new_libs="$new_libs $deplib" ;;
4434
*) new_libs="$new_libs $deplib" ;;
4437
compile_deplibs="$new_libs"
4230
4440
compile_command="$compile_command $compile_deplibs"
4231
4441
finalize_command="$finalize_command $finalize_deplibs"
4391
4606
export_symbols="$output_objdir/$outputname.exp"
4392
4607
$run $rm $export_symbols
4393
4608
$run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4610
*cygwin* | *mingw* )
4611
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4612
$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"'
4616
$run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4396
4617
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4397
4618
$run eval 'mv "$nlist"T "$nlist"'
4620
*cygwin* | *mingw* )
4621
$run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4622
$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4513
4740
# 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 $?
4741
$show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4742
$run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4517
4744
# Clean up the generated files.
4518
4745
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4519
4746
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4521
4748
# 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}%"`
4750
*cygwin* | *mingw* )
4751
if test -f "$output_objdir/${outputname}.def" ; then
4752
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4753
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4755
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4756
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4760
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4761
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4526
4766
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4533
4773
# really was required.
4535
4775
# Nullify the symbol file.
4536
compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
4537
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
4776
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4777
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4540
4780
if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4541
4781
# Replace the output file specification.
4542
compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4782
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
4543
4783
link_command="$compile_command$compile_rpath"
4545
4785
# We have no uninstalled library dependencies, so finalize right now.
4546
4786
$show "$link_command"
4547
4787
$run eval "$link_command"
4550
4790
# Delete the generated files.
4551
4791
if test -n "$dlsyms"; then
4749
4998
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4750
4999
#endif /* DIR_SEPARATOR_2 */
5001
#ifndef PATH_SEPARATOR_2
5002
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5003
#else /* PATH_SEPARATOR_2 */
5004
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5005
#endif /* PATH_SEPARATOR_2 */
4752
5007
#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4753
5008
#define XFREE(stale) do { \
4754
5009
if (stale) { free ((void *) stale); stale = 0; } \
5012
/* -DDEBUG is fairly common in CFLAGS. */
5014
#if defined DEBUGWRAPPER
5015
# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
5017
# define DEBUG(format, ...)
4757
5020
const char *program_name = NULL;
4759
5022
void * xmalloc (size_t num);
4760
5023
char * xstrdup (const char *string);
4761
char * basename (const char *name);
4762
char * fnqualify(const char *path);
5024
const char * base_name (const char *name);
5025
char * find_executable(const char *wrapper);
5026
int check_executable(const char *path);
4763
5027
char * strendzap(char *str, const char *pat);
4764
5028
void lt_fatal (const char *message, ...);
4769
5033
char **newargz;
4772
program_name = (char *) xstrdup ((char *) basename (argv[0]));
5036
program_name = (char *) xstrdup (base_name (argv[0]));
5037
DEBUG("(main) argv[0] : %s\n",argv[0]);
5038
DEBUG("(main) program_name : %s\n",program_name);
4773
5039
newargz = XMALLOC(char *, argc+2);
4776
cat >> $cwrappersource <<EOF
4777
newargz[0] = "$SHELL";
5042
cat >> $cwrappersource <<EOF
5043
newargz[0] = (char *) xstrdup("$SHELL");
4780
cat >> $cwrappersource <<"EOF"
4781
newargz[1] = fnqualify(argv[0]);
5046
cat >> $cwrappersource <<"EOF"
5047
newargz[1] = find_executable(argv[0]);
5048
if (newargz[1] == NULL)
5049
lt_fatal("Couldn't find %s", argv[0]);
5050
DEBUG("(main) found exe at : %s\n",newargz[1]);
4782
5051
/* we know the script has the same name, without the .exe */
4783
5052
/* so make sure newargz[1] doesn't end in .exe */
4784
5053
strendzap(newargz[1],".exe");
4785
5054
for (i = 1; i < argc; i++)
4786
5055
newargz[i+1] = xstrdup(argv[i]);
4787
5056
newargz[argc+1] = NULL;
4790
cat >> $cwrappersource <<EOF
5058
for (i=0; i<argc+1; i++)
5060
DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
5068
cat >> $cwrappersource <<EOF
5069
execv("$SHELL",(char const **)newargz);
5073
cat >> $cwrappersource <<EOF
4791
5074
execv("$SHELL",newargz);
4794
cat >> $cwrappersource <<"EOF"
5079
cat >> $cwrappersource <<"EOF"
4816
basename (const char *name)
5101
base_name (const char *name)
4818
5103
const char *base;
4820
5105
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4821
5106
/* Skip over the disk name in MSDOS pathnames. */
4822
if (isalpha (name[0]) && name[1] == ':')
5107
if (isalpha ((unsigned char)name[0]) && name[1] == ':')
4826
5111
for (base = name; *name; name++)
4827
5112
if (IS_DIR_SEPARATOR (*name))
4828
5113
base = name + 1;
4829
return (char *) base;
5118
check_executable(const char * path)
5122
DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5123
if ((!path) || (!*path))
5126
if ((stat (path, &st) >= 0) &&
5128
/* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5129
#if defined (S_IXOTH)
5130
((st.st_mode & S_IXOTH) == S_IXOTH) ||
5132
#if defined (S_IXGRP)
5133
((st.st_mode & S_IXGRP) == S_IXGRP) ||
5135
((st.st_mode & S_IXUSR) == S_IXUSR))
5142
/* Searches for the full path of the wrapper. Returns
5143
newly allocated full path name if found, NULL otherwise */
4833
fnqualify(const char *path)
5145
find_executable (const char* wrapper)
5150
/* static buffer for getcwd */
4837
5151
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 '~' */
5155
DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5157
if ((wrapper == NULL) || (*wrapper == '\0'))
5160
/* Absolute path? */
5161
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5162
if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5164
concat_name = xstrdup (wrapper);
5165
if (check_executable(concat_name))
5172
if (IS_DIR_SEPARATOR (wrapper[0]))
5174
concat_name = xstrdup (wrapper);
5175
if (check_executable(concat_name))
5179
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5183
for (p = wrapper; *p; p++)
5191
/* no slashes; search PATH */
5192
const char* path = getenv ("PATH");
5195
for (p = path; *p; p = p_next)
5199
for (q = p; *q; q++)
5200
if (IS_PATH_SEPARATOR(*q))
5203
p_next = (*q == '\0' ? q : q + 1);
5206
/* empty path: current directory */
5207
if (getcwd (tmp, LT_PATHMAX) == NULL)
5208
lt_fatal ("getcwd failed");
5209
tmp_len = strlen(tmp);
5210
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5211
memcpy (concat_name, tmp, tmp_len);
5212
concat_name[tmp_len] = '/';
5213
strcpy (concat_name + tmp_len + 1, wrapper);
5217
concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5218
memcpy (concat_name, p, p_len);
5219
concat_name[p_len] = '/';
5220
strcpy (concat_name + p_len + 1, wrapper);
5222
if (check_executable(concat_name))
5227
/* not found in PATH; assume curdir */
5229
/* Relative path | not found in path: prepend cwd */
4851
5230
if (getcwd (tmp, LT_PATHMAX) == NULL)
4852
5231
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);
5232
tmp_len = strlen(tmp);
5233
concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5234
memcpy (concat_name, tmp, tmp_len);
5235
concat_name[tmp_len] = '/';
5236
strcpy (concat_name + tmp_len + 1, wrapper);
5238
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
5285
# we should really use a build-platform specific compiler
5286
# here, but OTOH, the wrappers (shell script and this C one)
5287
# are only useful if you want to execute the "real" binary.
5288
# Since the "real" binary is built for $host, then this
5289
# wrapper might as well be built for $host, too.
5290
$run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5294
trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
4911
5296
$echo > $output "\
4925
5310
Xsed='${SED} -e 1s/^X//'
4926
5311
sed_quote_subst='$sed_quote_subst'
5313
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
5314
if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5317
# Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5318
# is contrary to our usage. Disable this feature.
5319
alias -g '\${1+\"\$@\"}'='\"\$@\"'
5320
setopt NO_GLOB_SUBST
5322
case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5324
BIN_SH=xpg4; export BIN_SH # for Tru64
5325
DUALCASE=1; export DUALCASE # for MKS sh
4928
5327
# The HP-UX ksh and POSIX shell print the target directory to stdout
4929
5328
# if CDPATH is set.
4930
5329
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5806
6205
if test "$fast_install" = no && test -n "$relink_command"; then
5807
6206
if test "$finalize" = yes && test -z "$run"; then
5809
test -n "$TMPDIR" && tmpdir="$TMPDIR"
5810
tmpdir="$tmpdir/libtool-$$"
5813
if $mkdir "$tmpdir"; then
5817
$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
6207
tmpdir=`func_mktempdir`
5820
6208
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
5821
6209
outputname="$tmpdir/$file"
5822
6210
# Replace the output file specification.
5823
relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
6211
relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
5825
6213
$show "$relink_command"
5826
6214
if $run eval "$relink_command"; then :