22570b68b3e4507a626bc56ac30ac32db44686f5
[platform/upstream/byacc.git] / aclocal.m4
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
5 dnl 
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:
13 dnl 
14 dnl The above copyright notice and this permission notice shall be included
15 dnl in all copies or portions of the Software.
16 dnl 
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.
24 dnl 
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
28 dnl authorization.
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.
34 dnl
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],
39 [
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
58 dnl -------------
59 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
60 dnl The second parameter if given makes this macro verbose.
61 dnl
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],
66 [
67 cf_fix_cppflags=no
68 cf_new_cflags=
69 cf_new_cppflags=
70 cf_new_extra_cppflags=
71
72 for cf_add_cflags in $1
73 do
74 case $cf_fix_cppflags in
75 (no)
76         case $cf_add_cflags in
77         (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
78                 case $cf_add_cflags in
79                 (-D*)
80                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
81
82                         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
83                                 && test -z "${cf_tst_cflags}" \
84                                 && cf_fix_cppflags=yes
85
86                         if test $cf_fix_cppflags = yes ; then
87                                 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
88                                 continue
89                         elif test "${cf_tst_cflags}" = "\"'" ; then
90                                 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
91                                 continue
92                         fi
93                         ;;
94                 esac
95                 case "$CPPFLAGS" in
96                 (*$cf_add_cflags)
97                         ;;
98                 (*)
99                         case $cf_add_cflags in
100                         (-D*)
101                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
102                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
103                                 ;;
104                         esac
105                         CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
106                         ;;
107                 esac
108                 ;;
109         (*)
110                 CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
111                 ;;
112         esac
113         ;;
114 (yes)
115         CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
116
117         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
118
119         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
120                 && test -z "${cf_tst_cflags}" \
121                 && cf_fix_cppflags=no
122         ;;
123 esac
124 done
125
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)
129 fi
130
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)
134 fi
135
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)
139 fi
140
141 AC_SUBST(EXTRA_CPPFLAGS)
142
143 ])dnl
144 dnl ---------------------------------------------------------------------------
145 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
146 dnl --------------
147 dnl use this macro for appending text without introducing an extra blank at
148 dnl the beginning
149 define([CF_APPEND_TEXT],
150 [
151         test -n "[$]$1" && $1="[$]$1 "
152         $1="[$]{$1}$2"
153 ])dnl
154 dnl ---------------------------------------------------------------------------
155 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
156 dnl --------------
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
162 dnl -------------
163 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
164 dnl values.
165 dnl
166 dnl Parameters:
167 dnl $1 = option name
168 dnl $2 = help-string
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
175 ifelse([$3],,[    :]dnl
176 ,[    $3]) ifelse([$4],,,[
177         else
178                 $4])
179         fi],[enableval=$5 ifelse([$4],,,[
180         $4
181 ])dnl
182 ])])dnl
183 dnl ---------------------------------------------------------------------------
184 dnl CF_CC_ENV_FLAGS version: 9 updated: 2018/07/29 18:03:26
185 dnl ---------------
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.
189 dnl
190 dnl In particular, it addresses the problem of being able to run the C
191 dnl preprocessor in a consistent manner.
192 dnl
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],
197 [
198 # This should have been defined by AC_PROG_CC
199 : ${CC:=cc}
200
201 AC_MSG_CHECKING(\$CFLAGS variable)
202 case "x$CFLAGS" in
203 (*-[[IUD]]*)
204         AC_MSG_RESULT(broken)
205         AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
206         cf_flags="$CFLAGS"
207         CFLAGS=
208         for cf_arg in $cf_flags
209         do
210                 CF_ADD_CFLAGS($cf_arg)
211         done
212         ;;
213 (*)
214         AC_MSG_RESULT(ok)
215         ;;
216 esac
217
218 AC_MSG_CHECKING(\$CC variable)
219 case "$CC" in
220 (*[[\ \ ]]-*)
221         AC_MSG_RESULT(broken)
222         AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
223         # humor him...
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))); }'`
226         CC="$cf_prog"
227         for cf_arg in $cf_flags
228         do
229                 case "x$cf_arg" in
230                 (x-[[IUDfgOW]]*)
231                         CF_ADD_CFLAGS($cf_arg)
232                         ;;
233                 (*)
234                         CC="$CC $cf_arg"
235                         ;;
236                 esac
237         done
238         CF_VERBOSE(resulting CC: '$CC')
239         CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
240         CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
241         ;;
242 (*)
243         AC_MSG_RESULT(ok)
244         ;;
245 esac
246 ])dnl
247 dnl ---------------------------------------------------------------------------
248 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
249 dnl --------------
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.
252 dnl
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.
257 dnl
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],
261 [
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"
265 else
266         system_name="`(uname -s -r) 2>/dev/null`"
267         if test -z "$system_name" ; then
268                 system_name="`(hostname) 2>/dev/null`"
269         fi
270 fi
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"])
273
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)
276
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.")
280 fi
281 ])dnl
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.
288 dnl
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.
292 dnl
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
298
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"
303         AC_TRY_COMPILE([],[
304 #ifdef __clang__
305 #else
306 make an error
307 #endif
308 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
309 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
310 ],[])
311         ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
312         AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
313 fi
314 ])
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.
320 dnl
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.
326 dnl
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).
331 dnl
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],
336 [
337 AC_REQUIRE([AC_PATH_XTRA])
338
339 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
340
341 AC_TRY_COMPILE(
342 [
343 #include <stdlib.h>
344 #include <X11/Intrinsic.h>
345 ],
346 [String foo = malloc(1); (void)foo],[
347
348 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
349         AC_TRY_COMPILE(
350                 [
351 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
352 #undef  XTSTRINGDEFINES /* X11R5 and later */
353 #include <stdlib.h>
354 #include <X11/Intrinsic.h>
355                 ],[String foo = malloc(1); *foo = 0],[
356                         cf_cv_const_x_string=no
357                 ],[
358                         cf_cv_const_x_string=yes
359                 ])
360 ])
361
362 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
363
364 case $cf_cv_const_x_string in
365 (no)
366         CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
367         ;;
368 (*)
369         CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
370         ;;
371 esac
372
373 ])
374 ])dnl
375 dnl ---------------------------------------------------------------------------
376 dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
377 dnl ---------------
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.
380 dnl
381 dnl Sets:
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
387 dnl
388 AC_DEFUN([CF_DISABLE_ECHO],[
389 AC_MSG_CHECKING(if you want to see long compiling messages)
390 CF_ARG_DISABLE(echo,
391         [  --disable-echo          do not display "compiling" commands],
392         [
393         ECHO_LT='--silent'
394         ECHO_LD='@echo linking [$]@;'
395         RULE_CC='@echo compiling [$]<'
396         SHOW_CC='@echo compiling [$]@'
397         ECHO_CC='@'
398 ],[
399         ECHO_LT=''
400         ECHO_LD=''
401         RULE_CC=''
402         SHOW_CC=''
403         ECHO_CC=''
404 ])
405 AC_MSG_RESULT($enableval)
406 AC_SUBST(ECHO_LT)
407 AC_SUBST(ECHO_LD)
408 AC_SUBST(RULE_CC)
409 AC_SUBST(SHOW_CC)
410 AC_SUBST(ECHO_CC)
411 ])dnl
412 dnl ---------------------------------------------------------------------------
413 dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
414 dnl ----------------
415 dnl Combine no-leak checks with the libraries or tools that are used for the
416 dnl checks.
417 AC_DEFUN([CF_DISABLE_LEAKS],[
418
419 AC_REQUIRE([CF_WITH_DMALLOC])
420 AC_REQUIRE([CF_WITH_DBMALLOC])
421 AC_REQUIRE([CF_WITH_VALGRIND])
422
423 AC_MSG_CHECKING(if you want to perform memory-leak testing)
424 AC_ARG_ENABLE(leaks,
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)
429
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.])
433 fi
434 ])dnl
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],
442 [
443 if test "$GCC" = yes
444 then
445 cat > conftest.i <<EOF
446 #ifndef GCC_PRINTF
447 #define GCC_PRINTF 0
448 #endif
449 #ifndef GCC_SCANF
450 #define GCC_SCANF 0
451 #endif
452 #ifndef GCC_NORETURN
453 #define GCC_NORETURN /* nothing */
454 #endif
455 #ifndef GCC_UNUSED
456 #define GCC_UNUSED /* nothing */
457 #endif
458 EOF
459 if test "$GCC" = yes
460 then
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"
467 #if     GCC_PRINTF
468 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
469 #else
470 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
471 #endif
472 #if     GCC_SCANF
473 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
474 #else
475 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
476 #endif
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; }
481 EOF
482         cf_printf_attribute=no
483         cf_scanf_attribute=no
484         for cf_attribute in scanf printf unused noreturn
485         do
486                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
487                 cf_directive="__attribute__(($cf_attribute))"
488                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
489
490                 case $cf_attribute in
491                 (printf)
492                         cf_printf_attribute=yes
493                         cat >conftest.h <<EOF
494 #define GCC_$cf_ATTRIBUTE 1
495 EOF
496                         ;;
497                 (scanf)
498                         cf_scanf_attribute=yes
499                         cat >conftest.h <<EOF
500 #define GCC_$cf_ATTRIBUTE 1
501 EOF
502                         ;;
503                 (*)
504                         cat >conftest.h <<EOF
505 #define GCC_$cf_ATTRIBUTE $cf_directive
506 EOF
507                         ;;
508                 esac
509
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
514                         (noreturn)
515                                 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
516                                 ;;
517                         (printf)
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.])
522                                 fi
523                                 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
524                                 ;;
525                         (scanf)
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.])
530                                 fi
531                                 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
532                                 ;;
533                         (unused)
534                                 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
535                                 ;;
536                         esac
537                 fi
538         done
539 else
540         fgrep define conftest.i >>confdefs.h
541 fi
542 rm -rf conftest*
543 fi
544 ])dnl
545 dnl ---------------------------------------------------------------------------
546 dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
547 dnl --------------
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])
552 GCC_VERSION=none
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)
558 fi
559 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
560 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
561 ])dnl
562 dnl ---------------------------------------------------------------------------
563 dnl CF_GCC_WARNINGS version: 37 updated: 2020/01/05 20:04:12
564 dnl ---------------
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:
567 dnl
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".
574 dnl     -pedantic
575 dnl
576 dnl Parameter:
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
579 dnl             -Wno-unused
580 dnl Special:
581 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
582 dnl
583 AC_DEFUN([CF_GCC_WARNINGS],
584 [
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) ; }
590 EOF
591 if test "$INTEL_COMPILER" = yes
592 then
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
603
604         AC_CHECKING([for $CC warning options])
605         cf_save_CFLAGS="$CFLAGS"
606         EXTRA_CFLAGS="-Wall"
607         for cf_opt in \
608                 wd1419 \
609                 wd1683 \
610                 wd1684 \
611                 wd193 \
612                 wd593 \
613                 wd279 \
614                 wd810 \
615                 wd869 \
616                 wd981
617         do
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"
622                 fi
623         done
624         CFLAGS="$cf_save_CFLAGS"
625 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
626 then
627         AC_CHECKING([for $CC warning options])
628         cf_save_CFLAGS="$CFLAGS"
629         EXTRA_CFLAGS=
630         cf_warn_CONST=""
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 \
635                 Wbad-function-cast \
636                 Wcast-align \
637                 Wcast-qual \
638                 Wdeclaration-after-statement \
639                 Wextra \
640                 Winline \
641                 Wmissing-declarations \
642                 Wmissing-prototypes \
643                 Wnested-externs \
644                 Wpointer-arith \
645                 Wshadow \
646                 Wstrict-prototypes \
647                 Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
648         do
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)
652                         case $cf_opt in
653                         (Winline)
654                                 case $GCC_VERSION in
655                                 ([[34]].*)
656                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
657                                         continue;;
658                                 esac
659                                 ;;
660                         (Wpointer-arith)
661                                 case $GCC_VERSION in
662                                 ([[12]].*)
663                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
664                                         continue;;
665                                 esac
666                                 ;;
667                         esac
668                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
669                 fi
670         done
671         CFLAGS="$cf_save_CFLAGS"
672 fi
673 rm -rf conftest*
674
675 AC_SUBST(EXTRA_CFLAGS)
676 ])dnl
677 dnl ---------------------------------------------------------------------------
678 dnl CF_GETOPT_HEADER version: 6 updated: 2014/07/22 14:45:54
679 dnl ----------------
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],
683 [
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
688 do
689 AC_TRY_COMPILE([
690 #include <$cf_header>],
691 [int x = optind; char *y = optarg],
692 [cf_cv_getopt_header=$cf_header
693  break])
694 done
695 ])
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])
698 fi
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])
701 fi
702 ])dnl
703 dnl ---------------------------------------------------------------------------
704 dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
705 dnl -------------
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.
710 dnl
711 dnl Well, yes we could work around it...
712 dnl
713 dnl Parameters:
714 dnl     $1 is the nominal value for _XOPEN_SOURCE
715 AC_DEFUN([CF_GNU_SOURCE],
716 [
717 cf_gnu_xopen_source=ifelse($1,,500,$1)
718
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
722                 return 0;
723         #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
724                 return 0;
725         #else
726         #       error not GNU C library
727         #endif],
728         [cf_cv_gnu_library=yes],
729         [cf_cv_gnu_library=no])
730 ])
731
732 if test x$cf_cv_gnu_library = xyes; then
733
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
736         # years later.
737         AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
738                 cf_save="$CPPFLAGS"
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)
742                                 return 0;
743                         #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
744                                 return 0;
745                         #else
746                         #       error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
747                         #endif],
748                         [cf_cv_gnu_library_219=yes],
749                         [cf_cv_gnu_library_219=no])
750                 CPPFLAGS="$cf_save"
751         ])
752
753         if test "x$cf_cv_gnu_library_219" = xyes; then
754                 cf_save="$CPPFLAGS"
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)
757                         AC_TRY_COMPILE([
758                                 #include <limits.h>
759                                 #include <sys/types.h>
760                                 ],[
761                                 #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
762                                         return 0;
763                                 #else
764                                 #       error GNU C library is too old
765                                 #endif],
766                                 [cf_cv_gnu_dftsrc_219=yes],
767                                 [cf_cv_gnu_dftsrc_219=no])
768                         ])
769                 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
770         else
771                 cf_cv_gnu_dftsrc_219=maybe
772         fi
773
774         if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
775
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
780                         #endif],
781                         [cf_cv_gnu_source=no],
782                         [cf_save="$CPPFLAGS"
783                          CF_ADD_CFLAGS(-D_GNU_SOURCE)
784                          AC_TRY_COMPILE([#include <sys/types.h>],[
785                                 #ifdef _XOPEN_SOURCE
786                                 #error  expected _XOPEN_SOURCE to be undefined
787                                 #endif],
788                                 [cf_cv_gnu_source=no],
789                                 [cf_cv_gnu_source=yes])
790                         CPPFLAGS="$cf_save"
791                         ])
792                 ])
793
794                 if test "$cf_cv_gnu_source" = yes
795                 then
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
801                                 #endif],
802                                 [cf_cv_default_source=no],
803                                 [cf_cv_default_source=yes])
804                         ])
805                         if test "$cf_cv_default_source" = yes
806                         then
807                                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
808                         fi
809                 fi
810         fi
811
812 fi
813 ])dnl
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.
820 dnl
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.
824 dnl
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
831
832 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
833         case $host_os in
834         (linux*|gnu*)
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"
838                 AC_TRY_COMPILE([],[
839 #ifdef __INTEL_COMPILER
840 #else
841 make an error
842 #endif
843 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
844 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
845 ],[])
846                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
847                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
848                 ;;
849         esac
850 fi
851 ])dnl
852 dnl ---------------------------------------------------------------------------
853 dnl CF_MAKE_DOCS version: 4 updated: 2015/07/04 21:43:03
854 dnl ------------
855 dnl $1 = name(s) to generate rules for
856 dnl $2 = suffix of corresponding manpages used as input.
857 dnl
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
861
862 cf_output=makefile
863 test -f "$cf_output" || cf_output=Makefile
864
865 if test "$cf_make_docs" = 0
866 then
867 cat >>$cf_output <<CF_EOF
868 ################################################################################
869 ## generated by $0
870 .SUFFIXES : .html .$2 .man .ps .pdf .txt
871
872 ${NROFF_NOTE}.$2.txt :
873 ${NROFF_NOTE}   [\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
874
875 ${GROFF_NOTE}.ps.pdf :
876 ${GROFF_NOTE}   ps2pdf [\$]*.ps
877 ${GROFF_NOTE}
878 ${GROFF_NOTE}.$2.ps :
879 ${GROFF_NOTE}   [\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
880 ${GROFF_NOTE}
881 ${GROFF_NOTE}.$2.txt :
882 ${GROFF_NOTE}   GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -Tascii -man | col -bx" >[\$]@
883
884 ${MAN2HTML_NOTE}.$2.html :
885 ${MAN2HTML_NOTE}        ./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
886
887 CF_EOF
888         cf_make_docs=1
889 fi
890
891 for cf_name in $1
892 do
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
900
901 clean \\
902 docs-clean ::
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
908
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
914 CF_EOF
915 done
916 ])dnl
917 dnl ---------------------------------------------------------------------------
918 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
919 dnl ------------
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])
924
925 AC_CHECK_PROGS(CTAGS, exctags ctags)
926 AC_CHECK_PROGS(ETAGS, exetags etags)
927
928 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
929
930 if test "$cf_cv_mixedcase" = yes ; then
931         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
932 else
933         MAKE_UPPER_TAGS=no
934 fi
935
936 if test "$MAKE_UPPER_TAGS" = yes ; then
937         MAKE_UPPER_TAGS=
938 else
939         MAKE_UPPER_TAGS="#"
940 fi
941
942 if test "$MAKE_LOWER_TAGS" = yes ; then
943         MAKE_LOWER_TAGS=
944 else
945         MAKE_LOWER_TAGS="#"
946 fi
947
948 AC_SUBST(CTAGS)
949 AC_SUBST(ETAGS)
950
951 AC_SUBST(MAKE_UPPER_TAGS)
952 AC_SUBST(MAKE_LOWER_TAGS)
953 ])dnl
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],
960 [
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*)
965                 cf_cv_mixedcase=no
966                 ;;
967         (*)
968                 cf_cv_mixedcase=yes
969                 ;;
970         esac
971 else
972         rm -f conftest CONFTEST
973         echo test >conftest
974         if test -f CONFTEST ; then
975                 cf_cv_mixedcase=no
976         else
977                 cf_cv_mixedcase=yes
978         fi
979         rm -f conftest CONFTEST
980 fi
981 ])
982 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
983 ])dnl
984 dnl ---------------------------------------------------------------------------
985 dnl CF_MKSTEMP version: 10 updated: 2017/01/21 11:12:16
986 dnl ----------
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],[
990 AC_CHECK_HEADERS( \
991 unistd.h \
992 )
993 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
994 rm -rf conftest*
995 AC_TRY_RUN([
996 #include <sys/types.h>
997 #ifdef HAVE_UNISTD_H
998 #include <unistd.h>
999 #endif
1000 #include <stdlib.h>
1001 #include <stdio.h>
1002 #include <string.h>
1003 #include <sys/stat.h>
1004 int main(void)
1005 {
1006         char *tmpl = "conftestXXXXXX";
1007         char name[2][80];
1008         int n;
1009         int result = 0;
1010         int fd;
1011         struct stat sb;
1012
1013         umask(077);
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) {
1021                                 result = 1;
1022                         }
1023                         close(fd);
1024                 }
1025         }
1026         if (result == 0
1027          && !strcmp(name[0], name[1]))
1028                 result = 1;
1029         ${cf_cv_main_return:-return}(result);
1030 }
1031 ],[cf_cv_func_mkstemp=yes
1032 ],[cf_cv_func_mkstemp=no
1033 ],[cf_cv_func_mkstemp=maybe])
1034 ])
1035 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
1036         AC_CHECK_FUNC(mkstemp)
1037 fi
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.])
1040 fi
1041 ])dnl
1042 dnl ---------------------------------------------------------------------------
1043 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1044 dnl ----------
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
1049 ])dnl
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)
1056 AC_ARG_WITH($1,
1057         [$2],
1058         [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1059          $4
1060 ])
1061         : ${with_cflags:=-g}
1062         : ${with_no_leaks:=yes}
1063          with_$1=yes],
1064         [with_$1=])
1065 AC_MSG_RESULT(${with_$1:-no})
1066
1067 case .$with_cflags in
1068 (.*-g*)
1069         case .$CFLAGS in
1070         (.*-g*)
1071                 ;;
1072         (*)
1073                 CF_ADD_CFLAGS([-g])
1074                 ;;
1075         esac
1076         ;;
1077 esac
1078 ])dnl
1079 dnl ---------------------------------------------------------------------------
1080 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
1081 dnl --------------
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"
1089 else
1090         cf_path_syntax="$ac_default_prefix"
1091 fi
1092
1093 case ".[$]$1" in
1094 (.\[$]\(*\)*|.\'*\'*)
1095         ;;
1096 (..|./*|.\\*)
1097         ;;
1098 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1099         ;;
1100 (.\[$]{*prefix}*|.\[$]{*dir}*)
1101         eval $1="[$]$1"
1102         case ".[$]$1" in
1103         (.NONE/*)
1104                 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1105                 ;;
1106         esac
1107         ;;
1108 (.no|.NONE/*)
1109         $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1110         ;;
1111 (*)
1112         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1113         ;;
1114 esac
1115 ])dnl
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.
1120 dnl
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
1124 dnl             Bindings Option
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
1128 dnl
1129 dnl Parameters:
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
1133
1134 if test "$cf_cv_posix_visible" = no; then
1135
1136 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1137
1138 cf_save_CFLAGS="$CFLAGS"
1139 cf_save_CPPFLAGS="$CPPFLAGS"
1140
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)
1143
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
1148 make an error
1149 #endif],
1150         [cf_cv_posix_c_source=no],
1151         [cf_want_posix_source=no
1152          case .$cf_POSIX_C_SOURCE in
1153          (.[[12]]??*)
1154                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1155                 ;;
1156          (.2)
1157                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1158                 cf_want_posix_source=yes
1159                 ;;
1160          (.*)
1161                 cf_want_posix_source=yes
1162                 ;;
1163          esac
1164          if test "$cf_want_posix_source" = yes ; then
1165                 AC_TRY_COMPILE([#include <sys/types.h>],[
1166 #ifdef _POSIX_SOURCE
1167 make an error
1168 #endif],[],
1169                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1170          fi
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
1178 make an error
1179 #endif],,
1180          [cf_cv_posix_c_source=no])
1181          CFLAGS="$cf_save_CFLAGS"
1182          CPPFLAGS="$cf_save_CPPFLAGS"
1183         ])
1184 ])
1185
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)
1190 fi
1191
1192 fi # cf_cv_posix_visible
1193
1194 ])dnl
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.
1200 dnl
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
1205 dnl problems.
1206 dnl
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],
1210 [
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
1218 #endif
1219 ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
1220 ])
1221 ])dnl
1222 dnl ---------------------------------------------------------------------------
1223 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
1224 dnl -----------
1225 dnl Check for awk, ensure that the check found something.
1226 AC_DEFUN([CF_PROG_AWK],
1227 [
1228 AC_PROG_AWK
1229 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
1230 ])dnl
1231 dnl ---------------------------------------------------------------------------
1232 dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
1233 dnl ----------
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])],
1240         [])
1241 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1242 CF_GCC_VERSION
1243 CF_ACVERSION_CHECK(2.52,
1244         [AC_PROG_CC_STDC],
1245         [CF_ANSI_CC_REQD])
1246 CF_CC_ENV_FLAGS
1247 ])dnl
1248 dnl ---------------------------------------------------------------------------
1249 dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
1250 dnl -------------
1251 dnl Check if groff is available, for cases (such as html output) where nroff
1252 dnl is not enough.
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
1258 then
1259         NROFF_NOTE=
1260         GROFF_NOTE="#"
1261 else
1262         NROFF_NOTE="#"
1263         GROFF_NOTE=
1264 fi
1265 AC_SUBST(GROFF_NOTE)
1266 AC_SUBST(NROFF_NOTE)
1267 ])dnl
1268 dnl ---------------------------------------------------------------------------
1269 dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
1270 dnl ------------
1271 AC_DEFUN([CF_PROG_LINT],
1272 [
1273 AC_CHECK_PROGS(LINT, lint cppcheck splint)
1274 case "x$LINT" in
1275 (xcppcheck|x*/cppcheck)
1276         test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
1277         ;;
1278 esac
1279 AC_SUBST(LINT_OPTS)
1280 ])dnl
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.
1288 dnl
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],
1293 [
1294 $1=`echo "$2" | \
1295         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
1296                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
1297 ])dnl
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,[
1305         AC_TRY_COMPILE([
1306 #include <stdlib.h>
1307 #include <string.h>
1308 #include <sys/types.h>
1309 ],[
1310 #ifndef _XOPEN_SOURCE
1311 make an error
1312 #endif],
1313         [cf_cv_xopen_source=no],
1314         [cf_save="$CPPFLAGS"
1315          CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
1316          AC_TRY_COMPILE([
1317 #include <stdlib.h>
1318 #include <string.h>
1319 #include <sys/types.h>
1320 ],[
1321 #ifdef _XOPEN_SOURCE
1322 make an error
1323 #endif],
1324         [cf_cv_xopen_source=no],
1325         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1326         CPPFLAGS="$cf_save"
1327         ])
1328 ])
1329
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)
1335 fi
1336 ])
1337 dnl ---------------------------------------------------------------------------
1338 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1339 dnl --------
1340 dnl Make an uppercase version of a variable
1341 dnl $1=uppercase($2)
1342 AC_DEFUN([CF_UPPER],
1343 [
1344 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1345 ])dnl
1346 dnl ---------------------------------------------------------------------------
1347 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1348 dnl ----------
1349 dnl Use AC_VERBOSE w/o the warnings
1350 AC_DEFUN([CF_VERBOSE],
1351 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
1352 CF_MSG_LOG([$1])
1353 ])dnl
1354 dnl ---------------------------------------------------------------------------
1355 dnl CF_WITHOUT_X version: 1 updated: 2020/03/03 18:27:24
1356 dnl ------------
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
1361 [])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],
1370         [USE_DBMALLOC])
1371
1372 if test "$with_dbmalloc" = yes ; then
1373         AC_CHECK_HEADER(dbmalloc.h,
1374                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1375 fi
1376 ])dnl
1377 dnl ---------------------------------------------------------------------------
1378 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1379 dnl ---------------
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],
1385         [USE_DMALLOC])
1386
1387 if test "$with_dmalloc" = yes ; then
1388         AC_CHECK_HEADER(dmalloc.h,
1389                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1390 fi
1391 ])dnl
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
1397 dnl
1398 dnl             http://invisible-island.net/scripts/man2html.html
1399 dnl
1400 dnl Generate a shell script which hides the differences between the two.
1401 dnl
1402 dnl We name that "man2html.tmp".
1403 dnl
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])
1407
1408 case "x${with_man2html}" in
1409 (xno)
1410         cf_man2html=no
1411         ;;
1412 (x|xyes)
1413         AC_PATH_PROG(cf_man2html,man2html,no)
1414         case "x$cf_man2html" in
1415         (x/*)
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 )
1418                 then
1419                         cf_man2html_ok=yes
1420                 else
1421                         cf_man2html=no
1422                         cf_man2html_ok=no
1423                 fi
1424                 AC_MSG_RESULT($cf_man2html_ok)
1425                 ;;
1426         (*)
1427                 cf_man2html=no
1428                 ;;
1429         esac
1430 esac
1431
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])
1437
1438 cf_with_groff=no
1439
1440 case $cf_man2html in
1441 (yes)
1442         AC_MSG_RESULT(man2html)
1443         AC_PATH_PROG(cf_man2html,man2html,no)
1444         ;;
1445 (no|groff|*/groff*)
1446         cf_with_groff=yes
1447         cf_man2html=$GROFF_PATH
1448         AC_MSG_RESULT($cf_man2html)
1449         ;;
1450 (*)
1451         AC_MSG_RESULT($cf_man2html)
1452         ;;
1453 esac
1454
1455 MAN2HTML_TEMP="man2html.tmp"
1456         cat >$MAN2HTML_TEMP <<CF_EOF
1457 #!$SHELL
1458 # Temporary script generated by CF_WITH_MAN2HTML
1459 # Convert inputs to html, sending result to standard output.
1460 #
1461 # Parameters:
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"
1465 #
1466 ROOT=\[$]1
1467 TYPE=\[$]2
1468 MACS=\[$]3
1469
1470 unset LANG
1471 unset LC_ALL
1472 unset LC_CTYPE
1473 unset LANGUAGE
1474 GROFF_NO_SGR=stupid
1475 export GROFF_NO_SGR
1476
1477 CF_EOF
1478
1479 if test "x$cf_with_groff" = xyes
1480 then
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}"
1485 CF_EOF
1486 else
1487         MAN2HTML_NOTE=""
1488         CF_PATH_SYNTAX(cf_man2html)
1489         MAN2HTML_PATH="$cf_man2html"
1490         AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
1491
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
1495 .SH SECTION
1496 MARKER
1497 CF_EOF
1498
1499         LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1500
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"
1506
1507         AC_MSG_RESULT($cf_man2html_top_bot)
1508
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
1511         do
1512         cat >>conftest.in <<CF_EOF
1513 .nf
1514 0
1515 1
1516 2
1517 3
1518 4
1519 5
1520 6
1521 7
1522 8
1523 9
1524 CF_EOF
1525         done
1526
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
1531
1532         rm -rf conftest*
1533         AC_MSG_RESULT($cf_man2html_page)
1534
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"
1538 case \${TYPE} in
1539 (ms)
1540         $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
1541         ;;
1542 (*)
1543         $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
1544         ;;
1545 esac
1546 CF_EOF
1547 fi
1548
1549 chmod 700 $MAN2HTML_TEMP
1550
1551 AC_SUBST(MAN2HTML_NOTE)
1552 AC_SUBST(MAN2HTML_PATH)
1553 AC_SUBST(MAN2HTML_TEMP)
1554 ])dnl
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],
1561         [USE_VALGRIND])
1562 ])dnl
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
1567 dnl
1568 dnl Parameters:
1569 dnl     $1 - see CF_GCC_WARNINGS
1570 AC_DEFUN([CF_WITH_WARNINGS],
1571 [
1572 if ( test "$GCC" = yes || test "$GXX" = yes )
1573 then
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
1581         CF_GCC_ATTRIBUTES
1582         CF_GCC_WARNINGS([$1])
1583 fi
1584 fi
1585 ])dnl
1586 dnl ---------------------------------------------------------------------------
1587 dnl CF_XOPEN_SOURCE version: 55 updated: 2018/12/31 20:46:17
1588 dnl ---------------
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.
1592 dnl
1593 dnl Parameters:
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])
1599
1600 if test "$cf_cv_posix_visible" = no; then
1601
1602 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1603 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1604 cf_xopen_source=
1605
1606 case $host_os in
1607 (aix[[4-7]]*)
1608         cf_xopen_source="-D_ALL_SOURCE"
1609         ;;
1610 (msys)
1611         cf_XOPEN_SOURCE=600
1612         ;;
1613 (darwin[[0-8]].*)
1614         cf_xopen_source="-D_APPLE_C_SOURCE"
1615         ;;
1616 (darwin*)
1617         cf_xopen_source="-D_DARWIN_C_SOURCE"
1618         cf_XOPEN_SOURCE=
1619         ;;
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
1625         cf_XOPEN_SOURCE=600
1626         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1627         ;;
1628 (hpux11*)
1629         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1630         ;;
1631 (hpux*)
1632         cf_xopen_source="-D_HPUX_SOURCE"
1633         ;;
1634 (irix[[56]].*)
1635         cf_xopen_source="-D_SGI_SOURCE"
1636         cf_XOPEN_SOURCE=
1637         ;;
1638 (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
1639         CF_GNU_SOURCE($cf_XOPEN_SOURCE)
1640         ;;
1641 (minix*)
1642         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
1643         ;;
1644 (mirbsd*)
1645         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1646         cf_XOPEN_SOURCE=
1647         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1648         ;;
1649 (netbsd*)
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
1651         ;;
1652 (openbsd[[4-9]]*)
1653         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1654         cf_xopen_source="-D_BSD_SOURCE"
1655         cf_XOPEN_SOURCE=600
1656         ;;
1657 (openbsd*)
1658         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1659         ;;
1660 (osf[[45]]*)
1661         cf_xopen_source="-D_OSF_SOURCE"
1662         ;;
1663 (nto-qnx*)
1664         cf_xopen_source="-D_QNX_SOURCE"
1665         ;;
1666 (sco*)
1667         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1668         ;;
1669 (solaris2.*)
1670         cf_xopen_source="-D__EXTENSIONS__"
1671         cf_cv_xopen_source=broken
1672         ;;
1673 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
1674         cf_XOPEN_SOURCE=
1675         cf_POSIX_C_SOURCE=
1676         ;;
1677 (*)
1678         CF_TRY_XOPEN_SOURCE
1679         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1680         ;;
1681 esac
1682
1683 if test -n "$cf_xopen_source" ; then
1684         CF_ADD_CFLAGS($cf_xopen_source,true)
1685 fi
1686
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
1694 make an error
1695 #endif],
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
1700         then
1701                 AC_TRY_COMPILE([#include <stdlib.h>],[
1702 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1703 make an error
1704 #endif],
1705                 [cf_XOPEN_SOURCE_set_ok=yes],
1706                 [cf_XOPEN_SOURCE_set_ok=no])
1707                 if test $cf_XOPEN_SOURCE_set_ok = no
1708                 then
1709                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
1710                 fi
1711         else
1712                 CF_TRY_XOPEN_SOURCE
1713         fi
1714 fi
1715 fi # cf_cv_posix_visible
1716 ])