Skip to content

bpo-45573: Use pkg-config for Modules/Setup #29164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Misc/python-embed.pc
Misc/python-config.sh
Modules/Setup.config
Modules/Setup.local
Modules/Setup
Modules/config.c
Modules/ld_so_aix
Programs/_freeze_module
Expand Down
52 changes: 50 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,48 @@ RUNSHARED= @RUNSHARED@
ENSUREPIP= @ENSUREPIP@

# OpenSSL options for setup.py so sysconfig can pick up AC_SUBST() vars.
MODULE__SSL_CFLAGS=@OPENSSL_INCLUDES@
MODULE__SSL_LDFLAGS=@OPENSSL_LIBS@ @OPENSSL_LDFLAGS@
MODULE__HASHLIB_CFLAGS=@OPENSSL_INCLUDES@
MODULE__HASHLIB_LDFLAGS=@OPENSSL_LIBS@ @OPENSSL_LDFLAGS@
OPENSSL_INCLUDES=@OPENSSL_INCLUDES@
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 Expand Up @@ -705,13 +742,24 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
fi


oldsharedmods: $(SHAREDMODS)
oldsharedmods: $(SHAREDMODS) pybuilddir.txt
# create relative links from build/lib.platform/egg.so to Modules/egg.so
# pybuilddir.txt is created too late. We cannot use it in Makefile
# targets. FreeBSD's ln does not have --relative option.
@target=`cat pybuilddir.txt`; \
for mod in X $(SHAREDMODS); do \
if test $$mod != X; then \
$(LN) -sf ../../$$mod $$target/`basename $$mod`; \
fi; \
done

Modules/Setup: $(srcdir)/Modules/Setup.in
./config.status --file=$@

Makefile Modules/config.c: Makefile.pre \
$(srcdir)/Modules/config.c.in \
$(MAKESETUP) \
$(srcdir)/Modules/Setup \
Modules/Setup \
Modules/Setup.local
$(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
-s Modules \
Expand Down
40 changes: 21 additions & 19 deletions Modules/Setup → Modules/Setup.in
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
#@HAVE_CURSES_TRUE@_crypt _cryptmodule.c $(CRYPT_CFLAGS) $(CRYPT_LIBS) # crypt(3); breaks many builds.
#@HAVE_NIS_TRUE@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
# _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
#@HAVE_BZ2_TRUE@_bz2 _bz2module.c $(BZ2_CFLAGS) $(BZ2_LIBS)
#@HAVE_FFI_TRUE@_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
#@HAVE_DBM_TRUE@_dbm _dbmmodule.c # -lndbm # dbm(3)
#@HAVE_GDBM_TRUE@_gdbm _gdbmmodule.c -lgdbm
#@HAVE_LZMA_TRUE@_lzma _lzmamodule.c $(LZMA_CFLAGS) $(LZMA_LIBS)
#@HAVE_SQLITE3_TRUE@_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)
#@HAVE_UUID_TRUE@_uuid _uuidmodule.c $(UUID_CFLAGS) $(UUID_LIBS)
#@HAVE_ZLIB_TRUE@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,11 +224,12 @@ 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)
#_hashlib _hashopenssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) -lcrypto
#@HAVE_OPENSSL_TRUE@_ssl _ssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) $(OPENSSL_LIBS)
#@HAVE_OPENSSL_TRUE@_hashlib _hashopenssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) -lcrypto

# To statically link OpenSSL:
# _ssl _ssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) \
Expand All @@ -248,7 +250,7 @@ time timemodule.c
# every system.

# *** Always uncomment this (leave the leading underscore in!):
#_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT $(TCLTK_INCLUDES) $(TCLTK_LIBS) \
#@HAVE_TCLTK_TRUE@_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT $(TCLTK_INCLUDES) $(TCLTK_LIBS) \
# *** Uncomment and edit to reflect where your Tcl/Tk libraries are:
# -L/usr/local/lib \
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:
Expand Down Expand Up @@ -281,13 +283,13 @@ time timemodule.c
# provided by the ncurses library. e.g. on Linux, link with -lncurses
# instead of -lcurses).

#_curses -lcurses -lcursesw -ltermcap _cursesmodule.c
#@HAVE_CURSES_TRUE@_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
#@HAVE_CURSES_PANEL_TRUE@_curses_panel _curses_panel.c $(CURSES_PANEL_CFLAGS) $(CURSES_PANEL_LIBS)

# macOS specific modules
# _scproxy _scproxy.c -framework SystemConfiguration -framework CoreFoundation
#@HAVE_SCPROXY_TRUE@_scproxy _scproxy.c -framework SystemConfiguration -framework CoreFoundation

# Examples

Expand All @@ -300,7 +302,7 @@ xxsubtype xxsubtype.c # Required for the test suite to pass!

#_xxsubinterpreters _xxsubinterpretersmodule.c
#_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c
#_ctypes_test _ctypes/_ctypes_test.c
#@HAVE_FFI_TRUE@_ctypes_test _ctypes/_ctypes_test.c
#_testbuffer _testbuffer.c
#_testimportmultiple _testimportmultiple.c
#_testinternalcapi _testinternalcapi.c
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