libchewing icon indicating copy to clipboard operation
libchewing copied to clipboard

Update m4/ax_pthread.m4 and m4/ax_with_curses.m4 (to fix build failure with ncurses built with --with-termlib option)

Open Arfrever opened this issue 6 years ago • 0 comments

m4/ax_pthread.m4 and m4/ax_with_curses.m4 files need to be updated to newest versions from autoconf-archive project: https://www.gnu.org/software/autoconf-archive/ (autoconf-archive-2019.01.06 is newest as of now.)

Updating of m4/ax_with_curses.m4 file is necessary to fix build failure with ncurses built with --with-termlib option.

Build failure looks in this way:

checking for NcursesW wide-character library... yes
checking for working ncursesw/curses.h... no
checking for working ncursesw.h... no
checking for working ncurses.h... no
configure: WARNING: could not find a working ncursesw/curses.h, ncursesw.h or ncurses.h
...
x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../include  -I../include -I../include/internal -I../src/porting_layer/include -I../test/ -I../thirdparty/sqlite-amalgamation -DCHEWING_DATA_PREFIX="\"/var/tmp/portage/app-i18n/libchewing-9999/work/libchewing-9999/data\"" -DTEST_HASH_DIR="\"/var/tmp/portage/app-i18n/libchewing-9999/work/libchewing-9999/test\"" -DTEST_DATA_DIR="\"/var/tmp/portage/app-i18n/libchewing-9999/work/libchewing-9999/test/data\"" -D_GNU_SOURCE    -Wall -march=native -O2 -pipe -fvisibility=hidden -march=native -O2 -pipe -c -o genkeystroke.o genkeystroke.c
genkeystroke.c:34:6: error: #error "SysV or X/Open-compatible Curses header file required"
 #    error "SysV or X/Open-compatible Curses header file required"
      ^~~~~
...

Difference between current version of m4/ax_with_curses.m4 file in libchewing and newest ax_with_curses.m4 file from autoconf-archive-2019.01.06 includes this part:

@@ -52,23 +54,29 @@
 #
 #   (These preprocessor symbols are discussed later in this document.)
 #
-#   The following output variable is defined by this macro; it is precious
-#   and may be overridden on the ./configure command line:
+#   The following output variables are defined by this macro; they are
+#   precious and may be overridden on the ./configure command line:
 #
-#     CURSES_LIB  - library to add to xxx_LDADD
+#     CURSES_LIBS  - library to add to xxx_LDADD
+#     CURSES_CFLAGS  - include paths to add to xxx_CPPFLAGS
 #
-#   The library listed in CURSES_LIB is NOT added to LIBS by default. You
-#   need to add CURSES_LIB to the appropriate xxx_LDADD line in your
-#   Makefile.am.  For example:
-#
-#     prog_LDADD = @CURSES_LIB@
-#
-#   If CURSES_LIB is set on the configure command line (such as by running
-#   "./configure CURSES_LIB=-lmycurses"), then the only header searched for
-#   is <curses.h>.  The user may use the CPPFLAGS precious variable to
-#   override the standard #include search path.  If the user needs to
-#   specify an alternative path for a library (such as for a non-standard
-#   NcurseW), the user should use the LDFLAGS variable.
+#   In previous versions of this macro, the flags CURSES_LIB and
+#   CURSES_CPPFLAGS were defined. These have been renamed, in keeping with
+#   AX_WITH_CURSES's close bigger brother, PKG_CHECK_MODULES, which should
+#   eventually supersede the use of AX_WITH_CURSES. Neither the library
+#   listed in CURSES_LIBS, nor the flags in CURSES_CFLAGS are added to LIBS,
+#   respectively CPPFLAGS, by default. You need to add both to the
+#   appropriate xxx_LDADD/xxx_CPPFLAGS line in your Makefile.am. For
+#   example:
+#
+#     prog_LDADD = @CURSES_LIBS@
+#     prog_CPPFLAGS = @CURSES_CFLAGS@
+#
+#   If CURSES_LIBS is set on the configure command line (such as by running
+#   "./configure CURSES_LIBS=-lmycurses"), then the only header searched for
+#   is <curses.h>. If the user needs to specify an alternative path for a
+#   library (such as for a non-standard NcurseW), the user should use the
+#   LDFLAGS variable.
 #
 #   The following shell variables may be defined by this macro:
 #
...
 
 AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
 AC_DEFUN([AX_WITH_CURSES], [
-    AC_ARG_VAR([CURSES_LIB], [linker library for Curses, e.g. -lcurses])
+    AC_ARG_VAR([CURSES_LIBS], [linker library for Curses, e.g. -lcurses])
+    AC_ARG_VAR([CURSES_CFLAGS], [preprocessor flags for Curses, e.g. -I/usr/include/ncursesw])
     AC_ARG_WITH([ncurses], [AS_HELP_STRING([--with-ncurses],
         [force the use of Ncurses or NcursesW])],
         [], [with_ncurses=check])

This means that after updating m4/ax_with_curses.m4 file it is necessary to make this change:

--- test/Makefile.am
+++ test/Makefile.am
@@ -65,7 +65,8 @@ check_PROGRAMS = \
 if ENABLE_TEXT_UI
 TEXT_UI_BIN=genkeystroke
 genkeystroke_SOURCES = genkeystroke.c
-genkeystroke_LDADD = $(LDADD) @CURSES_LIB@
+genkeystroke_CPPFLAGS = $(AM_CPPFLAGS) @CURSES_CFLAGS@
+genkeystroke_LDADD = $(LDADD) @CURSES_LIBS@
 else
 TEXT_UI_BIN=
 endif

Arfrever avatar Jul 21 '19 23:07 Arfrever