[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



"Richard W.M. Jones" <rjones 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_EXCEPT = \
  $(CVS_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi

# Nearly all .c files must include <config.h>.
sc_require_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 :;								\
	fi


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]