summaryrefslogtreecommitdiff
path: root/exports/Makefile
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-14 13:56:49 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-14 13:56:49 +0200
commitda83f54606c9c1d2786d87074ee17ed972d2e1b2 (patch)
tree0be57934f9f467c87576abb0b457fb54b2d25d52 /exports/Makefile
parentfd34e72da8c604517050ada7e883ba982829d985 (diff)
Refactor: Return without json
Diffstat (limited to 'exports/Makefile')
-rw-r--r--exports/Makefile12
1 files changed, 10 insertions, 2 deletions
diff --git a/exports/Makefile b/exports/Makefile
index b833228..46d17a9 100644
--- a/exports/Makefile
+++ b/exports/Makefile
@@ -2,6 +2,8 @@
include common.mk
+CLIBPATH=./c
+
ifeq ($(LIB_SUFFIX),.so)
# Add SONAME as cgo does not currently do this. Mostly for Android, see https://stackoverflow.com/a/48291044
export override CGO_LDFLAGS += -Wl,-soname,$(LIB_FILE)
@@ -13,12 +15,18 @@ ifdef COPY_LIB_TO
install $< -Dt $(COPY_LIB_TO)
endif
+${CLIBPATH}/libcommon$(LIB_SUFFIX): ${CLIBPATH}/common.c
+ $(CC) -c -Wall -Werror -fpic -o ${CLIBPATH}/common.o ${CLIBPATH}/common.c
+ $(CC) -shared -o $@ ${CLIBPATH}/common.o
+
# Build shared library and remove lib prefix (if any) from header name
# GOOS and GOARCH envvars are set by common.mk
# This extra target prevents unnecessary rebuild
-lib/$(GOOS)/$(GOARCH)/$(LIB_FILE): exports.go ..
- CGO_ENABLED=1 go build -o $@ -buildmode=c-shared $<
+lib/$(GOOS)/$(GOARCH)/$(LIB_FILE): ${CLIBPATH}/libcommon$(LIB_SUFFIX) exports.go servers.go ..
+ CGO_ENABLED=1 go build -o $@ -buildmode=c-shared .
mv lib/$(GOOS)/$(GOARCH)/$(LIB_PREFIX)$(LIB_NAME).h lib/$(GOOS)/$(GOARCH)/$(LIB_NAME).h || true # Normalize header name
clean:
rm -rf ../exports/lib/*
+ rm -rf ${CLIBPATH}/common.o
+ rm -rf ${CLIBPATH}/libcommon.so