ncurses 6.2 - patch 20200418
[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.158 2020/03/08 14:12:23 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 strstr \
260 tsearch \
261 )
262
263 # use a compile-check to work with ncurses*-config and subdirectory includes
264 AC_CACHE_CHECK(if we can use termcap.h,cf_cv_have_termcap_h,[
265         AC_TRY_COMPILE([
266 #include <curses.h>
267 #ifdef NCURSES_VERSION
268 #undef NCURSES_VERSION
269 #endif
270 #include <termcap.h>
271 #ifndef NCURSES_VERSION
272 #error wrong header
273 #endif
274 ],
275         [return 0;],
276         [cf_cv_have_termcap_h=yes],
277         [cf_cv_have_termcap_h=no])])
278 if test "x$cf_cv_have_termcap_h" = xyes
279 then
280         AC_DEFINE(HAVE_TERMCAP_H,1,[Define to 1 if we can use termcap.h])
281 else
282 AC_CACHE_CHECK(if we can use ncurses/termcap.h,cf_cv_have_ncurses_termcap_h,[
283         AC_TRY_COMPILE([
284 #include <ncurses/curses.h>
285 #ifdef NCURSES_VERSION
286 #undef NCURSES_VERSION
287 #endif
288 #include <ncurses/termcap.h>
289 #ifndef NCURSES_VERSION
290 #error wrong header
291 #endif
292 ],
293         [return 0;],
294         [cf_cv_have_ncurses_termcap_h=yes],
295         [cf_cv_have_ncurses_termcap_h=no])])
296 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])
297 fi
298
299 if test "x$ac_cv_func_getopt" = xno; then
300         AC_MSG_ERROR(getopt is required for building programs)
301 fi
302
303 if test "$cf_enable_widec" = yes; then
304 AC_CHECK_FUNCS( \
305 mblen \
306 mbrlen \
307 mbrtowc \
308 mbsrtowcs \
309 mbstowcs \
310 mbtowc \
311 wcsrtombs \
312 wcstombs \
313 )
314 fi
315
316 CF_CURSES_FUNCS( \
317 alloc_pair \
318 assume_default_colors \
319 chgat \
320 color_content \
321 color_set \
322 copywin \
323 delscreen \
324 dupwin \
325 filter \
326 getbegx \
327 getcurx \
328 getmaxx \
329 getnstr \
330 getparx \
331 getwin \
332 halfdelay \
333 init_extended_color \
334 mvderwin \
335 mvvline \
336 mvwin \
337 mvwvline \
338 napms \
339 newpad \
340 putwin \
341 reset_color_pairs \
342 resize_term \
343 resizeterm \
344 restartterm \
345 ripoffline \
346 scr_dump \
347 setupterm \
348 slk_color \
349 slk_init \
350 termattrs \
351 tgetent \
352 tigetnum \
353 tigetstr \
354 tputs_sp \
355 typeahead \
356 use_default_colors \
357 use_env \
358 use_extended_names \
359 use_screen \
360 use_window \
361 vid_puts \
362 vidputs \
363 vsscanf \
364 vw_printw \
365 wchgat \
366 winsdelln \
367 winsstr \
368 wresize \
369 wsyncdown \
370 _tracef \
371 )
372
373 CF_TPUTS_PROTO
374 CF_NCURSES_EXT_FUNCS
375
376 if test "$cf_enable_widec" = yes
377 then
378         # workaround for systems with ncurses before 20111029, due to change of
379         # feature test macro from _XPG5 to _XOPEN_SOURCE
380         if test -n "$cf_cv_ncurses_version" && test "x$cf_cv_ncurses_version" != xno
381         then
382                 cf_define_xpg5=no
383                 AC_MSG_CHECKING(if _XPG5 should be defined to enable wide-characters)
384
385                 AC_TRY_COMPILE([
386 #include <${cf_cv_ncurses_header:-curses.h}>],
387                         [int x = _XPG5],,
388                         [cf_save_cppflags="$CPPFLAGS"
389                          CPPFLAGS="$CPPFLAGS -D_XPG5"
390                          AC_TRY_COMPILE([
391 #include <${cf_cv_ncurses_header:-curses.h}>],
392                                 [int x = _XPG5],
393                                 [cf_define_xpg5=yes])
394                          CPPFLAGS="$cf_save_cppflags"])
395                 AC_MSG_RESULT($cf_define_xpg5)
396
397                 if test "$cf_define_xpg5" = yes
398                 then
399                         CPPFLAGS="$CPPFLAGS -D_XPG5"
400                 fi
401         fi
402
403         AC_CACHE_CHECK(for wide-character functions,cf_cv_widechar_funcs,[
404         AC_TRY_LINK([
405 #include <${cf_cv_ncurses_header:-curses.h}>],
406         [
407                 static wchar_t src_wchar[2];
408                 static cchar_t dst_cchar;
409                 setcchar(&dst_cchar, src_wchar, A_NORMAL, 0, (void *) 0);
410                 ],
411                 [cf_cv_widechar_funcs=yes],
412                 [cf_cv_widechar_funcs=no])
413         ])
414         if test "$cf_cv_widechar_funcs" != no ; then
415                 AC_DEFINE(USE_WIDEC_SUPPORT,1,[Define to 1 to enable wide-character support in (n)curses])
416         else
417                 AC_DEFINE(USE_WIDEC_SUPPORT,0)
418         fi
419 else
420         AC_DEFINE(USE_WIDEC_SUPPORT,0)
421 fi
422
423 AC_CACHE_CHECK(if $cf_cv_screen library uses pthreads,cf_cv_use_pthreads,[
424 AC_TRY_LINK([
425 #include <${cf_cv_ncurses_header:-curses.h}>
426 extern void _nc_init_pthreads(void);
427 ],
428 [
429         initscr();
430         _nc_init_pthreads();
431         ],
432         [cf_cv_use_pthreads=yes],
433         [cf_cv_use_pthreads=no])
434 ])
435 test $cf_cv_use_pthreads = yes && AC_DEFINE(USE_PTHREADS,1,[Define to 1 if $cf_cv_screen library uses pthreads])
436
437 CF_SYS_TIME_SELECT
438
439 # special check for test/ditto.c
440 CF_FUNC_OPENPTY
441 if test "$cf_cv_func_openpty" != no ; then
442         AC_DEFINE_UNQUOTED(USE_OPENPTY_HEADER,<$cf_cv_func_openpty>,[Define to actual header for openpty function])
443         AC_DEFINE(USE_XTERM_PTY,1,[Define to 1 if we should assume xterm pseudoterminal interface])
444         if test "x$cf_cv_lib_util" = xyes ; then
445                 CF_ADD_LIB(util,TEST_LIBS)
446         fi
447 fi
448
449 CF_FUNC_CURSES_VERSION
450
451 CF_CURSES_ACS_MAP
452 if test "$cf_enable_widec" = yes; then
453         CF_CURSES_WACS_MAP
454         CF_CURSES_WACS_SYMBOLS
455 fi
456
457 CF_CURSES_CHECK_TYPE(attr_t,long)
458
459 if test "$cf_enable_widec" = yes; then
460         CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T, NCURSES_OK_MBSTATE_T)
461         CF_WCHAR_TYPE(wchar_t,   NCURSES_WCHAR_T,   NCURSES_OK_WCHAR_T)
462         CF_WCHAR_TYPE(wint_t,    NCURSES_WINT_T,    NCURSES_OK_WINT_T)
463
464         if test "$NCURSES_OK_MBSTATE_T" = 0 ; then
465                 CF_CURSES_CHECK_TYPE(mbstate_t,long)
466         fi
467
468         if test "$NCURSES_OK_WCHAR_T" = 0 ; then
469                 CF_CURSES_CHECK_TYPE(wchar_t,long)
470         fi
471
472         if test "$NCURSES_OK_WINT_T" = 0 ; then
473                 CF_CURSES_CHECK_TYPE(wint_t,long)
474         fi
475 fi
476
477 CF_CURSES_CHECK_DATA(\
478 TABSIZE \
479 curscr \
480 ospeed \
481 boolnames \
482 boolfnames \
483 ttytype)
484
485 dnl ---------------------------------------------------------------------------
486 CF_HELP_MESSAGE(Testing/development Options:)
487 CF_ENABLE_WARNINGS(Wno-unknown-pragmas)
488 CF_DISABLE_LEAKS
489 CF_DISABLE_RPATH_HACK
490
491 TEST_ARGS="$LIBS"
492 LIBS=
493
494 dnl ---------------------------------------------------------------------------
495
496 AC_OUTPUT(Makefile,[
497 CF_PRG_RULES([$srcdir/mk-test.awk INSTALL=yes ECHO_LINK="$ECHO_LD"], .)
498         cat >>Makefile <<TEST_EOF
499
500 # These rules are generated so we do not rely on suffix rules, which do not
501 # work consistently for different make-programs (the '\$(MODEL)/' confuses
502 # some, and the '\$x' confuses others).
503 TEST_EOF
504
505 LIST=`sed -e 's/[[      ]].*//' -e '/^[[#@]]/d' $srcdir/modules`
506 for N in $LIST
507 do
508         cat >>Makefile <<TEST_EOF
509
510 \$(MODEL)/$N.o : \$(srcdir)/$N.c \\
511         \$(srcdir)/test.priv.h \\
512         ncurses_cfg.h
513         $SHOW_CC
514         $ECHO_CC\$(CC) -c \$(CFLAGS_DEFAULT) -DMODULE_NAME="$N" \$(srcdir)/$N.c
515 TEST_EOF
516 done
517
518 if test -f ../config.guess && test -f ../config.sub
519 then
520         cat >>Makefile <<TEST_EOF
521
522 # if we used CF_INHERIT for getting these files, we can remove them
523 distclean::
524         rm -f config.guess config.sub
525 TEST_EOF
526 fi
527 ],[
528 AWK="$AWK"
529 ECHO_CC="$ECHO_CC"
530 ECHO_LD="$ECHO_LD"
531 SHOW_CC="$SHOW_LD"
532 ],cat)