Codebase list guake / HEAD Makefile
HEAD

Tree @HEAD (Download .tar.gz)

Makefile @HEADraw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
.PHONY: build dev

PYTHON?=python3
PYTHON_INTERPRETER?=$(PYTHON)
MODULE:=guake
DESTDIR:=/
PREFIX?=/usr/local
exec_prefix:=$(PREFIX)
bindir = $(exec_prefix)/bin

# Use site.getsitepackages([PREFIX]) to guess possible install paths for uninstall.
PYTHON_SITEDIRS_FOR_PREFIX="env PREFIX=$(PREFIX) $(PYTHON_INTERPRETER) scripts/all-sitedirs-in-prefix.py"
ROOT_DIR=$(shell pwd)
DATA_DIR=$(ROOT_DIR)/guake/data
COMPILE_SCHEMA:=1

datarootdir:=$(PREFIX)/share
datadir:=$(datarootdir)
localedir:=$(datarootdir)/locale
gsettingsschemadir:=$(datarootdir)/glib-2.0/schemas

AUTOSTART_FOLDER:=~/.config/autostart

DEV_DATA_DIR:=$(DATA_DIR)

SHARE_DIR:=$(datadir)/guake
GUAKE_THEME_DIR:=$(SHARE_DIR)/guake
LOGIN_DESTOP_PATH = $(SHARE_DIR)
IMAGE_DIR:=$(SHARE_DIR)/pixmaps
GLADE_DIR:=$(SHARE_DIR)
SCHEMA_DIR:=$(gsettingsschemadir)

SLUG:=fragment_name

default: prepare-install
	# 'make' target, so users can install guake without need to install the 'dev' dependencies

prepare-install: generate-desktop generate-paths generate-mo compile-glib-schemas-dev

reset:
	dconf reset -f /org/guake/


all: clean dev style checks dists test docs

dev: clean-ln-venv ensure-pip pipenv-install-dev requirements ln-venv setup-githook \
	 prepare-install install-dev-locale
dev-actions: ensure-pip-system pipenv-install-dev prepare-install

ensure-pip:
	./scripts/bootstrap-dev-pip.sh

ensure-pip-system:
	./scripts/bootstrap-dev-pip.sh system

dev-no-pipenv: clean
	virtualenv --python $(PYTHON_INTERPRETER) .venv
	. .venv/bin/activate && pip install -r requirements.txt -r requirements-dev.txt -e .

pipenv-install-dev:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv install --dev --python $(PYTHON_INTERPRETER)

ln-venv:
	# use that to configure a symbolic link to the virtualenv in .venv
	rm -rf .venv
	ln -s $$(pipenv --venv) .venv

clean-ln-venv:
	@rm -f .venv

install-system: install-schemas compile-shemas install-locale install-guake

install-guake:
	# you probably want to execute this target with sudo:
	# sudo make install
	@echo "#############################################################"
	@echo
	@echo "Installing from source on your system is not recommended."
	@echo "Please prefer you application package manager (apt, yum, ...)"
	@echo
	@echo "#############################################################"
	@if [ "$(DESTDIR)" = "" ]; then $(PYTHON_INTERPRETER) -m pip install -r requirements.txt; fi

	@if [ `python -c "import sys; print(sys.version_info[0])"` -eq 2 ]; then SETUPTOOLS_SCM_PRETEND_VERSION=3.9.0; fi

	@rm -f guake/paths.py.dev
	@if [ -f guake/paths.py ]; then mv guake/paths.py guake/paths.py.dev; fi
	@cp -f guake/paths.py.in guake/paths.py
	@sed -i -e 's|{{ LOCALE_DIR }}|"$(localedir)"|g' guake/paths.py
	@sed -i -e 's|{{ IMAGE_DIR }}|"$(IMAGE_DIR)"|g' guake/paths.py
	@sed -i -e 's|{{ GLADE_DIR }}|"$(GLADE_DIR)"|g' guake/paths.py
	@sed -i -e 's|{{ GUAKE_THEME_DIR }}|"$(GUAKE_THEME_DIR)"|g' guake/paths.py
	@sed -i -e 's|{{ SCHEMA_DIR }}|"$(SCHEMA_DIR)"|g' guake/paths.py
	@sed -i -e 's|{{ LOGIN_DESTOP_PATH }}|"$(LOGIN_DESTOP_PATH)"|g' guake/paths.py
	@sed -i -e 's|{{ AUTOSTART_FOLDER }}|"$(AUTOSTART_FOLDER)"|g' guake/paths.py

	@$(PYTHON_INTERPRETER) -m pip install . --root "$(DESTDIR)" --prefix="/usr" || echo -e "\033[31;1msetup.py install failed, you may need to run \"sudo git config --global --add safe.directory '*'\"\033[0m"

	@rm -f guake/paths.py
	@if [ -f guake/paths.py.dev ]; then mv guake/paths.py.dev guake/paths.py; fi

	@update-desktop-database || echo "Could not run update-desktop-database, are you root?"
	@rm -rfv build *.egg-info

