Skip to content

Commit

Permalink
maint.mk: enforce the "include <config.h> first" rule
Browse files Browse the repository at this point in the history
* maint.mk (sc_require_config_h_first): New rule.
* .x-sc_require_config_h_first: New file.
  • Loading branch information
Jim Meyering committed Dec 21, 2008
1 parent 292d685 commit 317d2c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .x-sc_require_config_h_first
@@ -0,0 +1,9 @@
^lib/buffer-lcm\.c$
^src/false\.c$
^src/lbracket\.c$
^src/ls-dir\.c$
^src/ls-ls\.c$
^src/ls-vdir\.c$
^src/tac-pipe\.c$
^src/uname-arch\.c$
^src/uname-uname\.c$
15 changes: 15 additions & 0 deletions maint.mk
Expand Up @@ -191,6 +191,21 @@ sc_require_config_h:
else :; \ else :; \
fi fi


# You must include <config.h> before including any other header file.
sc_require_config_h_first:
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
fail=0; \
for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do \
grep '^# *include\>' $$i | sed 1q \
| grep '^# *include <config\.h>' > /dev/null \
|| { echo $$i; fail=1; }; \
done; \
test $$fail = 1 && \
{ echo '$(ME): the above files include some other header' \
'before <config.h>' 1>&2; exit 1; } || :; \
else :; \
fi

# To use this "command" macro, you must first define two shell variables: # To use this "command" macro, you must first define two shell variables:
# h: the header, enclosed in <> or "" # h: the header, enclosed in <> or ""
# re: a regular expression that matches IFF something provided by $h is used. # re: a regular expression that matches IFF something provided by $h is used.
Expand Down

0 comments on commit 317d2c6

Please sign in to comment.