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