[Libvir] Re: [PATCH] #include "config.h" needed

Jim Meyering jim at meyering.net
Fri Jan 4 08:25:27 UTC 2008

"Richard W.M. Jones" <rjones at redhat.com> wrote:
> Jim Meyering wrote:
>> I used to prefer "config.h", too, but after some discussion
>> many years ago, I switched, and now coreutils, gnulib, etc.
>> use <config.h> everywhere.
> Do you also prefer to defend with #ifdef HAVE_CONFIG_H / #endif around
> each one, or does it not matter?

I avoid #ifdef HAVE_CONFIG_H, since that #ifdef is useful only in a .c
file that might be compiled by a project with no config.h file.

> I'll take a look at adding a make distcheck rule later, thanks.

Here's what I use in coreutils/Makefile.maint:
[you can list the names of exceptions in the file, .x-sc_require_config_h]

# This is reported not to work with make-3.79.1
# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ME := Makefile.maint

CVS_LIST = build-aux/vc-list-files

  $(CVS_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi

# Nearly all .c files must include <config.h>.
	@if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then		\
	  grep -L '^# *include <config\.h>'				\
		$$($(CVS_LIST_EXCEPT) | grep '\.c$$')			\
	      | grep . &&						\
	  { echo '$(ME): the above files do not include <config.h>'	\
		1>&2; exit 1; } || :;					\
	else :;								\

More information about the libvir-list mailing list