]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
enforce the "include <config.h> first" rule
authorJim Meyering <meyering@redhat.com>
Wed, 17 Dec 2008 17:23:21 +0000 (17:23 +0000)
committerJim Meyering <meyering@redhat.com>
Wed, 17 Dec 2008 17:23:21 +0000 (17:23 +0000)
* 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.

.x-sc_require_config_h_first [new file with mode: 0644]
ChangeLog
Makefile.am
Makefile.maint
qemud/Makefile.am
qemud/remote_protocol.c
qemud/remote_protocol.h
qemud/remote_protocol.x

diff --git a/.x-sc_require_config_h_first b/.x-sc_require_config_h_first
new file mode 100644 (file)
index 0000000..58a8878
--- /dev/null
@@ -0,0 +1,2 @@
+^docs/examples/info1\.c$
+^docs/examples/suspend\.c$
index 323120d911911c6abefeb62f27c8c778e6f8590c..419fbba4ad9715787807f26d5e7e9934fd6190b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index d40a151f501b798a42fc1e66a74f38b8e748e45b..758ad50ffc509988e0999aea3dec6f0fd66fb725 100644 (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
index 687183ec81b4a0df7e1312308f8ffd44e1ac1523..bad330d3f130226a1e54ec889b7ff371f25a1b04 100644 (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.
index b8dae8890fbf513b045b9fed282c39de004d5489..b050bfa6834105be19d7468103c90df0402324cc 100644 (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
index ec8e6537b51f162542539d8dc573eee2d0f1b7da..cbd722de40d3485f071dae62ef54c6e171bbdc7b 100644 (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>
 
index bf107ae619a77403e354af47ddbfb5e690fd5372..3b8e37135fd736f1758e4e0e1421ea85c5c510ba 100644 (file)
@@ -13,7 +13,6 @@
 extern "C" {
 #endif
 
-#include <config.h>
 #include "internal.h"
 #include <arpa/inet.h>
 #define REMOTE_MESSAGE_MAX 262144
index 22327fdf695b88f5d85f32dc921b39bc71e90e81..2a6035be97163b1926c21eae5a3e1c7ab70cbab0 100644 (file)
@@ -36,7 +36,6 @@
  * 'REMOTE_'.  This makes names quite long.
  */
 
-%#include <config.h>
 %#include "internal.h"
 %#include <arpa/inet.h>