forked from tecnickcom/tc-lib-barcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
240 lines (193 loc) · 8.51 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# makefile
#
# @since 2015-02-21
# @category Library
# @package Barcode
# @author Nicola Asuni <[email protected]>
# @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD
# @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
# @link https://github.com/tecnick.com/tc-lib-barcode
#
# This file is part of tc-lib-barcode software library.
# ----------------------------------------------------------------------------------------------------------------------
# List special make targets that are not associated with files
.PHONY: help all test docs phpcs phpcs_test phpcbf phpcbf_test phpmd phpmd_test phpcpd phploc phpdep phpcmpinfo report qa qa_test qa_all clean build build_dev update server install uninstall rpm deb
# Project owner
OWNER=tecnickcom
# Project vendor
VENDOR=tecnick.com
# Project name
PROJECT=tc-lib-barcode
# Project version
VERSION=`cat VERSION`
# Project release number (packaging build number)
RELEASE=`cat RELEASE`
# Name of RPM or DEB package
PKGNAME=php-${OWNER}-${PROJECT}
# Data dir
DATADIR=usr/share
# PHP home folder
PHPHOME=${DATADIR}/php/Com/Tecnick
# Default installation path for code
LIBPATH=${PHPHOME}/Barcode/
# Default installation path for documentation
DOCPATH=${DATADIR}/doc/$(PKGNAME)/
# Installation path for the code
PATHINSTBIN=$(DESTDIR)/$(LIBPATH)
# Installation path for documentation
PATHINSTDOC=$(DESTDIR)/$(DOCPATH)
# Current directory
CURRENTDIR=`pwd`
# RPM Packaging path (where RPMs will be stored)
PATHRPMPKG=$(CURRENTDIR)/target/RPM
# DEB Packaging path (where DEBs will be stored)
PATHDEBPKG=$(CURRENTDIR)/target/DEB
# Default port number for the example server
PORT?=8000
# Composer executable (disable APC to as a work-around of a bug)
COMPOSER=$(shell which php) -d "apc.enable_cli=0" $(shell which composer)
# --- MAKE TARGETS ---
# Display general help about this command
help:
@echo ""
@echo "Welcome to ${PROJECT} make."
@echo "The following commands are available:"
@echo ""
@echo " make qa : Run the targets: test, phpcs and phpmd"
@echo " make qa_test : Run the targets: phpcs_test and phpmd_test"
@echo " make qa_all : Run the targets: qa and qa_all"
@echo ""
@echo " make test : Run the PHPUnit tests"
@echo ""
@echo " make phpcs : Run PHPCS on the source code and show any style violations"
@echo " make phpcs_test : Run PHPCS on the test code and show any style violations"
@echo ""
@echo " make phpcbf : Run PHPCBF on the source code to fix style violations"
@echo " make phpcbf_test : Run PHPCBF on the test code to fix style violations"
@echo ""
@echo " make phpmd : Run PHP Mess Detector on the source code"
@echo " make phpmd_test : Run PHP Mess Detector on the test code"
@echo ""
@echo " make phpcpd : Run PHP Copy/Paste Detector"
@echo " make phploc : Run PHPLOC to analyze the structure of the project"
@echo " make phpdep : Run JDepend static analysis and generate graphs"
@echo " make phpcmpinfo : Find out the minimum version and extensions required"
@echo " make report : Generates various static-analisys reports"
@echo ""
@echo " make docs : Generate source code documentation"
@echo ""
@echo " make clean : Delete the vendor and target directory"
@echo " make build : Clean and download the composer dependencies"
@echo " make build_dev : Clean and download the composer dependencies including dev ones"
@echo " make update : Update composer dependencies"
@echo ""
@echo " make server : Run the example server at http://localhost:"$(PORT)
@echo ""
@echo " make install : Install this library"
@echo " make uninstall : Remove all installed files"
@echo ""
@echo " make rpm : Build an RPM package"
@echo " make deb : Build a DEB package"
@echo ""
# alias for help target
all: help
# run the PHPUnit tests
test:
./vendor/bin/phpunit test
# generate docs using phpDocumentor
docs:
@rm -rf target/phpdocs && ./vendor/phpdocumentor/phpdocumentor/bin/phpdoc project:run --target="target/phpdocs/" --directory="src/" --ignore="vendor/" --encoding="UTF-8" --title="${PROJECT}" --parseprivate
# run PHPCS on the source code and show any style violations
phpcs:
@./vendor/bin/phpcs --ignore="./vendor/" --standard=psr2 src
# run PHPCS on the test code and show any style violations
phpcs_test:
@./vendor/bin/phpcs --standard=psr2 test
# run PHPCBF on the source code and show any style violations
phpcbf:
@./vendor/bin/phpcbf --ignore="./vendor/" --standard=psr2 src
# run PHPCBF on the test code and show any style violations
phpcbf_test:
@./vendor/bin/phpcbf --standard=psr2 test
# Run PHP Mess Detector on the source code
phpmd:
@./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude vendor
# run PHP Mess Detector on the test code
phpmd_test:
@./vendor/bin/phpmd test text unusedcode,naming,design
# run PHP Copy/Paste Detector
phpcpd:
mkdir -p ./target/report/
@./vendor/bin/phpcpd src --exclude vendor > ./target/report/phpcpd.txt
# run PHPLOC to analyze the structure of the project
phploc:
mkdir -p ./target/report/
@./vendor/bin/phploc src --exclude vendor > ./target/report/phploc.txt
# PHP static analysis
phpdep:
mkdir -p ./target/report/
@./vendor/bin/pdepend --jdepend-xml=./target/report/dependencies.xml --summary-xml=./target/report/metrics.xml --jdepend-chart=./target/report/dependecies.svg --overview-pyramid=./target/report/overview-pyramid.svg --ignore=vendor ./src
# parse any data source to find out the minimum version and extensions required for it to run
phpcmpinfo:
@./vendor/bartlett/php-compatinfo/bin/phpcompatinfo --no-ansi analyser:run src/ > ./target/report/phpcompatinfo.txt
# generate various reports
report: phpcpd phploc phpdep phpcmpinfo
# alias to run targets: test, phpcs and phpmd
qa: test phpcs phpmd
# alias to run targets: phpcs_test and phpmd_test
qa_test: phpcs_test phpmd_test
# alias to run targets: qa and qa_test
qa_all: qa qa_test
# delete the vendor and target directory
clean:
rm -rf ./vendor/
# clean and download the composer dependencies
build:
rm -rf ./vendor/ && ($(COMPOSER) -n install --no-dev --no-interaction)
# clean and download the composer dependencies including dev ones
build_dev:
rm -rf ./vendor/ && ($(COMPOSER) -n install --no-interaction)
# update composer dependencies
update:
($(COMPOSER) -n update --no-interaction)
# Run the development server
server:
php -t example -S localhost:$(PORT)
# Install this application
install: uninstall
mkdir -p $(PATHINSTBIN)
cp -rf ./src/* $(PATHINSTBIN)
cp -f ./resources/autoload.php $(PATHINSTBIN)
find $(PATHINSTBIN) -type d -exec chmod 755 {} \;
find $(PATHINSTBIN) -type f -exec chmod 644 {} \;
mkdir -p $(PATHINSTDOC)
cp -f ./LICENSE.TXT $(PATHINSTDOC)
cp -f ./README.md $(PATHINSTDOC)
cp -f ./VERSION $(PATHINSTDOC)
chmod -R 644 $(PATHINSTDOC)*
# Remove all installed files
uninstall:
rm -rf $(PATHINSTBIN)
rm -rf $(PATHINSTDOC)
# --- PACKAGING ---
# Build the RPM package for RedHat-like Linux distributions
rpm:
rm -rf $(PATHRPMPKG)
rpmbuild --define "_topdir $(PATHRPMPKG)" --define "_vendor $(VENDOR)" --define "_owner $(OWNER)" --define "_project $(PROJECT)" --define "_package $(PKGNAME)" --define "_version $(VERSION)" --define "_release $(RELEASE)" --define "_current_directory $(CURRENTDIR)" --define "_libpath /$(LIBPATH)" --define "_docpath /$(DOCPATH)" --define "_configpath $(CONFIGPATH)" -bb resources/rpm/rpm.spec
# Build the DEB package for Debian-like Linux distributions
deb: build
rm -rf $(PATHDEBPKG)
mkdir -p $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)
cp -rf $(CURRENTDIR)/src $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)
cp -f ./resources/autoload.php $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/src
cp -f ./README.md $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)
cp -f ./VERSION $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)
tar -zcvf $(PATHDEBPKG)/$(PKGNAME)_$(VERSION).orig.tar.gz -C $(PATHDEBPKG)/ $(PKGNAME)-$(VERSION)
cp -rf ./resources/debian $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian
sed -ri "s/~#VERSION#~/$(VERSION)/" $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/changelog
sed -ri "s/~#DATE#~/`date -R`/" $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/changelog
echo $(LIBPATH) > $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).dirs
echo "src/* $(LIBPATH)" > $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/install
echo "README.md $(DOCPATH)" >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/install
echo "VERSION $(DOCPATH)" >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/install
cd $(PATHDEBPKG)/$(PKGNAME)-$(VERSION) && debuild -us -uc