From 892d21b17164713f7eb655d340be7c77f4b5104e Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 21 Aug 2018 20:33:13 +0200 Subject: [PATCH] build: add warning when overwriting vars on "make" doing things like `make CC="mmix-linux-musl-gcc"` breaks the hosttools/ cross-compilation setup pretty hard and just straight up should not be done. These vars belong on `configure`, not `make`. Signed-off-by: David Lamparter --- Makefile.am | 42 ++++++++++++++++++++++++++++++++++++++++++ configure.ac | 4 +++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index ec186b3fc1..0ecab8b1f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,6 +8,48 @@ AM_CPPFLAGS += -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/lib \ DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DCONFDATE=$(CONFDATE) LIBCAP = @LIBCAP@ +# overwriting these vars breaks cross-compilation. let's be helpful and warn. +# +# note: "#AUTODERP# " will be removed from Makefile by configure. These are +# GNU make directives & automake will f*ck them up by trying to process them +# as automake directives. +# +#AUTODERP# null= +#AUTODERP# SPACE=$(null) $(null) +#AUTODERP# mkcheck_CC = $(findstring $(SPACE)CC=, $(SPACE)$(MAKEOVERRIDES)) +#AUTODERP# mkcheck_CFLAGS = $(findstring $(SPACE)CFLAGS=, $(SPACE)$(MAKEOVERRIDES)) +#AUTODERP# mkcheck_CPPFLAGS = $(findstring $(SPACE)CPPFLAGS=,$(SPACE)$(MAKEOVERRIDES)) +#AUTODERP# mkcheck_CCLD = $(findstring $(SPACE)CCLD=, $(SPACE)$(MAKEOVERRIDES)) +#AUTODERP# mkcheck_LD = $(findstring $(SPACE)LD=, $(SPACE)$(MAKEOVERRIDES)) +#AUTODERP# mkcheck_LDFLAGS = $(findstring $(SPACE)LDFLAGS=, $(SPACE)$(MAKEOVERRIDES)) +#AUTODERP# # +#AUTODERP# ifneq ($(mkcheck_CC),) +#AUTODERP# $(warning WARNING: you have overwritten the "CC" variable on the make command line.) +#AUTODERP# endif +#AUTODERP# ifneq ($(mkcheck_CFLAGS),) +#AUTODERP# $(warning WARNING: you have overwritten the "CFLAGS" variable on the make command line.) +#AUTODERP# endif +#AUTODERP# ifneq ($(mkcheck_CPPFLAGS),) +#AUTODERP# $(warning WARNING: you have overwritten the "CPPFLAGS" variable on the make command line.) +#AUTODERP# endif +#AUTODERP# ifneq ($(mkcheck_CCLD),) +#AUTODERP# $(warning WARNING: you have overwritten the "CCLD" variable on the make command line.) +#AUTODERP# endif +#AUTODERP# ifneq ($(mkcheck_LD),) +#AUTODERP# $(warning WARNING: you have overwritten the "LD" variable on the make command line.) +#AUTODERP# endif +#AUTODERP# ifneq ($(mkcheck_LDFLAGS),) +#AUTODERP# $(warning WARNING: you have overwritten the "LDFLAGS" variable on the make command line.) +#AUTODERP# endif +#AUTODERP# # +#AUTODERP# ifneq ($(mkcheck_CC)$(mkcheck_CFLAGS)$(mkcheck_CPPFLAGS)$(mkcheck_CCLD)$(mkcheck_LD)$(mkcheck_LDFLAGS),) +#AUTODERP# $(warning ------) +#AUTODERP# $(warning While overwriting these variables works most of the time, it is not recommended and can cause confusing build errors.) +#AUTODERP# $(warning This is especially problematic when cross-compiling, since tools that run on the build system during the build process will not be compiled correctly.) +#AUTODERP# $(warning All of these variables should be supplied to 'configure', and they will be remembered and correctly applied during 'make'.) +#AUTODERP# $(warning ------) +#AUTODERP# endif + EXTRA_DIST = BUILT_SOURCES = CLEANFILES = diff --git a/configure.ac b/configure.ac index 2d8723d5cf..12c1857758 100755 --- a/configure.ac +++ b/configure.ac @@ -1993,7 +1993,9 @@ AC_CACHE_VAL(ac_cv_htonl_works, ) AC_MSG_RESULT($ac_cv_htonl_works) -AC_CONFIG_FILES([Makefile +AC_CONFIG_FILES([Makefile],[sed -e 's/^#AUTODERP# //' -i Makefile]) + +AC_CONFIG_FILES([ bgpd/Makefile vtysh/Makefile tests/Makefile -- 2.39.5