OSDN Git Service

libreadline is a problematic library. Autoconf adds a block to the generated configur...
authorDavid Cantrell <dcantrell@redhat.com>
Wed, 14 Mar 2007 18:55:49 +0000 (14:55 -0400)
committerDavid Cantrell <dcantrel@mortise.boston.redhat.com>
Wed, 2 May 2007 18:17:27 +0000 (14:17 -0400)
libreadline specifically has unresolved symbols on at least Fedora and RHEL.  Why?  Well, the developer can choose to provide libtermcap, libncurses, or libncursesw (wide-char support) at compile time which all satisfy the curses API dependency that libreadline has.  When the parted configure script runs, it fails on readline because the --as-needed flag causes the linker to not include libncurses even though we already have that on the link line.

My solution is to remove the --as-needed flag when we scan for libreadline and then later check for rl_completion_matches() in libreadline.

configure.ac

index 86adcf4..92a8e80 100644 (file)
@@ -304,7 +304,12 @@ Note: (n)curses also seems to work as a substitute for termcap.  This was
 fi
 
 dnl Check for readline
+dnl NOTE: We need to remove the gl_cv_ignore_unused_libraries flag if we
+dnl detected one earlier.  libreadline on some platforms (e.g., RHEL and
+dnl Fedora) is left with 
 if test "$with_readline" = yes; then
+   OLD_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$(echo $LDFLAGS | sed -e 's/-Wl,--as-needed//g' | sed -e 's/-Wl,-z,ignore//g' | sed -e 's/-z\ ignore//g')"
        OLD_LIBS="$LIBS"
        LIBS="$LIBS $PARTED_LIBS"
        AC_CHECK_LIB(readline, readline,
@@ -322,6 +327,7 @@ package as well (which may be called readline-devel or something similar).
                $PARTED_LIBS
        )
        LIBS="$OLD_LIBS"
+   LDFLAGS="$OLD_LDFLAGS"
 fi
 
 AC_SUBST(PARTED_LIBS)
@@ -453,11 +459,17 @@ dnl Checks for library functions.
 AC_CHECK_FUNCS(sigaction)
 AC_CHECK_FUNCS(getuid)
 
+dnl NOTE: We need to remove the gl_cv_ignore_unused_libraries flag if we
+dnl detected one earlier.  libreadline on some platforms (e.g., RHEL and
+dnl Fedora) is left with 
 if test "$with_readline" = yes; then
+   OLD_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$(echo $LDFLAGS | sed -e 's/-Wl,--as-needed//g' | sed -e 's/-Wl,-z,ignore//g' | sed -e 's/-z\ ignore//g')"
        OLD_LIBS="$LIBS"
        LIBS="$LIBS $PARTED_LIBS -lreadline"
        AC_CHECK_FUNCS(rl_completion_matches)
        LIBS="$OLD_LIBS"
+   LDFLAGS="$OLD_LDFLAGS"
 fi
 
 AC_CHECK_FUNCS(canonicalize_file_name)