Ensures that config.h is always ordered correctly (first) in the includes. Also means that new source files get this for free without having to remember to add it.
We opt for -imacros over -include as its more portable, and the added constraint by -imacros doesn't bother us for config.h. Signed-off-by: Dave Reisner <dreis...@archlinux.org> --- Note that when I say "portable", I mean gcc, clang, and icc all support the option. I think that covers most of our bases. lib/libalpm/Makefile.am | 3 +++ lib/libalpm/add.c | 2 -- lib/libalpm/alpm.c | 2 -- lib/libalpm/backup.c | 2 -- lib/libalpm/be_local.c | 2 -- lib/libalpm/be_package.c | 2 -- lib/libalpm/be_sync.c | 2 -- lib/libalpm/conflict.c | 2 -- lib/libalpm/db.c | 2 -- lib/libalpm/delta.c | 2 -- lib/libalpm/delta.h | 2 -- lib/libalpm/deps.c | 2 -- lib/libalpm/diskspace.c | 2 -- lib/libalpm/dload.c | 2 -- lib/libalpm/error.c | 2 -- lib/libalpm/graph.c | 2 -- lib/libalpm/graph.h | 2 -- lib/libalpm/group.c | 2 -- lib/libalpm/handle.c | 2 -- lib/libalpm/log.c | 2 -- lib/libalpm/package.c | 2 -- lib/libalpm/package.h | 2 -- lib/libalpm/remove.c | 2 -- lib/libalpm/signing.c | 2 -- lib/libalpm/sync.c | 2 -- lib/libalpm/trans.c | 2 -- lib/libalpm/util.c | 2 -- lib/libalpm/util.h | 2 -- lib/libalpm/version.c | 2 -- src/pacman/Makefile.am | 5 ++++- src/pacman/callback.c | 2 -- src/pacman/conf.c | 2 -- src/pacman/database.c | 2 -- src/pacman/deptest.c | 2 -- src/pacman/package.c | 2 -- src/pacman/pacman.c | 2 -- src/pacman/query.c | 2 -- src/pacman/remove.c | 2 -- src/pacman/sync.c | 2 -- src/pacman/upgrade.c | 2 -- src/pacman/util.c | 2 -- src/util/Makefile.am | 5 ++++- src/util/cleanupdelta.c | 2 -- src/util/pacsort.c | 2 -- src/util/pactree.c | 2 -- src/util/testdb.c | 2 -- 46 files changed, 11 insertions(+), 88 deletions(-) diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 99f9c1b..61dcb87 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -7,6 +7,9 @@ include_HEADERS = alpm_list.h alpm.h DEFS = -DLOCALEDIR=\"@localedir@\" @DEFS@ +AM_CPPFLAGS = \ + -imacros $(top_builddir)/config.h + AM_CFLAGS = -pedantic -D_GNU_SOURCE if ENABLE_VISIBILITY_CC diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 78615bb..014990d 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <errno.h> #include <string.h> diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index e957f1a..3f7ab4b 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -21,8 +21,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #ifdef HAVE_LIBCURL #include <curl/curl.h> #endif diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c index 728c1d0..68856de 100644 --- a/lib/libalpm/backup.c +++ b/lib/libalpm/backup.c @@ -21,8 +21,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <string.h> diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 606f9e1..2deef22 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <unistd.h> #include <stdio.h> #include <stdlib.h> diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 4f530e0..41ecc75 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <string.h> #include <errno.h> diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 54c4f87..abc4a99 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <errno.h> #include <sys/types.h> #include <sys/stat.h> diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 5703aba..b5c55dc 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -22,8 +22,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 7708d18..3e53435 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -22,8 +22,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index 6315a85..5346716 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <string.h> #include <stdint.h> /* intmax_t */ diff --git a/lib/libalpm/delta.h b/lib/libalpm/delta.h index 05df420..42353f5 100644 --- a/lib/libalpm/delta.h +++ b/lib/libalpm/delta.h @@ -20,8 +20,6 @@ #ifndef _ALPM_DELTA_H #define _ALPM_DELTA_H -#include "config.h" /* ensure off_t is correct length */ - #include <sys/types.h> /* off_t */ #include "alpm.h" diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 9f7e902..9d7e547 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -20,8 +20,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index cfd6402..274aa67 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <errno.h> #if defined(HAVE_MNTENT_H) #include <mntent.h> diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index bcbc809..a3980d6 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <errno.h> diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c index 044dec7..528a3dc 100644 --- a/lib/libalpm/error.c +++ b/lib/libalpm/error.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #ifdef HAVE_LIBCURL #include <curl/curl.h> #endif diff --git a/lib/libalpm/graph.c b/lib/libalpm/graph.c index 3a7f24b..d080e05 100644 --- a/lib/libalpm/graph.c +++ b/lib/libalpm/graph.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include "graph.h" #include "util.h" #include "log.h" diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h index d4d134b..2910b7d 100644 --- a/lib/libalpm/graph.h +++ b/lib/libalpm/graph.h @@ -19,8 +19,6 @@ #ifndef _ALPM_GRAPH_H #define _ALPM_GRAPH_H -#include "config.h" /* ensure off_t is correct length */ - #include <sys/types.h> /* off_t */ #include "alpm_list.h" diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c index 47458df..8b407b2 100644 --- a/lib/libalpm/group.c +++ b/lib/libalpm/group.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <string.h> diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 01f5955..6518b7d 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -20,8 +20,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <errno.h> #include <stdlib.h> #include <string.h> diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c index 692ff79..14b454e 100644 --- a/lib/libalpm/log.c +++ b/lib/libalpm/log.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdio.h> #include <stdarg.h> #include <errno.h> diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index e96177a..68fec16 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -21,8 +21,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <string.h> #include <sys/types.h> diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 82a8326..172d2f3 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -24,8 +24,6 @@ #ifndef _ALPM_PACKAGE_H #define _ALPM_PACKAGE_H -#include "config.h" /* ensure off_t is correct length */ - #include <sys/types.h> /* off_t */ #include "alpm.h" diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index d7e06bc..8967eff 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -22,8 +22,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <errno.h> #include <string.h> diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index 0bef445..fbb6b13 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 3817ec8..b10f3e8 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -21,8 +21,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <sys/types.h> /* off_t */ #include <stdlib.h> #include <stdio.h> diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index cb97a4a..5ceaaa7 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -21,8 +21,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 4eeb0cd..b2974a4 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -22,8 +22,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <unistd.h> #include <ctype.h> diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 1e19274..54e69c1 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -24,8 +24,6 @@ #ifndef _ALPM_UTIL_H #define _ALPM_UTIL_H -#include "config.h" - #include "alpm_list.h" #include "alpm.h" #include "package.h" /* alpm_pkg_t */ diff --git a/lib/libalpm/version.c b/lib/libalpm/version.c index 6b65a41..a88b818 100644 --- a/lib/libalpm/version.c +++ b/lib/libalpm/version.c @@ -15,8 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <string.h> #include <ctype.h> diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am index 3790bdf..795b2d1 100644 --- a/src/pacman/Makefile.am +++ b/src/pacman/Makefile.am @@ -17,7 +17,10 @@ DEFS = -DLOCALEDIR=\"@localedir@\" \ -DCACHEDIR=\"$(cachedir)\" \ -DLOGFILE=\"$(logfile)\" \ @DEFS@ -INCLUDES = -I$(top_srcdir)/lib/libalpm + +AM_CPPFLAGS = \ + -imacros $(top_builddir)/config.h \ + -I$(top_srcdir)/lib/libalpm AM_CFLAGS = -pedantic -D_GNU_SOURCE diff --git a/src/pacman/callback.c b/src/pacman/callback.c index c118940..87ba30a 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 482a86d..6703243 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <errno.h> #include <glob.h> #include <limits.h> diff --git a/src/pacman/database.c b/src/pacman/database.c index 3e4a672..b973661 100644 --- a/src/pacman/database.c +++ b/src/pacman/database.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdio.h> #include <alpm.h> diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c index 0bf9cd8..63e7985 100644 --- a/src/pacman/deptest.c +++ b/src/pacman/deptest.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdio.h> #include <alpm.h> diff --git a/src/pacman/package.c b/src/pacman/package.c index d4bbf88..233e8e2 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index d2fa62f..3e17d90 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - /* special handling of package version for GIT */ #if defined(GIT_VERSION) #undef PACKAGE_VERSION diff --git a/src/pacman/query.c b/src/pacman/query.c index 4c2ea81..66813e3 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <stdint.h> diff --git a/src/pacman/remove.c b/src/pacman/remove.c index b6da7c3..3de5769 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <fnmatch.h> #include <stdlib.h> #include <stdio.h> diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 9015b08..a13b6c7 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 650af6b..87f7c39 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/src/pacman/util.c b/src/pacman/util.c index 12f3dca..7846291 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <sys/types.h> #include <sys/ioctl.h> #include <sys/stat.h> diff --git a/src/util/Makefile.am b/src/util/Makefile.am index e4af56c..57ba639 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -11,7 +11,10 @@ DEFS = -DLOCALEDIR=\"@localedir@\" \ -DDBPATH=\"$(dbpath)\" \ -DCACHEDIR=\"$(cachedir)\" \ @DEFS@ -INCLUDES = -I$(top_srcdir)/lib/libalpm + +AM_CPPFLAGS = \ + -imacros $(top_builddir)/config.h + -I$(top_srcdir)/lib/libalpm AM_CFLAGS = -pedantic -D_GNU_SOURCE diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c index d6bd0e8..ea34fe7 100644 --- a/src/util/cleanupdelta.c +++ b/src/util/cleanupdelta.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/util/pacsort.c b/src/util/pacsort.c index 0eedf59..7275cc7 100644 --- a/src/util/pacsort.c +++ b/src/util/pacsort.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <errno.h> #include <getopt.h> #include <stdio.h> diff --git a/src/util/pactree.c b/src/util/pactree.c index f95c5e8..55d63d7 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <ctype.h> #include <getopt.h> #include <stdio.h> diff --git a/src/util/testdb.c b/src/util/testdb.c index b15bbe5..4f6bfed 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -17,8 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - #include <unistd.h> #include <stdio.h> #include <stdlib.h> -- 1.7.8