build ext in CURDIR
[m6w6/travis-pecl] / Makefile
index 4be60ee100647da7fef9f8a607beb3e44cb6ad62..19584a01103efaa2c9ec7e9c1388d66c59b2eb87 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,8 +26,11 @@ PECL_EXTENSION ?= $(shell echo $(PECL) | cut -d: -f1)
 PECL_SONAME ?= $(if $(shell echo $(PECL) | cut -d: -f2),$(shell echo $(PECL) | cut -d: -f2),$(PECL_EXTENSION))
 PECL_VERSION ?= $(shell echo $(PECL) | cut -d: -f3 -s)
 PECL_INI = $(with_config_file_scan_dir)/pecl.ini
+PECL_DIR ?= $(srcdir)/pecl-$(PECL_EXTENSION)
 
-PHP_VERSION ?= $(shell test -e $(srcdir)/php-versions.json && cat $(srcdir)/php-versions.json | $(srcdir)/php-version.php $(PHP))
+PHP_VERSION_MAJOR = $(firstword $(subst ., ,$(PHP)))
+PHP_VERSIONS_JSON = $(srcdir)/php-versions$(PHP_VERSION_MAJOR).json
+PHP_VERSION ?= $(shell test -e $(PHP_VERSIONS_JSON) && cat $(PHP_VERSIONS_JSON) | $(srcdir)/php-version.php $(PHP))
 
 .SUFFIXES:
 
@@ -41,7 +44,7 @@ clean:
        @if test -d $(srcdir)/php-$(PHP_VERSION); then cd $(srcdir)/php-$(PHP_VERSION); make distclean || true; fi
 
 .PHONY: check
-check: $(srcdir)/php-versions.json
+check: $(PHP_VERSIONS_JSON)
        @if test -z "$(PHP)"; then echo "No php version specified, e.g. PHP=5.6"; exit 1; fi
 
 .PHONY: reconf
@@ -51,23 +54,23 @@ reconf: check $(srcdir)/php-$(PHP_VERSION)/configure
 .PHONY: php
 php: check $(bindir)/php
 
-$(srcdir)/php-versions.json: $(srcdir)/php-version.php
-       curl -Sso $@ "http://php.net/releases/index.php?json&version=5&max=-1"
+$(PHP_VERSIONS_JSON): $(srcdir)/php-version.php
+       curl -Sso $@ "http://php.net/releases/index.php?json&version=$(PHP_VERSION_MAJOR)&max=-1"
 
-$(srcdir)/php-$(PHP_VERSION)/configure: | $(srcdir)/php-versions.json
+$(srcdir)/php-$(PHP_VERSION)/configure: | $(PHP_VERSIONS_JSON)
        if test $(PHP_VERSION) = "master"; then \
-               cd $(srcdir) && git clone --depth 1 -b master https://github.com/php/php-src php-master && cd php-master && ./buildconf \
+               cd $(srcdir) && git clone --depth 1 -b master https://github.com/php/php-src php-master && cd php-master && ./buildconf; \
        else \
-               curl -Ss $(PHP_MIRROR)/php-$(PHP_VERSION).tar.bz2 | tar xj -C $(srcdir) \
+               curl -Ss $(PHP_MIRROR)/php-$(PHP_VERSION).tar.bz2 | tar xj -C $(srcdir); \
        fi
 
-$(srcdir)/php-$(PHP_VERSION)/Makefile: $(srcdir)/php-$(PHP_VERSION)/configure | $(srcdir)/php-versions.json
+$(srcdir)/php-$(PHP_VERSION)/Makefile: $(srcdir)/php-$(PHP_VERSION)/configure | $(PHP_VERSIONS_JSON)
        cd $(srcdir)/php-$(PHP_VERSION) && ./configure -C --prefix=$(prefix)
 
-$(srcdir)/php-$(PHP_VERSION)/sapi/cli/php: $(srcdir)/php-$(PHP_VERSION)/Makefile | $(srcdir)/php-versions.json
+$(srcdir)/php-$(PHP_VERSION)/sapi/cli/php: $(srcdir)/php-$(PHP_VERSION)/Makefile | $(PHP_VERSIONS_JSON)
        cd $(srcdir)/php-$(PHP_VERSION) && make -j $(JOBS) || make
 
-$(bindir)/php: $(srcdir)/php-$(PHP_VERSION)/sapi/cli/php | $(srcdir)/php-versions.json
+$(bindir)/php: $(srcdir)/php-$(PHP_VERSION)/sapi/cli/php | $(PHP_VERSIONS_JSON)
        cd $(srcdir)/php-$(PHP_VERSION) && make install
 
 $(with_config_file_scan_dir):
