From 99feaba617d94335a9dcf58598485bf4b31f55c3 Mon Sep 17 00:00:00 2001 From: FreeBSD Port Tooling Date: Wed, 8 Apr 2026 12:39:53 +1200 Subject: [PATCH] Make the build scripts work on FreeBSD Make the source build less shell-fragile by deriving version macros in make, failing header generation when the result is blank, and using portable bash shebangs for the touched scripts. This preserves the current build flow while making it work on FreeBSD hosts that do not ship bash at /bin/bash and that expose the make recipe ordering bug. --- Makefile | 17 ++++++++++++----- scripts/publish-release.sh | 2 +- scripts/vendor.sh | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 175ab16..b07f787 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ COMMIT=$(shell git rev-parse HEAD) VERSION=$(shell cat VERSION) DATE=$(shell date +'%FT%TZ%z') +VERSION_MAJOR=$(shell cut -d. -f1 VERSION) +VERSION_MINOR=$(shell cut -d. -f2 VERSION) +VERSION_PATCH=$(shell cut -d. -f3 VERSION | cut -d- -f1) INSTALL_LIB_DIR = /usr/local/lib INSTALL_INCLUDE_DIR = /usr/local/include @@ -150,13 +153,17 @@ $(TARGET_CLI): sqlite-vec.h $(LIBS_DIR)/sqlite-vec.a $(LIBS_DIR)/shell.a $(LIBS_ sqlite-vec.h: sqlite-vec.h.tmpl VERSION - VERSION=$(shell cat VERSION) \ + VERSION=$(VERSION) \ DATE=$(shell date -r VERSION +'%FT%TZ%z') \ SOURCE=$(shell git log -n 1 --pretty=format:%H -- VERSION) \ - VERSION_MAJOR=$$(echo $$VERSION | cut -d. -f1) \ - VERSION_MINOR=$$(echo $$VERSION | cut -d. -f2) \ - VERSION_PATCH=$$(echo $$VERSION | cut -d. -f3 | cut -d- -f1) \ + VERSION_MAJOR=$(VERSION_MAJOR) \ + VERSION_MINOR=$(VERSION_MINOR) \ + VERSION_PATCH=$(VERSION_PATCH) \ envsubst < $< > $@ + grep -Eq '^#define SQLITE_VEC_VERSION "[^"]+"' $@ + grep -Eq '^#define SQLITE_VEC_VERSION_MAJOR [0-9]+' $@ + grep -Eq '^#define SQLITE_VEC_VERSION_MINOR [0-9]+' $@ + grep -Eq '^#define SQLITE_VEC_VERSION_PATCH [0-9]+' $@ clean: rm -rf dist @@ -174,7 +181,7 @@ format: $(FORMAT_FILES) clang-format -i $(FORMAT_FILES) black tests/test-loadable.py -lint: SHELL:=/bin/bash +lint: SHELL:=$(shell command -v bash || echo /bin/bash) lint: diff -u <(cat $(FORMAT_FILES)) <(clang-format $(FORMAT_FILES)) diff --git a/scripts/publish-release.sh b/scripts/publish-release.sh index 1e3b4c9..f0aafd7 100755 --- a/scripts/publish-release.sh +++ b/scripts/publish-release.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail xtrace diff --git a/scripts/vendor.sh b/scripts/vendor.sh index 033ea1e..1b43431 100755 --- a/scripts/vendor.sh +++ b/scripts/vendor.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash mkdir -p vendor curl -o sqlite-amalgamation.zip https://www.sqlite.org/2024/sqlite-amalgamation-3450300.zip unzip sqlite-amalgamation.zip