Bump to 20230521
[platform/upstream/byacc.git] / aclocal.m4
1 dnl $Id: aclocal.m4,v 1.64 2023/05/21 19:57:27 tom Exp $
2 dnl Macros for byacc configure script (Thomas E. Dickey)
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 2004-2022,2023 Thomas E. Dickey
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: 15 updated: 2020/12/31 10:54:15
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_CFLAGS version: 3 updated: 2021/09/05 17:25:40
147 dnl ----------------
148 dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions.
149 dnl $1 = flags to add
150 dnl $2 = if given makes this macro verbose.
151 define([CF_APPEND_CFLAGS],
152 [
153 for cf_add_cflags in $1
154 do
155         case "x$cf_add_cflags" in
156         (x-[[DU]]*)
157                 CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2])
158                 CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2])
159                 ;;
160         esac
161         CF_ADD_CFLAGS([$cf_add_cflags],[$2])
162 done
163 ])dnl
164 dnl ---------------------------------------------------------------------------
165 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
166 dnl --------------
167 dnl use this macro for appending text without introducing an extra blank at
168 dnl the beginning
169 define([CF_APPEND_TEXT],
170 [
171         test -n "[$]$1" && $1="[$]$1 "
172         $1="[$]{$1}$2"
173 ])dnl
174 dnl ---------------------------------------------------------------------------
175 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
176 dnl --------------
177 dnl Allow user to disable a normally-on option.
178 AC_DEFUN([CF_ARG_DISABLE],
179 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
180 dnl ---------------------------------------------------------------------------
181 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
182 dnl -------------
183 dnl Allow user to enable a normally-off option.
184 AC_DEFUN([CF_ARG_ENABLE],
185 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
186 dnl ---------------------------------------------------------------------------
187 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
188 dnl -------------
189 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
190 dnl values.
191 dnl
192 dnl Parameters:
193 dnl $1 = option name
194 dnl $2 = help-string
195 dnl $3 = action to perform if option is not default
196 dnl $4 = action if perform if option is default
197 dnl $5 = default option value (either 'yes' or 'no')
198 AC_DEFUN([CF_ARG_OPTION],
199 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
200         if test "$enableval" != "$5" ; then
201 ifelse([$3],,[    :]dnl
202 ,[    $3]) ifelse([$4],,,[
203         else
204                 $4])
205         fi],[enableval=$5 ifelse([$4],,,[
206         $4
207 ])dnl
208 ])])dnl
209 dnl ---------------------------------------------------------------------------
210 dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25
211 dnl ---------------
212 AC_DEFUN([CF_C11_NORETURN],
213 [
214 AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
215 CF_ARG_ENABLE(stdnoreturn,
216         [  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics],
217         [enable_stdnoreturn=yes],
218         [enable_stdnoreturn=no])
219 AC_MSG_RESULT($enable_stdnoreturn)
220
221 if test $enable_stdnoreturn = yes; then
222 AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
223         [AC_TRY_COMPILE([
224 $ac_includes_default
225 #include <stdnoreturn.h>
226 static _Noreturn void giveup(void) { exit(0); }
227         ],
228         [if (feof(stdin)) giveup()],
229         cf_cv_c11_noreturn=yes,
230         cf_cv_c11_noreturn=no)
231         ])
232 else
233         cf_cv_c11_noreturn=no,
234 fi
235
236 if test "$cf_cv_c11_noreturn" = yes; then
237         AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
238         AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
239         HAVE_STDNORETURN_H=1
240 else
241         HAVE_STDNORETURN_H=0
242 fi
243
244 AC_SUBST(HAVE_STDNORETURN_H)
245 AC_SUBST(STDC_NORETURN)
246 ])dnl
247 dnl ---------------------------------------------------------------------------
248 dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46
249 dnl ---------------
250 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
251 dnl into CC.  This will not help with broken scripts that wrap the compiler
252 dnl with options, but eliminates a more common category of user confusion.
253 dnl
254 dnl In particular, it addresses the problem of being able to run the C
255 dnl preprocessor in a consistent manner.
256 dnl
257 dnl Caveat: this also disallows blanks in the pathname for the compiler, but
258 dnl the nuisance of having inconsistent settings for compiler and preprocessor
259 dnl outweighs that limitation.
260 AC_DEFUN([CF_CC_ENV_FLAGS],
261 [
262 # This should have been defined by AC_PROG_CC
263 : "${CC:=cc}"
264
265 AC_MSG_CHECKING(\$CFLAGS variable)
266 case "x$CFLAGS" in
267 (*-[[IUD]]*)
268         AC_MSG_RESULT(broken)
269         AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
270         cf_flags="$CFLAGS"
271         CFLAGS=
272         for cf_arg in $cf_flags
273         do
274                 CF_ADD_CFLAGS($cf_arg)
275         done
276         ;;
277 (*)
278         AC_MSG_RESULT(ok)
279         ;;
280 esac
281
282 AC_MSG_CHECKING(\$CC variable)
283 case "$CC" in
284 (*[[\ \ ]]-*)
285         AC_MSG_RESULT(broken)
286         AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
287         # humor him...
288         cf_prog=`echo "$CC" | sed -e 's/        / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
289         cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
290         CC="$cf_prog"
291         for cf_arg in $cf_flags
292         do
293                 case "x$cf_arg" in
294                 (x-[[IUDfgOW]]*)
295                         CF_ADD_CFLAGS($cf_arg)
296                         ;;
297                 (*)
298                         CC="$CC $cf_arg"
299                         ;;
300                 esac
301         done
302         CF_VERBOSE(resulting CC: '$CC')
303         CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
304         CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
305         ;;
306 (*)
307         AC_MSG_RESULT(ok)
308         ;;
309 esac
310 ])dnl
311 dnl ---------------------------------------------------------------------------
312 dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
313 dnl --------------
314 dnl Check if we're accidentally using a cache from a different machine.
315 dnl Derive the system name, as a check for reusing the autoconf cache.
316 dnl
317 dnl If we've packaged config.guess and config.sub, run that (since it does a
318 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
319 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
320 dnl which is useful in cross-compiles.
321 dnl
322 dnl Note: we would use $ac_config_sub, but that is one of the places where
323 dnl autoconf 2.5x broke compatibility with autoconf 2.13
324 AC_DEFUN([CF_CHECK_CACHE],
325 [
326 if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
327         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
328         system_name="$host_os"
329 else
330         system_name="`(uname -s -r) 2>/dev/null`"
331         if test -z "$system_name" ; then
332                 system_name="`(hostname) 2>/dev/null`"
333         fi
334 fi
335 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
336 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
337
338 test -z "$system_name" && system_name="$cf_cv_system_name"
339 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
340
341 if test ".$system_name" != ".$cf_cv_system_name" ; then
342         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
343         AC_MSG_ERROR("Please remove config.cache and try again.")
344 fi
345 ])dnl
346 dnl ---------------------------------------------------------------------------
347 dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25
348 dnl -----------------
349 dnl Check if the given compiler is really clang.  clang's C driver defines
350 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
351 dnl not ignore some gcc options.
352 dnl
353 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
354 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
355 dnl the wrappers for gcc and g++ warnings.
356 dnl
357 dnl $1 = GCC (default) or GXX
358 dnl $2 = CLANG_COMPILER (default)
359 dnl $3 = CFLAGS (default) or CXXFLAGS
360 AC_DEFUN([CF_CLANG_COMPILER],[
361 ifelse([$2],,CLANG_COMPILER,[$2])=no
362
363 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
364         AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
365         cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
366         AC_TRY_COMPILE([],[
367 #ifdef __clang__
368 #else
369 #error __clang__ is not defined
370 #endif
371 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
372 ],[])
373         ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
374         AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
375 fi
376
377 CLANG_VERSION=none
378
379 if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
380         case "$CC" in
381         (c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
382                 AC_MSG_WARN(replacing broken compiler alias $CC)
383                 CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
384                 CC=clang
385                 ;;
386         esac
387
388         AC_MSG_CHECKING(version of $CC)
389         CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
390         test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
391         AC_MSG_RESULT($CLANG_VERSION)
392
393         for cf_clang_opt in \
394                 -Qunused-arguments \
395                 -Wno-error=implicit-function-declaration
396         do
397                 AC_MSG_CHECKING(if option $cf_clang_opt works)
398                 cf_save_CFLAGS="$CFLAGS"
399                 CFLAGS="$CFLAGS $cf_clang_opt"
400                 AC_TRY_LINK([
401                         #include <stdio.h>],[
402                         printf("hello!\\n");],[
403                         cf_clang_optok=yes],[
404                         cf_clang_optok=no])
405                 AC_MSG_RESULT($cf_clang_optok)
406                 CFLAGS="$cf_save_CFLAGS"
407                 if test "$cf_clang_optok" = yes; then
408                         CF_VERBOSE(adding option $cf_clang_opt)
409                         CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
410                 fi
411         done
412 fi
413 ])
414 dnl ---------------------------------------------------------------------------
415 dnl CF_CONST_X_STRING version: 7 updated: 2021/06/07 17:39:17
416 dnl -----------------
417 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
418 dnl character-strings.
419 dnl
420 dnl It is ambiguous because the specification accommodated the pre-ANSI
421 dnl compilers bundled by more than one vendor in lieu of providing a standard C
422 dnl compiler other than by costly add-ons.  Because of this, the specification
423 dnl did not take into account the use of const for telling the compiler that
424 dnl string literals would be in readonly memory.
425 dnl
426 dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
427 dnl let the compiler decide how to represent Xt's strings which were #define'd.
428 dnl That does not solve the problem of using the block of Xt's strings which
429 dnl are compiled into the library (and is less efficient than one might want).
430 dnl
431 dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
432 dnl when compiling the library and compiling using the library, to tell the
433 dnl compiler that String is const.
434 AC_DEFUN([CF_CONST_X_STRING],
435 [
436 AC_REQUIRE([AC_PATH_XTRA])
437
438 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
439
440 AC_TRY_COMPILE(
441 [
442 #include <stdlib.h>
443 #include <X11/Intrinsic.h>
444 ],
445 [String foo = malloc(1); free((void*)foo)],[
446
447 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
448         AC_TRY_COMPILE(
449                 [
450 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
451 #undef  XTSTRINGDEFINES /* X11R5 and later */
452 #include <stdlib.h>
453 #include <X11/Intrinsic.h>
454                 ],[String foo = malloc(1); *foo = 0],[
455                         cf_cv_const_x_string=no
456                 ],[
457                         cf_cv_const_x_string=yes
458                 ])
459 ])
460
461 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
462
463 case "$cf_cv_const_x_string" in
464 (no)
465         CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
466         ;;
467 (*)
468         CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
469         ;;
470 esac
471
472 ])
473 ])dnl
474 dnl ---------------------------------------------------------------------------
475 dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04
476 dnl ---------------
477 dnl You can always use "make -n" to see the actual options, but it is hard to
478 dnl pick out/analyze warning messages when the compile-line is long.
479 dnl
480 dnl Sets:
481 dnl     ECHO_LT - symbol to control if libtool is verbose
482 dnl     ECHO_LD - symbol to prefix "cc -o" lines
483 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
484 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
485 dnl     ECHO_CC - symbol to put before any "cc" line
486 dnl
487 AC_DEFUN([CF_DISABLE_ECHO],[
488 AC_MSG_CHECKING(if you want to see long compiling messages)
489 CF_ARG_DISABLE(echo,
490         [  --disable-echo          do not display "compiling" commands],
491         [
492         ECHO_LT='--silent'
493         ECHO_LD='@echo linking [$]@;'
494         RULE_CC='@echo compiling [$]<'
495         SHOW_CC='@echo compiling [$]@'
496         ECHO_CC='@'
497 ],[
498         ECHO_LT=''
499         ECHO_LD=''
500         RULE_CC=''
501         SHOW_CC=''
502         ECHO_CC=''
503 ])
504 AC_MSG_RESULT($enableval)
505 AC_SUBST(ECHO_LT)
506 AC_SUBST(ECHO_LD)
507 AC_SUBST(RULE_CC)
508 AC_SUBST(SHOW_CC)
509 AC_SUBST(ECHO_CC)
510 ])dnl
511 dnl ---------------------------------------------------------------------------
512 dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50
513 dnl ----------------
514 dnl Combine no-leak checks with the libraries or tools that are used for the
515 dnl checks.
516 AC_DEFUN([CF_DISABLE_LEAKS],[
517
518 AC_REQUIRE([CF_WITH_DMALLOC])
519 AC_REQUIRE([CF_WITH_DBMALLOC])
520 AC_REQUIRE([CF_WITH_VALGRIND])
521
522 AC_MSG_CHECKING(if you want to perform memory-leak testing)
523 AC_ARG_ENABLE(leaks,
524         [  --disable-leaks         test: free permanent memory, analyze leaks],
525         [enable_leaks=$enableval],
526         [enable_leaks=yes])
527 dnl with_no_leaks is more readable...
528 if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
529 AC_MSG_RESULT($with_no_leaks)
530
531 if test "$enable_leaks" = no ; then
532         AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
533         AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
534 fi
535 ])dnl
536 dnl ---------------------------------------------------------------------------
537 dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
538 dnl ------------------
539 dnl Configure-option to enable gcc warnings
540 dnl
541 dnl $1 = extra options to add, if supported
542 dnl $2 = option for checking attributes.  By default, this is done when
543 dnl      warnings are enabled.  For other values:
544 dnl      yes: always do this, e.g., to use in generated library-headers
545 dnl      no: never do this
546 AC_DEFUN([CF_ENABLE_WARNINGS],[
547 if test "$GCC" = yes || test "$GXX" = yes
548 then
549 CF_FIX_WARNINGS(CFLAGS)
550 CF_FIX_WARNINGS(CPPFLAGS)
551 CF_FIX_WARNINGS(LDFLAGS)
552 AC_MSG_CHECKING(if you want to turn on gcc warnings)
553 CF_ARG_ENABLE(warnings,
554         [  --enable-warnings       test: turn on gcc compiler warnings],
555         [enable_warnings=yes],
556         [enable_warnings=no])
557 AC_MSG_RESULT($enable_warnings)
558 if test "$enable_warnings" = "yes"
559 then
560         ifelse($2,,[CF_GCC_ATTRIBUTES])
561         CF_GCC_WARNINGS($1)
562 fi
563 ifelse($2,yes,[CF_GCC_ATTRIBUTES])
564 fi
565 ])dnl
566 dnl ---------------------------------------------------------------------------
567 dnl CF_FIX_WARNINGS version: 4 updated: 2021/12/16 18:22:31
568 dnl ---------------
569 dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
570 dnl "-Werror" flags can interfere with configure-checks.  Those go into
571 dnl EXTRA_CFLAGS.
572 dnl
573 dnl $1 = variable name to repair
574 define([CF_FIX_WARNINGS],[
575 if test "$GCC" = yes || test "$GXX" = yes
576 then
577         case [$]$1 in
578         (*-Werror=*)
579                 cf_temp_flags=
580                 for cf_temp_scan in [$]$1
581                 do
582                         case "x$cf_temp_scan" in
583                         (x-Werror=format*)
584                                 CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
585                                 ;;
586                         (x-Werror=*)
587                                 CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
588                                 ;;
589                         (*)
590                                 CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
591                                 ;;
592                         esac
593                 done
594                 if test "x[$]$1" != "x$cf_temp_flags"
595                 then
596                         CF_VERBOSE(repairing $1: [$]$1)
597                         $1="$cf_temp_flags"
598                         CF_VERBOSE(... fixed [$]$1)
599                         CF_VERBOSE(... extra $EXTRA_CFLAGS)
600                 fi
601                 ;;
602         esac
603 fi
604 AC_SUBST(EXTRA_CFLAGS)
605 ])dnl
606 dnl ---------------------------------------------------------------------------
607 dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25
608 dnl -----------------
609 dnl Test for availability of useful gcc __attribute__ directives to quiet
610 dnl compiler warnings.  Though useful, not all are supported -- and contrary
611 dnl to documentation, unrecognized directives cause older compilers to barf.
612 AC_DEFUN([CF_GCC_ATTRIBUTES],
613 [AC_REQUIRE([AC_PROG_FGREP])dnl
614 AC_REQUIRE([CF_C11_NORETURN])dnl
615
616 if test "$GCC" = yes || test "$GXX" = yes
617 then
618 cat > conftest.i <<EOF
619 #ifndef GCC_PRINTF
620 #define GCC_PRINTF 0
621 #endif
622 #ifndef GCC_SCANF
623 #define GCC_SCANF 0
624 #endif
625 #ifndef GCC_NORETURN
626 #define GCC_NORETURN /* nothing */
627 #endif
628 #ifndef GCC_UNUSED
629 #define GCC_UNUSED /* nothing */
630 #endif
631 EOF
632 if test "$GCC" = yes
633 then
634         AC_CHECKING([for $CC __attribute__ directives])
635 cat > "conftest.$ac_ext" <<EOF
636 #line __oline__ "${as_me:-configure}"
637 #include <stdio.h>
638 #include "confdefs.h"
639 #include "conftest.h"
640 #include "conftest.i"
641 #if     GCC_PRINTF
642 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
643 #else
644 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
645 #endif
646 #if     GCC_SCANF
647 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
648 #else
649 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
650 #endif
651 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
652 extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
653 extern GCC_NORETURN void foo(void);
654 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
655 EOF
656         cf_printf_attribute=no
657         cf_scanf_attribute=no
658         for cf_attribute in scanf printf unused noreturn
659         do
660                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
661                 cf_directive="__attribute__(($cf_attribute))"
662                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
663
664                 case "$cf_attribute" in
665                 (printf)
666                         cf_printf_attribute=yes
667                         cat >conftest.h <<EOF
668 #define GCC_$cf_ATTRIBUTE 1
669 EOF
670                         ;;
671                 (scanf)
672                         cf_scanf_attribute=yes
673                         cat >conftest.h <<EOF
674 #define GCC_$cf_ATTRIBUTE 1
675 EOF
676                         ;;
677                 (*)
678                         cat >conftest.h <<EOF
679 #define GCC_$cf_ATTRIBUTE $cf_directive
680 EOF
681                         ;;
682                 esac
683
684                 if AC_TRY_EVAL(ac_compile); then
685                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
686                         cat conftest.h >>confdefs.h
687                         case "$cf_attribute" in
688                         (noreturn)
689                                 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
690                                 ;;
691                         (printf)
692                                 cf_value='/* nothing */'
693                                 if test "$cf_printf_attribute" != no ; then
694                                         cf_value='__attribute__((format(printf,fmt,var)))'
695                                         AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
696                                 fi
697                                 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
698                                 ;;
699                         (scanf)
700                                 cf_value='/* nothing */'
701                                 if test "$cf_scanf_attribute" != no ; then
702                                         cf_value='__attribute__((format(scanf,fmt,var)))'
703                                         AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
704                                 fi
705                                 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
706                                 ;;
707                         (unused)
708                                 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
709                                 ;;
710                         esac
711                 fi
712         done
713 else
714         ${FGREP-fgrep} define conftest.i >>confdefs.h
715 fi
716 rm -rf ./conftest*
717 fi
718 ])dnl
719 dnl ---------------------------------------------------------------------------
720 dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13
721 dnl --------------
722 dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
723 dnl compatible), attempt to determine if icc/clang is actually used.
724 AC_DEFUN([CF_GCC_VERSION],[
725 AC_REQUIRE([AC_PROG_CC])
726 GCC_VERSION=none
727 if test "$GCC" = yes ; then
728         AC_MSG_CHECKING(version of $CC)
729         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
730         test -z "$GCC_VERSION" && GCC_VERSION=unknown
731         AC_MSG_RESULT($GCC_VERSION)
732 fi
733 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
734 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
735 ])dnl
736 dnl ---------------------------------------------------------------------------
737 dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59
738 dnl ---------------
739 dnl Check if the compiler supports useful warning options.  There's a few that
740 dnl we don't use, simply because they're too noisy:
741 dnl
742 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
743 dnl     -Winline (usually not worthwhile)
744 dnl     -Wredundant-decls (system headers make this too noisy)
745 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
746 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
747 dnl             is enabled for ncurses using "--enable-const".
748 dnl     -pedantic
749 dnl
750 dnl Parameter:
751 dnl     $1 is an optional list of gcc warning flags that a particular
752 dnl             application might want to use, e.g., "no-unused" for
753 dnl             -Wno-unused
754 dnl Special:
755 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
756 dnl
757 AC_DEFUN([CF_GCC_WARNINGS],
758 [
759 AC_REQUIRE([CF_GCC_VERSION])
760 if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
761 cat > "conftest.$ac_ext" <<EOF
762 #line __oline__ "${as_me:-configure}"
763 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
764 EOF
765 if test "$INTEL_COMPILER" = yes
766 then
767 # The "-wdXXX" options suppress warnings:
768 # remark #1419: external declaration in primary source file
769 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
770 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
771 # remark #193: zero used for undefined preprocessing identifier
772 # remark #593: variable "curs_sb_left_arrow" was set but never used
773 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
774 # remark #869: parameter "tw" was never referenced
775 # remark #981: operands are evaluated in unspecified order
776 # warning #279: controlling expression is constant
777
778         AC_CHECKING([for $CC warning options])
779         cf_save_CFLAGS="$CFLAGS"
780         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
781         for cf_opt in \
782                 wd1419 \
783                 wd1683 \
784                 wd1684 \
785                 wd193 \
786                 wd593 \
787                 wd279 \
788                 wd810 \
789                 wd869 \
790                 wd981
791         do
792                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
793                 if AC_TRY_EVAL(ac_compile); then
794                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
795                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
796                 fi
797         done
798         CFLAGS="$cf_save_CFLAGS"
799 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
800 then
801         AC_CHECKING([for $CC warning options])
802         cf_save_CFLAGS="$CFLAGS"
803         cf_warn_CONST=""
804         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
805         cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
806         test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
807         for cf_opt in W Wall \
808                 Wbad-function-cast \
809                 Wcast-align \
810                 Wcast-qual \
811                 Wdeclaration-after-statement \
812                 Wextra \
813                 Winline \
814                 Wmissing-declarations \
815                 Wmissing-prototypes \
816                 Wnested-externs \
817                 Wpointer-arith \
818                 Wshadow \
819                 Wstrict-prototypes \
820                 Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
821         do
822                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
823                 if AC_TRY_EVAL(ac_compile); then
824                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
825                         case "$cf_opt" in
826                         (Winline)
827                                 case "$GCC_VERSION" in
828                                 ([[34]].*)
829                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
830                                         continue;;
831                                 esac
832                                 ;;
833                         (Wpointer-arith)
834                                 case "$GCC_VERSION" in
835                                 ([[12]].*)
836                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
837                                         continue;;
838                                 esac
839                                 ;;
840                         esac
841                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
842                 fi
843         done
844         CFLAGS="$cf_save_CFLAGS"
845 fi
846 rm -rf ./conftest*
847
848 AC_SUBST(EXTRA_CFLAGS)
849 ])dnl
850 dnl ---------------------------------------------------------------------------
851 dnl CF_GETOPT_HEADER version: 8 updated: 2021/06/19 19:16:16
852 dnl ----------------
853 dnl Check for getopt's variables which are commonly defined in stdlib.h,
854 dnl unistd.h or (nonstandard) in getopt.h
855 AC_DEFUN([CF_GETOPT_HEADER],
856 [
857 AC_HAVE_HEADERS(unistd.h getopt.h)
858 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
859 cf_cv_getopt_header=none
860 for cf_header in stdio.h stdlib.h unistd.h getopt.h
861 do
862 AC_TRY_COMPILE([
863 #include <$cf_header>],
864 [int x = optind; char *y = optarg; (void)x; (void)y],
865 [cf_cv_getopt_header=$cf_header
866  break])
867 done
868 ])
869 if test "$cf_cv_getopt_header" != none ; then
870         AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
871 fi
872 if test "$cf_cv_getopt_header" = getopt.h ; then
873         AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
874 fi
875 ])dnl
876 dnl ---------------------------------------------------------------------------
877 dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
878 dnl -------------
879 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
880 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
881 dnl (or misfeature) of glibc2, which breaks portability of many applications,
882 dnl since it is interwoven with GNU extensions.
883 dnl
884 dnl Well, yes we could work around it...
885 dnl
886 dnl Parameters:
887 dnl     $1 is the nominal value for _XOPEN_SOURCE
888 AC_DEFUN([CF_GNU_SOURCE],
889 [
890 cf_gnu_xopen_source=ifelse($1,,500,$1)
891
892 AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
893 AC_TRY_COMPILE([#include <sys/types.h>],[
894         #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
895                 return 0;
896         #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
897                 return 0;
898         #else
899         #       error not GNU C library
900         #endif],
901         [cf_cv_gnu_library=yes],
902         [cf_cv_gnu_library=no])
903 ])
904
905 if test x$cf_cv_gnu_library = xyes; then
906
907         # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
908         # was changed to help a little.  newlib incorporated the change about 4
909         # years later.
910         AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
911                 cf_save="$CPPFLAGS"
912                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
913                 AC_TRY_COMPILE([#include <sys/types.h>],[
914                         #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
915                                 return 0;
916                         #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
917                                 return 0;
918                         #else
919                         #       error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
920                         #endif],
921                         [cf_cv_gnu_library_219=yes],
922                         [cf_cv_gnu_library_219=no])
923                 CPPFLAGS="$cf_save"
924         ])
925
926         if test "x$cf_cv_gnu_library_219" = xyes; then
927                 cf_save="$CPPFLAGS"
928                 AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
929                         CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
930                         AC_TRY_COMPILE([
931                                 #include <limits.h>
932                                 #include <sys/types.h>
933                                 ],[
934                                 #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
935                                         return 0;
936                                 #else
937                                 #       error GNU C library is too old
938                                 #endif],
939                                 [cf_cv_gnu_dftsrc_219=yes],
940                                 [cf_cv_gnu_dftsrc_219=no])
941                         ])
942                 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
943         else
944                 cf_cv_gnu_dftsrc_219=maybe
945         fi
946
947         if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
948
949                 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
950                 AC_TRY_COMPILE([#include <sys/types.h>],[
951                         #ifndef _XOPEN_SOURCE
952                         #error  expected _XOPEN_SOURCE to be defined
953                         #endif],
954                         [cf_cv_gnu_source=no],
955                         [cf_save="$CPPFLAGS"
956                          CF_ADD_CFLAGS(-D_GNU_SOURCE)
957                          AC_TRY_COMPILE([#include <sys/types.h>],[
958                                 #ifdef _XOPEN_SOURCE
959                                 #error  expected _XOPEN_SOURCE to be undefined
960                                 #endif],
961                                 [cf_cv_gnu_source=no],
962                                 [cf_cv_gnu_source=yes])
963                         CPPFLAGS="$cf_save"
964                         ])
965                 ])
966
967                 if test "$cf_cv_gnu_source" = yes
968                 then
969                 AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
970                         CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
971                         AC_TRY_COMPILE([#include <sys/types.h>],[
972                                 #ifdef _DEFAULT_SOURCE
973                                 #error  expected _DEFAULT_SOURCE to be undefined
974                                 #endif],
975                                 [cf_cv_default_source=no],
976                                 [cf_cv_default_source=yes])
977                         ])
978                         if test "$cf_cv_default_source" = yes
979                         then
980                                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
981                         fi
982                 fi
983         fi
984
985 fi
986 ])dnl
987 dnl ---------------------------------------------------------------------------
988 dnl CF_INSTALL_MAN version: 5 updated: 2023/05/21 15:53:07
989 dnl --------------
990 dnl Call this to generate a script "install-man" which uses the detected
991 dnl manpage-format to compress the resulting manpage.  Providing this as a
992 dnl macro simplifies including the script in different programs.
993 dnl
994 dnl The generated script assumes that the program can be renamed, using two
995 dnl symbols in the manpage, e.g.,
996 dnl             .ds N Yacc
997 dnl     .ds n yacc
998 dnl which are later used as \*N and \*n, as well as a special case in the
999 dnl synopsis to work around limitations of makewhatis.
1000 dnl
1001 dnl Script parameters:
1002 dnl     $1 = input file
1003 dnl     $2 = output filename
1004 dnl
1005 dnl or (uninstall):
1006 dnl     $1 = output filename
1007 AC_DEFUN([CF_INSTALL_MAN],
1008 [
1009 AC_REQUIRE([AC_ARG_PROGRAM])
1010 AC_REQUIRE([AC_PROG_INSTALL])
1011 AC_REQUIRE([AC_LN_S])
1012 AC_REQUIRE([CF_MANPAGE_FORMAT])
1013 cf_install_man=install-man
1014 ac_config_files="$ac_config_files $cf_install_man"
1015 cf_install_man=$cf_install_man.in
1016 echo [$]as_me: creating $cf_install_man
1017 cat >[$]cf_install_man <<"CF_EOF"
1018 #!/bin/sh
1019 # generated by CF_INSTALL_MAN
1020
1021 LANG=C;     export LANG
1022 LC_ALL=C;   export LC_ALL
1023 LC_CTYPE=C; export LC_CTYPE
1024 LANGUAGE=C; export LANGUAGE
1025
1026 INSTALL="@INSTALL@"
1027 INSTALL_DATA="@INSTALL_DATA@"
1028
1029 usage() {
1030         cat <<EOF
1031 Usage: install-man [[-l]] [[source]] target
1032 EOF
1033         exit 1
1034 }
1035
1036 failed() {
1037         echo "?? [$]*" >&2
1038         exit 1
1039 }
1040
1041 test [$]# != 0 || usage
1042 OPTS=
1043 case "x[$]1" in
1044 (x-l)
1045         OPTS="link"
1046         shift
1047         ;;
1048 (x-*)
1049         usage
1050         ;;
1051 esac
1052
1053 source=
1054 if test [$]# = 2 ; then
1055         source=[$]1; shift
1056         target=[$]1
1057 elif test [$]# = 1 ; then
1058         test -n "$OPTS" && usage
1059         target=[$]1
1060 else
1061         usage
1062 fi
1063
1064 origin_name=`echo "$source" |sed -e 's%^.*/%%' -e 's%\..*%%'`
1065 actual_name=`echo "$origin_name" |sed '@program_transform_name@'`
1066 leading_cap=`echo "$actual_name" | sed -e 's%^\(.\).*$%\1%' | tr a-z A-Z``echo "$actual_name" | sed -e 's%^.%%'`
1067 capitalized=`echo "$actual_name" | tr a-z A-Z`
1068
1069 cf_tmpdir=`mktemp -d`
1070 trap 'rm -rf "$cf_tmpdir"; exit 1' 1 2 3 15
1071 trap 'rm -rf "$cf_tmpdir"; exit 0' 0
1072
1073 if test -n "$source" ; then
1074         suffix=
1075         test -n "@cf_manpage_so_strip" && suffix=".@cf_manpage_so_strip@"
1076         if test "x$OPTS" = xlink ; then
1077                 source_dir=`echo "$source" | sed -e "s%/[[^/]]*$%%"`
1078                 target_dir=`echo "$target" | sed -e "s%/[[^/]]*$%%"`
1079                 sourcelink="${source}${suffix}" 
1080                 targetfile="${target}${suffix}" 
1081                 targetlink="${target_dir}/${sourcelink}"
1082                 if test ! -d "$target_dir" ; then
1083                         failed "target directory does not exist: $target_dir"
1084                 elif test ! -f "$targetfile" ; then
1085                         failed "target file does not exist: $targetfile"
1086                 elif test "$source" != "$source_dir" ; then
1087                         failed "unexpected directory for source-link: $source_dir"
1088                 fi
1089                 test -f "$targetlink" && failed "already exists $targetlink"
1090                 ( cd "$target_dir" && @LN_S@ "`echo "$targetfile" | sed -e 's%^.*/%%'`" "$sourcelink" )
1091                 test -f "$targetlink" || failed "cannot create $targetlink"
1092                 target="$targetlink"
1093         else
1094                 echo "** installing $source to $target"
1095                 interim="$cf_tmpdir"/"`basename $source`"
1096                 if test "x$origin_name" != "x$actual_name" ; then
1097                         sed \
1098                                 -e "/^.ds N/s%N.*%N $leading_cap%" \
1099                                 -e "/^.ds n/s%n.*%n $actual_name%" \
1100                                 -e "/^\.TH/s%[[ ]][[ ]]*[[^ ]][[^ ]]*% $capitalized%" \
1101                                 -e "/^\.SH[[ ]][[ ]]*NAME/,/[[ ]]\\\\-[[ ]]/s%^\\\\\\*[[Nn]]%$actual_name%" \
1102                                 "$source" >"$interim" || exit 1
1103                         diff -c "$source" "$interim"
1104                 else
1105                         cp "$source" "$interim" || exit 1
1106                 fi
1107                 if test -n "@cf_manpage_compress@" ; then
1108                         @cf_manpage_compress@ "$interim"
1109                         source="${interim}${suffix}"
1110                 fi
1111                 if test -d "$target" ; then
1112                         target="$target"/"$source"
1113                 else
1114                         test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@"
1115                 fi
1116                 $INSTALL_DATA "$source" "$target" || exit 1
1117         fi
1118         echo "...installed $target"
1119 else
1120         echo "** removing $target"
1121         test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@"
1122         if test -f "$target" ; then
1123                 rm -f "$target"
1124                 echo "...removed $target"
1125         else
1126                 echo "...not found"
1127         fi
1128 fi
1129 exit 0
1130 CF_EOF
1131 ])dnl
1132 dnl ---------------------------------------------------------------------------
1133 dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25
1134 dnl -----------------
1135 dnl Check if the given compiler is really the Intel compiler for Linux.  It
1136 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1137 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1138 dnl
1139 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1140 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1141 dnl the wrappers for gcc and g++ warnings.
1142 dnl
1143 dnl $1 = GCC (default) or GXX
1144 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1145 dnl $3 = CFLAGS (default) or CXXFLAGS
1146 AC_DEFUN([CF_INTEL_COMPILER],[
1147 AC_REQUIRE([AC_CANONICAL_HOST])
1148 ifelse([$2],,INTEL_COMPILER,[$2])=no
1149
1150 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1151         case "$host_os" in
1152         (linux*|gnu*)
1153                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1154                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1155                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1156                 AC_TRY_COMPILE([],[
1157 #ifdef __INTEL_COMPILER
1158 #else
1159 #error __INTEL_COMPILER is not defined
1160 #endif
1161 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1162 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1163 ],[])
1164                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1165                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1166                 ;;
1167         esac
1168 fi
1169 ])dnl
1170 dnl ---------------------------------------------------------------------------
1171 dnl CF_MAKE_DOCS version: 5 updated: 2021/01/10 16:05:11
1172 dnl ------------
1173 dnl $1 = name(s) to generate rules for
1174 dnl $2 = suffix of corresponding manpages used as input.
1175 dnl
1176 dnl This works best if called at the end of configure.in, following CF_WITH_MAN2HTML
1177 define([CF_MAKE_DOCS],[
1178 test -z "$cf_make_docs" && cf_make_docs=0
1179
1180 cf_output=makefile
1181 test -f "$cf_output" || cf_output=Makefile
1182
1183 if test "$cf_make_docs" = 0
1184 then
1185 cat >>$cf_output <<CF_EOF
1186 ################################################################################
1187 ## generated by $0
1188 .SUFFIXES : .html .$2 .man .ps .pdf .txt
1189
1190 ${NROFF_NOTE}.$2.txt :
1191 ${NROFF_NOTE}   [\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
1192
1193 ${GROFF_NOTE}.ps.pdf :
1194 ${GROFF_NOTE}   ps2pdf [\$]*.ps
1195 ${GROFF_NOTE}
1196 ${GROFF_NOTE}.$2.ps :
1197 ${GROFF_NOTE}   [\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
1198 ${GROFF_NOTE}
1199 ${GROFF_NOTE}.$2.txt :
1200 ${GROFF_NOTE}   GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -rHY=0 -Tascii -man | col -bx" >[\$]@
1201
1202 ${MAN2HTML_NOTE}.$2.html :
1203 ${MAN2HTML_NOTE}        ./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
1204
1205 CF_EOF
1206         cf_make_docs=1
1207 fi
1208
1209 for cf_name in $1
1210 do
1211 cat >>$cf_output <<CF_EOF
1212 ################################################################################
1213 ${NROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
1214 ${MAN2HTML_NOTE}docs docs-$cf_name :: $cf_name.html
1215 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.pdf
1216 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.ps
1217 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
1218
1219 clean \\
1220 docs-clean ::
1221 ${NROFF_NOTE}   rm -f $cf_name.txt
1222 ${MAN2HTML_NOTE}        rm -f $cf_name.html
1223 ${GROFF_NOTE}   rm -f $cf_name.pdf
1224 ${GROFF_NOTE}   rm -f $cf_name.ps
1225 ${GROFF_NOTE}   rm -f $cf_name.txt
1226
1227 ${NROFF_NOTE}$cf_name.txt  : $cf_name.$2
1228 ${MAN2HTML_NOTE}$cf_name.html : $cf_name.$2
1229 ${GROFF_NOTE}$cf_name.pdf  : $cf_name.ps
1230 ${GROFF_NOTE}$cf_name.ps   : $cf_name.$2
1231 ${GROFF_NOTE}$cf_name.txt  : $cf_name.$2
1232 CF_EOF
1233 done
1234 ])dnl
1235 dnl ---------------------------------------------------------------------------
1236 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1237 dnl ------------
1238 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1239 dnl a monocase filesystem.
1240 AC_DEFUN([CF_MAKE_TAGS],[
1241 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1242
1243 AC_CHECK_PROGS(CTAGS, exctags ctags)
1244 AC_CHECK_PROGS(ETAGS, exetags etags)
1245
1246 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1247
1248 if test "$cf_cv_mixedcase" = yes ; then
1249         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1250 else
1251         MAKE_UPPER_TAGS=no
1252 fi
1253
1254 if test "$MAKE_UPPER_TAGS" = yes ; then
1255         MAKE_UPPER_TAGS=
1256 else
1257         MAKE_UPPER_TAGS="#"
1258 fi
1259
1260 if test "$MAKE_LOWER_TAGS" = yes ; then
1261         MAKE_LOWER_TAGS=
1262 else
1263         MAKE_LOWER_TAGS="#"
1264 fi
1265
1266 AC_SUBST(CTAGS)
1267 AC_SUBST(ETAGS)
1268
1269 AC_SUBST(MAKE_UPPER_TAGS)
1270 AC_SUBST(MAKE_LOWER_TAGS)
1271 ])dnl
1272 dnl ---------------------------------------------------------------------------
1273 dnl CF_MANPAGE_FORMAT version: 18 updated: 2023/05/19 18:35:02
1274 dnl -----------------
1275 dnl Option to allow user to override automatic configuration of manpage format.
1276 dnl There are several special cases:
1277 dnl
1278 dnl     compress - man checks for, can display compressed files
1279 dnl     bzip2 - man checks for, can display bzip2'd files
1280 dnl     gzip - man checks for, can display gzip'd files
1281 dnl     xz - man checks for, can display xz'd files
1282 dnl
1283 dnl     BSDI - files in the cat-directories are suffixed ".0"
1284 dnl     formatted - installer should format (put files in cat-directory)
1285 dnl     catonly - installer should only format, e.g., for a turnkey system.
1286 dnl
1287 dnl There are other configurations which this macro does not test, e.g., HPUX's
1288 dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
1289 dnl convention would not match our use).
1290 AC_DEFUN([CF_MANPAGE_FORMAT],
1291 [
1292 AC_REQUIRE([CF_PATHSEP])
1293 AC_MSG_CHECKING(format of man-pages)
1294
1295 AC_ARG_WITH(manpage-format,
1296         [  --with-manpage-format   specify manpage-format: gzip/compress/bzip2/xz,
1297                           BSDI/normal and optionally formatted/catonly,
1298                           e.g., gzip,formatted],
1299         [MANPAGE_FORMAT=$withval],
1300         [MANPAGE_FORMAT=unknown])
1301
1302 test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
1303 MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
1304
1305 cf_unknown=
1306
1307 case "$MANPAGE_FORMAT" in
1308 (unknown)
1309         if test -z "$MANPATH" ; then
1310                 MANPATH="/usr/man:/usr/share/man"
1311         fi
1312
1313         # look for the 'date' man-page (it is most likely to be installed!)
1314         MANPAGE_FORMAT=
1315         cf_preform="no"
1316         cf_catonly="yes"
1317         cf_example="date"
1318
1319         IFS="${IFS:-    }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
1320         for cf_dir in $MANPATH; do
1321                 test -z "$cf_dir" && cf_dir=/usr/man
1322                 for cf_name in $cf_dir/man*/$cf_example.[[01]]* $cf_dir/cat*/$cf_example.[[01]]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
1323                 do
1324                         cf_test=`echo "$cf_name" | sed -e 's/*//'`
1325                         if test "x$cf_test" = "x$cf_name" ; then
1326
1327                                 case "$cf_name" in
1328                                 (*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";;
1329                                 (*.xz)  MANPAGE_FORMAT="$MANPAGE_FORMAT xz";;
1330                                 (*.gz)  MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
1331                                 (*.Z)   MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
1332                                 (*.0)   MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
1333                                 (*)     MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
1334                                 esac
1335
1336                                 case "$cf_name" in
1337                                 ($cf_dir/man*)
1338                                         cf_catonly=no
1339                                         ;;
1340                                 ($cf_dir/cat*)
1341                                         cf_preform=yes
1342                                         ;;
1343                                 esac
1344                                 break
1345                         fi
1346
1347                         # if we found a match in either man* or cat*, stop looking
1348                         if test -n "$MANPAGE_FORMAT" ; then
1349                                 cf_found=no
1350                                 test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
1351                                 test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
1352                                 case "$cf_name" in
1353                                 ($cf_dir/cat*)
1354                                         cf_found=yes
1355                                         ;;
1356                                 esac
1357                                 test "$cf_found" = yes && break
1358                         fi
1359                 done
1360                 # only check the first directory in $MANPATH where we find manpages
1361                 if test -n "$MANPAGE_FORMAT" ; then
1362                         break
1363                 fi
1364         done
1365         # if we did not find the example, just assume it is normal
1366         test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
1367         IFS="$ac_save_ifs"
1368         ;;
1369 (*)
1370         for cf_option in $MANPAGE_FORMAT; do
1371         case "$cf_option" in
1372         (xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly)
1373                 ;;
1374         (*)
1375                 cf_unknown="$cf_unknown $cf_option"
1376                 ;;
1377         esac
1378         done
1379         ;;
1380 esac
1381
1382 AC_MSG_RESULT($MANPAGE_FORMAT)
1383 if test -n "$cf_unknown" ; then
1384         AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
1385 fi
1386
1387 cf_manpage_format=no
1388 cf_manpage_inboth=no
1389 cf_manpage_so_strip=
1390 cf_manpage_compress=
1391
1392 for cf_item in $MANPAGE_FORMAT
1393 do
1394 case "$cf_item" in
1395 (catonly)
1396         cf_manpage_format=yes
1397         cf_manpage_inboth=no
1398         ;;
1399 (formatted)
1400         cf_manpage_format=yes
1401         cf_manpage_inboth=yes
1402         ;;
1403 (compress)
1404         cf_manpage_so_strip="Z"
1405         cf_manpage_compress=compress
1406         ;;
1407 (gzip)
1408         cf_manpage_so_strip="gz"
1409         cf_manpage_compress=gzip
1410         ;;
1411 (bzip2)
1412         cf_manpage_so_strip="bz2"
1413         cf_manpage_compress=bzip2
1414         ;;
1415 (xz)
1416         cf_manpage_so_strip="xz"
1417         cf_manpage_compress=xz
1418         ;;
1419 esac
1420 done
1421
1422 AC_SUBST(cf_manpage_format)
1423 AC_SUBST(cf_manpage_inboth)
1424 AC_SUBST(cf_manpage_so_strip)
1425 AC_SUBST(cf_manpage_compress)
1426
1427 ])dnl
1428 dnl ---------------------------------------------------------------------------
1429 dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
1430 dnl ----------------------
1431 dnl Check if the file-system supports mixed-case filenames.  If we're able to
1432 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1433 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1434 [
1435 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1436 if test "$cross_compiling" = yes ; then
1437         case "$target_alias" in
1438         (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
1439                 cf_cv_mixedcase=no
1440                 ;;
1441         (*)
1442                 cf_cv_mixedcase=yes
1443                 ;;
1444         esac
1445 else
1446         rm -f conftest CONFTEST
1447         echo test >conftest
1448         if test -f CONFTEST ; then
1449                 cf_cv_mixedcase=no
1450         else
1451                 cf_cv_mixedcase=yes
1452         fi
1453         rm -f conftest CONFTEST
1454 fi
1455 ])
1456 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1457 ])dnl
1458 dnl ---------------------------------------------------------------------------
1459 dnl CF_MKSTEMP version: 12 updated: 2023/01/05 17:53:11
1460 dnl ----------
1461 dnl Check for a working mkstemp.  This creates two files, checks that they are
1462 dnl successfully created and distinct (AmigaOS apparently fails on the last).
1463 AC_DEFUN([CF_MKSTEMP],[
1464 AC_CHECK_HEADERS( \
1465 unistd.h \
1466 )
1467 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
1468 rm -rf ./conftest*
1469 AC_TRY_RUN([
1470 $ac_includes_default
1471
1472 int main(void)
1473 {
1474         char *tmpl = "conftestXXXXXX";
1475         char name[2][80];
1476         int n;
1477         int result = 0;
1478         int fd;
1479         struct stat sb;
1480
1481         umask(077);
1482         for (n = 0; n < 2; ++n) {
1483                 strcpy(name[n], tmpl);
1484                 if ((fd = mkstemp(name[n])) >= 0) {
1485                         if (!strcmp(name[n], tmpl)
1486                          || stat(name[n], &sb) != 0
1487                          || (sb.st_mode & S_IFMT) != S_IFREG
1488                          || (sb.st_mode & 077) != 0) {
1489                                 result = 1;
1490                         }
1491                         close(fd);
1492                 }
1493         }
1494         if (result == 0
1495          && !strcmp(name[0], name[1]))
1496                 result = 1;
1497         ${cf_cv_main_return:-return}(result);
1498 }
1499 ],[cf_cv_func_mkstemp=yes
1500 ],[cf_cv_func_mkstemp=no
1501 ],[cf_cv_func_mkstemp=maybe])
1502 ])
1503 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
1504         AC_CHECK_FUNC(mkstemp)
1505 fi
1506 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
1507         AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
1508 fi
1509 ])dnl
1510 dnl ---------------------------------------------------------------------------
1511 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1512 dnl ----------
1513 dnl Write a debug message to config.log, along with the line number in the
1514 dnl configure script.
1515 AC_DEFUN([CF_MSG_LOG],[
1516 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1517 ])dnl
1518 dnl ---------------------------------------------------------------------------
1519 dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
1520 dnl ------------------
1521 dnl see CF_WITH_NO_LEAKS
1522 dnl
1523 dnl $1 = option/name
1524 dnl $2 = help-text
1525 dnl $3 = symbol to define if the option is set
1526 dnl $4 = additional actions to take if the option is set
1527 AC_DEFUN([CF_NO_LEAKS_OPTION],[
1528 AC_MSG_CHECKING(if you want to use $1 for testing)
1529 AC_ARG_WITH($1,
1530         [$2],
1531         [case "x$withval" in
1532         (x|xno) ;;
1533         (*)
1534                 : "${with_cflags:=-g}"
1535                 : "${enable_leaks:=no}"
1536                 with_$1=yes
1537                 AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1538          $4
1539 ])
1540                 ;;
1541         esac],
1542         [with_$1=])
1543 AC_MSG_RESULT(${with_$1:-no})
1544
1545 case ".$with_cflags" in
1546 (.*-g*)
1547         case .$CFLAGS in
1548         (.*-g*)
1549                 ;;
1550         (*)
1551                 CF_ADD_CFLAGS([-g])
1552                 ;;
1553         esac
1554         ;;
1555 esac
1556 ])dnl
1557 dnl ---------------------------------------------------------------------------
1558 dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
1559 dnl ----------
1560 dnl Provide a value for the $PATH and similar separator (or amend the value
1561 dnl as provided in autoconf 2.5x).
1562 AC_DEFUN([CF_PATHSEP],
1563 [
1564         AC_MSG_CHECKING(for PATH separator)
1565         case "$cf_cv_system_name" in
1566         (os2*)  PATH_SEPARATOR=';'  ;;
1567         (*)     ${PATH_SEPARATOR:=':'}  ;;
1568         esac
1569 ifelse([$1],,,[$1=$PATH_SEPARATOR])
1570         AC_SUBST(PATH_SEPARATOR)
1571         AC_MSG_RESULT($PATH_SEPARATOR)
1572 ])dnl
1573 dnl ---------------------------------------------------------------------------
1574 dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
1575 dnl --------------
1576 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1577 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1578 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1579 dnl delayed evaluation of those symbols.
1580 AC_DEFUN([CF_PATH_SYNTAX],[
1581 if test "x$prefix" != xNONE; then
1582         cf_path_syntax="$prefix"
1583 else
1584         cf_path_syntax="$ac_default_prefix"
1585 fi
1586
1587 case ".[$]$1" in
1588 (.\[$]\(*\)*|.\'*\'*)
1589         ;;
1590 (..|./*|.\\*)
1591         ;;
1592 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1593         ;;
1594 (.\[$]\{*prefix\}*|.\[$]\{*dir\}*)
1595         eval $1="[$]$1"
1596         case ".[$]$1" in
1597         (.NONE/*)
1598                 $1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
1599                 ;;
1600         esac
1601         ;;
1602 (.no|.NONE/*)
1603         $1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
1604         ;;
1605 (*)
1606         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1607         ;;
1608 esac
1609 ])dnl
1610 dnl ---------------------------------------------------------------------------
1611 dnl CF_POSIX_C_SOURCE version: 12 updated: 2023/02/18 17:41:25
1612 dnl -----------------
1613 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1614 dnl
1615 dnl     POSIX.1-1990                            _POSIX_SOURCE
1616 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
1617 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
1618 dnl             Bindings Option
1619 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
1620 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
1621 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
1622 dnl
1623 dnl Parameters:
1624 dnl     $1 is the nominal value for _POSIX_C_SOURCE
1625 AC_DEFUN([CF_POSIX_C_SOURCE],
1626 [AC_REQUIRE([CF_POSIX_VISIBLE])dnl
1627
1628 if test "$cf_cv_posix_visible" = no; then
1629
1630 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1631
1632 cf_save_CFLAGS="$CFLAGS"
1633 cf_save_CPPFLAGS="$CPPFLAGS"
1634
1635 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1636 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1637
1638 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1639         CF_MSG_LOG(if the symbol is already defined go no further)
1640         AC_TRY_COMPILE([#include <sys/types.h>],[
1641 #ifndef _POSIX_C_SOURCE
1642 #error _POSIX_C_SOURCE is not defined
1643 #endif],
1644         [cf_cv_posix_c_source=no],
1645         [cf_want_posix_source=no
1646          case .$cf_POSIX_C_SOURCE in
1647          (.[[12]]??*)
1648                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1649                 ;;
1650          (.2)
1651                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1652                 cf_want_posix_source=yes
1653                 ;;
1654          (.*)
1655                 cf_want_posix_source=yes
1656                 ;;
1657          esac
1658          if test "$cf_want_posix_source" = yes ; then
1659                 AC_TRY_COMPILE([#include <sys/types.h>],[
1660 #ifdef _POSIX_SOURCE
1661 #error _POSIX_SOURCE is defined
1662 #endif],[],
1663                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1664          fi
1665          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1666          CFLAGS="$cf_trim_CFLAGS"
1667          CPPFLAGS="$cf_trim_CPPFLAGS"
1668          CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
1669          CF_MSG_LOG(if the second compile does not leave our definition intact error)
1670          AC_TRY_COMPILE([#include <sys/types.h>],[
1671 #ifndef _POSIX_C_SOURCE
1672 #error _POSIX_C_SOURCE is not defined
1673 #endif],,
1674          [cf_cv_posix_c_source=no])
1675          CFLAGS="$cf_save_CFLAGS"
1676          CPPFLAGS="$cf_save_CPPFLAGS"
1677         ])
1678 ])
1679
1680 if test "$cf_cv_posix_c_source" != no ; then
1681         CFLAGS="$cf_trim_CFLAGS"
1682         CPPFLAGS="$cf_trim_CPPFLAGS"
1683         CF_ADD_CFLAGS($cf_cv_posix_c_source)
1684 fi
1685
1686 fi # cf_cv_posix_visible
1687
1688 ])dnl
1689 dnl ---------------------------------------------------------------------------
1690 dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
1691 dnl ----------------
1692 dnl POSIX documents test-macros which an application may set before any system
1693 dnl headers are included to make features available.
1694 dnl
1695 dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
1696 dnl diverged from POSIX in 2002 by setting symbols which make all of the most
1697 dnl recent features visible in the system header files unless the application
1698 dnl overrides the corresponding test-macros.  Doing that introduces portability
1699 dnl problems.
1700 dnl
1701 dnl This macro makes a special check for the symbols used for this, to avoid a
1702 dnl conflicting definition.
1703 AC_DEFUN([CF_POSIX_VISIBLE],
1704 [
1705 AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
1706 AC_TRY_COMPILE([#include <stdio.h>],[
1707 #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
1708         && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
1709         && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
1710         && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
1711 #error conflicting symbols found
1712 #endif
1713 ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
1714 ])
1715 ])dnl
1716 dnl ---------------------------------------------------------------------------
1717 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
1718 dnl -----------
1719 dnl Check for awk, ensure that the check found something.
1720 AC_DEFUN([CF_PROG_AWK],
1721 [
1722 AC_PROG_AWK
1723 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
1724 ])dnl
1725 dnl ---------------------------------------------------------------------------
1726 dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
1727 dnl ----------
1728 dnl standard check for CC, plus followup sanity checks
1729 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1730 AC_DEFUN([CF_PROG_CC],[
1731 CF_ACVERSION_CHECK(2.53,
1732         [AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
1733          AC_REQUIRE([AC_PROG_CC])],
1734         [])
1735 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1736 CF_GCC_VERSION
1737 CF_ACVERSION_CHECK(2.52,
1738         [AC_PROG_CC_STDC],
1739         [CF_ANSI_CC_REQD])
1740 CF_CC_ENV_FLAGS
1741 ])dnl
1742 dnl ---------------------------------------------------------------------------
1743 dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
1744 dnl -------------
1745 dnl Check if groff is available, for cases (such as html output) where nroff
1746 dnl is not enough.
1747 AC_DEFUN([CF_PROG_GROFF],[
1748 AC_PATH_PROG(GROFF_PATH,groff,no)
1749 AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
1750 AC_PATH_PROG(TBL_PATH,tbl,cat)
1751 if test "x$GROFF_PATH" = xno
1752 then
1753         NROFF_NOTE=
1754         GROFF_NOTE="#"
1755 else
1756         NROFF_NOTE="#"
1757         GROFF_NOTE=
1758 fi
1759 AC_SUBST(GROFF_NOTE)
1760 AC_SUBST(NROFF_NOTE)
1761 ])dnl
1762 dnl ---------------------------------------------------------------------------
1763 dnl CF_PROG_LINT version: 5 updated: 2022/08/20 15:44:13
1764 dnl ------------
1765 AC_DEFUN([CF_PROG_LINT],
1766 [
1767 AC_CHECK_PROGS(LINT, lint cppcheck splint)
1768 case "x$LINT" in
1769 (xcppcheck|x*/cppcheck)
1770         test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
1771         ;;
1772 esac
1773 AC_SUBST(LINT_OPTS)
1774 AC_SUBST(LINT_LIBS)
1775 ])dnl
1776 dnl ---------------------------------------------------------------------------
1777 dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40
1778 dnl ----------------
1779 dnl Remove a given option from CFLAGS/CPPFLAGS
1780 dnl $1 = option to remove
1781 dnl $2 = variable to update
1782 dnl $3 = nonempty to allow verbose message
1783 define([CF_REMOVE_CFLAGS],
1784 [
1785 cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'`
1786 while true
1787 do
1788         cf_old_cflag=`echo "x[$]$2" | sed -e 's/^.//' -e 's/[[  ]][[    ]]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[[^   ]][[^   ]]*\\)\?%%" -e 's/^[[   ]]*//' -e 's%[[ ]][[ ]]*-D% -D%g' -e 's%[[ ]][[ ]]*-I% -I%g'`
1789         test "[$]$2" != "$cf_old_cflag" || break
1790         ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)])
1791         $2="$cf_old_cflag"
1792 done
1793 ])dnl
1794 dnl ---------------------------------------------------------------------------
1795 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1796 dnl ----------------
1797 dnl Remove all -U and -D options that refer to the given symbol from a list
1798 dnl of C compiler options.  This works around the problem that not all
1799 dnl compilers process -U and -D options from left-to-right, so a -U option
1800 dnl cannot be used to cancel the effect of a preceding -D option.
1801 dnl
1802 dnl $1 = target (which could be the same as the source variable)
1803 dnl $2 = source (including '$')
1804 dnl $3 = symbol to remove
1805 define([CF_REMOVE_DEFINE],
1806 [
1807 $1=`echo "$2" | \
1808         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
1809                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
1810 ])dnl
1811 dnl ---------------------------------------------------------------------------
1812 dnl CF_TRY_XOPEN_SOURCE version: 4 updated: 2022/09/10 15:16:16
1813 dnl -------------------
1814 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1815 dnl can define it successfully.
1816 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1817 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1818         AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
1819         [cf_cv_xopen_source=no],
1820         [cf_save="$CPPFLAGS"
1821          CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
1822          AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
1823                 [cf_cv_xopen_source=no],
1824                 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1825                 CPPFLAGS="$cf_save"
1826         ])
1827 ])
1828
1829 if test "$cf_cv_xopen_source" != no ; then
1830         CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1831         CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1832         cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1833         CF_APPEND_CFLAGS($cf_temp_xopen_source)
1834 fi
1835 ])
1836 dnl ---------------------------------------------------------------------------
1837 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1838 dnl --------
1839 dnl Make an uppercase version of a variable
1840 dnl $1=uppercase($2)
1841 AC_DEFUN([CF_UPPER],
1842 [
1843 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1844 ])dnl
1845 dnl ---------------------------------------------------------------------------
1846 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1847 dnl ----------
1848 dnl Use AC_VERBOSE w/o the warnings
1849 AC_DEFUN([CF_VERBOSE],
1850 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
1851 CF_MSG_LOG([$1])
1852 ])dnl
1853 dnl ---------------------------------------------------------------------------
1854 dnl CF_WITHOUT_X version: 3 updated: 2021/01/13 16:51:52
1855 dnl ------------
1856 dnl Use this to cancel the check for X headers/libraries which would be pulled
1857 dnl in via CF_GCC_WARNINGS.
1858 define([CF_WITHOUT_X],
1859 AC_DEFUN([AC_PATH_XTRA],[])
1860 AC_DEFUN([CF_SAVE_XTRA_FLAGS],[])
1861 AC_DEFUN([CF_RESTORE_XTRA_FLAGS],[])
1862 AC_DEFUN([CF_CONST_X_STRING],[echo "skipping X-const check";])dnl
1863 AC_SUBST(X_CFLAGS)
1864 AC_SUBST(X_LIBS)
1865 [])dnl
1866 dnl ---------------------------------------------------------------------------
1867 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1868 dnl ----------------
1869 dnl Configure-option for dbmalloc.  The optional parameter is used to override
1870 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1871 AC_DEFUN([CF_WITH_DBMALLOC],[
1872 CF_NO_LEAKS_OPTION(dbmalloc,
1873         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
1874         [USE_DBMALLOC])
1875
1876 if test "$with_dbmalloc" = yes ; then
1877         AC_CHECK_HEADER(dbmalloc.h,
1878                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1879 fi
1880 ])dnl
1881 dnl ---------------------------------------------------------------------------
1882 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1883 dnl ---------------
1884 dnl Configure-option for dmalloc.  The optional parameter is used to override
1885 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1886 AC_DEFUN([CF_WITH_DMALLOC],[
1887 CF_NO_LEAKS_OPTION(dmalloc,
1888         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
1889         [USE_DMALLOC])
1890
1891 if test "$with_dmalloc" = yes ; then
1892         AC_CHECK_HEADER(dmalloc.h,
1893                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1894 fi
1895 ])dnl
1896 dnl ---------------------------------------------------------------------------
1897 dnl CF_WITH_MAN2HTML version: 12 updated: 2021/01/03 18:30:50
1898 dnl ----------------
1899 dnl Check for man2html and groff.  Prefer man2html over groff, but use groff
1900 dnl as a fallback.  See
1901 dnl
1902 dnl             http://invisible-island.net/scripts/man2html.html
1903 dnl
1904 dnl Generate a shell script which hides the differences between the two.
1905 dnl
1906 dnl We name that "man2html.tmp".
1907 dnl
1908 dnl The shell script can be removed later, e.g., using "make distclean".
1909 AC_DEFUN([CF_WITH_MAN2HTML],[
1910 AC_REQUIRE([CF_PROG_GROFF])dnl
1911 AC_REQUIRE([AC_PROG_FGREP])dnl
1912
1913 case "x${with_man2html}" in
1914 (xno)
1915         cf_man2html=no
1916         ;;
1917 (x|xyes)
1918         AC_PATH_PROG(cf_man2html,man2html,no)
1919         case "x$cf_man2html" in
1920         (x/*)
1921                 AC_MSG_CHECKING(for the modified Earl Hood script)
1922                 if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
1923                 then
1924                         cf_man2html_ok=yes
1925                 else
1926                         cf_man2html=no
1927                         cf_man2html_ok=no
1928                 fi
1929                 AC_MSG_RESULT($cf_man2html_ok)
1930                 ;;
1931         (*)
1932                 cf_man2html=no
1933                 ;;
1934         esac
1935 esac
1936
1937 AC_MSG_CHECKING(for program to convert manpage to html)
1938 AC_ARG_WITH(man2html,
1939         [  --with-man2html=XXX     use XXX rather than groff],
1940         [cf_man2html=$withval],
1941         [cf_man2html=$cf_man2html])
1942
1943 cf_with_groff=no
1944
1945 case $cf_man2html in
1946 (yes)
1947         AC_MSG_RESULT(man2html)
1948         AC_PATH_PROG(cf_man2html,man2html,no)
1949         ;;
1950 (no|groff|*/groff*)
1951         cf_with_groff=yes
1952         cf_man2html=$GROFF_PATH
1953         AC_MSG_RESULT($cf_man2html)
1954         ;;
1955 (*)
1956         AC_MSG_RESULT($cf_man2html)
1957         ;;
1958 esac
1959
1960 MAN2HTML_TEMP="man2html.tmp"
1961         cat >$MAN2HTML_TEMP <<CF_EOF
1962 #!$SHELL
1963 # Temporary script generated by CF_WITH_MAN2HTML
1964 # Convert inputs to html, sending result to standard output.
1965 #
1966 # Parameters:
1967 # \${1} = rootname of file to convert
1968 # \${2} = suffix of file to convert, e.g., "1"
1969 # \${3} = macros to use, e.g., "man"
1970 #
1971 ROOT=\[$]1
1972 TYPE=\[$]2
1973 MACS=\[$]3
1974
1975 unset LANG
1976 unset LC_ALL
1977 unset LC_CTYPE
1978 unset LANGUAGE
1979 GROFF_NO_SGR=stupid
1980 export GROFF_NO_SGR
1981
1982 CF_EOF
1983
1984 NROFF_OPTS=
1985 if test "x$cf_with_groff" = xyes
1986 then
1987         MAN2HTML_NOTE="$GROFF_NOTE"
1988         MAN2HTML_PATH="$GROFF_PATH"
1989         cat >>$MAN2HTML_TEMP <<CF_EOF
1990 $SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
1991 CF_EOF
1992 else
1993         # disable hyphenation if this is groff
1994         if test "x$GROFF_PATH" != xno
1995         then
1996                 AC_MSG_CHECKING(if nroff is really groff)
1997                 cf_check_groff="`$NROFF_PATH --version 2>/dev/null | grep groff`"
1998                 test -n "$cf_check_groff" && cf_check_groff=yes
1999                 test -n "$cf_check_groff" || cf_check_groff=no
2000                 AC_MSG_RESULT($cf_check_groff)
2001                 test "x$cf_check_groff" = xyes && NROFF_OPTS="-rHY=0"
2002         fi
2003         MAN2HTML_NOTE=""
2004         CF_PATH_SYNTAX(cf_man2html)
2005         MAN2HTML_PATH="$cf_man2html"
2006         AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
2007
2008         # for this example, expect 3 lines of content, the remainder is head/foot
2009         cat >conftest.in <<CF_EOF
2010 .TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
2011 .SH SECTION
2012 MARKER
2013 CF_EOF
2014
2015         LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
2016
2017         cf_man2html_1st="`${FGREP-fgrep} -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
2018         cf_man2html_top=`expr "$cf_man2html_1st" - 2`
2019         cf_man2html_bot="`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`"
2020         cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"`
2021         cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
2022
2023         AC_MSG_RESULT($cf_man2html_top_bot)
2024
2025         AC_MSG_CHECKING(for pagesize to use)
2026         for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2027         do
2028         cat >>conftest.in <<CF_EOF
2029 .nf
2030 0
2031 1
2032 2
2033 3
2034 4
2035 5
2036 6
2037 7
2038 8
2039 9
2040 CF_EOF
2041         done
2042
2043         LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
2044         cf_man2html_page="`${FGREP-fgrep} -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
2045         test -z "$cf_man2html_page" && cf_man2html_page=99999
2046         test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
2047
2048         rm -rf conftest*
2049         AC_MSG_RESULT($cf_man2html_page)
2050
2051         cat >>$MAN2HTML_TEMP <<CF_EOF
2052 : \${MAN2HTML_PATH=$MAN2HTML_PATH}
2053 MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title=\"\$ROOT(\$TYPE)\" -compress -pgsize $cf_man2html_page"
2054 case \${TYPE} in
2055 (ms)
2056         $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
2057         ;;
2058 (*)
2059         $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
2060         ;;
2061 esac
2062 CF_EOF
2063 fi
2064
2065 chmod 700 $MAN2HTML_TEMP
2066
2067 AC_SUBST(MAN2HTML_NOTE)
2068 AC_SUBST(MAN2HTML_PATH)
2069 AC_SUBST(MAN2HTML_TEMP)
2070 ])dnl
2071 dnl ---------------------------------------------------------------------------
2072 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
2073 dnl ----------------
2074 AC_DEFUN([CF_WITH_VALGRIND],[
2075 CF_NO_LEAKS_OPTION(valgrind,
2076         [  --with-valgrind         test: use valgrind],
2077         [USE_VALGRIND])
2078 ])dnl
2079 dnl ---------------------------------------------------------------------------
2080 dnl CF_XOPEN_SOURCE version: 66 updated: 2023/04/03 04:19:37
2081 dnl ---------------
2082 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2083 dnl or adapt to the vendor's definitions to get equivalent functionality,
2084 dnl without losing the common non-POSIX features.
2085 dnl
2086 dnl Parameters:
2087 dnl     $1 is the nominal value for _XOPEN_SOURCE
2088 dnl     $2 is the nominal value for _POSIX_C_SOURCE
2089 dnl
2090 dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the
2091 dnl implementation predefines it, because X/Open and most implementations agree
2092 dnl that the latter is a legacy or "aligned" value.
2093 dnl
2094 dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns
2095 dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly.
2096 dnl
2097 dnl References:
2098 dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
2099 dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
2100 dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
2101 AC_DEFUN([CF_XOPEN_SOURCE],[
2102 AC_REQUIRE([AC_CANONICAL_HOST])
2103 AC_REQUIRE([CF_POSIX_VISIBLE])
2104
2105 if test "$cf_cv_posix_visible" = no; then
2106
2107 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
2108 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
2109 cf_xopen_source=
2110
2111 case "$host_os" in
2112 (aix[[4-7]]*)
2113         cf_xopen_source="-D_ALL_SOURCE"
2114         ;;
2115 (darwin[[0-8]].*)
2116         cf_xopen_source="-D_APPLE_C_SOURCE"
2117         ;;
2118 (darwin*)
2119         cf_xopen_source="-D_DARWIN_C_SOURCE"
2120         cf_XOPEN_SOURCE=
2121         ;;
2122 (freebsd*|dragonfly*|midnightbsd*)
2123         # 5.x headers associate
2124         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2125         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2126         cf_POSIX_C_SOURCE=200112L
2127         cf_XOPEN_SOURCE=600
2128         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2129         ;;
2130 (hpux11*)
2131         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
2132         ;;
2133 (hpux*)
2134         cf_xopen_source="-D_HPUX_SOURCE"
2135         ;;
2136 (irix[[56]].*)
2137         cf_xopen_source="-D_SGI_SOURCE"
2138         cf_XOPEN_SOURCE=
2139         ;;
2140 (linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*)
2141         CF_GNU_SOURCE($cf_XOPEN_SOURCE)
2142         ;;
2143 (minix*)
2144         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
2145         ;;
2146 (mirbsd*)
2147         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
2148         cf_XOPEN_SOURCE=
2149         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2150         ;;
2151 (netbsd*)
2152         cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2153         ;;
2154 (openbsd[[6-9]]*)
2155         # OpenBSD 6.x has broken locale support, both compile-time and runtime.
2156         # see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
2157         # Abusing the conformance level is a workaround.
2158         AC_MSG_WARN(this system does not provide usable locale support)
2159         cf_xopen_source="-D_BSD_SOURCE"
2160         cf_XOPEN_SOURCE=700
2161         ;;
2162 (openbsd[[4-5]]*)
2163         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
2164         cf_xopen_source="-D_BSD_SOURCE"
2165         cf_XOPEN_SOURCE=600
2166         ;;
2167 (openbsd*)
2168         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2169         ;;
2170 (osf[[45]]*)
2171         cf_xopen_source="-D_OSF_SOURCE"
2172         ;;
2173 (nto-qnx*)
2174         cf_xopen_source="-D_QNX_SOURCE"
2175         ;;
2176 (sco*)
2177         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2178         ;;
2179 (solaris2.*)
2180         cf_xopen_source="-D__EXTENSIONS__"
2181         cf_cv_xopen_source=broken
2182         ;;
2183 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
2184         cf_XOPEN_SOURCE=
2185         cf_POSIX_C_SOURCE=
2186         ;;
2187 (*)
2188         CF_TRY_XOPEN_SOURCE
2189         cf_save_xopen_cppflags="$CPPFLAGS"
2190         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2191         # Some of these niche implementations use copy/paste, double-check...
2192         if test "$cf_cv_xopen_source" = no ; then
2193                 CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE)
2194                 AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[
2195                         AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable)
2196                         CPPFLAGS="$cf_save_xopen_cppflags"])
2197         fi
2198         ;;
2199 esac
2200
2201 if test -n "$cf_xopen_source" ; then
2202         CF_APPEND_CFLAGS($cf_xopen_source,true)
2203 fi
2204
2205 dnl In anything but the default case, we may have system-specific setting
2206 dnl which is still not guaranteed to provide all of the entrypoints that
2207 dnl _XOPEN_SOURCE would yield.
2208 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
2209         AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
2210         AC_TRY_COMPILE([#include <stdlib.h>],[
2211 #ifndef _XOPEN_SOURCE
2212 #error _XOPEN_SOURCE is not defined
2213 #endif],
2214         [cf_XOPEN_SOURCE_set=yes],
2215         [cf_XOPEN_SOURCE_set=no])
2216         AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
2217         if test "$cf_XOPEN_SOURCE_set" = yes
2218         then
2219                 AC_TRY_COMPILE([#include <stdlib.h>],[
2220 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
2221 #error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
2222 #endif],
2223                 [cf_XOPEN_SOURCE_set_ok=yes],
2224                 [cf_XOPEN_SOURCE_set_ok=no])
2225                 if test "$cf_XOPEN_SOURCE_set_ok" = no
2226                 then
2227                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
2228                 fi
2229         else
2230                 CF_TRY_XOPEN_SOURCE
2231         fi
2232 fi
2233 fi # cf_cv_posix_visible
2234 ])
2235 dnl ---------------------------------------------------------------------------
2236 dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25
2237 dnl ---------------------
2238 dnl body of test when test-compiling for _XOPEN_SOURCE check
2239 define([CF__XOPEN_SOURCE_BODY],
2240 [
2241 #ifndef _XOPEN_SOURCE
2242 #error _XOPEN_SOURCE is not defined
2243 #endif
2244 ])
2245 dnl ---------------------------------------------------------------------------
2246 dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25
2247 dnl ---------------------
2248 dnl headers to include when test-compiling for _XOPEN_SOURCE check
2249 define([CF__XOPEN_SOURCE_HEAD],
2250 [
2251 $ac_includes_default
2252 ])