summarylogtreecommitdiffstats
path: root/0073-Fix-upstream-CFLAGS-override.patch
blob: a1a2337c78bb7492dcc3043216553687d45461a1 (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
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Sun, 24 May 2020 17:53:33 +0200
Subject: Fix upstream CFLAGS override

Upstream check for python clears OS build system CFLAGS
LP: #1879445
Closes: #961028
Origin: https://src.fedoraproject.org/rpms/hplip/raw/master/f/hplip-configure-python.patch
---
 configure.in | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/configure.in b/configure.in
index 1ca12ac..0dd1502 100644
--- a/configure.in
+++ b/configure.in
@@ -630,20 +630,31 @@ if test "$class_driver" = "no" && test "$hpijs_only_build" = "no" && test "$hpcu
    fi
 fi
 
-SAVE_CPPFLAGS="$CPPFLAGS"
-CFLAGS=`python-config --includes`
-if [ $? -eq 0 ] 
-then
-   echo $FLAGS
-else
-CFLAGS=`python3-config --includes`
-   if [ $? -eq 0 ]
-   then
-   echo $FLAGS
-   fi
+AC_PATH_PROG(python3_config_path, python3-config, [AC_MSG_ERROR([python3-config not installed], 6)])
+
+PYTHON_INCLUDES=`$python3_config_path --includes`
+if test "X$PYTHON_INCLUDES" == "X" ; then
+  AC_MSG_ERROR([Cannot get Python includes via python3-config], 6)
+fi
+
+PYTHON_LIBS=`$python3_config_path --libs`
+if test "X$PYTHON_LIBS" == "X" ; then
+  AC_MSG_ERROR([Cannot get Python libs via python3-config], 6)
+fi
+
+SAVE_CFLAGS=$CFLAGS
+SAVE_LIBS=$LIBS
+
+CFLAGS="$CFLAGS $PYTHON_INCLUDES"
+LIBS="$LIBS $PYTHON_LIBS"
+
+AC_TRY_LINK(,[ ], AC_MSG_RESULT(yes); python_includes="ok", AC_MSG_ERROR([no: PYTHON DISABLED], 6))
+
+if test "X$python_includes" != "Xok" ; then
+  CFLAGS="$SAVE_CFLAGS"
+  LIBS="$SAVE_LIBS"
 fi
 
-#CFLAGS=`(python-config --includes)`
 if test "$class_driver" = "no" && test "$hpijs_only_build" = "no" && test "$lite_build" = "no" && test "$hpcups_only_build" = "no"; then
    AC_ARG_VAR([PYTHON], [Python interpreter/compiler command])
    AC_CHECK_PROGS(PYTHON,[python python3 python2])
@@ -669,7 +680,6 @@ if test "$class_driver" = "no" && test "$hpijs_only_build" = "no" && test "$lite
           [AC_MSG_ERROR([cannot find python-devel support], 6)])
    CPPFLAGS=$save_CPPFLAGS
 fi
-CFLAGS="$save_CFLAGS"
 
 if test "$hpijs_only_build" = "no" && test "$scan_build" = "yes" && test "$hpcups_only_build" = "no"; then
    AC_CHECK_LIB([sane], [sane_open], [LIBS="$LIBS"], [AC_MSG_ERROR([cannot find sane-backends-devel support (or --disable-scan-build)], 12)])