Skip to content

Commit b95f803

Browse files
committed
bpo-31374: Create expat_config.h with autoconf
Fixes warnings in expat module: "_POSIX_C_SOURCE" redefined Signed-off-by: Christian Heimes <christian@python.org>
1 parent 5d84cb3 commit b95f803

6 files changed

Lines changed: 134 additions & 40 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Modules/Setup.config
3535
Modules/Setup.local
3636
Modules/config.c
3737
Modules/ld_so_aix
38+
Modules/expat/expat_config.h
3839
Programs/_freeze_importlib
3940
Programs/_freeze_importlib.exe
4041
Programs/_testembed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Generate expat_config.h with autoconf. This fixes a build warning in Python's
2+
copy of expat library.
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
#ifndef EXPAT_CONFIG_H
66
#define EXPAT_CONFIG_H
77

8-
#include <pyconfig.h>
9-
#ifdef WORDS_BIGENDIAN
10-
#define BYTEORDER 4321
11-
#else
12-
#define BYTEORDER 1234
13-
#endif
8+
#define BYTEORDER @BYTEORDER@
9+
@DEFINE_HAVE_MEMMOVE@
1410

1511
#define XML_NS 1
1612
#define XML_DTD 1

aclocal.m4

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# PARTICULAR PURPOSE.
1313

1414
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
15-
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
16-
dnl serial 11 (pkg-config-0.29.1)
17-
dnl
15+
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
16+
# serial 11 (pkg-config-0.29.1)
17+
1818
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
1919
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
2020
dnl
@@ -170,7 +170,7 @@ if test $pkg_failed = yes; then
170170
_PKG_SHORT_ERRORS_SUPPORTED
171171
if test $_pkg_short_errors_supported = yes; then
172172
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
173-
else
173+
else
174174
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
175175
fi
176176
# Put the nasty error message in config.log where it belongs
@@ -288,3 +288,71 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
288288
AS_VAR_IF([$1], [""], [$5], [$4])dnl
289289
])dnl PKG_CHECK_VAR
290290

291+
dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
292+
dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
293+
dnl [DESCRIPTION], [DEFAULT])
294+
dnl ------------------------------------------
295+
dnl
296+
dnl Prepare a "--with-" configure option using the lowercase
297+
dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
298+
dnl PKG_CHECK_MODULES in a single macro.
299+
AC_DEFUN([PKG_WITH_MODULES],
300+
[
301+
m4_pushdef([with_arg], m4_tolower([$1]))
302+
303+
m4_pushdef([description],
304+
[m4_default([$5], [build with ]with_arg[ support])])
305+
306+
m4_pushdef([def_arg], [m4_default([$6], [auto])])
307+
m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
308+
m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
309+
310+
m4_case(def_arg,
311+
[yes],[m4_pushdef([with_without], [--without-]with_arg)],
312+
[m4_pushdef([with_without],[--with-]with_arg)])
313+
314+
AC_ARG_WITH(with_arg,
315+
AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
316+
[AS_TR_SH([with_]with_arg)=def_arg])
317+
318+
AS_CASE([$AS_TR_SH([with_]with_arg)],
319+
[yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
320+
[auto],[PKG_CHECK_MODULES([$1],[$2],
321+
[m4_n([def_action_if_found]) $3],
322+
[m4_n([def_action_if_not_found]) $4])])
323+
324+
m4_popdef([with_arg])
325+
m4_popdef([description])
326+
m4_popdef([def_arg])
327+
328+
])dnl PKG_WITH_MODULES
329+
330+
dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
331+
dnl [DESCRIPTION], [DEFAULT])
332+
dnl -----------------------------------------------
333+
dnl
334+
dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
335+
dnl check._[VARIABLE-PREFIX] is exported as make variable.
336+
AC_DEFUN([PKG_HAVE_WITH_MODULES],
337+
[
338+
PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
339+
340+
AM_CONDITIONAL([HAVE_][$1],
341+
[test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
342+
])dnl PKG_HAVE_WITH_MODULES
343+
344+
dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
345+
dnl [DESCRIPTION], [DEFAULT])
346+
dnl ------------------------------------------------------
347+
dnl
348+
dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
349+
dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
350+
dnl and preprocessor variable.
351+
AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
352+
[
353+
PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
354+
355+
AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
356+
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
357+
])dnl PKG_HAVE_DEFINE_WITH_MODULES
358+

configure

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ LIBPL
630630
PY_ENABLE_SHARED
631631
EXT_SUFFIX
632632
SOABI
633+
DEFINE_HAVE_MEMMOVE
634+
BYTEORDER
633635
LIBC
634636
LIBM
635637
HAVE_GETHOSTBYNAME
@@ -779,7 +781,6 @@ infodir
779781
docdir
780782
oldincludedir
781783
includedir
782-
runstatedir
783784
localstatedir
784785
sharedstatedir
785786
sysconfdir
@@ -891,7 +892,6 @@ datadir='${datarootdir}'
891892
sysconfdir='${prefix}/etc'
892893
sharedstatedir='${prefix}/com'
893894
localstatedir='${prefix}/var'
894-
runstatedir='${localstatedir}/run'
895895
includedir='${prefix}/include'
896896
oldincludedir='/usr/include'
897897
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1144,15 +1144,6 @@ do
11441144
| -silent | --silent | --silen | --sile | --sil)
11451145
silent=yes ;;
11461146

