diff --git a/.x-sc_require_config_h_first b/.x-sc_require_config_h_first new file mode 100644 index 0000000000..58a88789f9 --- /dev/null +++ b/.x-sc_require_config_h_first @@ -0,0 +1,2 @@ +^docs/examples/info1\.c$ +^docs/examples/suspend\.c$ diff --git a/ChangeLog b/ChangeLog index 323120d911..419fbba4ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Dec 17 18:10:51 +0100 2008 Jim Meyering + + enforce the "include first" rule + * qemud/Makefile.am: Ensure that the generated remote_protocol.c + includes first. + * Makefile.maint (sc_require_config_h_first): New rule, so that + "make syntax-check" enforces this. + * .x-sc_require_config_h_first: New file. + * Makefile.am (.x-sc_require_config_h_first): Add it. + * qemud/remote_protocol.x: Don't include here. + * qemud/remote_protocol.c: Regenerate. + Wed Dec 17 18:10:51 +0100 2008 Jim Meyering let gcc's -Wformat do its job; avoid "make syntax-check" failure diff --git a/Makefile.am b/Makefile.am index d40a151f50..758ad50ffc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,7 @@ EXTRA_DIST = \ libvirt.pc libvirt.pc.in \ $(man_MANS) autobuild.sh \ .x-sc_avoid_if_before_free \ + .x-sc_require_config_h_first \ .x-sc_prohibit_strcmp \ .x-sc_require_config_h \ autogen.sh diff --git a/Makefile.maint b/Makefile.maint index 687183ec81..bad330d3f1 100644 --- a/Makefile.maint +++ b/Makefile.maint @@ -135,6 +135,21 @@ sc_require_config_h: else :; \ fi +# You must include 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 ' > /dev/null \ + || { echo $$i; fail=1; }; \ + done; \ + test $$fail = 1 && \ + { echo '$(ME): the above files include some other header' \ + 'before ' 1>&2; exit 1; } || :; \ + else :; \ + fi + # To use this "command" macro, you must first define two shell variables: # h: the header, enclosed in <> or "" # re: a regular expression that matches IFF something provided by $h is used. diff --git a/qemud/Makefile.am b/qemud/Makefile.am index b8dae8890f..b050bfa683 100644 --- a/qemud/Makefile.am +++ b/qemud/Makefile.am @@ -33,11 +33,15 @@ EXTRA_DIST = \ if RPCGEN SUFFIXES = .x +# The subshell ensures that remote_protocol.c ends up +# including before "remote_protocol.h". .x.c: - rm -f $@ $@-t $@-t2 + rm -f $@ $@-t $@-t1 $@-t2 rpcgen -c -o $@-t $< + (echo '#include '; cat $@-t) > $@-t1 if GLIBC_RPCGEN - perl -w rpcgen_fix.pl $@-t > $@-t2 + perl -w rpcgen_fix.pl $@-t1 > $@-t2 + rm $@-t1 chmod 444 $@-t2 mv $@-t2 $@ endif diff --git a/qemud/remote_protocol.c b/qemud/remote_protocol.c index ec8e6537b5..cbd722de40 100644 --- a/qemud/remote_protocol.c +++ b/qemud/remote_protocol.c @@ -1,10 +1,10 @@ +#include /* * Please do not edit this file. * It was generated using rpcgen. */ #include "remote_protocol.h" -#include #include "internal.h" #include diff --git a/qemud/remote_protocol.h b/qemud/remote_protocol.h index bf107ae619..3b8e37135f 100644 --- a/qemud/remote_protocol.h +++ b/qemud/remote_protocol.h @@ -13,7 +13,6 @@ extern "C" { #endif -#include #include "internal.h" #include #define REMOTE_MESSAGE_MAX 262144 diff --git a/qemud/remote_protocol.x b/qemud/remote_protocol.x index 22327fdf69..2a6035be97 100644 --- a/qemud/remote_protocol.x +++ b/qemud/remote_protocol.x @@ -36,7 +36,6 @@ * 'REMOTE_'. This makes names quite long. */ -%#include %#include "internal.h" %#include