1 dnl***************************************************************************
2 dnl Copyright 2018-2021,2022 Thomas E. Dickey *
3 dnl Copyright 2010-2016,2018 Free Software Foundation, Inc. *
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: *
13 dnl The above copyright notice and this permission notice shall be included *
14 dnl in all copies or substantial portions of the Software. *
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. *
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 *
28 dnl***************************************************************************
30 dnl Author: Thomas E. Dickey
32 dnl $Id: configure.in,v 1.85 2022/03/05 22:20:52 tom Exp $
33 dnl Process this file with autoconf to produce a configure script.
35 dnl For additional information, see
36 dnl https://invisible-island.net/autoconf/
37 dnl https://invisible-island.net/autoconf/my-autoconf.html
39 dnl ---------------------------------------------------------------------------
40 AC_PREREQ(2.52.20210509)
41 AC_REVISION($Revision: 1.85 $)
43 AC_CONFIG_HEADER(include/ncurses_cfg.h:include/ncurses_cfg.hin)
45 AC_DEFUN([AC_PATH_XTRA],[])dnl ignore dependencies on this
49 CF_HELP_MESSAGE(General Options:)
53 ### Save the given $CFLAGS to allow user-override.
54 cf_user_CFLAGS="$CFLAGS"
56 ### Default install-location
59 ### Checks for programs.
60 CF_PROG_CC(gnatgcc gcc cc)
62 AC_PROG_GCC_TRADITIONAL
63 CF_PROG_CC_C_O(CC,[$CFLAGS $CPPFLAGS])
75 AC_SYS_LONG_FILE_NAMES
77 # if we find pkg-config, check if we should install the ".pc" files.
79 CF_WITH_PKG_CONFIG_LIBDIR
81 AC_MSG_CHECKING(if you want to build test-programs)
83 [ --without-tests suppress build with test-programs],
84 [cf_with_tests=$withval],
86 AC_MSG_RESULT($cf_with_tests)
88 AC_MSG_CHECKING(if we should assume mixed-case filenames)
89 AC_ARG_ENABLE(mixed-case,
90 [ --enable-mixed-case tic should assume mixed-case filenames],
91 [enable_mixedcase=$enableval],
92 [enable_mixedcase=auto])
93 AC_MSG_RESULT($enable_mixedcase)
94 if test "$enable_mixedcase" = "auto" ; then
95 CF_MIXEDCASE_FILENAMES
97 cf_cv_mixedcase=$enable_mixedcase
98 if test "$enable_mixedcase" = "yes" ; then
99 AC_DEFINE(MIXEDCASE_FILENAMES)
103 # do this after mixed-case option (tags/TAGS is not as important as tic).
109 dnl These are standard among *NIX systems, but not when cross-compiling
110 AC_CHECK_TOOL(RANLIB, ranlib, ':')
111 AC_CHECK_TOOL(LD, ld, ld)
112 AC_CHECK_TOOL(AR, ar, ar)
116 dnl Special option for use by system-builders: the install-prefix is used to
117 dnl adjust the location into which the actual install is done, so that an
118 dnl archive can be built without modifying the host system's configuration.
119 AC_MSG_CHECKING(if you have specified an install-prefix)
120 AC_ARG_WITH(install-prefix,
121 [ --with-install-prefix prefixes actual install-location ($DESTDIR)],
125 (*) DESTDIR="$withval"
128 AC_MSG_RESULT($DESTDIR)
131 ###############################################################################
132 CF_HELP_MESSAGE(Build-Tools Needed to Compile Temporary Applications for Cross-compiling:)
133 # If we're cross-compiling, allow the user to override the tools and their
134 # options. The configure script is oriented toward identifying the host
135 # compiler, etc., but we need a build compiler to generate parts of the source.
138 ###############################################################################
139 CF_HELP_MESSAGE(Options to Specify the Libraries Built/Used:)
141 ### Options to allow the user to specify the set of libraries which are used.
142 ### Use "--without-normal --with-shared" to allow the default model to be
143 ### shared, for example.
146 AC_MSG_CHECKING(if you want to build shared C-objects)
148 [ --with-shared generate shared C-objects (needed for --with-ada-sharedlib)],
149 [with_shared=$withval],
151 AC_MSG_RESULT($with_shared)
152 test "$with_shared" = "yes" && cf_list_models="$cf_list_models shared"
154 AC_MSG_CHECKING(for specified models)
155 test -z "$cf_list_models" && cf_list_models=normal
156 AC_MSG_RESULT($cf_list_models)
158 ### Use the first model as the default, and save its suffix for use in building
159 ### up test-applications.
160 AC_MSG_CHECKING(for default model)
161 DFT_LWR_MODEL=`echo "$cf_list_models" | $AWK '{print $1}'`
162 AC_MSG_RESULT($DFT_LWR_MODEL)
164 CF_UPPER(DFT_UPR_MODEL,$DFT_LWR_MODEL)dnl
166 AC_SUBST(DFT_LWR_MODEL)dnl the default model ("normal")
167 AC_SUBST(DFT_UPR_MODEL)dnl the default model ("NORMAL")
171 CF_WITH_LIB_PREFIX(cf_prefix)
176 ###############################################################################
178 dnl Not all ports of gcc support the -g option
180 if test X"$CC_G_OPT" = X"" ; then
182 test -n "$GCC" && test "${ac_cv_prog_cc_g}" != yes && CC_G_OPT=''
186 AC_MSG_CHECKING(for default loader flags)
187 case $DFT_LWR_MODEL in
188 (normal) LD_MODEL='' ;;
189 (debug) LD_MODEL=$CC_G_OPT ;;
190 (profile) LD_MODEL='-pg';;
191 (shared) LD_MODEL='' ;;
193 AC_SUBST(LD_MODEL)dnl the type of link (e.g., -g or -pg)
194 AC_MSG_RESULT($LD_MODEL)
198 # The test/sample programs in the original tree link using rpath option.
199 # Make it optional for packagers.
200 if test -n "$LOCAL_LDFLAGS"
202 AC_MSG_CHECKING(if you want to link sample programs with rpath option)
203 AC_ARG_ENABLE(rpath-link,
204 [ --enable-rpath-link link sample programs with rpath option],
205 [with_rpath_link=$enableval],
206 [with_rpath_link=yes])
207 AC_MSG_RESULT($with_rpath_link)
208 if test "$with_rpath_link" = no
215 ###############################################################################
216 CF_HELP_MESSAGE(Fine-Tuning Your Configuration:)
218 ### use option --enable-broken-linker to force on use of broken-linker support
219 CF_ENABLE_BROKEN_LINKER
221 # Check to define _XOPEN_SOURCE "automatically"
226 ### Enable compiling-in rcs id's
227 AC_MSG_CHECKING(if RCS identifiers should be compiled-in)
229 [ --with-rcs-ids compile-in RCS identifiers],
230 [with_rcs_ids=$withval],
232 AC_MSG_RESULT($with_rcs_ids)
233 test "$with_rcs_ids" = yes && AC_DEFINE(USE_RCS_IDS,1,[Define to 1 if RCS identifiers should be compiled-in)])
235 ###############################################################################
236 CF_HELP_MESSAGE(Extensions:)
238 ### Note that some functions (such as const) are normally disabled anyway.
239 AC_MSG_CHECKING(if you want to build with function extensions)
240 AC_ARG_ENABLE(ext-funcs,
241 [ --disable-ext-funcs disable function-extensions],
242 [with_ext_funcs=$enableval],
243 [with_ext_funcs=yes])
244 AC_MSG_RESULT($with_ext_funcs)
245 if test "$with_ext_funcs" = yes ; then
247 AC_DEFINE(HAVE_USE_DEFAULT_COLORS,1,[Define to 1 if we have use_default_colors function])
248 AC_DEFINE(NCURSES_EXT_FUNCS,1,[Define to 1 if we have ncurses extended functions])
252 AC_SUBST(NCURSES_EXT_FUNCS)
254 ### use option --enable-const to turn on use of const beyond that in XSI.
255 AC_MSG_CHECKING(for extended use of const keyword)
257 [ --enable-const compile with extra/non-standard const],
258 [with_ext_const=$enableval],
260 AC_MSG_RESULT($with_ext_const)
261 NCURSES_CONST='/*nothing*/'
262 if test "$with_ext_const" = yes ; then
265 AC_SUBST(NCURSES_CONST)
267 ###############################################################################
268 # These options are relatively safe to experiment with.
269 CF_HELP_MESSAGE(Development Code:)
270 AC_MSG_CHECKING(if you want all development code)
272 [ --without-develop disable development options],
273 [with_develop=$withval],
275 AC_MSG_RESULT($with_develop)
277 ###############################################################################
278 # These are just experimental, probably should not be in a package:
279 CF_HELP_MESSAGE(Experimental Code:)
281 # This is still experimental (20080329), but should ultimately be moved to
282 # the script-block --with-normal, etc.
285 AC_MSG_CHECKING(if you want to use weak-symbols for pthreads)
286 AC_ARG_ENABLE(weak-symbols,
287 [ --enable-weak-symbols enable weak-symbols for pthreads],
288 [use_weak_symbols=$withval],
289 [use_weak_symbols=no])
290 AC_MSG_RESULT($use_weak_symbols)
291 if test "$use_weak_symbols" = yes ; then
294 cf_cv_weak_symbols=no
297 if test $cf_cv_weak_symbols = yes ; then
298 AC_DEFINE(USE_WEAK_SYMBOLS,1,[Define to 1 to enable weak-symbols for pthreads])
302 if test "$with_pthread" = "yes" ; then
303 AC_DEFINE(USE_PTHREADS,1,[Define to 1 to use the pthreads library])
305 if test $cf_cv_weak_symbols = yes ; then
311 # OpenSUSE is installing ncurses6, using reentrant option.
312 AC_CHECK_FUNC(_nc_TABSIZE,[assume_reentrant=yes], [assume_reentrant=no])
314 # Reentrant code has to be opaque; there's little advantage to making ncurses
315 # opaque outside of that, so there is no --enable-opaque option. We can use
316 # this option without --with-pthreads, but this will be always set for
318 AC_MSG_CHECKING(if you want experimental reentrant code)
319 AC_ARG_ENABLE(reentrant,
320 [ --enable-reentrant compile with experimental reentrant code],
321 [with_reentrant=$enableval],
322 [with_reentrant=$assume_reentrant])
323 AC_MSG_RESULT($with_reentrant)
324 if test "$with_reentrant" = yes ; then
325 cf_cv_enable_reentrant=1
326 if test $cf_cv_weak_symbols = yes ; then
327 CF_REMOVE_LIB(LIBS,$LIBS,pthread)
328 elif test "$assume_reentrant" = no ; then
329 LIB_SUFFIX="t${LIB_SUFFIX}"
331 AC_DEFINE(USE_REENTRANT,1,[Define to 1 to compile with experimental reentrant code])
333 cf_cv_enable_reentrant=0
335 AC_SUBST(cf_cv_enable_reentrant)
337 ### Allow using a different wrap-prefix
338 if test "$cf_cv_enable_reentrant" != 0 || test "$BROKEN_LINKER" = 1 ; then
339 AC_MSG_CHECKING(for prefix used to wrap public variables)
340 AC_ARG_WITH(wrap-prefix,
341 [ --with-wrap-prefix=XXX override prefix used for public variables],
342 [NCURSES_WRAP_PREFIX=$withval],
343 [NCURSES_WRAP_PREFIX=_nc_])
344 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
346 NCURSES_WRAP_PREFIX=_nc_
348 AC_SUBST(NCURSES_WRAP_PREFIX)
349 AC_DEFINE_UNQUOTED(NCURSES_WRAP_PREFIX,"$NCURSES_WRAP_PREFIX",[Define to override _nc_ ncurses internal prefix])
351 ###############################################################################
352 CF_HELP_MESSAGE(Testing/development Options:)
354 ### use option --disable-echo to suppress full display compiling commands
357 CF_ENABLE_WARNINGS(Wno-unknown-pragmas Wswitch-enum,yes)
358 if test "x$enable_warnings" = "xyes"; then
359 CF_ADD_ADAFLAGS(-gnatwa -gnatyg)
362 ### use option --enable-assertions to turn on generation of assertion code
363 AC_MSG_CHECKING(if you want to enable runtime assertions)
364 AC_ARG_ENABLE(assertions,
365 [ --enable-assertions test: turn on generation of assertion code],
366 [with_assertions=$enableval],
367 [with_assertions=no])
368 AC_MSG_RESULT($with_assertions)
371 if test "$with_assertions" = no
373 CPPFLAGS="$CPPFLAGS -DNDEBUG"
375 CF_ADD_ADAFLAGS(-gnata)
379 ### use option --disable-leaks to suppress "permanent" leaks, for testing
380 AC_DEFINE(HAVE_NC_ALLOC_H,1,[Define to 1 if we have nc_alloc.h header])
382 ### use option --enable-expanded to generate certain macros as functions
383 AC_ARG_ENABLE(expanded,
384 [ --enable-expanded test: generate functions for certain macros],
385 [test "$enableval" = yes && AC_DEFINE(NCURSES_EXPANDED,1,[Define to 1 if ncurses macros should be expanded as functions])])
387 ### use option --disable-macros to suppress macros in favor of functions
388 AC_ARG_ENABLE(macros,
389 [ --disable-macros test: use functions rather than macros],
390 [test "$enableval" = no && AC_DEFINE(NCURSES_NOMACROS,1,[Define to 1 if ncurses macros should be expanded as functions])])
392 # Normally we only add trace() to the debug-library. Allow this to be
393 # extended to all models of the ncurses library:
395 case "$CFLAGS $CPPFLAGS" in
401 AC_MSG_CHECKING(whether to add trace feature to all models)
403 [ --with-trace test: add trace() function to all models of ncurses],
404 [cf_with_trace=$withval],
405 [cf_with_trace=$cf_all_traces])
406 AC_MSG_RESULT($cf_with_trace)
408 if test "$cf_with_trace" = yes ; then
410 CF_ADD_CFLAGS(-DTRACE)
417 CF_DISABLE_GNAT_PROJECTS
419 ### Checks for libraries.
420 case $cf_cv_system_name in
425 AC_CHECK_FUNC(gettimeofday,
426 AC_DEFINE(HAVE_GETTIMEOFDAY),[
428 AC_CHECK_LIB(bsd, gettimeofday,
429 AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday])
430 LIBS="$LIBS -lbsd")])dnl CLIX: bzero, select, gettimeofday
434 ### Checks for header files.
435 AC_CHECK_SIZEOF([signed char])
440 ### checks for compiler characteristics
444 ### Checks for external-data
447 ### Checks for library functions.
450 dnl We'll do our own -g libraries, unless the user's overridden via $CFLAGS
451 if test -z "$cf_user_CFLAGS" && test "$with_no_leaks" = no ; then
452 CF_STRIP_G_OPT(CFLAGS)
453 CF_STRIP_G_OPT(CXXFLAGS)
456 CF_HELP_MESSAGE(Ada95 Binding Options:)
458 dnl Check for availability of GNU Ada Translator (GNAT).
459 dnl At the moment we support no other Ada95 compiler.
460 if test "$cf_with_ada" != "no" ; then
462 if test "$cf_cv_prog_gnat_correct" = yes; then
473 cf_ada_package=terminal_interface
474 AC_SUBST(cf_ada_package)
478 CF_WITH_ADA_SHAREDLIB
480 # allow the Ada binding to be renamed
481 CF_WITH_ADA_LIBNAME(AdaCurses)
483 AC_MSG_ERROR(No usable Ada compiler found)
486 AC_MSG_ERROR(The Ada compiler is needed for this package)
489 ################################################################################
493 AC_SUBST(TINFO_LDFLAGS2)
497 ### Construct the list of include-directories to be generated
501 ### Build up pieces for makefile rules
502 AC_MSG_CHECKING(default library suffix)
503 CF_LIB_TYPE($DFT_LWR_MODEL,DFT_ARG_SUFFIX)dnl
504 AC_SUBST(DFT_ARG_SUFFIX)dnl the string to append to "-lncurses" ("")
505 AC_MSG_RESULT($DFT_ARG_SUFFIX)
507 AC_MSG_CHECKING(default library-dependency suffix)
508 CF_LIB_SUFFIX($DFT_LWR_MODEL,DFT_LIB_SUFFIX,DFT_DEP_SUFFIX)dnl
509 AC_SUBST(DFT_DEP_SUFFIX)dnl the corresponding library-suffix (".a")
510 AC_MSG_RESULT($DFT_DEP_SUFFIX)
512 AC_MSG_CHECKING(default object directory)
513 CF_OBJ_SUBDIR($DFT_LWR_MODEL,DFT_OBJ_SUBDIR)dnl
514 AC_SUBST(DFT_OBJ_SUBDIR)dnl the default object-directory ("obj")
515 AC_MSG_RESULT($DFT_OBJ_SUBDIR)
517 ### Set up low-level terminfo dependencies for makefiles.
519 if test "$DFT_LWR_MODEL" = shared ; then
520 case $cf_cv_system_name in
522 # "lib" files have ".dll.a" suffix, "cyg" files have ".dll"
525 # "lib" files have ".dll.a" suffix, "msys-" files have ".dll"
530 USE_ARG_SUFFIX=${DFT_ARG_SUFFIX}
531 AC_SUBST(USE_ARG_SUFFIX)
533 USE_LIB_SUFFIX=${DFT_ARG_SUFFIX}
534 AC_SUBST(USE_LIB_SUFFIX)
536 USE_CFG_SUFFIX=${DFT_ARG_SUFFIX}
537 AC_SUBST(USE_CFG_SUFFIX)
539 ### Construct the list of subdirectories for which we'll customize makefiles
540 ### with the appropriate compile-rules.
542 SUB_MAKEFILES="gen/adacurses${USE_ARG_SUFFIX}-config:gen/adacurses-config.in"
544 AC_DEFINE_UNQUOTED(NCURSES_PATHSEP,'$PATH_SEPARATOR',[Define to override ':' as the library path-separator])
546 ################################################################################
554 dnl for separate build, this is good enough for "sh $(top_srcdir)/misc/shlib"
555 NCURSES_SHLIB2="sh -c"
556 AC_SUBST(NCURSES_SHLIB2)
558 ADA_SUBDIRS="include gen src doc"
559 if test "x$cf_with_tests" != "xno" ; then
560 ADA_SUBDIRS="$ADA_SUBDIRS samples"
562 for cf_dir in $ADA_SUBDIRS
564 SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
566 AC_SUBST(ADA_SUBDIRS)
569 AC_SUBST(NCURSES_TREE)
572 AC_SUBST(EXTERNAL_TREE)
574 # match layout used by make-tar.sh
575 ADAHTML_DIR=../doc/ada
576 AC_SUBST(ADAHTML_DIR)
578 if test "x$cross_compiling" = xyes ; then
579 ADAGEN_LDFLAGS='$(CROSS_LDFLAGS)'
581 ADAGEN_LDFLAGS='$(NATIVE_LDFLAGS)'
584 AC_SUBST(ADAGEN_LDFLAGS)
588 src/library.gpr:src/library.gpr.in \
589 doc/adacurses${DFT_ARG_SUFFIX}-config.1:doc/MKada_config.in \
591 if test -z "$USE_OLD_MAKERULES" ; then
592 $AWK -f $srcdir/mk-1st.awk <$srcdir/src/modules >>src/Makefile
595 ### Special initialization commands, used to pass information from the
596 ### configuration-run into config.status
599 DFT_ARG_SUFFIX="$DFT_ARG_SUFFIX"
600 DFT_LWR_MODEL="$DFT_LWR_MODEL"
602 LIB_PREFIX="$LIB_PREFIX"
603 LIB_SUFFIX="$LIB_SUFFIX"
605 NCURSES_MAJOR="$NCURSES_MAJOR"
606 NCURSES_MINOR="$NCURSES_MINOR"
607 NCURSES_PATCH="$NCURSES_PATCH"
608 USE_OLD_MAKERULES="$USE_OLD_MAKERULES"
609 cf_cv_VERSION_GNATMAKE=$cf_cv_VERSION_GNATMAKE
610 cf_cv_VERSION_GPRBUILD=$cf_cv_VERSION_GPRBUILD
611 cf_cv_abi_version="$cf_cv_abi_version"
612 cf_cv_rel_version="$cf_cv_rel_version"
613 cf_cv_rm_so_locs="$cf_cv_rm_so_locs"
614 cf_cv_shared_soname='$cf_cv_shared_soname'
615 cf_cv_shlib_version="$cf_cv_shlib_version"
616 cf_cv_shlib_version_infix="$cf_cv_shlib_version_infix"
617 cf_cv_system_name="$cf_cv_system_name"
622 ${MAKE:-make} preinstall