Skip to content

Commit 5d6e8c1

Browse files
authored
bpo-43617: Check autoconf-archive package in configure.ac (GH-25016)
Signed-off-by: Christian Heimes <[email protected]>
1 parent 11b85ab commit 5d6e8c1

File tree

6 files changed

+225
-216
lines changed

6 files changed

+225
-216
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve configure.ac: Check for presence of autoconf-archive package and
2+
remove our copies of M4 macros.

aclocal.m4

+209-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,90 @@
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+
# ===============================================================================
16+
# https://www.gnu.org/software/autoconf-archive/ax_c_float_words_bigendian.html
17+
# ===============================================================================
18+
#
19+
# SYNOPSIS
20+
#
21+
# AX_C_FLOAT_WORDS_BIGENDIAN([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN])
22+
#
23+
# DESCRIPTION
24+
#
25+
# Checks the ordering of words within a multi-word float. This check is
26+
# necessary because on some systems (e.g. certain ARM systems), the float
27+
# word ordering can be different from the byte ordering. In a multi-word
28+
# float context, "big-endian" implies that the word containing the sign
29+
# bit is found in the memory location with the lowest address. This
30+
# implementation was inspired by the AC_C_BIGENDIAN macro in autoconf.
31+
#
32+
# The endianness is detected by first compiling C code that contains a
33+
# special double float value, then grepping the resulting object file for
34+
# certain strings of ASCII values. The double is specially crafted to have
35+
# a binary representation that corresponds with a simple string. In this
36+
# implementation, the string "noonsees" was selected because the
37+
# individual word values ("noon" and "sees") are palindromes, thus making
38+
# this test byte-order agnostic. If grep finds the string "noonsees" in
39+
# the object file, the target platform stores float words in big-endian
40+
# order. If grep finds "seesnoon", float words are in little-endian order.
41+
# If neither value is found, the user is instructed to specify the
42+
# ordering.
43+
#
44+
# LICENSE
45+
#
46+
# Copyright (c) 2008 Daniel Amelang <[email protected]>
47+
#
48+
# Copying and distribution of this file, with or without modification, are
49+
# permitted in any medium without royalty provided the copyright notice
50+
# and this notice are preserved. This file is offered as-is, without any
51+
# warranty.
52+
53+
#serial 11
54+
55+
AC_DEFUN([AX_C_FLOAT_WORDS_BIGENDIAN],
56+
[AC_CACHE_CHECK(whether float word ordering is bigendian,
57+
ax_cv_c_float_words_bigendian, [
58+
59+
ax_cv_c_float_words_bigendian=unknown
60+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
61+
62+
double d = 90904234967036810337470478905505011476211692735615632014797120844053488865816695273723469097858056257517020191247487429516932130503560650002327564517570778480236724525140520121371739201496540132640109977779420565776568942592.0;
63+
64+
]])], [
65+
66+
if grep noonsees conftest.$ac_objext >/dev/null ; then
67+
ax_cv_c_float_words_bigendian=yes
68+
fi
69+
if grep seesnoon conftest.$ac_objext >/dev/null ; then
70+
if test "$ax_cv_c_float_words_bigendian" = unknown; then
71+
ax_cv_c_float_words_bigendian=no
72+
else
73+
ax_cv_c_float_words_bigendian=unknown
74+
fi
75+
fi
76+
77+
])])
78+
79+
case $ax_cv_c_float_words_bigendian in
80+
yes)
81+
m4_default([$1],
82+
[AC_DEFINE([FLOAT_WORDS_BIGENDIAN], 1,
83+
[Define to 1 if your system stores words within floats
84+
with the most significant word first])]) ;;
85+
no)
86+
$2 ;;
87+
*)
88+
m4_default([$3],
89+
[AC_MSG_ERROR([
90+
91+
Unknown float word ordering. You need to manually preset
92+
ax_cv_c_float_words_bigendian=no (or yes) according to your system.
93+
94+
])]) ;;
95+
esac
96+
97+
])# AX_C_FLOAT_WORDS_BIGENDIAN
98+
1599
# ===========================================================================
16100
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
17101
# ===========================================================================
@@ -66,6 +150,131 @@ AS_VAR_IF(CACHEVAR,yes,
66150
AS_VAR_POPDEF([CACHEVAR])dnl
67151
])dnl AX_CHECK_COMPILE_FLAGS
68152

