Finally fixing the issue with CC, CX, LD, and AR not being overridable from the environment.

pull/4901/head
Nicolas "Pixel" Noble 9 years ago
parent 1a8eb85eff
commit fba36bc4b8
  1. 26
      Makefile
  2. 26
      templates/Makefile.template

@ -229,11 +229,29 @@ prefix ?= /usr/local
PROTOC ?= protoc
DTRACE ?= dtrace
CONFIG ?= opt
CC ?= $(CC_$(CONFIG))
CXX ?= $(CXX_$(CONFIG))
LD ?= $(LD_$(CONFIG))
# Doing X ?= Y is the same as:
# ifeq ($(origin X), undefined)
# X = Y
# endif
# but some variables, such as CC, CXX, LD or AR, have defaults.
# So instead of using ?= on them, we need to check their origin.
# See:
# https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
# https://www.gnu.org/software/make/manual/html_node/Flavors.html#index-_003f_003d
# https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
ifeq ($(origin CC), default)
CC = $(CC_$(CONFIG))
endif
ifeq ($(origin CXX), default)
CXX = $(CXX_$(CONFIG))
endif
ifeq ($(origin LD), default)
LD = $(LD_$(CONFIG))
endif
LDXX ?= $(LDXX_$(CONFIG))
AR ?= ar
ifeq ($(origin AR), default)
AR = ar
endif
ifeq ($(SYSTEM),Linux)
STRIP ?= strip --strip-unneeded
else

@ -133,11 +133,29 @@
PROTOC ?= protoc
DTRACE ?= dtrace
CONFIG ?= opt
CC ?= $(CC_$(CONFIG))
CXX ?= $(CXX_$(CONFIG))
LD ?= $(LD_$(CONFIG))
# Doing X ?= Y is the same as:
# ifeq ($(origin X), undefined)
# X = Y
# endif
# but some variables, such as CC, CXX, LD or AR, have defaults.
# So instead of using ?= on them, we need to check their origin.
# See:
# https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
# https://www.gnu.org/software/make/manual/html_node/Flavors.html#index-_003f_003d
# https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
ifeq ($(origin CC), default)
CC = $(CC_$(CONFIG))
endif
ifeq ($(origin CXX), default)
CXX = $(CXX_$(CONFIG))
endif
ifeq ($(origin LD), default)
LD = $(LD_$(CONFIG))
endif
LDXX ?= $(LDXX_$(CONFIG))
AR ?= ar
ifeq ($(origin AR), default)
AR = ar
endif
ifeq ($(SYSTEM),Linux)
STRIP ?= strip --strip-unneeded
else

Loading…
Cancel
Save