From 827918b0270178fcfa07289f2383f88c73444090 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 31 May 2020 14:10:11 -0500 Subject: [PATCH] distutils: handle CFLAGS and LDFLAGS directly Otherwise it places LDFLAGS in the middle of the link arguments, before lib/bup/*.o which means we can't add lib dependencies (e.g. -lreadline). Pass the libs directly and specify them via the appropriate extra_* arguments. Signed-off-by: Rob Browning --- Makefile | 3 +-- lib/bup/csetup.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 42cbbcd..3d129a4 100644 --- a/Makefile +++ b/Makefile @@ -123,8 +123,7 @@ lib/bup/_helpers$(SOEXT): \ config/config.h lib/bup/bupsplit.h \ lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py @rm -f $@ - cd lib/bup && \ - LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" "$(bup_python)" csetup.py build + cd lib/bup && $(bup_python) csetup.py build "$(CFLAGS)" "$(LDFLAGS)" # Make sure there's just the one file we expect before we copy it. "$(bup_python)" -c \ "import glob; assert(len(glob.glob('lib/bup/build/*/_helpers*$(SOEXT)')) == 1)" diff --git a/lib/bup/csetup.py b/lib/bup/csetup.py index d46aac0..c5b6bb1 100644 --- a/lib/bup/csetup.py +++ b/lib/bup/csetup.py @@ -1,11 +1,22 @@ -from __future__ import absolute_import +from __future__ import absolute_import, print_function +import shlex, sys from distutils.core import setup, Extension +from os import environ + +if len(sys.argv) != 4: + print('Usage: csetup.py CFLAGS LDFLAGS', file=sys.stderr) + sys.exit(2) +_helpers_cflags = shlex.split(sys.argv[2]) +_helpers_ldflags = shlex.split(sys.argv[3]) +sys.argv = sys.argv[:2] _helpers_mod = Extension('_helpers', sources=['_helpers.c', 'bupsplit.c'], - depends=['../../config/config.h', 'bupsplit.h']) + depends=['../../config/config.h', 'bupsplit.h'], + extra_compile_args=_helpers_cflags, + extra_link_args=_helpers_ldflags) setup(name='_helpers', version='0.1', -- 2.39.2