git-cola v2.7
[git-cola.git] / Makefile
blobbb929bb1ff9d54553311da4ae014b7a354a9f71c
1 # The default target of this Makefile is...
2 all::
4 # The external commands used by this Makefile are...
5 CTAGS = ctags
6 CP = cp
7 FIND = find
8 FLAKE8 = flake8
9 GIT = git
10 GZIP = gzip
11 LN = ln
12 LN_S = $(LN) -s -f
13 MARKDOWN = markdown
14 MKDIR_P = mkdir -p
15 NOSETESTS = nosetests
16 PIP = pip
17 PYLINT = pylint
18 PYTHON = python
19 RM = rm -f
20 RM_R = rm -fr
21 RMDIR = rmdir
22 TAR = tar
24 # Flags
25 FLAKE8_FLAGS = --max-line-length=80 --statistics --doctests --format=pylint
26 PYLINT_FLAGS = --py3k --output-format=colorized --rcfile=.pylintrc
28 # These values can be overridden on the command-line or via config.mak
29 prefix = $(HOME)
30 bindir = $(prefix)/bin
31 datadir = $(prefix)/share/git-cola
32 coladir = $(datadir)/lib
33 hicolordir = $(prefix)/share/icons/hicolor/scalable/apps
34 darwin_python = /System/Library/Frameworks/Python.framework/Resources/Python.app/Contents/MacOS/Python
35 # DESTDIR =
37 cola_base := git-cola
38 cola_app_base= $(cola_base).app
39 cola_app = $(CURDIR)/$(cola_app_base)
40 cola_version = $(shell $(PYTHON) bin/git-cola version --brief)
41 cola_dist := $(cola_base)-$(cola_version)
43 NOSE_FLAGS = --with-doctest
44 NOSE_FLAGS += --with-id
45 NOSE_FLAGS += --exclude=sphinxtogithub
46 NOSE_FLAGS += --exclude=extras
47 # Allows "make test flags=--stop"
48 flags =
49 NOSE ?= $(NOSETESTS) $(NOSE_FLAGS) $(flags)
51 SETUP ?= $(PYTHON) setup.py
52 setup_args += --prefix=$(prefix)
53 setup_args += --quiet
54 setup_args += --force
55 setup_args += --install-scripts=$(bindir)
56 setup_args += --record=build/MANIFEST
57 setup_args += --install-lib=$(coladir)
58 ifdef DESTDIR
59 setup_args += --root=$(DESTDIR)
60 export DESTDIR
61 endif
62 export prefix
64 # If NO_VENDOR_LIBS is specified on the command line then pass it to setup.py
65 ifdef NO_VENDOR_LIBS
66 setup_args += --no-vendor-libs
67 endif
69 PYTHON_DIRS = cola
70 PYTHON_DIRS += test
72 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
73 ALL_PYTHON_DIRS += extras
75 PYTHON_SOURCES = bin/git-cola
76 PYTHON_SOURCES += bin/git-dag
77 PYTHON_SOURCES += share/git-cola/bin/git-xbase
78 PYTHON_SOURCES += setup.py
80 # User customizations
81 -include config.mak
83 all:: build
84 .PHONY: all
86 build:
87 $(SETUP) build
88 .PHONY: build
90 install: all
91 $(SETUP) install $(setup_args)
92 $(MKDIR_P) $(DESTDIR)$(hicolordir)
93 $(LN_S) $(datadir)/icons/git-cola.svg $(DESTDIR)$(hicolordir)/git-cola.svg
94 $(LN_S) git-cola $(DESTDIR)$(bindir)/cola
95 $(RM_R) $(DESTDIR)$(coladir)/git_cola*
96 $(RM_R) git_cola.egg-info
97 .PHONY: install
99 # Maintainer's dist target
100 dist:
101 $(GIT) archive --format=tar --prefix=$(cola_dist)/ HEAD^{tree} | \
102 $(GZIP) -f -9 - >$(cola_dist).tar.gz
103 .PHONY: dist
105 doc:
106 $(MAKE) -C share/doc/git-cola all
107 .PHONY: doc
109 html:
110 $(MAKE) -C share/doc/git-cola html
111 .PHONY: html
113 man:
114 $(MAKE) -C share/doc/git-cola man
115 .PHONY: man
117 install-doc:
118 $(MAKE) -C share/doc/git-cola install
119 .PHONY: install-doc
121 install-html:
122 $(MAKE) -C share/doc/git-cola install-html
123 .PHONY: install-html
125 install-man:
126 $(MAKE) -C share/doc/git-cola install-man
127 .PHONY: install-man
129 uninstall:
130 $(RM) $(DESTDIR)$(prefix)/bin/git-cola
131 $(RM) $(DESTDIR)$(prefix)/bin/git-dag
132 $(RM) $(DESTDIR)$(prefix)/bin/cola
133 $(RM) $(DESTDIR)$(prefix)/share/applications/git-cola.desktop
134 $(RM) $(DESTDIR)$(prefix)/share/applications/git-cola-folder-handler.desktop
135 $(RM) $(DESTDIR)$(prefix)/share/applications/git-dag.desktop
136 $(RM) $(DESTDIR)$(prefix)/share/icons/hicolor/scalable/apps/git-cola.svg
137 $(RM_R) $(DESTDIR)$(prefix)/share/git-cola
138 $(RM_R) $(DESTDIR)$(prefix)/share/doc/git-cola
139 $(RM) $(DESTDIR)$(prefix)/share/locale/*/LC_MESSAGES/git-cola.mo
140 -$(RMDIR) $(DESTDIR)$(prefix)/share/locale/*/LC_MESSAGES 2>/dev/null
141 -$(RMDIR) $(DESTDIR)$(prefix)/share/locale/* 2>/dev/null
142 -$(RMDIR) $(DESTDIR)$(prefix)/share/locale 2>/dev/null
143 -$(RMDIR) $(DESTDIR)$(prefix)/share/doc 2>/dev/null
144 -$(RMDIR) $(DESTDIR)$(prefix)/share/applications 2>/dev/null
145 -$(RMDIR) $(DESTDIR)$(prefix)/share 2>/dev/null
146 -$(RMDIR) $(DESTDIR)$(prefix)/bin 2>/dev/null
147 -$(RMDIR) $(DESTDIR)$(prefix) 2>/dev/null
148 .PHONY: uninstall
150 test: all
151 $(NOSE) $(PYTHON_DIRS)
152 .PHONY: test
154 coverage:
155 $(NOSE) --with-coverage --cover-package=cola $(PYTHON_DIRS)
156 .PHONY: coverage
158 clean:
159 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py[cod]' -print0 | xargs -0 rm -f
160 $(RM_R) build dist tags git-cola.app
161 $(RM_R) share/locale
162 $(MAKE) -C share/doc/git-cola clean
163 .PHONY: clean
165 tags:
166 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py' -print0 | xargs -0 $(CTAGS) -f tags
167 .PHONY: tags
169 pot:
170 $(SETUP) build_pot -N -d po
171 .PHONY: pot
174 $(SETUP) build_mo -f
175 .PHONY: mo
177 git-cola.app:
178 $(MKDIR_P) $(cola_app)/Contents/MacOS
179 $(MKDIR_P) $(cola_app)/Contents/Resources
180 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo $(cola_app)/Contents
181 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
182 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
183 $(MAKE) prefix=$(cola_app)/Contents/Resources install install-doc
184 $(LN_S) $(darwin_python) $(cola_app)/Contents/Resources/git-cola
185 .PHONY: git-cola.app
187 app-tarball: git-cola.app
188 $(TAR) czf $(cola_dist).app.tar.gz $(cola_app_base)
189 .PHONY: app-tarball
191 # Preview the markdown using "make README.html"
192 %.html: %.md
193 $(MARKDOWN) $< >$@
195 flake8:
196 $(FLAKE8) $(FLAKE8_FLAGS) $(PYTHON_SOURCES) $(PYTHON_DIRS)
197 .PHONY: flake8
199 pylint:
200 $(PYLINT) $(PYLINT_FLAGS) $(PYTHON_SOURCES) $(ALL_PYTHON_DIRS)
201 .PHONY: pylint
203 requirements:
204 $(PIP) install --requirement requirements.txt
205 $(PIP) install --requirement extras/requirements-dev.txt
206 .PHONY: requirements