forked from easyrdf/easyrdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
151 lines (123 loc) · 4.13 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
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
PACKAGE = easyrdf
VERSION = $(shell php -r "print json_decode(file_get_contents('composer.json'))->version;")
distdir = $(PACKAGE)-$(VERSION)
PHP = $(shell which php)
COMPOSER_FLAGS=--no-ansi --no-interaction
PHPUNIT = vendor/bin/phpunit
PHPUNIT_FLAGS = -c config/phpunit.xml
PHPCS = vendor/bin/phpcs
PHPCS_FLAGS = --standard=./config/phpcs_ruleset.xml --encoding=utf8 --extensions=php
SAMI = vendor/bin/sami.php
# Composer doesn't work with bsdtar - try and use GNU tar
TAR = $(shell which gtar || which gnutar || which tar)
# Disable copying extended attributes and resource forks on Mac OS X
export COPYFILE_DISABLE=true
EXAMPLE_FILES = examples/*.php
SOURCE_FILES = lib/*.php \
lib/*/*.php
TEST_FILES = test/*/*Test.php \
test/*/*/*Test.php
TEST_SUPPORT = Makefile test/cli_example_wrapper.php \
test/TestHelper.php \
test/EasyRdf/TestCase.php \
test/EasyRdf/Http/MockClient.php \
test/EasyRdf/Serialiser/NtriplesArray.php \
test/fixtures/*
DOC_FILES = docs/*.md \
docs/api
INFO_FILES = composer.json \
doap.rdf \
README.md \
LICENSE.md \
CHANGELOG.md
DISTFILES = $(EXAMPLE_FILES) $(SOURCE_FILES) $(TEST_FILES) \
$(TEST_SUPPORT) $(INFO_FILES) $(DOC_FILES)
.DEFAULT: help
all: help
# TARGET:test Run all the PHPUnit tests
.PHONY: test
test: $(PHPUNIT)
mkdir -p reports
$(PHP) $(PHPUNIT) $(PHPUNIT_FLAGS)
# TARGET:test-examples Run PHPUnit tests for each of the examples
.PHONY: test-examples
test-examples: $(PHPUNIT)
mkdir -p reports
$(PHP) $(PHPUNIT) $(PHPUNIT_FLAGS) --testsuite "EasyRdf Examples"
# TARGET:test-lib Run PHPUnit tests for the library
.PHONY: test-lib
test-lib: $(PHPUNIT)
mkdir -p reports
$(PHP) $(PHPUNIT) $(PHPUNIT_FLAGS) --testsuite "EasyRdf Library"
# TARGET:coverage Run library tests and generate coverage report
.PHONY: coverage
coverage: $(PHPUNIT)
mkdir -p reports/coverage
$(PHP) $(PHPUNIT) $(PHPUNIT_FLAGS) --coverage-html ./reports/coverage --testsuite "EasyRdf Library"
# TARGET:apidocs Generate HTML API documentation
.PHONY: apidocs
apidocs: $(SAMI)
$(PHP) $(SAMI) update config/sami.php -n -v --force
docs/api: apidocs
doap.rdf: doap.php composer.json vendor/autoload.php
$(PHP) doap.php > doap.rdf
# TARGET:cs Check the code style of the PHP source code
.PHONY: cs
cs: $(PHPCS)
$(PHPCS) $(PHPCS_FLAGS) lib test
# TARGET:lint Perform basic PHP syntax check on all files
.PHONY: lint
lint: $(EXAMPLE_FILES) $(SOURCE_FILES) $(TEST_FILES)
@for file in $^; do \
$(PHP) -l $$file || exit -1; \
done
# TARGET:dist Build archives for distribution
.PHONY: dist
dist: $(distdir).tar.gz
rm -Rf $(distdir)
@echo "Done."
%.tar.gz: %
$(TAR) zcf $@ $^
$(distdir): $(DISTFILES)
$(gatherfiles)
define gatherfiles
@for file in $^; do \
dir=$@/`dirname "$$file"`; \
test -d "$$dir" || mkdir -p "$$dir" || exit -1; \
cp -Rfp "$$file" "$@/$$file" || exit -1; \
done
endef
# TARGET:clean Delete any temporary and generated files
.PHONY: clean
clean:
find . -name '.DS_Store' -type f -delete
-rm -Rf $(distdir) reports vendor
-rm -Rf docs/api samicache
-rm -f composer.phar composer.lock
-rm -f doap.rdf
# TARGET:check-fixme Scan for files containing the words TODO or FIXME
.PHONY: check-fixme
check-fixme:
@git grep -n -E 'FIXME|TODO' || echo "No FIXME or TODO lines found."
# TARGET:help You're looking at it!
.PHONY: help
help:
# Usage:
# make <target> [OPTION=value]
#
# Targets:
@egrep "^# TARGET:" [Mm]akefile | sed 's/^# TARGET:/# /'
#
# Options:
# PHP Path to php
# Composer rules
composer.phar:
curl -s -z composer.phar -o composer.phar http://getcomposer.org/composer.phar
composer-install: composer.phar
$(PHP) composer.phar $(COMPOSER_FLAGS) install
composer-update: clean composer.phar
$(PHP) composer.phar $(COMPOSER_FLAGS) update
vendor/autoload.php: composer-install
vendor/bin/phpunit: composer-install
vendor/bin/phpcs: composer-install
vendor/bin/sami.php: composer-install