From 6e859fa7e28be5ae263c19e9da2579fcd053e0f0 Mon Sep 17 00:00:00 2001 From: Emma Tebibyte Date: Wed, 7 Jan 2026 19:46:44 -0700 Subject: [PATCH] Makefile: remove hard bindgen(1) dep --- Makefile | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index da03b76..afebf0b 100644 --- a/Makefile +++ b/Makefile @@ -28,13 +28,18 @@ MANDIR != test $(PREFIX_N) = / && printf '/usr/share/man\n' \ SYSEXITS != printf '\043include \n' | cpp -M - | tr ' ' '\n' \ | sed -n 's/sysexits\.h//p' || printf 'include\n' +BINDGEN ?= bindgen +BINDGENFLAGS ?= --fit-macro-constant-types \ + --default-macro-constant-type unsigned --use-core --formatter=none + CC ?= cc +CFLAGS += -I$(SYSEXITS) + RUSTC ?= rustc RUSTFLAGS += --extern delimit=build/o/libdelimit.rlib \ --extern getopt=build/o/libgetopt.rlib \ --extern strerror=build/o/libstrerror.rlib \ --extern sysexits=build/o/libsysexits.rlib -CFLAGS += -I$(SYSEXITS) # testing requires the absolute path to the bin directory set BIN = build/bin @@ -71,15 +76,15 @@ TESTS != printf '%s\n' "$(TESTFILES)" | xargs -n1 basename \ include $(TESTFILES) .PHONY: test -test: all $(TESTS) /tmp/delimit /tmp/getopt +test: all $(TESTS) build/test/delimit build/test/getopt @echo $(TESTS) - /tmp/delimit - /tmp/getopt + build/test/delimit + build/test/getopt -/tmp/delimit: src/libdelimit.rs +build/test/delimit: src/libdelimit.rs $(RUSTC) --test -o $@ src/libdelimit.rs -/tmp/getopt: src/libgetopt.rs +build/test/getopt: src/libgetopt.rs $(RUSTC) --test -o $@ src/libgetopt.rs .PHONY: docs @@ -109,8 +114,8 @@ build/o/libstrerror.rlib: build src/libstrerror.rs src/libstrerror.rs build/o/libsysexits.rlib: build/include/sysexits.h - bindgen --fit-macro-constant-types --default-macro-constant-type unsigned --use-core --formatter=none \ - build/include/sysexits.h | $(RUSTC) $(RUSTFLAGS) --crate-type lib -o $@ - + $(BINDGEN) $(BINDGENFLAGS) build/include/sysexits.h \ + | $(RUSTC) $(RUSTFLAGS) --crate-type lib -o $@ - # bandage solution until bindgen(1) gets stdin support build/include/sysexits.h: build $(SYSEXITS)sysexits.h -- 2.51.0