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