Make the compiler used by Makefile.devel customizable.
Reported by Mike Fulton <mikefultonpersonal@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnu-libiconv/2023-05/msg00006.html>.
* Makefile.devel: Require GNU make.
(CC): Use value from the environment, if set and non-empty.
(CFLAGS): Use value from the environment, if set.
* autogen.sh (GMAKE): New variable.
Use it for executing Makefile.devel.
diff --git a/ChangeLog b/ChangeLog
index 24e8cff..6f8772a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-05-19 Bruno Haible <bruno@clisp.org>
+
+ Make the compiler used by Makefile.devel customizable.
+ Reported by Mike Fulton <mikefultonpersonal@gmail.com> in
+ <https://lists.gnu.org/archive/html/bug-gnu-libiconv/2023-05/msg00006.html>.
+ * Makefile.devel: Require GNU make.
+ (CC): Use value from the environment, if set and non-empty.
+ (CFLAGS): Use value from the environment, if set.
+ * autogen.sh (GMAKE): New variable.
+ Use it for executing Makefile.devel.
+
2023-05-17 Bruno Haible <bruno@clisp.org>
On z/OS, allow charset tagging of temporary shell scripts.
diff --git a/Makefile.devel b/Makefile.devel
index 5535acc..f20755f 100644
--- a/Makefile.devel
+++ b/Makefile.devel
@@ -1,6 +1,13 @@
# -*- makefile -*-
# This is the developer's makefile, not the user's makefile.
# Don't use it unless you know exactly what you do!
+# It requires GNU make.
+# It obeys the environment variables GNULIB_TOOL, CC, CFLAGS
+# if you have set them.
+
+ifneq (,)
+This makefile requires GNU Make.
+endif
SHELL = /bin/sh
MAKE = make
@@ -9,8 +16,26 @@
AUTOMAKE = automake-1.16
ACLOCAL = aclocal-1.16
GPERF = gperf
-CC = gcc -Wall
+
+# Ignore the built-in default for CC. Also ignore $(CC) if it is empty.
+# https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
+# https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
+# https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#index-findstring
+# https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#index-stripping-whitespace
+# https://www.gnu.org/software/make/manual/html_node/Conditional-Functions.html#index-or
+# https://www.gnu.org/software/make/manual/html_node/Override-Directive.html
+ifneq ($(or $(findstring $(origin CC), undefined default),$(if $(strip $(CC)),,empty)),)
+override CC = gcc -Wall
+endif
+
+# Ignore the built-in default for CFLAGS.
+# https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
+# https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
+# https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#index-findstring
+ifneq ($(findstring $(origin CFLAGS), undefined default),)
CFLAGS = -O
+endif
+
MAN2HTML = groff -mandoc -Thtml
CP = cp
RM = rm -f
diff --git a/autogen.sh b/autogen.sh
index dd72d83..8b228d7 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -8,7 +8,7 @@
# It also requires
# - the gperf program.
-# Copyright (C) 2003-2012, 2016, 2018-2022 Free Software Foundation, Inc.
+# Copyright (C) 2003-2012, 2016, 2018-2023 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -47,6 +47,22 @@
# ========== Copy files from gnulib, automake, or the internet. ==========
+# Find GNU Make.
+if test -n "${MAKE}" && test "`${MAKE} --version 2>/dev/null | sed -e 's/ [0-9].*//' -e 1q`" = 'GNU Make'; then
+ GMAKE="${MAKE}"
+else
+ if test "`make --version 2>/dev/null | sed -e 's/ [0-9].*//' -e 1q`" = 'GNU Make'; then
+ GMAKE=make
+ else
+ if test "`gmake --version 2>/dev/null | sed -e 's/ [0-9].*//' -e 1q`" = 'GNU Make'; then
+ GMAKE=gmake
+ else
+ echo "*** - GNU Make not found" 1>&2
+ exit 1
+ fi
+ fi
+fi
+
if test $skip_gnulib = false; then
if test -n "$GNULIB_SRCDIR"; then
test -d "$GNULIB_SRCDIR" || {
@@ -70,9 +86,9 @@
$GNULIB_TOOL --copy-file $file || exit $?
chmod a+x $file || exit $?
done
- make -f Makefile.devel \
- gnulib-clean srclib/Makefile.gnulib gnulib-imported-files srclib/Makefile.in \
- GNULIB_TOOL="$GNULIB_TOOL"
+ $GMAKE -f Makefile.devel \
+ gnulib-clean srclib/Makefile.gnulib gnulib-imported-files srclib/Makefile.in \
+ GNULIB_TOOL="$GNULIB_TOOL"
fi
# Copy files into the libcharset subpackage, so that libcharset/autogen.sh
@@ -89,7 +105,7 @@
# ========== Generate files. ==========
-make -f Makefile.devel totally-clean all || exit $?
+$GMAKE -f Makefile.devel totally-clean all || exit $?
(cd libcharset
./autogen.sh || exit $?