2021-04-09 07:26:06 +00:00
|
|
|
# Copyright (c) 2018-2021 Status Research & Development GmbH. Licensed under
|
2019-01-23 12:59:26 +00:00
|
|
|
# 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.
|
|
|
|
|
2021-04-09 07:26:06 +00:00
|
|
|
SHELL := bash # the shell used internally by "make"
|
2019-09-10 00:48:34 +00:00
|
|
|
|
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
|
|
|
|
2021-04-09 07:26:06 +00:00
|
|
|
LINK_PCRE := 0
|
|
|
|
|
2020-04-18 12:56:40 +00:00
|
|
|
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
|
2019-08-20 22:03:15 +00:00
|
|
|
-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
|
2020-02-13 19:18:27 +00:00
|
|
|
TOOLS := \
|
2020-07-21 04:28:03 +00:00
|
|
|
test_tools_build
|
2020-02-13 19:18:27 +00:00
|
|
|
TOOLS_DIRS := \
|
2020-05-07 15:32:44 +00:00
|
|
|
tests
|
2019-02-27 23:07:23 +00:00
|
|
|
# comma-separated values for the "clean" target
|
|
|
|
TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS))
|
2020-02-13 19:18:27 +00:00
|
|
|
|
|
|
|
.PHONY: \
|
|
|
|
all \
|
|
|
|
$(TOOLS) \
|
|
|
|
deps \
|
|
|
|
update \
|
|
|
|
nimbus \
|
2021-06-28 15:53:13 +00:00
|
|
|
fluffy \
|
2020-02-13 19:18:27 +00:00
|
|
|
test \
|
|
|
|
test-reproducibility \
|
|
|
|
clean \
|
|
|
|
libnimbus.so \
|
|
|
|
libnimbus.a \
|
|
|
|
libbacktrace
|
2018-12-24 16:03:27 +00:00
|
|
|
|
2020-04-18 12:56:40 +00:00
|
|
|
ifeq ($(NIM_PARAMS),)
|
|
|
|
# "variables.mk" was not included, so we update the submodules.
|
|
|
|
GIT_SUBMODULE_UPDATE := git submodule update --init --recursive
|
|
|
|
.DEFAULT:
|
|
|
|
+@ echo -e "Git submodules not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \
|
|
|
|
$(GIT_SUBMODULE_UPDATE); \
|
|
|
|
echo
|
|
|
|
# Now that the included *.mk files appeared, and are newer than this file, Make will restart itself:
|
|
|
|
# https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles
|
|
|
|
#
|
|
|
|
# After restarting, it will execute its original goal, so we don't have to start a child Make here
|
|
|
|
# with "$(MAKE) $(MAKECMDGOALS)". Isn't hidden control flow great?
|
|
|
|
|
|
|
|
else # "variables.mk" was included. Business as usual until the end of this file.
|
|
|
|
|
2018-12-24 16:03:27 +00:00
|
|
|
# default target, because it's the first one that doesn't start with '.'
|
2020-04-18 12:56:40 +00:00
|
|
|
all: | $(TOOLS) nimbus
|
2019-08-20 22:03:15 +00:00
|
|
|
|
|
|
|
# must be included after the default target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
|
|
|
|
|
2021-01-19 09:02:24 +00:00
|
|
|
# default: use blst
|
|
|
|
USE_MIRACL := 0
|
|
|
|
|
|
|
|
# default: use nim native evm
|
|
|
|
ENABLE_EVMC := 0
|
|
|
|
|
2020-04-18 12:56:40 +00:00
|
|
|
# "-d:release" implies "--stacktrace:off" and it cannot be added to config.nims
|
|
|
|
ifeq ($(USE_LIBBACKTRACE), 0)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:debug -d:disable_libbacktrace
|
|
|
|
else
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:release
|
|
|
|
endif
|
2019-08-20 22:03:15 +00:00
|
|
|
|
2021-01-19 02:24:39 +00:00
|
|
|
ifneq ($(USE_MIRACL), 0)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:BLS_FORCE_BACKEND=miracl
|
|
|
|
endif
|
|
|
|
|
2021-01-19 09:02:24 +00:00
|
|
|
ifneq ($(ENABLE_EVMC), 0)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:evmc_enabled
|
|
|
|
endif
|
|
|
|
|
2021-04-23 07:50:48 +00:00
|
|
|
# disabled by default, enable with ENABLE_VM2SLOW=1
|
|
|
|
ifneq ($(if $(ENABLE_VM2LOWMEM),$(ENABLE_VM2LOWMEM),0),0)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:vm2_enabled -d:lowmem:1
|
|
|
|
else
|
2021-04-08 14:52:10 +00:00
|
|
|
# disabled by default, enable with ENABLE_VM2=1
|
|
|
|
ifneq ($(if $(ENABLE_VM2),$(ENABLE_VM2),0),0)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:vm2_enabled
|
|
|
|
endif
|
2021-04-23 07:50:48 +00:00
|
|
|
endif
|
2021-04-08 14:52:10 +00:00
|
|
|
|
2020-06-22 15:12:12 +00:00
|
|
|
deps: | deps-common nat-libs nimbus.nims
|
2020-04-15 22:21:58 +00:00
|
|
|
ifneq ($(USE_LIBBACKTRACE), 0)
|
|
|
|
deps: | libbacktrace
|
|
|
|
endif
|
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 && \
|
2020-04-15 22:21:58 +00:00
|
|
|
$(MAKE) nimbus.nims $(HANDLE_OUTPUT)
|
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 $@
|
|
|
|
|
2020-02-09 16:31:37 +00:00
|
|
|
# nim-libbacktrace
|
|
|
|
libbacktrace:
|
2020-04-18 12:56:40 +00:00
|
|
|
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
|
2020-02-09 16:31:37 +00:00
|
|
|
|
2021-07-09 11:34:16 +00:00
|
|
|
# builds and runs the nimbus 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
|
|
|
|
2021-07-09 11:34:16 +00:00
|
|
|
# Fluffy related targets
|
|
|
|
# builds the fluffy client
|
|
|
|
fluffy: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim fluffy $(NIM_PARAMS) nimbus.nims
|
|
|
|
|
2021-07-07 09:04:18 +00:00
|
|
|
# primitive reproducibility test
|
2021-07-09 11:34:16 +00:00
|
|
|
fluffy-test-reproducibility:
|
2021-07-07 09:04:18 +00:00
|
|
|
+ [ -e build/fluffy ] || $(MAKE) V=0 fluffy; \
|
|
|
|
MD5SUM1=$$($(MD5SUM) build/fluffy | cut -d ' ' -f 1) && \
|
|
|
|
rm -rf nimcache/*/fluffy && \
|
|
|
|
$(MAKE) V=0 fluffy && \
|
|
|
|
MD5SUM2=$$($(MD5SUM) build/fluffy | cut -d ' ' -f 1) && \
|
|
|
|
[ "$$MD5SUM1" = "$$MD5SUM2" ] && echo -e "\e[92mSuccess: identical binaries.\e[39m" || \
|
|
|
|
{ echo -e "\e[91mFailure: the binary changed between builds.\e[39m"; exit 1; }
|
|
|
|
|
2021-07-09 11:34:16 +00:00
|
|
|
# builds and runs the fluffy test suite
|
|
|
|
fluffy-test: | build deps
|
|
|
|
$(ENV_SCRIPT) nim testfluffy $(NIM_PARAMS) nimbus.nims
|
|
|
|
|
|
|
|
# builds the fluffy tools
|
|
|
|
fluffy-tools: | build deps
|
|
|
|
$(ENV_SCRIPT) nim portalcli $(NIM_PARAMS) nimbus.nims
|
|
|
|
|
2021-12-03 08:51:25 +00:00
|
|
|
# Build fluffy test_portal_testnet
|
|
|
|
fluffy-test-portal-testnet: | build deps
|
|
|
|
$(ENV_SCRIPT) nim test_portal_testnet $(NIM_PARAMS) nimbus.nims
|
|
|
|
|
2018-12-24 16:03:27 +00:00
|
|
|
# usual cleaning
|
2019-08-20 22:03:15 +00:00
|
|
|
clean: | clean-common
|
2021-07-09 11:34:16 +00:00
|
|
|
rm -rf build/{nimbus,fluffy,$(TOOLS_CSV),all_tests,test_rpc,all_fluffy_tests,portalcli}
|
2020-04-15 22:21:58 +00:00
|
|
|
ifneq ($(USE_LIBBACKTRACE), 0)
|
2020-02-09 16:31:37 +00:00
|
|
|
+ $(MAKE) -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT)
|
2020-04-15 22:21:58 +00:00
|
|
|
endif
|
2019-02-26 22:13:31 +00:00
|
|
|
|
Whisper: Remove C and Go wrappers and Nimbus as a library
Remove the C and Go example wrappers that call Nimbus as a library, by removing
the entire `wrappers/` directory. They are removed because they only wrap
Whisper protocol support, which has been removed as it is obsolete.
The only thing wrapped were Whisper functions, even though there were separate
`go_wrapper_example` and `go_wrapper_whisper_example` programs. The wrappers
don't build without Whisper in Nimbus, and without it, there isn't enough left
for them to be useful examples.
Also remove support for building the whole of Nimbus as a library, because
there is nothing left using it. These targets are gone from the Makefile:
- `wrappers`
- `wrappers-static`
- `libnimbus.so`
- `libnimbus.a`
The code isn't really gone, because it remains available in Git history. It
may be useful someday, so a comment has been left in the Makefile for future
generations:
> This note is kept so that anyone wanting to build Nimbus as a library or call
> from C or Go will know it has been done before. The previous working version
> can be found in Git history. Look for the `nimbus-eth1` commit that adds
> this comment and removes `wrappers/*`.
Also worth a note, the library support was not tested on Windows, and the
shared library support was only tested on Linux.
Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-06-01 16:45:11 +00:00
|
|
|
# Note about building Nimbus as a library:
|
|
|
|
#
|
|
|
|
# There were `wrappers`, `wrappers-static`, `libnimbus.so` and `libnimbus.a`
|
|
|
|
# target scripts here, and C and Go examples for calling the Nimbus library in
|
|
|
|
# directory `wrappers/`. They have been removed because they only wrapped
|
|
|
|
# Whisper protocol support, which has been removed as it is obsolete.
|
|
|
|
#
|
|
|
|
# This note is kept so that anyone wanting to build Nimbus as a library or call
|
|
|
|
# from C or Go will know it has been done before. The previous working version
|
|
|
|
# can be found in Git history. Look for the `nimbus-eth1` commit that adds
|
|
|
|
# this comment and removes `wrappers/*`.
|
2019-08-01 11:14:00 +00:00
|
|
|
|
2020-04-18 12:56:40 +00:00
|
|
|
endif # "variables.mk" was not included
|