cppcheck --std was added in 1.56
[m6w6/travis-pecl] / Makefile
1 export
2
3 PHP ?= 5.6
4 JOBS ?= 2
5 PHP_MIRROR ?= http://us1.php.net/distributions/
6 TMPDIR ?= /tmp
7
8 tmpnam := $(TMPDIR)/php-$(PHP)-$(shell env |grep -E '^with_|^enable_' | tr -c '[a-zA-Z_]' -)
9 makdir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
10
11 ifdef TRAVIS_JOB_NUMBER
12 prefix ?= $(HOME)/job-$(TRAVIS_JOB_NUMBER)
13 else
14 prefix ?= $(tmpnam)
15 endif
16 exec_prefix ?= $(prefix)
17 bindir = $(exec_prefix)/bin
18 srcdir := $(prefix)/src
19 ifdef TRAVIS_BUILD_DIR
20 curdir ?= $(TRAVIS_BUILD_DIR)
21 else
22 # CURDIR is a make builtin
23 curdir ?= $(CURDIR)
24 endif
25
26 enable_maintainer_zts ?= no
27 enable_debug ?= no
28 enable_all ?= no
29 with_config_file_scan_dir ?= $(prefix)/etc/php.d
30
31 with_php_config ?= $(bindir)/php-config
32 extdir = $(shell test -x $(with_php_config) && $(with_php_config) --extension-dir)
33
34 PECL_MIRROR ?= http://pecl.php.net/get/
35 PECL_WORDS := $(subst :, ,$(PECL))
36 PECL_EXTENSION ?= $(word 1,$(PECL_WORDS))
37 PECL_SONAME ?= $(if $(word 2,$(PECL_WORDS)),$(word 2,$(PECL_WORDS)),$(PECL_EXTENSION))
38 PECL_VERSION ?= $(word 3,$(PECL_WORDS))
39 PECL_INI = $(with_config_file_scan_dir)/pecl.ini
40 PECL_DIR := $(if $(filter ext ext%, $(MAKECMDGOALS)), $(curdir), $(srcdir)/pecl-$(PECL_EXTENSION))
41
42 #PHP_VERSION_MAJOR = $(firstword $(subst ., ,$(PHP)))
43
44 PHP_RELEASES = $(srcdir)/releases.tsv
45 PHP_VERSION ?= $(shell test -e $(PHP_RELEASES) && cat $(PHP_RELEASES) | awk -F "\t" '/^$(PHP)\t/{print $$2}')
46
47 CPPCHECK ?= -v -j $(JOBS) --enable=warning,portability,style --error-exitcode=42 --suppressions-list=$(makdir)/cppcheck.suppressions -I.
48
49 .SUFFIXES:
50
51 .PHONY: all
52 all: php
53
54 .PHONY: versions
55 versions: $(PHP_RELEASES)
56 grep "^$(PHP)" $<
57
58 $(PHP_RELEASES): $(makdir)/php-version-url-dist.php $(makdir)/php-version-url-qa.php | $(srcdir)
59 printf "master\tmaster\tgit clone --depth 1 -b master https://github.com/php/php-src php-master && cd php-master && ./buildconf\n" >$@
60 curl -Ss "http://php.net/releases/index.php?json&version=7&max=-1" | $(makdir)/php-version-url-dist.php >>$@
61 curl -Ss "http://php.net/releases/index.php?json&version=5&max=-1" | $(makdir)/php-version-url-dist.php >>$@
62 curl -Ss "http://qa.php.net/api.php?type=qa-releases&format=json" | $(makdir)/php-version-url-qa.php >>$@
63
64 ## -- PHP
65
66 .PHONY: clean
67 clean:
68 @if test -d $(srcdir)/php-$(PHP_VERSION); then cd $(srcdir)/php-$(PHP_VERSION); make distclean || true; fi
69
70 .PHONY: check
71 check: $(PHP_RELEASES)
72 @if test -z "$(PHP)"; then echo "No php version specified, e.g. PHP=5.6"; exit 1; fi
73
74 .PHONY: reconf
75 reconf: check $(srcdir)/php-$(PHP_VERSION)/configure
76 cd $(srcdir)/php-$(PHP_VERSION) && ./configure --cache-file=config.cache --prefix=$(prefix)
77
78 .PHONY: php
79 php: check $(bindir)/php | $(PECL_INI)
80 -for EXT_SONAME in $(extdir)/*.so; do \
81 EXT_SONAME=$$(basename $$EXT_SONAME); \
82 if test "$$EXT_SONAME" != "*.so" && ! grep -q extension=$$EXT_SONAME $(PECL_INI); then \
83 echo extension=$$EXT_SONAME >> $(PECL_INI); \
84 fi \
85 done
86
87 $(srcdir)/php-$(PHP_VERSION)/configure: | $(PHP_RELEASES)
88 cd $(srcdir) && awk -F "\t" '/^$(PHP)\t/{exit system($$3)}' <$|
89
90 $(srcdir)/php-$(PHP_VERSION)/Makefile: $(srcdir)/php-$(PHP_VERSION)/configure | $(PHP_RELEASES)
91 cd $(srcdir)/php-$(PHP_VERSION) && ./configure --cache-file=config.cache --prefix=$(prefix)
92
93 $(srcdir)/php-$(PHP_VERSION)/sapi/cli/php: $(srcdir)/php-$(PHP_VERSION)/Makefile | $(PHP_RELEASES)
94 cd $(srcdir)/php-$(PHP_VERSION) && make -j $(JOBS) || make
95
96 $(bindir)/php: $(srcdir)/php-$(PHP_VERSION)/sapi/cli/php | $(PHP_RELEASES)
97 cd $(srcdir)/php-$(PHP_VERSION) && make install
98
99 $(srcdir) $(extdir) $(with_config_file_scan_dir):
100 mkdir -p $@
101
102 ## -- PECL
103
104 .PHONY: pecl-check
105 pecl-check:
106 @if test -z "$(PECL)"; then echo "No pecl extension specified, e.g. PECL=pecl_http:http"; exit 1; fi
107
108 .PHONY: pecl-clean
109 pecl-clean:
110 @if test -d $(PECL_DIR); then cd $(PECL_DIR); make distclean || true; fi
111
112 .PHONY: pecl-rm
113 pecl-rm:
114 rm -f $(extdir)/$(PECL_SONAME).so
115
116 $(PECL_INI): | $(with_config_file_scan_dir)
117 touch $@
118
119 $(PECL_DIR)/config.m4:
120 mkdir -p $(PECL_DIR)
121 curl -Ss $(PECL_MIRROR)/$(PECL_EXTENSION)$(if $(PECL_VERSION),/$(PECL_VERSION)) | tar xz --strip-components 1 -C $(PECL_DIR)
122
123 $(PECL_DIR)/configure: $(PECL_DIR)/config.m4
124 cd $(PECL_DIR) && $(bindir)/phpize
125
126 $(PECL_DIR)/Makefile: $(PECL_DIR)/configure
127 cd $(PECL_DIR) && ./configure --cache-file=config.cache
128
129 $(PECL_DIR)/.libs/$(PECL_SONAME).so: $(PECL_DIR)/Makefile
130 cd $(PECL_DIR) && make -j $(JOBS) || make
131
132 $(extdir)/$(PECL_SONAME).so: $(PECL_DIR)/.libs/$(PECL_SONAME).so $(extdir)
133 cd $(PECL_DIR) && make install
134
135 .PHONY: pecl
136 pecl: pecl-check php $(extdir)/$(PECL_SONAME).so | $(PECL_INI)
137 grep -q extension=$(PECL_SONAME).so $(PECL_INI) || echo extension=$(PECL_SONAME).so >> $(PECL_INI)
138
139 .PHONY: ext-clean
140 ext-clean: pecl-clean
141
142 .PHONY: ext-rm
143 ext-rm: pecl-rm
144
145 .PHONY: ext
146 ext: pecl-check pecl
147 $(makdir)/check-packagexml.php package.xml
148
149 .PHONY: test
150 test: php
151 REPORT_EXIT_STATUS=1 $(bindir)/php run-tests.php -q -p $(bindir)/php --set-timeout 300 --show-diff tests
152
153 .PHONY: cppcheck
154 cppcheck:
155 cppcheck $(CPPCHECK) $$(awk -F= '/^CPPFLAGS|^INCLUDES/{print $$2}' <Makefile) .
156
157 pharext/%: $(PECL_INI) php | $(srcdir)/../%.ext.phar
158 for phar in $|; do $(bindir)/php $$phar --prefix=$(prefix) --ini=$(PECL_INI); done