summaryrefslogtreecommitdiff
path: root/repo/python/custom-bluetooth-h-path.patch
blob: 3d836e3f88aad7dcd9b51d0097764fa003896963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--- a/configure.ac
+++ b/configure.ac
@@ -2223,17 +2223,28 @@
 sys/param.h sys/random.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \
 sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
 sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
-libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
+libutil.h sys/resource.h netpacket/packet.h sysexits.h \
 linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \
 sys/endian.h sys/sysmacros.h linux/auxvec.h sys/auxv.h linux/memfd.h linux/wait.h sys/memfd.h \
 sys/mman.h sys/eventfd.h)
 AC_HEADER_DIRENT
 AC_HEADER_MAJOR
 
+AC_ARG_WITH([bluetoothdir],
+  [AS_HELP_STRING([--with-bluetoothdir=DIR], [Path to bluetooth/bluetooth.h header])],
+  [bluetoothdir=$withval],
+  [bluetoothdir=""])
+
+if test "$bluetoothdir" != ""
+then
+       BLUETOOTH_CFLAGS="-I$bluetoothdir"
+       AC_SUBST([BLUETOOTH_CFLAGS], [$BLUETOOTH_CFLAGS])
+fi
+
 # bluetooth/bluetooth.h has been known to not compile with -std=c99.
 # http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
 SAVE_CFLAGS=$CFLAGS
-CFLAGS="-std=c99 $CFLAGS"
+CFLAGS="-std=c99 $CFLAGS $BLUETOOTH_CFLAGS"
 AC_CHECK_HEADERS(bluetooth/bluetooth.h)
 CFLAGS=$SAVE_CFLAGS

diff --git a/setup.py b/setup.py
index bd5f736..9381135 100644
--- a/setup.py
+++ b/setup.py
@@ -1221,13 +1221,16 @@ class PyBuildExt(build_ext):
         self.add(Extension('_crypt', ['_cryptmodule.c'], libraries=libs))

     def detect_socket(self):
+        bluetooth_includes = [@bluetoothdir@]
         # socket(2)
         kwargs = {'depends': ['socketmodule.h']}
         if MACOS:
             # Issue #35569: Expose RFC 3542 socket options.
             kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']

-        self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
+        self.add(Extension('_socket', ['socketmodule.c'],
+            include_dirs=bluetooth_includes,
+            **kwargs))

     def detect_dbm_gdbm(self):
         # Modules that provide persistent dictionary-like semantics.  You will
@@ -2435,6 +2438,7 @@ class PyBuildExt(build_ext):
             return [v.strip() for v in value.split(sep) if v.strip()]

         openssl_includes = split_var('OPENSSL_INCLUDES', '-I')
+        openssl_includes = openssl_includes + (@bluetoothdir@,)
         openssl_libdirs = split_var('OPENSSL_LDFLAGS', '-L')
         openssl_libs = split_var('OPENSSL_LIBS', '-l')
         openssl_rpath = config_vars.get('OPENSSL_RPATH')