From f63014bddbc09c2f49f89bbef42c385f88b7e1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Thu, 1 Aug 2019 13:14:00 +0200 Subject: [PATCH] libnimbus.a and statically linked wrapper examples --- Makefile | 12 +++++++++++- wrappers/README.md | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 96bbd95bd..40c1d7e99 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ TOOLS_DIRS := premix tests # comma-separated values for the "clean" target TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS)) -.PHONY: all $(TOOLS) deps sanity-checks github-ssh build-nim update status ntags ctags nimbus testsuite test clean mrproper fetch-dlls test-libp2p-daemon nat-libs libminiupnpc.a libnatpmp.a go-checks libnimbus.so wrappers +.PHONY: all $(TOOLS) deps sanity-checks github-ssh build-nim update status ntags ctags nimbus testsuite test clean mrproper fetch-dlls test-libp2p-daemon nat-libs libminiupnpc.a libnatpmp.a go-checks libnimbus.so libnimbus.a wrappers # default target, because it's the first one that doesn't start with '.' all: $(TOOLS) nimbus @@ -209,6 +209,16 @@ wrappers: | build deps nat-libs libnimbus.so go-checks echo -e $(BUILD_MSG) "build/go_wrapper_example" && \ go build -o build/go_wrapper_example wrappers/wrapper_example.go +libnimbus.a: | build deps nat-libs + echo -e $(BUILD_MSG) "build/$@" && \ + $(ENV_SCRIPT) nim c --app:staticlib --noMain $(NIM_PARAMS) -o:build/$@ wrappers/wrapper.nim + +wrappers-static: | build deps nat-libs libnimbus.a go-checks + echo -e $(BUILD_MSG) "build/C_wrapper_example_static" && \ + $(CC) wrappers/wrapper_example.c -static -pthread -Lbuild -lnimbus -lm -ldl -g -o build/C_wrapper_example_static + echo -e $(BUILD_MSG) "build/go_wrapper_example_static" && \ + go build -ldflags "-linkmode external -extldflags '-static -ldl'" -o build/go_wrapper_example_static wrappers/wrapper_example.go + # https://bitbucket.org/nimcontrib/ntags/ - currently fails with "out of memory" ntags: ntags -R . diff --git a/wrappers/README.md b/wrappers/README.md index 807a79987..2558e0b9d 100644 --- a/wrappers/README.md +++ b/wrappers/README.md @@ -19,3 +19,9 @@ build/C_wrapper_example build/go_wrapper_example ``` +To build statically linked versions: + +```bash +make wrappers-static +``` +