From b95f8039be94740cf3eec14901ed3b88be8a2709 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 14 Sep 2017 11:34:23 +0200 Subject: [PATCH] bpo-31374: Create expat_config.h with autoconf Fixes warnings in expat module: "_POSIX_C_SOURCE" redefined Signed-off-by: Christian Heimes --- .gitignore | 1 + .../2017-09-14-11-34-13.bpo-31374.VFnngi.rst | 2 + .../{expat_config.h => expat_config.h.in} | 8 +- aclocal.m4 | 76 ++++++++++++++++++- configure | 61 ++++++++------- configure.ac | 26 ++++++- 6 files changed, 134 insertions(+), 40 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2017-09-14-11-34-13.bpo-31374.VFnngi.rst rename Modules/expat/{expat_config.h => expat_config.h.in} (69%) diff --git a/.gitignore b/.gitignore index 59206541ee41a76..93b115d0fe77a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ Modules/Setup.config Modules/Setup.local Modules/config.c Modules/ld_so_aix +Modules/expat/expat_config.h Programs/_freeze_importlib Programs/_freeze_importlib.exe Programs/_testembed diff --git a/Misc/NEWS.d/next/Build/2017-09-14-11-34-13.bpo-31374.VFnngi.rst b/Misc/NEWS.d/next/Build/2017-09-14-11-34-13.bpo-31374.VFnngi.rst new file mode 100644 index 000000000000000..82a78bb7dc69d68 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2017-09-14-11-34-13.bpo-31374.VFnngi.rst @@ -0,0 +1,2 @@ +Generate expat_config.h with autoconf. This fixes a build warning in Python's +copy of expat library. diff --git a/Modules/expat/expat_config.h b/Modules/expat/expat_config.h.in similarity index 69% rename from Modules/expat/expat_config.h rename to Modules/expat/expat_config.h.in index b8c1639b9769ab0..8a0555e3b28bd9b 100644 --- a/Modules/expat/expat_config.h +++ b/Modules/expat/expat_config.h.in @@ -5,12 +5,8 @@ #ifndef EXPAT_CONFIG_H #define EXPAT_CONFIG_H -#include -#ifdef WORDS_BIGENDIAN -#define BYTEORDER 4321 -#else -#define BYTEORDER 1234 -#endif +#define BYTEORDER @BYTEORDER@ +@DEFINE_HAVE_MEMMOVE@ #define XML_NS 1 #define XML_DTD 1 diff --git a/aclocal.m4 b/aclocal.m4 index 4eb2dc3bbe26bda..5fadcb1e44575ea 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -12,9 +12,9 @@ # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) -dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -dnl serial 11 (pkg-config-0.29.1) -dnl +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 11 (pkg-config-0.29.1) + dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl @@ -170,7 +170,7 @@ if test $pkg_failed = yes; then _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` - else + else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs @@ -288,3 +288,71 @@ AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR +dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], +dnl [DESCRIPTION], [DEFAULT]) +dnl ------------------------------------------ +dnl +dnl Prepare a "--with-" configure option using the lowercase +dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and +dnl PKG_CHECK_MODULES in a single macro. +AC_DEFUN([PKG_WITH_MODULES], +[ +m4_pushdef([with_arg], m4_tolower([$1])) + +m4_pushdef([description], + [m4_default([$5], [build with ]with_arg[ support])]) + +m4_pushdef([def_arg], [m4_default([$6], [auto])]) +m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) +m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) + +m4_case(def_arg, + [yes],[m4_pushdef([with_without], [--without-]with_arg)], + [m4_pushdef([with_without],[--with-]with_arg)]) + +AC_ARG_WITH(with_arg, + AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, + [AS_TR_SH([with_]with_arg)=def_arg]) + +AS_CASE([$AS_TR_SH([with_]with_arg)], + [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], + [auto],[PKG_CHECK_MODULES([$1],[$2], + [m4_n([def_action_if_found]) $3], + [m4_n([def_action_if_not_found]) $4])]) + +m4_popdef([with_arg]) +m4_popdef([description]) +m4_popdef([def_arg]) + +])dnl PKG_WITH_MODULES + +dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [DESCRIPTION], [DEFAULT]) +dnl ----------------------------------------------- +dnl +dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES +dnl check._[VARIABLE-PREFIX] is exported as make variable. +AC_DEFUN([PKG_HAVE_WITH_MODULES], +[ +PKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) + +AM_CONDITIONAL([HAVE_][$1], + [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) +])dnl PKG_HAVE_WITH_MODULES + +dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [DESCRIPTION], [DEFAULT]) +dnl ------------------------------------------------------ +dnl +dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after +dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make +dnl and preprocessor variable. +AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], +[ +PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) + +AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], + [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) +])dnl PKG_HAVE_DEFINE_WITH_MODULES + diff --git a/configure b/configure index 00dd1f0514a69cb..15638336b179ce5 100755 --- a/configure +++ b/configure @@ -630,6 +630,8 @@ LIBPL PY_ENABLE_SHARED EXT_SUFFIX SOABI +DEFINE_HAVE_MEMMOVE +BYTEORDER LIBC LIBM HAVE_GETHOSTBYNAME @@ -779,7 +781,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -891,7 +892,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1144,15 +1144,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1290,7 +1281,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1443,7 +1434,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -12253,19 +12243,6 @@ fi done -# Stuff for expat. -for ac_func in memmove -do : - ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove" -if test "x$ac_cv_func_memmove" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MEMMOVE 1 -_ACEOF - -fi -done - - # check for long file support functions for ac_func in fseek64 fseeko fstatvfs ftell64 ftello statvfs do : @@ -14860,6 +14837,37 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h esac +# Stuff for expat. +case "$ac_cv_c_bigendian" in + yes) + BYTEORDER=4321 + ;; + no) + BYTEORDER=1234 + ;; + *) + as_fn_error $? "unknown endianness $ac_cv_c_bigendian" "$LINENO" 5 + ;; +esac + + +for ac_func in memmove +do : + ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove" +if test "x$ac_cv_func_memmove" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MEMMOVE 1 +_ACEOF + DEFINE_HAVE_MEMMOVE='#define HAVE_MEMMOVE 1' +else + DEFINE_HAVE_MEMMOVE='#undef HAVE_MEMMOVE' +fi +done + + +ac_config_files="$ac_config_files Modules/expat/expat_config.h" + + # ABI version string for Python extension modules. This appears between the # periods in shared library file names, e.g. foo..so. It is calculated # from the following attributes which affect the ABI of this Python build (in @@ -17198,6 +17206,7 @@ do "Mac/PythonLauncher/Makefile") CONFIG_FILES="$CONFIG_FILES Mac/PythonLauncher/Makefile" ;; "Mac/Resources/framework/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/framework/Info.plist" ;; "Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;; + "Modules/expat/expat_config.h") CONFIG_FILES="$CONFIG_FILES Modules/expat/expat_config.h" ;; "Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;; "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;; "Misc/python-config.sh") CONFIG_FILES="$CONFIG_FILES Misc/python-config.sh" ;; diff --git a/configure.ac b/configure.ac index 88ab6a121571c41..cf483a16dd7e2cd 100644 --- a/configure.ac +++ b/configure.ac @@ -3684,9 +3684,6 @@ AC_CHECK_FUNCS(forkpty,, ) ) -# Stuff for expat. -AC_CHECK_FUNCS(memmove) - # check for long file support functions AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs) @@ -4585,6 +4582,27 @@ AC_MSG_RESULT($HAVE_USABLE_WCHAR_T) # check for endianness AC_C_BIGENDIAN +# Stuff for expat. +case "$ac_cv_c_bigendian" in + yes) + BYTEORDER=4321 + ;; + no) + BYTEORDER=1234 + ;; + *) + AC_MSG_ERROR([unknown endianness $ac_cv_c_bigendian]) + ;; +esac +AC_SUBST([BYTEORDER]) + +AC_CHECK_FUNCS(memmove, + [DEFINE_HAVE_MEMMOVE='#define HAVE_MEMMOVE 1'], + [DEFINE_HAVE_MEMMOVE='#undef HAVE_MEMMOVE'], +) +AC_SUBST([DEFINE_HAVE_MEMMOVE]) +AC_CONFIG_FILES([Modules/expat/expat_config.h]) + # ABI version string for Python extension modules. This appears between the # periods in shared library file names, e.g. foo..so. It is calculated # from the following attributes which affect the ABI of this Python build (in @@ -5386,7 +5404,7 @@ if test "$have_getrandom" = yes; then fi # generate output files -AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-config.sh) +AC_CONFIG_FILES([Makefile.pre Misc/python.pc Misc/python-config.sh]) AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) AC_OUTPUT