f5a726009a2432c7b6e2c0cb093c691e84dca502
[ncurses.git] / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
3 dnl                                                                          *
4 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
5 dnl copy of this software and associated documentation files (the            *
6 dnl "Software"), to deal in the Software without restriction, including      *
7 dnl without limitation the rights to use, copy, modify, merge, publish,      *
8 dnl distribute, distribute with modifications, sublicense, and/or sell       *
9 dnl copies of the Software, and to permit persons to whom the Software is    *
10 dnl furnished to do so, subject to the following conditions:                 *
11 dnl                                                                          *
12 dnl The above copyright notice and this permission notice shall be included  *
13 dnl in all copies or substantial portions of the Software.                   *
14 dnl                                                                          *
15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 dnl                                                                          *
23 dnl Except as contained in this notice, the name(s) of the above copyright   *
24 dnl holders shall not be used in advertising or otherwise to promote the     *
25 dnl sale, use or other dealings in this Software without prior written       *
26 dnl authorization.                                                           *
27 dnl***************************************************************************
28 dnl
29 dnl Author: Thomas E. Dickey 1995-on
30 dnl
31 dnl $Id: aclocal.m4,v 1.612 2012/06/08 16:25:28 tom Exp $
32 dnl Macros used in NCURSES auto-configuration script.
33 dnl
34 dnl These macros are maintained separately from NCURSES.  The copyright on
35 dnl this file applies to the aggregation of macros and does not affect use of
36 dnl these macros in other applications.
37 dnl
38 dnl See http://invisible-island.net/autoconf/ for additional information.
39 dnl
40 dnl ---------------------------------------------------------------------------
41 dnl ---------------------------------------------------------------------------
42 dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
43 dnl -------------------
44 dnl Inserted as requested by gettext 0.10.40
45 dnl File from /usr/share/aclocal
46 dnl codeset.m4
47 dnl ====================
48 dnl serial AM1
49 dnl
50 dnl From Bruno Haible.
51 AC_DEFUN([AM_LANGINFO_CODESET],
52 [
53   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
54     [AC_TRY_LINK([#include <langinfo.h>],
55       [char* cs = nl_langinfo(CODESET);],
56       am_cv_langinfo_codeset=yes,
57       am_cv_langinfo_codeset=no)
58     ])
59   if test $am_cv_langinfo_codeset = yes; then
60     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
61       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
62   fi
63 ])dnl
64 dnl ---------------------------------------------------------------------------
65 dnl CF_ACVERSION_CHECK version: 2 updated: 2011/05/08 11:22:03
66 dnl ------------------
67 dnl Conditionally generate script according to whether we're using a given autoconf.
68 dnl
69 dnl $1 = version to compare against
70 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
71 dnl $3 = code to use if AC_ACVERSION is older than $1.
72 define(CF_ACVERSION_CHECK,
73 [
74 ifdef([m4_version_compare],
75 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
76 [CF_ACVERSION_COMPARE(
77 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
78 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
79 dnl ---------------------------------------------------------------------------
80 dnl CF_ACVERSION_COMPARE version: 2 updated: 2011/04/14 20:56:50
81 dnl --------------------
82 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
83 dnl                      MAJOR2, MINOR2, TERNARY2,
84 dnl                      PRINTABLE2, not FOUND, FOUND)
85 define(CF_ACVERSION_COMPARE,
86 [ifelse(builtin([eval], [$2 < $5]), 1,
87 [ifelse([$8], , ,[$8])],
88 [ifelse([$9], , ,[$9])])])dnl
89 dnl ---------------------------------------------------------------------------
90 dnl CF_ADA_INCLUDE_DIRS version: 6 updated: 2010/02/26 19:52:07
91 dnl -------------------
92 dnl Construct the list of include-options for the C programs in the Ada95
93 dnl binding.
94 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
95 [
96 ACPPFLAGS="-I. -I../include -I../../include $ACPPFLAGS"
97 if test "$srcdir" != "."; then
98         ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
99 fi
100 if test "$GCC" != yes; then
101         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
102 elif test "$includedir" != "/usr/include"; then
103         if test "$includedir" = '${prefix}/include' ; then
104                 if test $prefix != /usr ; then
105                         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
106                 fi
107         else
108                 ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
109         fi
110 fi
111 AC_SUBST(ACPPFLAGS)
112 ])dnl
113 dnl ---------------------------------------------------------------------------
114 dnl CF_ADD_ADAFLAGS version: 1 updated: 2010/06/19 15:22:18
115 dnl ---------------
116 dnl Add to $ADAFLAGS, which is substituted into makefile and scripts.
117 AC_DEFUN([CF_ADD_ADAFLAGS],[
118         ADAFLAGS="$ADAFLAGS $1"
119         AC_SUBST(ADAFLAGS)
120 ])dnl
121 dnl ---------------------------------------------------------------------------
122 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
123 dnl -------------
124 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
125 dnl The second parameter if given makes this macro verbose.
126 dnl
127 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
128 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
129 dnl confused by the quotes (which require backslashes to keep them usable).
130 AC_DEFUN([CF_ADD_CFLAGS],
131 [
132 cf_fix_cppflags=no
133 cf_new_cflags=
134 cf_new_cppflags=
135 cf_new_extra_cppflags=
136
137 for cf_add_cflags in $1
138 do
139 case $cf_fix_cppflags in
140 no)
141         case $cf_add_cflags in #(vi
142         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
143                 case $cf_add_cflags in
144                 -D*)
145                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
146
147                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
148                                 && test -z "${cf_tst_cflags}" \
149                                 && cf_fix_cppflags=yes
150
151                         if test $cf_fix_cppflags = yes ; then
152                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
153                                 continue
154                         elif test "${cf_tst_cflags}" = "\"'" ; then
155                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
156                                 continue
157                         fi
158                         ;;
159                 esac
160                 case "$CPPFLAGS" in
161                 *$cf_add_cflags) #(vi
162                         ;;
163                 *) #(vi
164                         case $cf_add_cflags in #(vi
165                         -D*)
166                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
167                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
168                                 ;;
169                         esac
170                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
171                         ;;
172                 esac
173                 ;;
174         *)
175                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
176                 ;;
177         esac
178         ;;
179 yes)
180         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
181
182         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
183
184         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
185                 && test -z "${cf_tst_cflags}" \
186                 && cf_fix_cppflags=no
187         ;;
188 esac
189 done
190
191 if test -n "$cf_new_cflags" ; then
192         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
193         CFLAGS="$CFLAGS $cf_new_cflags"
194 fi
195
196 if test -n "$cf_new_cppflags" ; then
197         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
198         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
199 fi
200
201 if test -n "$cf_new_extra_cppflags" ; then
202         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
203         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
204 fi
205
206 AC_SUBST(EXTRA_CPPFLAGS)
207
208 ])dnl
209 dnl ---------------------------------------------------------------------------
210 dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
211 dnl -------------
212 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
213 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
214 dnl but old versions (and some misinstalled ones) need that.  To make things
215 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
216 dnl the include-path).
217 AC_DEFUN([CF_ADD_INCDIR],
218 [
219 if test -n "$1" ; then
220   for cf_add_incdir in $1
221   do
222         while test $cf_add_incdir != /usr/include
223         do
224           if test -d $cf_add_incdir
225           then
226                 cf_have_incdir=no
227                 if test -n "$CFLAGS$CPPFLAGS" ; then
228                   # a loop is needed to ensure we can add subdirs of existing dirs
229                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
230                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
231                           cf_have_incdir=yes; break
232                         fi
233                   done
234                 fi
235
236                 if test "$cf_have_incdir" = no ; then
237                   if test "$cf_add_incdir" = /usr/local/include ; then
238                         if test "$GCC" = yes
239                         then
240                           cf_save_CPPFLAGS=$CPPFLAGS
241                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
242                           AC_TRY_COMPILE([#include <stdio.h>],
243                                   [printf("Hello")],
244                                   [],
245                                   [cf_have_incdir=yes])
246                           CPPFLAGS=$cf_save_CPPFLAGS
247                         fi
248                   fi
249                 fi
250
251                 if test "$cf_have_incdir" = no ; then
252                   CF_VERBOSE(adding $cf_add_incdir to include-path)
253                   ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
254
255                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
256                   test "$cf_top_incdir" = "$cf_add_incdir" && break
257                   cf_add_incdir="$cf_top_incdir"
258                 else
259                   break
260                 fi
261           fi
262         done
263   done
264 fi
265 ])dnl
266 dnl ---------------------------------------------------------------------------
267 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
268 dnl ----------
269 dnl Add a library, used to enforce consistency.
270 dnl
271 dnl $1 = library to add, without the "-l"
272 dnl $2 = variable to update (default $LIBS)
273 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
274 dnl ---------------------------------------------------------------------------
275 dnl CF_ADD_LIBDIR version: 9 updated: 2010/05/26 16:44:57
276 dnl -------------
277 dnl     Adds to the library-path
278 dnl
279 dnl     Some machines have trouble with multiple -L options.
280 dnl
281 dnl $1 is the (list of) directory(s) to add
282 dnl $2 is the optional name of the variable to update (default LDFLAGS)
283 dnl
284 AC_DEFUN([CF_ADD_LIBDIR],
285 [
286 if test -n "$1" ; then
287   for cf_add_libdir in $1
288   do
289     if test $cf_add_libdir = /usr/lib ; then
290       :
291     elif test -d $cf_add_libdir
292     then
293       cf_have_libdir=no
294       if test -n "$LDFLAGS$LIBS" ; then
295         # a loop is needed to ensure we can add subdirs of existing dirs
296         for cf_test_libdir in $LDFLAGS $LIBS ; do
297           if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
298             cf_have_libdir=yes; break
299           fi
300         done
301       fi
302       if test "$cf_have_libdir" = no ; then
303         CF_VERBOSE(adding $cf_add_libdir to library-path)
304         ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
305       fi
306     fi
307   done
308 fi
309 ])dnl
310 dnl ---------------------------------------------------------------------------
311 dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
312 dnl -----------
313 dnl Add one or more libraries, used to enforce consistency.
314 dnl
315 dnl $1 = libraries to add, with the "-l", etc.
316 dnl $2 = variable to update (default $LIBS)
317 AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
318 dnl ---------------------------------------------------------------------------
319 dnl CF_ADD_SUBDIR_PATH version: 3 updated: 2010/07/03 20:58:12
320 dnl ------------------
321 dnl Append to a search-list for a nonstandard header/lib-file
322 dnl     $1 = the variable to return as result
323 dnl     $2 = the package name
324 dnl     $3 = the subdirectory, e.g., bin, include or lib
325 dnl $4 = the directory under which we will test for subdirectories
326 dnl $5 = a directory that we do not want $4 to match
327 AC_DEFUN([CF_ADD_SUBDIR_PATH],
328 [
329 test "$4" != "$5" && \
330 test -d "$4" && \
331 ifelse([$5],NONE,,[(test $5 = NONE || test "$4" != "$5") &&]) {
332         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
333         test -d $4/$3 &&          $1="[$]$1 $4/$3"
334         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
335         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
336         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
337         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
338 }
339 ])dnl
340 dnl ---------------------------------------------------------------------------
341 dnl CF_ANSI_CC_CHECK version: 11 updated: 2011/07/01 19:47:45
342 dnl ----------------
343 dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
344 dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
345 AC_DEFUN([CF_ANSI_CC_CHECK],
346 [
347 # This should have been defined by AC_PROG_CC
348 : ${CC:=cc}
349
350 # Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
351 # into CC.  This will not help with broken scripts that wrap the compiler with
352 # options, but eliminates a more common category of user confusion.
353 AC_MSG_CHECKING(\$CC variable)
354 case "$CC" in #(vi
355 *[[\ \  ]]-[[IUD]]*)
356         AC_MSG_RESULT(broken)
357         AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
358         # humor him...
359         cf_flags=`echo "$CC" | sed -e 's/^[[^   ]]*[[   ]]//'`
360         CC=`echo "$CC" | sed -e 's/[[   ]].*//'`
361         CF_ADD_CFLAGS($cf_flags)
362         ;;
363 *)
364         AC_MSG_RESULT(ok)
365         ;;
366 esac
367
368 AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
369 cf_cv_ansi_cc=no
370 cf_save_CFLAGS="$CFLAGS"
371 cf_save_CPPFLAGS="$CPPFLAGS"
372 # Don't try gcc -ansi; that turns off useful extensions and
373 # breaks some systems' header files.
374 # AIX                   -qlanglvl=ansi
375 # Ultrix and OSF/1      -std1
376 # HP-UX                 -Aa -D_HPUX_SOURCE
377 # SVR4                  -Xc
378 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
379 for cf_arg in "-DCC_HAS_PROTOS" \
380         "" \
381         -qlanglvl=ansi \
382         -std1 \
383         -Ae \
384         "-Aa -D_HPUX_SOURCE" \
385         -Xc
386 do
387         CF_ADD_CFLAGS($cf_arg)
388         AC_TRY_COMPILE(
389 [
390 #ifndef CC_HAS_PROTOS
391 #if !defined(__STDC__) || (__STDC__ != 1)
392 choke me
393 #endif
394 #endif
395 ],[
396         int test (int i, double x);
397         struct s1 {int (*f) (int a);};
398         struct s2 {int (*f) (double a);};],
399         [cf_cv_ansi_cc="$cf_arg"; break])
400 done
401 CFLAGS="$cf_save_CFLAGS"
402 CPPFLAGS="$cf_save_CPPFLAGS"
403 ])
404
405 if test "$cf_cv_ansi_cc" != "no"; then
406 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
407         CF_ADD_CFLAGS($cf_cv_ansi_cc)
408 else
409         AC_DEFINE(CC_HAS_PROTOS)
410 fi
411 fi
412 ])dnl
413 dnl ---------------------------------------------------------------------------
414 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
415 dnl ---------------
416 dnl For programs that must use an ANSI compiler, obtain compiler options that
417 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
418 dnl macros, since tools such as unproto can fake prototypes, but only part of
419 dnl the preprocessor.
420 AC_DEFUN([CF_ANSI_CC_REQD],
421 [AC_REQUIRE([CF_ANSI_CC_CHECK])
422 if test "$cf_cv_ansi_cc" = "no"; then
423         AC_MSG_ERROR(
424 [Your compiler does not appear to recognize prototypes.
425 You have the following choices:
426         a. adjust your compiler options
427         b. get an up-to-date compiler
428         c. use a wrapper such as unproto])
429 fi
430 ])dnl
431 dnl ---------------------------------------------------------------------------
432 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
433 dnl --------------
434 dnl Allow user to disable a normally-on option.
435 AC_DEFUN([CF_ARG_DISABLE],
436 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
437 dnl ---------------------------------------------------------------------------
438 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
439 dnl -------------
440 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
441 dnl values.
442 dnl
443 dnl Parameters:
444 dnl $1 = option name
445 dnl $2 = help-string
446 dnl $3 = action to perform if option is not default
447 dnl $4 = action if perform if option is default
448 dnl $5 = default option value (either 'yes' or 'no')
449 AC_DEFUN([CF_ARG_OPTION],
450 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
451   if test "$enableval" != "$5" ; then
452 ifelse([$3],,[    :]dnl
453 ,[    $3]) ifelse([$4],,,[
454   else
455     $4])
456   fi],[enableval=$5 ifelse([$4],,,[
457   $4
458 ])dnl
459   ])])dnl
460 dnl ---------------------------------------------------------------------------
461 dnl CF_AR_FLAGS version: 5 updated: 2010/05/20 20:24:29
462 dnl -----------
463 dnl Check for suitable "ar" (archiver) options for updating an archive.
464 AC_DEFUN([CF_AR_FLAGS],[
465 AC_REQUIRE([CF_PROG_AR])
466
467 AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
468         cf_cv_ar_flags=unknown
469         for cf_ar_flags in -curv curv -crv crv -cqv cqv -rv rv
470         do
471
472                 # check if $ARFLAGS already contains this choice
473                 if test "x$ARFLAGS" != "x" ; then
474                         cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
475                         if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
476                                 cf_cv_ar_flags=
477                                 break
478                         fi
479                 fi
480
481                 rm -f conftest.$ac_cv_objext
482                 rm -f conftest.a
483
484                 cat >conftest.$ac_ext <<EOF
485 #line __oline__ "configure"
486 int     testdata[[3]] = { 123, 456, 789 };
487 EOF
488                 if AC_TRY_EVAL(ac_compile) ; then
489                         echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AC_FD_CC
490                         $AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext 2>&AC_FD_CC 1>/dev/null
491                         if test -f conftest.a ; then
492                                 cf_cv_ar_flags=$cf_ar_flags
493                                 break
494                         fi
495                 else
496                         CF_VERBOSE(cannot compile test-program)
497                         break
498                 fi
499         done
500         rm -f conftest.a conftest.$ac_ext conftest.$ac_cv_objext
501 ])
502
503 if test -n "$ARFLAGS" ; then
504         if test -n "$cf_cv_ar_flags" ; then
505                 ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
506         fi
507 else
508         ARFLAGS=$cf_cv_ar_flags
509 fi
510
511 AC_SUBST(ARFLAGS)
512 ])
513 dnl ---------------------------------------------------------------------------
514 dnl CF_AWK_BIG_PRINTF version: 4 updated: 2011/10/30 17:09:50
515 dnl -----------------
516 dnl Check if awk can handle big strings using printf.  Some older versions of
517 dnl awk choke on large strings passed via "%s".
518 dnl
519 dnl $1 = desired string size
520 dnl $2 = variable to set with result
521 AC_DEFUN([CF_AWK_BIG_PRINTF],
522 [
523         case x$AWK in #(vi
524         x)
525                 eval $2=no
526                 ;;
527         *) #(vi
528                 if ( ${AWK} 'BEGIN { xx = "x"; while (length(xx) < $1) { xx = xx "x"; }; printf("%s\n", xx); }' 2>/dev/null \
529                         | $AWK '{ printf "%d\n", length([$]0); }' 2>/dev/null | $AWK 'BEGIN { eqls=0; recs=0; } { recs++; if ([$]0 == 12000) eqls++; } END { if (recs != 1 || eqls != 1) exit 1; }' 2>/dev/null >/dev/null ) ; then
530                         eval $2=yes
531                 else
532                         eval $2=no
533                 fi
534                 ;;
535         esac
536 ])dnl
537 dnl ---------------------------------------------------------------------------
538 dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18
539 dnl ------------
540 dnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
541 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
542 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
543 dnl
544 dnl Treat the configuration-variable specially here, since we're directly
545 dnl substituting its value (i.e., 1/0).
546 dnl
547 dnl $1 is the shell variable to store the result in, if not $cv_cv_builtin_bool
548 AC_DEFUN([CF_BOOL_DECL],
549 [
550 AC_MSG_CHECKING(if we should include stdbool.h)
551
552 AC_CACHE_VAL(cf_cv_header_stdbool_h,[
553         AC_TRY_COMPILE([],[bool foo = false],
554                 [cf_cv_header_stdbool_h=0],
555                 [AC_TRY_COMPILE([
556 #ifndef __BEOS__
557 #include <stdbool.h>
558 #endif
559 ],[bool foo = false],
560                         [cf_cv_header_stdbool_h=1],
561                         [cf_cv_header_stdbool_h=0])])])
562
563 if test "$cf_cv_header_stdbool_h" = 1
564 then    AC_MSG_RESULT(yes)
565 else    AC_MSG_RESULT(no)
566 fi
567
568 AC_MSG_CHECKING([for builtin bool type])
569
570 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
571         AC_TRY_COMPILE([
572 #include <stdio.h>
573 #include <sys/types.h>
574 ],[bool x = false],
575                 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
576                 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
577         ])
578
579 if test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1
580 then    AC_MSG_RESULT(yes)
581 else    AC_MSG_RESULT(no)
582 fi
583 ])dnl
584 dnl ---------------------------------------------------------------------------
585 dnl CF_BOOL_SIZE version: 12 updated: 2006/12/16 12:33:30
586 dnl ------------
587 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
588 dnl Don't bother looking for bool.h, since it's been deprecated.
589 dnl
590 dnl If the current compiler is C rather than C++, we get the bool definition
591 dnl from <stdbool.h>.
592 AC_DEFUN([CF_BOOL_SIZE],
593 [
594 AC_MSG_CHECKING([for size of bool])
595 AC_CACHE_VAL(cf_cv_type_of_bool,[
596         rm -f cf_test.out
597         AC_TRY_RUN([
598 #include <stdlib.h>
599 #include <stdio.h>
600
601 #if defined(__cplusplus)
602
603 #ifdef HAVE_GXX_BUILTIN_H
604 #include <g++/builtin.h>
605 #elif HAVE_GPP_BUILTIN_H
606 #include <gpp/builtin.h>
607 #elif HAVE_BUILTIN_H
608 #include <builtin.h>
609 #endif
610
611 #else
612
613 #if $cf_cv_header_stdbool_h
614 #include <stdbool.h>
615 #endif
616
617 #endif
618
619 main()
620 {
621         FILE *fp = fopen("cf_test.out", "w");
622         if (fp != 0) {
623                 bool x = true;
624                 if ((bool)(-x) >= 0)
625                         fputs("unsigned ", fp);
626                 if (sizeof(x) == sizeof(int))       fputs("int",  fp);
627                 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
628                 else if (sizeof(x) == sizeof(short))fputs("short",fp);
629                 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
630                 fclose(fp);
631         }
632         ${cf_cv_main_return:-return}(0);
633 }
634                 ],
635                 [cf_cv_type_of_bool=`cat cf_test.out`
636                  if test -z "$cf_cv_type_of_bool"; then
637                    cf_cv_type_of_bool=unknown
638                  fi],
639                 [cf_cv_type_of_bool=unknown],
640                 [cf_cv_type_of_bool=unknown])
641         ])
642         rm -f cf_test.out
643 AC_MSG_RESULT($cf_cv_type_of_bool)
644 if test "$cf_cv_type_of_bool" = unknown ; then
645         case .$NCURSES_BOOL in #(vi
646         .auto|.) NCURSES_BOOL=unsigned;;
647         esac
648         AC_MSG_WARN(Assuming $NCURSES_BOOL for type of bool)
649         cf_cv_type_of_bool=$NCURSES_BOOL
650 fi
651 ])dnl
652 dnl ---------------------------------------------------------------------------
653 dnl CF_BUILD_CC version: 6 updated: 2006/10/14 15:23:15
654 dnl -----------
655 dnl If we're cross-compiling, allow the user to override the tools and their
656 dnl options.  The configure script is oriented toward identifying the host
657 dnl compiler, etc., but we need a build compiler to generate parts of the
658 dnl source.
659 dnl
660 dnl $1 = default for $CPPFLAGS
661 dnl $2 = default for $LIBS
662 AC_DEFUN([CF_BUILD_CC],[
663 AC_REQUIRE([CF_PROG_EXT])
664 if test "$cross_compiling" = yes ; then
665
666         # defaults that we might want to override
667         : ${BUILD_CFLAGS:=''}
668         : ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
669         : ${BUILD_LDFLAGS:=''}
670         : ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
671         : ${BUILD_EXEEXT:='$x'}
672         : ${BUILD_OBJEXT:='o'}
673
674         AC_ARG_WITH(build-cc,
675                 [  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
676                 [BUILD_CC="$withval"],
677                 [AC_CHECK_PROGS(BUILD_CC, gcc cc cl)])
678         AC_MSG_CHECKING(for native build C compiler)
679         AC_MSG_RESULT($BUILD_CC)
680
681         AC_MSG_CHECKING(for native build C preprocessor)
682         AC_ARG_WITH(build-cpp,
683                 [  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
684                 [BUILD_CPP="$withval"],
685                 [BUILD_CPP='${BUILD_CC} -E'])
686         AC_MSG_RESULT($BUILD_CPP)
687
688         AC_MSG_CHECKING(for native build C flags)
689         AC_ARG_WITH(build-cflags,
690                 [  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
691                 [BUILD_CFLAGS="$withval"])
692         AC_MSG_RESULT($BUILD_CFLAGS)
693
694         AC_MSG_CHECKING(for native build C preprocessor-flags)
695         AC_ARG_WITH(build-cppflags,
696                 [  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
697                 [BUILD_CPPFLAGS="$withval"])
698         AC_MSG_RESULT($BUILD_CPPFLAGS)
699
700         AC_MSG_CHECKING(for native build linker-flags)
701         AC_ARG_WITH(build-ldflags,
702                 [  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
703                 [BUILD_LDFLAGS="$withval"])
704         AC_MSG_RESULT($BUILD_LDFLAGS)
705
706         AC_MSG_CHECKING(for native build linker-libraries)
707         AC_ARG_WITH(build-libs,
708                 [  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
709                 [BUILD_LIBS="$withval"])
710         AC_MSG_RESULT($BUILD_LIBS)
711
712         # this assumes we're on Unix.
713         BUILD_EXEEXT=
714         BUILD_OBJEXT=o
715
716         : ${BUILD_CC:='${CC}'}
717
718         if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
719                 AC_MSG_ERROR([Cross-build requires two compilers.
720 Use --with-build-cc to specify the native compiler.])
721         fi
722
723 else
724         : ${BUILD_CC:='${CC}'}
725         : ${BUILD_CPP:='${CPP}'}
726         : ${BUILD_CFLAGS:='${CFLAGS}'}
727         : ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
728         : ${BUILD_LDFLAGS:='${LDFLAGS}'}
729         : ${BUILD_LIBS:='${LIBS}'}
730         : ${BUILD_EXEEXT:='$x'}
731         : ${BUILD_OBJEXT:='o'}
732 fi
733
734 AC_SUBST(BUILD_CC)
735 AC_SUBST(BUILD_CPP)
736 AC_SUBST(BUILD_CFLAGS)
737 AC_SUBST(BUILD_CPPFLAGS)
738 AC_SUBST(BUILD_LDFLAGS)
739 AC_SUBST(BUILD_LIBS)
740 AC_SUBST(BUILD_EXEEXT)
741 AC_SUBST(BUILD_OBJEXT)
742 ])dnl
743 dnl ---------------------------------------------------------------------------
744 dnl CF_CFG_DEFAULTS version: 8 updated: 2011/06/04 20:09:13
745 dnl ---------------
746 dnl Determine the default configuration into which we'll install ncurses.  This
747 dnl can be overridden by the user's command-line options.  There's two items to
748 dnl look for:
749 dnl     1. the prefix (e.g., /usr)
750 dnl     2. the header files (e.g., /usr/include/ncurses)
751 dnl We'll look for a previous installation of ncurses and use the same defaults.
752 dnl
753 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
754 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
755 dnl programs from a vendor's.
756 AC_DEFUN([CF_CFG_DEFAULTS],
757 [
758 AC_MSG_CHECKING(for prefix)
759 if test "x$prefix" = "xNONE" ; then
760         case "$cf_cv_system_name" in
761                 # non-vendor systems don't have a conflict
762         openbsd*|freebsd*|mirbsd*|linux*|cygwin*|k*bsd*-gnu)
763                 prefix=/usr
764                 ;;
765         *)      prefix=$ac_default_prefix
766                 ;;
767         esac
768 fi
769 AC_MSG_RESULT($prefix)
770
771 if test "x$prefix" = "xNONE" ; then
772 AC_MSG_CHECKING(for default include-directory)
773 test -n "$verbose" && echo 1>&AC_FD_MSG
774 for cf_symbol in \
775         $includedir \
776         $includedir/ncurses \
777         $prefix/include \
778         $prefix/include/ncurses \
779         /usr/local/include \
780         /usr/local/include/ncurses \
781         /usr/include \
782         /usr/include/ncurses
783 do
784         cf_dir=`eval echo $cf_symbol`
785         if test -f $cf_dir/curses.h ; then
786         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
787                 includedir="$cf_symbol"
788                 test -n "$verbose"  && echo $ac_n "     found " 1>&AC_FD_MSG
789                 break
790         fi
791         fi
792         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
793 done
794 AC_MSG_RESULT($includedir)
795 fi
796 ])dnl
797 dnl ---------------------------------------------------------------------------
798 dnl CF_CGETENT version: 4 updated: 2011/08/07 14:54:41
799 dnl ----------
800 dnl Check if the terminal-capability database functions are available.  If not,
801 dnl ncurses has a much-reduced version.
802 AC_DEFUN([CF_CGETENT],[
803 AC_CACHE_CHECK(for terminal-capability database functions,cf_cv_cgetent,[
804 AC_TRY_LINK([
805 #include <stdlib.h>],[
806         char temp[128];
807         char *buf = temp;
808         char *db_array = temp;
809         cgetent(&buf, &db_array, "vt100");
810         cgetcap(buf, "tc", '=');
811         cgetmatch(buf, "tc");
812         ],
813         [cf_cv_cgetent=yes],
814         [cf_cv_cgetent=no])
815 ])
816
817 if test "$cf_cv_cgetent" = yes
818 then
819         AC_DEFINE(HAVE_BSD_CGETENT)
820 AC_CACHE_CHECK(if cgetent uses const parameter,cf_cv_cgetent_const,[
821 AC_TRY_LINK([
822 #include <stdlib.h>],[
823         char temp[128];
824         char *buf = temp;
825 #ifndef _NETBSD_SOURCE                  /* given, since April 2004 in stdlib.h */
826         const char *db_array = temp;
827         cgetent(&buf, &db_array, "vt100");
828 #endif
829         cgetcap(buf, "tc", '=');
830         cgetmatch(buf, "tc");
831         ],
832         [cf_cv_cgetent_const=yes],
833         [cf_cv_cgetent_const=no])
834 ])
835         if test "$cf_cv_cgetent_const" = yes
836         then
837                 AC_DEFINE_UNQUOTED(CGETENT_CONST,const)
838         fi
839 fi
840 ])dnl
841 dnl ---------------------------------------------------------------------------
842 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
843 dnl --------------
844 dnl Check if we're accidentally using a cache from a different machine.
845 dnl Derive the system name, as a check for reusing the autoconf cache.
846 dnl
847 dnl If we've packaged config.guess and config.sub, run that (since it does a
848 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
849 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
850 dnl which is useful in cross-compiles.
851 dnl
852 dnl Note: we would use $ac_config_sub, but that is one of the places where
853 dnl autoconf 2.5x broke compatibility with autoconf 2.13
854 AC_DEFUN([CF_CHECK_CACHE],
855 [
856 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
857         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
858         system_name="$host_os"
859 else
860         system_name="`(uname -s -r) 2>/dev/null`"
861         if test -z "$system_name" ; then
862                 system_name="`(hostname) 2>/dev/null`"
863         fi
864 fi
865 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
866 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
867
868 test -z "$system_name" && system_name="$cf_cv_system_name"
869 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
870
871 if test ".$system_name" != ".$cf_cv_system_name" ; then
872         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
873         AC_MSG_ERROR("Please remove config.cache and try again.")
874 fi
875 ])dnl
876 dnl ---------------------------------------------------------------------------
877 dnl CF_CHECK_ERRNO version: 11 updated: 2010/05/26 05:38:42
878 dnl --------------
879 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
880 dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
881 dnl ourselves.
882 dnl
883 dnl $1 = the name to check
884 dnl $2 = the assumed type
885 AC_DEFUN([CF_CHECK_ERRNO],
886 [
887 AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
888     AC_TRY_COMPILE([
889 #ifdef HAVE_STDLIB_H
890 #include <stdlib.h>
891 #endif
892 #include <stdio.h>
893 #include <sys/types.h>
894 #include <errno.h> ],
895     ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
896     [cf_cv_dcl_$1=yes],
897     [cf_cv_dcl_$1=no])
898 ])
899
900 if test "$cf_cv_dcl_$1" = no ; then
901     CF_UPPER(cf_result,decl_$1)
902     AC_DEFINE_UNQUOTED($cf_result)
903 fi
904
905 # It's possible (for near-UNIX clones) that the data doesn't exist
906 CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
907 ])dnl
908 dnl ---------------------------------------------------------------------------
909 dnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
910 dnl --------------------
911 dnl Check for existence of external data in the current set of libraries.  If
912 dnl we can modify it, it's real enough.
913 dnl $1 = the name to check
914 dnl $2 = its type
915 AC_DEFUN([CF_CHECK_EXTERN_DATA],
916 [
917 AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
918     AC_TRY_LINK([
919 #undef $1
920 extern $2 $1;
921 ],
922     [$1 = 2],
923     [cf_cv_have_$1=yes],
924     [cf_cv_have_$1=no])
925 ])
926
927 if test "$cf_cv_have_$1" = yes ; then
928     CF_UPPER(cf_result,have_$1)
929     AC_DEFINE_UNQUOTED($cf_result)
930 fi
931
932 ])dnl
933 dnl ---------------------------------------------------------------------------
934 dnl CF_CHECK_GPM_WGETCH version: 2 updated: 2010/08/14 18:25:37
935 dnl -------------------
936 dnl Check if GPM is already linked with curses.  If so - and if the linkage
937 dnl is not "weak" - warn about this because it can create problems linking
938 dnl applications with ncurses.
939 AC_DEFUN([CF_CHECK_GPM_WGETCH],[
940 AC_CHECK_LIB(gpm,Gpm_Wgetch,[
941
942 AC_CACHE_CHECK(if GPM is weakly bound to curses library, cf_cv_check_gpm_wgetch,[
943 cf_cv_check_gpm_wgetch=unknown
944 if test "$cross_compiling" != yes ; then
945
946 cat >conftest.$ac_ext <<CF_EOF
947 #include <gpm.h>
948 int main()
949 {
950         Gpm_Wgetch();
951         ${cf_cv_main_return:-return}(0);
952 }
953 CF_EOF
954
955         cf_save_LIBS="$LIBS"
956         # This only works if we can look at the symbol table.  If a shared
957         # library is stripped for install, we cannot use that.  So we're forced
958         # to rely on the static library, noting that some packagers may not
959         # include it.
960         LIBS="-static -lgpm -dynamic $LIBS"
961         if AC_TRY_EVAL(ac_compile) ; then
962                 if AC_TRY_EVAL(ac_link) ; then
963                         cf_cv_check_gpm_wgetch=`nm conftest$ac_exeext | egrep '\<wgetch\>' | egrep '\<[[vVwW]]\>'`
964                         test -n "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=yes
965                         test -z "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=no
966                 fi
967         fi
968         rm -rf conftest*
969         LIBS="$cf_save_LIBS"
970 fi
971 ])
972
973 if test "$cf_cv_check_gpm_wgetch" != yes ; then
974         AC_MSG_WARN(GPM library is already linked with curses - read the FAQ)
975 fi
976 ])])dnl
977 dnl ---------------------------------------------------------------------------
978 dnl CF_CHECK_WCHAR_H version: 1 updated: 2011/10/29 15:01:05
979 dnl ----------------
980 dnl Check if wchar.h can be used, i.e., without defining _XOPEN_SOURCE_EXTENDED
981 AC_DEFUN([CF_CHECK_WCHAR_H],[
982 AC_CACHE_CHECK(if wchar.h can be used as is,cf_cv_wchar_h_okay,[
983 AC_TRY_COMPILE(
984 [
985 #include <stdlib.h>
986 #include <wchar.h>
987 ],[
988         wint_t foo = 0;
989         int bar = iswpunct(foo)],
990         [cf_cv_wchar_h_okay=yes],
991         [cf_cv_wchar_h_okay=no])])
992
993 if test $cf_cv_wchar_h_okay = no
994 then
995         CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
996 fi
997 ])dnl
998 dnl ---------------------------------------------------------------------------
999 dnl CF_CPP_PARAM_INIT version: 5 updated: 2011/12/03 16:54:03
1000 dnl -----------------
1001 dnl Check if the C++ compiler accepts duplicate parameter initialization.  This
1002 dnl is a late feature for the standard and is not in some recent compilers
1003 dnl (1999/9/11).
1004 AC_DEFUN([CF_CPP_PARAM_INIT],
1005 [
1006 if test -n "$CXX"; then
1007 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
1008         AC_LANG_SAVE
1009         AC_LANG_CPLUSPLUS
1010         AC_TRY_RUN([
1011 class TEST {
1012 private:
1013         int value;
1014 public:
1015         TEST(int x = 1);
1016         ~TEST();
1017 };
1018
1019 TEST::TEST(int x = 1)   // some compilers do not like second initializer
1020 {
1021         value = x;
1022 }
1023 int main() { }
1024 ],
1025         [cf_cv_cpp_param_init=yes],
1026         [cf_cv_cpp_param_init=no],
1027         [cf_cv_cpp_param_init=unknown])
1028         AC_LANG_RESTORE
1029 ])
1030 fi
1031 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT)
1032 ])dnl
1033 dnl ---------------------------------------------------------------------------
1034 dnl CF_CPP_STATIC_CAST version: 1 updated: 2005/07/23 16:52:43
1035 dnl ------------------
1036 dnl Check if the C++ compiler accepts static_cast in generics.  This appears to
1037 dnl not be supported in g++ before 3.0
1038 AC_DEFUN([CF_CPP_STATIC_CAST],
1039 [
1040 if test -n "$CXX"; then
1041
1042 AC_CACHE_CHECK(if $CXX accepts static_cast,cf_cv_cpp_static_cast,[
1043         AC_LANG_SAVE
1044         AC_LANG_CPLUSPLUS
1045
1046         AC_TRY_COMPILE([
1047 class NCursesPanel
1048 {
1049 public:
1050   NCursesPanel(int nlines,
1051                int ncols,
1052                int begin_y = 0,
1053                int begin_x = 0)
1054   {
1055   }
1056
1057   ~NCursesPanel();
1058 };
1059
1060 template<class T> class NCursesUserPanel : public NCursesPanel
1061 {
1062 public:
1063   NCursesUserPanel (int nlines,
1064                     int ncols,
1065                     int begin_y = 0,
1066                     int begin_x = 0,
1067                     const T* p_UserData = static_cast<T*>(0))
1068     : NCursesPanel (nlines, ncols, begin_y, begin_x)
1069   {
1070   };
1071   NCursesUserPanel(const T* p_UserData = static_cast<T*>(0)) : NCursesPanel()
1072   {
1073   };
1074
1075   virtual ~NCursesUserPanel() {};
1076 };
1077 ],[
1078         const char* p_UserData = static_cast<char*>(0)],
1079         [cf_cv_cpp_static_cast=yes],
1080         [cf_cv_cpp_static_cast=no])
1081
1082         AC_LANG_RESTORE
1083 ])
1084
1085 fi
1086
1087 test "$cf_cv_cpp_static_cast" = yes && AC_DEFINE(CPP_HAS_STATIC_CAST)
1088 ])dnl
1089 dnl ---------------------------------------------------------------------------
1090 dnl CF_CXX_AR_FLAGS version: 1 updated: 2011/10/29 08:35:34
1091 dnl ---------------
1092 dnl Setup special archiver flags for given compilers.
1093 AC_DEFUN([CF_CXX_AR_FLAGS],[
1094         CXX_AR='$(AR)'
1095         CXX_ARFLAGS='$(ARFLAGS)'
1096         case $cf_cv_system_name in #(vi
1097         irix*) #(vi
1098             if test "$GXX" != yes ; then
1099                 CXX_AR='$(CXX)'
1100                 CXX_ARFLAGS='-ar -o'
1101             fi
1102             ;;
1103         sco3.2v5*) #(vi
1104             CXXLDFLAGS="-u main"
1105             ;;
1106         solaris2*)
1107             if test "$GXX" != yes ; then
1108                 CXX_AR='$(CXX)'
1109                 CXX_ARFLAGS='-xar -o'
1110             fi
1111             ;;
1112         esac
1113         AC_SUBST(CXXLDFLAGS)
1114         AC_SUBST(CXX_AR)
1115         AC_SUBST(CXX_ARFLAGS)
1116 ])dnl
1117 dnl ---------------------------------------------------------------------------
1118 dnl CF_CXX_IOSTREAM_NAMESPACE version: 1 updated: 2011/10/29 08:35:34
1119 dnl -------------------------
1120 dnl For c++, check if iostream uses "std::" namespace.
1121 AC_DEFUN([CF_CXX_IOSTREAM_NAMESPACE],[
1122 AC_CHECK_HEADERS(iostream)
1123 if test x"$ac_cv_header_iostream" = xyes ; then
1124         AC_MSG_CHECKING(if iostream uses std-namespace)
1125         AC_TRY_COMPILE([
1126 #include <iostream>
1127 using std::endl;
1128 using std::cerr;],[
1129 cerr << "testing" << endl;
1130 ],[cf_iostream_namespace=yes],[cf_iostream_namespace=no])
1131         AC_MSG_RESULT($cf_iostream_namespace)
1132         if test "$cf_iostream_namespace" = yes ; then
1133                 AC_DEFINE(IOSTREAM_NAMESPACE)
1134         fi
1135 fi
1136 ])dnl
1137 dnl ---------------------------------------------------------------------------
1138 dnl CF_C_INLINE version: 3 updated: 2010/05/01 15:14:41
1139 dnl -----------
1140 dnl Check if the C compiler supports "inline".
1141 dnl $1 is the name of a shell variable to set if inline is supported
1142 dnl $2 is the threshold for gcc 4.x's option controlling maximum inline size
1143 AC_DEFUN([CF_C_INLINE],[
1144 AC_C_INLINE
1145 $1=
1146 if test "$ac_cv_c_inline" != no ; then
1147   $1=inline
1148   if test "$INTEL_COMPILER" = yes
1149   then
1150     :
1151   elif test "$GCC" = yes
1152   then
1153     AC_CACHE_CHECK(if $CC supports options to tune inlining,cf_cv_gcc_inline,[
1154       cf_save_CFLAGS=$CFLAGS
1155       CFLAGS="$CFLAGS --param max-inline-insns-single=$2"
1156       AC_TRY_COMPILE([inline int foo(void) { return 1; }],
1157       [${cf_cv_main_return:-return} foo()],
1158       [cf_cv_gcc_inline=yes],
1159       [cf_cv_gcc_inline=no])
1160       CFLAGS=$cf_save_CFLAGS
1161     ])
1162     if test "$cf_cv_gcc_inline" = yes ; then
1163         CF_ADD_CFLAGS([--param max-inline-insns-single=$2])
1164     fi
1165   fi
1166 fi
1167 AC_SUBST($1)
1168 ])dnl
1169 dnl ---------------------------------------------------------------------------
1170 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
1171 dnl ----------
1172 dnl "dirname" is not portable, so we fake it with a shell script.
1173 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
1174 dnl ---------------------------------------------------------------------------
1175 dnl CF_DIRS_TO_MAKE version: 3 updated: 2002/02/23 20:38:31
1176 dnl ---------------
1177 AC_DEFUN([CF_DIRS_TO_MAKE],
1178 [
1179 DIRS_TO_MAKE="lib"
1180 for cf_item in $cf_list_models
1181 do
1182         CF_OBJ_SUBDIR($cf_item,cf_subdir)
1183         for cf_item2 in $DIRS_TO_MAKE
1184         do
1185                 test $cf_item2 = $cf_subdir && break
1186         done
1187         test ".$cf_item2" != ".$cf_subdir" && DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
1188 done
1189 for cf_dir in $DIRS_TO_MAKE
1190 do
1191         test ! -d $cf_dir && mkdir $cf_dir
1192 done
1193 AC_SUBST(DIRS_TO_MAKE)
1194 ])dnl
1195 dnl ---------------------------------------------------------------------------
1196 dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
1197 dnl ---------------
1198 dnl You can always use "make -n" to see the actual options, but it's hard to
1199 dnl pick out/analyze warning messages when the compile-line is long.
1200 dnl
1201 dnl Sets:
1202 dnl     ECHO_LT - symbol to control if libtool is verbose
1203 dnl     ECHO_LD - symbol to prefix "cc -o" lines
1204 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1205 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
1206 dnl     ECHO_CC - symbol to put before any "cc" line
1207 dnl
1208 AC_DEFUN([CF_DISABLE_ECHO],[
1209 AC_MSG_CHECKING(if you want to see long compiling messages)
1210 CF_ARG_DISABLE(echo,
1211         [  --disable-echo          display "compiling" commands],
1212         [
1213     ECHO_LT='--silent'
1214     ECHO_LD='@echo linking [$]@;'
1215     RULE_CC='@echo compiling [$]<'
1216     SHOW_CC='@echo compiling [$]@'
1217     ECHO_CC='@'
1218 ],[
1219     ECHO_LT=''
1220     ECHO_LD=''
1221     RULE_CC=''
1222     SHOW_CC=''
1223     ECHO_CC=''
1224 ])
1225 AC_MSG_RESULT($enableval)
1226 AC_SUBST(ECHO_LT)
1227 AC_SUBST(ECHO_LD)
1228 AC_SUBST(RULE_CC)
1229 AC_SUBST(SHOW_CC)
1230 AC_SUBST(ECHO_CC)
1231 ])dnl
1232 dnl ---------------------------------------------------------------------------
1233 dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
1234 dnl ----------------
1235 dnl Combine no-leak checks with the libraries or tools that are used for the
1236 dnl checks.
1237 AC_DEFUN([CF_DISABLE_LEAKS],[
1238
1239 AC_REQUIRE([CF_WITH_DMALLOC])
1240 AC_REQUIRE([CF_WITH_DBMALLOC])
1241 AC_REQUIRE([CF_WITH_VALGRIND])
1242
1243 AC_MSG_CHECKING(if you want to perform memory-leak testing)
1244 AC_ARG_ENABLE(leaks,
1245         [  --disable-leaks         test: free permanent memory, analyze leaks],
1246         [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
1247         : ${with_no_leaks:=no})
1248 AC_MSG_RESULT($with_no_leaks)
1249
1250 if test "$with_no_leaks" = yes ; then
1251         AC_DEFINE(NO_LEAKS)
1252         AC_DEFINE(YY_NO_LEAKS)
1253 fi
1254 ])dnl
1255 dnl ---------------------------------------------------------------------------
1256 dnl CF_DISABLE_LIBTOOL_VERSION version: 1 updated: 2010/05/15 15:45:59
1257 dnl --------------------------
1258 dnl Check if we should use the libtool 1.5 feature "-version-number" instead of
1259 dnl the older "-version-info" feature.  The newer feature allows us to use
1260 dnl version numbering on shared libraries which make them compatible with
1261 dnl various systems.
1262 AC_DEFUN([CF_DISABLE_LIBTOOL_VERSION],
1263 [
1264 AC_MSG_CHECKING(if libtool -version-number should be used)
1265 CF_ARG_DISABLE(libtool-version,
1266         [  --disable-libtool-version  enable to use libtool's incompatible naming scheme],
1267         [cf_libtool_version=no],
1268         [cf_libtool_version=yes])
1269 AC_MSG_RESULT($cf_libtool_version)
1270
1271 if test "$cf_libtool_version" = yes ; then
1272         LIBTOOL_VERSION="-version-number"
1273 else
1274         LIBTOOL_VERSION="-version-info"
1275 fi
1276
1277 AC_SUBST(LIBTOOL_VERSION)
1278 ])dnl
1279 dnl ---------------------------------------------------------------------------
1280 dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
1281 dnl ---------------------
1282 dnl The rpath-hack makes it simpler to build programs, particularly with the
1283 dnl *BSD ports which may have essential libraries in unusual places.  But it
1284 dnl can interfere with building an executable for the base system.  Use this
1285 dnl option in that case.
1286 AC_DEFUN([CF_DISABLE_RPATH_HACK],
1287 [
1288 AC_MSG_CHECKING(if rpath-hack should be disabled)
1289 CF_ARG_DISABLE(rpath-hack,
1290         [  --disable-rpath-hack    don't add rpath options for additional libraries],
1291         [cf_disable_rpath_hack=yes],
1292         [cf_disable_rpath_hack=no])
1293 AC_MSG_RESULT($cf_disable_rpath_hack)
1294 if test "$cf_disable_rpath_hack" = no ; then
1295         CF_RPATH_HACK
1296 fi
1297 ])
1298 dnl ---------------------------------------------------------------------------
1299 dnl CF_ENABLE_PC_FILES version: 7 updated: 2011/12/10 18:58:47
1300 dnl ------------------
1301 dnl This is the "--enable-pc-files" option, which is available if there is a
1302 dnl pkg-config configuration on the local machine.
1303 AC_DEFUN([CF_ENABLE_PC_FILES],[
1304 AC_REQUIRE([CF_PKG_CONFIG])
1305 AC_REQUIRE([CF_WITH_PKG_CONFIG_LIBDIR])
1306
1307 if test "$PKG_CONFIG" != none ; then
1308         if test -n "$PKG_CONFIG_LIBDIR" && test -d "$PKG_CONFIG_LIBDIR" ; then
1309                 AC_MSG_CHECKING(if we should install .pc files for $PKG_CONFIG)
1310                 AC_ARG_ENABLE(pc-files,
1311                         [  --enable-pc-files       generate and install .pc files for pkg-config],
1312                         [enable_pc_files=$enableval],
1313                         [enable_pc_files=no])
1314                 AC_MSG_RESULT($enable_pc_files)
1315         elif test -z "$PKG_CONFIG_LIBDIR" || test "$PKG_CONFIG_LIBDIR" != no; then
1316                 enable_pc_files=no
1317                 AC_MSG_WARN(did not find $PKG_CONFIG library)
1318         fi
1319 else
1320         enable_pc_files=no
1321 fi
1322 ])dnl
1323 dnl ---------------------------------------------------------------------------
1324 dnl CF_ENABLE_RPATH version: 2 updated: 2010/03/27 18:39:42
1325 dnl ---------------
1326 dnl Check if the rpath option should be used, setting cache variable
1327 dnl cf_cv_enable_rpath if so.
1328 AC_DEFUN([CF_ENABLE_RPATH],
1329 [
1330 AC_MSG_CHECKING(if rpath option should be used)
1331 AC_ARG_ENABLE(rpath,
1332 [  --enable-rpath          use rpath option when generating shared libraries],
1333 [cf_cv_enable_rpath=$enableval],
1334 [cf_cv_enable_rpath=no])
1335 AC_MSG_RESULT($cf_cv_enable_rpath)
1336 ])dnl
1337 dnl ---------------------------------------------------------------------------
1338 dnl CF_ENABLE_STRING_HACKS version: 1 updated: 2012/02/25 06:33:21
1339 dnl ----------------------
1340 dnl On a few platforms, the compiler and/or loader nags with untruthful
1341 dnl comments stating that "most" uses of strcat/strcpy/sprintf are incorrect,
1342 dnl and implying that most uses of the recommended alternatives are correct.
1343 dnl
1344 dnl Factually speaking, no one has actually counted the number of uses of these
1345 dnl functions versus the total of incorrect uses.  Samples of a few thousand
1346 dnl instances are meaningless compared to the hundreds of millions of lines of
1347 dnl existing C code.
1348 dnl
1349 dnl strlcat/strlcpy are (as of 2012) non-standard, and are available on some
1350 dnl platforms, in implementations of varying quality.  Likewise, snprintf is
1351 dnl standard - but evolved through phases, and older implementations are likely
1352 dnl to yield surprising results, as documented in manpages on various systems.
1353 AC_DEFUN([CF_ENABLE_STRING_HACKS],
1354 [
1355 AC_MSG_CHECKING(if you want to work around bogus compiler/loader warnings)
1356 AC_ARG_ENABLE(string-hacks,
1357         [  --enable-string-hacks  work around bogus compiler/loader warnings],
1358         [with_string_hacks=$enableval],
1359         [with_string_hacks=no])
1360 AC_MSG_RESULT($with_string_hacks)
1361
1362 if test "x$with_string_hacks" = "xyes"; then
1363         AC_DEFINE(USE_STRING_HACKS)
1364         AC_MSG_WARN(enabling string-hacks to work around bogus compiler/loader warnings)
1365         AC_CHECK_FUNCS( strlcat strlcpy snprintf )
1366 fi
1367 ])dnl
1368 dnl ---------------------------------------------------------------------------
1369 dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
1370 dnl --------
1371 dnl Check if 'errno' is declared in <errno.h>
1372 AC_DEFUN([CF_ERRNO],
1373 [
1374 CF_CHECK_ERRNO(errno)
1375 ])dnl
1376 dnl ---------------------------------------------------------------------------
1377 dnl CF_ETIP_DEFINES version: 5 updated: 2012/02/18 17:51:07
1378 dnl ---------------
1379 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
1380 dnl math.h and builtin.h, only for ncurses
1381 AC_DEFUN([CF_ETIP_DEFINES],
1382 [
1383 AC_MSG_CHECKING(for special defines needed for etip.h)
1384 cf_save_CXXFLAGS="$CXXFLAGS"
1385 cf_result="none"
1386
1387 # etip.h includes ncurses.h which includes ncurses_dll.h
1388 # But ncurses_dll.h is generated - fix here.
1389 test -d include || mkdir include
1390 test -f include/ncurses_dll.h || sed -e 's/@NCURSES_WRAP_PREFIX@/'$NCURSES_WRAP_PREFIX'/g' ${srcdir}/include/ncurses_dll.h.in >include/ncurses_dll.h
1391
1392 for cf_math in "" MATH_H
1393 do
1394 for cf_excp in "" MATH_EXCEPTION
1395 do
1396         CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -Iinclude -I${srcdir}/include"
1397         test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
1398         test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
1399 AC_TRY_COMPILE([
1400 #include <etip.h.in>
1401 ],[],[
1402         test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
1403         test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
1404         cf_result="$cf_math $cf_excp"
1405         break 2
1406 ],[])
1407 done
1408 done
1409 AC_MSG_RESULT($cf_result)
1410 CXXFLAGS="$cf_save_CXXFLAGS"
1411 ])
1412 dnl ---------------------------------------------------------------------------
1413 dnl CF_FIND_LINKAGE version: 19 updated: 2010/05/29 16:31:02
1414 dnl ---------------
1415 dnl Find a library (specifically the linkage used in the code fragment),
1416 dnl searching for it if it is not already in the library path.
1417 dnl See also CF_ADD_SEARCHPATH.
1418 dnl
1419 dnl Parameters (4-on are optional):
1420 dnl     $1 = headers for library entrypoint
1421 dnl     $2 = code fragment for library entrypoint
1422 dnl     $3 = the library name without the "-l" option or ".so" suffix.
1423 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1424 dnl     $5 = action to perform if not successful
1425 dnl     $6 = module name, if not the same as the library name
1426 dnl     $7 = extra libraries
1427 dnl
1428 dnl Sets these variables:
1429 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1430 dnl     $cf_cv_header_path_$3 - include-directory if needed
1431 dnl     $cf_cv_library_path_$3 - library-directory if needed
1432 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1433 AC_DEFUN([CF_FIND_LINKAGE],[
1434
1435 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1436 # will be set on completion of the AC_TRY_LINK below.
1437 cf_cv_header_path_$3=
1438 cf_cv_library_path_$3=
1439
1440 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1441
1442 cf_save_LIBS="$LIBS"
1443
1444 AC_TRY_LINK([$1],[$2],[
1445         cf_cv_find_linkage_$3=yes
1446         cf_cv_header_path_$3=/usr/include
1447         cf_cv_library_path_$3=/usr/lib
1448 ],[
1449
1450 LIBS="-l$3 $7 $cf_save_LIBS"
1451
1452 AC_TRY_LINK([$1],[$2],[
1453         cf_cv_find_linkage_$3=yes
1454         cf_cv_header_path_$3=/usr/include
1455         cf_cv_library_path_$3=/usr/lib
1456         cf_cv_library_file_$3="-l$3"
1457 ],[
1458         cf_cv_find_linkage_$3=no
1459         LIBS="$cf_save_LIBS"
1460
1461     CF_VERBOSE(find linkage for $3 library)
1462     CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1463
1464     cf_save_CPPFLAGS="$CPPFLAGS"
1465     cf_test_CPPFLAGS="$CPPFLAGS"
1466
1467     CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1468     for cf_cv_header_path_$3 in $cf_search
1469     do
1470       if test -d $cf_cv_header_path_$3 ; then
1471         CF_VERBOSE(... testing $cf_cv_header_path_$3)
1472         CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1473         AC_TRY_COMPILE([$1],[$2],[
1474             CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1475             cf_cv_find_linkage_$3=maybe
1476             cf_test_CPPFLAGS="$CPPFLAGS"
1477             break],[
1478             CPPFLAGS="$cf_save_CPPFLAGS"
1479             ])
1480       fi
1481     done
1482
1483     if test "$cf_cv_find_linkage_$3" = maybe ; then
1484
1485       CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1486
1487       cf_save_LIBS="$LIBS"
1488       cf_save_LDFLAGS="$LDFLAGS"
1489
1490       ifelse([$6],,,[
1491         CPPFLAGS="$cf_test_CPPFLAGS"
1492         LIBS="-l$3 $7 $cf_save_LIBS"
1493         AC_TRY_LINK([$1],[$2],[
1494             CF_VERBOSE(... found $3 library in system)
1495             cf_cv_find_linkage_$3=yes])
1496             CPPFLAGS="$cf_save_CPPFLAGS"
1497             LIBS="$cf_save_LIBS"
1498             ])
1499
1500       if test "$cf_cv_find_linkage_$3" != yes ; then
1501         CF_LIBRARY_PATH(cf_search,$3)
1502         for cf_cv_library_path_$3 in $cf_search
1503         do
1504           if test -d $cf_cv_library_path_$3 ; then
1505             CF_VERBOSE(... testing $cf_cv_library_path_$3)
1506             CPPFLAGS="$cf_test_CPPFLAGS"
1507             LIBS="-l$3 $7 $cf_save_LIBS"
1508             LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1509             AC_TRY_LINK([$1],[$2],[
1510                 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1511                 cf_cv_find_linkage_$3=yes
1512                 cf_cv_library_file_$3="-l$3"
1513                 break],[
1514                 CPPFLAGS="$cf_save_CPPFLAGS"
1515                 LIBS="$cf_save_LIBS"
1516                 LDFLAGS="$cf_save_LDFLAGS"
1517                 ])
1518           fi
1519         done
1520         CPPFLAGS="$cf_save_CPPFLAGS"
1521         LDFLAGS="$cf_save_LDFLAGS"
1522       fi
1523
1524     else
1525       cf_cv_find_linkage_$3=no
1526     fi
1527     ],$7)
1528 ])
1529
1530 LIBS="$cf_save_LIBS"
1531
1532 if test "$cf_cv_find_linkage_$3" = yes ; then
1533 ifelse([$4],,[
1534         CF_ADD_INCDIR($cf_cv_header_path_$3)
1535         CF_ADD_LIBDIR($cf_cv_library_path_$3)
1536         CF_ADD_LIB($3)
1537 ],[$4])
1538 else
1539 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1540 fi
1541 ])dnl
1542 dnl ---------------------------------------------------------------------------
1543 dnl CF_FIXUP_ADAFLAGS version: 1 updated: 2012/03/31 18:48:10
1544 dnl -----------------
1545 dnl make ADAFLAGS consistent with CFLAGS
1546 AC_DEFUN([CF_FIXUP_ADAFLAGS],[
1547         AC_MSG_CHECKING(optimization options for ADAFLAGS)
1548         case "$CFLAGS" in
1549         *-g*)
1550                 CF_ADD_ADAFLAGS(-g)
1551                 ;;
1552         esac
1553         case "$CFLAGS" in
1554         *-O*)
1555                 cf_O_flag=`echo "$CFLAGS" |sed -e 's/^.*-O/-O/' -e 's/[[        ]].*//'`
1556                 CF_ADD_ADAFLAGS($cf_O_flag)
1557                 ;;
1558         esac
1559         AC_MSG_RESULT($ADAFLAGS)
1560 ])dnl
1561 dnl ---------------------------------------------------------------------------
1562 dnl CF_FUNC_DLSYM version: 2 updated: 2010/05/29 16:31:02
1563 dnl -------------
1564 dnl Test for dlsym() and related functions, as well as libdl.
1565 dnl
1566 dnl Sets
1567 dnl     $cf_have_dlsym
1568 dnl     $cf_have_libdl
1569 AC_DEFUN([CF_FUNC_DLSYM],[
1570 cf_have_dlsym=no
1571 AC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
1572
1573 cf_have_libdl=no
1574 AC_CHECK_LIB(dl,dlsym,[
1575         cf_have_dlsym=yes
1576         cf_have_libdl=yes])])
1577
1578 if test "$cf_have_dlsym" = yes ; then
1579         test "$cf_have_libdl" = yes && CF_ADD_LIB(dl)
1580
1581         AC_MSG_CHECKING(whether able to link to dl*() functions)
1582         AC_TRY_LINK([#include <dlfcn.h>],[
1583                 void *obj;
1584                 if ((obj = dlopen("filename", 0)) != 0) {
1585                         if (dlsym(obj, "symbolname") == 0) {
1586                         dlclose(obj);
1587                         }
1588                 }],[
1589                 AC_DEFINE(HAVE_LIBDL)],[
1590                 AC_MSG_ERROR(Cannot link test program for libdl)])
1591         AC_MSG_RESULT(ok)
1592 else
1593         AC_MSG_ERROR(Cannot find dlsym function)
1594 fi
1595 ])
1596 dnl ---------------------------------------------------------------------------
1597 dnl CF_FUNC_MEMMOVE version: 7 updated: 2006/12/16 12:33:30
1598 dnl ---------------
1599 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
1600 dnl is found, add our own version of memmove to the list of objects.
1601 AC_DEFUN([CF_FUNC_MEMMOVE],
1602 [
1603 AC_CHECK_FUNC(memmove,,[
1604 AC_CHECK_FUNC(bcopy,[
1605         AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
1606                 AC_TRY_RUN([
1607 int main() {
1608         static char data[] = "abcdefghijklmnopqrstuwwxyz";
1609         char temp[40];
1610         bcopy(data, temp, sizeof(data));
1611         bcopy(temp+10, temp, 15);
1612         bcopy(temp+5, temp+15, 10);
1613         ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
1614 }
1615                 ],
1616                 [cf_cv_good_bcopy=yes],
1617                 [cf_cv_good_bcopy=no],
1618                 [cf_cv_good_bcopy=unknown])
1619                 ])
1620         ],[cf_cv_good_bcopy=no])
1621         if test "$cf_cv_good_bcopy" = yes ; then
1622                 AC_DEFINE(USE_OK_BCOPY)
1623         else
1624                 AC_DEFINE(USE_MY_MEMMOVE)
1625         fi
1626 ])])dnl
1627 dnl ---------------------------------------------------------------------------
1628 dnl CF_FUNC_NANOSLEEP version: 3 updated: 2006/12/16 12:33:30
1629 dnl -----------------
1630 dnl Check for existence of workable nanosleep() function.  Some systems, e.g.,
1631 dnl AIX 4.x, provide a non-working version.
1632 AC_DEFUN([CF_FUNC_NANOSLEEP],[
1633 AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[
1634 AC_TRY_RUN([
1635 #include <stdio.h>
1636 #include <errno.h>
1637 #include <time.h>
1638
1639 #ifdef HAVE_SYS_TIME_H
1640 #include <sys/time.h>
1641 #endif
1642
1643 int main() {
1644         struct timespec ts1, ts2;
1645         int code;
1646         ts1.tv_sec  = 0;
1647         ts1.tv_nsec = 750000000;
1648         ts2.tv_sec  = 0;
1649         ts2.tv_nsec = 0;
1650         errno = 0;
1651         code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */
1652         ${cf_cv_main_return:-return}(code != 0);
1653 }
1654 ],
1655         [cf_cv_func_nanosleep=yes],
1656         [cf_cv_func_nanosleep=no],
1657         [cf_cv_func_nanosleep=unknown])])
1658
1659 test "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP)
1660 ])
1661 dnl ---------------------------------------------------------------------------
1662 dnl CF_FUNC_OPENPTY version: 3 updated: 2010/05/29 16:31:02
1663 dnl ---------------
1664 dnl Check for openpty() function, along with <pty.h> header.  It may need the
1665 dnl "util" library as well.
1666 AC_DEFUN([CF_FUNC_OPENPTY],
1667 [
1668 AC_CHECK_LIB(util,openpty,cf_cv_lib_util=yes,cf_cv_lib_util=no)
1669 AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
1670     cf_save_LIBS="$LIBS"
1671     test $cf_cv_lib_util = yes && CF_ADD_LIB(util)
1672     for cf_header in pty.h libutil.h util.h
1673     do
1674     AC_TRY_LINK([
1675 #include <$cf_header>
1676 ],[
1677     int x = openpty((int *)0, (int *)0, (char *)0,
1678                    (struct termios *)0, (struct winsize *)0);
1679 ],[
1680         cf_cv_func_openpty=$cf_header
1681         break
1682 ],[
1683         cf_cv_func_openpty=no
1684 ])
1685     done
1686     LIBS="$cf_save_LIBS"
1687 ])
1688 ])dnl
1689 dnl ---------------------------------------------------------------------------
1690 dnl CF_FUNC_POLL version: 6 updated: 2012/06/08 12:22:55
1691 dnl ------------
1692 dnl See if the poll function really works.  Some platforms have poll(), but
1693 dnl it does not work for terminals or files.
1694 AC_DEFUN([CF_FUNC_POLL],[
1695 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
1696 AC_TRY_RUN([
1697 #include <stdlib.h>
1698 #include <stdio.h>
1699 #include <unistd.h>
1700 #include <fcntl.h>
1701 #ifdef HAVE_POLL_H
1702 #include <poll.h>
1703 #else
1704 #include <sys/poll.h>
1705 #endif
1706 int main() {
1707         struct pollfd myfds;
1708         int ret;
1709
1710         /* check for Darwin bug with respect to "devices" */
1711         myfds.fd = open("/dev/null", 1);
1712         if (myfds.fd < 0)
1713                 myfds.fd = 0;
1714         myfds.events = POLLIN;
1715         myfds.revents = 0;
1716
1717         ret = poll(&myfds, 1, 100);
1718
1719         if (ret < 0 || (myfds.revents & POLLNVAL)) {
1720                 ret = -1;
1721         } else {
1722                 int fd = 0;
1723                 if (!isatty(fd)) {
1724                         fd = open("/dev/tty", O_RDWR);
1725                 }
1726
1727                 /* also check with standard input */
1728                 myfds.fd = fd;
1729                 myfds.events = POLLIN;
1730                 myfds.revents = 0;
1731
1732                 ret = poll(&myfds, 1, 100);
1733                 if (ret < 0) {
1734                         ret = 0;
1735                 }
1736         }
1737         ${cf_cv_main_return:-return}(ret < 0);
1738 }],
1739         [cf_cv_working_poll=yes],
1740         [cf_cv_working_poll=no],
1741         [cf_cv_working_poll=unknown])])
1742 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL)
1743 ])dnl
1744 dnl ---------------------------------------------------------------------------
1745 dnl CF_FUNC_TERMIOS version: 2 updated: 2000/07/22 23:37:24
1746 dnl ---------------
1747 dnl Some old/broken variations define tcgetattr() only as a macro in
1748 dnl termio(s).h
1749 AC_DEFUN([CF_FUNC_TERMIOS],[
1750 AC_REQUIRE([CF_STRUCT_TERMIOS])
1751 AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
1752 AC_TRY_LINK([
1753 #include <sys/types.h>
1754 #ifdef HAVE_UNISTD_H
1755 #include <unistd.h>
1756 #endif
1757 #ifdef HAVE_TERMIOS_H
1758 #include <termios.h>
1759 #define TTY struct termios
1760 #else
1761 #ifdef HAVE_TERMIO_H
1762 #include <termio.h>
1763 #define TTY struct termio
1764 #endif
1765 #endif
1766 ],[
1767 TTY foo;
1768 tcgetattr(1, &foo);],
1769 [cf_cv_have_tcgetattr=yes],
1770 [cf_cv_have_tcgetattr=no])])
1771 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR)
1772 ])dnl
1773 dnl ---------------------------------------------------------------------------
1774 dnl CF_FUNC_VSSCANF version: 3 updated: 2001/12/19 00:50:10
1775 dnl ---------------
1776 dnl Check for vsscanf() function, which is in c9x but generally not in earlier
1777 dnl versions of C.  It is in the GNU C library, and can often be simulated by
1778 dnl other functions.
1779 AC_DEFUN([CF_FUNC_VSSCANF],
1780 [
1781 AC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
1782 AC_TRY_LINK([
1783 #include <stdarg.h>
1784 #include <stdio.h>],[
1785         va_list ap;
1786         vsscanf("from", "%d", ap)],[cf_cv_func_vsscanf=vsscanf],[
1787 AC_TRY_LINK([
1788 #include <stdarg.h>
1789 #include <stdio.h>],[
1790     FILE strbuf;
1791     char *str = "from";
1792
1793     strbuf._flag = _IOREAD;
1794     strbuf._ptr = strbuf._base = (unsigned char *) str;
1795     strbuf._cnt = strlen(str);
1796     strbuf._file = _NFILE;
1797     return (vfscanf(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=vfscanf],[
1798 AC_TRY_LINK([
1799 #include <stdarg.h>
1800 #include <stdio.h>],[
1801     FILE strbuf;
1802     char *str = "from";
1803
1804     strbuf._flag = _IOREAD;
1805     strbuf._ptr = strbuf._base = (unsigned char *) str;
1806     strbuf._cnt = strlen(str);
1807     strbuf._file = _NFILE;
1808     return (_doscan(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=_doscan],[
1809 cf_cv_func_vsscanf=no])])])])
1810
1811 case $cf_cv_func_vsscanf in #(vi
1812 vsscanf) AC_DEFINE(HAVE_VSSCANF);; #(vi
1813 vfscanf) AC_DEFINE(HAVE_VFSCANF);; #(vi
1814 _doscan) AC_DEFINE(HAVE__DOSCAN);;
1815 esac
1816
1817 ])dnl
1818 dnl ---------------------------------------------------------------------------
1819 dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
1820 dnl -----------------
1821 dnl Test for availability of useful gcc __attribute__ directives to quiet
1822 dnl compiler warnings.  Though useful, not all are supported -- and contrary
1823 dnl to documentation, unrecognized directives cause older compilers to barf.
1824 AC_DEFUN([CF_GCC_ATTRIBUTES],
1825 [
1826 if test "$GCC" = yes
1827 then
1828 cat > conftest.i <<EOF
1829 #ifndef GCC_PRINTF
1830 #define GCC_PRINTF 0
1831 #endif
1832 #ifndef GCC_SCANF
1833 #define GCC_SCANF 0
1834 #endif
1835 #ifndef GCC_NORETURN
1836 #define GCC_NORETURN /* nothing */
1837 #endif
1838 #ifndef GCC_UNUSED
1839 #define GCC_UNUSED /* nothing */
1840 #endif
1841 EOF
1842 if test "$GCC" = yes
1843 then
1844         AC_CHECKING([for $CC __attribute__ directives])
1845 cat > conftest.$ac_ext <<EOF
1846 #line __oline__ "${as_me:-configure}"
1847 #include "confdefs.h"
1848 #include "conftest.h"
1849 #include "conftest.i"
1850 #if     GCC_PRINTF
1851 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1852 #else
1853 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1854 #endif
1855 #if     GCC_SCANF
1856 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1857 #else
1858 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1859 #endif
1860 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1861 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1862 extern void foo(void) GCC_NORETURN;
1863 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1864 EOF
1865         cf_printf_attribute=no
1866         cf_scanf_attribute=no
1867         for cf_attribute in scanf printf unused noreturn
1868         do
1869                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1870                 cf_directive="__attribute__(($cf_attribute))"
1871                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1872
1873                 case $cf_attribute in #(vi
1874                 printf) #(vi
1875                         cf_printf_attribute=yes
1876                         cat >conftest.h <<EOF
1877 #define GCC_$cf_ATTRIBUTE 1
1878 EOF
1879                         ;;
1880                 scanf) #(vi
1881                         cf_scanf_attribute=yes
1882                         cat >conftest.h <<EOF
1883 #define GCC_$cf_ATTRIBUTE 1
1884 EOF
1885                         ;;
1886                 *) #(vi
1887                         cat >conftest.h <<EOF
1888 #define GCC_$cf_ATTRIBUTE $cf_directive
1889 EOF
1890                         ;;
1891                 esac
1892
1893                 if AC_TRY_EVAL(ac_compile); then
1894                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1895                         cat conftest.h >>confdefs.h
1896                         case $cf_attribute in #(vi
1897                         printf) #(vi
1898                                 if test "$cf_printf_attribute" = no ; then
1899                                         cat >>confdefs.h <<EOF
1900 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
1901 EOF
1902                                 else
1903                                         cat >>confdefs.h <<EOF
1904 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1905 EOF
1906                                 fi
1907                                 ;;
1908                         scanf) #(vi
1909                                 if test "$cf_scanf_attribute" = no ; then
1910                                         cat >>confdefs.h <<EOF
1911 #define GCC_SCANFLIKE(fmt,var) /* nothing */
1912 EOF
1913                                 else
1914                                         cat >>confdefs.h <<EOF
1915 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1916 EOF
1917                                 fi
1918                                 ;;
1919                         esac
1920                 fi
1921         done
1922 else
1923         fgrep define conftest.i >>confdefs.h
1924 fi
1925 rm -rf conftest*
1926 fi
1927 ])dnl
1928 dnl ---------------------------------------------------------------------------
1929 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
1930 dnl --------------
1931 dnl Find version of gcc
1932 AC_DEFUN([CF_GCC_VERSION],[
1933 AC_REQUIRE([AC_PROG_CC])
1934 GCC_VERSION=none
1935 if test "$GCC" = yes ; then
1936         AC_MSG_CHECKING(version of $CC)
1937         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1938         test -z "$GCC_VERSION" && GCC_VERSION=unknown
1939         AC_MSG_RESULT($GCC_VERSION)
1940 fi
1941 ])dnl
1942 dnl ---------------------------------------------------------------------------
1943 dnl CF_GCC_WARNINGS version: 28 updated: 2012/03/31 20:10:46
1944 dnl ---------------
1945 dnl Check if the compiler supports useful warning options.  There's a few that
1946 dnl we don't use, simply because they're too noisy:
1947 dnl
1948 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1949 dnl     -Wredundant-decls (system headers make this too noisy)
1950 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
1951 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
1952 dnl             is enabled for ncurses using "--enable-const".
1953 dnl     -pedantic
1954 dnl
1955 dnl Parameter:
1956 dnl     $1 is an optional list of gcc warning flags that a particular
1957 dnl             application might want to use, e.g., "no-unused" for
1958 dnl             -Wno-unused
1959 dnl Special:
1960 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1961 dnl
1962 AC_DEFUN([CF_GCC_WARNINGS],
1963 [
1964 AC_REQUIRE([CF_GCC_VERSION])
1965 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1966
1967 cat > conftest.$ac_ext <<EOF
1968 #line __oline__ "${as_me:-configure}"
1969 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1970 EOF
1971
1972 if test "$INTEL_COMPILER" = yes
1973 then
1974 # The "-wdXXX" options suppress warnings:
1975 # remark #1419: external declaration in primary source file
1976 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1977 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1978 # remark #193: zero used for undefined preprocessing identifier
1979 # remark #593: variable "curs_sb_left_arrow" was set but never used
1980 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1981 # remark #869: parameter "tw" was never referenced
1982 # remark #981: operands are evaluated in unspecified order
1983 # warning #279: controlling expression is constant
1984
1985         AC_CHECKING([for $CC warning options])
1986         cf_save_CFLAGS="$CFLAGS"
1987         EXTRA_CFLAGS="-Wall"
1988         for cf_opt in \
1989                 wd1419 \
1990                 wd1683 \
1991                 wd1684 \
1992                 wd193 \
1993                 wd593 \
1994                 wd279 \
1995                 wd810 \
1996                 wd869 \
1997                 wd981
1998         do
1999                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2000                 if AC_TRY_EVAL(ac_compile); then
2001                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2002                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2003                 fi
2004         done
2005         CFLAGS="$cf_save_CFLAGS"
2006
2007 elif test "$GCC" = yes
2008 then
2009         AC_CHECKING([for $CC warning options])
2010         cf_save_CFLAGS="$CFLAGS"
2011         EXTRA_CFLAGS=
2012         cf_warn_CONST=""
2013         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
2014         for cf_opt in W Wall \
2015                 Wbad-function-cast \
2016                 Wcast-align \
2017                 Wcast-qual \
2018                 Winline \
2019                 Wmissing-declarations \
2020                 Wmissing-prototypes \
2021                 Wnested-externs \
2022                 Wpointer-arith \
2023                 Wshadow \
2024                 Wstrict-prototypes \
2025                 Wundef $cf_warn_CONST $1
2026         do
2027                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2028                 if AC_TRY_EVAL(ac_compile); then
2029                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2030                         case $cf_opt in #(vi
2031                         Wcast-qual) #(vi
2032                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
2033                                 ;;
2034                         Winline) #(vi
2035                                 case $GCC_VERSION in
2036                                 [[34]].*)
2037                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
2038                                         continue;;
2039                                 esac
2040                                 ;;
2041                         Wpointer-arith) #(vi
2042                                 case $GCC_VERSION in
2043                                 [[12]].*)
2044                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
2045                                         continue;;
2046                                 esac
2047                                 ;;
2048                         esac
2049                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2050                 fi
2051         done
2052         CFLAGS="$cf_save_CFLAGS"
2053 fi
2054 rm -rf conftest*
2055
2056 AC_SUBST(EXTRA_CFLAGS)
2057 ])dnl
2058 dnl ---------------------------------------------------------------------------
2059 dnl CF_GETOPT_HEADER version: 4 updated: 2009/08/31 20:07:52
2060 dnl ----------------
2061 dnl Check for getopt's variables which are commonly defined in stdlib.h,
2062 dnl unistd.h or (nonstandard) in getopt.h
2063 AC_DEFUN([CF_GETOPT_HEADER],
2064 [
2065 AC_HAVE_HEADERS(unistd.h getopt.h)
2066 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
2067 cf_cv_getopt_header=none
2068 for cf_header in stdio.h stdlib.h unistd.h getopt.h
2069 do
2070 AC_TRY_COMPILE([
2071 #include <$cf_header>],
2072 [int x = optind; char *y = optarg],
2073 [cf_cv_getopt_header=$cf_header
2074  break])
2075 done
2076 ])
2077 if test $cf_cv_getopt_header != none ; then
2078         AC_DEFINE(HAVE_GETOPT_HEADER)
2079 fi
2080 ])dnl
2081 dnl ---------------------------------------------------------------------------
2082 dnl CF_GNAT_GENERICS version: 2 updated: 2011/03/23 20:24:41
2083 dnl ----------------
2084 AC_DEFUN([CF_GNAT_GENERICS],
2085 [
2086 AC_REQUIRE([CF_GNAT_VERSION])
2087
2088 AC_MSG_CHECKING(if GNAT supports generics)
2089 case $cf_gnat_version in #(vi
2090 3.[[1-9]]*|[[4-9]].*) #(vi
2091         cf_gnat_generics=yes
2092         ;;
2093 *)
2094         cf_gnat_generics=no
2095         ;;
2096 esac
2097 AC_MSG_RESULT($cf_gnat_generics)
2098
2099 if test "$cf_gnat_generics" = yes
2100 then
2101         cf_compile_generics=generics
2102         cf_generic_objects="\${GENOBJS}"
2103 else
2104         cf_compile_generics=
2105         cf_generic_objects=
2106 fi
2107
2108 AC_SUBST(cf_compile_generics)
2109 AC_SUBST(cf_generic_objects)
2110 ])dnl
2111 dnl ---------------------------------------------------------------------------
2112 dnl CF_GNAT_PRAGMA_UNREF version: 1 updated: 2010/06/19 15:22:18
2113 dnl --------------------
2114 dnl Check if the gnat pragma "Unreferenced" works.
2115 AC_DEFUN([CF_GNAT_PRAGMA_UNREF],[
2116 AC_CACHE_CHECK(if GNAT pragma Unreferenced works,cf_cv_pragma_unreferenced,[
2117 CF_GNAT_TRY_LINK([procedure conftest;],
2118 [with Text_IO;
2119 with GNAT.OS_Lib;
2120 procedure conftest is
2121    test : Integer;
2122    pragma Unreferenced (test);
2123 begin
2124    test := 1;
2125    Text_IO.Put ("Hello World");
2126    Text_IO.New_Line;
2127    GNAT.OS_Lib.OS_Exit (0);
2128 end conftest;],
2129         [cf_cv_pragma_unreferenced=yes],
2130         [cf_cv_pragma_unreferenced=no])])
2131
2132 # if the pragma is supported, use it (needed in the Trace code).
2133 if test $cf_cv_pragma_unreferenced = yes ; then
2134         PRAGMA_UNREF=TRUE
2135 else
2136         PRAGMA_UNREF=FALSE
2137 fi
2138 AC_SUBST(PRAGMA_UNREF)
2139 ])dnl
2140 dnl ---------------------------------------------------------------------------
2141 dnl CF_GNAT_PROJECTS version: 2 updated: 2011/03/23 20:24:41
2142 dnl ----------------
2143 dnl GNAT projects are configured with ".gpr" project files.
2144 dnl GNAT libraries are a further development, using the project feature.
2145 AC_DEFUN([CF_GNAT_PROJECTS],
2146 [
2147 AC_REQUIRE([CF_GNAT_VERSION])
2148
2149 cf_gnat_libraries=no
2150 cf_gnat_projects=no
2151
2152 AC_MSG_CHECKING(if GNAT supports project files)
2153 case $cf_gnat_version in #(vi
2154 3.[[0-9]]*) #(vi
2155         ;;
2156 *)
2157         case $cf_cv_system_name in #(vi
2158         cygwin*) #(vi
2159                 ;;
2160         *)
2161                 mkdir conftest.src conftest.bin conftest.lib
2162                 cd conftest.src
2163                 rm -rf conftest* *~conftest*
2164                 cat >>library.gpr <<CF_EOF
2165 project Library is
2166   Kind := External ("LIB_KIND");
2167   for Library_Name use "ConfTest";
2168   for Object_Dir use ".";
2169   for Library_ALI_Dir use External("LIBRARY_DIR");
2170   for Library_Version use External ("SONAME");
2171   for Library_Kind use Kind;
2172   for Library_Dir use External("BUILD_DIR");
2173   Source_Dir := External ("SOURCE_DIR");
2174   for Source_Dirs use (Source_Dir);
2175   package Compiler is
2176      for Default_Switches ("Ada") use
2177        ("-g",
2178         "-O2",
2179         "-gnatafno",
2180         "-gnatVa",   -- All validity checks
2181         "-gnatwa");  -- Activate all optional errors
2182   end Compiler;
2183 end Library;
2184 CF_EOF
2185                 cat >>confpackage.ads <<CF_EOF
2186 package ConfPackage is
2187    procedure conftest;
2188 end ConfPackage;
2189 CF_EOF
2190                 cat >>confpackage.adb <<CF_EOF
2191 with Text_IO;
2192 package body ConfPackage is
2193    procedure conftest is
2194    begin
2195       Text_IO.Put ("Hello World");
2196       Text_IO.New_Line;
2197    end conftest;
2198 end ConfPackage;
2199 CF_EOF
2200                 if ( $cf_ada_make $ADAFLAGS \
2201                                 -Plibrary.gpr \
2202                                 -XBUILD_DIR=`cd ../conftest.bin;pwd` \
2203                                 -XLIBRARY_DIR=`cd ../conftest.lib;pwd` \
2204                                 -XSOURCE_DIR=`pwd` \
2205                                 -XSONAME=libConfTest.so.1 \
2206                                 -XLIB_KIND=static 1>&AC_FD_CC 2>&1 ) ; then
2207                         cf_gnat_projects=yes
2208                 fi
2209                 cd ..
2210                 if test -f conftest.lib/confpackage.ali
2211                 then
2212                         cf_gnat_libraries=yes
2213                 fi
2214                 rm -rf conftest* *~conftest*
2215                 ;;
2216         esac
2217         ;;
2218 esac
2219 AC_MSG_RESULT($cf_gnat_projects)
2220
2221 if test $cf_gnat_projects = yes
2222 then
2223         AC_MSG_CHECKING(if GNAT supports libraries)
2224         AC_MSG_RESULT($cf_gnat_libraries)
2225 fi
2226
2227 if test "$cf_gnat_projects" = yes
2228 then
2229         USE_OLD_MAKERULES="#"
2230         USE_GNAT_PROJECTS=""
2231 else
2232         USE_OLD_MAKERULES=""
2233         USE_GNAT_PROJECTS="#"
2234 fi
2235
2236 if test "$cf_gnat_libraries" = yes
2237 then
2238         USE_GNAT_LIBRARIES=""
2239 else
2240         USE_GNAT_LIBRARIES="#"
2241 fi
2242
2243 AC_SUBST(USE_OLD_MAKERULES)
2244 AC_SUBST(USE_GNAT_PROJECTS)
2245 AC_SUBST(USE_GNAT_LIBRARIES)
2246 ])dnl
2247 dnl ---------------------------------------------------------------------------
2248 dnl CF_GNAT_SIGINT version: 1 updated: 2011/03/27 20:07:59
2249 dnl --------------
2250 dnl Check if gnat supports SIGINT, and presumably tasking.  For the latter, it
2251 dnl is noted that gnat may compile a tasking unit even for configurations which
2252 dnl fail at runtime.
2253 AC_DEFUN([CF_GNAT_SIGINT],[
2254 AC_CACHE_CHECK(if GNAT supports SIGINT,cf_cv_gnat_sigint,[
2255 CF_GNAT_TRY_LINK([with Ada.Interrupts.Names;
2256
2257 package ConfTest is
2258
2259    pragma Warnings (Off);  --  the next pragma exists since 3.11p
2260    pragma Unreserve_All_Interrupts;
2261    pragma Warnings (On);
2262
2263    protected Process is
2264       procedure Stop;
2265       function Continue return Boolean;
2266       pragma Attach_Handler (Stop, Ada.Interrupts.Names.SIGINT);
2267    private
2268       Done : Boolean := False;
2269    end Process;
2270
2271 end ConfTest;],
2272 [package body ConfTest is
2273    protected body Process is
2274       procedure Stop is
2275       begin
2276          Done := True;
2277       end Stop;
2278       function Continue return Boolean is
2279       begin
2280          return not Done;
2281       end Continue;
2282    end Process;
2283 end ConfTest;],
2284         [cf_cv_gnat_sigint=yes],
2285         [cf_cv_gnat_sigint=no])])
2286
2287 if test $cf_cv_gnat_sigint = yes ; then
2288         USE_GNAT_SIGINT=""
2289 else
2290         USE_GNAT_SIGINT="#"
2291 fi
2292 AC_SUBST(USE_GNAT_SIGINT)
2293 ])dnl
2294 dnl ---------------------------------------------------------------------------
2295 dnl CF_GNAT_TRY_LINK version: 3 updated: 2011/03/19 14:47:45
2296 dnl ----------------
2297 dnl Verify that a test program compiles/links with GNAT.
2298 dnl $cf_ada_make is set to the program that compiles/links
2299 dnl $ADAFLAGS may be set to the GNAT flags.
2300 dnl
2301 dnl $1 is the text of the spec
2302 dnl $2 is the text of the body
2303 dnl $3 is the shell command to execute if successful
2304 dnl $4 is the shell command to execute if not successful
2305 AC_DEFUN([CF_GNAT_TRY_LINK],
2306 [
2307 rm -rf conftest* *~conftest*
2308 cat >>conftest.ads <<CF_EOF
2309 $1
2310 CF_EOF
2311 cat >>conftest.adb <<CF_EOF
2312 $2
2313 CF_EOF
2314 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
2315 ifelse($3,,      :,[      $3])
2316 ifelse($4,,,[else
2317    $4])
2318 fi
2319 rm -rf conftest* *~conftest*
2320 ])dnl
2321 dnl ---------------------------------------------------------------------------
2322 dnl CF_GNAT_TRY_RUN version: 5 updated: 2011/03/19 14:47:45
2323 dnl ---------------
2324 dnl Verify that a test program compiles and runs with GNAT
2325 dnl $cf_ada_make is set to the program that compiles/links
2326 dnl $ADAFLAGS may be set to the GNAT flags.
2327 dnl
2328 dnl $1 is the text of the spec
2329 dnl $2 is the text of the body
2330 dnl $3 is the shell command to execute if successful
2331 dnl $4 is the shell command to execute if not successful
2332 AC_DEFUN([CF_GNAT_TRY_RUN],
2333 [
2334 rm -rf conftest* *~conftest*
2335 cat >>conftest.ads <<CF_EOF
2336 $1
2337 CF_EOF
2338 cat >>conftest.adb <<CF_EOF
2339 $2
2340 CF_EOF
2341 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
2342    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
2343 ifelse($3,,      :,[      $3])
2344 ifelse($4,,,[   else
2345       $4])
2346    fi
2347 ifelse($4,,,[else
2348    $4])
2349 fi
2350 rm -rf conftest* *~conftest*
2351 ])dnl
2352 dnl ---------------------------------------------------------------------------
2353 dnl CF_GNAT_VERSION version: 18 updated: 2012/01/21 19:28:10
2354 dnl ---------------
2355 dnl Verify version of GNAT.
2356 AC_DEFUN([CF_GNAT_VERSION],
2357 [
2358 AC_MSG_CHECKING(for gnat version)
2359 cf_gnat_version=`${cf_ada_make:-gnatmake} -v 2>&1 | \
2360         grep '[[0-9]].[[0-9]][[0-9]]*' |\
2361     sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
2362 AC_MSG_RESULT($cf_gnat_version)
2363
2364 case $cf_gnat_version in #(vi
2365 3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*|20[[0-9]][[0-9]]) #(vi
2366         cf_cv_prog_gnat_correct=yes
2367         ;;
2368 *)
2369         AC_MSG_WARN(Unsupported GNAT version $cf_gnat_version. We require 3.11 or better. Disabling Ada95 binding.)
2370         cf_cv_prog_gnat_correct=no
2371         ;;
2372 esac
2373 ])
2374 dnl ---------------------------------------------------------------------------
2375 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
2376 dnl -------------
2377 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
2378 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
2379 dnl (or misfeature) of glibc2, which breaks portability of many applications,
2380 dnl since it is interwoven with GNU extensions.
2381 dnl
2382 dnl Well, yes we could work around it...
2383 AC_DEFUN([CF_GNU_SOURCE],
2384 [
2385 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
2386 AC_TRY_COMPILE([#include <sys/types.h>],[
2387 #ifndef _XOPEN_SOURCE
2388 make an error
2389 #endif],
2390         [cf_cv_gnu_source=no],
2391         [cf_save="$CPPFLAGS"
2392          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
2393          AC_TRY_COMPILE([#include <sys/types.h>],[
2394 #ifdef _XOPEN_SOURCE
2395 make an error
2396 #endif],
2397         [cf_cv_gnu_source=no],
2398         [cf_cv_gnu_source=yes])
2399         CPPFLAGS="$cf_save"
2400         ])
2401 ])
2402 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
2403 ])dnl
2404 dnl ---------------------------------------------------------------------------
2405 dnl CF_GPP_LIBRARY version: 10 updated: 2010/05/29 16:31:02
2406 dnl --------------
2407 dnl If we're trying to use g++, test if libg++ is installed (a rather common
2408 dnl problem :-).  If we have the compiler but no library, we'll be able to
2409 dnl configure, but won't be able to build the c++ demo program.
2410 AC_DEFUN([CF_GPP_LIBRARY],
2411 [
2412 cf_cxx_library=unknown
2413 case $cf_cv_system_name in #(vi
2414 os2*) #(vi
2415         cf_gpp_libname=gpp
2416         ;;
2417 *)
2418         cf_gpp_libname=g++
2419         ;;
2420 esac
2421 if test "$GXX" = yes; then
2422         AC_MSG_CHECKING([for lib$cf_gpp_libname])
2423         cf_save="$LIBS"
2424         CF_ADD_LIB($cf_gpp_libname)
2425         AC_TRY_LINK([
2426 #include <$cf_gpp_libname/builtin.h>
2427         ],
2428         [two_arg_error_handler_t foo2 = lib_error_handler],
2429         [cf_cxx_library=yes
2430          CF_ADD_LIB($cf_gpp_libname,CXXLIBS)
2431          if test "$cf_gpp_libname" = cpp ; then
2432             AC_DEFINE(HAVE_GPP_BUILTIN_H)
2433          else
2434             AC_DEFINE(HAVE_GXX_BUILTIN_H)
2435          fi],
2436         [AC_TRY_LINK([
2437 #include <builtin.h>
2438         ],
2439         [two_arg_error_handler_t foo2 = lib_error_handler],
2440         [cf_cxx_library=yes
2441          CF_ADD_LIB($cf_gpp_libname,CXXLIBS)
2442          AC_DEFINE(HAVE_BUILTIN_H)],
2443         [cf_cxx_library=no])])
2444         LIBS="$cf_save"
2445         AC_MSG_RESULT($cf_cxx_library)
2446 fi
2447 ])dnl
2448 dnl ---------------------------------------------------------------------------
2449 dnl CF_GXX_VERSION version: 6 updated: 2010/10/23 15:44:18
2450 dnl --------------
2451 dnl Check for version of g++
2452 AC_DEFUN([CF_GXX_VERSION],[
2453 AC_REQUIRE([AC_PROG_CPP])
2454 GXX_VERSION=none
2455 if test "$GXX" = yes; then
2456         AC_MSG_CHECKING(version of g++)
2457         GXX_VERSION="`${CXX:-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
2458         test -z "$GXX_VERSION" && GXX_VERSION=unknown
2459         AC_MSG_RESULT($GXX_VERSION)
2460 fi
2461 ])dnl
2462 dnl ---------------------------------------------------------------------------
2463 dnl CF_GXX_WARNINGS version: 6 updated: 2010/08/14 18:25:37
2464 dnl ---------------
2465 dnl Check if the compiler supports useful warning options.
2466 dnl
2467 dnl Most of gcc's options apply to g++, except:
2468 dnl     -Wbad-function-cast
2469 dnl     -Wmissing-declarations
2470 dnl     -Wnested-externs
2471 dnl
2472 dnl Omit a few (for now):
2473 dnl     -Winline
2474 dnl
2475 dnl Parameter:
2476 dnl     $1 is an optional list of g++ warning flags that a particular
2477 dnl             application might want to use, e.g., "no-unused" for
2478 dnl             -Wno-unused
2479 dnl Special:
2480 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
2481 dnl
2482 AC_DEFUN([CF_GXX_WARNINGS],
2483 [
2484
2485 CF_INTEL_COMPILER(GXX,INTEL_CPLUSPLUS,CXXFLAGS)
2486
2487 AC_REQUIRE([CF_GXX_VERSION])
2488
2489 AC_LANG_SAVE
2490 AC_LANG_CPLUSPLUS
2491
2492 cat > conftest.$ac_ext <<EOF
2493 #line __oline__ "configure"
2494 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
2495 EOF
2496
2497 if test "$INTEL_CPLUSPLUS" = yes
2498 then
2499 # The "-wdXXX" options suppress warnings:
2500 # remark #1419: external declaration in primary source file
2501 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2502 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2503 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
2504 # remark #193: zero used for undefined preprocessing identifier
2505 # remark #593: variable "curs_sb_left_arrow" was set but never used
2506 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
2507 # remark #869: parameter "tw" was never referenced
2508 # remark #981: operands are evaluated in unspecified order
2509 # warning #269: invalid format string conversion
2510
2511         AC_CHECKING([for $CC warning options])
2512         cf_save_CXXFLAGS="$CXXFLAGS"
2513         EXTRA_CXXFLAGS="-Wall"
2514         for cf_opt in \
2515                 wd1419 \
2516                 wd1682 \
2517                 wd1683 \
2518                 wd1684 \
2519                 wd193 \
2520                 wd279 \
2521                 wd593 \
2522                 wd810 \
2523                 wd869 \
2524                 wd981
2525         do
2526                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt"
2527                 if AC_TRY_EVAL(ac_compile); then
2528                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2529                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
2530                 fi
2531         done
2532         CXXFLAGS="$cf_save_CXXFLAGS"
2533
2534 elif test "$GXX" = yes
2535 then
2536         AC_CHECKING([for $CXX warning options])
2537         cf_save_CXXFLAGS="$CXXFLAGS"
2538         EXTRA_CXXFLAGS="-W -Wall"
2539         cf_gxx_extra_warnings=""
2540         test "$with_ext_const" = yes && cf_gxx_extra_warnings="Wwrite-strings"
2541         case "$GCC_VERSION" in
2542         [[1-2]].*)
2543                 ;;
2544         *)
2545                 cf_gxx_extra_warnings="$cf_gxx_extra_warnings Weffc++"
2546                 ;;
2547         esac
2548         for cf_opt in \
2549                 Wabi \
2550                 fabi-version=0 \
2551                 Woverloaded-virtual \
2552                 Wsign-promo \
2553                 Wsynth \
2554                 Wold-style-cast \
2555                 Wcast-align \
2556                 Wcast-qual \
2557                 Wmissing-prototypes \
2558                 Wpointer-arith \
2559                 Wshadow \
2560                 Wstrict-prototypes \
2561                 Wundef $cf_gxx_extra_warnings $1
2562         do
2563                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
2564                 if AC_TRY_EVAL(ac_compile); then
2565                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2566                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
2567                 else
2568                         test -n "$verbose" && AC_MSG_RESULT(... no -$cf_opt)
2569                 fi
2570         done
2571         CXXFLAGS="$cf_save_CXXFLAGS"
2572 fi
2573
2574 rm -rf conftest*
2575 AC_LANG_RESTORE
2576 AC_SUBST(EXTRA_CXXFLAGS)
2577 ])dnl
2578 dnl ---------------------------------------------------------------------------
2579 dnl CF_HASHED_DB version: 4 updated: 2010/05/29 16:31:02
2580 dnl ------------
2581 dnl Look for an instance of the Berkeley hashed database.
2582 dnl
2583 dnl $1 = optional parameter, to specify install-prefix for the database.
2584 AC_DEFUN([CF_HASHED_DB],
2585 [
2586 ifelse([$1],,,[
2587 case $1 in #(vi
2588 yes|*able*) #(vi
2589     ;;
2590 *)
2591     if test -d "$1" ; then
2592         CF_ADD_INCDIR($1/include)
2593         CF_ADD_LIBDIR($1/lib)
2594     fi
2595 esac
2596 ])
2597 AC_CHECK_HEADER(db.h,[
2598 CF_HASHED_DB_VERSION
2599 if test "$cf_cv_hashed_db_version" = unknown ; then
2600         AC_MSG_ERROR(Cannot determine version of db)
2601 else
2602         CF_HASHED_DB_LIBS
2603         if test "$cf_cv_hashed_db_libs" = unknown ; then
2604                 AC_MSG_ERROR(Cannot determine library for db)
2605         elif test "$cf_cv_hashed_db_libs" != default ; then
2606                 CF_ADD_LIB($cf_cv_hashed_db_libs)
2607         fi
2608 fi
2609 ],[
2610         AC_MSG_ERROR(Cannot find db.h)
2611 ])
2612 ])dnl
2613 dnl ---------------------------------------------------------------------------
2614 dnl CF_HASHED_DB_LIBS version: 9 updated: 2010/05/29 16:31:02
2615 dnl -----------------
2616 dnl Given that we have the header and version for hashed database, find the
2617 dnl library information.
2618 AC_DEFUN([CF_HASHED_DB_LIBS],
2619 [
2620 AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
2621 cf_cv_hashed_db_libs=unknown
2622 for cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
2623 do
2624         cf_save_libs="$LIBS"
2625         if test -n "$cf_db_libs"; then
2626                 CF_ADD_LIB($cf_db_libs)
2627         fi
2628         CF_MSG_LOG(checking for library "$cf_db_libs")
2629         AC_TRY_LINK([
2630 $ac_includes_default
2631 #include <db.h>
2632 ],[
2633         char *path = "/tmp/foo";
2634 #ifdef DB_VERSION_MAJOR
2635 #if DB_VERSION_MAJOR >= 4
2636         DB *result = 0;
2637         db_create(&result, NULL, 0);
2638         result->open(result,
2639                 NULL,
2640                 path,
2641                 path,
2642                 DB_HASH,
2643                 DB_CREATE,
2644                 0644);
2645 #elif DB_VERSION_MAJOR >= 3
2646         DB *result = 0;
2647         db_create(&result, NULL, 0);
2648         result->open(result,
2649                 path,
2650                 path,
2651                 DB_HASH,
2652                 DB_CREATE,
2653                 0644);
2654 #elif DB_VERSION_MAJOR >= 2
2655         DB *result = 0;
2656         db_open(path,
2657                 DB_HASH,
2658                 DB_CREATE,
2659                 0644,
2660                 (DB_ENV *) 0,
2661                 (DB_INFO *) 0,
2662                 &result);
2663 #endif /* DB_VERSION_MAJOR */
2664 #else
2665         DB *result = dbopen(path,
2666                      2,
2667                      0644,
2668                      DB_HASH,
2669                      0);
2670 #endif
2671         ${cf_cv_main_return:-return}(result != 0)
2672 ],[
2673         if test -n "$cf_db_libs" ; then
2674                 cf_cv_hashed_db_libs=$cf_db_libs
2675         else
2676                 cf_cv_hashed_db_libs=default
2677         fi
2678         LIBS="$cf_save_libs"
2679         break
2680 ])
2681         LIBS="$cf_save_libs"
2682 done
2683 ])
2684 ])dnl
2685 dnl ---------------------------------------------------------------------------
2686 dnl CF_HASHED_DB_VERSION version: 3 updated: 2007/12/01 15:01:37
2687 dnl --------------------
2688 dnl Given that we have the header file for hashed database, find the version
2689 dnl information.
2690 AC_DEFUN([CF_HASHED_DB_VERSION],
2691 [
2692 AC_CACHE_CHECK(for version of db, cf_cv_hashed_db_version,[
2693 cf_cv_hashed_db_version=unknown
2694
2695 for cf_db_version in 1 2 3 4 5
2696 do
2697         CF_MSG_LOG(checking for db version $cf_db_version)
2698         AC_TRY_COMPILE([
2699 $ac_includes_default
2700 #include <db.h>
2701
2702 #ifdef DB_VERSION_MAJOR
2703         /* db2 (DB_VERSION_MAJOR=2) has also DB_VERSION_MINOR, tested with 7 */
2704 #if $cf_db_version == DB_VERSION_MAJOR
2705         /* ok */
2706 #else
2707         make an error
2708 #endif
2709 #else
2710 #if $cf_db_version == 1
2711         /* ok: assuming this is DB 1.8.5 */
2712 #else
2713         make an error
2714 #endif
2715 #endif
2716 ],[DBT *foo = 0],[
2717         cf_cv_hashed_db_version=$cf_db_version
2718         break
2719         ])
2720 done
2721 ])
2722 ])dnl
2723 dnl ---------------------------------------------------------------------------
2724 dnl CF_HEADER_PATH version: 12 updated: 2010/05/05 05:22:40
2725 dnl --------------
2726 dnl Construct a search-list of directories for a nonstandard header-file
2727 dnl
2728 dnl Parameters
2729 dnl     $1 = the variable to return as result
2730 dnl     $2 = the package name
2731 AC_DEFUN([CF_HEADER_PATH],
2732 [
2733 $1=
2734
2735 # collect the current set of include-directories from compiler flags
2736 cf_header_path_list=""
2737 if test -n "${CFLAGS}${CPPFLAGS}" ; then
2738         for cf_header_path in $CPPFLAGS $CFLAGS
2739         do
2740                 case $cf_header_path in #(vi
2741                 -I*)
2742                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
2743                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
2744                         cf_header_path_list="$cf_header_path_list [$]$1"
2745                         ;;
2746                 esac
2747         done
2748 fi
2749
2750 # add the variations for the package we are looking for
2751 CF_SUBDIR_PATH($1,$2,include)
2752
2753 test "$includedir" != NONE && \
2754 test "$includedir" != "/usr/include" && \
2755 test -d "$includedir" && {
2756         test -d $includedir &&    $1="[$]$1 $includedir"
2757         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
2758 }
2759
2760 test "$oldincludedir" != NONE && \
2761 test "$oldincludedir" != "/usr/include" && \
2762 test -d "$oldincludedir" && {
2763         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
2764         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
2765 }
2766
2767 $1="[$]$1 $cf_header_path_list"
2768 ])dnl
2769 dnl ---------------------------------------------------------------------------
2770 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
2771 dnl ---------------
2772 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
2773 AC_DEFUN([CF_HELP_MESSAGE],
2774 [AC_DIVERT_HELP([$1])dnl
2775 ])dnl
2776 dnl ---------------------------------------------------------------------------
2777 dnl CF_INCLUDE_DIRS version: 6 updated: 2009/01/06 19:37:40
2778 dnl ---------------
2779 dnl Construct the list of include-options according to whether we're building
2780 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
2781 dnl with gcc, don't append the includedir if it happens to be /usr/include,
2782 dnl since that usually breaks gcc's shadow-includes.
2783 AC_DEFUN([CF_INCLUDE_DIRS],
2784 [
2785 CPPFLAGS="$CPPFLAGS -I. -I../include"
2786 if test "$srcdir" != "."; then
2787         CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
2788 fi
2789 if test "$GCC" != yes; then
2790         CPPFLAGS="$CPPFLAGS -I\${includedir}"
2791 elif test "$includedir" != "/usr/include"; then
2792         if test "$includedir" = '${prefix}/include' ; then
2793                 if test $prefix != /usr ; then
2794                         CPPFLAGS="$CPPFLAGS -I\${includedir}"
2795                 fi
2796         else
2797                 CPPFLAGS="$CPPFLAGS -I\${includedir}"
2798         fi
2799 fi
2800 AC_SUBST(CPPFLAGS)
2801 ])dnl
2802 dnl ---------------------------------------------------------------------------
2803 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
2804 dnl -----------------
2805 dnl Check if the given compiler is really the Intel compiler for Linux.  It
2806 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
2807 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2808 dnl
2809 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2810 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2811 dnl the wrappers for gcc and g++ warnings.
2812 dnl
2813 dnl $1 = GCC (default) or GXX
2814 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2815 dnl $3 = CFLAGS (default) or CXXFLAGS
2816 AC_DEFUN([CF_INTEL_COMPILER],[
2817 ifelse([$2],,INTEL_COMPILER,[$2])=no
2818
2819 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
2820         case $host_os in
2821         linux*|gnu*)
2822                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
2823                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
2824                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
2825                 AC_TRY_COMPILE([],[
2826 #ifdef __INTEL_COMPILER
2827 #else
2828 make an error
2829 #endif
2830 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
2831 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
2832 ],[])
2833                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
2834                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
2835                 ;;
2836         esac
2837 fi
2838 ])dnl
2839 dnl ---------------------------------------------------------------------------
2840 dnl CF_ISASCII version: 3 updated: 2000/08/12 23:18:52
2841 dnl ----------
2842 dnl Check if we have either a function or macro for 'isascii()'.
2843 AC_DEFUN([CF_ISASCII],
2844 [
2845 AC_MSG_CHECKING(for isascii)
2846 AC_CACHE_VAL(cf_cv_have_isascii,[
2847         AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
2848         [cf_cv_have_isascii=yes],
2849         [cf_cv_have_isascii=no])
2850 ])dnl
2851 AC_MSG_RESULT($cf_cv_have_isascii)
2852 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII)
2853 ])dnl
2854 dnl ---------------------------------------------------------------------------
2855 dnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
2856 dnl ------------
2857 dnl Add checks for large file support.
2858 AC_DEFUN([CF_LARGEFILE],[
2859 ifdef([AC_FUNC_FSEEKO],[
2860     AC_SYS_LARGEFILE
2861     if test "$enable_largefile" != no ; then
2862         AC_FUNC_FSEEKO
2863
2864         # Normally we would collect these definitions in the config.h,
2865         # but (like _XOPEN_SOURCE), some environments rely on having these
2866         # defined before any of the system headers are included.  Another
2867         # case comes up with C++, e.g., on AIX the compiler compiles the
2868         # header files by themselves before looking at the body files it is
2869         # told to compile.  For ncurses, those header files do not include
2870         # the config.h
2871         test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
2872         test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
2873         test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
2874
2875         AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
2876                 AC_TRY_COMPILE([
2877 #include <sys/types.h>
2878 #include <dirent.h>
2879                 ],[
2880                 /* if transitional largefile support is setup, this is true */
2881                 extern struct dirent64 * readdir(DIR *);
2882                 struct dirent64 *x = readdir((DIR *)0);
2883                 struct dirent *y = readdir((DIR *)0);
2884                 int z = x - y;
2885                 ],
2886                 [cf_cv_struct_dirent64=yes],
2887                 [cf_cv_struct_dirent64=no])
2888         ])
2889         test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
2890     fi
2891 ])
2892 ])
2893 dnl ---------------------------------------------------------------------------
2894 dnl CF_LDFLAGS_STATIC version: 10 updated: 2011/09/24 12:51:48
2895 dnl -----------------
2896 dnl Check for compiler/linker flags used to temporarily force usage of static
2897 dnl libraries.  This depends on the compiler and platform.  Use this to help
2898 dnl ensure that the linker picks up a given library based on its position in
2899 dnl the list of linker options and libraries.
2900 AC_DEFUN([CF_LDFLAGS_STATIC],[
2901
2902 if test "$GCC" = yes ; then
2903         case $cf_cv_system_name in #(
2904         OS/2*|os2*|aix[[4]]*|solaris2.1[[0-9]]|darwin*)         #( vi
2905                 LDFLAGS_STATIC=
2906                 LDFLAGS_SHARED=
2907                 ;;
2908     *)  #( normally, except when broken
2909         LDFLAGS_STATIC=-static
2910         LDFLAGS_SHARED=-dynamic
2911         ;;
2912     esac
2913 else
2914         case $cf_cv_system_name in #(
2915         aix[[4-7]]*)    #( from ld manpage
2916                 LDFLAGS_STATIC=-bstatic
2917                 LDFLAGS_SHARED=-bdynamic
2918                 ;;
2919         hpux*)          #( from ld manpage for hpux10.20, hpux11.11
2920                 # We could also use just "archive" and "shared".
2921                 LDFLAGS_STATIC=-Wl,-a,archive_shared
2922                 LDFLAGS_SHARED=-Wl,-a,shared_archive
2923                 ;;
2924         irix*)          #( from ld manpage IRIX64
2925                 LDFLAGS_STATIC=-Bstatic
2926                 LDFLAGS_SHARED=-Bdynamic
2927                 ;;
2928         osf[[45]]*)     #( from ld manpage osf4.0d, osf5.1
2929                 # alternative "-oldstyle_liblookup" (not in cc manpage)
2930                 LDFLAGS_STATIC=-noso
2931                 LDFLAGS_SHARED=-so_archive
2932                 ;;
2933         solaris2*)
2934                 LDFLAGS_STATIC=-Bstatic
2935                 LDFLAGS_SHARED=-Bdynamic
2936                 ;;
2937         esac
2938 fi
2939
2940 if test -n "$LDFLAGS_STATIC" && test -n "$LDFLAGS_SHARED"
2941 then
2942         AC_MSG_CHECKING(if linker supports switching between static/dynamic)
2943
2944         rm -f libconftest.a
2945         cat >conftest.$ac_ext <<EOF
2946 #line __oline__ "configure"
2947 #include <stdio.h>
2948 int cf_ldflags_static(FILE *fp) { return fflush(fp); }
2949 EOF
2950         if AC_TRY_EVAL(ac_compile) ; then
2951                 ( $AR $ARFLAGS libconftest.a conftest.o ) 2>&AC_FD_CC 1>/dev/null
2952                 ( eval $RANLIB libconftest.a ) 2>&AC_FD_CC >/dev/null
2953         fi
2954         rm -f conftest.*
2955
2956         cf_save_LIBS="$LIBS"
2957
2958         LIBS="$LDFLAGS_STATIC -L`pwd` -lconftest $LDFLAGS_DYNAMIC $LIBS"
2959         AC_TRY_LINK([
2960 #line __oline__ "configure"
2961 #include <stdio.h>
2962 int cf_ldflags_static(FILE *fp);
2963 ],[
2964         return cf_ldflags_static(stdin);
2965 ],[
2966         # some linkers simply ignore the -dynamic
2967         case x`file conftest$ac_exeext 2>/dev/null` in #(vi
2968         *static*) # (vi
2969                 cf_ldflags_static=no
2970                 ;;
2971         *)
2972                 cf_ldflags_static=yes
2973                 ;;
2974         esac
2975 ],[cf_ldflags_static=no])
2976
2977         rm -f libconftest.*
2978         LIBS="$cf_save_LIBS"
2979
2980         AC_MSG_RESULT($cf_ldflags_static)
2981
2982         if test $cf_ldflags_static != yes
2983         then
2984                 LDFLAGS_STATIC=
2985                 LDFLAGS_SHARED=
2986         fi
2987 else
2988         LDFLAGS_STATIC=
2989         LDFLAGS_SHARED=
2990 fi
2991
2992 AC_SUBST(LDFLAGS_STATIC)
2993 AC_SUBST(LDFLAGS_SHARED)
2994 ])
2995 dnl ---------------------------------------------------------------------------
2996 dnl CF_LD_RPATH_OPT version: 5 updated: 2011/07/17 14:48:41
2997 dnl ---------------
2998 dnl For the given system and compiler, find the compiler flags to pass to the
2999 dnl loader to use the "rpath" feature.
3000 AC_DEFUN([CF_LD_RPATH_OPT],
3001 [
3002 AC_REQUIRE([CF_CHECK_CACHE])
3003
3004 LD_RPATH_OPT=
3005 AC_MSG_CHECKING(for an rpath option)
3006 case $cf_cv_system_name in #(vi
3007 irix*) #(vi
3008         if test "$GCC" = yes; then
3009                 LD_RPATH_OPT="-Wl,-rpath,"
3010         else
3011                 LD_RPATH_OPT="-rpath "
3012         fi
3013         ;;
3014 linux*|gnu*|k*bsd*-gnu) #(vi
3015         LD_RPATH_OPT="-Wl,-rpath,"
3016         ;;
3017 openbsd[[2-9]].*|mirbsd*) #(vi
3018         LD_RPATH_OPT="-Wl,-rpath,"
3019         ;;
3020 dragonfly*|freebsd*) #(vi
3021         LD_RPATH_OPT="-rpath "
3022         ;;
3023 netbsd*) #(vi
3024         LD_RPATH_OPT="-Wl,-rpath,"
3025         ;;
3026 osf*|mls+*) #(vi
3027         LD_RPATH_OPT="-rpath "
3028         ;;
3029 solaris2*) #(vi
3030         LD_RPATH_OPT="-R"
3031         ;;
3032 *)
3033         ;;
3034 esac
3035 AC_MSG_RESULT($LD_RPATH_OPT)
3036
3037 case "x$LD_RPATH_OPT" in #(vi
3038 x-R*)
3039         AC_MSG_CHECKING(if we need a space after rpath option)
3040         cf_save_LIBS="$LIBS"
3041         CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
3042         AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
3043         LIBS="$cf_save_LIBS"
3044         AC_MSG_RESULT($cf_rpath_space)
3045         test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
3046         ;;
3047 esac
3048 ])dnl
3049 dnl ---------------------------------------------------------------------------
3050 dnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
3051 dnl ---------------
3052 dnl Construct a search-list of directories for a nonstandard library-file
3053 dnl
3054 dnl Parameters
3055 dnl     $1 = the variable to return as result
3056 dnl     $2 = the package name
3057 AC_DEFUN([CF_LIBRARY_PATH],
3058 [
3059 $1=
3060 cf_library_path_list=""
3061 if test -n "${LDFLAGS}${LIBS}" ; then
3062         for cf_library_path in $LDFLAGS $LIBS
3063         do
3064                 case $cf_library_path in #(vi
3065                 -L*)
3066                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
3067                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
3068                         cf_library_path_list="$cf_library_path_list [$]$1"
3069                         ;;
3070                 esac
3071         done
3072 fi
3073
3074 CF_SUBDIR_PATH($1,$2,lib)
3075
3076 $1="$cf_library_path_list [$]$1"
3077 ])dnl
3078 dnl ---------------------------------------------------------------------------
3079 dnl CF_LIB_PREFIX version: 9 updated: 2012/01/21 19:28:10
3080 dnl -------------
3081 dnl Compute the library-prefix for the given host system
3082 dnl $1 = variable to set
3083 define([CF_LIB_PREFIX],
3084 [
3085         case $cf_cv_system_name in #(vi
3086         OS/2*|os2*) #(vi
3087         LIB_PREFIX=''
3088         ;;
3089         *)      LIB_PREFIX='lib'
3090         ;;
3091         esac
3092 ifelse($1,,,[$1=$LIB_PREFIX])
3093         AC_SUBST(LIB_PREFIX)
3094 ])dnl
3095 dnl ---------------------------------------------------------------------------
3096 dnl CF_LIB_RULES version: 64 updated: 2012/02/25 15:20:07
3097 dnl ------------
3098 dnl Append definitions and rules for the given models to the subdirectory
3099 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
3100 dnl subdirectory is a library-source directory, modify the LIBS_TO_MAKE list in
3101 dnl the corresponding makefile to list the models that we'll generate.
3102 dnl
3103 dnl For shared libraries, make a list of symbolic links to construct when
3104 dnl generating each library.  The convention used for Linux is the simplest
3105 dnl one:
3106 dnl     lib<name>.so    ->
3107 dnl     lib<name>.so.<major>    ->
3108 dnl     lib<name>.so.<maj>.<minor>
3109 AC_DEFUN([CF_LIB_RULES],
3110 [
3111 cf_prefix=$LIB_PREFIX
3112 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
3113
3114 case $cf_cv_shlib_version in #(vi
3115 cygdll|mingw)
3116         TINFO_NAME=$TINFO_ARG_SUFFIX
3117         TINFO_SUFFIX=.dll
3118         ;;
3119 esac
3120
3121 if test -n "$TINFO_SUFFIX" ; then
3122         case $TINFO_SUFFIX in
3123         tw*)
3124                 TINFO_NAME="${TINFO_NAME}tw"
3125                 TINFO_SUFFIX=`echo $TINFO_SUFFIX | sed 's/^tw//'`
3126                 ;;
3127         t*)
3128                 TINFO_NAME="${TINFO_NAME}t"
3129                 TINFO_SUFFIX=`echo $TINFO_SUFFIX | sed 's/^t//'`
3130                 ;;
3131         w*)
3132                 TINFO_NAME="${TINFO_NAME}w"
3133                 TINFO_SUFFIX=`echo $TINFO_SUFFIX | sed 's/^w//'`
3134                 ;;
3135         esac
3136 fi
3137
3138 for cf_dir in $SRC_SUBDIRS
3139 do
3140         if test ! -d $srcdir/$cf_dir ; then
3141                 continue
3142         elif test -f $srcdir/$cf_dir/modules; then
3143
3144                 SHARED_LIB=
3145                 LIBS_TO_MAKE=
3146                 for cf_item in $cf_LIST_MODELS
3147                 do
3148                         CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
3149                         if test $cf_item = shared ; then
3150                         if test "$cf_cv_do_symlinks" = yes ; then
3151                                 case "$cf_cv_shlib_version" in #(vi
3152                                 rel) #(vi
3153                                         case "$cf_cv_system_name" in #(vi
3154                                         darwin*)
3155                                         case .${LIB_SUFFIX} in
3156                                         .tw*)
3157                                                 cf_suffix=`echo $cf_suffix | sed 's/^tw//'`
3158                                                 cf_suffix=tw'.${REL_VERSION}'"$cf_suffix"
3159                                                 ;;
3160                                         .t*)
3161                                                 cf_suffix=`echo $cf_suffix | sed 's/^t//'`
3162                                                 cf_suffix=t'.${REL_VERSION}'"$cf_suffix"
3163                                                 ;;
3164                                         .w*)
3165                                                 cf_suffix=`echo $cf_suffix | sed 's/^w//'`
3166                                                 cf_suffix=w'.${REL_VERSION}'"$cf_suffix"
3167                                                 ;;
3168                                         *)
3169                                                 cf_suffix='.${REL_VERSION}'"$cf_suffix"
3170                                                 ;;
3171                                         esac
3172                                         ;; #(vi
3173                                         *) cf_suffix="$cf_suffix"'.${REL_VERSION}' ;;
3174                                         esac
3175                                         ;;
3176                                 abi)
3177                                         case "$cf_cv_system_name" in #(vi
3178                                         darwin*)
3179                                         case .${LIB_SUFFIX} in
3180                                         .tw*)
3181                                                 cf_suffix=`echo $cf_suffix | sed 's/^tw//'`
3182                                                 cf_suffix=tw'.${ABI_VERSION}'"$cf_suffix"
3183                                                 ;;
3184                                         .t*)
3185                                                 cf_suffix=`echo $cf_suffix | sed 's/^t//'`
3186                                                 cf_suffix=t'.${ABI_VERSION}'"$cf_suffix"
3187                                                 ;;
3188                                         .w*)
3189                                                 cf_suffix=`echo $cf_suffix | sed 's/^w//'`
3190                                                 cf_suffix=w'.${ABI_VERSION}'"$cf_suffix"
3191                                                 ;;
3192                                         *)
3193                                                 cf_suffix='.${ABI_VERSION}'"$cf_suffix"
3194                                                 ;;
3195                                         esac
3196                                         ;; #(vi
3197                                         *) cf_suffix="$cf_suffix"'.${ABI_VERSION}' ;;
3198                                         esac
3199                                         ;;
3200                                 esac
3201                         fi
3202                         # cygwin needs import library, and has unique naming convention
3203                         # use autodetected ${cf_prefix} for import lib and static lib, but
3204                         # use 'cyg' prefix for shared lib.
3205                         case $cf_cv_shlib_version in #(vi
3206                         cygdll) #(vi
3207                                 cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
3208                                 LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/cyg${cf_dir}${cf_cygsuf}"
3209                                 continue
3210                                 ;;
3211                         mingw)
3212                                 cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
3213                                 LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/lib${cf_dir}${cf_cygsuf}"
3214                                 continue
3215                                 ;;
3216                         esac
3217                         fi
3218                         LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
3219                 done
3220
3221                 if test $cf_dir = ncurses ; then
3222                         cf_subsets="$LIB_SUBSETS"
3223                         cf_r_parts="$cf_subsets"
3224                         cf_liblist="$LIBS_TO_MAKE"
3225
3226                         while test -n "$cf_r_parts"
3227                         do
3228                                 cf_l_parts=`echo "$cf_r_parts" |sed -e 's/ .*$//'`
3229                                 cf_r_parts=`echo "$cf_r_parts" |sed -e 's/^[[^ ]]* //'`
3230                                 if test "$cf_l_parts" != "$cf_r_parts" ; then
3231                                         cf_item=
3232                                         case $cf_l_parts in #(vi
3233                                         *termlib*) #(vi
3234                                                 cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
3235                                                 ;;
3236                                         *ticlib*)
3237                                                 cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TICS_LIB_SUFFIX}%g`
3238                                                 ;;
3239                                         *)
3240                                                 break
3241                                                 ;;
3242                                         esac
3243                                         if test -n "$cf_item"; then
3244                                                 LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
3245                                         fi
3246                                 else
3247                                         break
3248                                 fi
3249                         done
3250                 else
3251                         cf_subsets=`echo "$LIB_SUBSETS" | sed -e 's/^termlib.* //'`
3252                 fi
3253
3254                 sed -e "s%@LIBS_TO_MAKE@%$LIBS_TO_MAKE%" \
3255                     -e "s%@SHARED_LIB@%$SHARED_LIB%" \
3256                         $cf_dir/Makefile >$cf_dir/Makefile.out
3257                 mv $cf_dir/Makefile.out $cf_dir/Makefile
3258
3259                 $AWK -f $srcdir/mk-0th.awk \
3260                         libname="${cf_dir}${LIB_SUFFIX}" subsets="$LIB_SUBSETS" \
3261                         $srcdir/$cf_dir/modules >>$cf_dir/Makefile
3262
3263                 for cf_subset in $cf_subsets
3264                 do
3265                         cf_subdirs=
3266                         for cf_item in $cf_LIST_MODELS
3267                         do
3268                         echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})"
3269                         CF_UPPER(cf_ITEM,$cf_item)
3270                         CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
3271                         CF_OBJ_SUBDIR($cf_item,cf_subdir)
3272
3273                         # Test for case where we build libtinfo with a different name.
3274                         cf_libname=$cf_dir
3275                         if test $cf_dir = ncurses ; then
3276                                 case $cf_subset in
3277                                 *base*)
3278                                         cf_libname=${cf_libname}$LIB_SUFFIX
3279                                         ;;
3280                                 *termlib*)
3281                                         cf_libname=$TINFO_LIB_SUFFIX
3282                                         ;;
3283                                 ticlib*)
3284                                         cf_libname=$TICS_LIB_SUFFIX
3285                                         ;;
3286                                 esac
3287                         else
3288                                 cf_libname=${cf_libname}$LIB_SUFFIX
3289                         fi
3290                         if test -n "${DFT_ARG_SUFFIX}" ; then
3291                                 # undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
3292                                 cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
3293                         fi
3294
3295                         # These dependencies really are for development, not
3296                         # builds, but they are useful in porting, too.
3297                         cf_depend="../include/ncurses_cfg.h"
3298                         if test "$srcdir" = "."; then
3299                                 cf_reldir="."
3300                         else
3301                                 cf_reldir="\${srcdir}"
3302                         fi
3303
3304                         if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
3305                                 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
3306                         elif test -f $srcdir/$cf_dir/curses.priv.h; then
3307                                 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
3308                         fi
3309
3310                         cf_dir_suffix=
3311                         old_cf_suffix="$cf_suffix"
3312                         if test "$cf_cv_shlib_version_infix" = yes ; then
3313                         if test -n "$LIB_SUFFIX" ; then
3314                                 case $LIB_SUFFIX in
3315                                 tw*)
3316                                         cf_libname=`echo $cf_libname | sed 's/tw$//'`
3317                                         cf_suffix=`echo $cf_suffix | sed 's/^tw//'`
3318                                         cf_dir_suffix=tw
3319                                         ;;
3320                                 t*)
3321                                         cf_libname=`echo $cf_libname | sed 's/t$//'`
3322                                         cf_suffix=`echo $cf_suffix | sed 's/^t//'`
3323                                         cf_dir_suffix=t
3324                                         ;;
3325                                 w*)
3326                                         cf_libname=`echo $cf_libname | sed 's/w$//'`
3327                                         cf_suffix=`echo $cf_suffix | sed 's/^w//'`
3328                                         cf_dir_suffix=w
3329                                         ;;
3330                                 esac
3331                         fi
3332                         fi
3333
3334                         $AWK -f $srcdir/mk-1st.awk \
3335                                 name=${cf_libname}${cf_dir_suffix} \
3336                                 traces=$LIB_TRACING \
3337                                 MODEL=$cf_ITEM \
3338                                 model=$cf_subdir \
3339                                 prefix=$cf_prefix \
3340                                 suffix=$cf_suffix \
3341                                 subset=$cf_subset \
3342                                 driver=$cf_cv_term_driver \
3343                                 SymLink="$LN_S" \
3344                                 TermlibRoot=$TINFO_NAME \
3345                                 TermlibSuffix=$TINFO_SUFFIX \
3346                                 ShlibVer=$cf_cv_shlib_version \
3347                                 ShlibVerInfix=$cf_cv_shlib_version_infix \
3348                                 ReLink=${cf_cv_do_relink:-no} \
3349                                 DoLinks=$cf_cv_do_symlinks \
3350                                 rmSoLocs=$cf_cv_rm_so_locs \
3351                                 ldconfig="$LDCONFIG" \
3352                                 overwrite=$WITH_OVERWRITE \
3353                                 depend="$cf_depend" \
3354                                 host="$host" \
3355                                 libtool_version="$LIBTOOL_VERSION" \
3356                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
3357
3358                         cf_suffix="$old_cf_suffix"
3359
3360                         for cf_subdir2 in $cf_subdirs lib
3361                         do
3362                                 test $cf_subdir = $cf_subdir2 && break
3363                         done
3364                         test "${cf_subset}.${cf_subdir2}" != "${cf_subset}.${cf_subdir}" && \
3365                         $AWK -f $srcdir/mk-2nd.awk \
3366                                 name=$cf_dir \
3367                                 traces=$LIB_TRACING \
3368                                 MODEL=$cf_ITEM \
3369                                 model=$cf_subdir \
3370                                 subset=$cf_subset \
3371                                 srcdir=$srcdir \
3372                                 echo=$WITH_ECHO \
3373                                 crenames=$cf_cv_prog_CC_c_o \
3374                                 cxxrenames=$cf_cv_prog_CXX_c_o \
3375                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
3376                         cf_subdirs="$cf_subdirs $cf_subdir"
3377                         done
3378                 done
3379         fi
3380
3381         echo '  cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >>Makefile
3382 done
3383
3384 for cf_dir in $SRC_SUBDIRS
3385 do
3386         if test ! -d $srcdir/$cf_dir ; then
3387                 continue
3388         fi
3389
3390         if test -f $cf_dir/Makefile ; then
3391                 case "$cf_dir" in
3392                 Ada95) #(vi
3393                         echo 'libs \' >> Makefile
3394                         echo 'install.libs \' >> Makefile
3395                         echo 'uninstall.libs ::' >> Makefile
3396                         echo '  cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >> Makefile
3397                         ;;
3398                 esac
3399         fi
3400
3401         if test -f $srcdir/$cf_dir/modules; then
3402                 echo >> Makefile
3403                 if test -f $srcdir/$cf_dir/headers; then
3404 cat >> Makefile <<CF_EOF
3405 install.includes \\
3406 uninstall.includes \\
3407 CF_EOF
3408                 fi
3409 if test "$cf_dir" != "c++" ; then
3410 echo 'lint \' >> Makefile
3411 fi
3412 cat >> Makefile <<CF_EOF
3413 libs \\
3414 lintlib \\
3415 install.libs \\
3416 uninstall.libs \\
3417 install.$cf_dir \\
3418 uninstall.$cf_dir ::
3419         cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
3420 CF_EOF
3421         elif test -f $srcdir/$cf_dir/headers; then
3422 cat >> Makefile <<CF_EOF
3423
3424 libs \\
3425 install.libs \\
3426 uninstall.libs \\
3427 install.includes \\
3428 uninstall.includes ::
3429         cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
3430 CF_EOF
3431 fi
3432 done
3433
3434 cat >> Makefile <<CF_EOF
3435
3436 install.libs uninstall.libs \\
3437 install.data uninstall.data ::
3438 $MAKE_TERMINFO  cd misc && \${MAKE} \${CF_MFLAGS} \[$]@
3439 CF_EOF
3440
3441 if test "x$cf_with_manpages" = xyes; then
3442 cat >> Makefile <<CF_EOF
3443
3444 install.man \\
3445 uninstall.man ::
3446         cd man && \${MAKE} \${CF_MFLAGS} \[$]@
3447 CF_EOF
3448 fi
3449
3450 cat >> Makefile <<CF_EOF
3451
3452 distclean ::
3453         rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
3454         rm -f headers.sh headers.sed mk_shared_lib.sh
3455         rm -f edit_man.* man_alias.*
3456         rm -rf \${DIRS_TO_MAKE}
3457 CF_EOF
3458
3459 # Special case: tack's manpage lives in its own directory.
3460 if test "x$cf_with_manpages" = xyes; then
3461 if test -d tack ; then
3462 if test -f $srcdir/$tack.h; then
3463 cat >> Makefile <<CF_EOF
3464
3465 install.man \\
3466 uninstall.man ::
3467         cd tack && \${MAKE} \${CF_MFLAGS} \[$]@
3468 CF_EOF
3469 fi
3470 fi
3471 fi
3472
3473 dnl If we're installing into a subdirectory of /usr/include, etc., we should
3474 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
3475 dnl anything, and will make it more standardized.  It's awkward to decide this
3476 dnl at configuration because of quoting, so we'll simply make all headers
3477 dnl installed via a script that can do the right thing.
3478
3479 rm -f headers.sed headers.sh
3480
3481 dnl ( generating this script makes the makefiles a little tidier :-)
3482 echo creating headers.sh
3483 cat >headers.sh <<CF_EOF
3484 #! /bin/sh
3485 # This shell script is generated by the 'configure' script.  It is invoked in a
3486 # subdirectory of the build tree.  It generates a sed-script in the parent
3487 # directory that is used to adjust includes for header files that reside in a
3488 # subdirectory of /usr/include, etc.
3489 PRG=""
3490 while test \[$]# != 3
3491 do
3492 PRG="\$PRG \[$]1"; shift
3493 done
3494 DST=\[$]1
3495 REF=\[$]2
3496 SRC=\[$]3
3497 TMPSRC=\${TMPDIR:-/tmp}/\`basename \$SRC\`\$\$
3498 TMPSED=\${TMPDIR:-/tmp}/headers.sed\$\$
3499 echo installing \$SRC in \$DST
3500 CF_EOF
3501
3502 if test $WITH_CURSES_H = yes; then
3503         cat >>headers.sh <<CF_EOF
3504 case \$DST in
3505 /*/include/*)
3506         END=\`basename \$DST\`
3507         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
3508         do
3509                 NAME=\`basename \$i\`
3510                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
3511         done
3512         ;;
3513 *)
3514         echo "" >> \$TMPSED
3515         ;;
3516 esac
3517 CF_EOF
3518
3519 else
3520         cat >>headers.sh <<CF_EOF
3521 case \$DST in
3522 /*/include/*)
3523         END=\`basename \$DST\`
3524         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
3525         do
3526                 NAME=\`basename \$i\`
3527                 if test "\$NAME" = "curses.h"
3528                 then
3529                         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
3530                         NAME=ncurses.h
3531                 fi
3532                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
3533         done
3534         ;;
3535 *)
3536         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
3537         ;;
3538 esac
3539 CF_EOF
3540 fi
3541 cat >>headers.sh <<CF_EOF
3542 rm -f \$TMPSRC
3543 sed -f \$TMPSED \$SRC > \$TMPSRC
3544 NAME=\`basename \$SRC\`
3545 CF_EOF
3546 if test $WITH_CURSES_H != yes; then
3547         cat >>headers.sh <<CF_EOF
3548 test "\$NAME" = "curses.h" && NAME=ncurses.h
3549 CF_EOF
3550 fi
3551 cat >>headers.sh <<CF_EOF
3552 # Just in case someone gzip'd manpages, remove the conflicting copy.
3553 test -f \$DST/\$NAME.gz && rm -f \$DST/\$NAME.gz
3554
3555 eval \$PRG \$TMPSRC \$DST/\$NAME
3556 rm -f \$TMPSRC \$TMPSED
3557 CF_EOF
3558
3559 chmod 0755 headers.sh
3560
3561 for cf_dir in $SRC_SUBDIRS
3562 do
3563         if test ! -d $srcdir/$cf_dir ; then
3564                 continue
3565         fi
3566
3567         if test -f $srcdir/$cf_dir/headers; then
3568                 $AWK -f $srcdir/mk-hdr.awk \
3569                         subset="$LIB_SUBSETS" \
3570                         compat="$WITH_CURSES_H" \
3571                         $srcdir/$cf_dir/headers >>$cf_dir/Makefile
3572         fi
3573
3574         if test -f $srcdir/$cf_dir/modules; then
3575                 if test "$cf_dir" != "c++" ; then
3576                         cat >>$cf_dir/Makefile <<"CF_EOF"
3577 depend : ${AUTO_SRC}
3578         makedepend -- ${CPPFLAGS} -- ${C_SRC}
3579
3580 # DO NOT DELETE THIS LINE -- make depend depends on it.
3581 CF_EOF
3582                 fi
3583         fi
3584 done
3585 AC_SUBST(LIBS_TO_MAKE)
3586 ])dnl
3587 dnl ---------------------------------------------------------------------------
3588 dnl CF_LIB_SONAME version: 5 updated: 2010/08/14 18:25:37
3589 dnl -------------
3590 dnl Find the and soname for the given shared library.  Set the cache variable
3591 dnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
3592 dnl variable to "unknown".
3593 dnl
3594 dnl $1 = headers
3595 dnl $2 = code
3596 dnl $3 = library name
3597 AC_DEFUN([CF_LIB_SONAME],
3598 [
3599 AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
3600
3601 cf_cv_$3_soname=unknown
3602 if test "$cross_compiling" != yes ; then
3603 cat >conftest.$ac_ext <<CF_EOF
3604 $1
3605 int main()
3606 {
3607 $2
3608         ${cf_cv_main_return:-return}(0);
3609 }
3610 CF_EOF
3611 cf_save_LIBS="$LIBS"
3612         CF_ADD_LIB($3)
3613         if AC_TRY_EVAL(ac_compile) ; then
3614                 if AC_TRY_EVAL(ac_link) ; then
3615                         cf_cv_$3_soname=`ldd conftest$ac_exeext 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | fgrep lib$3.`
3616                         test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
3617                 fi
3618         fi
3619 rm -rf conftest*
3620 LIBS="$cf_save_LIBS"
3621 fi
3622 ])
3623 ])
3624 dnl ---------------------------------------------------------------------------
3625 dnl CF_LIB_SUFFIX version: 18 updated: 2012/02/25 15:20:07
3626 dnl -------------
3627 dnl Compute the library file-suffix from the given model name
3628 dnl $1 = model name
3629 dnl $2 = variable to set (the nominal library suffix)
3630 dnl $3 = dependency variable to set (actual filename)
3631 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
3632 AC_DEFUN([CF_LIB_SUFFIX],
3633 [
3634         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
3635         case $1 in #(vi
3636         libtool) #(vi
3637                 $2='.la'
3638                 $3=[$]$2
3639                 ;;
3640         normal) #(vi
3641                 $2='.a'
3642                 $3=[$]$2
3643                 ;;
3644         debug) #(vi
3645                 $2='_g.a'
3646                 $3=[$]$2
3647                 ;;
3648         profile) #(vi
3649                 $2='_p.a'
3650                 $3=[$]$2
3651                 ;;
3652         shared) #(vi
3653                 case $cf_cv_system_name in
3654                 aix[[5-7]]*) #(vi
3655                         $2='.a'
3656                         $3=[$]$2
3657                         ;;
3658                 cygwin*|mingw*) #(vi
3659                         $2='.dll'
3660                         $3='.dll.a'
3661                         ;;
3662                 darwin*) #(vi
3663                         $2='.dylib'
3664                         $3=[$]$2
3665                         ;;
3666                 hpux*) #(vi
3667                         case $target in
3668                         ia64*) #(vi
3669                                 $2='.so'
3670                                 $3=[$]$2
3671                                 ;;
3672                         *) #(vi
3673                                 $2='.sl'
3674                                 $3=[$]$2
3675                                 ;;
3676                         esac
3677                         ;;
3678                 *)      $2='.so'
3679                         $3=[$]$2
3680                         ;;
3681                 esac
3682         esac
3683         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
3684         test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}"
3685 ])dnl
3686 dnl ---------------------------------------------------------------------------
3687 dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
3688 dnl -----------
3689 dnl Compute the string to append to -library from the given model name
3690 dnl $1 = model name
3691 dnl $2 = variable to set
3692 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
3693 AC_DEFUN([CF_LIB_TYPE],
3694 [
3695         case $1 in
3696         libtool) $2=''   ;;
3697         normal)  $2=''   ;;
3698         debug)   $2='_g' ;;
3699         profile) $2='_p' ;;
3700         shared)  $2=''   ;;
3701         esac
3702         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
3703 ])dnl
3704 dnl ---------------------------------------------------------------------------
3705 dnl CF_LINK_DATAONLY version: 9 updated: 2009/01/01 20:21:38
3706 dnl ----------------
3707 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
3708 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
3709 dnl have to provide wrappers for global tables to ensure they're linked
3710 dnl properly.
3711 AC_DEFUN([CF_LINK_DATAONLY],
3712 [
3713 AC_MSG_CHECKING([if data-only library module links])
3714 AC_CACHE_VAL(cf_cv_link_dataonly,[
3715         rm -f conftest.a
3716         cat >conftest.$ac_ext <<EOF
3717 #line __oline__ "configure"
3718 int     testdata[[3]] = { 123, 456, 789 };
3719 EOF
3720         if AC_TRY_EVAL(ac_compile) ; then
3721                 mv conftest.o data.o && \
3722                 ( $AR $ARFLAGS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
3723         fi
3724         rm -f conftest.$ac_ext data.o
3725         cat >conftest.$ac_ext <<EOF
3726 #line __oline__ "configure"
3727 int     testfunc()
3728 {
3729 #if defined(NeXT)
3730         ${cf_cv_main_return:-return}(1);        /* I'm told this linker is broken */
3731 #else
3732         extern int testdata[[3]];
3733         return testdata[[0]] == 123
3734            &&  testdata[[1]] == 456
3735            &&  testdata[[2]] == 789;
3736 #endif
3737 }
3738 EOF
3739         if AC_TRY_EVAL(ac_compile); then
3740                 mv conftest.o func.o && \
3741                 ( $AR $ARFLAGS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
3742         fi
3743         rm -f conftest.$ac_ext func.o
3744         ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
3745         cf_saveLIBS="$LIBS"
3746         LIBS="conftest.a $LIBS"
3747         AC_TRY_RUN([
3748         int main()
3749         {
3750                 extern int testfunc();
3751                 ${cf_cv_main_return:-return} (!testfunc());
3752         }
3753         ],
3