1147-
-runstatedir | --runstatedir | --runstatedi | --runstated \
1148-
| --runstate | --runstat | --runsta | --runst | --runs \
1149-
| --run | --ru | --r)
1150-
ac_prev=runstatedir ;;
1151-
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
1152-
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
1153-
| --run=* | --ru=* | --r=*)
1154-
runstatedir=$ac_optarg ;;
1155-
11561147
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
11571148
ac_prev=sbindir ;;
11581149
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1290,7 +1281,7 @@ fi
12901281
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
12911282
datadir sysconfdir sharedstatedir localstatedir includedir \
12921283
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
1293-
libdir localedir mandir runstatedir
1284+
libdir localedir mandir
12941285
do
12951286
eval ac_val=\$$ac_var
12961287
# Remove trailing slashes.
@@ -1443,7 +1434,6 @@ Fine tuning of the installation directories:
14431434
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
14441435
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
14451436
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
1446-
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
14471437
--libdir=DIR object code libraries [EPREFIX/lib]
14481438
--includedir=DIR C header files [PREFIX/include]
14491439
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -12253,19 +12243,6 @@ fi
1225312243
done
1225412244

1225512245

12256-
# Stuff for expat.
12257-
for ac_func in memmove
12258-
do :
12259-
ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove"
12260-
if test "x$ac_cv_func_memmove" = xyes; then :
12261-
cat >>confdefs.h <<_ACEOF
12262-
#define HAVE_MEMMOVE 1
12263-
_ACEOF
12264-
12265-
fi
12266-
done
12267-
12268-
1226912246
# check for long file support functions
1227012247
for ac_func in fseek64 fseeko fstatvfs ftell64 ftello statvfs
1227112248
do :
@@ -14860,6 +14837,37 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
1486014837
esac
1486114838

1486214839

14840+
# Stuff for expat.
14841+
case "$ac_cv_c_bigendian" in
14842+
yes)
14843+
BYTEORDER=4321
14844+
;;
14845+
no)
14846+
BYTEORDER=1234
14847+
;;
14848+
*)
14849+
as_fn_error $? "unknown endianness $ac_cv_c_bigendian" "$LINENO" 5
14850+
;;
14851+
esac
14852+
14853+
14854+
for ac_func in memmove
14855+
do :
14856+
ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove"
14857+
if test "x$ac_cv_func_memmove" = xyes; then :
14858+
cat >>confdefs.h <<_ACEOF
14859+
#define HAVE_MEMMOVE 1
14860+
_ACEOF
14861+
DEFINE_HAVE_MEMMOVE='#define HAVE_MEMMOVE 1'
14862+
else
14863+
DEFINE_HAVE_MEMMOVE='#undef HAVE_MEMMOVE'
14864+
fi
14865+
done
14866+
14867+
14868+
ac_config_files="$ac_config_files Modules/expat/expat_config.h"
14869+
14870+
1486314871
# ABI version string for Python extension modules. This appears between the
1486414872
# periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
1486514873
# from the following attributes which affect the ABI of this Python build (in
@@ -17198,6 +17206,7 @@ do
1719817206
"Mac/PythonLauncher/Makefile") CONFIG_FILES="$CONFIG_FILES Mac/PythonLauncher/Makefile" ;;
1719917207
"Mac/Resources/framework/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/framework/Info.plist" ;;
1720017208
"Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;;
17209+
"Modules/expat/expat_config.h") CONFIG_FILES="$CONFIG_FILES Modules/expat/expat_config.h" ;;
1720117210
"Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;;
1720217211
"Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;;
1720317212
"Misc/python-config.sh") CONFIG_FILES="$CONFIG_FILES Misc/python-config.sh" ;;

configure.ac

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3684,9 +3684,6 @@ AC_CHECK_FUNCS(forkpty,,
36843684
)
36853685
)
36863686

3687-
# Stuff for expat.
3688-
AC_CHECK_FUNCS(memmove)
3689-
36903687
# check for long file support functions
36913688
AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
36923689

@@ -4585,6 +4582,27 @@ AC_MSG_RESULT($HAVE_USABLE_WCHAR_T)
45854582
# check for endianness
45864583
AC_C_BIGENDIAN
45874584

4585+
# Stuff for expat.
4586+
case "$ac_cv_c_bigendian" in
4587+
yes)
4588+
BYTEORDER=4321
4589+
;;
4590+
no)
4591+
BYTEORDER=1234
4592+
;;
4593+
*)
4594+
AC_MSG_ERROR([unknown endianness $ac_cv_c_bigendian])
4595+
;;
4596+
esac
4597+
AC_SUBST([BYTEORDER])
4598+
4599+
AC_CHECK_FUNCS(memmove,
4600+
[DEFINE_HAVE_MEMMOVE='#define HAVE_MEMMOVE 1'],
4601+
[DEFINE_HAVE_MEMMOVE='#undef HAVE_MEMMOVE'],
4602+
)
4603+
AC_SUBST([DEFINE_HAVE_MEMMOVE])
4604+
AC_CONFIG_FILES([Modules/expat/expat_config.h])
4605+
45884606
# ABI version string for Python extension modules. This appears between the
45894607
# periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
45904608
# from the following attributes which affect the ABI of this Python build (in
@@ -5386,7 +5404,7 @@ if test "$have_getrandom" = yes; then
53865404
fi
53875405

53885406
# generate output files
5389-
AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-config.sh)
5407+
AC_CONFIG_FILES([Makefile.pre Misc/python.pc Misc/python-config.sh])
53905408
AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
53915409
AC_OUTPUT
53925410

0 commit comments

Comments
 (0)