ncurses 6.0 - patch 20160409
[ncurses.git] / test / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2003-2015,2016 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 $Id: aclocal.m4,v 1.127 2016/04/09 21:39:32 tom Exp $
30 dnl
31 dnl Author: Thomas E. Dickey
32 dnl
33 dnl Macros used in NCURSES test programs auto-configuration script.
34 dnl
35 dnl These macros are maintained separately from NCURSES.  The copyright on
36 dnl this file applies to the aggregation of macros and does not affect use of
37 dnl these macros in other applications.
38 dnl
39 dnl See http://invisible-island.net/autoconf/ for additional information.
40 dnl
41 dnl ---------------------------------------------------------------------------
42 dnl ---------------------------------------------------------------------------
43 dnl AM_LANGINFO_CODESET version: 4 updated: 2015/04/18 08:56:57
44 dnl -------------------
45 dnl Inserted as requested by gettext 0.10.40
46 dnl File from /usr/share/aclocal
47 dnl codeset.m4
48 dnl ====================
49 dnl serial AM1
50 dnl
51 dnl From Bruno Haible.
52 AC_DEFUN([AM_LANGINFO_CODESET],
53 [
54 AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
55         [AC_TRY_LINK([#include <langinfo.h>],
56         [char* cs = nl_langinfo(CODESET);],
57         am_cv_langinfo_codeset=yes,
58         am_cv_langinfo_codeset=no)
59         ])
60         if test $am_cv_langinfo_codeset = yes; then
61                 AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
62                 [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
63         fi
64 ])dnl
65 dnl ---------------------------------------------------------------------------
66 dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
67 dnl ------------------
68 dnl Conditionally generate script according to whether we're using a given autoconf.
69 dnl
70 dnl $1 = version to compare against
71 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
72 dnl $3 = code to use if AC_ACVERSION is older than $1.
73 define([CF_ACVERSION_CHECK],
74 [
75 ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
76 ifdef([m4_version_compare],
77 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
78 [CF_ACVERSION_COMPARE(
79 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
80 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
81 dnl ---------------------------------------------------------------------------
82 dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
83 dnl --------------------
84 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
85 dnl                      MAJOR2, MINOR2, TERNARY2,
86 dnl                      PRINTABLE2, not FOUND, FOUND)
87 define([CF_ACVERSION_COMPARE],
88 [ifelse(builtin([eval], [$2 < $5]), 1,
89 [ifelse([$8], , ,[$8])],
90 [ifelse([$9], , ,[$9])])])dnl
91 dnl ---------------------------------------------------------------------------
92 dnl CF_ADD_CFLAGS version: 12 updated: 2015/04/12 15:39:00
93 dnl -------------
94 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
95 dnl The second parameter if given makes this macro verbose.
96 dnl
97 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
98 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
99 dnl confused by the quotes (which require backslashes to keep them usable).
100 AC_DEFUN([CF_ADD_CFLAGS],
101 [
102 cf_fix_cppflags=no
103 cf_new_cflags=
104 cf_new_cppflags=
105 cf_new_extra_cppflags=
106
107 for cf_add_cflags in $1
108 do
109 case $cf_fix_cppflags in
110 (no)
111         case $cf_add_cflags in
112         (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
113                 case $cf_add_cflags in
114                 (-D*)
115                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
116
117                         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
118                                 && test -z "${cf_tst_cflags}" \
119                                 && cf_fix_cppflags=yes
120
121                         if test $cf_fix_cppflags = yes ; then
122                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
123                                 continue
124                         elif test "${cf_tst_cflags}" = "\"'" ; then
125                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
126                                 continue
127                         fi
128                         ;;
129                 esac
130                 case "$CPPFLAGS" in
131                 (*$cf_add_cflags)
132                         ;;
133                 (*)
134                         case $cf_add_cflags in
135                         (-D*)
136                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
137                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
138                                 ;;
139                         esac
140                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
141                         ;;
142                 esac
143                 ;;
144         (*)
145                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
146                 ;;
147         esac
148         ;;
149 (yes)
150         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
151
152         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
153
154         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
155                 && test -z "${cf_tst_cflags}" \
156                 && cf_fix_cppflags=no
157         ;;
158 esac
159 done
160
161 if test -n "$cf_new_cflags" ; then
162         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
163         CFLAGS="$CFLAGS $cf_new_cflags"
164 fi
165
166 if test -n "$cf_new_cppflags" ; then
167         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
168         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
169 fi
170
171 if test -n "$cf_new_extra_cppflags" ; then
172         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
173         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
174 fi
175
176 AC_SUBST(EXTRA_CPPFLAGS)
177
178 ])dnl
179 dnl ---------------------------------------------------------------------------
180 dnl CF_ADD_INCDIR version: 14 updated: 2015/05/25 20:53:04
181 dnl -------------
182 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
183 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
184 dnl but old versions (and some misinstalled ones) need that.  To make things
185 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
186 dnl the include-path).
187 AC_DEFUN([CF_ADD_INCDIR],
188 [
189 if test -n "$1" ; then
190   for cf_add_incdir in $1
191   do
192         while test $cf_add_incdir != /usr/include
193         do
194           if test -d $cf_add_incdir
195           then
196                 cf_have_incdir=no
197                 if test -n "$CFLAGS$CPPFLAGS" ; then
198                   # a loop is needed to ensure we can add subdirs of existing dirs
199                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
200                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
201                           cf_have_incdir=yes; break
202                         fi
203                   done
204                 fi
205
206                 if test "$cf_have_incdir" = no ; then
207                   if test "$cf_add_incdir" = /usr/local/include ; then
208                         if test "$GCC" = yes
209                         then
210                           cf_save_CPPFLAGS=$CPPFLAGS
211                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
212                           AC_TRY_COMPILE([#include <stdio.h>],
213                                   [printf("Hello")],
214                                   [],
215                                   [cf_have_incdir=yes])
216                           CPPFLAGS=$cf_save_CPPFLAGS
217                         fi
218                   fi
219                 fi
220
221                 if test "$cf_have_incdir" = no ; then
222                   CF_VERBOSE(adding $cf_add_incdir to include-path)
223                   ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
224
225                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
226                   test "$cf_top_incdir" = "$cf_add_incdir" && break
227                   cf_add_incdir="$cf_top_incdir"
228                 else
229                   break
230                 fi
231           else
232                 break
233           fi
234         done
235   done
236 fi
237 ])dnl
238 dnl ---------------------------------------------------------------------------
239 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
240 dnl ----------
241 dnl Add a library, used to enforce consistency.
242 dnl
243 dnl $1 = library to add, without the "-l"
244 dnl $2 = variable to update (default $LIBS)
245 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
246 dnl ---------------------------------------------------------------------------
247 dnl CF_ADD_LIBDIR version: 10 updated: 2015/04/18 08:56:57
248 dnl -------------
249 dnl     Adds to the library-path
250 dnl
251 dnl     Some machines have trouble with multiple -L options.
252 dnl
253 dnl $1 is the (list of) directory(s) to add
254 dnl $2 is the optional name of the variable to update (default LDFLAGS)
255 dnl
256 AC_DEFUN([CF_ADD_LIBDIR],
257 [
258 if test -n "$1" ; then
259         for cf_add_libdir in $1
260         do
261                 if test $cf_add_libdir = /usr/lib ; then
262                         :
263                 elif test -d $cf_add_libdir
264                 then
265                         cf_have_libdir=no
266                         if test -n "$LDFLAGS$LIBS" ; then
267                                 # a loop is needed to ensure we can add subdirs of existing dirs
268                                 for cf_test_libdir in $LDFLAGS $LIBS ; do
269                                         if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
270                                                 cf_have_libdir=yes; break
271                                         fi
272                                 done
273                         fi
274                         if test "$cf_have_libdir" = no ; then
275                                 CF_VERBOSE(adding $cf_add_libdir to library-path)
276                                 ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
277                         fi
278                 fi
279         done
280 fi
281 ])dnl
282 dnl ---------------------------------------------------------------------------
283 dnl CF_ADD_LIBS version: 2 updated: 2014/07/13 14:33:27
284 dnl -----------
285 dnl Add one or more libraries, used to enforce consistency.  Libraries are
286 dnl prepended to an existing list, since their dependencies are assumed to
287 dnl already exist in the list.
288 dnl
289 dnl $1 = libraries to add, with the "-l", etc.
290 dnl $2 = variable to update (default $LIBS)
291 AC_DEFUN([CF_ADD_LIBS],[
292 cf_add_libs="$1"
293 # Filter out duplicates - this happens with badly-designed ".pc" files...
294 for cf_add_1lib in [$]ifelse($2,,LIBS,[$2])
295 do
296         for cf_add_2lib in $cf_add_libs
297         do
298                 if test "x$cf_add_1lib" = "x$cf_add_2lib"
299                 then
300                         cf_add_1lib=
301                         break
302                 fi
303         done
304         test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
305 done
306 ifelse($2,,LIBS,[$2])="$cf_add_libs"
307 ])dnl
308 dnl ---------------------------------------------------------------------------
309 dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
310 dnl ----------------
311 dnl Add a given library after another, e.g., following the one it satisfies a
312 dnl dependency for.
313 dnl
314 dnl $1 = the first library
315 dnl $2 = its dependency
316 AC_DEFUN([CF_ADD_LIB_AFTER],[
317 CF_VERBOSE(...before $LIBS)
318 LIBS=`echo "$LIBS" | sed -e "s/[[       ]][[    ]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
319 CF_VERBOSE(...after  $LIBS)
320 ])dnl
321 dnl ---------------------------------------------------------------------------
322 dnl CF_ADD_SUBDIR_PATH version: 4 updated: 2013/10/08 17:47:05
323 dnl ------------------
324 dnl Append to a search-list for a nonstandard header/lib-file
325 dnl     $1 = the variable to return as result
326 dnl     $2 = the package name
327 dnl     $3 = the subdirectory, e.g., bin, include or lib
328 dnl $4 = the directory under which we will test for subdirectories
329 dnl $5 = a directory that we do not want $4 to match
330 AC_DEFUN([CF_ADD_SUBDIR_PATH],
331 [
332 test "x$4" != "x$5" && \
333 test -d "$4" && \
334 ifelse([$5],NONE,,[(test -z "$5" || test x$5 = xNONE || test "x$4" != "x$5") &&]) {
335         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
336         test -d $4/$3 &&          $1="[$]$1 $4/$3"
337         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
338         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
339         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
340         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
341 }
342 ])dnl
343 dnl ---------------------------------------------------------------------------
344 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
345 dnl --------------
346 dnl Allow user to disable a normally-on option.
347 AC_DEFUN([CF_ARG_DISABLE],
348 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
349 dnl ---------------------------------------------------------------------------
350 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
351 dnl -------------
352 dnl Allow user to enable a normally-off option.
353 AC_DEFUN([CF_ARG_ENABLE],
354 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
355 dnl ---------------------------------------------------------------------------
356 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
357 dnl -------------
358 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
359 dnl values.
360 dnl
361 dnl Parameters:
362 dnl $1 = option name
363 dnl $2 = help-string
364 dnl $3 = action to perform if option is not default
365 dnl $4 = action if perform if option is default
366 dnl $5 = default option value (either 'yes' or 'no')
367 AC_DEFUN([CF_ARG_OPTION],
368 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
369         if test "$enableval" != "$5" ; then
370 ifelse([$3],,[    :]dnl
371 ,[    $3]) ifelse([$4],,,[
372         else
373                 $4])
374         fi],[enableval=$5 ifelse([$4],,,[
375         $4
376 ])dnl
377 ])])dnl
378 dnl ---------------------------------------------------------------------------
379 dnl CF_CC_ENV_FLAGS version: 2 updated: 2015/04/12 15:39:00
380 dnl ---------------
381 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
382 dnl into CC.  This will not help with broken scripts that wrap the compiler with
383 dnl options, but eliminates a more common category of user confusion.
384 AC_DEFUN([CF_CC_ENV_FLAGS],
385 [
386 # This should have been defined by AC_PROG_CC
387 : ${CC:=cc}
388
389 AC_MSG_CHECKING(\$CC variable)
390 case "$CC" in
391 (*[[\ \ ]]-[[IUD]]*)
392         AC_MSG_RESULT(broken)
393         AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
394         # humor him...
395         cf_flags=`echo "$CC" | sed -e 's/^[[^   ]]*[[   ]]//'`
396         CC=`echo "$CC" | sed -e 's/[[   ]].*//'`
397         CF_ADD_CFLAGS($cf_flags)
398         ;;
399 (*)
400         AC_MSG_RESULT(ok)
401         ;;
402 esac
403 ])dnl
404 dnl ---------------------------------------------------------------------------
405 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
406 dnl --------------
407 dnl Check if we're accidentally using a cache from a different machine.
408 dnl Derive the system name, as a check for reusing the autoconf cache.
409 dnl
410 dnl If we've packaged config.guess and config.sub, run that (since it does a
411 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
412 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
413 dnl which is useful in cross-compiles.
414 dnl
415 dnl Note: we would use $ac_config_sub, but that is one of the places where
416 dnl autoconf 2.5x broke compatibility with autoconf 2.13
417 AC_DEFUN([CF_CHECK_CACHE],
418 [
419 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
420         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
421         system_name="$host_os"
422 else
423         system_name="`(uname -s -r) 2>/dev/null`"
424         if test -z "$system_name" ; then
425                 system_name="`(hostname) 2>/dev/null`"
426         fi
427 fi
428 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
429 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
430
431 test -z "$system_name" && system_name="$cf_cv_system_name"
432 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
433
434 if test ".$system_name" != ".$cf_cv_system_name" ; then
435         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
436         AC_MSG_ERROR("Please remove config.cache and try again.")
437 fi
438 ])dnl
439 dnl ---------------------------------------------------------------------------
440 dnl CF_CHECK_CFLAGS version: 3 updated: 2014/07/22 05:32:57
441 dnl ---------------
442 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
443 dnl a build-configuration such as imake.  These have the pitfall that they
444 dnl often contain compiler-specific options which we cannot use, mixed with
445 dnl preprocessor options that we usually can.
446 AC_DEFUN([CF_CHECK_CFLAGS],
447 [
448 CF_VERBOSE(checking additions to CFLAGS)
449 cf_check_cflags="$CFLAGS"
450 cf_check_cppflags="$CPPFLAGS"
451 CF_ADD_CFLAGS($1,yes)
452 if test "x$cf_check_cflags" != "x$CFLAGS" ; then
453 AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
454         [CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
455          if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
456                  CF_VERBOSE(but keeping change to \$CPPFLAGS)
457          fi
458          CFLAGS="$cf_check_flags"])
459 fi
460 ])dnl
461 dnl ---------------------------------------------------------------------------
462 dnl CF_CHECK_CURSES_LIB version: 1 updated: 2015/04/25 20:53:11
463 dnl -------------------
464 dnl $1 = nominal library name, used also for header lookup
465 dnl $2 = suffix to append to library name
466 dnl $3 = function to check for using AC_CHECK_LIB
467 AC_DEFUN([CF_CHECK_CURSES_LIB],
468 [
469 AC_CHECK_LIB($1$2,$3,[
470 CF_UPPER(cf_upper,have_lib$1)
471 CF_ADD_LIBS(-l$1$2)
472 AC_DEFINE_UNQUOTED($cf_upper,1)])
473 ])dnl
474 dnl ---------------------------------------------------------------------------
475 dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
476 dnl -----------------
477 dnl Check if the given compiler is really clang.  clang's C driver defines
478 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
479 dnl not ignore some gcc options.
480 dnl
481 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
482 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
483 dnl the wrappers for gcc and g++ warnings.
484 dnl
485 dnl $1 = GCC (default) or GXX
486 dnl $2 = CLANG_COMPILER (default)
487 dnl $3 = CFLAGS (default) or CXXFLAGS
488 AC_DEFUN([CF_CLANG_COMPILER],[
489 ifelse([$2],,CLANG_COMPILER,[$2])=no
490
491 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
492         AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
493         cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
494         ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
495         AC_TRY_COMPILE([],[
496 #ifdef __clang__
497 #else
498 make an error
499 #endif
500 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
501 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
502 ],[])
503         ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
504         AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
505 fi
506 ])
507 dnl ---------------------------------------------------------------------------
508 dnl CF_CURSES_ACS_MAP version: 7 updated: 2012/10/06 16:39:58
509 dnl -----------------
510 dnl Check for likely values of acs_map[]:
511 AC_DEFUN([CF_CURSES_ACS_MAP],
512 [
513 AC_REQUIRE([CF_NCURSES_WRAP_PREFIX])dnl
514 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
515 cf_cv_curses_acs_map=unknown
516 for name in acs_map _acs_map __acs_map ${NCURSES_WRAP_PREFIX}acs_map
517 do
518 AC_TRY_LINK([
519 #include <${cf_cv_ncurses_header:-curses.h}>
520 ],[
521 $name['k'] = ACS_PLUS
522 ],[cf_cv_curses_acs_map=$name; break])
523 done
524 ])
525
526 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map,[Define as needed to override ncurses prefix _nc_])
527 ])
528 dnl ---------------------------------------------------------------------------
529 dnl CF_CURSES_CHECK_DATA version: 5 updated: 2014/07/19 18:41:17
530 dnl --------------------
531 dnl Check if curses.h defines the given data/variable.
532 dnl Use this after CF_NCURSES_CONFIG or CF_CURSES_CONFIG.
533 AC_DEFUN([CF_CURSES_CHECK_DATA],
534 [
535 AC_MSG_CHECKING(for data $1 declaration in ${cf_cv_ncurses_header:-curses.h})
536
537 AC_TRY_COMPILE(CF__CURSES_HEAD,[
538 void *foo = &($1)
539 ],cf_result=yes,cf_result=no)
540 AC_MSG_RESULT($cf_result)
541
542 if test $cf_result = yes ; then
543         CF_UPPER(cf_result,have_curses_data_$1)
544         AC_DEFINE_UNQUOTED($cf_result)
545 else
546         AC_MSG_CHECKING(for data $1 in library)
547         # BSD linkers insist on making weak linkage, but resolve at runtime.
548         AC_TRY_RUN(CF__CURSES_HEAD
549 [
550 extern char $1;
551 int main(void)
552 {
553         void *foo = &($1);
554         fprintf(stderr, "testing linkage of $1:%p\n", foo);
555         ${cf_cv_main_return:-return}(foo == 0);
556 }],[cf_result=yes],[cf_result=no],[
557         # cross-compiling
558         AC_TRY_LINK(CF__CURSES_HEAD
559 [extern char $1;],[
560         do {
561                 void *foo = &($1);
562                 fprintf(stderr, "testing linkage of $1:%p\n", foo);
563                 ${cf_cv_main_return:-return}(foo == 0);
564         } while (0)
565 ],[cf_result=yes],[cf_result=no])
566 ])
567         AC_MSG_RESULT($cf_result)
568         if test $cf_result = yes ; then
569                 CF_UPPER(cf_result,decl_curses_data_$1)
570                 AC_DEFINE_UNQUOTED($cf_result)
571         fi
572 fi
573 ])dnl
574 dnl ---------------------------------------------------------------------------
575 dnl CF_CURSES_CHECK_TYPE version: 4 updated: 2012/10/06 16:39:58
576 dnl --------------------
577 dnl Check if curses.h defines the given type
578 AC_DEFUN([CF_CURSES_CHECK_TYPE],
579 [
580 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header:-curses.h})
581 AC_TRY_COMPILE([
582 #ifndef _XOPEN_SOURCE_EXTENDED
583 #define _XOPEN_SOURCE_EXTENDED
584 #endif
585 #include <${cf_cv_ncurses_header:-curses.h}>],[
586 $1 foo
587 ],cf_result=yes,cf_result=no)
588 AC_MSG_RESULT($cf_result)
589 if test $cf_result = yes ; then
590         CF_UPPER(cf_result,have_type_$1)
591         AC_DEFINE_UNQUOTED($cf_result,1,[Define to 1 if we have type $1])
592 else
593         AC_DEFINE_UNQUOTED($1,$2,[Define to appropriate type if $1 is not declared])
594 fi
595 ])dnl
596 dnl ---------------------------------------------------------------------------
597 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
598 dnl ----------------
599 dnl Tie together the configure-script macros for curses.  It may be ncurses,
600 dnl but unless asked, we do not make a special search for ncurses.  However,
601 dnl still check for the ncurses version number, for use in other macros.
602 AC_DEFUN([CF_CURSES_CONFIG],
603 [
604 CF_CURSES_CPPFLAGS
605 CF_NCURSES_VERSION
606 CF_CURSES_LIBS
607 ])dnl
608 dnl ---------------------------------------------------------------------------
609 dnl CF_CURSES_CPPFLAGS version: 12 updated: 2015/04/15 19:08:48
610 dnl ------------------
611 dnl Look for the curses headers.
612 AC_DEFUN([CF_CURSES_CPPFLAGS],[
613
614 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
615 cf_cv_curses_incdir=no
616 case $host_os in
617 (hpux10.*)
618         if test "x$cf_cv_screen" = "xcurses_colr"
619         then
620                 test -d /usr/include/curses_colr && \
621                 cf_cv_curses_incdir="-I/usr/include/curses_colr"
622         fi
623         ;;
624 (sunos3*|sunos4*)
625         if test "x$cf_cv_screen" = "xcurses_5lib"
626         then
627                 test -d /usr/5lib && \
628                 test -d /usr/5include && \
629                 cf_cv_curses_incdir="-I/usr/5include"
630         fi
631         ;;
632 esac
633 ])
634 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
635
636 CF_CURSES_HEADER
637 CF_TERM_HEADER
638 ])dnl
639 dnl ---------------------------------------------------------------------------
640 dnl CF_CURSES_FUNCS version: 18 updated: 2014/07/19 18:44:41
641 dnl ---------------
642 dnl Curses-functions are a little complicated, since a lot of them are macros.
643 AC_DEFUN([CF_CURSES_FUNCS],
644 [
645 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
646 AC_REQUIRE([CF_XOPEN_CURSES])
647 AC_REQUIRE([CF_CURSES_TERM_H])
648 AC_REQUIRE([CF_CURSES_UNCTRL_H])
649 for cf_func in $1
650 do
651         CF_UPPER(cf_tr_func,$cf_func)
652         AC_MSG_CHECKING(for ${cf_func})
653         CF_MSG_LOG(${cf_func})
654         AC_CACHE_VAL(cf_cv_func_$cf_func,[
655                 eval cf_result='$ac_cv_func_'$cf_func
656                 if test ".$cf_result" != ".no"; then
657                         AC_TRY_LINK(CF__CURSES_HEAD,
658                         [
659 #ifndef ${cf_func}
660 long foo = (long)(&${cf_func});
661 fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
662 if (foo + 1234 > 5678)
663         ${cf_cv_main_return:-return}(foo);
664 #endif
665                         ],
666                         [cf_result=yes],
667                         [cf_result=no])
668                 fi
669                 eval 'cf_cv_func_'$cf_func'=$cf_result'
670         ])
671         # use the computed/retrieved cache-value:
672         eval 'cf_result=$cf_cv_func_'$cf_func
673         AC_MSG_RESULT($cf_result)
674         if test $cf_result != no; then
675                 AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
676         fi
677 done
678 ])dnl
679 dnl ---------------------------------------------------------------------------
680 dnl CF_CURSES_HEADER version: 5 updated: 2015/04/23 20:35:30
681 dnl ----------------
682 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
683 dnl variations of ncurses' installs.
684 dnl
685 dnl $1 = ncurses when looking for ncurses, or is empty
686 AC_DEFUN([CF_CURSES_HEADER],[
687 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
688 cf_cv_ncurses_header=none
689 for cf_header in \
690         ncurses.h ifelse($1,,,[$1/ncurses.h]) \
691         curses.h ifelse($1,,,[$1/curses.h]) ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
692 do
693 AC_TRY_COMPILE([#include <${cf_header}>],
694         [initscr(); tgoto("?", 0,0)],
695         [cf_cv_ncurses_header=$cf_header; break],[])
696 done
697 ])
698
699 if test "$cf_cv_ncurses_header" = none ; then
700         AC_MSG_ERROR(No curses header-files found)
701 fi
702
703 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
704 AC_CHECK_HEADERS($cf_cv_ncurses_header)
705 ])dnl
706 dnl ---------------------------------------------------------------------------
707 dnl CF_CURSES_LIBS version: 39 updated: 2015/05/10 19:52:14
708 dnl --------------
709 dnl Look for the curses libraries.  Older curses implementations may require
710 dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
711 AC_DEFUN([CF_CURSES_LIBS],[
712
713 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
714 AC_MSG_CHECKING(if we have identified curses libraries)
715 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
716         [initscr(); tgoto("?", 0,0)],
717         cf_result=yes,
718         cf_result=no)
719 AC_MSG_RESULT($cf_result)
720
721 if test "$cf_result" = no ; then
722 case $host_os in
723 (freebsd*)
724         AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
725         ;;
726 (hpux10.*)
727         # Looking at HPUX 10.20, the Hcurses library is the oldest (1997), cur_colr
728         # next (1998), and xcurses "newer" (2000).  There is no header file for
729         # Hcurses; the subdirectory curses_colr has the headers (curses.h and
730         # term.h) for cur_colr
731         if test "x$cf_cv_screen" = "xcurses_colr"
732         then
733                 AC_CHECK_LIB(cur_colr,initscr,[
734                         CF_ADD_LIBS(-lcur_colr)
735                         ac_cv_func_initscr=yes
736                         ],[
737                 AC_CHECK_LIB(Hcurses,initscr,[
738                         # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
739                         CF_ADD_LIBS(-lHcurses)
740                         CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
741                         ac_cv_func_initscr=yes
742                         ])])
743         fi
744         ;;
745 (linux*)
746         case `arch 2>/dev/null` in
747         (x86_64)
748                 if test -d /lib64
749                 then
750                         CF_ADD_LIBDIR(/lib64)
751                 else
752                         CF_ADD_LIBDIR(/lib)
753                 fi
754                 ;;
755         (*)
756                 CF_ADD_LIBDIR(/lib)
757                 ;;
758         esac
759         ;;
760 (sunos3*|sunos4*)
761         if test "x$cf_cv_screen" = "xcurses_5lib"
762         then
763                 if test -d /usr/5lib ; then
764                         CF_ADD_LIBDIR(/usr/5lib)
765                         CF_ADD_LIBS(-lcurses -ltermcap)
766                 fi
767         fi
768         ac_cv_func_initscr=yes
769         ;;
770 esac
771
772 if test ".$ac_cv_func_initscr" != .yes ; then
773         cf_save_LIBS="$LIBS"
774
775         if test ".${cf_cv_ncurses_version:-no}" != .no
776         then
777                 cf_check_list="ncurses curses cursesX"
778         else
779                 cf_check_list="cursesX curses ncurses"
780         fi
781
782         # Check for library containing tgoto.  Do this before curses library
783         # because it may be needed to link the test-case for initscr.
784         if test "x$cf_term_lib" = x
785         then
786                 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
787                         for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
788                         do
789                                 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
790                         done
791                 ])
792         fi
793
794         # Check for library containing initscr
795         test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
796         if test "x$cf_curs_lib" = x
797         then
798                 for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
799                 do
800                         AC_CHECK_LIB($cf_curs_lib,initscr,[break])
801                 done
802         fi
803         test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
804
805         LIBS="-l$cf_curs_lib $cf_save_LIBS"
806         if test "$cf_term_lib" = unknown ; then
807                 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
808                 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
809                         [initscr()],
810                         [cf_result=yes],
811                         [cf_result=no])
812                 AC_MSG_RESULT($cf_result)
813                 test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
814         elif test "$cf_curs_lib" = "$cf_term_lib" ; then
815                 :
816         elif test "$cf_term_lib" != predefined ; then
817                 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
818                 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
819                         [initscr(); tgoto((char *)0, 0, 0);],
820                         [cf_result=no],
821                         [
822                         LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
823                         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
824                                 [initscr()],
825                                 [cf_result=yes],
826                                 [cf_result=error])
827                         ])
828                 AC_MSG_RESULT($cf_result)
829         fi
830 fi
831 fi
832
833 ])dnl
834 dnl ---------------------------------------------------------------------------
835 dnl CF_CURSES_TERM_H version: 11 updated: 2015/04/15 19:08:48
836 dnl ----------------
837 dnl SVr4 curses should have term.h as well (where it puts the definitions of
838 dnl the low-level interface).  This may not be true in old/broken implementations,
839 dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
840 dnl running with Solaris 2.5.1).
841 AC_DEFUN([CF_CURSES_TERM_H],
842 [
843 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
844
845 AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
846
847 # If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
848 # for <term.h> if we do not find the variant.
849
850 cf_header_list="term.h ncurses/term.h ncursesw/term.h"
851
852 case ${cf_cv_ncurses_header:-curses.h} in
853 (*/*)
854         cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
855         cf_header_list="$cf_header_item $cf_header_list"
856         ;;
857 esac
858
859 for cf_header in $cf_header_list
860 do
861         AC_TRY_COMPILE([
862 #include <${cf_cv_ncurses_header:-curses.h}>
863 #include <${cf_header}>],
864         [WINDOW *x],
865         [cf_cv_term_header=$cf_header
866          break],
867         [cf_cv_term_header=no])
868 done
869
870 case $cf_cv_term_header in
871 (no)
872         # If curses is ncurses, some packagers still mess it up by trying to make
873         # us use GNU termcap.  This handles the most common case.
874         for cf_header in ncurses/term.h ncursesw/term.h
875         do
876                 AC_TRY_COMPILE([
877 #include <${cf_cv_ncurses_header:-curses.h}>
878 #ifdef NCURSES_VERSION
879 #include <${cf_header}>
880 #else
881 make an error
882 #endif],
883                         [WINDOW *x],
884                         [cf_cv_term_header=$cf_header
885                          break],
886                         [cf_cv_term_header=no])
887         done
888         ;;
889 esac
890 ])
891
892 case $cf_cv_term_header in
893 (term.h)
894         AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
895         ;;
896 (ncurses/term.h)
897         AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
898         ;;
899 (ncursesw/term.h)
900         AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
901         ;;
902 esac
903 ])dnl
904 dnl ---------------------------------------------------------------------------
905 dnl CF_CURSES_UNCTRL_H version: 4 updated: 2015/04/15 19:08:48
906 dnl ------------------
907 dnl Any X/Open curses implementation must have unctrl.h, but ncurses packages
908 dnl may put it in a subdirectory (along with ncurses' other headers, of
909 dnl course).  Packages which put the headers in inconsistent locations are
910 dnl broken).
911 AC_DEFUN([CF_CURSES_UNCTRL_H],
912 [
913 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
914
915 AC_CACHE_CHECK(for unctrl.h, cf_cv_unctrl_header,[
916
917 # If we found <ncurses/curses.h>, look for <ncurses/unctrl.h>, but always look
918 # for <unctrl.h> if we do not find the variant.
919
920 cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
921
922 case ${cf_cv_ncurses_header:-curses.h} in
923 (*/*)
924         cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
925         cf_header_list="$cf_header_item $cf_header_list"
926         ;;
927 esac
928
929 for cf_header in $cf_header_list
930 do
931         AC_TRY_COMPILE([
932 #include <${cf_cv_ncurses_header:-curses.h}>
933 #include <${cf_header}>],
934         [WINDOW *x],
935         [cf_cv_unctrl_header=$cf_header
936          break],
937         [cf_cv_unctrl_header=no])
938 done
939 ])
940
941 case $cf_cv_unctrl_header in
942 (no)
943         AC_MSG_WARN(unctrl.h header not found)
944         ;;
945 esac
946
947 case $cf_cv_unctrl_header in
948 (unctrl.h)
949         AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
950         ;;
951 (ncurses/unctrl.h)
952         AC_DEFINE(HAVE_NCURSES_UNCTRL_H,1,[Define to 1 if we have ncurses/unctrl.h])
953         ;;
954 (ncursesw/unctrl.h)
955         AC_DEFINE(HAVE_NCURSESW_UNCTRL_H,1,[Define to 1 if we have ncursesw/unctrl.h])
956         ;;
957 esac
958 ])dnl
959 dnl ---------------------------------------------------------------------------
960 dnl CF_CURSES_WACS_MAP version: 6 updated: 2012/10/06 08:57:51
961 dnl ------------------
962 dnl Check for likely values of wacs_map[].
963 AC_DEFUN([CF_CURSES_WACS_MAP],
964 [
965 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
966         cf_cv_curses_wacs_map=unknown
967         for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
968         do
969         AC_TRY_LINK([
970 #ifndef _XOPEN_SOURCE_EXTENDED
971 #define _XOPEN_SOURCE_EXTENDED
972 #endif
973 #include <${cf_cv_ncurses_header:-curses.h}>],
974         [void *foo = &($name['k'])],
975         [cf_cv_curses_wacs_map=$name
976          break])
977         done])
978
979 test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map,[Define to name of (n)curses wide-character array])
980 ])dnl
981 dnl ---------------------------------------------------------------------------
982 dnl CF_CURSES_WACS_SYMBOLS version: 2 updated: 2012/10/06 08:57:51
983 dnl ----------------------
984 dnl Do a check to see if the WACS_xxx constants are defined compatibly with
985 dnl X/Open Curses.  In particular, NetBSD's implementation of the WACS_xxx
986 dnl constants is broken since those constants do not point to cchar_t's.
987 AC_DEFUN([CF_CURSES_WACS_SYMBOLS],
988 [
989 AC_REQUIRE([CF_CURSES_WACS_MAP])
990
991 AC_CACHE_CHECK(for wide alternate character constants, cf_cv_curses_wacs_symbols,[
992 cf_cv_curses_wacs_symbols=no
993 if test "$cf_cv_curses_wacs_map" != unknown
994 then
995         AC_TRY_LINK([
996 #ifndef _XOPEN_SOURCE_EXTENDED
997 #define _XOPEN_SOURCE_EXTENDED
998 #endif
999 #include <${cf_cv_ncurses_header:-curses.h}>],
1000         [cchar_t *foo = WACS_PLUS;
1001          $cf_cv_curses_wacs_map['k'] = *WACS_PLUS],
1002         [cf_cv_curses_wacs_symbols=yes])
1003 else
1004         AC_TRY_LINK([
1005 #ifndef _XOPEN_SOURCE_EXTENDED
1006 #define _XOPEN_SOURCE_EXTENDED
1007 #endif
1008 #include <${cf_cv_ncurses_header:-curses.h}>],
1009         [cchar_t *foo = WACS_PLUS],
1010         [cf_cv_curses_wacs_symbols=yes])
1011 fi
1012 ])
1013
1014 test "$cf_cv_curses_wacs_symbols" != no && AC_DEFINE(CURSES_WACS_SYMBOLS,1,[Define to 1 if (n)curses supports wide-character WACS_ symbols])
1015 ])dnl
1016 dnl ---------------------------------------------------------------------------
1017 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
1018 dnl ----------
1019 dnl "dirname" is not portable, so we fake it with a shell script.
1020 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
1021 dnl ---------------------------------------------------------------------------
1022 dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
1023 dnl ---------------
1024 dnl You can always use "make -n" to see the actual options, but it's hard to
1025 dnl pick out/analyze warning messages when the compile-line is long.
1026 dnl
1027 dnl Sets:
1028 dnl     ECHO_LT - symbol to control if libtool is verbose
1029 dnl     ECHO_LD - symbol to prefix "cc -o" lines
1030 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1031 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
1032 dnl     ECHO_CC - symbol to put before any "cc" line
1033 dnl
1034 AC_DEFUN([CF_DISABLE_ECHO],[
1035 AC_MSG_CHECKING(if you want to see long compiling messages)
1036 CF_ARG_DISABLE(echo,
1037         [  --disable-echo          do not display "compiling" commands],
1038         [
1039         ECHO_LT='--silent'
1040         ECHO_LD='@echo linking [$]@;'
1041         RULE_CC='@echo compiling [$]<'
1042         SHOW_CC='@echo compiling [$]@'
1043         ECHO_CC='@'
1044 ],[
1045         ECHO_LT=''
1046         ECHO_LD=''
1047         RULE_CC=''
1048         SHOW_CC=''
1049         ECHO_CC=''
1050 ])
1051 AC_MSG_RESULT($enableval)
1052 AC_SUBST(ECHO_LT)
1053 AC_SUBST(ECHO_LD)
1054 AC_SUBST(RULE_CC)
1055 AC_SUBST(SHOW_CC)
1056 AC_SUBST(ECHO_CC)
1057 ])dnl
1058 dnl ---------------------------------------------------------------------------
1059 dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
1060 dnl ----------------
1061 dnl Combine no-leak checks with the libraries or tools that are used for the
1062 dnl checks.
1063 AC_DEFUN([CF_DISABLE_LEAKS],[
1064
1065 AC_REQUIRE([CF_WITH_DMALLOC])
1066 AC_REQUIRE([CF_WITH_DBMALLOC])
1067 AC_REQUIRE([CF_WITH_VALGRIND])
1068
1069 AC_MSG_CHECKING(if you want to perform memory-leak testing)
1070 AC_ARG_ENABLE(leaks,
1071         [  --disable-leaks         test: free permanent memory, analyze leaks],
1072         [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
1073         : ${with_no_leaks:=no})
1074 AC_MSG_RESULT($with_no_leaks)
1075
1076 if test "$with_no_leaks" = yes ; then
1077         AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
1078         AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
1079 fi
1080 ])dnl
1081 dnl ---------------------------------------------------------------------------
1082 dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
1083 dnl ---------------------
1084 dnl The rpath-hack makes it simpler to build programs, particularly with the
1085 dnl *BSD ports which may have essential libraries in unusual places.  But it
1086 dnl can interfere with building an executable for the base system.  Use this
1087 dnl option in that case.
1088 AC_DEFUN([CF_DISABLE_RPATH_HACK],
1089 [
1090 AC_MSG_CHECKING(if rpath-hack should be disabled)
1091 CF_ARG_DISABLE(rpath-hack,
1092         [  --disable-rpath-hack    don't add rpath options for additional libraries],
1093         [cf_disable_rpath_hack=yes],
1094         [cf_disable_rpath_hack=no])
1095 AC_MSG_RESULT($cf_disable_rpath_hack)
1096 if test "$cf_disable_rpath_hack" = no ; then
1097         CF_RPATH_HACK
1098 fi
1099 ])
1100 dnl ---------------------------------------------------------------------------
1101 dnl CF_ENABLE_WARNINGS version: 4 updated: 2009/07/26 17:53:03
1102 dnl ------------------
1103 dnl Configure-option to enable gcc warnings
1104 AC_DEFUN([CF_ENABLE_WARNINGS],[
1105 if ( test "$GCC" = yes || test "$GXX" = yes )
1106 then
1107 AC_MSG_CHECKING(if you want to turn on gcc warnings)
1108 CF_ARG_ENABLE(warnings,
1109         [  --enable-warnings       test: turn on gcc compiler warnings],
1110         [with_warnings=yes],
1111         [with_warnings=no])
1112 AC_MSG_RESULT($with_warnings)
1113 if test "$with_warnings" = "yes"
1114 then
1115         CF_GCC_ATTRIBUTES
1116         CF_GCC_WARNINGS
1117 fi
1118 fi
1119 ])dnl
1120 dnl ---------------------------------------------------------------------------
1121 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
1122 dnl ---------------
1123 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
1124 dnl prefer a standard location, and use -L options only if we do not find the
1125 dnl library in the standard library location(s).
1126 dnl     $1 = library name
1127 dnl     $2 = library class, usually the same as library name
1128 dnl     $3 = includes
1129 dnl     $4 = code fragment to compile/link
1130 dnl     $5 = corresponding function-name
1131 dnl     $6 = flag, nonnull if failure should not cause an error-exit
1132 dnl
1133 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
1134 dnl to use a -L option.
1135 AC_DEFUN([CF_FIND_LIBRARY],
1136 [
1137         eval 'cf_cv_have_lib_'$1'=no'
1138         cf_libdir=""
1139         AC_CHECK_FUNC($5,
1140                 eval 'cf_cv_have_lib_'$1'=yes',[
1141                 cf_save_LIBS="$LIBS"
1142                 AC_MSG_CHECKING(for $5 in -l$1)
1143                 LIBS="-l$1 $LIBS"
1144                 AC_TRY_LINK([$3],[$4],
1145                         [AC_MSG_RESULT(yes)
1146                          eval 'cf_cv_have_lib_'$1'=yes'
1147                         ],
1148                         [AC_MSG_RESULT(no)
1149                         CF_LIBRARY_PATH(cf_search,$2)
1150                         for cf_libdir in $cf_search
1151                         do
1152                                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
1153                                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
1154                                 AC_TRY_LINK([$3],[$4],
1155                                         [AC_MSG_RESULT(yes)
1156                                          eval 'cf_cv_have_lib_'$1'=yes'
1157                                          break],
1158                                         [AC_MSG_RESULT(no)
1159                                          LIBS="$cf_save_LIBS"])
1160                         done
1161                         ])
1162                 ])
1163 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
1164 ifelse($6,,[
1165 if test $cf_found_library = no ; then
1166         AC_MSG_ERROR(Cannot link $1 library)
1167 fi
1168 ])
1169 ])dnl
1170 dnl ---------------------------------------------------------------------------
1171 dnl CF_FIND_LINKAGE version: 20 updated: 2015/04/18 08:56:57
1172 dnl ---------------
1173 dnl Find a library (specifically the linkage used in the code fragment),
1174 dnl searching for it if it is not already in the library path.
1175 dnl See also CF_ADD_SEARCHPATH.
1176 dnl
1177 dnl Parameters (4-on are optional):
1178 dnl     $1 = headers for library entrypoint
1179 dnl     $2 = code fragment for library entrypoint
1180 dnl     $3 = the library name without the "-l" option or ".so" suffix.
1181 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1182 dnl     $5 = action to perform if not successful
1183 dnl     $6 = module name, if not the same as the library name
1184 dnl     $7 = extra libraries
1185 dnl
1186 dnl Sets these variables:
1187 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1188 dnl     $cf_cv_header_path_$3 - include-directory if needed
1189 dnl     $cf_cv_library_path_$3 - library-directory if needed
1190 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1191 AC_DEFUN([CF_FIND_LINKAGE],[
1192
1193 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1194 # will be set on completion of the AC_TRY_LINK below.
1195 cf_cv_header_path_$3=
1196 cf_cv_library_path_$3=
1197
1198 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1199
1200 cf_save_LIBS="$LIBS"
1201
1202 AC_TRY_LINK([$1],[$2],[
1203         cf_cv_find_linkage_$3=yes
1204         cf_cv_header_path_$3=/usr/include
1205         cf_cv_library_path_$3=/usr/lib
1206 ],[
1207
1208 LIBS="-l$3 $7 $cf_save_LIBS"
1209
1210 AC_TRY_LINK([$1],[$2],[
1211         cf_cv_find_linkage_$3=yes
1212         cf_cv_header_path_$3=/usr/include
1213         cf_cv_library_path_$3=/usr/lib
1214         cf_cv_library_file_$3="-l$3"
1215 ],[
1216         cf_cv_find_linkage_$3=no
1217         LIBS="$cf_save_LIBS"
1218
1219         CF_VERBOSE(find linkage for $3 library)
1220         CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1221
1222         cf_save_CPPFLAGS="$CPPFLAGS"
1223         cf_test_CPPFLAGS="$CPPFLAGS"
1224
1225         CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1226         for cf_cv_header_path_$3 in $cf_search
1227         do
1228                 if test -d $cf_cv_header_path_$3 ; then
1229                         CF_VERBOSE(... testing $cf_cv_header_path_$3)
1230                         CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1231                         AC_TRY_COMPILE([$1],[$2],[
1232                                 CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1233                                 cf_cv_find_linkage_$3=maybe
1234                                 cf_test_CPPFLAGS="$CPPFLAGS"
1235                                 break],[
1236                                 CPPFLAGS="$cf_save_CPPFLAGS"
1237                                 ])
1238                 fi
1239         done
1240
1241         if test "$cf_cv_find_linkage_$3" = maybe ; then
1242
1243                 CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1244
1245                 cf_save_LIBS="$LIBS"
1246                 cf_save_LDFLAGS="$LDFLAGS"
1247
1248                 ifelse([$6],,,[
1249                 CPPFLAGS="$cf_test_CPPFLAGS"
1250                 LIBS="-l$3 $7 $cf_save_LIBS"
1251                 AC_TRY_LINK([$1],[$2],[
1252                         CF_VERBOSE(... found $3 library in system)
1253                         cf_cv_find_linkage_$3=yes])
1254                         CPPFLAGS="$cf_save_CPPFLAGS"
1255                         LIBS="$cf_save_LIBS"
1256                         ])
1257
1258                 if test "$cf_cv_find_linkage_$3" != yes ; then
1259                         CF_LIBRARY_PATH(cf_search,$3)
1260                         for cf_cv_library_path_$3 in $cf_search
1261                         do
1262                                 if test -d $cf_cv_library_path_$3 ; then
1263                                         CF_VERBOSE(... testing $cf_cv_library_path_$3)
1264                                         CPPFLAGS="$cf_test_CPPFLAGS"
1265                                         LIBS="-l$3 $7 $cf_save_LIBS"
1266                                         LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1267                                         AC_TRY_LINK([$1],[$2],[
1268                                         CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1269                                         cf_cv_find_linkage_$3=yes
1270                                         cf_cv_library_file_$3="-l$3"
1271                                         break],[
1272                                         CPPFLAGS="$cf_save_CPPFLAGS"
1273                                         LIBS="$cf_save_LIBS"
1274                                         LDFLAGS="$cf_save_LDFLAGS"
1275                                         ])
1276                                 fi
1277                         done
1278                         CPPFLAGS="$cf_save_CPPFLAGS"
1279                         LDFLAGS="$cf_save_LDFLAGS"
1280                 fi
1281
1282         else
1283                 cf_cv_find_linkage_$3=no
1284         fi
1285         ],$7)
1286 ])
1287
1288 LIBS="$cf_save_LIBS"
1289
1290 if test "$cf_cv_find_linkage_$3" = yes ; then
1291 ifelse([$4],,[
1292         CF_ADD_INCDIR($cf_cv_header_path_$3)
1293         CF_ADD_LIBDIR($cf_cv_library_path_$3)
1294         CF_ADD_LIB($3)
1295 ],[$4])
1296 else
1297 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1298 fi
1299 ])dnl
1300 dnl ---------------------------------------------------------------------------
1301 dnl CF_FUNC_CURSES_VERSION version: 6 updated: 2012/10/06 16:39:58
1302 dnl ----------------------
1303 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
1304 dnl It's a character string "SVR4", not documented.
1305 AC_DEFUN([CF_FUNC_CURSES_VERSION],
1306 [
1307 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
1308 AC_TRY_RUN([
1309 #include <${cf_cv_ncurses_header:-curses.h}>
1310 int main()
1311 {
1312         char temp[1024];
1313         sprintf(temp, "%s\n", curses_version());
1314         ${cf_cv_main_return:-return}(0);
1315 }]
1316 ,[cf_cv_func_curses_version=yes]
1317 ,[cf_cv_func_curses_version=no]
1318 ,[cf_cv_func_curses_version=unknown])
1319 rm -f core])
1320 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION,1,[Define to 1 if we have curses_version function])
1321 ])
1322 dnl ---------------------------------------------------------------------------
1323 dnl CF_FUNC_OPENPTY version: 5 updated: 2015/09/12 14:46:50
1324 dnl ---------------
1325 dnl Check for openpty() function, along with <pty.h> header.  It may need the
1326 dnl "util" library as well.
1327 AC_DEFUN([CF_FUNC_OPENPTY],
1328 [
1329 AC_CHECK_LIB(util,openpty,cf_cv_lib_util=yes,cf_cv_lib_util=no)
1330 AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
1331         cf_save_LIBS="$LIBS"
1332         test $cf_cv_lib_util = yes && { CF_ADD_LIB(util) }
1333         for cf_header in pty.h libutil.h util.h
1334         do
1335         AC_TRY_LINK([
1336 #include <$cf_header>
1337 ],[
1338         int x = openpty((int *)0, (int *)0, (char *)0,
1339                                    (struct termios *)0, (struct winsize *)0);
1340 ],[
1341                 cf_cv_func_openpty=$cf_header
1342                 break
1343 ],[
1344                 cf_cv_func_openpty=no
1345 ])
1346         done
1347         LIBS="$cf_save_LIBS"
1348 ])
1349 ])dnl
1350 dnl ---------------------------------------------------------------------------
1351 dnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
1352 dnl -----------------
1353 dnl Test for availability of useful gcc __attribute__ directives to quiet
1354 dnl compiler warnings.  Though useful, not all are supported -- and contrary
1355 dnl to documentation, unrecognized directives cause older compilers to barf.
1356 AC_DEFUN([CF_GCC_ATTRIBUTES],
1357 [
1358 if test "$GCC" = yes
1359 then
1360 cat > conftest.i <<EOF
1361 #ifndef GCC_PRINTF
1362 #define GCC_PRINTF 0
1363 #endif
1364 #ifndef GCC_SCANF
1365 #define GCC_SCANF 0
1366 #endif
1367 #ifndef GCC_NORETURN
1368 #define GCC_NORETURN /* nothing */
1369 #endif
1370 #ifndef GCC_UNUSED
1371 #define GCC_UNUSED /* nothing */
1372 #endif
1373 EOF
1374 if test "$GCC" = yes
1375 then
1376         AC_CHECKING([for $CC __attribute__ directives])
1377 cat > conftest.$ac_ext <<EOF
1378 #line __oline__ "${as_me:-configure}"
1379 #include "confdefs.h"
1380 #include "conftest.h"
1381 #include "conftest.i"
1382 #if     GCC_PRINTF
1383 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1384 #else
1385 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1386 #endif
1387 #if     GCC_SCANF
1388 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1389 #else
1390 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1391 #endif
1392 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1393 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1394 extern void foo(void) GCC_NORETURN;
1395 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1396 EOF
1397         cf_printf_attribute=no
1398         cf_scanf_attribute=no
1399         for cf_attribute in scanf printf unused noreturn
1400         do
1401                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1402                 cf_directive="__attribute__(($cf_attribute))"
1403                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1404
1405                 case $cf_attribute in
1406                 (printf)
1407                         cf_printf_attribute=yes
1408                         cat >conftest.h <<EOF
1409 #define GCC_$cf_ATTRIBUTE 1
1410 EOF
1411                         ;;
1412                 (scanf)
1413                         cf_scanf_attribute=yes
1414                         cat >conftest.h <<EOF
1415 #define GCC_$cf_ATTRIBUTE 1
1416 EOF
1417                         ;;
1418                 (*)
1419                         cat >conftest.h <<EOF
1420 #define GCC_$cf_ATTRIBUTE $cf_directive
1421 EOF
1422                         ;;
1423                 esac
1424
1425                 if AC_TRY_EVAL(ac_compile); then
1426                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1427                         cat conftest.h >>confdefs.h
1428                         case $cf_attribute in
1429                         (noreturn)
1430                                 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
1431                                 ;;
1432                         (printf)
1433                                 cf_value='/* nothing */'
1434                                 if test "$cf_printf_attribute" != no ; then
1435                                         cf_value='__attribute__((format(printf,fmt,var)))'
1436                                         AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
1437                                 fi
1438                                 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
1439                                 ;;
1440                         (scanf)
1441                                 cf_value='/* nothing */'
1442                                 if test "$cf_scanf_attribute" != no ; then
1443                                         cf_value='__attribute__((format(scanf,fmt,var)))'
1444                                         AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
1445                                 fi
1446                                 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
1447                                 ;;
1448                         (unused)
1449                                 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
1450                                 ;;
1451                         esac
1452                 fi
1453         done
1454 else
1455         fgrep define conftest.i >>confdefs.h
1456 fi
1457 rm -rf conftest*
1458 fi
1459 ])dnl
1460 dnl ---------------------------------------------------------------------------
1461 dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
1462 dnl --------------
1463 dnl Find version of gcc
1464 AC_DEFUN([CF_GCC_VERSION],[
1465 AC_REQUIRE([AC_PROG_CC])
1466 GCC_VERSION=none
1467 if test "$GCC" = yes ; then
1468         AC_MSG_CHECKING(version of $CC)
1469         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.]].*//'`"
1470         test -z "$GCC_VERSION" && GCC_VERSION=unknown
1471         AC_MSG_RESULT($GCC_VERSION)
1472 fi
1473 ])dnl
1474 dnl ---------------------------------------------------------------------------
1475 dnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
1476 dnl ---------------
1477 dnl Check if the compiler supports useful warning options.  There's a few that
1478 dnl we don't use, simply because they're too noisy:
1479 dnl
1480 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1481 dnl     -Wredundant-decls (system headers make this too noisy)
1482 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
1483 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
1484 dnl             is enabled for ncurses using "--enable-const".
1485 dnl     -pedantic
1486 dnl
1487 dnl Parameter:
1488 dnl     $1 is an optional list of gcc warning flags that a particular
1489 dnl             application might want to use, e.g., "no-unused" for
1490 dnl             -Wno-unused
1491 dnl Special:
1492 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1493 dnl
1494 AC_DEFUN([CF_GCC_WARNINGS],
1495 [
1496 AC_REQUIRE([CF_GCC_VERSION])
1497 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1498 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
1499
1500 cat > conftest.$ac_ext <<EOF
1501 #line __oline__ "${as_me:-configure}"
1502 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1503 EOF
1504
1505 if test "$INTEL_COMPILER" = yes
1506 then
1507 # The "-wdXXX" options suppress warnings:
1508 # remark #1419: external declaration in primary source file
1509 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1510 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1511 # remark #193: zero used for undefined preprocessing identifier
1512 # remark #593: variable "curs_sb_left_arrow" was set but never used
1513 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1514 # remark #869: parameter "tw" was never referenced
1515 # remark #981: operands are evaluated in unspecified order
1516 # warning #279: controlling expression is constant
1517
1518         AC_CHECKING([for $CC warning options])
1519         cf_save_CFLAGS="$CFLAGS"
1520         EXTRA_CFLAGS="-Wall"
1521         for cf_opt in \
1522                 wd1419 \
1523                 wd1683 \
1524                 wd1684 \
1525                 wd193 \
1526                 wd593 \
1527                 wd279 \
1528                 wd810 \
1529                 wd869 \
1530                 wd981
1531         do
1532                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1533                 if AC_TRY_EVAL(ac_compile); then
1534                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1535                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1536                 fi
1537         done
1538         CFLAGS="$cf_save_CFLAGS"
1539
1540 elif test "$GCC" = yes
1541 then
1542         AC_CHECKING([for $CC warning options])
1543         cf_save_CFLAGS="$CFLAGS"
1544         EXTRA_CFLAGS=
1545         cf_warn_CONST=""
1546         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1547         cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
1548         test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
1549         for cf_opt in W Wall \
1550                 Wbad-function-cast \
1551                 Wcast-align \
1552                 Wcast-qual \
1553                 Wdeclaration-after-statement \
1554                 Wextra \
1555                 Winline \
1556                 Wmissing-declarations \
1557                 Wmissing-prototypes \
1558                 Wnested-externs \
1559                 Wpointer-arith \
1560                 Wshadow \
1561                 Wstrict-prototypes \
1562                 Wundef $cf_gcc_warnings $cf_warn_CONST $1
1563         do
1564                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1565                 if AC_TRY_EVAL(ac_compile); then
1566                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1567                         case $cf_opt in
1568                         (Wcast-qual)
1569                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1570                                 ;;
1571                         (Winline)
1572                                 case $GCC_VERSION in
1573                                 ([[34]].*)
1574                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1575                                         continue;;
1576                                 esac
1577                                 ;;
1578                         (Wpointer-arith)
1579                                 case $GCC_VERSION in
1580                                 ([[12]].*)
1581                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1582                                         continue;;
1583                                 esac
1584                                 ;;
1585                         esac
1586                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1587                 fi
1588         done
1589         CFLAGS="$cf_save_CFLAGS"
1590 fi
1591 rm -rf conftest*
1592
1593 AC_SUBST(EXTRA_CFLAGS)
1594 ])dnl
1595 dnl ---------------------------------------------------------------------------
1596 dnl CF_GETOPT_HEADER version: 6 updated: 2014/07/22 14:45:54
1597 dnl ----------------
1598 dnl Check for getopt's variables which are commonly defined in stdlib.h,
1599 dnl unistd.h or (nonstandard) in getopt.h
1600 AC_DEFUN([CF_GETOPT_HEADER],
1601 [
1602 AC_HAVE_HEADERS(unistd.h getopt.h)
1603 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
1604 cf_cv_getopt_header=none
1605 for cf_header in stdio.h stdlib.h unistd.h getopt.h
1606 do
1607 AC_TRY_COMPILE([
1608 #include <$cf_header>],
1609 [int x = optind; char *y = optarg],
1610 [cf_cv_getopt_header=$cf_header
1611  break])
1612 done
1613 ])
1614 if test $cf_cv_getopt_header != none ; then
1615         AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
1616 fi
1617 if test $cf_cv_getopt_header = getopt.h ; then
1618         AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
1619 fi
1620 ])dnl
1621 dnl ---------------------------------------------------------------------------
1622 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1623 dnl -------------
1624 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1625 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1626 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1627 dnl since it is interwoven with GNU extensions.
1628 dnl
1629 dnl Well, yes we could work around it...
1630 AC_DEFUN([CF_GNU_SOURCE],
1631 [
1632 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1633 AC_TRY_COMPILE([#include <sys/types.h>],[
1634 #ifndef _XOPEN_SOURCE
1635 make an error
1636 #endif],
1637         [cf_cv_gnu_source=no],
1638         [cf_save="$CPPFLAGS"
1639          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1640          AC_TRY_COMPILE([#include <sys/types.h>],[
1641 #ifdef _XOPEN_SOURCE
1642 make an error
1643 #endif],
1644         [cf_cv_gnu_source=no],
1645         [cf_cv_gnu_source=yes])
1646         CPPFLAGS="$cf_save"
1647         ])
1648 ])
1649 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1650 ])dnl
1651 dnl ---------------------------------------------------------------------------
1652 dnl CF_HEADER_PATH version: 13 updated: 2015/04/15 19:08:48
1653 dnl --------------
1654 dnl Construct a search-list of directories for a nonstandard header-file
1655 dnl
1656 dnl Parameters
1657 dnl     $1 = the variable to return as result
1658 dnl     $2 = the package name
1659 AC_DEFUN([CF_HEADER_PATH],
1660 [
1661 $1=
1662
1663 # collect the current set of include-directories from compiler flags
1664 cf_header_path_list=""
1665 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1666         for cf_header_path in $CPPFLAGS $CFLAGS
1667         do
1668                 case $cf_header_path in
1669                 (-I*)
1670                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1671                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1672                         cf_header_path_list="$cf_header_path_list [$]$1"
1673                         ;;
1674                 esac
1675         done
1676 fi
1677
1678 # add the variations for the package we are looking for
1679 CF_SUBDIR_PATH($1,$2,include)
1680
1681 test "$includedir" != NONE && \
1682 test "$includedir" != "/usr/include" && \
1683 test -d "$includedir" && {
1684         test -d $includedir &&    $1="[$]$1 $includedir"
1685         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1686 }
1687
1688 test "$oldincludedir" != NONE && \
1689 test "$oldincludedir" != "/usr/include" && \
1690 test -d "$oldincludedir" && {
1691         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
1692         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1693 }
1694
1695 $1="[$]$1 $cf_header_path_list"
1696 ])dnl
1697 dnl ---------------------------------------------------------------------------
1698 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1699 dnl ---------------
1700 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1701 AC_DEFUN([CF_HELP_MESSAGE],
1702 [AC_DIVERT_HELP([$1])dnl
1703 ])dnl
1704 dnl ---------------------------------------------------------------------------
1705 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
1706 dnl -----------------
1707 dnl If we do not have a given script, look for it in the parent directory.
1708 AC_DEFUN([CF_INHERIT_SCRIPT],
1709 [
1710 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
1711 ])dnl
1712 dnl ---------------------------------------------------------------------------
1713 dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
1714 dnl -----------------
1715 dnl Check if the given compiler is really the Intel compiler for Linux.  It
1716 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1717 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1718 dnl
1719 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1720 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1721 dnl the wrappers for gcc and g++ warnings.
1722 dnl
1723 dnl $1 = GCC (default) or GXX
1724 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1725 dnl $3 = CFLAGS (default) or CXXFLAGS
1726 AC_DEFUN([CF_INTEL_COMPILER],[
1727 AC_REQUIRE([AC_CANONICAL_HOST])
1728 ifelse([$2],,INTEL_COMPILER,[$2])=no
1729
1730 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1731         case $host_os in
1732         (linux*|gnu*)
1733                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1734                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1735                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1736                 AC_TRY_COMPILE([],[
1737 #ifdef __INTEL_COMPILER
1738 #else
1739 make an error
1740 #endif
1741 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1742 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1743 ],[])
1744                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1745                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1746                 ;;
1747         esac
1748 fi
1749 ])dnl
1750 dnl ---------------------------------------------------------------------------
1751 dnl CF_LD_RPATH_OPT version: 7 updated: 2016/02/20 18:01:19
1752 dnl ---------------
1753 dnl For the given system and compiler, find the compiler flags to pass to the
1754 dnl loader to use the "rpath" feature.
1755 AC_DEFUN([CF_LD_RPATH_OPT],
1756 [
1757 AC_REQUIRE([CF_CHECK_CACHE])
1758
1759 LD_RPATH_OPT=
1760 AC_MSG_CHECKING(for an rpath option)
1761 case $cf_cv_system_name in
1762 (irix*)
1763         if test "$GCC" = yes; then
1764                 LD_RPATH_OPT="-Wl,-rpath,"
1765         else
1766                 LD_RPATH_OPT="-rpath "
1767         fi
1768         ;;
1769 (linux*|gnu*|k*bsd*-gnu|freebsd*)
1770         LD_RPATH_OPT="-Wl,-rpath,"
1771         ;;
1772 (openbsd[[2-9]].*|mirbsd*)
1773         LD_RPATH_OPT="-Wl,-rpath,"
1774         ;;
1775 (dragonfly*)
1776         LD_RPATH_OPT="-rpath "
1777         ;;
1778 (netbsd*)
1779         LD_RPATH_OPT="-Wl,-rpath,"
1780         ;;
1781 (osf*|mls+*)
1782         LD_RPATH_OPT="-rpath "
1783         ;;
1784 (solaris2*)
1785         LD_RPATH_OPT="-R"
1786         ;;
1787 (*)
1788         ;;
1789 esac
1790 AC_MSG_RESULT($LD_RPATH_OPT)
1791
1792 case "x$LD_RPATH_OPT" in
1793 (x-R*)
1794         AC_MSG_CHECKING(if we need a space after rpath option)
1795         cf_save_LIBS="$LIBS"
1796         CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
1797         AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1798         LIBS="$cf_save_LIBS"
1799         AC_MSG_RESULT($cf_rpath_space)
1800         test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
1801         ;;
1802 esac
1803 ])dnl
1804 dnl ---------------------------------------------------------------------------
1805 dnl CF_LIBRARY_PATH version: 10 updated: 2015/04/15 19:08:48
1806 dnl ---------------
1807 dnl Construct a search-list of directories for a nonstandard library-file
1808 dnl
1809 dnl Parameters
1810 dnl     $1 = the variable to return as result
1811 dnl     $2 = the package name
1812 AC_DEFUN([CF_LIBRARY_PATH],
1813 [
1814 $1=
1815 cf_library_path_list=""
1816 if test -n "${LDFLAGS}${LIBS}" ; then
1817         for cf_library_path in $LDFLAGS $LIBS
1818         do
1819                 case $cf_library_path in
1820                 (-L*)
1821                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
1822                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
1823                         cf_library_path_list="$cf_library_path_list [$]$1"
1824                         ;;
1825                 esac
1826         done
1827 fi
1828
1829 CF_SUBDIR_PATH($1,$2,lib)
1830
1831 $1="$cf_library_path_list [$]$1"
1832 ])dnl
1833 dnl ---------------------------------------------------------------------------
1834 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1835 dnl ------------
1836 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1837 dnl a monocase filesystem.
1838 AC_DEFUN([CF_MAKE_TAGS],[
1839 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1840
1841 AC_CHECK_PROGS(CTAGS, exctags ctags)
1842 AC_CHECK_PROGS(ETAGS, exetags etags)
1843
1844 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1845
1846 if test "$cf_cv_mixedcase" = yes ; then
1847         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1848 else
1849         MAKE_UPPER_TAGS=no
1850 fi
1851
1852 if test "$MAKE_UPPER_TAGS" = yes ; then
1853         MAKE_UPPER_TAGS=
1854 else
1855         MAKE_UPPER_TAGS="#"
1856 fi
1857
1858 if test "$MAKE_LOWER_TAGS" = yes ; then
1859         MAKE_LOWER_TAGS=
1860 else
1861         MAKE_LOWER_TAGS="#"
1862 fi
1863
1864 AC_SUBST(CTAGS)
1865 AC_SUBST(ETAGS)
1866
1867 AC_SUBST(MAKE_UPPER_TAGS)
1868 AC_SUBST(MAKE_LOWER_TAGS)
1869 ])dnl
1870 dnl ---------------------------------------------------------------------------
1871 dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
1872 dnl -----------
1873 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
1874 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
1875 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
1876 AC_DEFUN([CF_MATH_LIB],
1877 [
1878 AC_CACHE_CHECK(if -lm needed for math functions,
1879         cf_cv_need_libm,[
1880         AC_TRY_LINK([
1881         #include <stdio.h>
1882         #include <math.h>
1883         ],
1884         [double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
1885         [cf_cv_need_libm=no],
1886         [cf_cv_need_libm=yes])])
1887 if test "$cf_cv_need_libm" = yes
1888 then
1889 ifelse($1,,[
1890         CF_ADD_LIB(m)
1891 ],[$1=-lm])
1892 fi
1893 ])
1894 dnl ---------------------------------------------------------------------------
1895 dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
1896 dnl ----------------------
1897 dnl Check if the file-system supports mixed-case filenames.  If we're able to
1898 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1899 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1900 [
1901 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1902 if test "$cross_compiling" = yes ; then
1903         case $target_alias in
1904         (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
1905                 cf_cv_mixedcase=no
1906                 ;;
1907         (*)
1908                 cf_cv_mixedcase=yes
1909                 ;;
1910         esac
1911 else
1912         rm -f conftest CONFTEST
1913         echo test >conftest
1914         if test -f CONFTEST ; then
1915                 cf_cv_mixedcase=no
1916         else
1917                 cf_cv_mixedcase=yes
1918         fi
1919         rm -f conftest CONFTEST
1920 fi
1921 ])
1922 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1923 ])dnl
1924 dnl ---------------------------------------------------------------------------
1925 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1926 dnl ----------
1927 dnl Write a debug message to config.log, along with the line number in the
1928 dnl configure script.
1929 AC_DEFUN([CF_MSG_LOG],[
1930 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1931 ])dnl
1932 dnl ---------------------------------------------------------------------------
1933 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
1934 dnl -------------------
1935 dnl Check if we can compile with ncurses' header file
1936 dnl $1 is the cache variable to set
1937 dnl $2 is the header-file to include
1938 dnl $3 is the root name (ncurses or ncursesw)
1939 AC_DEFUN([CF_NCURSES_CC_CHECK],[
1940         AC_TRY_COMPILE([
1941 ]ifelse($3,ncursesw,[
1942 #define _XOPEN_SOURCE_EXTENDED
1943 #undef  HAVE_LIBUTF8_H  /* in case we used CF_UTF8_LIB */
1944 #define HAVE_LIBUTF8_H  /* to force ncurses' header file to use cchar_t */
1945 ])[
1946 #include <$2>],[
1947 #ifdef NCURSES_VERSION
1948 ]ifelse($3,ncursesw,[
1949 #ifndef WACS_BSSB
1950         make an error
1951 #endif
1952 ])[
1953 printf("%s\n", NCURSES_VERSION);
1954 #else
1955 #ifdef __NCURSES_H
1956 printf("old\n");
1957 #else
1958         make an error
1959 #endif
1960 #endif
1961         ]
1962         ,[$1=$2]
1963         ,[$1=no])
1964 ])dnl
1965 dnl ---------------------------------------------------------------------------
1966 dnl CF_NCURSES_CONFIG version: 17 updated: 2015/07/07 04:22:07
1967 dnl -----------------
1968 dnl Tie together the configure-script macros for ncurses, preferring these in
1969 dnl order:
1970 dnl a) ".pc" files for pkg-config, using $NCURSES_CONFIG_PKG
1971 dnl b) the "-config" script from ncurses, using $NCURSES_CONFIG
1972 dnl c) just plain libraries
1973 dnl
1974 dnl $1 is the root library name (default: "ncurses")
1975 AC_DEFUN([CF_NCURSES_CONFIG],[
1976 AC_REQUIRE([CF_PKG_CONFIG])
1977 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1978 cf_have_ncuconfig=no
1979
1980 if test "x${PKG_CONFIG:=none}" != xnone; then
1981         AC_MSG_CHECKING(pkg-config for $cf_ncuconfig_root)
1982         if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
1983                 AC_MSG_RESULT(yes)
1984
1985                 AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
1986                 cf_have_ncuconfig=unknown
1987
1988                 cf_save_CPPFLAGS="$CPPFLAGS"
1989                 cf_save_LIBS="$LIBS"
1990
1991                 CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
1992                 CF_ADD_LIBS(`$PKG_CONFIG --libs $cf_ncuconfig_root`)
1993
1994                 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1995                         [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1996                         [AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
1997                                 int main(void)
1998                                 { char *xx = curses_version(); return (xx == 0); }],
1999                                 [cf_have_ncuconfig=yes],
2000                                 [cf_have_ncuconfig=no],
2001                                 [cf_have_ncuconfig=maybe])],
2002                         [cf_have_ncuconfig=no])
2003                 AC_MSG_RESULT($cf_have_ncuconfig)
2004                 test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
2005                 if test "$cf_have_ncuconfig" != "yes"
2006                 then
2007                         CPPFLAGS="$cf_save_CPPFLAGS"
2008                         LIBS="$cf_save_LIBS"
2009                         NCURSES_CONFIG_PKG=none
2010                 else
2011                         AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2012                         NCURSES_CONFIG_PKG=$cf_ncuconfig_root
2013                 fi
2014
2015         else
2016                 AC_MSG_RESULT(no)
2017                 NCURSES_CONFIG_PKG=none
2018         fi
2019 else
2020         NCURSES_CONFIG_PKG=none
2021 fi
2022
2023 if test "x$cf_have_ncuconfig" = "xno"; then
2024         echo "Looking for ${cf_ncuconfig_root}-config"
2025
2026         CF_ACVERSION_CHECK(2.52,
2027                 [AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
2028                 [AC_PATH_PROGS(NCURSES_CONFIG,  ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
2029
2030         if test "$NCURSES_CONFIG" != none ; then
2031
2032                 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
2033                 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
2034
2035                 # even with config script, some packages use no-override for curses.h
2036                 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
2037
2038                 dnl like CF_NCURSES_CPPFLAGS
2039                 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2040
2041                 dnl like CF_NCURSES_LIBS
2042                 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
2043                 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2044
2045                 dnl like CF_NCURSES_VERSION
2046                 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
2047
2048         else
2049
2050                 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
2051                 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
2052
2053         fi
2054 else
2055         NCURSES_CONFIG=none
2056 fi
2057 ])dnl
2058 dnl ---------------------------------------------------------------------------
2059 dnl CF_NCURSES_CPPFLAGS version: 21 updated: 2012/10/06 08:57:51
2060 dnl -------------------
2061 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
2062 dnl the CPPFLAGS variable so we can include its header.
2063 dnl
2064 dnl The header files may be installed as either curses.h, or ncurses.h (would
2065 dnl be obsolete, except that some packagers prefer this name to distinguish it
2066 dnl from a "native" curses implementation).  If not installed for overwrite,
2067 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2068 dnl /usr/include/ncurses), but someone may have installed overwriting the
2069 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
2070 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2071 dnl the header.
2072 dnl
2073 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2074 dnl is already in the include-path, don't even bother with this, since we cannot
2075 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
2076 dnl
2077 dnl The optional parameter gives the root name of the library, in case it is
2078 dnl not installed as the default curses library.  That is how the
2079 dnl wide-character version of ncurses is installed.
2080 AC_DEFUN([CF_NCURSES_CPPFLAGS],
2081 [AC_REQUIRE([CF_WITH_CURSES_DIR])
2082
2083 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2084 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2085
2086 test -n "$cf_cv_curses_dir" && \
2087 test "$cf_cv_curses_dir" != "no" && { \
2088   CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
2089 }
2090
2091 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2092         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2093         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2094         for cf_header in $cf_header_list
2095         do
2096                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2097                 test "$cf_cv_ncurses_h" != no && break
2098         done
2099 ])
2100
2101 CF_NCURSES_HEADER
2102 CF_TERM_HEADER
2103
2104 # some applications need this, but should check for NCURSES_VERSION
2105 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2106
2107 CF_NCURSES_VERSION
2108 ])dnl
2109 dnl ---------------------------------------------------------------------------
2110 dnl CF_NCURSES_EXT_FUNCS version: 4 updated: 2012/10/06 16:39:58
2111 dnl --------------------
2112 dnl Since 2007/11/17, ncurses has defined NCURSES_EXT_FUNCS; earlier versions
2113 dnl may provide these functions.  Define the symbol if it is not defined, and
2114 dnl if it is valid.
2115 AC_DEFUN([CF_NCURSES_EXT_FUNCS],
2116 [
2117 AC_CACHE_CHECK(for ncurses extended functions,cf_cv_ncurses_ext_funcs,[
2118 AC_TRY_COMPILE([
2119 #include <${cf_cv_ncurses_header:-curses.h}>],
2120 [
2121 int x = NCURSES_EXT_FUNCS
2122 ],[cf_cv_ncurses_ext_funcs=defined],[
2123 AC_TRY_LINK([
2124 #include <${cf_cv_ncurses_header:-curses.h}>],
2125 [
2126         (void) assume_default_colors (0, 0);
2127         (void) curses_version ();
2128         (void) define_key (0, 0);
2129         (void) is_term_resized (0, 0);
2130         (void) key_defined (0);
2131         (void) keybound (0, 0);
2132         (void) keyok (0, 0);
2133         (void) resize_term (0, 0);
2134         (void) resizeterm (0, 0);
2135         (void) use_default_colors ();
2136         (void) use_extended_names (0);
2137         (void) wresize (0, 0, 0);],
2138         [cf_cv_ncurses_ext_funcs=yes],
2139         [cf_cv_ncurses_ext_funcs=no])
2140 ])
2141 ])
2142 test "$cf_cv_ncurses_ext_funcs" = yes && AC_DEFINE(NCURSES_EXT_FUNCS,1,[Define to 1 if we have ncurses extensions])
2143 ])dnl
2144 dnl ---------------------------------------------------------------------------
2145 dnl CF_NCURSES_HEADER version: 4 updated: 2015/04/15 19:08:48
2146 dnl -----------------
2147 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2148 dnl variations of ncurses' installs.
2149 dnl
2150 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2151 AC_DEFUN([CF_NCURSES_HEADER],[
2152
2153 if test "$cf_cv_ncurses_h" != no ; then
2154         cf_cv_ncurses_header=$cf_cv_ncurses_h
2155 else
2156
2157 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2158         test -n "$verbose" && echo
2159         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2160         test -n "$verbose" && echo search path $cf_search
2161         cf_save2_CPPFLAGS="$CPPFLAGS"
2162         for cf_incdir in $cf_search
2163         do
2164                 CF_ADD_INCDIR($cf_incdir)
2165                 for cf_header in \
2166                         ncurses.h \
2167                         curses.h
2168                 do
2169                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2170                         if test "$cf_cv_ncurses_h2" != no ; then
2171                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
2172                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
2173                                 break
2174                         fi
2175                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2176                 done
2177                 CPPFLAGS="$cf_save2_CPPFLAGS"
2178                 test "$cf_cv_ncurses_h2" != no && break
2179         done
2180         test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2181         ])
2182
2183         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2184         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2185         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2186                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2187         fi
2188         CF_ADD_INCDIR($cf_1st_incdir)
2189
2190 fi
2191
2192 # Set definitions to allow ifdef'ing for ncurses.h
2193
2194 case $cf_cv_ncurses_header in
2195 (*ncurses.h)
2196         AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
2197         ;;
2198 esac
2199
2200 case $cf_cv_ncurses_header in
2201 (ncurses/curses.h|ncurses/ncurses.h)
2202         AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
2203         ;;
2204 (ncursesw/curses.h|ncursesw/ncurses.h)
2205         AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
2206         ;;
2207 esac
2208
2209 ])dnl
2210 dnl ---------------------------------------------------------------------------
2211 dnl CF_NCURSES_LIBS version: 17 updated: 2015/04/15 19:08:48
2212 dnl ---------------
2213 dnl Look for the ncurses library.  This is a little complicated on Linux,
2214 dnl because it may be linked with the gpm (general purpose mouse) library.
2215 dnl Some distributions have gpm linked with (bsd) curses, which makes it
2216 dnl unusable with ncurses.  However, we don't want to link with gpm unless
2217 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2218 dnl and the linker will record a dependency.
2219 dnl
2220 dnl The optional parameter gives the root name of the library, in case it is
2221 dnl not installed as the default curses library.  That is how the
2222 dnl wide-character version of ncurses is installed.
2223 AC_DEFUN([CF_NCURSES_LIBS],
2224 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2225
2226 cf_nculib_root=ifelse($1,,ncurses,$1)
2227         # This works, except for the special case where we find gpm, but
2228         # ncurses is in a nonstandard location via $LIBS, and we really want
2229         # to link gpm.
2230 cf_ncurses_LIBS=""
2231 cf_ncurses_SAVE="$LIBS"
2232 AC_CHECK_LIB(gpm,Gpm_Open,
2233         [AC_CHECK_LIB(gpm,initscr,
2234                 [LIBS="$cf_ncurses_SAVE"],
2235                 [cf_ncurses_LIBS="-lgpm"])])
2236
2237 case $host_os in
2238 (freebsd*)
2239         # This is only necessary if you are linking against an obsolete
2240         # version of ncurses (but it should do no harm, since it's static).
2241         if test "$cf_nculib_root" = ncurses ; then
2242                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2243         fi
2244         ;;
2245 esac
2246
2247 CF_ADD_LIBS($cf_ncurses_LIBS)
2248
2249 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2250 then
2251         CF_ADD_LIBS(-l$cf_nculib_root)
2252 else
2253         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2254                 [#include <${cf_cv_ncurses_header:-curses.h}>],
2255                 [initscr()],
2256                 initscr)
2257 fi
2258
2259 if test -n "$cf_ncurses_LIBS" ; then
2260         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2261         cf_ncurses_SAVE="$LIBS"
2262         for p in $cf_ncurses_LIBS ; do
2263                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2264                 if test "$q" != "$LIBS" ; then
2265                         LIBS="$q"
2266                 fi
2267         done
2268         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2269                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2270                 [AC_MSG_RESULT(yes)],
2271                 [AC_MSG_RESULT(no)
2272                  LIBS="$cf_ncurses_SAVE"])
2273 fi
2274
2275 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2276 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2277 ])dnl
2278 dnl ---------------------------------------------------------------------------
2279 dnl CF_NCURSES_PTHREADS version: 1 updated: 2016/02/20 19:23:20
2280 dnl -------------------
2281 dnl Use this followup check to ensure that we link with pthreads if ncurses
2282 dnl uses it.
2283 AC_DEFUN([CF_NCURSES_PTHREADS],[
2284 : ${cf_nculib_root:=ifelse($1,,ncurses,$1)}
2285 AC_CACHE_CHECK(if $cf_nculib_root uses pthreads, cf_cv_ncurses_pthreads,[
2286         AC_CHECK_LIB($cf_nculib_root,_nc_init_pthreads,
2287                 cf_cv_ncurses_pthreads=yes,
2288                 cf_cv_ncurses_pthreads=no)
2289 ])
2290 if test "$cf_cv_ncurses_pthreads" = yes
2291 then
2292         CF_ADD_LIBS(-lpthread)
2293 fi
2294 ])dnl
2295 dnl ---------------------------------------------------------------------------
2296 dnl CF_NCURSES_VERSION version: 14 updated: 2012/10/06 08:57:51
2297 dnl ------------------
2298 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2299 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
2300 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2301 AC_DEFUN([CF_NCURSES_VERSION],
2302 [
2303 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2304 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2305         cf_cv_ncurses_version=no
2306         cf_tempfile=out$$
2307         rm -f $cf_tempfile
2308         AC_TRY_RUN([
2309 #include <${cf_cv_ncurses_header:-curses.h}>
2310 #include <stdio.h>
2311 int main()
2312 {
2313         FILE *fp = fopen("$cf_tempfile", "w");
2314 #ifdef NCURSES_VERSION
2315 # ifdef NCURSES_VERSION_PATCH
2316         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2317 # else
2318         fprintf(fp, "%s\n", NCURSES_VERSION);
2319 # endif
2320 #else
2321 # ifdef __NCURSES_H
2322         fprintf(fp, "old\n");
2323 # else
2324         make an error
2325 # endif
2326 #endif
2327         ${cf_cv_main_return:-return}(0);
2328 }],[
2329         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2330
2331         # This will not work if the preprocessor splits the line after the
2332         # Autoconf token.  The 'unproto' program does that.
2333         cat > conftest.$ac_ext <<EOF
2334 #include <${cf_cv_ncurses_header:-curses.h}>
2335 #undef Autoconf
2336 #ifdef NCURSES_VERSION
2337 Autoconf NCURSES_VERSION
2338 #else
2339 #ifdef __NCURSES_H
2340 Autoconf "old"
2341 #endif
2342 ;
2343 #endif
2344 EOF
2345         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2346         AC_TRY_EVAL(cf_try)
2347         if test -f conftest.out ; then
2348                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2349                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2350                 rm -f conftest.out
2351         fi
2352 ])
2353         rm -f $cf_tempfile
2354 ])
2355 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2356 ])dnl
2357 dnl ---------------------------------------------------------------------------
2358 dnl CF_NCURSES_WRAP_PREFIX version: 1 updated: 2009/03/28 16:08:10
2359 dnl ----------------------
2360 dnl Check for ncurses "wrap-prefix" used for public variables which have been
2361 dnl wrapped with a function to help with concurrency control.
2362 AC_DEFUN([CF_NCURSES_WRAP_PREFIX],
2363 [
2364 AC_MSG_CHECKING(for ncurses wrap-prefix)
2365 AC_ARG_WITH(ncurses-wrap-prefix,
2366         [  --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables],
2367         [NCURSES_WRAP_PREFIX=$withval],
2368         [NCURSES_WRAP_PREFIX=_nc_])
2369 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
2370
2371 AC_SUBST(NCURSES_WRAP_PREFIX)
2372 ])
2373 dnl ---------------------------------------------------------------------------
2374 dnl CF_NETBSD_FORM_H version: 2 updated: 2012/10/06 16:39:58
2375 dnl ----------------
2376 dnl Check for NetBSD's form.h, which is incompatible with SVr4 and ncurses.
2377 dnl Some workarounds are needed in client programs to allow them to compile.
2378 AC_DEFUN([CF_NETBSD_FORM_H],[
2379 AC_CACHE_CHECK(for NetBSD form.h,cf_cv_netbsd_form_h,[
2380 AC_TRY_COMPILE([
2381 #include <${cf_cv_ncurses_header:-curses.h}>
2382 #include <form.h>
2383 ],[
2384         FORM *form;
2385         int y = current_field(form)->cursor_ypos;
2386         int x = current_field(form)->cursor_xpos;
2387 ],[cf_cv_netbsd_form_h=yes
2388 ],[cf_cv_netbsd_form_h=no])
2389 ])
2390
2391 test "$cf_cv_netbsd_form_h" = yes && AC_DEFINE(HAVE_NETBSD_FORM_H,1,[Define to 1 if we appear to be using NetBSD form.h])
2392 ])dnl
2393 dnl ---------------------------------------------------------------------------
2394 dnl CF_NETBSD_MENU_H version: 2 updated: 2012/10/06 16:39:58
2395 dnl ----------------
2396 dnl Check for NetBSD's menu.h, which is incompatible with SVr4 and ncurses.
2397 dnl Some workarounds are needed in client programs to allow them to compile.
2398 AC_DEFUN([CF_NETBSD_MENU_H],[
2399 AC_CACHE_CHECK(for NetBSD menu.h,cf_cv_netbsd_menu_h,[
2400 AC_TRY_COMPILE([
2401 #include <${cf_cv_ncurses_header:-curses.h}>
2402 #include <menu.h>
2403 ],[
2404         MENU *menu;
2405         int y = menu->max_item_width;
2406 ],[cf_cv_netbsd_menu_h=yes
2407 ],[cf_cv_netbsd_menu_h=no])
2408 ])
2409
2410 test "$cf_cv_netbsd_menu_h" = yes && AC_DEFINE(HAVE_NETBSD_MENU_H,1,[Define to 1 if we appear to be using NetBSD menu.h])
2411 ])dnl
2412 dnl ---------------------------------------------------------------------------
2413 dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
2414 dnl ------------------
2415 dnl see CF_WITH_NO_LEAKS
2416 AC_DEFUN([CF_NO_LEAKS_OPTION],[
2417 AC_MSG_CHECKING(if you want to use $1 for testing)
2418 AC_ARG_WITH($1,
2419         [$2],
2420         [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
2421          $4
2422 ])
2423         : ${with_cflags:=-g}
2424         : ${with_no_leaks:=yes}
2425          with_$1=yes],
2426         [with_$1=])
2427 AC_MSG_RESULT(${with_$1:-no})
2428
2429 case .$with_cflags in
2430 (.*-g*)
2431         case .$CFLAGS in
2432         (.*-g*)
2433                 ;;
2434         (*)
2435                 CF_ADD_CFLAGS([-g])
2436                 ;;
2437         esac
2438         ;;
2439 esac
2440 ])dnl
2441 dnl ---------------------------------------------------------------------------
2442 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
2443 dnl --------------
2444 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2445 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2446 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2447 dnl delayed evaluation of those symbols.
2448 AC_DEFUN([CF_PATH_SYNTAX],[
2449 if test "x$prefix" != xNONE; then
2450         cf_path_syntax="$prefix"
2451 else
2452         cf_path_syntax="$ac_default_prefix"
2453 fi
2454
2455 case ".[$]$1" in
2456 (.\[$]\(*\)*|.\'*\'*)
2457         ;;
2458 (..|./*|.\\*)
2459         ;;
2460 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
2461         ;;
2462 (.\[$]{*prefix}*|.\[$]{*dir}*)
2463         eval $1="[$]$1"
2464         case ".[$]$1" in
2465         (.NONE/*)
2466                 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2467                 ;;
2468         esac
2469         ;;
2470 (.no|.NONE/*)
2471         $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2472         ;;
2473 (*)
2474         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2475         ;;
2476 esac
2477 ])dnl
2478 dnl ---------------------------------------------------------------------------
2479 dnl CF_PDCURSES_X11 version: 13 updated: 2012/10/06 16:39:58
2480 dnl ---------------
2481 dnl Configure for PDCurses' X11 library
2482 AC_DEFUN([CF_PDCURSES_X11],[
2483 AC_REQUIRE([CF_X_ATHENA])
2484
2485 CF_ACVERSION_CHECK(2.52,
2486         [AC_CHECK_TOOLS(XCURSES_CONFIG, xcurses-config, none)],
2487         [AC_PATH_PROGS(XCURSES_CONFIG, xcurses-config, none)])
2488
2489 if test "$XCURSES_CONFIG" != none ; then
2490
2491 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
2492 CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
2493
2494 cf_cv_lib_XCurses=yes
2495
2496 else
2497
2498 LDFLAGS="$LDFLAGS $X_LIBS"
2499 CF_CHECK_CFLAGS($X_CFLAGS)
2500 AC_CHECK_LIB(X11,XOpenDisplay,
2501         [CF_ADD_LIBS(-lX11)],,
2502         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
2503 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
2504 CF_ADD_LIBS(-lXCurses)
2505 AC_TRY_LINK([
2506 #include <xcurses.h>
2507 char *XCursesProgramName = "test";
2508 ],[XCursesExit();],
2509 [cf_cv_lib_XCurses=yes],
2510 [cf_cv_lib_XCurses=no])
2511 ])
2512
2513 fi
2514
2515 if test $cf_cv_lib_XCurses = yes ; then
2516         AC_DEFINE(UNIX,1,[Define to 1 if using PDCurses on Unix])
2517         AC_DEFINE(XCURSES,1,[Define to 1 if using PDCurses on Unix])
2518         AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES,1,[Define to 1 if using PDCurses on Unix]))
2519 else
2520         AC_MSG_ERROR(Cannot link with XCurses)
2521 fi
2522 ])dnl
2523 dnl ---------------------------------------------------------------------------
2524 dnl CF_PKG_CONFIG version: 10 updated: 2015/04/26 18:06:58
2525 dnl -------------
2526 dnl Check for the package-config program, unless disabled by command-line.
2527 AC_DEFUN([CF_PKG_CONFIG],
2528 [
2529 AC_MSG_CHECKING(if you want to use pkg-config)
2530 AC_ARG_WITH(pkg-config,
2531         [  --with-pkg-config{=path} enable/disable use of pkg-config],
2532         [cf_pkg_config=$withval],
2533         [cf_pkg_config=yes])
2534 AC_MSG_RESULT($cf_pkg_config)
2535
2536 case $cf_pkg_config in
2537 (no)
2538         PKG_CONFIG=none
2539         ;;
2540 (yes)
2541         CF_ACVERSION_CHECK(2.52,
2542                 [AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
2543                 [AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
2544         ;;
2545 (*)
2546         PKG_CONFIG=$withval
2547         ;;
2548 esac
2549
2550 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2551 if test "$PKG_CONFIG" != none ; then
2552         CF_PATH_SYNTAX(PKG_CONFIG)
2553 elif test "x$cf_pkg_config" != xno ; then
2554         AC_MSG_WARN(pkg-config is not installed)
2555 fi
2556
2557 AC_SUBST(PKG_CONFIG)
2558 ])dnl
2559 dnl ---------------------------------------------------------------------------
2560 dnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
2561 dnl -----------------
2562 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2563 dnl
2564 dnl     POSIX.1-1990                            _POSIX_SOURCE
2565 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
2566 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
2567 dnl             Bindings Option
2568 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
2569 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
2570 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
2571 dnl
2572 dnl Parameters:
2573 dnl     $1 is the nominal value for _POSIX_C_SOURCE
2574 AC_DEFUN([CF_POSIX_C_SOURCE],
2575 [
2576 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2577
2578 cf_save_CFLAGS="$CFLAGS"
2579 cf_save_CPPFLAGS="$CPPFLAGS"
2580
2581 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2582 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2583
2584 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2585         CF_MSG_LOG(if the symbol is already defined go no further)
2586         AC_TRY_COMPILE([#include <sys/types.h>],[
2587 #ifndef _POSIX_C_SOURCE
2588 make an error
2589 #endif],
2590         [cf_cv_posix_c_source=no],
2591         [cf_want_posix_source=no
2592          case .$cf_POSIX_C_SOURCE in
2593          (.[[12]]??*)
2594                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2595                 ;;
2596          (.2)
2597                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2598                 cf_want_posix_source=yes
2599                 ;;
2600          (.*)
2601                 cf_want_posix_source=yes
2602                 ;;
2603          esac
2604          if test "$cf_want_posix_source" = yes ; then
2605                 AC_TRY_COMPILE([#include <sys/types.h>],[
2606 #ifdef _POSIX_SOURCE
2607 make an error
2608 #endif],[],
2609                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2610          fi
2611          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2612          CFLAGS="$cf_trim_CFLAGS"
2613          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2614          CF_MSG_LOG(if the second compile does not leave our definition intact error)
2615          AC_TRY_COMPILE([#include <sys/types.h>],[
2616 #ifndef _POSIX_C_SOURCE
2617 make an error
2618 #endif],,
2619          [cf_cv_posix_c_source=no])
2620          CFLAGS="$cf_save_CFLAGS"
2621          CPPFLAGS="$cf_save_CPPFLAGS"
2622         ])
2623 ])
2624
2625 if test "$cf_cv_posix_c_source" != no ; then
2626         CFLAGS="$cf_trim_CFLAGS"
2627         CPPFLAGS="$cf_trim_CPPFLAGS"
2628         CF_ADD_CFLAGS($cf_cv_posix_c_source)
2629 fi
2630
2631 ])dnl
2632 dnl ---------------------------------------------------------------------------
2633 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
2634 dnl ------------
2635 dnl Append definitions and rules for the given programs to the subdirectory
2636 dnl Makefiles, and the recursion rule for the top-level Makefile.
2637 dnl
2638 dnl parameters
2639 dnl     $1 = script to run
2640 dnl     $2 = list of subdirectories
2641 dnl
2642 dnl variables
2643 dnl     $AWK
2644 AC_DEFUN([CF_PRG_RULES],
2645 [
2646 for cf_dir in $2
2647 do
2648         if test ! -d $srcdir/$cf_dir; then
2649                 continue
2650         elif test -f $srcdir/$cf_dir/programs; then
2651                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
2652         fi
2653 done
2654
2655 ])dnl
2656 dnl ---------------------------------------------------------------------------
2657 dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
2658 dnl ----------
2659 dnl standard check for CC, plus followup sanity checks
2660 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
2661 AC_DEFUN([CF_PROG_CC],[
2662 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
2663 CF_GCC_VERSION
2664 CF_ACVERSION_CHECK(2.52,
2665         [AC_PROG_CC_STDC],
2666         [CF_ANSI_CC_REQD])
2667 CF_CC_ENV_FLAGS
2668 ])dnl
2669 dnl ---------------------------------------------------------------------------
2670 dnl CF_PROG_INSTALL version: 7 updated: 2015/04/18 08:56:57
2671 dnl ---------------
2672 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
2673 dnl misc/tabset install won't work properly.  Usually this happens only when
2674 dnl using the fallback mkinstalldirs script
2675 AC_DEFUN([CF_PROG_INSTALL],
2676 [AC_PROG_INSTALL
2677 case $INSTALL in
2678 (/*)
2679         ;;
2680 (*)
2681         CF_DIRNAME(cf_dir,$INSTALL)
2682         test -z "$cf_dir" && cf_dir=.
2683         INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
2684         ;;
2685 esac
2686 ])dnl
2687 dnl ---------------------------------------------------------------------------
2688 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
2689 dnl ------------
2690 AC_DEFUN([CF_PROG_LINT],
2691 [
2692 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
2693 AC_SUBST(LINT_OPTS)
2694 ])dnl
2695 dnl ---------------------------------------------------------------------------
2696 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2697 dnl ----------------
2698 dnl Remove all -U and -D options that refer to the given symbol from a list
2699 dnl of C compiler options.  This works around the problem that not all
2700 dnl compilers process -U and -D options from left-to-right, so a -U option
2701 dnl cannot be used to cancel the effect of a preceding -D option.
2702 dnl
2703 dnl $1 = target (which could be the same as the source variable)
2704 dnl $2 = source (including '$')
2705 dnl $3 = symbol to remove
2706 define([CF_REMOVE_DEFINE],
2707 [
2708 $1=`echo "$2" | \
2709         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
2710                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
2711 ])dnl
2712 dnl ---------------------------------------------------------------------------
2713 dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
2714 dnl -------------
2715 AC_DEFUN([CF_RPATH_HACK],
2716 [
2717 AC_REQUIRE([CF_LD_RPATH_OPT])
2718 AC_MSG_CHECKING(for updated LDFLAGS)
2719 if test -n "$LD_RPATH_OPT" ; then
2720         AC_MSG_RESULT(maybe)
2721
2722         AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
2723         cf_rpath_list="/usr/lib /lib"
2724         if test "$cf_ldd_prog" != no
2725         then
2726                 cf_rpath_oops=
2727
2728 AC_TRY_LINK([#include <stdio.h>],
2729                 [printf("Hello");],
2730                 [cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
2731                  cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[     ]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
2732
2733                 # If we passed the link-test, but get a "not found" on a given library,
2734                 # this could be due to inept reconfiguration of gcc to make it only
2735                 # partly honor /usr/local/lib (or whatever).  Sometimes this behavior
2736                 # is intentional, e.g., installing gcc in /usr/bin and suppressing the
2737                 # /usr/local libraries.
2738                 if test -n "$cf_rpath_oops"
2739                 then
2740                         for cf_rpath_src in $cf_rpath_oops
2741                         do
2742                                 for cf_rpath_dir in \
2743                                         /usr/local \
2744                                         /usr/pkg \
2745                                         /opt/sfw
2746                                 do
2747                                         if test -f $cf_rpath_dir/lib/$cf_rpath_src
2748                                         then
2749                                                 CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2750                                                 LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2751                                                 break
2752                                         fi
2753                                 done
2754                         done
2755                 fi
2756         fi
2757
2758         CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2759
2760         CF_RPATH_HACK_2(LDFLAGS)
2761         CF_RPATH_HACK_2(LIBS)
2762
2763         CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2764 else
2765         AC_MSG_RESULT(no)
2766 fi
2767 AC_SUBST(EXTRA_LDFLAGS)
2768 ])dnl
2769 dnl ---------------------------------------------------------------------------
2770 dnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
2771 dnl ---------------
2772 dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
2773 dnl EXTRA_LDFLAGS for each -L option found.
2774 dnl
2775 dnl $cf_rpath_list contains a list of directories to ignore.
2776 dnl
2777 dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
2778 dnl      but LIBS often has misplaced -L options.
2779 AC_DEFUN([CF_RPATH_HACK_2],
2780 [
2781 CF_VERBOSE(...checking $1 [$]$1)
2782
2783 cf_rpath_dst=
2784 for cf_rpath_src in [$]$1
2785 do
2786         case $cf_rpath_src in
2787         (-L*)
2788
2789                 # check if this refers to a directory which we will ignore
2790                 cf_rpath_skip=no
2791                 if test -n "$cf_rpath_list"
2792                 then
2793                         for cf_rpath_item in $cf_rpath_list
2794                         do
2795                                 if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
2796                                 then
2797                                         cf_rpath_skip=yes
2798                                         break
2799                                 fi
2800                         done
2801                 fi
2802
2803                 if test "$cf_rpath_skip" = no
2804                 then
2805                         # transform the option
2806                         if test "$LD_RPATH_OPT" = "-R " ; then
2807                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
2808                         else
2809                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
2810                         fi
2811
2812                         # if we have not already added this, add it now
2813                         cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
2814                         if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
2815                         then
2816                                 CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
2817                                 EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
2818                         fi
2819                 fi
2820                 ;;
2821         esac
2822         cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
2823 done
2824 $1=$cf_rpath_dst
2825
2826 CF_VERBOSE(...checked $1 [$]$1)
2827 AC_SUBST(EXTRA_LDFLAGS)
2828 ])dnl
2829 dnl ---------------------------------------------------------------------------
2830 dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
2831 dnl -----------
2832 dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
2833 dnl programs need this test).
2834 dnl
2835 dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
2836 dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
2837 dnl winsize declaration is left alone - we may revisit this if Apple choose to
2838 dnl break that part of the interface as well.
2839 AC_DEFUN([CF_SIGWINCH],
2840 [
2841 AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
2842         AC_TRY_COMPILE([
2843 #include <sys/types.h>
2844 #include <sys/signal.h>
2845 ],[int x = SIGWINCH],
2846         [cf_cv_define_sigwinch=yes],
2847         [AC_TRY_COMPILE([
2848 #undef _XOPEN_SOURCE
2849 #undef _POSIX_SOURCE
2850 #undef _POSIX_C_SOURCE
2851 #include <sys/types.h>
2852 #include <sys/signal.h>
2853 ],[int x = SIGWINCH],
2854         [cf_cv_define_sigwinch=maybe],
2855         [cf_cv_define_sigwinch=no])
2856 ])
2857 ])
2858
2859 if test "$cf_cv_define_sigwinch" = maybe ; then
2860 AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
2861 cf_cv_fixup_sigwinch=unknown
2862 cf_sigwinch=32
2863 while test $cf_sigwinch != 1
2864 do
2865         AC_TRY_COMPILE([
2866 #undef _XOPEN_SOURCE
2867 #undef _POSIX_SOURCE
2868 #undef _POSIX_C_SOURCE
2869 #include <sys/types.h>
2870 #include <sys/signal.h>
2871 ],[
2872 #if SIGWINCH != $cf_sigwinch
2873 make an error
2874 #endif
2875 int x = SIGWINCH],
2876         [cf_cv_fixup_sigwinch=$cf_sigwinch
2877          break])
2878
2879 cf_sigwinch=`expr $cf_sigwinch - 1`
2880 done
2881 ])
2882
2883         if test "$cf_cv_fixup_sigwinch" != unknown ; then
2884                 CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
2885         fi
2886 fi
2887 ])dnl
2888 dnl ---------------------------------------------------------------------------
2889 dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2890 dnl ---------------
2891 dnl signal handler, but there are some gcc depedencies in that recommendation.
2892 dnl Try anyway.
2893 AC_DEFUN([CF_SIG_ATOMIC_T],
2894 [
2895 AC_MSG_CHECKING(for signal global datatype)
2896 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2897         for cf_type in \
2898                 "volatile sig_atomic_t" \
2899                 "sig_atomic_t" \
2900                 "int"
2901         do
2902         AC_TRY_COMPILE([
2903 #include <sys/types.h>
2904 #include <signal.h>
2905 #include <stdio.h>
2906
2907 extern $cf_type x;
2908 $cf_type x;
2909 static void handler(int sig)
2910 {
2911         x = 5;
2912 }],
2913                 [signal(SIGINT, handler);
2914                  x = 1],
2915                 [cf_cv_sig_atomic_t=$cf_type],
2916                 [cf_cv_sig_atomic_t=no])
2917                 test "$cf_cv_sig_atomic_t" != no && break
2918         done
2919         ])
2920 AC_MSG_RESULT($cf_cv_sig_atomic_t)
2921 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2922 ])dnl
2923 dnl ---------------------------------------------------------------------------
2924 dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
2925 dnl --------------
2926 dnl Construct a search-list for a nonstandard header/lib-file
2927 dnl     $1 = the variable to return as result
2928 dnl     $2 = the package name
2929 dnl     $3 = the subdirectory, e.g., bin, include or lib
2930 AC_DEFUN([CF_SUBDIR_PATH],
2931 [
2932 $1=
2933
2934 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
2935
2936 for cf_subdir_prefix in \
2937         /usr \
2938         /usr/local \
2939         /usr/pkg \
2940         /opt \
2941         /opt/local \
2942         [$]HOME
2943 do
2944         CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
2945 done
2946 ])dnl
2947 dnl ---------------------------------------------------------------------------
2948 dnl CF_SYS_TIME_SELECT version: 6 updated: 2015/04/18 08:56:57
2949 dnl ------------------
2950 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2951 dnl older SCO configurations.
2952 AC_DEFUN([CF_SYS_TIME_SELECT],
2953 [
2954 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2955 AC_CACHE_VAL(cf_cv_sys_time_select,[
2956 AC_TRY_COMPILE([
2957 #include <sys/types.h>
2958 #ifdef HAVE_SYS_TIME_H
2959 #include <sys/time.h>
2960 #endif
2961 #ifdef HAVE_SYS_SELECT_H
2962 #include <sys/select.h>
2963 #endif
2964 ],[],[cf_cv_sys_time_select=yes],
2965          [cf_cv_sys_time_select=no])
2966          ])
2967 AC_MSG_RESULT($cf_cv_sys_time_select)
2968 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT,1,[Define to 1 if we can include <sys/time.h> with <sys/select.h>])
2969 ])dnl
2970 dnl ---------------------------------------------------------------------------
2971 dnl CF_TERM_HEADER version: 4 updated: 2015/04/15 19:08:48
2972 dnl --------------
2973 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
2974 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
2975 dnl but some packagers change this, breaking various applications.
2976 AC_DEFUN([CF_TERM_HEADER],[
2977 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
2978 case ${cf_cv_ncurses_header} in
2979 (*/ncurses.h|*/ncursesw.h)
2980         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
2981         ;;
2982 (*)
2983         cf_term_header=term.h
2984         ;;
2985 esac
2986
2987 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2988 do
2989 AC_TRY_COMPILE([#include <stdio.h>
2990 #include <${cf_cv_ncurses_header:-curses.h}>
2991 #include <$cf_test>
2992 ],[int x = auto_left_margin],[
2993         cf_cv_term_header="$cf_test"],[
2994         cf_cv_term_header=unknown
2995         ])
2996         test "$cf_cv_term_header" != unknown && break
2997 done
2998 ])
2999
3000 # Set definitions to allow ifdef'ing to accommodate subdirectories
3001
3002 case $cf_cv_term_header in
3003 (*term.h)
3004         AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
3005         ;;
3006 esac
3007
3008 case $cf_cv_term_header in
3009 (ncurses/term.h)
3010         AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
3011         ;;
3012 (ncursesw/term.h)
3013         AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
3014         ;;
3015 esac
3016 ])dnl
3017 dnl ---------------------------------------------------------------------------
3018 dnl CF_TOP_BUILDDIR version: 2 updated: 2013/07/27 17:38:32
3019 dnl ---------------
3020 dnl Define a top_builddir symbol, for applications that need an absolute path.
3021 AC_DEFUN([CF_TOP_BUILDDIR],
3022 [
3023 top_builddir=ifelse($1,,`pwd`,$1)
3024 AC_SUBST(top_builddir)
3025 ])dnl
3026 dnl ---------------------------------------------------------------------------
3027 dnl CF_TPUTS_PROTO version: 3 updated: 2015/04/17 21:26:14
3028 dnl --------------
3029 dnl Check for type of function-pointer passed to tputs.  Some old
3030 dnl implementations used functions that had different prototypes, making it
3031 dnl hard to compile portable programs using tputs.
3032 AC_DEFUN([CF_TPUTS_PROTO],[
3033 CF_CURSES_FUNCS(tputs)
3034 if test x$cf_cv_func_tputs = xyes
3035 then
3036         cf_done=no
3037         for cf_arg in int char
3038         do
3039                 for cf_ret in int void
3040                 do
3041                         if test $cf_ret = void
3042                         then
3043                                 cf_return="/* nothing */"
3044                         else
3045                                 cf_return="return value"
3046                         fi
3047                         AC_TRY_COMPILE([
3048 #include <${cf_cv_ncurses_header:-curses.h}>
3049 #include <$cf_cv_term_header>
3050
3051 static $cf_ret outc($cf_arg value) { $cf_return; }
3052 ],[
3053         tputs("hello", 0, outc);
3054         ${cf_cv_main_return:-return}(0);
3055 ],[
3056                 CF_VERBOSE([prototype $cf_ret func($cf_arg value)])
3057                 cat >>confdefs.h <<EOF
3058 #define TPUTS_ARG               $cf_arg
3059 #define TPUTS_PROTO(func,value) $cf_ret func(TPUTS_ARG value)
3060 #define TPUTS_RETURN(value)     $cf_return
3061 EOF
3062                 cf_done=yes
3063                 break
3064 ])
3065                 done
3066                 test $cf_done = yes && break
3067         done
3068 fi
3069 ])dnl
3070 dnl ---------------------------------------------------------------------------
3071 dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
3072 dnl --------------
3073 dnl Trim extra base X libraries added as a workaround for inconsistent library
3074 dnl dependencies returned by "new" pkg-config files.
3075 AC_DEFUN([CF_TRIM_X_LIBS],[
3076         for cf_trim_lib in Xmu Xt X11
3077         do
3078                 case "$LIBS" in
3079                 (*-l$cf_trim_lib\ *-l$cf_trim_lib*)
3080                         LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
3081                         CF_VERBOSE(..trimmed $LIBS)
3082                         ;;
3083                 esac
3084         done
3085 ])
3086 dnl ---------------------------------------------------------------------------
3087 dnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
3088 dnl -----------------
3089 dnl This is a simple wrapper to use for pkg-config, for libraries which may be
3090 dnl available in that form.
3091 dnl
3092 dnl $1 = package name
3093 dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
3094 dnl $3 = logic to use if pkg-config does not have the package
3095 AC_DEFUN([CF_TRY_PKG_CONFIG],[
3096 AC_REQUIRE([CF_PKG_CONFIG])
3097
3098 if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
3099         CF_VERBOSE(found package $1)
3100         cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
3101         cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
3102         CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
3103         CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
3104         CF_ADD_CFLAGS($cf_pkgconfig_incs)
3105         CF_ADD_LIBS($cf_pkgconfig_libs)
3106         ifelse([$2],,:,[$2])
3107 else
3108         cf_pkgconfig_incs=
3109         cf_pkgconfig_libs=
3110         ifelse([$3],,:,[$3])
3111 fi
3112 ])
3113 dnl ---------------------------------------------------------------------------
3114 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
3115 dnl -------------------
3116 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
3117 dnl can define it successfully.
3118 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
3119 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
3120         AC_TRY_COMPILE([
3121 #include <stdlib.h>
3122 #include <string.h>
3123 #include <sys/types.h>
3124 ],[
3125 #ifndef _XOPEN_SOURCE
3126 make an error
3127 #endif],
3128         [cf_cv_xopen_source=no],
3129         [cf_save="$CPPFLAGS"
3130          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3131          AC_TRY_COMPILE([
3132 #include <stdlib.h>
3133 #include <string.h>
3134 #include <sys/types.h>
3135 ],[
3136 #ifdef _XOPEN_SOURCE
3137 make an error
3138 #endif],
3139         [cf_cv_xopen_source=no],
3140         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3141         CPPFLAGS="$cf_save"
3142         ])
3143 ])
3144
3145 if test "$cf_cv_xopen_source" != no ; then
3146         CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3147         CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3148         cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3149         CF_ADD_CFLAGS($cf_temp_xopen_source)
3150 fi
3151 ])
3152 dnl ---------------------------------------------------------------------------
3153 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3154 dnl --------
3155 dnl Make an uppercase version of a variable
3156 dnl $1=uppercase($2)
3157 AC_DEFUN([CF_UPPER],
3158 [
3159 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3160 ])dnl
3161 dnl ---------------------------------------------------------------------------
3162 dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
3163 dnl -----------
3164 dnl Check for multibyte support, and if not found, utf8 compatibility library
3165 AC_DEFUN([CF_UTF8_LIB],
3166 [
3167 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3168         cf_save_LIBS="$LIBS"
3169         AC_TRY_LINK([
3170 #include <stdlib.h>],[putwc(0,0);],
3171         [cf_cv_utf8_lib=yes],
3172         [CF_FIND_LINKAGE([
3173 #include <libutf8.h>],[putwc(0,0);],utf8,
3174                 [cf_cv_utf8_lib=add-on],
3175                 [cf_cv_utf8_lib=no])
3176 ])])
3177
3178 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3179 # ncurses/ncursesw:
3180 if test "$cf_cv_utf8_lib" = "add-on" ; then
3181         AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
3182         CF_ADD_INCDIR($cf_cv_header_path_utf8)
3183         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
3184         CF_ADD_LIBS($cf_cv_library_file_utf8)
3185 fi
3186 ])dnl
3187 dnl ---------------------------------------------------------------------------
3188 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3189 dnl ----------
3190 dnl Use AC_VERBOSE w/o the warnings
3191 AC_DEFUN([CF_VERBOSE],
3192 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
3193 CF_MSG_LOG([$1])
3194 ])dnl
3195 dnl ---------------------------------------------------------------------------
3196 dnl CF_WCHAR_TYPE version: 4 updated: 2012/10/06 16:39:58
3197 dnl -------------
3198 dnl Check if type wide-character type $1 is declared, and if so, which header
3199 dnl file is needed.  The second parameter is used to set a shell variable when
3200 dnl the type is not found.  The first parameter sets a shell variable for the
3201 dnl opposite sense.
3202 AC_DEFUN([CF_WCHAR_TYPE],
3203 [
3204 # This is needed on Tru64 5.0 to declare $1
3205 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
3206 AC_TRY_COMPILE([
3207 #include <stdlib.h>
3208 #include <stdarg.h>
3209 #include <stdio.h>
3210 #ifdef HAVE_LIBUTF8_H
3211 #include <libutf8.h>
3212 #endif],
3213         [$1 state],
3214         [cf_cv_$1=no],
3215         [AC_TRY_COMPILE([
3216 #include <stdlib.h>
3217 #include <stdarg.h>
3218 #include <stdio.h>
3219 #include <wchar.h>
3220 #ifdef HAVE_LIBUTF8_H
3221 #include <libutf8.h>
3222 #endif],
3223         [$1 value],
3224         [cf_cv_$1=yes],
3225         [cf_cv_$1=unknown])])])
3226
3227 if test "$cf_cv_$1" = yes ; then
3228         AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
3229         NEED_WCHAR_H=1
3230 fi
3231
3232 ifelse([$2],,,[
3233 # if we do not find $1 in either place, use substitution to provide a fallback.
3234 if test "$cf_cv_$1" = unknown ; then
3235         $2=1
3236 fi
3237 ])
3238 ifelse($3,,,[
3239 # if we find $1 in either place, use substitution to provide a fallback.
3240 if test "$cf_cv_$1" != unknown ; then
3241         $3=1
3242 fi
3243 ])
3244 ])dnl
3245 dnl ---------------------------------------------------------------------------
3246 dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
3247 dnl ------------------
3248 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3249 dnl libraries.
3250 AC_DEFUN([CF_WITH_CURSES_DIR],[
3251
3252 AC_MSG_CHECKING(for specific curses-directory)
3253 AC_ARG_WITH(curses-dir,
3254         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
3255         [cf_cv_curses_dir=$withval],
3256         [cf_cv_curses_dir=no])
3257 AC_MSG_RESULT($cf_cv_curses_dir)
3258
3259 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
3260 then
3261         CF_PATH_SYNTAX(withval)
3262         if test -d "$cf_cv_curses_dir"
3263         then
3264                 CF_ADD_INCDIR($cf_cv_curses_dir/include)
3265                 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
3266         fi
3267 fi
3268 ])dnl
3269 dnl ---------------------------------------------------------------------------
3270 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
3271 dnl ----------------
3272 dnl Configure-option for dbmalloc.  The optional parameter is used to override
3273 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3274 AC_DEFUN([CF_WITH_DBMALLOC],[
3275 CF_NO_LEAKS_OPTION(dbmalloc,
3276         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3277         [USE_DBMALLOC])
3278
3279 if test "$with_dbmalloc" = yes ; then
3280         AC_CHECK_HEADER(dbmalloc.h,
3281                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3282 fi
3283 ])dnl
3284 dnl ---------------------------------------------------------------------------
3285 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3286 dnl ---------------
3287 dnl Configure-option for dmalloc.  The optional parameter is used to override
3288 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3289 AC_DEFUN([CF_WITH_DMALLOC],[
3290 CF_NO_LEAKS_OPTION(dmalloc,
3291         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
3292         [USE_DMALLOC])
3293
3294 if test "$with_dmalloc" = yes ; then
3295         AC_CHECK_HEADER(dmalloc.h,
3296                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
3297 fi
3298 ])dnl
3299 dnl ---------------------------------------------------------------------------
3300 dnl CF_WITH_NCURSES_ETC version: 5 updated: 2016/02/20 19:23:20
3301 dnl -------------------
3302 dnl Use this macro for programs which use any variant of "curses", e.g.,
3303 dnl "ncurses", and "PDCurses".  Programs that can use curses and some unrelated
3304 dnl library (such as slang) should use a "--with-screen=XXX" option.
3305 dnl
3306 dnl This does not use AC_DEFUN, because that would tell autoconf to run each
3307 dnl of the macros inside this one - before this macro.
3308 define([CF_WITH_NCURSES_ETC],[
3309 CF_WITH_CURSES_DIR
3310
3311 cf_cv_screen=curses
3312
3313 AC_MSG_CHECKING(for specified curses library type)
3314 AC_ARG_WITH(screen,
3315         [  --with-screen=XXX       use specified curses-libraries],
3316         [cf_cv_screen=$withval],[
3317
3318 AC_ARG_WITH(ncursesw,
3319         [  --with-ncursesw         use wide ncurses-libraries],
3320         [cf_cv_screen=ncursesw],[
3321
3322 AC_ARG_WITH(ncurses,
3323         [  --with-ncurses          use ncurses-libraries],
3324         [cf_cv_screen=ncurses],[
3325
3326 AC_ARG_WITH(pdcurses,
3327         [  --with-pdcurses         compile/link with pdcurses X11 library],
3328         [cf_cv_screen=pdcurses],[
3329
3330 AC_ARG_WITH(curses-colr,
3331         [  --with-curses-colr      compile/link with HPUX 10.x color-curses],
3332         [cf_cv_screen=curses_colr],[
3333
3334 AC_ARG_WITH(curses-5lib,
3335         [  --with-curses-5lib      compile/link with SunOS 5lib curses],
3336         [cf_cv_screen=curses_5lib])])])])])])
3337
3338 AC_MSG_RESULT($cf_cv_screen)
3339
3340 case $cf_cv_screen in
3341 (curses|curses_*)
3342         CF_CURSES_CONFIG
3343         ;;
3344 (ncursesw*)
3345         CF_UTF8_LIB
3346         CF_NCURSES_CONFIG($cf_cv_screen)
3347         ;;
3348 (ncurses*)
3349         CF_NCURSES_CONFIG($cf_cv_screen)
3350         ;;
3351 (pdcurses)
3352         CF_PDCURSES_X11
3353         ;;
3354 (*)
3355         AC_MSG_ERROR(unexpected screen-value: $cf_cv_screen)
3356         ;;
3357 esac
3358
3359 CF_NCURSES_PTHREADS($cf_cv_screen)
3360
3361 ])dnl
3362 dnl ---------------------------------------------------------------------------
3363 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3364 dnl ----------------
3365 AC_DEFUN([CF_WITH_VALGRIND],[
3366 CF_NO_LEAKS_OPTION(valgrind,
3367         [  --with-valgrind         test: use valgrind],
3368         [USE_VALGRIND])
3369 ])dnl
3370 dnl ---------------------------------------------------------------------------
3371 dnl CF_XOPEN_CURSES version: 13 updated: 2015/12/12 20:59:52
3372 dnl ---------------
3373 dnl Test if we should define X/Open source for curses, needed on Digital Unix
3374 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
3375 dnl
3376 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
3377 dnl as getbegy().  The latter is better design, but the former is standard.
3378 AC_DEFUN([CF_XOPEN_CURSES],
3379 [
3380 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3381 AC_CACHE_CHECK(definition to turn on extended curses functions,cf_cv_need_xopen_extension,[
3382 cf_cv_need_xopen_extension=unknown
3383 AC_TRY_LINK([
3384 #include <stdlib.h>
3385 #include <${cf_cv_ncurses_header:-curses.h}>],[
3386 #if defined(NCURSES_VERSION_PATCH)
3387 #if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
3388         make an error
3389 #endif
3390 #endif
3391 #ifdef NCURSES_VERSION
3392         cchar_t check;
3393         int check2 = curs_set((int)sizeof(check));
3394 #endif
3395         long x = winnstr(stdscr, "", 0);
3396         int x1, y1;
3397         getbegyx(stdscr, y1, x1)],
3398         [cf_cv_need_xopen_extension=none],
3399         [
3400         for cf_try_xopen_extension in _XOPEN_SOURCE_EXTENDED NCURSES_WIDECHAR
3401         do
3402                 AC_TRY_LINK([
3403 #define $cf_try_xopen_extension 1
3404 #include <stdlib.h>
3405 #include <${cf_cv_ncurses_header:-curses.h}>],[
3406 #ifdef NCURSES_VERSION
3407                 cchar_t check;
3408                 int check2 = curs_set((int)sizeof(check));
3409 #endif
3410                 long x = winnstr(stdscr, "", 0);
3411                 int x1, y1;
3412                 getbegyx(stdscr, y1, x1)],
3413                 [cf_cv_need_xopen_extension=$cf_try_xopen_extension; break])
3414         done
3415         ])
3416 ])
3417
3418 case $cf_cv_need_xopen_extension in
3419 (*_*)
3420         CPPFLAGS="$CPPFLAGS -D$cf_cv_need_xopen_extension"
3421         ;;
3422 esac
3423
3424 ])dnl
3425 dnl ---------------------------------------------------------------------------
3426 dnl CF_XOPEN_SOURCE version: 50 updated: 2015/10/17 19:03:33
3427 dnl ---------------
3428 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3429 dnl or adapt to the vendor's definitions to get equivalent functionality,
3430 dnl without losing the common non-POSIX features.
3431 dnl
3432 dnl Parameters:
3433 dnl     $1 is the nominal value for _XOPEN_SOURCE
3434 dnl     $2 is the nominal value for _POSIX_C_SOURCE
3435 AC_DEFUN([CF_XOPEN_SOURCE],[
3436 AC_REQUIRE([AC_CANONICAL_HOST])
3437
3438 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3439 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3440 cf_xopen_source=
3441
3442 case $host_os in
3443 (aix[[4-7]]*)
3444         cf_xopen_source="-D_ALL_SOURCE"
3445         ;;
3446 (cygwin|msys)
3447         cf_XOPEN_SOURCE=600
3448         ;;
3449 (darwin[[0-8]].*)
3450         cf_xopen_source="-D_APPLE_C_SOURCE"
3451         ;;
3452 (darwin*)
3453         cf_xopen_source="-D_DARWIN_C_SOURCE"
3454         cf_XOPEN_SOURCE=
3455         ;;
3456 (freebsd*|dragonfly*)
3457         # 5.x headers associate
3458         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3459         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3460         cf_POSIX_C_SOURCE=200112L
3461         cf_XOPEN_SOURCE=600
3462         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3463         ;;
3464 (hpux11*)
3465         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3466         ;;
3467 (hpux*)
3468         cf_xopen_source="-D_HPUX_SOURCE"
3469         ;;
3470 (irix[[56]].*)
3471         cf_xopen_source="-D_SGI_SOURCE"
3472         cf_XOPEN_SOURCE=
3473         ;;
3474 (linux*|gnu*|mint*|k*bsd*-gnu)
3475         CF_GNU_SOURCE
3476         ;;
3477 (minix*)
3478         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
3479         ;;
3480 (mirbsd*)
3481         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
3482         cf_XOPEN_SOURCE=
3483         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3484         ;;
3485 (netbsd*)
3486         cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3487         ;;
3488 (openbsd[[4-9]]*)
3489         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
3490         cf_xopen_source="-D_BSD_SOURCE"
3491         cf_XOPEN_SOURCE=600
3492         ;;
3493 (openbsd*)
3494         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3495         ;;
3496 (os2*)
3497         cf_XOPEN_SOURCE=
3498         ;;
3499 (osf[[45]]*)
3500         cf_xopen_source="-D_OSF_SOURCE"
3501         ;;
3502 (nto-qnx*)
3503         cf_xopen_source="-D_QNX_SOURCE"
3504         ;;
3505 (sco*)
3506         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3507         ;;
3508 (solaris2.*)
3509         cf_xopen_source="-D__EXTENSIONS__"
3510         cf_cv_xopen_source=broken
3511         ;;
3512 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
3513         cf_XOPEN_SOURCE=
3514         cf_POSIX_C_SOURCE=
3515         ;;
3516 (*)
3517         CF_TRY_XOPEN_SOURCE
3518         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3519         ;;
3520 esac
3521
3522 if test -n "$cf_xopen_source" ; then
3523         CF_ADD_CFLAGS($cf_xopen_source,true)
3524 fi
3525
3526 dnl In anything but the default case, we may have system-specific setting
3527 dnl which is still not guaranteed to provide all of the entrypoints that
3528 dnl _XOPEN_SOURCE would yield.
3529 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
3530         AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
3531         AC_TRY_COMPILE([#include <stdlib.h>],[
3532 #ifndef _XOPEN_SOURCE
3533 make an error
3534 #endif],
3535         [cf_XOPEN_SOURCE_set=yes],
3536         [cf_XOPEN_SOURCE_set=no])
3537         AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
3538         if test $cf_XOPEN_SOURCE_set = yes
3539         then
3540                 AC_TRY_COMPILE([#include <stdlib.h>],[
3541 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
3542 make an error
3543 #endif],
3544                 [cf_XOPEN_SOURCE_set_ok=yes],
3545                 [cf_XOPEN_SOURCE_set_ok=no])
3546                 if test $cf_XOPEN_SOURCE_set_ok = no
3547                 then
3548                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
3549                 fi
3550         else
3551                 CF_TRY_XOPEN_SOURCE
3552         fi
3553 fi
3554 ])
3555 dnl ---------------------------------------------------------------------------
3556 dnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
3557 dnl -----------
3558 dnl Check for Xaw (Athena) libraries
3559 dnl
3560 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
3561 AC_DEFUN([CF_X_ATHENA],
3562 [
3563 cf_x_athena=${cf_x_athena:-Xaw}
3564
3565 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
3566 withval=
3567 AC_ARG_WITH(Xaw3d,
3568         [  --with-Xaw3d            link with Xaw 3d library])
3569 if test "$withval" = yes ; then
3570         cf_x_athena=Xaw3d
3571         AC_MSG_RESULT(yes)
3572 else
3573         AC_MSG_RESULT(no)
3574 fi
3575
3576 AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
3577 withval=
3578 AC_ARG_WITH(Xaw3dxft,
3579         [  --with-Xaw3dxft         link with Xaw 3d xft library])
3580 if test "$withval" = yes ; then
3581         cf_x_athena=Xaw3dxft
3582         AC_MSG_RESULT(yes)
3583 else
3584         AC_MSG_RESULT(no)
3585 fi
3586
3587 AC_MSG_CHECKING(if you want to link with neXT Athena library)
3588 withval=
3589 AC_ARG_WITH(neXtaw,
3590         [  --with-neXtaw           link with neXT Athena library])
3591 if test "$withval" = yes ; then
3592         cf_x_athena=neXtaw
3593         AC_MSG_RESULT(yes)
3594 else
3595         AC_MSG_RESULT(no)
3596 fi
3597
3598 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
3599 withval=
3600 AC_ARG_WITH(XawPlus,
3601         [  --with-XawPlus          link with Athena-Plus library])
3602 if test "$withval" = yes ; then
3603         cf_x_athena=XawPlus
3604         AC_MSG_RESULT(yes)
3605 else
3606         AC_MSG_RESULT(no)
3607 fi
3608
3609 cf_x_athena_lib=""
3610
3611 if test "$PKG_CONFIG" != none ; then
3612         cf_athena_list=
3613         test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
3614         for cf_athena_pkg in \
3615                 $cf_athena_list \
3616                 ${cf_x_athena} \
3617                 ${cf_x_athena}-devel \
3618                 lib${cf_x_athena} \
3619                 lib${cf_x_athena}-devel
3620         do
3621                 CF_TRY_PKG_CONFIG($cf_athena_pkg,[
3622                         cf_x_athena_lib="$cf_pkgconfig_libs"
3623                         CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3624                         AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3625
3626                         CF_TRIM_X_LIBS
3627
3628 AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
3629 AC_TRY_LINK([
3630 #include <X11/Xmu/CharSet.h>
3631 ],[
3632 int check = XmuCompareISOLatin1("big", "small")
3633 ],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
3634
3635                         if test "$cf_cv_xaw_compat" = no
3636                         then
3637                                 # workaround for broken ".pc" files...
3638                                 case "$cf_x_athena_lib" in
3639                                 (*-lXmu*)
3640                                         ;;
3641                                 (*)
3642                                         CF_VERBOSE(work around broken package)
3643                                         cf_save_xmu="$LIBS"
3644                                         cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
3645                                         CF_TRY_PKG_CONFIG(xmu,[
3646                                                         LIBS="$cf_save_xmu"
3647                                                         CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
3648                                                 ],[
3649                                                         CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
3650                                                 ])
3651                                         CF_TRIM_X_LIBS
3652                                         ;;
3653                                 esac
3654                         fi
3655
3656                         break])
3657         done
3658 fi
3659
3660 if test -z "$cf_x_athena_lib" ; then
3661         CF_X_EXT
3662         CF_X_TOOLKIT
3663         CF_X_ATHENA_CPPFLAGS($cf_x_athena)
3664         CF_X_ATHENA_LIBS($cf_x_athena)
3665 fi
3666 ])dnl
3667 dnl ---------------------------------------------------------------------------
3668 dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
3669 dnl --------------------
3670 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3671 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3672 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
3673 [
3674 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3675 cf_x_athena_inc=""
3676
3677 for cf_path in default \
3678         /usr/contrib/X11R6 \
3679         /usr/contrib/X11R5 \
3680         /usr/lib/X11R5 \
3681         /usr/local
3682 do
3683         if test -z "$cf_x_athena_inc" ; then
3684                 cf_save="$CPPFLAGS"
3685                 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
3686                 if test $cf_path != default ; then
3687                         CPPFLAGS="$cf_save -I$cf_path/include"
3688                         AC_MSG_CHECKING(for $cf_test in $cf_path)
3689                 else
3690                         AC_MSG_CHECKING(for $cf_test)
3691                 fi
3692                 AC_TRY_COMPILE([
3693 #include <X11/Intrinsic.h>
3694 #include <$cf_test>],[],
3695                         [cf_result=yes],
3696                         [cf_result=no])
3697                 AC_MSG_RESULT($cf_result)
3698                 if test "$cf_result" = yes ; then
3699                         cf_x_athena_inc=$cf_path
3700                         break
3701                 else
3702                         CPPFLAGS="$cf_save"
3703                 fi
3704         fi
3705 done
3706
3707 if test -z "$cf_x_athena_inc" ; then
3708         AC_MSG_WARN(
3709 [Unable to successfully find Athena header files with test program])
3710 elif test "$cf_x_athena_inc" != default ; then
3711         CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
3712 fi
3713 ])
3714 dnl ---------------------------------------------------------------------------
3715 dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
3716 dnl ----------------
3717 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3718 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3719 AC_DEFUN([CF_X_ATHENA_LIBS],
3720 [AC_REQUIRE([CF_X_TOOLKIT])
3721 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3722 cf_x_athena_lib=""
3723
3724 for cf_path in default \
3725         /usr/contrib/X11R6 \
3726         /usr/contrib/X11R5 \
3727         /usr/lib/X11R5 \
3728         /usr/local
3729 do
3730         for cf_lib in \
3731                 ${cf_x_athena_root} \
3732                 ${cf_x_athena_root}7 \
3733                 ${cf_x_athena_root}6
3734         do
3735         for cf_libs in \
3736                 "-l$cf_lib -lXmu" \
3737                 "-l$cf_lib -lXpm -lXmu" \
3738                 "-l${cf_lib}_s -lXmu_s"
3739         do
3740                 if test -z "$cf_x_athena_lib" ; then
3741                         cf_save="$LIBS"
3742                         cf_test=XawSimpleMenuAddGlobalActions
3743                         if test $cf_path != default ; then
3744                                 CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
3745                                 AC_MSG_CHECKING(for $cf_libs in $cf_path)
3746                         else
3747                                 CF_ADD_LIBS($cf_libs)
3748                                 AC_MSG_CHECKING(for $cf_test in $cf_libs)
3749                         fi
3750                         AC_TRY_LINK([
3751 #include <X11/Intrinsic.h>
3752 #include <X11/$cf_x_athena_root/SimpleMenu.h>
3753 ],[
3754 $cf_test((XtAppContext) 0)],
3755                                 [cf_result=yes],
3756                                 [cf_result=no])
3757                         AC_MSG_RESULT($cf_result)
3758                         if test "$cf_result" = yes ; then
3759                                 cf_x_athena_lib="$cf_libs"
3760                                 break
3761                         fi
3762                         LIBS="$cf_save"
3763                 fi
3764         done # cf_libs
3765                 test -n "$cf_x_athena_lib" && break
3766         done # cf_lib
3767 done
3768
3769 if test -z "$cf_x_athena_lib" ; then
3770         AC_MSG_ERROR(
3771 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
3772 fi
3773
3774 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3775 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3776 ])
3777 dnl ---------------------------------------------------------------------------
3778 dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
3779 dnl --------
3780 AC_DEFUN([CF_X_EXT],[
3781 CF_TRY_PKG_CONFIG(Xext,,[
3782         AC_CHECK_LIB(Xext,XextCreateExtension,
3783                 [CF_ADD_LIB(Xext)])])
3784 ])dnl
3785 dnl ---------------------------------------------------------------------------
3786 dnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
3787 dnl ------------
3788 dnl Check for X Toolkit libraries
3789 AC_DEFUN([CF_X_TOOLKIT],
3790 [
3791 AC_REQUIRE([AC_PATH_XTRA])
3792 AC_REQUIRE([CF_CHECK_CACHE])
3793
3794 # OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
3795 # in some cases has installed dummy files in the former, other cases replaced
3796 # it with a link to the new location).  This complicates the configure script.
3797 # Check for that pitfall, and recover using pkg-config
3798 #
3799 # If none of these are set, the configuration is almost certainly broken.
3800 if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
3801 then
3802         CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
3803         CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
3804         CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
3805         CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
3806 fi
3807
3808 cf_have_X_LIBS=no
3809
3810 CF_TRY_PKG_CONFIG(xt,[
3811
3812         case "x$LIBS" in
3813         (*-lX11*)
3814                 ;;
3815         (*)
3816 # we have an "xt" package, but it may omit Xt's dependency on X11
3817 AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
3818 AC_TRY_LINK([
3819 #include <X11/Xlib.h>
3820 ],[
3821         int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
3822         int rc2 = XClearWindow((Display*) 0, (Window) 0);
3823         int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
3824         int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
3825 ],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
3826                 if test "$cf_cv_xt_x11_compat" = no
3827                 then
3828                         CF_VERBOSE(work around broken X11 dependency)
3829                         # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
3830                         CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
3831                 fi
3832                 ;;
3833         esac
3834
3835 AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
3836 AC_TRY_LINK([
3837 #include <X11/Shell.h>
3838 ],[int num = IceConnectionNumber(0)
3839 ],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
3840
3841         if test "$cf_cv_xt_ice_compat" = no
3842         then
3843                 # workaround for broken ".pc" files used for X Toolkit.
3844                 case "x$X_PRE_LIBS" in
3845                 (*-lICE*)
3846                         case "x$LIBS" in
3847                         (*-lICE*)
3848                                 ;;
3849                         (*)
3850                                 CF_VERBOSE(work around broken ICE dependency)
3851                                 CF_TRY_PKG_CONFIG(ice,
3852                                         [CF_TRY_PKG_CONFIG(sm)],
3853                                         [CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
3854                                 ;;
3855                         esac
3856                         ;;
3857                 esac
3858         fi
3859
3860         cf_have_X_LIBS=yes
3861 ],[
3862
3863         LDFLAGS="$X_LIBS $LDFLAGS"
3864         CF_CHECK_CFLAGS($X_CFLAGS)
3865
3866         AC_CHECK_FUNC(XOpenDisplay,,[
3867         AC_CHECK_LIB(X11,XOpenDisplay,
3868                 [CF_ADD_LIB(X11)],,
3869                 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3870
3871         AC_CHECK_FUNC(XtAppInitialize,,[
3872         AC_CHECK_LIB(Xt, XtAppInitialize,
3873                 [AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
3874                  cf_have_X_LIBS=Xt
3875                  LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
3876                 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3877 ])
3878
3879 if test $cf_have_X_LIBS = no ; then
3880         AC_MSG_WARN(
3881 [Unable to successfully link X Toolkit library (-lXt) with
3882 test program.  You will have to check and add the proper libraries by hand
3883 to makefile.])
3884 fi
3885 ])dnl
3886 dnl ---------------------------------------------------------------------------
3887 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
3888 dnl ---------------
3889 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
3890 dnl are both available.
3891 define([CF__CURSES_HEAD],[
3892 #ifdef HAVE_XCURSES
3893 #include <xcurses.h>
3894 char * XCursesProgramName = "test";
3895 #else
3896 #include <${cf_cv_ncurses_header:-curses.h}>
3897 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
3898 #include <ncursesw/term.h>
3899 #elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
3900 #include <ncurses/term.h>
3901 #elif defined(HAVE_TERM_H)
3902 #include <term.h>
3903 #endif
3904 #endif
3905 ])