153+
# ===========================================================================
154+
# https://www.gnu.org/software/autoconf-archive/ax_check_openssl.html
155+
# ===========================================================================
156+
#
157+
# SYNOPSIS
158+
#
159+
# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]])
160+
#
161+
# DESCRIPTION
162+
#
163+
# Look for OpenSSL in a number of default spots, or in a user-selected
164+
# spot (via --with-openssl). Sets
165+
#
166+
# OPENSSL_INCLUDES to the include directives required
167+
# OPENSSL_LIBS to the -l directives required
168+
# OPENSSL_LDFLAGS to the -L or -R flags required
169+
#
170+
# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
171+
#
172+
# This macro sets OPENSSL_INCLUDES such that source files should use the
173+
# openssl/ directory in include directives:
174+
#
175+
# #include <openssl/hmac.h>
176+
#
177+
# LICENSE
178+
#
179+
# Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/>
180+
# Copyright (c) 2009,2010 Dustin J. Mitchell <[email protected]>
181+
#
182+
# Copying and distribution of this file, with or without modification, are
183+
# permitted in any medium without royalty provided the copyright notice
184+
# and this notice are preserved. This file is offered as-is, without any
185+
# warranty.
186+
187+
#serial 10
188+
189+
AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL])
190+
AC_DEFUN([AX_CHECK_OPENSSL], [
191+
found=false
192+
AC_ARG_WITH([openssl],
193+
[AS_HELP_STRING([--with-openssl=DIR],
194+
[root of the OpenSSL directory])],
195+
[
196+
case "$withval" in
197+
"" | y | ye | yes | n | no)
198+
AC_MSG_ERROR([Invalid --with-openssl value])
199+
;;
200+
*) ssldirs="$withval"
201+
;;
202+
esac
203+
], [
204+
# if pkg-config is installed and openssl has installed a .pc file,
205+
# then use that information and don't search ssldirs
206+
AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
207+
if test x"$PKG_CONFIG" != x""; then
208+
OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
209+
if test $? = 0; then
210+
OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
211+
OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
212+
found=true
213+
fi
214+
fi
215+
216+
# no such luck; use some default ssldirs
217+
if ! $found; then
218+
ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
219+
fi
220+
]
221+
)
222+
223+
224+
# note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
225+
# an 'openssl' subdirectory
226+
227+
if ! $found; then
228+
OPENSSL_INCLUDES=
229+
for ssldir in $ssldirs; do
230+
AC_MSG_CHECKING([for openssl/ssl.h in $ssldir])
231+
if test -f "$ssldir/include/openssl/ssl.h"; then
232+
OPENSSL_INCLUDES="-I$ssldir/include"
233+
OPENSSL_LDFLAGS="-L$ssldir/lib"
234+
OPENSSL_LIBS="-lssl -lcrypto"
235+
found=true
236+
AC_MSG_RESULT([yes])
237+
break
238+
else
239+
AC_MSG_RESULT([no])
240+
fi
241+
done
242+
243+
# if the file wasn't found, well, go ahead and try the link anyway -- maybe
244+
# it will just work!
245+
fi
246+
247+
# try the preprocessor and linker with our new flags,
248+
# being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
249+
250+
AC_MSG_CHECKING([whether compiling and linking against OpenSSL works])
251+
echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \
252+
"OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD
253+
254+
save_LIBS="$LIBS"
255+
save_LDFLAGS="$LDFLAGS"
256+
save_CPPFLAGS="$CPPFLAGS"
257+
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
258+
LIBS="$OPENSSL_LIBS $LIBS"
259+
CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
260+
AC_LINK_IFELSE(
261+
[AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])],
262+
[
263+
AC_MSG_RESULT([yes])
264+
$1
265+
], [
266+
AC_MSG_RESULT([no])
267+
$2
268+
])
269+
CPPFLAGS="$save_CPPFLAGS"
270+
LDFLAGS="$save_LDFLAGS"
271+
LIBS="$save_LIBS"
272+
273+
AC_SUBST([OPENSSL_INCLUDES])
274+
AC_SUBST([OPENSSL_LIBS])
275+
AC_SUBST([OPENSSL_LDFLAGS])
276+
])
277+
69278
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
70279
# serial 11 (pkg-config-0.29.1)
71280

@@ -410,5 +619,3 @@ AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
410619
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
411620
])dnl PKG_HAVE_DEFINE_WITH_MODULES
412621

413-
m4_include([m4/ax_c_float_words_bigendian.m4])
414-
m4_include([m4/ax_check_openssl.m4])

configure

+3-3
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ Optional Packages:
15941594
--with-ensurepip[=install|upgrade|no]
15951595
"install" or "upgrade" using bundled pip (default is
15961596
upgrade)
1597-
--with-openssl=DIR override root of the OpenSSL directory to DIR
1597+
--with-openssl=DIR root of the OpenSSL directory
15981598
--with-openssl-rpath=[DIR|auto|no]
15991599
Set runtime library directory (rpath) for OpenSSL
16001600
libraries, no (default): don't set rpath, auto:
@@ -14571,10 +14571,10 @@ _ACEOF
1457114571
if ac_fn_c_try_compile "$LINENO"; then :
1457214572

1457314573

14574-
if $GREP noonsees conftest.$ac_objext >/dev/null ; then
14574+
if grep noonsees conftest.$ac_objext >/dev/null ; then
1457514575
ax_cv_c_float_words_bigendian=yes
1457614576
fi
14577-
if $GREP seesnoon conftest.$ac_objext >/dev/null ; then
14577+
if grep seesnoon conftest.$ac_objext >/dev/null ; then
1457814578
if test "$ax_cv_c_float_words_bigendian" = unknown; then
1457914579
ax_cv_c_float_words_bigendian=no
1458014580
else

configure.ac

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
dnl ***********************************************
2-
dnl * Please run autoreconf to test your changes! *
3-
dnl ***********************************************
1+
dnl ***************************************************
2+
dnl * Please run autoreconf -if to test your changes! *
3+
dnl ***************************************************
4+
dnl
5+
dnl Python's configure script requires autoconf 2.69 and autoconf-archive.
6+
dnl
47

58
# Set VERSION so we only need to edit in one place (i.e., here)
69
m4_define(PYTHON_VERSION, 3.10)
@@ -9,7 +12,11 @@ AC_PREREQ([2.69])
912

1013
AC_INIT([python],[PYTHON_VERSION],[https://bugs.python.org/])
1114

12-
AC_CONFIG_MACRO_DIR(m4)
15+
m4_ifdef(
16+
[AX_C_FLOAT_WORDS_BIGENDIAN],
17+
[],
18+
[AC_MSG_ERROR([Please install autoconf-archive package and re-run autoreconf])]
19+
)
1320

1421
AC_SUBST(BASECPPFLAGS)
1522
if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then

m4/ax_c_float_words_bigendian.m4

-83
This file was deleted.

0 commit comments

Comments
 (0)