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