make: alter how we compute compiler flags for setup.py stable
authorAugie Fackler <augie@google.com>
Thu, 21 Apr 2016 10:05:14 -0400
branchstable
changeset 31346 c6b108555dfadb2e0c52f3a5af1972039e46c4e7
parent 31345 ea794f2eb19dbffa7da3f1e4557b9687d0878831
child 31347 145cdc45b0df7b279ccd936db22264e807fe0718
push id216
push usergszorc@mozilla.com
push dateTue, 26 Apr 2016 22:20:13 +0000
make: alter how we compute compiler flags for setup.py This is portable between BSD and GNU make. I'm not thrilled with how it worked out, but it's portable and solves the problem.
Makefile
--- a/Makefile
+++ b/Makefile
@@ -14,16 +14,20 @@ PYFILES:=$(shell find mercurial hgext do
 DOCFILES=mercurial/help/*.txt
 export LANGUAGE=C
 export LC_ALL=C
 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
 
 # Set this to e.g. "mingw32" to use a non-default compiler.
 COMPILER=
 
+COMPILERFLAG_tmp_ =
+COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
+COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
+
 help:
 	@echo 'Commonly used make targets:'
 	@echo '  all          - build program and documentation'
 	@echo '  install      - install program and man pages to $$PREFIX ($(PREFIX))'
 	@echo '  install-home - install with setup.py install --home=$$HOME ($(HOME))'
 	@echo '  local        - build for inplace usage'
 	@echo '  tests        - run all tests in the automatic test suite'
 	@echo '  test-foo     - run only specified tests (e.g. test-merge1.t)'
@@ -38,26 +42,26 @@ help:
 	@echo 'Example for a local installation (usable in this directory):'
 	@echo '  make local && ./hg version'
 
 all: build doc
 
 local:
 	$(PYTHON) setup.py $(PURE) \
 	  build_py -c -d . \
-	  build_ext $(COMPILER:%=-c %) -i \
-	  build_hgexe $(COMPILER:%=-c %) -i \
+	  build_ext $(COMPILERFLAG) -i \
+	  build_hgexe $(COMPILERFLAG) -i \
 	  build_mo
 	env HGRCPATH= $(PYTHON) hg version
 
 build:
-	$(PYTHON) setup.py $(PURE) build $(COMPILER:%=-c %)
+	$(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
 
 wheel:
-	FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILER:%=-c %)
+	FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
 
 doc:
 	$(MAKE) -C doc
 
 clean:
 	-$(PYTHON) setup.py clean --all # ignore errors from this command
 	find contrib doc hgext hgext3rd i18n mercurial tests \
 		\( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'