From 120dcc6391f55d5e78934e4a497f4f1249d9c551 Mon Sep 17 00:00:00 2001 From: Zy Date: Sat, 5 Oct 2024 14:52:52 +0200 Subject: [PATCH] dev: add check_headers rule in the Makefile --- Makefile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Makefile b/Makefile index d2c6c26..bb19a37 100644 --- a/Makefile +++ b/Makefile @@ -343,3 +343,28 @@ endef #--------------------------------------------------------------------------------------- endif #--------------------------------------------------------------------------------------- + +# Added by Zy +# To check if the headers are protected and if they include everything they need. + +check_headers : + @ERROR=0; \ + for HEADER in $(wildcard **/*.h); \ + do \ + echo "check header $$HEADER..."; \ + > __tmp_check_header.c echo "#include \"$$HEADER\""; \ + >> __tmp_check_header.c echo "#include \"$$HEADER\""; \ + >> __tmp_check_header.c echo "int main(void) {}"; \ + $(CPP) -o __tmp_check_header.out __tmp_check_header.c; \ + if [ $$? -ne 0 ]; \ + then \ + ERROR=1; \ + echo " error \e[31m:(\e[0m"; \ + fi; \ + echo " good \e[32m:)\e[0m"; \ + 2> /dev/null rm -- "__tmp_check_header.out" "__tmp_check_header.c"; \ + done; \ + 2> /dev/null rm __tmp_check_header.out __tmp_check_header.c; \ + if [ $$ERROR -eq 0 ]; then true; else false; fi; + +.PHONY : check_headers