aboutsummaryrefslogtreecommitdiffstats
path: root/main/python3/custom-bluetooth-h-path.patch
blob: 85fe92b22296ff210fe3b8f24c9fa4ea9c656fec (plain) (blame)
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
64
65
66
67
68
69
70
71
72
diff --git a/configure.ac b/configure.ac
index c968d14..5b2793e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2205,16 +2205,27 @@ sys/kern_control.h sys/loadavg.h sys/lock.h sys/mkdev.h sys/modem.h \
 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/memfd.h linux/wait.h sys/memfd.h sys/mman.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
@@ -1127,6 +1127,7 @@ class PyBuildExt(build_ext):
                                libraries=libs))
 
     def detect_socket(self):
+        bluetooth_includes = [@bluetoothdir@]
         # socket(2)
         if not VXWORKS:
             kwargs = {'depends': ['socketmodule.h']}
@@ -1134,12 +1135,15 @@ class PyBuildExt(build_ext):
                 # 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))
         elif self.compiler.find_library_file(self.lib_dirs, 'net'):
             libs = ['net']
             self.add(Extension('_socket', ['socketmodule.c'],
                                depends=['socketmodule.h'],
-                               libraries=libs))
+                               libraries=libs,
+                               include_dirs=bluetooth_includes))
 
     def detect_dbm_gdbm(self):
         # Modules that provide persistent dictionary-like semantics.  You will
@@ -2322,6 +2326,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')
         if not openssl_libs: