From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-fedora-libncursesw.patch

;; Force libncursesw over libncurses to match the includes (RH BZ 1270534).
;;=push+jan

Fedora: Force libncursesw over libncurses to match the includes.
https://bugzilla.redhat.com/show_bug.cgi?id=1270534

diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
@@ -780,9 +780,6 @@ ENABLE_BFD_64_BIT_TRUE
 subdirs
 RPM_LIBS
 RPM_CFLAGS
-PKG_CONFIG_LIBDIR
-PKG_CONFIG_PATH
-PKG_CONFIG
 GDB_DATADIR
 DEBUGDIR
 MAKEINFO_EXTRA_FLAGS
@@ -990,12 +987,12 @@ PKG_CONFIG_PATH
 PKG_CONFIG_LIBDIR
 MAKEINFO
 MAKEINFOFLAGS
+RPM_CFLAGS
+RPM_LIBS
 AMD_DBGAPI_CFLAGS
 AMD_DBGAPI_LIBS
 DEBUGINFOD_CFLAGS
 DEBUGINFOD_LIBS
-RPM_CFLAGS
-RPM_LIBS
 YACC
 YFLAGS
 ZSTD_CFLAGS
@@ -1684,11 +1681,11 @@ Optional Packages:
                           [--with-auto-load-dir]
   --without-auto-load-safe-path
                           do not restrict auto-loaded files locations
+  --with-rpm              query rpm database for missing debuginfos (yes/no,
+                          def. auto=librpm.so)
   --with-amd-dbgapi       support for the amd-dbgapi target (yes / no / auto)
   --with-debuginfod       Enable debuginfo lookups with debuginfod
                           (auto/yes/no)
-  --with-rpm              query rpm database for missing debuginfos (yes/no,
-                          def. auto=librpm.so)
   --with-libunwind-ia64   use libunwind frame unwinding for ia64 targets
   --with-curses           use the curses library instead of the termcap
                           library
@@ -1761,6 +1758,8 @@ Some influential environment variables:
   MAKEINFO    Parent configure detects if it is of sufficient version.
   MAKEINFOFLAGS
               Parameters for MAKEINFO.
+  RPM_CFLAGS  C compiler flags for RPM, overriding pkg-config
+  RPM_LIBS    linker flags for RPM, overriding pkg-config
   AMD_DBGAPI_CFLAGS
               C compiler flags for AMD_DBGAPI, overriding pkg-config
   AMD_DBGAPI_LIBS
@@ -1769,8 +1768,6 @@ Some influential environment variables:
               C compiler flags for DEBUGINFOD, overriding pkg-config
   DEBUGINFOD_LIBS
               linker flags for DEBUGINFOD, overriding pkg-config
-  RPM_CFLAGS  C compiler flags for RPM, overriding pkg-config
-  RPM_LIBS    linker flags for RPM, overriding pkg-config
   YACC        The `Yet Another Compiler Compiler' implementation to use.
               Defaults to the first program found out of: `bison -y', `byacc',
               `yacc'.
@@ -11495,7 +11492,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11486 "configure"
+#line 11495 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11601,7 +11598,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11592 "configure"
+#line 11601 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18102,8 +18099,8 @@ $as_echo_n "checking specific librpm version... " >&6; }
   if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run test program while cross compiling
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -18275,132 +18272,12 @@ $as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
 $as_echo "no" >&6; }
     LIBS="$save_LIBS"
     if $DLOPEN_REQUIRE; then
-      as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
+      as_fn_error $? "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
     fi
 
-
-
-
-
-
-
-if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
-	if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
-set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-if test -n "$PKG_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-$as_echo "$PKG_CONFIG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_path_PKG_CONFIG"; then
-  ac_pt_PKG_CONFIG=$PKG_CONFIG
-  # Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ac_pt_PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
-if test -n "$ac_pt_PKG_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
-$as_echo "$ac_pt_PKG_CONFIG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_pt_PKG_CONFIG" = x; then
-    PKG_CONFIG=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    PKG_CONFIG=$ac_pt_PKG_CONFIG
-  fi
-else
-  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
-fi
-
-fi
-if test -n "$PKG_CONFIG"; then
-	_pkg_min_version=0.9.0
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
-$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
-	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	else
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		PKG_CONFIG=""
-	fi
-fi
-
 pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
-$as_echo_n "checking for RPM... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rpm" >&5
+$as_echo_n "checking for rpm... " >&6; }
 
 if test -n "$RPM_CFLAGS"; then
     pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
@@ -18437,6 +18314,30 @@ fi
     pkg_failed=untried
 fi
 
+if test $pkg_failed = no; then
+  pkg_save_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $pkg_cv_RPM_LIBS"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+  pkg_failed=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$pkg_save_LDFLAGS
+fi
+
 
 
 if test $pkg_failed = yes; then
@@ -18531,7 +18432,7 @@ $as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
       LIBS="$LIBS $RPM_LIBS"
     else
       if $RPM_REQUIRE; then
-	as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
+	as_fn_error $? "$RPM_PKG_ERRORS" "$LINENO" 5
       else
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
 $as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
@@ -21164,6 +21065,7 @@ if test x"$prefer_curses" = xyes; then
   # search /usr/local/include, if ncurses is installed in /usr/local.  A
   # default installation of ncurses on alpha*-dec-osf* will lead to such
   # a situation.
+  # Fedora: Force libncursesw over libncurses to match the includes.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing waddstr" >&5
 $as_echo_n "checking for library containing waddstr... " >&6; }
 if ${ac_cv_search_waddstr+:} false; then :
@@ -21188,7 +21090,7 @@ return waddstr ();
   return 0;
 }
 _ACEOF
-for ac_lib in '' ncursesw ncurses cursesX curses; do
+for ac_lib in '' ncursesw; do
   if test -z "$ac_lib"; then
     ac_res="none required"
   else
@@ -21260,6 +21162,7 @@ case $host_os in
 esac
 
 # These are the libraries checked by Readline.
+# Fedora: Force libncursesw over libncurses to match the includes.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
 $as_echo_n "checking for library containing tgetent... " >&6; }
 if ${ac_cv_search_tgetent+:} false; then :
@@ -21284,7 +21187,7 @@ return tgetent ();
   return 0;
 }
 _ACEOF
-for ac_lib in '' termcap tinfow tinfo curses ncursesw ncurses; do
+for ac_lib in '' ncursesw; do
   if test -z "$ac_lib"; then
     ac_res="none required"
   else
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -749,7 +749,8 @@ if test x"$prefer_curses" = xyes; then
   # search /usr/local/include, if ncurses is installed in /usr/local.  A
   # default installation of ncurses on alpha*-dec-osf* will lead to such
   # a situation.
-  AC_SEARCH_LIBS(waddstr, [ncursesw ncurses cursesX curses],
+  # Fedora: Force libncursesw over libncurses to match the includes.
+  AC_SEARCH_LIBS(waddstr, [ncursesw],
                  [curses_found=yes
                   AC_DEFINE([HAVE_LIBCURSES], [1],
                             [Define to 1 if curses is enabled.])
@@ -789,7 +790,8 @@ case $host_os in
 esac
 
 # These are the libraries checked by Readline.
-AC_SEARCH_LIBS(tgetent, [termcap tinfow tinfo curses ncursesw ncurses])
+# Fedora: Force libncursesw over libncurses to match the includes.
+AC_SEARCH_LIBS(tgetent, [ncursesw])
 
 if test "$ac_cv_search_tgetent" = no; then
   CONFIG_OBS="$CONFIG_OBS stub-termcap.o"
