dev: add check_headers rule in the Makefile

This commit is contained in:
Zy 2024-10-05 14:52:52 +02:00
parent 65c31c3899
commit 120dcc6391

View file

@ -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