Makefile: remove SYSEXITS; auto-generate sysexits.h falling back to the template
This commit is contained in:
parent
6efd398425
commit
c7ed30bd6e
14
Makefile
14
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 $@ -
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user