From e96be1888ae8b82905d5b554df7cad496b369cf3 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 22 Mar 2010 16:42:18 -0700 Subject: [PATCH] Allow zfs_config.h to be included by dependant packages (updated) We need dependent packages to be able to include zfs_config.h to build properly. This was partially solved previously be using AH_BOTTOM to #undef common #defines (PACKAGE, VERSION, etc) which autoconf always adds and cannot be easily removed. This solution works as long as the zfs_config.h is included before your projects config.h. That turns out to be easier said than done. In particular, this is a problem when your package includes its config.h using the -include gcc option which ensures the first thing included is your config.h. To handle all cases cleanly I have removed the AH_BOTTOM hack and replaced it with an AC_CONFIG_HEADERS command. This command runs immediately after zfs_config.h is written and with a little awk-foo it strips the offending #defines from the file. This eliminates the problem entirely and makes header safe for inclusion. --- Makefile.am | 5 +++-- config/Rules.am | 2 +- config/config.awk | 15 +++++++++++++++ config/kernel.m4 | 8 +++----- configure.ac | 8 +++++--- zfs_unconfig.h | 12 ------------ 6 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 config/config.awk delete mode 100644 zfs_unconfig.h diff --git a/Makefile.am b/Makefile.am index c174e98d1c..d0a70b06cd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,10 +9,11 @@ endif SUBDIRS = $(USER_DIR) $(KERNEL_DIR) AUTOMAKE_OPTIONS = foreign dist-zip -EXTRA_DIST = autogen.sh zfs.spec.in zfs-modules.spec.in +EXTRA_DIST = autogen.sh config/config.awk +EXTRA_DIST += zfs.spec.in zfs-modules.spec.in EXTRA_DIST += META DISCLAIMER GIT EXTRA_DIST += OPENSOLARIS.LICENSE ZFS.RELEASE -noinst_HEADERS = zfs_config.h zfs_unconfig.h +noinst_HEADERS = zfs_config.h distclean-local:: -$(RM) -R autom4te*.cache diff --git a/config/Rules.am b/config/Rules.am index e36860ee68..115fa348f4 100644 --- a/config/Rules.am +++ b/config/Rules.am @@ -1,4 +1,4 @@ -DEFAULT_INCLUDES = -I${top_srcdir} +DEFAULT_INCLUDES = -include ${top_srcdir}/zfs_config.h # FIXME: Add -Wshadow once everything is working AM_CFLAGS = -Wall -Wstrict-prototypes -fno-strict-aliasing -Werror diff --git a/config/config.awk b/config/config.awk new file mode 100644 index 0000000000..cc4b7cc265 --- /dev/null +++ b/config/config.awk @@ -0,0 +1,15 @@ +# Remove default preprocessor define's from config.h +# PACKAGE +# PACKAGE_BUGREPORT +# PACKAGE_NAME +# PACKAGE_STRING +# PACKAGE_TARNAME +# PACKAGE_VERSION +# STDC_HEADERS +# VERSION + +BEGIN { RS = "" ; FS = "\n" } \ + !/.#define PACKAGE./ && \ + !/.#define VERSION./ && \ + !/.#define STDC_HEADERS./ \ + { print $0"\n" } diff --git a/config/kernel.m4 b/config/kernel.m4 index 95c5942540..952eb3f3e3 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -23,15 +23,13 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_RQ_IS_SYNC ZFS_AC_KERNEL_RQ_FOR_EACH_SEGMENT - dnl # Kernel build make options - dnl # KERNELMAKE_PARAMS="V=1" # Enable verbose module build - KERNELMAKE_PARAMS= - dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other dnl # compiler options are added by the kernel build system. KERNELCPPFLAGS="$KERNELCPPFLAGS -Werror -DHAVE_SPL -D_KERNEL" KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\"" - KERNELCPPFLAGS="$KERNELCPPFLAGS -I$TOPDIR -I$SPL -I$SPL/include" + KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL/include" + KERNELCPPFLAGS="$KERNELCPPFLAGS -include $SPL/spl_config.h" + KERNELCPPFLAGS="$KERNELCPPFLAGS -include $TOPDIR/zfs_config.h" if test "$LINUX_OBJ" != "$LINUX"; then KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" diff --git a/configure.ac b/configure.ac index f49b09b764..1ef7003f97 100644 --- a/configure.ac +++ b/configure.ac @@ -35,10 +35,12 @@ AC_LANG(C) ZFS_AC_META AC_CONFIG_AUX_DIR([config]) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE([$ZFS_META_NAME], [$ZFS_META_VERSION]) -AC_CONFIG_HEADERS([zfs_config.h]) -AH_BOTTOM([#include ]) AM_MAINTAINER_MODE +AM_INIT_AUTOMAKE([$ZFS_META_NAME], [$ZFS_META_VERSION]) +AC_CONFIG_HEADERS([zfs_config.h], [ + (mv zfs_config.h zfs_config.h.tmp && + awk -f config/config.awk zfs_config.h.tmp >zfs_config.h && + rm zfs_config.h.tmp) || exit 1]) AC_PROG_INSTALL AC_PROG_CC diff --git a/zfs_unconfig.h b/zfs_unconfig.h deleted file mode 100644 index eee3b87adc..0000000000 --- a/zfs_unconfig.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Undefine these symbols to allow other autoheader enabled packages - * to leverage the ZFS configure checks without a header conflict. - */ -#undef PACKAGE -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION -#undef VERSION -#undef STDC_HEADERS