ncurses 6.2 - patch 20200531
[ncurses.git] / test / configure.in
1 dnl***************************************************************************
2 dnl Copyright 2018-2019,2020 Thomas E. Dickey                                *
3 dnl Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
4 dnl                                                                          *
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:                 *
12 dnl                                                                          *
13 dnl The above copyright notice and this permission notice shall be included  *
14 dnl in all copies or substantial portions of the Software.                   *
15 dnl                                                                          *
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.                               *
23 dnl                                                                          *
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       *
27 dnl authorization.                                                           *
28 dnl***************************************************************************
29 dnl
30 dnl Author: Thomas E. Dickey 1996-on
31 dnl
32 dnl $Id: configure.in,v 1.159 2020/05/30 00:13:37 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)
36 dnl
37 dnl If you're configuring ncurses, you shouldn't need to use this script.
38 dnl It's only for testing purposes.
39 dnl
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)
46 AC_INIT(ncurses.c)
47 AC_CONFIG_HEADER(ncurses_cfg.h:ncurses_tst.hin)
48
49 CF_INHERIT_SCRIPT(config.guess)
50 CF_INHERIT_SCRIPT(config.sub)
51 CF_CHECK_CACHE
52
53 AC_ARG_PROGRAM
54
55 CF_HELP_MESSAGE(General Options:)
56
57 AC_PROG_MAKE_SET
58 CF_PROG_CC
59 AC_C_INLINE
60 AC_PROG_CPP
61 AC_PROG_AWK
62 CF_PROG_INSTALL
63 CF_INSTALL_OPTS
64 CF_PROG_LINT
65 CF_MAKE_TAGS
66
67 CF_MATH_LIB(MATH_LIB,pow(sin(x),x))
68 AC_SUBST(MATH_LIB)
69
70 dnl Things that we don't need (or must override) if we're not building ncurses
71 CF_TOP_BUILDDIR
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)
78 LD="ld"                                                 AC_SUBST(LD)
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)
100
101 cf_cv_screen=curses
102 cf_cv_libtype=
103
104 AC_EXEEXT
105 AC_OBJEXT
106
107 CF_GCC_ATTRIBUTES
108 CF_ENABLE_STRING_HACKS
109 CF_XOPEN_SOURCE(600)
110 CF_SIG_ATOMIC_T
111
112 # Work around breakage on OS X
113 CF_SIGWINCH
114
115 # Checks for CODESET support.
116 AM_LANGINFO_CODESET
117
118 dnl ---------------------------------------------------------------------------
119 CF_PKG_CONFIG
120 CF_DISABLE_ECHO
121
122 dnl ---------------------------------------------------------------------------
123 CF_HELP_MESSAGE(Curses Version-dependent Options:)
124 CF_NCURSES_WRAP_PREFIX
125
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],
129         cf_enable_widec=no,
130         cf_enable_widec=yes,
131         yes)
132 AC_MSG_RESULT($cf_enable_widec)
133
134 dnl ---------------------------------------------------------------------------
135 CF_HELP_MESSAGE(Curses Version-dependent Options:)
136 CF_WITH_NCURSES_ETC
137
138 case $cf_cv_screen in
139 (ncurses*)
140         cf_cv_libtype=`echo "$cf_cv_screen" | sed -e 's/^ncurses//'`
141         ;;
142 esac
143
144 CF_WITH_X11_RGB
145
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).
148
149 dnl Autoconf builds up the $LIBS in reverse order
150
151 cf_curses_headers=
152
153 case $cf_cv_screen in
154 (pdcurses)
155         cf_default_panel=no
156         cf_default_form=no
157         cf_default_menu=no
158         cf_default_tinfo=no
159         ;;
160 (xcurses|bsdcurses)
161         cf_default_panel=no
162         cf_default_form=no
163         cf_default_menu=no
164         cf_default_tinfo=yes
165         ;;
166 (*)
167         cf_default_panel=yes
168         cf_default_form=yes
169         cf_default_menu=yes
170         cf_default_tinfo=yes
171         case $cf_cv_screen in
172         (ncurses*)
173                 cf_curses_headers="nc_alloc.h nomacros.h term_entry.h"
174                 ;;
175         esac
176         ;;
177 esac
178
179 CF_WITH_LIB_BASENAME(FORM_NAME,form)
180 CF_WITH_LIB_BASENAME(MENU_NAME,menu)
181 CF_WITH_LIB_BASENAME(PANEL_NAME,panel)
182
183 AC_MSG_CHECKING(if you want to check for panel functions)
184 CF_ARG_DISABLE(panel,
185         [  --disable-panel         disable checks for panel functions],
186         cf_enable_panel=no,
187         cf_enable_panel=$cf_default_panel,
188         yes)
189 AC_MSG_RESULT($cf_enable_panel)
190 if test $cf_enable_panel = yes
191 then
192         CF_CHECK_CURSES_LIB($PANEL_NAME,$cf_cv_libtype,new_panel,0)
193         cf_curses_headers="$cf_curses_headers panel.h"
194 fi
195
196 AC_MSG_CHECKING(if you want to check for menu functions)
197 CF_ARG_DISABLE(menu,
198         [  --disable-menu          disable checks for menu functions],
199         cf_enable_menu=no,
200         cf_enable_menu=$cf_default_menu,
201         yes)
202 AC_MSG_RESULT($cf_enable_menu)
203 if test $cf_enable_menu = yes
204 then
205         case $cf_cv_screen in
206         (ncurses*)
207                 ;;
208         (curses*)
209                 CF_NETBSD_MENU_H
210                 ;;
211         esac
212         CF_CHECK_CURSES_LIB($MENU_NAME,$cf_cv_libtype,menu_driver,[0,0])
213         cf_curses_headers="$cf_curses_headers menu.h"
214 fi
215
216 AC_MSG_CHECKING(if you want to check for form functions)
217 CF_ARG_DISABLE(form,
218         [  --disable-form          disable checks for form functions],
219         cf_enable_form=no,
220         cf_enable_form=$cf_default_form,
221         yes)
222 AC_MSG_RESULT($cf_enable_form)
223 if test $cf_enable_form = yes
224 then
225         case $cf_cv_screen in
226         (ncurses*)
227                 ;;
228         (curses*)
229                 CF_NETBSD_FORM_H
230                 ;;
231         esac
232         CF_CHECK_CURSES_LIB($FORM_NAME,$cf_cv_libtype,form_driver,[0,0])
233         cf_curses_headers="$cf_curses_headers form.h"
234 fi
235
236 # look for curses-related headers
237 AC_CHECK_HEADERS( $cf_curses_headers )
238
239 AC_STDC_HEADERS
240 AC_HEADER_TIME
241 AC_CHECK_HEADERS( \
242 getopt.h \
243 locale.h \
244 math.h \
245 stdarg.h \
246 stdint.h \
247 sys/ioctl.h \
248 sys/select.h \
249 sys/time.h \
250 termios.h \
251 unistd.h \
252 )
253
254 CF_GETOPT_HEADER
255
256 AC_CHECK_FUNCS( \
257 getopt \
258 gettimeofday \
259 snprintf \
260 strstr \
261 tsearch \
262 )
263
264 # use a compile-check to work with ncurses*-config and subdirectory includes
265 AC_CACHE_CHECK(if we can use termcap.h,cf_cv_have_termcap_h,[
266         AC_TRY_COMPILE([
267 #include <curses.h>
268 #ifdef NCURSES_VERSION
269 #undef NCURSES_VERSION
270 #endif
271 #include <termcap.h>
272 #ifndef NCURSES_VERSION
273 #error wrong header
274 #endif
275 ],
276         [return 0;],
277         [cf_cv_have_termcap_h=yes],
278         [cf_cv_have_termcap_h=no])])
279 if test "x$cf_cv_have_termcap_h" = xyes
280 then
281         AC_DEFINE(HAVE_TERMCAP_H,1,[Define to 1 if we can use termcap.h])
282 else
283 AC_CACHE_CHECK(if we can use ncurses/termcap.h,cf_cv_have_ncurses_termcap_h,[
284         AC_TRY_COMPILE([
285 #include <ncurses/curses.h>
286 #ifdef NCURSES_VERSION
287 #undef NCURSES_VERSION
288 #endif
289 #include <ncurses/termcap.h>
290 #ifndef NCURSES_VERSION
291 #error wrong header
292 #endif
293 ],
294         [return 0;],
295         [cf_cv_have_ncurses_termcap_h=yes],
296         [cf_cv_have_ncurses_termcap_h=no])])
297 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])
298 fi
299
300 if test "x$ac_cv_func_getopt" = xno; then
301         AC_MSG_ERROR(getopt is required for building programs)
302 fi
303
304 if test "$cf_enable_widec" = yes; then
305 AC_CHECK_FUNCS( \
306 mblen \
307 mbrlen \
308 mbrtowc \
309 mbsrtowcs \
310 mbstowcs \
311 mbtowc \
312 wcsrtombs \
313 wcstombs \
314 )
315 fi
316
317 CF_CURSES_FUNCS( \
318 alloc_pair \
319 assume_default_colors \
320 chgat \
321 color_content \
322 color_set \
323 copywin \
324 delscreen \
325 dupwin \
326 filter \
327 getbegx \
328 getcurx \
329 getmaxx \
330 getnstr \
331 getparx \
332 getwin \
333 halfdelay \
334 init_extended_color \
335 mvderwin \
336 mvvline \
337 mvwin \
338 mvwvline \
339 napms \
340 newpad \
341 putwin \
342 reset_color_pairs \
343 resize_term \
344 resizeterm \
345 restartterm \
346 ripoffline \
347 scr_dump \
348 setupterm \
349 slk_color \
350 slk_init \
351 termattrs \
352 tgetent \
353 tigetnum \
354 tigetstr \
355 tputs_sp \
356 typeahead \
357 use_default_colors \
358 use_env \
359 use_extended_names \
360 use_screen \
361 use_window \
362 vid_puts \
363 vidputs \
364 vsscanf \
365 vw_printw \
366 wchgat \
367 winsdelln \
368 winsstr \
369 wresize \
370 wsyncdown \
371 _tracef \
372 )
373
374 CF_TPUTS_PROTO
375 CF_NCURSES_EXT_FUNCS
376
377 if test "$cf_enable_widec" = yes
378 then
379         # workaround for systems with ncurses before 20111029, due to change of
380         # feature test macro from _XPG5 to _XOPEN_SOURCE
381         if test -n "$cf_cv_ncurses_version" && test "x$cf_cv_ncurses_version" != xno
382         then
383                 cf_define_xpg5=no
384                 AC_MSG_CHECKING(if _XPG5 should be defined to enable wide-characters)
385
386                 AC_TRY_COMPILE([
387 #include <${cf_cv_ncurses_header:-curses.h}>],
388                         [int x = _XPG5],,
389                         [cf_save_cppflags="$CPPFLAGS"
390                          CPPFLAGS="$CPPFLAGS -D_XPG5"
391                          AC_TRY_COMPILE([
392 #include <${cf_cv_ncurses_header:-curses.h}>],
393                                 [int x = _XPG5],
394                                 [cf_define_xpg5=yes])
395                          CPPFLAGS="$cf_save_cppflags"])
396                 AC_MSG_RESULT($cf_define_xpg5)
397
398                 if test "$cf_define_xpg5" = yes
399                 then
400                         CPPFLAGS="$CPPFLAGS -D_XPG5"
401                 fi
402         fi
403
404         AC_CACHE_CHECK(for wide-character functions,cf_cv_widechar_funcs,[
405         AC_TRY_LINK([
406 #include <${cf_cv_ncurses_header:-curses.h}>],
407         [
408                 static wchar_t src_wchar[2];
409                 static cchar_t dst_cchar;
410                 setcchar(&dst_cchar, src_wchar, A_NORMAL, 0, (void *) 0);
411                 ],
412                 [cf_cv_widechar_funcs=yes],
413                 [cf_cv_widechar_funcs=no])
414         ])
415         if test "$cf_cv_widechar_funcs" != no ; then
416                 AC_DEFINE(USE_WIDEC_SUPPORT,1,[Define to 1 to enable wide-character support in (n)curses])
417         else
418                 AC_DEFINE(USE_WIDEC_SUPPORT,0)
419         fi
420 else
421         AC_DEFINE(USE_WIDEC_SUPPORT,0)
422 fi
423
424 AC_CACHE_CHECK(if $cf_cv_screen library uses pthreads,cf_cv_use_pthreads,[
425 AC_TRY_LINK([
426 #include <${cf_cv_ncurses_header:-curses.h}>
427 extern void _nc_init_pthreads(void);
428 ],
429 [
430         initscr();
431         _nc_init_pthreads();
432         ],
433         [cf_cv_use_pthreads=yes],
434         [cf_cv_use_pthreads=no])
435 ])
436 test $cf_cv_use_pthreads = yes && AC_DEFINE(USE_PTHREADS,1,[Define to 1 if $cf_cv_screen library uses pthreads])
437
438 CF_SYS_TIME_SELECT
439
440 # special check for test/ditto.c
441 CF_FUNC_OPENPTY
442 if test "$cf_cv_func_openpty" != no ; then
443         AC_DEFINE_UNQUOTED(USE_OPENPTY_HEADER,<$cf_cv_func_openpty>,[Define to actual header for openpty function])
444         AC_DEFINE(USE_XTERM_PTY,1,[Define to 1 if we should assume xterm pseudoterminal interface])
445         if test "x$cf_cv_lib_util" = xyes ; then
446                 CF_ADD_LIB(util,TEST_LIBS)
447         fi
448 fi
449
450 CF_FUNC_CURSES_VERSION
451
452 CF_CURSES_ACS_MAP
453 if test "$cf_enable_widec" = yes; then
454         CF_CURSES_WACS_MAP
455         CF_CURSES_WACS_SYMBOLS
456 fi
457
458 CF_CURSES_CHECK_TYPE(attr_t,long)
459
460 if test "$cf_enable_widec" = yes; then
461         CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T, NCURSES_OK_MBSTATE_T)
462         CF_WCHAR_TYPE(wchar_t,   NCURSES_WCHAR_T,   NCURSES_OK_WCHAR_T)
463         CF_WCHAR_TYPE(wint_t,    NCURSES_WINT_T,    NCURSES_OK_WINT_T)
464
465         if test "$NCURSES_OK_MBSTATE_T" = 0 ; then
466                 CF_CURSES_CHECK_TYPE(mbstate_t,long)
467         fi
468
469         if test "$NCURSES_OK_WCHAR_T" = 0 ; then
470                 CF_CURSES_CHECK_TYPE(wchar_t,long)
471         fi
472
473         if test "$NCURSES_OK_WINT_T" = 0 ; then
474                 CF_CURSES_CHECK_TYPE(wint_t,long)
475         fi
476 fi
477
478 CF_CURSES_CHECK_DATA(\
479 TABSIZE \
480 curscr \
481 ospeed \
482 boolnames \
483 boolfnames \
484 ttytype)
485
486 dnl ---------------------------------------------------------------------------
487 CF_HELP_MESSAGE(Testing/development Options:)
488 CF_ENABLE_WARNINGS(Wno-unknown-pragmas)
489 CF_DISABLE_LEAKS
490 CF_DISABLE_RPATH_HACK
491
492 TEST_ARGS="$LIBS"
493 LIBS=
494
495 dnl ---------------------------------------------------------------------------
496
497 AC_OUTPUT(Makefile,[
498 CF_PRG_RULES([$srcdir/mk-test.awk INSTALL=yes ECHO_LINK="$ECHO_LD"], .)
499         cat >>Makefile <<TEST_EOF
500
501 # These rules are generated so we do not rely on suffix rules, which do not
502 # work consistently for different make-programs (the '\$(MODEL)/' confuses
503 # some, and the '\$x' confuses others).
504 TEST_EOF
505
506 LIST=`sed -e 's/[[      ]].*//' -e '/^[[#@]]/d' $srcdir/modules`
507 for N in $LIST
508 do
509         cat >>Makefile <<TEST_EOF
510
511 \$(MODEL)/$N.o : \$(srcdir)/$N.c \\
512         \$(srcdir)/test.priv.h \\
513         ncurses_cfg.h
514         $SHOW_CC
515         $ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) -DMODULE_NAME="$N" \$(srcdir)/$N.c
516 TEST_EOF
517 done
518
519 if test -f ../config.guess && test -f ../config.sub
520 then
521         cat >>Makefile <<TEST_EOF
522
523 # if we used CF_INHERIT for getting these files, we can remove them
524 distclean::
525         rm -f config.guess config.sub
526 TEST_EOF
527 fi
528 ],[
529 AWK="$AWK"
530 ECHO_CC="$ECHO_CC"
531 ECHO_LD="$ECHO_LD"
532 SHOW_CC="$SHOW_LD"
533 ],cat)