summarylogtreecommitdiffstats
path: root/0108-build-Cleanup-ncursesw-include-lookup-code.patch
blob: a37be8ae9b67d78da25bb11cd56dec53e81b0d60 (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
64
65
66
67
68
69
70
71
72
73
74
75
From 092108ff97a30264657e3f998de754e691cc58f4 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Fri, 23 Jul 2021 08:50:39 +0200
Subject: [PATCH 108/N] build: Cleanup ncursesw include lookup code

Mirror what si already done for libffi; Look it up via
pkg-config and use the exported path via sysconfig in setup.py

This should be merged into "dont include system ncurses path"
---
 Makefile.pre.in |  1 +
 configure.ac    | 19 ++++++++++---------
 setup.py        |  2 +-
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/Makefile.pre.in b/Makefile.pre.in
index 01cc055..fe25d9e 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -313,6 +313,7 @@ IO_OBJS=	\
 ##########################################################################
 
 LIBFFI_INCLUDEDIR=	@LIBFFI_INCLUDEDIR@
+NCURSESW_INCLUDEDIR=	@NCURSESW_INCLUDEDIR@
 
 ##########################################################################
 # Parser
diff --git a/configure.ac b/configure.ac
index 14e4c8c..bab62ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5556,17 +5556,18 @@ then
   [Define if you have struct stat.st_mtimensec])
 fi
 
+if test -n "$PKG_CONFIG"; then
+    NCURSESW_INCLUDEDIR="`"$PKG_CONFIG" ncursesw --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
+else
+    NCURSESW_INCLUDEDIR=""
+fi
+AC_SUBST(NCURSESW_INCLUDEDIR)
+
 # first curses header check
 ac_save_cppflags="$CPPFLAGS"
-case $host_os in
-    mingw*)
-    ;;
-    *)
-      if test "$cross_compiling" = no; then
-        CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
-      fi
-    ;;
-esac
+if test "$cross_compiling" = no; then
+  CPPFLAGS="$CPPFLAGS -I$NCURSESW_INCLUDEDIR"
+fi
 
 AC_CHECK_HEADERS(curses.h ncurses.h)
 
diff --git a/setup.py b/setup.py
index a2d5656..4e7a284 100644
--- a/setup.py
+++ b/setup.py
@@ -1098,7 +1098,7 @@ class PyBuildExt(build_ext):
         if curses_library == 'ncursesw':
             curses_defines.append(('HAVE_NCURSESW', '1'))
             if not CROSS_COMPILING:
-                curses_includes.append('/usr/include/ncursesw')
+                curses_includes.append(sysconfig.get_config_var("NCURSESW_INCLUDEDIR"))
             # Bug 1464056: If _curses.so links with ncursesw,
             # _curses_panel.so must link with panelw.
             panel_library = 'panelw'
-- 
2.32.0