prefs: allow opting-out of the published commit check
[git-cola.git] / Makefile
blobb392c3a949c72f2341f6b2df6f00d4ca84a5835f
1 # The default target of this Makefile is...
2 all::
4 # Development
5 # -----------
6 # make V=1 # generate files; V=1 increases verbosity
7 # make test [flags=...] # run tests; flags=-x fails fast
8 # make test V=2 # V=2 increases test verbosity
9 # make doc # build docs
10 # make flake8 # python style checks
11 # make pylint [color=1] # run pylint; color=1 colorizes output
12 # make pylint3k [color=1] # run python2+3 compatibility checks
13 # make format file=<filename> # run the yapf python formatter on <filename>
14 # make check [color=1] # run test, doc, flake8, pylint3k, and pylint
15 # make check file=<filename> # run checks on <filename>
17 # Release Prep
18 # ------------
19 # make pot # update main translation template
20 # make po # merge translations
21 # make mo # generate message files
22 # make i18n # all three of the above
24 # Installation
25 # ------------
26 # make prefix=<path> install
27 # DESTDIR is also supported.
29 # To disable distutil's replacement of "#!/usr/bin/env python" with
30 # the path to the build environment's python, pass USE_ENV_PYTHON=1
31 # when invoking make.
33 # The external commands used by this Makefile are...
34 CTAGS = ctags
35 CP = cp
36 FIND = find
37 FLAKE8 = flake8
38 GIT = git
39 GZIP = gzip
40 LN = ln
41 LN_S = $(LN) -s -f
42 MARKDOWN = markdown
43 MKDIR_P = mkdir -p
44 PIP = pip
45 PYLINT = pylint
46 PYTHON = python
47 PYTEST ?= $(PYTHON) -m pytest
48 RM = rm -f
49 RM_R = rm -fr
50 RMDIR = rmdir
51 TAR = tar
52 TOX ?= tox
53 YAPF = yapf
55 # Flags
56 # -----
57 ifdef V
58 VERBOSE = --verbose
59 ifeq ($(V),2)
60 TEST_VERBOSE = --verbose
61 VERBOSE_SHORT = -vv
62 else
63 VERBOSE_SHORT = -v
64 endif
65 else
66 QUIET = --quiet
67 endif
69 FLAKE8_FLAGS = $(VERBOSE)
70 FLAKE8_FLAGS += --max-line-length=80
71 FLAKE8_FLAGS += --format=pylint
72 FLAKE8_FLAGS += --doctests
74 PYTEST_FLAGS = $(QUIET) $(TEST_VERBOSE)
75 PYTEST_FLAGS += --doctest-modules
76 uname_S := $(shell uname -s)
77 ifneq ($(uname_S),Linux)
78 PYTEST_FLAGS += --ignore=cola/inotify.py
79 endif
81 TOX_FLAGS = $(VERBOSE_SHORT) --develop --skip-missing-interpreters
83 PYLINT_FLAGS = --rcfile=.pylintrc
84 PYLINT_FLAGS += --score=no
85 ifdef color
86 PYLINT_FLAGS += --output-format=colorized
87 endif
90 # These values can be overridden on the command-line or via config.mak
91 prefix = $(HOME)
92 bindir = $(prefix)/bin
93 datadir = $(prefix)/share/git-cola
94 coladir = $(datadir)/lib
95 hicolordir = $(prefix)/share/icons/hicolor/scalable/apps
96 # DESTDIR =
98 cola_base := git-cola
99 cola_app_base= $(cola_base).app
100 cola_app = $(CURDIR)/$(cola_app_base)
101 cola_version = $(shell $(PYTHON) bin/git-cola version --brief)
102 cola_dist := $(cola_base)-$(cola_version)
104 SETUP ?= $(PYTHON) setup.py
106 build_args += build
107 ifdef USE_ENV_PYTHON
108 build_args += --use-env-python
109 endif
111 install_args += install
112 install_args += --prefix="$(prefix)"
113 install_args += --force
114 install_args += --install-scripts="$(bindir)"
115 install_args += --record=build/MANIFEST
116 install_args += --install-lib="$(coladir)"
117 ifdef DESTDIR
118 install_args += --root="$(DESTDIR)"
119 export DESTDIR
120 endif
121 export prefix
123 # If NO_VENDOR_LIBS is specified on the command line then pass it to setup.py
124 ifdef NO_VENDOR_LIBS
125 install_args += --no-vendor-libs
126 endif
128 PYTHON_DIRS = cola
129 PYTHON_DIRS += test
131 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
132 ALL_PYTHON_DIRS += extras
134 PYTHON_SOURCES = bin/git-cola
135 PYTHON_SOURCES += bin/git-dag
136 PYTHON_SOURCES += share/git-cola/bin/git-xbase
137 PYTHON_SOURCES += setup.py
139 # User customizations
140 -include config.mak
142 all:: build
143 .PHONY: all
145 build_version:
146 @GIT=$(GIT) ./extras/generate-build-version.sh 2>/dev/null || true
147 .PHONY: build_version
149 build: build_version
150 $(SETUP) $(QUIET) $(VERBOSE) $(build_args)
151 .PHONY: build
153 install: all
154 $(SETUP) $(QUIET) $(VERBOSE) $(install_args)
155 $(MKDIR_P) "$(DESTDIR)$(hicolordir)"
156 $(LN_S) "$(datadir)/icons/git-cola.svg" \
157 "$(DESTDIR)$(hicolordir)/git-cola.svg"
158 $(LN_S) git-cola "$(DESTDIR)$(bindir)/cola"
159 $(RM_R) "$(DESTDIR)$(coladir)/git_cola"*
160 $(RM_R) git_cola.egg-info
161 .PHONY: install
163 # Maintainer's dist target
164 dist:
165 $(GIT) archive --format=tar --prefix=$(cola_dist)/ HEAD^{tree} | \
166 $(GZIP) -f -9 - >$(cola_dist).tar.gz
167 .PHONY: dist
169 doc:
170 $(MAKE) -C share/doc/git-cola all
171 .PHONY: doc
173 html:
174 $(MAKE) -C share/doc/git-cola html
175 .PHONY: html
177 man:
178 $(MAKE) -C share/doc/git-cola man
179 .PHONY: man
181 install-doc:
182 $(MAKE) -C share/doc/git-cola install
183 .PHONY: install-doc
185 install-html:
186 $(MAKE) -C share/doc/git-cola install-html
187 .PHONY: install-html
189 install-man:
190 $(MAKE) -C share/doc/git-cola install-man
191 .PHONY: install-man
193 uninstall:
194 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
195 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
196 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
197 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
198 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
199 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
200 $(RM) "$(DESTDIR)$(prefix)"/share/appdata/git-dag.appdata.xml
201 $(RM) "$(DESTDIR)$(prefix)"/share/appdata/git-cola.appdata.xml
202 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
203 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
204 $(RM_R) "$(DESTDIR)$(prefix)"/share/git-cola
205 $(RM) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES/git-cola.mo
206 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null
207 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/appdata 2>/dev/null
208 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null
209 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null
210 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null
211 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null
212 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null
213 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null
214 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null
215 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null
216 -$(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null
217 -$(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null
218 -$(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null
219 .PHONY: uninstall
221 test: all
222 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
223 .PHONY: test
225 coverage:
226 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
227 .PHONY: coverage
229 clean:
230 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py[cod]' -print0 | xargs -0 rm -f
231 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | xargs -0 rm -rf
232 $(RM_R) build dist tags git-cola.app
233 $(RM_R) share/locale
234 $(MAKE) -C share/doc/git-cola clean
235 .PHONY: clean
237 tags:
238 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py' -print0 | xargs -0 $(CTAGS) -f tags
239 .PHONY: tags
241 # Update i18n files
242 i18n:: pot
243 i18n:: po
244 i18n:: mo
245 .PHONY: i18n
247 pot:
248 $(SETUP) build_pot --build-dir=po --no-lang
249 .PHONY: pot
252 $(SETUP) build_pot --build-dir=po
253 .PHONY: po
256 $(SETUP) build_mo --force
257 .PHONY: mo
259 git-cola.app:
260 $(MKDIR_P) $(cola_app)/Contents/MacOS
261 $(MKDIR_P) $(cola_app)/Contents/Resources
262 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
263 $(cola_app)/Contents
264 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
265 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
266 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
267 .PHONY: git-cola.app
269 app-tarball: git-cola.app
270 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
271 .PHONY: app-tarball
273 # Preview the markdown using "make README.html"
274 %.html: %.md
275 $(MARKDOWN) $< >$@
277 flake8:
278 $(FLAKE8) --version
279 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
280 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS) contrib
281 .PHONY: flake8
283 pylint-version:
284 $(PYLINT) --version
285 .PHONY: pylint-version
287 pylint3k: pylint-version
288 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
289 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
290 .PHONY: pylint3k
292 pylint: pylint-version
293 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
294 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
295 .PHONY: pylint
297 # Pre-commit checks
298 ifdef file
299 check:
300 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
301 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
302 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
303 else
304 check:: all
305 check:: test
306 check:: doc
307 check:: flake8
308 check:: pylint3k
309 check:: pylint
310 endif
311 .PHONY: check
313 format:
314 $(YAPF) --in-place $(flags) $(file)
315 .PHONY: format
317 requirements:
318 $(PIP) install --requirement requirements/requirements.txt
319 .PHONY: requirements
321 requirements-dev:
322 $(PIP) install --requirement requirements/requirements-dev.txt
323 .PHONY: requirements-dev
325 tox:
326 $(TOX) $(TOX_FLAGS) $(flags)
327 .PHONY: tox