Skip to content

Commit 45425ff

Browse files
committed
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.
1 parent 41e0bd4 commit 45425ff

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2023-05-19 Bruno Haible <bruno@clisp.org>
2+
3+
Make the compiler used by Makefile.devel customizable.
4+
Reported by Mike Fulton <mikefultonpersonal@gmail.com> in
5+
<https://lists.gnu.org/archive/html/bug-gnu-libiconv/2023-05/msg00006.html>.
6+
* Makefile.devel: Require GNU make.
7+
(CC): Use value from the environment, if set and non-empty.
8+
(CFLAGS): Use value from the environment, if set.
9+
* autogen.sh (GMAKE): New variable.
10+
Use it for executing Makefile.devel.
11+
112
2023-05-17 Bruno Haible <bruno@clisp.org>
213

314
On z/OS, allow charset tagging of temporary shell scripts.

Makefile.devel

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# -*- makefile -*-
22
# This is the developer's makefile, not the user's makefile.
33
# Don't use it unless you know exactly what you do!
4+
# It requires GNU make.
5+
# It obeys the environment variables GNULIB_TOOL, CC, CFLAGS
6+
# if you have set them.
7+
8+
ifneq (,)
9+
This makefile requires GNU Make.
10+
endif
411

512
SHELL = /bin/sh
613
MAKE = make
@@ -9,8 +16,26 @@ AUTOHEADER = autoheader
916
AUTOMAKE = automake-1.16
1017
ACLOCAL = aclocal-1.16
1118
GPERF = gperf
12-
CC = gcc -Wall
19+
20+
# Ignore the built-in default for CC. Also ignore $(CC) if it is empty.
21+
# https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
22+
# https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
23+
# https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#index-findstring
24+
# https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#index-stripping-whitespace
25+
# https://www.gnu.org/software/make/manual/html_node/Conditional-Functions.html#index-or
26+
# https://www.gnu.org/software/make/manual/html_node/Override-Directive.html
27+
ifneq ($(or $(findstring $(origin CC), undefined default),$(if $(strip $(CC)),,empty)),)
28+
override CC = gcc -Wall
29+
endif
30+
31+
# Ignore the built-in default for CFLAGS.
32+
# https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
33+
# https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
34+
# https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#index-findstring
35+
ifneq ($(findstring $(origin CFLAGS), undefined default),)
1336
CFLAGS = -O
37+
endif
38+
1439
MAN2HTML = groff -mandoc -Thtml
1540
CP = cp
1641
RM = rm -f

autogen.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# It also requires
99
# - the gperf program.
1010

11-
# Copyright (C) 2003-2012, 2016, 2018-2022 Free Software Foundation, Inc.
11+
# Copyright (C) 2003-2012, 2016, 2018-2023 Free Software Foundation, Inc.
1212
#
1313
# This program is free software: you can redistribute it and/or modify
1414
# it under the terms of the GNU General Public License as published by
@@ -47,6 +47,22 @@ done
4747

4848
# ========== Copy files from gnulib, automake, or the internet. ==========
4949

50+
# Find GNU Make.
51+
if test -n "${MAKE}" && test "`${MAKE} --version 2>/dev/null | sed -e 's/ [0-9].*//' -e 1q`" = 'GNU Make'; then
52+
GMAKE="${MAKE}"
53+
else
54+
if test "`make --version 2>/dev/null | sed -e 's/ [0-9].*//' -e 1q`" = 'GNU Make'; then
55+
GMAKE=make
56+
else
57+
if test "`gmake --version 2>/dev/null | sed -e 's/ [0-9].*//' -e 1q`" = 'GNU Make'; then
58+
GMAKE=gmake
59+
else
60+
echo "*** - GNU Make not found" 1>&2
61+
exit 1
62+
fi
63+
fi
64+
fi
65+
5066
if test $skip_gnulib = false; then
5167
if test -n "$GNULIB_SRCDIR"; then
5268
test -d "$GNULIB_SRCDIR" || {
@@ -70,9 +86,9 @@ if test $skip_gnulib = false; then
7086
$GNULIB_TOOL --copy-file $file || exit $?
7187
chmod a+x $file || exit $?
7288
done
73-
make -f Makefile.devel \
74-
gnulib-clean srclib/Makefile.gnulib gnulib-imported-files srclib/Makefile.in \
75-
GNULIB_TOOL="$GNULIB_TOOL"
89+
$GMAKE -f Makefile.devel \
90+
gnulib-clean srclib/Makefile.gnulib gnulib-imported-files srclib/Makefile.in \
91+
GNULIB_TOOL="$GNULIB_TOOL"
7692
fi
7793

7894
# Copy files into the libcharset subpackage, so that libcharset/autogen.sh
@@ -89,7 +105,7 @@ done
89105

90106
# ========== Generate files. ==========
91107

92-
make -f Makefile.devel totally-clean all || exit $?
108+
$GMAKE -f Makefile.devel totally-clean all || exit $?
93109

94110
(cd libcharset
95111
./autogen.sh || exit $?

0 commit comments

Comments
 (0)