buildconf in master
[m6w6/travis-pecl] / 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 ?= $(shell test -e $(srcdir)/php-versions.json && cat $(srcdir)/php-versions.json | $(srcdir)/php-version.php $(PHP))
31
32 .SUFFIXES:
33
34 .PHONY: all
35 all: php
36
37 ## -- PHP
38
39 .PHONY: clean
40 clean:
41 @if test -d $(srcdir)/php-$(PHP_VERSION); then cd $(srcdir)/php-$(PHP_VERSION); make distclean || true; fi
42
43 .PHONY: check
44 check: $(srcdir)/php-versions.json
45 @if test -z "$(PHP)"; then echo "No php version specified, e.g. PHP=5.6"; exit 1; fi
46
47 .PHONY: reconf
48 reconf: check $(srcdir)/php-$(PHP_VERSION)/configure
49 cd $(srcdir)/php-$(PHP_VERSION) && ./configure -C --prefix=$(prefix)
50
51 .PHONY: php
52 php: check $(bindir)/php
53
54 $(srcdir)/php-versions.json: $(srcdir)/php-version.php
55 curl -Sso $@ "http://php.net/releases/index.php?json&version=5&max=-1"
56
57 $(srcdir)/php-$(PHP_VERSION)/configure: | $(srcdir)/php-versions.json
58 if test $(PHP_VERSION) = "master"; then \
59 cd $(srcdir) && git clone --depth 1 -b master https://github.com/php/php-src php-master && cd php-master && ./buildconf \
60 else \
61 curl -Ss $(PHP_MIRROR)/php-$(PHP_VERSION).tar.bz2 | tar xj -C $(srcdir) \
62 fi
63
64 $(srcdir)/php-$(PHP_VERSION)/Makefile: $(srcdir)/php-$(PHP_VERSION)/configure | $(srcdir)/php-versions.json
65 cd $(srcdir)/php-$(PHP_VERSION) && ./configure -C --prefix=$(prefix)
66
67 $(srcdir)/php-$(PHP_VERSION)/sapi/cli/php: $(srcdir)/php-$(PHP_VERSION)/Makefile | $(srcdir)/php-versions.json
68 cd $(srcdir)/php-$(PHP_VERSION) && make -j $(JOBS) || make
69
70 $(bindir)/php: $(srcdir)/php-$(PHP_VERSION)/sapi/cli/php | $(srcdir)/php-versions.json
71 cd $(srcdir)/php-$(PHP_VERSION) && make install
72
73 $(with_config_file_scan_dir):
74 mkdir -p $@
75
76 ## -- PECL
77
78 .PHONY: pecl-check
79 pecl-check:
80 @if test -z "$(PECL)"; then echo "No pecl extension specified, e.g. PECL=pecl_http:http"; exit 1; fi
81
82 .PHONY: pecl-clean
83 pecl-clean:
84 @if test -d $(srcdir)/pecl-$(PECL_EXTENSION); then cd $(srcdir)/pecl-$(PECL_EXTENSION); make distclean || true; fi
85
86 .PHONY: pecl-rm
87 pecl-rm:
88 rm -f $(extdir)/$(PECL_SONAME).so
89
90 $(PECL_INI): | $(with_config_file_scan_dir)
91 touch $@
92
93 $(srcdir)/pecl-$(PECL_EXTENSION):
94 test -e $@ || ln -s $(CURDIR) $@
95
96 $(srcdir)/pecl-$(PECL_EXTENSION)/config.m4:
97 mkdir -p $(srcdir)/pecl-$(PECL_EXTENSION)
98 curl -Ss $(PECL_MIRROR)/$(PECL_EXTENSION)$(if $(PECL_VERSION),/$(PECL_VERSION)) | tar xz --strip-components 1 -C $(srcdir)/pecl-$(PECL_EXTENSION)
99
100 $(srcdir)/pecl-$(PECL_EXTENSION)/configure: $(srcdir)/pecl-$(PECL_EXTENSION)/config.m4
101 cd $(srcdir)/pecl-$(PECL_EXTENSION) && $(bindir)/phpize
102
103 $(srcdir)/pecl-$(PECL_EXTENSION)/Makefile: $(srcdir)/pecl-$(PECL_EXTENSION)/configure
104 cd $(srcdir)/pecl-$(PECL_EXTENSION) && ./configure -C
105
106 $(srcdir)/pecl-$(PECL_EXTENSION)/.libs/$(PECL_SONAME).so: $(srcdir)/pecl-$(PECL_EXTENSION)/Makefile
107 cd $(srcdir)/pecl-$(PECL_EXTENSION) && make -j $(JOBS) || make
108
109 $(extdir)/$(PECL_SONAME).so: $(srcdir)/pecl-$(PECL_EXTENSION)/.libs/$(PECL_SONAME).so
110 cd $(srcdir)/pecl-$(PECL_EXTENSION) && make install
111
112 .PHONY: pecl
113 pecl: pecl-check php $(extdir)/$(PECL_SONAME).so | $(PECL_INI)
114 grep -q extension=$(PECL_SONAME).so $(PECL_INI) || echo extension=$(PECL_SONAME).so >> $(PECL_INI)
115
116 .PHONY: ext-clean
117 ext-clean: pecl-clean
118
119 .PHONY: ext-rm
120 ext-rm: pecl-rm
121
122 .PHONY: ext
123 ext: pecl-check $(srcdir)/pecl-$(PECL_EXTENSION) pecl
124 $(srcdir)/check-packagexml.php package.xml
125
126 .PHONY: php
127 test: php
128 REPORT_EXIT_STATUS=1 $(bindir)/php run-tests.php -q -p $(bindir)/php --set-timeout 300 --show-diff tests