install-locale:
	for f in $$(find po -iname "*.mo"); do \
		l="$${f%%.*}"; \
		lb=$$(basename $$l); \
		install -Dm644 "$$f" "$(DESTDIR)$(localedir)/$$lb/LC_MESSAGES/guake.mo"; \
	done;

install-dev-locale:
	for f in $$(find po -iname "*.mo"); do \
		l="$${f%%.*}"; \
		lb=$$(basename $$l); \
		install -Dm644 "$$f" "guake/po/$$lb/LC_MESSAGES/guake.mo"; \
	done;

uninstall-locale:
	find $(DESTDIR)$(localedir)/ -name "guake.mo" -exec rm -f "{}" + || :
	# prune two levels of empty locale/ subdirs
	find "$(DESTDIR)$(localedir)" -type d -a -empty -exec rmdir "{}" + || :
	find "$(DESTDIR)$(localedir)" -type d -a -empty -exec rmdir "{}" + || :

uninstall-dev-locale:
	@rm -rf guake/po

install-schemas:
	install -dm755                                       "$(DESTDIR)$(datadir)/applications"
	install -Dm644 "$(DEV_DATA_DIR)/guake.desktop"       "$(DESTDIR)$(datadir)/applications/"
	install -Dm644 "$(DEV_DATA_DIR)/guake-prefs.desktop" "$(DESTDIR)$(datadir)/applications/"
	install -dm755                                       "$(DESTDIR)$(datadir)/metainfo/"
	install -Dm644 "$(DEV_DATA_DIR)/guake.desktop.metainfo.xml"  "$(DESTDIR)$(datadir)/metainfo/"
	install -dm755                                 "$(DESTDIR)$(IMAGE_DIR)"
	install -Dm644 "$(DEV_DATA_DIR)"/pixmaps/*.png "$(DESTDIR)$(IMAGE_DIR)/"
	install -Dm644 "$(DEV_DATA_DIR)"/pixmaps/*.svg "$(DESTDIR)$(IMAGE_DIR)/"
	install -dm755                                     "$(DESTDIR)$(PREFIX)/share/pixmaps"
	install -Dm644 "$(DEV_DATA_DIR)/pixmaps/guake.png" "$(DESTDIR)$(PREFIX)/share/pixmaps/"
	install -dm755                                           "$(DESTDIR)$(SHARE_DIR)"
	install -Dm644 "$(DEV_DATA_DIR)/autostart-guake.desktop" "$(DESTDIR)$(SHARE_DIR)/"
	install -dm755                           "$(DESTDIR)$(GLADE_DIR)"
	install -Dm644 "$(DEV_DATA_DIR)"/*.glade "$(DESTDIR)$(GLADE_DIR)/"
	install -dm755                                         "$(DESTDIR)$(SCHEMA_DIR)"
	install -Dm644 "$(DEV_DATA_DIR)/org.guake.gschema.xml" "$(DESTDIR)$(SCHEMA_DIR)/"

compile-shemas:
	if [ $(COMPILE_SCHEMA) = 1 ]; then glib-compile-schemas $(DESTDIR)$(gsettingsschemadir); fi

uninstall-system: uninstall-schemas uninstall-locale
	$(SHELL) -c $(PYTHON_SITEDIRS_FOR_PREFIX) \
		| while read sitedir; do \
			echo "rm -rf $(DESTDIR)$$sitedir/{guake,guake-*.egg-info}"; \
			rm -rf $(DESTDIR)$$sitedir/guake; \
			rm -rf $(DESTDIR)$$sitedir/guake-*.egg-info; \
		done
	rm -f "$(DESTDIR)$(bindir)/guake"
	rm -f "$(DESTDIR)$(bindir)/guake-prefs"
	rm -f "$(DESTDIR)$(bindir)/guake-toggle"

purge-system: uninstall-system reset

uninstall-schemas:
	rm -f "$(DESTDIR)$(datadir)/applications/guake.desktop"
	rm -f "$(DESTDIR)$(datadir)/applications/guake-prefs.desktop"
	rm -f "$(DESTDIR)$(datadir)/metainfo/guake.desktop.metainfo.xml"
	rm -f "$(DESTDIR)$(datadir)/pixmaps/guake.png"
	rm -fr "$(DESTDIR)$(IMAGE_DIR)"
	rm -fr "$(DESTDIR)$(SHARE_DIR)"
	rm -f "$(DESTDIR)$(SCHEMA_DIR)/org.guake.gschema.xml"
	rm -f "$(DESTDIR)$(SCHEMA_DIR)/gschemas.compiled"

reinstall:
	sudo make uninstall && make && sudo make install && $(DESTDIR)$(bindir)/guake

reinstall-v:
	sudo make uninstall && make && sudo make install && $(DESTDIR)$(bindir)/guake -v

compile-glib-schemas-dev: clean-schemas
	glib-compile-schemas --strict $(DEV_DATA_DIR)

clean-schemas:
	rm -f $(DEV_DATA_DIR)/gschemas.compiled

style:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run pre-commit run --all-files

black:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run black $(MODULE)


checks: black-check flake8 pylint reno-lint

black-check:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run black --check $(MODULE) --extend-exclude $(MODULE)/_version.py

flake8:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run flake8 guake

pylint:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run pylint --rcfile=.pylintrc --output-format=colorized $(MODULE)

sc: style check

dists: update-po requirements prepare-install rm-dists sdist bdist wheels
build: dists

sdist: generate-paths
	export SKIP_GIT_SDIST=1 && PIPENV_IGNORE_VIRTUALENVS=1 pipenv run python setup.py sdist

rm-dists:
	rm -rf build dist

bdist: generate-paths
	# pipenv run python setup.py bdist
	@echo "Ignoring build of bdist package"

wheels: generate-paths
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run python setup.py bdist_wheel

wheel: wheels

run-local: compile-glib-schemas-dev
ifdef V
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run ./scripts/run-local.sh -v
else
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run ./scripts/run-local.sh
endif

run-local-prefs: compile-glib-schemas-dev
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run ./scripts/run-local-prefs.sh

run-fr: compile-glib-schemas-dev
	LC_ALL=fr_FR.UTF8 PIPENV_IGNORE_VIRTUALENVS=1 pipenv run ./scripts/run-local.sh


shell:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv shell


test:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run pytest $(MODULE)

test-actions:
	xvfb-run -a pipenv run pytest $(MODULE)
test-coverage:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run py.test -v --cov $(MODULE) --cov-report term-missing

test-pip-install-sdist: clean-pip-install-local generate-paths sdist
	@echo "Testing installation by pip (will install on ~/.local)"
	pip install --upgrade -vvv --user $(shell ls -1 dist/*.tar.gz | sort | head -n 1)
	ls -la ~/.local/share/guake
	~/.local/bin/guake

clean-pip-install-local:
	@rm -rfv ~/.local/guake
	@rm -rfv ~/.local/bin/guake
	@rm -rfv ~/.local/lib/python3.*/site-packages/guake
	@rm -rfv ~/.local/share/guake

