[buildd-tools-devel] Ubuntu patch for postgresql-debversion to build with --as-needed
Michael Bienia
michael at bienia.de
Wed Nov 17 17:28:22 UTC 2010
Hello,
the following patch was needed to get postgresql-debversion build again
after --as-needed was added to the default linker flags in Ubuntu natty.
Without this patch the configure failed at detecting libapt-pkg. The
error was that the linking failed which made configure believe that
libapt-pkg was missing:
,---- [config.log]
| configure:14508: checking for debVS in -lapt-pkg
| configure:14523: x86_64-linux-gnu-g++ -o conftest -g -O2 -Wl,-Bsymbolic-functions -lapt-pkg conftest.cpp >&5
| /tmp/ccIbnKrP.o: In function `pkgVersioningSystem::CmpVersion(char const*, char const*)':
| /usr/include/apt-pkg/version.h:53: undefined reference to `debVS'
| /usr/include/apt-pkg/version.h:53: undefined reference to `debVS'
| collect2: ld returned 1 exit status
`----
Exchanging the order of 'conftest.cpp' and '-lapt-pkg' fixes it as it
matches then the described behaviour for ld:
,----[ ld manpage; -l option ]-
| The linker will search an archive only once, at the location where
| it is specified on the command line. If the archive defines a
| symbol which was undefined in some object which appeared before the
| archive on the command line, the linker will include the
| appropriate file(s) from the archive. However, an undefined symbol
| in an object appearing later on the command line will not cause the
| linker to search the archive again.
`----
The actual change is to use LIBS instead of LDFLAGS inside configure.ac.
The patch was written by Michael Vogt.
Regards,
Michael
--- postgresql-debversion-1.0.3.orig/configure.ac
+++ postgresql-debversion-1.0.3/configure.ac
@@ -116,15 +116,15 @@
AC_SUBST([pg_contribdir])
AC_MSG_CHECKING([for debVS in -lapt-pkg])
-saved_ldflags="${LDFLAGS}"
-LDFLAGS="${LDFLAGS} -lapt-pkg"
+saved_libs="${LIBS}"
+LIBS="${LIBS} -lapt-pkg"
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <apt-pkg/debversion.h>],
[int result = debVS.CmpVersion ("1", "2");])],
[AC_MSG_RESULT([yes])
APT_PKG_LIBS="-lapt-pkg"],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([libapt-pkg (APT) is not installed, but is required by debversion])])
-LDFLAGS="${saved_ldflags}"
+LIBS="${saved_libs}"
AC_SUBST([APT_PKG_LIBS])
AM_CONDITIONAL([BUILD_DEBVERSION],
More information about the Buildd-tools-devel
mailing list