fetch: add support for the traditional FETCH_HEAD behavior
[git-cola.git] / Makefile
blob82a060804be752dd2aee0e960960e170502616cd
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 install_args += --ignore-installed
52 install_args += --no-deps
53 export prefix
55 PYTHON_DIRS = cola
56 PYTHON_DIRS += test
58 ALL_PYTHON_DIRS = $(PYTHON_DIRS)
60 # User customizations
61 -include config.mak
63 all::
65 .PHONY: install
66 install:: all
67 $(PIP) install $(install_args) .
69 .PHONY: doc
70 doc::
71 $(MAKE) -C docs all
73 .PHONY: html
74 html::
75 $(MAKE) -C docs html
77 .PHONY: man
78 man::
79 $(MAKE) -C docs man
81 .PHONY: install-doc
82 install-doc::
83 $(MAKE) -C docs install
85 .PHONY: install-html
86 install-html::
87 $(MAKE) -C docs install-html
89 .PHONY: install-man
90 install-man::
91 $(MAKE) -C docs install-man
93 .PHONY: uninstall
94 uninstall::
95 $(RM) "$(DESTDIR)$(prefix)"/bin/cola
96 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola
97 $(RM) "$(DESTDIR)$(prefix)"/bin/git-cola-sequence-editor
98 $(RM) "$(DESTDIR)$(prefix)"/bin/git-dag
99 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola.desktop
100 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-cola-folder-handler.desktop
101 $(RM) "$(DESTDIR)$(prefix)"/share/applications/git-dag.desktop
102 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-dag.appdata.xml
103 $(RM) "$(DESTDIR)$(prefix)"/share/metainfo/git-cola.appdata.xml
104 $(RM) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps/git-cola.svg
105 $(RM_R) "$(DESTDIR)$(prefix)"/share/doc/git-cola
106 $(RM_R) "$(DESTDIR)$(pythondir)"/git_cola-*
107 $(RM_R) "$(DESTDIR)$(pythondir)"/cola
108 $(RMDIR) -p "$(DESTDIR)$(pythondir)" 2>/dev/null || true
109 $(RMDIR) "$(DESTDIR)$(prefix)"/share/applications 2>/dev/null || true
110 $(RMDIR) "$(DESTDIR)$(prefix)"/share/metainfo 2>/dev/null || true
111 $(RMDIR) "$(DESTDIR)$(prefix)"/share/doc 2>/dev/null || true
112 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable/apps 2>/dev/null || true
113 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor/scalable 2>/dev/null || true
114 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons/hicolor 2>/dev/null || true
115 $(RMDIR) "$(DESTDIR)$(prefix)"/share/icons 2>/dev/null || true
116 $(RMDIR) "$(DESTDIR)$(prefix)"/share 2>/dev/null || true
117 $(RMDIR) "$(DESTDIR)$(prefix)"/bin 2>/dev/null || true
118 $(RMDIR) "$(DESTDIR)$(prefix)" 2>/dev/null || true
120 .PHONY: clean
121 clean::
122 $(FIND) $(ALL_PYTHON_DIRS) -name '*.py[cod]' -print0 | $(XARGS) -0 $(RM)
123 $(FIND) $(ALL_PYTHON_DIRS) -name __pycache__ -print0 | $(XARGS) -0 $(RM_R)
124 $(RM_R) build dist git-cola.app
125 $(MAKE) -C docs clean
127 # Build a git-cola.app bundle.
128 .PHONY: git-cola.app
129 git-cola.app::
130 cola_full_version := $(shell ./bin/git-cola version --brief)
132 git-cola.app::
133 $(MKDIR_P) $(cola_app)/Contents/MacOS
134 $(MKDIR_P) $(cola_app_resources)
135 $(PYTHON) -m venv $(cola_app_resources)
136 $(cola_app_resources)/bin/pip install '.[docs,extras,pyqt6]'
137 $(CP) contrib/darwin/Info.plist contrib/darwin/PkgInfo $(cola_app)/Contents
138 ifneq ($(cola_full_version),)
139 sed -i -e s/0.0.0.0/$(cola_full_version)/ $(cola_app)/Contents/Info.plist
140 endif
141 sed -i -e s/0.0.0/$(cola_version)/ $(cola_app)/Contents/Info.plist
142 $(CP) contrib/darwin/git-cola $(cola_app)/Contents/MacOS
143 $(CP) contrib/darwin/git-cola.icns $(cola_app)/Contents/Resources
144 $(MAKE) PIP=$(cola_app_resources)/bin/pip \
145 prefix=$(cola_app_resources) install
146 $(MAKE) SPHINXBUILD=$(cola_app_resources)/bin/sphinx-build \
147 prefix=$(cola_app_resources) install-doc
149 .PHONY: test
150 test::
151 @if type garden >/dev/null 2>&1; then \
152 garden test; \
153 else \
154 echo 'warning: "make test" requires "garden" https://gitlab.com/garden-rs/garden'; \
155 echo 'tip: run "cargo install garden-tools" to install "garden".'; \