From c7302624559e89f60d59f6806ff30e99d5368101 Mon Sep 17 00:00:00 2001 From: Ivan FB Date: Sat, 28 Mar 2026 03:12:33 +0100 Subject: [PATCH] add BearSSL.mk --- BearSSL.mk | 39 +++++++++++++++++++++++++++++++++++++++ Makefile | 2 ++ 2 files changed, 41 insertions(+) create mode 100644 BearSSL.mk diff --git a/BearSSL.mk b/BearSSL.mk new file mode 100644 index 000000000..7e7afb4c6 --- /dev/null +++ b/BearSSL.mk @@ -0,0 +1,39 @@ +# Copyright (c) 2022 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. + +########################### +## bearssl (nimbledeps) ## +########################### +# Rebuilds libbearssl.a from the package installed by nimble under +# nimbledeps/pkgs2/. Used by `make update` / $(NIMBLEDEPS_STAMP). +# +# BEARSSL_NIMBLEDEPS_DIR is evaluated at parse time, so targets that +# depend on it must be invoked via a recursive $(MAKE) call so the sub-make +# re-evaluates the variable after nimble setup has populated nimbledeps/. +# +# `ls -dt` (sort by modification time, newest first) is used to pick the +# latest installed version and is portable across Linux, macOS, and +# Windows (MSYS/MinGW). + +BEARSSL_NIMBLEDEPS_DIR := $(shell ls -dt $(CURDIR)/nimbledeps/pkgs2/bearssl-* 2>/dev/null | head -1) +BEARSSL_CSOURCES_DIR := $(BEARSSL_NIMBLEDEPS_DIR)/bearssl/csources + +.PHONY: clean-bearssl-nimbledeps rebuild-bearssl-nimbledeps + +clean-bearssl-nimbledeps: +ifeq ($(BEARSSL_NIMBLEDEPS_DIR),) + $(error No bearssl package found under nimbledeps/pkgs2/ — run 'make update' first) +endif + + [ -e "$(BEARSSL_CSOURCES_DIR)/build" ] && \ + "$(MAKE)" -C "$(BEARSSL_CSOURCES_DIR)" clean || true + +rebuild-bearssl-nimbledeps: | clean-bearssl-nimbledeps +ifeq ($(BEARSSL_NIMBLEDEPS_DIR),) + $(error No bearssl package found under nimbledeps/pkgs2/ — run 'make update' first) +endif + @echo "Rebuilding bearssl from $(BEARSSL_CSOURCES_DIR)" + + "$(MAKE)" -C "$(BEARSSL_CSOURCES_DIR)" lib diff --git a/Makefile b/Makefile index 7f38372f6..ca5287ce1 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ # according to those terms. include Nat.mk +include BearSSL.mk LINK_PCRE := 0 FORMAT_MSG := "\\x1B[95mFormatting:\\x1B[39m" @@ -71,6 +72,7 @@ $(NIMBLEDEPS_STAMP): | waku.nims nimble install --depsOnly $(MAKE) build-nph $(MAKE) rebuild-nat-libs-nimbledeps + $(MAKE) rebuild-bearssl-nimbledeps touch $@ update: