Well, I spent the last few days hacking at libtool to get it to use a
staging directory on HP-UX the way I would like. I've include patches
for version 1.5's libtool.m4 and ltmain.in. They include work done by
Ralph Schleicher, Albert Chin, and Martin Frydl in the "libtool
misfeature on HP-UX" thread a while back.

Be forewarned, my patch work is quite ugly in places and I have not
tested these on other platforms. Use at your own risk. If you use
them, you will likely get chatr errors when linking but these errors
can be ignored.

The patches accomplish the following things:

1. Make library paths dynamic instead of static.

2. When installing into a staging directory (DESTDIR is used), link
libraries against libraries installed in the staging directory first.

3. When installing into a staging directory, link programs against
libraries installed in the staging directory first. 

This last one was the hardest thing to accomplish. I first had to
disable an exit that would occur if libtool could not find the
libraries in their final locations. The warning message is printed,
but processing continues. I then had to modify the wrapper script that
is written when the the program is first linked in the build
directory. I add placeholders that allow me at install time to insert
code that checks for the existence of any requisite libraries in the
staging directory before prefixing the library's path with the
inst_prefix_dir value. 

Sincerely,
Dano Carroll
--- libtool-1.5/libtool.m4~     2003-04-14 16:58:23.000000000 -0500
+++ libtool-1.5/libtool.m4      2004-01-24 16:08:02.000000000 -0600
@@ -5412,19 +5412,23 @@
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
        case "$host_cpu" in
        hppa*64*|ia64*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib 
$libobjs $deplibs $compiler_flags'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib 
$libobjs $deplibs $compiler_flags~
+                       for i in \$deplibs ; do case \$i in /*) for j in \$i* ; do 
$echo chatr -l \$j $lib ; chatr -l \$j $lib > /dev/null ; done ;; esac ; done'
          ;;
        *)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname 
${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname 
${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags~
+                       for i in \$deplibs ; do case \$i in /*) for j in \$i* ; do 
$echo chatr -l \$j $lib ; chatr -l \$j $lib > /dev/null ; done ;; esac ; done'
          ;;
        esac
       else
        case "$host_cpu" in
        hppa*64*|ia64*)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs 
$linker_flags'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs 
$linker_flags~
+                       for i in \$deplibs ; do case \$i in /*) for j in \$i* ; do 
$echo chatr -l \$j $lib ; chatr -l \$j $lib > /dev/null ; done ;; esac ; done'
          ;;
        *)
-         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o 
$lib $libobjs $deplibs $linker_flags'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o 
$lib $libobjs $deplibs $linker_flags~
+                       for i in \$deplibs ; do case \$i in /*) for j in \$i* ; do 
$echo chatr -l \$j $lib ; chatr -l \$j $lib > /dev/null ; done ;; esac ; done'
          ;;
        esac
       fi
--- libtool-1.5/ltmain.in.bak   2003-04-14 16:58:24.000000000 -0500
+++ libtool-1.5/ltmain.in       2004-01-28 18:16:02.000000000 -0600
@@ -2401,7 +2401,20 @@
            add=
            # Finalize command for both is simple: just hardcode it.
            if test "$hardcode_direct" = yes; then
-             add="$libdir/$linklib"
+             if test "$linkmode" = prog ; then
+               # For programs I need to install placeholders for the
+               # install prefix so that it is replaced during install
+               # time
+               add="@[EMAIL PROTECTED]/[EMAIL PROTECTED]@$libdir/[EMAIL PROTECTED]@"
+             else
+               # When relinking libraries we need to pass path prefixes
+               # so that libraries interdependencies are resolved
+               if test -n "$inst_prefix_dir" && test -f 
"$inst_prefix_dir$libdir/$linklib" ; then
+                 add="$inst_prefix_dir$libdir/$linklib"
+               else
+                 add="$libdir/$linklib"
+               fi
+             fi
            elif test "$hardcode_minus_L" = yes; then
              add_dir="-L$libdir"
              add="-l$name"
@@ -4437,6 +4450,17 @@
       # Now create the wrapper script.
       $show "creating $output"
 
+      # Fix relink command for HP-UX.
+      case $host in
+       *-*-hpux10* | *-*-hpux11*)
+         if test -n "$finalize_deplibs"
+         then
+             relink_command="$relink_command ; tem=\"$finalize_deplibs\" ; for i in 
\$tem ; do case \$i in /*) for j in \$i* ; do if test -f \$j ; then $echo chatr -l \$j 
@OUTPUT@ ; chatr -l \$j @OUTPUT@ > /dev/null ; fi ; done ;; esac ; done ; $echo chatr 
+s enable @OUTPUT@ ; chatr +s enable @OUTPUT@ > /dev/null"
+         fi
+         ;;
+      esac
+
+
       # Quote the relink command for shipping.
       if test -n "$relink_command"; then
        # Preserve any variables that may affect compiler behavior
@@ -5546,11 +5570,19 @@
            libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: 
skip nested quoting test
            if test -n "$libdir" && test ! -f "$libfile"; then
              $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 
1>&2
-             finalize=no
+             # finalize=no stops linking, even if the link would succeed
+             # that is, not finding libfile in the final directory
+             # does not mean that linking will fail
+             finalize=yes
            fi
          done
 
          relink_command=
+         # This is a huge cheat. When used in an automake generated Makefile
+         # the DESTDIR environment is defined if user defines it during the
+         # installation phase. It would be better to determine inst_prefix_dir
+         # in a similar fashion to how it is determined for libraries
+         inst_prefix_dir=${DESTDIR}
          # To insure that "foo" is sourced, and not "foo.exe",
          # finese the cygwin/MSYS system by explicitly sourcing "foo."
          # which disallows the automatic-append-.exe behavior.
@@ -5579,6 +5611,16 @@
              outputname="$tmpdir/$file"
              # Replace the output file specification.
              relink_command=`$echo "X$relink_command" | $Xsed -e '[EMAIL 
PROTECTED]@%'"$outputname"'%g'`
+             # Replace the inst_prefix_dir so that paths to libraries
+             # are corrected when installing into a staging directory.
+             # This is ugly, but I need to check that the library exists
+             # in the staging area first, so that in the case of libraries
+             # that have previously been installed in the same library 
+             # library directory I don't inadvertently prefix them.
+             bt='\`'
+             relink_command=`$echo "X$relink_command" | $Xsed -e '[EMAIL 
PROTECTED]@%'"${bt}if test -f $inst_prefix_dir"'%g'`
+             relink_command=`$echo "X$relink_command" | $Xsed -e '[EMAIL 
PROTECTED]@%'" ; then $echo -n $inst_prefix_dir ; fi ; $echo -n "'%g'`
+             relink_command=`$echo "X$relink_command" | $Xsed -e '[EMAIL 
PROTECTED]@%'"${bt}"'%g'`
 
              $show "$relink_command"
              if $run eval "$relink_command"; then :
_______________________________________________
Libtool mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/libtool

Reply via email to