]> ncurses.scripts.mit.edu Git - ncurses.git/blob - aclocal.m4
c78c13830858c3d33976440117d4312117766126
[ncurses.git] / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright 2018-2020,2021 Thomas E. Dickey                                *
3 dnl Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
4 dnl                                                                          *
5 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
6 dnl copy of this software and associated documentation files (the            *
7 dnl "Software"), to deal in the Software without restriction, including      *
8 dnl without limitation the rights to use, copy, modify, merge, publish,      *
9 dnl distribute, distribute with modifications, sublicense, and/or sell       *
10 dnl copies of the Software, and to permit persons to whom the Software is    *
11 dnl furnished to do so, subject to the following conditions:                 *
12 dnl                                                                          *
13 dnl The above copyright notice and this permission notice shall be included  *
14 dnl in all copies or substantial portions of the Software.                   *
15 dnl                                                                          *
16 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 dnl                                                                          *
24 dnl Except as contained in this notice, the name(s) of the above copyright   *
25 dnl holders shall not be used in advertising or otherwise to promote the     *
26 dnl sale, use or other dealings in this Software without prior written       *
27 dnl authorization.                                                           *
28 dnl***************************************************************************
29 dnl
30 dnl Author: Thomas E. Dickey 1995-on
31 dnl
32 dnl $Id: aclocal.m4,v 1.975 2021/09/04 10:36:30 tom Exp $
33 dnl Macros used in NCURSES auto-configuration script.
34 dnl
35 dnl These macros are maintained separately from NCURSES.  The copyright on
36 dnl this file applies to the aggregation of macros and does not affect use of
37 dnl these macros in other applications.
38 dnl
39 dnl See these pages for additional information:
40 dnl             https://invisible-island.net/autoconf/
41 dnl             https://invisible-island.net/autoconf/my-autoconf.html
42 dnl
43 dnl ---------------------------------------------------------------------------
44 dnl ---------------------------------------------------------------------------
45 dnl AM_LANGINFO_CODESET version: 6 updated: 2021/01/01 16:53:59
46 dnl -------------------
47 dnl Inserted as requested by gettext 0.10.40
48 dnl File from /usr/share/aclocal
49 dnl codeset.m4
50 dnl ====================
51 dnl serial AM1
52 dnl
53 dnl From Bruno Haible.
54 AC_DEFUN([AM_LANGINFO_CODESET],
55 [
56 AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
57         [AC_TRY_LINK([#include <langinfo.h>],
58         [char* cs = nl_langinfo(CODESET); (void)cs],
59         am_cv_langinfo_codeset=yes,
60         am_cv_langinfo_codeset=no)
61         ])
62         if test "$am_cv_langinfo_codeset" = yes; then
63                 AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
64                 [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
65         fi
66 ])dnl
67 dnl ---------------------------------------------------------------------------
68 dnl CF_ABI_DEFAULTS version: 2 updated: 2015/06/06 13:49:58
69 dnl ---------------
70 dnl Provide configure-script defaults for different ncurses ABIs.
71 AC_DEFUN([CF_ABI_DEFAULTS],[
72 AC_REQUIRE([CF_NCURSES_WITH_ABI_VERSION])
73 case x$cf_cv_abi_version in
74 (x[[6789]])
75         cf_dft_ext_colors=yes
76         cf_dft_ext_const=yes
77         cf_dft_ext_mouse=yes
78         cf_dft_ext_putwin=yes
79         cf_dft_ext_spfuncs=yes
80         cf_dft_filter_syms=yes
81         cf_dft_chtype=uint32_t
82         cf_dft_mmask_t=uint32_t
83         cf_dft_interop=yes
84         cf_dft_tparm_arg=intptr_t
85         cf_dft_with_lp64=yes
86         ;;
87 (*)
88         cf_dft_ext_colors=no
89         cf_dft_ext_const=no
90         cf_dft_ext_mouse=no
91         cf_dft_ext_putwin=no
92         cf_dft_ext_spfuncs=no
93         cf_dft_filter_syms=no
94         cf_dft_chtype=auto
95         cf_dft_mmask_t=auto
96         cf_dft_interop=no
97         cf_dft_tparm_arg=long
98         cf_dft_with_lp64=no
99         ;;
100 esac
101 ])dnl
102 dnl ---------------------------------------------------------------------------
103 dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
104 dnl ------------------
105 dnl Conditionally generate script according to whether we're using a given autoconf.
106 dnl
107 dnl $1 = version to compare against
108 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
109 dnl $3 = code to use if AC_ACVERSION is older than $1.
110 define([CF_ACVERSION_CHECK],
111 [
112 ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
113 ifdef([m4_version_compare],
114 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
115 [CF_ACVERSION_COMPARE(
116 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
117 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
118 dnl ---------------------------------------------------------------------------
119 dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
120 dnl --------------------
121 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
122 dnl                      MAJOR2, MINOR2, TERNARY2,
123 dnl                      PRINTABLE2, not FOUND, FOUND)
124 define([CF_ACVERSION_COMPARE],
125 [ifelse(builtin([eval], [$2 < $5]), 1,
126 [ifelse([$8], , ,[$8])],
127 [ifelse([$9], , ,[$9])])])dnl
128 dnl ---------------------------------------------------------------------------
129 dnl CF_ADA_INCLUDE_DIRS version: 8 updated: 2013/10/14 04:24:07
130 dnl -------------------
131 dnl Construct the list of include-options for the C programs in the Ada95
132 dnl binding.
133 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
134 [
135 ACPPFLAGS="-I. -I../include -I../../include $ACPPFLAGS"
136 if test "$srcdir" != "."; then
137         ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
138 fi
139 if test "$GCC" != yes; then
140         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
141 elif test "$includedir" != "/usr/include"; then
142         if test "$includedir" = '${prefix}/include' ; then
143                 if test x$prefix != x/usr ; then
144                         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
145                 fi
146         else
147                 ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
148         fi
149 fi
150 AC_SUBST(ACPPFLAGS)
151 ])dnl
152 dnl ---------------------------------------------------------------------------
153 dnl CF_ADD_ADAFLAGS version: 1 updated: 2010/06/19 15:22:18
154 dnl ---------------
155 dnl Add to $ADAFLAGS, which is substituted into makefile and scripts.
156 AC_DEFUN([CF_ADD_ADAFLAGS],[
157         ADAFLAGS="$ADAFLAGS $1"
158         AC_SUBST(ADAFLAGS)
159 ])dnl
160 dnl ---------------------------------------------------------------------------
161 dnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15
162 dnl -------------
163 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
164 dnl $1 = flags to add
165 dnl $2 = if given makes this macro verbose.
166 dnl
167 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
168 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
169 dnl confused by the quotes (which require backslashes to keep them usable).
170 AC_DEFUN([CF_ADD_CFLAGS],
171 [
172 cf_fix_cppflags=no
173 cf_new_cflags=
174 cf_new_cppflags=
175 cf_new_extra_cppflags=
176
177 for cf_add_cflags in $1
178 do
179 case "$cf_fix_cppflags" in
180 (no)
181         case "$cf_add_cflags" in
182         (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
183                 case "$cf_add_cflags" in
184                 (-D*)
185                         cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
186
187                         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
188                                 && test -z "${cf_tst_cflags}" \
189                                 && cf_fix_cppflags=yes
190
191                         if test "$cf_fix_cppflags" = yes ; then
192                                 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
193                                 continue
194                         elif test "${cf_tst_cflags}" = "\"'" ; then
195                                 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
196                                 continue
197                         fi
198                         ;;
199                 esac
200                 case "$CPPFLAGS" in
201                 (*$cf_add_cflags)
202                         ;;
203                 (*)
204                         case "$cf_add_cflags" in
205                         (-D*)
206                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
207                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
208                                 ;;
209                         esac
210                         CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
211                         ;;
212                 esac
213                 ;;
214         (*)
215                 CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
216                 ;;
217         esac
218         ;;
219 (yes)
220         CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
221
222         cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'`
223
224         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
225                 && test -z "${cf_tst_cflags}" \
226                 && cf_fix_cppflags=no
227         ;;
228 esac
229 done
230
231 if test -n "$cf_new_cflags" ; then
232         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
233         CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
234 fi
235
236 if test -n "$cf_new_cppflags" ; then
237         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
238         CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
239 fi
240
241 if test -n "$cf_new_extra_cppflags" ; then
242         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
243         CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
244 fi
245
246 AC_SUBST(EXTRA_CPPFLAGS)
247
248 ])dnl
249 dnl ---------------------------------------------------------------------------
250 dnl CF_ADD_CXXFLAGS version: 1 updated: 2020/04/04 16:16:13
251 dnl ---------------
252 dnl Copy non-preprocessor flags to $CXXFLAGS, preprocessor flags to $CPPFLAGS
253 dnl The second parameter if given makes this macro verbose.
254 dnl
255 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
256 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
257 dnl confused by the quotes (which require backslashes to keep them usable).
258 AC_DEFUN([CF_ADD_CXXFLAGS],
259 [
260 cf_save_CXXFLAGS="$CFLAGS"
261 CFLAGS="$CXXFLAGS"
262 CF_ADD_CFLAGS($1 ifelse($2,,,[,$2]))
263 CXXFLAGS="$CFLAGS"
264 CFLAGS="$cf_save_CXXFLAGS"
265 ])dnl
266 dnl ---------------------------------------------------------------------------
267 dnl CF_ADD_INCDIR version: 17 updated: 2021/09/04 06:35:04
268 dnl -------------
269 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it is
270 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
271 dnl but old versions (and some misinstalled ones) need that.  To make things
272 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
273 dnl the include-path).
274 AC_DEFUN([CF_ADD_INCDIR],
275 [
276 if test -n "$1" ; then
277   for cf_add_incdir in $1
278   do
279         while test "$cf_add_incdir" != /usr/include
280         do
281           if test -d "$cf_add_incdir"
282           then
283                 cf_have_incdir=no
284                 if test -n "$CFLAGS$CPPFLAGS" ; then
285                   # a loop is needed to ensure we can add subdirs of existing dirs
286                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
287                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
288                           cf_have_incdir=yes; break
289                         fi
290                   done
291                 fi
292
293                 if test "$cf_have_incdir" = no ; then
294                   if test "$cf_add_incdir" = /usr/local/include ; then
295                         if test "$GCC" = yes
296                         then
297                           cf_save_CPPFLAGS=$CPPFLAGS
298                           CF_APPEND_TEXT(CPPFLAGS,-I$cf_add_incdir)
299                           AC_TRY_COMPILE([#include <stdio.h>],
300                                   [printf("Hello")],
301                                   [],
302                                   [cf_have_incdir=yes])
303                           CPPFLAGS=$cf_save_CPPFLAGS
304                         fi
305                   fi
306                 fi
307
308                 if test "$cf_have_incdir" = no ; then
309                   CF_VERBOSE(adding $cf_add_incdir to include-path)
310                   ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
311
312                   cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
313                   test "$cf_top_incdir" = "$cf_add_incdir" && break
314                   cf_add_incdir="$cf_top_incdir"
315                 else
316                   break
317                 fi
318           else
319                 break
320           fi
321         done
322   done
323 fi
324 ])dnl
325 dnl ---------------------------------------------------------------------------
326 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
327 dnl ----------
328 dnl Add a library, used to enforce consistency.
329 dnl
330 dnl $1 = library to add, without the "-l"
331 dnl $2 = variable to update (default $LIBS)
332 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
333 dnl ---------------------------------------------------------------------------
334 dnl CF_ADD_LIBDIR version: 11 updated: 2020/12/31 20:19:42
335 dnl -------------
336 dnl     Adds to the library-path
337 dnl
338 dnl     Some machines have trouble with multiple -L options.
339 dnl
340 dnl $1 is the (list of) directory(s) to add
341 dnl $2 is the optional name of the variable to update (default LDFLAGS)
342 dnl
343 AC_DEFUN([CF_ADD_LIBDIR],
344 [
345 if test -n "$1" ; then
346         for cf_add_libdir in $1
347         do
348                 if test "$cf_add_libdir" = /usr/lib ; then
349                         :
350                 elif test -d "$cf_add_libdir"
351                 then
352                         cf_have_libdir=no
353                         if test -n "$LDFLAGS$LIBS" ; then
354                                 # a loop is needed to ensure we can add subdirs of existing dirs
355                                 for cf_test_libdir in $LDFLAGS $LIBS ; do
356                                         if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
357                                                 cf_have_libdir=yes; break
358                                         fi
359                                 done
360                         fi
361                         if test "$cf_have_libdir" = no ; then
362                                 CF_VERBOSE(adding $cf_add_libdir to library-path)
363                                 ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
364                         fi
365                 fi
366         done
367 fi
368 ])dnl
369 dnl ---------------------------------------------------------------------------
370 dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33
371 dnl -----------
372 dnl Add one or more libraries, used to enforce consistency.  Libraries are
373 dnl prepended to an existing list, since their dependencies are assumed to
374 dnl already exist in the list.
375 dnl
376 dnl $1 = libraries to add, with the "-l", etc.
377 dnl $2 = variable to update (default $LIBS)
378 AC_DEFUN([CF_ADD_LIBS],[
379 cf_add_libs="[$]ifelse($2,,LIBS,[$2])"
380 # reverse order
381 cf_add_0lib=
382 for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
383 # filter duplicates
384 for cf_add_1lib in $cf_add_0lib; do
385         for cf_add_2lib in $cf_add_libs; do
386                 if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
387                         cf_add_1lib=
388                         break
389                 fi
390         done
391         test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
392 done
393 ifelse($2,,LIBS,[$2])="$cf_add_libs"
394 ])dnl
395 dnl ---------------------------------------------------------------------------
396 dnl CF_ADD_SUBDIR_PATH version: 5 updated: 2020/12/31 20:19:42
397 dnl ------------------
398 dnl Append to a search-list for a nonstandard header/lib-file
399 dnl     $1 = the variable to return as result
400 dnl     $2 = the package name
401 dnl     $3 = the subdirectory, e.g., bin, include or lib
402 dnl $4 = the directory under which we will test for subdirectories
403 dnl $5 = a directory that we do not want $4 to match
404 AC_DEFUN([CF_ADD_SUBDIR_PATH],
405 [
406 test "x$4" != "x$5" && \
407 test -d "$4" && \
408 ifelse([$5],NONE,,[{ test -z "$5" || test "x$5" = xNONE || test "x$4" != "x$5"; } &&]) {
409         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
410         test -d "$4/$3" &&          $1="[$]$1 $4/$3"
411         test -d "$4/$3/$2" &&       $1="[$]$1 $4/$3/$2"
412         test -d "$4/$3/$2/$3" &&    $1="[$]$1 $4/$3/$2/$3"
413         test -d "$4/$2/$3" &&       $1="[$]$1 $4/$2/$3"
414         test -d "$4/$2/$3/$2" &&    $1="[$]$1 $4/$2/$3/$2"
415 }
416 ])dnl
417 dnl ---------------------------------------------------------------------------
418 dnl CF_APPEND_CFLAGS version: 1 updated: 2021/08/28 15:20:37
419 dnl ----------------
420 dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions.
421 dnl $1 = flags to add
422 dnl $2 = if given makes this macro verbose.
423 define([CF_APPEND_CFLAGS],
424 [
425 for cf_add_cflags in $1
426 do
427         CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2])
428         CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2])
429 done
430 CF_ADD_CFLAGS([$1],[$2])
431 ])dnl
432 dnl ---------------------------------------------------------------------------
433 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
434 dnl --------------
435 dnl use this macro for appending text without introducing an extra blank at
436 dnl the beginning
437 define([CF_APPEND_TEXT],
438 [
439         test -n "[$]$1" && $1="[$]$1 "
440         $1="[$]{$1}$2"
441 ])dnl
442 dnl ---------------------------------------------------------------------------
443 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
444 dnl --------------
445 dnl Allow user to disable a normally-on option.
446 AC_DEFUN([CF_ARG_DISABLE],
447 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
448 dnl ---------------------------------------------------------------------------
449 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
450 dnl -------------
451 dnl Allow user to enable a normally-off option.
452 AC_DEFUN([CF_ARG_ENABLE],
453 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
454 dnl ---------------------------------------------------------------------------
455 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
456 dnl -------------
457 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
458 dnl values.
459 dnl
460 dnl Parameters:
461 dnl $1 = option name
462 dnl $2 = help-string
463 dnl $3 = action to perform if option is not default
464 dnl $4 = action if perform if option is default
465 dnl $5 = default option value (either 'yes' or 'no')
466 AC_DEFUN([CF_ARG_OPTION],
467 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
468         if test "$enableval" != "$5" ; then
469 ifelse([$3],,[    :]dnl
470 ,[    $3]) ifelse([$4],,,[
471         else
472                 $4])
473         fi],[enableval=$5 ifelse([$4],,,[
474         $4
475 ])dnl
476 ])])dnl
477 dnl ---------------------------------------------------------------------------
478 dnl CF_AR_FLAGS version: 9 updated: 2021/01/01 13:31:04
479 dnl -----------
480 dnl Check for suitable "ar" (archiver) options for updating an archive.
481 dnl
482 dnl In particular, handle some obsolete cases where the "-" might be omitted,
483 dnl as well as a workaround for breakage of make's archive rules by the GNU
484 dnl binutils "ar" program.
485 AC_DEFUN([CF_AR_FLAGS],[
486 AC_REQUIRE([CF_PROG_AR])
487
488 AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
489         case "$cf_cv_system_name" in
490         (*-msvc*)
491                 cf_cv_ar_flags=''
492                 cat >mk_static_lib.sh <<-EOF
493                 #!$SHELL
494                 MSVC_BIN="[$]AR"
495                 out="\[$]1"
496                 shift
497                 exec \[$]MSVC_BIN -out:"\[$]out" \[$]@
498                 EOF
499                 chmod +x mk_static_lib.sh
500                 AR=`pwd`/mk_static_lib.sh
501                 ;;
502         (*)
503                 cf_cv_ar_flags=unknown
504                 for cf_ar_flags in -curvU -curv curv -crv crv -cqv cqv -rv rv
505                 do
506
507                         # check if $ARFLAGS already contains this choice
508                         if test "x$ARFLAGS" != "x" ; then
509                                 cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
510                                 if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
511                                         cf_cv_ar_flags=
512                                         break
513                                 fi
514                         fi
515
516                         rm -f "conftest.$ac_cv_objext"
517                         rm -f conftest.a
518
519                         cat >"conftest.$ac_ext" <<EOF
520 #line __oline__ "configure"
521 int     testdata[[3]] = { 123, 456, 789 };
522 EOF
523                         if AC_TRY_EVAL(ac_compile) ; then
524                                 echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AC_FD_CC
525                                 $AR $ARFLAGS "$cf_ar_flags" conftest.a "conftest.$ac_cv_objext" 2>&AC_FD_CC 1>/dev/null
526                                 if test -f conftest.a ; then
527                                         cf_cv_ar_flags="$cf_ar_flags"
528                                         break
529                                 fi
530                         else
531                                 CF_VERBOSE(cannot compile test-program)
532                                 break
533                         fi
534                 done
535                 rm -f conftest.a "conftest.$ac_ext" "conftest.$ac_cv_objext"
536                 ;;
537         esac
538 ])
539
540 if test -n "$ARFLAGS" ; then
541         if test -n "$cf_cv_ar_flags" ; then
542                 ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
543         fi
544 else
545         ARFLAGS=$cf_cv_ar_flags
546 fi
547
548 AC_SUBST(ARFLAGS)
549 ])
550 dnl ---------------------------------------------------------------------------
551 dnl CF_AWK_BIG_PRINTF version: 5 updated: 2015/04/17 21:13:04
552 dnl -----------------
553 dnl Check if awk can handle big strings using printf.  Some older versions of
554 dnl awk choke on large strings passed via "%s".
555 dnl
556 dnl $1 = desired string size
557 dnl $2 = variable to set with result
558 AC_DEFUN([CF_AWK_BIG_PRINTF],
559 [
560         case x$AWK in
561         (x)
562                 eval $2=no
563                 ;;
564         (*)
565                 if ( ${AWK} 'BEGIN { xx = "x"; while (length(xx) < $1) { xx = xx "x"; }; printf("%s\n", xx); }' 2>/dev/null \
566                         | $AWK '{ printf "%d\n", length([$]0); }' 2>/dev/null | $AWK 'BEGIN { eqls=0; recs=0; } { recs++; if ([$]0 == 12000) eqls++; } END { if (recs != 1 || eqls != 1) exit 1; }' 2>/dev/null >/dev/null ) ; then
567                         eval $2=yes
568                 else
569                         eval $2=no
570                 fi
571                 ;;
572         esac
573 ])dnl
574 dnl ---------------------------------------------------------------------------
575 dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18
576 dnl ------------
577 dnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
578 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
579 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
580 dnl
581 dnl Treat the configuration-variable specially here, since we're directly
582 dnl substituting its value (i.e., 1/0).
583 dnl
584 dnl $1 is the shell variable to store the result in, if not $cv_cv_builtin_bool
585 AC_DEFUN([CF_BOOL_DECL],
586 [
587 AC_MSG_CHECKING(if we should include stdbool.h)
588
589 AC_CACHE_VAL(cf_cv_header_stdbool_h,[
590         AC_TRY_COMPILE([],[bool foo = false],
591                 [cf_cv_header_stdbool_h=0],
592                 [AC_TRY_COMPILE([
593 #ifndef __BEOS__
594 #include <stdbool.h>
595 #endif
596 ],[bool foo = false],
597                         [cf_cv_header_stdbool_h=1],
598                         [cf_cv_header_stdbool_h=0])])])
599
600 if test "$cf_cv_header_stdbool_h" = 1
601 then    AC_MSG_RESULT(yes)
602 else    AC_MSG_RESULT(no)
603 fi
604
605 AC_MSG_CHECKING([for builtin bool type])
606
607 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
608         AC_TRY_COMPILE([
609 #include <stdio.h>
610 #include <sys/types.h>
611 ],[bool x = false],
612                 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
613                 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
614         ])
615
616 if test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1
617 then    AC_MSG_RESULT(yes)
618 else    AC_MSG_RESULT(no)
619 fi
620 ])dnl
621 dnl ---------------------------------------------------------------------------
622 dnl CF_BOOL_SIZE version: 18 updated: 2021/09/04 06:35:04
623 dnl ------------
624 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
625 dnl Don't bother looking for bool.h, since it has been deprecated.
626 dnl
627 dnl If the current compiler is C rather than C++, we get the bool definition
628 dnl from <stdbool.h>.
629 AC_DEFUN([CF_BOOL_SIZE],
630 [
631 AC_CHECK_SIZEOF(bool,,[
632 #include <stdlib.h>
633 #include <stdio.h>
634
635 #if defined(__cplusplus)
636
637 #ifdef HAVE_GXX_BUILTIN_H
638 #include <g++/builtin.h>
639 #elif HAVE_GPP_BUILTIN_H
640 #include <gpp/builtin.h>
641 #elif HAVE_BUILTIN_H
642 #include <builtin.h>
643 #endif
644
645 #else
646
647 #if $cf_cv_header_stdbool_h
648 #include <stdbool.h>
649 #endif
650
651 #endif
652 ])
653
654 AC_CACHE_CHECK(for type of bool, cf_cv_type_of_bool,[
655         rm -f cf_test.out
656         AC_TRY_RUN([
657 #include <stdlib.h>
658 #include <stdio.h>
659
660 #if defined(__cplusplus)
661
662 #ifdef HAVE_GXX_BUILTIN_H
663 #include <g++/builtin.h>
664 #elif HAVE_GPP_BUILTIN_H
665 #include <gpp/builtin.h>
666 #elif HAVE_BUILTIN_H
667 #include <builtin.h>
668 #endif
669
670 #else
671
672 #if $cf_cv_header_stdbool_h
673 #include <stdbool.h>
674 #endif
675
676 #endif
677
678 int main(void)
679 {
680         FILE *fp = fopen("cf_test.out", "w");
681         if (fp != 0) {
682                 bool x = true;
683                 if ((bool)(-x) >= 0)
684                         fputs("unsigned ", fp);
685                 if (sizeof(x) == sizeof(int))       fputs("int",  fp);
686                 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
687                 else if (sizeof(x) == sizeof(short))fputs("short",fp);
688                 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
689                 fclose(fp);
690         }
691         ${cf_cv_main_return:-return}(0);
692 }
693                 ],
694                 [cf_cv_type_of_bool=`cat cf_test.out`
695                  if test -z "$cf_cv_type_of_bool"; then
696                    cf_cv_type_of_bool=unknown
697                  fi],
698                 [cf_cv_type_of_bool=unknown],
699                 [
700                 case x$ac_cv_sizeof_bool in
701                 (x1) cf_cv_type_of_bool="unsigned char";;
702                 (x2) cf_cv_type_of_bool="unsigned short";;
703                 (x4) cf_cv_type_of_bool="unsigned int";;
704                 (x8) cf_cv_type_of_bool="unsigned long";;
705                 (*)  cf_cv_type_of_bool=unknown;;
706                 esac
707                 ])
708         rm -f cf_test.out
709 ])
710
711 if test "$cf_cv_type_of_bool" = unknown ; then
712         case .$NCURSES_BOOL in
713         (.auto|.) NCURSES_BOOL=unsigned;;
714         esac
715         AC_MSG_WARN(Assuming $NCURSES_BOOL for type of bool)
716         cf_cv_type_of_bool=$NCURSES_BOOL
717 fi
718 ])dnl
719 dnl ---------------------------------------------------------------------------
720 dnl CF_BUILD_CC version: 9 updated: 2021/01/02 09:31:20
721 dnl -----------
722 dnl If we're cross-compiling, allow the user to override the tools and their
723 dnl options.  The configure script is oriented toward identifying the host
724 dnl compiler, etc., but we need a build compiler to generate parts of the
725 dnl source.
726 dnl
727 dnl $1 = default for $CPPFLAGS
728 dnl $2 = default for $LIBS
729 AC_DEFUN([CF_BUILD_CC],[
730 CF_ACVERSION_CHECK(2.52,,
731         [AC_REQUIRE([CF_PROG_EXT])])
732 if test "$cross_compiling" = yes ; then
733
734         # defaults that we might want to override
735         : ${BUILD_CFLAGS:=''}
736         : ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
737         : ${BUILD_LDFLAGS:=''}
738         : ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
739         : ${BUILD_EXEEXT:='$x'}
740         : ${BUILD_OBJEXT:='o'}
741
742         AC_ARG_WITH(build-cc,
743                 [  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
744                 [BUILD_CC="$withval"],
745                 [AC_CHECK_PROGS(BUILD_CC, [gcc clang c99 c89 cc cl],none)])
746         AC_MSG_CHECKING(for native build C compiler)
747         AC_MSG_RESULT($BUILD_CC)
748
749         AC_MSG_CHECKING(for native build C preprocessor)
750         AC_ARG_WITH(build-cpp,
751                 [  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
752                 [BUILD_CPP="$withval"],
753                 [BUILD_CPP='${BUILD_CC} -E'])
754         AC_MSG_RESULT($BUILD_CPP)
755
756         AC_MSG_CHECKING(for native build C flags)
757         AC_ARG_WITH(build-cflags,
758                 [  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
759                 [BUILD_CFLAGS="$withval"])
760         AC_MSG_RESULT($BUILD_CFLAGS)
761
762         AC_MSG_CHECKING(for native build C preprocessor-flags)
763         AC_ARG_WITH(build-cppflags,
764                 [  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
765                 [BUILD_CPPFLAGS="$withval"])
766         AC_MSG_RESULT($BUILD_CPPFLAGS)
767
768         AC_MSG_CHECKING(for native build linker-flags)
769         AC_ARG_WITH(build-ldflags,
770                 [  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
771                 [BUILD_LDFLAGS="$withval"])
772         AC_MSG_RESULT($BUILD_LDFLAGS)
773
774         AC_MSG_CHECKING(for native build linker-libraries)
775         AC_ARG_WITH(build-libs,
776                 [  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
777                 [BUILD_LIBS="$withval"])
778         AC_MSG_RESULT($BUILD_LIBS)
779
780         # this assumes we're on Unix.
781         BUILD_EXEEXT=
782         BUILD_OBJEXT=o
783
784         : ${BUILD_CC:='${CC}'}
785
786         if { test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}'; } ; then
787                 AC_MSG_ERROR([Cross-build requires two compilers.
788 Use --with-build-cc to specify the native compiler.])
789         fi
790
791 else
792         : ${BUILD_CC:='${CC}'}
793         : ${BUILD_CPP:='${CPP}'}
794         : ${BUILD_CFLAGS:='${CFLAGS}'}
795         : ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
796         : ${BUILD_LDFLAGS:='${LDFLAGS}'}
797         : ${BUILD_LIBS:='${LIBS}'}
798         : ${BUILD_EXEEXT:='$x'}
799         : ${BUILD_OBJEXT:='o'}
800 fi
801
802 AC_SUBST(BUILD_CC)
803 AC_SUBST(BUILD_CPP)
804 AC_SUBST(BUILD_CFLAGS)
805 AC_SUBST(BUILD_CPPFLAGS)
806 AC_SUBST(BUILD_LDFLAGS)
807 AC_SUBST(BUILD_LIBS)
808 AC_SUBST(BUILD_EXEEXT)
809 AC_SUBST(BUILD_OBJEXT)
810 ])dnl
811 dnl ---------------------------------------------------------------------------
812 dnl CF_C11_NORETURN version: 3 updated: 2021/03/28 11:36:23
813 dnl ---------------
814 AC_DEFUN([CF_C11_NORETURN],
815 [
816 AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
817 CF_ARG_ENABLE(stdnoreturn,
818         [  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics],
819         [enable_stdnoreturn=yes],
820         [enable_stdnoreturn=no])
821 AC_MSG_RESULT($enable_stdnoreturn)
822
823 if test $enable_stdnoreturn = yes; then
824 AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
825         [AC_TRY_COMPILE([
826 #include <stdio.h>
827 #include <stdlib.h>
828 #include <stdnoreturn.h>
829 static _Noreturn void giveup(void) { exit(0); }
830         ],
831         [if (feof(stdin)) giveup()],
832         cf_cv_c11_noreturn=yes,
833         cf_cv_c11_noreturn=no)
834         ])
835 else
836         cf_cv_c11_noreturn=no,
837 fi
838
839 if test "$cf_cv_c11_noreturn" = yes; then
840         AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
841         AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
842         HAVE_STDNORETURN_H=1
843 else
844         HAVE_STDNORETURN_H=0
845 fi
846
847 AC_SUBST(HAVE_STDNORETURN_H)
848 AC_SUBST(STDC_NORETURN)
849 ])dnl
850 dnl ---------------------------------------------------------------------------
851 dnl CF_CC_ENV_FLAGS version: 10 updated: 2020/12/31 18:40:20
852 dnl ---------------
853 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
854 dnl into CC.  This will not help with broken scripts that wrap the compiler
855 dnl with options, but eliminates a more common category of user confusion.
856 dnl
857 dnl In particular, it addresses the problem of being able to run the C
858 dnl preprocessor in a consistent manner.
859 dnl
860 dnl Caveat: this also disallows blanks in the pathname for the compiler, but
861 dnl the nuisance of having inconsistent settings for compiler and preprocessor
862 dnl outweighs that limitation.
863 AC_DEFUN([CF_CC_ENV_FLAGS],
864 [
865 # This should have been defined by AC_PROG_CC
866 : "${CC:=cc}"
867
868 AC_MSG_CHECKING(\$CFLAGS variable)
869 case "x$CFLAGS" in
870 (*-[[IUD]]*)
871         AC_MSG_RESULT(broken)
872         AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
873         cf_flags="$CFLAGS"
874         CFLAGS=
875         for cf_arg in $cf_flags
876         do
877                 CF_ADD_CFLAGS($cf_arg)
878         done
879         ;;
880 (*)
881         AC_MSG_RESULT(ok)
882         ;;
883 esac
884
885 AC_MSG_CHECKING(\$CC variable)
886 case "$CC" in
887 (*[[\ \ ]]-*)
888         AC_MSG_RESULT(broken)
889         AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
890         # humor him...
891         cf_prog=`echo "$CC" | sed -e 's/        / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
892         cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
893         CC="$cf_prog"
894         for cf_arg in $cf_flags
895         do
896                 case "x$cf_arg" in
897                 (x-[[IUDfgOW]]*)
898                         CF_ADD_CFLAGS($cf_arg)
899                         ;;
900                 (*)
901                         CC="$CC $cf_arg"
902                         ;;
903                 esac
904         done
905         CF_VERBOSE(resulting CC: '$CC')
906         CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
907         CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
908         ;;
909 (*)
910         AC_MSG_RESULT(ok)
911         ;;
912 esac
913 ])dnl
914 dnl ---------------------------------------------------------------------------
915 dnl CF_CFG_DEFAULTS version: 16 updated: 2021/01/04 19:33:05
916 dnl ---------------
917 dnl Determine the default configuration into which we'll install ncurses.  This
918 dnl can be overridden by the user's command-line options.  There's two items to
919 dnl look for:
920 dnl     1. the prefix (e.g., /usr)
921 dnl     2. the header files (e.g., /usr/include/ncurses)
922 dnl We'll look for a previous installation of ncurses and use the same defaults.
923 dnl
924 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
925 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
926 dnl programs from a vendor's.
927 AC_DEFUN([CF_CFG_DEFAULTS],
928 [AC_REQUIRE([AC_PROG_FGREP])dnl
929
930 AC_MSG_CHECKING(for prefix)
931 if test "x$prefix" = "xNONE" ; then
932         case "$cf_cv_system_name" in
933                 # non-vendor systems don't have a conflict
934         (openbsd*|freebsd*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
935                 prefix=/usr
936                 ;;
937         (*)     prefix=$ac_default_prefix
938                 ;;
939         esac
940 fi
941 AC_MSG_RESULT($prefix)
942
943 if test "x$prefix" = "xNONE" ; then
944 AC_MSG_CHECKING(for default include-directory)
945 test -n "$verbose" && echo 1>&AC_FD_MSG
946 for cf_symbol in \
947         "$includedir" \
948         "$includedir/ncurses" \
949         "$prefix/include" \
950         "$prefix/include/ncurses" \
951         /usr/local/include \
952         /usr/local/include/ncurses \
953         /usr/include \
954         /usr/include/ncurses
955 do
956         cf_dir=`eval echo "$cf_symbol"`
957         if test -f "$cf_dir/curses.h" ; then
958         if ( ${FGREP-fgrep} NCURSES_VERSION "$cf_dir/curses.h" >/dev/null 2>&1 ) ; then
959                 includedir="$cf_symbol"
960                 test -n "$verbose"  && echo $ECHO_N "   found " 1>&AC_FD_MSG
961                 break
962         fi
963         fi
964         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
965 done
966 AC_MSG_RESULT($includedir)
967 fi
968 ])dnl
969 dnl ---------------------------------------------------------------------------
970 dnl CF_CGETENT version: 6 updated: 2017/01/21 11:06:25
971 dnl ----------
972 dnl Check if the terminal-capability database functions are available.  If not,
973 dnl ncurses has a much-reduced version.
974 AC_DEFUN([CF_CGETENT],[
975 AC_CACHE_CHECK(for terminal-capability database functions,cf_cv_cgetent,[
976 AC_TRY_LINK([
977 #include <stdlib.h>],[
978         char temp[128];
979         char *buf = temp;
980         char *db_array = temp;
981         cgetent(&buf, &db_array, "vt100");
982         cgetcap(buf, "tc", '=');
983         cgetmatch(buf, "tc");
984         ],
985         [cf_cv_cgetent=yes],
986         [cf_cv_cgetent=no])
987 ])
988
989 if test "$cf_cv_cgetent" = yes
990 then
991         AC_DEFINE(HAVE_BSD_CGETENT,1,[Define to 1 if we have BSD cgetent])
992 AC_CACHE_CHECK(if cgetent uses const parameter,cf_cv_cgetent_const,[
993 AC_TRY_LINK([
994 #pragma GCC diagnostic error "-Wincompatible-pointer-types-discards-qualifiers"
995 #include <stdlib.h>],[
996         char temp[128];
997         char *buf = temp;
998 #ifndef _NETBSD_SOURCE                  /* given, since April 2004 in stdlib.h */
999         const char *db_array = temp;
1000         cgetent(&buf, &db_array, "vt100");
1001 #endif
1002         cgetcap(buf, "tc", '=');
1003         cgetmatch(buf, "tc");
1004         ],
1005         [cf_cv_cgetent_const=yes],
1006         [cf_cv_cgetent_const=no])
1007 ])
1008         if test "$cf_cv_cgetent_const" = yes
1009         then
1010                 AC_DEFINE_UNQUOTED(CGETENT_CONST,const,[Define to const if needed for some BSD cgetent variations])
1011         fi
1012 fi
1013 ])dnl
1014 dnl ---------------------------------------------------------------------------
1015 dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
1016 dnl --------------
1017 dnl Check if we're accidentally using a cache from a different machine.
1018 dnl Derive the system name, as a check for reusing the autoconf cache.
1019 dnl
1020 dnl If we've packaged config.guess and config.sub, run that (since it does a
1021 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
1022 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
1023 dnl which is useful in cross-compiles.
1024 dnl
1025 dnl Note: we would use $ac_config_sub, but that is one of the places where
1026 dnl autoconf 2.5x broke compatibility with autoconf 2.13
1027 AC_DEFUN([CF_CHECK_CACHE],
1028 [
1029 if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
1030         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
1031         system_name="$host_os"
1032 else
1033         system_name="`(uname -s -r) 2>/dev/null`"
1034         if test -z "$system_name" ; then
1035                 system_name="`(hostname) 2>/dev/null`"
1036         fi
1037 fi
1038 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
1039 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
1040
1041 test -z "$system_name" && system_name="$cf_cv_system_name"
1042 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
1043
1044 if test ".$system_name" != ".$cf_cv_system_name" ; then
1045         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
1046         AC_MSG_ERROR("Please remove config.cache and try again.")
1047 fi
1048 ])dnl
1049 dnl ---------------------------------------------------------------------------
1050 dnl CF_CHECK_ENVIRON version: 3 updated: 2010/05/26 16:44:57
1051 dnl ----------------
1052 dnl Check for data that is usually declared in <unistd.h>, e.g., the 'environ'
1053 dnl variable.  Define a DECL_xxx symbol if we must declare it ourselves.
1054 dnl
1055 dnl $1 = the name to check
1056 dnl $2 = the assumed type
1057 AC_DEFUN([CF_CHECK_ENVIRON],
1058 [
1059 AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
1060     AC_TRY_COMPILE([
1061 #ifdef HAVE_STDLIB_H
1062 #include <stdlib.h>
1063 #endif
1064 #include <unistd.h> ],
1065     ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
1066     [cf_cv_dcl_$1=yes],
1067     [cf_cv_dcl_$1=no])
1068 ])
1069
1070 if test "$cf_cv_dcl_$1" = no ; then
1071     CF_UPPER(cf_result,decl_$1)
1072     AC_DEFINE_UNQUOTED($cf_result)
1073 fi
1074
1075 # It's possible (for near-UNIX clones) that the data doesn't exist
1076 CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
1077 ])dnl
1078 dnl ---------------------------------------------------------------------------
1079 dnl CF_CHECK_ERRNO version: 13 updated: 2020/03/10 18:53:47
1080 dnl --------------
1081 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
1082 dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
1083 dnl ourselves.
1084 dnl
1085 dnl $1 = the name to check
1086 dnl $2 = the assumed type
1087 AC_DEFUN([CF_CHECK_ERRNO],
1088 [
1089 AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
1090         AC_TRY_COMPILE([
1091 #ifdef HAVE_STDLIB_H
1092 #include <stdlib.h>
1093 #endif
1094 #include <stdio.h>
1095 #include <sys/types.h>
1096 #include <errno.h> ],
1097         ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1; (void)x,
1098         [cf_cv_dcl_$1=yes],
1099         [cf_cv_dcl_$1=no])
1100 ])
1101
1102 if test "$cf_cv_dcl_$1" = no ; then
1103         CF_UPPER(cf_result,decl_$1)
1104         AC_DEFINE_UNQUOTED($cf_result)
1105 fi
1106
1107 # It's possible (for near-UNIX clones) that the data doesn't exist
1108 CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
1109 ])dnl
1110 dnl ---------------------------------------------------------------------------
1111 dnl CF_CHECK_EXTERN_DATA version: 5 updated: 2021/09/04 06:35:04
1112 dnl --------------------
1113 dnl Check for existence of external data in the current set of libraries.  If
1114 dnl we can modify it, it is real enough.
1115 dnl $1 = the name to check
1116 dnl $2 = its type
1117 AC_DEFUN([CF_CHECK_EXTERN_DATA],
1118 [
1119 AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
1120         AC_TRY_LINK([
1121 #undef $1
1122 extern $2 $1;
1123 ],
1124         [$1 = 2],
1125         [cf_cv_have_$1=yes],
1126         [cf_cv_have_$1=no])
1127 ])
1128
1129 if test "$cf_cv_have_$1" = yes ; then
1130         CF_UPPER(cf_result,have_$1)
1131         AC_DEFINE_UNQUOTED($cf_result)
1132 fi
1133
1134 ])dnl
1135 dnl ---------------------------------------------------------------------------
1136 dnl CF_CHECK_FVISIBILITY version: 2 updated: 2020/04/04 16:16:13
1137 dnl --------------------
1138 dnl Check whether the compiler understands -fvisibility=hidden
1139 dnl
1140 dnl $1 = compiler
1141 dnl $2 = compiler-flags variable name
1142 dnl $3 = cache variable to set
1143 AC_DEFUN([CF_CHECK_FVISIBILITY],[
1144 AC_CACHE_CHECK(if $1 -fvisibility=hidden option works,$3,[
1145     cf_save_cflags="[$]$2"
1146     $2="[$]$2 -fvisibility=hidden"
1147     AC_TRY_LINK([
1148 __attribute__ ((visibility("default"))) int somefunc() {return 42;}
1149         ],[
1150         if (somefunc()) return 1;
1151 ],
1152     [$3=yes],
1153     [$3=no])
1154     $2=$cf_save_cflags
1155 ])
1156 ])dnl
1157 dnl ---------------------------------------------------------------------------
1158 dnl CF_CHECK_GETENV version: 2 updated: 2021/01/02 17:09:14
1159 dnl ---------------
1160 dnl Check if repeated getenv calls return the same pointer, e.g., it does not
1161 dnl discard the previous pointer when returning a new one.
1162 AC_DEFUN([CF_CHECK_GETENV],
1163 [
1164 AC_REQUIRE([CF_CHECK_ENVIRON])
1165 AC_CHECK_FUNC( getenv, ,, AC_MSG_ERROR(getenv not found) )
1166 AC_CHECK_FUNCS( putenv setenv strdup )
1167 AC_CACHE_CHECK(if getenv returns consistent values,cf_cv_consistent_getenv,[
1168 AC_TRY_RUN([
1169 #include <stdlib.h>
1170 #include <unistd.h>
1171 #include <stdio.h>
1172 #include <string.h>
1173 #include <sys/types.h>
1174
1175 #if defined(HAVE_ENVIRON) && defined(DECL_ENVIRON) && !defined(environ)
1176 extern char **environ;  /* POSIX, but some systems are not... */
1177 #endif
1178
1179 #if defined(HAVE_STRDUP)
1180 #define str_alloc(s) strdup(s)
1181 #else
1182 #define str_alloc(s) strcpy(malloc(strlen(s) + 1, s))
1183 #endif
1184
1185 static void set_value(const char *name, const char *value)
1186 {
1187 #if defined(HAVE_SETENV)
1188         setenv(name, value, 1);
1189 #elif defined(HAVE_PUTENV)
1190         char buffer[1024];
1191         sprintf(buffer, "%s=%s", name, value);
1192         putenv(str_alloc(buffer));
1193 #else
1194 #error neither putenv/setenv found
1195 #endif
1196 }
1197 int main(void)
1198 {
1199         int pass;
1200         size_t numenv, limit, j;
1201         char **mynames;
1202         char **myvalues;
1203         char **mypointer;
1204         char *equals;
1205         for (numenv = 0; environ[numenv]; ++numenv) ;
1206         limit = numenv + 10;
1207         mynames = (char **) calloc(limit + 1, sizeof(char *));
1208         myvalues = (char **) calloc(limit + 1, sizeof(char *));
1209         mypointer = (char **) calloc(limit + 1, sizeof(char *));
1210 #if defined(HAVE_ENVIRON)
1211         for (j = 0; environ[j]; ++j) {
1212                 mynames[j] = str_alloc(environ[j]);
1213                 equals = strchr(mynames[j], '=');
1214                 if (equals != 0) {
1215                         *equals++ = '\\0';
1216                         myvalues[j] = str_alloc(equals);
1217                 } else {
1218                         myvalues[j] = str_alloc("");
1219                 }
1220         }
1221 #endif
1222         for (j = numenv; j < limit; ++j) {
1223                 char name[80];
1224                 char value[80];
1225                 size_t found;
1226                 size_t k = 0;
1227                 do {
1228                         size_t jk;
1229                         found = 0;
1230                         sprintf(name, "TERM%lu", (unsigned long) k);
1231                         for (jk = 0; jk < j; ++jk) {
1232                                 if (!strcmp(name, mynames[jk])) {
1233                                         found = 1;
1234                                         ++k;
1235                                         break;
1236                                 }
1237                         }
1238                 } while (found);
1239                 sprintf(value, "%lu:%p", (unsigned long) k, &mynames[j]);
1240                 set_value(name, value);
1241                 mynames[j] = str_alloc(name);
1242                 myvalues[j] = str_alloc(value);
1243         }
1244         for (pass = 0; pass < 3; ++pass) {
1245                 for (j = 0; j < limit; ++j) {
1246                         char *value = getenv(mynames[j]);
1247                         if (pass) {
1248                                 if (value == 0) {
1249                                         fprintf(stderr, "getenv returned null for %s\\n", mynames[j]);
1250                                         ${cf_cv_main_return:-return}(1);
1251                                 } else if (value != mypointer[j]) {
1252                                         fprintf(stderr, "getenv returned different pointer for %s\\n", mynames[j]);
1253                                         ${cf_cv_main_return:-return}(1);
1254                                 } else if (strcmp(value, myvalues[j])) {
1255                                         fprintf(stderr, "getenv returned different value for %s\\n", mynames[j]);
1256                                         ${cf_cv_main_return:-return}(1);
1257                                 }
1258                         } else {
1259                                 size_t k;
1260                                 mypointer[j] = value;
1261                                 for (k = 0; k < j; ++k) {
1262                                         if (mypointer[j] == mypointer[k]) {
1263                                                 fprintf(stderr, "getenv returned same pointer for %s and %s\\n", mynames[j], mynames[k]);
1264                                                 ${cf_cv_main_return:-return}(1);
1265                                         }
1266                                 }
1267                         }
1268                 }
1269         }
1270         ${cf_cv_main_return:-return}(0);
1271 }
1272 ],
1273 [cf_cv_consistent_getenv=yes],
1274 [cf_cv_consistent_getenv=no],
1275 [cf_cv_consistent_getenv=unknown])
1276 ])
1277
1278 if test "x$cf_cv_consistent_getenv" = xno
1279 then
1280         AC_DEFINE(HAVE_CONSISTENT_GETENV,1,[Define to 1 if getenv repeatably returns the same value for a given name])
1281 fi
1282 ])dnl
1283 dnl ---------------------------------------------------------------------------
1284 dnl CF_CHECK_GNAT_VERSION version: 4 updated: 2021/01/01 13:31:04
1285 dnl ---------------------
1286 AC_DEFUN([CF_CHECK_GNAT_VERSION],
1287 [
1288 AC_REQUIRE([CF_GNAT_VERSION])
1289 case "$cf_cv_gnat_version" in
1290 (3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*|[[1-9]][[0-9]].[[0-9]]*|20[[0-9]][[0-9]])
1291         cf_cv_prog_gnat_correct=yes
1292         ;;
1293 (*)
1294         AC_MSG_WARN(Unsupported GNAT version $cf_cv_gnat_version. We require 3.11 or better. Disabling Ada95 binding.)
1295         cf_cv_prog_gnat_correct=no
1296         ;;
1297 esac
1298 ])
1299 dnl ---------------------------------------------------------------------------
1300 dnl CF_CHECK_GPM_WGETCH version: 6 updated: 2021/01/04 18:48:01
1301 dnl -------------------
1302 dnl Check if GPM is already linked with curses.  If so - and if the linkage
1303 dnl is not "weak" - warn about this because it can create problems linking
1304 dnl applications with ncurses.
1305 AC_DEFUN([CF_CHECK_GPM_WGETCH],[
1306 AC_REQUIRE([AC_PROG_EGREP])dnl
1307
1308 AC_CHECK_LIB(gpm,Gpm_Wgetch,[
1309
1310 AC_CACHE_CHECK(if GPM is weakly bound to curses library, cf_cv_check_gpm_wgetch,[
1311 cf_cv_check_gpm_wgetch=unknown
1312 if test "$cross_compiling" != yes ; then
1313
1314 cat >conftest.$ac_ext <<CF_EOF
1315 #include <gpm.h>
1316 int main(void)
1317 {
1318         Gpm_Wgetch();
1319         ${cf_cv_main_return:-return}(0);
1320 }
1321 CF_EOF
1322
1323         cf_save_LIBS="$LIBS"
1324         # This only works if we can look at the symbol table.  If a shared
1325         # library is stripped for install, we cannot use that.  So we're forced
1326         # to rely on the static library, noting that some packagers may not
1327         # include it.
1328         LIBS="-static -lgpm -dynamic $LIBS"
1329         if AC_TRY_EVAL(ac_compile) ; then
1330                 if AC_TRY_EVAL(ac_link) ; then
1331                         cf_cv_check_gpm_wgetch="`nm \"conftest$ac_exeext\" | ${EGREP-egrep} '\<wgetch\>' | ${EGREP-egrep} '\<[[vVwW]]\>'`"
1332                         test -n "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=yes
1333                         test -z "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=no
1334                 fi
1335         fi
1336         rm -rf ./conftest*
1337         LIBS="$cf_save_LIBS"
1338 fi
1339 ])
1340
1341 if test "$cf_cv_check_gpm_wgetch" != yes ; then
1342         AC_MSG_WARN(GPM library is already linked with curses - read the FAQ)
1343 fi
1344 ])])dnl
1345 dnl ---------------------------------------------------------------------------
1346 dnl CF_CHECK_LIBTOOL_VERSION version: 2 updated: 2021/05/01 16:24:34
1347 dnl ------------------------
1348 dnl Show the version of libtool
1349 dnl
1350 dnl Save the version in a cache variable - this is not entirely a good thing,
1351 dnl but the version string from libtool is very ugly, and for bug reports it
1352 dnl might be useful to have the original string.
1353 dnl
1354 dnl There is an imitation in OpenBSD, which has no apparent use other than to
1355 dnl deny that it is GNU libtool.  Just ignore it.
1356 AC_DEFUN([CF_CHECK_LIBTOOL_VERSION],[
1357 if test -n "$LIBTOOL" && test "$LIBTOOL" != none
1358 then
1359         AC_MSG_CHECKING(version of $LIBTOOL)
1360         CF_LIBTOOL_VERSION
1361         AC_MSG_RESULT($cf_cv_libtool_version)
1362         if test -n "$cf_cv_libtool_version"
1363         then
1364                 cf_check_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' -e 's,[[()]],...,g' -e 's,[[ ]],-,g' -e '2,$d'`
1365                 case "x$cf_check_libtool_version" in
1366                 (*...GNU-libtool...*)
1367                         ;;
1368                 (*)
1369                         AC_MSG_ERROR(This is not GNU libtool)
1370                         ;;
1371                 esac
1372         else
1373                 AC_MSG_ERROR(No version found for $LIBTOOL)
1374         fi
1375 else
1376         AC_MSG_ERROR(GNU libtool has not been found)
1377 fi
1378 ])dnl
1379 dnl ---------------------------------------------------------------------------
1380 dnl CF_CHECK_WCHAR_H version: 3 updated: 2021/01/01 13:31:04
1381 dnl ----------------
1382 dnl Check if wchar.h can be used, i.e., without defining _XOPEN_SOURCE_EXTENDED
1383 AC_DEFUN([CF_CHECK_WCHAR_H],[
1384 AC_CHECK_HEADERS( \
1385 wchar.h \
1386 wctype.h \
1387 )
1388 AC_CACHE_CHECK(if wchar.h can be used as is,cf_cv_wchar_h_okay,[
1389 AC_TRY_COMPILE(
1390 [
1391 #include <stdlib.h>
1392 #ifdef HAVE_WCHAR_H
1393 #include <wchar.h>
1394 #endif
1395 #ifdef HAVE_WCTYPE_H
1396 #include <wctype.h>
1397 #endif
1398 ],[
1399         wint_t foo = 0;
1400         int bar = iswpunct(foo)],
1401         [cf_cv_wchar_h_okay=yes],
1402         [cf_cv_wchar_h_okay=no])])
1403
1404 if test "$cf_cv_wchar_h_okay" = no
1405 then
1406         CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
1407 fi
1408 ])dnl
1409 dnl ---------------------------------------------------------------------------
1410 dnl CF_CHECK_WCWIDTH_GRAPHICS version: 2 updated: 2021/01/02 17:09:14
1411 dnl -------------------------
1412 dnl Most "modern" terminal emulators are based to some degree on VT100, and
1413 dnl should support line-drawing.  Even with Unicode.  There is a problem.
1414 dnl
1415 dnl While most of the VT100 graphics characters were incorporated into Unicode,
1416 dnl all of those were combined into a page of useful graphics characters.
1417 dnl
1418 dnl So far, so good.
1419 dnl
1420 dnl However, while they are useful, there are other considerations.  CJK
1421 dnl is (because of poor device resolution) often rendered as double-width
1422 dnl characters.  So... for these generally-useful characters, what should
1423 dnl be the width (to make them consistent with adjacent characters)?
1424 dnl
1425 dnl The obvious choice would have been to make this locale-dependent, and use
1426 dnl wcwidth() to tell applications what the actual width is.  That was too
1427 dnl obvious.  Instead, we have a slew of "ambiguous-width" characters.
1428 dnl See for example
1429 dnl             http://www.unicode.org/reports/tr11/tr11-29.html
1430 dnl             http://www.cl.cam.ac.uk/~mgk25/ucs/scw-proposal.html
1431 dnl
1432 dnl The EastAsianWidth-6.2.0.txt file from the Unicode organization lists
1433 dnl more than 22,000 characters, with 1281 of those as ambiguous-width.  For
1434 dnl instance, it lists half (44/96) of the Latin-1 characters as
1435 dnl ambiguous-width.  Also, all of the box-characters at 0x2500 are ambiguous.
1436 dnl
1437 dnl What this means for the implementor is that on some systems wcwidth() can
1438 dnl give bad advice.  On Solaris, some of the ambiguous widths are returned as
1439 dnl 1 (the Latin-1 characters), while others are returned as 2 (line-drawing
1440 dnl characters).  These do not necessarily match the behavior of the terminal
1441 dnl emulator.  xterm, for instance, does an optional startup check to find if
1442 dnl this problem (or similar) exists with the system's locale tables, rejecting
1443 dnl them if they are too unreliable.
1444 AC_DEFUN([CF_CHECK_WCWIDTH_GRAPHICS],[
1445 AC_CACHE_CHECK(if wcwidth agrees graphics are single-width, cf_cv_wcwidth_graphics,[
1446 cat >conftest.in <<CF_EOF
1447 -       VT100 symbols
1448 0x250c  upper left corner
1449 0x2514  lower left corner
1450 0x2510  upper right corner
1451 0x2518  lower right corner
1452 0x251c  tee pointing left
1453 0x2524  tee pointing right
1454 0x2534  tee pointing up
1455 0x252c  tee pointing down
1456 0x2500  horizontal line
1457 0x2502  vertical line
1458 0x253c  large plus or crossover
1459 0x23ba  scan line 1
1460 0x23bd  scan line 9
1461 0x25c6  diamond
1462 0x2592  checker board (stipple)
1463 0x00b0  degree symbol
1464 0x00b1  plus/minus
1465 0x00b7  bullet
1466 -       Teletype 5410v1 symbols
1467 0x2190  arrow pointing left
1468 0x2192  arrow pointing right
1469 0x2193  arrow pointing down
1470 0x2191  arrow pointing up
1471 0x2592  board of squares
1472 0x2603  lantern symbol
1473 0x25ae  solid square block
1474 -       these defaults were invented for ncurses
1475 0x23bb  scan line 3
1476 0x23bc  scan line 7
1477 0x2264  less-than-or-equal-to
1478 0x2265  greater-than-or-equal-to
1479 0x03c0  greek pi
1480 0x2260  not-equal
1481 0x00a3  pound-sterling symbol
1482 -       thick-line-drawing
1483 0x250f  upper left corner
1484 0x2517  lower left corner
1485 0x2513  upper right corner
1486 0x251b  lower right corner
1487 0x2523  tee pointing left
1488 0x252b  tee pointing right
1489 0x253b  tee pointing up
1490 0x2533  tee pointing down
1491 0x2501  horizontal line
1492 0x2503  vertical line
1493 0x254b  large plus or crossover
1494 -       double-line-drawing
1495 0x2554  upper left corner
1496 0x255a  lower left corner
1497 0x2557  upper right corner
1498 0x255d  lower right corner
1499 0x2563  tee pointing left
1500 0x2560  tee pointing right
1501 0x2569  tee pointing up
1502 0x2566  tee pointing down
1503 0x2550  horizontal line
1504 0x2551  vertical line
1505 0x256c  large plus or crossover
1506 CF_EOF
1507 AC_TRY_RUN([
1508 #include <locale.h>
1509 #include <stdio.h>
1510 #include <wchar.h>
1511
1512 #define MY_LEN 80
1513
1514 int
1515 main(void)
1516 {
1517         FILE *fp;
1518         int value;
1519         char buffer[MY_LEN + 1];
1520         char notes[MY_LEN + 1];
1521         int totals = 0;
1522         int passed = 0;
1523
1524         if (setlocale(LC_ALL, "en_US.UTF8") ||
1525                 setlocale(LC_ALL, "en_US.UTF-8") ||
1526                 setlocale(LC_ALL, "en_US.utf8") ||
1527                 setlocale(LC_ALL, "en_US.utf-8")) {
1528                 if ((fp = fopen("conftest.in", "r")) != 0) {
1529                         while (fgets(buffer, MY_LEN, fp) != 0) {
1530                                 if (*buffer == '-') {
1531                                         fprintf(stderr, "\\t%s", buffer);
1532                                 } else if (sscanf(buffer, "%x %s", &value, notes) == 2) {
1533                                         ++totals;
1534                                         if (wcwidth(value) == 1)
1535                                                 ++passed;
1536                                         fprintf(stderr, "%d\\t%s", wcwidth(value), buffer);
1537                                 } else {
1538                                         fprintf(stderr, "?\\t%s", buffer);
1539                                 }
1540                         }
1541                 }
1542         }
1543         fprintf(stderr, "%d/%d passed wcwidth/graphics check\\n", passed, totals);
1544         return (totals == passed) ? 0 : 1;
1545 }
1546 ],
1547 [cf_cv_wcwidth_graphics=yes],
1548 [cf_cv_wcwidth_graphics=no],
1549 [cf_cv_wcwidth_graphics=unknown])
1550 ])
1551 ])dnl
1552 dnl ---------------------------------------------------------------------------
1553 dnl CF_CLANG_COMPILER version: 8 updated: 2021/01/01 13:31:04
1554 dnl -----------------
1555 dnl Check if the given compiler is really clang.  clang's C driver defines
1556 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
1557 dnl not ignore some gcc options.
1558 dnl
1559 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1560 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1561 dnl the wrappers for gcc and g++ warnings.
1562 dnl
1563 dnl $1 = GCC (default) or GXX
1564 dnl $2 = CLANG_COMPILER (default)
1565 dnl $3 = CFLAGS (default) or CXXFLAGS
1566 AC_DEFUN([CF_CLANG_COMPILER],[
1567 ifelse([$2],,CLANG_COMPILER,[$2])=no
1568
1569 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1570         AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
1571         cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1572         AC_TRY_COMPILE([],[
1573 #ifdef __clang__
1574 #else
1575 make an error
1576 #endif
1577 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
1578 ],[])
1579         ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1580         AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
1581 fi
1582
1583 CLANG_VERSION=none
1584
1585 if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
1586         case "$CC" in
1587         (c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
1588                 AC_MSG_WARN(replacing broken compiler alias $CC)
1589                 CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
1590                 CC=clang
1591                 ;;
1592         esac
1593
1594         AC_MSG_CHECKING(version of $CC)
1595         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.]].*//'`"
1596         test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
1597         AC_MSG_RESULT($CLANG_VERSION)
1598
1599         for cf_clang_opt in \
1600                 -Qunused-arguments \
1601                 -Wno-error=implicit-function-declaration
1602         do
1603                 AC_MSG_CHECKING(if option $cf_clang_opt works)
1604                 cf_save_CFLAGS="$CFLAGS"
1605                 CFLAGS="$CFLAGS $cf_clang_opt"
1606                 AC_TRY_LINK([
1607                         #include <stdio.h>],[
1608                         printf("hello!\\n");],[
1609                         cf_clang_optok=yes],[
1610                         cf_clang_optok=no])
1611                 AC_MSG_RESULT($cf_clang_optok)
1612                 CFLAGS="$cf_save_CFLAGS"
1613                 if test "$cf_clang_optok" = yes; then
1614                         CF_VERBOSE(adding option $cf_clang_opt)
1615                         CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
1616                 fi
1617         done
1618 fi
1619 ])
1620 dnl ---------------------------------------------------------------------------
1621 dnl CF_CONST_X_STRING version: 7 updated: 2021/06/07 17:39:17
1622 dnl -----------------
1623 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
1624 dnl character-strings.
1625 dnl
1626 dnl It is ambiguous because the specification accommodated the pre-ANSI
1627 dnl compilers bundled by more than one vendor in lieu of providing a standard C
1628 dnl compiler other than by costly add-ons.  Because of this, the specification
1629 dnl did not take into account the use of const for telling the compiler that
1630 dnl string literals would be in readonly memory.
1631 dnl
1632 dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
1633 dnl let the compiler decide how to represent Xt's strings which were #define'd.
1634 dnl That does not solve the problem of using the block of Xt's strings which
1635 dnl are compiled into the library (and is less efficient than one might want).
1636 dnl
1637 dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
1638 dnl when compiling the library and compiling using the library, to tell the
1639 dnl compiler that String is const.
1640 AC_DEFUN([CF_CONST_X_STRING],
1641 [
1642 AC_REQUIRE([AC_PATH_XTRA])
1643
1644 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
1645
1646 AC_TRY_COMPILE(
1647 [
1648 #include <stdlib.h>
1649 #include <X11/Intrinsic.h>
1650 ],
1651 [String foo = malloc(1); free((void*)foo)],[
1652
1653 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
1654         AC_TRY_COMPILE(
1655                 [
1656 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
1657 #undef  XTSTRINGDEFINES /* X11R5 and later */
1658 #include <stdlib.h>
1659 #include <X11/Intrinsic.h>
1660                 ],[String foo = malloc(1); *foo = 0],[
1661                         cf_cv_const_x_string=no
1662                 ],[
1663                         cf_cv_const_x_string=yes
1664                 ])
1665 ])
1666
1667 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
1668
1669 case "$cf_cv_const_x_string" in
1670 (no)
1671         CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
1672         ;;
1673 (*)
1674         CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
1675         ;;
1676 esac
1677
1678 ])
1679 ])dnl
1680 dnl ---------------------------------------------------------------------------
1681 dnl CF_CPP_PARAM_INIT version: 7 updated: 2017/01/21 11:06:25
1682 dnl -----------------
1683 dnl Check if the C++ compiler accepts duplicate parameter initialization.  This
1684 dnl is a late feature for the standard and is not in some recent compilers
1685 dnl (1999/9/11).
1686 AC_DEFUN([CF_CPP_PARAM_INIT],
1687 [
1688 if test -n "$CXX"; then
1689 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
1690         AC_LANG_SAVE
1691         AC_LANG_CPLUSPLUS
1692         AC_TRY_RUN([
1693 class TEST {
1694 private:
1695         int value;
1696 public:
1697         TEST(int x = 1);
1698         ~TEST();
1699 };
1700
1701 TEST::TEST(int x = 1)   // some compilers do not like second initializer
1702 {
1703         value = x;
1704 }
1705 int main(void) { }
1706 ],
1707         [cf_cv_cpp_param_init=yes],
1708         [cf_cv_cpp_param_init=no],
1709         [cf_cv_cpp_param_init=unknown])
1710         AC_LANG_RESTORE
1711 ])
1712 fi
1713 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT,1,[Define to 1 if C++ has parameter initialization])
1714 ])dnl
1715 dnl ---------------------------------------------------------------------------
1716 dnl CF_CPP_STATIC_CAST version: 3 updated: 2013/04/13 18:03:21
1717 dnl ------------------
1718 dnl Check if the C++ compiler accepts static_cast in generics.  This appears to
1719 dnl not be supported in g++ before 3.0
1720 AC_DEFUN([CF_CPP_STATIC_CAST],
1721 [
1722 if test -n "$CXX"; then
1723
1724 AC_CACHE_CHECK(if $CXX accepts static_cast,cf_cv_cpp_static_cast,[
1725         AC_LANG_SAVE
1726         AC_LANG_CPLUSPLUS
1727
1728         AC_TRY_COMPILE([
1729 class NCursesPanel
1730 {
1731 public:
1732   NCursesPanel(int nlines,
1733                int ncols,
1734                int begin_y = 0,
1735                int begin_x = 0)
1736   {
1737   }
1738   NCursesPanel();
1739   ~NCursesPanel();
1740 };
1741
1742 template<class T> class NCursesUserPanel : public NCursesPanel
1743 {
1744 public:
1745   NCursesUserPanel (int nlines,
1746                     int ncols,
1747                     int begin_y = 0,
1748                     int begin_x = 0,
1749                     const T* p_UserData = static_cast<T*>(0))
1750     : NCursesPanel (nlines, ncols, begin_y, begin_x)
1751   {
1752   };
1753   NCursesUserPanel(const T* p_UserData = static_cast<T*>(0)) : NCursesPanel()
1754   {
1755   };
1756
1757   virtual ~NCursesUserPanel() {};
1758 };
1759 ],[
1760         const char* p_UserData = static_cast<char*>(0)],
1761         [cf_cv_cpp_static_cast=yes],
1762         [cf_cv_cpp_static_cast=no])
1763
1764         AC_LANG_RESTORE
1765 ])
1766
1767 fi
1768
1769 test "$cf_cv_cpp_static_cast" = yes && AC_DEFINE(CPP_HAS_STATIC_CAST,1,[Define to 1 if C++ has static_cast])
1770 ])dnl
1771 dnl ---------------------------------------------------------------------------
1772 dnl CF_CXX_AR_FLAGS version: 3 updated: 2021/01/01 13:31:04
1773 dnl ---------------
1774 dnl Setup special archiver flags for given compilers.
1775 AC_DEFUN([CF_CXX_AR_FLAGS],[
1776         CXX_AR='$(AR)'
1777         CXX_ARFLAGS='$(ARFLAGS)'
1778         case "$cf_cv_system_name" in
1779         (irix*)
1780             if test "$GXX" != yes ; then
1781                 CXX_AR='$(CXX)'
1782                 CXX_ARFLAGS='-ar -o'
1783             fi
1784             ;;
1785         (sco3.2v5*)
1786             CXXLDFLAGS="-u main"
1787             ;;
1788         (solaris2*)
1789             if test "$GXX" != yes ; then
1790                 CXX_AR='$(CXX)'
1791                 CXX_ARFLAGS='-xar -o'
1792             fi
1793             ;;
1794         esac
1795         AC_SUBST(CXXLDFLAGS)
1796         AC_SUBST(CXX_AR)
1797         AC_SUBST(CXX_ARFLAGS)
1798 ])dnl
1799 dnl ---------------------------------------------------------------------------
1800 dnl CF_CXX_IOSTREAM_NAMESPACE version: 2 updated: 2012/10/06 17:56:13
1801 dnl -------------------------
1802 dnl For c++, check if iostream uses "std::" namespace.
1803 AC_DEFUN([CF_CXX_IOSTREAM_NAMESPACE],[
1804 AC_CHECK_HEADERS(iostream)
1805 if test x"$ac_cv_header_iostream" = xyes ; then
1806         AC_MSG_CHECKING(if iostream uses std-namespace)
1807         AC_TRY_COMPILE([
1808 #include <iostream>
1809 using std::endl;
1810 using std::cerr;],[
1811 cerr << "testing" << endl;
1812 ],[cf_iostream_namespace=yes],[cf_iostream_namespace=no])
1813         AC_MSG_RESULT($cf_iostream_namespace)
1814         if test "$cf_iostream_namespace" = yes ; then
1815                 AC_DEFINE(IOSTREAM_NAMESPACE,1,[Define to 1 if C++ has namespace iostream])
1816         fi
1817 fi
1818 ])dnl
1819 dnl ---------------------------------------------------------------------------
1820 dnl CF_C_INLINE version: 6 updated: 2019/09/07 13:38:36
1821 dnl -----------
1822 dnl Check if the C compiler supports "inline".
1823 dnl $1 is the name of a shell variable to set if inline is supported
1824 dnl $2 is the threshold for gcc 4.x's option controlling maximum inline size
1825 AC_DEFUN([CF_C_INLINE],[
1826 AC_REQUIRE([CF_GCC_VERSION])
1827 AC_C_INLINE
1828 $1=
1829 if test "$ac_cv_c_inline" != no ; then
1830         $1=inline
1831         if test "$INTEL_COMPILER" = yes
1832         then
1833                 :
1834         elif test "$CLANG_COMPILER" = yes
1835         then
1836                 :
1837         elif test "$GCC" = yes
1838         then
1839                 AC_CACHE_CHECK(if $CC supports options to tune inlining,cf_cv_gcc_inline,[
1840                 cf_save_CFLAGS=$CFLAGS
1841                 CFLAGS="$CFLAGS --param max-inline-insns-single=$2"
1842                 AC_TRY_COMPILE([inline int foo(void) { return 1; }],
1843                 [${cf_cv_main_return:-return} foo()],
1844                 [cf_cv_gcc_inline=yes],
1845                 [cf_cv_gcc_inline=no])
1846                 CFLAGS=$cf_save_CFLAGS
1847                 ])
1848                 if test "$cf_cv_gcc_inline" = yes ; then
1849                         CF_ADD_CFLAGS([--param max-inline-insns-single=$2])
1850                 fi
1851         fi
1852 fi
1853 AC_SUBST($1)
1854 ])dnl
1855 dnl ---------------------------------------------------------------------------
1856 dnl CF_DIRNAME version: 5 updated: 2020/12/31 20:19:42
1857 dnl ----------
1858 dnl "dirname" is not portable, so we fake it with a shell script.
1859 AC_DEFUN([CF_DIRNAME],[$1=`echo "$2" | sed -e 's%/[[^/]]*$%%'`])dnl
1860 dnl ---------------------------------------------------------------------------
1861 dnl CF_DIRS_TO_MAKE version: 4 updated: 2021/01/01 13:31:04
1862 dnl ---------------
1863 AC_DEFUN([CF_DIRS_TO_MAKE],
1864 [
1865 DIRS_TO_MAKE="lib"
1866 for cf_item in $cf_list_models
1867 do
1868         CF_OBJ_SUBDIR($cf_item,cf_subdir)
1869         for cf_item2 in $DIRS_TO_MAKE
1870         do
1871                 test "$cf_item2" = "$cf_subdir" && break
1872         done
1873         test ".$cf_item2" != ".$cf_subdir" && DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
1874 done
1875 for cf_dir in $DIRS_TO_MAKE
1876 do
1877         test ! -d "$cf_dir" && mkdir "$cf_dir"
1878 done
1879 AC_SUBST(DIRS_TO_MAKE)
1880 ])dnl
1881 dnl ---------------------------------------------------------------------------
1882 dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04
1883 dnl ---------------
1884 dnl You can always use "make -n" to see the actual options, but it is hard to
1885 dnl pick out/analyze warning messages when the compile-line is long.
1886 dnl
1887 dnl Sets:
1888 dnl     ECHO_LT - symbol to control if libtool is verbose
1889 dnl     ECHO_LD - symbol to prefix "cc -o" lines
1890 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1891 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
1892 dnl     ECHO_CC - symbol to put before any "cc" line
1893 dnl
1894 AC_DEFUN([CF_DISABLE_ECHO],[
1895 AC_MSG_CHECKING(if you want to see long compiling messages)
1896 CF_ARG_DISABLE(echo,
1897         [  --disable-echo          do not display "compiling" commands],
1898         [
1899         ECHO_LT='--silent'
1900         ECHO_LD='@echo linking [$]@;'
1901         RULE_CC='@echo compiling [$]<'
1902         SHOW_CC='@echo compiling [$]@'
1903         ECHO_CC='@'
1904 ],[
1905         ECHO_LT=''
1906         ECHO_LD=''
1907         RULE_CC=''
1908         SHOW_CC=''
1909         ECHO_CC=''
1910 ])
1911 AC_MSG_RESULT($enableval)
1912 AC_SUBST(ECHO_LT)
1913 AC_SUBST(ECHO_LD)
1914 AC_SUBST(RULE_CC)
1915 AC_SUBST(SHOW_CC)
1916 AC_SUBST(ECHO_CC)
1917 ])dnl
1918 dnl ---------------------------------------------------------------------------
1919 dnl CF_DISABLE_GNAT_PROJECTS version: 1 updated: 2014/06/01 11:34:00
1920 dnl ------------------------
1921 AC_DEFUN([CF_DISABLE_GNAT_PROJECTS],[
1922 AC_MSG_CHECKING(if we want to use GNAT projects)
1923 CF_ARG_DISABLE(gnat-projects,
1924         [  --disable-gnat-projects test: disable GNAT projects even if usable],
1925         [enable_gnat_projects=no],
1926         [enable_gnat_projects=yes])
1927 AC_MSG_RESULT($enable_gnat_projects)
1928 ])dnl
1929 dnl ---------------------------------------------------------------------------
1930 dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50
1931 dnl ----------------
1932 dnl Combine no-leak checks with the libraries or tools that are used for the
1933 dnl checks.
1934 AC_DEFUN([CF_DISABLE_LEAKS],[
1935
1936 AC_REQUIRE([CF_WITH_DMALLOC])
1937 AC_REQUIRE([CF_WITH_DBMALLOC])
1938 AC_REQUIRE([CF_WITH_VALGRIND])
1939
1940 AC_MSG_CHECKING(if you want to perform memory-leak testing)
1941 AC_ARG_ENABLE(leaks,
1942         [  --disable-leaks         test: free permanent memory, analyze leaks],
1943         [enable_leaks=$enableval],
1944         [enable_leaks=yes])
1945 dnl with_no_leaks is more readable...
1946 if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
1947 AC_MSG_RESULT($with_no_leaks)
1948
1949 if test "$enable_leaks" = no ; then
1950         AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
1951         AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
1952 fi
1953 ])dnl
1954 dnl ---------------------------------------------------------------------------
1955 dnl CF_DISABLE_LIBTOOL_VERSION version: 3 updated: 2015/04/17 21:13:04
1956 dnl --------------------------
1957 dnl Check if we should use the libtool 1.5 feature "-version-number" instead of
1958 dnl the older "-version-info" feature.  The newer feature allows us to use
1959 dnl version numbering on shared libraries which make them compatible with
1960 dnl various systems.
1961 AC_DEFUN([CF_DISABLE_LIBTOOL_VERSION],
1962 [
1963 AC_MSG_CHECKING(if libtool -version-number should be used)
1964 CF_ARG_DISABLE(libtool-version,
1965         [  --disable-libtool-version  enable to use libtool's incompatible naming scheme],
1966         [cf_libtool_version=no],
1967         [cf_libtool_version=yes])
1968 AC_MSG_RESULT($cf_libtool_version)
1969
1970 if test "$cf_libtool_version" = yes ; then
1971         LIBTOOL_VERSION="-version-number"
1972 else
1973         LIBTOOL_VERSION="-version-info"
1974         case "x$VERSION" in
1975         (x)
1976                 AC_MSG_WARN(VERSION was not set)
1977                 ;;
1978         (x*.*.*)
1979                 ABI_VERSION="$VERSION"
1980                 CF_VERBOSE(ABI_VERSION: $ABI_VERSION)
1981                 ;;
1982         (x*:*:*)
1983                 ABI_VERSION=`echo "$VERSION" | sed -e 's/:/./g'`
1984                 CF_VERBOSE(ABI_VERSION: $ABI_VERSION)
1985                 ;;
1986         (*)
1987                 AC_MSG_WARN(unexpected VERSION value: $VERSION)
1988                 ;;
1989         esac
1990 fi
1991
1992 AC_SUBST(ABI_VERSION)
1993 AC_SUBST(LIBTOOL_VERSION)
1994 ])dnl
1995 dnl ---------------------------------------------------------------------------
1996 dnl CF_DISABLE_RPATH_HACK version: 3 updated: 2021/01/05 20:14:44
1997 dnl ---------------------
1998 dnl The rpath-hack makes it simpler to build programs, particularly with the
1999 dnl *BSD ports which may have essential libraries in unusual places.  But it
2000 dnl can interfere with building an executable for the base system.  Use this
2001 dnl option in that case.
2002 AC_DEFUN([CF_DISABLE_RPATH_HACK],
2003 [
2004 AC_MSG_CHECKING(if rpath-hack should be disabled)
2005 CF_ARG_DISABLE(rpath-hack,
2006         [  --disable-rpath-hack    don't add rpath options for additional libraries],
2007         [enable_rpath_hack=no],
2008         [enable_rpath_hack=yes])
2009 dnl TODO - drop cf_disable_rpath_hack
2010 if test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
2011 AC_MSG_RESULT($cf_disable_rpath_hack)
2012
2013 if test "$enable_rpath_hack" = yes ; then
2014         CF_RPATH_HACK
2015 fi
2016 ])
2017 dnl ---------------------------------------------------------------------------
2018 dnl CF_ENABLE_BROKEN_LINKER version: 2 updated: 2021/01/02 17:09:14
2019 dnl -----------------------
2020 dnl Some linkers cannot reference a data-only object.  Cygwin used to be one.
2021 dnl This usually follows CF_LINK_DATAONLY, but is not required in case we need
2022 dnl an unconditional feature.
2023 AC_DEFUN([CF_ENABLE_BROKEN_LINKER],[
2024
2025 AC_MSG_CHECKING(if you want broken-linker support code)
2026 AC_ARG_ENABLE(broken_linker,
2027         [  --enable-broken_linker  compile with broken-linker support code],
2028         [with_broken_linker=$enableval],
2029         [with_broken_linker=no])
2030 AC_MSG_RESULT($with_broken_linker)
2031
2032 : "${BROKEN_LINKER:=0}"
2033 if test "x$with_broken_linker" = xyes ; then
2034         AC_DEFINE(BROKEN_LINKER,1,[Define to 1 to work around linkers which cannot link data-only modules])
2035         BROKEN_LINKER=1
2036 fi
2037 AC_SUBST(BROKEN_LINKER)
2038 ])dnl
2039 dnl ---------------------------------------------------------------------------
2040 dnl CF_ENABLE_PC_FILES version: 13 updated: 2015/11/01 05:27:39
2041 dnl ------------------
2042 dnl This is the "--enable-pc-files" option, which is available if there is a
2043 dnl pkg-config configuration on the local machine.
2044 AC_DEFUN([CF_ENABLE_PC_FILES],[
2045 AC_REQUIRE([CF_PKG_CONFIG])
2046 AC_REQUIRE([CF_WITH_PKG_CONFIG_LIBDIR])
2047
2048 if test "x$PKG_CONFIG" != xnone
2049 then
2050         AC_MSG_CHECKING(if we should install .pc files for $PKG_CONFIG)
2051 else
2052         AC_MSG_CHECKING(if we should install .pc files)
2053 fi
2054
2055 AC_ARG_ENABLE(pc-files,
2056         [  --enable-pc-files       generate and install .pc files for pkg-config],
2057         [enable_pc_files=$enableval],
2058         [enable_pc_files=no])
2059 AC_MSG_RESULT($enable_pc_files)
2060
2061 if test "x$enable_pc_files" != xno
2062 then
2063         MAKE_PC_FILES=
2064         case "x$PKG_CONFIG_LIBDIR" in
2065         (xno|xyes)
2066                 AC_MSG_WARN(no PKG_CONFIG_LIBDIR was found)
2067                 ;;
2068         (*)
2069                 CF_PATH_SYNTAX(PKG_CONFIG_LIBDIR)
2070                 ;;
2071         esac
2072 else
2073         MAKE_PC_FILES="#"
2074 fi
2075 AC_SUBST(MAKE_PC_FILES)
2076 ])dnl
2077 dnl ---------------------------------------------------------------------------
2078 dnl CF_ENABLE_RPATH version: 2 updated: 2010/03/27 18:39:42
2079 dnl ---------------
2080 dnl Check if the rpath option should be used, setting cache variable
2081 dnl cf_cv_enable_rpath if so.
2082 AC_DEFUN([CF_ENABLE_RPATH],
2083 [
2084 AC_MSG_CHECKING(if rpath option should be used)
2085 AC_ARG_ENABLE(rpath,
2086 [  --enable-rpath          use rpath option when generating shared libraries],
2087 [cf_cv_enable_rpath=$enableval],
2088 [cf_cv_enable_rpath=no])
2089 AC_MSG_RESULT($cf_cv_enable_rpath)
2090 ])dnl
2091 dnl ---------------------------------------------------------------------------
2092 dnl CF_ENABLE_STRING_HACKS version: 6 updated: 2021/01/05 19:23:48
2093 dnl ----------------------
2094 dnl On a few platforms, the compiler and/or loader nags with untruthful
2095 dnl comments stating that "most" uses of strcat/strcpy/sprintf are incorrect,
2096 dnl and implying that most uses of the recommended alternatives are correct.
2097 dnl
2098 dnl Factually speaking, no one has actually counted the number of uses of these
2099 dnl functions versus the total of incorrect uses.  Samples of a few thousand
2100 dnl instances are meaningless compared to the hundreds of millions of lines of
2101 dnl existing C code.
2102 dnl
2103 dnl strlcat/strlcpy are (as of 2012) non-standard, and are available on some
2104 dnl platforms, in implementations of varying quality.  Likewise, snprintf is
2105 dnl standard - but evolved through phases, and older implementations are likely
2106 dnl to yield surprising results, as documented in manpages on various systems.
2107 AC_DEFUN([CF_ENABLE_STRING_HACKS],
2108 [
2109 AC_MSG_CHECKING(if you want to work around bogus compiler/loader warnings)
2110 AC_ARG_ENABLE(string-hacks,
2111         [  --enable-string-hacks   work around bogus compiler/loader warnings],
2112         [enable_string_hacks=$enableval],
2113         [enable_string_hacks=no])
2114 AC_MSG_RESULT($enable_string_hacks)
2115
2116 if test "x$enable_string_hacks" = "xyes"; then
2117         AC_DEFINE(USE_STRING_HACKS,1,[Define to 1 to work around bogus compiler/loader warnings])
2118         AC_MSG_WARN(enabling string-hacks to work around bogus compiler/loader warnings)
2119         AC_CHECK_FUNC(strlcat,[
2120                 AC_DEFINE(HAVE_STRLCAT,1,[Define to 1 if we have strlcat function])
2121                 ],[
2122                 AC_CHECK_LIB(bsd,strlcat,[
2123                         CF_ADD_LIB(bsd)
2124                         AC_CHECK_HEADERS(bsd/string.h)
2125                         AC_DEFINE(HAVE_STRLCAT,1,[Define to 1 if we have strlcat function])
2126                         ])
2127                 ])
2128         AC_CHECK_FUNCS( strlcpy snprintf )
2129 fi
2130 ])dnl
2131 dnl ---------------------------------------------------------------------------
2132 dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
2133 dnl ------------------
2134 dnl Configure-option to enable gcc warnings
2135 dnl
2136 dnl $1 = extra options to add, if supported
2137 dnl $2 = option for checking attributes.  By default, this is done when
2138 dnl      warnings are enabled.  For other values:
2139 dnl      yes: always do this, e.g., to use in generated library-headers
2140 dnl      no: never do this
2141 AC_DEFUN([CF_ENABLE_WARNINGS],[
2142 if test "$GCC" = yes || test "$GXX" = yes
2143 then
2144 CF_FIX_WARNINGS(CFLAGS)
2145 CF_FIX_WARNINGS(CPPFLAGS)
2146 CF_FIX_WARNINGS(LDFLAGS)
2147 AC_MSG_CHECKING(if you want to turn on gcc warnings)
2148 CF_ARG_ENABLE(warnings,
2149         [  --enable-warnings       test: turn on gcc compiler warnings],
2150         [enable_warnings=yes],
2151         [enable_warnings=no])
2152 AC_MSG_RESULT($enable_warnings)
2153 if test "$enable_warnings" = "yes"
2154 then
2155         ifelse($2,,[CF_GCC_ATTRIBUTES])
2156         CF_GCC_WARNINGS($1)
2157 fi
2158 ifelse($2,yes,[CF_GCC_ATTRIBUTES])
2159 fi
2160 ])dnl
2161 dnl ---------------------------------------------------------------------------
2162 dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
2163 dnl --------
2164 dnl Check if 'errno' is declared in <errno.h>
2165 AC_DEFUN([CF_ERRNO],
2166 [
2167 CF_CHECK_ERRNO(errno)
2168 ])dnl
2169 dnl ---------------------------------------------------------------------------
2170 dnl CF_ETIP_DEFINES version: 6 updated: 2021/01/02 17:09:14
2171 dnl ---------------
2172 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
2173 dnl math.h and builtin.h, only for ncurses
2174 AC_DEFUN([CF_ETIP_DEFINES],
2175 [
2176 AC_MSG_CHECKING(for special defines needed for etip.h)
2177 cf_save_CXXFLAGS="$CXXFLAGS"
2178 cf_result="none"
2179
2180 # etip.h includes ncurses.h which includes ncurses_dll.h
2181 # But ncurses_dll.h is generated - fix here.
2182 test -d include || mkdir include
2183 test -f include/ncurses_dll.h || sed -e 's/@NCURSES_WRAP_PREFIX@/'$NCURSES_WRAP_PREFIX'/g' "${srcdir}/include/ncurses_dll.h.in" >include/ncurses_dll.h
2184
2185 for cf_math in "" MATH_H
2186 do
2187 for cf_excp in "" MATH_EXCEPTION
2188 do
2189         CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -Iinclude -I${srcdir}/include"
2190         test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
2191         test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
2192 AC_TRY_COMPILE([
2193 #include <etip.h.in>
2194 ],[],[
2195         test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
2196         test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
2197         cf_result="$cf_math $cf_excp"
2198         break 2
2199 ],[])
2200 done
2201 done
2202 AC_MSG_RESULT($cf_result)
2203 CXXFLAGS="$cf_save_CXXFLAGS"
2204 ])
2205 dnl ---------------------------------------------------------------------------
2206 dnl CF_FIND_LINKAGE version: 22 updated: 2020/12/31 20:19:42
2207 dnl ---------------
2208 dnl Find a library (specifically the linkage used in the code fragment),
2209 dnl searching for it if it is not already in the library path.
2210 dnl See also CF_ADD_SEARCHPATH.
2211 dnl
2212 dnl Parameters (4-on are optional):
2213 dnl     $1 = headers for library entrypoint
2214 dnl     $2 = code fragment for library entrypoint
2215 dnl     $3 = the library name without the "-l" option or ".so" suffix.
2216 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
2217 dnl     $5 = action to perform if not successful
2218 dnl     $6 = module name, if not the same as the library name
2219 dnl     $7 = extra libraries
2220 dnl
2221 dnl Sets these variables:
2222 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
2223 dnl     $cf_cv_header_path_$3 - include-directory if needed
2224 dnl     $cf_cv_library_path_$3 - library-directory if needed
2225 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
2226 AC_DEFUN([CF_FIND_LINKAGE],[
2227
2228 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
2229 # will be set on completion of the AC_TRY_LINK below.
2230 cf_cv_header_path_$3=
2231 cf_cv_library_path_$3=
2232
2233 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
2234
2235 cf_save_LIBS="$LIBS"
2236
2237 AC_TRY_LINK([$1],[$2],[
2238         cf_cv_find_linkage_$3=yes
2239         cf_cv_header_path_$3=/usr/include
2240         cf_cv_library_path_$3=/usr/lib
2241 ],[
2242
2243 LIBS="-l$3 $7 $cf_save_LIBS"
2244
2245 AC_TRY_LINK([$1],[$2],[
2246         cf_cv_find_linkage_$3=yes
2247         cf_cv_header_path_$3=/usr/include
2248         cf_cv_library_path_$3=/usr/lib
2249         cf_cv_library_file_$3="-l$3"
2250 ],[
2251         cf_cv_find_linkage_$3=no
2252         LIBS="$cf_save_LIBS"
2253
2254         CF_VERBOSE(find linkage for $3 library)
2255         CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
2256
2257         cf_save_CPPFLAGS="$CPPFLAGS"
2258         cf_test_CPPFLAGS="$CPPFLAGS"
2259
2260         CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
2261         for cf_cv_header_path_$3 in $cf_search
2262         do
2263                 if test -d "$cf_cv_header_path_$3" ; then
2264                         CF_VERBOSE(... testing $cf_cv_header_path_$3)
2265                         CPPFLAGS="$cf_save_CPPFLAGS"
2266                         CF_APPEND_TEXT(CPPFLAGS,-I$cf_cv_header_path_$3)
2267                         AC_TRY_COMPILE([$1],[$2],[
2268                                 CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
2269                                 cf_cv_find_linkage_$3=maybe
2270                                 cf_test_CPPFLAGS="$CPPFLAGS"
2271                                 break],[
2272                                 CPPFLAGS="$cf_save_CPPFLAGS"
2273                                 ])
2274                 fi
2275         done
2276
2277         if test "$cf_cv_find_linkage_$3" = maybe ; then
2278
2279                 CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
2280
2281                 cf_save_LIBS="$LIBS"
2282                 cf_save_LDFLAGS="$LDFLAGS"
2283
2284                 ifelse([$6],,,[
2285                 CPPFLAGS="$cf_test_CPPFLAGS"
2286                 LIBS="-l$3 $7 $cf_save_LIBS"
2287                 AC_TRY_LINK([$1],[$2],[
2288                         CF_VERBOSE(... found $3 library in system)
2289                         cf_cv_find_linkage_$3=yes])
2290                         CPPFLAGS="$cf_save_CPPFLAGS"
2291                         LIBS="$cf_save_LIBS"
2292                         ])
2293
2294                 if test "$cf_cv_find_linkage_$3" != yes ; then
2295                         CF_LIBRARY_PATH(cf_search,$3)
2296                         for cf_cv_library_path_$3 in $cf_search
2297                         do
2298                                 if test -d "$cf_cv_library_path_$3" ; then
2299                                         CF_VERBOSE(... testing $cf_cv_library_path_$3)
2300                                         CPPFLAGS="$cf_test_CPPFLAGS"
2301                                         LIBS="-l$3 $7 $cf_save_LIBS"
2302                                         LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
2303                                         AC_TRY_LINK([$1],[$2],[
2304                                         CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
2305                                         cf_cv_find_linkage_$3=yes
2306                                         cf_cv_library_file_$3="-l$3"
2307                                         break],[
2308                                         CPPFLAGS="$cf_save_CPPFLAGS"
2309                                         LIBS="$cf_save_LIBS"
2310                                         LDFLAGS="$cf_save_LDFLAGS"
2311                                         ])
2312                                 fi
2313                         done
2314                         CPPFLAGS="$cf_save_CPPFLAGS"
2315                         LDFLAGS="$cf_save_LDFLAGS"
2316                 fi
2317
2318         else
2319                 cf_cv_find_linkage_$3=no
2320         fi
2321         ],$7)
2322 ])
2323
2324 LIBS="$cf_save_LIBS"
2325
2326 if test "$cf_cv_find_linkage_$3" = yes ; then
2327 ifelse([$4],,[
2328         CF_ADD_INCDIR($cf_cv_header_path_$3)
2329         CF_ADD_LIBDIR($cf_cv_library_path_$3)
2330         CF_ADD_LIB($3)
2331 ],[$4])
2332 else
2333 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
2334 fi
2335 ])dnl
2336 dnl ---------------------------------------------------------------------------
2337 dnl CF_FIND_SUB_INCDIR version: 3 updated: 2021/01/01 13:31:04
2338 dnl ------------------
2339 dnl Find an include-directory with the given leaf-name.  This is useful for
2340 dnl example with FreeBSD ports, which use this convention to distinguish
2341 dnl different versions of the same port.
2342 AC_DEFUN([CF_FIND_SUB_INCDIR],[
2343         CF_SUBDIR_PATH(cf_search,$1,include)
2344         for cf_item in $cf_search
2345         do
2346                 case "$cf_item" in
2347                 (*/$1)
2348                         CF_ADD_INCDIR($cf_item)
2349                         ;;
2350                 esac
2351         done
2352 ])dnl
2353 dnl ---------------------------------------------------------------------------
2354 dnl CF_FIND_SUB_LIBDIR version: 3 updated: 2021/01/01 13:31:04
2355 dnl ------------------
2356 dnl Find a library-directory with the given leaf-name.  This is useful for
2357 dnl example with FreeBSD ports, which use this convention to distinguish
2358 dnl different versions of the same port.
2359 AC_DEFUN([CF_FIND_SUB_LIBDIR],[
2360         CF_SUBDIR_PATH(cf_search,$1,lib)
2361         for cf_item in $cf_search
2362         do
2363                 case "$cf_item" in
2364                 (*/$1)
2365                         CF_ADD_LIBDIR($cf_item)
2366                         ;;
2367                 esac
2368         done
2369 ])dnl
2370 dnl ---------------------------------------------------------------------------
2371 dnl CF_FIXUP_ADAFLAGS version: 2 updated: 2015/04/17 21:13:04
2372 dnl -----------------
2373 dnl make ADAFLAGS consistent with CFLAGS
2374 AC_DEFUN([CF_FIXUP_ADAFLAGS],[
2375         AC_MSG_CHECKING(optimization options for ADAFLAGS)
2376         case "$CFLAGS" in
2377         (*-g*)
2378                 CF_ADD_ADAFLAGS(-g)
2379                 ;;
2380         esac
2381         case "$CFLAGS" in
2382         (*-O*)
2383                 cf_O_flag=`echo "$CFLAGS" |sed -e 's/^.*-O/-O/' -e 's/[[        ]].*//'`
2384                 CF_ADD_ADAFLAGS($cf_O_flag)
2385                 ;;
2386         esac
2387         AC_MSG_RESULT($ADAFLAGS)
2388 ])dnl
2389 dnl ---------------------------------------------------------------------------
2390 dnl CF_FIX_WARNINGS version: 3 updated: 2020/12/31 18:40:20
2391 dnl ---------------
2392 dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
2393 dnl "-Werror" flags can interfere with configure-checks.  Those go into
2394 dnl EXTRA_CFLAGS.
2395 dnl
2396 dnl $1 = variable name to repair
2397 define([CF_FIX_WARNINGS],[
2398 if test "$GCC" = yes || test "$GXX" = yes
2399 then
2400         case [$]$1 in
2401         (*-Werror=*)
2402                 CF_VERBOSE(repairing $1: [$]$1)
2403                 cf_temp_flags=
2404                 for cf_temp_scan in [$]$1
2405                 do
2406                         case "x$cf_temp_scan" in
2407                         (x-Werror=*)
2408                                 CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
2409                                 ;;
2410                         (*)
2411                                 CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
2412                                 ;;
2413                         esac
2414                 done
2415                 $1="$cf_temp_flags"
2416                 CF_VERBOSE(... fixed [$]$1)
2417                 CF_VERBOSE(... extra $EXTRA_CFLAGS)
2418                 ;;
2419         esac
2420 fi
2421 AC_SUBST(EXTRA_CFLAGS)
2422 ])dnl
2423 dnl ---------------------------------------------------------------------------
2424 dnl CF_FOPEN_BIN_R version: 2 updated: 2019/12/31 08:53:54
2425 dnl --------------
2426 dnl Check if fopen works when the "b" (binary) flag is added to the mode
2427 dnl parameter.  POSIX ignores the "b", which c89 specified.  Some very old
2428 dnl systems do not accept it.
2429 AC_DEFUN([CF_FOPEN_BIN_R],[
2430 AC_CACHE_CHECK(if fopen accepts explicit binary mode,cf_cv_fopen_bin_r,[
2431         AC_TRY_RUN([
2432 #include <stdio.h>
2433 int main(void) {
2434         FILE *fp = fopen("conftest.tmp", "wb");
2435         int rc = 0;
2436         if (fp != 0) {
2437                 int p, q;
2438                 for (p = 0; p < 256; ++p) {
2439                         fputc(p, fp);
2440                 }
2441                 fclose(fp);
2442                 fp = fopen("conftest.tmp", "rb");
2443                 if (fp != 0) {
2444                         for (p = 0; p < 256; ++p) {
2445                                 q = fgetc(fp);
2446                                 if (q != p) {
2447                                         rc = 1;
2448                                         break;
2449                                 }
2450                         }
2451                 } else {
2452                         rc = 1;
2453                 }
2454         } else {
2455                 rc = 1;
2456         }
2457         ${cf_cv_main_return:-return} (rc);
2458 }
2459 ],
2460                 [cf_cv_fopen_bin_r=yes],
2461                 [cf_cv_fopen_bin_r=no],
2462                 [cf_cv_fopen_bin_r=unknown])
2463 ])
2464 test "x$cf_cv_fopen_bin_r" != xno && AC_DEFINE(USE_FOPEN_BIN_R,1,[Define to 1 if fopen accepts explicit binary mode])
2465 ])dnl
2466 dnl ---------------------------------------------------------------------------
2467 dnl CF_FORGET_TOOL version: 1 updated: 2013/04/06 18:03:09
2468 dnl --------------
2469 dnl Forget that we saw the given tool.
2470 AC_DEFUN([CF_FORGET_TOOL],[
2471 unset ac_cv_prog_ac_ct_$1
2472 unset ac_ct_$1
2473 unset $1
2474 ])dnl
2475 dnl ---------------------------------------------------------------------------
2476 dnl CF_FUNC_DLSYM version: 4 updated: 2015/09/12 14:46:44
2477 dnl -------------
2478 dnl Test for dlsym() and related functions, as well as libdl.
2479 dnl
2480 dnl Sets
2481 dnl     $cf_have_dlsym
2482 dnl     $cf_have_libdl
2483 AC_DEFUN([CF_FUNC_DLSYM],[
2484 cf_have_dlsym=no
2485 AC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
2486
2487 cf_have_libdl=no
2488 AC_CHECK_LIB(dl,dlsym,[
2489         cf_have_dlsym=yes
2490         cf_have_libdl=yes])])
2491
2492 if test "$cf_have_dlsym" = yes ; then
2493         test "$cf_have_libdl" = yes && { CF_ADD_LIB(dl) }
2494
2495         AC_MSG_CHECKING(whether able to link to dl*() functions)
2496         AC_TRY_LINK([#include <dlfcn.h>],[
2497                 void *obj;
2498                 if ((obj = dlopen("filename", 0)) != 0) {
2499                         if (dlsym(obj, "symbolname") == 0) {
2500                         dlclose(obj);
2501                         }
2502                 }],[
2503                 AC_DEFINE(HAVE_LIBDL,1,[Define to 1 if we have dl library])],[
2504                 AC_MSG_ERROR(Cannot link test program for libdl)])
2505         AC_MSG_RESULT(ok)
2506 else
2507         AC_MSG_ERROR(Cannot find dlsym function)
2508 fi
2509 ])
2510 dnl ---------------------------------------------------------------------------
2511 dnl CF_FUNC_MEMMOVE version: 9 updated: 2017/01/21 11:06:25
2512 dnl ---------------
2513 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
2514 dnl is found, add our own version of memmove to the list of objects.
2515 AC_DEFUN([CF_FUNC_MEMMOVE],
2516 [
2517 AC_CHECK_FUNC(memmove,,[
2518 AC_CHECK_FUNC(bcopy,[
2519         AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
2520                 AC_TRY_RUN([
2521 int main(void) {
2522         static char data[] = "abcdefghijklmnopqrstuwwxyz";
2523         char temp[40];
2524         bcopy(data, temp, sizeof(data));
2525         bcopy(temp+10, temp, 15);
2526         bcopy(temp+5, temp+15, 10);
2527         ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
2528 }
2529                 ],
2530                 [cf_cv_good_bcopy=yes],
2531                 [cf_cv_good_bcopy=no],
2532                 [cf_cv_good_bcopy=unknown])
2533                 ])
2534         ],[cf_cv_good_bcopy=no])
2535         if test "$cf_cv_good_bcopy" = yes ; then
2536                 AC_DEFINE(USE_OK_BCOPY,1,[Define to 1 to use bcopy when memmove is unavailable])
2537         else
2538                 AC_DEFINE(USE_MY_MEMMOVE,1,[Define to 1 to use replacement function when memmove is unavailable])
2539         fi
2540 ])])dnl
2541 dnl ---------------------------------------------------------------------------
2542 dnl CF_FUNC_NANOSLEEP version: 5 updated: 2017/01/21 11:06:25
2543 dnl -----------------
2544 dnl Check for existence of workable nanosleep() function.  Some systems, e.g.,
2545 dnl AIX 4.x, provide a non-working version.
2546 AC_DEFUN([CF_FUNC_NANOSLEEP],[
2547 AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[
2548 AC_TRY_RUN([
2549 #include <stdio.h>
2550 #include <errno.h>
2551 #include <time.h>
2552
2553 #ifdef HAVE_SYS_TIME_H
2554 #include <sys/time.h>
2555 #endif
2556
2557 int main(void) {
2558         struct timespec ts1, ts2;
2559         int code;
2560         ts1.tv_sec  = 0;
2561         ts1.tv_nsec = 750000000;
2562         ts2.tv_sec  = 0;
2563         ts2.tv_nsec = 0;
2564         errno = 0;
2565         code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */
2566         ${cf_cv_main_return:-return}(code != 0);
2567 }
2568 ],
2569         [cf_cv_func_nanosleep=yes],
2570         [cf_cv_func_nanosleep=no],
2571         [cf_cv_func_nanosleep=unknown])])
2572
2573 test "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP,1,[Define to 1 if we have nanosleep()])
2574 ])
2575 dnl ---------------------------------------------------------------------------
2576 dnl CF_FUNC_OPENPTY version: 6 updated: 2021/01/01 13:31:04
2577 dnl ---------------
2578 dnl Check for openpty() function, along with <pty.h> header.  It may need the
2579 dnl "util" library as well.
2580 AC_DEFUN([CF_FUNC_OPENPTY],
2581 [
2582 AC_CHECK_LIB(util,openpty,cf_cv_lib_util=yes,cf_cv_lib_util=no)
2583 AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
2584         cf_save_LIBS="$LIBS"
2585         test "$cf_cv_lib_util" = yes && { CF_ADD_LIB(util) }
2586         for cf_header in pty.h libutil.h util.h
2587         do
2588         AC_TRY_LINK([
2589 #include <$cf_header>
2590 ],[
2591         int x = openpty((int *)0, (int *)0, (char *)0,
2592                                    (struct termios *)0, (struct winsize *)0);
2593 ],[
2594                 cf_cv_func_openpty=$cf_header
2595                 break
2596 ],[
2597                 cf_cv_func_openpty=no
2598 ])
2599         done
2600         LIBS="$cf_save_LIBS"
2601 ])
2602 ])dnl
2603 dnl ---------------------------------------------------------------------------
2604 dnl CF_FUNC_POLL version: 10 updated: 2021/01/04 19:13:57
2605 dnl ------------
2606 dnl See if the poll function really works.  Some platforms have poll(), but
2607 dnl it does not work for terminals or files.
2608 AC_DEFUN([CF_FUNC_POLL],[
2609 tty >/dev/null 2>&1 || { AC_CHECK_FUNCS(posix_openpt) }
2610 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
2611 AC_TRY_RUN([
2612 #include <stdlib.h>
2613 #include <stdio.h>
2614 #include <unistd.h>
2615 #include <fcntl.h>
2616 #ifdef HAVE_POLL_H
2617 #include <poll.h>
2618 #else
2619 #include <sys/poll.h>
2620 #endif
2621 int main(void) {
2622         struct pollfd myfds;
2623         int ret;
2624
2625         /* check for Darwin bug with respect to "devices" */
2626         myfds.fd = open("/dev/null", 1);        /* O_WRONLY */
2627         if (myfds.fd < 0)
2628                 myfds.fd = 0;
2629         myfds.events = POLLIN;
2630         myfds.revents = 0;
2631
2632         ret = poll(&myfds, 1, 100);
2633
2634         if (ret < 0 || (myfds.revents & POLLNVAL)) {
2635                 ret = -1;
2636         } else {
2637                 int fd = 0;
2638                 if (!isatty(fd)) {
2639                         fd = open("/dev/tty", 2);       /* O_RDWR */
2640                 }
2641 #ifdef HAVE_POSIX_OPENPT
2642                 if (fd < 0) {
2643                         fd = posix_openpt(O_RDWR);
2644                 }
2645 #endif
2646
2647                 if (fd >= 0) {
2648                         /* also check with standard input */
2649                         myfds.fd = fd;
2650                         myfds.events = POLLIN;
2651                         myfds.revents = 0;
2652                         ret = poll(&myfds, 1, 100);
2653                 } else {
2654                         ret = -1;
2655                 }
2656         }
2657         ${cf_cv_main_return:-return}(ret < 0);
2658 }],
2659         [cf_cv_working_poll=yes],
2660         [cf_cv_working_poll=no],
2661         [cf_cv_working_poll=unknown])])
2662 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL,1,[Define to 1 if the poll function seems to work])
2663 ])dnl
2664 dnl ---------------------------------------------------------------------------
2665 dnl CF_FUNC_TERMIOS version: 3 updated: 2012/10/06 17:56:13
2666 dnl ---------------
2667 dnl Some old/broken variations define tcgetattr() only as a macro in
2668 dnl termio(s).h
2669 AC_DEFUN([CF_FUNC_TERMIOS],[
2670 AC_REQUIRE([CF_STRUCT_TERMIOS])
2671 AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
2672 AC_TRY_LINK([
2673 #include <sys/types.h>
2674 #ifdef HAVE_UNISTD_H
2675 #include <unistd.h>
2676 #endif
2677 #ifdef HAVE_TERMIOS_H
2678 #include <termios.h>
2679 #define TTY struct termios
2680 #else
2681 #ifdef HAVE_TERMIO_H
2682 #include <termio.h>
2683 #define TTY struct termio
2684 #endif
2685 #endif
2686 ],[
2687 TTY foo;
2688 tcgetattr(1, &foo);],
2689 [cf_cv_have_tcgetattr=yes],
2690 [cf_cv_have_tcgetattr=no])])
2691 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR,1,[Define to 1 if we have tcgetattr])
2692 ])dnl
2693 dnl ---------------------------------------------------------------------------
2694 dnl CF_FUNC_VSSCANF version: 7 updated: 2021/01/01 13:31:04
2695 dnl ---------------
2696 dnl Check for vsscanf() function, which is in c9x but generally not in earlier
2697 dnl versions of C.  It is in the GNU C library, and can often be simulated by
2698 dnl other functions.
2699 AC_DEFUN([CF_FUNC_VSSCANF],
2700 [
2701 AC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
2702 AC_TRY_LINK([
2703 #include <stdarg.h>
2704 #include <stdio.h>],[
2705         va_list ap;
2706         vsscanf("from", "%d", ap)],[cf_cv_func_vsscanf=vsscanf],[
2707 AC_TRY_LINK([
2708 #include <stdarg.h>
2709 #include <stdio.h>],[
2710         FILE strbuf;
2711         char *str = "from";
2712
2713         strbuf._flag = _IOREAD;
2714         strbuf._ptr = strbuf._base = (unsigned char *) str;
2715         strbuf._cnt = strlen(str);
2716         strbuf._file = _NFILE;
2717         return (vfscanf(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=vfscanf],[
2718 AC_TRY_LINK([
2719 #include <stdarg.h>
2720 #include <stdio.h>],[
2721         FILE strbuf;
2722         char *str = "from";
2723
2724         strbuf._flag = _IOREAD;
2725         strbuf._ptr = strbuf._base = (unsigned char *) str;
2726         strbuf._cnt = strlen(str);
2727         strbuf._file = _NFILE;
2728         return (_doscan(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=_doscan],[
2729 cf_cv_func_vsscanf=no])])])])
2730
2731 case "$cf_cv_func_vsscanf" in
2732 (vsscanf) AC_DEFINE(HAVE_VSSCANF,1,[Define to 1 if we have vsscanf]);;
2733 (vfscanf) AC_DEFINE(HAVE_VFSCANF,1,[Define to 1 if we have vfscanf]);;
2734 (_doscan) AC_DEFINE(HAVE__DOSCAN,1,[Define to 1 if we have _doscan]);;
2735 esac
2736
2737 ])dnl
2738 dnl ---------------------------------------------------------------------------
2739 dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25
2740 dnl -----------------
2741 dnl Test for availability of useful gcc __attribute__ directives to quiet
2742 dnl compiler warnings.  Though useful, not all are supported -- and contrary
2743 dnl to documentation, unrecognized directives cause older compilers to barf.
2744 AC_DEFUN([CF_GCC_ATTRIBUTES],
2745 [AC_REQUIRE([AC_PROG_FGREP])dnl
2746 AC_REQUIRE([CF_C11_NORETURN])dnl
2747
2748 if test "$GCC" = yes || test "$GXX" = yes
2749 then
2750 cat > conftest.i <<EOF
2751 #ifndef GCC_PRINTF
2752 #define GCC_PRINTF 0
2753 #endif
2754 #ifndef GCC_SCANF
2755 #define GCC_SCANF 0
2756 #endif
2757 #ifndef GCC_NORETURN
2758 #define GCC_NORETURN /* nothing */
2759 #endif
2760 #ifndef GCC_UNUSED
2761 #define GCC_UNUSED /* nothing */
2762 #endif
2763 EOF
2764 if test "$GCC" = yes
2765 then
2766         AC_CHECKING([for $CC __attribute__ directives])
2767 cat > "conftest.$ac_ext" <<EOF
2768 #line __oline__ "${as_me:-configure}"
2769 #include "confdefs.h"
2770 #include "conftest.h"
2771 #include "conftest.i"
2772 #if     GCC_PRINTF
2773 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
2774 #else
2775 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
2776 #endif
2777 #if     GCC_SCANF
2778 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
2779 #else
2780 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
2781 #endif
2782 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
2783 extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
2784 extern GCC_NORETURN void foo(void);
2785 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
2786 EOF
2787         cf_printf_attribute=no
2788         cf_scanf_attribute=no
2789         for cf_attribute in scanf printf unused noreturn
2790         do
2791                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
2792                 cf_directive="__attribute__(($cf_attribute))"
2793                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
2794
2795                 case "$cf_attribute" in
2796                 (printf)
2797                         cf_printf_attribute=yes
2798                         cat >conftest.h <<EOF
2799 #define GCC_$cf_ATTRIBUTE 1
2800 EOF
2801                         ;;
2802                 (scanf)
2803                         cf_scanf_attribute=yes
2804                         cat >conftest.h <<EOF
2805 #define GCC_$cf_ATTRIBUTE 1
2806 EOF
2807                         ;;
2808                 (*)
2809                         cat >conftest.h <<EOF
2810 #define GCC_$cf_ATTRIBUTE $cf_directive
2811 EOF
2812                         ;;
2813                 esac
2814
2815                 if AC_TRY_EVAL(ac_compile); then
2816                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
2817                         cat conftest.h >>confdefs.h
2818                         case "$cf_attribute" in
2819                         (noreturn)
2820                                 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
2821                                 ;;
2822                         (printf)
2823                                 cf_value='/* nothing */'
2824                                 if test "$cf_printf_attribute" != no ; then
2825                                         cf_value='__attribute__((format(printf,fmt,var)))'
2826                                         AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
2827                                 fi
2828                                 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
2829                                 ;;
2830                         (scanf)
2831                                 cf_value='/* nothing */'
2832                                 if test "$cf_scanf_attribute" != no ; then
2833                                         cf_value='__attribute__((format(scanf,fmt,var)))'
2834                                         AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
2835                                 fi
2836                                 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
2837                                 ;;
2838                         (unused)
2839                                 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
2840                                 ;;
2841                         esac
2842                 fi
2843         done
2844 else
2845         ${FGREP-fgrep} define conftest.i >>confdefs.h
2846 fi
2847 rm -rf ./conftest*
2848 fi
2849 ])dnl
2850 dnl ---------------------------------------------------------------------------
2851 dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
2852 dnl --------------
2853 dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
2854 dnl compatible), attempt to determine if icc/clang is actually used.
2855 AC_DEFUN([CF_GCC_VERSION],[
2856 AC_REQUIRE([AC_PROG_CC])
2857 GCC_VERSION=none
2858 if test "$GCC" = yes ; then
2859         AC_MSG_CHECKING(version of $CC)
2860         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
2861         test -z "$GCC_VERSION" && GCC_VERSION=unknown
2862         AC_MSG_RESULT($GCC_VERSION)
2863 fi
2864 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
2865 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
2866 ])dnl
2867 dnl ---------------------------------------------------------------------------
2868 dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59
2869 dnl ---------------
2870 dnl Check if the compiler supports useful warning options.  There's a few that
2871 dnl we don't use, simply because they're too noisy:
2872 dnl
2873 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
2874 dnl     -Winline (usually not worthwhile)
2875 dnl     -Wredundant-decls (system headers make this too noisy)
2876 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
2877 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
2878 dnl             is enabled for ncurses using "--enable-const".
2879 dnl     -pedantic
2880 dnl
2881 dnl Parameter:
2882 dnl     $1 is an optional list of gcc warning flags that a particular
2883 dnl             application might want to use, e.g., "no-unused" for
2884 dnl             -Wno-unused
2885 dnl Special:
2886 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
2887 dnl
2888 AC_DEFUN([CF_GCC_WARNINGS],
2889 [
2890 AC_REQUIRE([CF_GCC_VERSION])
2891 if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
2892 cat > "conftest.$ac_ext" <<EOF
2893 #line __oline__ "${as_me:-configure}"
2894 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
2895 EOF
2896 if test "$INTEL_COMPILER" = yes
2897 then
2898 # The "-wdXXX" options suppress warnings:
2899 # remark #1419: external declaration in primary source file
2900 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2901 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
2902 # remark #193: zero used for undefined preprocessing identifier
2903 # remark #593: variable "curs_sb_left_arrow" was set but never used
2904 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
2905 # remark #869: parameter "tw" was never referenced
2906 # remark #981: operands are evaluated in unspecified order
2907 # warning #279: controlling expression is constant
2908
2909         AC_CHECKING([for $CC warning options])
2910         cf_save_CFLAGS="$CFLAGS"
2911         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
2912         for cf_opt in \
2913                 wd1419 \
2914                 wd1683 \
2915                 wd1684 \
2916                 wd193 \
2917                 wd593 \
2918                 wd279 \
2919                 wd810 \
2920                 wd869 \
2921                 wd981
2922         do
2923                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2924                 if AC_TRY_EVAL(ac_compile); then
2925                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2926                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2927                 fi
2928         done
2929         CFLAGS="$cf_save_CFLAGS"
2930 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
2931 then
2932         AC_CHECKING([for $CC warning options])
2933         cf_save_CFLAGS="$CFLAGS"
2934         cf_warn_CONST=""
2935         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
2936         cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
2937         test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
2938         for cf_opt in W Wall \
2939                 Wbad-function-cast \
2940                 Wcast-align \
2941                 Wcast-qual \
2942                 Wdeclaration-after-statement \
2943                 Wextra \
2944                 Winline \
2945                 Wmissing-declarations \
2946                 Wmissing-prototypes \
2947                 Wnested-externs \
2948                 Wpointer-arith \
2949                 Wshadow \
2950                 Wstrict-prototypes \
2951                 Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
2952         do
2953                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2954                 if AC_TRY_EVAL(ac_compile); then
2955                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2956                         case "$cf_opt" in
2957                         (Winline)
2958                                 case "$GCC_VERSION" in
2959                                 ([[34]].*)
2960                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
2961                                         continue;;
2962                                 esac
2963                                 ;;
2964                         (Wpointer-arith)
2965                                 case "$GCC_VERSION" in
2966                                 ([[12]].*)
2967                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
2968                                         continue;;
2969                                 esac
2970                                 ;;
2971                         esac
2972                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2973                 fi
2974         done
2975         CFLAGS="$cf_save_CFLAGS"
2976 fi
2977 rm -rf ./conftest*
2978
2979 AC_SUBST(EXTRA_CFLAGS)
2980 ])dnl
2981 dnl ---------------------------------------------------------------------------
2982 dnl CF_GETOPT_HEADER version: 8 updated: 2021/06/19 19:16:16
2983 dnl ----------------
2984 dnl Check for getopt's variables which are commonly defined in stdlib.h,
2985 dnl unistd.h or (nonstandard) in getopt.h
2986 AC_DEFUN([CF_GETOPT_HEADER],
2987 [
2988 AC_HAVE_HEADERS(unistd.h getopt.h)
2989 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
2990 cf_cv_getopt_header=none
2991 for cf_header in stdio.h stdlib.h unistd.h getopt.h
2992 do
2993 AC_TRY_COMPILE([
2994 #include <$cf_header>],
2995 [int x = optind; char *y = optarg; (void)x; (void)y],
2996 [cf_cv_getopt_header=$cf_header
2997  break])
2998 done
2999 ])
3000 if test "$cf_cv_getopt_header" != none ; then
3001         AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
3002 fi
3003 if test "$cf_cv_getopt_header" = getopt.h ; then
3004         AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
3005 fi
3006 ])dnl
3007 dnl ---------------------------------------------------------------------------
3008 dnl CF_GNATPREP_OPT_T version: 1 updated: 2014/08/02 18:37:25
3009 dnl -----------------
3010 AC_DEFUN([CF_GNATPREP_OPT_T],[
3011 AC_CACHE_CHECK(if GNATPREP supports -T option,cf_cv_gnatprep_opt_t,[
3012 cf_cv_gnatprep_opt_t=no
3013 gnatprep -T 2>/dev/null >/dev/null && cf_cv_gnatprep_opt_t=yes
3014 ])
3015 test "$cf_cv_gnatprep_opt_t" = yes && GNATPREP_OPTS="-T $GNATPREP_OPTS"
3016 AC_SUBST(GNATPREP_OPTS)
3017 ])dnl
3018 dnl ---------------------------------------------------------------------------
3019 dnl CF_GNAT_GENERICS version: 7 updated: 2021/01/01 13:31:04
3020 dnl ----------------
3021 AC_DEFUN([CF_GNAT_GENERICS],
3022 [
3023 AC_REQUIRE([CF_GNAT_VERSION])
3024
3025 AC_MSG_CHECKING(if GNAT supports generics)
3026 case "$cf_cv_gnat_version" in
3027 (3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*|[[1-9]][[0-9]].[[0-9]]*|20[[0-9]][[0-9]])
3028         cf_gnat_generics=yes
3029         ;;
3030 (*)
3031         cf_gnat_generics=no
3032         ;;
3033 esac
3034 AC_MSG_RESULT($cf_gnat_generics)
3035
3036 if test "$cf_gnat_generics" = yes
3037 then
3038         cf_compile_generics=generics
3039         cf_generic_objects="\${GENOBJS}"
3040 else
3041         cf_compile_generics=
3042         cf_generic_objects=
3043 fi
3044
3045 AC_SUBST(cf_compile_generics)
3046 AC_SUBST(cf_generic_objects)
3047 ])dnl
3048 dnl ---------------------------------------------------------------------------
3049 dnl CF_GNAT_PROJECTS version: 13 updated: 2021/01/02 17:09:14
3050 dnl ----------------
3051 dnl GNAT projects are configured with ".gpr" project files.
3052 dnl GNAT libraries are a further development, using the project feature.
3053 AC_DEFUN([CF_GNAT_PROJECTS],
3054 [
3055 AC_REQUIRE([CF_GNAT_VERSION])
3056 AC_REQUIRE([CF_DISABLE_GNAT_PROJECTS])
3057
3058 cf_gnat_libraries=no
3059 cf_gnat_projects=no
3060
3061 if test "$enable_gnat_projects" != no ; then
3062 AC_MSG_CHECKING(if GNAT supports project files)
3063 case "$cf_cv_gnat_version" in
3064 (3.[[0-9]]*)
3065         ;;
3066 (*)
3067         case "$cf_cv_system_name" in
3068         (cygwin*|msys*)
3069                 ;;
3070         (*)
3071                 rm -rf ./conftest* ./*~conftest*
3072                 if mkdir conftest.src conftest.bin conftest.lib
3073                 then
3074                         cd conftest.src
3075                         rm -rf ./conftest* ./*~conftest*
3076                         cat >>library.gpr <<CF_EOF
3077 project Library is
3078   Kind := External ("LIB_KIND");
3079   for Library_Name use "ConfTest";
3080   for Object_Dir use ".";
3081   for Library_ALI_Dir use External("LIBRARY_DIR");
3082   for Library_Version use External ("SONAME");
3083   for Library_Kind use Kind;
3084   for Library_Dir use External("BUILD_DIR");
3085   Source_Dir := External ("SOURCE_DIR");
3086   for Source_Dirs use (Source_Dir);
3087 end Library;
3088 CF_EOF
3089                         cat >>confpackage.ads <<CF_EOF
3090 package ConfPackage is
3091    procedure conftest;
3092 end ConfPackage;
3093 CF_EOF
3094                         cat >>confpackage.adb <<CF_EOF
3095 with Text_IO;
3096 package body ConfPackage is
3097    procedure conftest is
3098    begin
3099       Text_IO.Put ("Hello World");
3100       Text_IO.New_Line;
3101    end conftest;
3102 end ConfPackage;
3103 CF_EOF
3104                         if ( "$cf_ada_make" $ADAFLAGS \
3105                                         -Plibrary.gpr \
3106                                         -XBUILD_DIR="`cd ../conftest.bin;pwd`" \
3107                                         -XLIBRARY_DIR="`cd ../conftest.lib;pwd`" \
3108                                         -XSOURCE_DIR="`pwd`" \
3109                                         -XSONAME=libConfTest.so.1 \
3110                                         -XLIB_KIND=static 1>&AC_FD_CC 2>&1 ) ; then
3111                                 cf_gnat_projects=yes
3112                         fi
3113                         cd ..
3114                 fi
3115                 if test -f conftest.lib/confpackage.ali
3116                 then
3117                         cf_gnat_libraries=yes
3118                 fi
3119                 rm -rf ./conftest* ./*~conftest*
3120                 ;;
3121         esac
3122         ;;
3123 esac
3124 AC_MSG_RESULT($cf_gnat_projects)
3125 fi # enable_gnat_projects
3126
3127 if test "$cf_gnat_projects" = yes
3128 then
3129         AC_MSG_CHECKING(if GNAT supports libraries)
3130         AC_MSG_RESULT($cf_gnat_libraries)
3131 fi
3132
3133 USE_OLD_MAKERULES=""
3134 USE_GNAT_PROJECTS="#"
3135 USE_GNAT_MAKE_GPR="#"
3136 USE_GNAT_GPRBUILD="#"
3137
3138 if test "$cf_gnat_projects" = yes
3139 then
3140         USE_OLD_MAKERULES="#"
3141         USE_GNAT_PROJECTS=""
3142         if test "$cf_cv_VERSION_GPRBUILD" != no
3143         then
3144                 USE_GNAT_GPRBUILD=""
3145         elif test "$cf_cv_VERSION_GNATMAKE" != no
3146         then
3147                 USE_GNAT_MAKE_GPR=""
3148         else
3149                 AC_MSG_WARN(use old makefile rules since tools are missing)
3150         fi
3151 fi
3152
3153 if test "$cf_gnat_libraries" = yes
3154 then
3155         USE_GNAT_LIBRARIES=""
3156 else
3157         USE_GNAT_LIBRARIES="#"
3158 fi
3159
3160 AC_SUBST(USE_OLD_MAKERULES)
3161 AC_SUBST(USE_GNAT_PROJECTS)
3162 AC_SUBST(USE_GNAT_LIBRARIES)
3163 AC_SUBST(USE_GNAT_MAKE_GPR)
3164 AC_SUBST(USE_GNAT_GPRBUILD)
3165 ])dnl
3166 dnl ---------------------------------------------------------------------------
3167 dnl CF_GNAT_SIGINT version: 2 updated: 2021/01/01 13:31:04
3168 dnl --------------
3169 dnl Check if gnat supports SIGINT, and presumably tasking.  For the latter, it
3170 dnl is noted that gnat may compile a tasking unit even for configurations which
3171 dnl fail at runtime.
3172 AC_DEFUN([CF_GNAT_SIGINT],[
3173 AC_CACHE_CHECK(if GNAT supports SIGINT,cf_cv_gnat_sigint,[
3174 CF_GNAT_TRY_LINK([with Ada.Interrupts.Names;
3175
3176 package ConfTest is
3177
3178    pragma Warnings (Off);  --  the next pragma exists since 3.11p
3179    pragma Unreserve_All_Interrupts;
3180    pragma Warnings (On);
3181
3182    protected Process is
3183       procedure Stop;
3184       function Continue return Boolean;
3185       pragma Attach_Handler (Stop, Ada.Interrupts.Names.SIGINT);
3186    private
3187       Done : Boolean := False;
3188    end Process;
3189
3190 end ConfTest;],
3191 [package body ConfTest is
3192    protected body Process is
3193       procedure Stop is
3194       begin
3195          Done := True;
3196       end Stop;
3197       function Continue return Boolean is
3198       begin
3199          return not Done;
3200       end Continue;
3201    end Process;
3202 end ConfTest;],
3203         [cf_cv_gnat_sigint=yes],
3204         [cf_cv_gnat_sigint=no])])
3205
3206 if test "$cf_cv_gnat_sigint" = yes ; then
3207         USE_GNAT_SIGINT=""
3208 else
3209         USE_GNAT_SIGINT="#"
3210 fi
3211 AC_SUBST(USE_GNAT_SIGINT)
3212 ])dnl
3213 dnl ---------------------------------------------------------------------------
3214 dnl CF_GNAT_TRY_LINK version: 4 updated: 2021/01/01 13:31:04
3215 dnl ----------------
3216 dnl Verify that a test program compiles/links with GNAT.
3217 dnl $cf_ada_make is set to the program that compiles/links
3218 dnl $ADAFLAGS may be set to the GNAT flags.
3219 dnl
3220 dnl $1 is the text of the spec
3221 dnl $2 is the text of the body
3222 dnl $3 is the shell command to execute if successful
3223 dnl $4 is the shell command to execute if not successful
3224 AC_DEFUN([CF_GNAT_TRY_LINK],
3225 [
3226 rm -rf ./conftest* ./*~conftest*
3227 cat >>conftest.ads <<CF_EOF
3228 $1
3229 CF_EOF
3230 cat >>conftest.adb <<CF_EOF
3231 $2
3232 CF_EOF
3233 if ( "$cf_ada_make" $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
3234 ifelse($3,,      :,[      $3])
3235 ifelse($4,,,[else
3236    $4])
3237 fi
3238 rm -rf ./conftest* ./*~conftest*
3239 ])dnl
3240 dnl ---------------------------------------------------------------------------
3241 dnl CF_GNAT_TRY_RUN version: 6 updated: 2021/01/01 13:31:04
3242 dnl ---------------
3243 dnl Verify that a test program compiles and runs with GNAT
3244 dnl $cf_ada_make is set to the program that compiles/links
3245 dnl $ADAFLAGS may be set to the GNAT flags.
3246 dnl
3247 dnl $1 is the text of the spec
3248 dnl $2 is the text of the body
3249 dnl $3 is the shell command to execute if successful
3250 dnl $4 is the shell command to execute if not successful
3251 AC_DEFUN([CF_GNAT_TRY_RUN],
3252 [
3253 rm -rf ./conftest* ./*~conftest*
3254 cat >>conftest.ads <<CF_EOF
3255 $1
3256 CF_EOF
3257 cat >>conftest.adb <<CF_EOF
3258 $2
3259 CF_EOF
3260 if ( "$cf_ada_make" $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
3261    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
3262 ifelse($3,,      :,[      $3])
3263 ifelse($4,,,[   else
3264       $4])
3265    fi
3266 ifelse($4,,,[else
3267    $4])
3268 fi
3269 rm -rf ./conftest* ./*~conftest*
3270 ])dnl
3271 dnl ---------------------------------------------------------------------------
3272 dnl CF_GNAT_VERSION version: 22 updated: 2019/12/31 08:53:54
3273 dnl ---------------
3274 dnl $1 = cache variable to update
3275 dnl $2 = program name
3276 dnl Verify version of GNAT or related tool
3277 AC_DEFUN([CF_GNAT_VERSION],
3278 [
3279 AC_CACHE_CHECK(for ifelse($2,,gnat,$2) version, cf_cv_gnat_version,[
3280 cf_cv_gnat_version=`ifelse($2,,${cf_ada_make:-gnatmake},$2) --version 2>&1 | \
3281         grep '[[0-9]].[[0-9]][[0-9]]*' |\
3282         sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
3283 ])
3284 test -z "$cf_cv_gnat_version" && cf_cv_gnat_version=no
3285 ifelse($1,,,[eval $1=$cf_cv_gnat_version; unset cf_cv_gnat_version])
3286 ])dnl
3287 dnl ---------------------------------------------------------------------------
3288 dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
3289 dnl -------------
3290 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
3291 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
3292 dnl (or misfeature) of glibc2, which breaks portability of many applications,
3293 dnl since it is interwoven with GNU extensions.
3294 dnl
3295 dnl Well, yes we could work around it...
3296 dnl
3297 dnl Parameters:
3298 dnl     $1 is the nominal value for _XOPEN_SOURCE
3299 AC_DEFUN([CF_GNU_SOURCE],
3300 [
3301 cf_gnu_xopen_source=ifelse($1,,500,$1)
3302
3303 AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
3304 AC_TRY_COMPILE([#include <sys/types.h>],[
3305         #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
3306                 return 0;
3307         #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
3308                 return 0;
3309         #else
3310         #       error not GNU C library
3311         #endif],
3312         [cf_cv_gnu_library=yes],
3313         [cf_cv_gnu_library=no])
3314 ])
3315
3316 if test x$cf_cv_gnu_library = xyes; then
3317
3318         # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
3319         # was changed to help a little.  newlib incorporated the change about 4
3320         # years later.
3321         AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
3322                 cf_save="$CPPFLAGS"
3323                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
3324                 AC_TRY_COMPILE([#include <sys/types.h>],[
3325                         #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
3326                                 return 0;
3327                         #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
3328                                 return 0;
3329                         #else
3330                         #       error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
3331                         #endif],
3332                         [cf_cv_gnu_library_219=yes],
3333                         [cf_cv_gnu_library_219=no])
3334                 CPPFLAGS="$cf_save"
3335         ])
3336
3337         if test "x$cf_cv_gnu_library_219" = xyes; then
3338                 cf_save="$CPPFLAGS"
3339                 AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
3340                         CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
3341                         AC_TRY_COMPILE([
3342                                 #include <limits.h>
3343                                 #include <sys/types.h>
3344                                 ],[
3345                                 #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
3346                                         return 0;
3347                                 #else
3348                                 #       error GNU C library is too old
3349                                 #endif],
3350                                 [cf_cv_gnu_dftsrc_219=yes],
3351                                 [cf_cv_gnu_dftsrc_219=no])
3352                         ])
3353                 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
3354         else
3355                 cf_cv_gnu_dftsrc_219=maybe
3356         fi
3357
3358         if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
3359
3360                 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
3361                 AC_TRY_COMPILE([#include <sys/types.h>],[
3362                         #ifndef _XOPEN_SOURCE
3363                         #error  expected _XOPEN_SOURCE to be defined
3364                         #endif],
3365                         [cf_cv_gnu_source=no],
3366                         [cf_save="$CPPFLAGS"
3367                          CF_ADD_CFLAGS(-D_GNU_SOURCE)
3368                          AC_TRY_COMPILE([#include <sys/types.h>],[
3369                                 #ifdef _XOPEN_SOURCE
3370                                 #error  expected _XOPEN_SOURCE to be undefined
3371                                 #endif],
3372                                 [cf_cv_gnu_source=no],
3373                                 [cf_cv_gnu_source=yes])
3374                         CPPFLAGS="$cf_save"
3375                         ])
3376                 ])
3377
3378                 if test "$cf_cv_gnu_source" = yes
3379                 then
3380                 AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
3381                         CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
3382                         AC_TRY_COMPILE([#include <sys/types.h>],[
3383                                 #ifdef _DEFAULT_SOURCE
3384                                 #error  expected _DEFAULT_SOURCE to be undefined
3385                                 #endif],
3386                                 [cf_cv_default_source=no],
3387                                 [cf_cv_default_source=yes])
3388                         ])
3389                         if test "$cf_cv_default_source" = yes
3390                         then
3391                                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
3392                         fi
3393                 fi
3394         fi
3395
3396 fi
3397 ])dnl
3398 dnl ---------------------------------------------------------------------------
3399 dnl CF_GPP_LIBRARY version: 13 updated: 2021/01/01 13:31:04
3400 dnl --------------
3401 dnl If we're trying to use g++, test if libg++ is installed (a rather common
3402 dnl problem :-).  If we have the compiler but no library, we'll be able to
3403 dnl configure, but won't be able to build the c++ demo program.
3404 AC_DEFUN([CF_GPP_LIBRARY],
3405 [
3406 cf_cxx_library=unknown
3407 case "$cf_cv_system_name" in
3408 (os2*)
3409         cf_gpp_libname=gpp
3410         ;;
3411 (*)
3412         cf_gpp_libname=g++
3413         ;;
3414 esac
3415 if test "$GXX" = yes; then
3416         AC_MSG_CHECKING([for lib$cf_gpp_libname])
3417         cf_save="$LIBS"
3418         CF_ADD_LIB($cf_gpp_libname)
3419         AC_TRY_LINK([
3420 #include <$cf_gpp_libname/builtin.h>
3421         ],
3422         [two_arg_error_handler_t foo2 = lib_error_handler],
3423         [cf_cxx_library=yes
3424          CF_ADD_LIB($cf_gpp_libname,CXXLIBS)
3425          if test "$cf_gpp_libname" = cpp ; then
3426             AC_DEFINE(HAVE_GPP_BUILTIN_H,1,[Define to 1 if we have gpp builtin.h])
3427          else
3428             AC_DEFINE(HAVE_GXX_BUILTIN_H,1,[Define to 1 if we have g++ builtin.h])
3429          fi],
3430         [AC_TRY_LINK([
3431 #include <builtin.h>
3432         ],
3433         [two_arg_error_handler_t foo2 = lib_error_handler],
3434         [cf_cxx_library=yes
3435          CF_ADD_LIB($cf_gpp_libname,CXXLIBS)
3436          AC_DEFINE(HAVE_BUILTIN_H,1,[Define to 1 if we have builtin.h])],
3437         [cf_cxx_library=no])])
3438         LIBS="$cf_save"
3439         AC_MSG_RESULT($cf_cxx_library)
3440 fi
3441 ])dnl
3442 dnl ---------------------------------------------------------------------------
3443 dnl CF_GXX_VERSION version: 8 updated: 2017/02/11 14:48:57
3444 dnl --------------
3445 dnl Check for version of g++
3446 AC_DEFUN([CF_GXX_VERSION],[
3447 AC_REQUIRE([AC_PROG_CPP])
3448 GXX_VERSION=none
3449 if test "$GXX" = yes; then
3450         AC_MSG_CHECKING(version of ${CXX:-g++})
3451         GXX_VERSION="`${CXX:-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
3452         if test -z "$GXX_VERSION"
3453         then
3454                 GXX_VERSION=unknown
3455                 GXX=no
3456         fi
3457         AC_MSG_RESULT($GXX_VERSION)
3458 fi
3459 ])dnl
3460 dnl ---------------------------------------------------------------------------
3461 dnl CF_GXX_WARNINGS version: 11 updated: 2021/01/08 16:50:55
3462 dnl ---------------
3463 dnl Check if the compiler supports useful warning options.
3464 dnl
3465 dnl Most of gcc's options apply to g++, except:
3466 dnl     -Wbad-function-cast
3467 dnl     -Wmissing-declarations
3468 dnl     -Wnested-externs
3469 dnl
3470 dnl Omit a few (for now):
3471 dnl     -Winline
3472 dnl
3473 dnl Parameter:
3474 dnl     $1 is an optional list of g++ warning flags that a particular
3475 dnl             application might want to use, e.g., "no-unused" for
3476 dnl             -Wno-unused
3477 dnl Special:
3478 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
3479 dnl
3480 AC_DEFUN([CF_GXX_WARNINGS],
3481 [
3482
3483 CF_INTEL_COMPILER(GXX,INTEL_CPLUSPLUS,CXXFLAGS)
3484 CF_CLANG_COMPILER(GXX,CLANG_CPLUSPLUS,CXXFLAGS)
3485
3486 AC_REQUIRE([CF_GXX_VERSION])
3487
3488 AC_LANG_SAVE
3489 AC_LANG_CPLUSPLUS
3490
3491 cat > conftest.$ac_ext <<EOF
3492 #line __oline__ "configure"
3493 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
3494 EOF
3495
3496 if test "$INTEL_CPLUSPLUS" = yes
3497 then
3498 # The "-wdXXX" options suppress warnings:
3499 # remark #1419: external declaration in primary source file
3500 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
3501 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
3502 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
3503 # remark #193: zero used for undefined preprocessing identifier
3504 # remark #593: variable "curs_sb_left_arrow" was set but never used
3505 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
3506 # remark #869: parameter "tw" was never referenced
3507 # remark #981: operands are evaluated in unspecified order
3508 # warning #269: invalid format string conversion
3509
3510         AC_CHECKING([for $CC warning options])
3511         cf_save_CXXFLAGS="$CXXFLAGS"
3512         EXTRA_CXXFLAGS="-Wall"
3513         for cf_opt in \
3514                 wd1419 \
3515                 wd1682 \
3516                 wd1683 \
3517                 wd1684 \
3518                 wd193 \
3519                 wd279 \
3520                 wd593 \
3521                 wd810 \
3522                 wd869 \
3523                 wd981
3524         do
3525                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt"
3526                 if AC_TRY_EVAL(ac_compile); then
3527                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
3528                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
3529                 fi
3530         done
3531         CXXFLAGS="$cf_save_CXXFLAGS"
3532
3533 elif test "$GXX" = yes
3534 then
3535         AC_CHECKING([for $CXX warning options])
3536         cf_save_CXXFLAGS="$CXXFLAGS"
3537         EXTRA_CXXFLAGS="-W -Wall"
3538         cf_gxx_extra_warnings=""
3539         test "$with_ext_const" = yes && cf_gxx_extra_warnings="Wwrite-strings"
3540         case "$GXX_VERSION" in
3541         ([[1-2]].*)
3542                 ;;
3543         (*)
3544                 cf_gxx_extra_warnings="$cf_gxx_extra_warnings Weffc++"
3545                 ;;
3546         esac
3547         for cf_opt in \
3548                 Wabi \
3549                 fabi-version=0 \
3550                 Wextra \
3551                 Wignored-qualifiers \
3552                 Wlogical-op \
3553                 Woverloaded-virtual \
3554                 Wsign-promo \
3555                 Wsynth \
3556                 Wold-style-cast \
3557                 Wcast-align \
3558                 Wcast-qual \
3559                 Wpointer-arith \
3560                 Wshadow \
3561                 Wundef $cf_gxx_extra_warnings $1
3562         do
3563                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
3564                 if AC_TRY_EVAL(ac_compile); then
3565                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
3566                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
3567                 else
3568                         test -n "$verbose" && AC_MSG_RESULT(... no -$cf_opt)
3569                 fi
3570         done
3571         CXXFLAGS="$cf_save_CXXFLAGS"
3572 fi
3573
3574 rm -rf ./conftest*
3575 AC_LANG_RESTORE
3576 AC_SUBST(EXTRA_CXXFLAGS)
3577 ])dnl
3578 dnl ---------------------------------------------------------------------------
3579 dnl CF_HASHED_DB version: 7 updated: 2015/04/18 08:56:57
3580 dnl ------------
3581 dnl Look for an instance of the Berkeley hashed database.
3582 dnl
3583 dnl $1 = optional parameter, to specify install-prefix for the database.
3584 AC_DEFUN([CF_HASHED_DB],
3585 [
3586 ifelse([$1],,,[
3587 case $1 in
3588 (yes|*able*)
3589         ;;
3590 (*)
3591         if test -d "$1" ; then
3592                 CF_ADD_INCDIR($1/include)
3593                 CF_ADD_LIBDIR($1/lib)
3594         else
3595                 case "$1" in
3596                 (./*|../*|/*)
3597                         AC_MSG_WARN(no such directory $1)
3598                         ;;
3599                 (*)
3600                         CF_FIND_SUB_INCDIR($1)
3601                         CF_FIND_SUB_LIBDIR($1)
3602                         ;;
3603                 esac
3604         fi
3605 esac
3606 ])
3607 AC_CHECK_HEADER(db.h,[
3608 CF_HASHED_DB_VERSION
3609 if test "$cf_cv_hashed_db_version" = unknown ; then
3610         AC_MSG_ERROR(Cannot determine version of db)
3611 else
3612         CF_HASHED_DB_LIBS
3613         if test "$cf_cv_hashed_db_libs" = unknown ; then
3614                 AC_MSG_ERROR(Cannot determine library for db)
3615         elif test "$cf_cv_hashed_db_libs" != default ; then
3616                 CF_ADD_LIB($cf_cv_hashed_db_libs)
3617         fi
3618 fi
3619 ],[
3620         AC_MSG_ERROR(Cannot find db.h)
3621 ])
3622 ])dnl
3623 dnl ---------------------------------------------------------------------------
3624 dnl CF_HASHED_DB_LIBS version: 10 updated: 2021/01/02 17:09:14
3625 dnl -----------------
3626 dnl Given that we have the header and version for hashed database, find the
3627 dnl library information.
3628 AC_DEFUN([CF_HASHED_DB_LIBS],
3629 [
3630 AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
3631 cf_cv_hashed_db_libs=unknown
3632 for cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
3633 do
3634         cf_save_libs="$LIBS"
3635         if test -n "$cf_db_libs"; then
3636                 CF_ADD_LIB($cf_db_libs)
3637         fi
3638         CF_MSG_LOG(checking for library $cf_db_libs)
3639         AC_TRY_LINK([
3640 $ac_includes_default
3641 #include <db.h>
3642 ],[
3643         char *path = "/tmp/foo";
3644 #ifdef DB_VERSION_MAJOR
3645 #if DB_VERSION_MAJOR >= 4
3646         DB *result = 0;
3647         db_create(&result, NULL, 0);
3648         result->open(result,
3649                 NULL,
3650                 path,
3651                 path,
3652                 DB_HASH,
3653                 DB_CREATE,
3654                 0644);
3655 #elif DB_VERSION_MAJOR >= 3
3656         DB *result = 0;
3657         db_create(&result, NULL, 0);
3658         result->open(result,
3659                 path,
3660                 path,
3661                 DB_HASH,
3662                 DB_CREATE,
3663                 0644);
3664 #elif DB_VERSION_MAJOR >= 2
3665         DB *result = 0;
3666         db_open(path,
3667                 DB_HASH,
3668                 DB_CREATE,
3669                 0644,
3670                 (DB_ENV *) 0,
3671                 (DB_INFO *) 0,
3672                 &result);
3673 #endif /* DB_VERSION_MAJOR */
3674 #else
3675         DB *result = dbopen(path,
3676                      2,
3677                      0644,
3678                      DB_HASH,
3679                      0);
3680 #endif
3681         ${cf_cv_main_return:-return}(result != 0)
3682 ],[
3683         if test -n "$cf_db_libs" ; then
3684                 cf_cv_hashed_db_libs=$cf_db_libs
3685         else
3686                 cf_cv_hashed_db_libs=default
3687         fi
3688         LIBS="$cf_save_libs"
3689         break
3690 ])
3691         LIBS="$cf_save_libs"
3692 done
3693 ])
3694 ])dnl
3695 dnl ---------------------------------------------------------------------------
3696 dnl CF_HASHED_DB_VERSION version: 4 updated: 2014/04/12 16:47:01
3697 dnl --------------------
3698 dnl Given that we have the header file for hashed database, find the version
3699 dnl information.
3700 AC_DEFUN([CF_HASHED_DB_VERSION],
3701 [
3702 AC_CACHE_CHECK(for version of db, cf_cv_hashed_db_version,[
3703 cf_cv_hashed_db_version=unknown
3704
3705 for cf_db_version in 1 2 3 4 5 6
3706 do
3707         CF_MSG_LOG(checking for db version $cf_db_version)
3708         AC_TRY_COMPILE([
3709 $ac_includes_default
3710 #include <db.h>
3711
3712 #ifdef DB_VERSION_MAJOR
3713         /* db2 (DB_VERSION_MAJOR=2) has also DB_VERSION_MINOR, tested with 7 */
3714 #if $cf_db_version == DB_VERSION_MAJOR
3715         /* ok */
3716 #else
3717         make an error
3718 #endif
3719 #else
3720 #if $cf_db_version == 1
3721         /* ok: assuming this is DB 1.8.5 */
3722 #else
3723         make an error
3724 #endif
3725 #endif
3726 ],[DBT *foo = 0],[
3727         cf_cv_hashed_db_version=$cf_db_version
3728         break
3729         ])
3730 done
3731 ])
3732 ])dnl
3733 dnl ---------------------------------------------------------------------------
3734 dnl CF_HEADER_PATH version: 15 updated: 2021/01/01 13:31:04
3735 dnl --------------
3736 dnl Construct a search-list of directories for a nonstandard header-file
3737 dnl
3738 dnl Parameters
3739 dnl     $1 = the variable to return as result
3740 dnl     $2 = the package name
3741 AC_DEFUN([CF_HEADER_PATH],
3742 [
3743 $1=
3744
3745 # collect the current set of include-directories from compiler flags
3746 cf_header_path_list=""
3747 if test -n "${CFLAGS}${CPPFLAGS}" ; then
3748         for cf_header_path in $CPPFLAGS $CFLAGS
3749         do
3750                 case "$cf_header_path" in
3751                 (-I*)
3752                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
3753                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
3754                         cf_header_path_list="$cf_header_path_list [$]$1"
3755                         ;;
3756                 esac
3757         done
3758 fi
3759
3760 # add the variations for the package we are looking for
3761 CF_SUBDIR_PATH($1,$2,include)
3762
3763 test "$includedir" != NONE && \
3764 test "$includedir" != "/usr/include" && \
3765 test -d "$includedir" && {
3766         test -d "$includedir" &&    $1="[$]$1 $includedir"
3767         test -d "$includedir/$2" && $1="[$]$1 $includedir/$2"
3768 }
3769
3770 test "$oldincludedir" != NONE && \
3771 test "$oldincludedir" != "/usr/include" && \
3772 test -d "$oldincludedir" && {
3773         test -d "$oldincludedir"    && $1="[$]$1 $oldincludedir"
3774         test -d "$oldincludedir/$2" && $1="[$]$1 $oldincludedir/$2"
3775 }
3776
3777 $1="[$]$1 $cf_header_path_list"
3778 ])dnl
3779 dnl ---------------------------------------------------------------------------
3780 dnl CF_HELP_MESSAGE version: 4 updated: 2019/12/31 08:53:54
3781 dnl ---------------
3782 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
3783 AC_DEFUN([CF_HELP_MESSAGE],
3784 [CF_ACVERSION_CHECK(2.53,[],[
3785 AC_DIVERT_HELP($1)])dnl
3786 ])dnl
3787 dnl ---------------------------------------------------------------------------
3788 dnl CF_INCLUDE_DIRS version: 10 updated: 2014/09/19 20:58:42
3789 dnl ---------------
3790 dnl Construct the list of include-options according to whether we're building
3791 dnl in the source directory or using '--srcdir=DIR' option.
3792 AC_DEFUN([CF_INCLUDE_DIRS],
3793 [
3794 if test "$srcdir" != "."; then
3795         CPPFLAGS="-I\${srcdir}/../include $CPPFLAGS"
3796 fi
3797 CPPFLAGS="-I../include $CPPFLAGS"
3798 if test "$srcdir" != "."; then
3799         CPPFLAGS="-I\${srcdir} $CPPFLAGS"
3800 fi
3801 CPPFLAGS="-I. $CPPFLAGS"
3802 AC_SUBST(CPPFLAGS)
3803 ])dnl
3804 dnl ---------------------------------------------------------------------------
3805 dnl CF_INSTALL_OPTS version: 2 updated: 2018/08/18 12:19:21
3806 dnl ---------------
3807 dnl prompt for/fill-in useful install-program options
3808 AC_DEFUN([CF_INSTALL_OPTS],
3809 [
3810 CF_INSTALL_OPT_S
3811 CF_INSTALL_OPT_P
3812 CF_INSTALL_OPT_O
3813 ])dnl
3814 dnl ---------------------------------------------------------------------------
3815 dnl CF_INSTALL_OPT_O version: 3 updated: 2020/12/31 20:19:42
3816 dnl ----------------
3817 dnl Almost all "install" programs default to the current user's ownership.
3818 dnl Almost - MINIX is an exception.
3819 AC_DEFUN([CF_INSTALL_OPT_O],
3820 [
3821 AC_MSG_CHECKING(if install needs to be told about ownership)
3822 case `$ac_config_guess` in
3823 (*minix)
3824         with_install_o=yes
3825         ;;
3826 (*)
3827         with_install_o=no
3828         ;;
3829 esac
3830
3831 AC_MSG_RESULT($with_install_o)
3832 if test "x$with_install_o" = xyes
3833 then
3834         INSTALL_OPT_O="`id root|sed -e 's/uid=[[0-9]]*(/ -o /' -e 's/gid=[[0-9]]*(/ -g /' -e 's/ [[^=[:space:]]][[^=[:space:]]]*=.*/ /' -e 's/)//g'`"
3835 else
3836         INSTALL_OPT_O=
3837 fi
3838
3839 AC_SUBST(INSTALL_OPT_O)
3840 ])dnl
3841 dnl ---------------------------------------------------------------------------
3842 dnl CF_INSTALL_OPT_P version: 3 updated: 2021/01/01 13:31:04
3843 dnl ----------------
3844 dnl Some install-programs accept a "-p" option to preserve file modification
3845 dnl timestamps.  That can be useful as an install option, as well as a way to
3846 dnl avoid the need for ranlib after copying a static archive.
3847 AC_DEFUN([CF_INSTALL_OPT_P],
3848 [
3849 : "${INSTALL:=install}"
3850 AC_CACHE_CHECK(if install accepts -p option, cf_cv_install_p,[
3851         rm -rf ./conftest*
3852         date >conftest.in
3853         mkdir conftest.out
3854         sleep 3
3855         if $INSTALL -p conftest.in conftest.out 2>/dev/null
3856         then
3857                 if test -f conftest.out/conftest.in
3858                 then
3859                         test conftest.in -nt conftest.out/conftest.in 2>conftest.err && \
3860                         test conftest.out/conftest.in -nt conftest.in 2>conftest.err
3861                         if test -s conftest.err
3862                         then
3863                                 cf_cv_install_p=no
3864                         else
3865                                 cf_cv_install_p=yes
3866                         fi
3867                 else
3868                         cf_cv_install_p=no
3869                 fi
3870         else
3871                 cf_cv_install_p=no
3872         fi
3873         rm -rf ./conftest*
3874 ])
3875 ])dnl
3876 dnl ---------------------------------------------------------------------------
3877 dnl CF_INSTALL_OPT_S version: 3 updated: 2021/01/05 19:23:48
3878 dnl ----------------
3879 dnl By default, we should strip executables which are installed, but leave the
3880 dnl ability to suppress that for unit-testing.
3881 AC_DEFUN([CF_INSTALL_OPT_S],
3882 [
3883 AC_MSG_CHECKING(if you want to install stripped executables)
3884 CF_ARG_DISABLE(stripping,
3885         [  --disable-stripping     do not strip (debug info) installed executables],
3886         [enable_stripping=no],
3887         [enable_stripping=yes])
3888 AC_MSG_RESULT($enable_stripping)
3889
3890 if test "$enable_stripping" = yes
3891 then
3892         INSTALL_OPT_S="-s"
3893 else
3894         INSTALL_OPT_S=
3895 fi
3896 AC_SUBST(INSTALL_OPT_S)
3897 ])dnl
3898 dnl ---------------------------------------------------------------------------
3899 dnl CF_INTEL_COMPILER version: 8 updated: 2021/01/01 16:53:59
3900 dnl -----------------
3901 dnl Check if the given compiler is really the Intel compiler for Linux.  It
3902 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
3903 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
3904 dnl
3905 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
3906 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
3907 dnl the wrappers for gcc and g++ warnings.
3908 dnl
3909 dnl $1 = GCC (default) or GXX
3910 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
3911 dnl $3 = CFLAGS (default) or CXXFLAGS
3912 AC_DEFUN([CF_INTEL_COMPILER],[
3913 AC_REQUIRE([AC_CANONICAL_HOST])
3914 ifelse([$2],,INTEL_COMPILER,[$2])=no
3915
3916 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
3917         case "$host_os" in
3918         (linux*|gnu*)
3919                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
3920                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
3921                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
3922                 AC_TRY_COMPILE([],[
3923 #ifdef __INTEL_COMPILER
3924 #else
3925 make an error
3926 #endif
3927 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
3928 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
3929 ],[])
3930                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
3931                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
3932                 ;;
3933         esac
3934 fi
3935 ])dnl
3936 dnl ---------------------------------------------------------------------------
3937 dnl CF_ISASCII version: 4 updated: 2012/10/06 17:56:13
3938 dnl ----------
3939 dnl Check if we have either a function or macro for 'isascii()'.
3940 AC_DEFUN([CF_ISASCII],
3941 [
3942 AC_MSG_CHECKING(for isascii)
3943 AC_CACHE_VAL(cf_cv_have_isascii,[
3944         AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
3945         [cf_cv_have_isascii=yes],
3946         [cf_cv_have_isascii=no])
3947 ])dnl
3948 AC_MSG_RESULT($cf_cv_have_isascii)
3949 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII,1,[Define to 1 if we have isascii()])
3950 ])dnl
3951 dnl ---------------------------------------------------------------------------
3952 dnl CF_LARGEFILE version: 12 updated: 2020/03/19 20:23:48
3953 dnl ------------
3954 dnl Add checks for large file support.
3955 AC_DEFUN([CF_LARGEFILE],[
3956 ifdef([AC_FUNC_FSEEKO],[
3957         AC_SYS_LARGEFILE
3958         if test "$enable_largefile" != no ; then
3959         AC_FUNC_FSEEKO
3960
3961         # Normally we would collect these definitions in the config.h,
3962         # but (like _XOPEN_SOURCE), some environments rely on having these
3963         # defined before any of the system headers are included.  Another
3964         # case comes up with C++, e.g., on AIX the compiler compiles the
3965         # header files by themselves before looking at the body files it is
3966         # told to compile.  For ncurses, those header files do not include
3967         # the config.h
3968         if test "$ac_cv_sys_large_files" != no
3969         then
3970                 CF_APPEND_TEXT(CPPFLAGS,-D_LARGE_FILES)
3971         fi
3972         if test "$ac_cv_sys_largefile_source" != no
3973         then
3974                 CF_APPEND_TEXT(CPPFLAGS,-D_LARGEFILE_SOURCE)
3975         fi
3976         if test "$ac_cv_sys_file_offset_bits" != no
3977         then
3978                 CF_APPEND_TEXT(CPPFLAGS,-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits)
3979         fi
3980
3981         AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
3982                 AC_TRY_COMPILE([
3983 #pragma GCC diagnostic error "-Wincompatible-pointer-types"
3984 #include <sys/types.h>
3985 #include <dirent.h>
3986                 ],[
3987                 /* if transitional largefile support is setup, this is true */
3988                 extern struct dirent64 * readdir(DIR *);
3989                 struct dirent64 *x = readdir((DIR *)0);
3990                 struct dirent *y = readdir((DIR *)0);
3991                 int z = x - y;
3992                 (void)z;
3993                 ],
3994                 [cf_cv_struct_dirent64=yes],
3995                 [cf_cv_struct_dirent64=no])
3996         ])
3997         test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64])
3998         fi
3999 ])
4000 ])
4001 dnl ---------------------------------------------------------------------------
4002 dnl CF_LDFLAGS_STATIC version: 14 updated: 2021/01/02 17:09:14
4003 dnl -----------------
4004 dnl Check for compiler/linker flags used to temporarily force usage of static
4005 dnl libraries.  This depends on the compiler and platform.  Use this to help
4006 dnl ensure that the linker picks up a given library based on its position in
4007 dnl the list of linker options and libraries.
4008 AC_DEFUN([CF_LDFLAGS_STATIC],[
4009
4010 if test "$GCC" = yes ; then
4011         case "$cf_cv_system_name" in
4012         (OS/2*|os2*|aix[[4]]*|solaris2.1[[0-9]]|darwin*)
4013                 LDFLAGS_STATIC=
4014                 LDFLAGS_SHARED=
4015                 ;;
4016         (*)     # normally, except when broken
4017                 LDFLAGS_STATIC=-static
4018                 LDFLAGS_SHARED=-dynamic
4019                 ;;
4020         esac
4021 else
4022         case "$cf_cv_system_name" in
4023         (aix[[4-7]]*)   # from ld manpage
4024                 LDFLAGS_STATIC=-bstatic
4025                 LDFLAGS_SHARED=-bdynamic
4026                 ;;
4027         (hpux*)         # from ld manpage for hpux10.20, hpux11.11
4028                 # We could also use just "archive" and "shared".
4029                 LDFLAGS_STATIC=-Wl,-a,archive_shared
4030                 LDFLAGS_SHARED=-Wl,-a,shared_archive
4031                 ;;
4032         (irix*)         # from ld manpage IRIX64
4033                 LDFLAGS_STATIC=-Bstatic
4034                 LDFLAGS_SHARED=-Bdynamic
4035                 ;;
4036         (osf[[45]]*)    # from ld manpage osf4.0d, osf5.1
4037                 # alternative "-oldstyle_liblookup" (not in cc manpage)
4038                 LDFLAGS_STATIC=-noso
4039                 LDFLAGS_SHARED=-so_archive
4040                 ;;
4041         (solaris2*)
4042                 LDFLAGS_STATIC=-Bstatic
4043                 LDFLAGS_SHARED=-Bdynamic
4044                 ;;
4045         esac
4046 fi
4047
4048 if test -n "$LDFLAGS_STATIC" && test -n "$LDFLAGS_SHARED"
4049 then
4050         AC_MSG_CHECKING(if linker supports switching between static/dynamic)
4051
4052         rm -f libconftest.a
4053         cat >conftest.$ac_ext <<EOF
4054 #line __oline__ "configure"
4055 #include <stdio.h>
4056 int cf_ldflags_static(FILE *fp) { return fflush(fp); }
4057 EOF
4058         if AC_TRY_EVAL(ac_compile) ; then
4059                 ( $AR $ARFLAGS libconftest.a conftest.o ) 2>&AC_FD_CC 1>/dev/null
4060                 ( eval $RANLIB libconftest.a ) 2>&AC_FD_CC >/dev/null
4061         fi
4062         rm -f conftest.*
4063
4064         cf_save_LIBS="$LIBS"
4065
4066         LIBS="$LDFLAGS_STATIC -L`pwd` -lconftest $LDFLAGS_DYNAMIC $LIBS"
4067         AC_TRY_LINK([
4068 #line __oline__ "configure"
4069 #include <stdio.h>
4070 int cf_ldflags_static(FILE *fp);
4071 ],[
4072         return cf_ldflags_static(stdin);
4073 ],[
4074         # some linkers simply ignore the -dynamic
4075         case x`file "conftest$ac_exeext" 2>/dev/null` in
4076         (*static*)
4077                 cf_ldflags_static=no
4078                 ;;
4079         (*)
4080                 cf_ldflags_static=yes
4081                 ;;
4082         esac
4083 ],[cf_ldflags_static=no])
4084
4085         rm -f libconftest.*
4086         LIBS="$cf_save_LIBS"
4087
4088         AC_MSG_RESULT($cf_ldflags_static)
4089
4090         if test "$cf_ldflags_static" != yes
4091         then
4092                 LDFLAGS_STATIC=
4093                 LDFLAGS_SHARED=
4094         fi
4095 else
4096         LDFLAGS_STATIC=
4097         LDFLAGS_SHARED=
4098 fi
4099
4100 AC_SUBST(LDFLAGS_STATIC)
4101 AC_SUBST(LDFLAGS_SHARED)
4102 ])
4103 dnl ---------------------------------------------------------------------------
4104 dnl CF_LD_RPATH_OPT version: 9 updated: 2021/01/01 13:31:04
4105 dnl ---------------
4106 dnl For the given system and compiler, find the compiler flags to pass to the
4107 dnl loader to use the "rpath" feature.
4108 AC_DEFUN([CF_LD_RPATH_OPT],
4109 [
4110 AC_REQUIRE([CF_CHECK_CACHE])
4111
4112 LD_RPATH_OPT=
4113 if test "x$cf_cv_enable_rpath" != xno
4114 then
4115         AC_MSG_CHECKING(for an rpath option)
4116         case "$cf_cv_system_name" in
4117         (irix*)
4118                 if test "$GCC" = yes; then
4119                         LD_RPATH_OPT="-Wl,-rpath,"
4120                 else
4121                         LD_RPATH_OPT="-rpath "
4122                 fi
4123                 ;;
4124         (linux*|gnu*|k*bsd*-gnu|freebsd*)
4125                 LD_RPATH_OPT="-Wl,-rpath,"
4126                 ;;
4127         (openbsd[[2-9]].*|mirbsd*)
4128                 LD_RPATH_OPT="-Wl,-rpath,"
4129                 ;;
4130         (dragonfly*)
4131                 LD_RPATH_OPT="-rpath "
4132                 ;;
4133         (netbsd*)
4134                 LD_RPATH_OPT="-Wl,-rpath,"
4135                 ;;
4136         (osf*|mls+*)
4137                 LD_RPATH_OPT="-rpath "
4138                 ;;
4139         (solaris2*)
4140                 LD_RPATH_OPT="-R"
4141                 ;;
4142         (*)
4143                 ;;
4144         esac
4145         AC_MSG_RESULT($LD_RPATH_OPT)
4146
4147         case "x$LD_RPATH_OPT" in
4148         (x-R*)
4149                 AC_MSG_CHECKING(if we need a space after rpath option)
4150                 cf_save_LIBS="$LIBS"
4151                 CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
4152                 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
4153                 LIBS="$cf_save_LIBS"
4154                 AC_MSG_RESULT($cf_rpath_space)
4155                 test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
4156                 ;;
4157         esac
4158 fi
4159 ])dnl
4160 dnl ---------------------------------------------------------------------------
4161 dnl CF_LD_SEARCHPATH version: 3 updated: 2021/03/05 19:13:35
4162 dnl ----------------
4163 dnl Try to obtain the linker's search-path, for use in scripts.
4164 dnl
4165 dnl Ignore LD_LIBRARY_PATH, etc.
4166 AC_DEFUN([CF_LD_SEARCHPATH],[
4167 AC_CACHE_CHECK(for linker search path,cf_cv_ld_searchpath,[
4168
4169 if test "$cross_compiling" != yes ; then
4170
4171 # GNU binutils' ld does not involve permissions which may stop ldconfig.
4172 cf_pathlist=`ld --verbose 2>/dev/null | grep SEARCH_DIR | sed -e 's,SEARCH_DIR[[("=]][[("=]]*,,g' -e 's/"[[)]];//gp' | sort -u`
4173
4174 # The -NX options tell newer versions of Linux ldconfig to not attempt to
4175 # update the cache, which makes it run faster.
4176 test -z "$cf_pathlist" && \
4177         cf_pathlist=`(ldconfig -NX -v) 2>/dev/null | sed -e '/^[[       ]]/d' -e 's/:$//' | sort -u`
4178
4179 test -z "$cf_pathlist" &&
4180         cf_pathlist=`(ldconfig -v) 2>/dev/null | sed -n -e '/^[[        ]]/d' -e 's/:$//p' | sort -u`
4181
4182 # This works with OpenBSD 6.5, which lists only filenames
4183 test -z "$cf_pathlist" &&
4184         cf_pathlist=`(ldconfig -v) 2>/dev/null | sed -n -e 's,^Adding \(.*\)/.*[$],\1,p' | sort -u`
4185
4186 if test -z "$cf_pathlist"
4187 then
4188         # dyld default path with MacOS
4189         if test -f /usr/bin/otool && test "x`uname -s`" = xDarwin
4190         then
4191                 # do this to bypass check
4192                 cf_cv_ld_searchpath='$HOME/lib'
4193                 cf_pathlist="/usr/local/lib /lib /usr/lib"
4194         fi
4195 fi
4196
4197 if test -z "$cf_pathlist"
4198 then
4199         # Solaris is "SunOS"
4200         if test -f /usr/bin/isainfo && test "x`uname -s`" = xSunOS
4201         then
4202                 case x`(isainfo -b)` in
4203                 (x64)
4204                         cf_pathlist="$cf_pathlist /lib/64 /usr/lib/64"
4205                         ;;
4206                 (x32)
4207                         test -d /usr/ccs/lib && cf_pathlist="$cf_pathlist /usr/ccs/lib"
4208                         cf_pathlist="$cf_pathlist /lib /usr/lib"
4209                         ;;
4210                 (*)
4211                         AC_MSG_WARN(problem with Solaris architecture)
4212                         ;;
4213                 esac
4214         fi
4215 fi
4216
4217 if test -z "$cf_pathlist"
4218 then
4219         # HP-UX
4220         if test x"`uname -s`" = xHP-UX
4221         then
4222                 case x`getconf LONG_BIT` in
4223                 (x64)
4224                         cf_pathlist="/usr/lib/hpux64"
4225                         ;;
4226                 (x*)
4227                         cf_pathlist="/usr/lib/hpux32"
4228                         ;;
4229                 esac
4230         fi
4231 fi
4232
4233 fi
4234
4235 # If nothing else, assume it is conventional
4236 test -z "$cf_pathlist" && cf_pathlist="/usr/lib /lib"
4237
4238 # Finally, check that this is only directories
4239 for cf_path in [$]0 $cf_pathlist
4240 do
4241         if test -d "$cf_path"; then
4242                 test -n "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath="${cf_cv_ld_searchpath} "
4243                 cf_cv_ld_searchpath="${cf_cv_ld_searchpath}${cf_path}"
4244         fi
4245 done
4246
4247 # Ensure that it is nonempty
4248 test -z "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath=/usr/lib
4249 ])
4250
4251 LD_SEARCHPATH=`echo "$cf_cv_ld_searchpath"|sed -e 's/ /|/g'`
4252 AC_SUBST(LD_SEARCHPATH)
4253 ])dnl
4254 dnl ---------------------------------------------------------------------------
4255 dnl CF_LIBRARY_PATH version: 11 updated: 2021/01/01 13:31:04
4256 dnl ---------------
4257 dnl Construct a search-list of directories for a nonstandard library-file
4258 dnl
4259 dnl Parameters
4260 dnl     $1 = the variable to return as result
4261 dnl     $2 = the package name
4262 AC_DEFUN([CF_LIBRARY_PATH],
4263 [
4264 $1=
4265 cf_library_path_list=""
4266 if test -n "${LDFLAGS}${LIBS}" ; then
4267         for cf_library_path in $LDFLAGS $LIBS
4268         do
4269                 case "$cf_library_path" in
4270                 (-L*)
4271                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
4272                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
4273                         cf_library_path_list="$cf_library_path_list [$]$1"
4274                         ;;
4275                 esac
4276         done
4277 fi
4278
4279 CF_SUBDIR_PATH($1,$2,lib)
4280
4281 $1="$cf_library_path_list [$]$1"
4282 ])dnl
4283 dnl ---------------------------------------------------------------------------
4284 dnl CF_LIBTOOL_VERSION version: 1 updated: 2013/04/06 18:03:09
4285 dnl ------------------
4286 AC_DEFUN([CF_LIBTOOL_VERSION],[
4287 if test -n "$LIBTOOL" && test "$LIBTOOL" != none
4288 then
4289         cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' |sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
4290 else
4291         cf_cv_libtool_version=
4292 fi
4293 test -z "$cf_cv_libtool_version" && unset cf_cv_libtool_version
4294 ])dnl
4295 dnl ---------------------------------------------------------------------------
4296 dnl CF_LIB_PREFIX version: 14 updated: 2021/01/01 13:31:04
4297 dnl -------------
4298 dnl Compute the library-prefix for the given host system
4299 dnl $1 = variable to set
4300 define([CF_LIB_PREFIX],
4301 [
4302         case "$cf_cv_system_name" in
4303         (OS/2*|os2*)
4304                 if test "$DFT_LWR_MODEL" = libtool; then
4305                         LIB_PREFIX='lib'
4306                 else
4307                         LIB_PREFIX=''
4308                 fi
4309                 ;;
4310         (*-msvc*)
4311                 LIB_PREFIX=''
4312                 ;;
4313         (*)     LIB_PREFIX='lib'
4314                 ;;
4315         esac
4316 ifelse($1,,,[$1=$LIB_PREFIX])
4317         AC_SUBST(LIB_PREFIX)
4318 ])dnl
4319 dnl ---------------------------------------------------------------------------
4320 dnl CF_LIB_RULES version: 97 updated: 2021/07/17 13:10:54
4321 dnl ------------
4322 dnl Append definitions and rules for the given models to the subdirectory
4323 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
4324 dnl subdirectory is a library-source directory, modify the Libs_To_Make list in
4325 dnl the corresponding makefile to list the models that we'll generate.
4326 dnl
4327 dnl For shared libraries, make a list of symbolic links to construct when
4328 dnl generating each library.  The convention used for Linux is the simplest
4329 dnl one:
4330 dnl     lib<name>.so    ->
4331 dnl     lib<name>.so.<major>    ->
4332 dnl     lib<name>.so.<maj>.<minor>
4333 dnl
4334 dnl Note: Libs_To_Make is mixed case, since it is not a pure autoconf variable.
4335 AC_DEFUN([CF_LIB_RULES],
4336 [AC_REQUIRE([AC_PROG_FGREP])dnl
4337 AC_REQUIRE([CF_MAKE_PHONY])dnl
4338
4339 cf_prefix=$LIB_PREFIX
4340 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
4341
4342 case "$cf_cv_shlib_version" in
4343 (cygdll|msysdll|mingw|msvcdll)
4344         TINFO_NAME=$TINFO_ARG_SUFFIX
4345         TINFO_SUFFIX=.dll
4346         ;;
4347 esac
4348
4349 if test -n "$TINFO_SUFFIX" ; then
4350         case "$TINFO_SUFFIX" in
4351         (tw*)
4352                 TINFO_NAME="${TINFO_NAME}tw${EXTRA_SUFFIX}"
4353                 TINFO_SUFFIX=`echo "$TINFO_SUFFIX" | sed 's/^tw'$EXTRA_SUFFIX'//'`
4354                 ;;
4355         (t*)
4356                 TINFO_NAME="${TINFO_NAME}t${EXTRA_SUFFIX}"
4357                 TINFO_SUFFIX=`echo "$TINFO_SUFFIX" | sed 's/^t'$EXTRA_SUFFIX'//'`
4358                 ;;
4359         (w*)
4360                 TINFO_NAME="${TINFO_NAME}w${EXTRA_SUFFIX}"
4361                 TINFO_SUFFIX=`echo "$TINFO_SUFFIX" | sed 's/^w'$EXTRA_SUFFIX'//'`
4362                 ;;
4363         esac
4364 fi
4365
4366 for cf_dir in $SRC_SUBDIRS
4367 do
4368         if test ! -d "$srcdir/$cf_dir" ; then
4369                 continue
4370         elif test -f "$srcdir/$cf_dir/modules" ; then
4371
4372                 SHARED_LIB=
4373                 Libs_To_Make=
4374                 cf_awk_program=
4375                 if test -n "${cf_cv_abi_version}" && test "x${cf_cv_abi_version}" != "x5"
4376                 then
4377                         cf_awk_program="$cf_awk_program\
4378 /deprecated in ABI${cf_cv_abi_version}/ { next; }\
4379 { sub(\"NCURSES([[WT]]+)?\", \"&${cf_cv_abi_version}\"); }\
4380 "
4381                 fi
4382
4383                 if test "x$WILDCARD_SYMS" = xno
4384                 then
4385                         cf_awk_program="$cf_awk_program\
4386 /[[     ]]_\\*;/ { skip=1; next; }\
4387 "
4388                 fi
4389
4390                 if test "x$cf_awk_program" != "x"
4391                 then
4392                         cat >>$cf_dir/Makefile <<CF_EOF
4393
4394 # Generated by CF_LIB_RULES
4395 resulting.map: $UNALTERED_SYMS
4396         $AWK 'BEGIN { skip = 1; last=""; } \
4397 $cf_awk_program \
4398 { if ( last != "" && ( skip == 0 || \[$]\[$]0 !~ /}/ ) ) { print last; }\
4399  skip = 0; last = \[$]\[$]0; } \
4400 END { print last; }' < "$UNALTERED_SYMS" >\[$]@
4401
4402 distclean::
4403         rm -f resulting.map
4404 CF_EOF
4405                 fi
4406
4407                 for cf_item in $cf_LIST_MODELS
4408                 do
4409                         CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
4410                         if test "$cf_dir" = "c++"
4411                         then
4412                                 CF_MAP_LIB_BASENAME(cf_libname,cxx)
4413                         else
4414                                 CF_MAP_LIB_BASENAME(cf_libname,$cf_dir)
4415                         fi
4416                         test -z "$cf_libname" && cf_libname="$cf_dir"
4417                         if test "$cf_item" = shared ; then
4418                                 if test -n "${LIB_SUFFIX}"
4419                                 then
4420                                         cf_shared_suffix=`echo "$cf_suffix" | sed 's/^'"${USE_LIB_SUFFIX}"'//'`
4421                                 else
4422                                         cf_shared_suffix="$cf_suffix"
4423                                 fi
4424                                 if test "$cf_cv_do_symlinks" = yes ; then
4425                                         cf_version_name=
4426
4427                                         case "$cf_cv_shlib_version" in
4428                                         (rel)
4429                                                 cf_version_name=REL_VERSION
4430                                                 ;;
4431                                         (abi)
4432                                                 cf_version_name=ABI_VERSION
4433                                                 ;;
4434                                         esac
4435
4436                                         if test -n "$cf_version_name"
4437                                         then
4438                                                 case "$cf_cv_system_name" in
4439                                                 (darwin*)
4440                                                         # "w", etc?
4441                                                         cf_suffix="${USE_LIB_SUFFIX}"'.${'$cf_version_name'}'"$cf_shared_suffix"
4442                                                         ;;
4443                                                 (*)
4444                                                         cf_suffix="$cf_suffix"'.${'$cf_version_name'}'
4445                                                         ;;
4446                                                 esac
4447                                         fi
4448                                         if test -n "${USE_LIB_SUFFIX}"
4449                                         then
4450                                                 cf_shared_suffix=`echo "$cf_suffix" | sed 's/^'"${USE_LIB_SUFFIX}"'//'`
4451                                         else
4452                                                 cf_shared_suffix="$cf_suffix"
4453                                         fi
4454                                 fi
4455                                 # cygwin needs import library, and has unique naming convention
4456                                 # use autodetected ${cf_prefix} for import lib and static lib, but
4457                                 # use 'cyg' prefix for shared lib.
4458                                 case "$cf_cv_shlib_version" in
4459                                 (cygdll)
4460                                         cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
4461                                         cf_add_lib="../lib/cyg${cf_libname}${cf_cygsuf}"
4462                                         ;;
4463                                 (msysdll)
4464                                         cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
4465                                         cf_add_lib="../lib/msys-${cf_libname}${cf_cygsuf}"
4466                                         ;;
4467                                 (mingw)
4468                                         cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
4469                                         cf_add_lib="../lib/lib${cf_libname}${cf_cygsuf}"
4470                                         ;;
4471                                 (msvcdll)
4472                                         cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
4473                                         cf_add_lib="../lib/${cf_libname}${cf_cygsuf}"
4474                                         ;;
4475                                 (*)
4476                                         cf_add_lib=
4477                                         ;;
4478                                 esac
4479                                 if test -n "$cf_add_lib"
4480                                 then
4481                                         Libs_To_Make="$Libs_To_Make $cf_add_lib"
4482                                         continue
4483                                 fi
4484                         fi
4485                         cf_add_lib="../lib/${cf_prefix}${cf_libname}${cf_suffix}"
4486                         Libs_To_Make="$Libs_To_Make $cf_add_lib"
4487                 done
4488
4489                 if test "$cf_dir" = ncurses ; then
4490                         cf_subsets="$LIB_SUBSETS"
4491                         cf_r_parts="$cf_subsets"
4492                         cf_liblist="$Libs_To_Make"
4493
4494                         while test -n "$cf_r_parts"
4495                         do
4496                                 cf_l_parts=`echo "$cf_r_parts" |sed -e 's/ .*$//'`
4497                                 cf_r_parts=`echo "$cf_r_parts" |sed -e 's/^[[^ ]]* //'`
4498                                 if test "$cf_l_parts" != "$cf_r_parts" ; then
4499                                         cf_add_lib=
4500                                         case "$cf_l_parts" in
4501                                         (*termlib*)
4502                                                 cf_add_lib=`echo "$cf_liblist" |sed -e s%${LIB_NAME}${USE_LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
4503                                                 ;;
4504                                         (*ticlib*)
4505                                                 cf_add_lib=`echo "$cf_liblist" |sed -e s%${LIB_NAME}${USE_LIB_SUFFIX}%${TICS_LIB_SUFFIX}%g`
4506                                                 ;;
4507                                         (*)
4508                                                 break
4509                                                 ;;
4510                                         esac
4511                                         if test -n "$cf_add_lib"; then
4512                                                 Libs_To_Make="$cf_add_lib $Libs_To_Make"
4513                                         fi
4514                                 else
4515                                         break
4516                                 fi
4517                         done
4518                 else
4519                         cf_subsets=`echo "$LIB_SUBSETS" | sed -e 's/^termlib.* //'`
4520                 fi
4521
4522                 if test "$cf_dir" = c++; then
4523                         if test "x$with_shared_cxx" != xyes && test -n "$cf_shared_suffix"; then
4524                                 cf_list=
4525                                 for cf_item in $Libs_To_Make
4526                                 do
4527                                         case "$cf_item" in
4528                                         (*.a)
4529                                                 ;;
4530                                         (*)
4531                                                 cf_item=`echo "$cf_item" | sed -e "s,"$cf_shared_suffix",.a,"`
4532                                                 ;;
4533                                         esac
4534                                         for cf_test in $cf_list
4535                                         do
4536                                                 if test "$cf_test" = "$cf_item"
4537                                                 then
4538                                                         cf_LIST_MODELS=`echo "$cf_LIST_MODELS" | sed -e 's/normal//'`
4539                                                         cf_item=
4540                                                         break
4541                                                 fi
4542                                         done
4543                                         test -n "$cf_item" && cf_list="$cf_list $cf_item"
4544                                 done
4545                                 Libs_To_Make="$cf_list"
4546                         fi
4547                 fi
4548
4549                 sed -e "s%@Libs_To_Make@%$Libs_To_Make%" \
4550                     -e "s%@SHARED_LIB@%$SHARED_LIB%" \
4551                         "$cf_dir/Makefile" >$cf_dir/Makefile.out
4552                 mv "$cf_dir/Makefile.out" "$cf_dir/Makefile"
4553
4554                 $AWK -f "$srcdir/mk-0th.awk" \
4555                         libname="${cf_dir}${LIB_SUFFIX}" subsets="$LIB_SUBSETS" ticlib="$TICS_LIB_SUFFIX" termlib="$TINFO_LIB_SUFFIX" \
4556                         "$srcdir/$cf_dir/modules" >>$cf_dir/Makefile
4557
4558                 for cf_subset in $cf_subsets
4559                 do
4560                         cf_subdirs=
4561                         for cf_item in $cf_LIST_MODELS
4562                         do
4563
4564                         echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})"
4565                         CF_UPPER(cf_ITEM,$cf_item)
4566
4567                         CXX_MODEL=$cf_ITEM
4568                         if test "$CXX_MODEL" = SHARED; then
4569                                 case "$cf_cv_shlib_version" in
4570                                 (cygdll|msysdll|mingw|msvcdll)
4571                                         test "x$with_shared_cxx" = xno && CF_VERBOSE(overriding CXX_MODEL to SHARED)
4572                                         with_shared_cxx=yes
4573                                         ;;
4574                                 (*)
4575                                         test "x$with_shared_cxx" = xno && CXX_MODEL=NORMAL
4576                                         ;;
4577                                 esac
4578                         fi
4579
4580                         CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
4581                         CF_OBJ_SUBDIR($cf_item,cf_subdir)
4582
4583                         # Test for case where we build libtinfo with a different name.
4584                         cf_libname=$cf_dir
4585                         if test "$cf_dir" = ncurses ; then
4586                                 case "$cf_subset" in
4587                                 (*base*)
4588                                         cf_libname=${cf_libname}$USE_LIB_SUFFIX
4589                                         ;;
4590                                 (*termlib*)
4591                                         cf_libname=$TINFO_LIB_SUFFIX
4592                                         ;;
4593                                 (ticlib*)
4594                                         cf_libname=$TICS_LIB_SUFFIX
4595                                         ;;
4596                                 esac
4597                         elif test "$cf_dir" = c++ ; then
4598                                 CF_MAP_LIB_BASENAME(cf_libname,cxx)
4599                                 cf_libname=${cf_libname}$USE_LIB_SUFFIX
4600                         else
4601                                 CF_MAP_LIB_BASENAME(cf_libname,$cf_dir)
4602                                 cf_libname=${cf_libname}$USE_LIB_SUFFIX
4603                         fi
4604                         if test -n "${USE_ARG_SUFFIX}" ; then
4605                                 # undo $USE_LIB_SUFFIX add-on in CF_LIB_SUFFIX
4606                                 cf_suffix=`echo "$cf_suffix" |sed -e "s%^${USE_LIB_SUFFIX}%%"`
4607                         fi
4608
4609                         # These dependencies really are for development, not
4610                         # builds, but they are useful in porting, too.
4611                         cf_depend="../include/ncurses_cfg.h"
4612                         if test "$srcdir" = "."; then
4613                                 cf_reldir="."
4614                         else
4615                                 cf_reldir="\${srcdir}"
4616                         fi
4617
4618                         if test -f "$srcdir/$cf_dir/$cf_dir.priv.h" ; then
4619                                 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
4620                         elif test -f "$srcdir/$cf_dir/curses.priv.h" ; then
4621                                 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
4622                         fi
4623
4624                         cf_dir_suffix=
4625                         old_cf_suffix="$cf_suffix"
4626                         if test "$cf_cv_shlib_version_infix" = yes ; then
4627                         if test -n "$USE_LIB_SUFFIX" ; then
4628                                 case "$USE_LIB_SUFFIX" in
4629                                 (tw*)
4630                                         cf_libname=`echo "$cf_libname" | sed 's/tw'$EXTRA_SUFFIX'$//'`
4631                                         cf_suffix=`echo "$cf_suffix" | sed 's/^tw'$EXTRA_SUFFIX'//'`
4632                                         cf_dir_suffix=tw$EXTRA_SUFFIX
4633                                         ;;
4634                                 (t*)
4635                                         cf_libname=`echo "$cf_libname" | sed 's/t'$EXTRA_SUFFIX'$//'`
4636                                         cf_suffix=`echo "$cf_suffix" | sed 's/^t'$EXTRA_SUFFIX'//'`
4637                                         cf_dir_suffix=t$EXTRA_SUFFIX
4638                                         ;;
4639                                 (w*)
4640                                         cf_libname=`echo "$cf_libname" | sed 's/w'$EXTRA_SUFFIX'$//'`
4641                                         cf_suffix=`echo "$cf_suffix" | sed 's/^w'$EXTRA_SUFFIX'//'`
4642                                         cf_dir_suffix=w$EXTRA_SUFFIX
4643                                         ;;
4644                                 (*)
4645                                         cf_libname=`echo "$cf_libname" | sed 's/'$EXTRA_SUFFIX'$//'`
4646                                         cf_suffix=`echo "$cf_suffix" | sed 's/^'$EXTRA_SUFFIX'//'`
4647                                         cf_dir_suffix=$EXTRA_SUFFIX
4648                                         ;;
4649                                 esac
4650                         fi
4651                         fi
4652
4653                         $AWK -f "$srcdir/mk-1st.awk" \
4654                                 name=${cf_libname}${cf_dir_suffix} \
4655                                 traces=$LIB_TRACING \
4656                                 MODEL=$cf_ITEM \
4657                                 CXX_MODEL=$CXX_MODEL \
4658                                 LIB_SUFFIX=$LIB_SUFFIX \
4659                                 USE_LIB_SUFFIX=$USE_LIB_SUFFIX \
4660                                 make_phony="${cf_cv_make_PHONY:-no}" \
4661                                 model=$cf_subdir \
4662                                 prefix=$cf_prefix \
4663                                 suffix=$cf_suffix \
4664                                 subset=$cf_subset \
4665                                 driver=$cf_cv_term_driver \
4666                                 SymLink="$LN_S" \
4667                                 TermlibRoot=$TINFO_NAME \
4668                                 TermlibSuffix=$TINFO_SUFFIX \
4669                                 ShlibVer=$cf_cv_shlib_version \
4670                                 ShlibVerInfix=$cf_cv_shlib_version_infix \
4671                                 ReLink=${cf_cv_do_relink:-no} \
4672                                 ReRanlib=${cf_cv_do_reranlib:-yes} \
4673                                 DoLinks=$cf_cv_do_symlinks \
4674                                 rmSoLocs=$cf_cv_rm_so_locs \
4675                                 ldconfig="$LDCONFIG" \
4676                                 overwrite=$WITH_OVERWRITE \
4677                                 depend="$cf_depend" \
4678                                 host="$host" \
4679                                 libtool_version="$LIBTOOL_VERSION" \
4680                                 "$srcdir/$cf_dir/modules" >>$cf_dir/Makefile
4681
4682                         cf_suffix="$old_cf_suffix"
4683
4684                         for cf_subdir2 in $cf_subdirs lib
4685                         do
4686                                 test "$cf_subdir" = "$cf_subdir2" && break
4687                         done
4688                         test "${cf_subset}.${cf_subdir2}" != "${cf_subset}.${cf_subdir}" && \
4689                         $AWK -f "$srcdir/mk-2nd.awk" \
4690                                 name=$cf_dir \
4691                                 traces=$LIB_TRACING \
4692                                 MODEL=$cf_ITEM \
4693                                 model=$cf_subdir \
4694                                 subset=$cf_subset \
4695                                 srcdir=$srcdir \
4696                                 echo=$WITH_ECHO \
4697                                 crenames=$cf_cv_prog_CC_c_o \
4698                                 cxxrenames=$cf_cv_prog_CXX_c_o \
4699                                 "$srcdir/$cf_dir/modules" >>$cf_dir/Makefile
4700                         cf_subdirs="$cf_subdirs $cf_subdir"
4701                         done
4702                 done
4703         fi
4704
4705         echo '  ( cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} [$]@ )' >>Makefile
4706 done
4707
4708 echo >> Makefile
4709 echo '# generated by CF_LIB_RULES' >> Makefile
4710
4711 if test "x$cf_cv_make_PHONY" = xyes ; then
4712         cat >> Makefile <<-CF_EOF
4713
4714         .PHONY :        libs
4715         .PHONY :        lintlib
4716         .PHONY :        install.includes
4717         .PHONY :        uninstall.includes
4718         .PHONY :        install.libs
4719         .PHONY :        uninstall.libs
4720 CF_EOF
4721 fi
4722
4723 for cf_dir in $SRC_SUBDIRS
4724 do
4725         if test ! -d "$srcdir/$cf_dir" ; then
4726                 continue
4727         fi
4728
4729         if test -f "$cf_dir/Makefile" ; then
4730                 case "$cf_dir" in
4731                 (Ada95)
4732                         echo 'libs \' >> Makefile
4733                         echo 'install.libs \' >> Makefile
4734                         echo 'uninstall.libs ::' >> Makefile
4735                         echo '  ( cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} [$]@ )' >> Makefile
4736                         ;;
4737                 esac
4738         fi
4739
4740         if test -f "$srcdir/$cf_dir/modules" ; then
4741
4742                 if test "x$cf_cv_make_PHONY" = xyes ; then
4743                         cat >> Makefile <<-CF_EOF
4744
4745                         .PHONY :        install.$cf_dir
4746                         .PHONY :        uninstall.$cf_dir
4747 CF_EOF
4748                 fi
4749
4750                 echo >> Makefile
4751                 if test -f "$srcdir/$cf_dir/headers" ; then
4752 cat >> Makefile <<CF_EOF
4753 install.includes \\
4754 uninstall.includes \\
4755 CF_EOF
4756                 fi
4757
4758 cat >> Makefile <<CF_EOF
4759 lint \\
4760 libs \\
4761 lintlib \\
4762 install.libs \\
4763 uninstall.libs \\
4764 install.$cf_dir \\
4765 uninstall.$cf_dir ::
4766         ( cd "$cf_dir" && \${MAKE} \${TOP_MFLAGS} \[$]@ )
4767 CF_EOF
4768         elif test -f "$srcdir/$cf_dir/headers" ; then
4769 cat >> Makefile <<CF_EOF
4770
4771 libs \\
4772 install.libs \\
4773 uninstall.libs \\
4774 install.includes \\
4775 uninstall.includes ::
4776         ( cd "$cf_dir" && \${MAKE} \${TOP_MFLAGS} \[$]@ )
4777 CF_EOF
4778 fi
4779 done
4780
4781 if test "x$cf_cv_make_PHONY" = xyes ; then
4782         cat >> Makefile <<-CF_EOF
4783
4784         .PHONY :        install.data
4785         .PHONY :        uninstall.data
4786 CF_EOF
4787 fi
4788
4789 if test "x$cf_with_db_install" = xyes; then
4790 cat >> Makefile <<CF_EOF
4791
4792 install.libs uninstall.libs \\
4793 install.data uninstall.data ::
4794 $MAKE_TERMINFO  ( cd misc && \${MAKE} \${TOP_MFLAGS} \[$]@ )
4795 CF_EOF
4796 else
4797 cat >> Makefile <<CF_EOF
4798
4799 install.libs uninstall.libs ::
4800         ( cd misc && \${MAKE} \${TOP_MFLAGS} \[$]@ )
4801 CF_EOF
4802 fi
4803
4804 if test "x$cf_with_manpages" = xyes; then
4805
4806 if test "x$cf_cv_make_PHONY" = xyes ; then
4807         cat >> Makefile <<-CF_EOF
4808
4809         .PHONY :        install.man
4810         .PHONY :        uninstall.man
4811 CF_EOF
4812 fi
4813
4814 cat >> Makefile <<CF_EOF
4815
4816 install.man \\
4817 uninstall.man ::
4818         ( cd man && \${MAKE} \${TOP_MFLAGS} \[$]@ )
4819 CF_EOF
4820 fi
4821
4822 cat >> Makefile <<CF_EOF
4823
4824 distclean ::
4825         rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
4826         rm -f headers.sh headers.sed mk_shared_lib.sh
4827         rm -f edit_man.* man_alias.*
4828         rm -rf \${DIRS_TO_MAKE}
4829 CF_EOF
4830
4831 # Special case: tack's manpage lives in its own directory.
4832 if test "x$cf_with_manpages" = xyes; then
4833 if test "x$cf_with_tack" = "xyes"; then
4834 cat >> Makefile <<CF_EOF
4835
4836 install.man \\
4837 uninstall.man ::
4838         ( cd tack && \${MAKE} \${TOP_MFLAGS} \[$]@ )
4839 CF_EOF
4840 fi
4841 fi
4842
4843 dnl If we're installing into a subdirectory of /usr/include, etc., we should
4844 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
4845 dnl anything, and will make it more standardized.  It's awkward to decide this
4846 dnl at configuration because of quoting, so we'll simply make all headers
4847 dnl installed via a script that can do the right thing.
4848
4849 rm -f headers.sed headers.sh
4850
4851 dnl ( generating this script makes the makefiles a little tidier :-)
4852 echo creating headers.sh
4853 cat >headers.sh <<CF_EOF
4854 #! $SHELL
4855 # This shell script is generated by the 'configure' script.  It is invoked in a
4856 # subdirectory of the build tree.  It generates a sed-script in the parent
4857 # directory that is used to adjust includes for header files that reside in a
4858 # subdirectory of /usr/include, etc.
4859 PRG=""
4860 while test \[$]# != 3
4861 do
4862 PRG="\$PRG \[$]1"; shift
4863 done
4864 DST=\[$]1
4865 REF=\[$]2
4866 SRC=\[$]3
4867 TMPSRC=\${TMPDIR:-/tmp}/\`basename \$SRC\`\$\$
4868 TMPSED=\${TMPDIR:-/tmp}/headers.sed\$\$
4869 echo installing \$SRC in \$DST
4870 CF_EOF
4871
4872 if test "$WITH_CURSES_H" = yes; then
4873         cat >>headers.sh <<CF_EOF
4874 case \$DST in
4875 (/*/include/*)
4876         END=\`basename \$DST\`
4877         for i in \`cat \$REF/../*/headers |${FGREP-fgrep} -v "#"\`
4878         do
4879                 NAME=\`basename \$i\`
4880                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
4881         done
4882         ;;
4883 (*)
4884         echo "" >> \$TMPSED
4885         ;;
4886 esac
4887 CF_EOF
4888
4889 else
4890         cat >>headers.sh <<CF_EOF
4891 case \$DST in
4892 (/*/include/*)
4893         END=\`basename \$DST\`
4894         for i in \`cat \$REF/../*/headers |${FGREP-fgrep} -v "#"\`
4895         do
4896                 NAME=\`basename \$i\`
4897                 if test "\$NAME" = "curses.h"
4898                 then
4899                         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
4900                         NAME=ncurses.h
4901                 fi
4902                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
4903         done
4904         ;;
4905 (*)
4906         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
4907         ;;
4908 esac
4909 CF_EOF
4910 fi
4911 cat >>headers.sh <<CF_EOF
4912 rm -f \$TMPSRC
4913 sed -f \$TMPSED \$SRC > \$TMPSRC
4914 NAME=\`basename \$SRC\`
4915 CF_EOF
4916 if test "$WITH_CURSES_H" != yes; then
4917         cat >>headers.sh <<CF_EOF
4918 test "\$NAME" = "curses.h" && NAME=ncurses.h
4919 CF_EOF
4920 fi
4921 cat >>headers.sh <<CF_EOF
4922 # Just in case someone gzip'd manpages, remove the conflicting copy.
4923 test -f \$DST/\$NAME.gz && rm -f \$DST/\$NAME.gz
4924
4925 eval \$PRG \$TMPSRC \$DST/\$NAME
4926 rm -f \$TMPSRC \$TMPSED
4927 CF_EOF
4928
4929 chmod 0755 headers.sh
4930
4931 for cf_dir in $SRC_SUBDIRS
4932 do
4933         if test ! -d "$srcdir/$cf_dir" ; then
4934                 continue
4935         fi
4936
4937         if test -f "$srcdir/$cf_dir/headers" ; then
4938                 $AWK -f "$srcdir/mk-hdr.awk" \
4939                         subset="$LIB_SUBSETS" \
4940                         compat="$WITH_CURSES_H" \
4941                         "$srcdir/$cf_dir/headers" >>$cf_dir/Makefile
4942         fi
4943
4944         if test -f "$srcdir/$cf_dir/modules" ; then
4945                 if test "$cf_dir" != "c++" ; then
4946                         if test "x$cf_cv_make_PHONY" = xyes ; then
4947                                 cat >> $cf_dir/Makefile <<-CF_EOF
4948
4949                                 .PHONY :        depend
4950 CF_EOF
4951                         fi
4952
4953                         cat >>$cf_dir/Makefile <<"CF_EOF"
4954 depend : ${AUTO_SRC}
4955         makedepend -- ${CPPFLAGS} -- ${C_SRC}
4956
4957 # DO NOT DELETE THIS LINE -- make depend depends on it.
4958 CF_EOF
4959                 fi
4960         fi
4961 done
4962 AC_SUBST(Libs_To_Make)
4963 ])dnl
4964 dnl ---------------------------------------------------------------------------
4965 dnl CF_LIB_SONAME version: 9 updated: 2021/01/04 18:48:01
4966 dnl -------------
4967 dnl Find the and soname for the given shared library.  Set the cache variable
4968 dnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
4969 dnl variable to "unknown".
4970 dnl
4971 dnl $1 = headers
4972 dnl $2 = code
4973 dnl $3 = library name
4974 AC_DEFUN([CF_LIB_SONAME],
4975 [AC_REQUIRE([AC_PROG_FGREP])dnl
4976
4977 AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
4978
4979 cf_cv_$3_soname=unknown
4980 if test "$cross_compiling" != yes ; then
4981 cat >conftest.$ac_ext <<CF_EOF
4982 $1
4983 int main(void)
4984 {
4985 $2
4986         ${cf_cv_main_return:-return}(0);
4987 }
4988 CF_EOF
4989 cf_save_LIBS="$LIBS"
4990         CF_ADD_LIB($3)
4991         if AC_TRY_EVAL(ac_compile) ; then
4992                 if AC_TRY_EVAL(ac_link) ; then
4993                         cf_cv_$3_soname="`ldd \"conftest$ac_exeext\" 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | ${FGREP-fgrep} lib$3.`"
4994                         test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
4995                 fi
4996         fi
4997 rm -rf ./conftest*
4998 LIBS="$cf_save_LIBS"
4999 fi
5000 ])
5001 ])
5002 dnl ---------------------------------------------------------------------------
5003 dnl CF_LIB_SUFFIX version: 28 updated: 2021/01/01 16:53:59
5004 dnl -------------
5005 dnl Compute the library file-suffix from the given model name
5006 dnl $1 = model name
5007 dnl $2 = variable to set (the nominal library suffix)
5008 dnl $3 = dependency variable to set (actual filename)
5009 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
5010 AC_DEFUN([CF_LIB_SUFFIX],
5011 [
5012         case X$1 in
5013         (Xlibtool)
5014                 $2='.la'
5015                 $3=[$]$2
5016                 ;;
5017         (Xdebug)
5018                 case "$cf_cv_system_name" in
5019                 (*-msvc*)
5020                         $2='_g.lib'
5021                         ;;
5022                 (*)
5023                         $2='_g.a'
5024                         ;;
5025                 esac
5026                 $3=[$]$2
5027                 ;;
5028         (Xprofile)
5029                 case "$cf_cv_system_name" in
5030                 (*-msvc*)
5031                         $2='_p.lib'
5032                         ;;
5033                 (*)
5034                         $2='_p.a'
5035                         ;;
5036                 esac
5037                 $3=[$]$2
5038                 ;;
5039         (Xshared)
5040                 case "$cf_cv_system_name" in
5041                 (aix[[5-7]]*)
5042                         $2='.so'
5043                         $3=[$]$2
5044                         ;;
5045                 (*-msvc*)
5046                         $2='.dll'
5047                         $3='.dll.lib'
5048                         ;;
5049                 (cygwin*|msys*|mingw*)
5050                         $2='.dll'
5051                         $3='.dll.a'
5052                         ;;
5053                 (darwin*)
5054                         $2='.dylib'
5055                         $3=[$]$2
5056                         ;;
5057                 (hpux*)
5058                         case "$target" in
5059                         (ia64*)
5060                                 $2='.so'
5061                                 $3=[$]$2
5062                                 ;;
5063                         (*)
5064                                 $2='.sl'
5065                                 $3=[$]$2
5066                                 ;;
5067                         esac
5068                         ;;
5069                 (*)
5070                         $2='.so'
5071                         $3=[$]$2
5072                         ;;
5073                 esac
5074                 ;;
5075         (*)
5076                 case "$target" in
5077                 (*-msvc*)
5078                         $2='.lib'
5079                         ;;
5080                 (*)
5081                         $2='.a'
5082                         ;;
5083                 esac
5084                 $3=[$]$2
5085                 ;;
5086         esac
5087         if test -n "${LIB_SUFFIX}${EXTRA_SUFFIX}"
5088         then
5089                 $2="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$2}"
5090                 $3="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$3}"
5091         fi
5092 ])dnl
5093 dnl ---------------------------------------------------------------------------
5094 dnl CF_LIB_TYPE version: 5 updated: 2015/04/17 21:13:04
5095 dnl -----------
5096 dnl Compute the string to append to -library from the given model name
5097 dnl $1 = model name
5098 dnl $2 = variable to set
5099 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
5100 AC_DEFUN([CF_LIB_TYPE],
5101 [
5102         case $1 in
5103         (libtool) $2=''   ;;
5104         (normal)  $2=''   ;;
5105         (debug)   $2='_g' ;;
5106         (profile) $2='_p' ;;
5107         (shared)  $2=''   ;;
5108         esac
5109         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
5110 ])dnl
5111 dnl ---------------------------------------------------------------------------
5112 dnl CF_LINK_DATAONLY version: 13 updated: 2020/02/08 15:59:30
5113 dnl ----------------
5114 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
5115 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
5116 dnl have to provide wrappers for global tables to ensure they're linked
5117 dnl properly.
5118 AC_DEFUN([CF_LINK_DATAONLY],
5119 [
5120 AC_MSG_CHECKING([if data-only library module links])
5121 AC_CACHE_VAL(cf_cv_link_dataonly,[
5122         rm -f conftest.a
5123         cat >conftest.$ac_ext <<EOF
5124 #line __oline__ "configure"
5125 int     testdata[[3]] = { 123, 456, 789 };
5126 EOF
5127         if AC_TRY_EVAL(ac_compile) ; then
5128                 mv conftest.o data.o && \
5129                 ( $AR $ARFLAGS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
5130         fi
5131         rm -f conftest.$ac_ext data.o
5132         cat >conftest.$ac_ext <<EOF
5133 #line __oline__ "configure"
5134 int     testfunc(void)
5135 {
5136 #if defined(NeXT)
5137         ${cf_cv_main_return:-return}(1);        /* I'm told this linker is broken */
5138 #else
5139         extern int testdata[[3]];
5140         return testdata[[0]] == 123
5141            &&  testdata[[1]] == 456
5142            &&  testdata[[2]] == 789;
5143 #endif
5144 }
5145 EOF
5146         if AC_TRY_EVAL(ac_compile); then
5147                 mv conftest.o func.o && \
5148                 ( $AR $ARFLAGS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
5149         fi
5150         rm -f conftest.$ac_ext func.o
5151         ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
5152         cf_saveLIBS="$LIBS"
5153         LIBS="conftest.a $LIBS"
5154         AC_TRY_RUN([
5155         int main(void)
5156         {
5157                 extern int testfunc();
5158                 ${cf_cv_main_return:-return} (!testfunc());
5159         }
5160         ],
5161         [cf_cv_link_dataonly=yes],
5162         [cf_cv_link_dataonly=no],
5163         [cf_cv_link_dataonly=unknown])
5164         LIBS="$cf_saveLIBS"
5165         ])
5166 AC_MSG_RESULT($cf_cv_link_dataonly)
5167
5168 if test "$cf_cv_link_dataonly" = no ; then
5169         AC_DEFINE(BROKEN_LINKER,1,[if data-only library module does not link])
5170         BROKEN_LINKER=1
5171 fi
5172 AC_SUBST(BROKEN_LINKER)
5173
5174 ])dnl
5175 dnl ---------------------------------------------------------------------------
5176 dnl CF_LINK_FUNCS version: 11 updated: 2021/04/18 14:08:47
5177 dnl -------------
5178 dnl Most Unix systems have both link and symlink, a few don't have symlink.
5179 dnl A few non-Unix systems implement symlink, but not link.
5180 dnl A few non-systems implement neither (or have nonfunctional versions).
5181 dnl
5182 dnl This allows for a 2-second difference in modification times to allow for
5183 dnl some marginal NFS implementations.
5184 AC_DEFUN([CF_LINK_FUNCS],
5185 [
5186 AC_CHECK_HEADERS( \
5187 unistd.h \
5188 )
5189 AC_CHECK_FUNCS( \
5190         remove \
5191         unlink )
5192
5193 if test "$cross_compiling" = yes ; then
5194         AC_CHECK_FUNCS( \
5195                 link \
5196                 symlink )
5197 else
5198         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
5199                 cf_cv_link_funcs=
5200                 for cf_func in link symlink ; do
5201                         AC_TRY_RUN([
5202 #include <stdio.h>
5203 #include <sys/types.h>
5204 #include <sys/stat.h>
5205 #ifdef HAVE_UNISTD_H
5206 #include <unistd.h>
5207 #endif
5208 int main(void)
5209 {
5210         int fail = 0;
5211         char *src = "conftest.tmp";
5212         char *dst = "conftest.chk";
5213         struct stat src_sb, dst_sb;
5214         FILE *fp = fopen(src, "w");
5215         if (fp == 0) { fail = 3; } else {
5216                 fclose(fp); stat(src, &src_sb);
5217                 if ($cf_func(src, dst) < 0) {
5218                         fail = 1;
5219                 } else if (stat(dst, &dst_sb) < 0) {
5220                         fail = 2;
5221                 } else {
5222                         long diff = (dst_sb.st_mtime - src_sb.st_mtime);
5223                         if (diff < 0) diff = -diff;
5224                         if (diff > 2) fail = 3;
5225                 }
5226         }
5227 #ifdef HAVE_UNLINK
5228         unlink(dst); unlink(src);
5229 #else
5230         remove(dst); remove(src);
5231 #endif
5232         ${cf_cv_main_return:-return} (fail);
5233 }
5234                         ],[
5235                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
5236                         eval 'ac_cv_func_'$cf_func'=yes'],[
5237                         eval 'ac_cv_func_'$cf_func'=no'],[
5238                         eval 'ac_cv_func_'$cf_func'=error'])
5239                 done
5240                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
5241         ])
5242         test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK,1,[Define to 1 if we have link() function])
5243         test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK,1,[Define to 1 if we have symlink() function])
5244 fi
5245 ])dnl
5246 dnl ---------------------------------------------------------------------------
5247 dnl CF_MAKEFLAGS version: 20 updated: 2021/01/03 19:29:49
5248 dnl ------------
5249 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
5250 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
5251 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
5252 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
5253 AC_DEFUN([CF_MAKEFLAGS],
5254 [AC_REQUIRE([AC_PROG_FGREP])dnl
5255
5256 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
5257         cf_cv_makeflags=''
5258         for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
5259         do
5260                 cat >cf_makeflags.tmp <<CF_EOF
5261 SHELL = $SHELL
5262 all :
5263         @ echo '.$cf_option'
5264 CF_EOF
5265                 cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp 2>/dev/null | ${FGREP-fgrep} -v "ing directory" | sed -e 's,[[  ]]*$,,'`
5266                 case "$cf_result" in
5267                 (.*k|.*kw)
5268                         cf_result="`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`"
5269                         case "$cf_result" in
5270                         (.*CC=*)        cf_cv_makeflags=
5271                                 ;;
5272                         (*)     cf_cv_makeflags=$cf_option
5273                                 ;;
5274                         esac
5275                         break
5276                         ;;
5277                 (.-)
5278                         ;;
5279                 (*)
5280                         CF_MSG_LOG(given option \"$cf_option\", no match \"$cf_result\")
5281                         ;;
5282                 esac
5283         done
5284         rm -f cf_makeflags.tmp
5285 ])
5286
5287 AC_SUBST(cf_cv_makeflags)
5288 ])dnl
5289 dnl ---------------------------------------------------------------------------
5290 dnl CF_MAKE_PHONY version: 3 updated: 2021/01/08 16:08:21
5291 dnl -------------
5292 dnl Check if the make-program handles a ".PHONY" target, e.g,. a target which
5293 dnl acts as a placeholder.
5294 dnl
5295 dnl The ".PHONY" feature was proposed in 2011 here
5296 dnl     https://www.austingroupbugs.net/view.php?id=523
5297 dnl and is scheduled for release in P1003.1 Issue 8 (late 2022).
5298 dnl
5299 dnl This is not supported by SVr4 make (or SunOS 4, 4.3SD, etc), but works with
5300 dnl a few others (i.e., GNU make and the non-POSIX "BSD" make):
5301 dnl
5302 dnl + This is a GNU make feature (since April 1988, but in turn from binutils,
5303 dnl   date unspecified).
5304 dnl
5305 dnl + It was adopted in NetBSD make in June 1995.
5306 dnl
5307 dnl + The other BSD make programs are derived from the NetBSD make (and for
5308 dnl   that reason are not actually different "implementations").
5309 dnl
5310 dnl + Some features of NetBSD make were actually adapted from pmake, which
5311 dnl   began as a modified GNU make starting in 1993.
5312 dnl
5313 dnl + Version 3.8 of the dmake program in January 1992 also implemented this
5314 dnl   GNU make extension, but is less well known than the BSD make.
5315 AC_DEFUN([CF_MAKE_PHONY],[
5316 AC_CACHE_CHECK(for \".PHONY\" make-support, cf_cv_make_PHONY,[
5317         rm -rf conftest*
5318         (
5319                 mkdir conftest || exit 1
5320                 cd conftest
5321                 cat >makefile <<'CF_EOF'
5322 .PHONY: always
5323 DATA=0
5324 always: always.out
5325         @echo "** making [$]@ [$](DATA)"
5326 once: once.out
5327         @echo "** making [$]@ [$](DATA)"
5328 always.out:
5329         @echo "** making [$]@ [$](DATA)"
5330         echo [$](DATA) > [$]@
5331 once.out:
5332         @echo "** making [$]@ [$](DATA)"
5333         echo [$](DATA) > [$]@
5334 CF_EOF
5335                 for cf_data in 1 2 3
5336                 do
5337                         ${MAKE:-make} always DATA=$cf_data
5338                         ${MAKE:-make} once   DATA=$cf_data
5339                         ${MAKE:-make} -t always once
5340                         if test -f always ; then
5341                                 echo "no (case 1)" > ../conftest.tmp
5342                         elif test ! -f always.out ; then
5343                                 echo "no (case 2)" > ../conftest.tmp
5344                         elif test ! -f once.out ; then
5345                                 echo "no (case 3)" > ../conftest.tmp
5346                         elif ! cmp -s always.out once.out ; then
5347                                 echo "no (case 4)" > ../conftest.tmp
5348                                 diff always.out once.out
5349                         else
5350                                 cf_check="`cat always.out`"
5351                                 if test "x$cf_check" != "x$cf_data" ; then
5352                                         echo "no (case 5)" > ../conftest.tmp
5353                                 else
5354                                         echo yes > ../conftest.tmp
5355                                         rm -f ./*.out
5356                                         continue
5357                                 fi
5358                         fi
5359                         break
5360                 done
5361         ) >&AC_FD_CC 2>&1
5362         cf_cv_make_PHONY="`cat conftest.tmp`"
5363         rm -rf conftest*
5364 ])
5365 MAKE_NO_PHONY="#"
5366 MAKE_PHONY="#"
5367 test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY=
5368 test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY=
5369 AC_SUBST(MAKE_NO_PHONY)
5370 AC_SUBST(MAKE_PHONY)
5371 ])dnl
5372 dnl ---------------------------------------------------------------------------
5373 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
5374 dnl ------------
5375 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
5376 dnl a monocase filesystem.
5377 AC_DEFUN([CF_MAKE_TAGS],[
5378 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
5379
5380 AC_CHECK_PROGS(CTAGS, exctags ctags)
5381 AC_CHECK_PROGS(ETAGS, exetags etags)
5382
5383 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
5384
5385 if test "$cf_cv_mixedcase" = yes ; then
5386         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
5387 else
5388         MAKE_UPPER_TAGS=no
5389 fi
5390
5391 if test "$MAKE_UPPER_TAGS" = yes ; then
5392         MAKE_UPPER_TAGS=
5393 else
5394         MAKE_UPPER_TAGS="#"
5395 fi
5396
5397 if test "$MAKE_LOWER_TAGS" = yes ; then
5398         MAKE_LOWER_TAGS=
5399 else
5400         MAKE_LOWER_TAGS="#"
5401 fi
5402
5403 AC_SUBST(CTAGS)
5404 AC_SUBST(ETAGS)
5405
5406 AC_SUBST(MAKE_UPPER_TAGS)
5407 AC_SUBST(MAKE_LOWER_TAGS)
5408 ])dnl
5409 dnl ---------------------------------------------------------------------------
5410 dnl CF_MANPAGE_FORMAT version: 15 updated: 2021/09/04 06:35:04
5411 dnl -----------------
5412 dnl Option to allow user to override automatic configuration of manpage format.
5413 dnl There are several special cases:
5414 dnl
5415 dnl     gzip - man checks for, can display gzip'd files
5416 dnl     compress - man checks for, can display compressed files
5417 dnl     BSDI - files in the cat-directories are suffixed ".0"
5418 dnl     formatted - installer should format (put files in cat-directory)
5419 dnl     catonly - installer should only format, e.g., for a turnkey system.
5420 dnl
5421 dnl There are other configurations which this macro does not test, e.g., HPUX's
5422 dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
5423 dnl convention would not match our use).
5424 AC_DEFUN([CF_MANPAGE_FORMAT],
5425 [
5426 AC_REQUIRE([CF_PATHSEP])
5427 AC_MSG_CHECKING(format of man-pages)
5428
5429 AC_ARG_WITH(manpage-format,
5430         [  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
5431                           optionally formatted/catonly, e.g., gzip,formatted],
5432         [MANPAGE_FORMAT=$withval],
5433         [MANPAGE_FORMAT=unknown])
5434
5435 test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
5436 MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
5437
5438 cf_unknown=
5439
5440 case "$MANPAGE_FORMAT" in
5441 (unknown)
5442         if test -z "$MANPATH" ; then
5443                 MANPATH="/usr/man:/usr/share/man"
5444         fi
5445
5446         # look for the 'date' man-page (it is most likely to be installed!)
5447         MANPAGE_FORMAT=
5448         cf_preform="no"
5449         cf_catonly="yes"
5450         cf_example="date"
5451
5452         IFS="${IFS:-    }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
5453         for cf_dir in $MANPATH; do
5454                 test -z "$cf_dir" && cf_dir=/usr/man
5455                 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
5456                 do
5457                         cf_test=`echo "$cf_name" | sed -e 's/*//'`
5458                         if test "x$cf_test" = "x$cf_name" ; then
5459
5460                                 case "$cf_name" in
5461                                 (*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
5462                                 (*.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
5463                                 (*.0)  MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
5464                                 (*)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
5465                                 esac
5466
5467                                 case "$cf_name" in
5468                                 ($cf_dir/man*)
5469                                         cf_catonly=no
5470                                         ;;
5471                                 ($cf_dir/cat*)
5472                                         cf_preform=yes
5473                                         ;;
5474                                 esac
5475                                 break
5476                         fi
5477
5478                         # if we found a match in either man* or cat*, stop looking
5479                         if test -n "$MANPAGE_FORMAT" ; then
5480                                 cf_found=no
5481                                 test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
5482                                 test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
5483                                 case "$cf_name" in
5484                                 ($cf_dir/cat*)
5485                                         cf_found=yes
5486                                         ;;
5487                                 esac
5488                                 test "$cf_found" = yes && break
5489                         fi
5490                 done
5491                 # only check the first directory in $MANPATH where we find manpages
5492                 if test -n "$MANPAGE_FORMAT" ; then
5493                         break
5494                 fi
5495         done
5496         # if we did not find the example, just assume it is normal
5497         test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
5498         IFS="$ac_save_ifs"
5499         ;;
5500 (*)
5501         for cf_option in $MANPAGE_FORMAT; do
5502         case "$cf_option" in
5503         (gzip|compress|BSDI|normal|formatted|catonly)
5504                 ;;
5505         (*)
5506                 cf_unknown="$cf_unknown $cf_option"
5507                 ;;
5508         esac
5509         done
5510         ;;
5511 esac
5512
5513 AC_MSG_RESULT($MANPAGE_FORMAT)
5514 if test -n "$cf_unknown" ; then
5515         AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
5516 fi
5517 ])dnl
5518 dnl ---------------------------------------------------------------------------
5519 dnl CF_MANPAGE_RENAMES version: 12 updated: 2021/01/01 16:53:59
5520 dnl ------------------
5521 dnl The Debian people have their own naming convention for manpages.  This
5522 dnl option lets us override the name of the file containing renaming, or
5523 dnl disable it altogether.
5524 AC_DEFUN([CF_MANPAGE_RENAMES],
5525 [
5526 AC_MSG_CHECKING(for manpage renaming)
5527
5528 AC_ARG_WITH(manpage-renames,
5529         [  --with-manpage-renames  specify manpage-renaming],
5530         [MANPAGE_RENAMES=$withval],
5531         [MANPAGE_RENAMES=yes])
5532
5533 case ".$MANPAGE_RENAMES" in
5534 (.no)
5535         ;;
5536 (.|.yes)
5537         # Debian 'man' program?
5538         if test -f /etc/debian_version ; then
5539                 MANPAGE_RENAMES=`cd "$srcdir" && pwd`/man/man_db.renames
5540         else
5541                 MANPAGE_RENAMES=no
5542         fi
5543         ;;
5544 esac
5545
5546 if test "$MANPAGE_RENAMES" != no ; then
5547         if test -f "$srcdir/man/$MANPAGE_RENAMES" ; then
5548                 MANPAGE_RENAMES=`cd "$srcdir/man" && pwd`/$MANPAGE_RENAMES
5549         elif test ! -f "$MANPAGE_RENAMES" ; then
5550                 AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
5551         fi
5552
5553         test ! -d man && mkdir man
5554
5555         # Construct a sed-script to perform renaming within man-pages
5556         if test -n "$MANPAGE_RENAMES" ; then
5557                 test ! -d man && mkdir man
5558                 $SHELL "$srcdir/man/make_sed.sh" "$MANPAGE_RENAMES" >./edit_man.sed
5559         fi
5560 fi
5561
5562 AC_MSG_RESULT($MANPAGE_RENAMES)
5563 AC_SUBST(MANPAGE_RENAMES)
5564 ])dnl
5565 dnl ---------------------------------------------------------------------------
5566 dnl CF_MANPAGE_SYMLINKS version: 6 updated: 2015/04/17 21:13:04
5567 dnl -------------------
5568 dnl Some people expect each tool to make all aliases for manpages in the
5569 dnl man-directory.  This accommodates the older, less-capable implementations
5570 dnl of 'man', and is optional.
5571 AC_DEFUN([CF_MANPAGE_SYMLINKS],
5572 [
5573 AC_MSG_CHECKING(if manpage aliases will be installed)
5574
5575 AC_ARG_WITH(manpage-aliases,
5576         [  --with-manpage-aliases  specify manpage-aliases using .so],
5577         [MANPAGE_ALIASES=$withval],
5578         [MANPAGE_ALIASES=yes])
5579
5580 AC_MSG_RESULT($MANPAGE_ALIASES)
5581
5582 case "x$LN_S" in
5583 (xln*)
5584         cf_use_symlinks=yes
5585         ;;
5586 (*)
5587         cf_use_symlinks=no
5588         ;;
5589 esac
5590
5591 MANPAGE_SYMLINKS=no
5592 if test "$MANPAGE_ALIASES" = yes ; then
5593 AC_MSG_CHECKING(if manpage symlinks should be used)
5594
5595 AC_ARG_WITH(manpage-symlinks,
5596         [  --with-manpage-symlinks specify manpage-aliases using symlinks],
5597         [MANPAGE_SYMLINKS=$withval],
5598         [MANPAGE_SYMLINKS=$cf_use_symlinks])
5599
5600 if test "$$cf_use_symlinks" = no; then
5601 if test "$MANPAGE_SYMLINKS" = yes ; then
5602         AC_MSG_WARN(cannot make symlinks, will use .so files)
5603         MANPAGE_SYMLINKS=no
5604 fi
5605 fi
5606
5607 AC_MSG_RESULT($MANPAGE_SYMLINKS)
5608 fi
5609
5610 ])dnl
5611 dnl ---------------------------------------------------------------------------
5612 dnl CF_MANPAGE_TBL version: 3 updated: 2002/01/19 22:51:32
5613 dnl --------------
5614 dnl This option causes manpages to be run through tbl(1) to generate tables
5615 dnl correctly.
5616 AC_DEFUN([CF_MANPAGE_TBL],
5617 [
5618 AC_MSG_CHECKING(for manpage tbl)
5619
5620 AC_ARG_WITH(manpage-tbl,
5621         [  --with-manpage-tbl      specify manpage processing with tbl],
5622         [MANPAGE_TBL=$withval],
5623         [MANPAGE_TBL=no])
5624
5625 AC_MSG_RESULT($MANPAGE_TBL)
5626 ])dnl
5627 dnl ---------------------------------------------------------------------------
5628 dnl CF_MAN_PAGES version: 51 updated: 2021/01/05 16:29:19
5629 dnl ------------
5630 dnl Try to determine if the man-pages on the system are compressed, and if
5631 dnl so, what format is used.  Use this information to construct a script that
5632 dnl will install man-pages.
5633 AC_DEFUN([CF_MAN_PAGES],
5634 [
5635 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
5636 CF_MANPAGE_FORMAT
5637 CF_MANPAGE_RENAMES
5638 CF_MANPAGE_SYMLINKS
5639 CF_MANPAGE_TBL
5640
5641 if test "$prefix" = "NONE" ; then
5642         cf_prefix="$ac_default_prefix"
5643 else
5644         cf_prefix="$prefix"
5645 fi
5646
5647 case "$MANPAGE_FORMAT" in
5648 (*catonly*)
5649         cf_format=yes
5650         cf_inboth=no
5651         ;;
5652 (*formatted*)
5653         cf_format=yes
5654         cf_inboth=yes
5655         ;;
5656 (*)
5657         cf_format=no
5658         cf_inboth=no
5659         ;;
5660 esac
5661
5662 test ! -d man && mkdir man
5663
5664 cf_so_strip=
5665 cf_compress=
5666 case "$MANPAGE_FORMAT" in
5667 (*compress*)
5668         cf_so_strip="Z"
5669         cf_compress=compress
5670         ;;
5671 (*gzip*)
5672         cf_so_strip="gz"
5673         cf_compress=gzip
5674         ;;
5675 esac
5676
5677 cf_edit_man=./edit_man.sh
5678 cf_man_alias=`pwd`/man_alias.sed
5679
5680 cat >$cf_edit_man <<CF_EOF
5681 #! $SHELL
5682 # this script is generated by the configure-script CF_MAN_PAGES macro.
5683
5684 prefix="$cf_prefix"
5685 datarootdir="$datarootdir"
5686 datadir="$datadir"
5687
5688 NCURSES_MAJOR="$NCURSES_MAJOR"
5689 NCURSES_MINOR="$NCURSES_MINOR"
5690 NCURSES_PATCH="$NCURSES_PATCH"
5691
5692 NCURSES_OSPEED="$NCURSES_OSPEED"
5693 TERMINFO="$TERMINFO"
5694
5695 INSTALL="$INSTALL"
5696 INSTALL_DATA="$INSTALL_DATA"
5697
5698 transform="$program_transform_name"
5699
5700 TMP=\${TMPDIR:=/tmp}/man\$\$
5701 trap "rm -f \$TMP" 0 1 2 3 15
5702
5703 form=\[$]1
5704 shift || exit 1
5705
5706 verb=\[$]1
5707 shift || exit 1
5708
5709 mandir=\[$]1
5710 shift || exit 1
5711
5712 srcdir=\[$]1
5713 top_srcdir=\[$]srcdir/..
5714 shift || exit 1
5715
5716 if test "\$form" = normal ; then
5717         if test "$cf_format" = yes ; then
5718         if test "$cf_inboth" = no ; then
5719                 $SHELL "\[$]0" format "\$verb" "\$mandir" "\$srcdir" "\[$]@"
5720                 exit $?
5721         fi
5722         fi
5723         cf_subdir=\$mandir/man
5724         cf_tables=$MANPAGE_TBL
5725 else
5726         cf_subdir=\$mandir/cat
5727         cf_tables=yes
5728 fi
5729
5730 # process the list of source-files
5731 for i in "\[$]@" ; do
5732 case \$i in
5733 (*.orig|*.rej) ;;
5734 (*.[[0-9]]*)
5735         section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`;
5736         if test "\$verb" = installing ; then
5737         if test ! -d "\$cf_subdir\${section}" ; then
5738                 mkdir -p "\$cf_subdir\$section"
5739         fi
5740         fi
5741
5742         # replace variables in man page
5743         if test ! -f "$cf_man_alias" ; then
5744 cat >>$cf_man_alias <<-CF_EOF2
5745                 s,@DATADIR@,\$datadir,g
5746                 s,@TERMINFO@,\${TERMINFO:="no default value"},g
5747                 s,@TERMINFO_DIRS@,\${TERMINFO_DIRS:="no default value"},g
5748                 s,@NCURSES_MAJOR@,\${NCURSES_MAJOR:="no default value"},g
5749                 s,@NCURSES_MINOR@,\${NCURSES_MINOR:="no default value"},g
5750                 s,@NCURSES_PATCH@,\${NCURSES_PATCH:="no default value"},g
5751                 s,@NCURSES_OSPEED@,\${NCURSES_OSPEED:="no default value"},g
5752 CF_EOF
5753         ifelse($1,,,[
5754         for cf_name in $1
5755         do
5756                 cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
5757                 cf_name=`echo "$cf_name" | sed "$program_transform_name"`
5758 cat >>$cf_edit_man <<-CF_EOF
5759                 s,@$cf_NAME@,$cf_name,g
5760 CF_EOF
5761         done
5762         ])
5763 cat >>$cf_edit_man <<CF_EOF
5764 CF_EOF2
5765                 echo "...made $cf_man_alias"
5766         fi
5767
5768         aliases=
5769         cf_source=\`basename "\$i"\`
5770         inalias=\$cf_source
5771         test ! -f "\$inalias" && inalias="\$srcdir/\$inalias"
5772         if test ! -f "\$inalias" ; then
5773                 echo ".. skipped \$cf_source"
5774                 continue
5775         fi
5776 CF_EOF
5777
5778 if test "$MANPAGE_ALIASES" != no ; then
5779 cat >>$cf_edit_man <<CF_EOF
5780         nCurses=ignore.3x
5781         test "$with_curses_h" = yes && nCurses=ncurses.3x
5782         aliases=\`sed -f "\$top_srcdir/man/manlinks.sed" "\$inalias" |sed -f "$cf_man_alias" | sort -u; test "\$inalias" = "\$nCurses" && echo curses\`
5783 CF_EOF
5784 fi
5785
5786 if test "$MANPAGE_RENAMES" = no ; then
5787 cat >>$cf_edit_man <<CF_EOF
5788         # perform program transformations for section 1 man pages
5789         if test \$section = 1 ; then
5790                 cf_target=\$cf_subdir\${section}/\`echo \$cf_source|sed "\${transform}"\`
5791         else
5792                 cf_target=\$cf_subdir\${section}/\$cf_source
5793         fi
5794 CF_EOF
5795 else
5796 cat >>$cf_edit_man <<CF_EOF
5797         cf_target=\`grep "^\$cf_source" $MANPAGE_RENAMES | $AWK '{print \[$]2}'\`
5798         if test -z "\$cf_target" ; then
5799                 echo "? missing rename for \$cf_source"
5800                 cf_target="\$cf_source"
5801         fi
5802         cf_target="\$cf_subdir\${section}/\${cf_target}"
5803
5804 CF_EOF
5805 fi
5806
5807 cat >>$cf_edit_man <<CF_EOF
5808         sed     -f "$cf_man_alias" \\
5809 CF_EOF
5810
5811 if test -f "$MANPAGE_RENAMES" ; then
5812 cat >>$cf_edit_man <<CF_EOF
5813                 < "\$i" | sed -f `pwd`/edit_man.sed >\$TMP
5814 CF_EOF
5815 else
5816 cat >>$cf_edit_man <<CF_EOF
5817                 < "\$i" >\$TMP
5818 CF_EOF
5819 fi
5820
5821 cat >>$cf_edit_man <<CF_EOF
5822 if test \$cf_tables = yes ; then
5823         tbl \$TMP >\$TMP.out
5824         mv \$TMP.out \$TMP
5825 fi
5826 CF_EOF
5827
5828 if test "$with_overwrite" != yes ; then
5829 cat >>$cf_edit_man <<CF_EOF
5830         sed -e "/\\#[    ]*include/s,<curses.h,<ncurses$LIB_SUFFIX/curses.h," < \$TMP >\$TMP.out
5831         mv \$TMP.out \$TMP
5832 CF_EOF
5833 fi
5834
5835 if test "$with_curses_h" != yes ; then
5836 cat >>$cf_edit_man <<CF_EOF
5837         sed -e "/\\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
5838         mv \$TMP.out \$TMP
5839 CF_EOF
5840 fi
5841
5842 cat >>$cf_edit_man <<CF_EOF
5843         if test "\$form" = format ; then
5844                 nroff -man \$TMP >\$TMP.out
5845                 mv \$TMP.out \$TMP
5846         fi
5847 CF_EOF
5848
5849 if test -n "$cf_compress" ; then
5850 cat >>$cf_edit_man <<CF_EOF
5851         if test "\$verb" = installing ; then
5852         if ( "$cf_compress" -f \$TMP )
5853         then
5854                 mv \$TMP.$cf_so_strip \$TMP
5855         fi
5856         fi
5857         cf_target="\$cf_target.$cf_so_strip"
5858 CF_EOF
5859 fi
5860
5861 case "$MANPAGE_FORMAT" in
5862 (*BSDI*)
5863 cat >>$cf_edit_man <<CF_EOF
5864         if test "\$form" = format ; then
5865                 # BSDI installs only .0 suffixes in the cat directories
5866                 cf_target="\`echo \$cf_target|sed -e 's/\\.[[1-9]]\\+[[a-z]]*/.0/'\`"
5867         fi
5868 CF_EOF
5869   ;;
5870 esac
5871
5872 cat >>$cf_edit_man <<CF_EOF
5873         suffix=\`basename "\$cf_target" | sed -e 's%^[[^.]]*%%'\`
5874         if test "\$verb" = installing ; then
5875                 echo "\$verb \$cf_target"
5876                 \$INSTALL_DATA \$TMP "\$cf_target"
5877                 test -d "\$cf_subdir\${section}" &&
5878                 test -n "\$aliases" && (
5879                         cd "\$cf_subdir\${section}" && (
5880                                 cf_source=\`echo "\$cf_target" |sed -e 's%^.*/\\([[^/]][[^/]]*/[[^/]][[^/]]*$\\)%\\1%'\`
5881                                 test -n "$cf_so_strip" && cf_source=\`echo "\$cf_source" |sed -e 's%\\.$cf_so_strip\$%%'\`
5882                                 cf_target=\`basename "\$cf_target"\`
5883                                 for cf_alias in \$aliases
5884                                 do
5885                                         if test "\$section" = 1 ; then
5886                                                 cf_alias=\`echo "\$cf_alias" |sed "\${transform}"\`
5887                                         fi
5888
5889                                         if test "$MANPAGE_SYMLINKS" = yes ; then
5890                                                 if test -f "\$cf_alias\${suffix}" ; then
5891                                                         if ( cmp -s "\$cf_target" "\$cf_alias\${suffix}" )
5892                                                         then
5893                                                                 continue
5894                                                         fi
5895                                                 fi
5896                                                 echo ".. \$verb alias \$cf_alias\${suffix}"
5897 CF_EOF
5898 case "x$LN_S" in
5899 (*-f)
5900 cat >>$cf_edit_man <<CF_EOF
5901                                                 $LN_S "\$cf_target" "\$cf_alias\${suffix}"
5902 CF_EOF
5903         ;;
5904 (*)
5905 cat >>$cf_edit_man <<CF_EOF
5906                                                 rm -f "\$cf_alias\${suffix}"
5907                                                 $LN_S "\$cf_target" "\$cf_alias\${suffix}"
5908 CF_EOF
5909         ;;
5910 esac
5911 cat >>$cf_edit_man <<CF_EOF
5912                                         elif test "\$cf_target" != "\$cf_alias\${suffix}" ; then
5913                                                 echo ".so \$cf_source" >\$TMP
5914 CF_EOF
5915 if test -n "$cf_compress" ; then
5916 cat >>$cf_edit_man <<CF_EOF
5917                                                 if test -n "$cf_so_strip" ; then
5918                                                         "$cf_compress" -f \$TMP
5919                                                         mv \$TMP.$cf_so_strip \$TMP
5920                                                 fi
5921 CF_EOF
5922 fi
5923 cat >>$cf_edit_man <<CF_EOF
5924                                                 echo ".. \$verb alias \$cf_alias\${suffix}"
5925                                                 rm -f "\$cf_alias\${suffix}"
5926                                                 \$INSTALL_DATA \$TMP "\$cf_alias\${suffix}"
5927                                         fi
5928                                 done
5929                         )
5930                 )
5931         elif test "\$verb" = removing ; then
5932                 test -f "\$cf_target" && (
5933                         echo "\$verb \$cf_target"
5934                         rm -f "\$cf_target"
5935                 )
5936                 test -d "\$cf_subdir\${section}" &&
5937                 test -n "\$aliases" && (
5938                         cd "\$cf_subdir\${section}" && (
5939                                 for cf_alias in \$aliases
5940                                 do
5941                                         if test "\$section" = 1 ; then
5942                                                 cf_alias=\`echo "\$cf_alias" |sed "\${transform}"\`
5943                                         fi
5944
5945                                         echo ".. \$verb alias \$cf_alias\${suffix}"
5946                                         rm -f "\$cf_alias\${suffix}"
5947                                 done
5948                         )
5949                 )
5950         else
5951 #               echo ".hy 0"
5952                 cat \$TMP
5953         fi
5954         ;;
5955 esac
5956 done
5957
5958 if test "$cf_inboth" = yes ; then
5959 if test "\$form" != format ; then
5960         $SHELL "\[$]0" format "\$verb" "\$mandir" "\$srcdir" "\[$]@"
5961 fi
5962 fi
5963
5964 exit 0
5965 CF_EOF
5966 chmod 755 "$cf_edit_man"
5967
5968 ])dnl
5969 dnl ---------------------------------------------------------------------------
5970 dnl CF_MAP_LIB_BASENAME version: 2 updated: 2021/01/02 17:09:14
5971 dnl -------------------
5972 dnl Convert a default-libname to the actual one used via CF_WITH_LIB_BASENAME.
5973 dnl
5974 dnl $1 = variable to set
5975 dnl $2 = default-libname
5976 AC_DEFUN([CF_MAP_LIB_BASENAME],[
5977 CF_UPPER(cf_map_lib_basename,$2)
5978 eval $1="\$${cf_map_lib_basename}_NAME"
5979 ])dnl
5980 dnl ---------------------------------------------------------------------------
5981 dnl CF_MATH_LIB version: 10 updated: 2020/12/31 18:40:20
5982 dnl -----------
5983 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
5984 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
5985 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
5986 AC_DEFUN([CF_MATH_LIB],
5987 [
5988 AC_CACHE_CHECK(if -lm needed for math functions,
5989         cf_cv_need_libm,[
5990         AC_TRY_LINK([
5991         #include <stdio.h>
5992         #include <stdlib.h>
5993         #include <math.h>
5994         ],
5995         [double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
5996         [cf_cv_need_libm=no],
5997         [cf_cv_need_libm=yes])])
5998 if test "$cf_cv_need_libm" = yes
5999 then
6000 ifelse($1,,[
6001         CF_ADD_LIB(m)
6002 ],[$1=-lm])
6003 fi
6004 ])
6005 dnl ---------------------------------------------------------------------------
6006 dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
6007 dnl ----------------------
6008 dnl Check if the file-system supports mixed-case filenames.  If we're able to
6009 dnl create a lowercase name and see it as uppercase, it doesn't support that.
6010 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
6011 [
6012 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
6013 if test "$cross_compiling" = yes ; then
6014         case "$target_alias" in
6015         (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
6016                 cf_cv_mixedcase=no
6017                 ;;
6018         (*)
6019                 cf_cv_mixedcase=yes
6020                 ;;
6021         esac
6022 else
6023         rm -f conftest CONFTEST
6024         echo test >conftest
6025         if test -f CONFTEST ; then
6026                 cf_cv_mixedcase=no
6027         else
6028                 cf_cv_mixedcase=yes
6029         fi
6030         rm -f conftest CONFTEST
6031 fi
6032 ])
6033 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
6034 ])dnl
6035 dnl ---------------------------------------------------------------------------
6036 dnl CF_MKSTEMP version: 11 updated: 2021/01/01 13:31:04
6037 dnl ----------
6038 dnl Check for a working mkstemp.  This creates two files, checks that they are
6039 dnl successfully created and distinct (AmigaOS apparently fails on the last).
6040 AC_DEFUN([CF_MKSTEMP],[
6041 AC_CHECK_HEADERS( \
6042 unistd.h \
6043 )
6044 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
6045 rm -rf ./conftest*
6046 AC_TRY_RUN([
6047 #include <sys/types.h>
6048 #ifdef HAVE_UNISTD_H
6049 #include <unistd.h>
6050 #endif
6051 #include <stdlib.h>
6052 #include <stdio.h>
6053 #include <string.h>
6054 #include <sys/stat.h>
6055 int main(void)
6056 {
6057         char *tmpl = "conftestXXXXXX";
6058         char name[2][80];
6059         int n;
6060         int result = 0;
6061         int fd;
6062         struct stat sb;
6063
6064         umask(077);
6065         for (n = 0; n < 2; ++n) {
6066                 strcpy(name[n], tmpl);
6067                 if ((fd = mkstemp(name[n])) >= 0) {
6068                         if (!strcmp(name[n], tmpl)
6069                          || stat(name[n], &sb) != 0
6070                          || (sb.st_mode & S_IFMT) != S_IFREG
6071                          || (sb.st_mode & 077) != 0) {
6072                                 result = 1;
6073                         }
6074                         close(fd);
6075                 }
6076         }
6077         if (result == 0
6078          && !strcmp(name[0], name[1]))
6079                 result = 1;
6080         ${cf_cv_main_return:-return}(result);
6081 }
6082 ],[cf_cv_func_mkstemp=yes
6083 ],[cf_cv_func_mkstemp=no
6084 ],[cf_cv_func_mkstemp=maybe])
6085 ])
6086 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
6087         AC_CHECK_FUNC(mkstemp)
6088 fi
6089 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
6090         AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
6091 fi
6092 ])dnl
6093 dnl ---------------------------------------------------------------------------
6094 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
6095 dnl ----------
6096 dnl Write a debug message to config.log, along with the line number in the
6097 dnl configure script.
6098 AC_DEFUN([CF_MSG_LOG],[
6099 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
6100 ])dnl
6101 dnl ---------------------------------------------------------------------------
6102 dnl CF_NCURSES_ABI_6 version: 4 updated: 2021/01/01 13:31:04
6103 dnl ----------------
6104 dnl Set ncurses' ABI to 6 unless overridden by explicit configure option, and
6105 dnl warn about this.
6106 AC_DEFUN([CF_NCURSES_ABI_6],[
6107 if test "${with_abi_version+set}" != set; then
6108         case "$cf_cv_rel_version" in
6109         (5.*)
6110                 cf_cv_rel_version=6.0
6111                 cf_cv_abi_version=6
6112                 AC_MSG_WARN(overriding ABI version to $cf_cv_abi_version)
6113                 ;;
6114         esac
6115 fi
6116 ])dnl
6117 dnl ---------------------------------------------------------------------------
6118 dnl CF_NCURSES_WITH_ABI_VERSION version: 3 updated: 2021/01/01 13:31:04
6119 dnl ---------------------------
6120 dnl Allow ncurses's ABI to be overridden.  Generally this happens when a
6121 dnl packager has incremented the ABI past that used in the original package,
6122 dnl and wishes to keep doing this.
6123 dnl
6124 dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
6125 dnl symbol.
6126 AC_DEFUN([CF_NCURSES_WITH_ABI_VERSION],[
6127 CF_WITH_ABI_VERSION($1)
6128 if test "x$cf_cv_abi_version" != "x$with_abi_version"
6129 then
6130         case "$cf_cv_rel_version" in
6131         (5.*)
6132                 cf_cv_rel_version=$with_abi_version.0
6133                 ;;
6134         esac
6135 fi
6136 ])dnl
6137 dnl ---------------------------------------------------------------------------
6138 dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
6139 dnl ------------------
6140 dnl see CF_WITH_NO_LEAKS
6141 dnl
6142 dnl $1 = option/name
6143 dnl $2 = help-text
6144 dnl $3 = symbol to define if the option is set
6145 dnl $4 = additional actions to take if the option is set
6146 AC_DEFUN([CF_NO_LEAKS_OPTION],[
6147 AC_MSG_CHECKING(if you want to use $1 for testing)
6148 AC_ARG_WITH($1,
6149         [$2],
6150         [case "x$withval" in
6151         (x|xno) ;;
6152         (*)
6153                 : "${with_cflags:=-g}"
6154                 : "${enable_leaks:=no}"
6155                 with_$1=yes
6156                 AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
6157          $4
6158 ])
6159                 ;;
6160         esac],
6161         [with_$1=])
6162 AC_MSG_RESULT(${with_$1:-no})
6163
6164 case ".$with_cflags" in
6165 (.*-g*)
6166         case .$CFLAGS in
6167         (.*-g*)
6168                 ;;
6169         (*)
6170                 CF_ADD_CFLAGS([-g])
6171                 ;;
6172         esac
6173         ;;
6174 esac
6175 ])dnl
6176 dnl ---------------------------------------------------------------------------
6177 dnl CF_NUMBER_SYNTAX version: 2 updated: 2015/04/17 21:13:04
6178 dnl ----------------
6179 dnl Check if the given variable is a number.  If not, report an error.
6180 dnl $1 is the variable
6181 dnl $2 is the message
6182 AC_DEFUN([CF_NUMBER_SYNTAX],[
6183 if test -n "$1" ; then
6184   case $1 in
6185   ([[0-9]]*)
6186         ;;
6187   (*)
6188         AC_MSG_ERROR($2 is not a number: $1)
6189         ;;
6190   esac
6191 else
6192   AC_MSG_ERROR($2 value is empty)
6193 fi
6194 ])dnl
6195 dnl ---------------------------------------------------------------------------
6196 dnl CF_OBJ_SUBDIR version: 8 updated: 2021/01/01 13:31:04
6197 dnl -------------
6198 dnl Compute the object-directory name from the given model name
6199 AC_DEFUN([CF_OBJ_SUBDIR],
6200 [
6201         case $1 in
6202         (libtool) $2='obj_lo'  ;;
6203         (normal)  $2='objects' ;;
6204         (debug)   $2='obj_g' ;;
6205         (profile) $2='obj_p' ;;
6206         (shared)
6207                 case "$cf_cv_system_name" in
6208                 (cygwin|msys)
6209                         $2='objects' ;;
6210                 (*)
6211                         $2='obj_s' ;;
6212                 esac
6213         esac
6214 ])dnl
6215 dnl ---------------------------------------------------------------------------
6216 dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
6217 dnl ----------
6218 dnl Provide a value for the $PATH and similar separator (or amend the value
6219 dnl as provided in autoconf 2.5x).
6220 AC_DEFUN([CF_PATHSEP],
6221 [
6222         AC_MSG_CHECKING(for PATH separator)
6223         case "$cf_cv_system_name" in
6224         (os2*)  PATH_SEPARATOR=';'  ;;
6225         (*)     ${PATH_SEPARATOR:=':'}  ;;
6226         esac
6227 ifelse([$1],,,[$1=$PATH_SEPARATOR])
6228         AC_SUBST(PATH_SEPARATOR)
6229         AC_MSG_RESULT($PATH_SEPARATOR)
6230 ])dnl
6231 dnl ---------------------------------------------------------------------------
6232 dnl CF_PATH_PROG version: 12 updated: 2021/01/02 09:31:20
6233 dnl ------------
6234 dnl Check for a given program, defining corresponding symbol.
6235 dnl     $1 = environment variable, which is suffixed by "_PATH" in the #define.
6236 dnl     $2 = program name to find.
6237 dnl     $3 = optional list of additional program names to test.
6238 dnl $4 = $PATH
6239 dnl
6240 dnl If there is more than one token in the result, #define the remaining tokens
6241 dnl to $1_ARGS.  We need this for 'install' in particular.
6242 dnl
6243 dnl FIXME: we should allow this to be overridden by environment variables
6244 dnl
6245 AC_DEFUN([CF_PATH_PROG],[
6246 AC_REQUIRE([CF_PATHSEP])
6247 test -z "[$]$1" && $1="$2"
6248 AC_PATH_PROGS($1,[$]$1 $2 ifelse($3,,,$3),[$]$1, ifelse($4,,,$4))
6249
6250 cf_path_prog=""
6251 cf_path_args=""
6252 IFS="${IFS:-    }"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
6253 for cf_temp in $ac_cv_path_$1
6254 do
6255         if test -z "$cf_path_prog" ; then
6256                 if test "$with_full_paths" = yes ; then
6257                         CF_PATH_SYNTAX(cf_temp,break)
6258                         cf_path_prog="$cf_temp"
6259                 else
6260                         cf_path_prog="`basename "$cf_temp"`"
6261                 fi
6262         elif test -z "$cf_path_args" ; then
6263                 cf_path_args="$cf_temp"
6264         else
6265                 cf_path_args="$cf_path_args $cf_temp"
6266         fi
6267 done
6268 IFS="$cf_save_ifs"
6269
6270 if test -n "$cf_path_prog" ; then
6271         CF_MSG_LOG(defining path for ${cf_path_prog})
6272         AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
6273         test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
6274 fi
6275 ])dnl
6276 dnl ---------------------------------------------------------------------------
6277 dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
6278 dnl --------------
6279 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
6280 dnl begins with one of the prefix/exec_prefix variables, and then again if the
6281 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
6282 dnl delayed evaluation of those symbols.
6283 AC_DEFUN([CF_PATH_SYNTAX],[
6284 if test "x$prefix" != xNONE; then
6285         cf_path_syntax="$prefix"
6286 else
6287         cf_path_syntax="$ac_default_prefix"
6288 fi
6289
6290 case ".[$]$1" in
6291 (.\[$]\(*\)*|.\'*\'*)
6292         ;;
6293 (..|./*|.\\*)
6294         ;;
6295 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
6296         ;;
6297 (.\[$]\{*prefix\}*|.\[$]\{*dir\}*)
6298         eval $1="[$]$1"
6299         case ".[$]$1" in
6300         (.NONE/*)
6301                 $1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
6302                 ;;
6303         esac
6304         ;;
6305 (.no|.NONE/*)
6306         $1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
6307         ;;
6308 (*)
6309         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
6310         ;;
6311 esac
6312 ])dnl
6313 dnl ---------------------------------------------------------------------------
6314 dnl CF_PKG_CONFIG version: 11 updated: 2021/01/01 13:31:04
6315 dnl -------------
6316 dnl Check for the package-config program, unless disabled by command-line.
6317 AC_DEFUN([CF_PKG_CONFIG],
6318 [
6319 AC_MSG_CHECKING(if you want to use pkg-config)
6320 AC_ARG_WITH(pkg-config,
6321         [  --with-pkg-config{=path} enable/disable use of pkg-config],
6322         [cf_pkg_config=$withval],
6323         [cf_pkg_config=yes])
6324 AC_MSG_RESULT($cf_pkg_config)
6325
6326 case "$cf_pkg_config" in
6327 (no)
6328         PKG_CONFIG=none
6329         ;;
6330 (yes)
6331         CF_ACVERSION_CHECK(2.52,
6332                 [AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
6333                 [AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
6334         ;;
6335 (*)
6336         PKG_CONFIG=$withval
6337         ;;
6338 esac
6339
6340 test -z "$PKG_CONFIG" && PKG_CONFIG=none
6341 if test "$PKG_CONFIG" != none ; then
6342         CF_PATH_SYNTAX(PKG_CONFIG)
6343 elif test "x$cf_pkg_config" != xno ; then
6344         AC_MSG_WARN(pkg-config is not installed)
6345 fi
6346
6347 AC_SUBST(PKG_CONFIG)
6348 ])dnl
6349 dnl ---------------------------------------------------------------------------
6350 dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
6351 dnl -----------------
6352 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
6353 dnl
6354 dnl     POSIX.1-1990                            _POSIX_SOURCE
6355 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
6356 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
6357 dnl             Bindings Option
6358 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
6359 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
6360 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
6361 dnl
6362 dnl Parameters:
6363 dnl     $1 is the nominal value for _POSIX_C_SOURCE
6364 AC_DEFUN([CF_POSIX_C_SOURCE],
6365 [AC_REQUIRE([CF_POSIX_VISIBLE])dnl
6366
6367 if test "$cf_cv_posix_visible" = no; then
6368
6369 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
6370
6371 cf_save_CFLAGS="$CFLAGS"
6372 cf_save_CPPFLAGS="$CPPFLAGS"
6373
6374 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
6375 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
6376
6377 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
6378         CF_MSG_LOG(if the symbol is already defined go no further)
6379         AC_TRY_COMPILE([#include <sys/types.h>],[
6380 #ifndef _POSIX_C_SOURCE
6381 make an error
6382 #endif],
6383         [cf_cv_posix_c_source=no],
6384         [cf_want_posix_source=no
6385          case .$cf_POSIX_C_SOURCE in
6386          (.[[12]]??*)
6387                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
6388                 ;;
6389          (.2)
6390                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
6391                 cf_want_posix_source=yes
6392                 ;;
6393          (.*)
6394                 cf_want_posix_source=yes
6395                 ;;
6396          esac
6397          if test "$cf_want_posix_source" = yes ; then
6398                 AC_TRY_COMPILE([#include <sys/types.h>],[
6399 #ifdef _POSIX_SOURCE
6400 make an error
6401 #endif],[],
6402                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
6403          fi
6404          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
6405          CFLAGS="$cf_trim_CFLAGS"
6406          CPPFLAGS="$cf_trim_CPPFLAGS"
6407          CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
6408          CF_MSG_LOG(if the second compile does not leave our definition intact error)
6409          AC_TRY_COMPILE([#include <sys/types.h>],[
6410 #ifndef _POSIX_C_SOURCE
6411 make an error
6412 #endif],,
6413          [cf_cv_posix_c_source=no])
6414          CFLAGS="$cf_save_CFLAGS"
6415          CPPFLAGS="$cf_save_CPPFLAGS"
6416         ])
6417 ])
6418
6419 if test "$cf_cv_posix_c_source" != no ; then
6420         CFLAGS="$cf_trim_CFLAGS"
6421         CPPFLAGS="$cf_trim_CPPFLAGS"
6422         CF_ADD_CFLAGS($cf_cv_posix_c_source)
6423 fi
6424
6425 fi # cf_cv_posix_visible
6426
6427 ])dnl
6428 dnl ---------------------------------------------------------------------------
6429 dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
6430 dnl ----------------
6431 dnl POSIX documents test-macros which an application may set before any system
6432 dnl headers are included to make features available.
6433 dnl
6434 dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
6435 dnl diverged from POSIX in 2002 by setting symbols which make all of the most
6436 dnl recent features visible in the system header files unless the application
6437 dnl overrides the corresponding test-macros.  Doing that introduces portability
6438 dnl problems.
6439 dnl
6440 dnl This macro makes a special check for the symbols used for this, to avoid a
6441 dnl conflicting definition.
6442 AC_DEFUN([CF_POSIX_VISIBLE],
6443 [
6444 AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
6445 AC_TRY_COMPILE([#include <stdio.h>],[
6446 #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
6447         && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
6448         && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
6449         && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
6450 #error conflicting symbols found
6451 #endif
6452 ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
6453 ])
6454 ])dnl
6455 dnl ---------------------------------------------------------------------------
6456 dnl CF_PREDEFINE version: 2 updated: 2010/05/26 16:44:57
6457 dnl ------------
6458 dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
6459 dnl
6460 dnl $1 = symbol to test
6461 dnl $2 = value (if any) to use for a predefinition
6462 AC_DEFUN([CF_PREDEFINE],
6463 [
6464 AC_MSG_CHECKING(if we must define $1)
6465 AC_TRY_COMPILE([#include <sys/types.h>
6466 ],[
6467 #ifndef $1
6468 make an error
6469 #endif],[cf_result=no],[cf_result=yes])
6470 AC_MSG_RESULT($cf_result)
6471
6472 if test "$cf_result" = yes ; then
6473         CPPFLAGS="$CPPFLAGS ifelse([$2],,-D$1,[-D$1=$2])"
6474 elif test "x$2" != "x" ; then
6475         AC_MSG_CHECKING(checking for compatible value versus $2)
6476         AC_TRY_COMPILE([#include <sys/types.h>
6477 ],[
6478 #if $1-$2 < 0
6479 make an error
6480 #endif],[cf_result=yes],[cf_result=no])
6481         AC_MSG_RESULT($cf_result)
6482         if test "$cf_result" = no ; then
6483                 # perhaps we can override it - try...
6484                 CPPFLAGS="$CPPFLAGS -D$1=$2"
6485         fi
6486 fi
6487 ])dnl
6488 dnl ---------------------------------------------------------------------------
6489 dnl CF_PRG_RULES version: 2 updated: 2021/01/01 13:31:04
6490 dnl ------------
6491 dnl Append definitions and rules for the given programs to the subdirectory
6492 dnl Makefiles, and the recursion rule for the top-level Makefile.
6493 dnl
6494 dnl parameters
6495 dnl     $1 = script to run
6496 dnl     $2 = list of subdirectories
6497 dnl
6498 dnl variables
6499 dnl     $AWK
6500 AC_DEFUN([CF_PRG_RULES],
6501 [
6502 for cf_dir in $2
6503 do
6504         if test ! -d "$srcdir/$cf_dir" ; then
6505                 continue
6506         elif test -f "$srcdir/$cf_dir/programs" ; then
6507                 $AWK -f $1 "$srcdir/$cf_dir/programs" >>$cf_dir/Makefile
6508         fi
6509 done
6510
6511 ])dnl
6512 dnl ---------------------------------------------------------------------------
6513 dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
6514 dnl ----------
6515 dnl Check for archiver "ar".
6516 AC_DEFUN([CF_PROG_AR],[
6517 AC_CHECK_TOOL(AR, ar, ar)
6518 ])
6519 dnl ---------------------------------------------------------------------------
6520 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
6521 dnl -----------
6522 dnl Check for awk, ensure that the check found something.
6523 AC_DEFUN([CF_PROG_AWK],
6524 [
6525 AC_PROG_AWK
6526 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
6527 ])dnl
6528 dnl ---------------------------------------------------------------------------
6529 dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
6530 dnl ----------
6531 dnl standard check for CC, plus followup sanity checks
6532 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
6533 AC_DEFUN([CF_PROG_CC],[
6534 CF_ACVERSION_CHECK(2.53,
6535         [AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
6536          AC_REQUIRE([AC_PROG_CC])],
6537         [])
6538 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
6539 CF_GCC_VERSION
6540 CF_ACVERSION_CHECK(2.52,
6541         [AC_PROG_CC_STDC],
6542         [CF_ANSI_CC_REQD])
6543 CF_CC_ENV_FLAGS
6544 ])dnl
6545 dnl ---------------------------------------------------------------------------
6546 dnl CF_PROG_CC_C_O version: 6 updated: 2021/01/01 13:31:04
6547 dnl --------------
6548 dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
6549 dnl the output file can be renamed, and allows for a shell variable that can
6550 dnl be used later.  The parameter is either CC or CXX.  The result is the
6551 dnl cache variable:
6552 dnl     $cf_cv_prog_CC_c_o
6553 dnl     $cf_cv_prog_CXX_c_o
6554 dnl
6555 dnl $1 = compiler
6556 dnl $2 = compiler options, if any
6557 AC_DEFUN([CF_PROG_CC_C_O],
6558 [AC_REQUIRE([AC_PROG_CC])dnl
6559 AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
6560 AC_CACHE_VAL(cf_cv_prog_$1_c_o,
6561 [
6562 cat > conftest.$ac_ext <<CF_EOF
6563 int main(void)
6564 {
6565         ${cf_cv_main_return:-return}(0);
6566 }
6567 CF_EOF
6568 # We do the test twice because some compilers refuse to overwrite an
6569 # existing .o file with -o, though they will create one.
6570 ac_try='[$]$1 $2 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
6571 if AC_TRY_EVAL(ac_try) &&
6572   test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
6573 then
6574   eval cf_cv_prog_$1_c_o=yes
6575 else
6576   eval cf_cv_prog_$1_c_o=no
6577 fi
6578 rm -rf ./conftest*
6579 ])dnl
6580 if test "$cf_cv_prog_$1_c_o" = yes; then
6581   AC_MSG_RESULT([yes])
6582 else
6583   AC_MSG_RESULT([no])
6584 fi
6585 ])dnl
6586 dnl ---------------------------------------------------------------------------
6587 dnl CF_PROG_GNAT version: 12 updated: 2021/01/02 17:09:14
6588 dnl ------------
6589 dnl Check for gnat/gnatmake/etc, ensure that the toolset is complete.
6590 AC_DEFUN([CF_PROG_GNAT],[
6591 for cf_prog_gnat in gnat gnatmake gprconfig gprbuild
6592 do
6593         CF_UPPER(cf_upper_prog_gnat,${cf_prog_gnat})
6594
6595         unset ac_cv_path_cf_TEMP_gnat
6596         unset cf_TEMP_gnat
6597         AC_PATH_PROG(cf_TEMP_gnat,$cf_prog_gnat,no)
6598         eval "cf_cv_PATH_$cf_upper_prog_gnat=[$]ac_cv_path_cf_TEMP_gnat"
6599
6600         if test "x$cf_TEMP_gnat" != xno; then
6601                 unset cf_cv_gnat_version
6602                 unset cf_TEMP_gnat
6603                 CF_GNAT_VERSION(cf_TEMP_gnat,$cf_prog_gnat)
6604         fi
6605         eval "cf_cv_VERSION_$cf_upper_prog_gnat=[$]cf_TEMP_gnat"
6606
6607         unset cf_TEMP_gnat
6608         unset cf_cv_gnat_version
6609         unset ac_cv_path_cf_TEMP_gnat
6610 done
6611
6612 if test "x$cf_cv_VERSION_GNATMAKE" = "xno"; then
6613         cf_ada_make=
6614         cf_cv_prog_gnat_correct=no
6615 else
6616         cf_ada_make=gnatmake
6617         if test "x$cf_cv_VERSION_GPRCONFIG" = "xno"; then
6618                 # gprconfig is newer than gnatmake; we can continue...
6619                 cf_ada_config="##"
6620         else
6621                 rm -rf ./conftest* ./*~conftest*
6622                 if mkdir conftest.src
6623                 then
6624                         cf_ada_config=""
6625                         cd conftest.src
6626                         for cf_gprconfig in Ada C
6627                         do
6628                                 AC_MSG_CHECKING(for gprconfig name for $cf_gprconfig)
6629                                 if test "$cf_gprconfig" = C
6630                                 then
6631                                         for cf_gprconfig_param in \
6632                                                 "$cf_gprconfig,,,,GNATGCC" \
6633                                                 "$cf_gprconfig,,,,GCC" \
6634                                                 "$cf_gprconfig"
6635                                         do
6636                                                 cf_gprconfig_value=`echo s| gprconfig --config=$cf_gprconfig_param 2>&AC_FD_CC | ${AWK:-awk} '/^\*/{print [$]3;}' | head -n 1`
6637                                                 test -n "$cf_gprconfig_value" && break
6638                                         done
6639                                 else
6640                                         cf_gprconfig_param=$cf_gprconfig
6641                                         cf_gprconfig_value=`echo s| gprconfig --config=$cf_gprconfig_param 2>&AC_FD_CC | ${AWK:-awk} '/^\*/{print [$]3;}' | head -n 1`
6642                                 fi
6643                                 if test -n "$cf_gprconfig_value"
6644                                 then
6645                                         eval "cf_ada_config_[$]cf_gprconfig=[$]cf_gprconfig_value"
6646                                         AC_MSG_RESULT($cf_gprconfig_value)
6647                                 else
6648                                         AC_MSG_RESULT(missing)
6649                                         cf_ada_config="#"
6650                                         break
6651                                 fi
6652                         done
6653                         cd ..
6654                         rm -rf ./conftest* ./*~conftest*
6655                 fi
6656         fi
6657         if test "x$cf_ada_config" != "x#"
6658         then
6659                 CF_GNAT_VERSION
6660                 CF_CHECK_GNAT_VERSION
6661                 AC_CHECK_PROG(M4_exists, m4, yes, no)
6662                 if test "$ac_cv_prog_M4_exists" = no; then
6663                         cf_cv_prog_gnat_correct=no
6664                         AC_MSG_WARN(Ada95 binding required program m4 not found. Ada95 binding disabled)
6665                 fi
6666                 if test "$cf_cv_prog_gnat_correct" = yes; then
6667                         AC_MSG_CHECKING(if GNAT works)
6668                         CF_GNAT_TRY_RUN([procedure conftest;],
6669 [with Text_IO;
6670 with GNAT.OS_Lib;
6671 procedure conftest is
6672 begin
6673    Text_IO.Put ("Hello World");
6674    Text_IO.New_Line;
6675    GNAT.OS_Lib.OS_Exit (0);
6676 end conftest;],
6677 [cf_cv_prog_gnat_correct=yes],
6678 [cf_cv_prog_gnat_correct=no])
6679                         AC_MSG_RESULT($cf_cv_prog_gnat_correct)
6680                 fi
6681         else
6682                 cf_cv_prog_gnat_correct=no
6683         fi
6684 fi
6685
6686 AC_SUBST(cf_ada_make)
6687 AC_SUBST(cf_ada_config)
6688 AC_SUBST(cf_ada_config_Ada)
6689 AC_SUBST(cf_ada_config_C)
6690 ])dnl
6691 dnl ---------------------------------------------------------------------------
6692 dnl CF_PROG_INSTALL version: 10 updated: 2021/01/04 19:33:05
6693 dnl ---------------
6694 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
6695 dnl misc/tabset install won't work properly.  Usually this happens only when
6696 dnl using the fallback mkinstalldirs script
6697 AC_DEFUN([CF_PROG_INSTALL],
6698 [AC_PROG_INSTALL
6699 case $INSTALL in
6700 (/*)
6701         ;;
6702 (*)
6703         CF_DIRNAME(cf_dir,$INSTALL)
6704         test -z "$cf_dir" && cf_dir=.
6705         INSTALL="`cd \"$cf_dir\" && pwd`"/"`echo "$INSTALL" | sed -e 's%^.*/%%'`"
6706         ;;
6707 esac
6708 ])dnl
6709 dnl ---------------------------------------------------------------------------
6710 dnl CF_PROG_LDCONFIG version: 5 updated: 2015/04/18 08:56:57
6711 dnl ----------------
6712 dnl Check for ldconfig, needed to fixup shared libraries that would be built
6713 dnl and then used in the install.
6714 AC_DEFUN([CF_PROG_LDCONFIG],[
6715 if test "$cross_compiling" = yes ; then
6716         LDCONFIG=:
6717 else
6718         case "$cf_cv_system_name" in
6719         (dragonfly*|mirbsd*|freebsd*)
6720                 test -z "$LDCONFIG" && LDCONFIG="/sbin/ldconfig -R"
6721                 ;;
6722         (*) LDPATH=$PATH:/sbin:/usr/sbin
6723                 AC_PATH_PROG(LDCONFIG,ldconfig,,$LDPATH)
6724                 ;;
6725         esac
6726 fi
6727 AC_SUBST(LDCONFIG)
6728 ])dnl
6729 dnl ---------------------------------------------------------------------------
6730 dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
6731 dnl ------------
6732 AC_DEFUN([CF_PROG_LINT],
6733 [
6734 AC_CHECK_PROGS(LINT, lint cppcheck splint)
6735 case "x$LINT" in
6736 (xcppcheck|x*/cppcheck)
6737         test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
6738         ;;
6739 esac
6740 AC_SUBST(LINT_OPTS)
6741 ])dnl
6742 dnl ---------------------------------------------------------------------------
6743 dnl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
6744 dnl ------------
6745 dnl Combine checks for "ln -s" and "ln -sf", updating $LN_S to include "-f"
6746 dnl option if it is supported.
6747 AC_DEFUN([CF_PROG_LN_S],[
6748 AC_PROG_LN_S
6749 AC_MSG_CHECKING(if $LN_S -f options work)
6750
6751 rm -f conf$$.src conf$$dst
6752 echo >conf$$.dst
6753 echo first >conf$$.src
6754 if $LN_S -f conf$$.src conf$$.dst 2>/dev/null; then
6755         cf_prog_ln_sf=yes
6756 else
6757         cf_prog_ln_sf=no
6758 fi
6759 rm -f conf$$.dst conf$$src
6760 AC_MSG_RESULT($cf_prog_ln_sf)
6761
6762 test "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
6763 ])dnl
6764 dnl ---------------------------------------------------------------------------
6765 dnl CF_REGEX version: 18 updated: 2021/01/01 16:53:59
6766 dnl --------
6767 dnl Attempt to determine if we've got one of the flavors of regular-expression
6768 dnl code that we can support.
6769 AC_DEFUN([CF_REGEX],
6770 [
6771
6772 cf_regex_func=no
6773 cf_regex_libs=
6774 case "$host_os" in
6775 (mingw*)
6776         # -lsystre -ltre -lintl -liconv
6777         AC_CHECK_LIB(systre,regcomp,[
6778                 AC_CHECK_LIB(iconv,libiconv_open,[CF_ADD_LIB(iconv)])
6779                 AC_CHECK_LIB(intl,libintl_gettext,[CF_ADD_LIB(intl)])
6780                 AC_CHECK_LIB(tre,tre_regcomp,[CF_ADD_LIB(tre)])
6781                 CF_ADD_LIB(systre)
6782                 cf_regex_func=regcomp
6783         ],[
6784                 AC_CHECK_LIB(gnurx,regcomp,[
6785                         CF_ADD_LIB(gnurx)
6786                         cf_regex_func=regcomp])
6787         ])
6788         ;;
6789 (*)
6790         cf_regex_libs="regex re"
6791         AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
6792                 for cf_regex_lib in $cf_regex_libs
6793                 do
6794                         AC_CHECK_LIB($cf_regex_lib,regcomp,[
6795                                         CF_ADD_LIB($cf_regex_lib)
6796                                         cf_regex_func=regcomp
6797                                         break])
6798                 done
6799         ])
6800         ;;
6801 esac
6802
6803 if test "$cf_regex_func" = no ; then
6804         AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
6805                 AC_CHECK_LIB(gen,compile,[
6806                                 CF_ADD_LIB(gen)
6807                                 cf_regex_func=compile])])
6808 fi
6809
6810 if test "$cf_regex_func" = no ; then
6811         AC_MSG_WARN(cannot find regular expression library)
6812 fi
6813
6814 AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
6815
6816 cf_cv_regex_hdrs=no
6817 case "$cf_regex_func" in
6818 (compile)
6819         for cf_regex_hdr in regexp.h regexpr.h
6820         do
6821                 AC_TRY_LINK([#include <$cf_regex_hdr>],[
6822                         char *p = compile("", "", "", 0);
6823                         int x = step("", "");
6824                         (void)p;
6825                         (void)x;
6826                 ],[
6827                         cf_cv_regex_hdrs=$cf_regex_hdr
6828                         break
6829                 ])
6830         done
6831         ;;
6832 (*)
6833         for cf_regex_hdr in regex.h
6834         do
6835                 AC_TRY_LINK([#include <sys/types.h>
6836 #include <$cf_regex_hdr>],[
6837                         regex_t *p = 0;
6838                         int x = regcomp(p, "", 0);
6839                         int y = regexec(p, "", 0, 0, 0);
6840                         (void)x;
6841                         (void)y;
6842                         regfree(p);
6843                 ],[
6844                         cf_cv_regex_hdrs=$cf_regex_hdr
6845                         break
6846                 ])
6847         done
6848         ;;
6849 esac
6850
6851 ])
6852
6853 case "$cf_cv_regex_hdrs" in
6854         (no)            AC_MSG_WARN(no regular expression header found) ;;
6855         (regex.h)       AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;;
6856         (regexp.h)      AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;;
6857         (regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
6858 esac
6859 ])dnl
6860 dnl ---------------------------------------------------------------------------
6861 dnl CF_REMOVE_CFLAGS version: 1 updated: 2021/08/28 15:20:37
6862 dnl ----------------
6863 dnl Remove a given option from CFLAGS/CPPFLAGS
6864 dnl $1 = option to remove
6865 dnl $2 = variable to update
6866 dnl $3 = nonempty to allow verbose message
6867 define([CF_REMOVE_CFLAGS],
6868 [
6869 cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'`
6870 cf_old_cflag="[$]$2"
6871
6872 case "[$]$2" in
6873 (*$1=*)
6874         cf_old_cflag=`echo "x$cf_old_cflag" | sed -e 's/^.//' -e "s%$cf_tmp_cflag=[[^   ]]*%%g"`
6875         ;;
6876 (*$1\ *)
6877         cf_old_cflag=`echo "x$cf_old_cflag" | sed -e 's/^.//' -e "s%${cf_tmp_cflag}.%%"`
6878         ;;
6879 (*$1)
6880         cf_old_cflag=`echo "x$cf_old_cflag" | sed -e 's/^.//' -e "s%$cf_tmp_cflag%%"`
6881         ;;
6882 esac
6883
6884 if test "[$]$2" != "$cf_old_cflag" ;
6885 then
6886         ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)])
6887         $2="$cf_new_cflag"
6888 fi
6889 ])dnl
6890 dnl ---------------------------------------------------------------------------
6891 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
6892 dnl ----------------
6893 dnl Remove all -U and -D options that refer to the given symbol from a list
6894 dnl of C compiler options.  This works around the problem that not all
6895 dnl compilers process -U and -D options from left-to-right, so a -U option
6896 dnl cannot be used to cancel the effect of a preceding -D option.
6897 dnl
6898 dnl $1 = target (which could be the same as the source variable)
6899 dnl $2 = source (including '$')
6900 dnl $3 = symbol to remove
6901 define([CF_REMOVE_DEFINE],
6902 [
6903 $1=`echo "$2" | \
6904         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
6905                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
6906 ])dnl
6907 dnl ---------------------------------------------------------------------------
6908 dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
6909 dnl -------------
6910 dnl Remove the given library from the symbol
6911 dnl
6912 dnl $1 = target (which could be the same as the source variable)
6913 dnl $2 = source (including '$')
6914 dnl $3 = library to remove
6915 define([CF_REMOVE_LIB],
6916 [
6917 # remove $3 library from $2
6918 $1=`echo "$2" | sed -e 's/-l$3[[        ]]//g' -e 's/-l$3[$]//'`
6919 ])dnl
6920 dnl ---------------------------------------------------------------------------
6921 dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
6922 dnl ---------------------
6923 dnl Restore flags saved in CF_SAVE_XTRA_FLAGS
6924 dnl $1 = name of current macro
6925 define([CF_RESTORE_XTRA_FLAGS],
6926 [
6927 LIBS="$cf_save_LIBS_$1"
6928 CFLAGS="$cf_save_CFLAGS_$1"
6929 CPPFLAGS="$cf_save_CPPFLAGS_$1"
6930 ])dnl
6931 dnl ---------------------------------------------------------------------------
6932 dnl CF_RPATH_HACK version: 13 updated: 2021/01/03 18:30:50
6933 dnl -------------
6934 AC_DEFUN([CF_RPATH_HACK],
6935 [AC_REQUIRE([AC_PROG_FGREP])dnl
6936 AC_REQUIRE([CF_LD_RPATH_OPT])dnl
6937
6938 AC_MSG_CHECKING(for updated LDFLAGS)
6939 if test -n "$LD_RPATH_OPT" ; then
6940         AC_MSG_RESULT(maybe)
6941
6942         AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
6943         cf_rpath_list="/usr/lib /lib"
6944         if test "$cf_ldd_prog" != no
6945         then
6946                 cf_rpath_oops=
6947
6948 AC_TRY_LINK([#include <stdio.h>],
6949                 [printf("Hello");],
6950                 [cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
6951                  cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[[        ]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
6952
6953                 # If we passed the link-test, but get a "not found" on a given library,
6954                 # this could be due to inept reconfiguration of gcc to make it only
6955                 # partly honor /usr/local/lib (or whatever).  Sometimes this behavior
6956                 # is intentional, e.g., installing gcc in /usr/bin and suppressing the
6957                 # /usr/local libraries.
6958                 if test -n "$cf_rpath_oops"
6959                 then
6960                         for cf_rpath_src in $cf_rpath_oops
6961                         do
6962                                 for cf_rpath_dir in \
6963                                         /usr/local \
6964                                         /usr/pkg \
6965                                         /opt/sfw
6966                                 do
6967                                         if test -f "$cf_rpath_dir/lib/$cf_rpath_src"
6968                                         then
6969                                                 CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
6970                                                 LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
6971                                                 break
6972                                         fi
6973                                 done
6974                         done
6975                 fi
6976         fi
6977
6978         CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
6979
6980         CF_RPATH_HACK_2(LDFLAGS)
6981         CF_RPATH_HACK_2(LIBS)
6982
6983         CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
6984 else
6985         AC_MSG_RESULT(no)
6986 fi
6987 AC_SUBST(EXTRA_LDFLAGS)
6988 ])dnl
6989 dnl ---------------------------------------------------------------------------
6990 dnl CF_RPATH_HACK_2 version: 8 updated: 2021/01/01 13:31:04
6991 dnl ---------------
6992 dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
6993 dnl EXTRA_LDFLAGS for each -L option found.
6994 dnl
6995 dnl $cf_rpath_list contains a list of directories to ignore.
6996 dnl
6997 dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
6998 dnl      but LIBS often has misplaced -L options.
6999 AC_DEFUN([CF_RPATH_HACK_2],
7000 [
7001 CF_VERBOSE(...checking $1 [$]$1)
7002
7003 cf_rpath_dst=
7004 for cf_rpath_src in [$]$1
7005 do
7006         case "$cf_rpath_src" in
7007         (-L*)
7008
7009                 # check if this refers to a directory which we will ignore
7010                 cf_rpath_skip=no
7011                 if test -n "$cf_rpath_list"
7012                 then
7013                         for cf_rpath_item in $cf_rpath_list
7014                         do
7015                                 if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
7016                                 then
7017                                         cf_rpath_skip=yes
7018                                         break
7019                                 fi
7020                         done
7021                 fi
7022
7023                 if test "$cf_rpath_skip" = no
7024                 then
7025                         # transform the option
7026                         if test "$LD_RPATH_OPT" = "-R " ; then
7027                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
7028                         else
7029                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
7030                         fi
7031
7032                         # if we have not already added this, add it now
7033                         cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
7034                         if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
7035                         then
7036                                 CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
7037                                 EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
7038                         fi
7039                 fi
7040                 ;;
7041         esac
7042         cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
7043 done
7044 $1=$cf_rpath_dst
7045
7046 CF_VERBOSE(...checked $1 [$]$1)
7047 AC_SUBST(EXTRA_LDFLAGS)
7048 ])dnl
7049 dnl ---------------------------------------------------------------------------
7050 dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
7051 dnl ------------------
7052 dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
7053 dnl and libraries which do not update those variables.
7054 dnl
7055 dnl $1 = name of current macro
7056 define([CF_SAVE_XTRA_FLAGS],
7057 [
7058 cf_save_LIBS_$1="$LIBS"
7059 cf_save_CFLAGS_$1="$CFLAGS"
7060 cf_save_CPPFLAGS_$1="$CPPFLAGS"
7061 LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
7062 for cf_X_CFLAGS in $X_CFLAGS
7063 do
7064         case "x$cf_X_CFLAGS" in
7065         x-[[IUD]]*)
7066                 CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
7067                 ;;
7068         *)
7069                 CFLAGS="$CFLAGS $cf_X_CFLAGS"
7070                 ;;
7071         esac
7072 done
7073 ])dnl
7074 dnl ---------------------------------------------------------------------------
7075 dnl CF_SHARED_OPTS version: 106 updated: 2021/08/07 16:59:57
7076 dnl --------------
7077 dnl --------------
7078 dnl Attempt to determine the appropriate CC/LD options for creating a shared
7079 dnl library.
7080 dnl
7081 dnl Notes:
7082 dnl a) ${LOCAL_LDFLAGS} is used to link executables that will run within
7083 dnl the build-tree, i.e., by making use of the libraries that are compiled in
7084 dnl $rel_builddir/lib We avoid compiling-in a $rel_builddir/lib path for the
7085 dnl shared library since that can lead to unexpected results at runtime.
7086 dnl b) ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared
7087 dnl libraries are compiled in ../../lib
7088 dnl
7089 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
7090 dnl to install symbolic links to the rel/abi versions of shared libraries.
7091 dnl
7092 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
7093 dnl version when making symbolic links.
7094 dnl
7095 dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
7096 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
7097 dnl (ex: libncurses.so.<ver>).
7098 dnl
7099 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
7100 AC_DEFUN([CF_SHARED_OPTS],
7101 [
7102         AC_REQUIRE([CF_LD_RPATH_OPT])
7103
7104         RM_SHARED_OPTS=
7105         LOCAL_LDFLAGS=
7106         LOCAL_LDFLAGS2=
7107         LD_SHARED_OPTS=
7108         INSTALL_LIB="-m 644"
7109         : ${rel_builddir:=.}
7110
7111         shlibdir=$libdir
7112         AC_SUBST(shlibdir)
7113
7114         MAKE_DLLS="#"
7115         AC_SUBST(MAKE_DLLS)
7116
7117         cf_cv_do_symlinks=no
7118         cf_ld_rpath_opt=
7119         test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
7120
7121         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
7122         AC_ARG_WITH(shlib-version,
7123         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
7124         [test -z "$withval" && withval=auto
7125         case "$withval" in
7126         (yes)
7127                 cf_cv_shlib_version=auto
7128                 ;;
7129         (rel|abi|auto)
7130                 cf_cv_shlib_version=$withval
7131                 ;;
7132         (*)
7133                 AC_MSG_RESULT($withval)
7134                 AC_MSG_ERROR([option value must be one of: rel, abi, or auto])
7135                 ;;
7136         esac
7137         ],[cf_cv_shlib_version=auto])
7138         AC_MSG_RESULT($cf_cv_shlib_version)
7139
7140         cf_cv_rm_so_locs=no
7141         cf_try_cflags=
7142
7143         # Some less-capable ports of gcc support only -fpic
7144         CC_SHARED_OPTS=
7145
7146         cf_try_fPIC=no
7147         if test "$GCC" = yes
7148         then
7149                 cf_try_fPIC=yes
7150         else
7151                 case "$cf_cv_system_name" in
7152                 (*linux*)       # e.g., PGI compiler
7153                         cf_try_fPIC=yes
7154                         ;;
7155                 esac
7156         fi
7157
7158         if test "$cf_try_fPIC" = yes
7159         then
7160                 AC_MSG_CHECKING(which $CC option to use)
7161                 cf_save_CFLAGS="$CFLAGS"
7162                 for CC_SHARED_OPTS in -fPIC -fpic ''
7163                 do
7164                         CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
7165                         AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
7166                 done
7167                 AC_MSG_RESULT($CC_SHARED_OPTS)
7168                 CFLAGS="$cf_save_CFLAGS"
7169         fi
7170
7171         cf_cv_shlib_version_infix=no
7172
7173         case "$cf_cv_system_name" in
7174         (aix4.[3-9]*|aix[[5-7]]*)
7175                 if test "$GCC" = yes; then
7176                         CC_SHARED_OPTS='-Wl,-brtl'
7177                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
7178                 else
7179                         CC_SHARED_OPTS='-brtl'
7180                         # as well as '-qpic=large -G' or perhaps "-bM:SRE -bnoentry -bexpall"
7181                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -G -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
7182                 fi
7183                 ;;
7184         (beos*)
7185                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
7186                 ;;
7187         (cygwin*)
7188                 CC_SHARED_OPTS=
7189                 MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
7190                 RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
7191                 cf_cv_shlib_version=cygdll
7192                 cf_cv_shlib_version_infix=cygdll
7193                 shlibdir=$bindir
7194                 MAKE_DLLS=
7195                 cat >mk_shared_lib.sh <<-CF_EOF
7196                 #!$SHELL
7197                 SHARED_LIB=\[$]1
7198                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
7199                 shift
7200                 cat <<-EOF
7201                 Linking shared library
7202                 ** SHARED_LIB \[$]SHARED_LIB
7203                 ** IMPORT_LIB \[$]IMPORT_LIB
7204 EOF
7205                 exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
7206 CF_EOF
7207                 chmod +x mk_shared_lib.sh
7208                 ;;
7209         (msys*)
7210                 CC_SHARED_OPTS=
7211                 MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
7212                 RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
7213                 cf_cv_shlib_version=msysdll
7214                 cf_cv_shlib_version_infix=msysdll
7215                 shlibdir=$bindir
7216                 MAKE_DLLS=
7217                 cat >mk_shared_lib.sh <<-CF_EOF
7218                 #!$SHELL
7219                 SHARED_LIB=\[$]1
7220                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/msys-/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
7221                 shift
7222                 cat <<-EOF
7223                 Linking shared library
7224                 ** SHARED_LIB \[$]SHARED_LIB
7225                 ** IMPORT_LIB \[$]IMPORT_LIB
7226 EOF
7227                 exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
7228 CF_EOF
7229                 chmod +x mk_shared_lib.sh
7230                 ;;
7231         (darwin*)
7232                 cf_try_cflags="no-cpp-precomp"
7233                 CC_SHARED_OPTS="-dynamic"
7234                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
7235                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
7236                 cf_cv_shlib_version_infix=yes
7237                 AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
7238                         cf_save_LDFLAGS=$LDFLAGS
7239                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
7240                         AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
7241                                 LDFLAGS=$cf_save_LDFLAGS])
7242                 if test "$cf_cv_ldflags_search_paths_first" = yes; then
7243                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
7244                 fi
7245                 ;;
7246         (haiku*)
7247                 CF_SHARED_SONAME
7248                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
7249                 ;;
7250         (hpux[[7-8]]*)
7251                 # HP-UX 8.07 ld lacks "+b" option used for libdir search-list
7252                 if test "$GCC" != yes; then
7253                         CC_SHARED_OPTS='+Z'
7254                 fi
7255                 MK_SHARED_LIB='${LD} ${LDFLAGS} -b -o $[@]'
7256                 INSTALL_LIB="-m 555"
7257                 ;;
7258         (hpux*)
7259                 # (tested with gcc 2.7.2 -- I don't have c89)
7260                 if test "$GCC" = yes; then
7261                         LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
7262                 else
7263                         CC_SHARED_OPTS='+Z'
7264                         LD_SHARED_OPTS='-Wl,+b,${libdir}'
7265                 fi
7266                 MK_SHARED_LIB='${LD} ${LDFLAGS} +b ${libdir} -b -o $[@]'
7267                 # HP-UX shared libraries must be executable, and should be
7268                 # readonly to exploit a quirk in the memory manager.
7269                 INSTALL_LIB="-m 555"
7270                 ;;
7271         (interix*)
7272                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
7273                 if test "$cf_cv_shlib_version" = rel; then
7274                         cf_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
7275                 else
7276                         cf_shared_soname='`basename $[@]`'
7277                 fi
7278                 CC_SHARED_OPTS=
7279                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-rpath,${RPATH_LIST} -Wl,-h,'$cf_shared_soname' -o $[@]'
7280                 ;;
7281         (irix*)
7282                 if test "$cf_cv_enable_rpath" = yes ; then
7283                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
7284                 fi
7285                 # tested with IRIX 5.2 and 'cc'.
7286                 if test "$GCC" != yes; then
7287                         CC_SHARED_OPTS='-KPIC'
7288                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
7289                 else
7290                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,`basename $[@]` -o $[@]'
7291                 fi
7292                 cf_cv_rm_so_locs=yes
7293                 ;;
7294         (linux*|gnu*|k*bsd*-gnu)
7295                 if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
7296                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
7297                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7298                 fi
7299                 if test "$cf_cv_enable_rpath" = yes ; then
7300                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
7301                 fi
7302                 CF_SHARED_SONAME
7303                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
7304                 ;;
7305         (mingw*msvc*)
7306                 cf_cv_shlib_version=msvcdll
7307                 cf_cv_shlib_version_infix=msvcdll
7308                 shlibdir=$bindir
7309                 MAKE_DLLS=
7310                 if test "$DFT_LWR_MODEL" = "shared" ; then
7311                         LOCAL_LDFLAGS="-link -dll"
7312                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7313                         EXTRA_LDFLAGS="-link -dll $EXTRA_LDFLAGS"
7314                 fi
7315                 CC_SHARED_OPTS=
7316                 MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ ${LD} [$]{CFLAGS}'
7317                 RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.lib"
7318                 cat >mk_shared_lib.sh <<-CF_EOF
7319                 #!$SHELL
7320                 SHARED_LIB=\[$]1
7321                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.lib/'\`
7322                 shift
7323                 my_ld=\[$]1
7324                 shift
7325                 cat <<-EOF
7326                 Linking shared library
7327                 ** SHARED LIB \$SHARED_LIB
7328                 ** IMPORT_LIB \$IMPORT_LIB
7329 EOF
7330                 args=\$(echo \[$]* | sed -E "s#-l(\w*)#\1.dll.lib#g" | sed -E "s#-L(\w*)#-LIBPATH:\1#g")
7331                 exec \$my_ld -DLL -IMPLIB:"\${IMPORT_LIB}" -OUT:"\${SHARED_LIB}" ${LDFLAGS} \$args
7332                 mv "\${IMPORT_LIB}" "\${IMPORT_LIB}"
7333 CF_EOF
7334                 chmod +x mk_shared_lib.sh
7335                 cat >mk_prog.sh <<-CF_EOF
7336                 #!$SHELL
7337                 shift
7338                 # Ignore first argument (compiler) and use LD (link.exe) unconditionally
7339                 LD="[$]LD"
7340                 clopts=()
7341                 ldopts=("/subsystem:console")
7342                 libs=()
7343                 isdll=0
7344                 while test \[$]# -gt 0; do
7345                         case "\[$]1" in
7346                                 -link)
7347                                         # ignore -link argument
7348                                         ;;
7349                                 -M[[TD]] | -M[[TD]]d)
7350                                         # ignore runtime-library option
7351                                         ;;
7352                                 -dll)
7353                                         isdll=1
7354                                         ;;
7355                                 -W* | -w*)
7356                                         # ignore warnings
7357                                         ;;
7358                                 -D*)
7359                                         clopts+=("\[$]1")
7360                                         ;;
7361                                 -I*)
7362                                         clopts+=("\[$]1")
7363                                         ;;
7364                                 -l*)
7365                                         libs+=("\`echo \"\[$]1\" | sed \"s/^-l//\"\`")
7366                                         ;;
7367                                 -L*)
7368                                         ldopts+=("\`echo \"\[$]1\" | sed \"s/^-L/-LIBPATH:/\"\`")
7369                                         ;;
7370                                 *.obj | *.o)
7371                                         ldopts+=("\[$]1")
7372                                         ;;
7373                                 -Wl,*)
7374                                         for linkarg in \`echo '\[$]1' | sed -e 's/-Wl,//' -e 's/,/ /'\`; do
7375                                                 ldopts+=("\[$]{linkarg}")
7376                                         done
7377                                         ;;
7378                                 *.lib)
7379                                         ldopts+=("\[$]1")
7380                                         ;;
7381                                 -o)
7382                                         shift
7383                                         ldopts+=("-out:\[$]1")
7384                                         ;;
7385                                 *)
7386                                         clopts+=("\[$]1")
7387                                         ldopts+=("\[$]1")
7388                                         ;;
7389                         esac
7390                         shift
7391                 done
7392                 if [[ "\$isdll" -ne 0 ]]; then
7393                         for lib in \[$]{libs[[*]]}; do
7394                                 ldopts+=("\[$]lib.dll.lib")
7395                         done
7396                 else
7397                         for lib in \[$]{libs[[*]]}; do
7398                                 ldopts+=("\[$]lib.lib")
7399                         done
7400                 fi
7401                 cat <<-EOF
7402                 Creating program
7403                 ** ld options:   "\[$]{ldopts[[@]]}"
7404 EOF
7405                 exec \[$]LD \[$]{ldopts[[@]]}
7406 CF_EOF
7407                 chmod +x mk_prog.sh
7408                 LINK_PROGS="$SHELL ${rel_builddir}/mk_prog.sh"
7409                 LINK_TESTS="$SHELL ${rel_builddir}/mk_prog.sh"
7410                 ;;
7411         (mingw*)
7412                 cf_cv_shlib_version=mingw
7413                 cf_cv_shlib_version_infix=mingw
7414                 shlibdir=$bindir
7415                 MAKE_DLLS=
7416                 if test "$DFT_LWR_MODEL" = "shared" ; then
7417                         LOCAL_LDFLAGS="-Wl,--enable-auto-import"
7418                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7419                         EXTRA_LDFLAGS="-Wl,--enable-auto-import $EXTRA_LDFLAGS"
7420                 fi
7421                 CC_SHARED_OPTS=
7422                 MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
7423                 RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
7424                 cat >mk_shared_lib.sh <<-CF_EOF
7425                 #!$SHELL
7426                 SHARED_LIB=\[$]1
7427                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
7428                 shift
7429                 cat <<-EOF
7430                 Linking shared library
7431                 ** SHARED_LIB \[$]SHARED_LIB
7432                 ** IMPORT_LIB \[$]IMPORT_LIB
7433 EOF
7434                 exec \[$]* ${LDFLAGS} -shared -Wl,--enable-auto-import,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
7435 CF_EOF
7436                 chmod +x mk_shared_lib.sh
7437                 ;;
7438         (openbsd[[2-9]].*|mirbsd*)
7439                 if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
7440                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
7441                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7442                 fi
7443                 if test "$cf_cv_enable_rpath" = yes ; then
7444                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
7445                 fi
7446                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
7447                 CF_SHARED_SONAME
7448                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
7449                 ;;
7450         (nskJ*)
7451                 CC_SHARED_OPTS=
7452                 MK_SHARED_LIB='${LD} -Wshared -Weld=-export_all -o $[@]'
7453                 ;;
7454         (nskL*)
7455                 CC_SHARED_OPTS=
7456                 MK_SHARED_LIB='${LD} -Wshared -Wxld=-export_all -o $[@]'
7457                 ;;
7458         (nto-qnx*|openbsd*|freebsd[[12]].*)
7459                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
7460                 MK_SHARED_LIB='${LD} ${LDFLAGS} -Bshareable -o $[@]'
7461                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
7462                 ;;
7463         (dragonfly*|freebsd*)
7464                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
7465                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
7466                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
7467                         LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${RPATH_LIST} $LOCAL_LDFLAGS"
7468                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
7469                 fi
7470                 CF_SHARED_SONAME
7471                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
7472                 ;;
7473         (netbsd*)
7474                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
7475                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
7476                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
7477                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7478                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
7479                         if test "$cf_cv_shlib_version" = auto; then
7480                         if test -f /usr/libexec/ld.elf_so; then
7481                                 cf_cv_shlib_version=abi
7482                         else
7483                                 cf_cv_shlib_version=rel
7484                         fi
7485                         fi
7486                         CF_SHARED_SONAME
7487                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
7488                 else
7489                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -o $[@]'
7490                 fi
7491                 ;;
7492         (osf*|mls+*)
7493                 # tested with OSF/1 V3.2 and 'cc'
7494                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
7495                 # link with shared libs).
7496                 MK_SHARED_LIB='${LD} ${LDFLAGS} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
7497                 case "$host_os" in
7498                 (osf4*)
7499                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
7500                         ;;
7501                 esac
7502                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
7503                 if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
7504                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
7505                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7506                 fi
7507                 cf_cv_rm_so_locs=yes
7508                 ;;
7509         (sco3.2v5*)  # also uw2* and UW7: hops 13-Apr-98
7510                 # tested with osr5.0.5
7511                 if test "$GCC" != yes; then
7512                         CC_SHARED_OPTS='-belf -KPIC'
7513                 fi
7514                 MK_SHARED_LIB='${LD} ${LDFLAGS} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
7515                 if test "$cf_cv_enable_rpath" = yes ; then
7516                         # only way is to set LD_RUN_PATH but no switch for it
7517                         RUN_PATH=$libdir
7518                 fi
7519                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
7520                 LINK_PROGS='LD_RUN_PATH=${libdir}'
7521                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
7522                 ;;
7523         (sunos4*)
7524                 # tested with SunOS 4.1.1 and gcc 2.7.0
7525                 if test "$GCC" != yes; then
7526                         CC_SHARED_OPTS='-KPIC'
7527                 fi
7528                 MK_SHARED_LIB='${LD} ${LDFLAGS} -assert pure-text -o $[@]'
7529                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
7530                 ;;
7531         (solaris2*)
7532                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
7533                 # tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
7534                 if test "$DFT_LWR_MODEL" = "shared" ; then
7535                         LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
7536                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7537                 fi
7538                 if test "$cf_cv_enable_rpath" = yes ; then
7539                         EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
7540                 fi
7541                 CF_SHARED_SONAME
7542                 if test "$GCC" != yes; then
7543                         cf_save_CFLAGS="$CFLAGS"
7544                         for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
7545                         do
7546                                 CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
7547                                 AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\\n");],[break])
7548                         done
7549                         CFLAGS="$cf_save_CFLAGS"
7550                         CC_SHARED_OPTS=$cf_shared_opts
7551                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
7552                 else
7553                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
7554                 fi
7555                 ;;
7556         (sysv5uw7*|unix_sv*)
7557                 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
7558                 if test "$GCC" != yes; then
7559                         CC_SHARED_OPTS='-KPIC'
7560                 fi
7561                 MK_SHARED_LIB='${LD} ${LDFLAGS} -d y -G -o [$]@'
7562                 ;;
7563         (*)
7564                 CC_SHARED_OPTS='unknown'
7565                 MK_SHARED_LIB='echo unknown'
7566                 ;;
7567         esac
7568
7569         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
7570         case "$cf_cv_shlib_version" in
7571         (rel|abi)
7572                 case "$MK_SHARED_LIB" in
7573                 (*'-o $[@]')
7574                         test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
7575                         ;;
7576                 (*)
7577                         AC_MSG_WARN(ignored --with-shlib-version)
7578                         ;;
7579                 esac
7580                 ;;
7581         esac
7582
7583         if test -n "$cf_try_cflags"
7584         then
7585 cat > conftest.$ac_ext <<EOF
7586 #line __oline__ "${as_me:-configure}"
7587 #include <stdio.h>
7588 int main(int argc, char *argv[[]])
7589 {
7590         printf("hello\\n");
7591         return (argv[[argc-1]] == 0) ;
7592 }
7593 EOF
7594                 cf_save_CFLAGS="$CFLAGS"
7595                 for cf_opt in $cf_try_cflags
7596                 do
7597                         CFLAGS="$cf_save_CFLAGS -$cf_opt"
7598                         AC_MSG_CHECKING(if CFLAGS option -$cf_opt works)
7599                         if AC_TRY_EVAL(ac_compile); then
7600                                 AC_MSG_RESULT(yes)
7601                                 cf_save_CFLAGS="$CFLAGS"
7602                         else
7603                                 AC_MSG_RESULT(no)
7604                         fi
7605                 done
7606                 CFLAGS="$cf_save_CFLAGS"
7607         fi
7608
7609
7610         # RPATH_LIST is a colon-separated list of directories
7611         test -n "$cf_ld_rpath_opt" && MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${RPATH_LIST}"
7612         test -z "$RPATH_LIST" && RPATH_LIST="\${libdir}"
7613
7614         test "$cf_cv_rm_so_locs" = yes && RM_SHARED_OPTS="$RM_SHARED_OPTS so_locations"
7615
7616         CF_VERBOSE(CC_SHARED_OPTS: $CC_SHARED_OPTS)
7617         CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
7618
7619         AC_SUBST(CC_SHARED_OPTS)
7620         AC_SUBST(LD_RPATH_OPT)
7621         AC_SUBST(LD_SHARED_OPTS)
7622         AC_SUBST(MK_SHARED_LIB)
7623         AC_SUBST(RM_SHARED_OPTS)
7624
7625         AC_SUBST(LINK_PROGS)
7626         AC_SUBST(LINK_TESTS)
7627
7628         AC_SUBST(EXTRA_LDFLAGS)
7629         AC_SUBST(LOCAL_LDFLAGS)
7630         AC_SUBST(LOCAL_LDFLAGS2)
7631
7632         AC_SUBST(INSTALL_LIB)
7633         AC_SUBST(RPATH_LIST)
7634 ])dnl
7635 dnl ---------------------------------------------------------------------------
7636 dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
7637 dnl ----------------
7638 dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
7639 dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
7640 dnl option.
7641 dnl
7642 dnl $1 is the default that should be used for "$cf_cv_shlib_version".
7643 dnl If missing, use "rel".
7644 define([CF_SHARED_SONAME],
7645 [
7646         test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
7647         if test "$cf_cv_shlib_version" = rel; then
7648                 cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
7649         else
7650                 cf_cv_shared_soname='`basename $[@]`'
7651         fi
7652 ])
7653 dnl ---------------------------------------------------------------------------
7654 dnl CF_SIGWINCH version: 6 updated: 2021/01/01 13:31:04
7655 dnl -----------
7656 dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
7657 dnl programs need this test).
7658 dnl
7659 dnl This is really a Mac OS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
7660 dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
7661 dnl winsize declaration is left alone - we may revisit this if Apple choose to
7662 dnl break that part of the interface as well.
7663 AC_DEFUN([CF_SIGWINCH],
7664 [
7665 AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
7666         AC_TRY_COMPILE([
7667 #include <sys/types.h>
7668 #include <sys/signal.h>
7669 ],[int x = SIGWINCH; (void)x],
7670         [cf_cv_define_sigwinch=yes],
7671         [AC_TRY_COMPILE([
7672 #undef _XOPEN_SOURCE
7673 #undef _POSIX_SOURCE
7674 #undef _POSIX_C_SOURCE
7675 #include <sys/types.h>
7676 #include <sys/signal.h>
7677 ],[int x = SIGWINCH; (void)x],
7678         [cf_cv_define_sigwinch=maybe],
7679         [cf_cv_define_sigwinch=no])
7680 ])
7681 ])
7682
7683 if test "$cf_cv_define_sigwinch" = maybe ; then
7684 AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
7685 cf_cv_fixup_sigwinch=unknown
7686 cf_sigwinch=32
7687 while test "$cf_sigwinch" != 1
7688 do
7689         AC_TRY_COMPILE([
7690 #undef _XOPEN_SOURCE
7691 #undef _POSIX_SOURCE
7692 #undef _POSIX_C_SOURCE
7693 #include <sys/types.h>
7694 #include <sys/signal.h>
7695 ],[
7696 #if SIGWINCH != $cf_sigwinch
7697 make an error
7698 #endif
7699 int x = SIGWINCH; (void)x],
7700         [cf_cv_fixup_sigwinch=$cf_sigwinch
7701          break])
7702
7703 cf_sigwinch="`expr "$cf_sigwinch" - 1`"
7704 done
7705 ])
7706
7707         if test "$cf_cv_fixup_sigwinch" != unknown ; then
7708                 CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
7709         fi
7710 fi
7711 ])dnl
7712 dnl ---------------------------------------------------------------------------
7713 dnl CF_SIG_ATOMIC_T version: 5 updated: 2020/03/10 18:53:47
7714 dnl ---------------
7715 dnl signal handler, but there are some gcc dependencies in that recommendation.
7716 dnl Try anyway.
7717 AC_DEFUN([CF_SIG_ATOMIC_T],
7718 [
7719 AC_MSG_CHECKING(for signal global datatype)
7720 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
7721         for cf_type in \
7722                 "volatile sig_atomic_t" \
7723                 "sig_atomic_t" \
7724                 "int"
7725         do
7726         AC_TRY_COMPILE([
7727 #include <sys/types.h>
7728 #include <signal.h>
7729 #include <stdio.h>
7730
7731 extern $cf_type x;
7732 $cf_type x;
7733 static void handler(int sig)
7734 {
7735         (void)sig;
7736         x = 5;
7737 }],
7738                 [signal(SIGINT, handler);
7739                  x = 1],
7740                 [cf_cv_sig_atomic_t=$cf_type],
7741                 [cf_cv_sig_atomic_t=no])
7742                 test "$cf_cv_sig_atomic_t" != no && break
7743         done
7744         ])
7745 AC_MSG_RESULT($cf_cv_sig_atomic_t)
7746 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
7747 ])dnl
7748 dnl ---------------------------------------------------------------------------
7749 dnl CF_SIZECHANGE version: 18 updated: 2021/09/04 06:35:04
7750 dnl -------------
7751 dnl Check for definitions & structures needed for window size-changing
7752 dnl
7753 dnl https://stackoverflow.com/questions/18878141/difference-between-structures-ttysize-and-winsize/50769952#50769952
7754 AC_DEFUN([CF_SIZECHANGE],
7755 [
7756 AC_REQUIRE([CF_STRUCT_TERMIOS])
7757 AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
7758         cf_cv_sizechange=unknown
7759         cf_save_CPPFLAGS="$CPPFLAGS"
7760
7761 for cf_opts in "" "NEED_PTEM_H"
7762 do
7763
7764         CPPFLAGS="$cf_save_CPPFLAGS"
7765         if test -n "$cf_opts"
7766         then
7767                 CF_APPEND_TEXT(CPPFLAGS,-D$cf_opts)
7768         fi
7769         AC_TRY_COMPILE([#include <sys/types.h>
7770 #ifdef HAVE_TERMIOS_H
7771 #include <termios.h>
7772 #else
7773 #ifdef HAVE_TERMIO_H
7774 #include <termio.h>
7775 #endif
7776 #endif
7777
7778 #ifdef NEED_PTEM_H
7779 /* This is a workaround for SCO:  they neglected to define struct winsize in
7780  * termios.h -- it is only in termio.h and ptem.h
7781  */
7782 #include <sys/stream.h>
7783 #include <sys/ptem.h>
7784 #endif
7785
7786 #ifdef HAVE_SYS_IOCTL_H
7787 #include <sys/ioctl.h>
7788 #endif
7789 ],[
7790 #ifdef TIOCGSIZE
7791         struct ttysize win;     /* SunOS 3.0... */
7792         int y = win.ts_lines = 2;
7793         int x = win.ts_cols = 1;
7794         (void)y;
7795         (void)x;
7796 #else
7797 #ifdef TIOCGWINSZ
7798         struct winsize win;     /* everything else */
7799         int y = win.ws_row = 2;
7800         int x = win.ws_col = 1;
7801         (void)y;
7802         (void)x;
7803 #else
7804         no TIOCGSIZE or TIOCGWINSZ
7805 #endif /* TIOCGWINSZ */
7806 #endif /* TIOCGSIZE */
7807         ],
7808         [cf_cv_sizechange=yes],
7809         [cf_cv_sizechange=no])
7810
7811         CPPFLAGS="$cf_save_CPPFLAGS"
7812         if test "$cf_cv_sizechange" = yes ; then
7813                 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
7814                 test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
7815                 break
7816         fi
7817 done
7818 ])
7819 if test "$cf_cv_sizechange" != no ; then
7820         AC_DEFINE(HAVE_SIZECHANGE,1,[Define to 1 if sizechange declarations are provided])
7821         case "$cf_cv_sizechange" in
7822         (NEED*)
7823                 AC_DEFINE_UNQUOTED($cf_cv_sizechange )
7824                 ;;
7825         esac
7826 fi
7827 ])dnl
7828 dnl ---------------------------------------------------------------------------
7829 dnl CF_SRC_MODULES version: 33 updated: 2021/01/01 13:31:04
7830 dnl --------------
7831 dnl For each parameter, test if the source-directory exists, and if it contains
7832 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
7833 dnl use in CF_LIB_RULES.
7834 dnl
7835 dnl This uses the configured value to make the lists SRC_SUBDIRS and
7836 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
7837 AC_DEFUN([CF_SRC_MODULES],
7838 [
7839 AC_REQUIRE([CF_CHECK_GNAT_VERSION])
7840 AC_MSG_CHECKING(for src modules)
7841
7842 # dependencies and linker-arguments for test-programs
7843 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
7844 TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEP2"
7845 if test "$DFT_LWR_MODEL" = "libtool"; then
7846         TEST_ARGS="${TEST_DEPS}"
7847         TEST_ARG2="${TEST_DEP2}"
7848 else
7849         TEST_ARGS="-l${LIB_NAME}${USE_ARG_SUFFIX} $TEST_ARGS"
7850         TEST_ARG2="-l${LIB_NAME}${USE_ARG_SUFFIX} $TEST_ARG2"
7851 fi
7852
7853 PC_MODULES_TO_MAKE="ncurses${USE_ARG_SUFFIX}"
7854 cf_cv_src_modules=
7855 for cf_dir in $1
7856 do
7857         if test -f "$srcdir/$cf_dir/modules" ; then
7858
7859                 # We may/may not have tack in the distribution, though the
7860                 # makefile is.
7861                 if test "$cf_dir" = tack ; then
7862                         if test "x$cf_with_tack" != "xyes"; then
7863                                 continue
7864                         fi
7865                 fi
7866
7867                 if test -z "$cf_cv_src_modules"; then
7868                         cf_cv_src_modules=$cf_dir
7869                 else
7870                         cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
7871                 fi
7872
7873                 # Make the ncurses_cfg.h file record the library interface files as
7874                 # well.  These are header files that are the same name as their
7875                 # directory.  Ncurses is the only library that does not follow
7876                 # that pattern.
7877                 if test "$cf_dir" = tack ; then
7878                         continue
7879                 elif test -f "$srcdir/${cf_dir}/${cf_dir}.h" ; then
7880                         CF_UPPER(cf_have_include,$cf_dir)
7881                         AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
7882                         AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
7883                         CF_MAP_LIB_BASENAME(TEST_ROOT,$cf_dir)
7884                         TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TEST_ROOT}${DFT_DEP_SUFFIX} $TEST_DEPS"
7885                         TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${TEST_ROOT}${DFT_DEP_SUFFIX} $TEST_DEP2"
7886                         if test "$DFT_LWR_MODEL" = "libtool"; then
7887                                 TEST_ARGS="${TEST_DEPS}"
7888                                 TEST_ARG2="${TEST_DEP2}"
7889                         else
7890                                 TEST_ARGS="-l${TEST_ROOT}${USE_ARG_SUFFIX} $TEST_ARGS"
7891                                 TEST_ARG2="-l${TEST_ROOT}${USE_ARG_SUFFIX} $TEST_ARG2"
7892                         fi
7893                         PC_MODULES_TO_MAKE="${PC_MODULES_TO_MAKE} ${cf_dir}${USE_ARG_SUFFIX}"
7894                 fi
7895         fi
7896 done
7897 AC_MSG_RESULT($cf_cv_src_modules)
7898
7899 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
7900 TEST_ARG2="-L${LIB_2ND} $TEST_ARG2"
7901
7902 AC_SUBST(TEST_ARGS)
7903 AC_SUBST(TEST_DEPS)
7904
7905 AC_SUBST(TEST_ARG2)
7906 AC_SUBST(TEST_DEP2)
7907
7908 SRC_SUBDIRS=
7909 if test "x$cf_with_manpages" != xno ; then
7910         SRC_SUBDIRS="$SRC_SUBDIRS man"
7911 fi
7912 SRC_SUBDIRS="$SRC_SUBDIRS include"
7913 for cf_dir in $cf_cv_src_modules
7914 do
7915         SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
7916 done
7917 if test "x$cf_with_tests" != "xno" ; then
7918         SRC_SUBDIRS="$SRC_SUBDIRS test"
7919 fi
7920 # always make this, to install the ncurses-config script
7921 SRC_SUBDIRS="$SRC_SUBDIRS misc"
7922 if test "$cf_with_cxx_binding" != no; then
7923         PC_MODULES_TO_MAKE="${PC_MODULES_TO_MAKE} ncurses++${USE_ARG_SUFFIX}"
7924         SRC_SUBDIRS="$SRC_SUBDIRS c++"
7925 fi
7926
7927 test "x$with_termlib" != xno && PC_MODULES_TO_MAKE="$PC_MODULES_TO_MAKE $TINFO_ARG_SUFFIX"
7928 test "x$with_ticlib" != xno && PC_MODULES_TO_MAKE="$PC_MODULES_TO_MAKE $TICS_ARG_SUFFIX"
7929
7930 AC_SUBST(PC_MODULES_TO_MAKE)
7931
7932 ADA_SUBDIRS=
7933 if test "x$cf_with_ada" = "xyes" && test "x$cf_cv_prog_gnat_correct" = xyes && test -f "$srcdir/Ada95/Makefile.in" ; then
7934         SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
7935         ADA_SUBDIRS="gen src"
7936         if test "x$cf_with_tests" != "xno" ; then
7937                 ADA_SUBDIRS="$ADA_SUBDIRS samples"
7938         fi
7939 fi
7940
7941 SUB_MAKEFILES=
7942 for cf_dir in $SRC_SUBDIRS
7943 do
7944         SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
7945 done
7946
7947 if test -n "$ADA_SUBDIRS"; then
7948         for cf_dir in $ADA_SUBDIRS
7949         do
7950                 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
7951         done
7952         AC_SUBST(ADA_SUBDIRS)
7953 fi
7954 ])dnl
7955 dnl ---------------------------------------------------------------------------
7956 dnl CF_STDCPP_LIBRARY version: 12 updated: 2021/01/01 13:31:04
7957 dnl -----------------
7958 dnl Check for -lstdc++, which is GNU's standard C++ library.
7959 dnl If $CXXLIBS is set, add that to the libraries used for test-linking.
7960 dnl If -lstdc++ was not already added to $LIBS or $CXXLIBS, and is needed,
7961 dnl add it to $CXXLIBS.
7962 AC_DEFUN([CF_STDCPP_LIBRARY],
7963 [
7964 if test -n "$GXX" ; then
7965
7966         cf_save="$LIBS"
7967         LIBS="$LIBS $CXXLIBS"
7968         AC_MSG_CHECKING(if we already have C++ library)
7969         AC_TRY_LINK([
7970                         #include <iostream>],[
7971                         std::cout << "Hello World!" << std::endl;],
7972                 [cf_have_libstdcpp=yes],
7973                 [cf_have_libstdcpp=no])
7974         AC_MSG_RESULT($cf_have_libstdcpp)
7975         LIBS="$cf_save"
7976
7977         if test "$cf_have_libstdcpp" != yes
7978         then
7979                 case "$cf_cv_system_name" in
7980                 (os2*)
7981                         if test -z "`g++ -dM -E - < /dev/null | grep __KLIBC__`"; then
7982                                 cf_stdcpp_libname=stdcpp
7983                         else
7984                                 cf_stdcpp_libname=stdc++
7985                         fi
7986                         ;;
7987                 (*)
7988                         cf_stdcpp_libname=stdc++
7989                         ;;
7990                 esac
7991
7992                 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
7993                         cf_save="$LIBS"
7994                         LIBS="$LIBS $CXXLIBS"
7995                         CF_ADD_LIB($cf_stdcpp_libname)
7996                 AC_TRY_LINK([
7997                                 #include <iostream>],[
7998                                 std::cout << "Hello World!" << std::endl;],
7999                         [cf_cv_libstdcpp=yes],
8000                         [cf_cv_libstdcpp=no])
8001                         LIBS="$cf_save"
8002                 ])
8003                 test "$cf_cv_libstdcpp" = yes && { CF_ADD_LIB($cf_stdcpp_libname,CXXLIBS) }
8004         fi
8005 fi
8006 ])dnl
8007 dnl ---------------------------------------------------------------------------
8008 dnl CF_STRIP_G_OPT version: 4 updated: 2021/01/02 09:31:20
8009 dnl --------------
8010 dnl     Remove "-g" option from the compiler options
8011 AC_DEFUN([CF_STRIP_G_OPT],
8012 [$1=`echo "${$1}" | CF__SED_TRIMBLANKS(-e 's%-g %%' -e 's%-g$%%')`])dnl
8013 dnl ---------------------------------------------------------------------------
8014 dnl CF_STRUCT_SIGACTION version: 5 updated: 2012/10/06 17:56:13
8015 dnl -------------------
8016 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
8017 dnl do this if we've found the sigaction function.
8018 AC_DEFUN([CF_STRUCT_SIGACTION],[
8019 AC_REQUIRE([CF_XOPEN_SOURCE])
8020
8021 if test "$ac_cv_func_sigaction" = yes; then
8022 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
8023 AC_TRY_COMPILE([
8024 #include <sys/types.h>
8025 #include <signal.h>],
8026         [struct sigaction act],
8027         [sigact_bad=no],
8028         [
8029 AC_TRY_COMPILE([
8030 #define _POSIX_SOURCE
8031 #include <sys/types.h>
8032 #include <signal.h>],
8033         [struct sigaction act],
8034         [sigact_bad=yes
8035          AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE])],
8036          [sigact_bad=unknown])])
8037 AC_MSG_RESULT($sigact_bad)
8038 fi
8039 ])dnl
8040 dnl ---------------------------------------------------------------------------
8041 dnl CF_STRUCT_TERMIOS version: 11 updated: 2020/03/19 20:46:13
8042 dnl -----------------
8043 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
8044 AC_DEFUN([CF_STRUCT_TERMIOS],[
8045 AC_REQUIRE([CF_XOPEN_SOURCE])
8046
8047 AC_CHECK_HEADERS( \
8048 termio.h \
8049 termios.h \
8050 unistd.h \
8051 sys/ioctl.h \
8052 sys/termio.h \
8053 )
8054
8055 if test "$ac_cv_header_termios_h" = yes ; then
8056         case "$CFLAGS $CPPFLAGS" in
8057         (*-D_POSIX_SOURCE*)
8058                 termios_bad=dunno ;;
8059         (*)     termios_bad=maybe ;;
8060         esac
8061         if test "$termios_bad" = maybe ; then
8062         AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
8063         AC_TRY_COMPILE([#include <termios.h>],
8064                 [struct termios foo; int x = foo.c_iflag = 1; (void)x],
8065                 termios_bad=no, [
8066                 AC_TRY_COMPILE([
8067 #define _POSIX_SOURCE
8068 #include <termios.h>],
8069                         [struct termios foo; int x = foo.c_iflag = 2; (void)x],
8070                         termios_bad=unknown,
8071                         termios_bad=yes AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE]))
8072                         ])
8073         AC_MSG_RESULT($termios_bad)
8074         fi
8075 fi
8076 ])dnl
8077 dnl ---------------------------------------------------------------------------
8078 dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
8079 dnl --------------
8080 dnl Construct a search-list for a nonstandard header/lib-file
8081 dnl     $1 = the variable to return as result
8082 dnl     $2 = the package name
8083 dnl     $3 = the subdirectory, e.g., bin, include or lib
8084 AC_DEFUN([CF_SUBDIR_PATH],
8085 [
8086 $1=
8087
8088 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
8089
8090 for cf_subdir_prefix in \
8091         /usr \
8092         /usr/local \
8093         /usr/pkg \
8094         /opt \
8095         /opt/local \
8096         [$]HOME
8097 do
8098         CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
8099 done
8100 ])dnl
8101 dnl ---------------------------------------------------------------------------
8102 dnl CF_SUBST_IF version: 2 updated: 2006/06/17 12:33:03
8103 dnl -----------
8104 dnl     Shorthand macro for substituting things that the user may override
8105 dnl     with an environment variable.
8106 dnl
8107 dnl     $1 = condition to pass to "test"
8108 dnl     $2 = environment variable
8109 dnl     $3 = value if the test succeeds
8110 dnl     $4 = value if the test fails
8111 AC_DEFUN([CF_SUBST_IF],
8112 [
8113 if test $1 ; then
8114         $2=$3
8115 ifelse($4,,,[else
8116         $2=$4])
8117 fi
8118 AC_SUBST($2)
8119 ])dnl
8120 dnl ---------------------------------------------------------------------------
8121 dnl CF_SUBST_NCURSES_VERSION version: 10 updated: 2021/01/04 18:48:01
8122 dnl ------------------------
8123 dnl Get the version-number for use in shared-library naming, etc.
8124 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
8125 [AC_REQUIRE([AC_PROG_EGREP])dnl
8126
8127 NCURSES_MAJOR="`${EGREP-egrep} '^NCURSES_MAJOR[[        ]]*=' "$srcdir/dist.mk" | sed -e 's/^[[^0-9]]*//'`"
8128 NCURSES_MINOR="`${EGREP-egrep} '^NCURSES_MINOR[[        ]]*=' "$srcdir/dist.mk" | sed -e 's/^[[^0-9]]*//'`"
8129 NCURSES_PATCH="`${EGREP-egrep} '^NCURSES_PATCH[[        ]]*=' "$srcdir/dist.mk" | sed -e 's/^[[^0-9]]*//'`"
8130 cf_cv_abi_version=${NCURSES_MAJOR}
8131 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
8132 dnl Show the computed version, for logging
8133 cf_cv_timestamp=`date`
8134 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
8135 dnl We need these values in the generated headers
8136 AC_SUBST(NCURSES_MAJOR)
8137 AC_SUBST(NCURSES_MINOR)
8138 AC_SUBST(NCURSES_PATCH)
8139 dnl We need these values in the generated makefiles
8140 AC_SUBST(cf_cv_rel_version)
8141 AC_SUBST(cf_cv_abi_version)
8142 AC_SUBST(cf_cv_builtin_bool)
8143 AC_SUBST(cf_cv_header_stdbool_h)
8144 AC_SUBST(cf_cv_type_of_bool)dnl
8145 ])dnl
8146 dnl ---------------------------------------------------------------------------
8147 dnl CF_SYS_TIME_SELECT version: 6 updated: 2015/04/18 08:56:57
8148 dnl ------------------
8149 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
8150 dnl older SCO configurations.
8151 AC_DEFUN([CF_SYS_TIME_SELECT],
8152 [
8153 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
8154 AC_CACHE_VAL(cf_cv_sys_time_select,[
8155 AC_TRY_COMPILE([
8156 #include <sys/types.h>
8157 #ifdef HAVE_SYS_TIME_H
8158 #include <sys/time.h>
8159 #endif
8160 #ifdef HAVE_SYS_SELECT_H
8161 #include <sys/select.h>
8162 #endif
8163 ],[],[cf_cv_sys_time_select=yes],
8164          [cf_cv_sys_time_select=no])
8165          ])
8166 AC_MSG_RESULT($cf_cv_sys_time_select)
8167 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT,1,[Define to 1 if we can include <sys/time.h> with <sys/select.h>])
8168 ])dnl
8169 dnl ---------------------------------------------------------------------------
8170 dnl CF_TOP_BUILDDIR version: 2 updated: 2013/07/27 17:38:32
8171 dnl ---------------
8172 dnl Define a top_builddir symbol, for applications that need an absolute path.
8173 AC_DEFUN([CF_TOP_BUILDDIR],
8174 [
8175 top_builddir=ifelse($1,,`pwd`,$1)
8176 AC_SUBST(top_builddir)
8177 ])dnl
8178 dnl ---------------------------------------------------------------------------
8179 dnl CF_TRY_PKG_CONFIG version: 6 updated: 2020/12/31 10:54:15
8180 dnl -----------------
8181 dnl This is a simple wrapper to use for pkg-config, for libraries which may be
8182 dnl available in that form.
8183 dnl
8184 dnl $1 = package name, which may be a shell variable
8185 dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
8186 dnl $3 = logic to use if pkg-config does not have the package
8187 AC_DEFUN([CF_TRY_PKG_CONFIG],[
8188 AC_REQUIRE([CF_PKG_CONFIG])
8189
8190 if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$1"; then
8191         CF_VERBOSE(found package $1)
8192         cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$1" 2>/dev/null`"
8193         cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$1" 2>/dev/null`"
8194         CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
8195         CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
8196         CF_ADD_CFLAGS($cf_pkgconfig_incs)
8197         CF_ADD_LIBS($cf_pkgconfig_libs)
8198         ifelse([$2],,:,[$2])
8199 else
8200         cf_pkgconfig_incs=
8201         cf_pkgconfig_libs=
8202         ifelse([$3],,:,[$3])
8203 fi
8204 ])
8205 dnl ---------------------------------------------------------------------------
8206 dnl CF_TRY_XOPEN_SOURCE version: 3 updated: 2021/08/28 15:20:37
8207 dnl -------------------
8208 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
8209 dnl can define it successfully.
8210 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
8211 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
8212         AC_TRY_COMPILE([
8213 #include <stdlib.h>
8214 #include <string.h>
8215 #include <sys/types.h>
8216 ],[
8217 #ifndef _XOPEN_SOURCE
8218 make an error
8219 #endif],
8220         [cf_cv_xopen_source=no],
8221         [cf_save="$CPPFLAGS"
8222          CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
8223          AC_TRY_COMPILE([
8224 #include <stdlib.h>
8225 #include <string.h>
8226 #include <sys/types.h>
8227 ],[
8228 #ifdef _XOPEN_SOURCE
8229 make an error
8230 #endif],
8231         [cf_cv_xopen_source=no],
8232         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
8233         CPPFLAGS="$cf_save"
8234         ])
8235 ])
8236
8237 if test "$cf_cv_xopen_source" != no ; then
8238         CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
8239         CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
8240         cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
8241         CF_APPEND_CFLAGS($cf_temp_xopen_source)
8242 fi
8243 ])
8244 dnl ---------------------------------------------------------------------------
8245 dnl CF_TYPEOF_CHTYPE version: 10 updated: 2017/01/21 11:06:25
8246 dnl ----------------
8247 dnl Determine the type we should use for chtype (and attr_t, which is treated
8248 dnl as the same thing).  We want around 32 bits, so on most machines want a
8249 dnl long, but on newer 64-bit machines, probably want an int.  If we're using
8250 dnl wide characters, we have to have a type compatible with that, as well.
8251 AC_DEFUN([CF_TYPEOF_CHTYPE],
8252 [
8253 AC_MSG_CHECKING([for type of chtype])
8254 AC_CACHE_VAL(cf_cv_typeof_chtype,[
8255                 AC_TRY_RUN([
8256 #define WANT_BITS 31
8257 #include <stdio.h>
8258 int main(void)
8259 {
8260         FILE *fp = fopen("cf_test.out", "w");
8261         if (fp != 0) {
8262                 char *result = "long";
8263                 if (sizeof(unsigned long) > sizeof(unsigned int)) {
8264                         int n;
8265                         unsigned int x, y;
8266                         for (n = 0; n < WANT_BITS; n++) {
8267                                 x = (1 << n);
8268                                 y = (x >> n);
8269                                 if (y != 1 || x == 0) {
8270                                         x = 0;
8271                                         break;
8272                                 }
8273                         }
8274                         /*
8275                          * If x is nonzero, an int is big enough for the bits
8276                          * that we want.
8277                          */
8278                         result = (x != 0) ? "int" : "long";
8279                 }
8280                 fputs(result, fp);
8281                 fclose(fp);
8282         }
8283         ${cf_cv_main_return:-return}(0);
8284 }
8285                 ],
8286                 [cf_cv_typeof_chtype=`cat cf_test.out`],
8287                 [cf_cv_typeof_chtype=long],
8288                 [cf_cv_typeof_chtype=long])
8289                 rm -f cf_test.out
8290         ])
8291 AC_MSG_RESULT($cf_cv_typeof_chtype)
8292
8293 AC_SUBST(cf_cv_typeof_chtype)
8294 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype,[Define to actual type if needed for chtype])
8295 ])dnl
8296 dnl ---------------------------------------------------------------------------
8297 dnl CF_TYPE_SIGACTION version: 4 updated: 2012/10/06 17:56:13
8298 dnl -----------------
8299 dnl
8300 AC_DEFUN([CF_TYPE_SIGACTION],
8301 [
8302 AC_MSG_CHECKING([for type sigaction_t])
8303 AC_CACHE_VAL(cf_cv_type_sigaction,[
8304         AC_TRY_COMPILE([
8305 #include <signal.h>],
8306                 [sigaction_t x],
8307                 [cf_cv_type_sigaction=yes],
8308                 [cf_cv_type_sigaction=no])])
8309 AC_MSG_RESULT($cf_cv_type_sigaction)
8310 test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION,1,[Define to 1 if we have the sigaction_t type])
8311 ])dnl
8312 dnl ---------------------------------------------------------------------------
8313 dnl CF_UNSIGNED_LITERALS version: 2 updated: 1998/02/07 22:10:16
8314 dnl --------------------
8315 dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
8316 dnl won't, but they're still there.
8317 AC_DEFUN([CF_UNSIGNED_LITERALS],
8318 [
8319 AC_MSG_CHECKING([if unsigned literals are legal])
8320 AC_CACHE_VAL(cf_cv_unsigned_literals,[
8321         AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
8322                 [cf_cv_unsigned_literals=yes],
8323                 [cf_cv_unsigned_literals=no])
8324         ])
8325 AC_MSG_RESULT($cf_cv_unsigned_literals)
8326 ])dnl
8327 dnl ---------------------------------------------------------------------------
8328 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
8329 dnl --------
8330 dnl Make an uppercase version of a variable
8331 dnl $1=uppercase($2)
8332 AC_DEFUN([CF_UPPER],
8333 [
8334 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
8335 ])dnl
8336 dnl ---------------------------------------------------------------------------
8337 dnl CF_UTF8_LIB version: 9 updated: 2021/05/19 19:35:25
8338 dnl -----------
8339 dnl Check for multibyte support, and if not found, utf8 compatibility library
8340 AC_DEFUN([CF_UTF8_LIB],
8341 [
8342 AC_HAVE_HEADERS(wchar.h)
8343 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
8344         cf_save_LIBS="$LIBS"
8345         AC_TRY_LINK([
8346 #include <stdlib.h>
8347 #include <stdio.h>
8348 #ifdef HAVE_WCHAR_H
8349 #include <wchar.h>
8350 #endif
8351 ],[putwc(0,0);],
8352         [cf_cv_utf8_lib=yes],
8353         [CF_FIND_LINKAGE([
8354 #include <libutf8.h>],[putwc(0,0);],utf8,
8355                 [cf_cv_utf8_lib=add-on],
8356                 [cf_cv_utf8_lib=no])
8357 ])])
8358
8359 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
8360 # ncurses/ncursesw:
8361 if test "$cf_cv_utf8_lib" = "add-on" ; then
8362         AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
8363         CF_ADD_INCDIR($cf_cv_header_path_utf8)
8364         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
8365         CF_ADD_LIBS($cf_cv_library_file_utf8)
8366 fi
8367 ])dnl
8368 dnl ---------------------------------------------------------------------------
8369 dnl CF_VA_COPY version: 6 updated: 2018/12/04 18:14:25
8370 dnl ----------
8371 dnl check for va_copy, part of stdarg.h starting with ISO C 1999.
8372 dnl Also, workaround for glibc's __va_copy, by checking for both.
8373 dnl Finally, try to accommodate pre-ISO C 1999 headers.
8374 AC_DEFUN([CF_VA_COPY],[
8375 AC_CACHE_CHECK(for va_copy, cf_cv_have_va_copy,[
8376 AC_TRY_LINK([
8377 #include <stdarg.h>
8378 ],[
8379         static va_list dst;
8380         static va_list src;
8381         va_copy(dst, src)],
8382         cf_cv_have_va_copy=yes,
8383         cf_cv_have_va_copy=no)])
8384
8385 if test "$cf_cv_have_va_copy" = yes;
8386 then
8387         AC_DEFINE(HAVE_VA_COPY,1,[Define to 1 if we have va_copy])
8388 else # !cf_cv_have_va_copy
8389
8390 AC_CACHE_CHECK(for __va_copy, cf_cv_have___va_copy,[
8391 AC_TRY_LINK([
8392 #include <stdarg.h>
8393 ],[
8394         static va_list dst;
8395         static va_list src;
8396         __va_copy(dst, src)],
8397         cf_cv_have___va_copy=yes,
8398         cf_cv_have___va_copy=no)])
8399
8400 if test "$cf_cv_have___va_copy" = yes
8401 then
8402         AC_DEFINE(HAVE___VA_COPY,1,[Define to 1 if we have __va_copy])
8403 else # !cf_cv_have___va_copy
8404
8405 AC_CACHE_CHECK(for __builtin_va_copy, cf_cv_have___builtin_va_copy,[
8406 AC_TRY_LINK([
8407 #include <stdarg.h>
8408 ],[
8409         static va_list dst;
8410         static va_list src;
8411         __builtin_va_copy(dst, src)],
8412         cf_cv_have___builtin_va_copy=yes,
8413         cf_cv_have___builtin_va_copy=no)])
8414
8415 test "$cf_cv_have___builtin_va_copy" = yes &&
8416         AC_DEFINE(HAVE___BUILTIN_VA_COPY,1,[Define to 1 if we have __builtin_va_copy])
8417
8418 fi # cf_cv_have___va_copy
8419
8420 fi # cf_cv_have_va_copy
8421
8422 case "${cf_cv_have_va_copy}${cf_cv_have___va_copy}${cf_cv_have___builtin_va_copy}" in
8423 (*yes*)
8424         ;;
8425
8426 (*)
8427         AC_CACHE_CHECK(if we can simply copy va_list, cf_cv_pointer_va_list,[
8428 AC_TRY_LINK([
8429 #include <stdarg.h>
8430 ],[
8431         va_list dst;
8432         va_list src;
8433         dst = src],
8434         cf_cv_pointer_va_list=yes,
8435         cf_cv_pointer_va_list=no)])
8436
8437         if test "$cf_cv_pointer_va_list" = no
8438         then
8439                 AC_CACHE_CHECK(if we can copy va_list indirectly, cf_cv_array_va_list,[
8440 AC_TRY_LINK([
8441 #include <stdarg.h>
8442 ],[
8443         va_list dst;
8444         va_list src;
8445         *dst = *src],
8446                         cf_cv_array_va_list=yes,
8447                         cf_cv_array_va_list=no)])
8448                 test "$cf_cv_array_va_list" = yes && AC_DEFINE(ARRAY_VA_LIST,1,[Define to 1 if we can copy va_list indirectly])
8449         fi
8450         ;;
8451 esac
8452 ])
8453 dnl ---------------------------------------------------------------------------
8454 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
8455 dnl ----------
8456 dnl Use AC_VERBOSE w/o the warnings
8457 AC_DEFUN([CF_VERBOSE],
8458 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
8459 CF_MSG_LOG([$1])
8460 ])dnl
8461 dnl ---------------------------------------------------------------------------
8462 dnl CF_VERSION_INFO version: 8 updated: 2021/01/01 13:31:04
8463 dnl ---------------
8464 dnl Define several useful symbols derived from the VERSION file.  A separate
8465 dnl file is preferred to embedding the version numbers in various scripts.
8466 dnl (automake is a textbook-example of why the latter is a bad idea, but there
8467 dnl are others).
8468 dnl
8469 dnl The file contents are:
8470 dnl     libtool-version release-version patch-version
8471 dnl or
8472 dnl     release-version
8473 dnl where
8474 dnl     libtool-version (see ?) consists of 3 integers separated by '.'
8475 dnl     release-version consists of a major version and minor version
8476 dnl             separated by '.', optionally followed by a patch-version
8477 dnl             separated by '-'.  The minor version need not be an
8478 dnl             integer (but it is preferred).
8479 dnl     patch-version is an integer in the form yyyymmdd, so ifdef's and
8480 dnl             scripts can easily compare versions.
8481 dnl
8482 dnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
8483 dnl simply extracts the first field using 'cut -f1'.
8484 dnl
8485 dnl Optional parameters:
8486 dnl $1 = internal name for package
8487 dnl $2 = external name for package
8488 AC_DEFUN([CF_VERSION_INFO],
8489 [
8490 if test -f "$srcdir/VERSION" ; then
8491         AC_MSG_CHECKING(for package version)
8492
8493         # if there are not enough fields, cut returns the last one...
8494         cf_field1=`sed -e '2,$d' "$srcdir/VERSION" |cut -f1`
8495         cf_field2=`sed -e '2,$d' "$srcdir/VERSION" |cut -f2`
8496         cf_field3=`sed -e '2,$d' "$srcdir/VERSION" |cut -f3`
8497
8498         # this is how CF_BUNDLED_INTL uses $VERSION:
8499         VERSION="$cf_field1"
8500
8501         VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
8502         test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version)
8503
8504         VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'`
8505         test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version)
8506
8507         AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR})
8508
8509         AC_MSG_CHECKING(for package patch date)
8510         VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'`
8511         case .$VERSION_PATCH in
8512         (.)
8513                 AC_MSG_ERROR(missing patch-date $VERSION_PATCH)
8514                 ;;
8515         (.[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
8516                 ;;
8517         (*)
8518                 AC_MSG_ERROR(illegal patch-date $VERSION_PATCH)
8519                 ;;
8520         esac
8521         AC_MSG_RESULT($VERSION_PATCH)
8522 else
8523         AC_MSG_ERROR(did not find $srcdir/VERSION)
8524 fi
8525
8526 # show the actual data that we have for versions:
8527 CF_VERBOSE(ABI VERSION $VERSION)
8528 CF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
8529 CF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
8530 CF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
8531
8532 AC_SUBST(VERSION)
8533 AC_SUBST(VERSION_MAJOR)
8534 AC_SUBST(VERSION_MINOR)
8535 AC_SUBST(VERSION_PATCH)
8536
8537 dnl if a package name is given, define its corresponding version info.  We
8538 dnl need the package name to ensure that the defined symbols are unique.
8539 ifelse($1,,,[
8540         cf_PACKAGE=$1
8541         PACKAGE=ifelse($2,,$1,$2)
8542         AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE",[Define to the package-name])
8543         AC_SUBST(PACKAGE)
8544         CF_UPPER(cf_PACKAGE,$cf_PACKAGE)
8545         AC_DEFINE_UNQUOTED(${cf_PACKAGE}_VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}")
8546         AC_DEFINE_UNQUOTED(${cf_PACKAGE}_PATCHDATE,${VERSION_PATCH})
8547 ])
8548 ])dnl
8549 dnl ---------------------------------------------------------------------------
8550 dnl CF_WCHAR_TYPE version: 4 updated: 2012/10/06 16:39:58
8551 dnl -------------
8552 dnl Check if type wide-character type $1 is declared, and if so, which header
8553 dnl file is needed.  The second parameter is used to set a shell variable when
8554 dnl the type is not found.  The first parameter sets a shell variable for the
8555 dnl opposite sense.
8556 AC_DEFUN([CF_WCHAR_TYPE],
8557 [
8558 # This is needed on Tru64 5.0 to declare $1
8559 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
8560 AC_TRY_COMPILE([
8561 #include <stdlib.h>
8562 #include <stdarg.h>
8563 #include <stdio.h>
8564 #ifdef HAVE_LIBUTF8_H
8565 #include <libutf8.h>
8566 #endif],
8567         [$1 state],
8568         [cf_cv_$1=no],
8569         [AC_TRY_COMPILE([
8570 #include <stdlib.h>
8571 #include <stdarg.h>
8572 #include <stdio.h>
8573 #include <wchar.h>
8574 #ifdef HAVE_LIBUTF8_H
8575 #include <libutf8.h>
8576 #endif],
8577         [$1 value],
8578         [cf_cv_$1=yes],
8579         [cf_cv_$1=unknown])])])
8580
8581 if test "$cf_cv_$1" = yes ; then
8582         AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
8583         NEED_WCHAR_H=1
8584 fi
8585
8586 ifelse([$2],,,[
8587 # if we do not find $1 in either place, use substitution to provide a fallback.
8588 if test "$cf_cv_$1" = unknown ; then
8589         $2=1
8590 fi
8591 ])
8592 ifelse($3,,,[
8593 # if we find $1 in either place, use substitution to provide a fallback.
8594 if test "$cf_cv_$1" != unknown ; then
8595         $3=1
8596 fi
8597 ])
8598 ])dnl
8599 dnl ---------------------------------------------------------------------------
8600 dnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06
8601 dnl ---------------
8602 dnl Check for compiler-support for weak symbols.
8603 dnl This works with "recent" gcc.
8604 AC_DEFUN([CF_WEAK_SYMBOLS],[
8605 AC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[
8606
8607 AC_TRY_COMPILE([
8608 #include <stdio.h>],
8609 [
8610 #if defined(__GNUC__)
8611 #  if defined __USE_ISOC99
8612 #    define _cat_pragma(exp)    _Pragma(#exp)
8613 #    define _weak_pragma(exp)   _cat_pragma(weak name)
8614 #  else
8615 #    define _weak_pragma(exp)
8616 #  endif
8617 #  define _declare(name)        __extension__ extern __typeof__(name) name
8618 #  define weak_symbol(name)     _weak_pragma(name) _declare(name) __attribute__((weak))
8619 #endif
8620
8621 weak_symbol(fopen);
8622 ],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
8623 ])
8624 ])dnl
8625 dnl ---------------------------------------------------------------------------
8626 dnl CF_WITH_ABI_VERSION version: 4 updated: 2021/01/01 13:31:04
8627 dnl -------------------
8628 dnl Allow library's ABI to be overridden.  Generally this happens when a
8629 dnl packager has incremented the ABI past that used in the original package,
8630 dnl and wishes to keep doing this.
8631 dnl
8632 dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
8633 dnl symbol.
8634 AC_DEFUN([CF_WITH_ABI_VERSION],[
8635 test -z "$cf_cv_abi_version" && cf_cv_abi_version=0
8636 AC_ARG_WITH(abi-version,
8637 [  --with-abi-version=XXX  override derived ABI version],[
8638         if test "x$cf_cv_abi_version" != "x$withval"
8639         then
8640                 AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
8641                 case "$cf_cv_rel_version" in
8642                 (5.*)
8643                         cf_cv_rel_version=$withval.0
8644                         ;;
8645                 (6.*)
8646                         cf_cv_rel_version=$withval.9    # FIXME: should be 10 as of 6.0 release
8647                         ;;
8648                 esac
8649         fi
8650         cf_cv_abi_version=$withval])
8651         CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
8652 ifelse($1,,,[
8653 $1_ABI=$cf_cv_abi_version
8654 ])
8655 ])dnl
8656 dnl ---------------------------------------------------------------------------
8657 dnl CF_WITH_ADA_COMPILER version: 2 updated: 2010/06/26 17:35:58
8658 dnl --------------------
8659 dnl Command-line option to specify the Ada95 compiler.
8660 AC_DEFUN([CF_WITH_ADA_COMPILER],[
8661 AC_MSG_CHECKING(for ada-compiler)
8662 AC_ARG_WITH(ada-compiler,
8663         [  --with-ada-compiler=CMD specify Ada95 compiler command (default gnatmake)],
8664         [cf_ada_compiler=$withval],
8665         [cf_ada_compiler=gnatmake])
8666 AC_SUBST(cf_ada_compiler)
8667 AC_MSG_RESULT($cf_ada_compiler)
8668 ])dnl
8669 dnl ---------------------------------------------------------------------------
8670 dnl CF_WITH_ADA_INCLUDE version: 2 updated: 2010/06/26 17:35:58
8671 dnl -------------------
8672 dnl Command-line option to specify where Ada includes will install.
8673 AC_DEFUN([CF_WITH_ADA_INCLUDE],[
8674 AC_MSG_CHECKING(for ada-include)
8675 CF_WITH_PATH(ada-include,
8676    [  --with-ada-include=DIR  Ada includes are in DIR],
8677    ADA_INCLUDE,
8678    PREFIX/share/ada/adainclude,
8679    [$]prefix/share/ada/adainclude)
8680 AC_SUBST(ADA_INCLUDE)
8681 AC_MSG_RESULT($ADA_INCLUDE)
8682 ])dnl
8683 dnl ---------------------------------------------------------------------------
8684 dnl CF_WITH_ADA_LIBNAME version: 1 updated: 2019/09/07 18:59:41
8685 dnl -------------------
8686 dnl CF_WITH_ADA_LIBNAME
8687 dnl -------------------
8688 dnl Command-line option to specify how to name the resulting Ada library.
8689 dnl $1 = default value
8690 AC_DEFUN([CF_WITH_ADA_LIBNAME],[
8691 AC_MSG_CHECKING(for ada-libname)
8692 AC_ARG_WITH(ada-libname,
8693    [  --with-ada-libname=XXX  override default Ada library-name],
8694    ADA_LIBNAME=[$]withval,
8695    ADA_LIBNAME=$1)
8696 case "x$ADA_LIBNAME" in
8697 (x|xyes|xno)
8698         ADA_LIBNAME=$1
8699         ;;
8700 esac
8701 AC_SUBST(ADA_LIBNAME)
8702 AC_MSG_RESULT($ADA_LIBNAME)
8703 ])dnl
8704 dnl ---------------------------------------------------------------------------
8705 dnl CF_WITH_ADA_OBJECTS version: 2 updated: 2010/06/26 17:35:58
8706 dnl -------------------
8707 dnl Command-line option to specify where Ada objects will install.
8708 AC_DEFUN([CF_WITH_ADA_OBJECTS],[
8709 AC_MSG_CHECKING(for ada-objects)
8710 CF_WITH_PATH(ada-objects,
8711    [  --with-ada-objects=DIR  Ada objects are in DIR],
8712    ADA_OBJECTS,
8713    PREFIX/lib/ada/adalib,
8714    [$]prefix/lib/ada/adalib)
8715 AC_SUBST(ADA_OBJECTS)
8716 AC_MSG_RESULT($ADA_OBJECTS)
8717 ])dnl
8718 dnl ---------------------------------------------------------------------------
8719 dnl CF_WITH_ADA_SHAREDLIB version: 5 updated: 2018/07/21 19:10:35
8720 dnl ---------------------
8721 dnl Command-line option to specify if an Ada95 shared-library should be built,
8722 dnl and optionally what its soname should be.
8723 AC_DEFUN([CF_WITH_ADA_SHAREDLIB],[
8724 AC_REQUIRE([CF_GNAT_PROJECTS])
8725 AC_MSG_CHECKING(if an Ada95 shared-library should be built)
8726 AC_ARG_WITH(ada-sharedlib,
8727         [  --with-ada-sharedlib=soname build shared-library (requires GNAT projects)],
8728         [with_ada_sharedlib=$withval],
8729         [with_ada_sharedlib=no])
8730 AC_MSG_RESULT($with_ada_sharedlib)
8731
8732 if test "x$with_ada_sharedlib" != xno
8733 then
8734         if test "x$cf_gnat_projects" != xyes
8735         then
8736                 AC_MSG_WARN(disabling shared-library since GNAT projects are not supported)
8737                 with_ada_sharedlib=no
8738         fi
8739 fi
8740
8741 ADA_SHAREDLIB='lib$(LIB_NAME).so.1'
8742 MAKE_ADA_SHAREDLIB="#"
8743
8744 if test "x$with_ada_sharedlib" != xno
8745 then
8746         MAKE_ADA_SHAREDLIB=
8747         if test "x$with_ada_sharedlib" != xyes
8748         then
8749                 ADA_SHAREDLIB="$with_ada_sharedlib"
8750         fi
8751 fi
8752
8753 AC_SUBST(ADA_SHAREDLIB)
8754 AC_SUBST(MAKE_ADA_SHAREDLIB)
8755 ])dnl
8756 dnl ---------------------------------------------------------------------------
8757 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
8758 dnl ----------------
8759 dnl Configure-option for dbmalloc.  The optional parameter is used to override
8760 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
8761 AC_DEFUN([CF_WITH_DBMALLOC],[
8762 CF_NO_LEAKS_OPTION(dbmalloc,
8763         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
8764         [USE_DBMALLOC])
8765
8766 if test "$with_dbmalloc" = yes ; then
8767         AC_CHECK_HEADER(dbmalloc.h,
8768                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
8769 fi
8770 ])dnl
8771 dnl ---------------------------------------------------------------------------
8772 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
8773 dnl ---------------
8774 dnl Configure-option for dmalloc.  The optional parameter is used to override
8775 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
8776 AC_DEFUN([CF_WITH_DMALLOC],[
8777 CF_NO_LEAKS_OPTION(dmalloc,
8778         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
8779         [USE_DMALLOC])
8780
8781 if test "$with_dmalloc" = yes ; then
8782         AC_CHECK_HEADER(dmalloc.h,
8783                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
8784 fi
8785 ])dnl
8786 dnl ---------------------------------------------------------------------------
8787 dnl CF_WITH_EXPORT_SYMS version: 3 updated: 2014/12/20 19:16:08
8788 dnl -------------------
8789 dnl Use this with libtool to specify the list of symbols that may be exported.
8790 dnl The input file contains one symbol per line; comments work with "#".
8791 dnl
8792 dnl $1 = basename of the ".sym" file (default $PACKAGE)
8793 AC_DEFUN([CF_WITH_EXPORT_SYMS],
8794 [
8795 AC_MSG_CHECKING(if exported-symbols file should be used)
8796 AC_ARG_WITH(export-syms,
8797         [  --with-export-syms=XXX  limit exported symbols using libtool],
8798         [with_export_syms=$withval],
8799         [with_export_syms=no])
8800 if test "x$with_export_syms" = xyes
8801 then
8802         with_export_syms='${top_srcdir}/package/ifelse($1,,${PACKAGE},[$1]).sym'
8803         AC_SUBST(PACKAGE)
8804 fi
8805 AC_MSG_RESULT($with_export_syms)
8806 if test "x$with_export_syms" != xno
8807 then
8808         EXPORT_SYMS="-export-symbols $with_export_syms"
8809         AC_SUBST(EXPORT_SYMS)
8810 fi
8811 ])dnl
8812 dnl ---------------------------------------------------------------------------
8813 dnl CF_WITH_GPM version: 10 updated: 2017/04/29 18:32:18
8814 dnl -----------
8815 dnl
8816 dnl The option parameter (if neither yes/no) is assumed to be the name of
8817 dnl the gpm library, e.g., for dynamic loading.
8818 AC_DEFUN([CF_WITH_GPM],
8819 [
8820 AC_MSG_CHECKING(if you want to link with the GPM mouse library)
8821 AC_ARG_WITH(gpm,
8822         [  --with-gpm              use Alessandro Rubini's GPM library],
8823         [with_gpm=$withval],
8824         [with_gpm=maybe])
8825 AC_MSG_RESULT($with_gpm)
8826
8827 if test "$with_gpm" != no ; then
8828         AC_CHECK_HEADER(gpm.h,[
8829                 AC_DEFINE(HAVE_GPM_H,1,[Define to 1 if we have gpm.h header])
8830                 if test "$with_gpm" != yes && test "$with_gpm" != maybe ; then
8831                         CF_VERBOSE(assuming we really have GPM library)
8832                         AC_DEFINE(HAVE_LIBGPM,1,[Define to 1 if we have the gpm library])
8833                         with_gpm=yes
8834                 else
8835                         AC_CHECK_LIB(gpm,Gpm_Open,[with_gpm=yes],[
8836                                 if test "$with_gpm" = maybe; then
8837                                         AC_MSG_WARN(Cannot link with GPM library)
8838                                         with_gpm=no
8839                                 else
8840                                         AC_MSG_ERROR(Cannot link with GPM library)
8841                                 fi
8842                         ])
8843                 fi
8844         ],[
8845                 test "$with_gpm" != maybe && AC_MSG_WARN(Cannot find GPM header)
8846                 with_gpm=no
8847         ])
8848 fi
8849 ])
8850 dnl ---------------------------------------------------------------------------
8851 dnl CF_WITH_LIBTOOL version: 36 updated: 2021/01/01 13:31:04
8852 dnl ---------------
8853 dnl Provide a configure option to incorporate libtool.  Define several useful
8854 dnl symbols for the makefile rules.
8855 dnl
8856 dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
8857 dnl macros from libtool.m4 which is in the aclocal directory of automake.
8858 dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
8859 dnl But that still does not work properly since the macro is expanded outside
8860 dnl the CF_WITH_LIBTOOL macro:
8861 dnl
8862 dnl     #!/bin/sh
8863 dnl     ACLOCAL=`aclocal --print-ac-dir`
8864 dnl     if test -z "$ACLOCAL" ; then
8865 dnl             echo cannot find aclocal directory
8866 dnl             exit 1
8867 dnl     elif test ! -f $ACLOCAL/libtool.m4 ; then
8868 dnl             echo cannot find libtool.m4 file
8869 dnl             exit 1
8870 dnl     fi
8871 dnl
8872 dnl     LOCAL=aclocal.m4
8873 dnl     ORIG=aclocal.m4.orig
8874 dnl
8875 dnl     trap "mv $ORIG $LOCAL" 0 1 2 3 15
8876 dnl     rm -f $ORIG
8877 dnl     mv $LOCAL $ORIG
8878 dnl
8879 dnl     # sed the LIBTOOL= assignment to omit the current directory?
8880 dnl     sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL:-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
8881 dnl     cat $ORIG >>$LOCAL
8882 dnl
8883 dnl     autoconf-257 $*
8884 dnl
8885 AC_DEFUN([CF_WITH_LIBTOOL],
8886 [
8887 AC_REQUIRE([CF_DISABLE_LIBTOOL_VERSION])
8888 ifdef([AC_PROG_LIBTOOL],,[
8889 LIBTOOL=
8890 ])
8891 # common library maintenance symbols that are convenient for libtool scripts:
8892 LIB_CREATE='${AR} -cr'
8893 LIB_OBJECT='${OBJECTS}'
8894 LIB_SUFFIX=.a
8895 LIB_PREP="$RANLIB"
8896
8897 # symbols used to prop libtool up to enable it to determine what it should be
8898 # doing:
8899 LIB_CLEAN=
8900 LIB_COMPILE=
8901 LIB_LINK='${CC}'
8902 LIB_INSTALL=
8903 LIB_UNINSTALL=
8904
8905 AC_MSG_CHECKING(if you want to build libraries with libtool)
8906 AC_ARG_WITH(libtool,
8907         [  --with-libtool          generate libraries with libtool],
8908         [with_libtool=$withval],
8909         [with_libtool=no])
8910 AC_MSG_RESULT($with_libtool)
8911 if test "$with_libtool" != "no"; then
8912 ifdef([AC_PROG_LIBTOOL],[
8913         # missing_content_AC_PROG_LIBTOOL{{
8914         AC_PROG_LIBTOOL
8915         # missing_content_AC_PROG_LIBTOOL}}
8916 ],[
8917         if test "$with_libtool" != "yes" ; then
8918                 CF_PATH_SYNTAX(with_libtool)
8919                 LIBTOOL=$with_libtool
8920         else
8921                 AC_CHECK_TOOLS(LIBTOOL,[libtool glibtool],none)
8922                 CF_LIBTOOL_VERSION
8923                 if test -z "$cf_cv_libtool_version" && test "$LIBTOOL" = libtool
8924                 then
8925                         CF_FORGET_TOOL(LIBTOOL)
8926                         AC_CHECK_TOOLS(LIBTOOL,[glibtool],none)
8927                         CF_LIBTOOL_VERSION
8928                 fi
8929         fi
8930         if test -z "$LIBTOOL" ; then
8931                 AC_MSG_ERROR(Cannot find libtool)
8932         fi
8933 ])dnl
8934         LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${libdir} ${LIBTOOL_VERSION} `cut -f1 ${top_srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} $(LIBS) -o'
8935         LIB_OBJECT='${OBJECTS:.o=.lo}'
8936         LIB_SUFFIX=.la
8937         LIB_CLEAN='${LIBTOOL} --mode=clean'
8938         LIB_COMPILE='${LIBTOOL} --mode=compile'
8939         LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
8940         LIB_INSTALL='${LIBTOOL} --mode=install'
8941         LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
8942         LIB_PREP=:
8943
8944         CF_CHECK_LIBTOOL_VERSION
8945
8946         # special hack to add -no-undefined (which libtool should do for itself)
8947         LT_UNDEF=
8948         case "$cf_cv_system_name" in
8949         (cygwin*|msys*|mingw32*|os2*|uwin*|aix[[4-7]])
8950                 LT_UNDEF=-no-undefined
8951                 ;;
8952         esac
8953         AC_SUBST([LT_UNDEF])
8954
8955         # special hack to add --tag option for C++ compiler
8956         case "$cf_cv_libtool_version" in
8957         (1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*)
8958                 LIBTOOL_CXX="$LIBTOOL --tag=CXX"
8959                 LIBTOOL="$LIBTOOL --tag=CC"
8960                 ;;
8961         (*)
8962                 LIBTOOL_CXX="$LIBTOOL"
8963                 ;;
8964         esac
8965 else
8966         LIBTOOL=""
8967         LIBTOOL_CXX=""
8968 fi
8969
8970 test -z "$LIBTOOL" && ECHO_LT=
8971
8972 AC_SUBST(LIBTOOL)
8973 AC_SUBST(LIBTOOL_CXX)
8974 AC_SUBST(LIBTOOL_OPTS)
8975
8976 AC_SUBST(LIB_CREATE)
8977 AC_SUBST(LIB_OBJECT)
8978 AC_SUBST(LIB_SUFFIX)
8979 AC_SUBST(LIB_PREP)
8980
8981 AC_SUBST(LIB_CLEAN)
8982 AC_SUBST(LIB_COMPILE)
8983 AC_SUBST(LIB_LINK)
8984 AC_SUBST(LIB_INSTALL)
8985 AC_SUBST(LIB_UNINSTALL)
8986
8987 ])dnl
8988 dnl ---------------------------------------------------------------------------
8989 dnl CF_WITH_LIBTOOL_OPTS version: 4 updated: 2015/04/17 21:13:04
8990 dnl --------------------
8991 dnl Allow user to pass additional libtool options into the library creation
8992 dnl and link steps.  The main use for this is to do something like
8993 dnl     ./configure --with-libtool-opts=-static
8994 dnl to get the same behavior as automake-flavored
8995 dnl     ./configure --enable-static
8996 AC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
8997 AC_MSG_CHECKING(for additional libtool options)
8998 AC_ARG_WITH(libtool-opts,
8999         [  --with-libtool-opts=XXX specify additional libtool options],
9000         [with_libtool_opts=$withval],
9001         [with_libtool_opts=no])
9002 AC_MSG_RESULT($with_libtool_opts)
9003
9004 case .$with_libtool_opts in
9005 (.yes|.no|.)
9006         ;;
9007 (*)
9008         LIBTOOL_OPTS="$LIBTOOL_OPTS $with_libtool_opts"
9009         ;;
9010 esac
9011
9012 AC_SUBST(LIBTOOL_OPTS)
9013 ])dnl
9014 dnl ---------------------------------------------------------------------------
9015 dnl CF_WITH_LIB_BASENAME version: 1 updated: 2020/03/07 20:05:14
9016 dnl --------------------
9017 dnl Allow for overriding the basename of a library, i.e., the part to which
9018 dnl prefixes/suffixes are attached.
9019 dnl
9020 dnl $1 = variable to set
9021 dnl $2 = option name
9022 dnl $3 = default basename for library, if omitted use $2
9023 AC_DEFUN([CF_WITH_LIB_BASENAME],
9024 [
9025 AC_MSG_CHECKING(for desired basename for $2 library)
9026 AC_ARG_WITH($2-libname,
9027         [  --with-$2-libname=XXX override ifelse($3,,$2,$3) basename of library],
9028         [with_lib_basename=$withval],
9029         [with_lib_basename=ifelse($3,,$2,$3)])
9030 $1="$with_lib_basename"
9031
9032 case "x[$]$1" in
9033 (x|xno|xnone|xyes)
9034         $1=ifelse($3,,$2,$3)
9035         ;;
9036 (*)
9037         ;;
9038 esac
9039
9040 AC_MSG_RESULT([$]$1)
9041 AC_SUBST($1)
9042 ])dnl
9043 dnl ---------------------------------------------------------------------------
9044 dnl CF_WITH_LIB_PREFIX version: 2 updated: 2021/01/01 16:53:59
9045 dnl ------------------
9046 dnl Allow the library-prefix to be overridden.  OS/2 EMX originally had no
9047 dnl "lib" prefix, e.g., because it used the dll naming convention.
9048 dnl
9049 dnl $1 = variable to set
9050 AC_DEFUN([CF_WITH_LIB_PREFIX],
9051 [
9052 AC_MSG_CHECKING(if you want to have a library-prefix)
9053 AC_ARG_WITH(lib-prefix,
9054         [  --with-lib-prefix       override library-prefix],
9055         [with_lib_prefix=$withval],
9056         [with_lib_prefix=auto])
9057 AC_MSG_RESULT($with_lib_prefix)
9058
9059 if test "$with_lib_prefix" = auto
9060 then
9061         CF_LIB_PREFIX($1)
9062 elif test "$with_lib_prefix" = no
9063 then
9064         LIB_PREFIX=
9065 else
9066         LIB_PREFIX=$with_lib_prefix
9067 fi
9068 ])dnl
9069 dnl ---------------------------------------------------------------------------
9070 dnl CF_WITH_PATH version: 12 updated: 2021/09/04 06:35:04
9071 dnl ------------
9072 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
9073 dnl defaulting to yes/no.
9074 dnl
9075 dnl $1 = option name
9076 dnl $2 = help-text
9077 dnl $3 = environment variable to set
9078 dnl $4 = default value, shown in the help-message, must be a constant
9079 dnl $5 = default value, if it is an expression & cannot be in the help-message
9080 dnl
9081 AC_DEFUN([CF_WITH_PATH],
9082 [AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
9083 ifelse([$4],,[withval="${$3}"],[withval="${$3:-ifelse([$5],,[$4],[$5])}"]))dnl
9084 if ifelse([$5],,true,[test -n "$5"]) ; then
9085 CF_PATH_SYNTAX(withval)
9086 fi
9087 eval $3="$withval"
9088 AC_SUBST($3)dnl
9089 ])dnl
9090 dnl ---------------------------------------------------------------------------
9091 dnl CF_WITH_PATHLIST version: 13 updated: 2021/09/04 06:35:04
9092 dnl ----------------
9093 dnl Process an option specifying a list of colon-separated paths.
9094 dnl
9095 dnl $1 = option name
9096 dnl $2 = help-text
9097 dnl $3 = environment variable to set
9098 dnl $4 = default value, shown in the help-message, must be a constant
9099 dnl $5 = default value, if it is an expression & cannot be in the help-message
9100 dnl $6 = flag to tell if we want to define or substitute
9101 dnl
9102 AC_DEFUN([CF_WITH_PATHLIST],[
9103 AC_REQUIRE([CF_PATHSEP])
9104 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
9105 ifelse($4,,[withval=${$3}],[withval=${$3:-ifelse($5,,$4,$5)}]))dnl
9106
9107 IFS="${IFS:-    }"; ac_save_ifs="$IFS"; IFS="${PATH_SEPARATOR}"
9108 cf_dst_path=
9109 for cf_src_path in $withval
9110 do
9111   CF_PATH_SYNTAX(cf_src_path)
9112   test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}$PATH_SEPARATOR"
9113   cf_dst_path="${cf_dst_path}${cf_src_path}"
9114 done
9115 IFS="$ac_save_ifs"
9116
9117 ifelse($6,define,[
9118 # Strip single quotes from the value, e.g., when it was supplied as a literal
9119 # for $4 or $5.
9120 case "$cf_dst_path" in
9121 (\'*)
9122   cf_dst_path="`echo "$cf_dst_path" |sed -e s/\'// -e s/\'\$//`"
9123   ;;
9124 esac
9125 cf_dst_path=`echo "$cf_dst_path" | sed -e 's/\\\\/\\\\\\\\/g'`
9126 ])
9127
9128 # This may use the prefix/exec_prefix symbols which will only yield "NONE"
9129 # so we have to check/work around.  We do prefer the result of "eval"...
9130 eval cf_dst_eval="$cf_dst_path"
9131 case "x$cf_dst_eval" in
9132 (xNONE*)
9133         $3=$cf_dst_path
9134         ;;
9135 (*)
9136         $3="$cf_dst_eval"
9137         ;;
9138 esac
9139 AC_SUBST($3)dnl
9140
9141 ])dnl
9142 dnl ---------------------------------------------------------------------------
9143 dnl CF_WITH_PATH_PROG version: 1 updated: 2019/06/30 19:44:43
9144 dnl -----------------
9145 dnl Check for a given program, like CF_PATH_PROG, but allow override using a
9146 dnl "--with-xxx" option.
9147 dnl
9148 dnl Parameters:
9149 dnl             $1 = environment variable to set/update
9150 dnl             $2 = program name
9151 dnl             $3 = help-text
9152 dnl             $4 = $PATH
9153 AC_DEFUN([CF_WITH_PATH_PROG],[
9154 AC_ARG_WITH($2-path,
9155         [  --with-$2-path=XXX     specify path of $2 ifelse($3,,,$3)],
9156         [AC_MSG_CHECKING(for $2 program ifelse($3,,,$3))
9157                 $1=$withval
9158                 AC_MSG_RESULT([$]$1)
9159                 CF_PATH_SYNTAX($1)
9160         ],
9161         [CF_PATH_PROG($1,$2,,ifelse($4,,,$4))
9162                 if test -z "[$]$1"
9163                 then
9164                         AC_MSG_WARN(no $2 program found ifelse($3,,,$3))
9165                 fi
9166         ])
9167 ])
9168 dnl ---------------------------------------------------------------------------
9169 dnl CF_WITH_PCRE2 version: 6 updated: 2021/08/11 20:35:34
9170 dnl -------------
9171 dnl Add PCRE2 (Perl-compatible regular expressions v2) to the build if it is
9172 dnl available and the user requests it.  Assume the application will otherwise
9173 dnl use the POSIX interface.
9174 dnl
9175 dnl TODO allow $withval to specify package location
9176 AC_DEFUN([CF_WITH_PCRE2],
9177 [
9178 AC_REQUIRE([CF_PKG_CONFIG])
9179
9180 AC_MSG_CHECKING(if you want to use PCRE2 for regular-expressions)
9181 AC_ARG_WITH(pcre2,
9182         [  --with-pcre2            use PCRE2 for regular-expressions])
9183 test -z "$with_pcre2" && with_pcre2=no
9184 AC_MSG_RESULT($with_pcre2)
9185
9186 if test "x$with_pcre2" != xno ; then
9187         cf_with_pcre2_ok=no
9188         for cf_with_pcre2 in libpcre2 libpcre2-posix libpcre
9189         do
9190                 CF_TRY_PKG_CONFIG($cf_with_pcre2,[cf_with_pcre2_ok=yes; break])
9191         done
9192         cf_with_pcre2_ok=yes || AC_MSG_ERROR(Cannot find PCRE2 library)
9193
9194         AC_DEFINE(HAVE_LIB_PCRE2,1,[Define to 1 if we can/should compile with the PCRE2 library])
9195
9196         # if pkgconfig gave no results, look for the libraries directly
9197         case "$LIBS" in
9198         (*pcre2-posix*|*pcreposix*)
9199                 ;;
9200         (*)
9201                 AC_CHECK_LIB(pcre2-posix,regcomp,[
9202                         CF_ADD_LIB(pcre2-posix)],
9203                         [AC_CHECK_LIB(pcreposix,regcomp,[
9204                          CF_ADD_LIB(pcreposix)
9205                         ],[AC_MSG_ERROR(Cannot find PCRE2 POSIX library)])])
9206                 ;;
9207         esac
9208
9209         # either way, check for the library header files
9210         AC_CHECK_HEADERS(pcre2posix.h pcreposix.h)
9211         AC_CHECK_FUNCS(PCRE2regcomp)
9212 fi
9213 ])dnl
9214 dnl ---------------------------------------------------------------------------
9215 dnl CF_WITH_PKG_CONFIG_LIBDIR version: 11 updated: 2021/01/01 16:16:30
9216 dnl -------------------------
9217 dnl Allow the choice of the pkg-config library directory to be overridden.
9218 AC_DEFUN([CF_WITH_PKG_CONFIG_LIBDIR],[
9219
9220 case "$PKG_CONFIG" in
9221 (no|none|yes)
9222         AC_MSG_CHECKING(for pkg-config library directory)
9223         ;;
9224 (*)
9225         AC_MSG_CHECKING(for $PKG_CONFIG library directory)
9226         ;;
9227 esac
9228
9229 PKG_CONFIG_LIBDIR=no
9230 AC_ARG_WITH(pkg-config-libdir,
9231         [  --with-pkg-config-libdir=XXX use given directory for installing pc-files],
9232         [PKG_CONFIG_LIBDIR=$withval],
9233         [test "x$PKG_CONFIG" != xnone && PKG_CONFIG_LIBDIR=yes])
9234
9235 case x$PKG_CONFIG_LIBDIR in
9236 (x/*)
9237         ;;
9238 (xyes)
9239         # Look for the library directory using the same prefix as the executable
9240         if test "x$PKG_CONFIG" = xnone
9241         then
9242                 cf_path=$prefix
9243         else
9244                 cf_path=`echo "$PKG_CONFIG" | sed -e 's,/[[^/]]*/[[^/]]*$,,'`
9245         fi
9246
9247         # If you don't like using the default architecture, you have to specify the
9248         # intended library directory and corresponding compiler/linker options.
9249         #
9250         # This case allows for Debian's 2014-flavor of multiarch, along with the
9251         # most common variations before that point.  Some other variants spell the
9252         # directory differently, e.g., "pkg-config", and put it in unusual places.
9253         # pkg-config has always been poorly standardized, which is ironic...
9254         case x`(arch) 2>/dev/null` in
9255         (*64)
9256                 cf_search_path="\
9257                         $cf_path/lib/*64-linux-gnu \
9258                         $cf_path/share \
9259                         $cf_path/lib64 \
9260                         $cf_path/lib32 \
9261                         $cf_path/lib"
9262                 ;;
9263         (*)
9264                 cf_search_path="\
9265                         $cf_path/lib/*-linux-gnu \
9266                         $cf_path/share \
9267                         $cf_path/lib32 \
9268                         $cf_path/lib \
9269                         $cf_path/libdata"
9270                 ;;
9271         esac
9272
9273         CF_VERBOSE(list...)
9274         for cf_config in $cf_search_path
9275         do
9276                 CF_VERBOSE(checking $cf_config/pkgconfig)
9277                 if test -d "$cf_config/pkgconfig"
9278                 then
9279                         PKG_CONFIG_LIBDIR=$cf_config/pkgconfig
9280                         AC_MSG_CHECKING(done)
9281                         break
9282                 fi
9283         done
9284         ;;
9285 (*)
9286         ;;
9287 esac
9288
9289 if test "x$PKG_CONFIG_LIBDIR" != xno ; then
9290         AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
9291 fi
9292
9293 AC_SUBST(PKG_CONFIG_LIBDIR)
9294 ])dnl
9295 dnl ---------------------------------------------------------------------------
9296 dnl CF_WITH_PTHREAD version: 7 updated: 2015/04/18 08:56:57
9297 dnl ---------------
9298 dnl Check for POSIX thread library.
9299 AC_DEFUN([CF_WITH_PTHREAD],
9300 [
9301 AC_MSG_CHECKING(if you want to link with the pthread library)
9302 AC_ARG_WITH(pthread,
9303         [  --with-pthread          use POSIX thread library],
9304         [with_pthread=$withval],
9305         [with_pthread=no])
9306 AC_MSG_RESULT($with_pthread)
9307
9308 if test "$with_pthread" != no ; then
9309         AC_CHECK_HEADER(pthread.h,[
9310         AC_DEFINE(HAVE_PTHREADS_H,1,[Define to 1 if we have pthreads.h header])
9311
9312         for cf_lib_pthread in pthread c_r
9313         do
9314             AC_MSG_CHECKING(if we can link with the $cf_lib_pthread library)
9315             cf_save_LIBS="$LIBS"
9316             CF_ADD_LIB($cf_lib_pthread)
9317             AC_TRY_LINK([
9318 #include <pthread.h>
9319 ],[
9320                 int rc = pthread_create(0,0,0,0);
9321                 int r2 = pthread_mutexattr_settype(0, 0);
9322 ],[with_pthread=yes],[with_pthread=no])
9323             LIBS="$cf_save_LIBS"
9324             AC_MSG_RESULT($with_pthread)
9325             test "$with_pthread" = yes && break
9326         done
9327
9328         if test "$with_pthread" = yes ; then
9329             CF_ADD_LIB($cf_lib_pthread)
9330             AC_DEFINE(HAVE_LIBPTHREADS,1,[Define to 1 if we have pthreads library])
9331         else
9332             AC_MSG_ERROR(Cannot link with pthread library)
9333         fi
9334         ])
9335 fi
9336 ])
9337 dnl ---------------------------------------------------------------------------
9338 dnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
9339 dnl -------------------
9340 dnl Allow library's release-version to be overridden.  Generally this happens when a
9341 dnl packager has incremented the release-version past that used in the original package,
9342 dnl and wishes to keep doing this.
9343 dnl
9344 dnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
9345 dnl and {package}_MINOR symbols
9346 dnl symbol.
9347 AC_DEFUN([CF_WITH_REL_VERSION],[
9348 test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
9349 AC_ARG_WITH(rel-version,
9350 [  --with-rel-version=XXX  override derived release version],
9351 [AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
9352  cf_cv_rel_version=$withval])
9353 ifelse($1,,[
9354  CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
9355 ],[
9356  $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
9357  $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
9358  CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
9359  CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
9360 ])
9361 ])dnl
9362 dnl ---------------------------------------------------------------------------
9363 dnl CF_WITH_SYSMOUSE version: 3 updated: 2012/10/06 17:56:13
9364 dnl ----------------
9365 dnl If we can compile with sysmouse, make it available unless it is not wanted.
9366 AC_DEFUN([CF_WITH_SYSMOUSE],[
9367 # not everyone has "test -c"
9368 if test -c /dev/sysmouse 2>/dev/null ; then
9369 AC_MSG_CHECKING(if you want to use sysmouse)
9370 AC_ARG_WITH(sysmouse,
9371         [  --with-sysmouse         use sysmouse (FreeBSD console)],
9372         [cf_with_sysmouse=$withval],
9373         [cf_with_sysmouse=maybe])
9374         if test "$cf_with_sysmouse" != no ; then
9375         AC_TRY_COMPILE([
9376 #include <osreldate.h>
9377 #if (__FreeBSD_version >= 400017)
9378 #include <sys/consio.h>
9379 #include <sys/fbio.h>
9380 #else
9381 #include <machine/console.h>
9382 #endif
9383 ],[
9384         struct mouse_info the_mouse;
9385         ioctl(0, CONS_MOUSECTL, &the_mouse);
9386 ],[cf_with_sysmouse=yes],[cf_with_sysmouse=no])
9387         fi
9388 AC_MSG_RESULT($cf_with_sysmouse)
9389 test "$cf_with_sysmouse" = yes && AC_DEFINE(USE_SYSMOUSE,1,[Define to 1 if we can/should use the sysmouse interface])
9390 fi
9391 ])dnl
9392 dnl ---------------------------------------------------------------------------
9393 dnl CF_WITH_SYSTYPE version: 1 updated: 2013/01/26 16:26:12
9394 dnl ---------------
9395 dnl For testing, override the derived host system-type which is used to decide
9396 dnl things such as the linker commands used to build shared libraries.  This is
9397 dnl normally chosen automatically based on the type of system which you are
9398 dnl building on.  We use it for testing the configure script.
9399 dnl
9400 dnl This is different from the --host option: it is used only for testing parts
9401 dnl of the configure script which would not be reachable with --host since that
9402 dnl relies on the build environment being real, rather than mocked up.
9403 AC_DEFUN([CF_WITH_SYSTYPE],[
9404 CF_CHECK_CACHE([AC_CANONICAL_SYSTEM])
9405 AC_ARG_WITH(system-type,
9406         [  --with-system-type=XXX  test: override derived host system-type],
9407 [AC_MSG_WARN(overriding system type to $withval)
9408         cf_cv_system_name=$withval
9409         host_os=$withval
9410 ])
9411 ])dnl
9412 dnl ---------------------------------------------------------------------------
9413 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
9414 dnl ----------------
9415 AC_DEFUN([CF_WITH_VALGRIND],[
9416 CF_NO_LEAKS_OPTION(valgrind,
9417         [  --with-valgrind         test: use valgrind],
9418         [USE_VALGRIND])
9419 ])dnl
9420 dnl ---------------------------------------------------------------------------
9421 dnl CF_WITH_VERSIONED_SYMS version: 10 updated: 2021/01/04 18:48:01
9422 dnl ----------------------
9423 dnl Use this when building shared library with ELF, to markup symbols with the
9424 dnl version identifier from the given input file.  Generally that identifier is
9425 dnl the same as the SONAME at which the symbol was first introduced.
9426 dnl
9427 dnl $1 = basename of the ".map" file (default $PACKAGE)
9428 AC_DEFUN([CF_WITH_VERSIONED_SYMS],
9429 [AC_REQUIRE([AC_PROG_FGREP])dnl
9430 AC_REQUIRE([AC_PROG_EGREP])dnl
9431
9432 AC_MSG_CHECKING(if versioned-symbols file should be used)
9433 AC_ARG_WITH(versioned-syms,
9434         [  --with-versioned-syms=X markup versioned symbols using ld],
9435         [with_versioned_syms=$withval],
9436         [with_versioned_syms=no])
9437 case "x$with_versioned_syms" in
9438 (xyes)
9439         with_versioned_syms='${top_srcdir}/package/ifelse($1,,${PACKAGE},[$1]).map'
9440         AC_SUBST(PACKAGE)
9441         ;;
9442 (xno)
9443         ;;
9444 (x/*)
9445         test -f "$with_versioned_syms" || AC_MSG_ERROR(expected a filename: $with_versioned_syms)
9446         ;;
9447 (*)
9448         test -f "$with_versioned_syms" || AC_MSG_ERROR(expected a filename: $with_versioned_syms)
9449         with_versioned_syms=`pwd`/"$with_versioned_syms"
9450         ;;
9451 esac
9452 AC_MSG_RESULT($with_versioned_syms)
9453
9454 RESULTING_SYMS=
9455 VERSIONED_SYMS=
9456 WILDCARD_SYMS=
9457
9458 if test "x$with_versioned_syms" != xno
9459 then
9460         RESULTING_SYMS=$with_versioned_syms
9461         case "x$MK_SHARED_LIB" in
9462         (*-Wl,*)
9463                 VERSIONED_SYMS="-Wl,--version-script,\${RESULTING_SYMS}"
9464                 MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-Wl,%\\[$]{VERSIONED_SYMS} -Wl,%"`
9465                 CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
9466                 ;;
9467         (*-dy\ *)
9468                 VERSIONED_SYMS="-Wl,-M,\${RESULTING_SYMS}"
9469                 MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-dy%\\[$]{VERSIONED_SYMS} -dy%"`
9470                 CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
9471                 ;;
9472         (*)
9473                 AC_MSG_WARN(this system does not support versioned-symbols)
9474                 ;;
9475         esac
9476
9477         # Linux ld can selectively override scope, e.g., of symbols beginning with
9478         # "_" by first declaring some as global, and then using a wildcard to
9479         # declare the others as local.  Some other loaders cannot do this.  Check
9480         # by constructing a (very) simple shared library and inspecting its
9481         # symbols.
9482         if test "x$VERSIONED_SYMS" != "x"
9483         then
9484                 AC_MSG_CHECKING(if wildcards can be used to selectively omit symbols)
9485                 WILDCARD_SYMS=no
9486
9487                 # make sources
9488                 rm -f conftest.*
9489
9490                 cat >conftest.ver <<EOF
9491 module_1.0 {
9492 global:
9493         globalf1;
9494 local:
9495         localf1;
9496 };
9497 module_2.0 {
9498 global:
9499         globalf2;
9500 local:
9501         localf2;
9502         _*;
9503 } module_1.0;
9504 submodule_1.0 {
9505 global:
9506         subglobalf1;
9507         _ismissing;
9508 local:
9509         sublocalf1;
9510 };
9511 submodule_2.0 {
9512 global:
9513         subglobalf2;
9514 local:
9515         sublocalf2;
9516         _*;
9517 } submodule_1.0;
9518 EOF
9519                 cat >conftest.$ac_ext <<EOF
9520 #line __oline__ "configure"
9521 int     _ismissing(void) { return 1; }
9522 int     _localf1(void) { return 1; }
9523 int     _localf2(void) { return 2; }
9524 int     globalf1(void) { return 1; }
9525 int     globalf2(void) { return 2; }
9526 int     _sublocalf1(void) { return 1; }
9527 int     _sublocalf2(void) { return 2; }
9528 int     subglobalf1(void) { return 1; }
9529 int     subglobalf2(void) { return 2; }
9530 EOF
9531                 cat >conftest.mk <<EOF
9532 CC=${CC}
9533 CFLAGS=${CFLAGS}
9534 CPPFLAGS=${CPPFLAGS}
9535 LDFLAGS=${LDFLAGS}
9536 LIBS=${LIBS}
9537 VERSIONED_SYMS=${VERSIONED_SYMS}
9538 RESULTING_SYMS=conftest.ver
9539 MK_SHARED_LIB=${MK_SHARED_LIB}
9540 conftest.so: conftest.$ac_cv_objext
9541                 \$(MK_SHARED_LIB) conftest.$ac_cv_objext
9542 EOF
9543
9544                 # compile source, make library
9545                 if make -f conftest.mk 2>&AC_FD_CC >/dev/null
9546                 then
9547                         # test for missing symbol in either Data or Text section
9548                         cf_missing="`nm -P conftest.so 2>&AC_FD_CC |${FGREP-fgrep} _ismissing | ${EGREP-egrep} '[[      ]][[DT]][[      ]]'`"
9549                         test -n "$cf_missing" && WILDCARD_SYMS=yes
9550                 fi
9551                 AC_MSG_RESULT($WILDCARD_SYMS)
9552                 rm -f conftest.*
9553         fi
9554 fi
9555 AC_SUBST(RESULTING_SYMS)
9556 AC_SUBST(VERSIONED_SYMS)
9557 AC_SUBST(WILDCARD_SYMS)
9558 ])dnl
9559 dnl ---------------------------------------------------------------------------
9560 dnl CF_WITH_X11_RGB version: 2 updated: 2019/12/31 08:53:54
9561 dnl ---------------
9562 dnl Handle configure option "--with-x11-rgb", setting these shell
9563 dnl variables:
9564 dnl
9565 dnl $RGB_PATH is the option value, used for finding the X11 rgb file.
9566 dnl $no_x11_rgb is a "#" (comment) if "--without-x11-rgb" is given.
9567 dnl
9568 dnl Most Linux's use this:
9569 dnl     /usr/share/X11/rgb.txt
9570 dnl Debian uses this:
9571 dnl     /etc/X11/rgb.txt
9572 dnl DragonFlyBSD ports uses this:
9573 dnl     /usr/pkg/lib/X11/rgb.txt
9574 dnl FreeBSD ports use these:
9575 dnl     /usr/local/lib/X11/rgb.txt
9576 dnl     /usr/local/share/X11/rgb.txt
9577 dnl Mandriva has these:
9578 dnl     /usr/lib/X11/rgb.txt
9579 dnl     /usr/lib64/X11/rgb.txt
9580 dnl NetBSD has these
9581 dnl     /usr/X11R7/lib/X11/rgb.txt
9582 dnl OpenSolaris uses
9583 dnl     32-bit:
9584 dnl     /usr/X11/etc/X11/rgb.txt
9585 dnl     /usr/X11/share/X11/rgb.txt
9586 dnl     /usr/X11/lib/X11/rgb.txt
9587 dnl OSX uses
9588 dnl             /opt/local/share/X11/rgb.txt (MacPorts)
9589 dnl             /opt/X11/share/X11/rgb.txt (non-ports)
9590 dnl     64-bit:
9591 dnl     /usr/X11/etc/X11/rgb.txt
9592 dnl     /usr/X11/share/X11/rgb.txt (perhaps)
9593 dnl     /usr/X11/lib/amd64/X11/rgb.txt
9594 dnl Solaris10 uses (in this order):
9595 dnl     /usr/openwin/lib/X11/rgb.txt
9596 dnl     /usr/X11/lib/X11/rgb.txt
9597 AC_DEFUN([CF_WITH_X11_RGB],[
9598 AC_MSG_CHECKING(for X11 rgb file)
9599 AC_ARG_WITH(x11-rgb,
9600         [  --with-x11-rgb=FILE   file containing X11 rgb information (EPREFIX/lib/X11/rgb.txt)],
9601         [RGB_PATH=$withval],
9602         [RGB_PATH=auto])
9603
9604 if test "x[$]RGB_PATH" = xauto
9605 then
9606         RGB_PATH='${exec_prefix}/lib/X11/rgb.txt'
9607         for cf_path in \
9608                 /opt/local/share/X11/rgb.txt \
9609                 /opt/X11/share/X11/rgb.txt \
9610                 /usr/share/X11/rgb.txt \
9611                 /usr/X11/share/X11/rgb.txt \
9612                 /usr/X11/lib/X11/rgb.txt \
9613                 /usr/lib/X11/rgb.txt \
9614                 /etc/X11/rgb.txt \
9615                 /usr/pkg/lib/X11/rgb.txt \
9616                 /usr/X11R7/lib/X11/rgb.txt \
9617                 /usr/X11R6/lib/X11/rgb.txt \
9618                 /usr/X11R5/lib/X11/rgb.txt \
9619                 /usr/X11R4/lib/X11/rgb.txt \
9620                 /usr/local/lib/X11/rgb.txt \
9621                 /usr/local/share/X11/rgb.txt \
9622                 /usr/lib64/X11/rgb.txt
9623         do
9624                 if test -f "$cf_path" ; then
9625                         RGB_PATH="$cf_path"
9626                         break
9627                 fi
9628         done
9629 else
9630         cf_path=$RGB_PATH
9631         CF_PATH_SYNTAX(cf_path)
9632 fi
9633
9634 AC_MSG_RESULT($RGB_PATH)
9635 AC_SUBST(RGB_PATH)
9636 AC_DEFINE_UNQUOTED(RGB_PATH,"$cf_path",[Define to the full pathname of rgb.txt])
9637
9638 no_x11_rgb=
9639 if test "$RGB_PATH" = no
9640 then
9641         no_x11_rgb="#"
9642 fi
9643 AC_SUBST(no_x11_rgb)
9644 ])dnl
9645 dnl ---------------------------------------------------------------------------
9646 dnl CF_XOPEN_SOURCE version: 59 updated: 2021/08/28 15:20:37
9647 dnl ---------------
9648 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
9649 dnl or adapt to the vendor's definitions to get equivalent functionality,
9650 dnl without losing the common non-POSIX features.
9651 dnl
9652 dnl Parameters:
9653 dnl     $1 is the nominal value for _XOPEN_SOURCE
9654 dnl     $2 is the nominal value for _POSIX_C_SOURCE
9655 AC_DEFUN([CF_XOPEN_SOURCE],[
9656 AC_REQUIRE([AC_CANONICAL_HOST])
9657 AC_REQUIRE([CF_POSIX_VISIBLE])
9658
9659 if test "$cf_cv_posix_visible" = no; then
9660
9661 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
9662 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
9663 cf_xopen_source=
9664
9665 case "$host_os" in
9666 (aix[[4-7]]*)
9667         cf_xopen_source="-D_ALL_SOURCE"
9668         ;;
9669 (msys)
9670         cf_XOPEN_SOURCE=600
9671         ;;
9672 (darwin[[0-8]].*)
9673         cf_xopen_source="-D_APPLE_C_SOURCE"
9674         ;;
9675 (darwin*)
9676         cf_xopen_source="-D_DARWIN_C_SOURCE"
9677         cf_XOPEN_SOURCE=
9678         ;;
9679 (freebsd*|dragonfly*|midnightbsd*)
9680         # 5.x headers associate
9681         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
9682         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
9683         cf_POSIX_C_SOURCE=200112L
9684         cf_XOPEN_SOURCE=600
9685         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
9686         ;;
9687 (hpux11*)
9688         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
9689         ;;
9690 (hpux*)
9691         cf_xopen_source="-D_HPUX_SOURCE"
9692         ;;
9693 (irix[[56]].*)
9694         cf_xopen_source="-D_SGI_SOURCE"
9695         cf_XOPEN_SOURCE=
9696         ;;
9697 (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
9698         CF_GNU_SOURCE($cf_XOPEN_SOURCE)
9699         ;;
9700 (minix*)
9701         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
9702         ;;
9703 (mirbsd*)
9704         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
9705         cf_XOPEN_SOURCE=
9706         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
9707         ;;
9708 (netbsd*)
9709         cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
9710         ;;
9711 (openbsd[[6-9]]*)
9712         # OpenBSD 6.x has broken locale support, both compile-time and runtime.
9713         # see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
9714         # Abusing the conformance level is a workaround.
9715         AC_MSG_WARN(this system does not provide usable locale support)
9716         cf_xopen_source="-D_BSD_SOURCE"
9717         cf_XOPEN_SOURCE=700
9718         ;;
9719 (openbsd[[4-5]]*)
9720         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
9721         cf_xopen_source="-D_BSD_SOURCE"
9722         cf_XOPEN_SOURCE=600
9723         ;;
9724 (openbsd*)
9725         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
9726         ;;
9727 (osf[[45]]*)
9728         cf_xopen_source="-D_OSF_SOURCE"
9729         ;;
9730 (nto-qnx*)
9731         cf_xopen_source="-D_QNX_SOURCE"
9732         ;;
9733 (sco*)
9734         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
9735         ;;
9736 (solaris2.*)
9737         cf_xopen_source="-D__EXTENSIONS__"
9738         cf_cv_xopen_source=broken
9739         ;;
9740 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
9741         cf_XOPEN_SOURCE=
9742         cf_POSIX_C_SOURCE=
9743         ;;
9744 (*)
9745         CF_TRY_XOPEN_SOURCE
9746         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
9747         ;;
9748 esac
9749
9750 if test -n "$cf_xopen_source" ; then
9751         CF_APPEND_CFLAGS($cf_xopen_source,true)
9752 fi
9753
9754 dnl In anything but the default case, we may have system-specific setting
9755 dnl which is still not guaranteed to provide all of the entrypoints that
9756 dnl _XOPEN_SOURCE would yield.
9757 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
9758         AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
9759         AC_TRY_COMPILE([#include <stdlib.h>],[
9760 #ifndef _XOPEN_SOURCE
9761 make an error
9762 #endif],
9763         [cf_XOPEN_SOURCE_set=yes],
9764         [cf_XOPEN_SOURCE_set=no])
9765         AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
9766         if test "$cf_XOPEN_SOURCE_set" = yes
9767         then
9768                 AC_TRY_COMPILE([#include <stdlib.h>],[
9769 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
9770 make an error
9771 #endif],
9772                 [cf_XOPEN_SOURCE_set_ok=yes],
9773                 [cf_XOPEN_SOURCE_set_ok=no])
9774                 if test "$cf_XOPEN_SOURCE_set_ok" = no
9775                 then
9776                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
9777                 fi
9778         else
9779                 CF_TRY_XOPEN_SOURCE
9780         fi
9781 fi
9782 fi # cf_cv_posix_visible
9783 ])
9784 dnl ---------------------------------------------------------------------------
9785 dnl CF__SED_TRIMBLANKS version: 1 updated: 2021/01/02 09:31:20
9786 dnl ------------------
9787 dnl Trim something using sed, then trim extra whitespace
9788 dnl $1 = extra parameters, e.g., in CF_STRIP_G_OPT
9789 define([CF__SED_TRIMBLANKS],[sed ifelse($1,,,[$1] )-e 's%[[     ]]% %g' -e 's% [[ ]]*% %g' -e 's%^ %%' -e 's% [$]%%'])dnl