diff options
| author | StevenWdV <stevenwdv@gmail.com> | 2022-02-04 01:18:12 +0100 |
|---|---|---|
| committer | StevenWdV <stevenwdv@gmail.com> | 2022-02-04 01:18:12 +0100 |
| commit | b60ecf2fe5ddfe506e02093286b3931873187e91 (patch) | |
| tree | b3804b1b95e70e96dec98cb0c2b571e0b895ebdd /wrappers/php | |
| parent | bb85487e40b47d701e64085e7574cb477a431f1e (diff) | |
More Makefile cleanup, support building in folder with spaces
Diffstat (limited to 'wrappers/php')
| -rw-r--r-- | wrappers/php/Makefile | 38 | ||||
| -rw-r--r-- | wrappers/php/README.md | 2 |
2 files changed, 15 insertions, 25 deletions
diff --git a/wrappers/php/Makefile b/wrappers/php/Makefile index e0262e9..5384d92 100644 --- a/wrappers/php/Makefile +++ b/wrappers/php/Makefile @@ -1,31 +1,21 @@ .PHONY: install-header test install-dev-dependencies clean EXPORTS_PATH ?= ../../exports -EXPORTS_LIB_PATH ?= $(EXPORTS_PATH)/lib - -ifneq ($(MAKECMDGOALS),clean) -include $(EXPORTS_PATH)/platform.mk +include $(EXPORTS_PATH)/common.mk # Add phpunit to PATH export PATH := $(abspath vendor/bin):$(PATH) -endif ifeq ($(COPY_LIB),1) -COPY_LIB_DIR = lib +COPY_LIB_DIR ?= lib endif - ifneq ($(COPY_LIB_DIR),) COPY_LIB_DIR := $(COPY_LIB_DIR)/ endif # Strip / replace elements confusing PHP's limited C parser: __SIZE_TYPE__, _Complex, extern "C" # Also add FFI_LIB library name, see https://www.php.net/manual/en/ffi.load -install-header: -ifneq ($(EXPORTS_PATH),) -ifneq ($(wildcard $(EXPORTS_PATH)/Makefile),) - $(MAKE) -C "$(EXPORTS_PATH)" -endif -endif +install-header: .try_build_lib mkdir -p src/headers sed --null-data \ -e 's/DO NOT EDIT/Modified for PHP/' \ @@ -36,25 +26,25 @@ endif \ -e 's/^/#define FFI_LIB "$(subst /,\/,$(COPY_LIB_DIR))$(LIB_FILE)"\n\n/' \ \ - "$(EXPORTS_LIB_PATH)/$(GOOS)/$(GOARCH)/$(LIB_NAME).h" > src/headers/$(LIB_NAME)_php.h -ifeq ($(COPY_LIB),1) - install "$(EXPORTS_LIB_PATH)/$(GOOS)/$(GOARCH)/$(LIB_FILE)" -Dt "$(COPY_LIB_DIR)" + "$(EXPORTS_LIB_SUBFOLDER_PATH)/$(LIB_NAME).h" >src/headers/$(LIB_NAME)_php.h +ifneq ($(COPY_LIB_DIR),) + install "$(EXPORTS_LIB_SUBFOLDER_PATH)/$(LIB_FILE)" -Dt "$(COPY_LIB_DIR)" endif test: install-header install-dev-dependencies phpunit +composers = composer composer.phar ./composer ./composer.phar +# Find first composer from list above, default to 'composer' +find_composer = $(firstword $(foreach bin,$(composers),$(if $(shell command -v $(bin)),$(bin),)) composer) +# Lazy variable: https://blog.jgc.org/2016/07/lazy-gnu-make-variables.html +COMPOSER ?= $(eval COMPOSER := $(find_composer))$(COMPOSER) + # Try: composer, composer.phar, ./composer.phar, ./composer # check-platform-reqs is needed because of config.platform in composer.json, see https://getcomposer.org/doc/06-config.md#platform install-dev-dependencies: - if command -v composer; then \ - composer install && composer check-platform-reqs; \ - elif command -v composer.phar; then \ - composer.phar install && composer.phar check-platform-reqs; \ - else \ - ./composer.phar install && ./composer.phar check-platform-reqs || \ - ./composer install && ./composer check-platform-reqs; \ - fi + $(COMPOSER) install + $(COMPOSER) check-platform-reqs clean: rm -rf vendor/ .phpunit* src/headers/*.h lib/* diff --git a/wrappers/php/README.md b/wrappers/php/README.md index b5cafa2..01e4d3e 100644 --- a/wrappers/php/README.md +++ b/wrappers/php/README.md @@ -32,4 +32,4 @@ When using this library, you will need to make sure that the linker can find the pass `COPY_LIB=1` to `make install-header` to copy the library over to this folder and load it via this relative path. If you do not build this as part of the full repository, specify `EXPORTS_PATH="path/to/exports-folder"` when calling -make. This folder must contain `platform.mk` and the `lib/` folder with built libraries and headers. +make. This folder must contain `common.mk` and the `lib/` folder with built libraries and headers. |
