summaryrefslogtreecommitdiff
path: root/wrappers/php/Makefile
blob: bab43055eadc48a45772e7fb14af26f78c48ba4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
.PHONY: install-header test install-dev-dependencies clean

ifneq (clean,$(MAKECMDGOALS))
GOOS      != go env GOHOSTOS
GOARCH    != go env GOHOSTARCH

export PATH := $(abspath vendor/bin):$(PATH)

ifeq (Windows_NT,$(OS))
export PATH := $(abspath ../../exports/$(GOOS)/$(GOARCH)):$(PATH)
else
export LD_LIBRARY_PATH := $(abspath ../../exports/$(GOOS)/$(GOARCH)):$(LD_LIBRARY_PATH)
endif
endif

install-header:
	$(MAKE) -C ../../exports
	mkdir -p src/headers
	sed --null-data \
		-e 's/DO NOT EDIT/Modified for PHP/' \
		-e 's/__SIZE_TYPE__/size_t/g' \
		-e 's/[^\n]*_Complex[^\n]*//g' \
		-e 's/#ifdef __cplusplus[^#]*#endif//g' \
		-e 's/^/#define FFI_LIB "eduvpn_verify"\n\n/' \
		"../../exports/$(GOOS)/$(GOARCH)/eduvpn_verify.h" > src/headers/eduvpn_verify_php.h

test: install-header install-dev-dependencies
	phpunit

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

clean:
	rm -rf vendor/ .phpunit* src/headers/*.h