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