File size: 3,961 Bytes
7578e9d
 
 
 
 
 
 
 
 
 
 
 
 
 
a19d10a
 
 
 
 
7578e9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b0bd61
 
 
 
 
 
 
 
 
 
 
 
 
 
a19d10a
7b0bd61
 
a19d10a
7b0bd61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
prefix = /usr/local

all:
	./po2mo.sh

clean:
	if [ -d $(srcdir)share/locale ]; then \
		rm -r $(srcdir)share/locale; \
	fi
install: all
	install -Dm644 $(srcdir)COPYING $(prefix)/share/doc/shutter/COPYING
	install -Dm644 $(srcdir)README $(prefix)/share/doc/shutter/README
	install -Dm755 $(srcdir)bin/shutter $(prefix)/bin/shutter
	cp -r $(srcdir)share/ $(prefix)/
	mkdir -p $(prefix)/share/shutter/lib
	cp -r $(srcdir)lib/. $(prefix)/share/shutter/lib/
	# compat: third-party plugins load modules from resources/modules
	rm -rf $(prefix)/share/shutter/resources/modules
	ln -s ../lib $(prefix)/share/shutter/resources/modules

uninstall:
	rm $(prefix)/bin/shutter
	rm $(prefix)/share/metainfo/shutter.metainfo.xml
	rm $(prefix)/share/applications/shutter.desktop
	rm -r $(prefix)/share/doc/shutter/
	rm $(prefix)/share/man/man1/shutter.1
	rm $(prefix)/share/pixmaps/shutter.png
	rm -r $(prefix)/share/shutter/
	rm $(prefix)/share/icons/HighContrast/scalable/apps/shutter.svg
	rm $(prefix)/share/icons/HighContrast/scalable/apps/shutter-panel.svg
	for size in 128x128  16x16  192x192  22x22  24x24  256x256  32x32  36x36  48x48  64x64  72x72  96x96; do \
		rm $(prefix)/share/icons/hicolor/$$size/apps/shutter.png; \
	done
	for size in 16x16 22x22 24x24; do \
		rm $(prefix)/share/icons/hicolor/$$size/apps/shutter-panel.png; \
	done
	rm $(prefix)/share/icons/hicolor/scalable/apps/shutter-panel.svg
	rm $(prefix)/share/icons/hicolor/scalable/apps/shutter.svg
	for locale in $(prefix)/share/locale/*; do \
		for mofile in shutter.mo shutter-plugins.mo shutter-upload-plugins.mo; do \
			if [ -f $$locale/LC_MESSAGES/$$mofile ]; then \
				rm $$locale/LC_MESSAGES/$$mofile; \
			fi \
		done \
	done

# ---------------------------------------------------------------------------
# Quality gates
#
#   make test   full suite incl. end-to-end smoke test, in a private X11
#               session (t/bin/with-x11: Xvfb + openbox + D-Bus, Wayland env
#               stripped). VISIBLE=1 uses Xephyr so you can watch it.
#   make boot   start bin/shutter for 15s and fail on Perl runtime errors
#   make lint   perltidy + perlcritic, enforced only on files added since the
#               fork point (ratchet: legacy code is not blocked, new code is)
#   make check  lint + test; run before every commit
# ---------------------------------------------------------------------------

FORK_POINT  ?= 43b5243
TEST_INC     = -I lib -I t/lib
WITH_X11     = t/bin/with-x11
BOOT_ERRORS  = Undefined subroutine|Can't locate|Global symbol|Not a CODE|Can't call method|syntax error|died|Bareword
NEW_PERL     = $(sort $(shell git diff --name-only --diff-filter=A $(FORK_POINT) -- '*.pm' '*.pl' '*.t' 2>/dev/null) \
                      $(shell git ls-files --others --exclude-standard -- '*.pm' '*.pl' '*.t' 2>/dev/null))

.PHONY: test test-unit boot lint check

test:
	SHUTTER_SMOKE_REQUIRED=1 $(WITH_X11) prove $(TEST_INC) -r t

# Everything except the smoke test (faster inner loop)
test-unit:
	$(WITH_X11) prove $(TEST_INC) -r t/Shutter t/syntax.t

# No window manager here, so the app idles in its main loop until killed;
# that is expected. We only care that startup produced no Perl errors.
boot:
	@h=$$(mktemp -d); \
	HOME=$$h XDG_CONFIG_HOME=$$h/.config XDG_CACHE_HOME=$$h/.cache \
		$(WITH_X11) timeout -k 3 15 perl bin/shutter --debug -n --disable_systray > $$h/boot.log 2>&1; \
	if grep -nE "$(BOOT_ERRORS)" $$h/boot.log; then echo "boot: FAILED (log: $$h/boot.log)"; exit 1; fi; \
	echo "boot: OK (no Perl runtime errors in 15s of startup)"; rm -rf $$h

lint:
	@if [ -z "$(NEW_PERL)" ]; then echo "lint: no files added since $(FORK_POINT)"; exit 0; fi; \
	fail=0; \
	for f in $(NEW_PERL); do \
		perltidy --profile=.perltidyrc -st "$$f" | cmp -s - "$$f" || { echo "perltidy: $$f is not tidy (run: perltidy --profile=.perltidyrc -b -bext='/' $$f)"; fail=1; }; \
	done; \
	perlcritic --profile .perlcriticrc $(NEW_PERL) || fail=1; \
	exit $$fail

check: lint test