@@ -81,7 +84,7 @@ pecl-check:
 
 .PHONY: pecl-clean
 pecl-clean:
-       @if test -d $(srcdir)/pecl-$(PECL_EXTENSION); then cd $(srcdir)/pecl-$(PECL_EXTENSION); make distclean || true; fi
+       @if test -d $(PECL_DIR); then cd $(PECL_DIR); make distclean || true; fi
 
 .PHONY: pecl-rm
 pecl-rm:
@@ -90,24 +93,21 @@ pecl-rm:
 $(PECL_INI): | $(with_config_file_scan_dir)
        touch $@
 
-$(srcdir)/pecl-$(PECL_EXTENSION):
-       test -e $@ || ln -s $(CURDIR) $@
+$(PECL_DIR)/config.m4:
+       mkdir -p $(PECL_DIR)
+       curl -Ss $(PECL_MIRROR)/$(PECL_EXTENSION)$(if $(PECL_VERSION),/$(PECL_VERSION)) | tar xz --strip-components 1 -C $(PECL_DIR)
 
-$(srcdir)/pecl-$(PECL_EXTENSION)/config.m4:
-       mkdir -p $(srcdir)/pecl-$(PECL_EXTENSION)
-       curl -Ss $(PECL_MIRROR)/$(PECL_EXTENSION)$(if $(PECL_VERSION),/$(PECL_VERSION)) | tar xz --strip-components 1 -C $(srcdir)/pecl-$(PECL_EXTENSION)
+$(PECL_DIR)/configure: $(PECL_DIR)/config.m4
+       cd $(PECL_DIR) && $(bindir)/phpize
 
-$(srcdir)/pecl-$(PECL_EXTENSION)/configure: $(srcdir)/pecl-$(PECL_EXTENSION)/config.m4
-       cd $(srcdir)/pecl-$(PECL_EXTENSION) && $(bindir)/phpize
+$(PECL_DIR)/Makefile: $(PECL_DIR)/configure
+       cd $(PECL_DIR) && ./configure -C
 
-$(srcdir)/pecl-$(PECL_EXTENSION)/Makefile: $(srcdir)/pecl-$(PECL_EXTENSION)/configure
-       cd $(srcdir)/pecl-$(PECL_EXTENSION) && ./configure -C
+$(PECL_DIR)/.libs/$(PECL_SONAME).so: $(PECL_DIR)/Makefile
+       cd $(PECL_DIR) && make -j $(JOBS) || make
 
-$(srcdir)/pecl-$(PECL_EXTENSION)/.libs/$(PECL_SONAME).so: $(srcdir)/pecl-$(PECL_EXTENSION)/Makefile
-       cd $(srcdir)/pecl-$(PECL_EXTENSION) && make -j $(JOBS) || make
-       
-$(extdir)/$(PECL_SONAME).so: $(srcdir)/pecl-$(PECL_EXTENSION)/.libs/$(PECL_SONAME).so
-       cd $(srcdir)/pecl-$(PECL_EXTENSION) && make install
+$(extdir)/$(PECL_SONAME).so: $(PECL_DIR)/.libs/$(PECL_SONAME).so
+       cd $(PECL_DIR) && make install
 
 .PHONY: pecl
 pecl: pecl-check php $(extdir)/$(PECL_SONAME).so | $(PECL_INI)
@@ -117,12 +117,18 @@ pecl: pecl-check php $(extdir)/$(PECL_SONAME).so | $(PECL_INI)
 ext-clean: pecl-clean
 
 .PHONY: ext-rm
+ext-rm: PECL_DIR:=$(CURDIR)
 ext-rm: pecl-rm
 
 .PHONY: ext
-ext: pecl-check $(srcdir)/pecl-$(PECL_EXTENSION) pecl
+ext: PECL_DIR:=$(CURDIR)
+ext: pecl-check pecl
        $(srcdir)/check-packagexml.php package.xml
 
 .PHONY: php
+test: PECL_DIR:=$(CURDIR)
 test: php
        REPORT_EXIT_STATUS=1 $(bindir)/php run-tests.php -q -p $(bindir)/php --set-timeout 300 --show-diff tests
+
+pharext/%: $(PECL_INI) php | $(srcdir)/../%.ext.phar
+       for phar in $|; do $(bindir)/php $$phar --prefix=$(prefix) --ini=$(PECL_INI); done