test-pip-install-wheel: clean-pip-install-local generate-paths wheel
	@echo "Testing installation by pip (will install on ~/.local)"
	pip install --upgrade -vvv --user $(shell ls -1 dist/*.whl | sort | head -n 1)
	ls -la ~/.local/share/guake
	~/.local/bin/guake -v

sct: style check update-po requirements test


docs: clean-docs sdist
	cd docs && PIPENV_IGNORE_VIRTUALENVS=1 pipenv run make html

docs-open:
	xdg-open docs/_build/html/index.html

tag-pbr:
	@{ \
		set -e ;\
		export VERSION=$$(PIPENV_IGNORE_VIRTUALENVS=1 pipenv run python setup.py --version | cut -d. -f1,2,3); \
		echo "I: Computed new version: $$VERSION"; \
		echo "I: presse ENTER to accept or type new version number:"; \
		read VERSION_OVERRIDE; \
		VERSION=$${VERSION_OVERRIDE:-$$VERSION}; \
		PROJECTNAME=$$(PIPENV_IGNORE_VIRTUALENVS=1 pipenv run python setup.py --name); \
		echo "I: Tagging $$PROJECTNAME in version $$VERSION with tag: $$VERSION" ; \
		echo "$$ git tag $$VERSION -m \"$$PROJECTNAME $$VERSION\""; \
		git tag $$VERSION -m "$$PROJECTNAME $$VERSION"; \
		echo "I: Pushing tag $$VERSION, press ENTER to continue, C-c to interrupt"; \
		echo "$$ git push upstream $$VERSION"; \
	}
	@# Note:
	@# To sign, need gpg configured and the following command:
	@#  git tag -s $$VERSION -m \"$$PROJECTNAME $$VERSION\""

pypi-publish: build
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run python setup.py upload -r pypi


update:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv update --clear
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv install --dev


lock: pipenv-lock requirements

requirements:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run pipenv_to_requirements

pipenv-lock:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv lock


freeze:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run pip freeze


setup-githook:
	rm -f .git/hooks/post-commit
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run pre-commit install


push:
	git push origin --tags


clean: clean-ln-venv rm-dists clean-docs clean-po clean-schemas clean-py clean-paths uninstall-dev-locale
	@echo "clean successful"

clean-py:
	@pipenv --rm ; true
	@find . -name "*.pyc" -exec rm -f {} \;
	@rm -f $(DEV_DATA_DIR)/guake-prefs.desktop $(DEV_DATA_DIR)/guake.desktop
	@rm -rf .eggs *.egg-info po/*.pot

clean-paths:
	rm -f guake/paths.py guake/paths.py.dev

clean-po:
	@rm -f po/guake.pot
	@find po -name "*.mo" -exec rm -f {} \;

clean-docs:
	rm -rf doc/_build

update-po:
	echo "generating pot file"
	@find guake -iname "*.py" | xargs xgettext --from-code=UTF-8 --output=guake-python.pot
	@find $(DEV_DATA_DIR) -iname "*.glade" | sed -E "s#$(ROOT_DIR)/##g" | xargs xgettext --from-code=UTF-8 \
	                                                  -L Glade \
	                                                  --output=guake-glade.pot
	@(\
	    find $(DEV_DATA_DIR) -iname "*.desktop" | sed -E "s#$(ROOT_DIR)/##g" | xargs xgettext --from-code=UTF-8 \
		                                                  -L Desktop \
	                                                      --output=guake-desktop.pot \
	) || ( \
	    echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
	    touch guake-desktop.pot)
	@msgcat --use-first guake-python.pot guake-glade.pot guake-desktop.pot > po/guake.pot
	@rm guake-python.pot guake-glade.pot guake-desktop.pot
	@for f in $$(find po -iname "*.po"); do \
	    echo "updating $$f"; \
	    msgcat --use-first "$$f" po/guake.pot > "$$f.new"; \
	    mv "$$f.new" $$f; \
	done;

pot: update-po

generate-mo:
	@for f in $$(find po -iname "*.po"); do \
	    echo "generating $$f"; \
		l="$${f%%.*}"; \
		msgfmt "$$f" -o "$$l.mo"; \
	done;


generate-desktop:
	@echo "generating desktop files"
	@msgfmt --desktop --template=$(DEV_DATA_DIR)/guake.template.desktop \
		   -d po \
		   -o $(DEV_DATA_DIR)/guake.desktop || ( \
			   	echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
				cp $(DEV_DATA_DIR)/guake.template.desktop $(DEV_DATA_DIR)/guake.desktop)
	@msgfmt --desktop --template=$(DEV_DATA_DIR)/guake-prefs.template.desktop \
		   -d po \
		   -o $(DEV_DATA_DIR)/guake-prefs.desktop || ( \
			   	echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
				cp $(DEV_DATA_DIR)/guake-prefs.template.desktop $(DEV_DATA_DIR)/guake-prefs.desktop)

generate-paths:
	@echo "Generating path.py..."
	@cp -f guake/paths.py.in guake/paths.py
	@# Generic
	@sed -i -e 's|{{ LOGIN_DESTOP_PATH }}|""|g' guake/paths.py
	@sed -i -e 's|{{ AUTOSTART_FOLDER }}|""|g' guake/paths.py
	@# Dev environment:
	@sed -i -e 's|{{ LOCALE_DIR }}|get_default_locale_dir()|g' guake/paths.py
	@sed -i -e 's|{{ IMAGE_DIR }}|get_default_image_dir()|g' guake/paths.py
	@sed -i -e 's|{{ GUAKE_THEME_DIR }}|get_default_theme_dir()|g' guake/paths.py
	@sed -i -e 's|{{ GLADE_DIR }}|get_default_glade_dir()|g' guake/paths.py
	@sed -i -e 's|{{ SCHEMA_DIR }}|get_default_schema_dir()|g' guake/paths.py

reno:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run reno new $(SLUG) --edit

reno-lint:
	PIPENV_IGNORE_VIRTUALENVS=1 pipenv run reno -q lint

release-note: release-note-github

release-note-github: reno-lint
	@echo
	@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
	@echo "!! Generating release note for GitHub !!"
	@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
	@echo "-------- copy / paste from here --------"
	@# markdown_github to be avoided => gfm output comes in pandoc 2.0.4 release dec 2017
	@pipenv run reno report --earliest-version 3.8.3 --no-show-source --collapse-pre-releases 2>/dev/null | \
		pandoc -f rst -t markdown --markdown-headings=atx --wrap=none --tab-stop 2 | \
		tr '\n' '\r' | \
			sed 's/\r<!-- -->\r//g' | \
			sed 's/\r\-\ \r\r\ /\r-/g' | \
			sed 's/\r\ \ \:\ \ \ /\r    /g' | \
			sed 's/\r\r\ \ \ \ \-\ /\r    - /g' | \
			sed 's/\r\ \ \ \ \-\ /\r  - /g' | \
			sed 's/\r\ \ >\ \-\ /\r  - /g' | \
			sed 's/\\\#/\#/g' | \
		tr '\r' '\n'

# aliases to gracefully handle typos on poor dev's terminal
check: checks
devel: dev
develop: dev
dist: dists
doc: docs
install: install-system
purge: purge-system
pypi: pypi-publish
run: run-local
run-prefs: run-local-prefs
styles: style
uninstall: uninstall-system
upgrade: update
wheel: wheels