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