2

I am currently trying to build and install a PAM module using autotools. While the building process goes smoothly, the install target does not behave quite as I'd like it to.

$ make install
bash ../libtool --mode=install install -c pam_mymodule.la '/usr/local/lib'

In the above piece of output, I removed absolute paths to GNU executables.

Two things are bothering me in this call:

  • make tries to move the pam_mymodule.la file, while I'd rather like it to move the .libs/pam_mymodule.so file.
  • make tries to move it into /usr/local/lib, while /lib/security is a more appropriate choice for PAM modules.

How can I change the install configuration?

John WH Smith
  • 2,743
  • 1
  • 21
  • 31
  • Related: http://stackoverflow.com/questions/8669303/gnu-autotools-install-binaries-into-bin-sbin-usr-bin-and-usr-sbin-intera – ptomato Sep 26 '14 at 07:19

1 Answers1

4

To address your two things in order:

  • The libtool script intercepts that install instruction and also installs the .so file in the appropriate place.

  • It's putting it in /usr/local/lib probably because you listed it in lib_LTLIBRARIES (although I can't be sure if you don't show your code) and your --prefix is set to its default of /usr/local.

This last one is difficult since Autotools' official stance is that all user-installed programs belong in /usr, whereas many other tools expect things to be in /lib/something. Here's one way to do it, that I personally consider wrong:

# Don't do this
libsecuritydir = /lib/security
libsecurity_LTLIBRARIES = pam_mymodule.la

This bypasses --prefix, which will go horribly, horribly wrong if you try to do a local install of your package without writing directly into your live system, which, trust me, you will want to do at some point. It will also prevent you from packaging your program in most Linux distributions' packaging systems.

The correct way is to push the responsibility onto whoever installs the package: add a --with-libsecuritydir argument to configure.ac using AC_ARG_WITH and let that default to $(libdir)/security:

AC_ARG_WITH([libsecuritydir],
    [AS_HELP_STRING([--with-libsecuritydir],
        [Directory for PAM modules, pass /lib/security for live install])],
    [], [with_libsecuritydir='$(libdir)/security'])
AC_SUBST([libsecuritydir], [$with_libsecuritydir])

and then just do

libsecurity_LTLIBRARIES = pam_mymodule.la

in Makefile.am.

When you want to install a live version directly into your system (or are building a binary package) pass --with-libsecuritydir=/lib/security to configure.

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • Perfect, thank you! I was afraid I would face some portability-related issue here, but using an option seems like the best solution indeed. Just a little note though: your `AS_IF` might want to test against `x` instead of `xno`, otherwise `libsecuritydir` will remain empty when the option isn't specified at all (unless you explicitly use `--with-libsecuritydir=no`. – John WH Smith Sep 26 '14 at 20:52
  • True, I should have used the fourth _action-if-not-given_ parameter of `AC_ARG_WITH` to do that. I'll edit the answer. – ptomato Sep 27 '14 at 04:51