Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-45573: Use pkg-config for Modules/Setup
Use pkg-config and a modified version of
``PKG_HAVE_DEFINE_WITH_MODULES`` to detect compiler flags and libraries
for ``Modules/Setup``.

For now CPython does not use any of the new flags in setup.py. We may
expand the use of pkg-config once we are sure that it works properly on
our target platforms.

Signed-off-by: Christian Heimes <christian@python.org>
  • Loading branch information
tiran committed Oct 26, 2021
commit afcd74be60794704b625999d04f61b336d088c13
33 changes: 33 additions & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,39 @@ OPENSSL_LIBS=@OPENSSL_LIBS@
OPENSSL_LDFLAGS=@OPENSSL_LDFLAGS@
OPENSSL_RPATH=@OPENSSL_RPATH@

# extension module flags
# detected manually
READLINE_LIBS=@READLINE_LIBS@
READLINE_CFLAGS=@READLINE_CFLAGS@
TCLTK_LIBS=@TCLTK_LIBS@
TCLTK_CFLAGS=@TCLTK_INCLUDES@

# detected with PKG_WITH_MODULES_OPTIONAL macro
NCURSESW_LIBS=@NCURSESW_LIBS@
NCURSESW_CFLAGS=@NCURSESW_CFLAGS@
CURSES_LIBS=@CURSES_LIBS@
CURSES_CFLAGS=@CURSES_CFLAGS@
CURSES_PANEL_LIBS=@CURSES_PANEL_LIBS@
CURSES_PANEL_CFLAGS=@CURSES_PANEL_CFLAGS@
SQLITE3_LIBS=@SQLITE3_LIBS@
SQLITE3_CFLAGS=@SQLITE3_CFLAGS@
ZLIB_LIBS=@ZLIB_LIBS@
ZLIB_CFLAGS=@ZLIB_CFLAGS@
BZ2_LIBS=@BZ2_LIBS@
BZ2_CFLAGS=@BZ2_CFLAGS@
LZMA_LIBS=@LZMA_LIBS@
LZMA_CFLAGS=@LZMA_CFLAGS@
EXPAT_LIBS=@EXPAT_LIBS@
EXPAT_CFLAGS=@EXPAT_CFLAGS@
UUID_LIBS=@UUID_LIBS@
UUID_CFLAGS=@UUID_CFLAGS@
FFI_LIBS=@FFI_LIBS@
FFI_CFLAGS=@FFI_CFLAGS@
NIS_LIBS=@NIS_LIBS@
NIS_CFLAGS=@NIS_CFLAGS@
CRYPT_LIBS=@CRYPT_LIBS@
CRYPT_CFLAGS=@CRYPT_CFLAGS@

# Default zoneinfo.TZPATH. Added here to expose it in sysconfig.get_config_var
TZPATH=@TZPATH@

Expand Down
26 changes: 14 additions & 12 deletions Modules/Setup
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ time timemodule.c
#binascii binascii.c
#cmath cmathmodule.c
#math mathmodule.c
#pyexpat -I$(srcdir)/Modules/expat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c
#pyexpat -I$(srcdir)/Modules/expat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c
#unicodedata unicodedata.c

# Modules with some UNIX dependencies -- on by default:
Expand All @@ -199,21 +199,22 @@ time timemodule.c
# Some more UNIX dependent modules -- off by default, since these
# are not supported by all UNIX systems:

#_crypt _cryptmodule.c -lcrypt # crypt(3); breaks many builds.
#nis nismodule.c -I/usr/include/tirpc -lnsl -ltirpc # Sun yellow pages -- not everywhere
#_crypt _cryptmodule.c $(CRYPT_CFLAGS) $(CRYPT_LIBS) # crypt(3); breaks many builds.
#nis nismodule.c $(NIS_CFLAGS) $(NIS_LIBS) # Sun yellow pages -- not everywhere
#termios termios.c # Steen Lumholt's termios module
#resource resource.c # Jeremy Hylton's rlimit interface

# Modules that require external libraries.

#_bz2 _bz2module.c -lbz2
#_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c -ldl -lffi -DHAVE_FFI_PREP_CIF_VAR -DHAVE_FFI_PREP_CLOSURE_LOC -DHAVE_FFI_CLOSURE_ALLOC
#_bz2 _bz2module.c $(BZ2_CFLAGS) $(BZ2_LIBS)
#_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c $(FFI_CFLAGS) $(FFI_LIBS) -DHAVE_FFI_PREP_CIF_VAR -DHAVE_FFI_PREP_CLOSURE_LOC -DHAVE_FFI_CLOSURE_ALLOC
# _dbm _dbmmodule.c # -lndbm # dbm(3)
#_gdbm _gdbmmodule.c -lgdbm
#_lzma _lzmamodule.c -llzma
#_sqlite3 _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c -lsqlite3
#_uuid _uuidmodule.c -luuid
#zlib zlibmodule.c -lz
#_lzma _lzmamodule.c $(LZMA_CFLAGS) $(LZMA_LIBS)
#_sqlite3 _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c $(SQLITE3_CFLAGS) $(SQLITE3_LIBS)
#_uuid _uuidmodule.c $(UUID_CFLAGS) $(UUID_LIBS)
#zlib zlibmodule.c $(ZLIB_CFLAGS) $(ZLIB_LIBS)


# GNU readline. Unlike previous Python incarnations, GNU readline is
# now incorporated in an optional module, configured in the Setup file
Expand All @@ -223,7 +224,8 @@ time timemodule.c
# it, depending on your system -- see the GNU readline instructions.
# It's okay for this to be a shared library, too.

#readline readline.c -lreadline -ltermcap
# readline readline.c -lreadline -ltermcap
#readline readline.c $(READLINE_CFLAGS) $(READLINE_LIBS)

# To dynamically link OpenSSL:
#_ssl _ssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) $(OPENSSL_LIBS)
Expand Down Expand Up @@ -281,10 +283,10 @@ time timemodule.c
# provided by the ncurses library. e.g. on Linux, link with -lncurses
# instead of -lcurses).

#_curses -lcurses -lcursesw -ltermcap _cursesmodule.c
#_curses _cursesmodule.c $(NCURSESW_CFLAGS) $(NCURSESW_LIBS) $(CURSES_CFLAGS) $(CURSES_LIBS)

# Wrapper for the panel library that's part of ncurses and SYSV curses.
#_curses_panel -lpanel -lncurses _curses_panel.c
#_curses_panel _curses_panel.c $(CURSES_PANEL_CFLAGS) $(CURSES_PANEL_LIBS)

# macOS specific modules
# _scproxy _scproxy.c -framework SystemConfiguration -framework CoreFoundation
Expand Down
50 changes: 50 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -619,3 +619,53 @@ 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

# AM_CONDITIONAL -*- Autoconf -*-

# Copyright (C) 1997-2020 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ([2.52])dnl
m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
m4_define([_AM_COND_VALUE_$1], [$2])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])

# Copyright (C) 2006-2020 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])

# AM_SUBST_NOTMAKE(VARIABLE)
# --------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])

Loading