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