garden: automatically activate the "env3" virtualenv
[git-cola.git] / Makefile
blob68904f51af31cffa5b79e81938959506af595b27
1 # The default target of this Makefile is...
2 .PHONY: all
3 all::
5 # Usage
6 # -----
7 # make prefix=<path> install # Install git-cola
9 # make doc # Build documentation
10 # make prefix=<path> install-doc # Install documentation
12 # Variables
13 # ---------
14 # prefix - Installation prefix.
15 # DESTDIR - Temporary staging directory.
17 # The external commands used by this Makefile are...
18 CP = cp
19 FIND = find
20 MKDIR_P = mkdir -p
21 PIP = pip
22 PYTHON ?= python3
23 RM = rm -f
24 RM_R = rm -fr
25 RMDIR = rmdir
26 XARGS = xargs
28 # These values can be overridden on the command-line or via config.mak
29 # DESTDIR =
30 prefix = $(HOME)
31 python_version := $(shell $(PYTHON) -c 'import sys; print("%s.%s" % sys.version_info[:2])')
32 python_lib = python$(python_version)/site-packages
33 pythondir = $(prefix)/lib/$(python_lib)
35 cola_base := git-cola
36 cola_app_base= $(cola_base).app
37 cola_app = $(CURDIR)/$(cola_app_base)
38 cola_app_resources = $(cola_app)/Contents/Resources
40 # Read $(VERSION) from cola/_version.py and strip quotes.
41 include cola/_version.py
42 cola_version := $(subst ',,$(VERSION))
44 install_args =
45 ifdef DESTDIR
46 install_args += --root="$(DESTDIR)"
47 export DESTDIR
48 endif
49 install_args += --prefix="$(prefix)"
50 install_args += --disable-pip-version-check
51 export prefix
53 PYTHON_DIRS = cola
54 PYTHON_DIRS += test
56 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
58 # User customizations
59 -include config.mak
61 all::
63 .PHONY: install
64 install:: all
65 $(PIP) install $(install_args) .
67 .PHONY: doc
68 doc::
69 $(MAKE) -C docs all
71 .PHONY: html
72 html::
73 $(MAKE) -C docs html
75 .PHONY: man
76 man::
77 $(MAKE) -C docs man
79 .PHONY: install-doc
80 install-doc::
81 $(MAKE) -C docs install
83 .PHONY: install-html
84 install-html::
85 $(MAKE) -C docs install-html
87 .PHONY: install-man
88 install-man::
89 $(MAKE) -C docs install-man
91 .PHONY: uninstall
92 uninstall::
93 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
94 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
95 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola-sequence-editor
96 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
97 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
98 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
99 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
100 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-dag.appdata.xml
101 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-cola.appdata.xml
102 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
103 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
104 $(RM_R) "$(DESTDIR)$(pythondir)"/git_cola-*
105 $(RM_R) "$(DESTDIR)$(pythondir)"/cola
106 $(RMDIR) -p "$(DESTDIR)$(pythondir)" 2>/dev/null || true
107 $(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null || true
108 $(RMDIR) "$(DESTDIR)$(prefix)"/share/metainfo 2>/dev/null || true
109 $(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null || true
110 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null || true
111 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
112 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
113 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
114 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
115 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
116 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
118 .PHONY: clean
119 clean::
120 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py[cod]' -print0 | $(XARGS) -0 $(RM)
121 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
122 $(RM_R) build dist git-cola.app
123 $(MAKE) -C docs clean
125 # Build a git-cola.app bundle.
126 .PHONY: git-cola.app
127 git-cola.app::
128 cola_full_version := $(shell ./bin/git-cola version --brief)
130 git-cola.app::
131 $(MKDIR_P) $(cola_app)/Contents/MacOS
132 $(MKDIR_P) $(cola_app_resources)
133 $(PYTHON) -m venv $(cola_app_resources)
134 $(cola_app_resources)/bin/pip install '.[docs,extras,pyqt6]'
135 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo $(cola_app)/Contents
136 ifneq ($(cola_full_version),)
137 sed -i -e s/0.0.0.0/$(cola_full_version)/ $(cola_app)/Contents/Info.plist
138 endif
139 sed -i -e s/0.0.0/$(cola_version)/ $(cola_app)/Contents/Info.plist
140 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
141 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
142 $(MAKE) PIP=$(cola_app_resources)/bin/pip \
143 prefix=$(cola_app_resources) install
144 $(MAKE) SPHINXBUILD=$(cola_app_resources)/bin/sphinx-build \
145 prefix=$(cola_app_resources) install-doc
147 .PHONY: test
148 test::
149 @if type garden >/dev/null 2>&1; then \
150 garden test; \
151 else \
152 echo 'warning: "make test" requires "garden" https://gitlab.com/garden-rs/garden'; \
153 echo 'tip: run "cargo install garden-tools" to install "garden".'; \