Hi,

now I've managed to get 'make install DESTDIR=...' working on
hppa-hpux10 and hppa-hpux11 with libtool.

With this patch, 10 tests ("demo-nofast.test" to "depdemo-unst.test")
change from SKIP to PASS, and both "Simple DESTDIR install" and "DESTDIR
with in-package deplibs" (destdir.at) change from "expected failure" to
"ok", for the 32bit hppa environments marked with "*" below.
No other tests do change their result.

The most important part of the fix is already suggested in comments
around 'hardcode_minus_L=yes', as the encoded library path is used as
fallback location for a specific library when runpath lookup fails.
As this isn't really 'hardcoding' in libtool's sense, hardcode_minus_L
can safely be set to 'no' IMO, opening the door for DESTDIR support.

This does require to use 'chatr' in demo-hardcode.test to not get false
positives when testing for hardcoded path (more comments inside).

Another minor one was that there is no need to pass
"+b $install_libdir", as the linker ignores subsequent "+b" values.

The patch has been tested in these HP-UX environments (as well as on
linux and aix, without any test result changes there):

arch  HP-UX bits * compiler
------------------------------
hppa  10.20  32  * gcc-3.0.1
hppa  10.20  32  * HP C Compiler A.10.32.30 (with CXX=false)

hppa  11.11  32  * gcc-3.3.4
hppa  11.11  32  * "HP C Compiler PHCO_27774" + "HP ANSI C++ A.03.52"
hppa  11.11  64    "HP C Compiler PHCO_27774" + "HP ANSI C++ A.03.52"

ia64  11.23  32    gcc-4.2.4
ia64  11.23  32    HP aC++/ANSI C A.06.10 (both cc/aCC)
ia64  11.23  64    gcc-4.2.4
ia64  11.23  64    HP aC++/ANSI C A.06.10 (both cc/aCC

hppa  11.31  32  * gcc-4.3.1
hppa  11.31  32  * "HP C Compiler PHCO_27774" + "HP ANSI C++ A.03.85"
hppa  11.31  64    "HP C Compiler PHCO_27774" + "HP ANSI C++ A.03.85"


The patch is created and tested using recent libtool.master - I'm just
unsure about the ChangeLog heading (already inside).

Setting 'hardcode_minus_L=no' can be dropped eventually, as it is the
default and a similar comment is in demo-hardcode.test now.

Thanks!

/haubi/
diff --git a/ChangeLog b/ChangeLog
index b01a42f..4999ea3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-05-26  Michael Haubenwallner <michael.haubenwall...@salomon.at>
+
+	Fix DESTDIR install for hppa-hpux10 and hppa-hpux11.
+	* libltdl/m4/libtool.m4: Set hardcode_into_libs=yes.
+	Set hardcode_minus_L back to 'no', as the stored path only is used as
+	fallback when the library is not found via runpath.
+	Do not set runpath with "+b $install_libdir", as this would ignore the
+	collected runpath subsequently set with "+b $libdir".
+	Set hardcode_libdir_flag_spec_ld along direct use of $LD only (hpux10).
+	* tests/demo-hardcode.test: Try 'chatr' to read hardcoded paths, to allow
+	for filtering out library paths being used as fallback.
+
 2009-05-05  Rainer Emrich  <r.emr...@de.tecosim.com>  (tiny change)
 	    Peter Rosin  <p...@lysator.liu.se>
 	    Ralf Wildenhues  <ralf.wildenh...@gmx.de>
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 8af17a8..df64654 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -2316,6 +2316,9 @@ hpux9* | hpux10* | hpux11*)
     ;;
   *)
     shrext_cmds='.sl'
+    case $host_os in hpux9*) ;;
+    *) hardcode_into_libs=yes ;;
+    esac
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
@@ -4713,20 +4716,20 @@ _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 -fPIC ${wl}+h ${wl}$soname -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'
+	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+	_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
       fi
       if test "$with_gnu_ld" = no; then
 	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
 	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
-	_LT_TAGVAR(hardcode_minus_L, $1)=yes
+	_LT_TAGVAR(hardcode_minus_L, $1)=no
       fi
       ;;
 
@@ -4740,7 +4743,7 @@ _LT_EOF
 	  _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 -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
@@ -4757,9 +4760,9 @@ _LT_EOF
 	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
 	  _LT_LINKER_OPTION([if $CC understands -b],
 	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
-	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
-	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
-	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'],
+	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'])],
+	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'])
 	  ;;
 	esac
       fi
@@ -4779,7 +4782,7 @@ _LT_EOF
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
-	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
+	  _LT_TAGVAR(hardcode_minus_L, $1)=no
 	  ;;
 	esac
       fi
@@ -5714,7 +5717,7 @@ if test "$_lt_caught_CXX_error" != yes; then
           *)
             _LT_TAGVAR(hardcode_direct, $1)=yes
             _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+            _LT_TAGVAR(hardcode_minus_L, $1)=no  # Not in the search PATH,
 					         # but as the default
 					         # location of the library.
             ;;
@@ -5734,7 +5737,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${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 -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -5758,7 +5761,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	            _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 -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 -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
diff --git a/tests/demo-hardcode.test b/tests/demo-hardcode.test
index 31b2e1d..da6a96d 100755
--- a/tests/demo-hardcode.test
+++ b/tests/demo-hardcode.test
@@ -39,6 +39,7 @@ func_make "hardcode"
 
 # Extra tools we might need
 : ${DUMPSTABS=dumpstabs}
+: ${CHATR=chatr}
 
 # Suck in all the hardcode_* variable settings.
 func_msg "Finding libtool.m4's guesses at hardcoding values"
@@ -70,11 +71,30 @@ for file in hc-*; do
   # Discover whether the objdir really was hardcoded.
   hardcoded=no
 
+  # hppa-hpux (SOM) stores the path of a shared library as found
+  # at linktime in the 'shared library list' of the resulting binary.
+  # When the type of such an entry is 'static', the runpath is ignored
+  # for that library. If the type is 'dynamic', the runpath is used,
+  # and we have to ignore that line when searching for hardcoded paths.
+  # For hppa64-hpux (ELF) and ia64-hpux (ELF), 'chatr' does not tell whether
+  # the shared library location is 'static' or 'dynamic', as the path
+  # component is not stored anyway when the library was found via '-L'.
+  # Additionally, aCC/cc store commandline and other information used to
+  # create object files into these (as 'ccom options', 'driver_command'),
+  # which may also lead to false positives when using 'cat'.
+  if { $CHATR $file ;} >/dev/null 2>&1; then
+    if $CHATR $file 2>/dev/null \
+       | $SED -n -e '/shared library dynamic path search/,/shared library binding/ {/^[ 	]*dynamic/!p;}' \
+       | $FGREP "$objdir" >/dev/null 2>&1; then
+       hardcoded=yes
+     else
+       hardcoded=no
+     fi
   # Solaris cc may store the command line in a debugging section,
   # which leads to false positives.  Unfortunately, Solaris strip
   # is not capable to remove the section (unlike GNU binutils strip).
   # So we use dumpstabs if it seems to work.
-  if { $DUMPSTABS -d $file; } >/dev/null 2>&1; then
+  elif { $DUMPSTABS -d $file; } >/dev/null 2>&1; then
     if $DUMPSTABS -d $file 2>/dev/null | $FGREP "$objdir" >/dev/null 2>&1; then
       hardcoded=yes
     else

Reply via email to