[pacman-dev] [PATCH] include config.h via Makefiles

Dan McGee dpmcgee at gmail.com
Wed Dec 21 18:10:42 EST 2011


On Wed, Dec 21, 2011 at 8:27 AM, Dave Reisner <d at falconindy.com> wrote:
> 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 <dreisner at 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.

Making all in src/util
make[2]: Entering directory `/home/dmcgee/projects/pacman/src/util'
gcc -std=gnu99 -DLOCALEDIR=\"/usr/share/locale\"
-DCONFFILE=\"/etc/pacman.conf\" -DROOTDIR=\"/\"
-DDBPATH=\"/var/lib/pacman/\" -DCACHEDIR=\"/var/cache/pacman/pkg/\"
-DHAVE_CONFIG_H -I. -I../..  -imacros ../../config.h  -pedantic
-D_GNU_SOURCE -g -O2 -fstack-protector-all -D_FORTIFY_SOURCE=2 -g
-Wall -Werror -MT testdb.o -MD -MP -MF .deps/testdb.Tpo -c -o testdb.o
testdb.c
testdb.c: In function ‘main’:
testdb.c:186:2: error: unknown type name ‘alpm_errno_t’
testdb.c:207:2: error: passing argument 3 of ‘alpm_initialize’ from
incompatible pointer type [-Werror]
/usr/include/alpm.h:1193:16: note: expected ‘enum _alpm_errno_t *’ but
argument is of type ‘int *’
cc1: all warnings being treated as errors
make[2]: *** [testdb.o] Error 1

You broke the build. :)


diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 57ba639..2110781 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -13,7 +13,7 @@ DEFS = -DLOCALEDIR=\"@localedir@\" \
        @DEFS@

 AM_CPPFLAGS = \
-       -imacros $(top_builddir)/config.h
+       -imacros $(top_builddir)/config.h \
        -I$(top_srcdir)/lib/libalpm

 AM_CFLAGS = -pedantic -D_GNU_SOURCE


-Dan


More information about the pacman-dev mailing list