1dnl*************************************************************************** 2dnl Copyright 2018-2023,2024 Thomas E. Dickey * 3dnl Copyright 1998-2017,2018 Free Software Foundation, Inc. * 4dnl * 5dnl Permission is hereby granted, free of charge, to any person obtaining a * 6dnl copy of this software and associated documentation files (the * 7dnl "Software"), to deal in the Software without restriction, including * 8dnl without limitation the rights to use, copy, modify, merge, publish, * 9dnl distribute, distribute with modifications, sublicense, and/or sell * 10dnl copies of the Software, and to permit persons to whom the Software is * 11dnl furnished to do so, subject to the following conditions: * 12dnl * 13dnl The above copyright notice and this permission notice shall be included * 14dnl in all copies or substantial portions of the Software. * 15dnl * 16dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 17dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 18dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 19dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 20dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 21dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 22dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 23dnl * 24dnl Except as contained in this notice, the name(s) of the above copyright * 25dnl holders shall not be used in advertising or otherwise to promote the * 26dnl sale, use or other dealings in this Software without prior written * 27dnl authorization. * 28dnl*************************************************************************** 29dnl 30dnl Author: Thomas E. Dickey 1996-on 31dnl 32dnl $Id: configure.in,v 1.174 2024/03/30 14:31:11 tom Exp $ 33dnl This is a simple configuration-script for the ncurses test programs that 34dnl allows the test-directory to be separately configured against a reference 35dnl system (i.e., sysvr4 curses) 36dnl 37dnl If you're configuring ncurses, you shouldn't need to use this script. 38dnl It's only for testing purposes. 39dnl 40dnl For additional information, see 41dnl https://invisible-island.net/autoconf/ 42dnl https://invisible-island.net/autoconf/my-autoconf.html 43dnl https://invisible-island.net/ncurses/ncurses-examples.html 44dnl --------------------------------------------------------------------------- 45AC_PREREQ(2.52.20210509) 46AC_INIT(ncurses.c) 47AC_CONFIG_HEADER(ncurses_cfg.h:ncurses_tst.hin) 48 49CF_INHERIT_SCRIPT(config.guess) 50CF_INHERIT_SCRIPT(config.sub) 51CF_CHECK_CACHE 52 53AC_ARG_PROGRAM 54 55CF_HELP_MESSAGE(General Options:) 56 57AC_PROG_MAKE_SET 58CF_PROG_CC 59AC_C_INLINE 60AC_PROG_CPP 61AC_PROG_AWK 62CF_PROG_INSTALL 63CF_INSTALL_OPTS 64CF_PROG_LINT 65CF_MAKE_PHONY 66CF_MAKE_TAGS 67 68CF_MATH_LIB(MATH_LIB,pow(sin(x),x)) 69AC_SUBST(MATH_LIB) 70 71dnl Things that we don't need (or must override) if we're not building ncurses 72CF_TOP_BUILDDIR 73CC_G_OPT="-g" AC_SUBST(CC_G_OPT) 74CC_SHARED_OPTS=unknown AC_SUBST(CC_SHARED_OPTS) 75CPPFLAGS="$CPPFLAGS" AC_SUBST(CPPFLAGS) 76DFT_DEP_SUFFIX="" AC_SUBST(DFT_DEP_SUFFIX) 77DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'` AC_SUBST(DFT_OBJ_SUBDIR) 78DFT_UPR_MODEL="NORMAL" AC_SUBST(DFT_UPR_MODEL) 79LD="ld" AC_SUBST(LD) 80LDFLAGS_SHARED="" AC_SUBST(LDFLAGS_SHARED) 81LDFLAGS_STATIC="" AC_SUBST(LDFLAGS_STATIC) 82LD_MODEL="" AC_SUBST(LD_MODEL) 83LD_SHARED_OPTS="" AC_SUBST(LD_SHARED_OPTS) 84LIBTOOL="" AC_SUBST(LIBTOOL) 85LIBTOOL_OPTS="" AC_SUBST(LIBTOOL_OPTS) 86LIB_CLEAN="" AC_SUBST(LIB_CLEAN) 87LIB_COMPILE="" AC_SUBST(LIB_COMPILE) 88LIB_LINK='${CC}' AC_SUBST(LIB_LINK) 89LINK_TESTS="" AC_SUBST(LINK_TESTS) 90LOCAL_LDFLAGS="" AC_SUBST(LOCAL_LDFLAGS) 91PACKAGE="ncurses-examples" AC_SUBST(PACKAGE) 92PTHREAD="-lm" AC_SUBST(PTHREAD) 93TEST_ARGS="" AC_SUBST(TEST_ARGS) 94TEST_DEPS="" AC_SUBST(TEST_DEPS) 95TEST_LIBS="" AC_SUBST(TEST_LIBS) 96TINFO_LDFLAGS='' AC_SUBST(TINFO_LDFLAGS) 97TINFO_LIBS='$(LIBS_CURSES)' AC_SUBST(TINFO_LIBS) 98cf_cv_abi_version="" AC_SUBST(cf_cv_abi_version) 99cf_cv_rel_version="" AC_SUBST(cf_cv_rel_version) 100includesubdir="" AC_SUBST(includesubdir) 101 102cf_cv_screen=curses 103cf_cv_libtype= 104 105AC_EXEEXT 106AC_OBJEXT 107 108CF_GCC_ATTRIBUTES 109CF_ENABLE_STRING_HACKS 110CF_XOPEN_SOURCE(600) 111AC_CHECK_DECL(exit) 112CF_SIG_ATOMIC_T 113 114# Work around breakage on OS X 115CF_SIGWINCH 116 117# Checks for CODESET support. 118AM_LANGINFO_CODESET 119 120dnl --------------------------------------------------------------------------- 121CF_PKG_CONFIG 122CF_DISABLE_ECHO 123 124dnl --------------------------------------------------------------------------- 125CF_HELP_MESSAGE(Curses Version-dependent Options:) 126CF_NCURSES_WRAP_PREFIX 127 128AC_MSG_CHECKING(if you want to check for wide-character functions) 129CF_ARG_DISABLE(widec, 130 [ --disable-widec disable checks for wide-character functions], 131 cf_enable_widec=no, 132 cf_enable_widec=yes, 133 yes) 134AC_MSG_RESULT($cf_enable_widec) 135 136dnl --------------------------------------------------------------------------- 137CF_HELP_MESSAGE(Curses Version-dependent Options:) 138CF_WITH_NCURSES_ETC 139 140case $cf_cv_screen in 141(ncurses*) 142 cf_cv_libtype=`echo "$cf_cv_screen" | sed -e 's/^ncurses//'` 143 ;; 144esac 145 146CF_WITH_X11_RGB 147 148dnl If we've not specified a library, assume we're using sysvr4 libraries 149dnl installed conventionally (e.g., SunOS 5.x - solaris). 150 151dnl Autoconf builds up the $LIBS in reverse order 152 153cf_curses_headers= 154 155case $cf_cv_screen in 156(pdcurses) 157 cf_default_panel=no 158 cf_default_form=no 159 cf_default_menu=no 160 cf_default_tinfo=no 161 ;; 162(xcurses|bsdcurses) 163 cf_default_panel=no 164 cf_default_form=no 165 cf_default_menu=no 166 cf_default_tinfo=yes 167 ;; 168(*) 169 cf_default_panel=yes 170 cf_default_form=yes 171 cf_default_menu=yes 172 cf_default_tinfo=yes 173 case $cf_cv_screen in 174 (ncurses*) 175 cf_curses_headers="nc_alloc.h nomacros.h term_entry.h" 176 ;; 177 esac 178 ;; 179esac 180 181CF_WITH_LIB_BASENAME(FORM_NAME,form) 182CF_WITH_LIB_BASENAME(MENU_NAME,menu) 183CF_WITH_LIB_BASENAME(PANEL_NAME,panel) 184 185AC_MSG_CHECKING(if you want to check for panel functions) 186CF_ARG_DISABLE(panel, 187 [ --disable-panel disable checks for panel functions], 188 cf_enable_panel=no, 189 cf_enable_panel=$cf_default_panel, 190 yes) 191AC_MSG_RESULT($cf_enable_panel) 192if test $cf_enable_panel = yes 193then 194 CF_CHECK_CURSES_LIB($PANEL_NAME,$cf_cv_libtype,new_panel,0) 195 cf_curses_headers="$cf_curses_headers panel.h" 196fi 197 198AC_MSG_CHECKING(if you want to check for menu functions) 199CF_ARG_DISABLE(menu, 200 [ --disable-menu disable checks for menu functions], 201 cf_enable_menu=no, 202 cf_enable_menu=$cf_default_menu, 203 yes) 204AC_MSG_RESULT($cf_enable_menu) 205if test $cf_enable_menu = yes 206then 207 case $cf_cv_screen in 208 (ncurses*) 209 ;; 210 (curses*) 211 CF_NETBSD_MENU_H 212 ;; 213 esac 214 CF_CHECK_CURSES_LIB($MENU_NAME,$cf_cv_libtype,menu_driver,[0,0]) 215 cf_curses_headers="$cf_curses_headers menu.h" 216fi 217 218AC_MSG_CHECKING(if you want to check for form functions) 219CF_ARG_DISABLE(form, 220 [ --disable-form disable checks for form functions], 221 cf_enable_form=no, 222 cf_enable_form=$cf_default_form, 223 yes) 224AC_MSG_RESULT($cf_enable_form) 225if test $cf_enable_form = yes 226then 227 case $cf_cv_screen in 228 (ncurses*) 229 ;; 230 (curses*) 231 CF_NETBSD_FORM_H 232 ;; 233 esac 234 CF_CHECK_CURSES_LIB($FORM_NAME,$cf_cv_libtype,form_driver,[0,0]) 235 cf_curses_headers="$cf_curses_headers form.h" 236fi 237 238# look for curses-related headers 239AC_CHECK_HEADERS( $cf_curses_headers ) 240 241AC_HEADER_TIME 242AC_CHECK_HEADERS( \ 243getopt.h \ 244locale.h \ 245math.h \ 246stdarg.h \ 247sys/ioctl.h \ 248sys/select.h \ 249sys/time.h \ 250termios.h \ 251unistd.h \ 252) 253 254CF_GETOPT_HEADER 255CF_FUNC_GETTIME 256 257AC_CHECK_FUNCS( \ 258getopt \ 259snprintf \ 260strdup \ 261strstr \ 262tsearch \ 263) 264 265# use a compile-check to work with ncurses*-config and subdirectory includes 266AC_CACHE_CHECK(if we can use termcap.h,cf_cv_have_termcap_h,[ 267 AC_TRY_COMPILE([ 268#include <curses.h> 269#ifdef NCURSES_VERSION 270#undef NCURSES_VERSION 271#endif 272#include <termcap.h> 273#ifndef NCURSES_VERSION 274#error wrong header 275#endif 276], 277 [return 0;], 278 [cf_cv_have_termcap_h=yes], 279 [cf_cv_have_termcap_h=no])]) 280if test "x$cf_cv_have_termcap_h" = xyes 281then 282 AC_DEFINE(HAVE_TERMCAP_H,1,[Define to 1 if we can use termcap.h]) 283else 284AC_CACHE_CHECK(if we can use ncurses/termcap.h,cf_cv_have_ncurses_termcap_h,[ 285 AC_TRY_COMPILE([ 286#include <ncurses/curses.h> 287#ifdef NCURSES_VERSION 288#undef NCURSES_VERSION 289#endif 290#include <ncurses/termcap.h> 291#ifndef NCURSES_VERSION 292#error wrong header 293#endif 294], 295 [return 0;], 296 [cf_cv_have_ncurses_termcap_h=yes], 297 [cf_cv_have_ncurses_termcap_h=no])]) 298test "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]) 299fi 300 301if test "x$ac_cv_func_getopt" = xno; then 302 AC_MSG_ERROR(getopt is required for building programs) 303fi 304 305if test "$cf_enable_widec" = yes; then 306AC_CHECK_FUNCS( \ 307mblen \ 308mbrlen \ 309mbrtowc \ 310mbsrtowcs \ 311mbstowcs \ 312mbtowc \ 313wcsrtombs \ 314wcstombs \ 315) 316fi 317 318CF_CURSES_FUNCS( \ 319_nc_tparm_analyze \ 320_tracef \ 321alloc_pair \ 322assume_default_colors \ 323chgat \ 324color_content \ 325color_set \ 326copywin \ 327curses_trace \ 328delscreen \ 329dupwin \ 330exit_curses \ 331exit_terminfo \ 332filter \ 333getbegx \ 334getcurx \ 335getmaxx \ 336getnstr \ 337getparx \ 338getwin \ 339halfdelay \ 340init_extended_color \ 341mvderwin \ 342mvvline \ 343mvwin \ 344mvwvline \ 345napms \ 346newpad \ 347putwin \ 348reset_color_pairs \ 349resize_term \ 350resizeterm \ 351restartterm \ 352ripoffline \ 353scr_dump \ 354setupterm \ 355slk_color \ 356slk_init \ 357termattrs \ 358termname \ 359tgetent \ 360tigetnum \ 361tigetstr \ 362tiparm \ 363tiparm_s \ 364tiscan_s \ 365tputs_sp \ 366typeahead \ 367unget_wch \ 368use_default_colors \ 369use_env \ 370use_extended_names \ 371use_screen \ 372use_window \ 373vid_puts \ 374vidputs \ 375vsscanf \ 376vw_printw \ 377wchgat \ 378winsdelln \ 379winsstr \ 380wresize \ 381wsyncdown \ 382) 383 384CF_TPUTS_PROTO 385CF_NCURSES_EXT_FUNCS 386 387if test "$cf_enable_widec" = yes 388then 389 # workaround for systems with ncurses before 20111029, due to change of 390 # feature test macro from _XPG5 to _XOPEN_SOURCE 391 if test -n "$cf_cv_ncurses_version" && test "x$cf_cv_ncurses_version" != xno 392 then 393 cf_define_xpg5=no 394 AC_MSG_CHECKING(if _XPG5 should be defined to enable wide-characters) 395 396 AC_TRY_COMPILE([ 397#include <${cf_cv_ncurses_header:-curses.h}>], 398 [int x = _XPG5],, 399 [cf_save_cppflags="$CPPFLAGS" 400 CPPFLAGS="$CPPFLAGS -D_XPG5" 401 AC_TRY_COMPILE([ 402#include <${cf_cv_ncurses_header:-curses.h}>], 403 [int x = _XPG5], 404 [cf_define_xpg5=yes]) 405 CPPFLAGS="$cf_save_cppflags"]) 406 AC_MSG_RESULT($cf_define_xpg5) 407 408 if test "$cf_define_xpg5" = yes 409 then 410 CPPFLAGS="$CPPFLAGS -D_XPG5" 411 fi 412 fi 413 414 AC_CACHE_CHECK(for wide-character functions,cf_cv_widechar_funcs,[ 415 AC_TRY_LINK([ 416#include <${cf_cv_ncurses_header:-curses.h}>], 417 [ 418 static wchar_t src_wchar[2]; 419 static cchar_t dst_cchar; 420 setcchar(&dst_cchar, src_wchar, A_NORMAL, 0, (void *) 0); 421 ], 422 [cf_cv_widechar_funcs=yes], 423 [cf_cv_widechar_funcs=no]) 424 ]) 425 if test "$cf_cv_widechar_funcs" != no ; then 426 AC_DEFINE(USE_WIDEC_SUPPORT,1,[Define to 1 to enable wide-character support in (n)curses]) 427 else 428 AC_DEFINE(USE_WIDEC_SUPPORT,0) 429 fi 430else 431 AC_DEFINE(USE_WIDEC_SUPPORT,0) 432fi 433 434AC_CACHE_CHECK(if $cf_cv_screen library uses pthreads,cf_cv_use_pthreads,[ 435AC_TRY_LINK([ 436#include <${cf_cv_ncurses_header:-curses.h}> 437extern void _nc_init_pthreads(void); 438], 439[ 440 initscr(); 441 _nc_init_pthreads(); 442 ], 443 [cf_cv_use_pthreads=yes], 444 [cf_cv_use_pthreads=no]) 445]) 446test $cf_cv_use_pthreads = yes && AC_DEFINE(USE_PTHREADS,1,[Define to 1 if $cf_cv_screen library uses pthreads]) 447 448CF_SYS_TIME_SELECT 449 450# special check for test/ditto.c 451CF_FUNC_OPENPTY 452if test "$cf_cv_func_openpty" != no ; then 453 AC_DEFINE_UNQUOTED(USE_OPENPTY_HEADER,<$cf_cv_func_openpty>,[Define to actual header for openpty function]) 454 AC_DEFINE(USE_XTERM_PTY,1,[Define to 1 if we should assume xterm pseudoterminal interface]) 455 if test "x$cf_cv_lib_util" = xyes ; then 456 CF_ADD_LIB(util,TEST_LIBS) 457 fi 458fi 459 460CF_FUNC_CURSES_VERSION 461 462CF_CURSES_ACS_MAP 463if test "$cf_enable_widec" = yes; then 464 CF_CURSES_WACS_MAP 465 CF_CURSES_WACS_SYMBOLS 466fi 467 468CF_CURSES_CHECK_TYPE(attr_t,long) 469 470if test "$cf_enable_widec" = yes; then 471 CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T, NCURSES_OK_MBSTATE_T) 472 CF_WCHAR_TYPE(wchar_t, NCURSES_WCHAR_T, NCURSES_OK_WCHAR_T) 473 CF_WCHAR_TYPE(wint_t, NCURSES_WINT_T, NCURSES_OK_WINT_T) 474 475 if test "$NCURSES_OK_MBSTATE_T" = 0 ; then 476 CF_CURSES_CHECK_TYPE(mbstate_t,long) 477 fi 478 479 if test "$NCURSES_OK_WCHAR_T" = 0 ; then 480 CF_CURSES_CHECK_TYPE(wchar_t,long) 481 fi 482 483 if test "$NCURSES_OK_WINT_T" = 0 ; then 484 CF_CURSES_CHECK_TYPE(wint_t,long) 485 fi 486fi 487 488CF_CURSES_CHECK_DATA(\ 489TABSIZE \ 490curscr \ 491ospeed \ 492boolnames \ 493boolfnames \ 494ttytype) 495 496dnl --------------------------------------------------------------------------- 497CF_HELP_MESSAGE(Testing/development Options:) 498CF_WITH_SCREEN_PDCURSES 499CF_ENABLE_WARNINGS(Wno-unknown-pragmas) 500CF_DISABLE_LEAKS 501CF_DISABLE_RPATH_HACK 502 503TEST_ARGS="$LIBS" 504LIBS= 505 506dnl --------------------------------------------------------------------------- 507 508AC_OUTPUT(Makefile,[ 509CF_PRG_RULES([$srcdir/mk-test.awk INSTALL=yes ECHO_LINK="$ECHO_LD"], .) 510 cat >>Makefile <<TEST_EOF 511 512# These rules are generated so we do not rely on suffix rules, which do not 513# work consistently for different make-programs (the '\$(MODEL)/' confuses 514# some, and the '\$x' confuses others). 515TEST_EOF 516 517LIST=`sed -e 's/[[ ]].*//' -e '/^[[#@]]/d' $srcdir/modules` 518for N in $LIST 519do 520 cat >>Makefile <<TEST_EOF 521 522\$(MODEL)/$N.o : \$(srcdir)/$N.c \\ 523 \$(srcdir)/test.priv.h \\ 524 ncurses_cfg.h 525 $SHOW_CC 526 $ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) -DMODULE_NAME="$N" \$(srcdir)/$N.c 527TEST_EOF 528done 529 530if test -f ../config.guess && test -f ../config.sub 531then 532 cat >>Makefile <<TEST_EOF 533 534# if we used CF_INHERIT for getting these files, we can remove them 535distclean:: 536 rm -f config.guess config.sub 537TEST_EOF 538fi 539],[ 540AWK="$AWK" 541ECHO_CC="$ECHO_CC" 542ECHO_LD="$ECHO_LD" 543SHOW_CC="$SHOW_LD" 544],cat) 545