configure: default to --prefix=/usr on GNU/Linux

Message ID xno73qmgll.fsf@greed.delorie.com
State New
Headers
Series configure: default to --prefix=/usr on GNU/Linux |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed
redhat-pt-bot/TryBot-still_applies warning Patch no longer applies to master

Commit Message

DJ Delorie Oct. 11, 2024, 10:15 p.m. UTC
  I'm getting tired of always typing --prefix=/usr
so making it the default.
  

Comments

H.J. Lu Oct. 11, 2024, 10:28 p.m. UTC | #1
On Sat, Oct 12, 2024 at 6:15 AM DJ Delorie <dj@redhat.com> wrote:
>
>
> I'm getting tired of always typing --prefix=/usr
> so making it the default.
>
> diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
> index 4d642e953b..93f8567d25 100644
> --- a/sysdeps/unix/sysv/linux/configure
> +++ b/sysdeps/unix/sysv/linux/configure
> @@ -116,7 +116,9 @@ if test -n "$sysheaders"; then
>    CPPFLAGS=$OLD_CPPFLAGS
>  fi
>
> -if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/" -o "$prefix" = "NONE"; then
> +ac_default_prefix=/usr
> +
> +if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/"; then
>    if test $enable_sanity = yes; then
>      echo "\
>  *** On GNU/Linux systems the GNU C Library should not be installed into
> diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
> index c177e082a9..e24456102d 100644
> --- a/sysdeps/unix/sysv/linux/configure.ac
> +++ b/sysdeps/unix/sysv/linux/configure.ac
> @@ -71,7 +71,9 @@ if test -n "$sysheaders"; then
>    CPPFLAGS=$OLD_CPPFLAGS
>  fi
>
> -if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/" -o "$prefix" = "NONE"; then
> +ac_default_prefix=/usr
> +
> +if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/"; then
>    if test $enable_sanity = yes; then
>      echo "\
>  *** On GNU/Linux systems the GNU C Library should not be installed into
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.
  
Andreas Schwab Oct. 12, 2024, 6:14 a.m. UTC | #2
On Okt 11 2024, DJ Delorie wrote:

> +ac_default_prefix=/usr

AC_PREFIX_DEFAULT([/usr])
  
DJ Delorie Oct. 25, 2024, 12:11 a.m. UTC | #3
DJ Delorie <dj@redhat.com> writes:
> I'm getting tired of always typing --prefix=/usr
> so making it the default.

So after using this a bit more in real-world cases, it turns out there's
no simple way to make "--prefix=/usr" the default.  There are way too
many subtle things that happen in AC_INIT() that you can't override and
can tell the difference between a user-specified prefix and a default
prefix, and these things are important to glibc (like where /etc is).

And by "subtle things" I'm including:

* config.site which is found according to $prefix and internally reads
  $prefix but $prefix is not yet set to the default prefix.

* glibc's various config fragments, including sysdeps/gnu/configure
  (which doesn't work at all with a default), which happen before the
  Linux-specific one.

The attached patch, plus reconfiguring pretty much EVERYTHING, seems to
give the correct results - although it makes --prefix=/usr the default
for Hurd too.  Overrides of course still work.

In-depth review appreciated ;-)

diff --git a/aclocal.m4 b/aclocal.m4
index d8c613faf7..f8959954b1 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -305,7 +305,7 @@ dnl LIBC_SLIBDIR_RTLDDIR([slibdir], [rtlddir])
 AC_DEFUN([LIBC_SLIBDIR_RTLDDIR],
 [test -n "$libc_cv_slibdir" ||
 case "$prefix" in
-/usr | /usr/)
+/usr | /usr/ | NONE)
   libc_cv_slibdir='/$1'
   libc_cv_rtlddir='/$2'
   if test "$libdir" = '${exec_prefix}/lib'; then
diff --git a/configure.ac b/configure.ac
index d5a00461ff..c6569e8309 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl Note we do not use AC_PREREQ here!  See aclocal.m4 for what we use instead.
+AC_PREFIX_DEFAULT([/usr])
 AC_INIT([GNU C Library], [(see version.h)], [https://sourceware.org/bugzilla/],
   [glibc], [https://www.gnu.org/software/glibc/])
 AC_CONFIG_SRCDIR([include/features.h])
diff --git a/sysdeps/gnu/configure.ac b/sysdeps/gnu/configure.ac
index 634fe4de2a..52bc35e223 100644
--- a/sysdeps/gnu/configure.ac
+++ b/sysdeps/gnu/configure.ac
@@ -8,7 +8,7 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # in /lib and /etc.
 LIBC_SLIBDIR_RTLDDIR([lib], [lib])
 case "$prefix" in
-/usr | /usr/)
+/usr | /usr/ | NONE)
   # Allow the user to override the path with --sysconfdir.
   if test "$sysconfdir" = '${prefix}/etc'; then
     libc_cv_sysconfdir=/etc
diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
index 4c43cda877..6f224ed048 100644
--- a/sysdeps/unix/sysv/linux/configure.ac
+++ b/sysdeps/unix/sysv/linux/configure.ac
@@ -71,8 +71,6 @@ if test -n "$sysheaders"; then
   CPPFLAGS=$OLD_CPPFLAGS
 fi
 
-AC_PREFIX_DEFAULT([/usr])
-
 if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/"; then
   if test $enable_sanity = yes; then
     echo "\
  

Patch

diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
index 4d642e953b..93f8567d25 100644
--- a/sysdeps/unix/sysv/linux/configure
+++ b/sysdeps/unix/sysv/linux/configure
@@ -116,7 +116,9 @@  if test -n "$sysheaders"; then
   CPPFLAGS=$OLD_CPPFLAGS
 fi
 
-if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/" -o "$prefix" = "NONE"; then
+ac_default_prefix=/usr
+
+if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/"; then
   if test $enable_sanity = yes; then
     echo "\
 *** On GNU/Linux systems the GNU C Library should not be installed into
diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
index c177e082a9..e24456102d 100644
--- a/sysdeps/unix/sysv/linux/configure.ac
+++ b/sysdeps/unix/sysv/linux/configure.ac
@@ -71,7 +71,9 @@  if test -n "$sysheaders"; then
   CPPFLAGS=$OLD_CPPFLAGS
 fi
 
-if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/" -o "$prefix" = "NONE"; then
+ac_default_prefix=/usr
+
+if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/"; then
   if test $enable_sanity = yes; then
     echo "\
 *** On GNU/Linux systems the GNU C Library should not be installed into