Skip to content

Commit

Permalink
build-sys: Properly order install dependencies of pylibmount
Browse files Browse the repository at this point in the history
Introduce a dependency so that libmount.so is installed before
pylibmount.so, so that when libtool tries to relink it, it can find
libmount.so in the destdir.

We introduce this additional make rule through an AC_SUBST variable, to
prevent automake from trying to interpret that.  This trick has been
suggested in http://stackoverflow.com/a/8643550.

This fixes a failure of `make install DESTDIR=...` when trying to relink
pylibmount against libmount.la.  libtool will look for libmount.so under
${DESTDIR}/${libdir} in that case, but if it is not yet present there,
libtool assumes it is a system installed library and use -lmount
instead, which causes the following failure if libmount is not installed
on the base system yet:

  libtool: install: warning: relinking `pylibmount.la'
  libtool: install: (... libtool --mode=relink gcc -o pylibmount.la \
        -rpath /usr/lib/python2.7/dist-packages/libmount \
        libmount/python/*.lo libmount.la ... -lpython2.7 \
        -inst-prefix-dir /path/to/destdir)
  /usr/bin/ld: cannot find -lmount
  collect2: error: ld returned 1 exit status
  libtool: install: error: relink `pylibmount.la' ...
  make[3]: *** [install-pylibmountexecLTLIBRARIES] Error 1

This seems to be a previously encountered issue, since automake includes
a hack to insert such a dependency rule to install all libLTLIBRARIES
before attempting to install binPROGRAMS, initially introduced in the
commit below:
http://git.savannah.gnu.org/cgit/automake.git/commit/?id=bd4a1d5ad1a72fa780a8b7fd6c365a5dad2e6220

Also related bug from Ubuntu tracker:
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1442076

Tested that `make install` starts working again after this commit, even
when libmount-dev is not installed on the system.  Also confirmed that
`make distcheck` is now functional.

Confirmed that the all the files expected in the Python directory (both
__init__.py and pylibmount.so) are present after an install.

Tested that parallel install works, the dependency is always respected
since it's explicit.

Inspected the generated Makefile and confirmed that the definition of
install-pylibmountexecLTLIBRARIES (generated by automake) and the
explicit dependency we introduced are both present.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
  • Loading branch information
filbranden committed Feb 5, 2016
1 parent d54eb46 commit 324330a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile.am
Expand Up @@ -96,6 +96,14 @@ include bash-completion/Makemodule.am

include tests/Makemodule.am

# pylibmountexec module must be installed after usrlib_exec libraries,
# otherwise the libtool relink step will fail to find libmount.la and
# will try -lmount which is possibly not available.
#
# So introduce this dependency rule:
# install-pylibmountexecLTLIBRARIES: install-usrlib_execLTLIBRARIES
@verbatim_pylibmount_dependency@

#
# Don't rely on configure.ac AC_CONFIG_FILES for install paths.
#
Expand Down
12 changes: 12 additions & 0 deletions configure.ac
Expand Up @@ -1918,6 +1918,18 @@ UL_REQUIRES_HAVE([pylibmount], [libpython], [libpython])
UL_REQUIRES_BUILD([pylibmount], [libmount])
AM_CONDITIONAL([BUILD_PYLIBMOUNT], [test "x$build_pylibmount" = "xyes"])

# We need to introduce a verbatim dependency into the Makefile, without automake
# trying to interpret it, so push it as a AM_SUBST_NOTMAKE variable.
verbatim_pylibmount_dependency='

# pylibmountexec module must be installed after usrlib_exec libraries,
# otherwise the libtool relink step will fail to find libmount.la and
# will try -lmount which is possibly not available.
install-pylibmountexecLTLIBRARIES: install-usrlib_execLTLIBRARIES

'
AC_SUBST([verbatim_pylibmount_dependency])
AM_SUBST_NOTMAKE([verbatim_pylibmount_dependency])

AC_ARG_ENABLE([pg-bell],
AS_HELP_STRING([--disable-pg-bell], [let pg not ring the bell on invalid keys]),
Expand Down

0 comments on commit 324330a

Please sign in to comment.