diff options
author | Christian Heimes <christian@python.org> | 2021-11-18 08:18:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 08:18:44 (GMT) |
commit | 25ecc040d007a55e4b5c30fa739054b52c1aacac (patch) | |
tree | a804c5fba2fba0e13a45dbd723eafee1f08f833f /Modules | |
parent | fc4474e45eecbea8e88095f28c98c5d56438d841 (diff) | |
download | cpython-25ecc040d007a55e4b5c30fa739054b52c1aacac.zip cpython-25ecc040d007a55e4b5c30fa739054b52c1aacac.tar.gz cpython-25ecc040d007a55e4b5c30fa739054b52c1aacac.tar.bz2 |
bpo-45573: Introduce extension module flags in Makefile (GH-29594)
``configure`` now uses a standardized format to forward state, compiler
flags, and linker flags to ``Makefile``, ``setup.py``, and
``Modules/Setup``. ``makesetup`` use the new variables by default if a
module line does not contain any compiler or linker flags. ``setup.py``
has a new function ``addext()``.
For a module ``egg``, configure adds:
* ``MODULE_EGG`` with value yes, missing, disabled, or n/a
* ``MODULE_EGG_CFLAGS``
* ``MODULE_EGG_LDFLAGS``
``Makefile.pre.in`` may also provide ``MODULE_EGG_DEPS`` that lists
dependencies such as header files and static libs.
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/Setup | 15 | ||||
-rwxr-xr-x | Modules/makesetup | 10 |
2 files changed, 20 insertions, 5 deletions
diff --git a/Modules/Setup b/Modules/Setup index 608866d..414c6af 100644 --- a/Modules/Setup +++ b/Modules/Setup @@ -42,6 +42,15 @@ # You can also use any Make variable that is detected by configure and # defined in Makefile.pre.in, e.g. OpenSSL flags $(OPENSSL_INCLUDES). # +# Rules generated by makesetup use additional variables: +# +# - All source file rules have a dependency on $(PYTHON_HEADERS) and on +# optional variable $(MODULES_{mod_upper}_DEPS). +# - If no <cpparg> and no <library> arguments are given, then makesetup +# defaults to $(MODULES_{mod_upper}_CFLAGS) cppargs and +# $(MODULES_{mod_upper}_LDFLAGS) libraries. The variables are typically +# defined by configure. +# # The build process works like this: # # 1. Build all modules that are declared as static in Modules/Setup, @@ -149,7 +158,7 @@ time timemodule.c #_contextvars _contextvarsmodule.c #_csv _csv.c #_datetime _datetimemodule.c -#_decimal _decimal/_decimal.c $(DECIMAL_CFLAGS) $(DECIMAL_LDFLAGS) +#_decimal _decimal/_decimal.c #_heapq _heapqmodule.c #_json _json.c #_lsprof _lsprof.c rotatingtree.c @@ -172,8 +181,8 @@ time timemodule.c #select selectmodule.c # XML -#_elementtree _elementtree.c $(EXPAT_CFLAGS) -#pyexpat pyexpat.c $(EXPAT_CFLAGS) $(EXPAT_LDFLAGS) +#_elementtree _elementtree.c +#pyexpat pyexpat.c # hashing builtins #_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c diff --git a/Modules/makesetup b/Modules/makesetup index a8817ff..2335724 100755 --- a/Modules/makesetup +++ b/Modules/makesetup @@ -154,6 +154,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | cpps= libs= mods= + mods_upper= skip= for arg in $line do @@ -194,11 +195,17 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | *.*) echo 1>&2 "bad word $arg in $line" exit 1;; -u) skip=libs; libs="$libs -u";; - [a-zA-Z_]*) mods="$mods $arg";; + [a-zA-Z_]*) + mods="$mods $arg" + mods_upper=$(echo $mods | tr '[a-z]' '[A-Z]');; *) echo 1>&2 "bad word $arg in $line" exit 1;; esac done + if test -z "$cpps" -a -z "$libs"; then + cpps="\$(MODULE_${mods_upper}_CFLAGS)" + libs="\$(MODULE_${mods_upper}_LDFLAGS)" + fi case $doconfig in yes) LIBS="$LIBS $libs" @@ -245,7 +252,6 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | *) cc="$cc \$(PY_BUILTIN_MODULE_CFLAGS)";; esac - mods_upper=$(echo $mods | tr '[a-z]' '[A-Z]') # force rebuild when header file or module build flavor (static/shared) is changed rule="$obj: $src \$(MODULE_${mods_upper}_DEPS) \$(PYTHON_HEADERS) Modules/config.c; $cc $cpps -c $src -o $obj" echo "$rule" >>$rulesf |