Debian Codegraph @

aclocal.m4

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