gnumake: do not use MAKE_CXX

Removes unnecessary C++ compiler reference when CXX environment variable
is set to an absolute path.

+68 -2
+4 -2
pkgs/development/tools/build-managers/gnumake/default.nix
··· 1 1 { lib 2 2 , stdenv 3 3 , fetchurl 4 - , updateAutotoolsGnuConfigScriptsHook 4 + , autoreconfHook 5 5 , guileSupport ? false, guile 6 6 # avoid guile depend on bootstrap to prevent dependency cycles 7 7 , inBootstrap ? false ··· 24 24 25 25 # to update apply these patches with `git am *.patch` to https://git.savannah.gnu.org/git/make.git 26 26 patches = [ 27 + # See patch message. 28 + ./make-cxx.patch 27 29 # Replaces /bin/sh with sh, see patch file for reasoning 28 30 ./0001-No-impure-bin-sh.patch 29 31 # Purity: don't look for library dependencies (of the form `-lfoo') in /lib ··· 32 34 ./0002-remove-impure-dirs.patch 33 35 ]; 34 36 35 - nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ] ++ lib.optionals guileEnabled [ pkg-config ]; 37 + nativeBuildInputs = [ autoreconfHook pkg-config ]; 36 38 buildInputs = lib.optionals guileEnabled [ guile ]; 37 39 38 40 configureFlags = lib.optional guileEnabled "--with-guile"
+64
pkgs/development/tools/build-managers/gnumake/make-cxx.patch
··· 1 + Do not search for a C++ compiler and set MAKE_CXX. 2 + 3 + Removes unnecessary reference to C++ compiler if CXX is set to an 4 + absolute path. If CXX is not an absolute path, we avoid defaulting CXX 5 + to a compiler name that was used to build the package. 6 + 7 + Context: GNU Make defines default values for CC, CXX and other 8 + environment variables. For CXX, it usually defaults to g++, however, 9 + FreeBSD and OpenBSD no longer ship GCC as a system compiler (and use 10 + Clang instead). For C compiler, POSIX standardizes the name to be "cc", 11 + but there is no such standard for C++ compiler name. As a fix, GNU Make 12 + uses CXX set for build as a default (via MAKE_CXX preprocessor macro in 13 + the source code). 14 + 15 + We revert the change that added this behavior and set the default to c++ 16 + or g++ that does not depend on the build platform. 17 + 18 + In stdenv, CXX environment variable is always defined and overrides the 19 + default value. 20 + 21 + References: 22 + • https://savannah.gnu.org/bugs/?63668 23 + • https://git.savannah.gnu.org/cgit/make.git/commit/?id=ffa28f3914ff402b3915f75e4fed86ac6fb1449d 24 + 25 + --- a/configure.ac 26 + +++ b/configure.ac 27 + @@ -37,6 +37,4 @@ AM_INIT_AUTOMAKE([1.16.1 foreign -Werror -Wall]) 28 + # Checks for programs. 29 + AC_USE_SYSTEM_EXTENSIONS 30 + AC_PROG_CC 31 + -AC_PROG_CXX 32 + -AC_DEFINE_UNQUOTED(MAKE_CXX, ["$CXX"], [Default C++ compiler.]) 33 + 34 + --- a/src/default.c 35 + +++ b/src/default.c 36 + @@ -528,22 +528,15 @@ static const char *default_variables[] = 37 + #ifdef GCC_IS_NATIVE 38 + "CC", "gcc", 39 + "OBJC", "gcc", 40 + +# ifdef __MSDOS__ 41 + + "CXX", "gpp", /* g++ is an invalid name on MSDOS */ 42 + +# else 43 + + "CXX", "g++", 44 + +# endif /* __MSDOS__ */ 45 + #else 46 + "CC", "cc", 47 + "OBJC", "cc", 48 + + "CXX", "c++", 49 + #endif 50 + -#ifdef MAKE_CXX 51 + - "CXX", MAKE_CXX, 52 + -#else 53 + -# ifdef GCC_IS_NATIVE 54 + -# ifdef __MSDOS__ 55 + - "CXX", "gpp", /* g++ is an invalid name on MSDOS */ 56 + -# else 57 + - "CXX", "gcc", 58 + -# endif /* __MSDOS__ */ 59 + -# else 60 + - "CXX", "g++", 61 + -# endif 62 + -#endif 63 + /* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist, 64 + and to the empty string if $@ does exist. */