2022-11-30 20:02:39 +00:00
|
|
|
# Copyright (c) 2022 Status Research & Development GmbH. Licensed under
|
2020-04-30 15:51:30 +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.
|
|
|
|
BUILD_SYSTEM_DIR := vendor/nimbus-build-system
|
2022-01-24 11:48:06 +00:00
|
|
|
EXCLUDED_NIM_PACKAGES := vendor/nim-dnsdisc/vendor
|
2021-06-15 07:51:09 +00:00
|
|
|
LINK_PCRE := 0
|
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
|
2020-04-29 04:49:27 +00:00
|
|
|
|
2020-04-29 05:54:03 +00:00
|
|
|
|
2020-04-30 15:51:30 +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?
|
2020-05-01 05:00:00 +00:00
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
else # "variables.mk" was included. Business as usual until the end of this file.
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
|
|
|
|
##########
|
|
|
|
## Main ##
|
|
|
|
##########
|
|
|
|
.PHONY: all test update clean v1 v2
|
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
# default target, because it's the first one that doesn't start with '.'
|
2021-06-23 17:14:37 +00:00
|
|
|
all: | v1 v2
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
test: | test1 test2
|
|
|
|
|
|
|
|
v1: | wakunode1 example1 sim1
|
2022-12-07 14:09:59 +00:00
|
|
|
v2: | wakunode2 example2 wakubridge chat2 chat2bridge
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
waku.nims:
|
|
|
|
ln -s waku.nimble $@
|
|
|
|
|
|
|
|
update: | update-common
|
|
|
|
rm -rf waku.nims && \
|
|
|
|
$(MAKE) waku.nims $(HANDLE_OUTPUT)
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
clean:
|
|
|
|
rm -rf build
|
2020-04-30 15:51:30 +00:00
|
|
|
|
|
|
|
# must be included after the default target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
|
|
|
|
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
## Git version
|
|
|
|
GIT_VERSION ?= $(shell git describe --abbrev=6 --always --tags)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:git_version=\"$(GIT_VERSION)\"
|
|
|
|
|
|
|
|
|
|
|
|
##################
|
|
|
|
## Dependencies ##
|
|
|
|
##################
|
|
|
|
.PHONY: deps libbacktrace
|
|
|
|
|
|
|
|
deps: | deps-common nat-libs waku.nims
|
|
|
|
|
|
|
|
|
|
|
|
### nim-libbacktrace
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2020-04-30 15:51:30 +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
|
|
|
|
|
2022-11-07 08:14:21 +00:00
|
|
|
libbacktrace:
|
|
|
|
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
|
2022-10-18 23:03:43 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
clean-libbacktrace:
|
|
|
|
+ $(MAKE) -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT)
|
2022-03-30 15:17:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
# Extend deps and clean targets
|
2020-04-30 15:51:30 +00:00
|
|
|
ifneq ($(USE_LIBBACKTRACE), 0)
|
|
|
|
deps: | libbacktrace
|
|
|
|
endif
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
clean: | clean-libbacktrace
|
2022-11-07 08:14:21 +00:00
|
|
|
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
##################
|
|
|
|
## Experimental ##
|
|
|
|
##################
|
|
|
|
.PHONY: librln
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
EXPERIMENTAL ?= false
|
|
|
|
EXPERIMENTAL_PARAMS ?= $(EMPTY)
|
2020-10-08 09:10:45 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
ifeq ($(EXPERIMENTAL), true)
|
|
|
|
RLN := true
|
|
|
|
endif
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
### RLN
|
2021-07-19 09:54:36 +00:00
|
|
|
|
2023-03-21 07:37:10 +00:00
|
|
|
LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2022-12-05 23:33:03 +00:00
|
|
|
LIBRLN_FILE := rln.lib
|
2022-11-30 20:02:39 +00:00
|
|
|
else
|
2022-12-05 23:33:03 +00:00
|
|
|
LIBRLN_FILE := librln.a
|
2022-11-30 20:02:39 +00:00
|
|
|
endif
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
$(LIBRLN_BUILDDIR)/$(LIBRLN_FILE):
|
|
|
|
echo -e $(BUILD_MSG) "$@" && \
|
2023-03-21 07:37:10 +00:00
|
|
|
./scripts/build_rln.sh $(LIBRLN_BUILDDIR)
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
ifneq ($(RLN), true)
|
|
|
|
librln: ; # noop
|
|
|
|
else
|
2023-03-21 07:37:10 +00:00
|
|
|
EXPERIMENTAL_PARAMS += -d:rln --passL:$(LIBRLN_FILE) --passL:-lm
|
2022-11-30 20:02:39 +00:00
|
|
|
librln: $(LIBRLN_BUILDDIR)/$(LIBRLN_FILE)
|
|
|
|
endif
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
clean-librln:
|
|
|
|
cargo clean --manifest-path vendor/zerokit/rln/Cargo.toml
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
# Extend clean target
|
|
|
|
clean: | clean-librln
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2020-10-03 05:26:49 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
#############
|
|
|
|
## Waku v2 ##
|
|
|
|
#############
|
|
|
|
.PHONY: test2 wakunode2 example2 sim2 scripts2 wakubridge chat2 chat2bridge
|
2020-08-26 12:20:04 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
test2: | build deps librln
|
2020-12-21 11:32:02 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2022-11-30 20:02:39 +00:00
|
|
|
$(ENV_SCRIPT) nim test2 $(NIM_PARAMS) $(EXPERIMENTAL_PARAMS) waku.nims
|
2020-12-21 11:32:02 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
wakunode2: | build deps librln
|
2020-04-30 15:51:30 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2022-11-30 20:02:39 +00:00
|
|
|
$(ENV_SCRIPT) nim wakunode2 $(NIM_PARAMS) $(EXPERIMENTAL_PARAMS) waku.nims
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2022-11-07 08:14:21 +00:00
|
|
|
example2: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim example2 $(NIM_PARAMS) waku.nims
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
# TODO: Remove unused target
|
|
|
|
sim2: | build deps wakunode2
|
2020-04-30 15:51:30 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2020-10-03 05:26:49 +00:00
|
|
|
$(ENV_SCRIPT) nim sim2 $(NIM_PARAMS) waku.nims
|
2020-09-10 04:18:35 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
# TODO: Remove unused target
|
2022-11-07 08:14:21 +00:00
|
|
|
scripts2: | build deps wakunode2
|
2020-09-10 04:18:35 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2022-11-07 08:14:21 +00:00
|
|
|
$(ENV_SCRIPT) nim scripts2 $(NIM_PARAMS) waku.nims
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
wakubridge: | build deps
|
2022-11-07 08:14:21 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim bridge $(NIM_PARAMS) waku.nims
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
chat2: | build deps librln
|
2022-11-07 08:14:21 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2022-11-30 20:02:39 +00:00
|
|
|
$(ENV_SCRIPT) nim chat2 $(NIM_PARAMS) $(EXPERIMENTAL_PARAMS) waku.nims
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
chat2bridge: | build deps
|
2022-11-07 08:14:21 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim chat2bridge $(NIM_PARAMS) waku.nims
|
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
|
|
|
|
###################
|
|
|
|
## Waku v2 tools ##
|
|
|
|
###################
|
|
|
|
.PHONY: wakucanary networkmonitor
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2022-10-11 03:58:44 +00:00
|
|
|
wakucanary: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim wakucanary $(NIM_PARAMS) waku.nims
|
|
|
|
|
2022-11-10 09:29:34 +00:00
|
|
|
networkmonitor: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim networkmonitor $(NIM_PARAMS) waku.nims
|
2021-02-04 19:30:00 +00:00
|
|
|
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
#################
|
|
|
|
## Waku legacy ##
|
|
|
|
#################
|
|
|
|
.PHONY: testwhisper test1 wakunode1 example1 sim1
|
|
|
|
|
|
|
|
testwhisper: | build deps
|
2022-11-07 08:14:21 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2022-11-30 20:02:39 +00:00
|
|
|
$(ENV_SCRIPT) nim testwhisper $(NIM_PARAMS) waku.nims
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
test1: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim test1 $(NIM_PARAMS) waku.nims
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
wakunode1: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim wakunode1 $(NIM_PARAMS) waku.nims
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2023-03-13 14:33:24 +00:00
|
|
|
example1: | build deps
|
2022-11-30 20:02:39 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim example1 $(NIM_PARAMS) waku.nims
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
sim1: | build deps wakunode1
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim sim1 $(NIM_PARAMS) waku.nims
|
2021-02-04 19:30:00 +00:00
|
|
|
|
2022-08-05 20:58:19 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
###################
|
|
|
|
## Documentation ##
|
|
|
|
###################
|
|
|
|
.PHONY: docs
|
2020-10-08 09:10:45 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
# TODO: Remove unused target
|
|
|
|
docs: | build deps
|
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
2022-12-12 11:22:46 +00:00
|
|
|
$(ENV_SCRIPT) nim doc --run --index:on --project --out:.gh-pages waku/waku.nim waku.nims
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
|
|
|
|
#####################
|
|
|
|
## Container image ##
|
|
|
|
#####################
|
|
|
|
# -d:insecure - Necessary to enable Prometheus HTTP endpoint for metrics
|
|
|
|
# -d:chronicles_colors:none - Necessary to disable colors in logs for Docker
|
|
|
|
DOCKER_IMAGE_NIMFLAGS ?= -d:chronicles_colors:none -d:insecure
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2020-05-26 12:04:40 +00:00
|
|
|
# build a docker image for the fleet
|
2022-11-30 20:02:39 +00:00
|
|
|
docker-image: MAKE_TARGET ?= wakunode2
|
2023-03-17 14:04:26 +00:00
|
|
|
docker-image: DOCKER_IMAGE_TAG ?= $(MAKE_TARGET)-$(GIT_VERSION)
|
2020-09-09 18:14:07 +00:00
|
|
|
docker-image: DOCKER_IMAGE_NAME ?= statusteam/nim-waku:$(DOCKER_IMAGE_TAG)
|
2020-05-26 12:04:40 +00:00
|
|
|
docker-image:
|
|
|
|
docker build \
|
2020-09-09 18:14:07 +00:00
|
|
|
--build-arg="MAKE_TARGET=$(MAKE_TARGET)" \
|
2022-05-17 19:11:07 +00:00
|
|
|
--build-arg="NIMFLAGS=$(DOCKER_IMAGE_NIMFLAGS)" \
|
2022-11-30 20:02:39 +00:00
|
|
|
--build-arg="EXPERIMENTAL=$(EXPERIMENTAL)" \
|
|
|
|
--label="commit=$(GIT_VERSION)" \
|
2020-05-26 12:04:40 +00:00
|
|
|
--tag $(DOCKER_IMAGE_NAME) .
|
|
|
|
|
|
|
|
docker-push:
|
|
|
|
docker push $(DOCKER_IMAGE_NAME)
|
|
|
|
|
2022-11-07 08:14:21 +00:00
|
|
|
|
2022-11-30 20:02:39 +00:00
|
|
|
##############
|
|
|
|
## Wrappers ##
|
|
|
|
##############
|
|
|
|
# TODO: Remove unused target
|
2022-11-07 08:14:21 +00:00
|
|
|
libwaku.so: | build deps deps2
|
2021-06-13 12:50:10 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/$@" && \
|
|
|
|
$(ENV_SCRIPT) nim c --app:lib --noMain --nimcache:nimcache/libwaku $(NIM_PARAMS) -o:build/$@.0 wrappers/libwaku.nim && \
|
|
|
|
rm -f build/$@ && \
|
|
|
|
ln -s $@.0 build/$@
|
|
|
|
|
|
|
|
# libraries for dynamic linking of non-Nim objects
|
|
|
|
EXTRA_LIBS_DYNAMIC := -L"$(CURDIR)/build" -lwaku -lm
|
2022-11-30 20:02:39 +00:00
|
|
|
|
|
|
|
# TODO: Remove unused target
|
|
|
|
wrappers: | build deps librln libwaku.so
|
2021-06-13 12:50:10 +00:00
|
|
|
echo -e $(BUILD_MSG) "build/C_wrapper_example" && \
|
|
|
|
$(CC) wrappers/wrapper_example.c -Wl,-rpath,'$$ORIGIN' $(EXTRA_LIBS_DYNAMIC) -g -o build/C_wrapper_example
|
|
|
|
echo -e $(BUILD_MSG) "build/go_wrapper_example" && \
|
|
|
|
go build -ldflags "-linkmode external -extldflags '$(EXTRA_LIBS_DYNAMIC)'" -o build/go_wrapper_example wrappers/wrapper_example.go #wrappers/cfuncs.go
|
2022-11-30 20:02:39 +00:00
|
|
|
|
|
|
|
endif # "variables.mk" was not included
|