Index: bfd/configure.in =================================================================== RCS file: /cvs/src/src/bfd/configure.in,v --- bfd/configure.in 3 May 2012 13:11:54 -0000 1.313 +++ bfd/configure.in 7 May 2012 16:42:05 -0000 @@ -117,6 +117,14 @@ AC_CONFIG_HEADERS(config.h:config.in) +AH_VERBATIM([00_CONFIG_H_CHECK], +[/* Check that config.h is #included before system headers + * (this works only for glibc, but that should be enough) + */ +#if defined(__GLIBC__) +# error config.h must be #included before system headers +#endif]) + if test -z "$target" ; then AC_MSG_ERROR(Unrecognized target system type; please check config.sub.) fi Index: bfd/bfd-in.h =================================================================== RCS file: /cvs/src/src/bfd/bfd-in.h,v --- bfd/bfd-in.h 24 Apr 2012 05:12:29 -0000 1.162 +++ bfd/bfd-in.h 7 May 2012 16:42:05 -0000 @@ -25,6 +25,10 @@ #ifndef __BFD_H_SEEN__ #define __BFD_H_SEEN__ +#ifndef PACKAGE +#error config.h must be included before this header +#endif + #ifdef __cplusplus extern "C" { #endif Index: bfd/sysdep.h =================================================================== RCS file: /cvs/src/src/bfd/sysdep.h,v --- bfd/sysdep.h 2 Sep 2009 07:18:37 -0000 1.21 +++ bfd/sysdep.h 7 May 2012 16:42:05 -0000 @@ -23,6 +23,10 @@ #ifndef BFD_SYSDEP_H #define BFD_SYSDEP_H +#ifdef PACKAGE +#error sysdep.h must be included in lieu of config.h +#endif + #include "config.h" #include "ansidecl.h" Index: binutils/configure.in =================================================================== RCS file: /cvs/src/src/binutils/configure.in,v --- binutils/configure.in 2 May 2012 14:51:05 -0000 1.109 +++ binutils/configure.in 7 May 2012 16:42:05 -0000 @@ -44,6 +44,14 @@ AC_CONFIG_HEADERS(config.h:config.in) +AH_VERBATIM([00_CONFIG_H_CHECK], +[/* Check that config.h is #included before system headers + * (this works only for glibc, but that should be enough) + */ +#if defined(__GLIBC__) +# error config.h must be #included before system headers +#endif]) + if test -z "$target" ; then AC_MSG_ERROR(Unrecognized target system type; please check config.sub.) fi Index: gas/configure.in =================================================================== RCS file: /cvs/src/src/gas/configure.in,v --- gas/configure.in 6 Apr 2012 16:48:57 -0000 1.228 +++ gas/configure.in 7 May 2012 16:42:05 -0000 @@ -58,6 +58,14 @@ # Generate a header file AC_CONFIG_HEADERS(config.h:config.in) +AH_VERBATIM([00_CONFIG_H_CHECK], +[/* Check that config.h is #included before system headers + * (this works only for glibc, but that should be enough) + */ +#if defined(__GLIBC__) +# error config.h must be #included before system headers +#endif]) + # If we are on a DOS filesystem, we must use gdb.ini rather than # .gdbinit. case "${host}" in Index: ld/configure.in =================================================================== RCS file: /cvs/src/src/ld/configure.in,v --- ld/configure.in 6 Apr 2012 16:49:02 -0000 1.74 +++ ld/configure.in 7 May 2012 16:42:06 -0000 @@ -124,6 +124,14 @@ AC_CONFIG_HEADERS([config.h:config.in]) +AH_VERBATIM([00_CONFIG_H_CHECK], +[/* Check that config.h is #included before system headers + * (this works only for glibc, but that should be enough) + */ +#if defined(__GLIBC__) +# error config.h must be #included before system headers +#endif]) + if test -z "$target" ; then AC_MSG_ERROR(Unrecognized target system type; please check config.sub.) fi Index: ld/sysdep.h =================================================================== RCS file: /cvs/src/src/ld/sysdep.h,v --- ld/sysdep.h 15 Oct 2010 16:21:41 -0000 1.10 +++ ld/sysdep.h 7 May 2012 16:42:06 -0000 @@ -22,6 +22,10 @@ #ifndef LD_SYSDEP_H #define LD_SYSDEP_H +#ifdef PACKAGE +#error sysdep.h must be included in lieu of config.h +#endif + #include "config.h" #include Index: opcodes/configure.in =================================================================== RCS file: /cvs/src/src/opcodes/configure.in,v --- opcodes/configure.in 3 May 2012 13:12:05 -0000 1.103 +++ opcodes/configure.in 7 May 2012 16:42:06 -0000 @@ -45,6 +45,14 @@ AC_CONFIG_HEADERS(config.h:config.in) +AH_VERBATIM([00_CONFIG_H_CHECK], +[/* Check that config.h is #included before system headers + * (this works only for glibc, but that should be enough) + */ +#if defined(__GLIBC__) +# error config.h must be #included before system headers +#endif]) + if test -z "$target" ; then AC_MSG_ERROR(Unrecognized target system type; please check config.sub.) fi Index: opcodes/sysdep.h =================================================================== RCS file: /cvs/src/src/opcodes/sysdep.h,v --- opcodes/sysdep.h 2 Sep 2009 07:20:30 -0000 1.8 +++ opcodes/sysdep.h 7 May 2012 16:42:06 -0000 @@ -27,6 +27,10 @@ trying to replace often did that. If it can be dropped from this file (check in a non-ANSI environment!), it should be. */ +#ifdef PACKAGE +#error sysdep.h must be included in lieu of config.h +#endif + #include "config.h" #include "ansidecl.h" Index: gold/configure.ac =================================================================== RCS file: /cvs/src/src/gold/configure.ac,v --- gold/configure.ac 6 Apr 2012 16:48:58 -0000 1.72 +++ gold/configure.ac 7 May 2012 16:42:06 -0000 @@ -11,6 +11,14 @@ AM_CONFIG_HEADER(config.h:config.in) +AH_VERBATIM([00_CONFIG_H_CHECK], +[/* Check that config.h is #included before system headers + * (this works only for glibc, but that should be enough) + */ +#if defined(__GLIBC__) +# error config.h must be #included before system headers +#endif]) + AC_ARG_WITH(sysroot, [ --with-sysroot[=DIR] search for usr/lib et al within DIR], [sysroot=$withval], [sysroot=no]) Index: libiberty/configure.ac =================================================================== RCS file: /cvs/src/src/libiberty/configure.ac,v --- libiberty/configure.ac 22 Aug 2011 17:16:25 -0000 1.60 +++ libiberty/configure.ac 7 May 2012 16:42:06 -0000 @@ -163,6 +163,14 @@ dnl AM_CONFIG_HEADER(config.h:config.in) AC_CONFIG_HEADER(config.h:config.in) +AH_VERBATIM([00_CONFIG_H_CHECK], +[/* Check that config.h is #included before system headers + * (this works only for glibc, but that should be enough) + */ +#if defined(__GLIBC__) +# error config.h must be #included before system headers +#endif]) + dnl When we start using automake: dnl AM_MAINTAINER_MODE dnl AC_EXEEXT