From 5ae1b15b6e98d325f1b53f3a89d8df9327173e69 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 24 Mar 2011 22:39:56 +0000 Subject: [PATCH] Ensure that other packages defining PACKAGE_ macros don't hurt us, and protect others from our PACKAGE_ macros. This commit was SVN r24571. --- configure.ac | 5 +++- opal/include/opal_config_bottom.h | 21 ++++++++++++++++- opal/include/opal_config_top.h | 38 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 opal/include/opal_config_top.h diff --git a/configure.ac b/configure.ac index de7e64a28d..d74e0747e1 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ # University of Stuttgart. All rights reserved. # Copyright (c) 2004-2005 The Regents of the University of California. # All rights reserved. -# Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2006-2011 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved. # Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights # reserved. @@ -208,6 +208,9 @@ AH_TOP([/* -*- c -*- #ifndef OPAL_CONFIG_H #define OPAL_CONFIG_H + +#include "opal_config_top.h" + ]) AH_BOTTOM([ #include "opal_config_bottom.h" diff --git a/opal/include/opal_config_bottom.h b/opal/include/opal_config_bottom.h index ce4e502f45..e8263a997d 100644 --- a/opal/include/opal_config_bottom.h +++ b/opal/include/opal_config_bottom.h @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2009-2011 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -618,4 +618,23 @@ static inline uint16_t ntohs(uint16_t netvar) { return netvar; } #define restrict #endif +#else + +/* For a similar reason to what is listed in opal_config_top.h, we + want to protect others from the autoconf/automake-generated + PACKAGE_ macros in opal_config.h. We can't put these undef's + directly in opal_config.h because they'll be turned into #defines' + via autoconf. + + So put them here in case any only else includes OMPI/ORTE/OPAL's + config.h files. */ + +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef PACKAGE_URL +#undef HAVE_CONFIG_H + #endif /* OMPI_BUILDING */ diff --git a/opal/include/opal_config_top.h b/opal/include/opal_config_top.h new file mode 100644 index 0000000000..9b1837dbc0 --- /dev/null +++ b/opal/include/opal_config_top.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + * This file is included at the top of opal_config.h, and is + * therefore a) before all the #define's that were output from + * configure, and b) included in most/all files in Open MPI. + * + * Since this file is *only* ever included by opal_config.h, and + * opal_config.h already has #ifndef/#endif protection, there is no + * need to #ifndef/#endif protection here. + */ + +#ifndef OPAL_CONFIG_H +#error "opal_config_top.h should only be included from opal_config.h" +#endif + +/* The only purpose of this file is to undef the PACKAGE_ macros + that are put in by autoconf/automake projects. Specifically, if + you include a .h file from another project that defines these + macros (e.g., gmp.h) and then include OMPI/ORTE/OPAL's config.h, + you'll get a preprocessor conflict. So put these undef's here to + protect us from other package's PACKAGE_ macros. + + Note that we can't put them directly in opal_config.h (e.g., via + AH_TOP) because they will be turned into #define's by autoconf. */ + +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef PACKAGE_URL +#undef HAVE_CONFIG_H