File: Makefile

package info (click to toggle)
play.it 2.34.2-3
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 1,392 kB
  • sloc: sh: 16,456; makefile: 95
file content (135 lines) | stat: -rw-r--r-- 4,769 bytes parent folder | download
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
# Build the library

.PHONY: all clean

all: lib/libplayit2.sh

lib/libplayit2.sh: src/*/*.sh
	mkdir --parents lib
	find src -type f -name '*.sh' -print0 | LC_ALL=C sort -z | xargs -0 cat > lib/libplayit2.sh

clean:
	rm --force lib/libplayit2.sh


# Install the library, main script, and man pages

.PHONY: install uninstall

## Set the default install paths
UID := $(shell id --user)
ifeq ($(UID),0)
    prefix = /usr/local
    bindir = $(prefix)/games
    datadir = $(prefix)/share/games
    mandir = $(prefix)/share/man
    zshdir = $(prefix)/share/zsh
    fishdir = $(prefix)/share/fish
else
    ifeq ($(XDG_DATA_HOME),)
        XDG_DATA_HOME := $(HOME)/.local/share
    endif
    prefix = $(XDG_DATA_HOME)
    bindir = $(HOME)/.local/bin
    datadir = $(prefix)
    mandir = $(prefix)/man
    zshdir = $(prefix)/zsh
    fishdir = $(prefix)/fish
endif

install: all
	install -D --mode=644 lib/libplayit2.sh $(DESTDIR)$(datadir)/play.it/libplayit2.sh
	install -D --mode=755 play.it $(DESTDIR)$(bindir)/play.it
	install -D --mode=644 man/man6/play.it.6 $(DESTDIR)$(mandir)/man6/play.it.6
	install -D --mode=644 man/fr/man6/play.it.6 $(DESTDIR)$(mandir)/fr/man6/play.it.6

uninstall: uninstall-completion
	rm --force $(DESTDIR)$(bindir)/play.it $(DESTDIR)$(datadir)/play.it/libplayit2.sh $(DESTDIR)$(mandir)/man6/play.it.6 $(DESTDIR)$(mandir)/fr/man6/play.it.6
	rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir) $(DESTDIR)$(datadir)/play.it $(DESTDIR)$(mandir)/man6 $(DESTDIR)$(mandir)/fr/man6


# Install shell completion

.PHONY: install-completion-all install-completion-zsh install-completion-fish uninstall-completion

install-completion-all: install-completion-zsh install-completion-fish

install-completion-zsh:
	install -D --mode=644 shell-completions/zsh/_play.it $(DESTDIR)$(zshdir)/vendor-completions/_play.it

install-completion-fish:
	install -D --mode=644 shell-completions/fish/play.it.fish $(DESTDIR)$(fishdir)/vendor_completions.d/play.it.fish

uninstall-completion:
	rm --force $(DESTDIR)$(zshdir)/vendor-completions/_play.it
	rm --force $(DESTDIR)$(fishdir)/vendor_completions.d/play.it.fish
	test -d $(DESTDIR)$(zshdir)/vendor-completions && \
		rmdir --parents --ignore-fail-on-non-empty $(DESTDIR)$(zshdir)/vendor-completions || true
	test -d $(DESTDIR)$(fishdir)/vendor_completions.d && \
		rmdir --parents --ignore-fail-on-non-empty $(DESTDIR)$(fishdir)/vendor_completions.d || true


# Release preparation

.PHONY: dist

## The generated tarball is signed with gpg by default,
## NO_SIGN should be set to a non-0 value to skip the signature.
NO_SIGN := 0

dist: VERSION = $(shell head --lines=1 CHANGELOG)
dist: TARBALL = play.it-$(VERSION).tar.gz
dist: TAR_OPTIONS := --sort=name --mtime=2017-06-14 --owner=root:0 --group=root:0 --use-compress-program='gzip --no-name'
dist: CHANGELOG LICENSE README.md Makefile play.it man/man6/play.it.6 man/fr/man6/play.it.6 shell-completions/zsh/_play.it shell-completions/fish/play.it.fish src/*/*.sh tests/shunit2/*.sh
	mkdir --parents dist
	LC_ALL=C tar cf dist/$(TARBALL) $(TAR_OPTIONS) \
		   CHANGELOG \
		   LICENSE \
		   README.md \
		   Makefile \
		   play.it \
		   man/man6/play.it.6 \
		   man/fr/man6/play.it.6 \
		   shell-completions/zsh/_play.it \
		   shell-completions/fish/play.it.fish \
		   src/*/*.sh \
		   tests/shunit2/*.sh
ifeq ($(NO_SIGN),0)
	rm --force dist/$(TARBALL).asc
	gpg --armor --detach-sign dist/$(TARBALL)
endif


# Run tests, including:
# - syntax checks, relying on ShellCheck
# - regression tests, relying on shUnit2
# - man page syntax check

.PHONY: check shellcheck-library shellcheck-wrapper shunit2 man-syntax

check: shellcheck-library shellcheck-wrapper shunit2 man-syntax

## This is a unicode quote. Delete and retype it (or ignore/doublequote for literal).
shellcheck-library: SHELLCHECK_EXCLUDE += --exclude=SC1112
## Expressions don't expand in single quotes, use double quotes for that.
shellcheck-library: SHELLCHECK_EXCLUDE += --exclude=SC2016
## Double quote to prevent globbing and word splitting.
shellcheck-library: SHELLCHECK_EXCLUDE += --exclude=SC2086
## In POSIX sh, local is undefined.
shellcheck-library: SHELLCHECK_EXCLUDE += --exclude=SC3043
shellcheck-library:
	shellcheck --shell=sh $(SHELLCHECK_EXCLUDE) lib/libplayit2.sh

shellcheck-wrapper:
	shellcheck --external-sources --shell=sh play.it

SHUNIT2_SCRIPTS := $(wildcard tests/shunit2/*.sh)
SHUNIT2_TESTS := $(addprefix shunit2_, $(SHUNIT2_SCRIPTS))
.PHONY: $(SHUNIT2_TESTS)
shunit2: $(SHUNIT2_TESTS)
$(SHUNIT2_TESTS): shunit2_%: %
	shunit2 $<

man-syntax:
	man --warnings --encoding=UTF-8 --local-file --troff-device=utf8 --ditroff man/man6/play.it.6 >/dev/null
	man --warnings --encoding=UTF-8 --local-file --troff-device=utf8 --ditroff man/fr/man6/play.it.6 >/dev/null