##// END OF EJS Templates
makefile: use Python 3 by default (BC)...
Gregory Szorc -
r46425:c2837640 default
parent child Browse files
Show More
@@ -1,258 +1,267 b''
1 # If you want to change PREFIX, do not just edit it below. The changed
1 # If you want to change PREFIX, do not just edit it below. The changed
2 # value wont get passed on to recursive make calls. You should instead
2 # value wont get passed on to recursive make calls. You should instead
3 # override the variable on the command like:
3 # override the variable on the command like:
4 #
4 #
5 # % make PREFIX=/opt/ install
5 # % make PREFIX=/opt/ install
6
6
7 export PREFIX=/usr/local
7 export PREFIX=/usr/local
8
9 # Default to Python 3.
10 #
11 # Windows ships Python 3 as `python.exe`.
12 ifeq ($(OS),Windows_NT)
8 PYTHON?=python
13 PYTHON?=python
14 else
15 PYTHON?=python3
16 endif
17
9 $(eval HGROOT := $(shell pwd))
18 $(eval HGROOT := $(shell pwd))
10 HGPYTHONS ?= $(HGROOT)/build/pythons
19 HGPYTHONS ?= $(HGROOT)/build/pythons
11 PURE=
20 PURE=
12 PYFILESCMD=find mercurial hgext doc -name '*.py'
21 PYFILESCMD=find mercurial hgext doc -name '*.py'
13 PYFILES:=$(shell $(PYFILESCMD))
22 PYFILES:=$(shell $(PYFILESCMD))
14 DOCFILES=mercurial/helptext/*.txt
23 DOCFILES=mercurial/helptext/*.txt
15 export LANGUAGE=C
24 export LANGUAGE=C
16 export LC_ALL=C
25 export LC_ALL=C
17 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
26 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
18 OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
27 OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
19 CARGO = cargo
28 CARGO = cargo
20
29
21 # Set this to e.g. "mingw32" to use a non-default compiler.
30 # Set this to e.g. "mingw32" to use a non-default compiler.
22 COMPILER=
31 COMPILER=
23
32
24 COMPILERFLAG_tmp_ =
33 COMPILERFLAG_tmp_ =
25 COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
34 COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
26 COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
35 COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
27
36
28 help:
37 help:
29 @echo 'Commonly used make targets:'
38 @echo 'Commonly used make targets:'
30 @echo ' all - build program and documentation'
39 @echo ' all - build program and documentation'
31 @echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
40 @echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
32 @echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
41 @echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
33 @echo ' local - build for inplace usage'
42 @echo ' local - build for inplace usage'
34 @echo ' tests - run all tests in the automatic test suite'
43 @echo ' tests - run all tests in the automatic test suite'
35 @echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
44 @echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
36 @echo ' dist - run all tests and create a source tarball in dist/'
45 @echo ' dist - run all tests and create a source tarball in dist/'
37 @echo ' clean - remove files created by other targets'
46 @echo ' clean - remove files created by other targets'
38 @echo ' (except installed files or dist source tarball)'
47 @echo ' (except installed files or dist source tarball)'
39 @echo ' update-pot - update i18n/hg.pot'
48 @echo ' update-pot - update i18n/hg.pot'
40 @echo
49 @echo
41 @echo 'Example for a system-wide installation under /usr/local:'
50 @echo 'Example for a system-wide installation under /usr/local:'
42 @echo ' make all && su -c "make install" && hg version'
51 @echo ' make all && su -c "make install" && hg version'
43 @echo
52 @echo
44 @echo 'Example for a local installation (usable in this directory):'
53 @echo 'Example for a local installation (usable in this directory):'
45 @echo ' make local && ./hg version'
54 @echo ' make local && ./hg version'
46
55
47 all: build doc
56 all: build doc
48
57
49 local:
58 local:
50 $(PYTHON) setup.py $(PURE) \
59 $(PYTHON) setup.py $(PURE) \
51 build_py -c -d . \
60 build_py -c -d . \
52 build_ext $(COMPILERFLAG) -i \
61 build_ext $(COMPILERFLAG) -i \
53 build_hgexe $(COMPILERFLAG) -i \
62 build_hgexe $(COMPILERFLAG) -i \
54 build_mo
63 build_mo
55 env HGRCPATH= $(PYTHON) hg version
64 env HGRCPATH= $(PYTHON) hg version
56
65
57 build:
66 build:
58 $(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
67 $(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
59
68
60 wheel:
69 wheel:
61 FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
70 FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
62
71
63 doc:
72 doc:
64 $(MAKE) -C doc
73 $(MAKE) -C doc
65
74
66 cleanbutpackages:
75 cleanbutpackages:
67 rm -f hg.exe
76 rm -f hg.exe
68 -$(PYTHON) setup.py clean --all # ignore errors from this command
77 -$(PYTHON) setup.py clean --all # ignore errors from this command
69 find contrib doc hgext hgext3rd i18n mercurial tests hgdemandimport \
78 find contrib doc hgext hgext3rd i18n mercurial tests hgdemandimport \
70 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
79 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
71 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
80 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
72 rm -f mercurial/__modulepolicy__.py
81 rm -f mercurial/__modulepolicy__.py
73 if test -d .hg; then rm -f mercurial/__version__.py; fi
82 if test -d .hg; then rm -f mercurial/__version__.py; fi
74 rm -rf build mercurial/locale
83 rm -rf build mercurial/locale
75 $(MAKE) -C doc clean
84 $(MAKE) -C doc clean
76 $(MAKE) -C contrib/chg distclean
85 $(MAKE) -C contrib/chg distclean
77 rm -rf rust/target
86 rm -rf rust/target
78 rm -f mercurial/rustext.so
87 rm -f mercurial/rustext.so
79
88
80 clean: cleanbutpackages
89 clean: cleanbutpackages
81 rm -rf packages
90 rm -rf packages
82
91
83 install: install-bin install-doc
92 install: install-bin install-doc
84
93
85 install-bin: build
94 install-bin: build
86 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
95 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
87
96
88 install-doc: doc
97 install-doc: doc
89 cd doc && $(MAKE) $(MFLAGS) install
98 cd doc && $(MAKE) $(MFLAGS) install
90
99
91 install-home: install-home-bin install-home-doc
100 install-home: install-home-bin install-home-doc
92
101
93 install-home-bin: build
102 install-home-bin: build
94 $(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
103 $(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
95
104
96 install-home-doc: doc
105 install-home-doc: doc
97 cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
106 cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
98
107
99 MANIFEST-doc:
108 MANIFEST-doc:
100 $(MAKE) -C doc MANIFEST
109 $(MAKE) -C doc MANIFEST
101
110
102 MANIFEST.in: MANIFEST-doc
111 MANIFEST.in: MANIFEST-doc
103 hg manifest | sed -e 's/^/include /' > MANIFEST.in
112 hg manifest | sed -e 's/^/include /' > MANIFEST.in
104 echo include mercurial/__version__.py >> MANIFEST.in
113 echo include mercurial/__version__.py >> MANIFEST.in
105 sed -e 's/^/include /' < doc/MANIFEST >> MANIFEST.in
114 sed -e 's/^/include /' < doc/MANIFEST >> MANIFEST.in
106
115
107 dist: tests dist-notests
116 dist: tests dist-notests
108
117
109 dist-notests: doc MANIFEST.in
118 dist-notests: doc MANIFEST.in
110 TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
119 TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
111
120
112 check: tests
121 check: tests
113
122
114 tests:
123 tests:
115 # Run Rust tests if cargo is installed
124 # Run Rust tests if cargo is installed
116 if command -v $(CARGO) >/dev/null 2>&1; then \
125 if command -v $(CARGO) >/dev/null 2>&1; then \
117 $(MAKE) rust-tests; \
126 $(MAKE) rust-tests; \
118 fi
127 fi
119 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
128 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
120
129
121 test-%:
130 test-%:
122 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
131 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
123
132
124 testpy-%:
133 testpy-%:
125 @echo Looking for Python $* in $(HGPYTHONS)
134 @echo Looking for Python $* in $(HGPYTHONS)
126 [ -e $(HGPYTHONS)/$*/bin/python ] || ( \
135 [ -e $(HGPYTHONS)/$*/bin/python ] || ( \
127 cd $$(mktemp --directory --tmpdir) && \
136 cd $$(mktemp --directory --tmpdir) && \
128 $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
137 $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
129 cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
138 cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
130
139
131 rust-tests: py_feature = $(shell $(PYTHON) -c \
140 rust-tests: py_feature = $(shell $(PYTHON) -c \
132 'import sys; print(["python27-bin", "python3-bin"][sys.version_info[0] >= 3])')
141 'import sys; print(["python27-bin", "python3-bin"][sys.version_info[0] >= 3])')
133 rust-tests:
142 rust-tests:
134 cd $(HGROOT)/rust/hg-cpython \
143 cd $(HGROOT)/rust/hg-cpython \
135 && $(CARGO) test --quiet --all \
144 && $(CARGO) test --quiet --all \
136 --no-default-features --features "$(py_feature) $(HG_RUST_FEATURES)"
145 --no-default-features --features "$(py_feature) $(HG_RUST_FEATURES)"
137
146
138 check-code:
147 check-code:
139 hg manifest | xargs python contrib/check-code.py
148 hg manifest | xargs python contrib/check-code.py
140
149
141 format-c:
150 format-c:
142 clang-format --style file -i \
151 clang-format --style file -i \
143 `hg files 'set:(**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"'`
152 `hg files 'set:(**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"'`
144
153
145 update-pot: i18n/hg.pot
154 update-pot: i18n/hg.pot
146
155
147 i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
156 i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
148 $(PYTHON) i18n/hggettext mercurial/commands.py \
157 $(PYTHON) i18n/hggettext mercurial/commands.py \
149 hgext/*.py hgext/*/__init__.py \
158 hgext/*.py hgext/*/__init__.py \
150 mercurial/fileset.py mercurial/revset.py \
159 mercurial/fileset.py mercurial/revset.py \
151 mercurial/templatefilters.py \
160 mercurial/templatefilters.py \
152 mercurial/templatefuncs.py \
161 mercurial/templatefuncs.py \
153 mercurial/templatekw.py \
162 mercurial/templatekw.py \
154 mercurial/filemerge.py \
163 mercurial/filemerge.py \
155 mercurial/hgweb/webcommands.py \
164 mercurial/hgweb/webcommands.py \
156 mercurial/util.py \
165 mercurial/util.py \
157 $(DOCFILES) > i18n/hg.pot.tmp
166 $(DOCFILES) > i18n/hg.pot.tmp
158 # All strings marked for translation in Mercurial contain
167 # All strings marked for translation in Mercurial contain
159 # ASCII characters only. But some files contain string
168 # ASCII characters only. But some files contain string
160 # literals like this '\037\213'. xgettext thinks it has to
169 # literals like this '\037\213'. xgettext thinks it has to
161 # parse them even though they are not marked for translation.
170 # parse them even though they are not marked for translation.
162 # Extracting with an explicit encoding of ISO-8859-1 will make
171 # Extracting with an explicit encoding of ISO-8859-1 will make
163 # xgettext "parse" and ignore them.
172 # xgettext "parse" and ignore them.
164 $(PYFILESCMD) | xargs \
173 $(PYFILESCMD) | xargs \
165 xgettext --package-name "Mercurial" \
174 xgettext --package-name "Mercurial" \
166 --msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
175 --msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
167 --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
176 --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
168 --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
177 --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
169 -d hg -p i18n -o hg.pot.tmp
178 -d hg -p i18n -o hg.pot.tmp
170 $(PYTHON) i18n/posplit i18n/hg.pot.tmp
179 $(PYTHON) i18n/posplit i18n/hg.pot.tmp
171 # The target file is not created before the last step. So it never is in
180 # The target file is not created before the last step. So it never is in
172 # an intermediate state.
181 # an intermediate state.
173 mv -f i18n/hg.pot.tmp i18n/hg.pot
182 mv -f i18n/hg.pot.tmp i18n/hg.pot
174
183
175 %.po: i18n/hg.pot
184 %.po: i18n/hg.pot
176 # work on a temporary copy for never having a half completed target
185 # work on a temporary copy for never having a half completed target
177 cp $@ $@.tmp
186 cp $@ $@.tmp
178 msgmerge --no-location --update $@.tmp $^
187 msgmerge --no-location --update $@.tmp $^
179 mv -f $@.tmp $@
188 mv -f $@.tmp $@
180
189
181 # Packaging targets
190 # Packaging targets
182
191
183 packaging_targets := \
192 packaging_targets := \
184 centos5 \
193 centos5 \
185 centos6 \
194 centos6 \
186 centos7 \
195 centos7 \
187 centos8 \
196 centos8 \
188 deb \
197 deb \
189 docker-centos5 \
198 docker-centos5 \
190 docker-centos6 \
199 docker-centos6 \
191 docker-centos7 \
200 docker-centos7 \
192 docker-centos8 \
201 docker-centos8 \
193 docker-debian-bullseye \
202 docker-debian-bullseye \
194 docker-debian-buster \
203 docker-debian-buster \
195 docker-debian-stretch \
204 docker-debian-stretch \
196 docker-fedora \
205 docker-fedora \
197 docker-ubuntu-trusty \
206 docker-ubuntu-trusty \
198 docker-ubuntu-trusty-ppa \
207 docker-ubuntu-trusty-ppa \
199 docker-ubuntu-xenial \
208 docker-ubuntu-xenial \
200 docker-ubuntu-xenial-ppa \
209 docker-ubuntu-xenial-ppa \
201 docker-ubuntu-artful \
210 docker-ubuntu-artful \
202 docker-ubuntu-artful-ppa \
211 docker-ubuntu-artful-ppa \
203 docker-ubuntu-bionic \
212 docker-ubuntu-bionic \
204 docker-ubuntu-bionic-ppa \
213 docker-ubuntu-bionic-ppa \
205 fedora \
214 fedora \
206 linux-wheels \
215 linux-wheels \
207 linux-wheels-x86_64 \
216 linux-wheels-x86_64 \
208 linux-wheels-i686 \
217 linux-wheels-i686 \
209 ppa
218 ppa
210
219
211 # Forward packaging targets for convenience.
220 # Forward packaging targets for convenience.
212 $(packaging_targets):
221 $(packaging_targets):
213 $(MAKE) -C contrib/packaging $@
222 $(MAKE) -C contrib/packaging $@
214
223
215 osx:
224 osx:
216 rm -rf build/mercurial
225 rm -rf build/mercurial
217 /usr/bin/python2.7 setup.py install --optimize=1 \
226 /usr/bin/python2.7 setup.py install --optimize=1 \
218 --root=build/mercurial/ --prefix=/usr/local/ \
227 --root=build/mercurial/ --prefix=/usr/local/ \
219 --install-lib=/Library/Python/2.7/site-packages/
228 --install-lib=/Library/Python/2.7/site-packages/
220 make -C doc all install DESTDIR="$(PWD)/build/mercurial/"
229 make -C doc all install DESTDIR="$(PWD)/build/mercurial/"
221 # Place a bogon .DS_Store file in the target dir so we can be
230 # Place a bogon .DS_Store file in the target dir so we can be
222 # sure it doesn't get included in the final package.
231 # sure it doesn't get included in the final package.
223 touch build/mercurial/.DS_Store
232 touch build/mercurial/.DS_Store
224 # install zsh completions - this location appears to be
233 # install zsh completions - this location appears to be
225 # searched by default as of macOS Sierra.
234 # searched by default as of macOS Sierra.
226 install -d build/mercurial/usr/local/share/zsh/site-functions/
235 install -d build/mercurial/usr/local/share/zsh/site-functions/
227 install -m 0644 contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/_hg
236 install -m 0644 contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/_hg
228 # install bash completions - there doesn't appear to be a
237 # install bash completions - there doesn't appear to be a
229 # place that's searched by default for bash, so we'll follow
238 # place that's searched by default for bash, so we'll follow
230 # the lead of Apple's git install and just put it in a
239 # the lead of Apple's git install and just put it in a
231 # location of our own.
240 # location of our own.
232 install -d build/mercurial/usr/local/hg/contrib/
241 install -d build/mercurial/usr/local/hg/contrib/
233 install -m 0644 contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash
242 install -m 0644 contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash
234 make -C contrib/chg \
243 make -C contrib/chg \
235 HGPATH=/usr/local/bin/hg \
244 HGPATH=/usr/local/bin/hg \
236 PYTHON=/usr/bin/python2.7 \
245 PYTHON=/usr/bin/python2.7 \
237 DESTDIR=../../build/mercurial \
246 DESTDIR=../../build/mercurial \
238 PREFIX=/usr/local \
247 PREFIX=/usr/local \
239 clean install
248 clean install
240 mkdir -p $${OUTPUTDIR:-dist}
249 mkdir -p $${OUTPUTDIR:-dist}
241 HGVER=$$(python contrib/genosxversion.py $(OSXVERSIONFLAGS) build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py) && \
250 HGVER=$$(python contrib/genosxversion.py $(OSXVERSIONFLAGS) build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py) && \
242 OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
251 OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
243 pkgbuild --filter \\.DS_Store --root build/mercurial/ \
252 pkgbuild --filter \\.DS_Store --root build/mercurial/ \
244 --identifier org.mercurial-scm.mercurial \
253 --identifier org.mercurial-scm.mercurial \
245 --version "$${HGVER}" \
254 --version "$${HGVER}" \
246 build/mercurial.pkg && \
255 build/mercurial.pkg && \
247 productbuild --distribution contrib/packaging/macosx/distribution.xml \
256 productbuild --distribution contrib/packaging/macosx/distribution.xml \
248 --package-path build/ \
257 --package-path build/ \
249 --version "$${HGVER}" \
258 --version "$${HGVER}" \
250 --resources contrib/packaging/macosx/ \
259 --resources contrib/packaging/macosx/ \
251 "$${OUTPUTDIR:-dist/}"/Mercurial-"$${HGVER}"-macosx"$${OSXVER}".pkg
260 "$${OUTPUTDIR:-dist/}"/Mercurial-"$${HGVER}"-macosx"$${OSXVER}".pkg
252
261
253 .PHONY: help all local build doc cleanbutpackages clean install install-bin \
262 .PHONY: help all local build doc cleanbutpackages clean install install-bin \
254 install-doc install-home install-home-bin install-home-doc \
263 install-doc install-home install-home-bin install-home-doc \
255 dist dist-notests check tests rust-tests check-code format-c \
264 dist dist-notests check tests rust-tests check-code format-c \
256 update-pot \
265 update-pot \
257 $(packaging_targets) \
266 $(packaging_targets) \
258 osx
267 osx
General Comments 0
You need to be logged in to leave comments. Login now