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