1 dnl $Id: aclocal.m4,v 1.49 2020/09/10 14:49:09 tom Exp $
2 dnl Macros for byacc configure script (Thomas E. Dickey)
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 2004-2019,2020 Thomas E. Dickey
6 dnl Permission is hereby granted, free of charge, to any person obtaining a
7 dnl copy of this software and associated documentation files (the
8 dnl "Software"), to deal in the Software without restriction, including
9 dnl without limitation the rights to use, copy, modify, merge, publish,
10 dnl distribute, distribute with modifications, sublicense, and/or sell
11 dnl copies of the Software, and to permit persons to whom the Software is
12 dnl furnished to do so, subject to the following conditions:
14 dnl The above copyright notice and this permission notice shall be included
15 dnl in all copies or portions of the Software.
17 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 dnl Except as contained in this notice, the name(s) of the above copyright
26 dnl holders shall not be used in advertising or otherwise to promote the
27 dnl sale, use or other dealings in this Software without prior written
29 dnl ---------------------------------------------------------------------------
30 dnl ---------------------------------------------------------------------------
31 dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
32 dnl ------------------
33 dnl Conditionally generate script according to whether we're using a given autoconf.
35 dnl $1 = version to compare against
36 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
37 dnl $3 = code to use if AC_ACVERSION is older than $1.
38 define([CF_ACVERSION_CHECK],
40 ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
41 ifdef([m4_version_compare],
42 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
43 [CF_ACVERSION_COMPARE(
44 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
45 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
46 dnl ---------------------------------------------------------------------------
47 dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
48 dnl --------------------
49 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
50 dnl MAJOR2, MINOR2, TERNARY2,
51 dnl PRINTABLE2, not FOUND, FOUND)
52 define([CF_ACVERSION_COMPARE],
53 [ifelse(builtin([eval], [$2 < $5]), 1,
54 [ifelse([$8], , ,[$8])],
55 [ifelse([$9], , ,[$9])])])dnl
56 dnl ---------------------------------------------------------------------------
57 dnl CF_ADD_CFLAGS version: 14 updated: 2020/04/04 16:16:13
59 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
61 dnl $2 = if given makes this macro verbose.
63 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
64 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
65 dnl confused by the quotes (which require backslashes to keep them usable).
66 AC_DEFUN([CF_ADD_CFLAGS],
71 cf_new_extra_cppflags=
73 for cf_add_cflags in $1
75 case $cf_fix_cppflags in
77 case $cf_add_cflags in
78 (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
79 case $cf_add_cflags in
81 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
83 test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
84 && test -z "${cf_tst_cflags}" \
85 && cf_fix_cppflags=yes
87 if test $cf_fix_cppflags = yes ; then
88 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
90 elif test "${cf_tst_cflags}" = "\"'" ; then
91 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
100 case $cf_add_cflags in
102 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
103 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
106 CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
111 CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
116 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
118 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
120 test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
121 && test -z "${cf_tst_cflags}" \
122 && cf_fix_cppflags=no
127 if test -n "$cf_new_cflags" ; then
128 ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
129 CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
132 if test -n "$cf_new_cppflags" ; then
133 ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
134 CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
137 if test -n "$cf_new_extra_cppflags" ; then
138 ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
139 CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
142 AC_SUBST(EXTRA_CPPFLAGS)
145 dnl ---------------------------------------------------------------------------
146 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
148 dnl use this macro for appending text without introducing an extra blank at
150 define([CF_APPEND_TEXT],
152 test -n "[$]$1" && $1="[$]$1 "
155 dnl ---------------------------------------------------------------------------
156 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
158 dnl Allow user to disable a normally-on option.
159 AC_DEFUN([CF_ARG_DISABLE],
160 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
161 dnl ---------------------------------------------------------------------------
162 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
164 dnl Allow user to enable a normally-off option.
165 AC_DEFUN([CF_ARG_ENABLE],
166 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
167 dnl ---------------------------------------------------------------------------
168 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
170 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
176 dnl $3 = action to perform if option is not default
177 dnl $4 = action if perform if option is default
178 dnl $5 = default option value (either 'yes' or 'no')
179 AC_DEFUN([CF_ARG_OPTION],
180 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
181 if test "$enableval" != "$5" ; then
183 ,[ $3]) ifelse([$4],,,[
186 fi],[enableval=$5 ifelse([$4],,,[
190 dnl ---------------------------------------------------------------------------
191 dnl CF_CC_ENV_FLAGS version: 9 updated: 2018/07/29 18:03:26
193 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
194 dnl into CC. This will not help with broken scripts that wrap the compiler
195 dnl with options, but eliminates a more common category of user confusion.
197 dnl In particular, it addresses the problem of being able to run the C
198 dnl preprocessor in a consistent manner.
200 dnl Caveat: this also disallows blanks in the pathname for the compiler, but
201 dnl the nuisance of having inconsistent settings for compiler and preprocessor
202 dnl outweighs that limitation.
203 AC_DEFUN([CF_CC_ENV_FLAGS],
205 # This should have been defined by AC_PROG_CC
208 AC_MSG_CHECKING(\$CFLAGS variable)
211 AC_MSG_RESULT(broken)
212 AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
215 for cf_arg in $cf_flags
217 CF_ADD_CFLAGS($cf_arg)
225 AC_MSG_CHECKING(\$CC variable)
228 AC_MSG_RESULT(broken)
229 AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
231 cf_prog=`echo "$CC" | sed -e 's/ / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
232 cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
234 for cf_arg in $cf_flags
238 CF_ADD_CFLAGS($cf_arg)
245 CF_VERBOSE(resulting CC: '$CC')
246 CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
247 CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
254 dnl ---------------------------------------------------------------------------
255 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
257 dnl Check if we're accidentally using a cache from a different machine.
258 dnl Derive the system name, as a check for reusing the autoconf cache.
260 dnl If we've packaged config.guess and config.sub, run that (since it does a
261 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
262 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
263 dnl which is useful in cross-compiles.
265 dnl Note: we would use $ac_config_sub, but that is one of the places where
266 dnl autoconf 2.5x broke compatibility with autoconf 2.13
267 AC_DEFUN([CF_CHECK_CACHE],
269 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
270 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
271 system_name="$host_os"
273 system_name="`(uname -s -r) 2>/dev/null`"
274 if test -z "$system_name" ; then
275 system_name="`(hostname) 2>/dev/null`"
278 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
279 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
281 test -z "$system_name" && system_name="$cf_cv_system_name"
282 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
284 if test ".$system_name" != ".$cf_cv_system_name" ; then
285 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
286 AC_MSG_ERROR("Please remove config.cache and try again.")
289 dnl ---------------------------------------------------------------------------
290 dnl CF_CLANG_COMPILER version: 3 updated: 2020/08/28 04:10:22
291 dnl -----------------
292 dnl Check if the given compiler is really clang. clang's C driver defines
293 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
294 dnl not ignore some gcc options.
296 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
297 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
298 dnl the wrappers for gcc and g++ warnings.
300 dnl $1 = GCC (default) or GXX
301 dnl $2 = CLANG_COMPILER (default)
302 dnl $3 = CFLAGS (default) or CXXFLAGS
303 AC_DEFUN([CF_CLANG_COMPILER],[
304 ifelse([$2],,CLANG_COMPILER,[$2])=no
306 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
307 AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
308 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
309 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
315 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
316 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
318 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
319 AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
322 if test "x$CLANG_COMPILER" = "xyes" ; then
323 CF_APPEND_TEXT(CFLAGS,-Wno-error=implicit-function-declaration)
326 dnl ---------------------------------------------------------------------------
327 dnl CF_CONST_X_STRING version: 4 updated: 2020/03/10 18:53:47
328 dnl -----------------
329 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
330 dnl character-strings.
332 dnl It is ambiguous because the specification accommodated the pre-ANSI
333 dnl compilers bundled by more than one vendor in lieu of providing a standard C
334 dnl compiler other than by costly add-ons. Because of this, the specification
335 dnl did not take into account the use of const for telling the compiler that
336 dnl string literals would be in readonly memory.
338 dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
339 dnl let the compiler decide how to represent Xt's strings which were #define'd.
340 dnl That does not solve the problem of using the block of Xt's strings which
341 dnl are compiled into the library (and is less efficient than one might want).
343 dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
344 dnl when compiling the library and compiling using the library, to tell the
345 dnl compiler that String is const.
346 AC_DEFUN([CF_CONST_X_STRING],
348 AC_REQUIRE([AC_PATH_XTRA])
350 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
355 #include <X11/Intrinsic.h>
357 [String foo = malloc(1); (void)foo],[
359 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
362 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
363 #undef XTSTRINGDEFINES /* X11R5 and later */
365 #include <X11/Intrinsic.h>
366 ],[String foo = malloc(1); *foo = 0],[
367 cf_cv_const_x_string=no
369 cf_cv_const_x_string=yes
373 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
375 case $cf_cv_const_x_string in
377 CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
380 CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
386 dnl ---------------------------------------------------------------------------
387 dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
389 dnl You can always use "make -n" to see the actual options, but it's hard to
390 dnl pick out/analyze warning messages when the compile-line is long.
393 dnl ECHO_LT - symbol to control if libtool is verbose
394 dnl ECHO_LD - symbol to prefix "cc -o" lines
395 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
396 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
397 dnl ECHO_CC - symbol to put before any "cc" line
399 AC_DEFUN([CF_DISABLE_ECHO],[
400 AC_MSG_CHECKING(if you want to see long compiling messages)
402 [ --disable-echo do not display "compiling" commands],
405 ECHO_LD='@echo linking [$]@;'
406 RULE_CC='@echo compiling [$]<'
407 SHOW_CC='@echo compiling [$]@'
416 AC_MSG_RESULT($enableval)
423 dnl ---------------------------------------------------------------------------
424 dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
426 dnl Combine no-leak checks with the libraries or tools that are used for the
428 AC_DEFUN([CF_DISABLE_LEAKS],[
430 AC_REQUIRE([CF_WITH_DMALLOC])
431 AC_REQUIRE([CF_WITH_DBMALLOC])
432 AC_REQUIRE([CF_WITH_VALGRIND])
434 AC_MSG_CHECKING(if you want to perform memory-leak testing)
436 [ --disable-leaks test: free permanent memory, analyze leaks],
437 [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
438 : ${with_no_leaks:=no})
439 AC_MSG_RESULT($with_no_leaks)
441 if test "$with_no_leaks" = yes ; then
442 AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
443 AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
446 dnl ---------------------------------------------------------------------------
447 dnl CF_ENABLE_WARNINGS version: 7 updated: 2020/08/29 09:05:21
448 dnl ------------------
449 dnl Configure-option to enable gcc warnings
451 dnl $1 = extra options to add, if supported
452 dnl $2 = option for checking attributes. By default, this is done when
453 dnl warnings are enabled. For other values:
454 dnl yes: always do this, e.g., to use in generated library-headers
455 dnl no: never do this
456 AC_DEFUN([CF_ENABLE_WARNINGS],[
457 if ( test "$GCC" = yes || test "$GXX" = yes )
459 CF_FIX_WARNINGS(CFLAGS)
460 CF_FIX_WARNINGS(CPPFLAGS)
461 CF_FIX_WARNINGS(LDFLAGS)
462 AC_MSG_CHECKING(if you want to turn on gcc warnings)
463 CF_ARG_ENABLE(warnings,
464 [ --enable-warnings test: turn on gcc compiler warnings],
467 AC_MSG_RESULT($with_warnings)
468 if test "$with_warnings" = "yes"
470 ifelse($2,,[CF_GCC_ATTRIBUTES])
473 ifelse($2,yes,[CF_GCC_ATTRIBUTES])
476 dnl ---------------------------------------------------------------------------
477 dnl CF_FIX_WARNINGS version: 2 updated: 2020/08/28 15:08:28
479 dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc. Any of gcc's
480 dnl "-Werror" flags can interfere with configure-checks. Those go into
483 dnl $1 = variable name to repair
484 define([CF_FIX_WARNINGS],[
485 if ( test "$GCC" = yes || test "$GXX" = yes )
489 CF_VERBOSE(repairing $1: [$]$1)
491 for cf_temp_scan in [$]$1
493 case "x$cf_temp_scan" in
495 CF_APPEND_TEXT(EXTRA_CFLAGS,"$cf_temp_scan")
498 CF_APPEND_TEXT(cf_temp_flags,"$cf_temp_scan")
503 CF_VERBOSE(... fixed [$]$1)
504 CF_VERBOSE(... extra $EXTRA_CFLAGS)
508 AC_SUBST(EXTRA_CFLAGS)
510 dnl ---------------------------------------------------------------------------
511 dnl CF_GCC_ATTRIBUTES version: 19 updated: 2020/08/29 09:05:21
512 dnl -----------------
513 dnl Test for availability of useful gcc __attribute__ directives to quiet
514 dnl compiler warnings. Though useful, not all are supported -- and contrary
515 dnl to documentation, unrecognized directives cause older compilers to barf.
516 AC_DEFUN([CF_GCC_ATTRIBUTES],
518 if ( test "$GCC" = yes || test "$GXX" = yes )
520 cat > conftest.i <<EOF
528 #define GCC_NORETURN /* nothing */
531 #define GCC_UNUSED /* nothing */
536 AC_CHECKING([for $CC __attribute__ directives])
537 cat > conftest.$ac_ext <<EOF
538 #line __oline__ "${as_me:-configure}"
539 #include "confdefs.h"
540 #include "conftest.h"
541 #include "conftest.i"
543 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
545 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
548 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
550 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
552 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
553 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
554 extern void foo(void) GCC_NORETURN;
555 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
557 cf_printf_attribute=no
558 cf_scanf_attribute=no
559 for cf_attribute in scanf printf unused noreturn
561 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
562 cf_directive="__attribute__(($cf_attribute))"
563 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
565 case $cf_attribute in
567 cf_printf_attribute=yes
568 cat >conftest.h <<EOF
569 #define GCC_$cf_ATTRIBUTE 1
573 cf_scanf_attribute=yes
574 cat >conftest.h <<EOF
575 #define GCC_$cf_ATTRIBUTE 1
579 cat >conftest.h <<EOF
580 #define GCC_$cf_ATTRIBUTE $cf_directive
585 if AC_TRY_EVAL(ac_compile); then
586 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
587 cat conftest.h >>confdefs.h
588 case $cf_attribute in
590 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
593 cf_value='/* nothing */'
594 if test "$cf_printf_attribute" != no ; then
595 cf_value='__attribute__((format(printf,fmt,var)))'
596 AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
598 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
601 cf_value='/* nothing */'
602 if test "$cf_scanf_attribute" != no ; then
603 cf_value='__attribute__((format(scanf,fmt,var)))'
604 AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
606 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
609 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
615 fgrep define conftest.i >>confdefs.h
620 dnl ---------------------------------------------------------------------------
621 dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
623 dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
624 dnl compatible), attempt to determine if icc/clang is actually used.
625 AC_DEFUN([CF_GCC_VERSION],[
626 AC_REQUIRE([AC_PROG_CC])
628 if test "$GCC" = yes ; then
629 AC_MSG_CHECKING(version of $CC)
630 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
631 test -z "$GCC_VERSION" && GCC_VERSION=unknown
632 AC_MSG_RESULT($GCC_VERSION)
634 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
635 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
637 dnl ---------------------------------------------------------------------------
638 dnl CF_GCC_WARNINGS version: 38 updated: 2020/08/28 15:08:28
640 dnl Check if the compiler supports useful warning options. There's a few that
641 dnl we don't use, simply because they're too noisy:
643 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
644 dnl -Winline (usually not worthwhile)
645 dnl -Wredundant-decls (system headers make this too noisy)
646 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
647 dnl -Wwrite-strings (too noisy, but should review occasionally). This
648 dnl is enabled for ncurses using "--enable-const".
652 dnl $1 is an optional list of gcc warning flags that a particular
653 dnl application might want to use, e.g., "no-unused" for
656 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
658 AC_DEFUN([CF_GCC_WARNINGS],
660 AC_REQUIRE([CF_GCC_VERSION])
661 if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
662 cat > conftest.$ac_ext <<EOF
663 #line __oline__ "${as_me:-configure}"
664 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
666 if test "$INTEL_COMPILER" = yes
668 # The "-wdXXX" options suppress warnings:
669 # remark #1419: external declaration in primary source file
670 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
671 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
672 # remark #193: zero used for undefined preprocessing identifier
673 # remark #593: variable "curs_sb_left_arrow" was set but never used
674 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
675 # remark #869: parameter "tw" was never referenced
676 # remark #981: operands are evaluated in unspecified order
677 # warning #279: controlling expression is constant
679 AC_CHECKING([for $CC warning options])
680 cf_save_CFLAGS="$CFLAGS"
681 EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
693 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
694 if AC_TRY_EVAL(ac_compile); then
695 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
696 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
699 CFLAGS="$cf_save_CFLAGS"
700 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
702 AC_CHECKING([for $CC warning options])
703 cf_save_CFLAGS="$CFLAGS"
705 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
706 cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
707 test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
708 for cf_opt in W Wall \
712 Wdeclaration-after-statement \
715 Wmissing-declarations \
716 Wmissing-prototypes \
721 Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
723 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
724 if AC_TRY_EVAL(ac_compile); then
725 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
730 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
737 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
742 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
745 CFLAGS="$cf_save_CFLAGS"
749 AC_SUBST(EXTRA_CFLAGS)
751 dnl ---------------------------------------------------------------------------
752 dnl CF_GETOPT_HEADER version: 6 updated: 2014/07/22 14:45:54
754 dnl Check for getopt's variables which are commonly defined in stdlib.h,
755 dnl unistd.h or (nonstandard) in getopt.h
756 AC_DEFUN([CF_GETOPT_HEADER],
758 AC_HAVE_HEADERS(unistd.h getopt.h)
759 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
760 cf_cv_getopt_header=none
761 for cf_header in stdio.h stdlib.h unistd.h getopt.h
764 #include <$cf_header>],
765 [int x = optind; char *y = optarg],
766 [cf_cv_getopt_header=$cf_header
770 if test $cf_cv_getopt_header != none ; then
771 AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
773 if test $cf_cv_getopt_header = getopt.h ; then
774 AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
777 dnl ---------------------------------------------------------------------------
778 dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
780 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
781 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
782 dnl (or misfeature) of glibc2, which breaks portability of many applications,
783 dnl since it is interwoven with GNU extensions.
785 dnl Well, yes we could work around it...
788 dnl $1 is the nominal value for _XOPEN_SOURCE
789 AC_DEFUN([CF_GNU_SOURCE],
791 cf_gnu_xopen_source=ifelse($1,,500,$1)
793 AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
794 AC_TRY_COMPILE([#include <sys/types.h>],[
795 #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
797 #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
800 # error not GNU C library
802 [cf_cv_gnu_library=yes],
803 [cf_cv_gnu_library=no])
806 if test x$cf_cv_gnu_library = xyes; then
808 # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
809 # was changed to help a little. newlib incorporated the change about 4
811 AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
813 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
814 AC_TRY_COMPILE([#include <sys/types.h>],[
815 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
817 #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
820 # error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
822 [cf_cv_gnu_library_219=yes],
823 [cf_cv_gnu_library_219=no])
827 if test "x$cf_cv_gnu_library_219" = xyes; then
829 AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
830 CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
833 #include <sys/types.h>
835 #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
838 # error GNU C library is too old
840 [cf_cv_gnu_dftsrc_219=yes],
841 [cf_cv_gnu_dftsrc_219=no])
843 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
845 cf_cv_gnu_dftsrc_219=maybe
848 if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
850 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
851 AC_TRY_COMPILE([#include <sys/types.h>],[
852 #ifndef _XOPEN_SOURCE
853 #error expected _XOPEN_SOURCE to be defined
855 [cf_cv_gnu_source=no],
857 CF_ADD_CFLAGS(-D_GNU_SOURCE)
858 AC_TRY_COMPILE([#include <sys/types.h>],[
860 #error expected _XOPEN_SOURCE to be undefined
862 [cf_cv_gnu_source=no],
863 [cf_cv_gnu_source=yes])
868 if test "$cf_cv_gnu_source" = yes
870 AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
871 CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
872 AC_TRY_COMPILE([#include <sys/types.h>],[
873 #ifdef _DEFAULT_SOURCE
874 #error expected _DEFAULT_SOURCE to be undefined
876 [cf_cv_default_source=no],
877 [cf_cv_default_source=yes])
879 if test "$cf_cv_default_source" = yes
881 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
888 dnl ---------------------------------------------------------------------------
889 dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
890 dnl -----------------
891 dnl Check if the given compiler is really the Intel compiler for Linux. It
892 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
893 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
895 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
896 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
897 dnl the wrappers for gcc and g++ warnings.
899 dnl $1 = GCC (default) or GXX
900 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
901 dnl $3 = CFLAGS (default) or CXXFLAGS
902 AC_DEFUN([CF_INTEL_COMPILER],[
903 AC_REQUIRE([AC_CANONICAL_HOST])
904 ifelse([$2],,INTEL_COMPILER,[$2])=no
906 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
909 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
910 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
911 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
913 #ifdef __INTEL_COMPILER
917 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
918 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
920 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
921 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
926 dnl ---------------------------------------------------------------------------
927 dnl CF_MAKE_DOCS version: 4 updated: 2015/07/04 21:43:03
929 dnl $1 = name(s) to generate rules for
930 dnl $2 = suffix of corresponding manpages used as input.
932 dnl This works best if called at the end of configure.in, following CF_WITH_MAN2HTML
933 define([CF_MAKE_DOCS],[
934 test -z "$cf_make_docs" && cf_make_docs=0
937 test -f "$cf_output" || cf_output=Makefile
939 if test "$cf_make_docs" = 0
941 cat >>$cf_output <<CF_EOF
942 ################################################################################
944 .SUFFIXES : .html .$2 .man .ps .pdf .txt
946 ${NROFF_NOTE}.$2.txt :
947 ${NROFF_NOTE} [\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
949 ${GROFF_NOTE}.ps.pdf :
950 ${GROFF_NOTE} ps2pdf [\$]*.ps
952 ${GROFF_NOTE}.$2.ps :
953 ${GROFF_NOTE} [\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
955 ${GROFF_NOTE}.$2.txt :
956 ${GROFF_NOTE} GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -Tascii -man | col -bx" >[\$]@
958 ${MAN2HTML_NOTE}.$2.html :
959 ${MAN2HTML_NOTE} ./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
967 cat >>$cf_output <<CF_EOF
968 ################################################################################
969 ${NROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
970 ${MAN2HTML_NOTE}docs docs-$cf_name :: $cf_name.html
971 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.pdf
972 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.ps
973 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
977 ${NROFF_NOTE} rm -f $cf_name.txt
978 ${MAN2HTML_NOTE} rm -f $cf_name.html
979 ${GROFF_NOTE} rm -f $cf_name.pdf
980 ${GROFF_NOTE} rm -f $cf_name.ps
981 ${GROFF_NOTE} rm -f $cf_name.txt
983 ${NROFF_NOTE}$cf_name.txt : $cf_name.$2
984 ${MAN2HTML_NOTE}$cf_name.html : $cf_name.$2
985 ${GROFF_NOTE}$cf_name.pdf : $cf_name.ps
986 ${GROFF_NOTE}$cf_name.ps : $cf_name.$2
987 ${GROFF_NOTE}$cf_name.txt : $cf_name.$2
991 dnl ---------------------------------------------------------------------------
992 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
994 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
995 dnl a monocase filesystem.
996 AC_DEFUN([CF_MAKE_TAGS],[
997 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
999 AC_CHECK_PROGS(CTAGS, exctags ctags)
1000 AC_CHECK_PROGS(ETAGS, exetags etags)
1002 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1004 if test "$cf_cv_mixedcase" = yes ; then
1005 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1010 if test "$MAKE_UPPER_TAGS" = yes ; then
1016 if test "$MAKE_LOWER_TAGS" = yes ; then
1025 AC_SUBST(MAKE_UPPER_TAGS)
1026 AC_SUBST(MAKE_LOWER_TAGS)
1028 dnl ---------------------------------------------------------------------------
1029 dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
1030 dnl ----------------------
1031 dnl Check if the file-system supports mixed-case filenames. If we're able to
1032 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1033 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1035 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1036 if test "$cross_compiling" = yes ; then
1037 case $target_alias in
1038 (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
1046 rm -f conftest CONFTEST
1048 if test -f CONFTEST ; then
1053 rm -f conftest CONFTEST
1056 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1058 dnl ---------------------------------------------------------------------------
1059 dnl CF_MKSTEMP version: 10 updated: 2017/01/21 11:12:16
1061 dnl Check for a working mkstemp. This creates two files, checks that they are
1062 dnl successfully created and distinct (AmigaOS apparently fails on the last).
1063 AC_DEFUN([CF_MKSTEMP],[
1067 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
1070 #include <sys/types.h>
1071 #ifdef HAVE_UNISTD_H
1077 #include <sys/stat.h>
1080 char *tmpl = "conftestXXXXXX";
1088 for (n = 0; n < 2; ++n) {
1089 strcpy(name[n], tmpl);
1090 if ((fd = mkstemp(name[n])) >= 0) {
1091 if (!strcmp(name[n], tmpl)
1092 || stat(name[n], &sb) != 0
1093 || (sb.st_mode & S_IFMT) != S_IFREG
1094 || (sb.st_mode & 077) != 0) {
1101 && !strcmp(name[0], name[1]))
1103 ${cf_cv_main_return:-return}(result);
1105 ],[cf_cv_func_mkstemp=yes
1106 ],[cf_cv_func_mkstemp=no
1107 ],[cf_cv_func_mkstemp=maybe])
1109 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
1110 AC_CHECK_FUNC(mkstemp)
1112 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
1113 AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
1116 dnl ---------------------------------------------------------------------------
1117 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1119 dnl Write a debug message to config.log, along with the line number in the
1120 dnl configure script.
1121 AC_DEFUN([CF_MSG_LOG],[
1122 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1124 dnl ---------------------------------------------------------------------------
1125 dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
1126 dnl ------------------
1127 dnl see CF_WITH_NO_LEAKS
1128 AC_DEFUN([CF_NO_LEAKS_OPTION],[
1129 AC_MSG_CHECKING(if you want to use $1 for testing)
1132 [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1135 : ${with_cflags:=-g}
1136 : ${with_no_leaks:=yes}
1139 AC_MSG_RESULT(${with_$1:-no})
1141 case .$with_cflags in
1153 dnl ---------------------------------------------------------------------------
1154 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
1156 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1157 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1158 dnl result begins with 'NONE'. This is necessary to work around autoconf's
1159 dnl delayed evaluation of those symbols.
1160 AC_DEFUN([CF_PATH_SYNTAX],[
1161 if test "x$prefix" != xNONE; then
1162 cf_path_syntax="$prefix"
1164 cf_path_syntax="$ac_default_prefix"
1168 (.\[$]\(*\)*|.\'*\'*)
1172 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1174 (.\[$]{*prefix}*|.\[$]{*dir}*)
1178 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1183 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1186 ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1190 dnl ---------------------------------------------------------------------------
1191 dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
1192 dnl -----------------
1193 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1195 dnl POSIX.1-1990 _POSIX_SOURCE
1196 dnl POSIX.1-1990 and _POSIX_SOURCE and
1197 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
1199 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
1200 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
1201 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
1204 dnl $1 is the nominal value for _POSIX_C_SOURCE
1205 AC_DEFUN([CF_POSIX_C_SOURCE],
1206 [AC_REQUIRE([CF_POSIX_VISIBLE])dnl
1208 if test "$cf_cv_posix_visible" = no; then
1210 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1212 cf_save_CFLAGS="$CFLAGS"
1213 cf_save_CPPFLAGS="$CPPFLAGS"
1215 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1216 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1218 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1219 CF_MSG_LOG(if the symbol is already defined go no further)
1220 AC_TRY_COMPILE([#include <sys/types.h>],[
1221 #ifndef _POSIX_C_SOURCE
1224 [cf_cv_posix_c_source=no],
1225 [cf_want_posix_source=no
1226 case .$cf_POSIX_C_SOURCE in
1228 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1231 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1232 cf_want_posix_source=yes
1235 cf_want_posix_source=yes
1238 if test "$cf_want_posix_source" = yes ; then
1239 AC_TRY_COMPILE([#include <sys/types.h>],[
1240 #ifdef _POSIX_SOURCE
1243 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1245 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1246 CFLAGS="$cf_trim_CFLAGS"
1247 CPPFLAGS="$cf_trim_CPPFLAGS"
1248 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
1249 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1250 AC_TRY_COMPILE([#include <sys/types.h>],[
1251 #ifndef _POSIX_C_SOURCE
1254 [cf_cv_posix_c_source=no])
1255 CFLAGS="$cf_save_CFLAGS"
1256 CPPFLAGS="$cf_save_CPPFLAGS"
1260 if test "$cf_cv_posix_c_source" != no ; then
1261 CFLAGS="$cf_trim_CFLAGS"
1262 CPPFLAGS="$cf_trim_CPPFLAGS"
1263 CF_ADD_CFLAGS($cf_cv_posix_c_source)
1266 fi # cf_cv_posix_visible
1269 dnl ---------------------------------------------------------------------------
1270 dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
1271 dnl ----------------
1272 dnl POSIX documents test-macros which an application may set before any system
1273 dnl headers are included to make features available.
1275 dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
1276 dnl diverged from POSIX in 2002 by setting symbols which make all of the most
1277 dnl recent features visible in the system header files unless the application
1278 dnl overrides the corresponding test-macros. Doing that introduces portability
1281 dnl This macro makes a special check for the symbols used for this, to avoid a
1282 dnl conflicting definition.
1283 AC_DEFUN([CF_POSIX_VISIBLE],
1285 AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
1286 AC_TRY_COMPILE([#include <stdio.h>],[
1287 #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
1288 && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
1289 && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
1290 && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
1291 #error conflicting symbols found
1293 ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
1296 dnl ---------------------------------------------------------------------------
1297 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
1299 dnl Check for awk, ensure that the check found something.
1300 AC_DEFUN([CF_PROG_AWK],
1303 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
1305 dnl ---------------------------------------------------------------------------
1306 dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
1308 dnl standard check for CC, plus followup sanity checks
1309 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1310 AC_DEFUN([CF_PROG_CC],[
1311 CF_ACVERSION_CHECK(2.53,
1312 [AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
1313 AC_REQUIRE([AC_PROG_CC])],
1315 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1317 CF_ACVERSION_CHECK(2.52,
1322 dnl ---------------------------------------------------------------------------
1323 dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
1325 dnl Check if groff is available, for cases (such as html output) where nroff
1327 AC_DEFUN([CF_PROG_GROFF],[
1328 AC_PATH_PROG(GROFF_PATH,groff,no)
1329 AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
1330 AC_PATH_PROG(TBL_PATH,tbl,cat)
1331 if test "x$GROFF_PATH" = xno
1339 AC_SUBST(GROFF_NOTE)
1340 AC_SUBST(NROFF_NOTE)
1342 dnl ---------------------------------------------------------------------------
1343 dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
1345 AC_DEFUN([CF_PROG_LINT],
1347 AC_CHECK_PROGS(LINT, lint cppcheck splint)
1349 (xcppcheck|x*/cppcheck)
1350 test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
1355 dnl ---------------------------------------------------------------------------
1356 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1357 dnl ----------------
1358 dnl Remove all -U and -D options that refer to the given symbol from a list
1359 dnl of C compiler options. This works around the problem that not all
1360 dnl compilers process -U and -D options from left-to-right, so a -U option
1361 dnl cannot be used to cancel the effect of a preceding -D option.
1363 dnl $1 = target (which could be the same as the source variable)
1364 dnl $2 = source (including '$')
1365 dnl $3 = symbol to remove
1366 define([CF_REMOVE_DEFINE],
1369 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
1370 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
1372 dnl ---------------------------------------------------------------------------
1373 dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
1374 dnl -------------------
1375 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1376 dnl can define it successfully.
1377 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1378 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1382 #include <sys/types.h>
1384 #ifndef _XOPEN_SOURCE
1387 [cf_cv_xopen_source=no],
1388 [cf_save="$CPPFLAGS"
1389 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
1393 #include <sys/types.h>
1395 #ifdef _XOPEN_SOURCE
1398 [cf_cv_xopen_source=no],
1399 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1404 if test "$cf_cv_xopen_source" != no ; then
1405 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1406 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1407 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1408 CF_ADD_CFLAGS($cf_temp_xopen_source)
1411 dnl ---------------------------------------------------------------------------
1412 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1414 dnl Make an uppercase version of a variable
1415 dnl $1=uppercase($2)
1416 AC_DEFUN([CF_UPPER],
1418 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1420 dnl ---------------------------------------------------------------------------
1421 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1423 dnl Use AC_VERBOSE w/o the warnings
1424 AC_DEFUN([CF_VERBOSE],
1425 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1428 dnl ---------------------------------------------------------------------------
1429 dnl CF_WITHOUT_X version: 1 updated: 2020/03/03 18:27:24
1431 dnl Use this to cancel the check for X headers/libraries which would be pulled
1432 dnl in via CF_GCC_WARNINGS.
1433 define([CF_WITHOUT_X],
1434 AC_DEFUN([CF_CONST_X_STRING],[echo "skipping X-const check";])dnl
1436 dnl ---------------------------------------------------------------------------
1437 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1438 dnl ----------------
1439 dnl Configure-option for dbmalloc. The optional parameter is used to override
1440 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1441 AC_DEFUN([CF_WITH_DBMALLOC],[
1442 CF_NO_LEAKS_OPTION(dbmalloc,
1443 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
1446 if test "$with_dbmalloc" = yes ; then
1447 AC_CHECK_HEADER(dbmalloc.h,
1448 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1451 dnl ---------------------------------------------------------------------------
1452 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1454 dnl Configure-option for dmalloc. The optional parameter is used to override
1455 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1456 AC_DEFUN([CF_WITH_DMALLOC],[
1457 CF_NO_LEAKS_OPTION(dmalloc,
1458 [ --with-dmalloc test: use Gray Watson's dmalloc library],
1461 if test "$with_dmalloc" = yes ; then
1462 AC_CHECK_HEADER(dmalloc.h,
1463 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1466 dnl ---------------------------------------------------------------------------
1467 dnl CF_WITH_MAN2HTML version: 8 updated: 2018/06/27 18:44:03
1468 dnl ----------------
1469 dnl Check for man2html and groff. Prefer man2html over groff, but use groff
1470 dnl as a fallback. See
1472 dnl http://invisible-island.net/scripts/man2html.html
1474 dnl Generate a shell script which hides the differences between the two.
1476 dnl We name that "man2html.tmp".
1478 dnl The shell script can be removed later, e.g., using "make distclean".
1479 AC_DEFUN([CF_WITH_MAN2HTML],[
1480 AC_REQUIRE([CF_PROG_GROFF])
1482 case "x${with_man2html}" in
1487 AC_PATH_PROG(cf_man2html,man2html,no)
1488 case "x$cf_man2html" in
1490 AC_MSG_CHECKING(for the modified Earl Hood script)
1491 if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
1498 AC_MSG_RESULT($cf_man2html_ok)
1506 AC_MSG_CHECKING(for program to convert manpage to html)
1507 AC_ARG_WITH(man2html,
1508 [ --with-man2html=XXX use XXX rather than groff],
1509 [cf_man2html=$withval],
1510 [cf_man2html=$cf_man2html])
1514 case $cf_man2html in
1516 AC_MSG_RESULT(man2html)
1517 AC_PATH_PROG(cf_man2html,man2html,no)
1521 cf_man2html=$GROFF_PATH
1522 AC_MSG_RESULT($cf_man2html)
1525 AC_MSG_RESULT($cf_man2html)
1529 MAN2HTML_TEMP="man2html.tmp"
1530 cat >$MAN2HTML_TEMP <<CF_EOF
1532 # Temporary script generated by CF_WITH_MAN2HTML
1533 # Convert inputs to html, sending result to standard output.
1536 # \${1} = rootname of file to convert
1537 # \${2} = suffix of file to convert, e.g., "1"
1538 # \${3} = macros to use, e.g., "man"
1553 if test "x$cf_with_groff" = xyes
1555 MAN2HTML_NOTE="$GROFF_NOTE"
1556 MAN2HTML_PATH="$GROFF_PATH"
1557 cat >>$MAN2HTML_TEMP <<CF_EOF
1558 $SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
1562 CF_PATH_SYNTAX(cf_man2html)
1563 MAN2HTML_PATH="$cf_man2html"
1564 AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
1566 # for this example, expect 3 lines of content, the remainder is head/foot
1567 cat >conftest.in <<CF_EOF
1568 .TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
1573 LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1575 cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1576 cf_man2html_top=`expr $cf_man2html_1st - 2`
1577 cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
1578 cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
1579 cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
1581 AC_MSG_RESULT($cf_man2html_top_bot)
1583 AC_MSG_CHECKING(for pagesize to use)
1584 for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1586 cat >>conftest.in <<CF_EOF
1601 LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1602 cf_man2html_page=`fgrep -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1603 test -z "$cf_man2html_page" && cf_man2html_page=99999
1604 test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
1607 AC_MSG_RESULT($cf_man2html_page)
1609 cat >>$MAN2HTML_TEMP <<CF_EOF
1610 : \${MAN2HTML_PATH=$MAN2HTML_PATH}
1611 MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page"
1614 $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
1617 $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
1623 chmod 700 $MAN2HTML_TEMP
1625 AC_SUBST(MAN2HTML_NOTE)
1626 AC_SUBST(MAN2HTML_PATH)
1627 AC_SUBST(MAN2HTML_TEMP)
1629 dnl ---------------------------------------------------------------------------
1630 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
1631 dnl ----------------
1632 AC_DEFUN([CF_WITH_VALGRIND],[
1633 CF_NO_LEAKS_OPTION(valgrind,
1634 [ --with-valgrind test: use valgrind],
1637 dnl ---------------------------------------------------------------------------
1638 dnl CF_XOPEN_SOURCE version: 55 updated: 2018/12/31 20:46:17
1640 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1641 dnl or adapt to the vendor's definitions to get equivalent functionality,
1642 dnl without losing the common non-POSIX features.
1645 dnl $1 is the nominal value for _XOPEN_SOURCE
1646 dnl $2 is the nominal value for _POSIX_C_SOURCE
1647 AC_DEFUN([CF_XOPEN_SOURCE],[
1648 AC_REQUIRE([AC_CANONICAL_HOST])
1649 AC_REQUIRE([CF_POSIX_VISIBLE])
1651 if test "$cf_cv_posix_visible" = no; then
1653 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1654 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1659 cf_xopen_source="-D_ALL_SOURCE"
1665 cf_xopen_source="-D_APPLE_C_SOURCE"
1668 cf_xopen_source="-D_DARWIN_C_SOURCE"
1671 (freebsd*|dragonfly*|midnightbsd*)
1672 # 5.x headers associate
1673 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1674 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1675 cf_POSIX_C_SOURCE=200112L
1677 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1680 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1683 cf_xopen_source="-D_HPUX_SOURCE"
1686 cf_xopen_source="-D_SGI_SOURCE"
1689 (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
1690 CF_GNU_SOURCE($cf_XOPEN_SOURCE)
1693 cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
1696 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1698 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1701 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1704 # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1705 cf_xopen_source="-D_BSD_SOURCE"
1709 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1712 cf_xopen_source="-D_OSF_SOURCE"
1715 cf_xopen_source="-D_QNX_SOURCE"
1718 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1721 cf_xopen_source="-D__EXTENSIONS__"
1722 cf_cv_xopen_source=broken
1724 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
1730 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1734 if test -n "$cf_xopen_source" ; then
1735 CF_ADD_CFLAGS($cf_xopen_source,true)
1738 dnl In anything but the default case, we may have system-specific setting
1739 dnl which is still not guaranteed to provide all of the entrypoints that
1740 dnl _XOPEN_SOURCE would yield.
1741 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1742 AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1743 AC_TRY_COMPILE([#include <stdlib.h>],[
1744 #ifndef _XOPEN_SOURCE
1747 [cf_XOPEN_SOURCE_set=yes],
1748 [cf_XOPEN_SOURCE_set=no])
1749 AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1750 if test $cf_XOPEN_SOURCE_set = yes
1752 AC_TRY_COMPILE([#include <stdlib.h>],[
1753 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1756 [cf_XOPEN_SOURCE_set_ok=yes],
1757 [cf_XOPEN_SOURCE_set_ok=no])
1758 if test $cf_XOPEN_SOURCE_set_ok = no
1760 AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
1766 fi # cf_cv_posix_visible