sim: erc32: fix linking against local readline on modern (ncurses) systems
authorMike Frysinger <vapier@gentoo.org>
Sat, 31 Dec 2011 07:06:47 +0000 (07:06 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sat, 31 Dec 2011 07:06:47 +0000 (07:06 +0000)
The current erc32 configure script only searches for -ltermcap to provide
any termcap funcs (which readlines needs).  When building against a local
readline (which is static), we hit link failures like so:
  gcc ...-I/-D flags... -o sis \
    sis.o exec.o erc32.o func.o help.o float.o \
    ../../bfd/libbfd.a ../../opcodes/libopcodes.a \
    ../../libiberty/libiberty.a -lz -lnsl \
    ../../readline/libreadline.a -lm
  ../../readline/libreadline.a(display.o): In function 'cr':
  .../readline/display.c:2486: undefined reference to 'tputs'
  collect2: ld returned 1 exit status
  make[2]: *** [sis] Error 1

Use AC_SEARCH_LIBS from gdb's configure.ac as suggested by Joel Brobecker
to check for additional termcap providers.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
sim/erc32/ChangeLog
sim/erc32/configure
sim/erc32/configure.ac

index eacec76106fb1536a37f1bada5f5ae98f0560d37..edd77ecbf6a581178be5db8444ae051238f41c51 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-31  Mike Frysinger  <vapier@gentoo.org>
+
+       * configure.ac: Change AC_CHECK_LIB to AC_SEARCH_LIBS to match
+       the code in gdb's configure.ac with $TERMCAP.
+       * configure: Regenerated.
+
 2011-12-03  Mike Frysinger  <vapier@gentoo.org>
 
        * aclocal.m4: New file.
index 7a74c471052051654363088ce7ad1988b335428b..0de9c7d7df1787538600b217eb11a1d8664c28a6 100755 (executable)
@@ -2434,9 +2434,9 @@ sim_inline="-DDEFAULT_INLINE=0"
 # AC_PROG_CPP_WERROR
 
 # Test for GNAT.
-# We require the gnatbind program, and a compiler driver that
-# understands Ada.  We use the user's CC setting, already found,
-# and possibly add $1 to the command-line parameters.
+# We require the gnatbind & gnatmake programs, as well as a compiler driver
+# that understands Ada.  We use the user's CC setting, already found, and
+# possibly add $1 to the command-line parameters.
 #
 # Sets the shell variable have_gnat to yes or no as appropriate, and
 # substitutes GNATBIND and GNATMAKE.
@@ -4765,38 +4765,61 @@ $as_echo "$sim_cv_os_cygwin" >&6; }
 if test x$sim_cv_os_cygwin = xyes; then
   TERMCAP='`if test -r ../../libtermcap/libtermcap.a; then echo ../../libtermcap/libtermcap.a; else echo -ltermcap; fi` -luser32'
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ltermcap" >&5
-$as_echo_n "checking for main in -ltermcap... " >&6; }
-if test "${ac_cv_lib_termcap_main+set}" = set; then :
+  # Keep in sync with gdb's configure.ac list.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
+$as_echo_n "checking for library containing tgetent... " >&6; }
+if test "${ac_cv_search_tgetent+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltermcap  $LIBS"
+  ac_func_search_save_LIBS=$LIBS
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char tgetent ();
 int
 main ()
 {
-return main ();
+return tgetent ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_termcap_main=yes
-else
-  ac_cv_lib_termcap_main=no
+for ac_lib in '' termcap tinfo curses ncurses; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_tgetent=$ac_res
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+    conftest$ac_exeext
+  if test "${ac_cv_search_tgetent+set}" = set; then :
+  break
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_main" >&5
-$as_echo "$ac_cv_lib_termcap_main" >&6; }
-if test "x$ac_cv_lib_termcap_main" = x""yes; then :
-  TERMCAP=-ltermcap
+done
+if test "${ac_cv_search_tgetent+set}" = set; then :
+
+else
+  ac_cv_search_tgetent=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetent" >&5
+$as_echo "$ac_cv_search_tgetent" >&6; }
+ac_res=$ac_cv_search_tgetent
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+  TERMCAP=$ac_cv_search_tgetent
 else
   TERMCAP=""
 fi
index 5a43b5eb50dc059a848332b20c822401645372db..bc460917784fbe50b021e041ad9762d1c9cffa7e 100644 (file)
@@ -17,7 +17,9 @@ lose
 if test x$sim_cv_os_cygwin = xyes; then
   TERMCAP='`if test -r ../../libtermcap/libtermcap.a; then echo ../../libtermcap/libtermcap.a; else echo -ltermcap; fi` -luser32'
 else
-  AC_CHECK_LIB(termcap, main, TERMCAP=-ltermcap, TERMCAP="")
+  # Keep in sync with gdb's configure.ac list.
+  AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncurses],
+    [TERMCAP=$ac_cv_search_tgetent], [TERMCAP=""])
 fi
 AC_SUBST(TERMCAP)
 
This page took 0.031279 seconds and 4 git commands to generate.