enforce the "include <config.h> first" rule

* qemud/Makefile.am: Ensure that the generated remote_protocol.c
includes <config.h> 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 <config.h> here.
* qemud/remote_protocol.c: Regenerate.
This commit is contained in:
Jim Meyering 2008-12-17 17:23:21 +00:00
parent e4c7e12300
commit 4cea12bb69
8 changed files with 37 additions and 5 deletions

View File

@ -0,0 +1,2 @@
^docs/examples/info1\.c$
^docs/examples/suspend\.c$

View File

@ -1,3 +1,15 @@
Wed Dec 17 18:10:51 +0100 2008 Jim Meyering <meyering@redhat.com>
enforce the "include <config.h> first" rule
* qemud/Makefile.am: Ensure that the generated remote_protocol.c
includes <config.h> 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 <config.h> here.
* qemud/remote_protocol.c: Regenerate.
Wed Dec 17 18:10:51 +0100 2008 Jim Meyering <meyering@redhat.com>
let gcc's -Wformat do its job; avoid "make syntax-check" failure

View File

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

View File

@ -135,6 +135,21 @@ sc_require_config_h:
else :; \
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:
# h: the header, enclosed in <> or ""
# re: a regular expression that matches IFF something provided by $h is used.

View File

@ -33,11 +33,15 @@ EXTRA_DIST = \
if RPCGEN
SUFFIXES = .x
# The subshell ensures that remote_protocol.c ends up
# including <config.h> before "remote_protocol.h".
.x.c:
rm -f $@ $@-t $@-t2
rm -f $@ $@-t $@-t1 $@-t2
rpcgen -c -o $@-t $<
(echo '#include <config.h>'; 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

View File

@ -1,10 +1,10 @@
#include <config.h>
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "remote_protocol.h"
#include <config.h>
#include "internal.h"
#include <arpa/inet.h>

View File

@ -13,7 +13,6 @@
extern "C" {
#endif
#include <config.h>
#include "internal.h"
#include <arpa/inet.h>
#define REMOTE_MESSAGE_MAX 262144

View File

@ -36,7 +36,6 @@
* 'REMOTE_'. This makes names quite long.
*/
%#include <config.h>
%#include "internal.h"
%#include <arpa/inet.h>