1 dnl $Id: aclocal.m4,v 1.48 2020/03/10 22:53:47 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: 13 updated: 2017/02/25 18:57:40
59 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
60 dnl The second parameter if given makes this macro verbose.
62 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
63 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
64 dnl confused by the quotes (which require backslashes to keep them usable).
65 AC_DEFUN([CF_ADD_CFLAGS],
70 cf_new_extra_cppflags=
72 for cf_add_cflags in $1
74 case $cf_fix_cppflags in
76 case $cf_add_cflags in
77 (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
78 case $cf_add_cflags in
80 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
82 test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
83 && test -z "${cf_tst_cflags}" \
84 && cf_fix_cppflags=yes
86 if test $cf_fix_cppflags = yes ; then
87 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
89 elif test "${cf_tst_cflags}" = "\"'" ; then
90 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
99 case $cf_add_cflags in
101 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
102 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
105 CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
110 CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
115 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
117 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
119 test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
120 && test -z "${cf_tst_cflags}" \
121 && cf_fix_cppflags=no
126 if test -n "$cf_new_cflags" ; then
127 ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
128 CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
131 if test -n "$cf_new_cppflags" ; then
132 ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
133 CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
136 if test -n "$cf_new_extra_cppflags" ; then
137 ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
138 CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
141 AC_SUBST(EXTRA_CPPFLAGS)
144 dnl ---------------------------------------------------------------------------
145 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
147 dnl use this macro for appending text without introducing an extra blank at
149 define([CF_APPEND_TEXT],
151 test -n "[$]$1" && $1="[$]$1 "
154 dnl ---------------------------------------------------------------------------
155 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
157 dnl Allow user to disable a normally-on option.
158 AC_DEFUN([CF_ARG_DISABLE],
159 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
160 dnl ---------------------------------------------------------------------------
161 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
163 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
169 dnl $3 = action to perform if option is not default
170 dnl $4 = action if perform if option is default
171 dnl $5 = default option value (either 'yes' or 'no')
172 AC_DEFUN([CF_ARG_OPTION],
173 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
174 if test "$enableval" != "$5" ; then
176 ,[ $3]) ifelse([$4],,,[
179 fi],[enableval=$5 ifelse([$4],,,[
183 dnl ---------------------------------------------------------------------------
184 dnl CF_CC_ENV_FLAGS version: 9 updated: 2018/07/29 18:03:26
186 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
187 dnl into CC. This will not help with broken scripts that wrap the compiler
188 dnl with options, but eliminates a more common category of user confusion.
190 dnl In particular, it addresses the problem of being able to run the C
191 dnl preprocessor in a consistent manner.
193 dnl Caveat: this also disallows blanks in the pathname for the compiler, but
194 dnl the nuisance of having inconsistent settings for compiler and preprocessor
195 dnl outweighs that limitation.
196 AC_DEFUN([CF_CC_ENV_FLAGS],
198 # This should have been defined by AC_PROG_CC
201 AC_MSG_CHECKING(\$CFLAGS variable)
204 AC_MSG_RESULT(broken)
205 AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
208 for cf_arg in $cf_flags
210 CF_ADD_CFLAGS($cf_arg)
218 AC_MSG_CHECKING(\$CC variable)
221 AC_MSG_RESULT(broken)
222 AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
224 cf_prog=`echo "$CC" | sed -e 's/ / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
225 cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
227 for cf_arg in $cf_flags
231 CF_ADD_CFLAGS($cf_arg)
238 CF_VERBOSE(resulting CC: '$CC')
239 CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
240 CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
247 dnl ---------------------------------------------------------------------------
248 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
250 dnl Check if we're accidentally using a cache from a different machine.
251 dnl Derive the system name, as a check for reusing the autoconf cache.
253 dnl If we've packaged config.guess and config.sub, run that (since it does a
254 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
255 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
256 dnl which is useful in cross-compiles.
258 dnl Note: we would use $ac_config_sub, but that is one of the places where
259 dnl autoconf 2.5x broke compatibility with autoconf 2.13
260 AC_DEFUN([CF_CHECK_CACHE],
262 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
263 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
264 system_name="$host_os"
266 system_name="`(uname -s -r) 2>/dev/null`"
267 if test -z "$system_name" ; then
268 system_name="`(hostname) 2>/dev/null`"
271 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
272 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
274 test -z "$system_name" && system_name="$cf_cv_system_name"
275 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
277 if test ".$system_name" != ".$cf_cv_system_name" ; then
278 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
279 AC_MSG_ERROR("Please remove config.cache and try again.")
282 dnl ---------------------------------------------------------------------------
283 dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
284 dnl -----------------
285 dnl Check if the given compiler is really clang. clang's C driver defines
286 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
287 dnl not ignore some gcc options.
289 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
290 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
291 dnl the wrappers for gcc and g++ warnings.
293 dnl $1 = GCC (default) or GXX
294 dnl $2 = CLANG_COMPILER (default)
295 dnl $3 = CFLAGS (default) or CXXFLAGS
296 AC_DEFUN([CF_CLANG_COMPILER],[
297 ifelse([$2],,CLANG_COMPILER,[$2])=no
299 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
300 AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
301 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
302 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
308 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
309 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
311 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
312 AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
315 dnl ---------------------------------------------------------------------------
316 dnl CF_CONST_X_STRING version: 4 updated: 2020/03/10 18:53:47
317 dnl -----------------
318 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
319 dnl character-strings.
321 dnl It is ambiguous because the specification accommodated the pre-ANSI
322 dnl compilers bundled by more than one vendor in lieu of providing a standard C
323 dnl compiler other than by costly add-ons. Because of this, the specification
324 dnl did not take into account the use of const for telling the compiler that
325 dnl string literals would be in readonly memory.
327 dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
328 dnl let the compiler decide how to represent Xt's strings which were #define'd.
329 dnl That does not solve the problem of using the block of Xt's strings which
330 dnl are compiled into the library (and is less efficient than one might want).
332 dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
333 dnl when compiling the library and compiling using the library, to tell the
334 dnl compiler that String is const.
335 AC_DEFUN([CF_CONST_X_STRING],
337 AC_REQUIRE([AC_PATH_XTRA])
339 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
344 #include <X11/Intrinsic.h>
346 [String foo = malloc(1); (void)foo],[
348 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
351 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
352 #undef XTSTRINGDEFINES /* X11R5 and later */
354 #include <X11/Intrinsic.h>
355 ],[String foo = malloc(1); *foo = 0],[
356 cf_cv_const_x_string=no
358 cf_cv_const_x_string=yes
362 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
364 case $cf_cv_const_x_string in
366 CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
369 CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
375 dnl ---------------------------------------------------------------------------
376 dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
378 dnl You can always use "make -n" to see the actual options, but it's hard to
379 dnl pick out/analyze warning messages when the compile-line is long.
382 dnl ECHO_LT - symbol to control if libtool is verbose
383 dnl ECHO_LD - symbol to prefix "cc -o" lines
384 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
385 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
386 dnl ECHO_CC - symbol to put before any "cc" line
388 AC_DEFUN([CF_DISABLE_ECHO],[
389 AC_MSG_CHECKING(if you want to see long compiling messages)
391 [ --disable-echo do not display "compiling" commands],
394 ECHO_LD='@echo linking [$]@;'
395 RULE_CC='@echo compiling [$]<'
396 SHOW_CC='@echo compiling [$]@'
405 AC_MSG_RESULT($enableval)
412 dnl ---------------------------------------------------------------------------
413 dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
415 dnl Combine no-leak checks with the libraries or tools that are used for the
417 AC_DEFUN([CF_DISABLE_LEAKS],[
419 AC_REQUIRE([CF_WITH_DMALLOC])
420 AC_REQUIRE([CF_WITH_DBMALLOC])
421 AC_REQUIRE([CF_WITH_VALGRIND])
423 AC_MSG_CHECKING(if you want to perform memory-leak testing)
425 [ --disable-leaks test: free permanent memory, analyze leaks],
426 [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
427 : ${with_no_leaks:=no})
428 AC_MSG_RESULT($with_no_leaks)
430 if test "$with_no_leaks" = yes ; then
431 AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
432 AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
435 dnl ---------------------------------------------------------------------------
436 dnl CF_GCC_ATTRIBUTES version: 18 updated: 2020/03/10 18:53:47
437 dnl -----------------
438 dnl Test for availability of useful gcc __attribute__ directives to quiet
439 dnl compiler warnings. Though useful, not all are supported -- and contrary
440 dnl to documentation, unrecognized directives cause older compilers to barf.
441 AC_DEFUN([CF_GCC_ATTRIBUTES],
445 cat > conftest.i <<EOF
453 #define GCC_NORETURN /* nothing */
456 #define GCC_UNUSED /* nothing */
461 AC_CHECKING([for $CC __attribute__ directives])
462 cat > conftest.$ac_ext <<EOF
463 #line __oline__ "${as_me:-configure}"
464 #include "confdefs.h"
465 #include "conftest.h"
466 #include "conftest.i"
468 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
470 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
473 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
475 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
477 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
478 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
479 extern void foo(void) GCC_NORETURN;
480 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
482 cf_printf_attribute=no
483 cf_scanf_attribute=no
484 for cf_attribute in scanf printf unused noreturn
486 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
487 cf_directive="__attribute__(($cf_attribute))"
488 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
490 case $cf_attribute in
492 cf_printf_attribute=yes
493 cat >conftest.h <<EOF
494 #define GCC_$cf_ATTRIBUTE 1
498 cf_scanf_attribute=yes
499 cat >conftest.h <<EOF
500 #define GCC_$cf_ATTRIBUTE 1
504 cat >conftest.h <<EOF
505 #define GCC_$cf_ATTRIBUTE $cf_directive
510 if AC_TRY_EVAL(ac_compile); then
511 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
512 cat conftest.h >>confdefs.h
513 case $cf_attribute in
515 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
518 cf_value='/* nothing */'
519 if test "$cf_printf_attribute" != no ; then
520 cf_value='__attribute__((format(printf,fmt,var)))'
521 AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
523 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
526 cf_value='/* nothing */'
527 if test "$cf_scanf_attribute" != no ; then
528 cf_value='__attribute__((format(scanf,fmt,var)))'
529 AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
531 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
534 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
540 fgrep define conftest.i >>confdefs.h
545 dnl ---------------------------------------------------------------------------
546 dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
548 dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
549 dnl compatible), attempt to determine if icc/clang is actually used.
550 AC_DEFUN([CF_GCC_VERSION],[
551 AC_REQUIRE([AC_PROG_CC])
553 if test "$GCC" = yes ; then
554 AC_MSG_CHECKING(version of $CC)
555 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.]].*//'`"
556 test -z "$GCC_VERSION" && GCC_VERSION=unknown
557 AC_MSG_RESULT($GCC_VERSION)
559 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
560 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
562 dnl ---------------------------------------------------------------------------
563 dnl CF_GCC_WARNINGS version: 37 updated: 2020/01/05 20:04:12
565 dnl Check if the compiler supports useful warning options. There's a few that
566 dnl we don't use, simply because they're too noisy:
568 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
569 dnl -Winline (usually not worthwhile)
570 dnl -Wredundant-decls (system headers make this too noisy)
571 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
572 dnl -Wwrite-strings (too noisy, but should review occasionally). This
573 dnl is enabled for ncurses using "--enable-const".
577 dnl $1 is an optional list of gcc warning flags that a particular
578 dnl application might want to use, e.g., "no-unused" for
581 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
583 AC_DEFUN([CF_GCC_WARNINGS],
585 AC_REQUIRE([CF_GCC_VERSION])
586 if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
587 cat > conftest.$ac_ext <<EOF
588 #line __oline__ "${as_me:-configure}"
589 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
591 if test "$INTEL_COMPILER" = yes
593 # The "-wdXXX" options suppress warnings:
594 # remark #1419: external declaration in primary source file
595 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
596 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
597 # remark #193: zero used for undefined preprocessing identifier
598 # remark #593: variable "curs_sb_left_arrow" was set but never used
599 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
600 # remark #869: parameter "tw" was never referenced
601 # remark #981: operands are evaluated in unspecified order
602 # warning #279: controlling expression is constant
604 AC_CHECKING([for $CC warning options])
605 cf_save_CFLAGS="$CFLAGS"
618 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
619 if AC_TRY_EVAL(ac_compile); then
620 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
621 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
624 CFLAGS="$cf_save_CFLAGS"
625 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
627 AC_CHECKING([for $CC warning options])
628 cf_save_CFLAGS="$CFLAGS"
631 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
632 cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
633 test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
634 for cf_opt in W Wall \
638 Wdeclaration-after-statement \
641 Wmissing-declarations \
642 Wmissing-prototypes \
647 Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
649 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
650 if AC_TRY_EVAL(ac_compile); then
651 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
656 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
663 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
668 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
671 CFLAGS="$cf_save_CFLAGS"
675 AC_SUBST(EXTRA_CFLAGS)
677 dnl ---------------------------------------------------------------------------
678 dnl CF_GETOPT_HEADER version: 6 updated: 2014/07/22 14:45:54
680 dnl Check for getopt's variables which are commonly defined in stdlib.h,
681 dnl unistd.h or (nonstandard) in getopt.h
682 AC_DEFUN([CF_GETOPT_HEADER],
684 AC_HAVE_HEADERS(unistd.h getopt.h)
685 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
686 cf_cv_getopt_header=none
687 for cf_header in stdio.h stdlib.h unistd.h getopt.h
690 #include <$cf_header>],
691 [int x = optind; char *y = optarg],
692 [cf_cv_getopt_header=$cf_header
696 if test $cf_cv_getopt_header != none ; then
697 AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
699 if test $cf_cv_getopt_header = getopt.h ; then
700 AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
703 dnl ---------------------------------------------------------------------------
704 dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
706 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
707 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
708 dnl (or misfeature) of glibc2, which breaks portability of many applications,
709 dnl since it is interwoven with GNU extensions.
711 dnl Well, yes we could work around it...
714 dnl $1 is the nominal value for _XOPEN_SOURCE
715 AC_DEFUN([CF_GNU_SOURCE],
717 cf_gnu_xopen_source=ifelse($1,,500,$1)
719 AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
720 AC_TRY_COMPILE([#include <sys/types.h>],[
721 #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
723 #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
726 # error not GNU C library
728 [cf_cv_gnu_library=yes],
729 [cf_cv_gnu_library=no])
732 if test x$cf_cv_gnu_library = xyes; then
734 # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
735 # was changed to help a little. newlib incorporated the change about 4
737 AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
739 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
740 AC_TRY_COMPILE([#include <sys/types.h>],[
741 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
743 #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
746 # error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
748 [cf_cv_gnu_library_219=yes],
749 [cf_cv_gnu_library_219=no])
753 if test "x$cf_cv_gnu_library_219" = xyes; then
755 AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
756 CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
759 #include <sys/types.h>
761 #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
764 # error GNU C library is too old
766 [cf_cv_gnu_dftsrc_219=yes],
767 [cf_cv_gnu_dftsrc_219=no])
769 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
771 cf_cv_gnu_dftsrc_219=maybe
774 if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
776 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
777 AC_TRY_COMPILE([#include <sys/types.h>],[
778 #ifndef _XOPEN_SOURCE
779 #error expected _XOPEN_SOURCE to be defined
781 [cf_cv_gnu_source=no],
783 CF_ADD_CFLAGS(-D_GNU_SOURCE)
784 AC_TRY_COMPILE([#include <sys/types.h>],[
786 #error expected _XOPEN_SOURCE to be undefined
788 [cf_cv_gnu_source=no],
789 [cf_cv_gnu_source=yes])
794 if test "$cf_cv_gnu_source" = yes
796 AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
797 CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
798 AC_TRY_COMPILE([#include <sys/types.h>],[
799 #ifdef _DEFAULT_SOURCE
800 #error expected _DEFAULT_SOURCE to be undefined
802 [cf_cv_default_source=no],
803 [cf_cv_default_source=yes])
805 if test "$cf_cv_default_source" = yes
807 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
814 dnl ---------------------------------------------------------------------------
815 dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
816 dnl -----------------
817 dnl Check if the given compiler is really the Intel compiler for Linux. It
818 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
819 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
821 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
822 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
823 dnl the wrappers for gcc and g++ warnings.
825 dnl $1 = GCC (default) or GXX
826 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
827 dnl $3 = CFLAGS (default) or CXXFLAGS
828 AC_DEFUN([CF_INTEL_COMPILER],[
829 AC_REQUIRE([AC_CANONICAL_HOST])
830 ifelse([$2],,INTEL_COMPILER,[$2])=no
832 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
835 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
836 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
837 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
839 #ifdef __INTEL_COMPILER
843 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
844 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
846 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
847 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
852 dnl ---------------------------------------------------------------------------
853 dnl CF_MAKE_DOCS version: 4 updated: 2015/07/04 21:43:03
855 dnl $1 = name(s) to generate rules for
856 dnl $2 = suffix of corresponding manpages used as input.
858 dnl This works best if called at the end of configure.in, following CF_WITH_MAN2HTML
859 define([CF_MAKE_DOCS],[
860 test -z "$cf_make_docs" && cf_make_docs=0
863 test -f "$cf_output" || cf_output=Makefile
865 if test "$cf_make_docs" = 0
867 cat >>$cf_output <<CF_EOF
868 ################################################################################
870 .SUFFIXES : .html .$2 .man .ps .pdf .txt
872 ${NROFF_NOTE}.$2.txt :
873 ${NROFF_NOTE} [\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
875 ${GROFF_NOTE}.ps.pdf :
876 ${GROFF_NOTE} ps2pdf [\$]*.ps
878 ${GROFF_NOTE}.$2.ps :
879 ${GROFF_NOTE} [\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
881 ${GROFF_NOTE}.$2.txt :
882 ${GROFF_NOTE} GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -Tascii -man | col -bx" >[\$]@
884 ${MAN2HTML_NOTE}.$2.html :
885 ${MAN2HTML_NOTE} ./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
893 cat >>$cf_output <<CF_EOF
894 ################################################################################
895 ${NROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
896 ${MAN2HTML_NOTE}docs docs-$cf_name :: $cf_name.html
897 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.pdf
898 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.ps
899 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
903 ${NROFF_NOTE} rm -f $cf_name.txt
904 ${MAN2HTML_NOTE} rm -f $cf_name.html
905 ${GROFF_NOTE} rm -f $cf_name.pdf
906 ${GROFF_NOTE} rm -f $cf_name.ps
907 ${GROFF_NOTE} rm -f $cf_name.txt
909 ${NROFF_NOTE}$cf_name.txt : $cf_name.$2
910 ${MAN2HTML_NOTE}$cf_name.html : $cf_name.$2
911 ${GROFF_NOTE}$cf_name.pdf : $cf_name.ps
912 ${GROFF_NOTE}$cf_name.ps : $cf_name.$2
913 ${GROFF_NOTE}$cf_name.txt : $cf_name.$2
917 dnl ---------------------------------------------------------------------------
918 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
920 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
921 dnl a monocase filesystem.
922 AC_DEFUN([CF_MAKE_TAGS],[
923 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
925 AC_CHECK_PROGS(CTAGS, exctags ctags)
926 AC_CHECK_PROGS(ETAGS, exetags etags)
928 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
930 if test "$cf_cv_mixedcase" = yes ; then
931 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
936 if test "$MAKE_UPPER_TAGS" = yes ; then
942 if test "$MAKE_LOWER_TAGS" = yes ; then
951 AC_SUBST(MAKE_UPPER_TAGS)
952 AC_SUBST(MAKE_LOWER_TAGS)
954 dnl ---------------------------------------------------------------------------
955 dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
956 dnl ----------------------
957 dnl Check if the file-system supports mixed-case filenames. If we're able to
958 dnl create a lowercase name and see it as uppercase, it doesn't support that.
959 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
961 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
962 if test "$cross_compiling" = yes ; then
963 case $target_alias in
964 (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
972 rm -f conftest CONFTEST
974 if test -f CONFTEST ; then
979 rm -f conftest CONFTEST
982 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
984 dnl ---------------------------------------------------------------------------
985 dnl CF_MKSTEMP version: 10 updated: 2017/01/21 11:12:16
987 dnl Check for a working mkstemp. This creates two files, checks that they are
988 dnl successfully created and distinct (AmigaOS apparently fails on the last).
989 AC_DEFUN([CF_MKSTEMP],[
993 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
996 #include <sys/types.h>
1003 #include <sys/stat.h>
1006 char *tmpl = "conftestXXXXXX";
1014 for (n = 0; n < 2; ++n) {
1015 strcpy(name[n], tmpl);
1016 if ((fd = mkstemp(name[n])) >= 0) {
1017 if (!strcmp(name[n], tmpl)
1018 || stat(name[n], &sb) != 0
1019 || (sb.st_mode & S_IFMT) != S_IFREG
1020 || (sb.st_mode & 077) != 0) {
1027 && !strcmp(name[0], name[1]))
1029 ${cf_cv_main_return:-return}(result);
1031 ],[cf_cv_func_mkstemp=yes
1032 ],[cf_cv_func_mkstemp=no
1033 ],[cf_cv_func_mkstemp=maybe])
1035 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
1036 AC_CHECK_FUNC(mkstemp)
1038 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
1039 AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
1042 dnl ---------------------------------------------------------------------------
1043 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1045 dnl Write a debug message to config.log, along with the line number in the
1046 dnl configure script.
1047 AC_DEFUN([CF_MSG_LOG],[
1048 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1050 dnl ---------------------------------------------------------------------------
1051 dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
1052 dnl ------------------
1053 dnl see CF_WITH_NO_LEAKS
1054 AC_DEFUN([CF_NO_LEAKS_OPTION],[
1055 AC_MSG_CHECKING(if you want to use $1 for testing)
1058 [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1061 : ${with_cflags:=-g}
1062 : ${with_no_leaks:=yes}
1065 AC_MSG_RESULT(${with_$1:-no})
1067 case .$with_cflags in
1079 dnl ---------------------------------------------------------------------------
1080 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
1082 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1083 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1084 dnl result begins with 'NONE'. This is necessary to work around autoconf's
1085 dnl delayed evaluation of those symbols.
1086 AC_DEFUN([CF_PATH_SYNTAX],[
1087 if test "x$prefix" != xNONE; then
1088 cf_path_syntax="$prefix"
1090 cf_path_syntax="$ac_default_prefix"
1094 (.\[$]\(*\)*|.\'*\'*)
1098 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1100 (.\[$]{*prefix}*|.\[$]{*dir}*)
1104 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1109 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1112 ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1116 dnl ---------------------------------------------------------------------------
1117 dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
1118 dnl -----------------
1119 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1121 dnl POSIX.1-1990 _POSIX_SOURCE
1122 dnl POSIX.1-1990 and _POSIX_SOURCE and
1123 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
1125 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
1126 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
1127 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
1130 dnl $1 is the nominal value for _POSIX_C_SOURCE
1131 AC_DEFUN([CF_POSIX_C_SOURCE],
1132 [AC_REQUIRE([CF_POSIX_VISIBLE])dnl
1134 if test "$cf_cv_posix_visible" = no; then
1136 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1138 cf_save_CFLAGS="$CFLAGS"
1139 cf_save_CPPFLAGS="$CPPFLAGS"
1141 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1142 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1144 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1145 CF_MSG_LOG(if the symbol is already defined go no further)
1146 AC_TRY_COMPILE([#include <sys/types.h>],[
1147 #ifndef _POSIX_C_SOURCE
1150 [cf_cv_posix_c_source=no],
1151 [cf_want_posix_source=no
1152 case .$cf_POSIX_C_SOURCE in
1154 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1157 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1158 cf_want_posix_source=yes
1161 cf_want_posix_source=yes
1164 if test "$cf_want_posix_source" = yes ; then
1165 AC_TRY_COMPILE([#include <sys/types.h>],[
1166 #ifdef _POSIX_SOURCE
1169 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1171 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1172 CFLAGS="$cf_trim_CFLAGS"
1173 CPPFLAGS="$cf_trim_CPPFLAGS"
1174 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
1175 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1176 AC_TRY_COMPILE([#include <sys/types.h>],[
1177 #ifndef _POSIX_C_SOURCE
1180 [cf_cv_posix_c_source=no])
1181 CFLAGS="$cf_save_CFLAGS"
1182 CPPFLAGS="$cf_save_CPPFLAGS"
1186 if test "$cf_cv_posix_c_source" != no ; then
1187 CFLAGS="$cf_trim_CFLAGS"
1188 CPPFLAGS="$cf_trim_CPPFLAGS"
1189 CF_ADD_CFLAGS($cf_cv_posix_c_source)
1192 fi # cf_cv_posix_visible
1195 dnl ---------------------------------------------------------------------------
1196 dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
1197 dnl ----------------
1198 dnl POSIX documents test-macros which an application may set before any system
1199 dnl headers are included to make features available.
1201 dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
1202 dnl diverged from POSIX in 2002 by setting symbols which make all of the most
1203 dnl recent features visible in the system header files unless the application
1204 dnl overrides the corresponding test-macros. Doing that introduces portability
1207 dnl This macro makes a special check for the symbols used for this, to avoid a
1208 dnl conflicting definition.
1209 AC_DEFUN([CF_POSIX_VISIBLE],
1211 AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
1212 AC_TRY_COMPILE([#include <stdio.h>],[
1213 #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
1214 && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
1215 && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
1216 && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
1217 #error conflicting symbols found
1219 ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
1222 dnl ---------------------------------------------------------------------------
1223 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
1225 dnl Check for awk, ensure that the check found something.
1226 AC_DEFUN([CF_PROG_AWK],
1229 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
1231 dnl ---------------------------------------------------------------------------
1232 dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
1234 dnl standard check for CC, plus followup sanity checks
1235 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1236 AC_DEFUN([CF_PROG_CC],[
1237 CF_ACVERSION_CHECK(2.53,
1238 [AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
1239 AC_REQUIRE([AC_PROG_CC])],
1241 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1243 CF_ACVERSION_CHECK(2.52,
1248 dnl ---------------------------------------------------------------------------
1249 dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
1251 dnl Check if groff is available, for cases (such as html output) where nroff
1253 AC_DEFUN([CF_PROG_GROFF],[
1254 AC_PATH_PROG(GROFF_PATH,groff,no)
1255 AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
1256 AC_PATH_PROG(TBL_PATH,tbl,cat)
1257 if test "x$GROFF_PATH" = xno
1265 AC_SUBST(GROFF_NOTE)
1266 AC_SUBST(NROFF_NOTE)
1268 dnl ---------------------------------------------------------------------------
1269 dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
1271 AC_DEFUN([CF_PROG_LINT],
1273 AC_CHECK_PROGS(LINT, lint cppcheck splint)
1275 (xcppcheck|x*/cppcheck)
1276 test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
1281 dnl ---------------------------------------------------------------------------
1282 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1283 dnl ----------------
1284 dnl Remove all -U and -D options that refer to the given symbol from a list
1285 dnl of C compiler options. This works around the problem that not all
1286 dnl compilers process -U and -D options from left-to-right, so a -U option
1287 dnl cannot be used to cancel the effect of a preceding -D option.
1289 dnl $1 = target (which could be the same as the source variable)
1290 dnl $2 = source (including '$')
1291 dnl $3 = symbol to remove
1292 define([CF_REMOVE_DEFINE],
1295 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
1296 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
1298 dnl ---------------------------------------------------------------------------
1299 dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
1300 dnl -------------------
1301 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1302 dnl can define it successfully.
1303 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1304 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1308 #include <sys/types.h>
1310 #ifndef _XOPEN_SOURCE
1313 [cf_cv_xopen_source=no],
1314 [cf_save="$CPPFLAGS"
1315 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
1319 #include <sys/types.h>
1321 #ifdef _XOPEN_SOURCE
1324 [cf_cv_xopen_source=no],
1325 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1330 if test "$cf_cv_xopen_source" != no ; then
1331 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1332 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1333 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1334 CF_ADD_CFLAGS($cf_temp_xopen_source)
1337 dnl ---------------------------------------------------------------------------
1338 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1340 dnl Make an uppercase version of a variable
1341 dnl $1=uppercase($2)
1342 AC_DEFUN([CF_UPPER],
1344 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1346 dnl ---------------------------------------------------------------------------
1347 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1349 dnl Use AC_VERBOSE w/o the warnings
1350 AC_DEFUN([CF_VERBOSE],
1351 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1354 dnl ---------------------------------------------------------------------------
1355 dnl CF_WITHOUT_X version: 1 updated: 2020/03/03 18:27:24
1357 dnl Use this to cancel the check for X headers/libraries which would be pulled
1358 dnl in via CF_GCC_WARNINGS.
1359 define([CF_WITHOUT_X],
1360 AC_DEFUN([CF_CONST_X_STRING],[echo "skipping X-const check";])dnl
1362 dnl ---------------------------------------------------------------------------
1363 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1364 dnl ----------------
1365 dnl Configure-option for dbmalloc. The optional parameter is used to override
1366 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1367 AC_DEFUN([CF_WITH_DBMALLOC],[
1368 CF_NO_LEAKS_OPTION(dbmalloc,
1369 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
1372 if test "$with_dbmalloc" = yes ; then
1373 AC_CHECK_HEADER(dbmalloc.h,
1374 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1377 dnl ---------------------------------------------------------------------------
1378 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1380 dnl Configure-option for dmalloc. The optional parameter is used to override
1381 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1382 AC_DEFUN([CF_WITH_DMALLOC],[
1383 CF_NO_LEAKS_OPTION(dmalloc,
1384 [ --with-dmalloc test: use Gray Watson's dmalloc library],
1387 if test "$with_dmalloc" = yes ; then
1388 AC_CHECK_HEADER(dmalloc.h,
1389 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1392 dnl ---------------------------------------------------------------------------
1393 dnl CF_WITH_MAN2HTML version: 8 updated: 2018/06/27 18:44:03
1394 dnl ----------------
1395 dnl Check for man2html and groff. Prefer man2html over groff, but use groff
1396 dnl as a fallback. See
1398 dnl http://invisible-island.net/scripts/man2html.html
1400 dnl Generate a shell script which hides the differences between the two.
1402 dnl We name that "man2html.tmp".
1404 dnl The shell script can be removed later, e.g., using "make distclean".
1405 AC_DEFUN([CF_WITH_MAN2HTML],[
1406 AC_REQUIRE([CF_PROG_GROFF])
1408 case "x${with_man2html}" in
1413 AC_PATH_PROG(cf_man2html,man2html,no)
1414 case "x$cf_man2html" in
1416 AC_MSG_CHECKING(for the modified Earl Hood script)
1417 if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
1424 AC_MSG_RESULT($cf_man2html_ok)
1432 AC_MSG_CHECKING(for program to convert manpage to html)
1433 AC_ARG_WITH(man2html,
1434 [ --with-man2html=XXX use XXX rather than groff],
1435 [cf_man2html=$withval],
1436 [cf_man2html=$cf_man2html])
1440 case $cf_man2html in
1442 AC_MSG_RESULT(man2html)
1443 AC_PATH_PROG(cf_man2html,man2html,no)
1447 cf_man2html=$GROFF_PATH
1448 AC_MSG_RESULT($cf_man2html)
1451 AC_MSG_RESULT($cf_man2html)
1455 MAN2HTML_TEMP="man2html.tmp"
1456 cat >$MAN2HTML_TEMP <<CF_EOF
1458 # Temporary script generated by CF_WITH_MAN2HTML
1459 # Convert inputs to html, sending result to standard output.
1462 # \${1} = rootname of file to convert
1463 # \${2} = suffix of file to convert, e.g., "1"
1464 # \${3} = macros to use, e.g., "man"
1479 if test "x$cf_with_groff" = xyes
1481 MAN2HTML_NOTE="$GROFF_NOTE"
1482 MAN2HTML_PATH="$GROFF_PATH"
1483 cat >>$MAN2HTML_TEMP <<CF_EOF
1484 $SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
1488 CF_PATH_SYNTAX(cf_man2html)
1489 MAN2HTML_PATH="$cf_man2html"
1490 AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
1492 # for this example, expect 3 lines of content, the remainder is head/foot
1493 cat >conftest.in <<CF_EOF
1494 .TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
1499 LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1501 cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1502 cf_man2html_top=`expr $cf_man2html_1st - 2`
1503 cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
1504 cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
1505 cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
1507 AC_MSG_RESULT($cf_man2html_top_bot)
1509 AC_MSG_CHECKING(for pagesize to use)
1510 for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1512 cat >>conftest.in <<CF_EOF
1527 LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1528 cf_man2html_page=`fgrep -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1529 test -z "$cf_man2html_page" && cf_man2html_page=99999
1530 test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
1533 AC_MSG_RESULT($cf_man2html_page)
1535 cat >>$MAN2HTML_TEMP <<CF_EOF
1536 : \${MAN2HTML_PATH=$MAN2HTML_PATH}
1537 MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page"
1540 $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
1543 $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
1549 chmod 700 $MAN2HTML_TEMP
1551 AC_SUBST(MAN2HTML_NOTE)
1552 AC_SUBST(MAN2HTML_PATH)
1553 AC_SUBST(MAN2HTML_TEMP)
1555 dnl ---------------------------------------------------------------------------
1556 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
1557 dnl ----------------
1558 AC_DEFUN([CF_WITH_VALGRIND],[
1559 CF_NO_LEAKS_OPTION(valgrind,
1560 [ --with-valgrind test: use valgrind],
1563 dnl ---------------------------------------------------------------------------
1564 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
1565 dnl ----------------
1566 dnl Combine the checks for gcc features into a configure-script option
1569 dnl $1 - see CF_GCC_WARNINGS
1570 AC_DEFUN([CF_WITH_WARNINGS],
1572 if ( test "$GCC" = yes || test "$GXX" = yes )
1574 AC_MSG_CHECKING(if you want to check for gcc warnings)
1575 AC_ARG_WITH(warnings,
1576 [ --with-warnings test: turn on gcc warnings],
1577 [cf_opt_with_warnings=$withval],
1578 [cf_opt_with_warnings=no])
1579 AC_MSG_RESULT($cf_opt_with_warnings)
1580 if test "$cf_opt_with_warnings" != no ; then
1582 CF_GCC_WARNINGS([$1])
1586 dnl ---------------------------------------------------------------------------
1587 dnl CF_XOPEN_SOURCE version: 55 updated: 2018/12/31 20:46:17
1589 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1590 dnl or adapt to the vendor's definitions to get equivalent functionality,
1591 dnl without losing the common non-POSIX features.
1594 dnl $1 is the nominal value for _XOPEN_SOURCE
1595 dnl $2 is the nominal value for _POSIX_C_SOURCE
1596 AC_DEFUN([CF_XOPEN_SOURCE],[
1597 AC_REQUIRE([AC_CANONICAL_HOST])
1598 AC_REQUIRE([CF_POSIX_VISIBLE])
1600 if test "$cf_cv_posix_visible" = no; then
1602 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1603 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1608 cf_xopen_source="-D_ALL_SOURCE"
1614 cf_xopen_source="-D_APPLE_C_SOURCE"
1617 cf_xopen_source="-D_DARWIN_C_SOURCE"
1620 (freebsd*|dragonfly*|midnightbsd*)
1621 # 5.x headers associate
1622 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1623 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1624 cf_POSIX_C_SOURCE=200112L
1626 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1629 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1632 cf_xopen_source="-D_HPUX_SOURCE"
1635 cf_xopen_source="-D_SGI_SOURCE"
1638 (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
1639 CF_GNU_SOURCE($cf_XOPEN_SOURCE)
1642 cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
1645 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1647 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1650 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1653 # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1654 cf_xopen_source="-D_BSD_SOURCE"
1658 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1661 cf_xopen_source="-D_OSF_SOURCE"
1664 cf_xopen_source="-D_QNX_SOURCE"
1667 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1670 cf_xopen_source="-D__EXTENSIONS__"
1671 cf_cv_xopen_source=broken
1673 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
1679 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1683 if test -n "$cf_xopen_source" ; then
1684 CF_ADD_CFLAGS($cf_xopen_source,true)
1687 dnl In anything but the default case, we may have system-specific setting
1688 dnl which is still not guaranteed to provide all of the entrypoints that
1689 dnl _XOPEN_SOURCE would yield.
1690 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1691 AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1692 AC_TRY_COMPILE([#include <stdlib.h>],[
1693 #ifndef _XOPEN_SOURCE
1696 [cf_XOPEN_SOURCE_set=yes],
1697 [cf_XOPEN_SOURCE_set=no])
1698 AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1699 if test $cf_XOPEN_SOURCE_set = yes
1701 AC_TRY_COMPILE([#include <stdlib.h>],[
1702 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1705 [cf_XOPEN_SOURCE_set_ok=yes],
1706 [cf_XOPEN_SOURCE_set_ok=no])
1707 if test $cf_XOPEN_SOURCE_set_ok = no
1709 AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
1715 fi # cf_cv_posix_visible