Imported Upstream version 20200910
[platform/upstream/byacc.git] / aclocal.m4
1 dnl $Id: aclocal.m4,v 1.49 2020/09/10 14:49:09 tom Exp $
2 dnl Macros for byacc configure script (Thomas E. Dickey)
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 2004-2019,2020 Thomas E. Dickey
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: 14 updated: 2020/04/04 16:16:13
58 dnl -------------
59 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
60 dnl $1 = flags to add
61 dnl $2 = if given makes this macro verbose.
62 dnl
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],
67 [
68 cf_fix_cppflags=no
69 cf_new_cflags=
70 cf_new_cppflags=
71 cf_new_extra_cppflags=
72
73 for cf_add_cflags in $1
74 do
75 case $cf_fix_cppflags in
76 (no)
77         case $cf_add_cflags in
78         (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
79                 case $cf_add_cflags in
80                 (-D*)
81                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
82
83                         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
84                                 && test -z "${cf_tst_cflags}" \
85                                 && cf_fix_cppflags=yes
86
87                         if test $cf_fix_cppflags = yes ; then
88                                 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
89                                 continue
90                         elif test "${cf_tst_cflags}" = "\"'" ; then
91                                 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
92                                 continue
93                         fi
94                         ;;
95                 esac
96                 case "$CPPFLAGS" in
97                 (*$cf_add_cflags)
98                         ;;
99                 (*)
100                         case $cf_add_cflags in
101                         (-D*)
102                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
103                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
104                                 ;;
105                         esac
106                         CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
107                         ;;
108                 esac
109                 ;;
110         (*)
111                 CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
112                 ;;
113         esac
114         ;;
115 (yes)
116         CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
117
118         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
119
120         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
121                 && test -z "${cf_tst_cflags}" \
122                 && cf_fix_cppflags=no
123         ;;
124 esac
125 done
126
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)
130 fi
131
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)
135 fi
136
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)
140 fi
141
142 AC_SUBST(EXTRA_CPPFLAGS)
143
144 ])dnl
145 dnl ---------------------------------------------------------------------------
146 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
147 dnl --------------
148 dnl use this macro for appending text without introducing an extra blank at
149 dnl the beginning
150 define([CF_APPEND_TEXT],
151 [
152         test -n "[$]$1" && $1="[$]$1 "
153         $1="[$]{$1}$2"
154 ])dnl
155 dnl ---------------------------------------------------------------------------
156 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
157 dnl --------------
158 dnl Allow user to disable a normally-on option.
159 AC_DEFUN([CF_ARG_DISABLE],
160 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
161 dnl ---------------------------------------------------------------------------
162 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
163 dnl -------------
164 dnl Allow user to enable a normally-off option.
165 AC_DEFUN([CF_ARG_ENABLE],
166 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
167 dnl ---------------------------------------------------------------------------
168 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
169 dnl -------------
170 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
171 dnl values.
172 dnl
173 dnl Parameters:
174 dnl $1 = option name
175 dnl $2 = help-string
176 dnl $3 = action to perform if option is not default
177 dnl $4 = action if perform if option is default
178 dnl $5 = default option value (either 'yes' or 'no')
179 AC_DEFUN([CF_ARG_OPTION],
180 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
181         if test "$enableval" != "$5" ; then
182 ifelse([$3],,[    :]dnl
183 ,[    $3]) ifelse([$4],,,[
184         else
185                 $4])
186         fi],[enableval=$5 ifelse([$4],,,[
187         $4
188 ])dnl
189 ])])dnl
190 dnl ---------------------------------------------------------------------------
191 dnl CF_CC_ENV_FLAGS version: 9 updated: 2018/07/29 18:03:26
192 dnl ---------------
193 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
194 dnl into CC.  This will not help with broken scripts that wrap the compiler
195 dnl with options, but eliminates a more common category of user confusion.
196 dnl
197 dnl In particular, it addresses the problem of being able to run the C
198 dnl preprocessor in a consistent manner.
199 dnl
200 dnl Caveat: this also disallows blanks in the pathname for the compiler, but
201 dnl the nuisance of having inconsistent settings for compiler and preprocessor
202 dnl outweighs that limitation.
203 AC_DEFUN([CF_CC_ENV_FLAGS],
204 [
205 # This should have been defined by AC_PROG_CC
206 : ${CC:=cc}
207
208 AC_MSG_CHECKING(\$CFLAGS variable)
209 case "x$CFLAGS" in
210 (*-[[IUD]]*)
211         AC_MSG_RESULT(broken)
212         AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
213         cf_flags="$CFLAGS"
214         CFLAGS=
215         for cf_arg in $cf_flags
216         do
217                 CF_ADD_CFLAGS($cf_arg)
218         done
219         ;;
220 (*)
221         AC_MSG_RESULT(ok)
222         ;;
223 esac
224
225 AC_MSG_CHECKING(\$CC variable)
226 case "$CC" in
227 (*[[\ \ ]]-*)
228         AC_MSG_RESULT(broken)
229         AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
230         # humor him...
231         cf_prog=`echo "$CC" | sed -e 's/        / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
232         cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
233         CC="$cf_prog"
234         for cf_arg in $cf_flags
235         do
236                 case "x$cf_arg" in
237                 (x-[[IUDfgOW]]*)
238                         CF_ADD_CFLAGS($cf_arg)
239                         ;;
240                 (*)
241                         CC="$CC $cf_arg"
242                         ;;
243                 esac
244         done
245         CF_VERBOSE(resulting CC: '$CC')
246         CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
247         CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
248         ;;
249 (*)
250         AC_MSG_RESULT(ok)
251         ;;
252 esac
253 ])dnl
254 dnl ---------------------------------------------------------------------------
255 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
256 dnl --------------
257 dnl Check if we're accidentally using a cache from a different machine.
258 dnl Derive the system name, as a check for reusing the autoconf cache.
259 dnl
260 dnl If we've packaged config.guess and config.sub, run that (since it does a
261 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
262 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
263 dnl which is useful in cross-compiles.
264 dnl
265 dnl Note: we would use $ac_config_sub, but that is one of the places where
266 dnl autoconf 2.5x broke compatibility with autoconf 2.13
267 AC_DEFUN([CF_CHECK_CACHE],
268 [
269 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
270         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
271         system_name="$host_os"
272 else
273         system_name="`(uname -s -r) 2>/dev/null`"
274         if test -z "$system_name" ; then
275                 system_name="`(hostname) 2>/dev/null`"
276         fi
277 fi
278 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
279 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
280
281 test -z "$system_name" && system_name="$cf_cv_system_name"
282 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
283
284 if test ".$system_name" != ".$cf_cv_system_name" ; then
285         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
286         AC_MSG_ERROR("Please remove config.cache and try again.")
287 fi
288 ])dnl
289 dnl ---------------------------------------------------------------------------
290 dnl CF_CLANG_COMPILER version: 3 updated: 2020/08/28 04:10:22
291 dnl -----------------
292 dnl Check if the given compiler is really clang.  clang's C driver defines
293 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
294 dnl not ignore some gcc options.
295 dnl
296 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
297 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
298 dnl the wrappers for gcc and g++ warnings.
299 dnl
300 dnl $1 = GCC (default) or GXX
301 dnl $2 = CLANG_COMPILER (default)
302 dnl $3 = CFLAGS (default) or CXXFLAGS
303 AC_DEFUN([CF_CLANG_COMPILER],[
304 ifelse([$2],,CLANG_COMPILER,[$2])=no
305
306 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
307         AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
308         cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
309         ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
310         AC_TRY_COMPILE([],[
311 #ifdef __clang__
312 #else
313 make an error
314 #endif
315 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
316 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
317 ],[])
318         ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
319         AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
320 fi
321
322 if test "x$CLANG_COMPILER" = "xyes" ; then
323         CF_APPEND_TEXT(CFLAGS,-Wno-error=implicit-function-declaration)
324 fi
325 ])
326 dnl ---------------------------------------------------------------------------
327 dnl CF_CONST_X_STRING version: 4 updated: 2020/03/10 18:53:47
328 dnl -----------------
329 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
330 dnl character-strings.
331 dnl
332 dnl It is ambiguous because the specification accommodated the pre-ANSI
333 dnl compilers bundled by more than one vendor in lieu of providing a standard C
334 dnl compiler other than by costly add-ons.  Because of this, the specification
335 dnl did not take into account the use of const for telling the compiler that
336 dnl string literals would be in readonly memory.
337 dnl
338 dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
339 dnl let the compiler decide how to represent Xt's strings which were #define'd. 
340 dnl That does not solve the problem of using the block of Xt's strings which
341 dnl are compiled into the library (and is less efficient than one might want).
342 dnl
343 dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
344 dnl when compiling the library and compiling using the library, to tell the
345 dnl compiler that String is const.
346 AC_DEFUN([CF_CONST_X_STRING],
347 [
348 AC_REQUIRE([AC_PATH_XTRA])
349
350 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
351
352 AC_TRY_COMPILE(
353 [
354 #include <stdlib.h>
355 #include <X11/Intrinsic.h>
356 ],
357 [String foo = malloc(1); (void)foo],[
358
359 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
360         AC_TRY_COMPILE(
361                 [
362 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
363 #undef  XTSTRINGDEFINES /* X11R5 and later */
364 #include <stdlib.h>
365 #include <X11/Intrinsic.h>
366                 ],[String foo = malloc(1); *foo = 0],[
367                         cf_cv_const_x_string=no
368                 ],[
369                         cf_cv_const_x_string=yes
370                 ])
371 ])
372
373 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
374
375 case $cf_cv_const_x_string in
376 (no)
377         CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
378         ;;
379 (*)
380         CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
381         ;;
382 esac
383
384 ])
385 ])dnl
386 dnl ---------------------------------------------------------------------------
387 dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
388 dnl ---------------
389 dnl You can always use "make -n" to see the actual options, but it's hard to
390 dnl pick out/analyze warning messages when the compile-line is long.
391 dnl
392 dnl Sets:
393 dnl     ECHO_LT - symbol to control if libtool is verbose
394 dnl     ECHO_LD - symbol to prefix "cc -o" lines
395 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
396 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
397 dnl     ECHO_CC - symbol to put before any "cc" line
398 dnl
399 AC_DEFUN([CF_DISABLE_ECHO],[
400 AC_MSG_CHECKING(if you want to see long compiling messages)
401 CF_ARG_DISABLE(echo,
402         [  --disable-echo          do not display "compiling" commands],
403         [
404         ECHO_LT='--silent'
405         ECHO_LD='@echo linking [$]@;'
406         RULE_CC='@echo compiling [$]<'
407         SHOW_CC='@echo compiling [$]@'
408         ECHO_CC='@'
409 ],[
410         ECHO_LT=''
411         ECHO_LD=''
412         RULE_CC=''
413         SHOW_CC=''
414         ECHO_CC=''
415 ])
416 AC_MSG_RESULT($enableval)
417 AC_SUBST(ECHO_LT)
418 AC_SUBST(ECHO_LD)
419 AC_SUBST(RULE_CC)
420 AC_SUBST(SHOW_CC)
421 AC_SUBST(ECHO_CC)
422 ])dnl
423 dnl ---------------------------------------------------------------------------
424 dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
425 dnl ----------------
426 dnl Combine no-leak checks with the libraries or tools that are used for the
427 dnl checks.
428 AC_DEFUN([CF_DISABLE_LEAKS],[
429
430 AC_REQUIRE([CF_WITH_DMALLOC])
431 AC_REQUIRE([CF_WITH_DBMALLOC])
432 AC_REQUIRE([CF_WITH_VALGRIND])
433
434 AC_MSG_CHECKING(if you want to perform memory-leak testing)
435 AC_ARG_ENABLE(leaks,
436         [  --disable-leaks         test: free permanent memory, analyze leaks],
437         [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
438         : ${with_no_leaks:=no})
439 AC_MSG_RESULT($with_no_leaks)
440
441 if test "$with_no_leaks" = yes ; then
442         AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
443         AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
444 fi
445 ])dnl
446 dnl ---------------------------------------------------------------------------
447 dnl CF_ENABLE_WARNINGS version: 7 updated: 2020/08/29 09:05:21
448 dnl ------------------
449 dnl Configure-option to enable gcc warnings
450 dnl
451 dnl $1 = extra options to add, if supported
452 dnl $2 = option for checking attributes.  By default, this is done when
453 dnl      warnings are enabled.  For other values:
454 dnl      yes: always do this, e.g., to use in generated library-headers
455 dnl      no: never do this
456 AC_DEFUN([CF_ENABLE_WARNINGS],[
457 if ( test "$GCC" = yes || test "$GXX" = yes )
458 then
459 CF_FIX_WARNINGS(CFLAGS)
460 CF_FIX_WARNINGS(CPPFLAGS)
461 CF_FIX_WARNINGS(LDFLAGS)
462 AC_MSG_CHECKING(if you want to turn on gcc warnings)
463 CF_ARG_ENABLE(warnings,
464         [  --enable-warnings       test: turn on gcc compiler warnings],
465         [with_warnings=yes],
466         [with_warnings=no])
467 AC_MSG_RESULT($with_warnings)
468 if test "$with_warnings" = "yes"
469 then
470         ifelse($2,,[CF_GCC_ATTRIBUTES])
471         CF_GCC_WARNINGS($1)
472 fi
473 ifelse($2,yes,[CF_GCC_ATTRIBUTES])
474 fi
475 ])dnl
476 dnl ---------------------------------------------------------------------------
477 dnl CF_FIX_WARNINGS version: 2 updated: 2020/08/28 15:08:28
478 dnl ---------------
479 dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
480 dnl "-Werror" flags can interfere with configure-checks.  Those go into
481 dnl EXTRA_CFLAGS.
482 dnl
483 dnl $1 = variable name to repair
484 define([CF_FIX_WARNINGS],[
485 if ( test "$GCC" = yes || test "$GXX" = yes )
486 then
487         case [$]$1 in
488         (*-Werror=*)
489                 CF_VERBOSE(repairing $1: [$]$1)
490                 cf_temp_flags=
491                 for cf_temp_scan in [$]$1
492                 do
493                         case "x$cf_temp_scan" in
494                         (x-Werror=*)
495                                 CF_APPEND_TEXT(EXTRA_CFLAGS,"$cf_temp_scan")
496                                 ;;
497                         (*)
498                                 CF_APPEND_TEXT(cf_temp_flags,"$cf_temp_scan")
499                                 ;;
500                         esac
501                 done
502                 $1="$cf_temp_flags"
503                 CF_VERBOSE(... fixed [$]$1)
504                 CF_VERBOSE(... extra $EXTRA_CFLAGS)
505                 ;;
506         esac
507 fi
508 AC_SUBST(EXTRA_CFLAGS)
509 ])dnl
510 dnl ---------------------------------------------------------------------------
511 dnl CF_GCC_ATTRIBUTES version: 19 updated: 2020/08/29 09:05:21
512 dnl -----------------
513 dnl Test for availability of useful gcc __attribute__ directives to quiet
514 dnl compiler warnings.  Though useful, not all are supported -- and contrary
515 dnl to documentation, unrecognized directives cause older compilers to barf.
516 AC_DEFUN([CF_GCC_ATTRIBUTES],
517 [
518 if ( test "$GCC" = yes || test "$GXX" = yes )
519 then
520 cat > conftest.i <<EOF
521 #ifndef GCC_PRINTF
522 #define GCC_PRINTF 0
523 #endif
524 #ifndef GCC_SCANF
525 #define GCC_SCANF 0
526 #endif
527 #ifndef GCC_NORETURN
528 #define GCC_NORETURN /* nothing */
529 #endif
530 #ifndef GCC_UNUSED
531 #define GCC_UNUSED /* nothing */
532 #endif
533 EOF
534 if test "$GCC" = yes
535 then
536         AC_CHECKING([for $CC __attribute__ directives])
537 cat > conftest.$ac_ext <<EOF
538 #line __oline__ "${as_me:-configure}"
539 #include "confdefs.h"
540 #include "conftest.h"
541 #include "conftest.i"
542 #if     GCC_PRINTF
543 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
544 #else
545 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
546 #endif
547 #if     GCC_SCANF
548 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
549 #else
550 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
551 #endif
552 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
553 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
554 extern void foo(void) GCC_NORETURN;
555 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
556 EOF
557         cf_printf_attribute=no
558         cf_scanf_attribute=no
559         for cf_attribute in scanf printf unused noreturn
560         do
561                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
562                 cf_directive="__attribute__(($cf_attribute))"
563                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
564
565                 case $cf_attribute in
566                 (printf)
567                         cf_printf_attribute=yes
568                         cat >conftest.h <<EOF
569 #define GCC_$cf_ATTRIBUTE 1
570 EOF
571                         ;;
572                 (scanf)
573                         cf_scanf_attribute=yes
574                         cat >conftest.h <<EOF
575 #define GCC_$cf_ATTRIBUTE 1
576 EOF
577                         ;;
578                 (*)
579                         cat >conftest.h <<EOF
580 #define GCC_$cf_ATTRIBUTE $cf_directive
581 EOF
582                         ;;
583                 esac
584
585                 if AC_TRY_EVAL(ac_compile); then
586                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
587                         cat conftest.h >>confdefs.h
588                         case $cf_attribute in
589                         (noreturn)
590                                 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
591                                 ;;
592                         (printf)
593                                 cf_value='/* nothing */'
594                                 if test "$cf_printf_attribute" != no ; then
595                                         cf_value='__attribute__((format(printf,fmt,var)))'
596                                         AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
597                                 fi
598                                 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
599                                 ;;
600                         (scanf)
601                                 cf_value='/* nothing */'
602                                 if test "$cf_scanf_attribute" != no ; then
603                                         cf_value='__attribute__((format(scanf,fmt,var)))'
604                                         AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
605                                 fi
606                                 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
607                                 ;;
608                         (unused)
609                                 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
610                                 ;;
611                         esac
612                 fi
613         done
614 else
615         fgrep define conftest.i >>confdefs.h
616 fi
617 rm -rf conftest*
618 fi
619 ])dnl
620 dnl ---------------------------------------------------------------------------
621 dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
622 dnl --------------
623 dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
624 dnl compatible), attempt to determine if icc/clang is actually used.
625 AC_DEFUN([CF_GCC_VERSION],[
626 AC_REQUIRE([AC_PROG_CC])
627 GCC_VERSION=none
628 if test "$GCC" = yes ; then
629         AC_MSG_CHECKING(version of $CC)
630         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
631         test -z "$GCC_VERSION" && GCC_VERSION=unknown
632         AC_MSG_RESULT($GCC_VERSION)
633 fi
634 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
635 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
636 ])dnl
637 dnl ---------------------------------------------------------------------------
638 dnl CF_GCC_WARNINGS version: 38 updated: 2020/08/28 15:08:28
639 dnl ---------------
640 dnl Check if the compiler supports useful warning options.  There's a few that
641 dnl we don't use, simply because they're too noisy:
642 dnl
643 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
644 dnl     -Winline (usually not worthwhile)
645 dnl     -Wredundant-decls (system headers make this too noisy)
646 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
647 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
648 dnl             is enabled for ncurses using "--enable-const".
649 dnl     -pedantic
650 dnl
651 dnl Parameter:
652 dnl     $1 is an optional list of gcc warning flags that a particular
653 dnl             application might want to use, e.g., "no-unused" for
654 dnl             -Wno-unused
655 dnl Special:
656 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
657 dnl
658 AC_DEFUN([CF_GCC_WARNINGS],
659 [
660 AC_REQUIRE([CF_GCC_VERSION])
661 if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
662 cat > conftest.$ac_ext <<EOF
663 #line __oline__ "${as_me:-configure}"
664 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
665 EOF
666 if test "$INTEL_COMPILER" = yes
667 then
668 # The "-wdXXX" options suppress warnings:
669 # remark #1419: external declaration in primary source file
670 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
671 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
672 # remark #193: zero used for undefined preprocessing identifier
673 # remark #593: variable "curs_sb_left_arrow" was set but never used
674 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
675 # remark #869: parameter "tw" was never referenced
676 # remark #981: operands are evaluated in unspecified order
677 # warning #279: controlling expression is constant
678
679         AC_CHECKING([for $CC warning options])
680         cf_save_CFLAGS="$CFLAGS"
681         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
682         for cf_opt in \
683                 wd1419 \
684                 wd1683 \
685                 wd1684 \
686                 wd193 \
687                 wd593 \
688                 wd279 \
689                 wd810 \
690                 wd869 \
691                 wd981
692         do
693                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
694                 if AC_TRY_EVAL(ac_compile); then
695                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
696                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
697                 fi
698         done
699         CFLAGS="$cf_save_CFLAGS"
700 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
701 then
702         AC_CHECKING([for $CC warning options])
703         cf_save_CFLAGS="$CFLAGS"
704         cf_warn_CONST=""
705         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
706         cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
707         test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
708         for cf_opt in W Wall \
709                 Wbad-function-cast \
710                 Wcast-align \
711                 Wcast-qual \
712                 Wdeclaration-after-statement \
713                 Wextra \
714                 Winline \
715                 Wmissing-declarations \
716                 Wmissing-prototypes \
717                 Wnested-externs \
718                 Wpointer-arith \
719                 Wshadow \
720                 Wstrict-prototypes \
721                 Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
722         do
723                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
724                 if AC_TRY_EVAL(ac_compile); then
725                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
726                         case $cf_opt in
727                         (Winline)
728                                 case $GCC_VERSION in
729                                 ([[34]].*)
730                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
731                                         continue;;
732                                 esac
733                                 ;;
734                         (Wpointer-arith)
735                                 case $GCC_VERSION in
736                                 ([[12]].*)
737                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
738                                         continue;;
739                                 esac
740                                 ;;
741                         esac
742                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
743                 fi
744         done
745         CFLAGS="$cf_save_CFLAGS"
746 fi
747 rm -rf conftest*
748
749 AC_SUBST(EXTRA_CFLAGS)
750 ])dnl
751 dnl ---------------------------------------------------------------------------
752 dnl CF_GETOPT_HEADER version: 6 updated: 2014/07/22 14:45:54
753 dnl ----------------
754 dnl Check for getopt's variables which are commonly defined in stdlib.h,
755 dnl unistd.h or (nonstandard) in getopt.h
756 AC_DEFUN([CF_GETOPT_HEADER],
757 [
758 AC_HAVE_HEADERS(unistd.h getopt.h)
759 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
760 cf_cv_getopt_header=none
761 for cf_header in stdio.h stdlib.h unistd.h getopt.h
762 do
763 AC_TRY_COMPILE([
764 #include <$cf_header>],
765 [int x = optind; char *y = optarg],
766 [cf_cv_getopt_header=$cf_header
767  break])
768 done
769 ])
770 if test $cf_cv_getopt_header != none ; then
771         AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
772 fi
773 if test $cf_cv_getopt_header = getopt.h ; then
774         AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
775 fi
776 ])dnl
777 dnl ---------------------------------------------------------------------------
778 dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
779 dnl -------------
780 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
781 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
782 dnl (or misfeature) of glibc2, which breaks portability of many applications,
783 dnl since it is interwoven with GNU extensions.
784 dnl
785 dnl Well, yes we could work around it...
786 dnl
787 dnl Parameters:
788 dnl     $1 is the nominal value for _XOPEN_SOURCE
789 AC_DEFUN([CF_GNU_SOURCE],
790 [
791 cf_gnu_xopen_source=ifelse($1,,500,$1)
792
793 AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
794 AC_TRY_COMPILE([#include <sys/types.h>],[
795         #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
796                 return 0;
797         #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
798                 return 0;
799         #else
800         #       error not GNU C library
801         #endif],
802         [cf_cv_gnu_library=yes],
803         [cf_cv_gnu_library=no])
804 ])
805
806 if test x$cf_cv_gnu_library = xyes; then
807
808         # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
809         # was changed to help a little.  newlib incorporated the change about 4
810         # years later.
811         AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
812                 cf_save="$CPPFLAGS"
813                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
814                 AC_TRY_COMPILE([#include <sys/types.h>],[
815                         #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
816                                 return 0;
817                         #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
818                                 return 0;
819                         #else
820                         #       error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
821                         #endif],
822                         [cf_cv_gnu_library_219=yes],
823                         [cf_cv_gnu_library_219=no])
824                 CPPFLAGS="$cf_save"
825         ])
826
827         if test "x$cf_cv_gnu_library_219" = xyes; then
828                 cf_save="$CPPFLAGS"
829                 AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
830                         CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
831                         AC_TRY_COMPILE([
832                                 #include <limits.h>
833                                 #include <sys/types.h>
834                                 ],[
835                                 #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
836                                         return 0;
837                                 #else
838                                 #       error GNU C library is too old
839                                 #endif],
840                                 [cf_cv_gnu_dftsrc_219=yes],
841                                 [cf_cv_gnu_dftsrc_219=no])
842                         ])
843                 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
844         else
845                 cf_cv_gnu_dftsrc_219=maybe
846         fi
847
848         if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
849
850                 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
851                 AC_TRY_COMPILE([#include <sys/types.h>],[
852                         #ifndef _XOPEN_SOURCE
853                         #error  expected _XOPEN_SOURCE to be defined
854                         #endif],
855                         [cf_cv_gnu_source=no],
856                         [cf_save="$CPPFLAGS"
857                          CF_ADD_CFLAGS(-D_GNU_SOURCE)
858                          AC_TRY_COMPILE([#include <sys/types.h>],[
859                                 #ifdef _XOPEN_SOURCE
860                                 #error  expected _XOPEN_SOURCE to be undefined
861                                 #endif],
862                                 [cf_cv_gnu_source=no],
863                                 [cf_cv_gnu_source=yes])
864                         CPPFLAGS="$cf_save"
865                         ])
866                 ])
867
868                 if test "$cf_cv_gnu_source" = yes
869                 then
870                 AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
871                         CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
872                         AC_TRY_COMPILE([#include <sys/types.h>],[
873                                 #ifdef _DEFAULT_SOURCE
874                                 #error  expected _DEFAULT_SOURCE to be undefined
875                                 #endif],
876                                 [cf_cv_default_source=no],
877                                 [cf_cv_default_source=yes])
878                         ])
879                         if test "$cf_cv_default_source" = yes
880                         then
881                                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
882                         fi
883                 fi
884         fi
885
886 fi
887 ])dnl
888 dnl ---------------------------------------------------------------------------
889 dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
890 dnl -----------------
891 dnl Check if the given compiler is really the Intel compiler for Linux.  It
892 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
893 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
894 dnl
895 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
896 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
897 dnl the wrappers for gcc and g++ warnings.
898 dnl
899 dnl $1 = GCC (default) or GXX
900 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
901 dnl $3 = CFLAGS (default) or CXXFLAGS
902 AC_DEFUN([CF_INTEL_COMPILER],[
903 AC_REQUIRE([AC_CANONICAL_HOST])
904 ifelse([$2],,INTEL_COMPILER,[$2])=no
905
906 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
907         case $host_os in
908         (linux*|gnu*)
909                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
910                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
911                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
912                 AC_TRY_COMPILE([],[
913 #ifdef __INTEL_COMPILER
914 #else
915 make an error
916 #endif
917 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
918 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
919 ],[])
920                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
921                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
922                 ;;
923         esac
924 fi
925 ])dnl
926 dnl ---------------------------------------------------------------------------
927 dnl CF_MAKE_DOCS version: 4 updated: 2015/07/04 21:43:03
928 dnl ------------
929 dnl $1 = name(s) to generate rules for
930 dnl $2 = suffix of corresponding manpages used as input.
931 dnl
932 dnl This works best if called at the end of configure.in, following CF_WITH_MAN2HTML
933 define([CF_MAKE_DOCS],[
934 test -z "$cf_make_docs" && cf_make_docs=0
935
936 cf_output=makefile
937 test -f "$cf_output" || cf_output=Makefile
938
939 if test "$cf_make_docs" = 0
940 then
941 cat >>$cf_output <<CF_EOF
942 ################################################################################
943 ## generated by $0
944 .SUFFIXES : .html .$2 .man .ps .pdf .txt
945
946 ${NROFF_NOTE}.$2.txt :
947 ${NROFF_NOTE}   [\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
948
949 ${GROFF_NOTE}.ps.pdf :
950 ${GROFF_NOTE}   ps2pdf [\$]*.ps
951 ${GROFF_NOTE}
952 ${GROFF_NOTE}.$2.ps :
953 ${GROFF_NOTE}   [\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
954 ${GROFF_NOTE}
955 ${GROFF_NOTE}.$2.txt :
956 ${GROFF_NOTE}   GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -Tascii -man | col -bx" >[\$]@
957
958 ${MAN2HTML_NOTE}.$2.html :
959 ${MAN2HTML_NOTE}        ./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
960
961 CF_EOF
962         cf_make_docs=1
963 fi
964
965 for cf_name in $1
966 do
967 cat >>$cf_output <<CF_EOF
968 ################################################################################
969 ${NROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
970 ${MAN2HTML_NOTE}docs docs-$cf_name :: $cf_name.html
971 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.pdf
972 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.ps
973 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
974
975 clean \\
976 docs-clean ::
977 ${NROFF_NOTE}   rm -f $cf_name.txt
978 ${MAN2HTML_NOTE}        rm -f $cf_name.html
979 ${GROFF_NOTE}   rm -f $cf_name.pdf
980 ${GROFF_NOTE}   rm -f $cf_name.ps
981 ${GROFF_NOTE}   rm -f $cf_name.txt
982
983 ${NROFF_NOTE}$cf_name.txt  : $cf_name.$2
984 ${MAN2HTML_NOTE}$cf_name.html : $cf_name.$2
985 ${GROFF_NOTE}$cf_name.pdf  : $cf_name.ps
986 ${GROFF_NOTE}$cf_name.ps   : $cf_name.$2
987 ${GROFF_NOTE}$cf_name.txt  : $cf_name.$2
988 CF_EOF
989 done
990 ])dnl
991 dnl ---------------------------------------------------------------------------
992 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
993 dnl ------------
994 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
995 dnl a monocase filesystem.
996 AC_DEFUN([CF_MAKE_TAGS],[
997 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
998
999 AC_CHECK_PROGS(CTAGS, exctags ctags)
1000 AC_CHECK_PROGS(ETAGS, exetags etags)
1001
1002 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1003
1004 if test "$cf_cv_mixedcase" = yes ; then
1005         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1006 else
1007         MAKE_UPPER_TAGS=no
1008 fi
1009
1010 if test "$MAKE_UPPER_TAGS" = yes ; then
1011         MAKE_UPPER_TAGS=
1012 else
1013         MAKE_UPPER_TAGS="#"
1014 fi
1015
1016 if test "$MAKE_LOWER_TAGS" = yes ; then
1017         MAKE_LOWER_TAGS=
1018 else
1019         MAKE_LOWER_TAGS="#"
1020 fi
1021
1022 AC_SUBST(CTAGS)
1023 AC_SUBST(ETAGS)
1024
1025 AC_SUBST(MAKE_UPPER_TAGS)
1026 AC_SUBST(MAKE_LOWER_TAGS)
1027 ])dnl
1028 dnl ---------------------------------------------------------------------------
1029 dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
1030 dnl ----------------------
1031 dnl Check if the file-system supports mixed-case filenames.  If we're able to
1032 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1033 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1034 [
1035 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1036 if test "$cross_compiling" = yes ; then
1037         case $target_alias in
1038         (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
1039                 cf_cv_mixedcase=no
1040                 ;;
1041         (*)
1042                 cf_cv_mixedcase=yes
1043                 ;;
1044         esac
1045 else
1046         rm -f conftest CONFTEST
1047         echo test >conftest
1048         if test -f CONFTEST ; then
1049                 cf_cv_mixedcase=no
1050         else
1051                 cf_cv_mixedcase=yes
1052         fi
1053         rm -f conftest CONFTEST
1054 fi
1055 ])
1056 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1057 ])dnl
1058 dnl ---------------------------------------------------------------------------
1059 dnl CF_MKSTEMP version: 10 updated: 2017/01/21 11:12:16
1060 dnl ----------
1061 dnl Check for a working mkstemp.  This creates two files, checks that they are
1062 dnl successfully created and distinct (AmigaOS apparently fails on the last).
1063 AC_DEFUN([CF_MKSTEMP],[
1064 AC_CHECK_HEADERS( \
1065 unistd.h \
1066 )
1067 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
1068 rm -rf conftest*
1069 AC_TRY_RUN([
1070 #include <sys/types.h>
1071 #ifdef HAVE_UNISTD_H
1072 #include <unistd.h>
1073 #endif
1074 #include <stdlib.h>
1075 #include <stdio.h>
1076 #include <string.h>
1077 #include <sys/stat.h>
1078 int main(void)
1079 {
1080         char *tmpl = "conftestXXXXXX";
1081         char name[2][80];
1082         int n;
1083         int result = 0;
1084         int fd;
1085         struct stat sb;
1086
1087         umask(077);
1088         for (n = 0; n < 2; ++n) {
1089                 strcpy(name[n], tmpl);
1090                 if ((fd = mkstemp(name[n])) >= 0) {
1091                         if (!strcmp(name[n], tmpl)
1092                          || stat(name[n], &sb) != 0
1093                          || (sb.st_mode & S_IFMT) != S_IFREG
1094                          || (sb.st_mode & 077) != 0) {
1095                                 result = 1;
1096                         }
1097                         close(fd);
1098                 }
1099         }
1100         if (result == 0
1101          && !strcmp(name[0], name[1]))
1102                 result = 1;
1103         ${cf_cv_main_return:-return}(result);
1104 }
1105 ],[cf_cv_func_mkstemp=yes
1106 ],[cf_cv_func_mkstemp=no
1107 ],[cf_cv_func_mkstemp=maybe])
1108 ])
1109 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
1110         AC_CHECK_FUNC(mkstemp)
1111 fi
1112 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
1113         AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
1114 fi
1115 ])dnl
1116 dnl ---------------------------------------------------------------------------
1117 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1118 dnl ----------
1119 dnl Write a debug message to config.log, along with the line number in the
1120 dnl configure script.
1121 AC_DEFUN([CF_MSG_LOG],[
1122 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1123 ])dnl
1124 dnl ---------------------------------------------------------------------------
1125 dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
1126 dnl ------------------
1127 dnl see CF_WITH_NO_LEAKS
1128 AC_DEFUN([CF_NO_LEAKS_OPTION],[
1129 AC_MSG_CHECKING(if you want to use $1 for testing)
1130 AC_ARG_WITH($1,
1131         [$2],
1132         [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1133          $4
1134 ])
1135         : ${with_cflags:=-g}
1136         : ${with_no_leaks:=yes}
1137          with_$1=yes],
1138         [with_$1=])
1139 AC_MSG_RESULT(${with_$1:-no})
1140
1141 case .$with_cflags in
1142 (.*-g*)
1143         case .$CFLAGS in
1144         (.*-g*)
1145                 ;;
1146         (*)
1147                 CF_ADD_CFLAGS([-g])
1148                 ;;
1149         esac
1150         ;;
1151 esac
1152 ])dnl
1153 dnl ---------------------------------------------------------------------------
1154 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
1155 dnl --------------
1156 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1157 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1158 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1159 dnl delayed evaluation of those symbols.
1160 AC_DEFUN([CF_PATH_SYNTAX],[
1161 if test "x$prefix" != xNONE; then
1162         cf_path_syntax="$prefix"
1163 else
1164         cf_path_syntax="$ac_default_prefix"
1165 fi
1166
1167 case ".[$]$1" in
1168 (.\[$]\(*\)*|.\'*\'*)
1169         ;;
1170 (..|./*|.\\*)
1171         ;;
1172 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1173         ;;
1174 (.\[$]{*prefix}*|.\[$]{*dir}*)
1175         eval $1="[$]$1"
1176         case ".[$]$1" in
1177         (.NONE/*)
1178                 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1179                 ;;
1180         esac
1181         ;;
1182 (.no|.NONE/*)
1183         $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1184         ;;
1185 (*)
1186         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1187         ;;
1188 esac
1189 ])dnl
1190 dnl ---------------------------------------------------------------------------
1191 dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
1192 dnl -----------------
1193 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1194 dnl
1195 dnl     POSIX.1-1990                            _POSIX_SOURCE
1196 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
1197 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
1198 dnl             Bindings Option
1199 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
1200 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
1201 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
1202 dnl
1203 dnl Parameters:
1204 dnl     $1 is the nominal value for _POSIX_C_SOURCE
1205 AC_DEFUN([CF_POSIX_C_SOURCE],
1206 [AC_REQUIRE([CF_POSIX_VISIBLE])dnl
1207
1208 if test "$cf_cv_posix_visible" = no; then
1209
1210 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1211
1212 cf_save_CFLAGS="$CFLAGS"
1213 cf_save_CPPFLAGS="$CPPFLAGS"
1214
1215 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1216 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1217
1218 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1219         CF_MSG_LOG(if the symbol is already defined go no further)
1220         AC_TRY_COMPILE([#include <sys/types.h>],[
1221 #ifndef _POSIX_C_SOURCE
1222 make an error
1223 #endif],
1224         [cf_cv_posix_c_source=no],
1225         [cf_want_posix_source=no
1226          case .$cf_POSIX_C_SOURCE in
1227          (.[[12]]??*)
1228                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1229                 ;;
1230          (.2)
1231                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1232                 cf_want_posix_source=yes
1233                 ;;
1234          (.*)
1235                 cf_want_posix_source=yes
1236                 ;;
1237          esac
1238          if test "$cf_want_posix_source" = yes ; then
1239                 AC_TRY_COMPILE([#include <sys/types.h>],[
1240 #ifdef _POSIX_SOURCE
1241 make an error
1242 #endif],[],
1243                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1244          fi
1245          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1246          CFLAGS="$cf_trim_CFLAGS"
1247          CPPFLAGS="$cf_trim_CPPFLAGS"
1248          CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
1249          CF_MSG_LOG(if the second compile does not leave our definition intact error)
1250          AC_TRY_COMPILE([#include <sys/types.h>],[
1251 #ifndef _POSIX_C_SOURCE
1252 make an error
1253 #endif],,
1254          [cf_cv_posix_c_source=no])
1255          CFLAGS="$cf_save_CFLAGS"
1256          CPPFLAGS="$cf_save_CPPFLAGS"
1257         ])
1258 ])
1259
1260 if test "$cf_cv_posix_c_source" != no ; then
1261         CFLAGS="$cf_trim_CFLAGS"
1262         CPPFLAGS="$cf_trim_CPPFLAGS"
1263         CF_ADD_CFLAGS($cf_cv_posix_c_source)
1264 fi
1265
1266 fi # cf_cv_posix_visible
1267
1268 ])dnl
1269 dnl ---------------------------------------------------------------------------
1270 dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
1271 dnl ----------------
1272 dnl POSIX documents test-macros which an application may set before any system
1273 dnl headers are included to make features available.
1274 dnl
1275 dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
1276 dnl diverged from POSIX in 2002 by setting symbols which make all of the most
1277 dnl recent features visible in the system header files unless the application
1278 dnl overrides the corresponding test-macros.  Doing that introduces portability
1279 dnl problems.
1280 dnl
1281 dnl This macro makes a special check for the symbols used for this, to avoid a
1282 dnl conflicting definition.
1283 AC_DEFUN([CF_POSIX_VISIBLE],
1284 [
1285 AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
1286 AC_TRY_COMPILE([#include <stdio.h>],[
1287 #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
1288         && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
1289         && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
1290         && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
1291 #error conflicting symbols found
1292 #endif
1293 ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
1294 ])
1295 ])dnl
1296 dnl ---------------------------------------------------------------------------
1297 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
1298 dnl -----------
1299 dnl Check for awk, ensure that the check found something.
1300 AC_DEFUN([CF_PROG_AWK],
1301 [
1302 AC_PROG_AWK
1303 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
1304 ])dnl
1305 dnl ---------------------------------------------------------------------------
1306 dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
1307 dnl ----------
1308 dnl standard check for CC, plus followup sanity checks
1309 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1310 AC_DEFUN([CF_PROG_CC],[
1311 CF_ACVERSION_CHECK(2.53,
1312         [AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
1313          AC_REQUIRE([AC_PROG_CC])],
1314         [])
1315 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1316 CF_GCC_VERSION
1317 CF_ACVERSION_CHECK(2.52,
1318         [AC_PROG_CC_STDC],
1319         [CF_ANSI_CC_REQD])
1320 CF_CC_ENV_FLAGS
1321 ])dnl
1322 dnl ---------------------------------------------------------------------------
1323 dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
1324 dnl -------------
1325 dnl Check if groff is available, for cases (such as html output) where nroff
1326 dnl is not enough.
1327 AC_DEFUN([CF_PROG_GROFF],[
1328 AC_PATH_PROG(GROFF_PATH,groff,no)
1329 AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
1330 AC_PATH_PROG(TBL_PATH,tbl,cat)
1331 if test "x$GROFF_PATH" = xno
1332 then
1333         NROFF_NOTE=
1334         GROFF_NOTE="#"
1335 else
1336         NROFF_NOTE="#"
1337         GROFF_NOTE=
1338 fi
1339 AC_SUBST(GROFF_NOTE)
1340 AC_SUBST(NROFF_NOTE)
1341 ])dnl
1342 dnl ---------------------------------------------------------------------------
1343 dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
1344 dnl ------------
1345 AC_DEFUN([CF_PROG_LINT],
1346 [
1347 AC_CHECK_PROGS(LINT, lint cppcheck splint)
1348 case "x$LINT" in
1349 (xcppcheck|x*/cppcheck)
1350         test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
1351         ;;
1352 esac
1353 AC_SUBST(LINT_OPTS)
1354 ])dnl
1355 dnl ---------------------------------------------------------------------------
1356 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1357 dnl ----------------
1358 dnl Remove all -U and -D options that refer to the given symbol from a list
1359 dnl of C compiler options.  This works around the problem that not all
1360 dnl compilers process -U and -D options from left-to-right, so a -U option
1361 dnl cannot be used to cancel the effect of a preceding -D option.
1362 dnl
1363 dnl $1 = target (which could be the same as the source variable)
1364 dnl $2 = source (including '$')
1365 dnl $3 = symbol to remove
1366 define([CF_REMOVE_DEFINE],
1367 [
1368 $1=`echo "$2" | \
1369         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
1370                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
1371 ])dnl
1372 dnl ---------------------------------------------------------------------------
1373 dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
1374 dnl -------------------
1375 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1376 dnl can define it successfully.
1377 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1378 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1379         AC_TRY_COMPILE([
1380 #include <stdlib.h>
1381 #include <string.h>
1382 #include <sys/types.h>
1383 ],[
1384 #ifndef _XOPEN_SOURCE
1385 make an error
1386 #endif],
1387         [cf_cv_xopen_source=no],
1388         [cf_save="$CPPFLAGS"
1389          CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
1390          AC_TRY_COMPILE([
1391 #include <stdlib.h>
1392 #include <string.h>
1393 #include <sys/types.h>
1394 ],[
1395 #ifdef _XOPEN_SOURCE
1396 make an error
1397 #endif],
1398         [cf_cv_xopen_source=no],
1399         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1400         CPPFLAGS="$cf_save"
1401         ])
1402 ])
1403
1404 if test "$cf_cv_xopen_source" != no ; then
1405         CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1406         CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1407         cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1408         CF_ADD_CFLAGS($cf_temp_xopen_source)
1409 fi
1410 ])
1411 dnl ---------------------------------------------------------------------------
1412 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1413 dnl --------
1414 dnl Make an uppercase version of a variable
1415 dnl $1=uppercase($2)
1416 AC_DEFUN([CF_UPPER],
1417 [
1418 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1419 ])dnl
1420 dnl ---------------------------------------------------------------------------
1421 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1422 dnl ----------
1423 dnl Use AC_VERBOSE w/o the warnings
1424 AC_DEFUN([CF_VERBOSE],
1425 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
1426 CF_MSG_LOG([$1])
1427 ])dnl
1428 dnl ---------------------------------------------------------------------------
1429 dnl CF_WITHOUT_X version: 1 updated: 2020/03/03 18:27:24
1430 dnl ------------
1431 dnl Use this to cancel the check for X headers/libraries which would be pulled
1432 dnl in via CF_GCC_WARNINGS.
1433 define([CF_WITHOUT_X],
1434 AC_DEFUN([CF_CONST_X_STRING],[echo "skipping X-const check";])dnl
1435 [])dnl
1436 dnl ---------------------------------------------------------------------------
1437 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1438 dnl ----------------
1439 dnl Configure-option for dbmalloc.  The optional parameter is used to override
1440 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1441 AC_DEFUN([CF_WITH_DBMALLOC],[
1442 CF_NO_LEAKS_OPTION(dbmalloc,
1443         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
1444         [USE_DBMALLOC])
1445
1446 if test "$with_dbmalloc" = yes ; then
1447         AC_CHECK_HEADER(dbmalloc.h,
1448                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1449 fi
1450 ])dnl
1451 dnl ---------------------------------------------------------------------------
1452 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1453 dnl ---------------
1454 dnl Configure-option for dmalloc.  The optional parameter is used to override
1455 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1456 AC_DEFUN([CF_WITH_DMALLOC],[
1457 CF_NO_LEAKS_OPTION(dmalloc,
1458         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
1459         [USE_DMALLOC])
1460
1461 if test "$with_dmalloc" = yes ; then
1462         AC_CHECK_HEADER(dmalloc.h,
1463                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1464 fi
1465 ])dnl
1466 dnl ---------------------------------------------------------------------------
1467 dnl CF_WITH_MAN2HTML version: 8 updated: 2018/06/27 18:44:03
1468 dnl ----------------
1469 dnl Check for man2html and groff.  Prefer man2html over groff, but use groff
1470 dnl as a fallback.  See
1471 dnl
1472 dnl             http://invisible-island.net/scripts/man2html.html
1473 dnl
1474 dnl Generate a shell script which hides the differences between the two.
1475 dnl
1476 dnl We name that "man2html.tmp".
1477 dnl
1478 dnl The shell script can be removed later, e.g., using "make distclean".
1479 AC_DEFUN([CF_WITH_MAN2HTML],[
1480 AC_REQUIRE([CF_PROG_GROFF])
1481
1482 case "x${with_man2html}" in
1483 (xno)
1484         cf_man2html=no
1485         ;;
1486 (x|xyes)
1487         AC_PATH_PROG(cf_man2html,man2html,no)
1488         case "x$cf_man2html" in
1489         (x/*)
1490                 AC_MSG_CHECKING(for the modified Earl Hood script)
1491                 if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
1492                 then
1493                         cf_man2html_ok=yes
1494                 else
1495                         cf_man2html=no
1496                         cf_man2html_ok=no
1497                 fi
1498                 AC_MSG_RESULT($cf_man2html_ok)
1499                 ;;
1500         (*)
1501                 cf_man2html=no
1502                 ;;
1503         esac
1504 esac
1505
1506 AC_MSG_CHECKING(for program to convert manpage to html)
1507 AC_ARG_WITH(man2html,
1508         [  --with-man2html=XXX     use XXX rather than groff],
1509         [cf_man2html=$withval],
1510         [cf_man2html=$cf_man2html])
1511
1512 cf_with_groff=no
1513
1514 case $cf_man2html in
1515 (yes)
1516         AC_MSG_RESULT(man2html)
1517         AC_PATH_PROG(cf_man2html,man2html,no)
1518         ;;
1519 (no|groff|*/groff*)
1520         cf_with_groff=yes
1521         cf_man2html=$GROFF_PATH
1522         AC_MSG_RESULT($cf_man2html)
1523         ;;
1524 (*)
1525         AC_MSG_RESULT($cf_man2html)
1526         ;;
1527 esac
1528
1529 MAN2HTML_TEMP="man2html.tmp"
1530         cat >$MAN2HTML_TEMP <<CF_EOF
1531 #!$SHELL
1532 # Temporary script generated by CF_WITH_MAN2HTML
1533 # Convert inputs to html, sending result to standard output.
1534 #
1535 # Parameters:
1536 # \${1} = rootname of file to convert
1537 # \${2} = suffix of file to convert, e.g., "1"
1538 # \${3} = macros to use, e.g., "man"
1539 #
1540 ROOT=\[$]1
1541 TYPE=\[$]2
1542 MACS=\[$]3
1543
1544 unset LANG
1545 unset LC_ALL
1546 unset LC_CTYPE
1547 unset LANGUAGE
1548 GROFF_NO_SGR=stupid
1549 export GROFF_NO_SGR
1550
1551 CF_EOF
1552
1553 if test "x$cf_with_groff" = xyes
1554 then
1555         MAN2HTML_NOTE="$GROFF_NOTE"
1556         MAN2HTML_PATH="$GROFF_PATH"
1557         cat >>$MAN2HTML_TEMP <<CF_EOF
1558 $SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
1559 CF_EOF
1560 else
1561         MAN2HTML_NOTE=""
1562         CF_PATH_SYNTAX(cf_man2html)
1563         MAN2HTML_PATH="$cf_man2html"
1564         AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
1565
1566         # for this example, expect 3 lines of content, the remainder is head/foot
1567         cat >conftest.in <<CF_EOF
1568 .TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
1569 .SH SECTION
1570 MARKER
1571 CF_EOF
1572
1573         LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1574
1575         cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1576         cf_man2html_top=`expr $cf_man2html_1st - 2`
1577         cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
1578         cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
1579         cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
1580
1581         AC_MSG_RESULT($cf_man2html_top_bot)
1582
1583         AC_MSG_CHECKING(for pagesize to use)
1584         for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1585         do
1586         cat >>conftest.in <<CF_EOF
1587 .nf
1588 0
1589 1
1590 2
1591 3
1592 4
1593 5
1594 6
1595 7
1596 8
1597 9
1598 CF_EOF
1599         done
1600
1601         LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1602         cf_man2html_page=`fgrep -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1603         test -z "$cf_man2html_page" && cf_man2html_page=99999
1604         test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
1605
1606         rm -rf conftest*
1607         AC_MSG_RESULT($cf_man2html_page)
1608
1609         cat >>$MAN2HTML_TEMP <<CF_EOF
1610 : \${MAN2HTML_PATH=$MAN2HTML_PATH}
1611 MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page"
1612 case \${TYPE} in
1613 (ms)
1614         $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
1615         ;;
1616 (*)
1617         $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
1618         ;;
1619 esac
1620 CF_EOF
1621 fi
1622
1623 chmod 700 $MAN2HTML_TEMP
1624
1625 AC_SUBST(MAN2HTML_NOTE)
1626 AC_SUBST(MAN2HTML_PATH)
1627 AC_SUBST(MAN2HTML_TEMP)
1628 ])dnl
1629 dnl ---------------------------------------------------------------------------
1630 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
1631 dnl ----------------
1632 AC_DEFUN([CF_WITH_VALGRIND],[
1633 CF_NO_LEAKS_OPTION(valgrind,
1634         [  --with-valgrind         test: use valgrind],
1635         [USE_VALGRIND])
1636 ])dnl
1637 dnl ---------------------------------------------------------------------------
1638 dnl CF_XOPEN_SOURCE version: 55 updated: 2018/12/31 20:46:17
1639 dnl ---------------
1640 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1641 dnl or adapt to the vendor's definitions to get equivalent functionality,
1642 dnl without losing the common non-POSIX features.
1643 dnl
1644 dnl Parameters:
1645 dnl     $1 is the nominal value for _XOPEN_SOURCE
1646 dnl     $2 is the nominal value for _POSIX_C_SOURCE
1647 AC_DEFUN([CF_XOPEN_SOURCE],[
1648 AC_REQUIRE([AC_CANONICAL_HOST])
1649 AC_REQUIRE([CF_POSIX_VISIBLE])
1650
1651 if test "$cf_cv_posix_visible" = no; then
1652
1653 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1654 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1655 cf_xopen_source=
1656
1657 case $host_os in
1658 (aix[[4-7]]*)
1659         cf_xopen_source="-D_ALL_SOURCE"
1660         ;;
1661 (msys)
1662         cf_XOPEN_SOURCE=600
1663         ;;
1664 (darwin[[0-8]].*)
1665         cf_xopen_source="-D_APPLE_C_SOURCE"
1666         ;;
1667 (darwin*)
1668         cf_xopen_source="-D_DARWIN_C_SOURCE"
1669         cf_XOPEN_SOURCE=
1670         ;;
1671 (freebsd*|dragonfly*|midnightbsd*)
1672         # 5.x headers associate
1673         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1674         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1675         cf_POSIX_C_SOURCE=200112L
1676         cf_XOPEN_SOURCE=600
1677         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1678         ;;
1679 (hpux11*)
1680         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1681         ;;
1682 (hpux*)
1683         cf_xopen_source="-D_HPUX_SOURCE"
1684         ;;
1685 (irix[[56]].*)
1686         cf_xopen_source="-D_SGI_SOURCE"
1687         cf_XOPEN_SOURCE=
1688         ;;
1689 (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
1690         CF_GNU_SOURCE($cf_XOPEN_SOURCE)
1691         ;;
1692 (minix*)
1693         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
1694         ;;
1695 (mirbsd*)
1696         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1697         cf_XOPEN_SOURCE=
1698         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1699         ;;
1700 (netbsd*)
1701         cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1702         ;;
1703 (openbsd[[4-9]]*)
1704         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1705         cf_xopen_source="-D_BSD_SOURCE"
1706         cf_XOPEN_SOURCE=600
1707         ;;
1708 (openbsd*)
1709         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1710         ;;
1711 (osf[[45]]*)
1712         cf_xopen_source="-D_OSF_SOURCE"
1713         ;;
1714 (nto-qnx*)
1715         cf_xopen_source="-D_QNX_SOURCE"
1716         ;;
1717 (sco*)
1718         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1719         ;;
1720 (solaris2.*)
1721         cf_xopen_source="-D__EXTENSIONS__"
1722         cf_cv_xopen_source=broken
1723         ;;
1724 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
1725         cf_XOPEN_SOURCE=
1726         cf_POSIX_C_SOURCE=
1727         ;;
1728 (*)
1729         CF_TRY_XOPEN_SOURCE
1730         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1731         ;;
1732 esac
1733
1734 if test -n "$cf_xopen_source" ; then
1735         CF_ADD_CFLAGS($cf_xopen_source,true)
1736 fi
1737
1738 dnl In anything but the default case, we may have system-specific setting
1739 dnl which is still not guaranteed to provide all of the entrypoints that
1740 dnl _XOPEN_SOURCE would yield.
1741 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1742         AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1743         AC_TRY_COMPILE([#include <stdlib.h>],[
1744 #ifndef _XOPEN_SOURCE
1745 make an error
1746 #endif],
1747         [cf_XOPEN_SOURCE_set=yes],
1748         [cf_XOPEN_SOURCE_set=no])
1749         AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1750         if test $cf_XOPEN_SOURCE_set = yes
1751         then
1752                 AC_TRY_COMPILE([#include <stdlib.h>],[
1753 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1754 make an error
1755 #endif],
1756                 [cf_XOPEN_SOURCE_set_ok=yes],
1757                 [cf_XOPEN_SOURCE_set_ok=no])
1758                 if test $cf_XOPEN_SOURCE_set_ok = no
1759                 then
1760                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
1761                 fi
1762         else
1763                 CF_TRY_XOPEN_SOURCE
1764         fi
1765 fi
1766 fi # cf_cv_posix_visible
1767 ])