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