]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/aclocal.m4
ncurses 6.1 - patch 20200111
[ncurses.git] / Ada95 / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2010-2019,2020 Free Software Foundation, Inc.              *
3 dnl                                                                          *
4 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
5 dnl copy of this software and associated documentation files (the            *
6 dnl "Software"), to deal in the Software without restriction, including      *
7 dnl without limitation the rights to use, copy, modify, merge, publish,      *
8 dnl distribute, distribute with modifications, sublicense, and/or sell       *
9 dnl copies of the Software, and to permit persons to whom the Software is    *
10 dnl furnished to do so, subject to the following conditions:                 *
11 dnl                                                                          *
12 dnl The above copyright notice and this permission notice shall be included  *
13 dnl in all copies or substantial portions of the Software.                   *
14 dnl                                                                          *
15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 dnl                                                                          *
23 dnl Except as contained in this notice, the name(s) of the above copyright   *
24 dnl holders shall not be used in advertising or otherwise to promote the     *
25 dnl sale, use or other dealings in this Software without prior written       *
26 dnl authorization.                                                           *
27 dnl***************************************************************************
28 dnl
29 dnl Author: Thomas E. Dickey
30 dnl
31 dnl $Id: aclocal.m4,v 1.151 2020/01/11 23:42:04 tom Exp $
32 dnl Macros used in NCURSES Ada95 auto-configuration script.
33 dnl
34 dnl These macros are maintained separately from NCURSES.  The copyright on
35 dnl this file applies to the aggregation of macros and does not affect use of
36 dnl these macros in other applications.
37 dnl
38 dnl See these pages for additional information:
39 dnl             https://invisible-island.net/autoconf/
40 dnl             https://invisible-island.net/autoconf/my-autoconf.html
41 dnl
42 dnl ---------------------------------------------------------------------------
43 dnl ---------------------------------------------------------------------------
44 dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
45 dnl ------------------
46 dnl Conditionally generate script according to whether we're using a given autoconf.
47 dnl
48 dnl $1 = version to compare against
49 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
50 dnl $3 = code to use if AC_ACVERSION is older than $1.
51 define([CF_ACVERSION_CHECK],
52 [
53 ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
54 ifdef([m4_version_compare],
55 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
56 [CF_ACVERSION_COMPARE(
57 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
58 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
59 dnl ---------------------------------------------------------------------------
60 dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
61 dnl --------------------
62 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
63 dnl                      MAJOR2, MINOR2, TERNARY2,
64 dnl                      PRINTABLE2, not FOUND, FOUND)
65 define([CF_ACVERSION_COMPARE],
66 [ifelse(builtin([eval], [$2 < $5]), 1,
67 [ifelse([$8], , ,[$8])],
68 [ifelse([$9], , ,[$9])])])dnl
69 dnl ---------------------------------------------------------------------------
70 dnl CF_ADA_INCLUDE_DIRS version: 8 updated: 2013/10/14 04:24:07
71 dnl -------------------
72 dnl Construct the list of include-options for the C programs in the Ada95
73 dnl binding.
74 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
75 [
76 ACPPFLAGS="-I. -I../include -I../../include $ACPPFLAGS"
77 if test "$srcdir" != "."; then
78         ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
79 fi
80 if test "$GCC" != yes; then
81         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
82 elif test "$includedir" != "/usr/include"; then
83         if test "$includedir" = '${prefix}/include' ; then
84                 if test x$prefix != x/usr ; then
85                         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
86                 fi
87         else
88                 ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
89         fi
90 fi
91 AC_SUBST(ACPPFLAGS)
92 ])dnl
93 dnl ---------------------------------------------------------------------------
94 dnl CF_ADD_ADAFLAGS version: 1 updated: 2010/06/19 15:22:18
95 dnl ---------------
96 dnl Add to $ADAFLAGS, which is substituted into makefile and scripts.
97 AC_DEFUN([CF_ADD_ADAFLAGS],[
98         ADAFLAGS="$ADAFLAGS $1"
99         AC_SUBST(ADAFLAGS)
100 ])dnl
101 dnl ---------------------------------------------------------------------------
102 dnl CF_ADD_CFLAGS version: 13 updated: 2017/02/25 18:57:40
103 dnl -------------
104 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
105 dnl The second parameter if given makes this macro verbose.
106 dnl
107 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
108 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
109 dnl confused by the quotes (which require backslashes to keep them usable).
110 AC_DEFUN([CF_ADD_CFLAGS],
111 [
112 cf_fix_cppflags=no
113 cf_new_cflags=
114 cf_new_cppflags=
115 cf_new_extra_cppflags=
116
117 for cf_add_cflags in $1
118 do
119 case $cf_fix_cppflags in
120 (no)
121         case $cf_add_cflags in
122         (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
123                 case $cf_add_cflags in
124                 (-D*)
125                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
126
127                         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
128                                 && test -z "${cf_tst_cflags}" \
129                                 && cf_fix_cppflags=yes
130
131                         if test $cf_fix_cppflags = yes ; then
132                                 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
133                                 continue
134                         elif test "${cf_tst_cflags}" = "\"'" ; then
135                                 CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
136                                 continue
137                         fi
138                         ;;
139                 esac
140                 case "$CPPFLAGS" in
141                 (*$cf_add_cflags)
142                         ;;
143                 (*)
144                         case $cf_add_cflags in
145                         (-D*)
146                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
147                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
148                                 ;;
149                         esac
150                         CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
151                         ;;
152                 esac
153                 ;;
154         (*)
155                 CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
156                 ;;
157         esac
158         ;;
159 (yes)
160         CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
161
162         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
163
164         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
165                 && test -z "${cf_tst_cflags}" \
166                 && cf_fix_cppflags=no
167         ;;
168 esac
169 done
170
171 if test -n "$cf_new_cflags" ; then
172         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
173         CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
174 fi
175
176 if test -n "$cf_new_cppflags" ; then
177         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
178         CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
179 fi
180
181 if test -n "$cf_new_extra_cppflags" ; then
182         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
183         CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
184 fi
185
186 AC_SUBST(EXTRA_CPPFLAGS)
187
188 ])dnl
189 dnl ---------------------------------------------------------------------------
190 dnl CF_ADD_INCDIR version: 15 updated: 2018/06/20 20:23:13
191 dnl -------------
192 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
193 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
194 dnl but old versions (and some misinstalled ones) need that.  To make things
195 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
196 dnl the include-path).
197 AC_DEFUN([CF_ADD_INCDIR],
198 [
199 if test -n "$1" ; then
200   for cf_add_incdir in $1
201   do
202         while test $cf_add_incdir != /usr/include
203         do
204           if test -d $cf_add_incdir
205           then
206                 cf_have_incdir=no
207                 if test -n "$CFLAGS$CPPFLAGS" ; then
208                   # a loop is needed to ensure we can add subdirs of existing dirs
209                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
210                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
211                           cf_have_incdir=yes; break
212                         fi
213                   done
214                 fi
215
216                 if test "$cf_have_incdir" = no ; then
217                   if test "$cf_add_incdir" = /usr/local/include ; then
218                         if test "$GCC" = yes
219                         then
220                           cf_save_CPPFLAGS=$CPPFLAGS
221                           CF_APPEND_TEXT(CPPFLAGS,-I$cf_add_incdir)
222                           AC_TRY_COMPILE([#include <stdio.h>],
223                                   [printf("Hello")],
224                                   [],
225                                   [cf_have_incdir=yes])
226                           CPPFLAGS=$cf_save_CPPFLAGS
227                         fi
228                   fi
229                 fi
230
231                 if test "$cf_have_incdir" = no ; then
232                   CF_VERBOSE(adding $cf_add_incdir to include-path)
233                   ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
234
235                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
236                   test "$cf_top_incdir" = "$cf_add_incdir" && break
237                   cf_add_incdir="$cf_top_incdir"
238                 else
239                   break
240                 fi
241           else
242                 break
243           fi
244         done
245   done
246 fi
247 ])dnl
248 dnl ---------------------------------------------------------------------------
249 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
250 dnl ----------
251 dnl Add a library, used to enforce consistency.
252 dnl
253 dnl $1 = library to add, without the "-l"
254 dnl $2 = variable to update (default $LIBS)
255 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
256 dnl ---------------------------------------------------------------------------
257 dnl CF_ADD_LIBDIR version: 10 updated: 2015/04/18 08:56:57
258 dnl -------------
259 dnl     Adds to the library-path
260 dnl
261 dnl     Some machines have trouble with multiple -L options.
262 dnl
263 dnl $1 is the (list of) directory(s) to add
264 dnl $2 is the optional name of the variable to update (default LDFLAGS)
265 dnl
266 AC_DEFUN([CF_ADD_LIBDIR],
267 [
268 if test -n "$1" ; then
269         for cf_add_libdir in $1
270         do
271                 if test $cf_add_libdir = /usr/lib ; then
272                         :
273                 elif test -d $cf_add_libdir
274                 then
275                         cf_have_libdir=no
276                         if test -n "$LDFLAGS$LIBS" ; then
277                                 # a loop is needed to ensure we can add subdirs of existing dirs
278                                 for cf_test_libdir in $LDFLAGS $LIBS ; do
279                                         if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
280                                                 cf_have_libdir=yes; break
281                                         fi
282                                 done
283                         fi
284                         if test "$cf_have_libdir" = no ; then
285                                 CF_VERBOSE(adding $cf_add_libdir to library-path)
286                                 ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
287                         fi
288                 fi
289         done
290 fi
291 ])dnl
292 dnl ---------------------------------------------------------------------------
293 dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33
294 dnl -----------
295 dnl Add one or more libraries, used to enforce consistency.  Libraries are
296 dnl prepended to an existing list, since their dependencies are assumed to
297 dnl already exist in the list.
298 dnl
299 dnl $1 = libraries to add, with the "-l", etc.
300 dnl $2 = variable to update (default $LIBS)
301 AC_DEFUN([CF_ADD_LIBS],[
302 cf_add_libs="[$]ifelse($2,,LIBS,[$2])"
303 # reverse order
304 cf_add_0lib=
305 for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
306 # filter duplicates
307 for cf_add_1lib in $cf_add_0lib; do
308         for cf_add_2lib in $cf_add_libs; do
309                 if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
310                         cf_add_1lib=
311                         break
312                 fi
313         done
314         test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
315 done
316 ifelse($2,,LIBS,[$2])="$cf_add_libs"
317 ])dnl
318 dnl ---------------------------------------------------------------------------
319 dnl CF_ADD_SUBDIR_PATH version: 4 updated: 2013/10/08 17:47:05
320 dnl ------------------
321 dnl Append to a search-list for a nonstandard header/lib-file
322 dnl     $1 = the variable to return as result
323 dnl     $2 = the package name
324 dnl     $3 = the subdirectory, e.g., bin, include or lib
325 dnl $4 = the directory under which we will test for subdirectories
326 dnl $5 = a directory that we do not want $4 to match
327 AC_DEFUN([CF_ADD_SUBDIR_PATH],
328 [
329 test "x$4" != "x$5" && \
330 test -d "$4" && \
331 ifelse([$5],NONE,,[(test -z "$5" || test x$5 = xNONE || test "x$4" != "x$5") &&]) {
332         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
333         test -d $4/$3 &&          $1="[$]$1 $4/$3"
334         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
335         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
336         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
337         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
338 }
339 ])dnl
340 dnl ---------------------------------------------------------------------------
341 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
342 dnl --------------
343 dnl use this macro for appending text without introducing an extra blank at
344 dnl the beginning
345 define([CF_APPEND_TEXT],
346 [
347         test -n "[$]$1" && $1="[$]$1 "
348         $1="[$]{$1}$2"
349 ])dnl
350 dnl ---------------------------------------------------------------------------
351 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
352 dnl --------------
353 dnl Allow user to disable a normally-on option.
354 AC_DEFUN([CF_ARG_DISABLE],
355 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
356 dnl ---------------------------------------------------------------------------
357 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
358 dnl -------------
359 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
360 dnl values.
361 dnl
362 dnl Parameters:
363 dnl $1 = option name
364 dnl $2 = help-string
365 dnl $3 = action to perform if option is not default
366 dnl $4 = action if perform if option is default
367 dnl $5 = default option value (either 'yes' or 'no')
368 AC_DEFUN([CF_ARG_OPTION],
369 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
370         if test "$enableval" != "$5" ; then
371 ifelse([$3],,[    :]dnl
372 ,[    $3]) ifelse([$4],,,[
373         else
374                 $4])
375         fi],[enableval=$5 ifelse([$4],,,[
376         $4
377 ])dnl
378 ])])dnl
379 dnl ---------------------------------------------------------------------------
380 dnl CF_AR_FLAGS version: 6 updated: 2015/10/10 15:25:05
381 dnl -----------
382 dnl Check for suitable "ar" (archiver) options for updating an archive.
383 dnl
384 dnl In particular, handle some obsolete cases where the "-" might be omitted,
385 dnl as well as a workaround for breakage of make's archive rules by the GNU
386 dnl binutils "ar" program.
387 AC_DEFUN([CF_AR_FLAGS],[
388 AC_REQUIRE([CF_PROG_AR])
389
390 AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
391         cf_cv_ar_flags=unknown
392         for cf_ar_flags in -curvU -curv curv -crv crv -cqv cqv -rv rv
393         do
394
395                 # check if $ARFLAGS already contains this choice
396                 if test "x$ARFLAGS" != "x" ; then
397                         cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
398                         if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
399                                 cf_cv_ar_flags=
400                                 break
401                         fi
402                 fi
403
404                 rm -f conftest.$ac_cv_objext
405                 rm -f conftest.a
406
407                 cat >conftest.$ac_ext <<EOF
408 #line __oline__ "configure"
409 int     testdata[[3]] = { 123, 456, 789 };
410 EOF
411                 if AC_TRY_EVAL(ac_compile) ; then
412                         echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AC_FD_CC
413                         $AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext 2>&AC_FD_CC 1>/dev/null
414                         if test -f conftest.a ; then
415                                 cf_cv_ar_flags=$cf_ar_flags
416                                 break
417                         fi
418                 else
419                         CF_VERBOSE(cannot compile test-program)
420                         break
421                 fi
422         done
423         rm -f conftest.a conftest.$ac_ext conftest.$ac_cv_objext
424 ])
425
426 if test -n "$ARFLAGS" ; then
427         if test -n "$cf_cv_ar_flags" ; then
428                 ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
429         fi
430 else
431         ARFLAGS=$cf_cv_ar_flags
432 fi
433
434 AC_SUBST(ARFLAGS)
435 ])
436 dnl ---------------------------------------------------------------------------
437 dnl CF_BUILD_CC version: 8 updated: 2018/01/04 20:31:04
438 dnl -----------
439 dnl If we're cross-compiling, allow the user to override the tools and their
440 dnl options.  The configure script is oriented toward identifying the host
441 dnl compiler, etc., but we need a build compiler to generate parts of the
442 dnl source.
443 dnl
444 dnl $1 = default for $CPPFLAGS
445 dnl $2 = default for $LIBS
446 AC_DEFUN([CF_BUILD_CC],[
447 CF_ACVERSION_CHECK(2.52,,
448         [AC_REQUIRE([CF_PROG_EXT])])
449 if test "$cross_compiling" = yes ; then
450
451         # defaults that we might want to override
452         : ${BUILD_CFLAGS:=''}
453         : ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
454         : ${BUILD_LDFLAGS:=''}
455         : ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
456         : ${BUILD_EXEEXT:='$x'}
457         : ${BUILD_OBJEXT:='o'}
458
459         AC_ARG_WITH(build-cc,
460                 [  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
461                 [BUILD_CC="$withval"],
462                 [AC_CHECK_PROGS(BUILD_CC, [gcc clang c99 c89 cc cl],none)])
463         AC_MSG_CHECKING(for native build C compiler)
464         AC_MSG_RESULT($BUILD_CC)
465
466         AC_MSG_CHECKING(for native build C preprocessor)
467         AC_ARG_WITH(build-cpp,
468                 [  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
469                 [BUILD_CPP="$withval"],
470                 [BUILD_CPP='${BUILD_CC} -E'])
471         AC_MSG_RESULT($BUILD_CPP)
472
473         AC_MSG_CHECKING(for native build C flags)
474         AC_ARG_WITH(build-cflags,
475                 [  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
476                 [BUILD_CFLAGS="$withval"])
477         AC_MSG_RESULT($BUILD_CFLAGS)
478
479         AC_MSG_CHECKING(for native build C preprocessor-flags)
480         AC_ARG_WITH(build-cppflags,
481                 [  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
482                 [BUILD_CPPFLAGS="$withval"])
483         AC_MSG_RESULT($BUILD_CPPFLAGS)
484
485         AC_MSG_CHECKING(for native build linker-flags)
486         AC_ARG_WITH(build-ldflags,
487                 [  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
488                 [BUILD_LDFLAGS="$withval"])
489         AC_MSG_RESULT($BUILD_LDFLAGS)
490
491         AC_MSG_CHECKING(for native build linker-libraries)
492         AC_ARG_WITH(build-libs,
493                 [  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
494                 [BUILD_LIBS="$withval"])
495         AC_MSG_RESULT($BUILD_LIBS)
496
497         # this assumes we're on Unix.
498         BUILD_EXEEXT=
499         BUILD_OBJEXT=o
500
501         : ${BUILD_CC:='${CC}'}
502
503         if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
504                 AC_MSG_ERROR([Cross-build requires two compilers.
505 Use --with-build-cc to specify the native compiler.])
506         fi
507
508 else
509         : ${BUILD_CC:='${CC}'}
510         : ${BUILD_CPP:='${CPP}'}
511         : ${BUILD_CFLAGS:='${CFLAGS}'}
512         : ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
513         : ${BUILD_LDFLAGS:='${LDFLAGS}'}
514         : ${BUILD_LIBS:='${LIBS}'}
515         : ${BUILD_EXEEXT:='$x'}
516         : ${BUILD_OBJEXT:='o'}
517 fi
518
519 AC_SUBST(BUILD_CC)
520 AC_SUBST(BUILD_CPP)
521 AC_SUBST(BUILD_CFLAGS)
522 AC_SUBST(BUILD_CPPFLAGS)
523 AC_SUBST(BUILD_LDFLAGS)
524 AC_SUBST(BUILD_LIBS)
525 AC_SUBST(BUILD_EXEEXT)
526 AC_SUBST(BUILD_OBJEXT)
527 ])dnl
528 dnl ---------------------------------------------------------------------------
529 dnl CF_CC_ENV_FLAGS version: 9 updated: 2018/07/29 18:03:26
530 dnl ---------------
531 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
532 dnl into CC.  This will not help with broken scripts that wrap the compiler
533 dnl with options, but eliminates a more common category of user confusion.
534 dnl
535 dnl In particular, it addresses the problem of being able to run the C
536 dnl preprocessor in a consistent manner.
537 dnl
538 dnl Caveat: this also disallows blanks in the pathname for the compiler, but
539 dnl the nuisance of having inconsistent settings for compiler and preprocessor
540 dnl outweighs that limitation.
541 AC_DEFUN([CF_CC_ENV_FLAGS],
542 [
543 # This should have been defined by AC_PROG_CC
544 : ${CC:=cc}
545
546 AC_MSG_CHECKING(\$CFLAGS variable)
547 case "x$CFLAGS" in
548 (*-[[IUD]]*)
549         AC_MSG_RESULT(broken)
550         AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
551         cf_flags="$CFLAGS"
552         CFLAGS=
553         for cf_arg in $cf_flags
554         do
555                 CF_ADD_CFLAGS($cf_arg)
556         done
557         ;;
558 (*)
559         AC_MSG_RESULT(ok)
560         ;;
561 esac
562
563 AC_MSG_CHECKING(\$CC variable)
564 case "$CC" in
565 (*[[\ \ ]]-*)
566         AC_MSG_RESULT(broken)
567         AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
568         # humor him...
569         cf_prog=`echo "$CC" | sed -e 's/        / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
570         cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
571         CC="$cf_prog"
572         for cf_arg in $cf_flags
573         do
574                 case "x$cf_arg" in
575                 (x-[[IUDfgOW]]*)
576                         CF_ADD_CFLAGS($cf_arg)
577                         ;;
578                 (*)
579                         CC="$CC $cf_arg"
580                         ;;
581                 esac
582         done
583         CF_VERBOSE(resulting CC: '$CC')
584         CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
585         CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
586         ;;
587 (*)
588         AC_MSG_RESULT(ok)
589         ;;
590 esac
591 ])dnl
592 dnl ---------------------------------------------------------------------------
593 dnl CF_CFG_DEFAULTS version: 11 updated: 2015/04/17 21:13:04
594 dnl ---------------
595 dnl Determine the default configuration into which we'll install ncurses.  This
596 dnl can be overridden by the user's command-line options.  There's two items to
597 dnl look for:
598 dnl     1. the prefix (e.g., /usr)
599 dnl     2. the header files (e.g., /usr/include/ncurses)
600 dnl We'll look for a previous installation of ncurses and use the same defaults.
601 dnl
602 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
603 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
604 dnl programs from a vendor's.
605 AC_DEFUN([CF_CFG_DEFAULTS],
606 [
607 AC_MSG_CHECKING(for prefix)
608 if test "x$prefix" = "xNONE" ; then
609         case "$cf_cv_system_name" in
610                 # non-vendor systems don't have a conflict
611         (openbsd*|freebsd*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
612                 prefix=/usr
613                 ;;
614         (*)     prefix=$ac_default_prefix
615                 ;;
616         esac
617 fi
618 AC_MSG_RESULT($prefix)
619
620 if test "x$prefix" = "xNONE" ; then
621 AC_MSG_CHECKING(for default include-directory)
622 test -n "$verbose" && echo 1>&AC_FD_MSG
623 for cf_symbol in \
624         $includedir \
625         $includedir/ncurses \
626         $prefix/include \
627         $prefix/include/ncurses \
628         /usr/local/include \
629         /usr/local/include/ncurses \
630         /usr/include \
631         /usr/include/ncurses
632 do
633         cf_dir=`eval echo $cf_symbol`
634         if test -f $cf_dir/curses.h ; then
635         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
636                 includedir="$cf_symbol"
637                 test -n "$verbose"  && echo $ac_n "     found " 1>&AC_FD_MSG
638                 break
639         fi
640         fi
641         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
642 done
643 AC_MSG_RESULT($includedir)
644 fi
645 ])dnl
646 dnl ---------------------------------------------------------------------------
647 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
648 dnl --------------
649 dnl Check if we're accidentally using a cache from a different machine.
650 dnl Derive the system name, as a check for reusing the autoconf cache.
651 dnl
652 dnl If we've packaged config.guess and config.sub, run that (since it does a
653 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
654 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
655 dnl which is useful in cross-compiles.
656 dnl
657 dnl Note: we would use $ac_config_sub, but that is one of the places where
658 dnl autoconf 2.5x broke compatibility with autoconf 2.13
659 AC_DEFUN([CF_CHECK_CACHE],
660 [
661 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
662         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
663         system_name="$host_os"
664 else
665         system_name="`(uname -s -r) 2>/dev/null`"
666         if test -z "$system_name" ; then
667                 system_name="`(hostname) 2>/dev/null`"
668         fi
669 fi
670 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
671 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
672
673 test -z "$system_name" && system_name="$cf_cv_system_name"
674 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
675
676 if test ".$system_name" != ".$cf_cv_system_name" ; then
677         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
678         AC_MSG_ERROR("Please remove config.cache and try again.")
679 fi
680 ])dnl
681 dnl ---------------------------------------------------------------------------
682 dnl CF_CHECK_GNAT_VERSION version: 2 updated: 2019/12/31 08:53:54
683 dnl ---------------------
684 AC_DEFUN([CF_CHECK_GNAT_VERSION],
685 [
686 AC_REQUIRE([CF_GNAT_VERSION])
687 case $cf_cv_gnat_version in
688 (3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*|20[[0-9]][[0-9]])
689         cf_cv_prog_gnat_correct=yes
690         ;;
691 (*)
692         AC_MSG_WARN(Unsupported GNAT version $cf_cv_gnat_version. We require 3.11 or better. Disabling Ada95 binding.)
693         cf_cv_prog_gnat_correct=no
694         ;;
695 esac
696 ])
697 dnl ---------------------------------------------------------------------------
698 dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
699 dnl -----------------
700 dnl Check if the given compiler is really clang.  clang's C driver defines
701 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
702 dnl not ignore some gcc options.
703 dnl
704 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
705 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
706 dnl the wrappers for gcc and g++ warnings.
707 dnl
708 dnl $1 = GCC (default) or GXX
709 dnl $2 = CLANG_COMPILER (default)
710 dnl $3 = CFLAGS (default) or CXXFLAGS
711 AC_DEFUN([CF_CLANG_COMPILER],[
712 ifelse([$2],,CLANG_COMPILER,[$2])=no
713
714 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
715         AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
716         cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
717         ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
718         AC_TRY_COMPILE([],[
719 #ifdef __clang__
720 #else
721 make an error
722 #endif
723 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
724 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
725 ],[])
726         ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
727         AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
728 fi
729 ])
730 dnl ---------------------------------------------------------------------------
731 dnl CF_CONST_X_STRING version: 3 updated: 2020/01/11 18:39:22
732 dnl -----------------
733 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
734 dnl character-strings.
735 dnl
736 dnl It is ambiguous because the specification accommodated the pre-ANSI
737 dnl compilers bundled by more than one vendor in lieu of providing a standard C
738 dnl compiler other than by costly add-ons.  Because of this, the specification
739 dnl did not take into account the use of const for telling the compiler that
740 dnl string literals would be in readonly memory.
741 dnl
742 dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
743 dnl let the compiler decide how to represent Xt's strings which were #define'd. 
744 dnl That does not solve the problem of using the block of Xt's strings which
745 dnl are compiled into the library (and is less efficient than one might want).
746 dnl
747 dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
748 dnl when compiling the library and compiling using the library, to tell the
749 dnl compiler that String is const.
750 AC_DEFUN([CF_CONST_X_STRING],
751 [
752 AC_REQUIRE([AC_PATH_XTRA])
753
754 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
755
756 AC_TRY_COMPILE(
757 [
758 #include <stdlib.h>
759 #include <X11/Intrinsic.h>
760 ],
761 [String foo = malloc(1)],[
762
763 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
764         AC_TRY_COMPILE(
765                 [
766 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
767 #undef  XTSTRINGDEFINES /* X11R5 and later */
768 #include <stdlib.h>
769 #include <X11/Intrinsic.h>
770                 ],[String foo = malloc(1); *foo = 0],[
771                         cf_cv_const_x_string=no
772                 ],[
773                         cf_cv_const_x_string=yes
774                 ])
775 ])
776
777 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
778
779 case $cf_cv_const_x_string in
780 (no)
781         CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
782         ;;
783 (*)
784         CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
785         ;;
786 esac
787
788 ])
789 ])dnl
790 dnl ---------------------------------------------------------------------------
791 dnl CF_CONST_X_STRING version: 3 updated: 2020/01/11 18:39:22
792 dnl -----------------
793 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
794 dnl character-strings.
795 dnl
796 dnl It is ambiguous because the specification accommodated the pre-ANSI
797 dnl compilers bundled by more than one vendor in lieu of providing a standard C
798 dnl compiler other than by costly add-ons.  Because of this, the specification
799 dnl did not take into account the use of const for telling the compiler that
800 dnl string literals would be in readonly memory.
801 dnl
802 dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
803 dnl let the compiler decide how to represent Xt's strings which were #define'd. 
804 dnl That does not solve the problem of using the block of Xt's strings which
805 dnl are compiled into the library (and is less efficient than one might want).
806 dnl
807 dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
808 dnl when compiling the library and compiling using the library, to tell the
809 dnl compiler that String is const.
810 AC_DEFUN([CF_CONST_X_STRING],
811 [
812 AC_REQUIRE([AC_PATH_XTRA])
813
814 CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
815
816 AC_TRY_COMPILE(
817 [
818 #include <stdlib.h>
819 #include <X11/Intrinsic.h>
820 ],
821 [String foo = malloc(1)],[
822
823 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
824         AC_TRY_COMPILE(
825                 [
826 #define _CONST_X_STRING /* X11R7.8 (perhaps) */
827 #undef  XTSTRINGDEFINES /* X11R5 and later */
828 #include <stdlib.h>
829 #include <X11/Intrinsic.h>
830                 ],[String foo = malloc(1); *foo = 0],[
831                         cf_cv_const_x_string=no
832                 ],[
833                         cf_cv_const_x_string=yes
834                 ])
835 ])
836
837 CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
838
839 case $cf_cv_const_x_string in
840 (no)
841         CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
842         ;;
843 (*)
844         CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
845         ;;
846 esac
847
848 ])
849 ])dnl
850 dnl ---------------------------------------------------------------------------
851 dnl CF_CURSES_HEADER version: 5 updated: 2015/04/23 20:35:30
852 dnl ----------------
853 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
854 dnl variations of ncurses' installs.
855 dnl
856 dnl $1 = ncurses when looking for ncurses, or is empty
857 AC_DEFUN([CF_CURSES_HEADER],[
858 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
859 cf_cv_ncurses_header=none
860 for cf_header in \
861         ncurses.h ifelse($1,,,[$1/ncurses.h]) \
862         curses.h ifelse($1,,,[$1/curses.h]) ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
863 do
864 AC_TRY_COMPILE([#include <${cf_header}>],
865         [initscr(); tgoto("?", 0,0)],
866         [cf_cv_ncurses_header=$cf_header; break],[])
867 done
868 ])
869
870 if test "$cf_cv_ncurses_header" = none ; then
871         AC_MSG_ERROR(No curses header-files found)
872 fi
873
874 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
875 AC_CHECK_HEADERS($cf_cv_ncurses_header)
876 ])dnl
877 dnl ---------------------------------------------------------------------------
878 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
879 dnl ----------
880 dnl "dirname" is not portable, so we fake it with a shell script.
881 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
882 dnl ---------------------------------------------------------------------------
883 dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
884 dnl ---------------
885 dnl You can always use "make -n" to see the actual options, but it's hard to
886 dnl pick out/analyze warning messages when the compile-line is long.
887 dnl
888 dnl Sets:
889 dnl     ECHO_LT - symbol to control if libtool is verbose
890 dnl     ECHO_LD - symbol to prefix "cc -o" lines
891 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
892 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
893 dnl     ECHO_CC - symbol to put before any "cc" line
894 dnl
895 AC_DEFUN([CF_DISABLE_ECHO],[
896 AC_MSG_CHECKING(if you want to see long compiling messages)
897 CF_ARG_DISABLE(echo,
898         [  --disable-echo          do not display "compiling" commands],
899         [
900         ECHO_LT='--silent'
901         ECHO_LD='@echo linking [$]@;'
902         RULE_CC='@echo compiling [$]<'
903         SHOW_CC='@echo compiling [$]@'
904         ECHO_CC='@'
905 ],[
906         ECHO_LT=''
907         ECHO_LD=''
908         RULE_CC=''
909         SHOW_CC=''
910         ECHO_CC=''
911 ])
912 AC_MSG_RESULT($enableval)
913 AC_SUBST(ECHO_LT)
914 AC_SUBST(ECHO_LD)
915 AC_SUBST(RULE_CC)
916 AC_SUBST(SHOW_CC)
917 AC_SUBST(ECHO_CC)
918 ])dnl
919 dnl ---------------------------------------------------------------------------
920 dnl CF_DISABLE_GNAT_PROJECTS version: 1 updated: 2014/06/01 11:34:00
921 dnl ------------------------
922 AC_DEFUN([CF_DISABLE_GNAT_PROJECTS],[
923 AC_MSG_CHECKING(if we want to use GNAT projects)
924 CF_ARG_DISABLE(gnat-projects,
925         [  --disable-gnat-projects test: disable GNAT projects even if usable],
926         [enable_gnat_projects=no],
927         [enable_gnat_projects=yes])
928 AC_MSG_RESULT($enable_gnat_projects)
929 ])dnl
930 dnl ---------------------------------------------------------------------------
931 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
932 dnl ---------------
933 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
934 dnl prefer a standard location, and use -L options only if we do not find the
935 dnl library in the standard library location(s).
936 dnl     $1 = library name
937 dnl     $2 = library class, usually the same as library name
938 dnl     $3 = includes
939 dnl     $4 = code fragment to compile/link
940 dnl     $5 = corresponding function-name
941 dnl     $6 = flag, nonnull if failure should not cause an error-exit
942 dnl
943 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
944 dnl to use a -L option.
945 AC_DEFUN([CF_FIND_LIBRARY],
946 [
947         eval 'cf_cv_have_lib_'$1'=no'
948         cf_libdir=""
949         AC_CHECK_FUNC($5,
950                 eval 'cf_cv_have_lib_'$1'=yes',[
951                 cf_save_LIBS="$LIBS"
952                 AC_MSG_CHECKING(for $5 in -l$1)
953                 LIBS="-l$1 $LIBS"
954                 AC_TRY_LINK([$3],[$4],
955                         [AC_MSG_RESULT(yes)
956                          eval 'cf_cv_have_lib_'$1'=yes'
957                         ],
958                         [AC_MSG_RESULT(no)
959                         CF_LIBRARY_PATH(cf_search,$2)
960                         for cf_libdir in $cf_search
961                         do
962                                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
963                                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
964                                 AC_TRY_LINK([$3],[$4],
965                                         [AC_MSG_RESULT(yes)
966                                          eval 'cf_cv_have_lib_'$1'=yes'
967                                          break],
968                                         [AC_MSG_RESULT(no)
969                                          LIBS="$cf_save_LIBS"])
970                         done
971                         ])
972                 ])
973 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
974 ifelse($6,,[
975 if test $cf_found_library = no ; then
976         AC_MSG_ERROR(Cannot link $1 library)
977 fi
978 ])
979 ])dnl
980 dnl ---------------------------------------------------------------------------
981 dnl CF_FIND_LINKAGE version: 21 updated: 2018/06/20 20:23:13
982 dnl ---------------
983 dnl Find a library (specifically the linkage used in the code fragment),
984 dnl searching for it if it is not already in the library path.
985 dnl See also CF_ADD_SEARCHPATH.
986 dnl
987 dnl Parameters (4-on are optional):
988 dnl     $1 = headers for library entrypoint
989 dnl     $2 = code fragment for library entrypoint
990 dnl     $3 = the library name without the "-l" option or ".so" suffix.
991 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
992 dnl     $5 = action to perform if not successful
993 dnl     $6 = module name, if not the same as the library name
994 dnl     $7 = extra libraries
995 dnl
996 dnl Sets these variables:
997 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
998 dnl     $cf_cv_header_path_$3 - include-directory if needed
999 dnl     $cf_cv_library_path_$3 - library-directory if needed
1000 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1001 AC_DEFUN([CF_FIND_LINKAGE],[
1002
1003 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1004 # will be set on completion of the AC_TRY_LINK below.
1005 cf_cv_header_path_$3=
1006 cf_cv_library_path_$3=
1007
1008 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1009
1010 cf_save_LIBS="$LIBS"
1011
1012 AC_TRY_LINK([$1],[$2],[
1013         cf_cv_find_linkage_$3=yes
1014         cf_cv_header_path_$3=/usr/include
1015         cf_cv_library_path_$3=/usr/lib
1016 ],[
1017
1018 LIBS="-l$3 $7 $cf_save_LIBS"
1019
1020 AC_TRY_LINK([$1],[$2],[
1021         cf_cv_find_linkage_$3=yes
1022         cf_cv_header_path_$3=/usr/include
1023         cf_cv_library_path_$3=/usr/lib
1024         cf_cv_library_file_$3="-l$3"
1025 ],[
1026         cf_cv_find_linkage_$3=no
1027         LIBS="$cf_save_LIBS"
1028
1029         CF_VERBOSE(find linkage for $3 library)
1030         CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1031
1032         cf_save_CPPFLAGS="$CPPFLAGS"
1033         cf_test_CPPFLAGS="$CPPFLAGS"
1034
1035         CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1036         for cf_cv_header_path_$3 in $cf_search
1037         do
1038                 if test -d $cf_cv_header_path_$3 ; then
1039                         CF_VERBOSE(... testing $cf_cv_header_path_$3)
1040                         CPPFLAGS="$cf_save_CPPFLAGS"
1041                         CF_APPEND_TEXT(CPPFLAGS,-I$cf_cv_header_path_$3)
1042                         AC_TRY_COMPILE([$1],[$2],[
1043                                 CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1044                                 cf_cv_find_linkage_$3=maybe
1045                                 cf_test_CPPFLAGS="$CPPFLAGS"
1046                                 break],[
1047                                 CPPFLAGS="$cf_save_CPPFLAGS"
1048                                 ])
1049                 fi
1050         done
1051
1052         if test "$cf_cv_find_linkage_$3" = maybe ; then
1053
1054                 CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1055
1056                 cf_save_LIBS="$LIBS"
1057                 cf_save_LDFLAGS="$LDFLAGS"
1058
1059                 ifelse([$6],,,[
1060                 CPPFLAGS="$cf_test_CPPFLAGS"
1061                 LIBS="-l$3 $7 $cf_save_LIBS"
1062                 AC_TRY_LINK([$1],[$2],[
1063                         CF_VERBOSE(... found $3 library in system)
1064                         cf_cv_find_linkage_$3=yes])
1065                         CPPFLAGS="$cf_save_CPPFLAGS"
1066                         LIBS="$cf_save_LIBS"
1067                         ])
1068
1069                 if test "$cf_cv_find_linkage_$3" != yes ; then
1070                         CF_LIBRARY_PATH(cf_search,$3)
1071                         for cf_cv_library_path_$3 in $cf_search
1072                         do
1073                                 if test -d $cf_cv_library_path_$3 ; then
1074                                         CF_VERBOSE(... testing $cf_cv_library_path_$3)
1075                                         CPPFLAGS="$cf_test_CPPFLAGS"
1076                                         LIBS="-l$3 $7 $cf_save_LIBS"
1077                                         LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1078                                         AC_TRY_LINK([$1],[$2],[
1079                                         CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1080                                         cf_cv_find_linkage_$3=yes
1081                                         cf_cv_library_file_$3="-l$3"
1082                                         break],[
1083                                         CPPFLAGS="$cf_save_CPPFLAGS"
1084                                         LIBS="$cf_save_LIBS"
1085                                         LDFLAGS="$cf_save_LDFLAGS"
1086                                         ])
1087                                 fi
1088                         done
1089                         CPPFLAGS="$cf_save_CPPFLAGS"
1090                         LDFLAGS="$cf_save_LDFLAGS"
1091                 fi
1092
1093         else
1094                 cf_cv_find_linkage_$3=no
1095         fi
1096         ],$7)
1097 ])
1098
1099 LIBS="$cf_save_LIBS"
1100
1101 if test "$cf_cv_find_linkage_$3" = yes ; then
1102 ifelse([$4],,[
1103         CF_ADD_INCDIR($cf_cv_header_path_$3)
1104         CF_ADD_LIBDIR($cf_cv_library_path_$3)
1105         CF_ADD_LIB($3)
1106 ],[$4])
1107 else
1108 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1109 fi
1110 ])dnl
1111 dnl ---------------------------------------------------------------------------
1112 dnl CF_FIXUP_ADAFLAGS version: 2 updated: 2015/04/17 21:13:04
1113 dnl -----------------
1114 dnl make ADAFLAGS consistent with CFLAGS
1115 AC_DEFUN([CF_FIXUP_ADAFLAGS],[
1116         AC_MSG_CHECKING(optimization options for ADAFLAGS)
1117         case "$CFLAGS" in
1118         (*-g*)
1119                 CF_ADD_ADAFLAGS(-g)
1120                 ;;
1121         esac
1122         case "$CFLAGS" in
1123         (*-O*)
1124                 cf_O_flag=`echo "$CFLAGS" |sed -e 's/^.*-O/-O/' -e 's/[[        ]].*//'`
1125                 CF_ADD_ADAFLAGS($cf_O_flag)
1126                 ;;
1127         esac
1128         AC_MSG_RESULT($ADAFLAGS)
1129 ])dnl
1130 dnl ---------------------------------------------------------------------------
1131 dnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
1132 dnl -----------------
1133 dnl Test for availability of useful gcc __attribute__ directives to quiet
1134 dnl compiler warnings.  Though useful, not all are supported -- and contrary
1135 dnl to documentation, unrecognized directives cause older compilers to barf.
1136 AC_DEFUN([CF_GCC_ATTRIBUTES],
1137 [
1138 if test "$GCC" = yes
1139 then
1140 cat > conftest.i <<EOF
1141 #ifndef GCC_PRINTF
1142 #define GCC_PRINTF 0
1143 #endif
1144 #ifndef GCC_SCANF
1145 #define GCC_SCANF 0
1146 #endif
1147 #ifndef GCC_NORETURN
1148 #define GCC_NORETURN /* nothing */
1149 #endif
1150 #ifndef GCC_UNUSED
1151 #define GCC_UNUSED /* nothing */
1152 #endif
1153 EOF
1154 if test "$GCC" = yes
1155 then
1156         AC_CHECKING([for $CC __attribute__ directives])
1157 cat > conftest.$ac_ext <<EOF
1158 #line __oline__ "${as_me:-configure}"
1159 #include "confdefs.h"
1160 #include "conftest.h"
1161 #include "conftest.i"
1162 #if     GCC_PRINTF
1163 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1164 #else
1165 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1166 #endif
1167 #if     GCC_SCANF
1168 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1169 #else
1170 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1171 #endif
1172 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1173 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1174 extern void foo(void) GCC_NORETURN;
1175 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1176 EOF
1177         cf_printf_attribute=no
1178         cf_scanf_attribute=no
1179         for cf_attribute in scanf printf unused noreturn
1180         do
1181                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1182                 cf_directive="__attribute__(($cf_attribute))"
1183                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1184
1185                 case $cf_attribute in
1186                 (printf)
1187                         cf_printf_attribute=yes
1188                         cat >conftest.h <<EOF
1189 #define GCC_$cf_ATTRIBUTE 1
1190 EOF
1191                         ;;
1192                 (scanf)
1193                         cf_scanf_attribute=yes
1194                         cat >conftest.h <<EOF
1195 #define GCC_$cf_ATTRIBUTE 1
1196 EOF
1197                         ;;
1198                 (*)
1199                         cat >conftest.h <<EOF
1200 #define GCC_$cf_ATTRIBUTE $cf_directive
1201 EOF
1202                         ;;
1203                 esac
1204
1205                 if AC_TRY_EVAL(ac_compile); then
1206                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1207                         cat conftest.h >>confdefs.h
1208                         case $cf_attribute in
1209                         (noreturn)
1210                                 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
1211                                 ;;
1212                         (printf)
1213                                 cf_value='/* nothing */'
1214                                 if test "$cf_printf_attribute" != no ; then
1215                                         cf_value='__attribute__((format(printf,fmt,var)))'
1216                                         AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
1217                                 fi
1218                                 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
1219                                 ;;
1220                         (scanf)
1221                                 cf_value='/* nothing */'
1222                                 if test "$cf_scanf_attribute" != no ; then
1223                                         cf_value='__attribute__((format(scanf,fmt,var)))'
1224                                         AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
1225                                 fi
1226                                 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
1227                                 ;;
1228                         (unused)
1229                                 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
1230                                 ;;
1231                         esac
1232                 fi
1233         done
1234 else
1235         fgrep define conftest.i >>confdefs.h
1236 fi
1237 rm -rf conftest*
1238 fi
1239 ])dnl
1240 dnl ---------------------------------------------------------------------------
1241 dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
1242 dnl --------------
1243 dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
1244 dnl compatible), attempt to determine if icc/clang is actually used.
1245 AC_DEFUN([CF_GCC_VERSION],[
1246 AC_REQUIRE([AC_PROG_CC])
1247 GCC_VERSION=none
1248 if test "$GCC" = yes ; then
1249         AC_MSG_CHECKING(version of $CC)
1250         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.]].*//'`"
1251         test -z "$GCC_VERSION" && GCC_VERSION=unknown
1252         AC_MSG_RESULT($GCC_VERSION)
1253 fi
1254 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1255 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
1256 ])dnl
1257 dnl ---------------------------------------------------------------------------
1258 dnl CF_GCC_WARNINGS version: 37 updated: 2020/01/05 20:04:12
1259 dnl ---------------
1260 dnl Check if the compiler supports useful warning options.  There's a few that
1261 dnl we don't use, simply because they're too noisy:
1262 dnl
1263 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1264 dnl     -Winline (usually not worthwhile)
1265 dnl     -Wredundant-decls (system headers make this too noisy)
1266 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
1267 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
1268 dnl             is enabled for ncurses using "--enable-const".
1269 dnl     -pedantic
1270 dnl
1271 dnl Parameter:
1272 dnl     $1 is an optional list of gcc warning flags that a particular
1273 dnl             application might want to use, e.g., "no-unused" for
1274 dnl             -Wno-unused
1275 dnl Special:
1276 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1277 dnl
1278 AC_DEFUN([CF_GCC_WARNINGS],
1279 [
1280 AC_REQUIRE([CF_GCC_VERSION])
1281 if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
1282 cat > conftest.$ac_ext <<EOF
1283 #line __oline__ "${as_me:-configure}"
1284 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1285 EOF
1286 if test "$INTEL_COMPILER" = yes
1287 then
1288 # The "-wdXXX" options suppress warnings:
1289 # remark #1419: external declaration in primary source file
1290 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1291 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1292 # remark #193: zero used for undefined preprocessing identifier
1293 # remark #593: variable "curs_sb_left_arrow" was set but never used
1294 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1295 # remark #869: parameter "tw" was never referenced
1296 # remark #981: operands are evaluated in unspecified order
1297 # warning #279: controlling expression is constant
1298
1299         AC_CHECKING([for $CC warning options])
1300         cf_save_CFLAGS="$CFLAGS"
1301         EXTRA_CFLAGS="-Wall"
1302         for cf_opt in \
1303                 wd1419 \
1304                 wd1683 \
1305                 wd1684 \
1306                 wd193 \
1307                 wd593 \
1308                 wd279 \
1309                 wd810 \
1310                 wd869 \
1311                 wd981
1312         do
1313                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1314                 if AC_TRY_EVAL(ac_compile); then
1315                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1316                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1317                 fi
1318         done
1319         CFLAGS="$cf_save_CFLAGS"
1320 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
1321 then
1322         AC_CHECKING([for $CC warning options])
1323         cf_save_CFLAGS="$CFLAGS"
1324         EXTRA_CFLAGS=
1325         cf_warn_CONST=""
1326         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1327         cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
1328         test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
1329         for cf_opt in W Wall \
1330                 Wbad-function-cast \
1331                 Wcast-align \
1332                 Wcast-qual \
1333                 Wdeclaration-after-statement \
1334                 Wextra \
1335                 Winline \
1336                 Wmissing-declarations \
1337                 Wmissing-prototypes \
1338                 Wnested-externs \
1339                 Wpointer-arith \
1340                 Wshadow \
1341                 Wstrict-prototypes \
1342                 Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
1343         do
1344                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1345                 if AC_TRY_EVAL(ac_compile); then
1346                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1347                         case $cf_opt in
1348                         (Winline)
1349                                 case $GCC_VERSION in
1350                                 ([[34]].*)
1351                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1352                                         continue;;
1353                                 esac
1354                                 ;;
1355                         (Wpointer-arith)
1356                                 case $GCC_VERSION in
1357                                 ([[12]].*)
1358                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1359                                         continue;;
1360                                 esac
1361                                 ;;
1362                         esac
1363                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1364                 fi
1365         done
1366         CFLAGS="$cf_save_CFLAGS"
1367 fi
1368 rm -rf conftest*
1369
1370 AC_SUBST(EXTRA_CFLAGS)
1371 ])dnl
1372 dnl ---------------------------------------------------------------------------
1373 dnl CF_GNATPREP_OPT_T version: 1 updated: 2014/08/02 18:37:25
1374 dnl -----------------
1375 AC_DEFUN([CF_GNATPREP_OPT_T],[
1376 AC_CACHE_CHECK(if GNATPREP supports -T option,cf_cv_gnatprep_opt_t,[
1377 cf_cv_gnatprep_opt_t=no
1378 gnatprep -T 2>/dev/null >/dev/null && cf_cv_gnatprep_opt_t=yes
1379 ])
1380 test "$cf_cv_gnatprep_opt_t" = yes && GNATPREP_OPTS="-T $GNATPREP_OPTS"
1381 AC_SUBST(GNATPREP_OPTS)
1382 ])dnl
1383 dnl ---------------------------------------------------------------------------
1384 dnl CF_GNAT_GENERICS version: 4 updated: 2019/12/31 08:53:54
1385 dnl ----------------
1386 AC_DEFUN([CF_GNAT_GENERICS],
1387 [
1388 AC_REQUIRE([CF_GNAT_VERSION])
1389
1390 AC_MSG_CHECKING(if GNAT supports generics)
1391 case $cf_cv_gnat_version in
1392 (3.[[1-9]]*|[[4-9]].*)
1393         cf_gnat_generics=yes
1394         ;;
1395 (*)
1396         cf_gnat_generics=no
1397         ;;
1398 esac
1399 AC_MSG_RESULT($cf_gnat_generics)
1400
1401 if test "$cf_gnat_generics" = yes
1402 then
1403         cf_compile_generics=generics
1404         cf_generic_objects="\${GENOBJS}"
1405 else
1406         cf_compile_generics=
1407         cf_generic_objects=
1408 fi
1409
1410 AC_SUBST(cf_compile_generics)
1411 AC_SUBST(cf_generic_objects)
1412 ])dnl
1413 dnl ---------------------------------------------------------------------------
1414 dnl CF_GNAT_PROJECTS version: 10 updated: 2019/12/31 08:53:54
1415 dnl ----------------
1416 dnl GNAT projects are configured with ".gpr" project files.
1417 dnl GNAT libraries are a further development, using the project feature.
1418 AC_DEFUN([CF_GNAT_PROJECTS],
1419 [
1420 AC_REQUIRE([CF_GNAT_VERSION])
1421 AC_REQUIRE([CF_DISABLE_GNAT_PROJECTS])
1422
1423 cf_gnat_libraries=no
1424 cf_gnat_projects=no
1425
1426 if test "$enable_gnat_projects" != no ; then
1427 AC_MSG_CHECKING(if GNAT supports project files)
1428 case $cf_cv_gnat_version in
1429 (3.[[0-9]]*)
1430         ;;
1431 (*)
1432         case $cf_cv_system_name in
1433         (cygwin*|msys*)
1434                 ;;
1435         (*)
1436                 rm -rf conftest* *~conftest*
1437                 if mkdir conftest.src conftest.bin conftest.lib
1438                 then
1439                         cd conftest.src
1440                         rm -rf conftest* *~conftest*
1441                         cat >>library.gpr <<CF_EOF
1442 project Library is
1443   Kind := External ("LIB_KIND");
1444   for Library_Name use "ConfTest";
1445   for Object_Dir use ".";
1446   for Library_ALI_Dir use External("LIBRARY_DIR");
1447   for Library_Version use External ("SONAME");
1448   for Library_Kind use Kind;
1449   for Library_Dir use External("BUILD_DIR");
1450   Source_Dir := External ("SOURCE_DIR");
1451   for Source_Dirs use (Source_Dir);
1452 end Library;
1453 CF_EOF
1454                         cat >>confpackage.ads <<CF_EOF
1455 package ConfPackage is
1456    procedure conftest;
1457 end ConfPackage;
1458 CF_EOF
1459                         cat >>confpackage.adb <<CF_EOF
1460 with Text_IO;
1461 package body ConfPackage is
1462    procedure conftest is
1463    begin
1464       Text_IO.Put ("Hello World");
1465       Text_IO.New_Line;
1466    end conftest;
1467 end ConfPackage;
1468 CF_EOF
1469                         if ( $cf_ada_make $ADAFLAGS \
1470                                         -Plibrary.gpr \
1471                                         -XBUILD_DIR=`cd ../conftest.bin;pwd` \
1472                                         -XLIBRARY_DIR=`cd ../conftest.lib;pwd` \
1473                                         -XSOURCE_DIR=`pwd` \
1474                                         -XSONAME=libConfTest.so.1 \
1475                                         -XLIB_KIND=static 1>&AC_FD_CC 2>&1 ) ; then
1476                                 cf_gnat_projects=yes
1477                         fi
1478                         cd ..
1479                 fi
1480                 if test -f conftest.lib/confpackage.ali
1481                 then
1482                         cf_gnat_libraries=yes
1483                 fi
1484                 rm -rf conftest* *~conftest*
1485                 ;;
1486         esac
1487         ;;
1488 esac
1489 AC_MSG_RESULT($cf_gnat_projects)
1490 fi # enable_gnat_projects
1491
1492 if test $cf_gnat_projects = yes
1493 then
1494         AC_MSG_CHECKING(if GNAT supports libraries)
1495         AC_MSG_RESULT($cf_gnat_libraries)
1496 fi
1497
1498 if test "$cf_gnat_projects" = yes
1499 then
1500         USE_OLD_MAKERULES="#"
1501         USE_GNAT_PROJECTS=""
1502 else
1503         USE_OLD_MAKERULES=""
1504         USE_GNAT_PROJECTS="#"
1505 fi
1506
1507 if test "$cf_gnat_libraries" = yes
1508 then
1509         USE_GNAT_LIBRARIES=""
1510 else
1511         USE_GNAT_LIBRARIES="#"
1512 fi
1513
1514 AC_SUBST(USE_OLD_MAKERULES)
1515 AC_SUBST(USE_GNAT_PROJECTS)
1516 AC_SUBST(USE_GNAT_LIBRARIES)
1517 ])dnl
1518 dnl ---------------------------------------------------------------------------
1519 dnl CF_GNAT_SIGINT version: 1 updated: 2011/03/27 20:07:59
1520 dnl --------------
1521 dnl Check if gnat supports SIGINT, and presumably tasking.  For the latter, it
1522 dnl is noted that gnat may compile a tasking unit even for configurations which
1523 dnl fail at runtime.
1524 AC_DEFUN([CF_GNAT_SIGINT],[
1525 AC_CACHE_CHECK(if GNAT supports SIGINT,cf_cv_gnat_sigint,[
1526 CF_GNAT_TRY_LINK([with Ada.Interrupts.Names;
1527
1528 package ConfTest is
1529
1530    pragma Warnings (Off);  --  the next pragma exists since 3.11p
1531    pragma Unreserve_All_Interrupts;
1532    pragma Warnings (On);
1533
1534    protected Process is
1535       procedure Stop;
1536       function Continue return Boolean;
1537       pragma Attach_Handler (Stop, Ada.Interrupts.Names.SIGINT);
1538    private
1539       Done : Boolean := False;
1540    end Process;
1541
1542 end ConfTest;],
1543 [package body ConfTest is
1544    protected body Process is
1545       procedure Stop is
1546       begin
1547          Done := True;
1548       end Stop;
1549       function Continue return Boolean is
1550       begin
1551          return not Done;
1552       end Continue;
1553    end Process;
1554 end ConfTest;],
1555         [cf_cv_gnat_sigint=yes],
1556         [cf_cv_gnat_sigint=no])])
1557
1558 if test $cf_cv_gnat_sigint = yes ; then
1559         USE_GNAT_SIGINT=""
1560 else
1561         USE_GNAT_SIGINT="#"
1562 fi
1563 AC_SUBST(USE_GNAT_SIGINT)
1564 ])dnl
1565 dnl ---------------------------------------------------------------------------
1566 dnl CF_GNAT_TRY_LINK version: 3 updated: 2011/03/19 14:47:45
1567 dnl ----------------
1568 dnl Verify that a test program compiles/links with GNAT.
1569 dnl $cf_ada_make is set to the program that compiles/links
1570 dnl $ADAFLAGS may be set to the GNAT flags.
1571 dnl
1572 dnl $1 is the text of the spec
1573 dnl $2 is the text of the body
1574 dnl $3 is the shell command to execute if successful
1575 dnl $4 is the shell command to execute if not successful
1576 AC_DEFUN([CF_GNAT_TRY_LINK],
1577 [
1578 rm -rf conftest* *~conftest*
1579 cat >>conftest.ads <<CF_EOF
1580 $1
1581 CF_EOF
1582 cat >>conftest.adb <<CF_EOF
1583 $2
1584 CF_EOF
1585 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1586 ifelse($3,,      :,[      $3])
1587 ifelse($4,,,[else
1588    $4])
1589 fi
1590 rm -rf conftest* *~conftest*
1591 ])dnl
1592 dnl ---------------------------------------------------------------------------
1593 dnl CF_GNAT_TRY_RUN version: 5 updated: 2011/03/19 14:47:45
1594 dnl ---------------
1595 dnl Verify that a test program compiles and runs with GNAT
1596 dnl $cf_ada_make is set to the program that compiles/links
1597 dnl $ADAFLAGS may be set to the GNAT flags.
1598 dnl
1599 dnl $1 is the text of the spec
1600 dnl $2 is the text of the body
1601 dnl $3 is the shell command to execute if successful
1602 dnl $4 is the shell command to execute if not successful
1603 AC_DEFUN([CF_GNAT_TRY_RUN],
1604 [
1605 rm -rf conftest* *~conftest*
1606 cat >>conftest.ads <<CF_EOF
1607 $1
1608 CF_EOF
1609 cat >>conftest.adb <<CF_EOF
1610 $2
1611 CF_EOF
1612 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1613    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
1614 ifelse($3,,      :,[      $3])
1615 ifelse($4,,,[   else
1616       $4])
1617    fi
1618 ifelse($4,,,[else
1619    $4])
1620 fi
1621 rm -rf conftest* *~conftest*
1622 ])dnl
1623 dnl ---------------------------------------------------------------------------
1624 dnl CF_GNAT_VERSION version: 22 updated: 2019/12/31 08:53:54
1625 dnl ---------------
1626 dnl $1 = cache variable to update
1627 dnl $2 = program name
1628 dnl Verify version of GNAT or related tool
1629 AC_DEFUN([CF_GNAT_VERSION],
1630 [
1631 AC_CACHE_CHECK(for ifelse($2,,gnat,$2) version, cf_cv_gnat_version,[
1632 cf_cv_gnat_version=`ifelse($2,,${cf_ada_make:-gnatmake},$2) --version 2>&1 | \
1633         grep '[[0-9]].[[0-9]][[0-9]]*' |\
1634         sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
1635 ])
1636 test -z "$cf_cv_gnat_version" && cf_cv_gnat_version=no
1637 ifelse($1,,,[eval $1=$cf_cv_gnat_version; unset cf_cv_gnat_version])
1638 ])dnl
1639 dnl ---------------------------------------------------------------------------
1640 dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
1641 dnl -------------
1642 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1643 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1644 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1645 dnl since it is interwoven with GNU extensions.
1646 dnl
1647 dnl Well, yes we could work around it...
1648 dnl
1649 dnl Parameters:
1650 dnl     $1 is the nominal value for _XOPEN_SOURCE
1651 AC_DEFUN([CF_GNU_SOURCE],
1652 [
1653 cf_gnu_xopen_source=ifelse($1,,500,$1)
1654
1655 AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
1656 AC_TRY_COMPILE([#include <sys/types.h>],[
1657         #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
1658                 return 0;
1659         #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
1660                 return 0;
1661         #else
1662         #       error not GNU C library
1663         #endif],
1664         [cf_cv_gnu_library=yes],
1665         [cf_cv_gnu_library=no])
1666 ])
1667
1668 if test x$cf_cv_gnu_library = xyes; then
1669
1670         # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
1671         # was changed to help a little.  newlib incorporated the change about 4
1672         # years later.
1673         AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
1674                 cf_save="$CPPFLAGS"
1675                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
1676                 AC_TRY_COMPILE([#include <sys/types.h>],[
1677                         #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
1678                                 return 0;
1679                         #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
1680                                 return 0;
1681                         #else
1682                         #       error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
1683                         #endif],
1684                         [cf_cv_gnu_library_219=yes],
1685                         [cf_cv_gnu_library_219=no])
1686                 CPPFLAGS="$cf_save"
1687         ])
1688
1689         if test "x$cf_cv_gnu_library_219" = xyes; then
1690                 cf_save="$CPPFLAGS"
1691                 AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
1692                         CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
1693                         AC_TRY_COMPILE([
1694                                 #include <limits.h>
1695                                 #include <sys/types.h>
1696                                 ],[
1697                                 #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
1698                                         return 0;
1699                                 #else
1700                                 #       error GNU C library is too old
1701                                 #endif],
1702                                 [cf_cv_gnu_dftsrc_219=yes],
1703                                 [cf_cv_gnu_dftsrc_219=no])
1704                         ])
1705                 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
1706         else
1707                 cf_cv_gnu_dftsrc_219=maybe
1708         fi
1709
1710         if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
1711
1712                 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1713                 AC_TRY_COMPILE([#include <sys/types.h>],[
1714                         #ifndef _XOPEN_SOURCE
1715                         #error  expected _XOPEN_SOURCE to be defined
1716                         #endif],
1717                         [cf_cv_gnu_source=no],
1718                         [cf_save="$CPPFLAGS"
1719                          CF_ADD_CFLAGS(-D_GNU_SOURCE)
1720                          AC_TRY_COMPILE([#include <sys/types.h>],[
1721                                 #ifdef _XOPEN_SOURCE
1722                                 #error  expected _XOPEN_SOURCE to be undefined
1723                                 #endif],
1724                                 [cf_cv_gnu_source=no],
1725                                 [cf_cv_gnu_source=yes])
1726                         CPPFLAGS="$cf_save"
1727                         ])
1728                 ])
1729
1730                 if test "$cf_cv_gnu_source" = yes
1731                 then
1732                 AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
1733                         CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
1734                         AC_TRY_COMPILE([#include <sys/types.h>],[
1735                                 #ifdef _DEFAULT_SOURCE
1736                                 #error  expected _DEFAULT_SOURCE to be undefined
1737                                 #endif],
1738                                 [cf_cv_default_source=no],
1739                                 [cf_cv_default_source=yes])
1740                         ])
1741                         if test "$cf_cv_default_source" = yes
1742                         then
1743                                 CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
1744                         fi
1745                 fi
1746         fi
1747
1748 fi
1749 ])dnl
1750 dnl ---------------------------------------------------------------------------
1751 dnl CF_HEADER_PATH version: 13 updated: 2015/04/15 19:08:48
1752 dnl --------------
1753 dnl Construct a search-list of directories for a nonstandard header-file
1754 dnl
1755 dnl Parameters
1756 dnl     $1 = the variable to return as result
1757 dnl     $2 = the package name
1758 AC_DEFUN([CF_HEADER_PATH],
1759 [
1760 $1=
1761
1762 # collect the current set of include-directories from compiler flags
1763 cf_header_path_list=""
1764 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1765         for cf_header_path in $CPPFLAGS $CFLAGS
1766         do
1767                 case $cf_header_path in
1768                 (-I*)
1769                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1770                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1771                         cf_header_path_list="$cf_header_path_list [$]$1"
1772                         ;;
1773                 esac
1774         done
1775 fi
1776
1777 # add the variations for the package we are looking for
1778 CF_SUBDIR_PATH($1,$2,include)
1779
1780 test "$includedir" != NONE && \
1781 test "$includedir" != "/usr/include" && \
1782 test -d "$includedir" && {
1783         test -d $includedir &&    $1="[$]$1 $includedir"
1784         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1785 }
1786
1787 test "$oldincludedir" != NONE && \
1788 test "$oldincludedir" != "/usr/include" && \
1789 test -d "$oldincludedir" && {
1790         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
1791         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1792 }
1793
1794 $1="[$]$1 $cf_header_path_list"
1795 ])dnl
1796 dnl ---------------------------------------------------------------------------
1797 dnl CF_HELP_MESSAGE version: 4 updated: 2019/12/31 08:53:54
1798 dnl ---------------
1799 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1800 AC_DEFUN([CF_HELP_MESSAGE],
1801 [CF_ACVERSION_CHECK(2.53,[],[
1802 AC_DIVERT_HELP($1)])dnl
1803 ])dnl
1804 dnl ---------------------------------------------------------------------------
1805 dnl CF_INCLUDE_DIRS version: 10 updated: 2014/09/19 20:58:42
1806 dnl ---------------
1807 dnl Construct the list of include-options according to whether we're building
1808 dnl in the source directory or using '--srcdir=DIR' option.
1809 AC_DEFUN([CF_INCLUDE_DIRS],
1810 [
1811 if test "$srcdir" != "."; then
1812         CPPFLAGS="-I\${srcdir}/../include $CPPFLAGS"
1813 fi
1814 CPPFLAGS="-I../include $CPPFLAGS"
1815 if test "$srcdir" != "."; then
1816         CPPFLAGS="-I\${srcdir} $CPPFLAGS"
1817 fi
1818 CPPFLAGS="-I. $CPPFLAGS"
1819 AC_SUBST(CPPFLAGS)
1820 ])dnl
1821 dnl ---------------------------------------------------------------------------
1822 dnl CF_INSTALL_OPTS version: 2 updated: 2018/08/18 12:19:21
1823 dnl ---------------
1824 dnl prompt for/fill-in useful install-program options
1825 AC_DEFUN([CF_INSTALL_OPTS],
1826 [
1827 CF_INSTALL_OPT_S
1828 CF_INSTALL_OPT_P
1829 CF_INSTALL_OPT_O
1830 ])dnl
1831 dnl ---------------------------------------------------------------------------
1832 dnl CF_INSTALL_OPT_O version: 2 updated: 2015/05/15 19:45:35
1833 dnl ----------------
1834 dnl Almost all "install" programs default to the current user's ownership.
1835 dnl Almost - MINIX is an exception.
1836 AC_DEFUN([CF_INSTALL_OPT_O],
1837 [
1838 AC_MSG_CHECKING(if install needs to be told about ownership)
1839 case `$ac_config_guess` in
1840 (*minix)
1841         with_install_o=yes
1842         ;;
1843 (*)
1844         with_install_o=no
1845         ;;
1846 esac
1847
1848 AC_MSG_RESULT($with_install_o)
1849 if test "x$with_install_o" = xyes
1850 then
1851         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'`
1852 else
1853         INSTALL_OPT_O=
1854 fi
1855
1856 AC_SUBST(INSTALL_OPT_O)
1857 ])dnl
1858 dnl ---------------------------------------------------------------------------
1859 dnl CF_INSTALL_OPT_P version: 1 updated: 2018/08/18 12:19:21
1860 dnl ----------------
1861 dnl Some install-programs accept a "-p" option to preserve file modification
1862 dnl timestamps.  That can be useful as an install option, as well as a way to
1863 dnl avoid the need for ranlib after copying a static archive.
1864 AC_DEFUN([CF_INSTALL_OPT_P],
1865 [
1866 : ${INSTALL:=install}
1867 AC_CACHE_CHECK(if install accepts -p option, cf_cv_install_p,[
1868         rm -rf conftest*
1869         date >conftest.in
1870         mkdir conftest.out
1871         sleep 3
1872         if $INSTALL -p conftest.in conftest.out 2>/dev/null
1873         then
1874                 if test -f conftest.out/conftest.in
1875                 then
1876                         test conftest.in -nt conftest.out/conftest.in 2>conftest.err && \
1877                         test conftest.out/conftest.in -nt conftest.in 2>conftest.err
1878                         if test -s conftest.err
1879                         then
1880                                 cf_cv_install_p=no
1881                         else
1882                                 cf_cv_install_p=yes
1883                         fi
1884                 else
1885                         cf_cv_install_p=no
1886                 fi
1887         else
1888                 cf_cv_install_p=no
1889         fi
1890         rm -rf conftest*
1891 ])
1892 ])dnl
1893 dnl ---------------------------------------------------------------------------
1894 dnl CF_INSTALL_OPT_S version: 2 updated: 2018/08/18 12:19:21
1895 dnl ----------------
1896 dnl By default, we should strip executables which are installed, but leave the
1897 dnl ability to suppress that for unit-testing.
1898 AC_DEFUN([CF_INSTALL_OPT_S],
1899 [
1900 AC_MSG_CHECKING(if you want to install stripped executables)
1901 CF_ARG_DISABLE(stripping,
1902         [  --disable-stripping     do not strip (debug info) installed executables],
1903         [with_stripping=no],
1904         [with_stripping=yes])
1905 AC_MSG_RESULT($with_stripping)
1906
1907 if test "$with_stripping" = yes
1908 then
1909         INSTALL_OPT_S="-s"
1910 else
1911         INSTALL_OPT_S=
1912 fi
1913 AC_SUBST(INSTALL_OPT_S)
1914 ])dnl
1915 dnl ---------------------------------------------------------------------------
1916 dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
1917 dnl -----------------
1918 dnl Check if the given compiler is really the Intel compiler for Linux.  It
1919 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1920 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1921 dnl
1922 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1923 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1924 dnl the wrappers for gcc and g++ warnings.
1925 dnl
1926 dnl $1 = GCC (default) or GXX
1927 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1928 dnl $3 = CFLAGS (default) or CXXFLAGS
1929 AC_DEFUN([CF_INTEL_COMPILER],[
1930 AC_REQUIRE([AC_CANONICAL_HOST])
1931 ifelse([$2],,INTEL_COMPILER,[$2])=no
1932
1933 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1934         case $host_os in
1935         (linux*|gnu*)
1936                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1937                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1938                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1939                 AC_TRY_COMPILE([],[
1940 #ifdef __INTEL_COMPILER
1941 #else
1942 make an error
1943 #endif
1944 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1945 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1946 ],[])
1947                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1948                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1949                 ;;
1950         esac
1951 fi
1952 ])dnl
1953 dnl ---------------------------------------------------------------------------
1954 dnl CF_LARGEFILE version: 11 updated: 2018/06/20 20:23:13
1955 dnl ------------
1956 dnl Add checks for large file support.
1957 AC_DEFUN([CF_LARGEFILE],[
1958 ifdef([AC_FUNC_FSEEKO],[
1959         AC_SYS_LARGEFILE
1960         if test "$enable_largefile" != no ; then
1961         AC_FUNC_FSEEKO
1962
1963         # Normally we would collect these definitions in the config.h,
1964         # but (like _XOPEN_SOURCE), some environments rely on having these
1965         # defined before any of the system headers are included.  Another
1966         # case comes up with C++, e.g., on AIX the compiler compiles the
1967         # header files by themselves before looking at the body files it is
1968         # told to compile.  For ncurses, those header files do not include
1969         # the config.h
1970         if test "$ac_cv_sys_large_files" != no
1971         then
1972                 CF_APPEND_TEXT(CPPFLAGS,-D_LARGE_FILES)
1973         fi
1974         if test "$ac_cv_sys_largefile_source" != no
1975         then
1976                 CF_APPEND_TEXT(CPPFLAGS,-D_LARGEFILE_SOURCE)
1977         fi
1978         if test "$ac_cv_sys_file_offset_bits" != no
1979         then
1980                 CF_APPEND_TEXT(CPPFLAGS,-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits)
1981         fi
1982
1983         AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
1984                 AC_TRY_COMPILE([
1985 #pragma GCC diagnostic error "-Wincompatible-pointer-types"
1986 #include <sys/types.h>
1987 #include <dirent.h>
1988                 ],[
1989                 /* if transitional largefile support is setup, this is true */
1990                 extern struct dirent64 * readdir(DIR *);
1991                 struct dirent64 *x = readdir((DIR *)0);
1992                 struct dirent *y = readdir((DIR *)0);
1993                 int z = x - y;
1994                 ],
1995                 [cf_cv_struct_dirent64=yes],
1996                 [cf_cv_struct_dirent64=no])
1997         ])
1998         test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64])
1999         fi
2000 ])
2001 ])
2002 dnl ---------------------------------------------------------------------------
2003 dnl CF_LD_RPATH_OPT version: 8 updated: 2018/08/18 16:36:35
2004 dnl ---------------
2005 dnl For the given system and compiler, find the compiler flags to pass to the
2006 dnl loader to use the "rpath" feature.
2007 AC_DEFUN([CF_LD_RPATH_OPT],
2008 [
2009 AC_REQUIRE([CF_CHECK_CACHE])
2010
2011 LD_RPATH_OPT=
2012 if test "x$cf_cv_enable_rpath" != xno
2013 then
2014         AC_MSG_CHECKING(for an rpath option)
2015         case $cf_cv_system_name in
2016         (irix*)
2017                 if test "$GCC" = yes; then
2018                         LD_RPATH_OPT="-Wl,-rpath,"
2019                 else
2020                         LD_RPATH_OPT="-rpath "
2021                 fi
2022                 ;;
2023         (linux*|gnu*|k*bsd*-gnu|freebsd*)
2024                 LD_RPATH_OPT="-Wl,-rpath,"
2025                 ;;
2026         (openbsd[[2-9]].*|mirbsd*)
2027                 LD_RPATH_OPT="-Wl,-rpath,"
2028                 ;;
2029         (dragonfly*)
2030                 LD_RPATH_OPT="-rpath "
2031                 ;;
2032         (netbsd*)
2033                 LD_RPATH_OPT="-Wl,-rpath,"
2034                 ;;
2035         (osf*|mls+*)
2036                 LD_RPATH_OPT="-rpath "
2037                 ;;
2038         (solaris2*)
2039                 LD_RPATH_OPT="-R"
2040                 ;;
2041         (*)
2042                 ;;
2043         esac
2044         AC_MSG_RESULT($LD_RPATH_OPT)
2045
2046         case "x$LD_RPATH_OPT" in
2047         (x-R*)
2048                 AC_MSG_CHECKING(if we need a space after rpath option)
2049                 cf_save_LIBS="$LIBS"
2050                 CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
2051                 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
2052                 LIBS="$cf_save_LIBS"
2053                 AC_MSG_RESULT($cf_rpath_space)
2054                 test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
2055                 ;;
2056         esac
2057 fi
2058 ])dnl
2059 dnl ---------------------------------------------------------------------------
2060 dnl CF_LIBRARY_PATH version: 10 updated: 2015/04/15 19:08:48
2061 dnl ---------------
2062 dnl Construct a search-list of directories for a nonstandard library-file
2063 dnl
2064 dnl Parameters
2065 dnl     $1 = the variable to return as result
2066 dnl     $2 = the package name
2067 AC_DEFUN([CF_LIBRARY_PATH],
2068 [
2069 $1=
2070 cf_library_path_list=""
2071 if test -n "${LDFLAGS}${LIBS}" ; then
2072         for cf_library_path in $LDFLAGS $LIBS
2073         do
2074                 case $cf_library_path in
2075                 (-L*)
2076                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
2077                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
2078                         cf_library_path_list="$cf_library_path_list [$]$1"
2079                         ;;
2080                 esac
2081         done
2082 fi
2083
2084 CF_SUBDIR_PATH($1,$2,lib)
2085
2086 $1="$cf_library_path_list [$]$1"
2087 ])dnl
2088 dnl ---------------------------------------------------------------------------
2089 dnl CF_LIB_PREFIX version: 12 updated: 2015/10/17 19:03:33
2090 dnl -------------
2091 dnl Compute the library-prefix for the given host system
2092 dnl $1 = variable to set
2093 define([CF_LIB_PREFIX],
2094 [
2095         case $cf_cv_system_name in
2096         (OS/2*|os2*)
2097                 if test "$DFT_LWR_MODEL" = libtool; then
2098                         LIB_PREFIX='lib'
2099                 else
2100                         LIB_PREFIX=''
2101                 fi
2102                 ;;
2103         (*)     LIB_PREFIX='lib'
2104                 ;;
2105         esac
2106 ifelse($1,,,[$1=$LIB_PREFIX])
2107         AC_SUBST(LIB_PREFIX)
2108 ])dnl
2109 dnl ---------------------------------------------------------------------------
2110 dnl CF_LIB_SUFFIX version: 25 updated: 2015/04/17 21:13:04
2111 dnl -------------
2112 dnl Compute the library file-suffix from the given model name
2113 dnl $1 = model name
2114 dnl $2 = variable to set (the nominal library suffix)
2115 dnl $3 = dependency variable to set (actual filename)
2116 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
2117 AC_DEFUN([CF_LIB_SUFFIX],
2118 [
2119         case X$1 in
2120         (Xlibtool)
2121                 $2='.la'
2122                 $3=[$]$2
2123                 ;;
2124         (Xdebug)
2125                 $2='_g.a'
2126                 $3=[$]$2
2127                 ;;
2128         (Xprofile)
2129                 $2='_p.a'
2130                 $3=[$]$2
2131                 ;;
2132         (Xshared)
2133                 case $cf_cv_system_name in
2134                 (aix[[5-7]]*)
2135                         $2='.so'
2136                         $3=[$]$2
2137                         ;;
2138                 (cygwin*|msys*|mingw*)
2139                         $2='.dll'
2140                         $3='.dll.a'
2141                         ;;
2142                 (darwin*)
2143                         $2='.dylib'
2144                         $3=[$]$2
2145                         ;;
2146                 (hpux*)
2147                         case $target in
2148                         (ia64*)
2149                                 $2='.so'
2150                                 $3=[$]$2
2151                                 ;;
2152                         (*)
2153                                 $2='.sl'
2154                                 $3=[$]$2
2155                                 ;;
2156                         esac
2157                         ;;
2158                 (*)
2159                         $2='.so'
2160                         $3=[$]$2
2161                         ;;
2162                 esac
2163                 ;;
2164         (*)
2165                 $2='.a'
2166                 $3=[$]$2
2167                 ;;
2168         esac
2169         if test -n "${LIB_SUFFIX}${EXTRA_SUFFIX}"
2170         then
2171                 $2="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$2}"
2172                 $3="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$3}"
2173         fi
2174 ])dnl
2175 dnl ---------------------------------------------------------------------------
2176 dnl CF_LIB_TYPE version: 5 updated: 2015/04/17 21:13:04
2177 dnl -----------
2178 dnl Compute the string to append to -library from the given model name
2179 dnl $1 = model name
2180 dnl $2 = variable to set
2181 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
2182 AC_DEFUN([CF_LIB_TYPE],
2183 [
2184         case $1 in
2185         (libtool) $2=''   ;;
2186         (normal)  $2=''   ;;
2187         (debug)   $2='_g' ;;
2188         (profile) $2='_p' ;;
2189         (shared)  $2=''   ;;
2190         esac
2191         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
2192 ])dnl
2193 dnl ---------------------------------------------------------------------------
2194 dnl CF_LINK_DATAONLY version: 12 updated: 2017/07/23 17:46:07
2195 dnl ----------------
2196 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
2197 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
2198 dnl have to provide wrappers for global tables to ensure they're linked
2199 dnl properly.
2200 AC_DEFUN([CF_LINK_DATAONLY],
2201 [
2202 AC_MSG_CHECKING([if data-only library module links])
2203 AC_CACHE_VAL(cf_cv_link_dataonly,[
2204         rm -f conftest.a
2205         cat >conftest.$ac_ext <<EOF
2206 #line __oline__ "configure"
2207 int     testdata[[3]] = { 123, 456, 789 };
2208 EOF
2209         if AC_TRY_EVAL(ac_compile) ; then
2210                 mv conftest.o data.o && \
2211                 ( $AR $ARFLAGS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
2212         fi
2213         rm -f conftest.$ac_ext data.o
2214         cat >conftest.$ac_ext <<EOF
2215 #line __oline__ "configure"
2216 int     testfunc(void)
2217 {
2218 #if defined(NeXT)
2219         ${cf_cv_main_return:-return}(1);        /* I'm told this linker is broken */
2220 #else
2221         extern int testdata[[3]];
2222         return testdata[[0]] == 123
2223            &&  testdata[[1]] == 456
2224            &&  testdata[[2]] == 789;
2225 #endif
2226 }
2227 EOF
2228         if AC_TRY_EVAL(ac_compile); then
2229                 mv conftest.o func.o && \
2230                 ( $AR $ARFLAGS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
2231         fi
2232         rm -f conftest.$ac_ext func.o
2233         ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
2234         cf_saveLIBS="$LIBS"
2235         LIBS="conftest.a $LIBS"
2236         AC_TRY_RUN([
2237         int main(void)
2238         {
2239                 extern int testfunc();
2240                 ${cf_cv_main_return:-return} (!testfunc());
2241         }
2242         ],
2243         [cf_cv_link_dataonly=yes],
2244         [cf_cv_link_dataonly=no],
2245         [cf_cv_link_dataonly=unknown])
2246         LIBS="$cf_saveLIBS"
2247         ])
2248 AC_MSG_RESULT($cf_cv_link_dataonly)
2249
2250 if test "$cf_cv_link_dataonly" = no ; then
2251         AC_DEFINE(BROKEN_LINKER,1,[if data-only library module does not link])
2252         BROKEN_LINKER=1
2253 fi
2254
2255 ])dnl
2256 dnl ---------------------------------------------------------------------------
2257 dnl CF_MAKEFLAGS version: 18 updated: 2018/02/21 21:26:03
2258 dnl ------------
2259 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
2260 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
2261 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
2262 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
2263 AC_DEFUN([CF_MAKEFLAGS],
2264 [
2265 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
2266         cf_cv_makeflags=''
2267         for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
2268         do
2269                 cat >cf_makeflags.tmp <<CF_EOF
2270 SHELL = $SHELL
2271 all :
2272         @ echo '.$cf_option'
2273 CF_EOF
2274                 cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp 2>/dev/null | fgrep -v "ing directory" | sed -e 's,[[   ]]*$,,'`
2275                 case "$cf_result" in
2276                 (.*k|.*kw)
2277                         cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
2278                         case "$cf_result" in
2279                         (.*CC=*)        cf_cv_makeflags=
2280                                 ;;
2281                         (*)     cf_cv_makeflags=$cf_option
2282                                 ;;
2283                         esac
2284                         break
2285                         ;;
2286                 (.-)
2287                         ;;
2288                 (*)
2289                         CF_MSG_LOG(given option \"$cf_option\", no match \"$cf_result\")
2290                         ;;
2291                 esac
2292         done
2293         rm -f cf_makeflags.tmp
2294 ])
2295
2296 AC_SUBST(cf_cv_makeflags)
2297 ])dnl
2298 dnl ---------------------------------------------------------------------------
2299 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
2300 dnl ------------
2301 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
2302 dnl a monocase filesystem.
2303 AC_DEFUN([CF_MAKE_TAGS],[
2304 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
2305
2306 AC_CHECK_PROGS(CTAGS, exctags ctags)
2307 AC_CHECK_PROGS(ETAGS, exetags etags)
2308
2309 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
2310
2311 if test "$cf_cv_mixedcase" = yes ; then
2312         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
2313 else
2314         MAKE_UPPER_TAGS=no
2315 fi
2316
2317 if test "$MAKE_UPPER_TAGS" = yes ; then
2318         MAKE_UPPER_TAGS=
2319 else
2320         MAKE_UPPER_TAGS="#"
2321 fi
2322
2323 if test "$MAKE_LOWER_TAGS" = yes ; then
2324         MAKE_LOWER_TAGS=
2325 else
2326         MAKE_LOWER_TAGS="#"
2327 fi
2328
2329 AC_SUBST(CTAGS)
2330 AC_SUBST(ETAGS)
2331
2332 AC_SUBST(MAKE_UPPER_TAGS)
2333 AC_SUBST(MAKE_LOWER_TAGS)
2334 ])dnl
2335 dnl ---------------------------------------------------------------------------
2336 dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
2337 dnl ----------------------
2338 dnl Check if the file-system supports mixed-case filenames.  If we're able to
2339 dnl create a lowercase name and see it as uppercase, it doesn't support that.
2340 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
2341 [
2342 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
2343 if test "$cross_compiling" = yes ; then
2344         case $target_alias in
2345         (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
2346                 cf_cv_mixedcase=no
2347                 ;;
2348         (*)
2349                 cf_cv_mixedcase=yes
2350                 ;;
2351         esac
2352 else
2353         rm -f conftest CONFTEST
2354         echo test >conftest
2355         if test -f CONFTEST ; then
2356                 cf_cv_mixedcase=no
2357         else
2358                 cf_cv_mixedcase=yes
2359         fi
2360         rm -f conftest CONFTEST
2361 fi
2362 ])
2363 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
2364 ])dnl
2365 dnl ---------------------------------------------------------------------------
2366 dnl CF_MKSTEMP version: 10 updated: 2017/01/21 11:12:16
2367 dnl ----------
2368 dnl Check for a working mkstemp.  This creates two files, checks that they are
2369 dnl successfully created and distinct (AmigaOS apparently fails on the last).
2370 AC_DEFUN([CF_MKSTEMP],[
2371 AC_CHECK_HEADERS( \
2372 unistd.h \
2373 )
2374 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
2375 rm -rf conftest*
2376 AC_TRY_RUN([
2377 #include <sys/types.h>
2378 #ifdef HAVE_UNISTD_H
2379 #include <unistd.h>
2380 #endif
2381 #include <stdlib.h>
2382 #include <stdio.h>
2383 #include <string.h>
2384 #include <sys/stat.h>
2385 int main(void)
2386 {
2387         char *tmpl = "conftestXXXXXX";
2388         char name[2][80];
2389         int n;
2390         int result = 0;
2391         int fd;
2392         struct stat sb;
2393
2394         umask(077);
2395         for (n = 0; n < 2; ++n) {
2396                 strcpy(name[n], tmpl);
2397                 if ((fd = mkstemp(name[n])) >= 0) {
2398                         if (!strcmp(name[n], tmpl)
2399                          || stat(name[n], &sb) != 0
2400                          || (sb.st_mode & S_IFMT) != S_IFREG
2401                          || (sb.st_mode & 077) != 0) {
2402                                 result = 1;
2403                         }
2404                         close(fd);
2405                 }
2406         }
2407         if (result == 0
2408          && !strcmp(name[0], name[1]))
2409                 result = 1;
2410         ${cf_cv_main_return:-return}(result);
2411 }
2412 ],[cf_cv_func_mkstemp=yes
2413 ],[cf_cv_func_mkstemp=no
2414 ],[cf_cv_func_mkstemp=maybe])
2415 ])
2416 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
2417         AC_CHECK_FUNC(mkstemp)
2418 fi
2419 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
2420         AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
2421 fi
2422 ])dnl
2423 dnl ---------------------------------------------------------------------------
2424 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
2425 dnl ----------
2426 dnl Write a debug message to config.log, along with the line number in the
2427 dnl configure script.
2428 AC_DEFUN([CF_MSG_LOG],[
2429 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
2430 ])dnl
2431 dnl ---------------------------------------------------------------------------
2432 dnl CF_NCURSES_ADDON version: 5 updated: 2015/04/26 18:06:58
2433 dnl ----------------
2434 dnl Configure an ncurses add-on, built outside the ncurses tree.
2435 AC_DEFUN([CF_NCURSES_ADDON],[
2436 AC_REQUIRE([CF_NCURSES_CONFIG])
2437
2438 AC_PROVIDE([CF_SUBST_NCURSES_VERSION])
2439
2440 AC_MSG_CHECKING(if you want wide-character code)
2441 AC_ARG_ENABLE(widec,
2442         [  --enable-widec          compile with wide-char/UTF-8 code],
2443         [with_widec=$enableval],
2444         [with_widec=no])
2445 AC_MSG_RESULT($with_widec)
2446 if test "$with_widec" = yes ; then
2447         CF_UTF8_LIB
2448         CF_NCURSES_CONFIG(ncursesw)
2449 else
2450         CF_NCURSES_CONFIG(ncurses)
2451 fi
2452
2453 if test "$NCURSES_CONFIG_PKG" != none ; then
2454         cf_version=`$PKG_CONFIG --modversion $NCURSES_CONFIG_PKG 2>/dev/null`
2455
2456         NCURSES_MAJOR=`echo "$cf_version" | sed -e 's/\..*//'`
2457         NCURSES_MINOR=`echo "$cf_version" | sed -e 's/^[[0-9]][[0-9]]*\.//' -e 's/\..*//'`
2458         NCURSES_PATCH=`echo "$cf_version" | sed -e 's/^[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.//'`
2459
2460         cf_cv_abi_version=`$PKG_CONFIG --variable=abi_version $NCURSES_CONFIG_PKG 2>/dev/null`
2461         if test -z "$cf_cv_abi_version"
2462         then
2463                 cf_cv_abi_version=`$PKG_CONFIG --variable=major_version $NCURSES_CONFIG_PKG 2>/dev/null`
2464         fi
2465
2466 elif test "$NCURSES_CONFIG" != none ; then
2467
2468         cf_version=`$NCURSES_CONFIG --version 2>/dev/null`
2469
2470         NCURSES_MAJOR=`echo "$cf_version" | sed -e 's/\..*//'`
2471         NCURSES_MINOR=`echo "$cf_version" | sed -e 's/^[[0-9]][[0-9]]*\.//' -e 's/\..*//'`
2472         NCURSES_PATCH=`echo "$cf_version" | sed -e 's/^[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.//'`
2473
2474         # ABI version is not available from headers
2475         cf_cv_abi_version=`$NCURSES_CONFIG --abi-version 2>/dev/null`
2476
2477 else
2478
2479         for cf_name in MAJOR MINOR PATCH
2480         do
2481         cat >conftest.$ac_ext <<CF_EOF
2482         #include <${cf_cv_ncurses_header:-curses.h}>
2483         AUTOCONF_$cf_name NCURSES_VERSION_$cf_name
2484 CF_EOF
2485                 cf_try="$ac_cpp conftest.$ac_ext 2>&5 | fgrep AUTOCONF_$cf_name >conftest.out"
2486                 AC_TRY_EVAL(cf_try)
2487                 if test -f conftest.out ; then
2488                         cf_result=`cat conftest.out | sed -e "s/^.*AUTOCONF_$cf_name[[  ]][[    ]]*//"`
2489                         eval NCURSES_$cf_name=\"$cf_result\"
2490                         # cat conftest.$ac_ext
2491                         # cat conftest.out
2492                 fi
2493         done
2494
2495         cf_cv_abi_version=${NCURSES_MAJOR}
2496
2497 fi
2498
2499 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
2500
2501 dnl Show the computed version, for logging
2502 cf_cv_timestamp=`date`
2503
2504 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
2505
2506 dnl We need these values in the generated headers
2507 AC_SUBST(NCURSES_MAJOR)
2508 AC_SUBST(NCURSES_MINOR)
2509 AC_SUBST(NCURSES_PATCH)
2510
2511 dnl We need these values in the generated makefiles
2512 AC_SUBST(cf_cv_rel_version)
2513 AC_SUBST(cf_cv_abi_version)
2514
2515 dnl FIXME - not needed for Ada95
2516 AC_SUBST(cf_cv_builtin_bool)
2517 AC_SUBST(cf_cv_header_stdbool_h)
2518 AC_SUBST(cf_cv_type_of_bool)dnl
2519
2520 ])
2521 dnl ---------------------------------------------------------------------------
2522 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
2523 dnl -------------------
2524 dnl Check if we can compile with ncurses' header file
2525 dnl $1 is the cache variable to set
2526 dnl $2 is the header-file to include
2527 dnl $3 is the root name (ncurses or ncursesw)
2528 AC_DEFUN([CF_NCURSES_CC_CHECK],[
2529         AC_TRY_COMPILE([
2530 ]ifelse($3,ncursesw,[
2531 #define _XOPEN_SOURCE_EXTENDED
2532 #undef  HAVE_LIBUTF8_H  /* in case we used CF_UTF8_LIB */
2533 #define HAVE_LIBUTF8_H  /* to force ncurses' header file to use cchar_t */
2534 ])[
2535 #include <$2>],[
2536 #ifdef NCURSES_VERSION
2537 ]ifelse($3,ncursesw,[
2538 #ifndef WACS_BSSB
2539         make an error
2540 #endif
2541 ])[
2542 printf("%s\n", NCURSES_VERSION);
2543 #else
2544 #ifdef __NCURSES_H
2545 printf("old\n");
2546 #else
2547         make an error
2548 #endif
2549 #endif
2550         ]
2551         ,[$1=$2]
2552         ,[$1=no])
2553 ])dnl
2554 dnl ---------------------------------------------------------------------------
2555 dnl CF_NCURSES_CONFIG version: 21 updated: 2018/06/20 20:23:13
2556 dnl -----------------
2557 dnl Tie together the configure-script macros for ncurses, preferring these in
2558 dnl order:
2559 dnl a) ".pc" files for pkg-config, using $NCURSES_CONFIG_PKG
2560 dnl b) the "-config" script from ncurses, using $NCURSES_CONFIG
2561 dnl c) just plain libraries
2562 dnl
2563 dnl $1 is the root library name (default: "ncurses")
2564 AC_DEFUN([CF_NCURSES_CONFIG],[
2565 AC_REQUIRE([CF_PKG_CONFIG])
2566 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
2567 cf_have_ncuconfig=no
2568
2569 if test "x${PKG_CONFIG:=none}" != xnone; then
2570         AC_MSG_CHECKING(pkg-config for $cf_ncuconfig_root)
2571         if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
2572                 AC_MSG_RESULT(yes)
2573
2574                 AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
2575                 cf_have_ncuconfig=unknown
2576
2577                 cf_save_CPPFLAGS="$CPPFLAGS"
2578                 cf_save_LIBS="$LIBS"
2579
2580                 CF_ADD_CFLAGS(`$PKG_CONFIG --cflags $cf_ncuconfig_root`)
2581                 CF_ADD_LIBS(`$PKG_CONFIG --libs $cf_ncuconfig_root`)
2582
2583                 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2584                         [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2585                         [AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
2586                                 int main(void)
2587                                 { char *xx = curses_version(); return (xx == 0); }],
2588                                 [cf_have_ncuconfig=yes],
2589                                 [cf_have_ncuconfig=no],
2590                                 [cf_have_ncuconfig=maybe])],
2591                         [cf_have_ncuconfig=no])
2592                 AC_MSG_RESULT($cf_have_ncuconfig)
2593                 test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
2594                 if test "$cf_have_ncuconfig" != "yes"
2595                 then
2596                         CPPFLAGS="$cf_save_CPPFLAGS"
2597                         LIBS="$cf_save_LIBS"
2598                         NCURSES_CONFIG_PKG=none
2599                 else
2600                         AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2601                         NCURSES_CONFIG_PKG=$cf_ncuconfig_root
2602                         CF_TERM_HEADER
2603                 fi
2604
2605         else
2606                 AC_MSG_RESULT(no)
2607                 NCURSES_CONFIG_PKG=none
2608         fi
2609 else
2610         NCURSES_CONFIG_PKG=none
2611 fi
2612
2613 if test "x$cf_have_ncuconfig" = "xno"; then
2614         cf_ncurses_config="${cf_ncuconfig_root}${NCURSES_CONFIG_SUFFIX}-config"; echo "Looking for ${cf_ncurses_config}"
2615
2616         CF_ACVERSION_CHECK(2.52,
2617                 [AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
2618                 [AC_PATH_PROGS(NCURSES_CONFIG,  ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
2619
2620         if test "$NCURSES_CONFIG" != none ; then
2621
2622                 CF_ADD_CFLAGS(`$NCURSES_CONFIG --cflags`)
2623                 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
2624
2625                 # even with config script, some packages use no-override for curses.h
2626                 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
2627
2628                 dnl like CF_NCURSES_CPPFLAGS
2629                 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2630
2631                 dnl like CF_NCURSES_LIBS
2632                 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
2633                 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2634
2635                 dnl like CF_NCURSES_VERSION
2636                 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
2637
2638         else
2639
2640                 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
2641                 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
2642
2643         fi
2644 else
2645         NCURSES_CONFIG=none
2646 fi
2647 ])dnl
2648 dnl ---------------------------------------------------------------------------
2649 dnl CF_NCURSES_CPPFLAGS version: 21 updated: 2012/10/06 08:57:51
2650 dnl -------------------
2651 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
2652 dnl the CPPFLAGS variable so we can include its header.
2653 dnl
2654 dnl The header files may be installed as either curses.h, or ncurses.h (would
2655 dnl be obsolete, except that some packagers prefer this name to distinguish it
2656 dnl from a "native" curses implementation).  If not installed for overwrite,
2657 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2658 dnl /usr/include/ncurses), but someone may have installed overwriting the
2659 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
2660 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2661 dnl the header.
2662 dnl
2663 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2664 dnl is already in the include-path, don't even bother with this, since we cannot
2665 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
2666 dnl
2667 dnl The optional parameter gives the root name of the library, in case it is
2668 dnl not installed as the default curses library.  That is how the
2669 dnl wide-character version of ncurses is installed.
2670 AC_DEFUN([CF_NCURSES_CPPFLAGS],
2671 [AC_REQUIRE([CF_WITH_CURSES_DIR])
2672
2673 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2674 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2675
2676 test -n "$cf_cv_curses_dir" && \
2677 test "$cf_cv_curses_dir" != "no" && { \
2678   CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
2679 }
2680
2681 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2682         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2683         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2684         for cf_header in $cf_header_list
2685         do
2686                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2687                 test "$cf_cv_ncurses_h" != no && break
2688         done
2689 ])
2690
2691 CF_NCURSES_HEADER
2692 CF_TERM_HEADER
2693
2694 # some applications need this, but should check for NCURSES_VERSION
2695 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2696
2697 CF_NCURSES_VERSION
2698 ])dnl
2699 dnl ---------------------------------------------------------------------------
2700 dnl CF_NCURSES_HEADER version: 4 updated: 2015/04/15 19:08:48
2701 dnl -----------------
2702 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2703 dnl variations of ncurses' installs.
2704 dnl
2705 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2706 AC_DEFUN([CF_NCURSES_HEADER],[
2707
2708 if test "$cf_cv_ncurses_h" != no ; then
2709         cf_cv_ncurses_header=$cf_cv_ncurses_h
2710 else
2711
2712 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2713         test -n "$verbose" && echo
2714         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2715         test -n "$verbose" && echo search path $cf_search
2716         cf_save2_CPPFLAGS="$CPPFLAGS"
2717         for cf_incdir in $cf_search
2718         do
2719                 CF_ADD_INCDIR($cf_incdir)
2720                 for cf_header in \
2721                         ncurses.h \
2722                         curses.h
2723                 do
2724                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2725                         if test "$cf_cv_ncurses_h2" != no ; then
2726                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
2727                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
2728                                 break
2729                         fi
2730                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2731                 done
2732                 CPPFLAGS="$cf_save2_CPPFLAGS"
2733                 test "$cf_cv_ncurses_h2" != no && break
2734         done
2735         test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2736         ])
2737
2738         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2739         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2740         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2741                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2742         fi
2743         CF_ADD_INCDIR($cf_1st_incdir)
2744
2745 fi
2746
2747 # Set definitions to allow ifdef'ing for ncurses.h
2748
2749 case $cf_cv_ncurses_header in
2750 (*ncurses.h)
2751         AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
2752         ;;
2753 esac
2754
2755 case $cf_cv_ncurses_header in
2756 (ncurses/curses.h|ncurses/ncurses.h)
2757         AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
2758         ;;
2759 (ncursesw/curses.h|ncursesw/ncurses.h)
2760         AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
2761         ;;
2762 esac
2763
2764 ])dnl
2765 dnl ---------------------------------------------------------------------------
2766 dnl CF_NCURSES_LIBS version: 17 updated: 2015/04/15 19:08:48
2767 dnl ---------------
2768 dnl Look for the ncurses library.  This is a little complicated on Linux,
2769 dnl because it may be linked with the gpm (general purpose mouse) library.
2770 dnl Some distributions have gpm linked with (bsd) curses, which makes it
2771 dnl unusable with ncurses.  However, we don't want to link with gpm unless
2772 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2773 dnl and the linker will record a dependency.
2774 dnl
2775 dnl The optional parameter gives the root name of the library, in case it is
2776 dnl not installed as the default curses library.  That is how the
2777 dnl wide-character version of ncurses is installed.
2778 AC_DEFUN([CF_NCURSES_LIBS],
2779 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2780
2781 cf_nculib_root=ifelse($1,,ncurses,$1)
2782         # This works, except for the special case where we find gpm, but
2783         # ncurses is in a nonstandard location via $LIBS, and we really want
2784         # to link gpm.
2785 cf_ncurses_LIBS=""
2786 cf_ncurses_SAVE="$LIBS"
2787 AC_CHECK_LIB(gpm,Gpm_Open,
2788         [AC_CHECK_LIB(gpm,initscr,
2789                 [LIBS="$cf_ncurses_SAVE"],
2790                 [cf_ncurses_LIBS="-lgpm"])])
2791
2792 case $host_os in
2793 (freebsd*)
2794         # This is only necessary if you are linking against an obsolete
2795         # version of ncurses (but it should do no harm, since it's static).
2796         if test "$cf_nculib_root" = ncurses ; then
2797                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2798         fi
2799         ;;
2800 esac
2801
2802 CF_ADD_LIBS($cf_ncurses_LIBS)
2803
2804 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2805 then
2806         CF_ADD_LIBS(-l$cf_nculib_root)
2807 else
2808         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2809                 [#include <${cf_cv_ncurses_header:-curses.h}>],
2810                 [initscr()],
2811                 initscr)
2812 fi
2813
2814 if test -n "$cf_ncurses_LIBS" ; then
2815         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2816         cf_ncurses_SAVE="$LIBS"
2817         for p in $cf_ncurses_LIBS ; do
2818                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2819                 if test "$q" != "$LIBS" ; then
2820                         LIBS="$q"
2821                 fi
2822         done
2823         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2824                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2825                 [AC_MSG_RESULT(yes)],
2826                 [AC_MSG_RESULT(no)
2827                  LIBS="$cf_ncurses_SAVE"])
2828 fi
2829
2830 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2831 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2832 ])dnl
2833 dnl ---------------------------------------------------------------------------
2834 dnl CF_NCURSES_VERSION version: 15 updated: 2017/05/09 19:26:10
2835 dnl ------------------
2836 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2837 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
2838 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2839 AC_DEFUN([CF_NCURSES_VERSION],
2840 [
2841 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2842 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2843         cf_cv_ncurses_version=no
2844         cf_tempfile=out$$
2845         rm -f $cf_tempfile
2846         AC_TRY_RUN([
2847 #include <${cf_cv_ncurses_header:-curses.h}>
2848 #include <stdio.h>
2849 int main(void)
2850 {
2851         FILE *fp = fopen("$cf_tempfile", "w");
2852 #ifdef NCURSES_VERSION
2853 # ifdef NCURSES_VERSION_PATCH
2854         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2855 # else
2856         fprintf(fp, "%s\n", NCURSES_VERSION);
2857 # endif
2858 #else
2859 # ifdef __NCURSES_H
2860         fprintf(fp, "old\n");
2861 # else
2862         make an error
2863 # endif
2864 #endif
2865         ${cf_cv_main_return:-return}(0);
2866 }],[
2867         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2868
2869         # This will not work if the preprocessor splits the line after the
2870         # Autoconf token.  The 'unproto' program does that.
2871         cat > conftest.$ac_ext <<EOF
2872 #include <${cf_cv_ncurses_header:-curses.h}>
2873 #undef Autoconf
2874 #ifdef NCURSES_VERSION
2875 Autoconf NCURSES_VERSION
2876 #else
2877 #ifdef __NCURSES_H
2878 Autoconf "old"
2879 #endif
2880 ;
2881 #endif
2882 EOF
2883         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2884         AC_TRY_EVAL(cf_try)
2885         if test -f conftest.out ; then
2886                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2887                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2888                 rm -f conftest.out
2889         fi
2890 ])
2891         rm -f $cf_tempfile
2892 ])
2893 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2894 ])dnl
2895 dnl ---------------------------------------------------------------------------
2896 dnl CF_OBJ_SUBDIR version: 7 updated: 2015/04/17 21:13:04
2897 dnl -------------
2898 dnl Compute the object-directory name from the given model name
2899 AC_DEFUN([CF_OBJ_SUBDIR],
2900 [
2901         case $1 in
2902         (libtool) $2='obj_lo'  ;;
2903         (normal)  $2='objects' ;;
2904         (debug)   $2='obj_g' ;;
2905         (profile) $2='obj_p' ;;
2906         (shared)
2907                 case $cf_cv_system_name in
2908                 (cygwin|msys)
2909                         $2='objects' ;;
2910                 (*)
2911                         $2='obj_s' ;;
2912                 esac
2913         esac
2914 ])dnl
2915 dnl ---------------------------------------------------------------------------
2916 dnl CF_PATHSEP version: 7 updated: 2015/04/12 15:39:00
2917 dnl ----------
2918 dnl Provide a value for the $PATH and similar separator (or amend the value
2919 dnl as provided in autoconf 2.5x).
2920 AC_DEFUN([CF_PATHSEP],
2921 [
2922         AC_MSG_CHECKING(for PATH separator)
2923         case $cf_cv_system_name in
2924         (os2*)  PATH_SEPARATOR=';'  ;;
2925         (*)     ${PATH_SEPARATOR:=':'}  ;;
2926         esac
2927 ifelse([$1],,,[$1=$PATH_SEPARATOR])
2928         AC_SUBST(PATH_SEPARATOR)
2929         AC_MSG_RESULT($PATH_SEPARATOR)
2930 ])dnl
2931 dnl ---------------------------------------------------------------------------
2932 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
2933 dnl --------------
2934 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2935 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2936 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2937 dnl delayed evaluation of those symbols.
2938 AC_DEFUN([CF_PATH_SYNTAX],[
2939 if test "x$prefix" != xNONE; then
2940         cf_path_syntax="$prefix"
2941 else
2942         cf_path_syntax="$ac_default_prefix"
2943 fi
2944
2945 case ".[$]$1" in
2946 (.\[$]\(*\)*|.\'*\'*)
2947         ;;
2948 (..|./*|.\\*)
2949         ;;
2950 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
2951         ;;
2952 (.\[$]{*prefix}*|.\[$]{*dir}*)
2953         eval $1="[$]$1"
2954         case ".[$]$1" in
2955         (.NONE/*)
2956                 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2957                 ;;
2958         esac
2959         ;;
2960 (.no|.NONE/*)
2961         $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2962         ;;
2963 (*)
2964         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2965         ;;
2966 esac
2967 ])dnl
2968 dnl ---------------------------------------------------------------------------
2969 dnl CF_PKG_CONFIG version: 10 updated: 2015/04/26 18:06:58
2970 dnl -------------
2971 dnl Check for the package-config program, unless disabled by command-line.
2972 AC_DEFUN([CF_PKG_CONFIG],
2973 [
2974 AC_MSG_CHECKING(if you want to use pkg-config)
2975 AC_ARG_WITH(pkg-config,
2976         [  --with-pkg-config{=path} enable/disable use of pkg-config],
2977         [cf_pkg_config=$withval],
2978         [cf_pkg_config=yes])
2979 AC_MSG_RESULT($cf_pkg_config)
2980
2981 case $cf_pkg_config in
2982 (no)
2983         PKG_CONFIG=none
2984         ;;
2985 (yes)
2986         CF_ACVERSION_CHECK(2.52,
2987                 [AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
2988                 [AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
2989         ;;
2990 (*)
2991         PKG_CONFIG=$withval
2992         ;;
2993 esac
2994
2995 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2996 if test "$PKG_CONFIG" != none ; then
2997         CF_PATH_SYNTAX(PKG_CONFIG)
2998 elif test "x$cf_pkg_config" != xno ; then
2999         AC_MSG_WARN(pkg-config is not installed)
3000 fi
3001
3002 AC_SUBST(PKG_CONFIG)
3003 ])dnl
3004 dnl ---------------------------------------------------------------------------
3005 dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
3006 dnl -----------------
3007 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
3008 dnl
3009 dnl     POSIX.1-1990                            _POSIX_SOURCE
3010 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
3011 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
3012 dnl             Bindings Option
3013 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
3014 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
3015 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
3016 dnl
3017 dnl Parameters:
3018 dnl     $1 is the nominal value for _POSIX_C_SOURCE
3019 AC_DEFUN([CF_POSIX_C_SOURCE],
3020 [AC_REQUIRE([CF_POSIX_VISIBLE])dnl
3021
3022 if test "$cf_cv_posix_visible" = no; then
3023
3024 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
3025
3026 cf_save_CFLAGS="$CFLAGS"
3027 cf_save_CPPFLAGS="$CPPFLAGS"
3028
3029 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
3030 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
3031
3032 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
3033         CF_MSG_LOG(if the symbol is already defined go no further)
3034         AC_TRY_COMPILE([#include <sys/types.h>],[
3035 #ifndef _POSIX_C_SOURCE
3036 make an error
3037 #endif],
3038         [cf_cv_posix_c_source=no],
3039         [cf_want_posix_source=no
3040          case .$cf_POSIX_C_SOURCE in
3041          (.[[12]]??*)
3042                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3043                 ;;
3044          (.2)
3045                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3046                 cf_want_posix_source=yes
3047                 ;;
3048          (.*)
3049                 cf_want_posix_source=yes
3050                 ;;
3051          esac
3052          if test "$cf_want_posix_source" = yes ; then
3053                 AC_TRY_COMPILE([#include <sys/types.h>],[
3054 #ifdef _POSIX_SOURCE
3055 make an error
3056 #endif],[],
3057                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
3058          fi
3059          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
3060          CFLAGS="$cf_trim_CFLAGS"
3061          CPPFLAGS="$cf_trim_CPPFLAGS"
3062          CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
3063          CF_MSG_LOG(if the second compile does not leave our definition intact error)
3064          AC_TRY_COMPILE([#include <sys/types.h>],[
3065 #ifndef _POSIX_C_SOURCE
3066 make an error
3067 #endif],,
3068          [cf_cv_posix_c_source=no])
3069          CFLAGS="$cf_save_CFLAGS"
3070          CPPFLAGS="$cf_save_CPPFLAGS"
3071         ])
3072 ])
3073
3074 if test "$cf_cv_posix_c_source" != no ; then
3075         CFLAGS="$cf_trim_CFLAGS"
3076         CPPFLAGS="$cf_trim_CPPFLAGS"
3077         CF_ADD_CFLAGS($cf_cv_posix_c_source)
3078 fi
3079
3080 fi # cf_cv_posix_visible
3081
3082 ])dnl
3083 dnl ---------------------------------------------------------------------------
3084 dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
3085 dnl ----------------
3086 dnl POSIX documents test-macros which an application may set before any system
3087 dnl headers are included to make features available.
3088 dnl
3089 dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
3090 dnl diverged from POSIX in 2002 by setting symbols which make all of the most
3091 dnl recent features visible in the system header files unless the application
3092 dnl overrides the corresponding test-macros.  Doing that introduces portability
3093 dnl problems.
3094 dnl
3095 dnl This macro makes a special check for the symbols used for this, to avoid a
3096 dnl conflicting definition.
3097 AC_DEFUN([CF_POSIX_VISIBLE],
3098 [
3099 AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
3100 AC_TRY_COMPILE([#include <stdio.h>],[
3101 #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
3102         && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
3103         && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
3104         && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
3105 #error conflicting symbols found
3106 #endif
3107 ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
3108 ])
3109 ])dnl
3110 dnl ---------------------------------------------------------------------------
3111 dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
3112 dnl ----------
3113 dnl Check for archiver "ar".
3114 AC_DEFUN([CF_PROG_AR],[
3115 AC_CHECK_TOOL(AR, ar, ar)
3116 ])
3117 dnl ---------------------------------------------------------------------------
3118 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
3119 dnl -----------
3120 dnl Check for awk, ensure that the check found something.
3121 AC_DEFUN([CF_PROG_AWK],
3122 [
3123 AC_PROG_AWK
3124 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
3125 ])dnl
3126 dnl ---------------------------------------------------------------------------
3127 dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
3128 dnl ----------
3129 dnl standard check for CC, plus followup sanity checks
3130 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
3131 AC_DEFUN([CF_PROG_CC],[
3132 CF_ACVERSION_CHECK(2.53,
3133         [AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
3134          AC_REQUIRE([AC_PROG_CC])],
3135         [])
3136 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
3137 CF_GCC_VERSION
3138 CF_ACVERSION_CHECK(2.52,
3139         [AC_PROG_CC_STDC],
3140         [CF_ANSI_CC_REQD])
3141 CF_CC_ENV_FLAGS
3142 ])dnl
3143 dnl ---------------------------------------------------------------------------
3144 dnl CF_PROG_CC_C_O version: 5 updated: 2017/01/21 11:06:25
3145 dnl --------------
3146 dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
3147 dnl the output file can be renamed, and allows for a shell variable that can
3148 dnl be used later.  The parameter is either CC or CXX.  The result is the
3149 dnl cache variable:
3150 dnl     $cf_cv_prog_CC_c_o
3151 dnl     $cf_cv_prog_CXX_c_o
3152 dnl
3153 dnl $1 = compiler
3154 dnl $2 = compiler options, if any
3155 AC_DEFUN([CF_PROG_CC_C_O],
3156 [AC_REQUIRE([AC_PROG_CC])dnl
3157 AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
3158 AC_CACHE_VAL(cf_cv_prog_$1_c_o,
3159 [
3160 cat > conftest.$ac_ext <<CF_EOF
3161 int main(void)
3162 {
3163         ${cf_cv_main_return:-return}(0);
3164 }
3165 CF_EOF
3166 # We do the test twice because some compilers refuse to overwrite an
3167 # existing .o file with -o, though they will create one.
3168 ac_try='[$]$1 $2 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
3169 if AC_TRY_EVAL(ac_try) &&
3170   test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
3171 then
3172   eval cf_cv_prog_$1_c_o=yes
3173 else
3174   eval cf_cv_prog_$1_c_o=no
3175 fi
3176 rm -rf conftest*
3177 ])dnl
3178 if test $cf_cv_prog_$1_c_o = yes; then
3179   AC_MSG_RESULT([yes])
3180 else
3181   AC_MSG_RESULT([no])
3182 fi
3183 ])dnl
3184 dnl ---------------------------------------------------------------------------
3185 dnl CF_PROG_EGREP version: 2 updated: 2015/04/18 08:56:57
3186 dnl -------------
3187 dnl AC_PROG_EGREP was introduced in autoconf 2.53.
3188 dnl This macro adds a check to ensure the script found something.
3189 AC_DEFUN([CF_PROG_EGREP],
3190 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
3191         [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
3192                 then ac_cv_prog_egrep='grep -E'
3193                 else ac_cv_prog_egrep='egrep'
3194         fi])
3195         EGREP=$ac_cv_prog_egrep
3196         AC_SUBST([EGREP])
3197         test -z "$EGREP" && AC_MSG_ERROR(No egrep program found)
3198 ])dnl
3199 dnl ---------------------------------------------------------------------------
3200 dnl CF_PROG_EXT version: 14 updated: 2018/06/20 20:23:13
3201 dnl -----------
3202 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
3203 AC_DEFUN([CF_PROG_EXT],
3204 [
3205 AC_REQUIRE([CF_CHECK_CACHE])
3206 case $cf_cv_system_name in
3207 (os2*)
3208         CFLAGS="$CFLAGS -Zmt"
3209         CF_APPEND_TEXT(CPPFLAGS,-D__ST_MT_ERRNO__)
3210         CXXFLAGS="$CXXFLAGS -Zmt"
3211         # autoconf's macro sets -Zexe and suffix both, which conflict:w
3212         LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
3213         ac_cv_exeext=.exe
3214         ;;
3215 esac
3216
3217 AC_EXEEXT
3218 AC_OBJEXT
3219
3220 PROG_EXT="$EXEEXT"
3221 AC_SUBST(PROG_EXT)
3222 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT",[Define to the program extension (normally blank)])
3223 ])dnl
3224 dnl ---------------------------------------------------------------------------
3225 dnl CF_PROG_GNAT version: 10 updated: 2019/12/31 08:53:54
3226 dnl ------------
3227 dnl Check for gnat/gnatmake/etc, ensure that the toolset is complete.
3228 AC_DEFUN([CF_PROG_GNAT],[
3229 for cf_prog_gnat in gnat gnatmake gprconfig gprbuild
3230 do
3231         CF_UPPER(cf_upper_prog_gnat,${cf_prog_gnat})
3232
3233         unset ac_cv_path_cf_TEMP_gnat
3234         unset cf_TEMP_gnat
3235         AC_PATH_PROG(cf_TEMP_gnat,$cf_prog_gnat,no)
3236         eval cf_cv_PATH_$cf_upper_prog_gnat=[$]ac_cv_path_cf_TEMP_gnat
3237
3238         if test "x$cf_TEMP_gnat" != xno; then
3239                 unset cf_cv_gnat_version
3240                 unset cf_TEMP_gnat
3241                 CF_GNAT_VERSION(cf_TEMP_gnat,$cf_prog_gnat)
3242         fi
3243         eval cf_cv_VERSION_$cf_upper_prog_gnat=[$]cf_TEMP_gnat
3244
3245         unset cf_TEMP_gnat
3246         unset cf_cv_gnat_version
3247         unset ac_cv_path_cf_TEMP_gnat
3248 done
3249
3250 if test "x$cf_cv_VERSION_GNATMAKE" = "xno"; then
3251         cf_ada_make=
3252         cf_cv_prog_gnat_correct=no
3253 else
3254         cf_ada_make=gnatmake
3255         if test "x$cf_cv_VERSION_GPRCONFIG" = "xno"; then
3256                 # gprconfig is newer than gnatmake; we can continue...
3257                 cf_ada_config="##"
3258         else
3259                 rm -rf conftest* *~conftest*
3260                 if mkdir conftest.src
3261                 then
3262                         cf_ada_config=""
3263                         cd conftest.src
3264                         for cf_gprconfig in Ada C
3265                         do
3266                                 AC_MSG_CHECKING(for gprconfig name for $cf_gprconfig)
3267                                 if test $cf_gprconfig = C
3268                                 then
3269                                         for cf_gprconfig_param in \
3270                                                 $cf_gprconfig,,,,GNATGCC \
3271                                                 $cf_gprconfig,,,,GCC \
3272                                                 $cf_gprconfig
3273                                         do
3274                                                 cf_gprconfig_value=`echo s| gprconfig --config=$cf_gprconfig_param 2>&AC_FD_CC | ${AWK:-awk} '/^\*/{print [$]3;}' | head -n 1`
3275                                                 test -n "$cf_gprconfig_value" && break
3276                                         done
3277                                 else
3278                                         cf_gprconfig_param=$cf_gprconfig
3279                                         cf_gprconfig_value=`echo s| gprconfig --config=$cf_gprconfig_param 2>&AC_FD_CC | ${AWK:-awk} '/^\*/{print [$]3;}' | head -n 1`
3280                                 fi
3281                                 if test -n "$cf_gprconfig_value"
3282                                 then
3283                                         eval cf_ada_config_[$]cf_gprconfig=[$]cf_gprconfig_value
3284                                         AC_MSG_RESULT($cf_gprconfig_value)
3285                                 else
3286                                         AC_MSG_RESULT(missing)
3287                                         cf_ada_config="#"
3288                                         break
3289                                 fi
3290                         done
3291                         cd ..
3292                         rm -rf conftest* *~conftest*
3293                 fi
3294         fi
3295         if test "x$cf_ada_config" != "x#"
3296         then
3297                 CF_GNAT_VERSION
3298                 CF_CHECK_GNAT_VERSION
3299                 AC_CHECK_PROG(M4_exists, m4, yes, no)
3300                 if test "$ac_cv_prog_M4_exists" = no; then
3301                         cf_cv_prog_gnat_correct=no
3302                         AC_MSG_WARN(Ada95 binding required program m4 not found. Ada95 binding disabled)
3303                 fi
3304                 if test "$cf_cv_prog_gnat_correct" = yes; then
3305                         AC_MSG_CHECKING(if GNAT works)
3306                         CF_GNAT_TRY_RUN([procedure conftest;],
3307 [with Text_IO;
3308 with GNAT.OS_Lib;
3309 procedure conftest is
3310 begin
3311    Text_IO.Put ("Hello World");
3312    Text_IO.New_Line;
3313    GNAT.OS_Lib.OS_Exit (0);
3314 end conftest;],
3315 [cf_cv_prog_gnat_correct=yes],
3316 [cf_cv_prog_gnat_correct=no])
3317                         AC_MSG_RESULT($cf_cv_prog_gnat_correct)
3318                 fi
3319         else
3320                 cf_cv_prog_gnat_correct=no
3321         fi
3322 fi
3323
3324 AC_SUBST(cf_ada_make)
3325 AC_SUBST(cf_ada_config)
3326 AC_SUBST(cf_ada_config_Ada)
3327 AC_SUBST(cf_ada_config_C)
3328 ])dnl
3329 dnl ---------------------------------------------------------------------------
3330 dnl CF_PROG_INSTALL version: 7 updated: 2015/04/18 08:56:57
3331 dnl ---------------
3332 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
3333 dnl misc/tabset install won't work properly.  Usually this happens only when
3334 dnl using the fallback mkinstalldirs script
3335 AC_DEFUN([CF_PROG_INSTALL],
3336 [AC_PROG_INSTALL
3337 case $INSTALL in
3338 (/*)
3339         ;;
3340 (*)
3341         CF_DIRNAME(cf_dir,$INSTALL)
3342         test -z "$cf_dir" && cf_dir=.
3343         INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
3344         ;;
3345 esac
3346 ])dnl
3347 dnl ---------------------------------------------------------------------------
3348 dnl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
3349 dnl ------------
3350 dnl Combine checks for "ln -s" and "ln -sf", updating $LN_S to include "-f"
3351 dnl option if it is supported.
3352 AC_DEFUN([CF_PROG_LN_S],[
3353 AC_PROG_LN_S
3354 AC_MSG_CHECKING(if $LN_S -f options work)
3355
3356 rm -f conf$$.src conf$$dst
3357 echo >conf$$.dst
3358 echo first >conf$$.src
3359 if $LN_S -f conf$$.src conf$$.dst 2>/dev/null; then
3360         cf_prog_ln_sf=yes
3361 else
3362         cf_prog_ln_sf=no
3363 fi
3364 rm -f conf$$.dst conf$$src
3365 AC_MSG_RESULT($cf_prog_ln_sf)
3366
3367 test "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
3368 ])dnl
3369 dnl ---------------------------------------------------------------------------
3370 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
3371 dnl ----------------
3372 dnl Remove all -U and -D options that refer to the given symbol from a list
3373 dnl of C compiler options.  This works around the problem that not all
3374 dnl compilers process -U and -D options from left-to-right, so a -U option
3375 dnl cannot be used to cancel the effect of a preceding -D option.
3376 dnl
3377 dnl $1 = target (which could be the same as the source variable)
3378 dnl $2 = source (including '$')
3379 dnl $3 = symbol to remove
3380 define([CF_REMOVE_DEFINE],
3381 [
3382 $1=`echo "$2" | \
3383         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
3384                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
3385 ])dnl
3386 dnl ---------------------------------------------------------------------------
3387 dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
3388 dnl -------------
3389 dnl Remove the given library from the symbol
3390 dnl
3391 dnl $1 = target (which could be the same as the source variable)
3392 dnl $2 = source (including '$')
3393 dnl $3 = library to remove
3394 define([CF_REMOVE_LIB],
3395 [
3396 # remove $3 library from $2
3397 $1=`echo "$2" | sed -e 's/-l$3[[        ]]//g' -e 's/-l$3[$]//'`
3398 ])dnl
3399 dnl ---------------------------------------------------------------------------
3400 dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
3401 dnl ---------------------
3402 dnl Restore flags saved in CF_SAVE_XTRA_FLAGS
3403 dnl $1 = name of current macro
3404 define([CF_RESTORE_XTRA_FLAGS],
3405 [
3406 LIBS="$cf_save_LIBS_$1"
3407 CFLAGS="$cf_save_CFLAGS_$1"
3408 CPPFLAGS="$cf_save_CPPFLAGS_$1"
3409 ])dnl
3410 dnl ---------------------------------------------------------------------------
3411 dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
3412 dnl ------------------
3413 dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
3414 dnl and libraries which do not update those variables.
3415 dnl
3416 dnl $1 = name of current macro
3417 define([CF_SAVE_XTRA_FLAGS],
3418 [
3419 cf_save_LIBS_$1="$LIBS"
3420 cf_save_CFLAGS_$1="$CFLAGS"
3421 cf_save_CPPFLAGS_$1="$CPPFLAGS"
3422 LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
3423 for cf_X_CFLAGS in $X_CFLAGS
3424 do
3425         case "x$cf_X_CFLAGS" in
3426         x-[[IUD]]*)
3427                 CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
3428                 ;;
3429         *)
3430                 CFLAGS="$CFLAGS $cf_X_CFLAGS"
3431                 ;;
3432         esac
3433 done
3434 ])dnl
3435 dnl ---------------------------------------------------------------------------
3436 dnl CF_SHARED_OPTS version: 93 updated: 2018/08/18 16:36:35
3437 dnl --------------
3438 dnl --------------
3439 dnl Attempt to determine the appropriate CC/LD options for creating a shared
3440 dnl library.
3441 dnl
3442 dnl Notes:
3443 dnl a) ${LOCAL_LDFLAGS} is used to link executables that will run within
3444 dnl the build-tree, i.e., by making use of the libraries that are compiled in
3445 dnl $rel_builddir/lib We avoid compiling-in a $rel_builddir/lib path for the
3446 dnl shared library since that can lead to unexpected results at runtime.
3447 dnl b) ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared
3448 dnl libraries are compiled in ../../lib
3449 dnl
3450 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
3451 dnl to install symbolic links to the rel/abi versions of shared libraries.
3452 dnl
3453 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
3454 dnl version when making symbolic links.
3455 dnl
3456 dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
3457 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
3458 dnl (ex: libncurses.so.<ver>).
3459 dnl
3460 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
3461 AC_DEFUN([CF_SHARED_OPTS],
3462 [
3463         AC_REQUIRE([CF_LD_RPATH_OPT])
3464
3465         RM_SHARED_OPTS=
3466         LOCAL_LDFLAGS=
3467         LOCAL_LDFLAGS2=
3468         LD_SHARED_OPTS=
3469         INSTALL_LIB="-m 644"
3470         : ${rel_builddir:=.}
3471
3472         shlibdir=$libdir
3473         AC_SUBST(shlibdir)
3474
3475         MAKE_DLLS="#"
3476         AC_SUBST(MAKE_DLLS)
3477
3478         cf_cv_do_symlinks=no
3479         cf_ld_rpath_opt=
3480         test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
3481
3482         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
3483         AC_ARG_WITH(shlib-version,
3484         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
3485         [test -z "$withval" && withval=auto
3486         case $withval in
3487         (yes)
3488                 cf_cv_shlib_version=auto
3489                 ;;
3490         (rel|abi|auto)
3491                 cf_cv_shlib_version=$withval
3492                 ;;
3493         (*)
3494                 AC_MSG_RESULT($withval)
3495                 AC_MSG_ERROR([option value must be one of: rel, abi, or auto])
3496                 ;;
3497         esac
3498         ],[cf_cv_shlib_version=auto])
3499         AC_MSG_RESULT($cf_cv_shlib_version)
3500
3501         cf_cv_rm_so_locs=no
3502         cf_try_cflags=
3503
3504         # Some less-capable ports of gcc support only -fpic
3505         CC_SHARED_OPTS=
3506
3507         cf_try_fPIC=no
3508         if test "$GCC" = yes
3509         then
3510                 cf_try_fPIC=yes
3511         else
3512                 case $cf_cv_system_name in
3513                 (*linux*)       # e.g., PGI compiler
3514                         cf_try_fPIC=yes
3515                         ;;
3516                 esac
3517         fi
3518
3519         if test "$cf_try_fPIC" = yes
3520         then
3521                 AC_MSG_CHECKING(which $CC option to use)
3522                 cf_save_CFLAGS="$CFLAGS"
3523                 for CC_SHARED_OPTS in -fPIC -fpic ''
3524                 do
3525                         CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
3526                         AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
3527                 done
3528                 AC_MSG_RESULT($CC_SHARED_OPTS)
3529                 CFLAGS="$cf_save_CFLAGS"
3530         fi
3531
3532         cf_cv_shlib_version_infix=no
3533
3534         case $cf_cv_system_name in
3535         (aix4.[3-9]*|aix[[5-7]]*)
3536                 if test "$GCC" = yes; then
3537                         CC_SHARED_OPTS='-Wl,-brtl'
3538                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
3539                 else
3540                         CC_SHARED_OPTS='-brtl'
3541                         # as well as '-qpic=large -G' or perhaps "-bM:SRE -bnoentry -bexpall"
3542                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -G -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
3543                 fi
3544                 ;;
3545         (beos*)
3546                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
3547                 ;;
3548         (cygwin*)
3549                 CC_SHARED_OPTS=
3550                 MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
3551                 RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
3552                 cf_cv_shlib_version=cygdll
3553                 cf_cv_shlib_version_infix=cygdll
3554                 shlibdir=$bindir
3555                 MAKE_DLLS=
3556                 cat >mk_shared_lib.sh <<-CF_EOF
3557                 #!$SHELL
3558                 SHARED_LIB=\[$]1
3559                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
3560                 shift
3561                 cat <<-EOF
3562                 Linking shared library
3563                 ** SHARED_LIB \[$]SHARED_LIB
3564                 ** IMPORT_LIB \[$]IMPORT_LIB
3565 EOF
3566                 exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
3567 CF_EOF
3568                 chmod +x mk_shared_lib.sh
3569                 ;;
3570         (msys*)
3571                 CC_SHARED_OPTS=
3572                 MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
3573                 RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
3574                 cf_cv_shlib_version=msysdll
3575                 cf_cv_shlib_version_infix=msysdll
3576                 shlibdir=$bindir
3577                 MAKE_DLLS=
3578                 cat >mk_shared_lib.sh <<-CF_EOF
3579                 #!$SHELL
3580                 SHARED_LIB=\[$]1
3581                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/msys-/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
3582                 shift
3583                 cat <<-EOF
3584                 Linking shared library
3585                 ** SHARED_LIB \[$]SHARED_LIB
3586                 ** IMPORT_LIB \[$]IMPORT_LIB
3587 EOF
3588                 exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
3589 CF_EOF
3590                 chmod +x mk_shared_lib.sh
3591                 ;;
3592         (darwin*)
3593                 cf_try_cflags="no-cpp-precomp"
3594                 CC_SHARED_OPTS="-dynamic"
3595                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
3596                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
3597                 cf_cv_shlib_version_infix=yes
3598                 AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
3599                         cf_save_LDFLAGS=$LDFLAGS
3600                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
3601                         AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
3602                                 LDFLAGS=$cf_save_LDFLAGS])
3603                 if test $cf_cv_ldflags_search_paths_first = yes; then
3604                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
3605                 fi
3606                 ;;
3607         (hpux[[7-8]]*)
3608                 # HP-UX 8.07 ld lacks "+b" option used for libdir search-list
3609                 if test "$GCC" != yes; then
3610                         CC_SHARED_OPTS='+Z'
3611                 fi
3612                 MK_SHARED_LIB='${LD} ${LDFLAGS} -b -o $[@]'
3613                 INSTALL_LIB="-m 555"
3614                 ;;
3615         (hpux*)
3616                 # (tested with gcc 2.7.2 -- I don't have c89)
3617                 if test "$GCC" = yes; then
3618                         LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
3619                 else
3620                         CC_SHARED_OPTS='+Z'
3621                         LD_SHARED_OPTS='-Wl,+b,${libdir}'
3622                 fi
3623                 MK_SHARED_LIB='${LD} ${LDFLAGS} +b ${libdir} -b -o $[@]'
3624                 # HP-UX shared libraries must be executable, and should be
3625                 # readonly to exploit a quirk in the memory manager.
3626                 INSTALL_LIB="-m 555"
3627                 ;;
3628         (interix*)
3629                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3630                 if test "$cf_cv_shlib_version" = rel; then
3631                         cf_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
3632                 else
3633                         cf_shared_soname='`basename $[@]`'
3634                 fi
3635                 CC_SHARED_OPTS=
3636                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-rpath,${RPATH_LIST} -Wl,-h,'$cf_shared_soname' -o $[@]'
3637                 ;;
3638         (irix*)
3639                 if test "$cf_cv_enable_rpath" = yes ; then
3640                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3641                 fi
3642                 # tested with IRIX 5.2 and 'cc'.
3643                 if test "$GCC" != yes; then
3644                         CC_SHARED_OPTS='-KPIC'
3645                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
3646                 else
3647                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,`basename $[@]` -o $[@]'
3648                 fi
3649                 cf_cv_rm_so_locs=yes
3650                 ;;
3651         (linux*|gnu*|k*bsd*-gnu)
3652                 if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
3653                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
3654                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3655                 fi
3656                 if test "$cf_cv_enable_rpath" = yes ; then
3657                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3658                 fi
3659                 CF_SHARED_SONAME
3660                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
3661                 ;;
3662         (mingw*)
3663                 cf_cv_shlib_version=mingw
3664                 cf_cv_shlib_version_infix=mingw
3665                 shlibdir=$bindir
3666                 MAKE_DLLS=
3667                 if test "$DFT_LWR_MODEL" = "shared" ; then
3668                         LOCAL_LDFLAGS="-Wl,--enable-auto-import"
3669                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3670                         EXTRA_LDFLAGS="-Wl,--enable-auto-import $EXTRA_LDFLAGS"
3671                 fi
3672                 CC_SHARED_OPTS=
3673                 MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
3674                 RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
3675                 cat >mk_shared_lib.sh <<-CF_EOF
3676                 #!$SHELL
3677                 SHARED_LIB=\[$]1
3678                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
3679                 shift
3680                 cat <<-EOF
3681                 Linking shared library
3682                 ** SHARED_LIB \[$]SHARED_LIB
3683                 ** IMPORT_LIB \[$]IMPORT_LIB
3684 EOF
3685                 exec \[$]* ${LDFLAGS} -shared -Wl,--enable-auto-import,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
3686 CF_EOF
3687                 chmod +x mk_shared_lib.sh
3688                 ;;
3689         (openbsd[[2-9]].*|mirbsd*)
3690                 if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
3691                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
3692                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3693                 fi
3694                 if test "$cf_cv_enable_rpath" = yes ; then
3695                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3696                 fi
3697                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3698                 CF_SHARED_SONAME
3699                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
3700                 ;;
3701         (nto-qnx*|openbsd*|freebsd[[12]].*)
3702                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3703                 MK_SHARED_LIB='${LD} ${LDFLAGS} -Bshareable -o $[@]'
3704                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3705                 ;;
3706         (dragonfly*|freebsd*)
3707                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3708                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
3709                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
3710                         LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${RPATH_LIST} $LOCAL_LDFLAGS"
3711                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3712                 fi
3713                 CF_SHARED_SONAME
3714                 MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
3715                 ;;
3716         (netbsd*)
3717                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3718                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
3719                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
3720                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3721                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3722                         if test "$cf_cv_shlib_version" = auto; then
3723                         if test -f /usr/libexec/ld.elf_so; then
3724                                 cf_cv_shlib_version=abi
3725                         else
3726                                 cf_cv_shlib_version=rel
3727                         fi
3728                         fi
3729                         CF_SHARED_SONAME
3730                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
3731                 else
3732                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -Wl,-shared -Wl,-Bshareable -o $[@]'
3733                 fi
3734                 ;;
3735         (osf*|mls+*)
3736                 # tested with OSF/1 V3.2 and 'cc'
3737                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
3738                 # link with shared libs).
3739                 MK_SHARED_LIB='${LD} ${LDFLAGS} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
3740                 case $host_os in
3741                 (osf4*)
3742                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
3743                         ;;
3744                 esac
3745                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
3746                 if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
3747                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
3748                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3749                 fi
3750                 cf_cv_rm_so_locs=yes
3751                 ;;
3752         (sco3.2v5*)  # also uw2* and UW7: hops 13-Apr-98
3753                 # tested with osr5.0.5
3754                 if test "$GCC" != yes; then
3755                         CC_SHARED_OPTS='-belf -KPIC'
3756                 fi
3757                 MK_SHARED_LIB='${LD} ${LDFLAGS} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
3758                 if test "$cf_cv_enable_rpath" = yes ; then
3759                         # only way is to set LD_RUN_PATH but no switch for it
3760                         RUN_PATH=$libdir
3761                 fi
3762                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3763                 LINK_PROGS='LD_RUN_PATH=${libdir}'
3764                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
3765                 ;;
3766         (sunos4*)
3767                 # tested with SunOS 4.1.1 and gcc 2.7.0
3768                 if test "$GCC" != yes; then
3769                         CC_SHARED_OPTS='-KPIC'
3770                 fi
3771                 MK_SHARED_LIB='${LD} ${LDFLAGS} -assert pure-text -o $[@]'
3772                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3773                 ;;
3774         (solaris2*)
3775                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
3776                 # tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
3777                 if test "$DFT_LWR_MODEL" = "shared" ; then
3778                         LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
3779                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3780                 fi
3781                 if test "$cf_cv_enable_rpath" = yes ; then
3782                         EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
3783                 fi
3784                 CF_SHARED_SONAME
3785                 if test "$GCC" != yes; then
3786                         cf_save_CFLAGS="$CFLAGS"
3787                         for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
3788                         do
3789                                 CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
3790                                 AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\n");],[break])
3791                         done
3792                         CFLAGS="$cf_save_CFLAGS"
3793                         CC_SHARED_OPTS=$cf_shared_opts
3794                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
3795                 else
3796                         MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
3797                 fi
3798                 ;;
3799         (sysv5uw7*|unix_sv*)
3800                 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
3801                 if test "$GCC" != yes; then
3802                         CC_SHARED_OPTS='-KPIC'
3803                 fi
3804                 MK_SHARED_LIB='${LD} ${LDFLAGS} -d y -G -o [$]@'
3805                 ;;
3806         (*)
3807                 CC_SHARED_OPTS='unknown'
3808                 MK_SHARED_LIB='echo unknown'
3809                 ;;
3810         esac
3811
3812         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
3813         case "$cf_cv_shlib_version" in
3814         (rel|abi)
3815                 case "$MK_SHARED_LIB" in
3816                 (*'-o $[@]')
3817                         test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
3818                         ;;
3819                 (*)
3820                         AC_MSG_WARN(ignored --with-shlib-version)
3821                         ;;
3822                 esac
3823                 ;;
3824         esac
3825
3826         if test -n "$cf_try_cflags"
3827         then
3828 cat > conftest.$ac_ext <<EOF
3829 #line __oline__ "${as_me:-configure}"
3830 #include <stdio.h>
3831 int main(int argc, char *argv[[]])
3832 {
3833         printf("hello\n");
3834         return (argv[[argc-1]] == 0) ;
3835 }
3836 EOF
3837                 cf_save_CFLAGS="$CFLAGS"
3838                 for cf_opt in $cf_try_cflags
3839                 do
3840                         CFLAGS="$cf_save_CFLAGS -$cf_opt"
3841                         AC_MSG_CHECKING(if CFLAGS option -$cf_opt works)
3842                         if AC_TRY_EVAL(ac_compile); then
3843                                 AC_MSG_RESULT(yes)
3844                                 cf_save_CFLAGS="$CFLAGS"
3845                         else
3846                                 AC_MSG_RESULT(no)
3847                         fi
3848                 done
3849                 CFLAGS="$cf_save_CFLAGS"
3850         fi
3851
3852
3853         # RPATH_LIST is a colon-separated list of directories
3854         test -n "$cf_ld_rpath_opt" && MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${RPATH_LIST}"
3855         test -z "$RPATH_LIST" && RPATH_LIST="\${libdir}"
3856
3857         test $cf_cv_rm_so_locs = yes && RM_SHARED_OPTS="$RM_SHARED_OPTS so_locations"
3858
3859         CF_VERBOSE(CC_SHARED_OPTS: $CC_SHARED_OPTS)
3860         CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
3861
3862         AC_SUBST(CC_SHARED_OPTS)
3863         AC_SUBST(LD_RPATH_OPT)
3864         AC_SUBST(LD_SHARED_OPTS)
3865         AC_SUBST(MK_SHARED_LIB)
3866         AC_SUBST(RM_SHARED_OPTS)
3867
3868         AC_SUBST(LINK_PROGS)
3869         AC_SUBST(LINK_TESTS)
3870
3871         AC_SUBST(EXTRA_LDFLAGS)
3872         AC_SUBST(LOCAL_LDFLAGS)
3873         AC_SUBST(LOCAL_LDFLAGS2)
3874
3875         AC_SUBST(INSTALL_LIB)
3876         AC_SUBST(RPATH_LIST)
3877 ])dnl
3878 dnl ---------------------------------------------------------------------------
3879 dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
3880 dnl ----------------
3881 dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
3882 dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
3883 dnl option.
3884 dnl
3885 dnl $1 is the default that should be used for "$cf_cv_shlib_version".
3886 dnl If missing, use "rel".
3887 define([CF_SHARED_SONAME],
3888 [
3889         test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
3890         if test "$cf_cv_shlib_version" = rel; then
3891                 cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
3892         else
3893                 cf_cv_shared_soname='`basename $[@]`'
3894         fi
3895 ])
3896 dnl ---------------------------------------------------------------------------
3897 dnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
3898 dnl --------------
3899 dnl     Remove "-g" option from the compiler options
3900 AC_DEFUN([CF_STRIP_G_OPT],
3901 [$1=`echo ${$1} | sed -e 's%-g %%' -e 's%-g$%%'`])dnl
3902 dnl ---------------------------------------------------------------------------
3903 dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
3904 dnl --------------
3905 dnl Construct a search-list for a nonstandard header/lib-file
3906 dnl     $1 = the variable to return as result
3907 dnl     $2 = the package name
3908 dnl     $3 = the subdirectory, e.g., bin, include or lib
3909 AC_DEFUN([CF_SUBDIR_PATH],
3910 [
3911 $1=
3912
3913 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
3914
3915 for cf_subdir_prefix in \
3916         /usr \
3917         /usr/local \
3918         /usr/pkg \
3919         /opt \
3920         /opt/local \
3921         [$]HOME
3922 do
3923         CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
3924 done
3925 ])dnl
3926 dnl ---------------------------------------------------------------------------
3927 dnl CF_TERM_HEADER version: 4 updated: 2015/04/15 19:08:48
3928 dnl --------------
3929 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
3930 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
3931 dnl but some packagers change this, breaking various applications.
3932 AC_DEFUN([CF_TERM_HEADER],[
3933 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
3934 case ${cf_cv_ncurses_header} in
3935 (*/ncurses.h|*/ncursesw.h)
3936         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
3937         ;;
3938 (*)
3939         cf_term_header=term.h
3940         ;;
3941 esac
3942
3943 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
3944 do
3945 AC_TRY_COMPILE([#include <stdio.h>
3946 #include <${cf_cv_ncurses_header:-curses.h}>
3947 #include <$cf_test>
3948 ],[int x = auto_left_margin],[
3949         cf_cv_term_header="$cf_test"],[
3950         cf_cv_term_header=unknown
3951         ])
3952         test "$cf_cv_term_header" != unknown && break
3953 done
3954 ])
3955
3956 # Set definitions to allow ifdef'ing to accommodate subdirectories
3957
3958 case $cf_cv_term_header in
3959 (*term.h)
3960         AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
3961         ;;
3962 esac
3963
3964 case $cf_cv_term_header in
3965 (ncurses/term.h)
3966         AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
3967         ;;
3968 (ncursesw/term.h)
3969         AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
3970         ;;
3971 esac
3972 ])dnl
3973 dnl ---------------------------------------------------------------------------
3974 dnl CF_TOP_BUILDDIR version: 2 updated: 2013/07/27 17:38:32
3975 dnl ---------------
3976 dnl Define a top_builddir symbol, for applications that need an absolute path.
3977 AC_DEFUN([CF_TOP_BUILDDIR],
3978 [
3979 top_builddir=ifelse($1,,`pwd`,$1)
3980 AC_SUBST(top_builddir)
3981 ])dnl
3982 dnl ---------------------------------------------------------------------------
3983 dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
3984 dnl -------------------
3985 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
3986 dnl can define it successfully.
3987 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
3988 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
3989         AC_TRY_COMPILE([
3990 #include <stdlib.h>
3991 #include <string.h>
3992 #include <sys/types.h>
3993 ],[
3994 #ifndef _XOPEN_SOURCE
3995 make an error
3996 #endif],
3997         [cf_cv_xopen_source=no],
3998         [cf_save="$CPPFLAGS"
3999          CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
4000          AC_TRY_COMPILE([
4001 #include <stdlib.h>
4002 #include <string.h>
4003 #include <sys/types.h>
4004 ],[
4005 #ifdef _XOPEN_SOURCE
4006 make an error
4007 #endif],
4008         [cf_cv_xopen_source=no],
4009         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
4010         CPPFLAGS="$cf_save"
4011         ])
4012 ])
4013
4014 if test "$cf_cv_xopen_source" != no ; then
4015         CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
4016         CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
4017         cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
4018         CF_ADD_CFLAGS($cf_temp_xopen_source)
4019 fi
4020 ])
4021 dnl ---------------------------------------------------------------------------
4022 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
4023 dnl --------
4024 dnl Make an uppercase version of a variable
4025 dnl $1=uppercase($2)
4026 AC_DEFUN([CF_UPPER],
4027 [
4028 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
4029 ])dnl
4030 dnl ---------------------------------------------------------------------------
4031 dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
4032 dnl -----------
4033 dnl Check for multibyte support, and if not found, utf8 compatibility library
4034 AC_DEFUN([CF_UTF8_LIB],
4035 [
4036 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
4037         cf_save_LIBS="$LIBS"
4038         AC_TRY_LINK([
4039 #include <stdlib.h>],[putwc(0,0);],
4040         [cf_cv_utf8_lib=yes],
4041         [CF_FIND_LINKAGE([
4042 #include <libutf8.h>],[putwc(0,0);],utf8,
4043                 [cf_cv_utf8_lib=add-on],
4044                 [cf_cv_utf8_lib=no])
4045 ])])
4046
4047 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
4048 # ncurses/ncursesw:
4049 if test "$cf_cv_utf8_lib" = "add-on" ; then
4050         AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
4051         CF_ADD_INCDIR($cf_cv_header_path_utf8)
4052         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
4053         CF_ADD_LIBS($cf_cv_library_file_utf8)
4054 fi
4055 ])dnl
4056 dnl ---------------------------------------------------------------------------
4057 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
4058 dnl ----------
4059 dnl Use AC_VERBOSE w/o the warnings
4060 AC_DEFUN([CF_VERBOSE],
4061 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
4062 CF_MSG_LOG([$1])
4063 ])dnl
4064 dnl ---------------------------------------------------------------------------
4065 dnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06
4066 dnl ---------------
4067 dnl Check for compiler-support for weak symbols.
4068 dnl This works with "recent" gcc.
4069 AC_DEFUN([CF_WEAK_SYMBOLS],[
4070 AC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[
4071
4072 AC_TRY_COMPILE([
4073 #include <stdio.h>],
4074 [
4075 #if defined(__GNUC__)
4076 #  if defined __USE_ISOC99
4077 #    define _cat_pragma(exp)    _Pragma(#exp)
4078 #    define _weak_pragma(exp)   _cat_pragma(weak name)
4079 #  else
4080 #    define _weak_pragma(exp)
4081 #  endif
4082 #  define _declare(name)        __extension__ extern __typeof__(name) name
4083 #  define weak_symbol(name)     _weak_pragma(name) _declare(name) __attribute__((weak))
4084 #endif
4085
4086 weak_symbol(fopen);
4087 ],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
4088 ])
4089 ])dnl
4090 dnl ---------------------------------------------------------------------------
4091 dnl CF_WITH_ADA_COMPILER version: 2 updated: 2010/06/26 17:35:58
4092 dnl --------------------
4093 dnl Command-line option to specify the Ada95 compiler.
4094 AC_DEFUN([CF_WITH_ADA_COMPILER],[
4095 AC_MSG_CHECKING(for ada-compiler)
4096 AC_ARG_WITH(ada-compiler,
4097         [  --with-ada-compiler=CMD specify Ada95 compiler command (default gnatmake)],
4098         [cf_ada_compiler=$withval],
4099         [cf_ada_compiler=gnatmake])
4100 AC_SUBST(cf_ada_compiler)
4101 AC_MSG_RESULT($cf_ada_compiler)
4102 ])dnl
4103 dnl ---------------------------------------------------------------------------
4104 dnl CF_WITH_ADA_INCLUDE version: 2 updated: 2010/06/26 17:35:58
4105 dnl -------------------
4106 dnl Command-line option to specify where Ada includes will install.
4107 AC_DEFUN([CF_WITH_ADA_INCLUDE],[
4108 AC_MSG_CHECKING(for ada-include)
4109 CF_WITH_PATH(ada-include,
4110    [  --with-ada-include=DIR  Ada includes are in DIR],
4111    ADA_INCLUDE,
4112    PREFIX/share/ada/adainclude,
4113    [$]prefix/share/ada/adainclude)
4114 AC_SUBST(ADA_INCLUDE)
4115 AC_MSG_RESULT($ADA_INCLUDE)
4116 ])dnl
4117 dnl ---------------------------------------------------------------------------
4118 dnl CF_WITH_ADA_LIBNAME version: 1 updated: 2019/09/07 18:59:41
4119 dnl -------------------
4120 dnl CF_WITH_ADA_LIBNAME
4121 dnl -------------------
4122 dnl Command-line option to specify how to name the resulting Ada library.
4123 dnl $1 = default value
4124 AC_DEFUN([CF_WITH_ADA_LIBNAME],[
4125 AC_MSG_CHECKING(for ada-libname)
4126 AC_ARG_WITH(ada-libname,
4127    [  --with-ada-libname=XXX  override default Ada library-name],
4128    ADA_LIBNAME=[$]withval,
4129    ADA_LIBNAME=$1)
4130 case "x$ADA_LIBNAME" in
4131 (x|xyes|xno)
4132         ADA_LIBNAME=$1
4133         ;;
4134 esac
4135 AC_SUBST(ADA_LIBNAME)
4136 AC_MSG_RESULT($ADA_LIBNAME)
4137 ])dnl
4138 dnl ---------------------------------------------------------------------------
4139 dnl CF_WITH_ADA_OBJECTS version: 2 updated: 2010/06/26 17:35:58
4140 dnl -------------------
4141 dnl Command-line option to specify where Ada objects will install.
4142 AC_DEFUN([CF_WITH_ADA_OBJECTS],[
4143 AC_MSG_CHECKING(for ada-objects)
4144 CF_WITH_PATH(ada-objects,
4145    [  --with-ada-objects=DIR  Ada objects are in DIR],
4146    ADA_OBJECTS,
4147    PREFIX/lib/ada/adalib,
4148    [$]prefix/lib/ada/adalib)
4149 AC_SUBST(ADA_OBJECTS)
4150 AC_MSG_RESULT($ADA_OBJECTS)
4151 ])dnl
4152 dnl ---------------------------------------------------------------------------
4153 dnl CF_WITH_ADA_SHAREDLIB version: 5 updated: 2018/07/21 19:10:35
4154 dnl ---------------------
4155 dnl Command-line option to specify if an Ada95 shared-library should be built,
4156 dnl and optionally what its soname should be.
4157 AC_DEFUN([CF_WITH_ADA_SHAREDLIB],[
4158 AC_REQUIRE([CF_GNAT_PROJECTS])
4159 AC_MSG_CHECKING(if an Ada95 shared-library should be built)
4160 AC_ARG_WITH(ada-sharedlib,
4161         [  --with-ada-sharedlib=soname build shared-library (requires GNAT projects)],
4162         [with_ada_sharedlib=$withval],
4163         [with_ada_sharedlib=no])
4164 AC_MSG_RESULT($with_ada_sharedlib)
4165
4166 if test "x$with_ada_sharedlib" != xno
4167 then
4168         if test "x$cf_gnat_projects" != xyes
4169         then
4170                 AC_MSG_WARN(disabling shared-library since GNAT projects are not supported)
4171                 with_ada_sharedlib=no
4172         fi
4173 fi
4174
4175 ADA_SHAREDLIB='lib$(LIB_NAME).so.1'
4176 MAKE_ADA_SHAREDLIB="#"
4177
4178 if test "x$with_ada_sharedlib" != xno
4179 then
4180         MAKE_ADA_SHAREDLIB=
4181         if test "x$with_ada_sharedlib" != xyes
4182         then
4183                 ADA_SHAREDLIB="$with_ada_sharedlib"
4184         fi
4185 fi
4186
4187 AC_SUBST(ADA_SHAREDLIB)
4188 AC_SUBST(MAKE_ADA_SHAREDLIB)
4189 ])dnl
4190 dnl ---------------------------------------------------------------------------
4191 dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
4192 dnl ------------------
4193 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
4194 dnl libraries.
4195 AC_DEFUN([CF_WITH_CURSES_DIR],[
4196
4197 AC_MSG_CHECKING(for specific curses-directory)
4198 AC_ARG_WITH(curses-dir,
4199         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
4200         [cf_cv_curses_dir=$withval],
4201         [cf_cv_curses_dir=no])
4202 AC_MSG_RESULT($cf_cv_curses_dir)
4203
4204 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
4205 then
4206         CF_PATH_SYNTAX(withval)
4207         if test -d "$cf_cv_curses_dir"
4208         then
4209                 CF_ADD_INCDIR($cf_cv_curses_dir/include)
4210                 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
4211         fi
4212 fi
4213 ])dnl
4214 dnl ---------------------------------------------------------------------------
4215 dnl CF_WITH_LIB_PREFIX version: 1 updated: 2012/01/21 19:28:10
4216 dnl ------------------
4217 dnl Allow the library-prefix to be overridden.  OS/2 EMX originally had no
4218 dnl "lib" prefix, e.g., because it used the dll naming convention.
4219 dnl
4220 dnl $1 = variable to set
4221 AC_DEFUN([CF_WITH_LIB_PREFIX],
4222 [
4223 AC_MSG_CHECKING(if you want to have a library-prefix)
4224 AC_ARG_WITH(lib-prefix,
4225         [  --with-lib-prefix       override library-prefix],
4226         [with_lib_prefix=$withval],
4227         [with_lib_prefix=auto])
4228 AC_MSG_RESULT($with_lib_prefix)
4229
4230 if test $with_lib_prefix = auto
4231 then
4232         CF_LIB_PREFIX($1)
4233 elif test $with_lib_prefix = no
4234 then
4235         LIB_PREFIX=
4236 else
4237         LIB_PREFIX=$with_lib_prefix
4238 fi
4239 ])dnl
4240 dnl ---------------------------------------------------------------------------
4241 dnl CF_WITH_PATH version: 11 updated: 2012/09/29 15:04:19
4242 dnl ------------
4243 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
4244 dnl defaulting to yes/no.
4245 dnl
4246 dnl $1 = option name
4247 dnl $2 = help-text
4248 dnl $3 = environment variable to set
4249 dnl $4 = default value, shown in the help-message, must be a constant
4250 dnl $5 = default value, if it's an expression & cannot be in the help-message
4251 dnl
4252 AC_DEFUN([CF_WITH_PATH],
4253 [AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
4254 ifelse([$4],,[withval="${$3}"],[withval="${$3:-ifelse([$5],,[$4],[$5])}"]))dnl
4255 if ifelse([$5],,true,[test -n "$5"]) ; then
4256 CF_PATH_SYNTAX(withval)
4257 fi
4258 eval $3="$withval"
4259 AC_SUBST($3)dnl
4260 ])dnl
4261 dnl ---------------------------------------------------------------------------
4262 dnl CF_WITH_PKG_CONFIG_LIBDIR version: 10 updated: 2015/08/22 17:10:56
4263 dnl -------------------------
4264 dnl Allow the choice of the pkg-config library directory to be overridden.
4265 AC_DEFUN([CF_WITH_PKG_CONFIG_LIBDIR],[
4266
4267 case $PKG_CONFIG in
4268 (no|none|yes)
4269         AC_MSG_CHECKING(for pkg-config library directory)
4270         ;;
4271 (*)
4272         AC_MSG_CHECKING(for $PKG_CONFIG library directory)
4273         ;;
4274 esac
4275
4276 PKG_CONFIG_LIBDIR=no
4277 AC_ARG_WITH(pkg-config-libdir,
4278         [  --with-pkg-config-libdir=XXX use given directory for installing pc-files],
4279         [PKG_CONFIG_LIBDIR=$withval],
4280         [test "x$PKG_CONFIG" != xnone && PKG_CONFIG_LIBDIR=yes])
4281
4282 case x$PKG_CONFIG_LIBDIR in
4283 (x/*)
4284         ;;
4285 (xyes)
4286         # Look for the library directory using the same prefix as the executable
4287         if test "x$PKG_CONFIG" = xnone
4288         then
4289                 cf_path=$prefix
4290         else
4291                 cf_path=`echo "$PKG_CONFIG" | sed -e 's,/[[^/]]*/[[^/]]*$,,'`
4292         fi
4293
4294         # If you don't like using the default architecture, you have to specify the
4295         # intended library directory and corresponding compiler/linker options.
4296         #
4297         # This case allows for Debian's 2014-flavor of multiarch, along with the
4298         # most common variations before that point.  Some other variants spell the
4299         # directory differently, e.g., "pkg-config", and put it in unusual places.
4300         # pkg-config has always been poorly standardized, which is ironic...
4301         case x`(arch) 2>/dev/null` in
4302         (*64)
4303                 cf_search_path="\
4304                         $cf_path/lib/*64-linux-gnu \
4305                         $cf_path/share \
4306                         $cf_path/lib64 \
4307                         $cf_path/lib32 \
4308                         $cf_path/lib"
4309                 ;;
4310         (*)
4311                 cf_search_path="\
4312                         $cf_path/lib/*-linux-gnu \
4313                         $cf_path/share \
4314                         $cf_path/lib32 \
4315                         $cf_path/lib \
4316                         $cf_path/libdata"
4317                 ;;
4318         esac
4319
4320         CF_VERBOSE(list...)
4321         for cf_config in $cf_search_path
4322         do
4323                 CF_VERBOSE(checking $cf_config/pkgconfig)
4324                 if test -d $cf_config/pkgconfig
4325                 then
4326                         PKG_CONFIG_LIBDIR=$cf_config/pkgconfig
4327                         AC_MSG_CHECKING(done)
4328                         break
4329                 fi
4330         done
4331         ;;
4332 (*)
4333         ;;
4334 esac
4335
4336 if test "x$PKG_CONFIG_LIBDIR" != xno ; then
4337         AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
4338 fi
4339
4340 AC_SUBST(PKG_CONFIG_LIBDIR)
4341 ])dnl
4342 dnl ---------------------------------------------------------------------------
4343 dnl CF_WITH_PTHREAD version: 7 updated: 2015/04/18 08:56:57
4344 dnl ---------------
4345 dnl Check for POSIX thread library.
4346 AC_DEFUN([CF_WITH_PTHREAD],
4347 [
4348 AC_MSG_CHECKING(if you want to link with the pthread library)
4349 AC_ARG_WITH(pthread,
4350         [  --with-pthread          use POSIX thread library],
4351         [with_pthread=$withval],
4352         [with_pthread=no])
4353 AC_MSG_RESULT($with_pthread)
4354
4355 if test "$with_pthread" != no ; then
4356         AC_CHECK_HEADER(pthread.h,[
4357         AC_DEFINE(HAVE_PTHREADS_H,1,[Define to 1 if we have pthreads.h header])
4358
4359         for cf_lib_pthread in pthread c_r
4360         do
4361             AC_MSG_CHECKING(if we can link with the $cf_lib_pthread library)
4362             cf_save_LIBS="$LIBS"
4363             CF_ADD_LIB($cf_lib_pthread)
4364             AC_TRY_LINK([
4365 #include <pthread.h>
4366 ],[
4367                 int rc = pthread_create(0,0,0,0);
4368                 int r2 = pthread_mutexattr_settype(0, 0);
4369 ],[with_pthread=yes],[with_pthread=no])
4370             LIBS="$cf_save_LIBS"
4371             AC_MSG_RESULT($with_pthread)
4372             test "$with_pthread" = yes && break
4373         done
4374
4375         if test "$with_pthread" = yes ; then
4376             CF_ADD_LIB($cf_lib_pthread)
4377             AC_DEFINE(HAVE_LIBPTHREADS,1,[Define to 1 if we have pthreads library])
4378         else
4379             AC_MSG_ERROR(Cannot link with pthread library)
4380         fi
4381         ])
4382 fi
4383 ])
4384 dnl ---------------------------------------------------------------------------
4385 dnl CF_WITH_SYSTYPE version: 1 updated: 2013/01/26 16:26:12
4386 dnl ---------------
4387 dnl For testing, override the derived host system-type which is used to decide
4388 dnl things such as the linker commands used to build shared libraries.  This is
4389 dnl normally chosen automatically based on the type of system which you are
4390 dnl building on.  We use it for testing the configure script.
4391 dnl
4392 dnl This is different from the --host option: it is used only for testing parts
4393 dnl of the configure script which would not be reachable with --host since that
4394 dnl relies on the build environment being real, rather than mocked up.
4395 AC_DEFUN([CF_WITH_SYSTYPE],[
4396 CF_CHECK_CACHE([AC_CANONICAL_SYSTEM])
4397 AC_ARG_WITH(system-type,
4398         [  --with-system-type=XXX  test: override derived host system-type],
4399 [AC_MSG_WARN(overriding system type to $withval)
4400         cf_cv_system_name=$withval
4401         host_os=$withval
4402 ])
4403 ])dnl
4404 dnl ---------------------------------------------------------------------------
4405 dnl CF_XOPEN_SOURCE version: 55 updated: 2018/12/31 20:46:17
4406 dnl ---------------
4407 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
4408 dnl or adapt to the vendor's definitions to get equivalent functionality,
4409 dnl without losing the common non-POSIX features.
4410 dnl
4411 dnl Parameters:
4412 dnl     $1 is the nominal value for _XOPEN_SOURCE
4413 dnl     $2 is the nominal value for _POSIX_C_SOURCE
4414 AC_DEFUN([CF_XOPEN_SOURCE],[
4415 AC_REQUIRE([AC_CANONICAL_HOST])
4416 AC_REQUIRE([CF_POSIX_VISIBLE])
4417
4418 if test "$cf_cv_posix_visible" = no; then
4419
4420 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
4421 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
4422 cf_xopen_source=
4423
4424 case $host_os in
4425 (aix[[4-7]]*)
4426         cf_xopen_source="-D_ALL_SOURCE"
4427         ;;
4428 (msys)
4429         cf_XOPEN_SOURCE=600
4430         ;;
4431 (darwin[[0-8]].*)
4432         cf_xopen_source="-D_APPLE_C_SOURCE"
4433         ;;
4434 (darwin*)
4435         cf_xopen_source="-D_DARWIN_C_SOURCE"
4436         cf_XOPEN_SOURCE=
4437         ;;
4438 (freebsd*|dragonfly*|midnightbsd*)
4439         # 5.x headers associate
4440         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
4441         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
4442         cf_POSIX_C_SOURCE=200112L
4443         cf_XOPEN_SOURCE=600
4444         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
4445         ;;
4446 (hpux11*)
4447         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
4448         ;;
4449 (hpux*)
4450         cf_xopen_source="-D_HPUX_SOURCE"
4451         ;;
4452 (irix[[56]].*)
4453         cf_xopen_source="-D_SGI_SOURCE"
4454         cf_XOPEN_SOURCE=
4455         ;;
4456 (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
4457         CF_GNU_SOURCE($cf_XOPEN_SOURCE)
4458         ;;
4459 (minix*)
4460         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
4461         ;;
4462 (mirbsd*)
4463         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
4464         cf_XOPEN_SOURCE=
4465         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4466         ;;
4467 (netbsd*)
4468         cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
4469         ;;
4470 (openbsd[[4-9]]*)
4471         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
4472         cf_xopen_source="-D_BSD_SOURCE"
4473         cf_XOPEN_SOURCE=600
4474         ;;
4475 (openbsd*)
4476         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
4477         ;;
4478 (osf[[45]]*)
4479         cf_xopen_source="-D_OSF_SOURCE"
4480         ;;
4481 (nto-qnx*)
4482         cf_xopen_source="-D_QNX_SOURCE"
4483         ;;
4484 (sco*)
4485         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
4486         ;;
4487 (solaris2.*)
4488         cf_xopen_source="-D__EXTENSIONS__"
4489         cf_cv_xopen_source=broken
4490         ;;
4491 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
4492         cf_XOPEN_SOURCE=
4493         cf_POSIX_C_SOURCE=
4494         ;;
4495 (*)
4496         CF_TRY_XOPEN_SOURCE
4497         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4498         ;;
4499 esac
4500
4501 if test -n "$cf_xopen_source" ; then
4502         CF_ADD_CFLAGS($cf_xopen_source,true)
4503 fi
4504
4505 dnl In anything but the default case, we may have system-specific setting
4506 dnl which is still not guaranteed to provide all of the entrypoints that
4507 dnl _XOPEN_SOURCE would yield.
4508 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
4509         AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
4510         AC_TRY_COMPILE([#include <stdlib.h>],[
4511 #ifndef _XOPEN_SOURCE
4512 make an error
4513 #endif],
4514         [cf_XOPEN_SOURCE_set=yes],
4515         [cf_XOPEN_SOURCE_set=no])
4516         AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
4517         if test $cf_XOPEN_SOURCE_set = yes
4518         then
4519                 AC_TRY_COMPILE([#include <stdlib.h>],[
4520 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
4521 make an error
4522 #endif],
4523                 [cf_XOPEN_SOURCE_set_ok=yes],
4524                 [cf_XOPEN_SOURCE_set_ok=no])
4525                 if test $cf_XOPEN_SOURCE_set_ok = no
4526                 then
4527                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
4528                 fi
4529         else
4530                 CF_TRY_XOPEN_SOURCE
4531         fi
4532 fi
4533 fi # cf_cv_posix_visible
4534 ])