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