1 dnl***************************************************************************
2 dnl Copyright 2018-2021,2022 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.166 2022/08/20 16:35:33 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.20210509)
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:)
68 CF_MATH_LIB(MATH_LIB,pow(sin(x),x))
71 dnl Things that we don't need (or must override) if we're not building ncurses
73 CC_G_OPT="-g" AC_SUBST(CC_G_OPT)
74 CC_SHARED_OPTS=unknown AC_SUBST(CC_SHARED_OPTS)
75 CPPFLAGS="$CPPFLAGS" AC_SUBST(CPPFLAGS)
76 DFT_DEP_SUFFIX="" AC_SUBST(DFT_DEP_SUFFIX)
77 DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'` AC_SUBST(DFT_OBJ_SUBDIR)
78 DFT_UPR_MODEL="NORMAL" AC_SUBST(DFT_UPR_MODEL)
80 LDFLAGS_SHARED="" AC_SUBST(LDFLAGS_SHARED)
81 LDFLAGS_STATIC="" AC_SUBST(LDFLAGS_STATIC)
82 LD_MODEL="" AC_SUBST(LD_MODEL)
83 LD_SHARED_OPTS="" AC_SUBST(LD_SHARED_OPTS)
84 LIBTOOL="" AC_SUBST(LIBTOOL)
85 LIBTOOL_OPTS="" AC_SUBST(LIBTOOL_OPTS)
86 LIB_CLEAN="" AC_SUBST(LIB_CLEAN)
87 LIB_COMPILE="" AC_SUBST(LIB_COMPILE)
88 LIB_LINK='${CC}' AC_SUBST(LIB_LINK)
89 LINK_TESTS="" AC_SUBST(LINK_TESTS)
90 LOCAL_LDFLAGS="" AC_SUBST(LOCAL_LDFLAGS)
91 PACKAGE="ncurses-examples" AC_SUBST(PACKAGE)
92 PTHREAD="-lm" AC_SUBST(PTHREAD)
93 TEST_ARGS="" AC_SUBST(TEST_ARGS)
94 TEST_DEPS="" AC_SUBST(TEST_DEPS)
95 TEST_LIBS="" AC_SUBST(TEST_LIBS)
96 TINFO_LDFLAGS='' AC_SUBST(TINFO_LDFLAGS)
97 TINFO_LIBS='$(LIBS_CURSES)' AC_SUBST(TINFO_LIBS)
98 cf_cv_abi_version="" AC_SUBST(cf_cv_abi_version)
99 cf_cv_rel_version="" AC_SUBST(cf_cv_rel_version)
100 includesubdir="" AC_SUBST(includesubdir)
109 CF_ENABLE_STRING_HACKS
113 # Work around breakage on OS X
116 # Checks for CODESET support.
119 dnl ---------------------------------------------------------------------------
123 dnl ---------------------------------------------------------------------------
124 CF_HELP_MESSAGE(Curses Version-dependent Options:)
125 CF_NCURSES_WRAP_PREFIX
127 AC_MSG_CHECKING(if you want to check for wide-character functions)
128 CF_ARG_DISABLE(widec,
129 [ --disable-widec disable checks for wide-character functions],
133 AC_MSG_RESULT($cf_enable_widec)
135 dnl ---------------------------------------------------------------------------
136 CF_HELP_MESSAGE(Curses Version-dependent Options:)
139 case $cf_cv_screen in
141 cf_cv_libtype=`echo "$cf_cv_screen" | sed -e 's/^ncurses//'`
147 dnl If we've not specified a library, assume we're using sysvr4 libraries
148 dnl installed conventionally (e.g., SunOS 5.x - solaris).
150 dnl Autoconf builds up the $LIBS in reverse order
154 case $cf_cv_screen in
172 case $cf_cv_screen in
174 cf_curses_headers="nc_alloc.h nomacros.h term_entry.h"
180 CF_WITH_LIB_BASENAME(FORM_NAME,form)
181 CF_WITH_LIB_BASENAME(MENU_NAME,menu)
182 CF_WITH_LIB_BASENAME(PANEL_NAME,panel)
184 AC_MSG_CHECKING(if you want to check for panel functions)
185 CF_ARG_DISABLE(panel,
186 [ --disable-panel disable checks for panel functions],
188 cf_enable_panel=$cf_default_panel,
190 AC_MSG_RESULT($cf_enable_panel)
191 if test $cf_enable_panel = yes
193 CF_CHECK_CURSES_LIB($PANEL_NAME,$cf_cv_libtype,new_panel,0)
194 cf_curses_headers="$cf_curses_headers panel.h"
197 AC_MSG_CHECKING(if you want to check for menu functions)
199 [ --disable-menu disable checks for menu functions],
201 cf_enable_menu=$cf_default_menu,
203 AC_MSG_RESULT($cf_enable_menu)
204 if test $cf_enable_menu = yes
206 case $cf_cv_screen in
213 CF_CHECK_CURSES_LIB($MENU_NAME,$cf_cv_libtype,menu_driver,[0,0])
214 cf_curses_headers="$cf_curses_headers menu.h"
217 AC_MSG_CHECKING(if you want to check for form functions)
219 [ --disable-form disable checks for form functions],
221 cf_enable_form=$cf_default_form,
223 AC_MSG_RESULT($cf_enable_form)
224 if test $cf_enable_form = yes
226 case $cf_cv_screen in
233 CF_CHECK_CURSES_LIB($FORM_NAME,$cf_cv_libtype,form_driver,[0,0])
234 cf_curses_headers="$cf_curses_headers form.h"
237 # look for curses-related headers
238 AC_CHECK_HEADERS( $cf_curses_headers )
267 # use a compile-check to work with ncurses*-config and subdirectory includes
268 AC_CACHE_CHECK(if we can use termcap.h,cf_cv_have_termcap_h,[
271 #ifdef NCURSES_VERSION
272 #undef NCURSES_VERSION
275 #ifndef NCURSES_VERSION
280 [cf_cv_have_termcap_h=yes],
281 [cf_cv_have_termcap_h=no])])
282 if test "x$cf_cv_have_termcap_h" = xyes
284 AC_DEFINE(HAVE_TERMCAP_H,1,[Define to 1 if we can use termcap.h])
286 AC_CACHE_CHECK(if we can use ncurses/termcap.h,cf_cv_have_ncurses_termcap_h,[
288 #include <ncurses/curses.h>
289 #ifdef NCURSES_VERSION
290 #undef NCURSES_VERSION
292 #include <ncurses/termcap.h>
293 #ifndef NCURSES_VERSION
298 [cf_cv_have_ncurses_termcap_h=yes],
299 [cf_cv_have_ncurses_termcap_h=no])])
300 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])
303 if test "x$ac_cv_func_getopt" = xno; then
304 AC_MSG_ERROR(getopt is required for building programs)
307 if test "$cf_enable_widec" = yes; then
322 assume_default_colors \
340 init_extended_color \
385 if test "$cf_enable_widec" = yes
387 # workaround for systems with ncurses before 20111029, due to change of
388 # feature test macro from _XPG5 to _XOPEN_SOURCE
389 if test -n "$cf_cv_ncurses_version" && test "x$cf_cv_ncurses_version" != xno
392 AC_MSG_CHECKING(if _XPG5 should be defined to enable wide-characters)
395 #include <${cf_cv_ncurses_header:-curses.h}>],
397 [cf_save_cppflags="$CPPFLAGS"
398 CPPFLAGS="$CPPFLAGS -D_XPG5"
400 #include <${cf_cv_ncurses_header:-curses.h}>],
402 [cf_define_xpg5=yes])
403 CPPFLAGS="$cf_save_cppflags"])
404 AC_MSG_RESULT($cf_define_xpg5)
406 if test "$cf_define_xpg5" = yes
408 CPPFLAGS="$CPPFLAGS -D_XPG5"
412 AC_CACHE_CHECK(for wide-character functions,cf_cv_widechar_funcs,[
414 #include <${cf_cv_ncurses_header:-curses.h}>],
416 static wchar_t src_wchar[2];
417 static cchar_t dst_cchar;
418 setcchar(&dst_cchar, src_wchar, A_NORMAL, 0, (void *) 0);
420 [cf_cv_widechar_funcs=yes],
421 [cf_cv_widechar_funcs=no])
423 if test "$cf_cv_widechar_funcs" != no ; then
424 AC_DEFINE(USE_WIDEC_SUPPORT,1,[Define to 1 to enable wide-character support in (n)curses])
426 AC_DEFINE(USE_WIDEC_SUPPORT,0)
429 AC_DEFINE(USE_WIDEC_SUPPORT,0)
432 AC_CACHE_CHECK(if $cf_cv_screen library uses pthreads,cf_cv_use_pthreads,[
434 #include <${cf_cv_ncurses_header:-curses.h}>
435 extern void _nc_init_pthreads(void);
441 [cf_cv_use_pthreads=yes],
442 [cf_cv_use_pthreads=no])
444 test $cf_cv_use_pthreads = yes && AC_DEFINE(USE_PTHREADS,1,[Define to 1 if $cf_cv_screen library uses pthreads])
448 # special check for test/ditto.c
450 if test "$cf_cv_func_openpty" != no ; then
451 AC_DEFINE_UNQUOTED(USE_OPENPTY_HEADER,<$cf_cv_func_openpty>,[Define to actual header for openpty function])
452 AC_DEFINE(USE_XTERM_PTY,1,[Define to 1 if we should assume xterm pseudoterminal interface])
453 if test "x$cf_cv_lib_util" = xyes ; then
454 CF_ADD_LIB(util,TEST_LIBS)
458 CF_FUNC_CURSES_VERSION
461 if test "$cf_enable_widec" = yes; then
463 CF_CURSES_WACS_SYMBOLS
466 CF_CURSES_CHECK_TYPE(attr_t,long)
468 if test "$cf_enable_widec" = yes; then
469 CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T, NCURSES_OK_MBSTATE_T)
470 CF_WCHAR_TYPE(wchar_t, NCURSES_WCHAR_T, NCURSES_OK_WCHAR_T)
471 CF_WCHAR_TYPE(wint_t, NCURSES_WINT_T, NCURSES_OK_WINT_T)
473 if test "$NCURSES_OK_MBSTATE_T" = 0 ; then
474 CF_CURSES_CHECK_TYPE(mbstate_t,long)
477 if test "$NCURSES_OK_WCHAR_T" = 0 ; then
478 CF_CURSES_CHECK_TYPE(wchar_t,long)
481 if test "$NCURSES_OK_WINT_T" = 0 ; then
482 CF_CURSES_CHECK_TYPE(wint_t,long)
486 CF_CURSES_CHECK_DATA(\
494 dnl ---------------------------------------------------------------------------
495 CF_HELP_MESSAGE(Testing/development Options:)
496 CF_WITH_SCREEN_PDCURSES
497 CF_ENABLE_WARNINGS(Wno-unknown-pragmas)
499 CF_DISABLE_RPATH_HACK
504 dnl ---------------------------------------------------------------------------
507 CF_PRG_RULES([$srcdir/mk-test.awk INSTALL=yes ECHO_LINK="$ECHO_LD"], .)
508 cat >>Makefile <<TEST_EOF
510 # These rules are generated so we do not rely on suffix rules, which do not
511 # work consistently for different make-programs (the '\$(MODEL)/' confuses
512 # some, and the '\$x' confuses others).
515 LIST=`sed -e 's/[[ ]].*//' -e '/^[[#@]]/d' $srcdir/modules`
518 cat >>Makefile <<TEST_EOF
520 \$(MODEL)/$N.o : \$(srcdir)/$N.c \\
521 \$(srcdir)/test.priv.h \\
524 $ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) -DMODULE_NAME="$N" \$(srcdir)/$N.c
528 if test -f ../config.guess && test -f ../config.sub
530 cat >>Makefile <<TEST_EOF
532 # if we used CF_INHERIT for getting these files, we can remove them
534 rm -f config.guess config.sub