1 dnl***************************************************************************
2 dnl Copyright 2018-2019,2020 Thomas E. Dickey *
3 dnl Copyright 1998-2017,2018 Free Software Foundation, Inc. *
5 dnl Permission is hereby granted, free of charge, to any person obtaining a *
6 dnl copy of this software and associated documentation files (the *
7 dnl "Software"), to deal in the Software without restriction, including *
8 dnl without limitation the rights to use, copy, modify, merge, publish, *
9 dnl distribute, distribute with modifications, sublicense, and/or sell *
10 dnl copies of the Software, and to permit persons to whom the Software is *
11 dnl furnished to do so, subject to the following conditions: *
13 dnl The above copyright notice and this permission notice shall be included *
14 dnl in all copies or substantial portions of the Software. *
16 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 dnl Except as contained in this notice, the name(s) of the above copyright *
25 dnl holders shall not be used in advertising or otherwise to promote the *
26 dnl sale, use or other dealings in this Software without prior written *
28 dnl***************************************************************************
30 dnl Author: Thomas E. Dickey 1996-on
32 dnl $Id: configure.in,v 1.157 2020/02/02 23:34:34 tom Exp $
33 dnl This is a simple configuration-script for the ncurses test programs that
34 dnl allows the test-directory to be separately configured against a reference
35 dnl system (i.e., sysvr4 curses)
37 dnl If you're configuring ncurses, you shouldn't need to use this script.
38 dnl It's only for testing purposes.
40 dnl For additional information, see
41 dnl https://invisible-island.net/autoconf/
42 dnl https://invisible-island.net/autoconf/my-autoconf.html
43 dnl https://invisible-island.net/ncurses/ncurses-examples.html
44 dnl ---------------------------------------------------------------------------
45 AC_PREREQ(2.52.20200111)
47 AC_CONFIG_HEADER(ncurses_cfg.h:ncurses_tst.hin)
49 CF_INHERIT_SCRIPT(config.guess)
50 CF_INHERIT_SCRIPT(config.sub)
55 CF_HELP_MESSAGE(General Options:)
67 CF_MATH_LIB(MATH_LIB,pow(sin(x),x))
70 dnl Things that we don't need (or must override) if we're not building ncurses
72 CC_G_OPT="-g" AC_SUBST(CC_G_OPT)
73 CC_SHARED_OPTS=unknown AC_SUBST(CC_SHARED_OPTS)
74 CPPFLAGS="$CPPFLAGS" AC_SUBST(CPPFLAGS)
75 DFT_DEP_SUFFIX="" AC_SUBST(DFT_DEP_SUFFIX)
76 DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'` AC_SUBST(DFT_OBJ_SUBDIR)
77 DFT_UPR_MODEL="NORMAL" AC_SUBST(DFT_UPR_MODEL)
79 LDFLAGS_SHARED="" AC_SUBST(LDFLAGS_SHARED)
80 LDFLAGS_STATIC="" AC_SUBST(LDFLAGS_STATIC)
81 LD_MODEL="" AC_SUBST(LD_MODEL)
82 LD_SHARED_OPTS="" AC_SUBST(LD_SHARED_OPTS)
83 LIBTOOL="" AC_SUBST(LIBTOOL)
84 LIBTOOL_OPTS="" AC_SUBST(LIBTOOL_OPTS)
85 LIB_CLEAN="" AC_SUBST(LIB_CLEAN)
86 LIB_COMPILE="" AC_SUBST(LIB_COMPILE)
87 LIB_LINK='${CC}' AC_SUBST(LIB_LINK)
88 LINK_TESTS="" AC_SUBST(LINK_TESTS)
89 LOCAL_LDFLAGS="" AC_SUBST(LOCAL_LDFLAGS)
90 PACKAGE="ncurses-examples" AC_SUBST(PACKAGE)
91 PTHREAD="-lm" AC_SUBST(PTHREAD)
92 TEST_ARGS="" AC_SUBST(TEST_ARGS)
93 TEST_DEPS="" AC_SUBST(TEST_DEPS)
94 TEST_LIBS="" AC_SUBST(TEST_LIBS)
95 TINFO_LDFLAGS='' AC_SUBST(TINFO_LDFLAGS)
96 TINFO_LIBS='$(LIBS_CURSES)' AC_SUBST(TINFO_LIBS)
97 cf_cv_abi_version="" AC_SUBST(cf_cv_abi_version)
98 cf_cv_rel_version="" AC_SUBST(cf_cv_rel_version)
99 includesubdir="" AC_SUBST(includesubdir)
108 CF_ENABLE_STRING_HACKS
112 # Work around breakage on OS X
115 # Checks for CODESET support.
118 dnl ---------------------------------------------------------------------------
122 dnl ---------------------------------------------------------------------------
123 CF_HELP_MESSAGE(Curses Version-dependent Options:)
124 CF_NCURSES_WRAP_PREFIX
126 AC_MSG_CHECKING(if you want to check for wide-character functions)
127 CF_ARG_DISABLE(widec,
128 [ --disable-widec disable checks for wide-character functions],
132 AC_MSG_RESULT($cf_enable_widec)
134 dnl ---------------------------------------------------------------------------
135 CF_HELP_MESSAGE(Curses Version-dependent Options:)
138 case $cf_cv_screen in
140 cf_cv_libtype=`echo "$cf_cv_screen" | sed -e 's/^ncurses//'`
146 dnl If we've not specified a library, assume we're using sysvr4 libraries
147 dnl installed conventionally (e.g., SunOS 5.x - solaris).
149 dnl Autoconf builds up the $LIBS in reverse order
153 case $cf_cv_screen in
171 case $cf_cv_screen in
173 cf_curses_headers="nc_alloc.h nomacros.h term_entry.h"
179 AC_MSG_CHECKING(if you want to check for panel functions)
180 CF_ARG_DISABLE(panel,
181 [ --disable-panel disable checks for panel functions],
183 cf_enable_panel=$cf_default_panel,
185 AC_MSG_RESULT($cf_enable_panel)
186 if test $cf_enable_panel = yes
188 CF_CHECK_CURSES_LIB(panel,$cf_cv_libtype,new_panel,0)
189 cf_curses_headers="$cf_curses_headers panel.h"
192 AC_MSG_CHECKING(if you want to check for menu functions)
194 [ --disable-menu disable checks for menu functions],
196 cf_enable_menu=$cf_default_menu,
198 AC_MSG_RESULT($cf_enable_menu)
199 if test $cf_enable_menu = yes
201 case $cf_cv_screen in
208 CF_CHECK_CURSES_LIB(menu,$cf_cv_libtype,menu_driver,[0,0])
209 cf_curses_headers="$cf_curses_headers menu.h"
212 AC_MSG_CHECKING(if you want to check for form functions)
214 [ --disable-form disable checks for form functions],
216 cf_enable_form=$cf_default_form,
218 AC_MSG_RESULT($cf_enable_form)
219 if test $cf_enable_form = yes
221 case $cf_cv_screen in
228 CF_CHECK_CURSES_LIB(form,$cf_cv_libtype,form_driver,[0,0])
229 cf_curses_headers="$cf_curses_headers form.h"
232 # look for curses-related headers
233 AC_CHECK_HEADERS( $cf_curses_headers )
259 # use a compile-check to work with ncurses*-config and subdirectory includes
260 AC_CACHE_CHECK(if we can use termcap.h,cf_cv_have_termcap_h,[
263 #ifdef NCURSES_VERSION
264 #undef NCURSES_VERSION
267 #ifndef NCURSES_VERSION
272 [cf_cv_have_termcap_h=yes],
273 [cf_cv_have_termcap_h=no])])
274 if test "x$cf_cv_have_termcap_h" = xyes
276 AC_DEFINE(HAVE_TERMCAP_H,1,[Define to 1 if we can use termcap.h])
278 AC_CACHE_CHECK(if we can use ncurses/termcap.h,cf_cv_have_ncurses_termcap_h,[
280 #include <ncurses/curses.h>
281 #ifdef NCURSES_VERSION
282 #undef NCURSES_VERSION
284 #include <ncurses/termcap.h>
285 #ifndef NCURSES_VERSION
290 [cf_cv_have_ncurses_termcap_h=yes],
291 [cf_cv_have_ncurses_termcap_h=no])])
292 test "x$cf_cv_have_ncurses_termcap_h" = xyes && AC_DEFINE(HAVE_NCURSES_TERMCAP_H,1,[Define to 1 if we can use ncurses/termcap.h])
295 if test "x$ac_cv_func_getopt" = xno; then
296 AC_MSG_ERROR(getopt is required for building programs)
299 if test "$cf_enable_widec" = yes; then
314 assume_default_colors \
329 init_extended_color \
372 if test "$cf_enable_widec" = yes
374 # workaround for systems with ncurses before 20111029, due to change of
375 # feature test macro from _XPG5 to _XOPEN_SOURCE
376 if test -n "$cf_cv_ncurses_version" && test "x$cf_cv_ncurses_version" != xno
379 AC_MSG_CHECKING(if _XPG5 should be defined to enable wide-characters)
382 #include <${cf_cv_ncurses_header:-curses.h}>],
384 [cf_save_cppflags="$CPPFLAGS"
385 CPPFLAGS="$CPPFLAGS -D_XPG5"
387 #include <${cf_cv_ncurses_header:-curses.h}>],
389 [cf_define_xpg5=yes])
390 CPPFLAGS="$cf_save_cppflags"])
391 AC_MSG_RESULT($cf_define_xpg5)
393 if test "$cf_define_xpg5" = yes
395 CPPFLAGS="$CPPFLAGS -D_XPG5"
399 AC_CACHE_CHECK(for wide-character functions,cf_cv_widechar_funcs,[
401 #include <${cf_cv_ncurses_header:-curses.h}>],
403 static wchar_t src_wchar[2];
404 static cchar_t dst_cchar;
405 setcchar(&dst_cchar, src_wchar, A_NORMAL, 0, (void *) 0);
407 [cf_cv_widechar_funcs=yes],
408 [cf_cv_widechar_funcs=no])
410 if test "$cf_cv_widechar_funcs" != no ; then
411 AC_DEFINE(USE_WIDEC_SUPPORT,1,[Define to 1 to enable wide-character support in (n)curses])
413 AC_DEFINE(USE_WIDEC_SUPPORT,0)
416 AC_DEFINE(USE_WIDEC_SUPPORT,0)
419 AC_CACHE_CHECK(if $cf_cv_screen library uses pthreads,cf_cv_use_pthreads,[
421 #include <${cf_cv_ncurses_header:-curses.h}>
422 extern void _nc_init_pthreads(void);
428 [cf_cv_use_pthreads=yes],
429 [cf_cv_use_pthreads=no])
431 test $cf_cv_use_pthreads = yes && AC_DEFINE(USE_PTHREADS,1,[Define to 1 if $cf_cv_screen library uses pthreads])
435 # special check for test/ditto.c
437 if test "$cf_cv_func_openpty" != no ; then
438 AC_DEFINE_UNQUOTED(USE_OPENPTY_HEADER,<$cf_cv_func_openpty>,[Define to actual header for openpty function])
439 AC_DEFINE(USE_XTERM_PTY,1,[Define to 1 if we should assume xterm pseudoterminal interface])
440 if test "x$cf_cv_lib_util" = xyes ; then
441 CF_ADD_LIB(util,TEST_LIBS)
445 CF_FUNC_CURSES_VERSION
448 if test "$cf_enable_widec" = yes; then
450 CF_CURSES_WACS_SYMBOLS
453 CF_CURSES_CHECK_TYPE(attr_t,long)
455 if test "$cf_enable_widec" = yes; then
456 CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T, NCURSES_OK_MBSTATE_T)
457 CF_WCHAR_TYPE(wchar_t, NCURSES_WCHAR_T, NCURSES_OK_WCHAR_T)
458 CF_WCHAR_TYPE(wint_t, NCURSES_WINT_T, NCURSES_OK_WINT_T)
460 if test "$NCURSES_OK_MBSTATE_T" = 0 ; then
461 CF_CURSES_CHECK_TYPE(mbstate_t,long)
464 if test "$NCURSES_OK_WCHAR_T" = 0 ; then
465 CF_CURSES_CHECK_TYPE(wchar_t,long)
468 if test "$NCURSES_OK_WINT_T" = 0 ; then
469 CF_CURSES_CHECK_TYPE(wint_t,long)
473 CF_CURSES_CHECK_DATA(\
481 dnl ---------------------------------------------------------------------------
482 CF_HELP_MESSAGE(Testing/development Options:)
483 CF_ENABLE_WARNINGS(Wno-unknown-pragmas)
485 CF_DISABLE_RPATH_HACK
490 dnl ---------------------------------------------------------------------------
493 CF_PRG_RULES([$srcdir/mk-test.awk INSTALL=yes ECHO_LINK="$ECHO_LD"], .)
494 cat >>Makefile <<TEST_EOF
496 # These rules are generated so we do not rely on suffix rules, which do not
497 # work consistently for different make-programs (the '\$(MODEL)/' confuses
498 # some, and the '\$x' confuses others).
501 LIST=`sed -e 's/[[ ]].*//' -e '/^[[#@]]/d' $srcdir/modules`
504 cat >>Makefile <<TEST_EOF
506 \$(MODEL)/$N.o : \$(srcdir)/$N.c \\
507 \$(srcdir)/test.priv.h \\
510 $ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) -DMODULE_NAME="$N" \$(srcdir)/$N.c
514 if test -f ../config.guess && test -f ../config.sub
516 cat >>Makefile <<TEST_EOF
518 # if we used CF_INHERIT for getting these files, we can remove them
520 rm -f config.guess config.sub