1From 3ed9d35554631a1e0c438636b60b6b9b699cba4b Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3Date: Wed, 22 Feb 2017 17:40:45 -0800
4Subject: [PATCH] Add an option to disable expat
5
6This patch replaces the existing --with-system-expat option with a
7--with-expat={system,builtin,none} option, which allows to tell Python
8whether we want to use the system expat (already installed), the expat
9builtin the Python sources, or no expat at all (which disables the
10installation of XML modules).
11
12Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
13Signed-off-by: Samuel Martin <s.martin49@gmail.com>
14[ Andrey Smirnov: ported to Python 3.6 ]
15Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
16[ Adam Duskett: ported to Python 3.10.0 ]
17Signed-off-by: Adam Duskett <aduskett@gmail.com>
18---
19 Makefile.pre.in |  5 ++++-
20 configure.ac    | 20 ++++++++++++++------
21 2 files changed, 18 insertions(+), 7 deletions(-)
22
23diff --git a/Makefile.pre.in b/Makefile.pre.in
24index 09408c3471f..8e5f6762d20 100644
25--- a/Makefile.pre.in
26+++ b/Makefile.pre.in
27@@ -1938,7 +1938,6 @@ LIBSUBDIRS=	asyncio \
28 		urllib \
29 		venv venv/scripts venv/scripts/common venv/scripts/posix \
30 		wsgiref \
31-		$(XMLLIBSUBDIRS) \
32 		xmlrpc \
33 		zoneinfo \
34 		__phello__
35@@ -2087,6 +2086,10 @@ ifeq (@CURSES@,yes)
36 LIBSUBDIRS += curses
37 endif
38
39+ifeq (@EXPAT@,yes)
40+LIBSUBDIRS += $(XMLLIBSUBDIRS)
41+endif
42+
43 TEST_MODULES=@TEST_MODULES@
44 libinstall:	all $(srcdir)/Modules/xxmodule.c
45 	@for i in $(SCRIPTDIR) $(LIBDEST); \
46diff --git a/configure.ac b/configure.ac
47index 5d52c813ba6..6e577f19b8c 100644
48--- a/configure.ac
49+++ b/configure.ac
50@@ -3615,15 +3615,23 @@ LIBS="$withval $LIBS"
51 AC_SUBST(DISABLED_EXTENSIONS)
52
53 # Check for use of the system expat library
54-AC_MSG_CHECKING(for --with-system-expat)
55-AC_ARG_WITH(system_expat,
56-            AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library, see Doc/library/pyexpat.rst (default is no)]),
57+AC_MSG_CHECKING(for --with-expat)
58+AC_ARG_WITH(expat,
59+            AS_HELP_STRING([--with-expat], [select which expat version to use: system, builtin, none]),
60             [],
61-            [with_system_expat="no"])
62+            [with_expat="builtin"])
63
64-AC_MSG_RESULT($with_system_expat)
65+AC_MSG_RESULT($with_expat)
66
67-AS_VAR_IF([with_system_expat], [yes], [
68+if test "$with_expat" != "none"; then
69+   EXPAT=yes
70+else
71+   DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} pyexpat"
72+   EXPAT=no
73+fi
74+AC_SUBST(EXPAT)
75+
76+AS_VAR_IF([with_expat], [system], [
77   LIBEXPAT_CFLAGS=${LIBEXPAT_CFLAGS-""}
78   LIBEXPAT_LDFLAGS=${LIBEXPAT_LDFLAGS-"-lexpat"}
79   LIBEXPAT_INTERNAL=
80--
812.44.0
82
83