summaryrefslogtreecommitdiff
path: root/exports
diff options
context:
space:
mode:
authorStevenWdV <stevenwdv@gmail.com>2021-12-17 16:39:51 +0100
committerStevenWdV <stevenwdv@gmail.com>2021-12-17 16:39:51 +0100
commita79995670baf0ae755cbbe78c5d77fc49575d342 (patch)
tree4c98d0962b9ef02b652c418f217f0d365c3139f9 /exports
parenta47513aeeb728b6316ba6765afdd7e5adbf4f2e3 (diff)
Fix PHP wrapper on Unix, extract common platform detection logic
Diffstat (limited to 'exports')
-rw-r--r--exports/Makefile14
-rw-r--r--exports/platform.mk23
2 files changed, 24 insertions, 13 deletions
diff --git a/exports/Makefile b/exports/Makefile
index b3dc3db..547ee92 100644
--- a/exports/Makefile
+++ b/exports/Makefile
@@ -1,18 +1,6 @@
.PHONY: build copy-to clean
-GOOS != go env GOHOSTOS
-GOARCH != go env GOHOSTARCH
-
-ifeq (windows,$(GOOS))
-LIB_PREFIX =
-LIB_SUFFIX = .dll
-else ifeq (darwin,$(GOOS))
-LIB_PREFIX = lib
-LIB_SUFFIX = .dylib
-else
-LIB_PREFIX = lib
-LIB_SUFFIX = .so
-endif
+include platform.mk
# Creates targets like 'linux/amd64/eduvpn_verify.so'
build: $(GOOS)/$(GOARCH)/$(LIB_PREFIX)eduvpn_verify$(LIB_SUFFIX)
diff --git a/exports/platform.mk b/exports/platform.mk
new file mode 100644
index 0000000..60f47ee
--- /dev/null
+++ b/exports/platform.mk
@@ -0,0 +1,23 @@
+ifndef GOOS
+export GOOS != go env GOHOSTOS
+endif
+ifndef GOARCH
+export GOARCH != go env GOHOSTARCH
+endif
+
+ifeq (windows,$(GOOS))
+LIB_PREFIX =
+LIB_SUFFIX = .dll
+else ifeq (darwin,$(GOOS))
+LIB_PREFIX = lib
+LIB_SUFFIX = .dylib
+else
+LIB_PREFIX = lib
+LIB_SUFFIX = .so
+endif
+
+ifeq (Windows_NT,$(OS))
+export PATH := $(abspath ../../exports/$(GOOS)/$(GOARCH)):$(PATH)
+else
+export LD_LIBRARY_PATH := $(abspath ../../exports/$(GOOS)/$(GOARCH)):$(LD_LIBRARY_PATH)
+endif