]> arthur.barton.de Git - bup.git/commitdiff
distutils: handle CFLAGS and LDFLAGS directly
authorRob Browning <rlb@defaultvalue.org>
Sun, 31 May 2020 19:10:11 +0000 (14:10 -0500)
committerRob Browning <rlb@defaultvalue.org>
Fri, 19 Jun 2020 22:50:38 +0000 (17:50 -0500)
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 <rlb@defaultvalue.org>
Makefile
lib/bup/csetup.py

index 42cbbcd8b2142a662e64a0b5fcbc142663e1dabe..3d129a4e3f7cc71ca67c7bd9370e0a6009aa01b6 100644 (file)
--- 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)"
index d46aac0ae422571a75dbbe52ae20178d5441a777..c5b6bb136ca3a2cdfb0a4fff40e800cc26bf6f70 100644 (file)
@@ -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',