1 dnl $Id: aclocal.m4,v 1.64 2023/05/21 19:57:27 tom Exp $
2 dnl Macros for byacc configure script (Thomas E. Dickey)
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 2004-2022,2023 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: 15 updated: 2020/12/31 10:54:15
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_CFLAGS version: 3 updated: 2021/09/05 17:25:40
148 dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions.
149 dnl $1 = flags to add
150 dnl $2 = if given makes this macro verbose.
151 define([CF_APPEND_CFLAGS],
153 for cf_add_cflags in $1
155 case "x$cf_add_cflags" in
157 CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2])
158 CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2])
161 CF_ADD_CFLAGS([$cf_add_cflags],[$2])
164 dnl ---------------------------------------------------------------------------
165 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
167 dnl use this macro for appending text without introducing an extra blank at
169 define([CF_APPEND_TEXT],
171 test -n "[$]$1" && $1="[$]$1 "
174 dnl ---------------------------------------------------------------------------
175 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
177 dnl Allow user to disable a normally-on option.
178 AC_DEFUN([CF_ARG_DISABLE],
179 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
180 dnl ---------------------------------------------------------------------------
181 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
183 dnl Allow user to enable a normally-off option.
184 AC_DEFUN([CF_ARG_ENABLE],
185 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
186 dnl ---------------------------------------------------------------------------
187 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
189 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
195 dnl $3 = action to perform if option is not default
196 dnl $4 = action if perform if option is default
197 dnl $5 = default option value (either 'yes' or 'no')
198 AC_DEFUN([CF_ARG_OPTION],
199 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
200 if test "$enableval" != "$5" ; then
202 ,[ $3]) ifelse([$4],,,[
205 fi],[enableval=$5 ifelse([$4],,,[
209 dnl ---------------------------------------------------------------------------
210 dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25
212 AC_DEFUN([CF_C11_NORETURN],
214 AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
215 CF_ARG_ENABLE(stdnoreturn,
216 [ --enable-stdnoreturn enable C11 _Noreturn feature for diagnostics],
217 [enable_stdnoreturn=yes],
218 [enable_stdnoreturn=no])
219 AC_MSG_RESULT($enable_stdnoreturn)
221 if test $enable_stdnoreturn = yes; then
222 AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
225 #include <stdnoreturn.h>
226 static _Noreturn void giveup(void) { exit(0); }
228 [if (feof(stdin)) giveup()],
229 cf_cv_c11_noreturn=yes,
230 cf_cv_c11_noreturn=no)
233 cf_cv_c11_noreturn=no,
236 if test "$cf_cv_c11_noreturn" = yes; then
237 AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
238 AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
244 AC_SUBST(HAVE_STDNORETURN_H)
245 AC_SUBST(STDC_NORETURN)
247 dnl ---------------------------------------------------------------------------
248 dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46
250 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
251 dnl into CC. This will not help with broken scripts that wrap the compiler
252 dnl with options, but eliminates a more common category of user confusion.
254 dnl In particular, it addresses the problem of being able to run the C
255 dnl preprocessor in a consistent manner.
257 dnl Caveat: this also disallows blanks in the pathname for the compiler, but
258 dnl the nuisance of having inconsistent settings for compiler and preprocessor
259 dnl outweighs that limitation.
260 AC_DEFUN([CF_CC_ENV_FLAGS],
262 # This should have been defined by AC_PROG_CC
265 AC_MSG_CHECKING(\$CFLAGS variable)
268 AC_MSG_RESULT(broken)
269 AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
272 for cf_arg in $cf_flags
274 CF_ADD_CFLAGS($cf_arg)
282 AC_MSG_CHECKING(\$CC variable)
285 AC_MSG_RESULT(broken)
286 AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
288 cf_prog=`echo "$CC" | sed -e 's/ / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
289 cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
291 for cf_arg in $cf_flags
295 CF_ADD_CFLAGS($cf_arg)
302 CF_VERBOSE(resulting CC: '$CC')
303 CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
304 CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
311 dnl ---------------------------------------------------------------------------
312 dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
314 dnl Check if we're accidentally using a cache from a different machine.
315 dnl Derive the system name, as a check for reusing the autoconf cache.
317 dnl If we've packaged config.guess and config.sub, run that (since it does a
318 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
319 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
320 dnl which is useful in cross-compiles.
322 dnl Note: we would use $ac_config_sub, but that is one of the places where
323 dnl autoconf 2.5x broke compatibility with autoconf 2.13
324 AC_DEFUN([CF_CHECK_CACHE],
326 if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
327 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
328 system_name="$host_os"
330 system_name="`(uname -s -r) 2>/dev/null`"
331 if test -z "$system_name" ; then
332 system_name="`(hostname) 2>/dev/null`"
335 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
336 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
338 test -z "$system_name" && system_name="$cf_cv_system_name"
339 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
341 if test ".$system_name" != ".$cf_cv_system_name" ; then
342 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
343 AC_MSG_ERROR("Please remove config.cache and try again.")
346 dnl ---------------------------------------------------------------------------
347 dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25
348 dnl -----------------
349 dnl Check if the given compiler is really clang. clang's C driver defines
350 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
351 dnl not ignore some gcc options.
353 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
354 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
355 dnl the wrappers for gcc and g++ warnings.
357 dnl $1 = GCC (default) or GXX
358 dnl $2 = CLANG_COMPILER (default)
359 dnl $3 = CFLAGS (default) or CXXFLAGS
360 AC_DEFUN([CF_CLANG_COMPILER],[
361 ifelse([$2],,CLANG_COMPILER,[$2])=no
363 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
364 AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
365 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
369 #error __clang__ is not defined
371 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
373 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
374 AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
379 if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
381 (c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
382 AC_MSG_WARN(replacing broken compiler alias $CC)
383 CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
388 AC_MSG_CHECKING(version of $CC)
389 CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
390 test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
391 AC_MSG_RESULT($CLANG_VERSION)
393 for cf_clang_opt in \
395 -Wno-error=implicit-function-declaration
397 AC_MSG_CHECKING(if option $cf_clang_opt works)
398 cf_save_CFLAGS="$CFLAGS"
399 CFLAGS="$CFLAGS $cf_clang_opt"
401 #include <stdio.h>],[
402 printf("hello!\\n");],[
403 cf_clang_optok=yes],[
405 AC_MSG_RESULT($cf_clang_optok)
406 CFLAGS="$cf_save_CFLAGS"
407 if test "$cf_clang_optok" = yes; then
408 CF_VERBOSE(adding option $cf_clang_opt)
409 CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
414 dnl ---------------------------------------------------------------------------
415 dnl CF_CONST_X_STRING version: 7 updated: 2021/06/07 17:39:17
416 dnl -----------------
417 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
418 dnl character-strings.
420 dnl It is ambiguous because the specification accommodated the pre-ANSI
421 dnl compilers bundled by more than one vendor in lieu of providing a standard C
422 dnl compiler other than by costly add-ons. Because of this, the specification
423 dnl did not take into account the use of const for telling the compiler that
424 dnl string literals would be in readonly memory.
426 dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
427 dnl let the compiler decide how to represent Xt's strings which were #define'd.
428 dnl That does not solve the problem of using the block of Xt's strings which
429 dnl are compiled into the library (and is less efficient than one might want).
431 dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
432 dnl when compiling the library and compiling using the library, to tell the
433 dnl compiler that String is const.
434 AC_DEFUN([CF_CONST_X_STRING],
436 AC_REQUIRE([AC_PATH_XTRA])
438 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
443 #include <X11/Intrinsic.h>
445 [String foo = malloc(1); free((void*)foo)],[
447 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
450 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
451 #undef XTSTRINGDEFINES /* X11R5 and later */
453 #include <X11/Intrinsic.h>
454 ],[String foo = malloc(1); *foo = 0],[
455 cf_cv_const_x_string=no
457 cf_cv_const_x_string=yes
461 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
463 case "$cf_cv_const_x_string" in
465 CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
468 CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
474 dnl ---------------------------------------------------------------------------
475 dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04
477 dnl You can always use "make -n" to see the actual options, but it is hard to
478 dnl pick out/analyze warning messages when the compile-line is long.
481 dnl ECHO_LT - symbol to control if libtool is verbose
482 dnl ECHO_LD - symbol to prefix "cc -o" lines
483 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
484 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
485 dnl ECHO_CC - symbol to put before any "cc" line
487 AC_DEFUN([CF_DISABLE_ECHO],[
488 AC_MSG_CHECKING(if you want to see long compiling messages)
490 [ --disable-echo do not display "compiling" commands],
493 ECHO_LD='@echo linking [$]@;'
494 RULE_CC='@echo compiling [$]<'
495 SHOW_CC='@echo compiling [$]@'
504 AC_MSG_RESULT($enableval)
511 dnl ---------------------------------------------------------------------------
512 dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50
514 dnl Combine no-leak checks with the libraries or tools that are used for the
516 AC_DEFUN([CF_DISABLE_LEAKS],[
518 AC_REQUIRE([CF_WITH_DMALLOC])
519 AC_REQUIRE([CF_WITH_DBMALLOC])
520 AC_REQUIRE([CF_WITH_VALGRIND])
522 AC_MSG_CHECKING(if you want to perform memory-leak testing)
524 [ --disable-leaks test: free permanent memory, analyze leaks],
525 [enable_leaks=$enableval],
527 dnl with_no_leaks is more readable...
528 if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
529 AC_MSG_RESULT($with_no_leaks)
531 if test "$enable_leaks" = no ; then
532 AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
533 AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
536 dnl ---------------------------------------------------------------------------
537 dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
538 dnl ------------------
539 dnl Configure-option to enable gcc warnings
541 dnl $1 = extra options to add, if supported
542 dnl $2 = option for checking attributes. By default, this is done when
543 dnl warnings are enabled. For other values:
544 dnl yes: always do this, e.g., to use in generated library-headers
545 dnl no: never do this
546 AC_DEFUN([CF_ENABLE_WARNINGS],[
547 if test "$GCC" = yes || test "$GXX" = yes
549 CF_FIX_WARNINGS(CFLAGS)
550 CF_FIX_WARNINGS(CPPFLAGS)
551 CF_FIX_WARNINGS(LDFLAGS)
552 AC_MSG_CHECKING(if you want to turn on gcc warnings)
553 CF_ARG_ENABLE(warnings,
554 [ --enable-warnings test: turn on gcc compiler warnings],
555 [enable_warnings=yes],
556 [enable_warnings=no])
557 AC_MSG_RESULT($enable_warnings)
558 if test "$enable_warnings" = "yes"
560 ifelse($2,,[CF_GCC_ATTRIBUTES])
563 ifelse($2,yes,[CF_GCC_ATTRIBUTES])
566 dnl ---------------------------------------------------------------------------
567 dnl CF_FIX_WARNINGS version: 4 updated: 2021/12/16 18:22:31
569 dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc. Any of gcc's
570 dnl "-Werror" flags can interfere with configure-checks. Those go into
573 dnl $1 = variable name to repair
574 define([CF_FIX_WARNINGS],[
575 if test "$GCC" = yes || test "$GXX" = yes
580 for cf_temp_scan in [$]$1
582 case "x$cf_temp_scan" in
584 CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
587 CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
590 CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
594 if test "x[$]$1" != "x$cf_temp_flags"
596 CF_VERBOSE(repairing $1: [$]$1)
598 CF_VERBOSE(... fixed [$]$1)
599 CF_VERBOSE(... extra $EXTRA_CFLAGS)
604 AC_SUBST(EXTRA_CFLAGS)
606 dnl ---------------------------------------------------------------------------
607 dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25
608 dnl -----------------
609 dnl Test for availability of useful gcc __attribute__ directives to quiet
610 dnl compiler warnings. Though useful, not all are supported -- and contrary
611 dnl to documentation, unrecognized directives cause older compilers to barf.
612 AC_DEFUN([CF_GCC_ATTRIBUTES],
613 [AC_REQUIRE([AC_PROG_FGREP])dnl
614 AC_REQUIRE([CF_C11_NORETURN])dnl
616 if test "$GCC" = yes || test "$GXX" = yes
618 cat > conftest.i <<EOF
626 #define GCC_NORETURN /* nothing */
629 #define GCC_UNUSED /* nothing */
634 AC_CHECKING([for $CC __attribute__ directives])
635 cat > "conftest.$ac_ext" <<EOF
636 #line __oline__ "${as_me:-configure}"
638 #include "confdefs.h"
639 #include "conftest.h"
640 #include "conftest.i"
642 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
644 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
647 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
649 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
651 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
652 extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
653 extern GCC_NORETURN void foo(void);
654 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
656 cf_printf_attribute=no
657 cf_scanf_attribute=no
658 for cf_attribute in scanf printf unused noreturn
660 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
661 cf_directive="__attribute__(($cf_attribute))"
662 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
664 case "$cf_attribute" in
666 cf_printf_attribute=yes
667 cat >conftest.h <<EOF
668 #define GCC_$cf_ATTRIBUTE 1
672 cf_scanf_attribute=yes
673 cat >conftest.h <<EOF
674 #define GCC_$cf_ATTRIBUTE 1
678 cat >conftest.h <<EOF
679 #define GCC_$cf_ATTRIBUTE $cf_directive
684 if AC_TRY_EVAL(ac_compile); then
685 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
686 cat conftest.h >>confdefs.h
687 case "$cf_attribute" in
689 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
692 cf_value='/* nothing */'
693 if test "$cf_printf_attribute" != no ; then
694 cf_value='__attribute__((format(printf,fmt,var)))'
695 AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
697 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
700 cf_value='/* nothing */'
701 if test "$cf_scanf_attribute" != no ; then
702 cf_value='__attribute__((format(scanf,fmt,var)))'
703 AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
705 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
708 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
714 ${FGREP-fgrep} define conftest.i >>confdefs.h
719 dnl ---------------------------------------------------------------------------
720 dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13
722 dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
723 dnl compatible), attempt to determine if icc/clang is actually used.
724 AC_DEFUN([CF_GCC_VERSION],[
725 AC_REQUIRE([AC_PROG_CC])
727 if test "$GCC" = yes ; then
728 AC_MSG_CHECKING(version of $CC)
729 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
730 test -z "$GCC_VERSION" && GCC_VERSION=unknown
731 AC_MSG_RESULT($GCC_VERSION)
733 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
734 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
736 dnl ---------------------------------------------------------------------------
737 dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59
739 dnl Check if the compiler supports useful warning options. There's a few that
740 dnl we don't use, simply because they're too noisy:
742 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
743 dnl -Winline (usually not worthwhile)
744 dnl -Wredundant-decls (system headers make this too noisy)
745 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
746 dnl -Wwrite-strings (too noisy, but should review occasionally). This
747 dnl is enabled for ncurses using "--enable-const".
751 dnl $1 is an optional list of gcc warning flags that a particular
752 dnl application might want to use, e.g., "no-unused" for
755 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
757 AC_DEFUN([CF_GCC_WARNINGS],
759 AC_REQUIRE([CF_GCC_VERSION])
760 if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
761 cat > "conftest.$ac_ext" <<EOF
762 #line __oline__ "${as_me:-configure}"
763 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
765 if test "$INTEL_COMPILER" = yes
767 # The "-wdXXX" options suppress warnings:
768 # remark #1419: external declaration in primary source file
769 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
770 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
771 # remark #193: zero used for undefined preprocessing identifier
772 # remark #593: variable "curs_sb_left_arrow" was set but never used
773 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
774 # remark #869: parameter "tw" was never referenced
775 # remark #981: operands are evaluated in unspecified order
776 # warning #279: controlling expression is constant
778 AC_CHECKING([for $CC warning options])
779 cf_save_CFLAGS="$CFLAGS"
780 EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
792 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
793 if AC_TRY_EVAL(ac_compile); then
794 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
795 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
798 CFLAGS="$cf_save_CFLAGS"
799 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
801 AC_CHECKING([for $CC warning options])
802 cf_save_CFLAGS="$CFLAGS"
804 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
805 cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
806 test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
807 for cf_opt in W Wall \
811 Wdeclaration-after-statement \
814 Wmissing-declarations \
815 Wmissing-prototypes \
820 Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
822 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
823 if AC_TRY_EVAL(ac_compile); then
824 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
827 case "$GCC_VERSION" in
829 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
834 case "$GCC_VERSION" in
836 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
841 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
844 CFLAGS="$cf_save_CFLAGS"
848 AC_SUBST(EXTRA_CFLAGS)
850 dnl ---------------------------------------------------------------------------
851 dnl CF_GETOPT_HEADER version: 8 updated: 2021/06/19 19:16:16
853 dnl Check for getopt's variables which are commonly defined in stdlib.h,
854 dnl unistd.h or (nonstandard) in getopt.h
855 AC_DEFUN([CF_GETOPT_HEADER],
857 AC_HAVE_HEADERS(unistd.h getopt.h)
858 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
859 cf_cv_getopt_header=none
860 for cf_header in stdio.h stdlib.h unistd.h getopt.h
863 #include <$cf_header>],
864 [int x = optind; char *y = optarg; (void)x; (void)y],
865 [cf_cv_getopt_header=$cf_header
869 if test "$cf_cv_getopt_header" != none ; then
870 AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
872 if test "$cf_cv_getopt_header" = getopt.h ; then
873 AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
876 dnl ---------------------------------------------------------------------------
877 dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
879 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
880 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
881 dnl (or misfeature) of glibc2, which breaks portability of many applications,
882 dnl since it is interwoven with GNU extensions.
884 dnl Well, yes we could work around it...
887 dnl $1 is the nominal value for _XOPEN_SOURCE
888 AC_DEFUN([CF_GNU_SOURCE],
890 cf_gnu_xopen_source=ifelse($1,,500,$1)
892 AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
893 AC_TRY_COMPILE([#include <sys/types.h>],[
894 #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
896 #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
899 # error not GNU C library
901 [cf_cv_gnu_library=yes],
902 [cf_cv_gnu_library=no])
905 if test x$cf_cv_gnu_library = xyes; then
907 # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
908 # was changed to help a little. newlib incorporated the change about 4
910 AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
912 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
913 AC_TRY_COMPILE([#include <sys/types.h>],[
914 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
916 #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
919 # error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
921 [cf_cv_gnu_library_219=yes],
922 [cf_cv_gnu_library_219=no])
926 if test "x$cf_cv_gnu_library_219" = xyes; then
928 AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
929 CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
932 #include <sys/types.h>
934 #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
937 # error GNU C library is too old
939 [cf_cv_gnu_dftsrc_219=yes],
940 [cf_cv_gnu_dftsrc_219=no])
942 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
944 cf_cv_gnu_dftsrc_219=maybe
947 if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
949 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
950 AC_TRY_COMPILE([#include <sys/types.h>],[
951 #ifndef _XOPEN_SOURCE
952 #error expected _XOPEN_SOURCE to be defined
954 [cf_cv_gnu_source=no],
956 CF_ADD_CFLAGS(-D_GNU_SOURCE)
957 AC_TRY_COMPILE([#include <sys/types.h>],[
959 #error expected _XOPEN_SOURCE to be undefined
961 [cf_cv_gnu_source=no],
962 [cf_cv_gnu_source=yes])
967 if test "$cf_cv_gnu_source" = yes
969 AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
970 CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
971 AC_TRY_COMPILE([#include <sys/types.h>],[
972 #ifdef _DEFAULT_SOURCE
973 #error expected _DEFAULT_SOURCE to be undefined
975 [cf_cv_default_source=no],
976 [cf_cv_default_source=yes])
978 if test "$cf_cv_default_source" = yes
980 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
987 dnl ---------------------------------------------------------------------------
988 dnl CF_INSTALL_MAN version: 5 updated: 2023/05/21 15:53:07
990 dnl Call this to generate a script "install-man" which uses the detected
991 dnl manpage-format to compress the resulting manpage. Providing this as a
992 dnl macro simplifies including the script in different programs.
994 dnl The generated script assumes that the program can be renamed, using two
995 dnl symbols in the manpage, e.g.,
998 dnl which are later used as \*N and \*n, as well as a special case in the
999 dnl synopsis to work around limitations of makewhatis.
1001 dnl Script parameters:
1003 dnl $2 = output filename
1006 dnl $1 = output filename
1007 AC_DEFUN([CF_INSTALL_MAN],
1009 AC_REQUIRE([AC_ARG_PROGRAM])
1010 AC_REQUIRE([AC_PROG_INSTALL])
1011 AC_REQUIRE([AC_LN_S])
1012 AC_REQUIRE([CF_MANPAGE_FORMAT])
1013 cf_install_man=install-man
1014 ac_config_files="$ac_config_files $cf_install_man"
1015 cf_install_man=$cf_install_man.in
1016 echo [$]as_me: creating $cf_install_man
1017 cat >[$]cf_install_man <<"CF_EOF"
1019 # generated by CF_INSTALL_MAN
1022 LC_ALL=C; export LC_ALL
1023 LC_CTYPE=C; export LC_CTYPE
1024 LANGUAGE=C; export LANGUAGE
1027 INSTALL_DATA="@INSTALL_DATA@"
1031 Usage: install-man [[-l]] [[source]] target
1041 test [$]# != 0 || usage
1054 if test [$]# = 2 ; then
1057 elif test [$]# = 1 ; then
1058 test -n "$OPTS" && usage
1064 origin_name=`echo "$source" |sed -e 's%^.*/%%' -e 's%\..*%%'`
1065 actual_name=`echo "$origin_name" |sed '@program_transform_name@'`
1066 leading_cap=`echo "$actual_name" | sed -e 's%^\(.\).*$%\1%' | tr a-z A-Z``echo "$actual_name" | sed -e 's%^.%%'`
1067 capitalized=`echo "$actual_name" | tr a-z A-Z`
1069 cf_tmpdir=`mktemp -d`
1070 trap 'rm -rf "$cf_tmpdir"; exit 1' 1 2 3 15
1071 trap 'rm -rf "$cf_tmpdir"; exit 0' 0
1073 if test -n "$source" ; then
1075 test -n "@cf_manpage_so_strip" && suffix=".@cf_manpage_so_strip@"
1076 if test "x$OPTS" = xlink ; then
1077 source_dir=`echo "$source" | sed -e "s%/[[^/]]*$%%"`
1078 target_dir=`echo "$target" | sed -e "s%/[[^/]]*$%%"`
1079 sourcelink="${source}${suffix}"
1080 targetfile="${target}${suffix}"
1081 targetlink="${target_dir}/${sourcelink}"
1082 if test ! -d "$target_dir" ; then
1083 failed "target directory does not exist: $target_dir"
1084 elif test ! -f "$targetfile" ; then
1085 failed "target file does not exist: $targetfile"
1086 elif test "$source" != "$source_dir" ; then
1087 failed "unexpected directory for source-link: $source_dir"
1089 test -f "$targetlink" && failed "already exists $targetlink"
1090 ( cd "$target_dir" && @LN_S@ "`echo "$targetfile" | sed -e 's%^.*/%%'`" "$sourcelink" )
1091 test -f "$targetlink" || failed "cannot create $targetlink"
1092 target="$targetlink"
1094 echo "** installing $source to $target"
1095 interim="$cf_tmpdir"/"`basename $source`"
1096 if test "x$origin_name" != "x$actual_name" ; then
1098 -e "/^.ds N/s%N.*%N $leading_cap%" \
1099 -e "/^.ds n/s%n.*%n $actual_name%" \
1100 -e "/^\.TH/s%[[ ]][[ ]]*[[^ ]][[^ ]]*% $capitalized%" \
1101 -e "/^\.SH[[ ]][[ ]]*NAME/,/[[ ]]\\\\-[[ ]]/s%^\\\\\\*[[Nn]]%$actual_name%" \
1102 "$source" >"$interim" || exit 1
1103 diff -c "$source" "$interim"
1105 cp "$source" "$interim" || exit 1
1107 if test -n "@cf_manpage_compress@" ; then
1108 @cf_manpage_compress@ "$interim"
1109 source="${interim}${suffix}"
1111 if test -d "$target" ; then
1112 target="$target"/"$source"
1114 test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@"
1116 $INSTALL_DATA "$source" "$target" || exit 1
1118 echo "...installed $target"
1120 echo "** removing $target"
1121 test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@"
1122 if test -f "$target" ; then
1124 echo "...removed $target"
1132 dnl ---------------------------------------------------------------------------
1133 dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25
1134 dnl -----------------
1135 dnl Check if the given compiler is really the Intel compiler for Linux. It
1136 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1137 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1139 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1140 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
1141 dnl the wrappers for gcc and g++ warnings.
1143 dnl $1 = GCC (default) or GXX
1144 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1145 dnl $3 = CFLAGS (default) or CXXFLAGS
1146 AC_DEFUN([CF_INTEL_COMPILER],[
1147 AC_REQUIRE([AC_CANONICAL_HOST])
1148 ifelse([$2],,INTEL_COMPILER,[$2])=no
1150 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1153 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1154 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1155 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1157 #ifdef __INTEL_COMPILER
1159 #error __INTEL_COMPILER is not defined
1161 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1162 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1164 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1165 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1170 dnl ---------------------------------------------------------------------------
1171 dnl CF_MAKE_DOCS version: 5 updated: 2021/01/10 16:05:11
1173 dnl $1 = name(s) to generate rules for
1174 dnl $2 = suffix of corresponding manpages used as input.
1176 dnl This works best if called at the end of configure.in, following CF_WITH_MAN2HTML
1177 define([CF_MAKE_DOCS],[
1178 test -z "$cf_make_docs" && cf_make_docs=0
1181 test -f "$cf_output" || cf_output=Makefile
1183 if test "$cf_make_docs" = 0
1185 cat >>$cf_output <<CF_EOF
1186 ################################################################################
1188 .SUFFIXES : .html .$2 .man .ps .pdf .txt
1190 ${NROFF_NOTE}.$2.txt :
1191 ${NROFF_NOTE} [\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
1193 ${GROFF_NOTE}.ps.pdf :
1194 ${GROFF_NOTE} ps2pdf [\$]*.ps
1196 ${GROFF_NOTE}.$2.ps :
1197 ${GROFF_NOTE} [\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
1199 ${GROFF_NOTE}.$2.txt :
1200 ${GROFF_NOTE} GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -rHY=0 -Tascii -man | col -bx" >[\$]@
1202 ${MAN2HTML_NOTE}.$2.html :
1203 ${MAN2HTML_NOTE} ./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
1211 cat >>$cf_output <<CF_EOF
1212 ################################################################################
1213 ${NROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
1214 ${MAN2HTML_NOTE}docs docs-$cf_name :: $cf_name.html
1215 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.pdf
1216 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.ps
1217 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
1221 ${NROFF_NOTE} rm -f $cf_name.txt
1222 ${MAN2HTML_NOTE} rm -f $cf_name.html
1223 ${GROFF_NOTE} rm -f $cf_name.pdf
1224 ${GROFF_NOTE} rm -f $cf_name.ps
1225 ${GROFF_NOTE} rm -f $cf_name.txt
1227 ${NROFF_NOTE}$cf_name.txt : $cf_name.$2
1228 ${MAN2HTML_NOTE}$cf_name.html : $cf_name.$2
1229 ${GROFF_NOTE}$cf_name.pdf : $cf_name.ps
1230 ${GROFF_NOTE}$cf_name.ps : $cf_name.$2
1231 ${GROFF_NOTE}$cf_name.txt : $cf_name.$2
1235 dnl ---------------------------------------------------------------------------
1236 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1238 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
1239 dnl a monocase filesystem.
1240 AC_DEFUN([CF_MAKE_TAGS],[
1241 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1243 AC_CHECK_PROGS(CTAGS, exctags ctags)
1244 AC_CHECK_PROGS(ETAGS, exetags etags)
1246 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1248 if test "$cf_cv_mixedcase" = yes ; then
1249 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1254 if test "$MAKE_UPPER_TAGS" = yes ; then
1260 if test "$MAKE_LOWER_TAGS" = yes ; then
1269 AC_SUBST(MAKE_UPPER_TAGS)
1270 AC_SUBST(MAKE_LOWER_TAGS)
1272 dnl ---------------------------------------------------------------------------
1273 dnl CF_MANPAGE_FORMAT version: 18 updated: 2023/05/19 18:35:02
1274 dnl -----------------
1275 dnl Option to allow user to override automatic configuration of manpage format.
1276 dnl There are several special cases:
1278 dnl compress - man checks for, can display compressed files
1279 dnl bzip2 - man checks for, can display bzip2'd files
1280 dnl gzip - man checks for, can display gzip'd files
1281 dnl xz - man checks for, can display xz'd files
1283 dnl BSDI - files in the cat-directories are suffixed ".0"
1284 dnl formatted - installer should format (put files in cat-directory)
1285 dnl catonly - installer should only format, e.g., for a turnkey system.
1287 dnl There are other configurations which this macro does not test, e.g., HPUX's
1288 dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
1289 dnl convention would not match our use).
1290 AC_DEFUN([CF_MANPAGE_FORMAT],
1292 AC_REQUIRE([CF_PATHSEP])
1293 AC_MSG_CHECKING(format of man-pages)
1295 AC_ARG_WITH(manpage-format,
1296 [ --with-manpage-format specify manpage-format: gzip/compress/bzip2/xz,
1297 BSDI/normal and optionally formatted/catonly,
1298 e.g., gzip,formatted],
1299 [MANPAGE_FORMAT=$withval],
1300 [MANPAGE_FORMAT=unknown])
1302 test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
1303 MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
1307 case "$MANPAGE_FORMAT" in
1309 if test -z "$MANPATH" ; then
1310 MANPATH="/usr/man:/usr/share/man"
1313 # look for the 'date' man-page (it is most likely to be installed!)
1319 IFS="${IFS:- }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
1320 for cf_dir in $MANPATH; do
1321 test -z "$cf_dir" && cf_dir=/usr/man
1322 for cf_name in $cf_dir/man*/$cf_example.[[01]]* $cf_dir/cat*/$cf_example.[[01]]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
1324 cf_test=`echo "$cf_name" | sed -e 's/*//'`
1325 if test "x$cf_test" = "x$cf_name" ; then
1328 (*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";;
1329 (*.xz) MANPAGE_FORMAT="$MANPAGE_FORMAT xz";;
1330 (*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
1331 (*.Z) MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
1332 (*.0) MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
1333 (*) MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
1347 # if we found a match in either man* or cat*, stop looking
1348 if test -n "$MANPAGE_FORMAT" ; then
1350 test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
1351 test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
1357 test "$cf_found" = yes && break
1360 # only check the first directory in $MANPATH where we find manpages
1361 if test -n "$MANPAGE_FORMAT" ; then
1365 # if we did not find the example, just assume it is normal
1366 test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
1370 for cf_option in $MANPAGE_FORMAT; do
1371 case "$cf_option" in
1372 (xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly)
1375 cf_unknown="$cf_unknown $cf_option"
1382 AC_MSG_RESULT($MANPAGE_FORMAT)
1383 if test -n "$cf_unknown" ; then
1384 AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
1387 cf_manpage_format=no
1388 cf_manpage_inboth=no
1389 cf_manpage_so_strip=
1390 cf_manpage_compress=
1392 for cf_item in $MANPAGE_FORMAT
1396 cf_manpage_format=yes
1397 cf_manpage_inboth=no
1400 cf_manpage_format=yes
1401 cf_manpage_inboth=yes
1404 cf_manpage_so_strip="Z"
1405 cf_manpage_compress=compress
1408 cf_manpage_so_strip="gz"
1409 cf_manpage_compress=gzip
1412 cf_manpage_so_strip="bz2"
1413 cf_manpage_compress=bzip2
1416 cf_manpage_so_strip="xz"
1417 cf_manpage_compress=xz
1422 AC_SUBST(cf_manpage_format)
1423 AC_SUBST(cf_manpage_inboth)
1424 AC_SUBST(cf_manpage_so_strip)
1425 AC_SUBST(cf_manpage_compress)
1428 dnl ---------------------------------------------------------------------------
1429 dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
1430 dnl ----------------------
1431 dnl Check if the file-system supports mixed-case filenames. If we're able to
1432 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1433 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1435 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1436 if test "$cross_compiling" = yes ; then
1437 case "$target_alias" in
1438 (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
1446 rm -f conftest CONFTEST
1448 if test -f CONFTEST ; then
1453 rm -f conftest CONFTEST
1456 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1458 dnl ---------------------------------------------------------------------------
1459 dnl CF_MKSTEMP version: 12 updated: 2023/01/05 17:53:11
1461 dnl Check for a working mkstemp. This creates two files, checks that they are
1462 dnl successfully created and distinct (AmigaOS apparently fails on the last).
1463 AC_DEFUN([CF_MKSTEMP],[
1467 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
1470 $ac_includes_default
1474 char *tmpl = "conftestXXXXXX";
1482 for (n = 0; n < 2; ++n) {
1483 strcpy(name[n], tmpl);
1484 if ((fd = mkstemp(name[n])) >= 0) {
1485 if (!strcmp(name[n], tmpl)
1486 || stat(name[n], &sb) != 0
1487 || (sb.st_mode & S_IFMT) != S_IFREG
1488 || (sb.st_mode & 077) != 0) {
1495 && !strcmp(name[0], name[1]))
1497 ${cf_cv_main_return:-return}(result);
1499 ],[cf_cv_func_mkstemp=yes
1500 ],[cf_cv_func_mkstemp=no
1501 ],[cf_cv_func_mkstemp=maybe])
1503 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
1504 AC_CHECK_FUNC(mkstemp)
1506 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
1507 AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
1510 dnl ---------------------------------------------------------------------------
1511 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1513 dnl Write a debug message to config.log, along with the line number in the
1514 dnl configure script.
1515 AC_DEFUN([CF_MSG_LOG],[
1516 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1518 dnl ---------------------------------------------------------------------------
1519 dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
1520 dnl ------------------
1521 dnl see CF_WITH_NO_LEAKS
1523 dnl $1 = option/name
1525 dnl $3 = symbol to define if the option is set
1526 dnl $4 = additional actions to take if the option is set
1527 AC_DEFUN([CF_NO_LEAKS_OPTION],[
1528 AC_MSG_CHECKING(if you want to use $1 for testing)
1531 [case "x$withval" in
1534 : "${with_cflags:=-g}"
1535 : "${enable_leaks:=no}"
1537 AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1543 AC_MSG_RESULT(${with_$1:-no})
1545 case ".$with_cflags" in
1557 dnl ---------------------------------------------------------------------------
1558 dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
1560 dnl Provide a value for the $PATH and similar separator (or amend the value
1561 dnl as provided in autoconf 2.5x).
1562 AC_DEFUN([CF_PATHSEP],
1564 AC_MSG_CHECKING(for PATH separator)
1565 case "$cf_cv_system_name" in
1566 (os2*) PATH_SEPARATOR=';' ;;
1567 (*) ${PATH_SEPARATOR:=':'} ;;
1569 ifelse([$1],,,[$1=$PATH_SEPARATOR])
1570 AC_SUBST(PATH_SEPARATOR)
1571 AC_MSG_RESULT($PATH_SEPARATOR)
1573 dnl ---------------------------------------------------------------------------
1574 dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
1576 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1577 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1578 dnl result begins with 'NONE'. This is necessary to work around autoconf's
1579 dnl delayed evaluation of those symbols.
1580 AC_DEFUN([CF_PATH_SYNTAX],[
1581 if test "x$prefix" != xNONE; then
1582 cf_path_syntax="$prefix"
1584 cf_path_syntax="$ac_default_prefix"
1588 (.\[$]\(*\)*|.\'*\'*)
1592 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1594 (.\[$]\{*prefix\}*|.\[$]\{*dir\}*)
1598 $1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
1603 $1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
1606 ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1610 dnl ---------------------------------------------------------------------------
1611 dnl CF_POSIX_C_SOURCE version: 12 updated: 2023/02/18 17:41:25
1612 dnl -----------------
1613 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1615 dnl POSIX.1-1990 _POSIX_SOURCE
1616 dnl POSIX.1-1990 and _POSIX_SOURCE and
1617 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
1619 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
1620 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
1621 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
1624 dnl $1 is the nominal value for _POSIX_C_SOURCE
1625 AC_DEFUN([CF_POSIX_C_SOURCE],
1626 [AC_REQUIRE([CF_POSIX_VISIBLE])dnl
1628 if test "$cf_cv_posix_visible" = no; then
1630 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1632 cf_save_CFLAGS="$CFLAGS"
1633 cf_save_CPPFLAGS="$CPPFLAGS"
1635 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1636 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1638 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1639 CF_MSG_LOG(if the symbol is already defined go no further)
1640 AC_TRY_COMPILE([#include <sys/types.h>],[
1641 #ifndef _POSIX_C_SOURCE
1642 #error _POSIX_C_SOURCE is not defined
1644 [cf_cv_posix_c_source=no],
1645 [cf_want_posix_source=no
1646 case .$cf_POSIX_C_SOURCE in
1648 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1651 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1652 cf_want_posix_source=yes
1655 cf_want_posix_source=yes
1658 if test "$cf_want_posix_source" = yes ; then
1659 AC_TRY_COMPILE([#include <sys/types.h>],[
1660 #ifdef _POSIX_SOURCE
1661 #error _POSIX_SOURCE is defined
1663 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1665 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1666 CFLAGS="$cf_trim_CFLAGS"
1667 CPPFLAGS="$cf_trim_CPPFLAGS"
1668 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
1669 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1670 AC_TRY_COMPILE([#include <sys/types.h>],[
1671 #ifndef _POSIX_C_SOURCE
1672 #error _POSIX_C_SOURCE is not defined
1674 [cf_cv_posix_c_source=no])
1675 CFLAGS="$cf_save_CFLAGS"
1676 CPPFLAGS="$cf_save_CPPFLAGS"
1680 if test "$cf_cv_posix_c_source" != no ; then
1681 CFLAGS="$cf_trim_CFLAGS"
1682 CPPFLAGS="$cf_trim_CPPFLAGS"
1683 CF_ADD_CFLAGS($cf_cv_posix_c_source)
1686 fi # cf_cv_posix_visible
1689 dnl ---------------------------------------------------------------------------
1690 dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
1691 dnl ----------------
1692 dnl POSIX documents test-macros which an application may set before any system
1693 dnl headers are included to make features available.
1695 dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
1696 dnl diverged from POSIX in 2002 by setting symbols which make all of the most
1697 dnl recent features visible in the system header files unless the application
1698 dnl overrides the corresponding test-macros. Doing that introduces portability
1701 dnl This macro makes a special check for the symbols used for this, to avoid a
1702 dnl conflicting definition.
1703 AC_DEFUN([CF_POSIX_VISIBLE],
1705 AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
1706 AC_TRY_COMPILE([#include <stdio.h>],[
1707 #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
1708 && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
1709 && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
1710 && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
1711 #error conflicting symbols found
1713 ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
1716 dnl ---------------------------------------------------------------------------
1717 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
1719 dnl Check for awk, ensure that the check found something.
1720 AC_DEFUN([CF_PROG_AWK],
1723 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
1725 dnl ---------------------------------------------------------------------------
1726 dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
1728 dnl standard check for CC, plus followup sanity checks
1729 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1730 AC_DEFUN([CF_PROG_CC],[
1731 CF_ACVERSION_CHECK(2.53,
1732 [AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
1733 AC_REQUIRE([AC_PROG_CC])],
1735 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1737 CF_ACVERSION_CHECK(2.52,
1742 dnl ---------------------------------------------------------------------------
1743 dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
1745 dnl Check if groff is available, for cases (such as html output) where nroff
1747 AC_DEFUN([CF_PROG_GROFF],[
1748 AC_PATH_PROG(GROFF_PATH,groff,no)
1749 AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
1750 AC_PATH_PROG(TBL_PATH,tbl,cat)
1751 if test "x$GROFF_PATH" = xno
1759 AC_SUBST(GROFF_NOTE)
1760 AC_SUBST(NROFF_NOTE)
1762 dnl ---------------------------------------------------------------------------
1763 dnl CF_PROG_LINT version: 5 updated: 2022/08/20 15:44:13
1765 AC_DEFUN([CF_PROG_LINT],
1767 AC_CHECK_PROGS(LINT, lint cppcheck splint)
1769 (xcppcheck|x*/cppcheck)
1770 test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
1776 dnl ---------------------------------------------------------------------------
1777 dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40
1778 dnl ----------------
1779 dnl Remove a given option from CFLAGS/CPPFLAGS
1780 dnl $1 = option to remove
1781 dnl $2 = variable to update
1782 dnl $3 = nonempty to allow verbose message
1783 define([CF_REMOVE_CFLAGS],
1785 cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'`
1788 cf_old_cflag=`echo "x[$]$2" | sed -e 's/^.//' -e 's/[[ ]][[ ]]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[[^ ]][[^ ]]*\\)\?%%" -e 's/^[[ ]]*//' -e 's%[[ ]][[ ]]*-D% -D%g' -e 's%[[ ]][[ ]]*-I% -I%g'`
1789 test "[$]$2" != "$cf_old_cflag" || break
1790 ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)])
1794 dnl ---------------------------------------------------------------------------
1795 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1796 dnl ----------------
1797 dnl Remove all -U and -D options that refer to the given symbol from a list
1798 dnl of C compiler options. This works around the problem that not all
1799 dnl compilers process -U and -D options from left-to-right, so a -U option
1800 dnl cannot be used to cancel the effect of a preceding -D option.
1802 dnl $1 = target (which could be the same as the source variable)
1803 dnl $2 = source (including '$')
1804 dnl $3 = symbol to remove
1805 define([CF_REMOVE_DEFINE],
1808 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
1809 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
1811 dnl ---------------------------------------------------------------------------
1812 dnl CF_TRY_XOPEN_SOURCE version: 4 updated: 2022/09/10 15:16:16
1813 dnl -------------------
1814 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1815 dnl can define it successfully.
1816 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1817 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1818 AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
1819 [cf_cv_xopen_source=no],
1820 [cf_save="$CPPFLAGS"
1821 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
1822 AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
1823 [cf_cv_xopen_source=no],
1824 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1829 if test "$cf_cv_xopen_source" != no ; then
1830 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1831 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1832 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1833 CF_APPEND_CFLAGS($cf_temp_xopen_source)
1836 dnl ---------------------------------------------------------------------------
1837 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1839 dnl Make an uppercase version of a variable
1840 dnl $1=uppercase($2)
1841 AC_DEFUN([CF_UPPER],
1843 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1845 dnl ---------------------------------------------------------------------------
1846 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1848 dnl Use AC_VERBOSE w/o the warnings
1849 AC_DEFUN([CF_VERBOSE],
1850 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1853 dnl ---------------------------------------------------------------------------
1854 dnl CF_WITHOUT_X version: 3 updated: 2021/01/13 16:51:52
1856 dnl Use this to cancel the check for X headers/libraries which would be pulled
1857 dnl in via CF_GCC_WARNINGS.
1858 define([CF_WITHOUT_X],
1859 AC_DEFUN([AC_PATH_XTRA],[])
1860 AC_DEFUN([CF_SAVE_XTRA_FLAGS],[])
1861 AC_DEFUN([CF_RESTORE_XTRA_FLAGS],[])
1862 AC_DEFUN([CF_CONST_X_STRING],[echo "skipping X-const check";])dnl
1866 dnl ---------------------------------------------------------------------------
1867 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1868 dnl ----------------
1869 dnl Configure-option for dbmalloc. The optional parameter is used to override
1870 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1871 AC_DEFUN([CF_WITH_DBMALLOC],[
1872 CF_NO_LEAKS_OPTION(dbmalloc,
1873 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
1876 if test "$with_dbmalloc" = yes ; then
1877 AC_CHECK_HEADER(dbmalloc.h,
1878 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1881 dnl ---------------------------------------------------------------------------
1882 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1884 dnl Configure-option for dmalloc. The optional parameter is used to override
1885 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1886 AC_DEFUN([CF_WITH_DMALLOC],[
1887 CF_NO_LEAKS_OPTION(dmalloc,
1888 [ --with-dmalloc test: use Gray Watson's dmalloc library],
1891 if test "$with_dmalloc" = yes ; then
1892 AC_CHECK_HEADER(dmalloc.h,
1893 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1896 dnl ---------------------------------------------------------------------------
1897 dnl CF_WITH_MAN2HTML version: 12 updated: 2021/01/03 18:30:50
1898 dnl ----------------
1899 dnl Check for man2html and groff. Prefer man2html over groff, but use groff
1900 dnl as a fallback. See
1902 dnl http://invisible-island.net/scripts/man2html.html
1904 dnl Generate a shell script which hides the differences between the two.
1906 dnl We name that "man2html.tmp".
1908 dnl The shell script can be removed later, e.g., using "make distclean".
1909 AC_DEFUN([CF_WITH_MAN2HTML],[
1910 AC_REQUIRE([CF_PROG_GROFF])dnl
1911 AC_REQUIRE([AC_PROG_FGREP])dnl
1913 case "x${with_man2html}" in
1918 AC_PATH_PROG(cf_man2html,man2html,no)
1919 case "x$cf_man2html" in
1921 AC_MSG_CHECKING(for the modified Earl Hood script)
1922 if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
1929 AC_MSG_RESULT($cf_man2html_ok)
1937 AC_MSG_CHECKING(for program to convert manpage to html)
1938 AC_ARG_WITH(man2html,
1939 [ --with-man2html=XXX use XXX rather than groff],
1940 [cf_man2html=$withval],
1941 [cf_man2html=$cf_man2html])
1945 case $cf_man2html in
1947 AC_MSG_RESULT(man2html)
1948 AC_PATH_PROG(cf_man2html,man2html,no)
1952 cf_man2html=$GROFF_PATH
1953 AC_MSG_RESULT($cf_man2html)
1956 AC_MSG_RESULT($cf_man2html)
1960 MAN2HTML_TEMP="man2html.tmp"
1961 cat >$MAN2HTML_TEMP <<CF_EOF
1963 # Temporary script generated by CF_WITH_MAN2HTML
1964 # Convert inputs to html, sending result to standard output.
1967 # \${1} = rootname of file to convert
1968 # \${2} = suffix of file to convert, e.g., "1"
1969 # \${3} = macros to use, e.g., "man"
1985 if test "x$cf_with_groff" = xyes
1987 MAN2HTML_NOTE="$GROFF_NOTE"
1988 MAN2HTML_PATH="$GROFF_PATH"
1989 cat >>$MAN2HTML_TEMP <<CF_EOF
1990 $SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
1993 # disable hyphenation if this is groff
1994 if test "x$GROFF_PATH" != xno
1996 AC_MSG_CHECKING(if nroff is really groff)
1997 cf_check_groff="`$NROFF_PATH --version 2>/dev/null | grep groff`"
1998 test -n "$cf_check_groff" && cf_check_groff=yes
1999 test -n "$cf_check_groff" || cf_check_groff=no
2000 AC_MSG_RESULT($cf_check_groff)
2001 test "x$cf_check_groff" = xyes && NROFF_OPTS="-rHY=0"
2004 CF_PATH_SYNTAX(cf_man2html)
2005 MAN2HTML_PATH="$cf_man2html"
2006 AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
2008 # for this example, expect 3 lines of content, the remainder is head/foot
2009 cat >conftest.in <<CF_EOF
2010 .TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
2015 LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
2017 cf_man2html_1st="`${FGREP-fgrep} -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
2018 cf_man2html_top=`expr "$cf_man2html_1st" - 2`
2019 cf_man2html_bot="`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`"
2020 cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"`
2021 cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
2023 AC_MSG_RESULT($cf_man2html_top_bot)
2025 AC_MSG_CHECKING(for pagesize to use)
2026 for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2028 cat >>conftest.in <<CF_EOF
2043 LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
2044 cf_man2html_page="`${FGREP-fgrep} -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
2045 test -z "$cf_man2html_page" && cf_man2html_page=99999
2046 test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
2049 AC_MSG_RESULT($cf_man2html_page)
2051 cat >>$MAN2HTML_TEMP <<CF_EOF
2052 : \${MAN2HTML_PATH=$MAN2HTML_PATH}
2053 MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title=\"\$ROOT(\$TYPE)\" -compress -pgsize $cf_man2html_page"
2056 $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
2059 $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
2065 chmod 700 $MAN2HTML_TEMP
2067 AC_SUBST(MAN2HTML_NOTE)
2068 AC_SUBST(MAN2HTML_PATH)
2069 AC_SUBST(MAN2HTML_TEMP)
2071 dnl ---------------------------------------------------------------------------
2072 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
2073 dnl ----------------
2074 AC_DEFUN([CF_WITH_VALGRIND],[
2075 CF_NO_LEAKS_OPTION(valgrind,
2076 [ --with-valgrind test: use valgrind],
2079 dnl ---------------------------------------------------------------------------
2080 dnl CF_XOPEN_SOURCE version: 66 updated: 2023/04/03 04:19:37
2082 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2083 dnl or adapt to the vendor's definitions to get equivalent functionality,
2084 dnl without losing the common non-POSIX features.
2087 dnl $1 is the nominal value for _XOPEN_SOURCE
2088 dnl $2 is the nominal value for _POSIX_C_SOURCE
2090 dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the
2091 dnl implementation predefines it, because X/Open and most implementations agree
2092 dnl that the latter is a legacy or "aligned" value.
2094 dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns
2095 dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly.
2098 dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
2099 dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
2100 dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
2101 AC_DEFUN([CF_XOPEN_SOURCE],[
2102 AC_REQUIRE([AC_CANONICAL_HOST])
2103 AC_REQUIRE([CF_POSIX_VISIBLE])
2105 if test "$cf_cv_posix_visible" = no; then
2107 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
2108 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
2113 cf_xopen_source="-D_ALL_SOURCE"
2116 cf_xopen_source="-D_APPLE_C_SOURCE"
2119 cf_xopen_source="-D_DARWIN_C_SOURCE"
2122 (freebsd*|dragonfly*|midnightbsd*)
2123 # 5.x headers associate
2124 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2125 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2126 cf_POSIX_C_SOURCE=200112L
2128 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2131 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
2134 cf_xopen_source="-D_HPUX_SOURCE"
2137 cf_xopen_source="-D_SGI_SOURCE"
2140 (linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*)
2141 CF_GNU_SOURCE($cf_XOPEN_SOURCE)
2144 cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
2147 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
2149 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2152 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2155 # OpenBSD 6.x has broken locale support, both compile-time and runtime.
2156 # see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
2157 # Abusing the conformance level is a workaround.
2158 AC_MSG_WARN(this system does not provide usable locale support)
2159 cf_xopen_source="-D_BSD_SOURCE"
2163 # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
2164 cf_xopen_source="-D_BSD_SOURCE"
2168 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2171 cf_xopen_source="-D_OSF_SOURCE"
2174 cf_xopen_source="-D_QNX_SOURCE"
2177 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2180 cf_xopen_source="-D__EXTENSIONS__"
2181 cf_cv_xopen_source=broken
2183 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
2189 cf_save_xopen_cppflags="$CPPFLAGS"
2190 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2191 # Some of these niche implementations use copy/paste, double-check...
2192 if test "$cf_cv_xopen_source" = no ; then
2193 CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE)
2194 AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[
2195 AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable)
2196 CPPFLAGS="$cf_save_xopen_cppflags"])
2201 if test -n "$cf_xopen_source" ; then
2202 CF_APPEND_CFLAGS($cf_xopen_source,true)
2205 dnl In anything but the default case, we may have system-specific setting
2206 dnl which is still not guaranteed to provide all of the entrypoints that
2207 dnl _XOPEN_SOURCE would yield.
2208 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
2209 AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
2210 AC_TRY_COMPILE([#include <stdlib.h>],[
2211 #ifndef _XOPEN_SOURCE
2212 #error _XOPEN_SOURCE is not defined
2214 [cf_XOPEN_SOURCE_set=yes],
2215 [cf_XOPEN_SOURCE_set=no])
2216 AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
2217 if test "$cf_XOPEN_SOURCE_set" = yes
2219 AC_TRY_COMPILE([#include <stdlib.h>],[
2220 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
2221 #error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
2223 [cf_XOPEN_SOURCE_set_ok=yes],
2224 [cf_XOPEN_SOURCE_set_ok=no])
2225 if test "$cf_XOPEN_SOURCE_set_ok" = no
2227 AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
2233 fi # cf_cv_posix_visible
2235 dnl ---------------------------------------------------------------------------
2236 dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25
2237 dnl ---------------------
2238 dnl body of test when test-compiling for _XOPEN_SOURCE check
2239 define([CF__XOPEN_SOURCE_BODY],
2241 #ifndef _XOPEN_SOURCE
2242 #error _XOPEN_SOURCE is not defined
2245 dnl ---------------------------------------------------------------------------
2246 dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25
2247 dnl ---------------------
2248 dnl headers to include when test-compiling for _XOPEN_SOURCE check
2249 define([CF__XOPEN_SOURCE_HEAD],
2251 $ac_includes_default