Hello!

The last fixes make it possible to use the GRUB shell under FreeBSD
and probably under most other OS'es

Quite disappointing was however, that the GRUB shell was compiled
without ncurses on FreeBSD-3.2

There have been two problems.
1) "getch" is not exported by the supplied version of ncurses (it's
defined as macro)
2) curses.h comes from old BSD Curses and lacks some definitions.

I haven't done any attempts to port GRUB to old Curses. But the stock
ncurses works without any changes provided that the right files are
included and linked

I have added tests for the location of the best [n]curses.h
I remember that some versions of Cygwin only have ncurses/curses.h,
so "configure" tests for ncurses/curses.h, ncurses.h and curses.h

The increasing number of defines forced me to add autoheader support.
Unfortunately, non-trivial macros such as EXT_C don't works with
autoheader, so I simplified grub_ASM_EXT_C and renamed it to
grub_ASM_USCORE

Even libtool and glib test only for two cases - no underscore and one
leading underscore. GRUB isn't aimed to be more portable than libtool,
so it also tests for those cases only.

ChangeLog:
        * acconfig.h: new file for autoheader support
        * acinclude.m4: grub_ASM_EXT_C renamed to grub_ASM_USCORE
        It defines HAVE_ASM_USCORE if C symbols get an underscore
        after compiling to assembler
        * configure.in: added AM_CONFIG_HEADER. Autoconf 2.13 is
        now required. Test for wgetch(), not getch() in -l[n]curses
        * stage2/shared.h: define EXT_C. Include the best existing
        header for [n]curses.
        
Please don't forget to run:

aclocal && autoheader && automake && autoconf
cvs add acconfig.h

