48c39408831ea87953919cc5d045490eeb975f94
[ncurses.git] / Ada95 / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2010,2011 Free Software Foundation, Inc.                   *
3 dnl                                                                          *
4 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
5 dnl copy of this software and associated documentation files (the            *
6 dnl "Software"), to deal in the Software without restriction, including      *
7 dnl without limitation the rights to use, copy, modify, merge, publish,      *
8 dnl distribute, distribute with modifications, sublicense, and/or sell       *
9 dnl copies of the Software, and to permit persons to whom the Software is    *
10 dnl furnished to do so, subject to the following conditions:                 *
11 dnl                                                                          *
12 dnl The above copyright notice and this permission notice shall be included  *
13 dnl in all copies or substantial portions of the Software.                   *
14 dnl                                                                          *
15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 dnl                                                                          *
23 dnl Except as contained in this notice, the name(s) of the above copyright   *
24 dnl holders shall not be used in advertising or otherwise to promote the     *
25 dnl sale, use or other dealings in this Software without prior written       *
26 dnl authorization.                                                           *
27 dnl***************************************************************************
28 dnl
29 dnl Author: Thomas E. Dickey
30 dnl
31 dnl $Id: aclocal.m4,v 1.23 2011/03/28 00:08:52 tom Exp $
32 dnl Macros used in NCURSES Ada95 auto-configuration script.
33 dnl
34 dnl These macros are maintained separately from NCURSES.  The copyright on
35 dnl this file applies to the aggregation of macros and does not affect use of
36 dnl these macros in other applications.
37 dnl
38 dnl See http://invisible-island.net/autoconf/ for additional information.
39 dnl
40 dnl ---------------------------------------------------------------------------
41 dnl ---------------------------------------------------------------------------
42 dnl CF_ADA_INCLUDE_DIRS version: 6 updated: 2010/02/26 19:52:07
43 dnl -------------------
44 dnl Construct the list of include-options for the C programs in the Ada95
45 dnl binding.
46 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
47 [
48 ACPPFLAGS="-I. -I../include -I../../include $ACPPFLAGS"
49 if test "$srcdir" != "."; then
50         ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
51 fi
52 if test "$GCC" != yes; then
53         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
54 elif test "$includedir" != "/usr/include"; then
55         if test "$includedir" = '${prefix}/include' ; then
56                 if test $prefix != /usr ; then
57                         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
58                 fi
59         else
60                 ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
61         fi
62 fi
63 AC_SUBST(ACPPFLAGS)
64 ])dnl
65 dnl ---------------------------------------------------------------------------
66 dnl CF_ADD_ADAFLAGS version: 1 updated: 2010/06/19 15:22:18
67 dnl ---------------
68 dnl Add to $ADAFLAGS, which is substituted into makefile and scripts.
69 AC_DEFUN([CF_ADD_ADAFLAGS],[
70         ADAFLAGS="$ADAFLAGS $1"
71         AC_SUBST(ADAFLAGS)
72 ])dnl
73 dnl ---------------------------------------------------------------------------
74 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
75 dnl -------------
76 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
77 dnl The second parameter if given makes this macro verbose.
78 dnl
79 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
80 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
81 dnl confused by the quotes (which require backslashes to keep them usable).
82 AC_DEFUN([CF_ADD_CFLAGS],
83 [
84 cf_fix_cppflags=no
85 cf_new_cflags=
86 cf_new_cppflags=
87 cf_new_extra_cppflags=
88
89 for cf_add_cflags in $1
90 do
91 case $cf_fix_cppflags in
92 no)
93         case $cf_add_cflags in #(vi
94         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
95                 case $cf_add_cflags in
96                 -D*)
97                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
98
99                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
100                                 && test -z "${cf_tst_cflags}" \
101                                 && cf_fix_cppflags=yes
102
103                         if test $cf_fix_cppflags = yes ; then
104                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
105                                 continue
106                         elif test "${cf_tst_cflags}" = "\"'" ; then
107                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
108                                 continue
109                         fi
110                         ;;
111                 esac
112                 case "$CPPFLAGS" in
113                 *$cf_add_cflags) #(vi
114                         ;;
115                 *) #(vi
116                         case $cf_add_cflags in #(vi
117                         -D*)
118                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
119                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
120                                 ;;
121                         esac
122                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
123                         ;;
124                 esac
125                 ;;
126         *)
127                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
128                 ;;
129         esac
130         ;;
131 yes)
132         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
133
134         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
135
136         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
137                 && test -z "${cf_tst_cflags}" \
138                 && cf_fix_cppflags=no
139         ;;
140 esac
141 done
142
143 if test -n "$cf_new_cflags" ; then
144         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
145         CFLAGS="$CFLAGS $cf_new_cflags"
146 fi
147
148 if test -n "$cf_new_cppflags" ; then
149         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
150         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
151 fi
152
153 if test -n "$cf_new_extra_cppflags" ; then
154         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
155         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
156 fi
157
158 AC_SUBST(EXTRA_CPPFLAGS)
159
160 ])dnl
161 dnl ---------------------------------------------------------------------------
162 dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
163 dnl -------------
164 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
165 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
166 dnl but old versions (and some misinstalled ones) need that.  To make things
167 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
168 dnl the include-path).
169 AC_DEFUN([CF_ADD_INCDIR],
170 [
171 if test -n "$1" ; then
172   for cf_add_incdir in $1
173   do
174         while test $cf_add_incdir != /usr/include
175         do
176           if test -d $cf_add_incdir
177           then
178                 cf_have_incdir=no
179                 if test -n "$CFLAGS$CPPFLAGS" ; then
180                   # a loop is needed to ensure we can add subdirs of existing dirs
181                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
182                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
183                           cf_have_incdir=yes; break
184                         fi
185                   done
186                 fi
187
188                 if test "$cf_have_incdir" = no ; then
189                   if test "$cf_add_incdir" = /usr/local/include ; then
190                         if test "$GCC" = yes
191                         then
192                           cf_save_CPPFLAGS=$CPPFLAGS
193                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
194                           AC_TRY_COMPILE([#include <stdio.h>],
195                                   [printf("Hello")],
196                                   [],
197                                   [cf_have_incdir=yes])
198                           CPPFLAGS=$cf_save_CPPFLAGS
199                         fi
200                   fi
201                 fi
202
203                 if test "$cf_have_incdir" = no ; then
204                   CF_VERBOSE(adding $cf_add_incdir to include-path)
205                   ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
206
207                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
208                   test "$cf_top_incdir" = "$cf_add_incdir" && break
209                   cf_add_incdir="$cf_top_incdir"
210                 else
211                   break
212                 fi
213           fi
214         done
215   done
216 fi
217 ])dnl
218 dnl ---------------------------------------------------------------------------
219 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
220 dnl ----------
221 dnl Add a library, used to enforce consistency.
222 dnl
223 dnl $1 = library to add, without the "-l"
224 dnl $2 = variable to update (default $LIBS)
225 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
226 dnl ---------------------------------------------------------------------------
227 dnl CF_ADD_LIBDIR version: 9 updated: 2010/05/26 16:44:57
228 dnl -------------
229 dnl     Adds to the library-path
230 dnl
231 dnl     Some machines have trouble with multiple -L options.
232 dnl
233 dnl $1 is the (list of) directory(s) to add
234 dnl $2 is the optional name of the variable to update (default LDFLAGS)
235 dnl
236 AC_DEFUN([CF_ADD_LIBDIR],
237 [
238 if test -n "$1" ; then
239   for cf_add_libdir in $1
240   do
241     if test $cf_add_libdir = /usr/lib ; then
242       :
243     elif test -d $cf_add_libdir
244     then
245       cf_have_libdir=no
246       if test -n "$LDFLAGS$LIBS" ; then
247         # a loop is needed to ensure we can add subdirs of existing dirs
248         for cf_test_libdir in $LDFLAGS $LIBS ; do
249           if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
250             cf_have_libdir=yes; break
251           fi
252         done
253       fi
254       if test "$cf_have_libdir" = no ; then
255         CF_VERBOSE(adding $cf_add_libdir to library-path)
256         ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
257       fi
258     fi
259   done
260 fi
261 ])dnl
262 dnl ---------------------------------------------------------------------------
263 dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
264 dnl -----------
265 dnl Add one or more libraries, used to enforce consistency.
266 dnl
267 dnl $1 = libraries to add, with the "-l", etc.
268 dnl $2 = variable to update (default $LIBS)
269 AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
270 dnl ---------------------------------------------------------------------------
271 dnl CF_ADD_SUBDIR_PATH version: 3 updated: 2010/07/03 20:58:12
272 dnl ------------------
273 dnl Append to a search-list for a nonstandard header/lib-file
274 dnl     $1 = the variable to return as result
275 dnl     $2 = the package name
276 dnl     $3 = the subdirectory, e.g., bin, include or lib
277 dnl $4 = the directory under which we will test for subdirectories
278 dnl $5 = a directory that we do not want $4 to match
279 AC_DEFUN([CF_ADD_SUBDIR_PATH],
280 [
281 test "$4" != "$5" && \
282 test -d "$4" && \
283 ifelse([$5],NONE,,[(test $5 = NONE || test "$4" != "$5") &&]) {
284         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
285         test -d $4/$3 &&          $1="[$]$1 $4/$3"
286         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
287         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
288         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
289         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
290 }
291 ])dnl
292 dnl ---------------------------------------------------------------------------
293 dnl CF_ANSI_CC_CHECK version: 10 updated: 2010/10/23 15:52:32
294 dnl ----------------
295 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
296 dnl in the sharutils 4.2 distribution.
297 AC_DEFUN([CF_ANSI_CC_CHECK],
298 [
299 AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
300 cf_cv_ansi_cc=no
301 cf_save_CFLAGS="$CFLAGS"
302 cf_save_CPPFLAGS="$CPPFLAGS"
303 # Don't try gcc -ansi; that turns off useful extensions and
304 # breaks some systems' header files.
305 # AIX                   -qlanglvl=ansi
306 # Ultrix and OSF/1      -std1
307 # HP-UX                 -Aa -D_HPUX_SOURCE
308 # SVR4                  -Xc
309 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
310 for cf_arg in "-DCC_HAS_PROTOS" \
311         "" \
312         -qlanglvl=ansi \
313         -std1 \
314         -Ae \
315         "-Aa -D_HPUX_SOURCE" \
316         -Xc
317 do
318         CF_ADD_CFLAGS($cf_arg)
319         AC_TRY_COMPILE(
320 [
321 #ifndef CC_HAS_PROTOS
322 #if !defined(__STDC__) || (__STDC__ != 1)
323 choke me
324 #endif
325 #endif
326 ],[
327         int test (int i, double x);
328         struct s1 {int (*f) (int a);};
329         struct s2 {int (*f) (double a);};],
330         [cf_cv_ansi_cc="$cf_arg"; break])
331 done
332 CFLAGS="$cf_save_CFLAGS"
333 CPPFLAGS="$cf_save_CPPFLAGS"
334 ])
335
336 if test "$cf_cv_ansi_cc" != "no"; then
337 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
338         CF_ADD_CFLAGS($cf_cv_ansi_cc)
339 else
340         AC_DEFINE(CC_HAS_PROTOS)
341 fi
342 fi
343 ])dnl
344 dnl ---------------------------------------------------------------------------
345 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
346 dnl ---------------
347 dnl For programs that must use an ANSI compiler, obtain compiler options that
348 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
349 dnl macros, since tools such as unproto can fake prototypes, but only part of
350 dnl the preprocessor.
351 AC_DEFUN([CF_ANSI_CC_REQD],
352 [AC_REQUIRE([CF_ANSI_CC_CHECK])
353 if test "$cf_cv_ansi_cc" = "no"; then
354         AC_MSG_ERROR(
355 [Your compiler does not appear to recognize prototypes.
356 You have the following choices:
357         a. adjust your compiler options
358         b. get an up-to-date compiler
359         c. use a wrapper such as unproto])
360 fi
361 ])dnl
362 dnl ---------------------------------------------------------------------------
363 dnl CF_AR_FLAGS version: 5 updated: 2010/05/20 20:24:29
364 dnl -----------
365 dnl Check for suitable "ar" (archiver) options for updating an archive.
366 AC_DEFUN([CF_AR_FLAGS],[
367 AC_REQUIRE([CF_PROG_AR])
368
369 AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
370         cf_cv_ar_flags=unknown
371         for cf_ar_flags in -curv curv -crv crv -cqv cqv -rv rv
372         do
373
374                 # check if $ARFLAGS already contains this choice
375                 if test "x$ARFLAGS" != "x" ; then
376                         cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
377                         if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
378                                 cf_cv_ar_flags=
379                                 break
380                         fi
381                 fi
382
383                 rm -f conftest.$ac_cv_objext
384                 rm -f conftest.a
385
386                 cat >conftest.$ac_ext <<EOF
387 #line __oline__ "configure"
388 int     testdata[[3]] = { 123, 456, 789 };
389 EOF
390                 if AC_TRY_EVAL(ac_compile) ; then
391                         echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AC_FD_CC
392                         $AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext 2>&AC_FD_CC 1>/dev/null
393                         if test -f conftest.a ; then
394                                 cf_cv_ar_flags=$cf_ar_flags
395                                 break
396                         fi
397                 else
398                         CF_VERBOSE(cannot compile test-program)
399                         break
400                 fi
401         done
402         rm -f conftest.a conftest.$ac_ext conftest.$ac_cv_objext
403 ])
404
405 if test -n "$ARFLAGS" ; then
406         if test -n "$cf_cv_ar_flags" ; then
407                 ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
408         fi
409 else
410         ARFLAGS=$cf_cv_ar_flags
411 fi
412
413 AC_SUBST(ARFLAGS)
414 ])
415 dnl ---------------------------------------------------------------------------
416 dnl CF_BUILD_CC version: 6 updated: 2006/10/14 15:23:15
417 dnl -----------
418 dnl If we're cross-compiling, allow the user to override the tools and their
419 dnl options.  The configure script is oriented toward identifying the host
420 dnl compiler, etc., but we need a build compiler to generate parts of the
421 dnl source.
422 dnl
423 dnl $1 = default for $CPPFLAGS
424 dnl $2 = default for $LIBS
425 AC_DEFUN([CF_BUILD_CC],[
426 AC_REQUIRE([CF_PROG_EXT])
427 if test "$cross_compiling" = yes ; then
428
429         # defaults that we might want to override
430         : ${BUILD_CFLAGS:=''}
431         : ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
432         : ${BUILD_LDFLAGS:=''}
433         : ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
434         : ${BUILD_EXEEXT:='$x'}
435         : ${BUILD_OBJEXT:='o'}
436
437         AC_ARG_WITH(build-cc,
438                 [  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
439                 [BUILD_CC="$withval"],
440                 [AC_CHECK_PROGS(BUILD_CC, gcc cc cl)])
441         AC_MSG_CHECKING(for native build C compiler)
442         AC_MSG_RESULT($BUILD_CC)
443
444         AC_MSG_CHECKING(for native build C preprocessor)
445         AC_ARG_WITH(build-cpp,
446                 [  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
447                 [BUILD_CPP="$withval"],
448                 [BUILD_CPP='${BUILD_CC} -E'])
449         AC_MSG_RESULT($BUILD_CPP)
450
451         AC_MSG_CHECKING(for native build C flags)
452         AC_ARG_WITH(build-cflags,
453                 [  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
454                 [BUILD_CFLAGS="$withval"])
455         AC_MSG_RESULT($BUILD_CFLAGS)
456
457         AC_MSG_CHECKING(for native build C preprocessor-flags)
458         AC_ARG_WITH(build-cppflags,
459                 [  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
460                 [BUILD_CPPFLAGS="$withval"])
461         AC_MSG_RESULT($BUILD_CPPFLAGS)
462
463         AC_MSG_CHECKING(for native build linker-flags)
464         AC_ARG_WITH(build-ldflags,
465                 [  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
466                 [BUILD_LDFLAGS="$withval"])
467         AC_MSG_RESULT($BUILD_LDFLAGS)
468
469         AC_MSG_CHECKING(for native build linker-libraries)
470         AC_ARG_WITH(build-libs,
471                 [  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
472                 [BUILD_LIBS="$withval"])
473         AC_MSG_RESULT($BUILD_LIBS)
474
475         # this assumes we're on Unix.
476         BUILD_EXEEXT=
477         BUILD_OBJEXT=o
478
479         : ${BUILD_CC:='${CC}'}
480
481         if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
482                 AC_MSG_ERROR([Cross-build requires two compilers.
483 Use --with-build-cc to specify the native compiler.])
484         fi
485
486 else
487         : ${BUILD_CC:='${CC}'}
488         : ${BUILD_CPP:='${CPP}'}
489         : ${BUILD_CFLAGS:='${CFLAGS}'}
490         : ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
491         : ${BUILD_LDFLAGS:='${LDFLAGS}'}
492         : ${BUILD_LIBS:='${LIBS}'}
493         : ${BUILD_EXEEXT:='$x'}
494         : ${BUILD_OBJEXT:='o'}
495 fi
496
497 AC_SUBST(BUILD_CC)
498 AC_SUBST(BUILD_CPP)
499 AC_SUBST(BUILD_CFLAGS)
500 AC_SUBST(BUILD_CPPFLAGS)
501 AC_SUBST(BUILD_LDFLAGS)
502 AC_SUBST(BUILD_LIBS)
503 AC_SUBST(BUILD_EXEEXT)
504 AC_SUBST(BUILD_OBJEXT)
505 ])dnl
506 dnl ---------------------------------------------------------------------------
507 dnl CF_CFG_DEFAULTS version: 7 updated: 2005/09/24 16:15:00
508 dnl ---------------
509 dnl Determine the default configuration into which we'll install ncurses.  This
510 dnl can be overridden by the user's command-line options.  There's two items to
511 dnl look for:
512 dnl     1. the prefix (e.g., /usr)
513 dnl     2. the header files (e.g., /usr/include/ncurses)
514 dnl We'll look for a previous installation of ncurses and use the same defaults.
515 dnl
516 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
517 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
518 dnl programs from a vendor's.
519 AC_DEFUN([CF_CFG_DEFAULTS],
520 [
521 AC_MSG_CHECKING(for prefix)
522 if test "x$prefix" = "xNONE" ; then
523         case "$cf_cv_system_name" in
524                 # non-vendor systems don't have a conflict
525         openbsd*|freebsd*|linux*|cygwin*|k*bsd*-gnu)
526                 prefix=/usr
527                 ;;
528         *)      prefix=$ac_default_prefix
529                 ;;
530         esac
531 fi
532 AC_MSG_RESULT($prefix)
533
534 if test "x$prefix" = "xNONE" ; then
535 AC_MSG_CHECKING(for default include-directory)
536 test -n "$verbose" && echo 1>&AC_FD_MSG
537 for cf_symbol in \
538         $includedir \
539         $includedir/ncurses \
540         $prefix/include \
541         $prefix/include/ncurses \
542         /usr/local/include \
543         /usr/local/include/ncurses \
544         /usr/include \
545         /usr/include/ncurses
546 do
547         cf_dir=`eval echo $cf_symbol`
548         if test -f $cf_dir/curses.h ; then
549         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
550                 includedir="$cf_symbol"
551                 test -n "$verbose"  && echo $ac_n "     found " 1>&AC_FD_MSG
552                 break
553         fi
554         fi
555         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
556 done
557 AC_MSG_RESULT($includedir)
558 fi
559 ])dnl
560 dnl ---------------------------------------------------------------------------
561 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
562 dnl --------------
563 dnl Check if we're accidentally using a cache from a different machine.
564 dnl Derive the system name, as a check for reusing the autoconf cache.
565 dnl
566 dnl If we've packaged config.guess and config.sub, run that (since it does a
567 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
568 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
569 dnl which is useful in cross-compiles.
570 dnl
571 dnl Note: we would use $ac_config_sub, but that is one of the places where
572 dnl autoconf 2.5x broke compatibility with autoconf 2.13
573 AC_DEFUN([CF_CHECK_CACHE],
574 [
575 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
576         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
577         system_name="$host_os"
578 else
579         system_name="`(uname -s -r) 2>/dev/null`"
580         if test -z "$system_name" ; then
581                 system_name="`(hostname) 2>/dev/null`"
582         fi
583 fi
584 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
585 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
586
587 test -z "$system_name" && system_name="$cf_cv_system_name"
588 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
589
590 if test ".$system_name" != ".$cf_cv_system_name" ; then
591         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
592         AC_MSG_ERROR("Please remove config.cache and try again.")
593 fi
594 ])dnl
595 dnl ---------------------------------------------------------------------------
596 dnl CF_CURSES_HEADER version: 2 updated: 2010/04/28 06:02:16
597 dnl ----------------
598 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
599 dnl variations of ncurses' installs.
600 dnl
601 dnl $1 = ncurses when looking for ncurses, or is empty
602 AC_DEFUN([CF_CURSES_HEADER],[
603 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
604 cf_cv_ncurses_header=none
605 for cf_header in ifelse($1,,,[ \
606     $1/curses.h \
607         $1/ncurses.h]) \
608         curses.h \
609         ncurses.h ifelse($1,,[ncurses/curses.h ncurses/ncurses.h])
610 do
611 AC_TRY_COMPILE([#include <${cf_header}>],
612         [initscr(); tgoto("?", 0,0)],
613         [cf_cv_ncurses_header=$cf_header; break],[])
614 done
615 ])
616
617 if test "$cf_cv_ncurses_header" = none ; then
618         AC_MSG_ERROR(No curses header-files found)
619 fi
620
621 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
622 AC_CHECK_HEADERS($cf_cv_ncurses_header)
623 ])dnl
624 dnl ---------------------------------------------------------------------------
625 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
626 dnl ----------
627 dnl "dirname" is not portable, so we fake it with a shell script.
628 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
629 dnl ---------------------------------------------------------------------------
630 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
631 dnl ---------------
632 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
633 dnl prefer a standard location, and use -L options only if we do not find the
634 dnl library in the standard library location(s).
635 dnl     $1 = library name
636 dnl     $2 = library class, usually the same as library name
637 dnl     $3 = includes
638 dnl     $4 = code fragment to compile/link
639 dnl     $5 = corresponding function-name
640 dnl     $6 = flag, nonnull if failure should not cause an error-exit
641 dnl
642 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
643 dnl to use a -L option.
644 AC_DEFUN([CF_FIND_LIBRARY],
645 [
646         eval 'cf_cv_have_lib_'$1'=no'
647         cf_libdir=""
648         AC_CHECK_FUNC($5,
649                 eval 'cf_cv_have_lib_'$1'=yes',[
650                 cf_save_LIBS="$LIBS"
651                 AC_MSG_CHECKING(for $5 in -l$1)
652                 LIBS="-l$1 $LIBS"
653                 AC_TRY_LINK([$3],[$4],
654                         [AC_MSG_RESULT(yes)
655                          eval 'cf_cv_have_lib_'$1'=yes'
656                         ],
657                         [AC_MSG_RESULT(no)
658                         CF_LIBRARY_PATH(cf_search,$2)
659                         for cf_libdir in $cf_search
660                         do
661                                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
662                                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
663                                 AC_TRY_LINK([$3],[$4],
664                                         [AC_MSG_RESULT(yes)
665                                          eval 'cf_cv_have_lib_'$1'=yes'
666                                          break],
667                                         [AC_MSG_RESULT(no)
668                                          LIBS="$cf_save_LIBS"])
669                         done
670                         ])
671                 ])
672 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
673 ifelse($6,,[
674 if test $cf_found_library = no ; then
675         AC_MSG_ERROR(Cannot link $1 library)
676 fi
677 ])
678 ])dnl
679 dnl ---------------------------------------------------------------------------
680 dnl CF_FIND_LINKAGE version: 19 updated: 2010/05/29 16:31:02
681 dnl ---------------
682 dnl Find a library (specifically the linkage used in the code fragment),
683 dnl searching for it if it is not already in the library path.
684 dnl See also CF_ADD_SEARCHPATH.
685 dnl
686 dnl Parameters (4-on are optional):
687 dnl     $1 = headers for library entrypoint
688 dnl     $2 = code fragment for library entrypoint
689 dnl     $3 = the library name without the "-l" option or ".so" suffix.
690 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
691 dnl     $5 = action to perform if not successful
692 dnl     $6 = module name, if not the same as the library name
693 dnl     $7 = extra libraries
694 dnl
695 dnl Sets these variables:
696 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
697 dnl     $cf_cv_header_path_$3 - include-directory if needed
698 dnl     $cf_cv_library_path_$3 - library-directory if needed
699 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
700 AC_DEFUN([CF_FIND_LINKAGE],[
701
702 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
703 # will be set on completion of the AC_TRY_LINK below.
704 cf_cv_header_path_$3=
705 cf_cv_library_path_$3=
706
707 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
708
709 cf_save_LIBS="$LIBS"
710
711 AC_TRY_LINK([$1],[$2],[
712         cf_cv_find_linkage_$3=yes
713         cf_cv_header_path_$3=/usr/include
714         cf_cv_library_path_$3=/usr/lib
715 ],[
716
717 LIBS="-l$3 $7 $cf_save_LIBS"
718
719 AC_TRY_LINK([$1],[$2],[
720         cf_cv_find_linkage_$3=yes
721         cf_cv_header_path_$3=/usr/include
722         cf_cv_library_path_$3=/usr/lib
723         cf_cv_library_file_$3="-l$3"
724 ],[
725         cf_cv_find_linkage_$3=no
726         LIBS="$cf_save_LIBS"
727
728     CF_VERBOSE(find linkage for $3 library)
729     CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
730
731     cf_save_CPPFLAGS="$CPPFLAGS"
732     cf_test_CPPFLAGS="$CPPFLAGS"
733
734     CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
735     for cf_cv_header_path_$3 in $cf_search
736     do
737       if test -d $cf_cv_header_path_$3 ; then
738         CF_VERBOSE(... testing $cf_cv_header_path_$3)
739         CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
740         AC_TRY_COMPILE([$1],[$2],[
741             CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
742             cf_cv_find_linkage_$3=maybe
743             cf_test_CPPFLAGS="$CPPFLAGS"
744             break],[
745             CPPFLAGS="$cf_save_CPPFLAGS"
746             ])
747       fi
748     done
749
750     if test "$cf_cv_find_linkage_$3" = maybe ; then
751
752       CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
753
754       cf_save_LIBS="$LIBS"
755       cf_save_LDFLAGS="$LDFLAGS"
756
757       ifelse([$6],,,[
758         CPPFLAGS="$cf_test_CPPFLAGS"
759         LIBS="-l$3 $7 $cf_save_LIBS"
760         AC_TRY_LINK([$1],[$2],[
761             CF_VERBOSE(... found $3 library in system)
762             cf_cv_find_linkage_$3=yes])
763             CPPFLAGS="$cf_save_CPPFLAGS"
764             LIBS="$cf_save_LIBS"
765             ])
766
767       if test "$cf_cv_find_linkage_$3" != yes ; then
768         CF_LIBRARY_PATH(cf_search,$3)
769         for cf_cv_library_path_$3 in $cf_search
770         do
771           if test -d $cf_cv_library_path_$3 ; then
772             CF_VERBOSE(... testing $cf_cv_library_path_$3)
773             CPPFLAGS="$cf_test_CPPFLAGS"
774             LIBS="-l$3 $7 $cf_save_LIBS"
775             LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
776             AC_TRY_LINK([$1],[$2],[
777                 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
778                 cf_cv_find_linkage_$3=yes
779                 cf_cv_library_file_$3="-l$3"
780                 break],[
781                 CPPFLAGS="$cf_save_CPPFLAGS"
782                 LIBS="$cf_save_LIBS"
783                 LDFLAGS="$cf_save_LDFLAGS"
784                 ])
785           fi
786         done
787         CPPFLAGS="$cf_save_CPPFLAGS"
788         LDFLAGS="$cf_save_LDFLAGS"
789       fi
790
791     else
792       cf_cv_find_linkage_$3=no
793     fi
794     ],$7)
795 ])
796
797 LIBS="$cf_save_LIBS"
798
799 if test "$cf_cv_find_linkage_$3" = yes ; then
800 ifelse([$4],,[
801         CF_ADD_INCDIR($cf_cv_header_path_$3)
802         CF_ADD_LIBDIR($cf_cv_library_path_$3)
803         CF_ADD_LIB($3)
804 ],[$4])
805 else
806 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
807 fi
808 ])dnl
809 dnl ---------------------------------------------------------------------------
810 dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
811 dnl -----------------
812 dnl Test for availability of useful gcc __attribute__ directives to quiet
813 dnl compiler warnings.  Though useful, not all are supported -- and contrary
814 dnl to documentation, unrecognized directives cause older compilers to barf.
815 AC_DEFUN([CF_GCC_ATTRIBUTES],
816 [
817 if test "$GCC" = yes
818 then
819 cat > conftest.i <<EOF
820 #ifndef GCC_PRINTF
821 #define GCC_PRINTF 0
822 #endif
823 #ifndef GCC_SCANF
824 #define GCC_SCANF 0
825 #endif
826 #ifndef GCC_NORETURN
827 #define GCC_NORETURN /* nothing */
828 #endif
829 #ifndef GCC_UNUSED
830 #define GCC_UNUSED /* nothing */
831 #endif
832 EOF
833 if test "$GCC" = yes
834 then
835         AC_CHECKING([for $CC __attribute__ directives])
836 cat > conftest.$ac_ext <<EOF
837 #line __oline__ "${as_me:-configure}"
838 #include "confdefs.h"
839 #include "conftest.h"
840 #include "conftest.i"
841 #if     GCC_PRINTF
842 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
843 #else
844 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
845 #endif
846 #if     GCC_SCANF
847 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
848 #else
849 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
850 #endif
851 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
852 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
853 extern void foo(void) GCC_NORETURN;
854 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
855 EOF
856         cf_printf_attribute=no
857         cf_scanf_attribute=no
858         for cf_attribute in scanf printf unused noreturn
859         do
860                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
861                 cf_directive="__attribute__(($cf_attribute))"
862                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
863
864                 case $cf_attribute in #(vi
865                 printf) #(vi
866                         cf_printf_attribute=yes
867                         cat >conftest.h <<EOF
868 #define GCC_$cf_ATTRIBUTE 1
869 EOF
870                         ;;
871                 scanf) #(vi
872                         cf_scanf_attribute=yes
873                         cat >conftest.h <<EOF
874 #define GCC_$cf_ATTRIBUTE 1
875 EOF
876                         ;;
877                 *) #(vi
878                         cat >conftest.h <<EOF
879 #define GCC_$cf_ATTRIBUTE $cf_directive
880 EOF
881                         ;;
882                 esac
883
884                 if AC_TRY_EVAL(ac_compile); then
885                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
886                         cat conftest.h >>confdefs.h
887                         case $cf_attribute in #(vi
888                         printf) #(vi
889                                 if test "$cf_printf_attribute" = no ; then
890                                         cat >>confdefs.h <<EOF
891 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
892 EOF
893                                 else
894                                         cat >>confdefs.h <<EOF
895 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
896 EOF
897                                 fi
898                                 ;;
899                         scanf) #(vi
900                                 if test "$cf_scanf_attribute" = no ; then
901                                         cat >>confdefs.h <<EOF
902 #define GCC_SCANFLIKE(fmt,var) /* nothing */
903 EOF
904                                 else
905                                         cat >>confdefs.h <<EOF
906 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
907 EOF
908                                 fi
909                                 ;;
910                         esac
911                 fi
912         done
913 else
914         fgrep define conftest.i >>confdefs.h
915 fi
916 rm -rf conftest*
917 fi
918 ])dnl
919 dnl ---------------------------------------------------------------------------
920 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
921 dnl --------------
922 dnl Find version of gcc
923 AC_DEFUN([CF_GCC_VERSION],[
924 AC_REQUIRE([AC_PROG_CC])
925 GCC_VERSION=none
926 if test "$GCC" = yes ; then
927         AC_MSG_CHECKING(version of $CC)
928         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
929         test -z "$GCC_VERSION" && GCC_VERSION=unknown
930         AC_MSG_RESULT($GCC_VERSION)
931 fi
932 ])dnl
933 dnl ---------------------------------------------------------------------------
934 dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
935 dnl ---------------
936 dnl Check if the compiler supports useful warning options.  There's a few that
937 dnl we don't use, simply because they're too noisy:
938 dnl
939 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
940 dnl     -Wredundant-decls (system headers make this too noisy)
941 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
942 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
943 dnl             is enabled for ncurses using "--enable-const".
944 dnl     -pedantic
945 dnl
946 dnl Parameter:
947 dnl     $1 is an optional list of gcc warning flags that a particular
948 dnl             application might want to use, e.g., "no-unused" for
949 dnl             -Wno-unused
950 dnl Special:
951 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
952 dnl
953 AC_DEFUN([CF_GCC_WARNINGS],
954 [
955 AC_REQUIRE([CF_GCC_VERSION])
956 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
957
958 cat > conftest.$ac_ext <<EOF
959 #line __oline__ "${as_me:-configure}"
960 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
961 EOF
962
963 if test "$INTEL_COMPILER" = yes
964 then
965 # The "-wdXXX" options suppress warnings:
966 # remark #1419: external declaration in primary source file
967 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
968 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
969 # remark #193: zero used for undefined preprocessing identifier
970 # remark #593: variable "curs_sb_left_arrow" was set but never used
971 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
972 # remark #869: parameter "tw" was never referenced
973 # remark #981: operands are evaluated in unspecified order
974 # warning #279: controlling expression is constant
975
976         AC_CHECKING([for $CC warning options])
977         cf_save_CFLAGS="$CFLAGS"
978         EXTRA_CFLAGS="-Wall"
979         for cf_opt in \
980                 wd1419 \
981                 wd1683 \
982                 wd1684 \
983                 wd193 \
984                 wd593 \
985                 wd279 \
986                 wd810 \
987                 wd869 \
988                 wd981
989         do
990                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
991                 if AC_TRY_EVAL(ac_compile); then
992                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
993                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
994                 fi
995         done
996         CFLAGS="$cf_save_CFLAGS"
997
998 elif test "$GCC" = yes
999 then
1000         AC_CHECKING([for $CC warning options])
1001         cf_save_CFLAGS="$CFLAGS"
1002         EXTRA_CFLAGS=
1003         cf_warn_CONST=""
1004         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1005         for cf_opt in W Wall \
1006                 Wbad-function-cast \
1007                 Wcast-align \
1008                 Wcast-qual \
1009                 Winline \
1010                 Wmissing-declarations \
1011                 Wmissing-prototypes \
1012                 Wnested-externs \
1013                 Wpointer-arith \
1014                 Wshadow \
1015                 Wstrict-prototypes \
1016                 Wundef $cf_warn_CONST $1
1017         do
1018                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1019                 if AC_TRY_EVAL(ac_compile); then
1020                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1021                         case $cf_opt in #(vi
1022                         Wcast-qual) #(vi
1023                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1024                                 ;;
1025                         Winline) #(vi
1026                                 case $GCC_VERSION in
1027                                 [[34]].*)
1028                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1029                                         continue;;
1030                                 esac
1031                                 ;;
1032                         esac
1033                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1034                 fi
1035         done
1036         CFLAGS="$cf_save_CFLAGS"
1037 fi
1038 rm -rf conftest*
1039
1040 AC_SUBST(EXTRA_CFLAGS)
1041 ])dnl
1042 dnl ---------------------------------------------------------------------------
1043 dnl CF_GNAT_GENERICS version: 2 updated: 2011/03/23 20:24:41
1044 dnl ----------------
1045 AC_DEFUN([CF_GNAT_GENERICS],
1046 [
1047 AC_REQUIRE([CF_GNAT_VERSION])
1048
1049 AC_MSG_CHECKING(if GNAT supports generics)
1050 case $cf_gnat_version in #(vi
1051 3.[[1-9]]*|[[4-9]].*) #(vi
1052         cf_gnat_generics=yes
1053         ;;
1054 *)
1055         cf_gnat_generics=no
1056         ;;
1057 esac
1058 AC_MSG_RESULT($cf_gnat_generics)
1059
1060 if test "$cf_gnat_generics" = yes
1061 then
1062         cf_compile_generics=generics
1063         cf_generic_objects="\${GENOBJS}"
1064 else
1065         cf_compile_generics=
1066         cf_generic_objects=
1067 fi
1068
1069 AC_SUBST(cf_compile_generics)
1070 AC_SUBST(cf_generic_objects)
1071 ])dnl
1072 dnl ---------------------------------------------------------------------------
1073 dnl CF_GNAT_SIGINT version: 1 updated: 2011/03/27 20:07:59
1074 dnl --------------
1075 dnl Check if gnat supports SIGINT, and presumably tasking.  For the latter, it
1076 dnl is noted that gnat may compile a tasking unit even for configurations which
1077 dnl fail at runtime.
1078 AC_DEFUN([CF_GNAT_SIGINT],[
1079 AC_CACHE_CHECK(if GNAT supports SIGINT,cf_cv_gnat_sigint,[
1080 CF_GNAT_TRY_LINK([with Ada.Interrupts.Names;
1081
1082 package ConfTest is
1083
1084    pragma Warnings (Off);  --  the next pragma exists since 3.11p
1085    pragma Unreserve_All_Interrupts;
1086    pragma Warnings (On);
1087
1088    protected Process is
1089       procedure Stop;
1090       function Continue return Boolean;
1091       pragma Attach_Handler (Stop, Ada.Interrupts.Names.SIGINT);
1092    private
1093       Done : Boolean := False;
1094    end Process;
1095
1096 end ConfTest;],
1097 [package body ConfTest is
1098    protected body Process is
1099       procedure Stop is
1100       begin
1101          Done := True;
1102       end Stop;
1103       function Continue return Boolean is
1104       begin
1105          return not Done;
1106       end Continue;
1107    end Process;
1108 end ConfTest;],
1109         [cf_cv_gnat_sigint=yes],
1110         [cf_cv_gnat_sigint=no])])
1111
1112 if test $cf_cv_gnat_sigint = yes ; then
1113         USE_GNAT_SIGINT=""
1114 else
1115         USE_GNAT_SIGINT="#"
1116 fi
1117 AC_SUBST(USE_GNAT_SIGINT)
1118 ])dnl
1119 dnl ---------------------------------------------------------------------------
1120 dnl CF_GNAT_PRAGMA_UNREF version: 1 updated: 2010/06/19 15:22:18
1121 dnl --------------------
1122 dnl Check if the gnat pragma "Unreferenced" works.
1123 AC_DEFUN([CF_GNAT_PRAGMA_UNREF],[
1124 AC_CACHE_CHECK(if GNAT pragma Unreferenced works,cf_cv_pragma_unreferenced,[
1125 CF_GNAT_TRY_LINK([procedure conftest;],
1126 [with Text_IO;
1127 with GNAT.OS_Lib;
1128 procedure conftest is
1129    test : Integer;
1130    pragma Unreferenced (test);
1131 begin
1132    test := 1;
1133    Text_IO.Put ("Hello World");
1134    Text_IO.New_Line;
1135    GNAT.OS_Lib.OS_Exit (0);
1136 end conftest;],
1137         [cf_cv_pragma_unreferenced=yes],
1138         [cf_cv_pragma_unreferenced=no])])
1139
1140 # if the pragma is supported, use it (needed in the Trace code).
1141 if test $cf_cv_pragma_unreferenced = yes ; then
1142         PRAGMA_UNREF=TRUE
1143 else
1144         PRAGMA_UNREF=FALSE
1145 fi
1146 AC_SUBST(PRAGMA_UNREF)
1147 ])dnl
1148 dnl ---------------------------------------------------------------------------
1149 dnl CF_GNAT_PROJECTS version: 2 updated: 2011/03/23 20:24:41
1150 dnl ----------------
1151 dnl GNAT projects are configured with ".gpr" project files.
1152 dnl GNAT libraries are a further development, using the project feature.
1153 AC_DEFUN([CF_GNAT_PROJECTS],
1154 [
1155 AC_REQUIRE([CF_GNAT_VERSION])
1156
1157 cf_gnat_libraries=no
1158 cf_gnat_projects=no
1159
1160 AC_MSG_CHECKING(if GNAT supports project files)
1161 case $cf_gnat_version in #(vi
1162 3.[[0-9]]*) #(vi
1163         ;;
1164 *)
1165         case $cf_cv_system_name in #(vi
1166         cygwin*) #(vi
1167                 ;;
1168         *)
1169                 mkdir conftest.src conftest.bin conftest.lib
1170                 cd conftest.src
1171                 rm -rf conftest* *~conftest*
1172                 cat >>library.gpr <<CF_EOF
1173 project Library is
1174   Kind := External ("LIB_KIND");
1175   for Library_Name use "ConfTest";
1176   for Object_Dir use ".";
1177   for Library_ALI_Dir use External("LIBRARY_DIR");
1178   for Library_Version use External ("SONAME");
1179   for Library_Kind use Kind;
1180   for Library_Dir use External("BUILD_DIR");
1181   Source_Dir := External ("SOURCE_DIR");
1182   for Source_Dirs use (Source_Dir);
1183   package Compiler is
1184      for Default_Switches ("Ada") use
1185        ("-g",
1186         "-O2",
1187         "-gnatafno",
1188         "-gnatVa",   -- All validity checks
1189         "-gnatwa");  -- Activate all optional errors
1190   end Compiler;
1191 end Library;
1192 CF_EOF
1193                 cat >>confpackage.ads <<CF_EOF
1194 package ConfPackage is
1195    procedure conftest;
1196 end ConfPackage;
1197 CF_EOF
1198                 cat >>confpackage.adb <<CF_EOF
1199 with Text_IO;
1200 package body ConfPackage is
1201    procedure conftest is
1202    begin
1203       Text_IO.Put ("Hello World");
1204       Text_IO.New_Line;
1205    end conftest;
1206 end ConfPackage;
1207 CF_EOF
1208                 if ( $cf_ada_make $ADAFLAGS \
1209                                 -Plibrary.gpr \
1210                                 -XBUILD_DIR=`cd ../conftest.bin;pwd` \
1211                                 -XLIBRARY_DIR=`cd ../conftest.lib;pwd` \
1212                                 -XSOURCE_DIR=`pwd` \
1213                                 -XSONAME=libConfTest.so.1 \
1214                                 -XLIB_KIND=static 1>&AC_FD_CC 2>&1 ) ; then
1215                         cf_gnat_projects=yes
1216                 fi
1217                 cd ..
1218                 if test -f conftest.lib/confpackage.ali
1219                 then
1220                         cf_gnat_libraries=yes
1221                 fi
1222                 rm -rf conftest* *~conftest*
1223                 ;;
1224         esac
1225         ;;
1226 esac
1227 AC_MSG_RESULT($cf_gnat_projects)
1228
1229 if test $cf_gnat_projects = yes
1230 then
1231         AC_MSG_CHECKING(if GNAT supports libraries)
1232         AC_MSG_RESULT($cf_gnat_libraries)
1233 fi
1234
1235 if test "$cf_gnat_projects" = yes
1236 then
1237         USE_OLD_MAKERULES="#"
1238         USE_GNAT_PROJECTS=""
1239 else
1240         USE_OLD_MAKERULES=""
1241         USE_GNAT_PROJECTS="#"
1242 fi
1243
1244 if test "$cf_gnat_libraries" = yes
1245 then
1246         USE_GNAT_LIBRARIES=""
1247 else
1248         USE_GNAT_LIBRARIES="#"
1249 fi
1250
1251 AC_SUBST(USE_OLD_MAKERULES)
1252 AC_SUBST(USE_GNAT_PROJECTS)
1253 AC_SUBST(USE_GNAT_LIBRARIES)
1254 ])dnl
1255 dnl ---------------------------------------------------------------------------
1256 dnl CF_GNAT_TRY_LINK version: 3 updated: 2011/03/19 14:47:45
1257 dnl ----------------
1258 dnl Verify that a test program compiles/links with GNAT.
1259 dnl $cf_ada_make is set to the program that compiles/links
1260 dnl $ADAFLAGS may be set to the GNAT flags.
1261 dnl
1262 dnl $1 is the text of the spec
1263 dnl $2 is the text of the body
1264 dnl $3 is the shell command to execute if successful
1265 dnl $4 is the shell command to execute if not successful
1266 AC_DEFUN([CF_GNAT_TRY_LINK],
1267 [
1268 rm -rf conftest* *~conftest*
1269 cat >>conftest.ads <<CF_EOF
1270 $1
1271 CF_EOF
1272 cat >>conftest.adb <<CF_EOF
1273 $2
1274 CF_EOF
1275 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1276 ifelse($3,,      :,[      $3])
1277 ifelse($4,,,[else
1278    $4])
1279 fi
1280 rm -rf conftest* *~conftest*
1281 ])dnl
1282 dnl ---------------------------------------------------------------------------
1283 dnl CF_GNAT_TRY_RUN version: 5 updated: 2011/03/19 14:47:45
1284 dnl ---------------
1285 dnl Verify that a test program compiles and runs with GNAT
1286 dnl $cf_ada_make is set to the program that compiles/links
1287 dnl $ADAFLAGS may be set to the GNAT flags.
1288 dnl
1289 dnl $1 is the text of the spec
1290 dnl $2 is the text of the body
1291 dnl $3 is the shell command to execute if successful
1292 dnl $4 is the shell command to execute if not successful
1293 AC_DEFUN([CF_GNAT_TRY_RUN],
1294 [
1295 rm -rf conftest* *~conftest*
1296 cat >>conftest.ads <<CF_EOF
1297 $1
1298 CF_EOF
1299 cat >>conftest.adb <<CF_EOF
1300 $2
1301 CF_EOF
1302 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1303    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
1304 ifelse($3,,      :,[      $3])
1305 ifelse($4,,,[   else
1306       $4])
1307    fi
1308 ifelse($4,,,[else
1309    $4])
1310 fi
1311 rm -rf conftest* *~conftest*
1312 ])dnl
1313 dnl ---------------------------------------------------------------------------
1314 dnl CF_GNAT_VERSION version: 17 updated: 2011/03/23 20:24:41
1315 dnl ---------------
1316 dnl Verify version of GNAT.
1317 AC_DEFUN([CF_GNAT_VERSION],
1318 [
1319 AC_MSG_CHECKING(for gnat version)
1320 cf_gnat_version=`${cf_ada_make:-gnatmake} -v 2>&1 | \
1321         grep '[[0-9]].[[0-9]][[0-9]]*' |\
1322     sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
1323 AC_MSG_RESULT($cf_gnat_version)
1324
1325 case $cf_gnat_version in #(vi
1326 3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*) #(vi
1327         cf_cv_prog_gnat_correct=yes
1328         ;;
1329 *)
1330         AC_MSG_WARN(Unsupported GNAT version $cf_gnat_version. We require 3.11 or better. Disabling Ada95 binding.)
1331         cf_cv_prog_gnat_correct=no
1332         ;;
1333 esac
1334 ])
1335 dnl ---------------------------------------------------------------------------
1336 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1337 dnl -------------
1338 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1339 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1340 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1341 dnl since it is interwoven with GNU extensions.
1342 dnl
1343 dnl Well, yes we could work around it...
1344 AC_DEFUN([CF_GNU_SOURCE],
1345 [
1346 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1347 AC_TRY_COMPILE([#include <sys/types.h>],[
1348 #ifndef _XOPEN_SOURCE
1349 make an error
1350 #endif],
1351         [cf_cv_gnu_source=no],
1352         [cf_save="$CPPFLAGS"
1353          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1354          AC_TRY_COMPILE([#include <sys/types.h>],[
1355 #ifdef _XOPEN_SOURCE
1356 make an error
1357 #endif],
1358         [cf_cv_gnu_source=no],
1359         [cf_cv_gnu_source=yes])
1360         CPPFLAGS="$cf_save"
1361         ])
1362 ])
1363 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1364 ])dnl
1365 dnl ---------------------------------------------------------------------------
1366 dnl CF_HEADER_PATH version: 12 updated: 2010/05/05 05:22:40
1367 dnl --------------
1368 dnl Construct a search-list of directories for a nonstandard header-file
1369 dnl
1370 dnl Parameters
1371 dnl     $1 = the variable to return as result
1372 dnl     $2 = the package name
1373 AC_DEFUN([CF_HEADER_PATH],
1374 [
1375 $1=
1376
1377 # collect the current set of include-directories from compiler flags
1378 cf_header_path_list=""
1379 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1380         for cf_header_path in $CPPFLAGS $CFLAGS
1381         do
1382                 case $cf_header_path in #(vi
1383                 -I*)
1384                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1385                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1386                         cf_header_path_list="$cf_header_path_list [$]$1"
1387                         ;;
1388                 esac
1389         done
1390 fi
1391
1392 # add the variations for the package we are looking for
1393 CF_SUBDIR_PATH($1,$2,include)
1394
1395 test "$includedir" != NONE && \
1396 test "$includedir" != "/usr/include" && \
1397 test -d "$includedir" && {
1398         test -d $includedir &&    $1="[$]$1 $includedir"
1399         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1400 }
1401
1402 test "$oldincludedir" != NONE && \
1403 test "$oldincludedir" != "/usr/include" && \
1404 test -d "$oldincludedir" && {
1405         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
1406         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1407 }
1408
1409 $1="[$]$1 $cf_header_path_list"
1410 ])dnl
1411 dnl ---------------------------------------------------------------------------
1412 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1413 dnl ---------------
1414 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1415 AC_DEFUN([CF_HELP_MESSAGE],
1416 [AC_DIVERT_HELP([$1])dnl
1417 ])dnl
1418 dnl ---------------------------------------------------------------------------
1419 dnl CF_INCLUDE_DIRS version: 6 updated: 2009/01/06 19:37:40
1420 dnl ---------------
1421 dnl Construct the list of include-options according to whether we're building
1422 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
1423 dnl with gcc, don't append the includedir if it happens to be /usr/include,
1424 dnl since that usually breaks gcc's shadow-includes.
1425 AC_DEFUN([CF_INCLUDE_DIRS],
1426 [
1427 CPPFLAGS="$CPPFLAGS -I. -I../include"
1428 if test "$srcdir" != "."; then
1429         CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
1430 fi
1431 if test "$GCC" != yes; then
1432         CPPFLAGS="$CPPFLAGS -I\${includedir}"
1433 elif test "$includedir" != "/usr/include"; then
1434         if test "$includedir" = '${prefix}/include' ; then
1435                 if test $prefix != /usr ; then
1436                         CPPFLAGS="$CPPFLAGS -I\${includedir}"
1437                 fi
1438         else
1439                 CPPFLAGS="$CPPFLAGS -I\${includedir}"
1440         fi
1441 fi
1442 AC_SUBST(CPPFLAGS)
1443 ])dnl
1444 dnl ---------------------------------------------------------------------------
1445 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
1446 dnl -----------------
1447 dnl Check if the given compiler is really the Intel compiler for Linux.  It
1448 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1449 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1450 dnl
1451 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1452 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1453 dnl the wrappers for gcc and g++ warnings.
1454 dnl
1455 dnl $1 = GCC (default) or GXX
1456 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1457 dnl $3 = CFLAGS (default) or CXXFLAGS
1458 AC_DEFUN([CF_INTEL_COMPILER],[
1459 ifelse([$2],,INTEL_COMPILER,[$2])=no
1460
1461 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1462         case $host_os in
1463         linux*|gnu*)
1464                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1465                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1466                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1467                 AC_TRY_COMPILE([],[
1468 #ifdef __INTEL_COMPILER
1469 #else
1470 make an error
1471 #endif
1472 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1473 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1474 ],[])
1475                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1476                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1477                 ;;
1478         esac
1479 fi
1480 ])dnl
1481 dnl ---------------------------------------------------------------------------
1482 dnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
1483 dnl ------------
1484 dnl Add checks for large file support.
1485 AC_DEFUN([CF_LARGEFILE],[
1486 ifdef([AC_FUNC_FSEEKO],[
1487     AC_SYS_LARGEFILE
1488     if test "$enable_largefile" != no ; then
1489         AC_FUNC_FSEEKO
1490
1491         # Normally we would collect these definitions in the config.h,
1492         # but (like _XOPEN_SOURCE), some environments rely on having these
1493         # defined before any of the system headers are included.  Another
1494         # case comes up with C++, e.g., on AIX the compiler compiles the
1495         # header files by themselves before looking at the body files it is
1496         # told to compile.  For ncurses, those header files do not include
1497         # the config.h
1498         test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
1499         test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
1500         test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
1501
1502         AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
1503                 AC_TRY_COMPILE([
1504 #include <sys/types.h>
1505 #include <dirent.h>
1506                 ],[
1507                 /* if transitional largefile support is setup, this is true */
1508                 extern struct dirent64 * readdir(DIR *);
1509                 struct dirent64 *x = readdir((DIR *)0);
1510                 struct dirent *y = readdir((DIR *)0);
1511                 int z = x - y;
1512                 ],
1513                 [cf_cv_struct_dirent64=yes],
1514                 [cf_cv_struct_dirent64=no])
1515         ])
1516         test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
1517     fi
1518 ])
1519 ])
1520 dnl ---------------------------------------------------------------------------
1521 dnl CF_LD_RPATH_OPT version: 3 updated: 2010/06/02 05:03:05
1522 dnl ---------------
1523 dnl For the given system and compiler, find the compiler flags to pass to the
1524 dnl loader to use the "rpath" feature.
1525 AC_DEFUN([CF_LD_RPATH_OPT],
1526 [
1527 AC_REQUIRE([CF_CHECK_CACHE])
1528
1529 LD_RPATH_OPT=
1530 AC_MSG_CHECKING(for an rpath option)
1531 case $cf_cv_system_name in #(vi
1532 irix*) #(vi
1533         if test "$GCC" = yes; then
1534                 LD_RPATH_OPT="-Wl,-rpath,"
1535         else
1536                 LD_RPATH_OPT="-rpath "
1537         fi
1538         ;;
1539 linux*|gnu*|k*bsd*-gnu) #(vi
1540         LD_RPATH_OPT="-Wl,-rpath,"
1541         ;;
1542 openbsd[[2-9]].*) #(vi
1543         LD_RPATH_OPT="-Wl,-rpath,"
1544         ;;
1545 freebsd*) #(vi
1546         LD_RPATH_OPT="-rpath "
1547         ;;
1548 netbsd*) #(vi
1549         LD_RPATH_OPT="-Wl,-rpath,"
1550         ;;
1551 osf*|mls+*) #(vi
1552         LD_RPATH_OPT="-rpath "
1553         ;;
1554 solaris2*) #(vi
1555         LD_RPATH_OPT="-R"
1556         ;;
1557 *)
1558         ;;
1559 esac
1560 AC_MSG_RESULT($LD_RPATH_OPT)
1561
1562 case "x$LD_RPATH_OPT" in #(vi
1563 x-R*)
1564         AC_MSG_CHECKING(if we need a space after rpath option)
1565         cf_save_LIBS="$LIBS"
1566         CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
1567         AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1568         LIBS="$cf_save_LIBS"
1569         AC_MSG_RESULT($cf_rpath_space)
1570         test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
1571         ;;
1572 esac
1573 ])dnl
1574 dnl ---------------------------------------------------------------------------
1575 dnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
1576 dnl ---------------
1577 dnl Construct a search-list of directories for a nonstandard library-file
1578 dnl
1579 dnl Parameters
1580 dnl     $1 = the variable to return as result
1581 dnl     $2 = the package name
1582 AC_DEFUN([CF_LIBRARY_PATH],
1583 [
1584 $1=
1585 cf_library_path_list=""
1586 if test -n "${LDFLAGS}${LIBS}" ; then
1587         for cf_library_path in $LDFLAGS $LIBS
1588         do
1589                 case $cf_library_path in #(vi
1590                 -L*)
1591                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
1592                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
1593                         cf_library_path_list="$cf_library_path_list [$]$1"
1594                         ;;
1595                 esac
1596         done
1597 fi
1598
1599 CF_SUBDIR_PATH($1,$2,lib)
1600
1601 $1="$cf_library_path_list [$]$1"
1602 ])dnl
1603 dnl ---------------------------------------------------------------------------
1604 dnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16
1605 dnl -------------
1606 dnl Compute the library-prefix for the given host system
1607 dnl $1 = variable to set
1608 AC_DEFUN([CF_LIB_PREFIX],
1609 [
1610         case $cf_cv_system_name in #(vi
1611         OS/2*|os2*) #(vi
1612         LIB_PREFIX=''
1613         ;;
1614         *)      LIB_PREFIX='lib'
1615         ;;
1616         esac
1617 ifelse($1,,,[$1=$LIB_PREFIX])
1618         AC_SUBST(LIB_PREFIX)
1619 ])dnl
1620 dnl ---------------------------------------------------------------------------
1621 dnl CF_LIB_SONAME version: 5 updated: 2010/08/14 18:25:37
1622 dnl -------------
1623 dnl Find the and soname for the given shared library.  Set the cache variable
1624 dnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
1625 dnl variable to "unknown".
1626 dnl
1627 dnl $1 = headers
1628 dnl $2 = code
1629 dnl $3 = library name
1630 AC_DEFUN([CF_LIB_SONAME],
1631 [
1632 AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
1633
1634 cf_cv_$3_soname=unknown
1635 if test "$cross_compiling" != yes ; then
1636 cat >conftest.$ac_ext <<CF_EOF
1637 $1
1638 int main()
1639 {
1640 $2
1641         ${cf_cv_main_return:-return}(0);
1642 }
1643 CF_EOF
1644 cf_save_LIBS="$LIBS"
1645         CF_ADD_LIB($3)
1646         if AC_TRY_EVAL(ac_compile) ; then
1647                 if AC_TRY_EVAL(ac_link) ; then
1648                         cf_cv_$3_soname=`ldd conftest$ac_exeext 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | fgrep lib$3.`
1649                         test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
1650                 fi
1651         fi
1652 rm -rf conftest*
1653 LIBS="$cf_save_LIBS"
1654 fi
1655 ])
1656 ])
1657 dnl ---------------------------------------------------------------------------
1658 dnl CF_LIB_SUFFIX version: 16 updated: 2008/12/27 12:30:03
1659 dnl -------------
1660 dnl Compute the library file-suffix from the given model name
1661 dnl $1 = model name
1662 dnl $2 = variable to set (the nominal library suffix)
1663 dnl $3 = dependency variable to set (actual filename)
1664 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1665 AC_DEFUN([CF_LIB_SUFFIX],
1666 [
1667         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1668         case $1 in #(vi
1669         libtool) #(vi
1670                 $2='.la'
1671                 $3=[$]$2
1672                 ;;
1673         normal) #(vi
1674                 $2='.a'
1675                 $3=[$]$2
1676                 ;;
1677         debug) #(vi
1678                 $2='_g.a'
1679                 $3=[$]$2
1680                 ;;
1681         profile) #(vi
1682                 $2='_p.a'
1683                 $3=[$]$2
1684                 ;;
1685         shared) #(vi
1686                 case $cf_cv_system_name in
1687                 aix[[56]]*) #(vi
1688                         $2='.a'
1689                         $3=[$]$2
1690                         ;;
1691                 cygwin*) #(vi
1692                         $2='.dll'
1693                         $3='.dll.a'
1694                         ;;
1695                 darwin*) #(vi
1696                         $2='.dylib'
1697                         $3=[$]$2
1698                         ;;
1699                 hpux*) #(vi
1700                         case $target in
1701                         ia64*) #(vi
1702                                 $2='.so'
1703                                 $3=[$]$2
1704                                 ;;
1705                         *) #(vi
1706                                 $2='.sl'
1707                                 $3=[$]$2
1708                                 ;;
1709                         esac
1710                         ;;
1711                 *)      $2='.so'
1712                         $3=[$]$2
1713                         ;;
1714                 esac
1715         esac
1716         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1717         test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}"
1718 ])dnl
1719 dnl ---------------------------------------------------------------------------
1720 dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
1721 dnl -----------
1722 dnl Compute the string to append to -library from the given model name
1723 dnl $1 = model name
1724 dnl $2 = variable to set
1725 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1726 AC_DEFUN([CF_LIB_TYPE],
1727 [
1728         case $1 in
1729         libtool) $2=''   ;;
1730         normal)  $2=''   ;;
1731         debug)   $2='_g' ;;
1732         profile) $2='_p' ;;
1733         shared)  $2=''   ;;
1734         esac
1735         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1736 ])dnl
1737 dnl ---------------------------------------------------------------------------
1738 dnl CF_LINK_DATAONLY version: 9 updated: 2009/01/01 20:21:38
1739 dnl ----------------
1740 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
1741 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
1742 dnl have to provide wrappers for global tables to ensure they're linked
1743 dnl properly.
1744 AC_DEFUN([CF_LINK_DATAONLY],
1745 [
1746 AC_MSG_CHECKING([if data-only library module links])
1747 AC_CACHE_VAL(cf_cv_link_dataonly,[
1748         rm -f conftest.a
1749         cat >conftest.$ac_ext <<EOF
1750 #line __oline__ "configure"
1751 int     testdata[[3]] = { 123, 456, 789 };
1752 EOF
1753         if AC_TRY_EVAL(ac_compile) ; then
1754                 mv conftest.o data.o && \
1755                 ( $AR $ARFLAGS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
1756         fi
1757         rm -f conftest.$ac_ext data.o
1758         cat >conftest.$ac_ext <<EOF
1759 #line __oline__ "configure"
1760 int     testfunc()
1761 {
1762 #if defined(NeXT)
1763         ${cf_cv_main_return:-return}(1);        /* I'm told this linker is broken */
1764 #else
1765         extern int testdata[[3]];
1766         return testdata[[0]] == 123
1767            &&  testdata[[1]] == 456
1768            &&  testdata[[2]] == 789;
1769 #endif
1770 }
1771 EOF
1772         if AC_TRY_EVAL(ac_compile); then
1773                 mv conftest.o func.o && \
1774                 ( $AR $ARFLAGS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
1775         fi
1776         rm -f conftest.$ac_ext func.o
1777         ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
1778         cf_saveLIBS="$LIBS"
1779         LIBS="conftest.a $LIBS"
1780         AC_TRY_RUN([
1781         int main()
1782         {
1783                 extern int testfunc();
1784                 ${cf_cv_main_return:-return} (!testfunc());
1785         }
1786         ],
1787         [cf_cv_link_dataonly=yes],
1788         [cf_cv_link_dataonly=no],
1789         [cf_cv_link_dataonly=unknown])
1790         LIBS="$cf_saveLIBS"
1791         ])
1792 AC_MSG_RESULT($cf_cv_link_dataonly)
1793
1794 if test "$cf_cv_link_dataonly" = no ; then
1795         AC_DEFINE(BROKEN_LINKER)
1796         BROKEN_LINKER=1
1797 fi
1798
1799 ])dnl
1800 dnl ---------------------------------------------------------------------------
1801 dnl CF_LINK_FUNCS version: 7 updated: 2006/12/16 12:33:30
1802 dnl -------------
1803 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1804 dnl A few non-Unix systems implement symlink, but not link.
1805 dnl A few non-systems implement neither (or have nonfunctional versions).
1806 AC_DEFUN([CF_LINK_FUNCS],
1807 [
1808 AC_CHECK_FUNCS( \
1809         remove \
1810         unlink )
1811
1812 if test "$cross_compiling" = yes ; then
1813         AC_CHECK_FUNCS( \
1814                 link \
1815                 symlink )
1816 else
1817         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1818                 cf_cv_link_funcs=
1819                 for cf_func in link symlink ; do
1820                         AC_TRY_RUN([
1821 #include <sys/types.h>
1822 #include <sys/stat.h>
1823 #ifdef HAVE_UNISTD_H
1824 #include <unistd.h>
1825 #endif
1826 int main()
1827 {
1828         int fail = 0;
1829         char *src = "config.log";
1830         char *dst = "conftest.chk";
1831         struct stat src_sb;
1832         struct stat dst_sb;
1833
1834         stat(src, &src_sb);
1835         fail = ($cf_func("config.log", "conftest.chk") < 0)
1836             || (stat(dst, &dst_sb) < 0)
1837             || (dst_sb.st_mtime != src_sb.st_mtime);
1838 #ifdef HAVE_UNLINK
1839         unlink(dst);
1840 #else
1841         remove(dst);
1842 #endif
1843         ${cf_cv_main_return:-return} (fail);
1844 }
1845                         ],[
1846                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1847                         eval 'ac_cv_func_'$cf_func'=yes'],[
1848                         eval 'ac_cv_func_'$cf_func'=no'],[
1849                         eval 'ac_cv_func_'$cf_func'=error'])
1850                 done
1851                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1852         ])
1853         test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK)
1854         test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
1855 fi
1856 ])dnl
1857 dnl ---------------------------------------------------------------------------
1858 dnl CF_MAIN_RETURN version: 1 updated: 2006/12/10 09:51:54
1859 dnl --------------
1860 dnl Check if a return from main to the shell actually returns the same exit
1861 dnl code.  This is true for almost any POSIX environment.
1862 dnl
1863 dnl Some very old environments did not flush stdout, etc., on an exit.  That
1864 dnl would be a useful case to test for also.
1865 AC_DEFUN([CF_MAIN_RETURN],
1866 [
1867 cf_cv_main_return=return
1868 ])dnl
1869 dnl ---------------------------------------------------------------------------
1870 dnl CF_MAKEFLAGS version: 13 updated: 2010/10/23 15:52:32
1871 dnl ------------
1872 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
1873 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
1874 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1875 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
1876 AC_DEFUN([CF_MAKEFLAGS],
1877 [
1878 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
1879         cf_cv_makeflags=''
1880         for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
1881         do
1882                 cat >cf_makeflags.tmp <<CF_EOF
1883 SHELL = /bin/sh
1884 all :
1885         @ echo '.$cf_option'
1886 CF_EOF
1887                 cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[      ]]*$,,'`
1888                 case "$cf_result" in
1889                 .*k)
1890                         cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1891                         case "$cf_result" in
1892                         .*CC=*) cf_cv_makeflags=
1893                                 ;;
1894                         *)      cf_cv_makeflags=$cf_option
1895                                 ;;
1896                         esac
1897                         break
1898                         ;;
1899                 .-)     ;;
1900                 *)      echo "given option \"$cf_option\", no match \"$cf_result\""
1901                         ;;
1902                 esac
1903         done
1904         rm -f cf_makeflags.tmp
1905 ])
1906
1907 AC_SUBST(cf_cv_makeflags)
1908 ])dnl
1909 dnl ---------------------------------------------------------------------------
1910 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1911 dnl ------------
1912 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1913 dnl a monocase filesystem.
1914 AC_DEFUN([CF_MAKE_TAGS],[
1915 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1916
1917 AC_CHECK_PROGS(CTAGS, exctags ctags)
1918 AC_CHECK_PROGS(ETAGS, exetags etags)
1919
1920 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1921
1922 if test "$cf_cv_mixedcase" = yes ; then
1923         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1924 else
1925         MAKE_UPPER_TAGS=no
1926 fi
1927
1928 if test "$MAKE_UPPER_TAGS" = yes ; then
1929         MAKE_UPPER_TAGS=
1930 else
1931         MAKE_UPPER_TAGS="#"
1932 fi
1933
1934 if test "$MAKE_LOWER_TAGS" = yes ; then
1935         MAKE_LOWER_TAGS=
1936 else
1937         MAKE_LOWER_TAGS="#"
1938 fi
1939
1940 AC_SUBST(CTAGS)
1941 AC_SUBST(ETAGS)
1942
1943 AC_SUBST(MAKE_UPPER_TAGS)
1944 AC_SUBST(MAKE_LOWER_TAGS)
1945 ])dnl
1946 dnl ---------------------------------------------------------------------------
1947 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
1948 dnl ----------------------
1949 dnl Check if the file-system supports mixed-case filenames.  If we're able to
1950 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1951 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1952 [
1953 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1954 if test "$cross_compiling" = yes ; then
1955         case $target_alias in #(vi
1956         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
1957                 cf_cv_mixedcase=no
1958                 ;;
1959         *)
1960                 cf_cv_mixedcase=yes
1961                 ;;
1962         esac
1963 else
1964         rm -f conftest CONFTEST
1965         echo test >conftest
1966         if test -f CONFTEST ; then
1967                 cf_cv_mixedcase=no
1968         else
1969                 cf_cv_mixedcase=yes
1970         fi
1971         rm -f conftest CONFTEST
1972 fi
1973 ])
1974 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
1975 ])dnl
1976 dnl ---------------------------------------------------------------------------
1977 dnl CF_MKSTEMP version: 7 updated: 2010/08/14 18:25:37
1978 dnl ----------
1979 dnl Check for a working mkstemp.  This creates two files, checks that they are
1980 dnl successfully created and distinct (AmigaOS apparently fails on the last).
1981 AC_DEFUN([CF_MKSTEMP],[
1982 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
1983 rm -rf conftest*
1984 AC_TRY_RUN([
1985 #include <sys/types.h>
1986 #include <stdlib.h>
1987 #include <stdio.h>
1988 #include <string.h>
1989 #include <sys/stat.h>
1990 int main()
1991 {
1992         char *tmpl = "conftestXXXXXX";
1993         char name[2][80];
1994         int n;
1995         int result = 0;
1996         int fd;
1997         struct stat sb;
1998
1999         umask(077);
2000         for (n = 0; n < 2; ++n) {
2001                 strcpy(name[n], tmpl);
2002                 if ((fd = mkstemp(name[n])) >= 0) {
2003                         if (!strcmp(name[n], tmpl)
2004                          || stat(name[n], &sb) != 0
2005                          || (sb.st_mode & S_IFMT) != S_IFREG
2006                          || (sb.st_mode & 077) != 0) {
2007                                 result = 1;
2008                         }
2009                         close(fd);
2010                 }
2011         }
2012         if (result == 0
2013          && !strcmp(name[0], name[1]))
2014                 result = 1;
2015         ${cf_cv_main_return:-return}(result);
2016 }
2017 ],[cf_cv_func_mkstemp=yes
2018 ],[cf_cv_func_mkstemp=no
2019 ],[AC_CHECK_FUNC(mkstemp)
2020 ])
2021 ])
2022 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
2023         AC_DEFINE(HAVE_MKSTEMP)
2024 fi
2025 ])dnl
2026 dnl ---------------------------------------------------------------------------
2027 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
2028 dnl ----------
2029 dnl Write a debug message to config.log, along with the line number in the
2030 dnl configure script.
2031 AC_DEFUN([CF_MSG_LOG],[
2032 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
2033 ])dnl
2034 dnl ---------------------------------------------------------------------------
2035 dnl CF_NCURSES_ADDON version: 4 updated: 2011/03/27 17:10:13
2036 dnl ----------------
2037 dnl Configure an ncurses add-on, built outside the ncurses tree.
2038 AC_DEFUN([CF_NCURSES_ADDON],[
2039
2040 AC_PROVIDE([CF_SUBST_NCURSES_VERSION])
2041
2042 AC_MSG_CHECKING(if you want wide-character code)
2043 AC_ARG_ENABLE(widec,
2044         [  --enable-widec          compile with wide-char/UTF-8 code],
2045         [with_widec=$enableval],
2046         [with_widec=no])
2047 AC_MSG_RESULT($with_widec)
2048 if test "$with_widec" = yes ; then
2049         CF_UTF8_LIB 
2050         CF_NCURSES_CONFIG(ncursesw)
2051 else
2052         CF_NCURSES_CONFIG(ncurses)
2053 fi
2054
2055 if test "$NCURSES_CONFIG" != none ; then
2056
2057 cf_version=`$NCURSES_CONFIG --version`
2058
2059 NCURSES_MAJOR=`echo "$cf_version" | sed -e 's/\..*//'`
2060 NCURSES_MINOR=`echo "$cf_version" | sed -e 's/^[[0-9]][[0-9]]*\.//' -e 's/\..*//'`
2061 NCURSES_PATCH=`echo "$cf_version" | sed -e 's/^[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.//'`
2062
2063 # ABI version is not available from headers
2064 cf_cv_abi_version=`$NCURSES_CONFIG --abi-version`
2065
2066 else
2067
2068 for cf_name in MAJOR MINOR PATCH
2069 do
2070 cat >conftest.$ac_ext <<CF_EOF
2071 #include <${cf_cv_ncurses_header:-curses.h}>
2072 AUTOCONF_$cf_name NCURSES_VERSION_$cf_name
2073 CF_EOF
2074         cf_try="$ac_cpp conftest.$ac_ext 2>&5 | fgrep AUTOCONF_$cf_name >conftest.out"
2075         AC_TRY_EVAL(cf_try)
2076         if test -f conftest.out ; then
2077                 cf_result=`cat conftest.out | sed -e "s/^.*AUTOCONF_$cf_name[[  ]][[    ]]*//"`
2078                 eval NCURSES_$cf_name=\"$cf_result\"
2079                 # cat conftest.$ac_ext
2080                 # cat conftest.out
2081         fi
2082 done
2083
2084 cf_cv_abi_version=${NCURSES_MAJOR}
2085
2086 fi
2087
2088 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
2089
2090 dnl Show the computed version, for logging
2091 cf_cv_timestamp=`date`
2092
2093 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
2094
2095 dnl We need these values in the generated headers
2096 AC_SUBST(NCURSES_MAJOR)
2097 AC_SUBST(NCURSES_MINOR)
2098 AC_SUBST(NCURSES_PATCH)
2099
2100 dnl We need these values in the generated makefiles
2101 AC_SUBST(cf_cv_rel_version)
2102 AC_SUBST(cf_cv_abi_version)
2103
2104 dnl FIXME - not needed for Ada95
2105 AC_SUBST(cf_cv_builtin_bool)
2106 AC_SUBST(cf_cv_header_stdbool_h)
2107 AC_SUBST(cf_cv_type_of_bool)dnl
2108
2109 ])
2110 dnl ---------------------------------------------------------------------------
2111 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
2112 dnl -------------------
2113 dnl Check if we can compile with ncurses' header file
2114 dnl $1 is the cache variable to set
2115 dnl $2 is the header-file to include
2116 dnl $3 is the root name (ncurses or ncursesw)
2117 AC_DEFUN([CF_NCURSES_CC_CHECK],[
2118         AC_TRY_COMPILE([
2119 ]ifelse($3,ncursesw,[
2120 #define _XOPEN_SOURCE_EXTENDED
2121 #undef  HAVE_LIBUTF8_H  /* in case we used CF_UTF8_LIB */
2122 #define HAVE_LIBUTF8_H  /* to force ncurses' header file to use cchar_t */
2123 ])[
2124 #include <$2>],[
2125 #ifdef NCURSES_VERSION
2126 ]ifelse($3,ncursesw,[
2127 #ifndef WACS_BSSB
2128         make an error
2129 #endif
2130 ])[
2131 printf("%s\n", NCURSES_VERSION);
2132 #else
2133 #ifdef __NCURSES_H
2134 printf("old\n");
2135 #else
2136         make an error
2137 #endif
2138 #endif
2139         ]
2140         ,[$1=$2]
2141         ,[$1=no])
2142 ])dnl
2143 dnl ---------------------------------------------------------------------------
2144 dnl CF_NCURSES_CONFIG version: 8 updated: 2010/07/08 05:17:30
2145 dnl -----------------
2146 dnl Tie together the configure-script macros for ncurses.
2147 dnl Prefer the "-config" script from ncurses 6.x, to simplify analysis.
2148 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
2149 dnl
2150 dnl $1 is the root library name (default: "ncurses")
2151 AC_DEFUN([CF_NCURSES_CONFIG],
2152 [
2153 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
2154
2155 echo "Looking for ${cf_ncuconfig_root}-config"
2156 AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
2157
2158 if test "$NCURSES_CONFIG" != none ; then
2159
2160 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
2161 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
2162
2163 # even with config script, some packages use no-override for curses.h
2164 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
2165
2166 dnl like CF_NCURSES_CPPFLAGS
2167 AC_DEFINE(NCURSES)
2168
2169 dnl like CF_NCURSES_LIBS
2170 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
2171 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2172
2173 dnl like CF_NCURSES_VERSION
2174 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
2175
2176 else
2177
2178 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
2179 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
2180
2181 fi
2182 ])dnl
2183 dnl ---------------------------------------------------------------------------
2184 dnl CF_NCURSES_CPPFLAGS version: 20 updated: 2010/11/20 17:02:38
2185 dnl -------------------
2186 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
2187 dnl the CPPFLAGS variable so we can include its header.
2188 dnl
2189 dnl The header files may be installed as either curses.h, or ncurses.h (would
2190 dnl be obsolete, except that some packagers prefer this name to distinguish it
2191 dnl from a "native" curses implementation).  If not installed for overwrite,
2192 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2193 dnl /usr/include/ncurses), but someone may have installed overwriting the
2194 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
2195 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2196 dnl the header.
2197 dnl
2198 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2199 dnl is already in the include-path, don't even bother with this, since we cannot
2200 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
2201 dnl
2202 dnl The optional parameter gives the root name of the library, in case it is
2203 dnl not installed as the default curses library.  That is how the
2204 dnl wide-character version of ncurses is installed.
2205 AC_DEFUN([CF_NCURSES_CPPFLAGS],
2206 [AC_REQUIRE([CF_WITH_CURSES_DIR])
2207
2208 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2209 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2210
2211 test -n "$cf_cv_curses_dir" && \
2212 test "$cf_cv_curses_dir" != "no" && { \
2213   CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
2214 }
2215
2216 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2217         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2218         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2219         for cf_header in $cf_header_list
2220         do
2221                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2222                 test "$cf_cv_ncurses_h" != no && break
2223         done
2224 ])
2225
2226 CF_NCURSES_HEADER
2227 CF_TERM_HEADER
2228
2229 # some applications need this, but should check for NCURSES_VERSION
2230 AC_DEFINE(NCURSES)
2231
2232 CF_NCURSES_VERSION
2233 ])dnl
2234 dnl ---------------------------------------------------------------------------
2235 dnl CF_NCURSES_HEADER version: 2 updated: 2008/03/23 14:48:54
2236 dnl -----------------
2237 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2238 dnl variations of ncurses' installs.
2239 dnl
2240 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2241 AC_DEFUN([CF_NCURSES_HEADER],[
2242
2243 if test "$cf_cv_ncurses_h" != no ; then
2244         cf_cv_ncurses_header=$cf_cv_ncurses_h
2245 else
2246
2247 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2248         test -n "$verbose" && echo
2249         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2250         test -n "$verbose" && echo search path $cf_search
2251         cf_save2_CPPFLAGS="$CPPFLAGS"
2252         for cf_incdir in $cf_search
2253         do
2254                 CF_ADD_INCDIR($cf_incdir)
2255                 for cf_header in \
2256                         ncurses.h \
2257                         curses.h
2258                 do
2259                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2260                         if test "$cf_cv_ncurses_h2" != no ; then
2261                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
2262                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
2263                                 break
2264                         fi
2265                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2266                 done
2267                 CPPFLAGS="$cf_save2_CPPFLAGS"
2268                 test "$cf_cv_ncurses_h2" != no && break
2269         done
2270         test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2271         ])
2272
2273         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2274         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2275         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2276                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2277         fi
2278         CF_ADD_INCDIR($cf_1st_incdir)
2279
2280 fi
2281
2282 # Set definitions to allow ifdef'ing for ncurses.h
2283
2284 case $cf_cv_ncurses_header in # (vi
2285 *ncurses.h)
2286         AC_DEFINE(HAVE_NCURSES_H)
2287         ;;
2288 esac
2289
2290 case $cf_cv_ncurses_header in # (vi
2291 ncurses/curses.h|ncurses/ncurses.h)
2292         AC_DEFINE(HAVE_NCURSES_NCURSES_H)
2293         ;;
2294 ncursesw/curses.h|ncursesw/ncurses.h)
2295         AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
2296         ;;
2297 esac
2298
2299 ])dnl
2300 dnl ---------------------------------------------------------------------------
2301 dnl CF_NCURSES_LIBS version: 16 updated: 2010/11/20 17:02:38
2302 dnl ---------------
2303 dnl Look for the ncurses library.  This is a little complicated on Linux,
2304 dnl because it may be linked with the gpm (general purpose mouse) library.
2305 dnl Some distributions have gpm linked with (bsd) curses, which makes it
2306 dnl unusable with ncurses.  However, we don't want to link with gpm unless
2307 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2308 dnl and the linker will record a dependency.
2309 dnl
2310 dnl The optional parameter gives the root name of the library, in case it is
2311 dnl not installed as the default curses library.  That is how the
2312 dnl wide-character version of ncurses is installed.
2313 AC_DEFUN([CF_NCURSES_LIBS],
2314 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2315
2316 cf_nculib_root=ifelse($1,,ncurses,$1)
2317         # This works, except for the special case where we find gpm, but
2318         # ncurses is in a nonstandard location via $LIBS, and we really want
2319         # to link gpm.
2320 cf_ncurses_LIBS=""
2321 cf_ncurses_SAVE="$LIBS"
2322 AC_CHECK_LIB(gpm,Gpm_Open,
2323         [AC_CHECK_LIB(gpm,initscr,
2324                 [LIBS="$cf_ncurses_SAVE"],
2325                 [cf_ncurses_LIBS="-lgpm"])])
2326
2327 case $host_os in #(vi
2328 freebsd*)
2329         # This is only necessary if you are linking against an obsolete
2330         # version of ncurses (but it should do no harm, since it's static).
2331         if test "$cf_nculib_root" = ncurses ; then
2332                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2333         fi
2334         ;;
2335 esac
2336
2337 CF_ADD_LIBS($cf_ncurses_LIBS)
2338
2339 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2340 then
2341         CF_ADD_LIBS(-l$cf_nculib_root)
2342 else
2343         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2344                 [#include <${cf_cv_ncurses_header:-curses.h}>],
2345                 [initscr()],
2346                 initscr)
2347 fi
2348
2349 if test -n "$cf_ncurses_LIBS" ; then
2350         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2351         cf_ncurses_SAVE="$LIBS"
2352         for p in $cf_ncurses_LIBS ; do
2353                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2354                 if test "$q" != "$LIBS" ; then
2355                         LIBS="$q"
2356                 fi
2357         done
2358         AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2359                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2360                 [AC_MSG_RESULT(yes)],
2361                 [AC_MSG_RESULT(no)
2362                  LIBS="$cf_ncurses_SAVE"])
2363 fi
2364
2365 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2366 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2367 ])dnl
2368 dnl ---------------------------------------------------------------------------
2369 dnl CF_NCURSES_VERSION version: 13 updated: 2010/10/23 15:54:49
2370 dnl ------------------
2371 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2372 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
2373 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2374 AC_DEFUN([CF_NCURSES_VERSION],
2375 [
2376 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2377 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2378         cf_cv_ncurses_version=no
2379         cf_tempfile=out$$
2380         rm -f $cf_tempfile
2381         AC_TRY_RUN([
2382 #include <${cf_cv_ncurses_header:-curses.h}>
2383 #include <stdio.h>
2384 int main()
2385 {
2386         FILE *fp = fopen("$cf_tempfile", "w");
2387 #ifdef NCURSES_VERSION
2388 # ifdef NCURSES_VERSION_PATCH
2389         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2390 # else
2391         fprintf(fp, "%s\n", NCURSES_VERSION);
2392 # endif
2393 #else
2394 # ifdef __NCURSES_H
2395         fprintf(fp, "old\n");
2396 # else
2397         make an error
2398 # endif
2399 #endif
2400         ${cf_cv_main_return:-return}(0);
2401 }],[
2402         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2403
2404         # This will not work if the preprocessor splits the line after the
2405         # Autoconf token.  The 'unproto' program does that.
2406         cat > conftest.$ac_ext <<EOF
2407 #include <${cf_cv_ncurses_header:-curses.h}>
2408 #undef Autoconf
2409 #ifdef NCURSES_VERSION
2410 Autoconf NCURSES_VERSION
2411 #else
2412 #ifdef __NCURSES_H
2413 Autoconf "old"
2414 #endif
2415 ;
2416 #endif
2417 EOF
2418         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2419         AC_TRY_EVAL(cf_try)
2420         if test -f conftest.out ; then
2421                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2422                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2423                 rm -f conftest.out
2424         fi
2425 ])
2426         rm -f $cf_tempfile
2427 ])
2428 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
2429 ])dnl
2430 dnl ---------------------------------------------------------------------------
2431 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
2432 dnl ------------------
2433 dnl see CF_WITH_NO_LEAKS
2434 AC_DEFUN([CF_NO_LEAKS_OPTION],[
2435 AC_MSG_CHECKING(if you want to use $1 for testing)
2436 AC_ARG_WITH($1,
2437         [$2],
2438         [AC_DEFINE($3)ifelse([$4],,[
2439          $4
2440 ])
2441         : ${with_cflags:=-g}
2442         : ${with_no_leaks:=yes}
2443          with_$1=yes],
2444         [with_$1=])
2445 AC_MSG_RESULT(${with_$1:-no})
2446
2447 case .$with_cflags in #(vi
2448 .*-g*)
2449         case .$CFLAGS in #(vi
2450         .*-g*) #(vi
2451                 ;;
2452         *)
2453                 CF_ADD_CFLAGS([-g])
2454                 ;;
2455         esac
2456         ;;
2457 esac
2458 ])dnl
2459 dnl ---------------------------------------------------------------------------
2460 dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
2461 dnl ----------------
2462 dnl Check if the given variable is a number.  If not, report an error.
2463 dnl $1 is the variable
2464 dnl $2 is the message
2465 AC_DEFUN([CF_NUMBER_SYNTAX],[
2466 if test -n "$1" ; then
2467   case $1 in #(vi
2468   [[0-9]]*) #(vi
2469         ;;
2470   *)
2471         AC_MSG_ERROR($2 is not a number: $1)
2472         ;;
2473   esac
2474 else
2475   AC_MSG_ERROR($2 value is empty)
2476 fi
2477 ])dnl
2478 dnl ---------------------------------------------------------------------------
2479 dnl CF_OBJ_SUBDIR version: 4 updated: 2002/02/23 20:38:31
2480 dnl -------------
2481 dnl Compute the object-directory name from the given model name
2482 AC_DEFUN([CF_OBJ_SUBDIR],
2483 [
2484         case $1 in
2485         libtool) $2='obj_lo'  ;;
2486         normal)  $2='objects' ;;
2487         debug)   $2='obj_g' ;;
2488         profile) $2='obj_p' ;;
2489         shared)
2490                 case $cf_cv_system_name in #(vi
2491                 cygwin) #(vi
2492                         $2='objects' ;;
2493                 *)
2494                         $2='obj_s' ;;
2495                 esac
2496         esac
2497 ])dnl
2498 dnl ---------------------------------------------------------------------------
2499 dnl CF_PATHSEP version: 5 updated: 2010/05/26 05:38:42
2500 dnl ----------
2501 dnl Provide a value for the $PATH and similar separator
2502 AC_DEFUN([CF_PATHSEP],
2503 [
2504         case $cf_cv_system_name in
2505         os2*)   PATH_SEPARATOR=';'  ;;
2506         *)      PATH_SEPARATOR=':'  ;;
2507         esac
2508 ifelse([$1],,,[$1=$PATH_SEPARATOR])
2509         AC_SUBST(PATH_SEPARATOR)
2510 ])dnl
2511 dnl ---------------------------------------------------------------------------
2512 dnl CF_PATH_SYNTAX version: 13 updated: 2010/05/26 05:38:42
2513 dnl --------------
2514 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2515 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2516 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2517 dnl delayed evaluation of those symbols.
2518 AC_DEFUN([CF_PATH_SYNTAX],[
2519 if test "x$prefix" != xNONE; then
2520   cf_path_syntax="$prefix"
2521 else
2522   cf_path_syntax="$ac_default_prefix"
2523 fi
2524
2525 case ".[$]$1" in #(vi
2526 .\[$]\(*\)*|.\'*\'*) #(vi
2527   ;;
2528 ..|./*|.\\*) #(vi
2529   ;;
2530 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
2531   ;;
2532 .\[$]{*prefix}*) #(vi
2533   eval $1="[$]$1"
2534   case ".[$]$1" in #(vi
2535   .NONE/*)
2536     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2537     ;;
2538   esac
2539   ;; #(vi
2540 .no|.NONE/*)
2541   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2542   ;;
2543 *)
2544   ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2545   ;;
2546 esac
2547 ])dnl
2548 dnl ---------------------------------------------------------------------------
2549 dnl CF_PKG_CONFIG version: 4 updated: 2011/02/18 20:26:24
2550 dnl -------------
2551 dnl Check for the package-config program, unless disabled by command-line.
2552 AC_DEFUN([CF_PKG_CONFIG],
2553 [
2554 AC_MSG_CHECKING(if you want to use pkg-config)
2555 AC_ARG_WITH(pkg-config,
2556         [  --with-pkg-config{=path} enable/disable use of pkg-config],
2557         [cf_pkg_config=$withval],
2558         [cf_pkg_config=yes])
2559 AC_MSG_RESULT($cf_pkg_config)
2560
2561 case $cf_pkg_config in #(vi
2562 no) #(vi
2563         PKG_CONFIG=none
2564         ;;
2565 yes) #(vi
2566         AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)
2567         ;;
2568 *)
2569         PKG_CONFIG=$withval
2570         ;;
2571 esac
2572
2573 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2574 if test "$PKG_CONFIG" != none ; then
2575         CF_PATH_SYNTAX(PKG_CONFIG)
2576 fi
2577
2578 AC_SUBST(PKG_CONFIG)
2579 ])dnl
2580 dnl ---------------------------------------------------------------------------
2581 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
2582 dnl -----------------
2583 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2584 dnl
2585 dnl     POSIX.1-1990                            _POSIX_SOURCE
2586 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
2587 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
2588 dnl             Bindings Option
2589 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
2590 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
2591 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
2592 dnl
2593 dnl Parameters:
2594 dnl     $1 is the nominal value for _POSIX_C_SOURCE
2595 AC_DEFUN([CF_POSIX_C_SOURCE],
2596 [
2597 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2598
2599 cf_save_CFLAGS="$CFLAGS"
2600 cf_save_CPPFLAGS="$CPPFLAGS"
2601
2602 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2603 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2604
2605 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2606         CF_MSG_LOG(if the symbol is already defined go no further)
2607         AC_TRY_COMPILE([#include <sys/types.h>],[
2608 #ifndef _POSIX_C_SOURCE
2609 make an error
2610 #endif],
2611         [cf_cv_posix_c_source=no],
2612         [cf_want_posix_source=no
2613          case .$cf_POSIX_C_SOURCE in #(vi
2614          .[[12]]??*) #(vi
2615                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2616                 ;;
2617          .2) #(vi
2618                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2619                 cf_want_posix_source=yes
2620                 ;;
2621          .*)
2622                 cf_want_posix_source=yes
2623                 ;;
2624          esac
2625          if test "$cf_want_posix_source" = yes ; then
2626                 AC_TRY_COMPILE([#include <sys/types.h>],[
2627 #ifdef _POSIX_SOURCE
2628 make an error
2629 #endif],[],
2630                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2631          fi
2632          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2633          CFLAGS="$cf_trim_CFLAGS"
2634          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2635          CF_MSG_LOG(if the second compile does not leave our definition intact error)
2636          AC_TRY_COMPILE([#include <sys/types.h>],[
2637 #ifndef _POSIX_C_SOURCE
2638 make an error
2639 #endif],,
2640          [cf_cv_posix_c_source=no])
2641          CFLAGS="$cf_save_CFLAGS"
2642          CPPFLAGS="$cf_save_CPPFLAGS"
2643         ])
2644 ])
2645
2646 if test "$cf_cv_posix_c_source" != no ; then
2647         CFLAGS="$cf_trim_CFLAGS"
2648         CPPFLAGS="$cf_trim_CPPFLAGS"
2649         CF_ADD_CFLAGS($cf_cv_posix_c_source)
2650 fi
2651
2652 ])dnl
2653 dnl ---------------------------------------------------------------------------
2654 dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
2655 dnl ----------
2656 dnl Check for archiver "ar".
2657 AC_DEFUN([CF_PROG_AR],[
2658 AC_CHECK_TOOL(AR, ar, ar)
2659 ])
2660 dnl ---------------------------------------------------------------------------
2661 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
2662 dnl -----------
2663 dnl Check for awk, ensure that the check found something.
2664 AC_DEFUN([CF_PROG_AWK],
2665 [
2666 AC_PROG_AWK
2667 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
2668 ])dnl
2669 dnl ---------------------------------------------------------------------------
2670 dnl CF_PROG_CC_C_O version: 3 updated: 2010/08/14 18:25:37
2671 dnl --------------
2672 dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
2673 dnl the output file can be renamed, and allows for a shell variable that can
2674 dnl be used later.  The parameter is either CC or CXX.  The result is the
2675 dnl cache variable:
2676 dnl     $cf_cv_prog_CC_c_o
2677 dnl     $cf_cv_prog_CXX_c_o
2678 AC_DEFUN([CF_PROG_CC_C_O],
2679 [AC_REQUIRE([AC_PROG_CC])dnl
2680 AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
2681 AC_CACHE_VAL(cf_cv_prog_$1_c_o,
2682 [
2683 cat > conftest.$ac_ext <<CF_EOF
2684 #include <stdio.h>
2685 int main()
2686 {
2687         ${cf_cv_main_return:-return}(0);
2688 }
2689 CF_EOF
2690 # We do the test twice because some compilers refuse to overwrite an
2691 # existing .o file with -o, though they will create one.
2692 ac_try='[$]$1 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
2693 if AC_TRY_EVAL(ac_try) &&
2694   test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
2695 then
2696   eval cf_cv_prog_$1_c_o=yes
2697 else
2698   eval cf_cv_prog_$1_c_o=no
2699 fi
2700 rm -rf conftest*
2701 ])dnl
2702 if test $cf_cv_prog_$1_c_o = yes; then
2703   AC_MSG_RESULT([yes])
2704 else
2705   AC_MSG_RESULT([no])
2706 fi
2707 ])dnl
2708 dnl ---------------------------------------------------------------------------
2709 dnl CF_PROG_EGREP version: 1 updated: 2006/09/16 11:40:59
2710 dnl -------------
2711 dnl AC_PROG_EGREP was introduced in autoconf 2.53.
2712 dnl This macro adds a check to ensure the script found something.
2713 AC_DEFUN([CF_PROG_EGREP],
2714 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
2715    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
2716     then ac_cv_prog_egrep='grep -E'
2717     else ac_cv_prog_egrep='egrep'
2718     fi])
2719  EGREP=$ac_cv_prog_egrep
2720  AC_SUBST([EGREP])
2721 test -z "$EGREP" && AC_MSG_ERROR(No egrep program found)
2722 ])dnl
2723 dnl ---------------------------------------------------------------------------
2724 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
2725 dnl -----------
2726 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
2727 AC_DEFUN([CF_PROG_EXT],
2728 [
2729 AC_REQUIRE([CF_CHECK_CACHE])
2730 case $cf_cv_system_name in
2731 os2*)
2732     CFLAGS="$CFLAGS -Zmt"
2733     CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
2734     CXXFLAGS="$CXXFLAGS -Zmt"
2735     # autoconf's macro sets -Zexe and suffix both, which conflict:w
2736     LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
2737     ac_cv_exeext=.exe
2738     ;;
2739 esac
2740
2741 AC_EXEEXT
2742 AC_OBJEXT
2743
2744 PROG_EXT="$EXEEXT"
2745 AC_SUBST(PROG_EXT)
2746 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
2747 ])dnl
2748 dnl ---------------------------------------------------------------------------
2749 dnl CF_PROG_GNAT version: 1 updated: 2010/06/19 15:22:18
2750 dnl ------------
2751 dnl Check for gnatmake, ensure that it is complete.
2752 AC_DEFUN([CF_PROG_GNAT],[
2753 cf_ada_make=gnatmake
2754 AC_CHECK_PROG(gnat_exists, $cf_ada_make, yes, no)
2755 if test "$ac_cv_prog_gnat_exists" = no; then
2756    cf_ada_make=
2757 else
2758    CF_GNAT_VERSION
2759    AC_CHECK_PROG(M4_exists, m4, yes, no)
2760    if test "$ac_cv_prog_M4_exists" = no; then
2761       cf_cv_prog_gnat_correct=no
2762       echo Ada95 binding required program m4 not found. Ada95 binding disabled.
2763    fi
2764    if test "$cf_cv_prog_gnat_correct" = yes; then
2765       AC_MSG_CHECKING(if GNAT works)
2766       CF_GNAT_TRY_RUN([procedure conftest;],
2767 [with Text_IO;
2768 with GNAT.OS_Lib;
2769 procedure conftest is
2770 begin
2771    Text_IO.Put ("Hello World");
2772    Text_IO.New_Line;
2773    GNAT.OS_Lib.OS_Exit (0);
2774 end conftest;],[cf_cv_prog_gnat_correct=yes],[cf_cv_prog_gnat_correct=no])
2775       AC_MSG_RESULT($cf_cv_prog_gnat_correct)
2776    fi
2777 fi
2778
2779 AC_SUBST(cf_ada_make)
2780 ])dnl
2781 dnl ---------------------------------------------------------------------------
2782 dnl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
2783 dnl ------------
2784 dnl Combine checks for "ln -s" and "ln -sf", updating $LN_S to include "-f"
2785 dnl option if it is supported.
2786 AC_DEFUN([CF_PROG_LN_S],[
2787 AC_PROG_LN_S
2788 AC_MSG_CHECKING(if $LN_S -f options work)
2789
2790 rm -f conf$$.src conf$$dst
2791 echo >conf$$.dst
2792 echo first >conf$$.src
2793 if $LN_S -f conf$$.src conf$$.dst 2>/dev/null; then
2794         cf_prog_ln_sf=yes
2795 else
2796         cf_prog_ln_sf=no
2797 fi
2798 rm -f conf$$.dst conf$$src
2799 AC_MSG_RESULT($cf_prog_ln_sf)
2800
2801 test "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
2802 ])dnl
2803 dnl ---------------------------------------------------------------------------
2804 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2805 dnl ----------------
2806 dnl Remove all -U and -D options that refer to the given symbol from a list
2807 dnl of C compiler options.  This works around the problem that not all
2808 dnl compilers process -U and -D options from left-to-right, so a -U option
2809 dnl cannot be used to cancel the effect of a preceding -D option.
2810 dnl
2811 dnl $1 = target (which could be the same as the source variable)
2812 dnl $2 = source (including '$')
2813 dnl $3 = symbol to remove
2814 define([CF_REMOVE_DEFINE],
2815 [
2816 $1=`echo "$2" | \
2817         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
2818                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
2819 ])dnl
2820 dnl ---------------------------------------------------------------------------
2821 dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
2822 dnl -------------
2823 dnl Remove the given library from the symbol
2824 dnl
2825 dnl $1 = target (which could be the same as the source variable)
2826 dnl $2 = source (including '$')
2827 dnl $3 = library to remove
2828 define([CF_REMOVE_LIB],
2829 [
2830 # remove $3 library from $2
2831 $1=`echo "$2" | sed -e 's/-l$3[[        ]]//g' -e 's/-l$3[$]//'`
2832 ])dnl
2833 dnl ---------------------------------------------------------------------------
2834 dnl CF_SHARED_OPTS version: 64 updated: 2010/06/05 16:51:16
2835 dnl --------------
2836 dnl --------------
2837 dnl Attempt to determine the appropriate CC/LD options for creating a shared
2838 dnl library.
2839 dnl
2840 dnl Note: ${LOCAL_LDFLAGS} is used to link executables that will run within the
2841 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
2842 dnl We avoid compiling-in a ../lib path for the shared library since that can
2843 dnl lead to unexpected results at runtime.
2844 dnl ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared libraries
2845 dnl are compiled in ../../lib
2846 dnl
2847 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
2848 dnl to install symbolic links to the rel/abi versions of shared libraries.
2849 dnl
2850 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
2851 dnl version when making symbolic links.
2852 dnl
2853 dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
2854 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
2855 dnl (ex: libncurses.so.<ver>).
2856 dnl
2857 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
2858 AC_DEFUN([CF_SHARED_OPTS],
2859 [
2860         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2861         AC_REQUIRE([CF_LD_RPATH_OPT])
2862         LOCAL_LDFLAGS=
2863         LOCAL_LDFLAGS2=
2864         LD_SHARED_OPTS=
2865         INSTALL_LIB="-m 644"
2866
2867         cf_cv_do_symlinks=no
2868         cf_ld_rpath_opt=
2869         test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
2870
2871         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
2872         AC_ARG_WITH(shlib-version,
2873         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
2874         [test -z "$withval" && withval=auto
2875         case $withval in #(vi
2876         yes) #(vi
2877                 cf_cv_shlib_version=auto
2878                 ;;
2879         rel|abi|auto|no) #(vi
2880                 cf_cv_shlib_version=$withval
2881                 ;;
2882         *)
2883                 AC_MSG_ERROR([option value must be one of: rel, abi, auto or no])
2884                 ;;
2885         esac
2886         ],[cf_cv_shlib_version=auto])
2887         AC_MSG_RESULT($cf_cv_shlib_version)
2888
2889         cf_cv_rm_so_locs=no
2890
2891         # Some less-capable ports of gcc support only -fpic
2892         CC_SHARED_OPTS=
2893         if test "$GCC" = yes
2894         then
2895                 AC_MSG_CHECKING(which $CC option to use)
2896                 cf_save_CFLAGS="$CFLAGS"
2897                 for CC_SHARED_OPTS in -fPIC -fpic ''
2898                 do
2899                         CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
2900                         AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
2901                 done
2902                 AC_MSG_RESULT($CC_SHARED_OPTS)
2903                 CFLAGS="$cf_save_CFLAGS"
2904         fi
2905
2906         cf_cv_shlib_version_infix=no
2907
2908         case $cf_cv_system_name in #(vi
2909         aix[[56]]*) #(vi
2910                 if test "$GCC" = yes; then
2911                         CC_SHARED_OPTS=
2912                         MK_SHARED_LIB='$(CC) -shared'
2913                 fi
2914                 ;;
2915         beos*) #(vi
2916                 MK_SHARED_LIB='${CC} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
2917                 ;;
2918         cygwin*) #(vi
2919                 CC_SHARED_OPTS=
2920                 MK_SHARED_LIB='sh ../mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
2921                 cf_cv_shlib_version=cygdll
2922                 cf_cv_shlib_version_infix=cygdll
2923                 cat >mk_shared_lib.sh <<-CF_EOF
2924                 #!/bin/sh
2925                 SHARED_LIB=\[$]1
2926                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
2927                 shift
2928                 cat <<-EOF
2929                 Linking shared library
2930                 ** SHARED_LIB \[$]SHARED_LIB
2931                 ** IMPORT_LIB \[$]IMPORT_LIB
2932 EOF
2933                 exec \[$]* -shared -Wl,--out-implib=../lib/\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o ../lib/\[$]{SHARED_LIB}
2934 CF_EOF
2935                 chmod +x mk_shared_lib.sh
2936                 ;;
2937         darwin*) #(vi
2938                 EXTRA_CFLAGS="-no-cpp-precomp"
2939                 CC_SHARED_OPTS="-dynamic"
2940                 MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
2941                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
2942                 cf_cv_shlib_version_infix=yes
2943                 AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
2944                         cf_save_LDFLAGS=$LDFLAGS
2945                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
2946                         AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
2947                                 LDFLAGS=$cf_save_LDFLAGS])
2948                 if test $cf_cv_ldflags_search_paths_first = yes; then
2949                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
2950                 fi
2951                 ;;
2952         hpux*) #(vi
2953                 # (tested with gcc 2.7.2 -- I don't have c89)
2954                 if test "$GCC" = yes; then
2955                         LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
2956                 else
2957                         CC_SHARED_OPTS='+Z'
2958                         LD_SHARED_OPTS='-Wl,+b,${libdir}'
2959                 fi
2960                 MK_SHARED_LIB='${LD} +b ${libdir} -b -o $[@]'
2961                 # HP-UX shared libraries must be executable, and should be
2962                 # readonly to exploit a quirk in the memory manager.
2963                 INSTALL_LIB="-m 555"
2964                 ;;
2965         irix*) #(vi
2966                 if test "$cf_cv_enable_rpath" = yes ; then
2967                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
2968                 fi
2969                 # tested with IRIX 5.2 and 'cc'.
2970                 if test "$GCC" != yes; then
2971                         CC_SHARED_OPTS='-KPIC'
2972                         MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
2973                 else
2974                         MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]'
2975                 fi
2976                 cf_cv_rm_so_locs=yes
2977                 ;;
2978         linux*|gnu*|k*bsd*-gnu) #(vi
2979                 if test "$DFT_LWR_MODEL" = "shared" ; then
2980                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
2981                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2982                 fi
2983                 if test "$cf_cv_enable_rpath" = yes ; then
2984                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
2985                 fi
2986                 CF_SHARED_SONAME
2987                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
2988                 ;;
2989         openbsd[[2-9]].*) #(vi
2990                 if test "$DFT_LWR_MODEL" = "shared" ; then
2991                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
2992                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2993                 fi
2994                 if test "$cf_cv_enable_rpath" = yes ; then
2995                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
2996                 fi
2997                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2998                 CF_SHARED_SONAME
2999                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
3000                 ;;
3001         nto-qnx*|openbsd*|freebsd[[12]].*) #(vi
3002                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3003                 MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
3004                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3005                 ;;
3006         freebsd*) #(vi
3007                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3008                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
3009                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
3010                         LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${libdir} $LOCAL_LDFLAGS"
3011                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
3012                 fi
3013                 CF_SHARED_SONAME
3014                 MK_SHARED_LIB='${LD} -shared -Bshareable -soname=`basename $[@]` -o $[@]'
3015                 ;;
3016         netbsd*) #(vi
3017                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3018                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
3019                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
3020                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3021                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
3022                         if test "$cf_cv_shlib_version" = auto; then
3023                         if test -f /usr/libexec/ld.elf_so; then
3024                                 cf_cv_shlib_version=abi
3025                         else
3026                                 cf_cv_shlib_version=rel
3027                         fi
3028                         fi
3029                         CF_SHARED_SONAME
3030                         MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
3031                 else
3032                         MK_SHARED_LIB='${LD} -shared -Bshareable -o $[@]'
3033                 fi
3034                 ;;
3035         osf*|mls+*) #(vi
3036                 # tested with OSF/1 V3.2 and 'cc'
3037                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
3038                 # link with shared libs).
3039                 MK_SHARED_LIB='${LD} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
3040                 case $host_os in #(vi
3041                 osf4*)
3042                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
3043                         ;;
3044                 esac
3045                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
3046                 if test "$DFT_LWR_MODEL" = "shared" ; then
3047                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
3048                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3049                 fi
3050                 cf_cv_rm_so_locs=yes
3051                 ;;
3052         sco3.2v5*)  # (also uw2* and UW7: hops 13-Apr-98
3053                 # tested with osr5.0.5
3054                 if test "$GCC" != yes; then
3055                         CC_SHARED_OPTS='-belf -KPIC'
3056                 fi
3057                 MK_SHARED_LIB='${LD} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
3058                 if test "$cf_cv_enable_rpath" = yes ; then
3059                         # only way is to set LD_RUN_PATH but no switch for it
3060                         RUN_PATH=$libdir
3061                 fi
3062                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3063                 LINK_PROGS='LD_RUN_PATH=${libdir}'
3064                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
3065                 ;;
3066         sunos4*) #(vi
3067                 # tested with SunOS 4.1.1 and gcc 2.7.0
3068                 if test "$GCC" != yes; then
3069                         CC_SHARED_OPTS='-KPIC'
3070                 fi
3071                 MK_SHARED_LIB='${LD} -assert pure-text -o $[@]'
3072                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3073                 ;;
3074         solaris2*) #(vi
3075                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
3076                 # tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
3077                 if test "$DFT_LWR_MODEL" = "shared" ; then
3078                         LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
3079                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3080                 fi
3081                 if test "$cf_cv_enable_rpath" = yes ; then
3082                         EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
3083                 fi
3084                 CF_SHARED_SONAME
3085                 if test "$GCC" != yes; then
3086                         cf_save_CFLAGS="$CFLAGS"
3087                         for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
3088                         do
3089                                 CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
3090                                 AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\n");],[break])
3091                         done
3092                         CFLAGS="$cf_save_CFLAGS"
3093                         CC_SHARED_OPTS=$cf_shared_opts
3094                         MK_SHARED_LIB='${CC} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
3095                 else
3096                         MK_SHARED_LIB='${CC} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
3097                 fi
3098                 ;;
3099         sysv5uw7*|unix_sv*) #(vi
3100                 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
3101                 if test "$GCC" != yes; then
3102                         CC_SHARED_OPTS='-KPIC'
3103                 fi
3104                 MK_SHARED_LIB='${LD} -d y -G -o [$]@'
3105                 ;;
3106         *)
3107                 CC_SHARED_OPTS='unknown'
3108                 MK_SHARED_LIB='echo unknown'
3109                 ;;
3110         esac
3111
3112         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
3113         case "$cf_cv_shlib_version" in #(vi
3114         rel|abi)
3115                 case "$MK_SHARED_LIB" in #(vi
3116                 *'-o $[@]') #(vi
3117                         test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
3118                         ;;
3119                 *)
3120                         AC_MSG_WARN(ignored --with-shlib-version)
3121                         ;;
3122                 esac
3123                 ;;
3124         esac
3125
3126         if test -n "$cf_ld_rpath_opt" ; then
3127                 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${libdir}"
3128         fi
3129
3130         AC_SUBST(CC_SHARED_OPTS)
3131         AC_SUBST(LD_RPATH_OPT)
3132         AC_SUBST(LD_SHARED_OPTS)
3133         AC_SUBST(MK_SHARED_LIB)
3134         AC_SUBST(LINK_PROGS)
3135         AC_SUBST(LINK_TESTS)
3136         AC_SUBST(EXTRA_LDFLAGS)
3137         AC_SUBST(LOCAL_LDFLAGS)
3138         AC_SUBST(LOCAL_LDFLAGS2)
3139         AC_SUBST(INSTALL_LIB)
3140 ])dnl
3141 dnl ---------------------------------------------------------------------------
3142 dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
3143 dnl ----------------
3144 dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
3145 dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
3146 dnl option.
3147 dnl
3148 dnl $1 is the default that should be used for "$cf_cv_shlib_version".
3149 dnl If missing, use "rel".
3150 define([CF_SHARED_SONAME],
3151 [
3152         test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
3153         if test "$cf_cv_shlib_version" = rel; then
3154                 cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
3155         else
3156                 cf_cv_shared_soname='`basename $[@]`'
3157         fi
3158 ])
3159 dnl ---------------------------------------------------------------------------
3160 dnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
3161 dnl --------------
3162 dnl     Remove "-g" option from the compiler options
3163 AC_DEFUN([CF_STRIP_G_OPT],
3164 [$1=`echo ${$1} | sed -e 's%-g %%' -e 's%-g$%%'`])dnl
3165 dnl ---------------------------------------------------------------------------
3166 dnl CF_SUBDIR_PATH version: 6 updated: 2010/04/21 06:20:50
3167 dnl --------------
3168 dnl Construct a search-list for a nonstandard header/lib-file
3169 dnl     $1 = the variable to return as result
3170 dnl     $2 = the package name
3171 dnl     $3 = the subdirectory, e.g., bin, include or lib
3172 AC_DEFUN([CF_SUBDIR_PATH],
3173 [
3174 $1=
3175
3176 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
3177 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
3178 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
3179 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
3180 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
3181 ])dnl
3182 dnl ---------------------------------------------------------------------------
3183 dnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
3184 dnl --------
3185 dnl     Shorthand macro for substituting things that the user may override
3186 dnl     with an environment variable.
3187 dnl
3188 dnl     $1 = long/descriptive name
3189 dnl     $2 = environment variable
3190 dnl     $3 = default value
3191 AC_DEFUN([CF_SUBST],
3192 [AC_CACHE_VAL(cf_cv_subst_$2,[
3193 AC_MSG_CHECKING(for $1 (symbol $2))
3194 CF_SUBST_IF([-z "[$]$2"], [$2], [$3])
3195 cf_cv_subst_$2=[$]$2
3196 AC_MSG_RESULT([$]$2)
3197 ])
3198 ])dnl
3199 dnl ---------------------------------------------------------------------------
3200 dnl CF_TERM_HEADER version: 2 updated: 2010/10/23 15:54:49
3201 dnl --------------
3202 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
3203 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
3204 dnl but some packagers change this, breaking various applications.
3205 AC_DEFUN([CF_TERM_HEADER],[
3206 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
3207 case ${cf_cv_ncurses_header} in #(vi
3208 */ncurses.h|*/ncursesw.h) #(vi
3209         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
3210         ;;
3211 *)
3212         cf_term_header=term.h
3213         ;;
3214 esac
3215
3216 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
3217 do
3218 AC_TRY_COMPILE([#include <stdio.h>
3219 #include <${cf_cv_ncurses_header:-curses.h}>
3220 #include <$cf_test>
3221 ],[int x = auto_left_margin],[
3222         cf_cv_term_header="$cf_test"],[
3223         cf_cv_term_header=unknown
3224         ])
3225         test "$cf_cv_term_header" != unknown && break
3226 done
3227 ])
3228
3229 # Set definitions to allow ifdef'ing to accommodate subdirectories
3230
3231 case $cf_cv_term_header in # (vi
3232 *term.h)
3233         AC_DEFINE(HAVE_TERM_H)
3234         ;;
3235 esac
3236
3237 case $cf_cv_term_header in # (vi
3238 ncurses/term.h) #(vi
3239         AC_DEFINE(HAVE_NCURSES_TERM_H)
3240         ;;
3241 ncursesw/term.h)
3242         AC_DEFINE(HAVE_NCURSESW_TERM_H)
3243         ;;
3244 esac
3245 ])dnl
3246 dnl ---------------------------------------------------------------------------
3247 dnl CF_TOP_BUILDDIR version: 1 updated: 2006/10/15 16:33:23
3248 dnl ---------------
3249 dnl Define a top_builddir symbol, for applications that need an absolute path.
3250 AC_DEFUN([CF_TOP_BUILDDIR],
3251 [
3252 top_builddir=`pwd`
3253 AC_SUBST(top_builddir)
3254 ])dnl
3255 dnl ---------------------------------------------------------------------------
3256 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3257 dnl --------
3258 dnl Make an uppercase version of a variable
3259 dnl $1=uppercase($2)
3260 AC_DEFUN([CF_UPPER],
3261 [
3262 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3263 ])dnl
3264 dnl ---------------------------------------------------------------------------
3265 dnl CF_UTF8_LIB version: 7 updated: 2010/06/20 09:24:28
3266 dnl -----------
3267 dnl Check for multibyte support, and if not found, utf8 compatibility library
3268 AC_DEFUN([CF_UTF8_LIB],
3269 [
3270 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3271         cf_save_LIBS="$LIBS"
3272         AC_TRY_LINK([
3273 #include <stdlib.h>],[putwc(0,0);],
3274         [cf_cv_utf8_lib=yes],
3275         [CF_FIND_LINKAGE([
3276 #include <libutf8.h>],[putwc(0,0);],utf8,
3277                 [cf_cv_utf8_lib=add-on],
3278                 [cf_cv_utf8_lib=no])
3279 ])])
3280
3281 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3282 # ncurses/ncursesw:
3283 if test "$cf_cv_utf8_lib" = "add-on" ; then
3284         AC_DEFINE(HAVE_LIBUTF8_H)
3285         CF_ADD_INCDIR($cf_cv_header_path_utf8)
3286         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
3287         CF_ADD_LIBS($cf_cv_library_file_utf8)
3288 fi
3289 ])dnl
3290 dnl ---------------------------------------------------------------------------
3291 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3292 dnl ----------
3293 dnl Use AC_VERBOSE w/o the warnings
3294 AC_DEFUN([CF_VERBOSE],
3295 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
3296 CF_MSG_LOG([$1])
3297 ])dnl
3298 dnl ---------------------------------------------------------------------------
3299 dnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06
3300 dnl ---------------
3301 dnl Check for compiler-support for weak symbols.
3302 dnl This works with "recent" gcc.
3303 AC_DEFUN([CF_WEAK_SYMBOLS],[
3304 AC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[
3305
3306 AC_TRY_COMPILE([
3307 #include <stdio.h>],
3308 [
3309 #if defined(__GNUC__)
3310 #  if defined __USE_ISOC99
3311 #    define _cat_pragma(exp)    _Pragma(#exp)
3312 #    define _weak_pragma(exp)   _cat_pragma(weak name)
3313 #  else
3314 #    define _weak_pragma(exp)
3315 #  endif
3316 #  define _declare(name)        __extension__ extern __typeof__(name) name
3317 #  define weak_symbol(name)     _weak_pragma(name) _declare(name) __attribute__((weak))
3318 #endif
3319
3320 weak_symbol(fopen);
3321 ],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
3322 ])
3323 ])dnl
3324 dnl ---------------------------------------------------------------------------
3325 dnl CF_WITH_ADA_COMPILER version: 2 updated: 2010/06/26 17:35:58
3326 dnl --------------------
3327 dnl Command-line option to specify the Ada95 compiler.
3328 AC_DEFUN([CF_WITH_ADA_COMPILER],[
3329 AC_MSG_CHECKING(for ada-compiler)
3330 AC_ARG_WITH(ada-compiler,
3331         [  --with-ada-compiler=CMD specify Ada95 compiler command (default gnatmake)],
3332         [cf_ada_compiler=$withval],
3333         [cf_ada_compiler=gnatmake])
3334 AC_SUBST(cf_ada_compiler)
3335 AC_MSG_RESULT($cf_ada_compiler)
3336 ])dnl
3337 dnl ---------------------------------------------------------------------------
3338 dnl CF_WITH_ADA_INCLUDE version: 2 updated: 2010/06/26 17:35:58
3339 dnl -------------------
3340 dnl Command-line option to specify where Ada includes will install.
3341 AC_DEFUN([CF_WITH_ADA_INCLUDE],[
3342 AC_MSG_CHECKING(for ada-include)
3343 CF_WITH_PATH(ada-include,
3344    [  --with-ada-include=DIR  Ada includes are in DIR],
3345    ADA_INCLUDE,
3346    PREFIX/share/ada/adainclude,
3347    [$]prefix/share/ada/adainclude)
3348 AC_SUBST(ADA_INCLUDE)
3349 AC_MSG_RESULT($ADA_INCLUDE)
3350 ])dnl
3351 dnl ---------------------------------------------------------------------------
3352 dnl CF_WITH_ADA_OBJECTS version: 2 updated: 2010/06/26 17:35:58
3353 dnl -------------------
3354 dnl Command-line option to specify where Ada objects will install.
3355 AC_DEFUN([CF_WITH_ADA_OBJECTS],[
3356 AC_MSG_CHECKING(for ada-objects)
3357 CF_WITH_PATH(ada-objects,
3358    [  --with-ada-objects=DIR  Ada objects are in DIR],
3359    ADA_OBJECTS,
3360    PREFIX/lib/ada/adalib,
3361    [$]prefix/lib/ada/adalib)
3362 AC_SUBST(ADA_OBJECTS)
3363 AC_MSG_RESULT($ADA_OBJECTS)
3364 ])dnl
3365 dnl ---------------------------------------------------------------------------
3366 dnl CF_WITH_ADA_SHAREDLIB version: 2 updated: 2010/06/26 17:35:58
3367 dnl ---------------------
3368 dnl Command-line option to specify if an Ada95 shared-library should be built,
3369 dnl and optionally what its soname should be.
3370 AC_DEFUN([CF_WITH_ADA_SHAREDLIB],[
3371 AC_MSG_CHECKING(if an Ada95 shared-library should be built)
3372 AC_ARG_WITH(ada-sharedlib,
3373         [  --with-ada-sharedlib=XX build Ada95 shared-library],
3374         [with_ada_sharedlib=$withval],
3375         [with_ada_sharedlib=no])
3376 AC_MSG_RESULT($with_ada_sharedlib)
3377
3378 ADA_SHAREDLIB='lib$(LIB_NAME).so.1'
3379 MAKE_ADA_SHAREDLIB="#"
3380
3381 if test "x$with_ada_sharedlib" != xno
3382 then
3383         MAKE_ADA_SHAREDLIB=
3384         if test "x$with_ada_sharedlib" != xyes
3385         then
3386                 ADA_SHAREDLIB="$with_ada_sharedlib"
3387         fi
3388 fi
3389
3390 AC_SUBST(ADA_SHAREDLIB)
3391 AC_SUBST(MAKE_ADA_SHAREDLIB)
3392 ])dnl
3393 dnl ---------------------------------------------------------------------------
3394 dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
3395 dnl ------------------
3396 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3397 dnl libraries.
3398 AC_DEFUN([CF_WITH_CURSES_DIR],[
3399
3400 AC_MSG_CHECKING(for specific curses-directory)
3401 AC_ARG_WITH(curses-dir,
3402         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
3403         [cf_cv_curses_dir=$withval],
3404         [cf_cv_curses_dir=no])
3405 AC_MSG_RESULT($cf_cv_curses_dir)
3406
3407 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
3408 then
3409         CF_PATH_SYNTAX(withval)
3410         if test -d "$cf_cv_curses_dir"
3411         then
3412                 CF_ADD_INCDIR($cf_cv_curses_dir/include)
3413                 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
3414         fi
3415 fi
3416 ])dnl
3417 dnl ---------------------------------------------------------------------------
3418 dnl CF_WITH_PATH version: 10 updated: 2010/10/23 15:44:18
3419 dnl ------------
3420 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
3421 dnl defaulting to yes/no.
3422 dnl
3423 dnl $1 = option name
3424 dnl $2 = help-text
3425 dnl $3 = environment variable to set
3426 dnl $4 = default value, shown in the help-message, must be a constant
3427 dnl $5 = default value, if it's an expression & cannot be in the help-message
3428 dnl
3429 AC_DEFUN([CF_WITH_PATH],
3430 [AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
3431 ifelse([$4],,[withval="${$3}"],[withval="${$3:-ifelse([$5],,[$4],[$5])}"]))dnl
3432 if ifelse([$5],,true,[test -n "$5"]) ; then
3433 CF_PATH_SYNTAX(withval)
3434 fi
3435 $3="$withval"
3436 AC_SUBST($3)dnl
3437 ])dnl
3438 dnl ---------------------------------------------------------------------------
3439 dnl CF_WITH_PTHREAD version: 3 updated: 2010/05/29 16:31:02
3440 dnl ---------------
3441 dnl Check for POSIX thread library.
3442 AC_DEFUN([CF_WITH_PTHREAD],
3443 [
3444 AC_MSG_CHECKING(if you want to link with the pthread library)
3445 AC_ARG_WITH(pthread,
3446     [  --with-pthread          use POSIX thread library],
3447     [with_pthread=$withval],
3448     [with_pthread=no])
3449 AC_MSG_RESULT($with_pthread)
3450
3451 if test "$with_pthread" != no ; then
3452     AC_CHECK_HEADER(pthread.h,[
3453         AC_DEFINE(HAVE_PTHREADS_H)
3454
3455         AC_MSG_CHECKING(if we can link with the pthread library)
3456         cf_save_LIBS="$LIBS"
3457         CF_ADD_LIB(pthread)
3458         AC_TRY_LINK([
3459 #include <pthread.h>
3460 ],[
3461         int rc = pthread_create(0,0,0,0);
3462 ],[with_pthread=yes],[with_pthread=no])
3463         LIBS="$cf_save_LIBS"
3464         AC_MSG_RESULT($with_pthread)
3465
3466         if test "$with_pthread" = yes ; then
3467             CF_ADD_LIB(pthread)
3468             AC_DEFINE(HAVE_LIBPTHREADS)
3469         else
3470             AC_MSG_ERROR(Cannot link with pthread library)
3471         fi
3472     ])
3473 fi
3474 ])
3475 dnl ---------------------------------------------------------------------------
3476 dnl CF_XOPEN_SOURCE version: 35 updated: 2011/02/20 20:37:37
3477 dnl ---------------
3478 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3479 dnl or adapt to the vendor's definitions to get equivalent functionality,
3480 dnl without losing the common non-POSIX features.
3481 dnl
3482 dnl Parameters:
3483 dnl     $1 is the nominal value for _XOPEN_SOURCE
3484 dnl     $2 is the nominal value for _POSIX_C_SOURCE
3485 AC_DEFUN([CF_XOPEN_SOURCE],[
3486
3487 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3488 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3489 cf_xopen_source=
3490
3491 case $host_os in #(vi
3492 aix[[456]]*) #(vi
3493         cf_xopen_source="-D_ALL_SOURCE"
3494         ;;
3495 cygwin) #(vi
3496         cf_XOPEN_SOURCE=600
3497         ;;
3498 darwin[[0-8]].*) #(vi
3499         cf_xopen_source="-D_APPLE_C_SOURCE"
3500         ;;
3501 darwin*) #(vi
3502         cf_xopen_source="-D_DARWIN_C_SOURCE"
3503         ;;
3504 freebsd*|dragonfly*) #(vi
3505         # 5.x headers associate
3506         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3507         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3508         cf_POSIX_C_SOURCE=200112L
3509         cf_XOPEN_SOURCE=600
3510         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3511         ;;
3512 hpux11*) #(vi
3513         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3514         ;;
3515 hpux*) #(vi
3516         cf_xopen_source="-D_HPUX_SOURCE"
3517         ;;
3518 irix[[56]].*) #(vi
3519         cf_xopen_source="-D_SGI_SOURCE"
3520         ;;
3521 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
3522         CF_GNU_SOURCE
3523         ;;
3524 mirbsd*) #(vi
3525         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
3526         ;;
3527 netbsd*) #(vi
3528         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3529         ;;
3530 openbsd*) #(vi
3531         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3532         ;;
3533 osf[[45]]*) #(vi
3534         cf_xopen_source="-D_OSF_SOURCE"
3535         ;;
3536 nto-qnx*) #(vi
3537         cf_xopen_source="-D_QNX_SOURCE"
3538         ;;
3539 sco*) #(vi
3540         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3541         ;;
3542 solaris2.1[[0-9]]) #(vi
3543         cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3544         ;;
3545 solaris2.[[1-9]]) #(vi
3546         cf_xopen_source="-D__EXTENSIONS__"
3547         ;;
3548 *)
3549         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
3550         AC_TRY_COMPILE([#include <sys/types.h>],[
3551 #ifndef _XOPEN_SOURCE
3552 make an error
3553 #endif],
3554         [cf_cv_xopen_source=no],
3555         [cf_save="$CPPFLAGS"
3556          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3557          AC_TRY_COMPILE([#include <sys/types.h>],[
3558 #ifdef _XOPEN_SOURCE
3559 make an error
3560 #endif],
3561         [cf_cv_xopen_source=no],
3562         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3563         CPPFLAGS="$cf_save"
3564         ])
3565 ])
3566         if test "$cf_cv_xopen_source" != no ; then
3567                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3568                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3569                 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3570                 CF_ADD_CFLAGS($cf_temp_xopen_source)
3571         fi
3572         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3573         ;;
3574 esac
3575
3576 if test -n "$cf_xopen_source" ; then
3577         CF_ADD_CFLAGS($cf_xopen_source)
3578 fi
3579 ])