2022-11-30 21:02:39 +01:00
# Copyright (c) 2022 Status Research & Development GmbH. Licensed under
2020-04-30 17:51:30 +02: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.
2020-04-29 12:49:27 +08:00
2026-04-02 17:16:12 +02:00
i n c l u d e N a t . m k
i n c l u d e B e a r S S L . m k
2020-04-29 13:54:03 +08:00
2026-04-02 17:16:12 +02:00
LINK_PCRE := 0
FORMAT_MSG := "\\x1B[95mFormatting:\\x1B[39m"
BUILD_MSG := "Building:"
2020-04-30 17:51:30 +02:00
2024-10-23 11:59:37 +05:30
# Determine the OS
detected_OS := $( shell uname -s)
i f n e q ( , $( findstring MINGW ,$ ( detected_OS ) ) )
detected_OS := Windows
e n d i f
2026-04-02 17:16:12 +02:00
# NIM binary location
NIM_BINARY := $( shell which nim)
NPH := $( CURDIR) /nimbledeps/bin/nph
NIMBLEDEPS_STAMP := nimbledeps/.nimble-setup
# Compilation parameters
NIM_PARAMS ?=
2024-10-28 16:43:00 +01:00
i f e q ( $( detected_OS ) , W i n d o w s )
2025-03-05 21:21:59 +05:30
MINGW_PATH = /mingw64
NIM_PARAMS += --passC:" -I $( MINGW_PATH) /include "
NIM_PARAMS += --passL:" -L $( MINGW_PATH) /lib "
2026-04-02 17:16:12 +02:00
LIBS = -lws2_32 -lbcrypt -liphlpapi -luserenv -lntdll -lpq
2024-10-23 11:59:37 +05:30
NIM_PARAMS += $( foreach lib,$( LIBS) ,--passL:" $( lib) " )
2026-02-11 03:00:57 +05:30
NIM_PARAMS += --passL:"-Wl,--allow-multiple-definition"
2025-11-25 10:05:40 +01:00
export PATH := /c/msys64/usr/bin:/c/msys64/mingw64/bin:/c/msys64/usr/lib:/c/msys64/mingw64/lib:$( PATH)
2024-05-21 21:00:22 -04:00
e n d i f
2022-11-30 21:02:39 +01:00
##########
## Main ##
##########
2026-04-02 17:16:12 +02:00
.PHONY : all test update clean examples deps nimble
2022-11-30 21:02:39 +01:00
2026-04-02 17:16:12 +02:00
# default target
2026-01-29 15:48:34 +01:00
all : | wakunode 2 libwaku
examples : | example 2 chat 2 chat 2bridge
2021-06-23 19:14:37 +02:00
2025-07-22 12:06:08 +05:30
test_file := $( word 2,$( MAKECMDGOALS) )
d e f i n e t e s t _ n a m e
$( shell echo '$ ( MAKECMDGOALS ) ' | cut -d ' ' -f 3-)
e n d e f
2025-07-08 18:25:36 +05:30
test :
2025-07-22 12:06:08 +05:30
i f e q ( $( strip $ ( test_file ) ) , )
2025-07-08 18:25:36 +05:30
$( MAKE) testcommon
$( MAKE) testwaku
e l s e
2025-07-22 12:06:08 +05:30
$( MAKE) compile-test TEST_FILE = " $( test_file) " TEST_NAME = " $( call test_name) "
2025-07-08 18:25:36 +05:30
e n d i f
2026-04-02 17:16:12 +02:00
# this prevents make from erroring on unknown targets
2025-07-08 18:25:36 +05:30
% :
@true
2022-11-07 09:14:21 +01:00
2022-11-30 21:02:39 +01:00
waku.nims :
ln -s waku.nimble $@
2026-04-03 22:14:17 +02:00
$(NIMBLEDEPS_STAMP) : nimble .lock | waku .nims
2026-04-04 16:31:02 +02:00
# nim and nimble entries in nimble.lock carry platform-specific checksums that
# cause checksum mismatches on other platforms. Strip them before setup and
# restore the original lock file afterwards so the versioned file stays intact.
cp nimble.lock nimble.lock.bak
python3 -c "import json; lock=json.load(open('nimble.lock')); [lock['packages'].pop(k,None) for k in ['nim','nimble']]; json.dump(lock,open('nimble.lock','w'),indent=2)"
nimble setup --localdeps || { mv nimble.lock.bak nimble.lock; exit 1; }
mv nimble.lock.bak nimble.lock
2024-10-28 16:43:00 +01:00
$( MAKE) build-nph
2026-04-02 17:16:12 +02:00
$( MAKE) rebuild-nat-libs-nimbledeps
$( MAKE) rebuild-bearssl-nimbledeps
touch $@
update :
rm -f $( NIMBLEDEPS_STAMP)
$( MAKE) $( NIMBLEDEPS_STAMP)
nimble lock
2022-11-07 09:14:21 +01:00
2022-11-30 21:02:39 +01:00
clean :
2026-04-02 17:51:49 +02:00
rm -rf build 2> /dev/null || true
rm -rf nimbledeps 2> /dev/null || true
2026-04-02 17:16:12 +02:00
rm nimble.lock 2> /dev/null || true
2026-04-02 17:51:49 +02:00
rm -fr nimcache 2> /dev/null || true
rm nimble.paths 2> /dev/null || true
2026-04-02 17:16:12 +02:00
nimble clean
2026-04-02 17:51:49 +02:00
REQUIRED_NIM_VERSION := $( shell grep -E '^requires "nim ==' waku.nimble | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' )
REQUIRED_NIMBLE_VERSION := $( shell grep -E '^requires "nimble ==' waku.nimble | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' )
2026-04-02 17:16:12 +02:00
build :
2026-04-02 17:51:49 +02:00
@nim_ver= $$ ( nim --version 2>/dev/null | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) ; \
if [ " $$ nim_ver " != " $( REQUIRED_NIM_VERSION) " ] ; then \
echo " Error: Nim $( REQUIRED_NIM_VERSION) is required, but found ' $$ nim_ver' " ; \
exit 1; \
fi
@nimble_ver= $$ ( nimble --version 2>/dev/null | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) ; \
if [ " $$ nimble_ver " != " $( REQUIRED_NIMBLE_VERSION) " ] ; then \
echo " Error: Nimble $( REQUIRED_NIMBLE_VERSION) is required, but found ' $$ nimble_ver' " ; \
exit 1; \
fi
2026-04-02 17:16:12 +02:00
mkdir -p build
nimble :
echo "Inside nimble target, checking for nimble..." && \
command -v nimble >/dev/null 2>& 1 || { \
mv nimbledeps nimbledeps_backup 2>/dev/null || true; \
echo "choosenim not found, installing ..." ; \
curl -sSf https://nim-lang.org/choosenim/init.sh | sh; \
mv nimbledeps_backup nimbledeps 2>/dev/null || true; \
}
2020-04-30 17:51:30 +02:00
2023-04-25 17:54:28 +02:00
## Possible values: prod; debug
TARGET ?= prod
2022-11-07 09:14:21 +01:00
2022-11-30 21:02:39 +01:00
## Git version
GIT_VERSION ?= $( shell git describe --abbrev= 6 --always --tags)
NIM_PARAMS := $( NIM_PARAMS) -d:git_version= \" $( GIT_VERSION) \"
2023-04-25 17:54:28 +02:00
## Heaptracker options
HEAPTRACKER ?= 0
HEAPTRACKER_INJECT ?= 0
i f e q ( $( HEAPTRACKER ) , 1 )
2025-05-28 19:07:07 +02:00
TARGET := debug-with-heaptrack
2023-04-25 17:54:28 +02:00
i f e q ( $( HEAPTRACKER_INJECT ) , 1 )
HEAPTRACK_PARAMS := -d:heaptracker -d:heaptracker_inject
2025-05-28 19:07:07 +02:00
NIM_PARAMS := $( NIM_PARAMS) -d:heaptracker -d:heaptracker_inject
2023-04-25 17:54:28 +02:00
e l s e
HEAPTRACK_PARAMS := -d:heaptracker
2025-05-28 19:07:07 +02:00
NIM_PARAMS := $( NIM_PARAMS) -d:heaptracker
2023-04-25 17:54:28 +02:00
e n d i f
2024-02-22 16:59:13 +05:30
e n d i f
2026-04-02 17:16:12 +02:00
# Debug/Release mode
2025-01-23 12:11:54 +01:00
i f e q ( $( DEBUG ) , 0 )
2026-04-02 17:16:12 +02:00
NIM_PARAMS := $( NIM_PARAMS) -d:release
2025-01-23 12:11:54 +01:00
e l s e
NIM_PARAMS := $( NIM_PARAMS) -d:debug
e n d i f
NIM_PARAMS := $( NIM_PARAMS) -d:disable_libbacktrace
2020-04-30 17:51:30 +02:00
2025-11-22 08:11:05 +05:30
# enable experimental exit is dest feature in libp2p mix
2026-01-23 14:06:30 +01:00
NIM_PARAMS := $( NIM_PARAMS) -d:libp2p_mix_experimental_exit_is_dest
2025-11-22 08:11:05 +05:30
2023-09-13 12:45:55 +02:00
i f e q ( $( POSTGRES ) , 1 )
NIM_PARAMS := $( NIM_PARAMS) -d:postgres -d:nimDebugDlOpen
e n d i f
2024-06-26 14:25:58 +02:00
i f e q ( $( DEBUG_DISCV 5) , 1 )
NIM_PARAMS := $( NIM_PARAMS) -d:debugDiscv5
e n d i f
2026-04-02 17:16:12 +02:00
# Export NIM_PARAMS so nimble can access it
export NIM_PARAMS
2022-11-07 09:14:21 +01:00
2026-04-02 17:16:12 +02:00
##################
## Dependencies ##
##################
.PHONY : deps
2025-04-09 09:45:43 +02:00
2026-04-02 17:16:12 +02:00
FOUNDRY_VERSION := 1.5.0
PNPM_VERSION := 10.23.0
rustup :
i f e q ( , $( shell which cargo ) )
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
e n d i f
rln-deps : rustup
./scripts/install_rln_tests_dependencies.sh $( FOUNDRY_VERSION) $( PNPM_VERSION)
deps : | nimble
2022-11-07 09:14:21 +01:00
2022-11-30 21:02:39 +01:00
##################
2023-09-11 12:02:31 +05:30
## RLN ##
2022-11-30 21:02:39 +01:00
##################
2024-06-20 15:05:21 +05:30
.PHONY : librln
2020-04-30 17:51:30 +02:00
2023-09-01 16:50:55 +05:30
LIBRLN_BUILDDIR := $( CURDIR) /vendor/zerokit
2025-10-15 19:08:46 +05:30
LIBRLN_VERSION := v0.9.0
2022-11-07 09:14:21 +01:00
2024-10-23 11:59:37 +05:30
i f e q ( $( detected_OS ) , W i n d o w s )
2026-01-23 14:06:30 +01:00
LIBRLN_FILE ?= rln.lib
2022-11-30 21:02:39 +01:00
e l s e
2026-01-23 14:06:30 +01:00
LIBRLN_FILE ?= librln_$( LIBRLN_VERSION) .a
2022-11-30 21:02:39 +01:00
e n d i f
2022-11-07 09:14:21 +01:00
2023-08-30 00:22:22 +05:30
$(LIBRLN_FILE) :
2026-04-03 23:03:17 +02:00
git submodule update --init vendor/zerokit
2022-11-30 21:02:39 +01:00
echo -e $( BUILD_MSG) " $@ " && \
2026-04-02 17:16:12 +02:00
bash scripts/build_rln.sh $( LIBRLN_BUILDDIR) $( LIBRLN_VERSION) $( LIBRLN_FILE)
2022-11-07 09:14:21 +01:00
2024-06-20 15:05:21 +05:30
librln : | $( LIBRLN_FILE )
2024-05-21 21:00:22 -04:00
$( eval NIM_PARAMS += --passL:$( LIBRLN_FILE) --passL:-lm)
2020-04-30 17:51:30 +02:00
2022-11-30 21:02:39 +01:00
clean-librln :
cargo clean --manifest-path vendor/zerokit/rln/Cargo.toml
2023-08-30 00:22:22 +05:30
rm -f $( LIBRLN_FILE)
2022-11-07 09:14:21 +01:00
2022-11-30 21:02:39 +01:00
clean : | clean -librln
2020-04-30 17:51:30 +02:00
2023-03-31 15:24:04 +02:00
#################
## Waku Common ##
#################
.PHONY : testcommon
2026-04-02 17:16:12 +02:00
testcommon : | build
2023-03-31 15:24:04 +02:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble testcommon
2023-03-31 15:24:04 +02:00
2023-08-09 18:11:50 +01:00
##########
## Waku ##
##########
2024-07-17 15:21:37 +02:00
.PHONY : testwaku wakunode 2 testwakunode 2 example 2 chat 2 chat 2bridge liteprotocoltester
2020-08-26 14:20:04 +02:00
2026-04-02 17:16:12 +02:00
testwaku : | build rln -deps librln
2020-12-21 12:32:02 +01:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble test
2020-12-21 12:32:02 +01:00
2026-04-02 17:16:12 +02:00
wakunode2 : | $( NIMBLEDEPS_STAMP ) build deps librln
2020-04-30 17:51:30 +02:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble wakunode2
2020-04-30 17:51:30 +02:00
2026-04-02 17:16:12 +02:00
benchmarks : | $( NIMBLEDEPS_STAMP ) build deps librln
2024-02-09 17:06:25 +01:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble benchmarks
2024-02-09 17:06:25 +01:00
2026-04-02 17:16:12 +02:00
testwakunode2 : | $( NIMBLEDEPS_STAMP ) build deps librln
2023-04-25 15:34:57 +02:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble testwakunode2
2023-04-25 15:34:57 +02:00
2026-04-02 17:16:12 +02:00
example2 : | $( NIMBLEDEPS_STAMP ) build deps librln
2022-11-07 09:14:21 +01:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble example2
2022-11-07 09:14:21 +01:00
2026-04-02 17:16:12 +02:00
chat2 : | $( NIMBLEDEPS_STAMP ) build deps librln
2022-11-07 09:14:21 +01:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble chat2
2022-11-07 09:14:21 +01:00
2026-04-02 17:16:12 +02:00
chat2mix : | $( NIMBLEDEPS_STAMP ) build deps librln
2025-09-11 20:40:01 +05:30
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble chat2mix
2025-09-11 20:40:01 +05:30
2026-04-02 17:16:12 +02:00
rln-db-inspector : | $( NIMBLEDEPS_STAMP ) build deps librln
2023-09-07 18:15:25 +05:30
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble rln_db_inspector
2023-09-07 18:15:25 +05:30
2026-04-02 17:16:12 +02:00
chat2bridge : | $( NIMBLEDEPS_STAMP ) build deps librln
2022-11-07 09:14:21 +01:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble chat2bridge
2022-11-07 09:14:21 +01:00
2026-04-02 17:16:12 +02:00
liteprotocoltester : | $( NIMBLEDEPS_STAMP ) build deps librln
2024-05-21 23:03:33 +02:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble liteprotocoltester
2024-05-21 23:03:33 +02:00
2026-04-02 17:16:12 +02:00
lightpushwithmix : | $( NIMBLEDEPS_STAMP ) build deps librln
2025-09-11 20:40:01 +05:30
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble lightpushwithmix
2025-09-11 20:40:01 +05:30
2026-04-02 17:16:12 +02:00
api_example : | $( NIMBLEDEPS_STAMP ) build deps librln
2026-01-30 01:06:00 +01:00
echo -e $( BUILD_MSG) " build/ $@ " && \
$( ENV_SCRIPT) nim api_example $( NIM_PARAMS) waku.nims
2026-04-02 17:16:12 +02:00
build/% : | $( NIMBLEDEPS_STAMP ) build deps librln
2024-07-17 15:21:37 +02:00
echo -e $( BUILD_MSG) " build/ $* " && \
2026-04-02 17:16:12 +02:00
nimble buildone $*
2024-07-17 15:21:37 +02:00
2026-04-02 17:16:12 +02:00
compile-test : | $( NIMBLEDEPS_STAMP ) build deps librln
2025-08-29 13:14:05 +02:00
echo -e $( BUILD_MSG) " $( TEST_FILE) " " \" $( TEST_NAME) \" " && \
2026-04-03 01:11:18 +02:00
nimble buildTest $( TEST_FILE) && \
nimble execTest $( TEST_FILE) " \" $( TEST_NAME) \" "
2022-11-30 21:02:39 +01:00
2023-08-09 18:11:50 +01:00
################
## Waku tools ##
################
2023-04-12 10:22:45 +02:00
.PHONY : tools wakucanary networkmonitor
tools : networkmonitor wakucanary
2020-04-30 17:51:30 +02:00
2026-04-02 17:16:12 +02:00
wakucanary : | $( NIMBLEDEPS_STAMP ) build deps librln
2022-10-11 05:58:44 +02:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble wakucanary
2022-10-11 05:58:44 +02:00
2026-04-02 17:16:12 +02:00
networkmonitor : | $( NIMBLEDEPS_STAMP ) build deps librln
2022-11-10 10:29:34 +01:00
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble networkmonitor
2021-02-04 11:30:00 -08:00
2024-08-20 15:14:35 +10:00
############
## Format ##
############
2024-09-11 11:51:42 +10:00
.PHONY : build -nph install -nph clean -nph print -nph -path
2024-08-20 15:14:35 +10:00
2024-10-28 16:43:00 +01:00
build-nph : | build deps
2026-04-02 17:16:12 +02:00
i f n e q ( $( detected_OS ) , W i n d o w s )
2026-04-02 17:51:49 +02:00
if command -v nph > /dev/null 2>& 1; then \
echo "nph already installed, skipping" ; \
else \
echo "Installing nph globally" ; \
2026-04-03 23:27:00 +02:00
( cd /tmp && nimble install nph@0.7.0 --accept -g) ; \
2026-04-02 17:51:49 +02:00
fi
echo "Check if nph utility is available"
2026-04-02 17:16:12 +02:00
PATH = " $( CURDIR) /nimbledeps/bin: $$ PATH " command -v nph
2024-10-28 16:43:00 +01:00
e l s e
2026-04-02 17:16:12 +02:00
echo "Skipping nph build on Windows (nph is only used on Unix-like systems)"
2024-10-28 16:43:00 +01:00
e n d i f
2024-08-20 15:14:35 +10:00
GIT_PRE_COMMIT_HOOK := .git/hooks/pre-commit
install-nph : build -nph
i f e q ( "$(wildcard $(GIT_PRE_COMMIT_HOOK))" , "" )
cp ./scripts/git_pre_commit_format.sh $( GIT_PRE_COMMIT_HOOK)
e l s e
echo " $( GIT_PRE_COMMIT_HOOK) already present, will NOT override "
exit 1
e n d i f
2024-10-28 16:43:00 +01:00
nph/% : | build -nph
2024-08-20 15:14:35 +10:00
echo -e $( FORMAT_MSG) " nph/ $* " && \
$( NPH) $*
clean-nph :
rm -f $( NPH)
2024-09-11 11:51:42 +10:00
print-nph-path :
2026-04-02 17:16:12 +02:00
@echo " $( NPH) "
2024-09-11 11:51:42 +10:00
2024-08-20 15:14:35 +10:00
clean : | clean -nph
2022-11-07 09:14:21 +01:00
2022-11-30 21:02:39 +01:00
###################
## Documentation ##
###################
2024-01-30 19:55:26 +08:00
.PHONY : docs coverage
2020-10-08 11:10:45 +02:00
2022-11-30 21:02:39 +01:00
docs : | build deps
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
nimble doc --run --index:on --project --out:.gh-pages waku/waku.nim waku.nims
2020-04-30 17:51:30 +02:00
2024-01-30 19:55:26 +08:00
coverage :
echo -e $( BUILD_MSG) " build/ $@ " && \
2026-04-02 17:16:12 +02:00
./scripts/run_cov.sh -y
2022-11-30 21:02:39 +01:00
#####################
## Container image ##
#####################
2023-09-13 12:45:55 +02:00
DOCKER_IMAGE_NIMFLAGS ?= -d:chronicles_colors:none -d:insecure -d:postgres
2023-04-25 17:54:28 +02:00
DOCKER_IMAGE_NIMFLAGS := $( DOCKER_IMAGE_NIMFLAGS) $( HEAPTRACK_PARAMS)
2020-04-30 17:51:30 +02:00
2022-11-30 21:02:39 +01:00
docker-image : MAKE_TARGET ?= wakunode 2
2023-03-17 15:04:26 +01:00
docker-image : DOCKER_IMAGE_TAG ?= $( MAKE_TARGET ) -$( GIT_VERSION )
2023-09-26 12:09:20 +02:00
docker-image : DOCKER_IMAGE_NAME ?= wakuorg /nwaku :$( DOCKER_IMAGE_TAG )
2020-05-26 14:04:40 +02:00
docker-image :
docker build \
2020-09-09 20:14:07 +02:00
--build-arg= " MAKE_TARGET= $( MAKE_TARGET) " \
2022-05-17 21:11:07 +02:00
--build-arg= " NIMFLAGS= $( DOCKER_IMAGE_NIMFLAGS) " \
2023-05-23 10:44:57 +02:00
--build-arg= " LOG_LEVEL= $( LOG_LEVEL) " \
2025-08-29 08:10:22 +02:00
--build-arg= " HEAPTRACK_BUILD= $( HEAPTRACKER) " \
2024-02-27 14:13:52 +01:00
--label= " commit= $( shell git rev-parse HEAD) " \
--label= " version= $( GIT_VERSION) " \
2023-04-25 17:54:28 +02:00
--target $( TARGET) \
2020-05-26 14:04:40 +02:00
--tag $( DOCKER_IMAGE_NAME) .
2025-04-25 14:15:39 +02:00
docker-quick-image : MAKE_TARGET ?= wakunode 2
docker-quick-image : DOCKER_IMAGE_TAG ?= $( MAKE_TARGET ) -$( GIT_VERSION )
docker-quick-image : DOCKER_IMAGE_NAME ?= wakuorg /nwaku :$( DOCKER_IMAGE_TAG )
2025-08-29 08:10:22 +02:00
docker-quick-image : NIM_PARAMS := $( NIM_PARAMS ) -d :chronicles_colors :none -d :insecure -d :postgres --passL :$( LIBRLN_FILE ) --passL :-lm
2026-04-02 17:16:12 +02:00
docker-quick-image : | build librln wakunode 2
2025-04-25 14:15:39 +02:00
docker build \
--build-arg= " MAKE_TARGET= $( MAKE_TARGET) " \
--tag $( DOCKER_IMAGE_NAME) \
2025-05-28 19:07:07 +02:00
--target $( TARGET) \
--file docker/binaries/Dockerfile.bn.local \
2025-04-25 14:15:39 +02:00
.
2020-05-26 14:04:40 +02:00
docker-push :
docker push $( DOCKER_IMAGE_NAME)
2024-10-25 22:59:02 +02:00
####################################
## Container lite-protocol-tester ##
####################################
DOCKER_LPT_NIMFLAGS ?= -d:chronicles_colors:none -d:insecure
docker-liteprotocoltester : DOCKER_LPT_TAG ?= latest
docker-liteprotocoltester : DOCKER_LPT_NAME ?= wakuorg /liteprotocoltester :$( DOCKER_LPT_TAG )
docker-liteprotocoltester :
docker build \
--build-arg= "MAKE_TARGET=liteprotocoltester" \
--build-arg= " NIMFLAGS= $( DOCKER_LPT_NIMFLAGS) " \
--build-arg= "LOG_LEVEL=TRACE" \
--label= " commit= $( shell git rev-parse HEAD) " \
--label= " version= $( GIT_VERSION) " \
2024-11-26 20:42:27 +01:00
--target $( if $( filter deploy,$( DOCKER_LPT_TAG) ) ,deployment_lpt,standalone_lpt) \
2024-10-25 22:59:02 +02:00
--tag $( DOCKER_LPT_NAME) \
--file apps/liteprotocoltester/Dockerfile.liteprotocoltester.compile \
.
2025-04-25 14:15:39 +02:00
docker-quick-liteprotocoltester : DOCKER_LPT_TAG ?= latest
docker-quick-liteprotocoltester : DOCKER_LPT_NAME ?= wakuorg /liteprotocoltester :$( DOCKER_LPT_TAG )
docker-quick-liteprotocoltester : | liteprotocoltester
docker build \
--tag $( DOCKER_LPT_NAME) \
--file apps/liteprotocoltester/Dockerfile.liteprotocoltester \
.
2024-10-25 22:59:02 +02:00
docker-liteprotocoltester-push :
docker push $( DOCKER_LPT_NAME)
2023-05-12 18:08:41 +02:00
################
## C Bindings ##
################
2026-02-17 10:38:35 +01:00
.PHONY : cbindings cwaku_example libwaku liblogosdelivery liblogosdelivery_example
2023-05-12 18:08:41 +02:00
2026-04-02 17:16:12 +02:00
detected_OS ?= Linux
i f e q ( $( OS ) , W i n d o w s _ N T )
detected_OS := Windows
e l s e
detected_OS := $( shell uname -s)
e n d i f
BUILD_COMMAND ?= Dynamic
2025-01-23 12:11:54 +01:00
STATIC ?= 0
2026-04-02 17:16:12 +02:00
i f e q ( $( STATIC ) , 1 )
BUILD_COMMAND = Static
e n d i f
2021-06-13 20:50:10 +08:00
2025-12-15 12:11:11 +01:00
i f e q ( $( detected_OS ) , W i n d o w s )
2026-04-02 17:16:12 +02:00
BUILD_COMMAND := $( BUILD_COMMAND) Windows
2025-12-15 12:11:11 +01:00
e l s e i f e q ( $( detected_OS ) , D a r w i n )
2026-04-02 17:16:12 +02:00
BUILD_COMMAND := $( BUILD_COMMAND) Mac
export IOS_SDK_PATH := $( shell xcrun --sdk iphoneos --show-sdk-path)
2025-12-15 12:11:11 +01:00
e l s e i f e q ( $( detected_OS ) , L i n u x )
2026-04-02 17:16:12 +02:00
BUILD_COMMAND := $( BUILD_COMMAND) Linux
2023-05-19 08:20:12 +02:00
e n d i f
2022-11-30 21:02:39 +01:00
2026-04-02 17:16:12 +02:00
libwaku : | $( NIMBLEDEPS_STAMP ) librln
nimble --verbose libwaku$( BUILD_COMMAND) $( NIM_PARAMS) waku.nimble
2026-02-17 10:38:35 +01:00
2026-04-02 17:16:12 +02:00
liblogosdelivery : | $( NIMBLEDEPS_STAMP ) librln
nimble --verbose liblogosdelivery$( BUILD_COMMAND) $( NIM_PARAMS) waku.nimble
2026-02-17 10:38:35 +01:00
logosdelivery_example : | build liblogosdelivery
@echo -e $( BUILD_MSG) " build/ $@ "
i f e q ( $( detected_OS ) , D a r w i n )
gcc -o build/$@ \
liblogosdelivery/examples/logosdelivery_example.c \
2026-03-04 09:48:48 +01:00
liblogosdelivery/examples/json_utils.c \
2026-02-17 10:38:35 +01:00
-I./liblogosdelivery \
-L./build \
-llogosdelivery \
-Wl,-rpath,./build
e l s e i f e q ( $( detected_OS ) , L i n u x )
gcc -o build/$@ \
liblogosdelivery/examples/logosdelivery_example.c \
2026-03-04 09:48:48 +01:00
liblogosdelivery/examples/json_utils.c \
2026-02-17 10:38:35 +01:00
-I./liblogosdelivery \
-L./build \
-llogosdelivery \
-Wl,-rpath,'$$ORIGIN'
e l s e i f e q ( $( detected_OS ) , W i n d o w s )
gcc -o build/$@ .exe \
liblogosdelivery/examples/logosdelivery_example.c \
2026-03-04 09:48:48 +01:00
liblogosdelivery/examples/json_utils.c \
2026-02-17 10:38:35 +01:00
-I./liblogosdelivery \
-L./build \
-llogosdelivery \
-lws2_32
e n d i f
2025-12-15 12:11:11 +01:00
2026-04-02 17:16:12 +02:00
cwaku_example : | build libwaku
echo -e $( BUILD_MSG) " build/ $@ " && \
cc -o " build/ $@ " \
./examples/cbindings/waku_example.c \
./examples/cbindings/base64.c \
-lwaku -Lbuild/ \
-pthread -ldl -lm
cppwaku_example : | build libwaku
echo -e $( BUILD_MSG) " build/ $@ " && \
g++ -o " build/ $@ " \
./examples/cpp/waku.cpp \
./examples/cpp/base64.cpp \
-lwaku -Lbuild/ \
-pthread -ldl -lm
nodejswaku : | build deps
echo -e $( BUILD_MSG) " build/ $@ " && \
node-gyp build --directory= examples/nodejs/
2024-05-21 21:00:22 -04:00
#####################
## Mobile Bindings ##
#####################
.PHONY : libwaku -android \
2026-04-02 17:16:12 +02:00
libwaku-android-precheck \
libwaku-android-arm64 \
libwaku-android-amd64 \
libwaku-android-x86 \
libwaku-android-arm
2024-05-21 21:00:22 -04:00
ANDROID_TARGET ?= 30
i f e q ( $( detected_OS ) , D a r w i n )
ANDROID_TOOLCHAIN_DIR := $( ANDROID_NDK_HOME) /toolchains/llvm/prebuilt/darwin-x86_64
e l s e
ANDROID_TOOLCHAIN_DIR := $( ANDROID_NDK_HOME) /toolchains/llvm/prebuilt/linux-x86_64
e n d i f
2024-06-20 15:05:21 +05:30
libwaku-android-precheck :
2024-05-21 21:00:22 -04:00
i f n d e f A N D R O I D _ N D K _ H O M E
2026-04-02 17:16:12 +02:00
$( error ANDROID_NDK_HOME is not set )
2024-05-21 21:00:22 -04:00
e n d i f
build-libwaku-for-android-arch :
2026-01-23 14:06:30 +01:00
i f n e q ( $( findstring /nix /store ,$ ( LIBRLN_FILE ) ) , )
mkdir -p $( CURDIR) /build/android/$( ABIDIR) /
2026-04-02 17:16:12 +02:00
CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_ARCH = $( ANDROID_ARCH) ANDROID_COMPILER = $( ANDROID_COMPILER) ANDROID_TOOLCHAIN_DIR = $( ANDROID_TOOLCHAIN_DIR) nimble libWakuAndroid
2026-01-23 14:06:30 +01:00
e l s e
./scripts/build_rln_android.sh $( CURDIR) /build $( LIBRLN_BUILDDIR) $( LIBRLN_VERSION) $( CROSS_TARGET) $( ABIDIR)
e n d i f
2026-04-02 17:16:12 +02:00
$( MAKE) rebuild-nat-libs-nimbledeps CC = $( ANDROID_TOOLCHAIN_DIR) /bin/$( ANDROID_COMPILER)
2024-05-21 21:00:22 -04:00
libwaku-android-arm64 : ANDROID_ARCH =aarch 64-linux -android
libwaku-android-arm64 : CPU =arm 64
libwaku-android-arm64 : ABIDIR =arm 64-v 8a
libwaku-android-arm64 : | libwaku -android -precheck build deps
$( MAKE) build-libwaku-for-android-arch ANDROID_ARCH = $( ANDROID_ARCH) CROSS_TARGET = $( ANDROID_ARCH) CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_COMPILER = $( ANDROID_ARCH) $( ANDROID_TARGET) -clang
libwaku-android-amd64 : ANDROID_ARCH =x 86_ 64-linux -android
libwaku-android-amd64 : CPU =amd 64
libwaku-android-amd64 : ABIDIR =x 86_ 64
libwaku-android-amd64 : | libwaku -android -precheck build deps
$( MAKE) build-libwaku-for-android-arch ANDROID_ARCH = $( ANDROID_ARCH) CROSS_TARGET = $( ANDROID_ARCH) CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_COMPILER = $( ANDROID_ARCH) $( ANDROID_TARGET) -clang
libwaku-android-x86 : ANDROID_ARCH =i 686-linux -android
libwaku-android-x86 : CPU =i 386
libwaku-android-x86 : ABIDIR =x 86
libwaku-android-x86 : | libwaku -android -precheck build deps
$( MAKE) build-libwaku-for-android-arch ANDROID_ARCH = $( ANDROID_ARCH) CROSS_TARGET = $( ANDROID_ARCH) CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_COMPILER = $( ANDROID_ARCH) $( ANDROID_TARGET) -clang
libwaku-android-arm : ANDROID_ARCH =armv 7a -linux -androideabi
libwaku-android-arm : CPU =arm
libwaku-android-arm : ABIDIR =armeabi -v 7a
libwaku-android-arm : | libwaku -android -precheck build deps
$( MAKE) build-libwaku-for-android-arch ANDROID_ARCH = $( ANDROID_ARCH) CROSS_TARGET = armv7-linux-androideabi CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_COMPILER = $( ANDROID_ARCH) $( ANDROID_TARGET) -clang
libwaku-android :
$( MAKE) libwaku-android-amd64
$( MAKE) libwaku-android-arm64
$( MAKE) libwaku-android-x86
2025-12-22 15:40:09 +02:00
#################
## iOS Bindings #
#################
.PHONY : libwaku -ios -precheck \
2026-04-02 17:16:12 +02:00
libwaku-ios-device \
libwaku-ios-simulator \
libwaku-ios
2025-12-22 15:40:09 +02:00
IOS_DEPLOYMENT_TARGET ?= 18.0
d e f i n e g e t _ i o s _ s d k _ p a t h
$( shell xcrun --sdk $ ( 1) --show -sdk -path 2>/dev /null )
e n d e f
libwaku-ios-precheck :
i f e q ( $( detected_OS ) , D a r w i n )
@command -v xcrun >/dev/null 2>& 1 || { echo "Error: Xcode command line tools not installed" ; exit 1; }
e l s e
$( error iOS builds are only supported on macOS)
e n d i f
build-libwaku-for-ios-arch :
2026-04-02 17:16:12 +02:00
IOS_SDK = $( IOS_SDK) IOS_ARCH = $( IOS_ARCH) IOS_SDK_PATH = $( IOS_SDK_PATH) nimble libWakuIOS
2025-12-22 15:40:09 +02:00
libwaku-ios-device : IOS_ARCH =arm 64
libwaku-ios-device : IOS_SDK =iphoneos
libwaku-ios-device : IOS_SDK_PATH =$( call get_ios_sdk_path ,iphoneos )
libwaku-ios-device : | libwaku -ios -precheck build deps
$( MAKE) build-libwaku-for-ios-arch IOS_ARCH = $( IOS_ARCH) IOS_SDK = $( IOS_SDK) IOS_SDK_PATH = $( IOS_SDK_PATH)
libwaku-ios-simulator : IOS_ARCH =arm 64
libwaku-ios-simulator : IOS_SDK =iphonesimulator
libwaku-ios-simulator : IOS_SDK_PATH =$( call get_ios_sdk_path ,iphonesimulator )
libwaku-ios-simulator : | libwaku -ios -precheck build deps
$( MAKE) build-libwaku-for-ios-arch IOS_ARCH = $( IOS_ARCH) IOS_SDK = $( IOS_SDK) IOS_SDK_PATH = $( IOS_SDK_PATH)
libwaku-ios :
$( MAKE) libwaku-ios-device
$( MAKE) libwaku-ios-simulator
2023-05-18 14:45:45 +02:00
###################
# Release Targets #
###################
release-notes :
docker run \
-it \
--rm \
-v $$ { PWD} :/opt/sv4git/repo:z \
-u $( shell id -u) \
docker.io/wakuorg/sv4git:latest \
release-notes | \
2026-04-02 17:16:12 +02:00
sed -E 's@#([0-9]+)@[#\1](https://github.com/waku-org/nwaku/issues/\1)@g'