-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
110 lines (79 loc) · 1.94 KB
/
Makefile
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
# Commands expected to be pre-installed
COMPOSER_CMD=composer
PHIVE_CMD=phive
GPG_CMD=gpg
GIT_CMD=git
# Tools installed by this script
BEHAT_CMD=tools/behat
BOX_CMD=tools/box
PHPCS_CMD=tools/phpcs
PHPSTAN_CMD=tools/phpstan
# Setup
TARGET=autogiro2xml.phar
DESTDIR=/usr/local/bin
VERSION=VERSION
SIGNATURE=${TARGET}.asc
SIGNATURE_ID=hannes.forsgard@fripost.org
SRC_FILES:=$(shell find src/ bin/ -type f)
.DEFAULT_GOAL=all
.PHONY: all clean
all: test analyze build check
clean:
rm $(TARGET) --interactive=no -f
rm $(VERSION) --interactive=no -f
rm $(SIGNATURE) --interactive=no -f
rm -rf vendor
rm -rf tools
#
# Build and sign
#
.PHONY: build build_release sign
build:
rm -rf $(VERSION)
make $(TARGET)
build_release: all sign
$(TARGET): vendor/installed $(SRC_FILES) box.json $(VERSION) $(BOX_CMD)
$(BOX_CMD) compile
sign: $(SIGNATURE)
$(SIGNATURE): $(TARGET)
rm -rf $@
$(GPG_CMD) -u $(SIGNATURE_ID) --detach-sign --output $@ $<
$(VERSION):
-$(GIT_CMD) describe > $@
#
# Install/uninstall
#
.PHONY: install uninstall
install: $(TARGET)
mkdir -p $(DESTDIR)
cp $< $(DESTDIR)/`basename "$(TARGET)" .phar`
uninstall:
rm -f $(DESTDIR)/`basename "$(TARGET)" .phar`
#
# Tests and analysis
#
.PHONY: analyze test check phpstan phpcs
analyze: phpstan phpcs
test: vendor/installed $(BEHAT_CMD)
$(BEHAT_CMD) --stop-on-failure --suite=default
check: $(TARGET) $(BEHAT_CMD)
$(BEHAT_CMD) --stop-on-failure --suite=phar
phpstan: vendor/installed $(PHPSTAN_CMD)
$(PHPSTAN_CMD) analyze -l 8 src
phpcs: $(PHPCS_CMD)
$(PHPCS_CMD)
#
# Dependencies
#
composer.lock: composer.json
@echo composer.lock is not up to date
vendor/installed: composer.lock
$(COMPOSER_CMD) install
touch $@
tools/installed: .phive/phars.xml
$(PHIVE_CMD) install --force-accept-unsigned --trust-gpg-keys CF1A108D0E7AE720,31C7E470E2138192,0FD3A3029E470F86
touch $@
$(BEHAT_CMD): tools/installed
$(BOX_CMD): tools/installed
$(PHPCS_CMD): tools/installed
$(PHPSTAN_CMD): tools/installed