menu: move the Rebase and Reset sub-menus to the top-level menubar
[git-cola.git] / Makefile
blob11a21f531045e995e4203a693d23b032660fba0c
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 # run the black python formatter
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 BLACK = black
35 CTAGS = ctags
36 CP = cp
37 FIND = find
38 FLAKE8 = flake8
39 GREP = grep
40 GIT = git
41 GZIP = gzip
42 LN = ln
43 LN_S = $(LN) -s -f
44 MARKDOWN = markdown
45 MKDIR_P = mkdir -p
46 PIP = pip
47 PYLINT = pylint
48 PYTHON ?= python
49 PYTEST = $(PYTHON) -m pytest
50 RM = rm -f
51 RM_R = rm -fr
52 RMDIR = rmdir
53 TAR = tar
54 TOX = tox
55 XARGS = xargs
57 # Flags
58 # -----
59 ifdef V
60 VERBOSE = --verbose
61 ifeq ($(V),2)
62 TEST_VERBOSE = --verbose
63 VERBOSE_SHORT = -vv
64 else
65 VERBOSE_SHORT = -v
66 endif
67 else
68 QUIET = --quiet
69 endif
71 FLAKE8_FLAGS = $(VERBOSE)
73 PYTEST_FLAGS = $(QUIET) $(TEST_VERBOSE)
74 PYTEST_FLAGS += --doctest-modules
75 uname_S := $(shell uname -s)
76 ifneq ($(uname_S),Linux)
77 PYTEST_FLAGS += --ignore=cola/inotify.py
78 endif
80 TOX_FLAGS = $(VERBOSE_SHORT) --develop --skip-missing-interpreters
81 TOX_ENVS ?= py{27,34,35,36,37},pylint{2,36,37}
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 python_lib := $(shell $(PYTHON) -c \
95 'import distutils.sysconfig as sc; print(sc.get_python_lib(prefix=""))')
96 pythondir = $(prefix)/$(python_lib)
97 hicolordir = $(prefix)/share/icons/hicolor/scalable/apps
98 # DESTDIR =
100 cola_base := git-cola
101 cola_app_base= $(cola_base).app
102 cola_app = $(CURDIR)/$(cola_app_base)
103 cola_version = $(shell $(PYTHON) bin/git-cola version --brief)
104 cola_dist := $(cola_base)-$(cola_version)
106 SETUP ?= $(PYTHON) setup.py
108 build_args += build
109 ifdef USE_ENV_PYTHON
110 build_args += --use-env-python
111 endif
113 install_args += install
114 install_args += --prefix="$(prefix)"
115 install_args += --force
116 install_args += --install-scripts="$(bindir)"
117 install_args += --record=build/MANIFEST
118 ifdef DESTDIR
119 install_args += --root="$(DESTDIR)"
120 export DESTDIR
121 endif
122 export prefix
124 ifdef NO_PRIVATE_LIBS
125 install_args += --no-private-libs
126 endif
127 ifdef NO_VENDOR_LIBS
128 install_args += --no-vendor-libs
129 endif
131 PYTHON_DIRS = cola
132 PYTHON_DIRS += test
134 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
135 ALL_PYTHON_DIRS += extras
137 PYTHON_SOURCES = bin/git-cola
138 PYTHON_SOURCES += bin/git-cola-sequence-editor
139 PYTHON_SOURCES += bin/git-dag
140 PYTHON_SOURCES += setup.py
142 # User customizations
143 -include config.mak
145 .PHONY: all
146 all:: build
148 .PHONY: build_version
149 build_version:
150 @GIT=$(GIT) ./extras/generate-build-version.sh 2>/dev/null || true
152 .PHONY: build
153 build: build_version
154 $(SETUP) $(QUIET) $(VERBOSE) $(build_args)
156 .PHONY: install
157 install: all
158 $(SETUP) $(QUIET) $(VERBOSE) $(install_args)
159 $(MKDIR_P) "$(DESTDIR)$(hicolordir)"
160 $(LN_S) "$(datadir)/icons/git-cola.svg" \
161 "$(DESTDIR)$(hicolordir)/git-cola.svg"
162 $(LN_S) git-cola "$(DESTDIR)$(bindir)/cola"
164 # Maintainer's dist target
165 .PHONY: dist
166 dist:
167 $(GIT) archive --format=tar --prefix=$(cola_dist)/ HEAD^{tree} | \
168 $(GZIP) -f -9 - >$(cola_dist).tar.gz
170 .PHONY: doc
171 doc:
172 $(MAKE) -C share/doc/git-cola all
174 .PHONY: html
175 html:
176 $(MAKE) -C share/doc/git-cola html
178 .PHONY: man
179 man:
180 $(MAKE) -C share/doc/git-cola man
182 .PHONY: install-doc
183 install-doc:
184 $(MAKE) -C share/doc/git-cola install
186 .PHONY: install-html
187 install-html:
188 $(MAKE) -C share/doc/git-cola install-html
190 .PHONY: install-man
191 install-man:
192 $(MAKE) -C share/doc/git-cola install-man
194 .PHONY: uninstall
195 uninstall:
196 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
197 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola-sequence-editor
198 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
199 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
200 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
201 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
202 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
203 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-dag.appdata.xml
204 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-cola.appdata.xml
205 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
206 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
207 $(RM_R) "$(DESTDIR)$(prefix)"/share/git-cola
208 $(RM) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES/git-cola.mo
209 $(RM_R) "$(DESTDIR)$(pythondir)"/git_cola-*
210 $(RM_R) "$(DESTDIR)$(pythondir)"/cola
211 $(RMDIR) -p "$(DESTDIR)$(pythondir)" 2>/dev/null || true
212 $(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null || true
213 $(RMDIR) "$(DESTDIR)$(prefix)"/share/metainfo 2>/dev/null || true
214 $(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null || true
215 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/*/LC_MESSAGES 2>/dev/null || true
216 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale/* 2>/dev/null || true
217 $(RMDIR) "$(DESTDIR)$(prefix)"/share/locale 2>/dev/null || true
218 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null || true
219 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
220 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
221 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
222 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
223 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
224 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
226 .PHONY: test
227 test: all
228 $(PYTEST) $(PYTEST_FLAGS) $(flags) $(PYTHON_DIRS)
230 .PHONY: coverage
231 coverage:
232 $(PYTEST) $(PYTEST_FLAGS) --cov=cola $(flags) $(PYTHON_DIRS)
234 .PHONY: clean
235 clean:
236 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py[cod]' -print0 | $(XARGS) -0 $(RM)
237 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
238 $(RM_R) build dist tags git-cola.app
239 $(RM_R) share/locale
240 $(MAKE) -C share/doc/git-cola clean
242 .PHONY: tags
243 tags:
244 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py' -print0 | $($XARGS) -0 $(CTAGS) -f tags
246 # Update i18n files
247 .PHONY: i18n
248 i18n:: pot
249 i18n:: po
250 i18n:: mo
252 .PHONY: pot
253 pot:
254 $(SETUP) build_pot --build-dir=po --no-lang
256 .PHONY: po
258 $(SETUP) build_pot --build-dir=po
260 .PHONY: mo
262 $(SETUP) build_mo --force
264 .PHONY: git-cola.app
265 git-cola.app:
266 $(MKDIR_P) $(cola_app)/Contents/MacOS
267 $(MKDIR_P) $(cola_app)/Contents/Resources
268 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo \
269 $(cola_app)/Contents
270 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
271 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
272 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
274 .PHONY: app-tarball
275 app-tarball: git-cola.app
276 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
278 # Preview the markdown using "make README.html"
279 %.html: %.md
280 $(MARKDOWN) $< >$@
282 .PHONY: flake8
283 flake8:
284 $(FLAKE8) --version
285 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) \
286 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS) contrib
288 .PHONY: pylint3k
289 pylint3k:
290 $(PYLINT) --version
291 $(PYLINT) $(PYLINT_FLAGS) --py3k $(flags) \
292 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
294 .PHONY: pylint
295 pylint:
296 $(PYLINT) --version
297 $(PYLINT) $(PYLINT_FLAGS) $(flags) \
298 $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
300 # Pre-commit checks
301 .PHONY: check
302 ifdef file
303 check:
304 $(FLAKE8) $(FLAKE8_FLAGS) $(flags) $(file)
305 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized $(flags) $(file)
306 $(PYLINT) $(PYLINT_FLAGS) --output-format=colorized --py3k $(flags) $(file)
307 else
308 check:: all
309 check:: test
310 check:: doc
311 check:: flake8
312 check:: pylint3k
313 check:: pylint
314 endif
316 .PHONY: format
317 format:
318 $(GIT) ls-files -- '*.py' | \
319 $(GREP) -v ^qtpy | \
320 $(XARGS) $(BLACK) --skip-string-normalization --target-version=py27
321 $(BLACK) --skip-string-normalization --target-version=py27 $(PYTHON_SOURCES)
323 .PHONY: requirements
324 requirements:
325 $(PIP) install --requirement requirements/requirements.txt
327 .PHONY: requirements-dev
328 requirements-dev:
329 $(PIP) install --requirement requirements/requirements-dev.txt
331 .PHONY: tox
332 tox:
333 $(TOX) $(TOX_FLAGS) $(flags)
335 .PHONY: tox-check
336 tox-check:
337 $(TOX) $(TOX_FLAGS) -e "$(TOX_ENVS)" $(flags)