Pavel Roskin
diff -urN acconfig.h acconfig.h
--- acconfig.h  Thu Jan  1 03:00:00 1970
+++ acconfig.h  Sat Sep 11 21:33:32 1999
@@ -0,0 +1,11 @@
+/* This file is still needed because the defines below are
+   AC_DEFINEd in more that one place. */
+
+/* Define it to "addr32" or "addr32;" to make GAS happy. */
+#undef ADDR32
+
+/* Define it to "data32" or "data32;" to make GAS happy. */
+#undef DATA32
+
+/* Define if you have a curses library (ncurses preferred). */
+#undef HAVE_LIBCURSES
diff -urN acinclude.m4 acinclude.m4
--- acinclude.m4        Thu Aug  5 18:01:41 1999
+++ acinclude.m4        Sat Sep 11 21:36:53 1999
@@ -1,10 +1,11 @@
-dnl grub_ASM_EXT_C checks what name gcc will use for C symbol.
-dnl Originally written by Erich Boleyn, the author of GRUB, and modified
-dnl by OKUJI Yoshinori to autoconfiscate the test.
-AC_DEFUN(grub_ASM_EXT_C,
+dnl grub_ASM_USCORE checks if C symbols get an underscore after
+dnl compiling to assembler.
+dnl Written by Pavel Roskin. Based on grub_ASM_EXT_C written by
+dnl Erich Boleyn and modified by OKUJI Yoshinori
+AC_DEFUN(grub_ASM_USCORE,
 [AC_REQUIRE([AC_PROG_CC])
-AC_MSG_CHECKING([symbol names produced by ${CC-cc}])
-AC_CACHE_VAL(grub_cv_asm_ext_c,
+AC_MSG_CHECKING([if C symbols get an underscore after compilation])
+AC_CACHE_VAL(grub_cv_asm_uscore,
 [cat > conftest.c <<\EOF
 int
 func (int *list)
@@ -19,23 +20,17 @@
   AC_MSG_ERROR([${CC-cc} failed to produce assembly code])
 fi
 
-set dummy `grep \.globl conftest.s | grep func | sed -e s/\\.globl// | sed -e 
s/func/\ sym\ /`
-shift
-if test -z "[$]1"; then
-  AC_MSG_ERROR([C symbol not found])
+if grep _func conftest.s >/dev/null 2>&1; then
+  grub_cv_asm_uscore=yes
+  AC_DEFINE_UNQUOTED([HAVE_ASM_USCORE], $grub_cv_asm_uscore,
+    [Define if C symbols get an underscore after compilation])
+else
+  grub_cv_asm_uscore=no
 fi
-grub_cv_asm_ext_c="[$]1"
-while test [$]# != 0; do
-  shift
-  dummy=[$]1
-  if test ! -z ${dummy}; then
-    grub_cv_asm_ext_c="$grub_cv_asm_ext_c ## $dummy"
-  fi
-done
+
 rm -f conftest*])
 
-AC_MSG_RESULT([$grub_cv_asm_ext_c])
-AC_DEFINE_UNQUOTED([EXT_C(sym)], $grub_cv_asm_ext_c)
+AC_MSG_RESULT([$grub_cv_asm_uscore])
 ])
 
 
diff -urN configure.in configure.in
--- configure.in        Mon Sep  6 18:35:14 1999
+++ configure.in        Sat Sep 11 21:33:32 1999
@@ -17,7 +17,8 @@
 AM_INIT_AUTOMAKE(
    esyscmd([sed 's/ .*$//; q' debian/changelog]),
    esyscmd([sed 's/^.*(\(.*\)).*$/\1/; q' debian/changelog]))dnl
-AC_PREREQ(2.12)
+AM_CONFIG_HEADER(config.h)
+AC_PREREQ(2.13)
 
 AC_CANONICAL_HOST
 
@@ -87,7 +88,7 @@
 AC_CHECK_TOOL(OBJCOPY, objcopy)
 
 # Defined in acinclude.m4.
-grub_ASM_EXT_C
+grub_ASM_USCORE
 grub_PROG_OBJCOPY_ABSOLUTE
 if test "x$grub_cv_prog_objcopy_absolute" != xyes; then
   AC_MSG_ERROR([GRUB requires a working absolute objcopy; upgrade your binutils])
@@ -108,14 +109,14 @@
 fi
 
 # Check for curses libraries.
-AC_CHECK_LIB(ncurses, getch, [GRUB_LIBS="$GRUB_LIBS -lncurses"
+AC_CHECK_LIB(ncurses, wgetch, [GRUB_LIBS="$GRUB_LIBS -lncurses"
 AC_DEFINE(HAVE_LIBCURSES)],
-               [AC_CHECK_LIB(curses, getch, [GRUB_LIBS="$GRUB_LIBS -lcurses"
+               [AC_CHECK_LIB(curses, wgetch, [GRUB_LIBS="$GRUB_LIBS -lcurses"
 AC_DEFINE(HAVE_LIBCURSES)])])
 AC_SUBST(GRUB_LIBS)
 
 # Check for headers.
-AC_CHECK_HEADERS(string.h strings.h)
+AC_CHECK_HEADERS(string.h strings.h ncurses/curses.h ncurses.h curses.h)
 
 # Check for user options.
 
diff -urN stage2/shared.h stage2/shared.h
--- stage2/shared.h     Sat Sep 11 14:48:36 1999
+++ stage2/shared.h     Sat Sep 11 21:33:32 1999
@@ -23,6 +23,15 @@
  *  Generic defines to use anywhere
  */
 
+#include <config.h>
+
+/* Add underscores to C symbols in assembler code if needed. */
+#ifdef HAVE_ASM_USCORE
+# define EXT_C(sym) _ ## sym
+#else
+# define EXT_C(sym) sym
+#endif
+
 /* Maybe redirect memory requests through grub_scratch_mem. */
 #ifdef GRUB_UTIL
 extern char *grub_scratch_mem;
@@ -226,7 +235,11 @@
 # define KEY_PPAGE       0x5100
 # define A_NORMAL        0x7
 # define A_REVERSE       0x70
-#else
+#elif defined(HAVE_NCURSES_CURSES_H)
+# include <ncurses/curses.h>
+#elif defined(HAVE_NCURSES_H)
+# include <ncurses.h>
+#elif defined(HAVE_CURSES_H)
 # include <curses.h>
 #endif
 

Reply via email to