diff mbox

detect overridden install prefix [BZ #18512]

Message ID 557A1DCF.6080208@redhat.com
State New
Headers show

Commit Message

Martin Sebor June 11, 2015, 11:46 p.m. UTC
Attempting to install glibc configured with --prefix=/usr into
a non-standard directory specified by the prefix make variable
fails with an error.  Carlos indicated this is an unsupported
use case that he would prefer to detect and error out on early
in the installation process.

Attached is a simple patch that implements this detection. The
patch also updates the INSTALL file to mention this caveat and
recommend using DESTDIR instead.  To keep the patch simple
I didn't implement the idea of detecting whether the overridden
prefix is actually different than the prefix the library was
configured with.

ChangeLog:

2015-06-11  Martin Sebor  <msebor@redhat.com>

	[BZ #18512]
	* Makerules (check-install-supported): New target.
	install: Add check-install-supported as a dependency.
	* INSTALL (Installing the C Library): Document that overriding
	prefix and exec_prefix is not supported.  Mention DESTDIR.

Martin

Comments

Joseph Myers June 12, 2015, 12:45 a.m. UTC | #1
On Thu, 11 Jun 2015, Martin Sebor wrote:

> Attached is a simple patch that implements this detection. The
> patch also updates the INSTALL file to mention this caveat and

INSTALL is a generated file.  You need to update install.texi and 
regenerate INSTALL.
Carlos O'Donell June 12, 2015, 1:56 a.m. UTC | #2
On 06/11/2015 07:46 PM, Martin Sebor wrote:
> Attempting to install glibc configured with --prefix=/usr into
> a non-standard directory specified by the prefix make variable
> fails with an error.  Carlos indicated this is an unsupported
> use case that he would prefer to detect and error out on early
> in the installation process.
> 
> Attached is a simple patch that implements this detection. The
> patch also updates the INSTALL file to mention this caveat and
> recommend using DESTDIR instead.  To keep the patch simple
> I didn't implement the idea of detecting whether the overridden
> prefix is actually different than the prefix the library was
> configured with.
> 
> ChangeLog:
> 
> 2015-06-11  Martin Sebor  <msebor@redhat.com>
> 
>     [BZ #18512]
>     * Makerules (check-install-supported): New target.
>     install: Add check-install-supported as a dependency.
>     * INSTALL (Installing the C Library): Document that overriding
>     prefix and exec_prefix is not supported.  Mention DESTDIR.

The Makerules changes look good to me.

As Joseph notes INSTALL is a generated file.

OK to commit if you fix the INSTALL bit.

Cheers,
Carlos.
Andreas Schwab June 12, 2015, 9:30 a.m. UTC | #3
Martin Sebor <msebor@redhat.com> writes:

> +# an error message since doing so is not supported (sed DESTDIR

s/sed/set/

Andreas.
diff mbox

Patch

diff --git a/INSTALL b/INSTALL
index 8e13f2c..c1a8ecf 100644
--- a/INSTALL
+++ b/INSTALL
@@ -295,11 +295,13 @@  headers from libraries other than the GNU C Library yourself after
 installing the library.
 
    You can install the GNU C Library somewhere other than where you
-configured it to go by setting the 'install_root' variable on the
-command line for 'make install'.  The value of this variable is
+configured it to go by setting the 'DESTDIR' GNU standard make variable
+on the command line for 'make install'.  The value of this variable is
 prepended to all the paths for installation.  This is useful when
 setting up a chroot environment or preparing a binary distribution.  The
-directory should be specified with an absolute file name.
+directory should be specified with an absolute file name.  Installing
+with the prefix and exec_prefix GNU standard make variables set is not
+supported.
 
    The GNU C Library includes a daemon called 'nscd', which you may or
 may not want to run.  'nscd' caches name service lookups; it can
diff --git a/Makerules b/Makerules
index c79915f..502d22a 100644
--- a/Makerules
+++ b/Makerules
@@ -906,6 +906,26 @@  endef
 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
 			     $(inst_libdir)/$(patsubst %,$(libtype$o),\
 						     $(libprefix)$(libc-name)))
+
+.PHONY: check-install-supported
+check-install-supported:
+
+# Check to see if the prefix or exec_prefix GNU standard variable
+# has been overridden on the command line and, if so, fail with
+# an error message since doing so is not supported (sed DESTDIR
+# instead).
+ifeq ($(origin prefix),command line)
+check-install-supported:
+	$(error Overriding prefix is not supported. Set DESTDIR instead.)
+endif
+
+ifeq ($(origin exec_prefix),command line)
+check-install-supported:
+	$(error Overriding exec_prefix is not supported. Set DESTDIR instead.)
+endif
+
+install: check-install-supported
+
 install: $(installed-libcs)
 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
 	$(make-target-directory)