Fabio M. Di Nitto wrote:
> On Mon, 2009-06-29 at 11:24 +0200, Jim Meyering wrote:
>> With an explicit --prefix, "make install" would install into /sbin
>> regardless:
>>
>> $ ./configure --prefix=/p/p/coro
>> ...
>> $ make install
>> make[1]: Entering directory `/h/meyering/w/co/gfs2-utils/gfs2/mkfs'
>> /p/bin/install -c -d /sbin
>> make[1]: Nothing to be done for `install-data-am'.
>> /p/bin/install -c -m 755 mkfs.gfs2 /sbin
>> /p/bin/install: cannot create regular file `/sbin/mkfs.gfs2': Permission
>> denied
>> make[1]: *** [install-exec-local] Error 1
>> make[1]: Leaving directory `/h/meyering/w/co/gfs2-utils/gfs2/mkfs'
>> make: *** [install-am] Error 2
>>
>> Along the way I noticed the Makefile.am files
>> were using noinst_PROGRAMS and adding their own install rules.
>> It's easier/cleaner/etc. to use sbin_PROGRAMS.
>> Here's the patch:
>>
>> >From d794b4e7948741f5d6767970a2fde2c5fce15947 Mon Sep 17 00:00:00 2001
>> From: Jim Meyering <[email protected]>
>> Date: Mon, 29 Jun 2009 11:23:09 +0200
>> Subject: [PATCH gfs2-utils] Use automake's sbin_PROGRAMS, rather than
>> writing our own rules.
>>
>> This also fixes a "make install" failure to honor --prefix.
>> * gfs2/mount/Makefile.am (sbin_PROGRAMS): Use sbin_PROGRAMS,
>> not noinst_PROGRAMS.
>> (install-exec-local, uninstall-local): Remove rules.
>> Automake automates this when you define sbin_PROGRAMS.
>> * gfs2/fsck/Makefile.am (sbin_PROGRAMS): Likewise.
>> (install-exec-local, uninstall-local): Remove rules.
>> * gfs2/mkfs/Makefile.am (sbin_PROGRAMS): Likewise.
>> (install-exec-local, uninstall-local): Remove rules.
>> (install-exec-hook, uninstall-hook): Remove unnecessary sub-shells.
>> ---
>> gfs2/fsck/Makefile.am | 10 +---------
>> gfs2/mkfs/Makefile.am | 16 ++++------------
>> gfs2/mount/Makefile.am | 10 +---------
>> 3 files changed, 6 insertions(+), 30 deletions(-)
>
> This is the same problem we discussed in another occasion (can't
> remember which one).
>
> Those 3 binaries need to go in /sbin. mount(8) looks for mount helpers
> only in /sbin. Without the helper we fail to mount gfs2 or /usr could be
> on a gfs2 filesystem.. chicken egg?
>
> sbin_PROGRAM will install them in /usr/sbin that is not correct (in the
> default case of course). All distro ship fsck* and mkfs* also in /sbin
> in order to check the filesystem (without /usr mounted) or reformat
> (same reason).
>
> Handling of prefix can be better I agree, but turning them into
> sbin_PROGRAM doesn't work either.
>
> Clearly I am open to any better solution than the one I have in place...
Sure.
There's already so much default-munging going on in configure.ac,
why not add a tiny bit more.
This incremental patch does what you seem to want:
In case we're using the default (/usr) prefix
and the default exec_prefix, and set sbindir to /sbin:
diff --git a/configure.ac b/configure.ac
index a568463..ca0301e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,7 @@ fi
case $exec_prefix in
NONE) exec_prefix=$prefix;;
+ test "$prefix:$sbindir" = '/usr:${exec_prefix}/sbin' && sbindir=/sbin
prefix) exec_prefix=$prefix;;
esac