Merge pull request #874 from WaxyMocha/patch-1
[git-cola.git] / Makefile
blobb84bd2480410fc5fb1d30c70876d0c8ca478f607
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 check file=<filename> # run precommit checks on <filename>
14 # make format file=<filename> # run the yapf python formatter on <filename>
15 # make precommit [color=1] # run test, doc, flake8, pylint3k, and pylint
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
77 TOX_FLAGS = $(VERBOSE_SHORT) --develop --skip-missing-interpreters
79 PYLINT_FLAGS = --rcfile=.pylintrc
80 PYLINT_FLAGS += --score=no
81 ifdef color
82 PYLINT_FLAGS += --output-format=colorized
83 endif
86 # These values can be overridden on the command-line or via config.mak
87 prefix = $(HOME)
88 bindir = $(prefix)/bin
89 datadir = $(prefix)/share/git-cola
90 coladir = $(datadir)/lib
91 hicolordir = $(prefix)/share/icons/hicolor/scalable/apps
92 # DESTDIR =
94 cola_base := git-cola
95 cola_app_base= $(cola_base).app
96 cola_app = $(CURDIR)/$(cola_app_base)
97 cola_version = $(shell $(PYTHON) bin/git-cola version --brief)
98 cola_dist := $(cola_base)-$(cola_version)
100 SETUP ?= $(PYTHON) setup.py
102 build_args += build
103 ifdef USE_ENV_PYTHON
104 build_args += --use-env-python
105 endif
107 install_args += install
108 install_args += --prefix="$(prefix)"
109 install_args += --force
110 install_args += --install-scripts="$(bindir)"
111 install_args += --record=build/MANIFEST
112 install_args += --install-lib="$(coladir)"
113 ifdef DESTDIR
114 install_args += --root="$(DESTDIR)"
115 export DESTDIR
116 endif
117 export prefix
119 # If NO_VENDOR_LIBS is specified on the command line then pass it to setup.py
120 ifdef NO_VENDOR_LIBS
121 install_args += --no-vendor-libs
122 endif
124 PYTHON_DIRS = cola
125 PYTHON_DIRS += test
127 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
128 ALL_PYTHON_DIRS += extras
130 PYTHON_SOURCES = bin/git-cola
131 PYTHON_SOURCES += bin/git-dag
132 PYTHON_SOURCES += share/git-cola/bin/git-xbase
133 PYTHON_SOURCES += setup.py
135 # User customizations
136 -include config.mak
138 all:: build
139 .PHONY: all
141 build_version:
142 @GIT=$(GIT) ./extras/generate-build-version.sh 2>/dev/null || true
143 .PHONY: build_version
145 build: build_version
146 $(SETUP) $(QUIET) $(VERBOSE) $(build_args)
147 .PHONY: build
149 install: all
150 $(SETUP) $(QUIET) $(VERBOSE) $(install_args)
151 $(MKDIR_P) "$(DESTDIR)$(hicolordir)"
152 $(LN_S) "$(datadir)/icons/git-cola.svg" \
153 "$(DESTDIR)$(hicolordir)/git-cola.svg"
154 $(LN_S) git-cola "$(DESTDIR)$(bindir)/cola"
155 $(RM_R) "$(DESTDIR)$(coladir)/git_cola"*
156 $(RM_R) git_cola.egg-info
157 .PHONY: install
159 # Maintainer's dist target
160 dist:
161 $(GIT) archive --format=tar --prefix=$(cola_dist)/ HEAD^{tree} | \
162 $(GZIP) -f -9 - >$(cola_dist).tar.gz
163 .PHONY: dist
165 doc:
166 $(MAKE) -C share/doc/git-cola all
167 .PHONY: doc
169 html:
170 $(MAKE) -C share/doc/git-cola html
171 .PHONY: html
173 man:
174 $(MAKE) -C share/doc/git-cola man
175 .PHONY: man
177 install-doc:
178 $(MAKE) -C share/doc/git-cola install
179 .PHONY: install-doc
181 install-html:
182 $(MAKE) -C share/doc/git-cola install-html
183 .PHONY: install-html
185 install-man:
186 $(MAKE) -C share/doc/git-cola install-man
187 .PHONY: install-man
189 uninstall:
190 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
191 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
192 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
193 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
194 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
195 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
196 $(RM) "$(DESTDIR)$(prefix)"/share/appdata/git-dag.appdata.xml
197 $(RM) "$(DESTDIR)$(prefix)"/share/appdata/git-cola.appdata.xml
198 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
199 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
200 $(RM_R) "$(DESTDIR)$(prefix)"/share/git-cola
201 $(RM) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES/git-cola.mo
202 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null
203 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/appdata 2>/dev/null
204 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null
205 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null
206 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null
207 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null
208 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null
209 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null
210 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null
211 -$(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null
212 -$(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null
213 -$(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null
214 -$(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null
215 .PHONY: uninstall
217 test: all
218 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
219 .PHONY: test
221 coverage:
222 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
223 .PHONY: coverage
225 clean:
226 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py[cod]' -print0 | xargs -0 rm -f
227 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | xargs -0 rm -rf
228 $(RM_R) build dist tags git-cola.app
229 $(RM_R) share/locale
230 $(MAKE) -C share/doc/git-cola clean
231 .PHONY: clean
233 tags:
234 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py' -print0 | xargs -0 $(CTAGS) -f tags
235 .PHONY: tags
237 # Update i18n files
238 i18n:: pot
239 i18n:: po
240 i18n:: mo
241 .PHONY: i18n
243 pot:
244 $(SETUP) build_pot --build-dir=po --no-lang
245 .PHONY: pot
248 $(SETUP) build_pot --build-dir=po
249 .PHONY: po
252 $(SETUP) build_mo --force
253 .PHONY: mo
255 git-cola.app:
256 $(MKDIR_P) $(cola_app)/Contents/MacOS
257 $(MKDIR_P) $(cola_app)/Contents/Resources
258 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
259 $(cola_app)/Contents
260 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
261 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
262 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
263 .PHONY: git-cola.app
265 app-tarball: git-cola.app
266 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
267 .PHONY: app-tarball
269 # Preview the markdown using "make README.html"
270 %.html: %.md
271 $(MARKDOWN) $< >$@
273 flake8:
274 $(FLAKE8) $(FLAKE8_FLAGS) $(PYTHON_SOURCES) $(PYTHON_DIRS)
275 .PHONY: flake8
277 pylint3k:
278 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
279 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
280 .PHONY: pylint3k
282 pylint:
283 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
284 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
285 .PHONY: pylint
287 check:
288 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
289 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
290 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
291 .PHONY: check
293 # Pre-commit checks
294 precommit:: all
295 precommit:: doc
296 precommit:: test
297 precommit:: flake8
298 precommit:: pylint3k
299 precommit:: pylint
300 .PHONY: precommit
302 format:
303 $(YAPF) --in-place $(flags) $(file)
304 .PHONY: format
306 requirements:
307 $(PIP) install --requirement requirements/requirements.txt
308 .PHONY: requirements
310 requirements-dev:
311 $(PIP) install --requirement requirements/requirements-dev.txt
312 .PHONY: requirements-dev
314 tox:
315 $(TOX) $(TOX_FLAGS) $(flags)
316 .PHONY: tox