2019-01-23 12:59:26 +00:00
|
|
|
# Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under
|
|
|
|
# either of:
|
|
|
|
# - Apache License, version 2.0
|
|
|
|
# - MIT license
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2019-09-10 00:48:34 +00:00
|
|
|
SHELL := bash # the shell used internally by "make"
|
|
|
|
|
2019-08-20 22:03:15 +00:00
|
|
|
# used inside the included makefiles
|
|
|
|
BUILD_SYSTEM_DIR := vendor/nimbus-build-system
|
2019-03-26 16:39:57 +00:00
|
|
|
|
2019-08-20 22:03:15 +00:00
|
|
|
# we don't want an error here, so we can handle things later, in the build-system-checks target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
|
2018-12-24 16:03:27 +00:00
|
|
|
|
2019-02-27 23:07:23 +00:00
|
|
|
# debugging tools + testing tools
|
|
|
|
TOOLS := premix persist debug dumper hunter regress tracerTestGen persistBlockTestGen
|
2019-03-26 16:39:57 +00:00
|
|
|
TOOLS_DIRS := premix tests
|
2019-02-27 23:07:23 +00:00
|
|
|
# comma-separated values for the "clean" target
|
|
|
|
TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS))
|
|
|
|
|
2019-08-20 22:03:15 +00:00
|
|
|
.PHONY: all $(TOOLS) build-system-checks deps update nimbus test test-reproducibility clean libnimbus.so libnimbus.a wrappers wrappers-static
|
2018-12-24 16:03:27 +00:00
|
|
|
|
|
|
|
# default target, because it's the first one that doesn't start with '.'
|
2019-08-20 22:03:15 +00:00
|
|
|
all: build-system-checks $(TOOLS) nimbus
|
|
|
|
|
|
|
|
# must be included after the default target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
|
|
|
|
|
|
|
|
GIT_SUBMODULE_UPDATE := git submodule update --init --recursive
|
|
|
|
build-system-checks:
|
|
|
|
@[[ -e "$(BUILD_SYSTEM_DIR)/makefiles" ]] || { \
|
|
|
|
echo -e "'$(BUILD_SYSTEM_DIR)/makefiles' not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \
|
|
|
|
$(GIT_SUBMODULE_UPDATE); \
|
|
|
|
echo -e "\nYou can now run '$(MAKE)' again."; \
|
|
|
|
exit 1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
deps: | deps-common nimbus.nims
|
2019-01-23 12:59:26 +00:00
|
|
|
|
2019-08-20 22:03:15 +00:00
|
|
|
#- deletes and recreates "nimbus.nims" which on Windows is a copy instead of a proper symlink
|
|
|
|
update: | update-common
|
|
|
|
rm -rf nimbus.nims && \
|
|
|
|
$(MAKE) nimbus.nims
|
2019-03-29 17:08:39 +00:00
|
|
|
|
2019-02-27 23:07:23 +00:00
|
|
|
# builds the tools, wherever they are
|
2019-09-04 17:14:54 +00:00
|
|
|
$(TOOLS): | build deps
|
2019-03-26 16:39:57 +00:00
|
|
|
for D in $(TOOLS_DIRS); do [ -e "$${D}/$@.nim" ] && TOOL_DIR="$${D}" && break; done && \
|
2019-03-29 17:08:39 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ "$${TOOL_DIR}/$@.nim"
|
2018-12-24 16:03:27 +00:00
|
|
|
|
2019-02-27 23:07:23 +00:00
|
|
|
# a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated
|
2019-09-04 17:14:54 +00:00
|
|
|
nimbus: | build deps
|
2019-03-29 17:08:39 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim nimbus $(NIM_PARAMS) nimbus.nims
|
2018-12-24 16:03:27 +00:00
|
|
|
|
2019-02-16 21:45:19 +00:00
|
|
|
# symlink
|
|
|
|
nimbus.nims:
|
|
|
|
ln -s nimbus.nimble $@
|
|
|
|
|
2019-03-17 00:54:30 +00:00
|
|
|
# builds and runs the test suite
|
2019-09-04 17:14:54 +00:00
|
|
|
test: | build deps
|
2019-02-16 21:23:17 +00:00
|
|
|
$(ENV_SCRIPT) nim test $(NIM_PARAMS) nimbus.nims
|
|
|
|
|
|
|
|
# primitive reproducibility test
|
|
|
|
test-reproducibility:
|
|
|
|
+ [ -e build/nimbus ] || $(MAKE) V=0 nimbus; \
|
2019-02-17 16:42:04 +00:00
|
|
|
MD5SUM1=$$($(MD5SUM) build/nimbus | cut -d ' ' -f 1) && \
|
|
|
|
rm -rf nimcache/*/nimbus && \
|
|
|
|
$(MAKE) V=0 nimbus && \
|
|
|
|
MD5SUM2=$$($(MD5SUM) build/nimbus | cut -d ' ' -f 1) && \
|
2019-02-17 18:01:40 +00:00
|
|
|
[ "$$MD5SUM1" = "$$MD5SUM2" ] && echo -e "\e[92mSuccess: identical binaries.\e[39m" || \
|
|
|
|
{ echo -e "\e[91mFailure: the binary changed between builds.\e[39m"; exit 1; }
|
2018-12-24 16:03:27 +00:00
|
|
|
|
|
|
|
# usual cleaning
|
2019-08-20 22:03:15 +00:00
|
|
|
clean: | clean-common
|
|
|
|
rm -rf build/{nimbus,$(TOOLS_CSV),all_tests,test_rpc,*_wrapper_test}
|
2019-02-26 22:13:31 +00:00
|
|
|
|
2019-09-04 17:14:54 +00:00
|
|
|
libnimbus.so: | build deps
|
2019-07-31 11:54:48 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2019-08-02 16:59:47 +00:00
|
|
|
$(ENV_SCRIPT) nim c --app:lib --noMain --nimcache:nimcache/libnimbus $(NIM_PARAMS) -o:build/$@.0 wrappers/libnimbus.nim && \
|
2019-07-31 11:54:48 +00:00
|
|
|
rm -f build/$@ && \
|
|
|
|
ln -s $@.0 build/$@
|
|
|
|
|
2019-09-04 17:14:54 +00:00
|
|
|
wrappers: | build deps libnimbus.so go-checks
|
2019-08-01 00:44:27 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/C_wrapper_example" && \
|
|
|
|
$(CC) wrappers/wrapper_example.c -Wl,-rpath,'$$ORIGIN' -Lbuild -lnimbus -lm -g -o build/C_wrapper_example
|
|
|
|
echo -e $(BUILD_MSG) "build/go_wrapper_example" && \
|
2019-11-27 10:06:58 +00:00
|
|
|
go build -o build/go_wrapper_example wrappers/wrapper_example.go wrappers/cfuncs.go
|
2019-09-12 16:32:07 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/go_wrapper_whisper_example" && \
|
2019-11-27 10:06:58 +00:00
|
|
|
go build -o build/go_wrapper_whisper_example wrappers/wrapper_whisper_example.go wrappers/cfuncs.go
|
2019-07-31 11:54:48 +00:00
|
|
|
|
2019-09-04 17:14:54 +00:00
|
|
|
libnimbus.a: | build deps
|
2019-08-01 11:14:00 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2019-08-02 16:59:47 +00:00
|
|
|
rm -f build/$@ && \
|
2019-11-26 17:53:04 +00:00
|
|
|
$(ENV_SCRIPT) nim c --app:staticlib --noMain --nimcache:nimcache/libnimbus_static $(NIM_PARAMS) -o:build/$@ wrappers/libnimbus.nim && \
|
|
|
|
[[ -e "$@" ]] && mv "$@" build/ # workaround for https://github.com/nim-lang/Nim/issues/12745
|
2019-08-01 11:14:00 +00:00
|
|
|
|
2019-09-04 17:14:54 +00:00
|
|
|
wrappers-static: | build deps libnimbus.a go-checks
|
2019-08-01 11:14:00 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/C_wrapper_example_static" && \
|
2019-09-05 12:31:20 +00:00
|
|
|
$(CC) wrappers/wrapper_example.c -static -pthread -Lbuild -lnimbus -lm -ldl -lpcre -g -o build/C_wrapper_example_static
|
2019-08-01 11:14:00 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/go_wrapper_example_static" && \
|
2019-09-10 10:16:57 +00:00
|
|
|
go build -ldflags "-linkmode external -extldflags '-static -ldl -lpcre'" -o build/go_wrapper_example_static wrappers/wrapper_example.go wrappers/cfuncs.go
|
2019-11-26 15:09:58 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/go_wrapper_whisper_example_static" && \
|
|
|
|
go build -ldflags "-linkmode external -extldflags '-static -ldl -lpcre'" -o build/go_wrapper_whisper_example_static wrappers/wrapper_example.go wrappers/cfuncs.go
|
2019-08-01 11:14:00 +00:00
|
|
|
|
2019-12-12 18:40:34 +00:00
|
|
|
wakunode: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim wakunode $(NIM_PARAMS) nimbus.nims
|