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