From bdd258e7c4c3f2e3826d627e13556ff1a0fd71b2 Mon Sep 17 00:00:00 2001 From: DTB Date: Thu, 27 Jun 2024 20:30:40 -0600 Subject: [PATCH 1/7] Makefile: SYSEXITS: fix non-portable (openbsd) sed line --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9ecbedb..b234869 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ PREFIX ?= /usr/local MANDIR != [ $(PREFIX) = / ] && printf '/usr/share/man\n' \ || printf '/share/man\n' -SYSEXITS != printf '\043include \n' | cpp -M - | sed 's/ /\n/g' \ +SYSEXITS != printf '\043include \n' | cpp -M - | tr ' ' '\n' \ | sed -n 's/sysexits\.h//p' || printf 'include\n' CC ?= cc -- 2.30.2 From ab14fd6c0c83979f4bc83a3b8a1bc1ec44522be4 Mon Sep 17 00:00:00 2001 From: DTB Date: Thu, 27 Jun 2024 20:40:14 -0600 Subject: [PATCH 2/7] Makefile: SYSEXITS: use cpp -include instead of printf --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b234869..3e7c0f3 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ PREFIX ?= /usr/local MANDIR != [ $(PREFIX) = / ] && printf '/usr/share/man\n' \ || printf '/share/man\n' -SYSEXITS != printf '\043include \n' | cpp -M - | tr ' ' '\n' \ +SYSEXITS != Date: Thu, 27 Jun 2024 20:41:49 -0600 Subject: [PATCH 3/7] Makefile: SYSEXITS: use /dev/null directly instead of in a pipe --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3e7c0f3..8114cfc 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ PREFIX ?= /usr/local MANDIR != [ $(PREFIX) = / ] && printf '/usr/share/man\n' \ || printf '/share/man\n' -SYSEXITS != Date: Thu, 27 Jun 2024 21:09:31 -0600 Subject: [PATCH 4/7] Makefile: remove SYSEXITS; auto-generate sysexits.h falling back to the template --- Makefile | 14 ++++++++------ include/{sysexits.h => sysexits.h.template} | 0 2 files changed, 8 insertions(+), 6 deletions(-) rename include/{sysexits.h => sysexits.h.template} (100%) diff --git a/Makefile b/Makefile index 8114cfc..b9f62cd 100644 --- a/Makefile +++ b/Makefile @@ -18,15 +18,13 @@ PREFIX ?= /usr/local MANDIR != [ $(PREFIX) = / ] && printf '/usr/share/man\n' \ || printf '/share/man\n' -SYSEXITS != cpp -M -include sysexits.h /dev/null | tr ' ' '\n' \ - | sed -n 's/sysexits\.h//p' || printf 'include\n' CC ?= cc RUSTC ?= rustc RUSTLIBS = --extern getopt=build/o/libgetopt.rlib \ --extern sysexits=build/o/libsysexits.rlib \ --extern strerror=build/o/libstrerror.rlib -CFLAGS += -I$(SYSEXITS) +CFLAGS += -Ibuild/include .PHONY: all all: docs dj false fop hru intcmp mm npc rpn scrut str strcmp swab true @@ -65,6 +63,12 @@ docs: docs/ build rustlibs: build/o/libsysexits.rlib build/o/libgetopt.rlib \ build/o/libstrerror.rlib +build/include/sysexits.h: build + cpp -dM -include sysexits.h /dev/null \ + | grep '^.define EX_' >$@ \ + || cpp -dM -include stdlib.h include/sysexits.h.template \ + | grep -e '^.define EX_' -e '^.define EXIT_' >$@ + build/o/libgetopt.rlib: build src/getopt-rs/lib.rs $(RUSTC) $(RUSTFLAGS) --crate-type=lib --crate-name=getopt \ -o $@ src/getopt-rs/lib.rs @@ -74,9 +78,7 @@ build/o/libstrerror.rlib: build src/strerror.rs src/strerror.rs # bandage solution until bindgen(1) gets stdin support -build/o/libsysexits.rlib: build $(SYSEXITS)sysexits.h - printf '\043define EXIT_FAILURE 1\n' | cat - $(SYSEXITS)sysexits.h \ - > build/include/sysexits.h +build/o/libsysexits.rlib: build build/include/sysexits.h bindgen --default-macro-constant-type signed --use-core --formatter=none \ build/include/sysexits.h | $(RUSTC) $(RUSTFLAGS) --crate-type lib -o $@ - diff --git a/include/sysexits.h b/include/sysexits.h.template similarity index 100% rename from include/sysexits.h rename to include/sysexits.h.template -- 2.30.2 From 8c4552c0f3c88fdc413bc7cde0e29a6aa5ba31de Mon Sep 17 00:00:00 2001 From: DTB Date: Thu, 27 Jun 2024 21:33:03 -0600 Subject: [PATCH 5/7] Makefile: replace bindgen with awk --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index b9f62cd..7dbe906 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,6 @@ CFLAGS += -Ibuild/include .PHONY: all all: docs dj false fop hru intcmp mm npc rpn scrut str strcmp swab true -# keep build/include until bindgen(1) has stdin support -# https://github.com/rust-lang/rust-bindgen/issues/2703 build: mkdir -p build/bin build/docs build/include build/lib build/o build/test @@ -77,10 +75,10 @@ build/o/libstrerror.rlib: build src/strerror.rs $(RUSTC) $(RUSTFLAGS) --crate-type=lib -o $@ \ src/strerror.rs -# bandage solution until bindgen(1) gets stdin support build/o/libsysexits.rlib: build build/include/sysexits.h - bindgen --default-macro-constant-type signed --use-core --formatter=none \ - build/include/sysexits.h | $(RUSTC) $(RUSTFLAGS) --crate-type lib -o $@ - + Date: Fri, 28 Jun 2024 08:06:14 -0600 Subject: [PATCH 6/7] Makefile: fix npc, clean up swab --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7dbe906..43e2f1b 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ build/bin/mm: src/mm.c build .PHONY: npc npc: build/bin/npc build/bin/npc: src/npc.c build - $(CC) $(CFLAGAS) -o $@ src/npc.c + $(CC) $(CFLAGS) -o $@ src/npc.c .PHONY: rpn rpn: build/bin/rpn @@ -138,9 +138,7 @@ build/bin/strcmp: src/strcmp.c build .PHONY: swab swab: build/bin/swab build/bin/swab: src/swab.rs build rustlibs - $(RUSTC) $(RUSTFLAGS) --extern getopt=build/o/libgetopt.rlib \ - --extern sysexits=build/o/libsysexits.rlib \ - -o $@ src/swab.rs + $(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ src/swab.rs .PHONY: true true: build/bin/true -- 2.30.2 From 17b5573d40e17bbc44a716f618220d84c7537686 Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 28 Jun 2024 08:09:02 -0600 Subject: [PATCH 7/7] Makefile: build/include/sysexits.h depends on include/sysexits.h.template --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43e2f1b..16d26e9 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ docs: docs/ build rustlibs: build/o/libsysexits.rlib build/o/libgetopt.rlib \ build/o/libstrerror.rlib -build/include/sysexits.h: build +build/include/sysexits.h: build include/sysexits.h.template cpp -dM -include sysexits.h /dev/null \ | grep '^.define EX_' >$@ \ || cpp -dM -include stdlib.h include/sysexits.h.template \ -- 2.30.2