aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-15 00:38:47 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-15 03:01:11 +0200
commit30d93ab31e863d324cc8f83c78afe420bd1869db (patch)
tree5b8adadf4dbc5f897252ceda80967bec599e5597 /Makefile
parent6aeb68ee1ac276bfa87d5fabbbb33287cdde89d9 (diff)
downloadffwd-30d93ab31e863d324cc8f83c78afe420bd1869db.tar.gz
ffwd-30d93ab31e863d324cc8f83c78afe420bd1869db.zip
ci: add github release workflow
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile25
1 files changed, 22 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index f1285aa..c184a3e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,30 @@
-CC = gcc
+CC ?= gcc
+AR ?= ar
+ARCH_FLAGS ?= -march=native
+
+BUILD_DATE ?= $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
+BUILD_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
+BUILD_OS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
+BUILD_ARCH ?= $(shell uname -m)
+
+VERSION_CFLAGS = \
+ -DEMBED_BUILD_DATE=\"$(BUILD_DATE)\" \
+ -DEMBED_BUILD_COMMIT=\"$(BUILD_COMMIT)\" \
+ -DEMBED_BUILD_OS=\"$(BUILD_OS)\" \
+ -DEMBED_BUILD_ARCH=\"$(BUILD_ARCH)\"
+
+VERSION_CFLAGS =
+ifneq ($(strip $(VERSION)),)
+VERSION_CFLAGS += -DEMBED_VERSION=\"$(VERSION)\"
+endif
+
# Allow FP reassociation and contraction so reduction loops vectorize, but do
# not assume finite math or approximate libm calls: full -ffast-math produced
# NaN embeddings on GCC/OpenBLAS Linux builds (-ffinite-math-only and
# -fapprox-func are the unsafe parts and stay off).
# -fvisibility=hidden pairs with EMBED_API in the public headers: a new
# public function without the annotation will be missing from the shared lib.
-CFLAGS_BASE = -Wall -Wextra -O3 -march=native -fPIC -fvisibility=hidden \
+CFLAGS_BASE = -Wall -Wextra -O3 $(ARCH_FLAGS) $(VERSION_CFLAGS) -fPIC -fvisibility=hidden \
-fno-math-errno -ffp-contract=fast -fno-trapping-math \
-fno-signed-zeros -fassociative-math -freciprocal-math
LDFLAGS = -lm -lpthread
@@ -338,7 +357,7 @@ debug:
# Static library and binary link
# =============================================================================
$(LIB): $(OBJS) $(EXTRA_OBJS)
- ar rcs $@ $^
+ $(AR) rcs $@ $^
$(TARGET): $(LIB) embed_cli.o
$(CC) $(CFLAGS) -o $@ embed_cli.o $(LIB) $(LDFLAGS) $(CJSON_LDFLAGS)