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