diff --git a/ChangeLog b/ChangeLog index 0680ba9e..43d01f68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,8 +39,180 @@ (func_convert_path_msys_to_cygwin): New function. (func_convert_path_nix_to_cygwin): New function. +2010-08-28 Ralf Wildenhues + + Fix symlist variable path to use _WIN32 instead of __WINDOWS__. + * libltdl/config/ltmain.m4sh, libltdl/libltdl/lt_system.h, + libltdl/m4/libtool.m4, tests/demo/foo.h, tests/pdemo/foo.h: + Change __WINDOWS__ to _WIN32. + Report by Charles Wilson. + + Add $pic_flag to archive_cmds and archive_expsym_cmds. + * libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS) + + [GNU ld, netbsd]: Add $pic_flag if ELF. + [GNU ld, solaris]: Likewise. + [GNU ld, default case]: Likewise. + [!GNU ld, freebsd, dragonfly]: Add $pic_flag. + [!GNU ld, GCC, hpux9]: Add $pic_flag. + [!GNU ld, GCC, hpux10]: Replace -fPIC with $pic_flag + [!GNU ld, GCC, hpux11, !hppa*64]: Replace -fPIC with $pic_flag. + [!GNU ld, GCC, irix5, irix6, nonstopux]: Add $pic_flag. + [!GNU ld, GCC, osf4, osf5]: Likewise. + [!GNU ld, GCC, solaris]: Likewise. + (_LT_LANG_CXX_CONFIG) + [hpux9]: Add $pic_flag if $GXX. + [hpux10, hpux11, !hppa*64]: Replace -fPIC with $pic_flag. + [irix5, irix6]: Add $pic_flag if $GXX. + [osf4, osf5]: Likewise. + [solaris]: Add $pic_flag if $GXX and not GCC 2.7. + + Uniform const'ness of symlist variable lt_preloaded_symbols. + On some systems, lt_preloaded_symbols may not be declared + const due to relocation issues. C99 requires qualification to + match for compatible declarations, so ensure we declare + const'ness in the same way everywhere; link-time optimization + may otherwise rightfully complain about inconsistencies. + Since ltdl.h may not depend upon config.h, rely on system + defines for choosing const'ness. + * NEWS: Update. + * doc/libtool.texi (Dlpreopening): Document this issue. + * libltdl/config/ltmain.m4sh (func_generate_dlsyms): + [__WINDOWS__, __CYGWIN__, _WIN32_WCE]: Define LT_DLSYM_CONST + according to system defines. Remove old shell cruft. Use + LT_DLSYM_CONST for lt_${my_prefix}_LTX_preloaded_symbols. + * libltdl/libltdl/lt_system.h (LT_DLSYM_CONST): Likewise, + define LT_DLSYM_CONST according to system defines. + * tests/demo/foo.h (LT_DLSYM_CONST): Likewise. + * tests/pdemo/foo.h (LT_DLSYM_CONST): Likewise. + * tests/demo/dlmain.c (lt_dlsymlist): Use LT_DLSYM_CONST. + * tests/pdemo/longer_file_name_dlmain.c (lt_dlsymlist): + Likewise. + * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Likewise + for configure test code. + * libltdl/ltdl.c (preloaded_symbols): Use LT_DLSYM_CONST. + * libltdl/ltdl.h (LTDL_SET_PRELOADED_SYMBOLS): Likewise. + +2010-08-28 Dave Korn + + Ensure cwrapper magic string is not optimized away. + * libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src): + Declare MAGIC_EXE as volatile. + Report by Charles Wilson. + +2010-08-28 Ralf Wildenhues + + Fix quoting in non-XSI func_xform, for IRIX sh. + * libltdl/config/ltmain.m4sh (func_xform): Remove spurious extra + M4 quotes. + + Fix response file test for unreliable exit status of IRIX ar. + * libltdl/m4/libtool.m4 (_LT_PROG_AR): IRIX ar will not fail + over a command-line argument specifying a nonexistent file (such + as `@FILE'), so ensure failure with a reponse file containing + a nonexistent file. Also, use lt_* variable prefix for + temporary variables. + + Fix AC_LANG_PROGRAM warnings from git Autoconf. + * libltdl/m4/libtool.m4 (_LT_SYS_MODULE_PATH_AIX): Fix + underquoted AC_LANG_PROGRAM call. + (LT_PROG_AR): Use AC_LANG_PROGRAM. + (_LT_LINKER_SHLIBS) [irix, GCC]: Use the right source for the + given language. + * NEWS: Update. + +2010-08-22 Ralf Wildenhues + + fix AIX testsuite regression + * libltdl/config/ltmain.m4sh (func_resolve_sysroot): Partly + revert v2.2.10-83-gc45a288: Do not absolutize path here, only do + sysroot replacement. + (func_mode_link): Adjust. + +2010-08-22 Charles Wilson + + fix --mode=finish + * libltdl/config/ltmain.m4sh (func_mode_finish): Invert then/else + blocks of the "if $opt_dry_run" conditional. + +2010-08-15 Paolo Bonzini + + improve code for sysroot --mode=finish + * libltdl/config/ltmain.m4sh (func_mode_finish): Change sysroot_regex + and sysroot_cmd delimiter from pipe to slash. Wrap the entire for + loop with "if $opt_dry_run...fi" and print an explanatory message + for the --dry-run case. + +2010-08-12 Paolo Bonzini + + add libtool --mode=finish mode for sysroot + * doc/libtool.texi (Finish mode): Document behavior when *.la files + are passed. + * libltdl/config/ltmain.m4sh (func_mode_finish): Eliminate sysroot + or `=' signs representing it from files in $libs. + * tests/sysroot.at (SYSROOT_TESTS): Test for presence of sysroot + references before running libtool --mode=finish, and for absence + afterwards. + + reorganize parsing of --mode=finish arguments + * libltdl/config/ltmain.m4sh (func_mode_finish): Split arguments for + directories and *.la files. + + fix sysroot handling for deplibs of preopened libtool libs + * libltdl/config/ltmain.m4sh: Pass $dependency_libs of preopened libtool + through func_resolve_sysroot. + + fix sysroot tests to pass on Fedora 13 + * tests/sysroot.at: Link $prefix/include into the sysroot as well, as + required by newer GCC. + +2010-07-29 Paolo Bonzini + + initial version of the NEWS entry + * NEWS: Document sysroot support. + + add sysroot test + * Makefile.am (TESTSUITE_AT): Add tests/sysroot.at. + * tests/sysroot.at: New. + + emit sysrooted paths when installing .la files + * libltdl/config/ltmain.m4sh (func_replace_sysroot): New. + (func_mode_link): Prepend paths in $libdir with the sysroot. Further, + replace the sysroot with = (using func_replace_sysroot) whenever + such a path is written in a .la file. + + process postdeps to include sysrooted paths + * libltdl/m4/libtool.m4 (_LT_FUNC_STRIPNAME_CNF): New (from Charles Wilson). + (_LT_SYS_HIDDEN_LIBDEPS): Require it. Use func_stripname_cnf to convert + sysroot (-L= and -R=) usage in postdeps. Adjust the code because -L, -R + and -l flags will now always be separated from the rest of the argument. + + handle sysrooted paths when reading dependencies to la files + * libltdl/config/ltmain.m4sh (func_mode_execute, func_mode_install, + func_mode_link): Whenever a .la file occurs in another .la file, + expand the sysroot path in it. + +2010-07-28 Paolo Bonzini + + teach libtool -L= and -R= + * libltdl/config/ltmain.m4sh (func_resolve_sysroot): New. + (func_mode_link): Always pass result of stripping -L and -R to + func_resolve_sysroot before using it. Remove absolute path expansion + when func_resolve_sysroot subsumes it. Expand sysroot in -rpath. + When processing dependent libraries also resolve sysroot paths there. + + add --with-sysroot + * libltdl/m4/libtool.m4 (_LT_HOST_NONCANONICAL, _LT_WITH_SYSROOT): New. + (LT_SETUP): Require _LT_WITH_SYSROOT. + + handle sysroot flags + * libltdl/config/ltmain.m4sh (func_mode_link): Recognize --sysroot + option. + 2010-08-27 Ralf Wildenhues + * NEWS: Only bootstrapping needs new Automake and Autoconf. + check-interactive and check-noninteractive for both testsuites. * Makefile.am (COMMON_TESTS, TESTS): Split into ... (NONINTERACTIVE_TESTS, INTERACTIVE_TESTS): ... these new diff --git a/Makefile.am b/Makefile.am index 7dad62ec..de3eafe6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -504,7 +504,8 @@ TESTSUITE_AT = tests/testsuite.at \ tests/cmdline_wrap.at \ tests/pic_flag.at \ tests/darwin.at \ - tests/deplibs-mingw.at + tests/deplibs-mingw.at \ + tests/sysroot.at EXTRA_DIST += $(srcdir)/$(TESTSUITE) $(TESTSUITE_AT) $(srcdir)/tests/package.m4 diff --git a/NEWS b/NEWS index 2357a8ea..688bdca6 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,16 @@ New in 2.2.12 2010-08-??: git version 2.2.11a, Libtool team: * New features: + - Sysroot support. This allows you to build cross-compiled packages + with the same prefix that will be used on the destination machine, + and still find dependent libraries under the compiler's "sysroot". + Without sysroot support, paths internal to the build system may leak + into the product of the build. + + Sysroot support is disabled unless the --with-sysroot configure + option is passed to configure, because .la files generated with + sysroot support will _not_ be usable in general with older Libtools. + - On non-cygwin Windows systems, we now lookup potential library file names without regard to file name case. - The old testsuite now uses the `parallel-tests' Automake test driver @@ -12,9 +22,9 @@ New in 2.2.12 2010-08-??: git version 2.2.11a, Libtool team: * Important incompatible changes: - - Autoconf 2.62 and Automake 1.11.1 or newer are now required for building - Libtool. For using Libtool in your own projects, Autoconf 2.59 and - Automake 1.9.6 should still work. + - Autoconf 2.62 and Automake 1.11.1 or newer are now required for + bootstrapping Libtool. For using Libtool in your own projects, + Autoconf 2.59 and Automake 1.9.6 should still work. * Changes in supported systems or compilers: @@ -27,6 +37,9 @@ New in 2.2.12 2010-08-??: git version 2.2.11a, Libtool team: - The `check-interactive' and `check-noninteractive' convenience make targets now also work for the old testsuite. + - Warnings from Autoconf v2.67-36-g1e604ec about incomplete programs + passed to AC_*_IFELSE tests have been fixed. + - On IRIX, the test for -Wl,-exported_symbol now also works with gfortran. New in 2.2.10 2010-06-10: git version 2.2.9a, Libtool team: @@ -70,6 +83,9 @@ New in 2.2.7b 2010-05-20: git version 2.2.7a, Libtool team: options that begin with '--lt-*' from the argument list before launching (uninstalled) programs. Any '--lt-*' option on the command line not recognized by the wrapper will result in an error. + - The type of the symbol lists variables (lt_*_LTX_preloaded_symbols) has + been fixed in the manual and in a couple of tests to match the actual + implementation. * Changes in supported systems or compilers: diff --git a/doc/libtool.texi b/doc/libtool.texi index f042a78a..a3f1c59e 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -1723,12 +1723,18 @@ commands are also completed. @cindex finish mode @cindex mode, finish -@dfn{Finish} mode helps system administrators install libtool libraries -so that they can be located and linked into user programs. +@dfn{Finish} mode has two functions. One is to help system administrators +install libtool libraries so that they can be located and linked into +user programs. To invoke this functionality, pass the name of a library +directory as @var{mode-arg}. Running this command may require superuser +privileges, and the @option{--dry-run} option may be useful. -Each @var{mode-arg} is interpreted as the name of a library directory. -Running this command may require superuser privileges, so the -@option{--dry-run} option may be useful. +The second is to facilitate transferring libtool libraries to a native +compilation environment after they were built in a cross-compilation +environment. Cross-compilation environments may rely on recent libtool +features, and running libtool in finish mode will make it easier to +work with older versions of libtool. This task is performed whenever +the @var{mode-arg} is a @samp{.la} file. @node Uninstall mode @section Uninstall mode @@ -3415,6 +3421,9 @@ The last element of all has a @var{name} and @var{address} of To facilitate inclusion of symbol lists into libraries, @code{lt_preloaded_symbols} is @samp{#define}d to a suitably unique name in @file{ltdl.h}. + +This variable may not be declared @code{const} on some systems due to +relocation issues. @end deftypevar Some compilers may allow identifiers that are not valid in ANSI C, such diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 17006ea5..32860c77 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -191,7 +191,7 @@ func_lo2o () # func_xform libobj-or-source func_xform () { - func_xform_result=`$ECHO "${1}" | $SED 's/\.[[^.]]*$/.lo/'` + func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation @@ -546,6 +546,37 @@ func_source () } +# func_resolve_sysroot PATH +# Replace a leading = in PATH with a sysroot. Store the result into +# func_resolve_sysroot_result +func_resolve_sysroot () +{ + func_resolve_sysroot_result=$1 + case $func_resolve_sysroot_result in + =*) + func_stripname '=' '' "$func_resolve_sysroot_result" + func_resolve_sysroot_result=$lt_sysroot$func_stripname_result + ;; + esac +} + +# func_replace_sysroot PATH +# If PATH begins with the sysroot, replace it with = and +# store the result into func_replace_sysroot_result. +func_replace_sysroot () +{ + case "$lt_sysroot:$1" in + ?*:"$lt_sysroot"*) + func_stripname "$lt_sysroot" '' "$1" + func_replace_sysroot_result="=$func_stripname_result" + ;; + *) + # Including no sysroot. + func_replace_sysroot_result=$1 + ;; + esac +} + # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. @@ -1691,6 +1722,9 @@ func_mode_execute () dir= case $file in *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" @@ -1808,15 +1842,52 @@ test "$opt_mode" = execute && func_mode_execute ${1+"$@"} func_mode_finish () { $opt_debug - libdirs="$nonopt" + libs= + libdirs= admincmds= - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - func_append libdirs " $dir" - done + for opt in "$nonopt" ${1+"$@"} + do + if test -d "$opt"; then + func_append libdirs " $opt" + elif test -f "$opt"; then + if func_lalib_unsafe_p "$opt"; then + func_append libs " $opt" + else + func_warning "\`$opt' is not a valid libtool archive" + fi + + else + func_fatal_error "invalid argument \`$opt'" + fi + done + + if test -n "$libs"; then + if test -n "$lt_sysroot"; then + sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` + sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" + else + sysroot_cmd= + fi + + # Remove sysroot references + if $opt_dry_run; then + for lib in $libs; do + echo "removing references to $lt_sysroot and \`=' prefixes from $lib" + done + else + tmpdir=`func_mktempdir` + for lib in $libs; do + sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ + > $tmpdir/tmp-la + mv -f $tmpdir/tmp-la $lib + done + ${RM}r "$tmpdir" + fi + fi + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. @@ -1835,49 +1906,51 @@ func_mode_finish () # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - $ECHO " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" - $ECHO " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $ECHO " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo + $ECHO " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo - echo "See any operating system documentation about shared libraries for" - case $host in - solaris2.[6789]|solaris2.1[0-9]) - echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" - echo "pages." - ;; - *) - echo "more information, such as the ld(1) and ld.so(8) manual pages." - ;; - esac - echo "----------------------------------------------------------------------" + echo "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" + echo "pages." + ;; + *) + echo "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + echo "----------------------------------------------------------------------" + fi exit $EXIT_SUCCESS } @@ -2042,6 +2115,9 @@ func_mode_install () ;; *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" @@ -2388,6 +2464,18 @@ extern \"C\" { #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + /* External symbol declarations for the compiler. */\ " @@ -2529,26 +2617,9 @@ typedef struct { const char *name; void *address; } lt_dlsymlist; -" - case $host in - *cygwin* | *mingw* | *cegcc* ) - echo >> "$output_objdir/$my_dlsyms" "\ -/* DATA imports from DLLs on WIN32 con't be const, because - runtime relocations are performed -- see ld's documentation - on pseudo-relocs. */" - lt_dlsym_const= ;; - *osf5*) - echo >> "$output_objdir/$my_dlsyms" "\ -/* This system does not cope well with relocations in const data */" - lt_dlsym_const= ;; - *) - lt_dlsym_const=const ;; - esac - - echo >> "$output_objdir/$my_dlsyms" "\ -extern $lt_dlsym_const lt_dlsymlist +extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; -$lt_dlsym_const lt_dlsymlist +LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," @@ -3405,7 +3476,7 @@ void lt_dump_script (FILE *f); EOF cat </dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + AC_MSG_RESULT([${with_sysroot}]) + AC_MSG_ERROR([The sysroot must be an absolute path.]) + ;; +esac + + AC_MSG_RESULT([${lt_sysroot:-no}]) +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl +[dependent libraries, and in which our libraries should be installed.])]) + # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], @@ -1324,12 +1358,17 @@ _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no - AC_COMPILE_IFELSE([[int some_variable = 0;]], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst - am_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst' - AC_TRY_EVAL([am_ar_try]) + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst' + AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then - lt_cv_ar_at_file=@ + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + AC_TRY_EVAL([lt_ar_try]) + if test "$ac_status" -ne 0; then + lt_cv_ar_at_file=@ + fi fi rm -f conftest.* libconftest.a ]) @@ -3609,6 +3648,18 @@ _LT_EOF if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t@_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT@&t@_DLSYM_CONST +#else +# define LT@&t@_DLSYM_CONST const +#endif + #ifdef __cplusplus extern "C" { #endif @@ -3620,7 +3671,7 @@ _LT_EOF cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ -const struct { +LT@&t@_DLSYM_CONST struct { const char *name; void *address; } @@ -4683,8 +4734,8 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; @@ -4702,8 +4753,8 @@ _LT_EOF _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -4749,8 +4800,8 @@ _LT_EOF *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -5026,7 +5077,7 @@ _LT_EOF # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no @@ -5034,7 +5085,7 @@ _LT_EOF hpux9*) if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi @@ -5050,7 +5101,7 @@ _LT_EOF hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi @@ -5074,10 +5125,10 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else @@ -5124,15 +5175,24 @@ _LT_EOF irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE(int foo(void) {}, - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - ) + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], + [C++], [[int foo (void) { return 0; }]], + [Fortran 77], [[ + subroutine foo + end]], + [Fortran], [[ + subroutine foo + end]])])], [ + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + ]) LDFLAGS="$save_LDFLAGS" else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' @@ -5218,7 +5278,7 @@ _LT_EOF osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' @@ -5237,9 +5297,9 @@ _LT_EOF _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) @@ -6060,7 +6120,7 @@ if test "$_lt_caught_CXX_error" != yes; then ;; *) if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no @@ -6131,10 +6191,10 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi @@ -6175,9 +6235,9 @@ if test "$_lt_caught_CXX_error" != yes; then *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes @@ -6455,7 +6515,7 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac @@ -6542,9 +6602,9 @@ if test "$_lt_caught_CXX_error" != yes; then if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when @@ -6687,6 +6747,29 @@ AC_LANG_POP ])# _LT_LANG_CXX_CONFIG +# _LT_FUNC_STRIPNAME_CNF +# ---------------------- +# func_stripname_cnf prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# +# This function is identical to the (non-XSI) version of func_stripname, +# except this one can be used by m4 code that may be executed by configure, +# rather than the libtool script. +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl +AC_REQUIRE([_LT_DECL_SED]) +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) +func_stripname_cnf () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; + esac +} # func_stripname_cnf +])# _LT_FUNC_STRIPNAME_CNF + # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose @@ -6695,6 +6778,7 @@ AC_LANG_POP # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= @@ -6765,13 +6849,22 @@ if AC_TRY_EVAL(ac_compile); then test $p = "-R"; then prev=$p continue - else - prev= fi + # Expand the sysroot to ease extracting the directories later. + if test -z "$prev"; then + case $p in + -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; + -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; + -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; + esac + fi + case $p in + =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; + esac if test "$pre_test_object_deps_done" = no; then - case ${prev}${p} in - -L* | -R*) + case ${prev} in + -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. @@ -6791,6 +6884,7 @@ if AC_TRY_EVAL(ac_compile); then _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi + prev= ;; *.$objext) diff --git a/tests/demo/dlmain.c b/tests/demo/dlmain.c index c970998d..8c8be09e 100644 --- a/tests/demo/dlmain.c +++ b/tests/demo/dlmain.c @@ -34,7 +34,7 @@ typedef struct lt_ptr_t address; } lt_dlsymlist; -extern const lt_dlsymlist lt_preloaded_symbols[]; +extern LT_DLSYM_CONST lt_dlsymlist lt_preloaded_symbols[]; int main () diff --git a/tests/demo/foo.h b/tests/demo/foo.h index 287f9c31..167096a6 100644 --- a/tests/demo/foo.h +++ b/tests/demo/foo.h @@ -1,6 +1,6 @@ /* foo.h -- interface to the libfoo library - Copyright (C) 1996-1999 Free Software Foundation, Inc. + Copyright (C) 1996-1999, 2010 Free Software Foundation, Inc. Written by Gord Matzigkeit, 1996 This file is part of GNU Libtool. @@ -62,6 +62,18 @@ or obtained by writing to the Free Software Foundation, Inc., # define lt_ptr_t char* #endif +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + /* Silly constants that the functions return. */ #define HELLO_RET 0xe110 #define FOO_RET 0xf00 diff --git a/tests/pdemo/foo.h b/tests/pdemo/foo.h index f09db19f..a2b2a4ac 100644 --- a/tests/pdemo/foo.h +++ b/tests/pdemo/foo.h @@ -1,6 +1,6 @@ /* foo.h -- interface to the libfoo library - Copyright (C) 1996-1999 Free Software Foundation, Inc. + Copyright (C) 1996-1999, 2010 Free Software Foundation, Inc. Written by Gord Matzigkeit, 1996 This file is part of GNU Libtool. @@ -61,6 +61,18 @@ or obtained by writing to the Free Software Foundation, Inc., # define lt_ptr_t char* #endif +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + #ifdef __CYGWIN32__ # ifdef LIBFOO_DLL /* need some (as yet non-existant) automake magic to tell diff --git a/tests/pdemo/longer_file_name_dlmain.c b/tests/pdemo/longer_file_name_dlmain.c index ef1e4c5b..ad223dce 100644 --- a/tests/pdemo/longer_file_name_dlmain.c +++ b/tests/pdemo/longer_file_name_dlmain.c @@ -34,7 +34,7 @@ typedef struct lt_ptr_t address; } lt_dlsymlist; -extern const lt_dlsymlist lt_preloaded_symbols[]; +extern LT_DLSYM_CONST lt_dlsymlist lt_preloaded_symbols[]; int main (int argc, char **argv) diff --git a/tests/sysroot.at b/tests/sysroot.at new file mode 100644 index 00000000..c0ac6d16 --- /dev/null +++ b/tests/sysroot.at @@ -0,0 +1,208 @@ +# static.at -- test flags for sysrooting -*- Autotest -*- +# +# Copyright (C) 2009 Free Software Foundation, Inc. +# Written by Paolo Bonzini, 2009 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, +# or obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#### + +m4_define([SYSROOT_TEST], [ +AT_SETUP([$1]) +AT_KEYWORDS([libtool sysroot]) + +gcc_sysroot=`$CC --print-sysroot 2> /dev/null` +if test $? != 0; then + gcc_sysroot= +fi +AT_CHECK([test -n "$gcc_sysroot" || exit 77]) + +# Detect installation prefix for the compiler +prefix= +for i in crt1.o crt2.o crti.o; do + j=`$CC --print-file-name $i 2> /dev/null` + test $? = 0 || continue + case "$j" in + $gcc_sysroot*/lib/$i) + prefix=`echo "$j" | sed "s,^$gcc_sysroot\\(.*\\)/lib/$i\$,\\1,"` + break ;; + esac +done +AT_CHECK([test -n "$prefix" || exit 77]) + +sysroot=`pwd`/sys-root + +# difficult to use AS_DIRNAME inside the AT_CHECK macro, so +# encapsulate as a shell function. +local_dirname() { + AS_DIRNAME(["$[]1"]) +} + +AT_CHECK([ +(cd "$gcc_sysroot" && find ".$prefix/bin" ".$prefix/include" ".$prefix/lib" \! -type d) | \ +while read file; do + dir=`local_dirname "$sysroot/$file"` + test -d "$dir" || mkdir -p "$dir" + rm -f "$sysroot/$file" + ln -s "$gcc_sysroot/$file" "$sysroot/$file" || \ + cp "$gcc_sysroot/$file" "$sysroot/$file" +done]) + +LDFLAGS="$LDFLAGS --sysroot=$sysroot -no-undefined" +configure_options="$configure_options --with-sysroot=$sysroot --prefix=$prefix" + +#??? +if test "$shlibpath_var" = PATH; then + configure_options="$configure_options --libdir=/$prefix/bin" +fi + +AT_CHECK([mkdir lib1 lib2 prog]) + +# Build and install package 1. +AT_DATA([lib1/configure.ac], +[[AC_INIT([lib1], [1.0]) +AM_INIT_AUTOMAKE([foreign]) +AC_PROG_CC +AC_CONFIG_SRCDIR([lib1.c]) +LT_INIT +AC_OUTPUT(Makefile) +]]) + +AT_DATA([lib1/Makefile.am], +[[lib_LTLIBRARIES = lib1.la +lib1_la_SOURCES = lib1.c +lib1_la_LDFLAGS = -rpath $(libdir) +]]) + +AT_DATA([lib1/lib1.c], +[[#include +#include +char *f(const char *s) +{ + return strdup (s); +} +]]) + +cd lib1 +LT_AT_BOOTSTRAP([], [-I $abs_top_srcdir/libltdl/m4], [ignore], + [--add-missing], [], [], [all]) + +AT_CHECK([$MAKE install DESTDIR=$sysroot], [0], [ignore], [ignore]) +AT_CHECK([test -f "$sysroot/$prefix/lib/lib1.la"]) +AT_CHECK([grep -F "$sysroot" "$sysroot/$prefix/lib/lib1.la"], [1]) +cd .. + +# Build and install package 2. +AT_DATA([lib2/configure.ac], +[[AC_INIT([lib2], [1.0]) +AM_INIT_AUTOMAKE([foreign]) +AC_PROG_CC +AC_CONFIG_SRCDIR([lib2.c]) +LT_INIT +sysroot=$with_sysroot +AC_SUBST([sysroot]) +AC_OUTPUT(Makefile) +]]) + +AT_DATA([lib2/Makefile.am], +[[lib_LTLIBRARIES = lib2.la +lib2_la_SOURCES = lib2.c +lib2_la_LDFLAGS = -rpath $(libdir) +lib2_la_LIBADD = $2]1[$3 +]]) + +AT_DATA([lib2/lib2.c], +[[#include +#include +#include +extern char *f(const char *s); +char *g(const char *s) +{ + char *q = f(s); + puts (q); + return q; +} +]]) + +cd lib2 +LT_AT_BOOTSTRAP([], [-I $abs_top_srcdir/libltdl/m4], [ignore], + [--add-missing], [], [], [all]) + +AT_CHECK([$MAKE install DESTDIR=$sysroot], [0], [ignore], [ignore]) +AT_CHECK([test -f $sysroot/$prefix/lib/lib2.la]) +AT_CHECK([grep -F "$sysroot" "$sysroot/$prefix/lib/lib2.la"], [1]) +cd .. + +# Build and install a program. +AT_DATA([prog/configure.ac], +[[AC_INIT([prog], [1.0]) +AM_INIT_AUTOMAKE([foreign]) +AC_PROG_CC +AC_CONFIG_SRCDIR([prog.c]) +LT_INIT +sysroot=$with_sysroot +AC_SUBST([sysroot]) +AC_OUTPUT(Makefile) +]]) + +AT_DATA([prog/Makefile.am], +[[bin_PROGRAMS = prog +prog_SOURCES = prog.c +prog_LDADD = $2]2[$3 +]]) + +AT_DATA([prog/prog.c], +[[#include +#include +#include +extern char *g(const char *s); +int main() +{ + char *q = g("hello world"); + free (q); + return 0; +} +]]) + +cd prog +LT_AT_BOOTSTRAP([], [-I $abs_top_srcdir/libltdl/m4], [ignore], + [--add-missing], [], [], [all]) + +AT_CHECK([$MAKE install DESTDIR=$sysroot], [0], [ignore], [ignore]) +AT_CHECK([test -f $sysroot/$prefix/bin/prog$EXEEXT]) +AT_CHECK([grep -F "$sysroot" "$sysroot/$prefix/bin/prog$EXEEXT"], [1]) +AT_CHECK([grep "'.*=" $sysroot/$prefix/lib/lib2.la], [0], [ignore]) +AT_CHECK([./libtool --mode=finish $sysroot/$prefix/lib/lib@<:@12@:>@.la], [0], [ignore]) +AT_CHECK([grep "'.*=" $sysroot/$prefix/lib/lib@<:@12@:>@.la], [1]) + +# missing tests +# 1) pass absolute .la files +# 2) pass absolute -L +# 2) pass relative .la files + +cd .. +AT_CLEANUP +]) + +AT_BANNER([sysroot tests]) +SYSROOT_TEST([-L=.../lib -l], [-L=$(libdir) -l], []) +SYSROOT_TEST([-L SYSROOT/.../lib -l], [-L$(sysroot)$(libdir) -l], []) +SYSROOT_TEST([SYSROOT/.../*.la], [$(sysroot)$(libdir)/lib], [.la]) + +dnl This one does not make sense. +dnl SYSROOT_TEST([=.../*.la], [=$(libdir)/lib], [.la])