-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
GNUmakefile
84 lines (69 loc) · 2.38 KB
/
GNUmakefile
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
VERSION=`cat VERSION`
DIST_DIR=update.sh-$(VERSION)
DIST_FILES=update.sh VERSION README.md NEWS.md Makefile COPYRIGHT.md COPYING.md ChangeLog update.sh.completion
FORMATTED_FILES=update.sh VERSION README.md NEWS.md COPYRIGHT.md COPYING.md RELEASE_NOTES.md publish_release.sh update.sh.completion
SHELLCHECK_FILES=update.sh publish_release.sh
YEAR=`date +"%Y"`
dist: version_check formatting_check copyright_check shellcheck
rm -rf $(DIST_DIR) $(DIST_DIR).tar.gz
mkdir $(DIST_DIR)
cp -r $(DIST_FILES) $(DIST_DIR)
# avoid to include extended attribute data files
# see https://superuser.com/questions/259703/get-mac-tar-to-stop-putting-filenames-in-tar-archives
export COPY_EXTENDED_ATTRIBUTES_DISABLE=1; \
export COPYFILE_DISABLE=1; \
tar cfz $(DIST_DIR).tar.gz $(DIST_DIR)
tar cfj $(DIST_DIR).tar.bz2 $(DIST_DIR)
CODESPELL := $(shell command -v codespell 2> /dev/null )
# spell check
codespell:
ifndef CODESPELL
echo "no codespell installed"
else
codespell \
.
endif
remove_blanks:
sed -i '' 's/[[:blank:]]*$$//' $(DIST_FILES)
formatting_check:
! grep -q '\\t' $(FORMATTED_FILES)
! grep -q '[[:blank:]]$$' $(DIST_FILES)
SHFMT= := $(shell command -v shfmt 2> /dev/null)
format:
ifndef SHFMT
echo "No shfmt installed"
else
# -p POSIX
# -w write to file
# -s simplify
# -i 4 indent with 4 spaces
shfmt -p -w -s -i 4 $(SHELLCHECK_FILES)
endif
version_check:
grep -q "VERSION\ *=\ *[\'\"]*$(VERSION)" update.sh
grep -q "${VERSION}" NEWS.md
echo "Version check: OK"
copyright_check:
grep -q "© Matteo Corti, 2018-$(YEAR)" README.md
grep -q "Copyright © 2018-$(YEAR) Matteo Corti" COPYRIGHT.md
grep -q "Copyright (c) 2018-$(YEAR) Matteo Corti <matteo@corti.li>" update.sh
echo "Copyright year check: OK"
SHELLCHECK := $(shell command -v shellcheck 2> /dev/null)
shellcheck:
ifndef SHELLCHECK
echo "No shellcheck installed: skipping test"
else
if shellcheck --help 2>&1 | grep -q -- '-o\ ' ; then shellcheck -o all $(SHELLCHECK_FILES) ; else shellcheck $(SHELLCHECK_FILES) ; fi
endif
COMPLETIONS_DIR := $(shell pkg-config --variable=completionsdir bash-completion)
install_bash_completion:
ifdef COMPLETIONS_DIR
cp update.sh.completion $(COMPLETIONS_DIR)/update.sh
endif
install:
cp update.sh /usr/local/bin
clean:
rm -rf *~ *.bak
distclean: clean
rm -rf update.sh-[0-9]*
.PHONY: distclean version_check copyright_check remove_blanks dist codespell clean install install_completion