add 7.0 as explicitely supported PHP version
[m6w6/pecl-ci] / Makefile
1 export
2
3 PHP ?= 5.6
4 JOBS ?= 2
5 PHP_MIRROR ?= http://us1.php.net/distributions/
6
7 ifdef TRAVIS_JOB_NUMBER
8 prefix ?= $(HOME)/job-$(TRAVIS_JOB_NUMBER)
9 else
10 prefix ?= $(HOME)
11 endif
12 exec_prefix ?= $(prefix)
13 bindir = $(exec_prefix)/bin
14 srcdir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
15
16 enable_maintainer_zts ?= no
17 enable_debug ?= no
18 enable_all ?= no
19 with_config_file_scan_dir ?= $(prefix)/etc/php.d
20
21 with_php_config ?= $(bindir)/php-config
22 extdir = $(shell test -x $(with_php_config) && $(with_php_config) --extension-dir)
23
24 PECL_MIRROR ?= http://pecl.php.net/get/
25 PECL_EXTENSION ?= $(shell echo $(PECL) | cut -d: -f1)
26 PECL_SONAME ?= $(if $(shell echo $(PECL) | cut -d: -f2),$(shell echo $(PECL) | cut -d: -f2),$(PECL_EXTENSION))
27 PECL_VERSION ?= $(shell echo $(PECL) | cut -d: -f3 -s)
28 PECL_INI = $(with_config_file_scan_dir)/pecl.ini
29
30 PHP_VERSION_MAJOR = $(firstword $(subst ., ,$(PHP)))
31 PHP_VERSIONS_JSON = $(srcdir)/php-versions$(PHP_VERSION_MAJOR).json
32 PHP_VERSION ?= $(shell test -e $(PHP_VERSIONS_JSON) && cat $(PHP_VERSIONS_JSON) | $(srcdir)/php-version.php $(PHP))
33
34 .SUFFIXES:
35
36 .PHONY: all
37 all: php
38
39 ## -- PHP
40
41 .PHONY: clean
42 clean:
43 @if test -d $(srcdir)/php-$(PHP_VERSION); then cd $(srcdir)/php-$(PHP_VERSION); make distclean || true; fi
44
45 .PHONY: check
46 check: $(PHP_VERSIONS_JSON)
47 @if test -z "$(PHP)"; then echo "No php version specified, e.g. PHP=5.6"; exit 1; fi
48
49 .PHONY: reconf
50 reconf: check $(srcdir)/php-$(PHP_VERSION)/configure
51 cd $(srcdir)/php-$(PHP_VERSION) && ./configure -C --prefix=$(prefix)
52
53 .PHONY: php
54 php: check $(bindir)/php
55
56 $(PHP_VERSIONS_JSON): $(srcdir)/php-version.php
57 curl -Sso $@ "http://php.net/releases/index.php?json&version=$(PHP_VERSION_MAJOR)&max=-1"
58
59 $(srcdir)/php-$(PHP_VERSION)/configure: | $(srcdir)/php-versions.json
60 if test $(PHP_VERSION) = "master"; then \
61 cd $(srcdir) && git clone --depth 1 -b master https://github.com/php/php-src php-master && cd php-master && ./buildconf; \
62 else \
63 curl -Ss $(PHP_MIRROR)/php-$(PHP_VERSION).tar.bz2 | tar xj -C $(srcdir); \
64 fi
65
66 $(srcdir)/php-$(PHP_VERSION)/Makefile: $(srcdir)/php-$(PHP_VERSION)/configure | $(srcdir)/php-versions.json
67 cd $(srcdir)/php-$(PHP_VERSION) && ./configure -C --prefix=$(prefix)
68
69 $(srcdir)/php-$(PHP_VERSION)/sapi/cli/php: $(srcdir)/php-$(PHP_VERSION)/Makefile | $(srcdir)/php-versions.json
70 cd $(srcdir)/php-$(PHP_VERSION) && make -j $(JOBS) || make
71
72 $(bindir)/php: $(srcdir)/php-$(PHP_VERSION)/sapi/cli/php | $(srcdir)/php-versions.json
73 cd $(srcdir)/php-$(PHP_VERSION) && make install
74
75 $(with_config_file_scan_dir):
76 mkdir -p $@
77
78 ## -- PECL
79
80 .PHONY: pecl-check
81 pecl-check:
82 @if test -z "$(PECL)"; then echo "No pecl extension specified, e.g. PECL=pecl_http:http"; exit 1; fi
83
84 .PHONY: pecl-clean
85 pecl-clean:
86 @if test -d $(srcdir)/pecl-$(PECL_EXTENSION); then cd $(srcdir)/pecl-$(PECL_EXTENSION); make distclean || true; fi
87
88 .PHONY: pecl-rm
89 pecl-rm:
90 rm -f $(extdir)/$(PECL_SONAME).so
91
92 $(PECL_INI): | $(with_config_file_scan_dir)
93 touch $@
94
95 $(srcdir)/pecl-$(PECL_EXTENSION):
96 test -e $@ || ln -s $(CURDIR) $@
97
98 $(srcdir)/pecl-$(PECL_EXTENSION)/config.m4:
99 mkdir -p $(srcdir)/pecl-$(PECL_EXTENSION)
100 curl -Ss $(PECL_MIRROR)/$(PECL_EXTENSION)$(if $(PECL_VERSION),/$(PECL_VERSION)) | tar xz --strip-components 1 -C $(srcdir)/pecl-$(PECL_EXTENSION)
101
102 $(srcdir)/pecl-$(PECL_EXTENSION)/configure: $(srcdir)/pecl-$(PECL_EXTENSION)/config.m4
103 cd $(srcdir)/pecl-$(PECL_EXTENSION) && $(bindir)/phpize
104
105 $(srcdir)/pecl-$(PECL_EXTENSION)/Makefile: $(srcdir)/pecl-$(PECL_EXTENSION)/configure
106 cd $(srcdir)/pecl-$(PECL_EXTENSION) && ./configure -C
107
108 $(srcdir)/pecl-$(PECL_EXTENSION)/.libs/$(PECL_SONAME).so: $(srcdir)/pecl-$(PECL_EXTENSION)/Makefile
109 cd $(srcdir)/pecl-$(PECL_EXTENSION) && make -j $(JOBS) || make
110
111 $(extdir)/$(PECL_SONAME).so: $(srcdir)/pecl-$(PECL_EXTENSION)/.libs/$(PECL_SONAME).so
112 cd $(srcdir)/pecl-$(PECL_EXTENSION) && make install
113
114 .PHONY: pecl
115 pecl: pecl-check php $(extdir)/$(PECL_SONAME).so | $(PECL_INI)
116 grep -q extension=$(PECL_SONAME).so $(PECL_INI) || echo extension=$(PECL_SONAME).so >> $(PECL_INI)
117
118 .PHONY: ext-clean
119 ext-clean: pecl-clean
120
121 .PHONY: ext-rm
122 ext-rm: pecl-rm
123
124 .PHONY: ext
125 ext: pecl-check $(srcdir)/pecl-$(PECL_EXTENSION) pecl
126 $(srcdir)/check-packagexml.php package.xml
127
128 .PHONY: php
129 test: php
130 REPORT_EXIT_STATUS=1 $(bindir)/php run-tests.php -q -p $(bindir)/php --set-timeout 300 --show-diff tests
131
132 pharext/%: $(PECL_INI) php | $(srcdir)/../%.ext.phar
133 for phar in $|; do $(bindir)/php $$phar --prefix=$(prefix) --ini=$(PECL_INI); done