From f1599796efed1eb67759cf42f47fe4bf6a9bf93c Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Fri, 19 Jul 2013 17:07:31 -0700 Subject: [PATCH] configure: Update to use AX_WITH_CURSES MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For a more portable build system convert to using the autoconf-archive AX_WITH_CURSES macros. Allows building on openSUSE, which has a different header file layout than other distros, and fixes menu entries with UTF-8 characters; this causes fedora installs (codename "Schrödinger´s cat") to break the UI. Signed-off-by: Geoff Levand --- configure.ac.in | 37 +++++++++++++++++-------------------- ui/ncurses/Makefile.am | 5 ++--- ui/ncurses/generic-main.c | 4 ++-- ui/ncurses/nc-boot-editor.c | 2 ++ ui/ncurses/nc-boot-editor.h | 11 +++++++++-- ui/ncurses/nc-cui.c | 2 ++ ui/ncurses/nc-menu.c | 2 ++ ui/ncurses/nc-menu.h | 11 +++++++++-- ui/ncurses/nc-scr.c | 4 ++++ ui/ncurses/nc-scr.h | 14 +++++++++++++- ui/ncurses/ps3-main.c | 4 ++-- 11 files changed, 64 insertions(+), 32 deletions(-) diff --git a/configure.ac.in b/configure.ac.in index 51cfdb8..8372b98 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -28,14 +28,29 @@ AC_PROG_INSTALL AM_INIT_AUTOMAKE LT_INIT -AC_CHECK_HEADERS([stdarg.h]) -AC_CHECK_HEADERS([varargs.h]) +AX_WITH_CURSES +AX_WITH_CURSES_MENU +AX_WITH_CURSES_FORM + +AM_CONDITIONAL([WITH_NCURSES], [test "x$ax_cv_curses" = "xyes"]) + +if test "x$ax_cv_curses" = xyes; then + if test "x$ax_cv_menu" != xyes; then + AC_MSG_ERROR([--with-ncurses requires the ncurses menu library]) + fi + if test "x$ax_cv_form" != xyes; then + AC_MSG_ERROR([--with-ncurses requires the ncurses form library]) + fi +fi AC_CHECK_LIB([udev], [udev_new], [], [AC_MSG_FAILURE([The libudev development library is required by petitboot. Try installing the package libudev-dev or libudev-devel.])] ) +AC_CHECK_HEADERS([stdarg.h]) +AC_CHECK_HEADERS([varargs.h]) + dnl Checking for va_copy availability AC_MSG_CHECKING([for va_copy]) AC_TRY_LINK([#include @@ -57,24 +72,6 @@ else fi fi -AC_ARG_WITH( - [ncurses], - [AS_HELP_STRING([--with-ncurses], - [build text console UI programs using ncurses [default=yes]] - )], - [], - [with_ncurses=yes] -) -AM_CONDITIONAL([WITH_NCURSES], [test "x$with_ncurses" = "xyes"]) - -AS_IF( - [test "x$with_ncurses" = "xyes"], - AC_CHECK_LIB([ncurses], [initscr], - [], - [AC_MSG_FAILURE([--with-ncurses was given but the test for libncurses failed. Try installing the package ncurses-dev or ncurses-devel.])] - ) -) - AC_ARG_WITH( [twin-x11], [AS_HELP_STRING([--with-twin-x11], diff --git a/ui/ncurses/Makefile.am b/ui/ncurses/Makefile.am index 6d360d2..64b6eb1 100644 --- a/ui/ncurses/Makefile.am +++ b/ui/ncurses/Makefile.am @@ -20,12 +20,11 @@ AM_CPPFLAGS = \ AM_CFLAGS = \ $(DEFAULT_CFLAGS) -AM_LDFLAGS = -lmenu -lform -lncurses - common_libs = \ libpbnc.la \ $(top_builddir)/ui/common/libpbui.la \ - $(top_builddir)/lib/libpbcore.la + $(top_builddir)/lib/libpbcore.la \ + @MENU_LIB@ @FORM_LIB@ @CURSES_LIB@ noinst_LTLIBRARIES = libpbnc.la diff --git a/ui/ncurses/generic-main.c b/ui/ncurses/generic-main.c index 6280a34..cafd23a 100644 --- a/ui/ncurses/generic-main.c +++ b/ui/ncurses/generic-main.c @@ -18,11 +18,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#if defined(HAVE_CONFIG_H) #include "config.h" -#endif #define _GNU_SOURCE + +#include #include #include #include diff --git a/ui/ncurses/nc-boot-editor.c b/ui/ncurses/nc-boot-editor.c index 4579b1a..0b658f2 100644 --- a/ui/ncurses/nc-boot-editor.c +++ b/ui/ncurses/nc-boot-editor.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" + #define _GNU_SOURCE #include diff --git a/ui/ncurses/nc-boot-editor.h b/ui/ncurses/nc-boot-editor.h index bdcc560..a509f75 100644 --- a/ui/ncurses/nc-boot-editor.h +++ b/ui/ncurses/nc-boot-editor.h @@ -19,9 +19,16 @@ #if !defined(_PB_NC_KED_H) #define _PB_NC_KED_H -#include #include /* This must be included before ncurses.h */ -#include +#if defined HAVE_NCURSESW_FORM_H +# include +#elif defined HAVE_NCURSES_FORM_H +# include +#elif defined HAVE_FORM_H +# include +#else +# error "Curses form.h not found." +#endif #include "types/types.h" #include "ui/common/ui-system.h" diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index 3f82f85..4baaec1 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" + #define _GNU_SOURCE #include diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c index 0612d8a..e28168e 100644 --- a/ui/ncurses/nc-menu.c +++ b/ui/ncurses/nc-menu.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" + #define _GNU_SOURCE #include diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h index 750bef5..f010835 100644 --- a/ui/ncurses/nc-menu.h +++ b/ui/ncurses/nc-menu.h @@ -19,9 +19,16 @@ #if !defined(_PB_NC_MENU_H) #define _PB_NC_MENU_H -#include #include /* This must be included before ncurses.h */ -#include +#if defined HAVE_NCURSESW_MENU_H +# include +#elif defined HAVE_NCURSES_MENU_H +# include +#elif defined HAVE_MENU_H +# include +#else +# error "Curses menu.h not found." +#endif #include "log/log.h" #include "types/types.h" diff --git a/ui/ncurses/nc-scr.c b/ui/ncurses/nc-scr.c index 062d34a..d2455d4 100644 --- a/ui/ncurses/nc-scr.c +++ b/ui/ncurses/nc-scr.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" + +#define _GNU_SOURCE + #include #include diff --git a/ui/ncurses/nc-scr.h b/ui/ncurses/nc-scr.h index f18753a..a8aa314 100644 --- a/ui/ncurses/nc-scr.h +++ b/ui/ncurses/nc-scr.h @@ -20,7 +20,19 @@ #define _PB_NC_SCR_H #include /* This must be included before ncurses.h */ -#include +#if defined HAVE_NCURSESW_CURSES_H +# include +#elif defined HAVE_NCURSESW_H +# include +#elif defined HAVE_NCURSES_CURSES_H +# include +#elif defined HAVE_NCURSES_H +# include +#elif defined HAVE_CURSES_H +# include +#else +# error "Curses header file not found." +#endif #ifdef DEBUG #define DBG(fmt, args...) pb_log("DBG: " fmt, ## args) diff --git a/ui/ncurses/ps3-main.c b/ui/ncurses/ps3-main.c index 5735055..5be8c32 100644 --- a/ui/ncurses/ps3-main.c +++ b/ui/ncurses/ps3-main.c @@ -24,11 +24,11 @@ * ncurses mouse support */ -#if defined(HAVE_CONFIG_H) #include "config.h" -#endif #define _GNU_SOURCE + +#include #include #include #include -- 2.39.2