]> ncurses.scripts.mit.edu Git - ncurses.git/blob - aclocal.m4
ncurses 5.7 - patch 20100130
[ncurses.git] / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
3 dnl                                                                          *
4 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
5 dnl copy of this software and associated documentation files (the            *
6 dnl "Software"), to deal in the Software without restriction, including      *
7 dnl without limitation the rights to use, copy, modify, merge, publish,      *
8 dnl distribute, distribute with modifications, sublicense, and/or sell       *
9 dnl copies of the Software, and to permit persons to whom the Software is    *
10 dnl furnished to do so, subject to the following conditions:                 *
11 dnl                                                                          *
12 dnl The above copyright notice and this permission notice shall be included  *
13 dnl in all copies or substantial portions of the Software.                   *
14 dnl                                                                          *
15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 dnl                                                                          *
23 dnl Except as contained in this notice, the name(s) of the above copyright   *
24 dnl holders shall not be used in advertising or otherwise to promote the     *
25 dnl sale, use or other dealings in this Software without prior written       *
26 dnl authorization.                                                           *
27 dnl***************************************************************************
28 dnl
29 dnl Author: Thomas E. Dickey 1995-on
30 dnl
31 dnl $Id: aclocal.m4,v 1.491 2010/01/30 23:42:10 tom Exp $
32 dnl Macros used in NCURSES auto-configuration script.
33 dnl
34 dnl These macros are maintained separately from NCURSES.  The copyright on
35 dnl this file applies to the aggregation of macros and does not affect use of
36 dnl these macros in other applications.
37 dnl
38 dnl See http://invisible-island.net/autoconf/ for additional information.
39 dnl
40 dnl ---------------------------------------------------------------------------
41 dnl ---------------------------------------------------------------------------
42 dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
43 dnl -------------------
44 dnl Inserted as requested by gettext 0.10.40
45 dnl File from /usr/share/aclocal
46 dnl codeset.m4
47 dnl ====================
48 dnl serial AM1
49 dnl
50 dnl From Bruno Haible.
51 AC_DEFUN([AM_LANGINFO_CODESET],
52 [
53   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
54     [AC_TRY_LINK([#include <langinfo.h>],
55       [char* cs = nl_langinfo(CODESET);],
56       am_cv_langinfo_codeset=yes,
57       am_cv_langinfo_codeset=no)
58     ])
59   if test $am_cv_langinfo_codeset = yes; then
60     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
61       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
62   fi
63 ])dnl
64 dnl ---------------------------------------------------------------------------
65 dnl CF_ADA_INCLUDE_DIRS version: 5 updated: 2006/10/14 15:23:15
66 dnl -------------------
67 dnl Construct the list of include-options for the C programs in the Ada95
68 dnl binding.
69 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
70 [
71 ACPPFLAGS="-I. -I../../include $ACPPFLAGS"
72 if test "$srcdir" != "."; then
73         ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
74 fi
75 if test "$GCC" != yes; then
76         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
77 elif test "$includedir" != "/usr/include"; then
78         if test "$includedir" = '${prefix}/include' ; then
79                 if test $prefix != /usr ; then
80                         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
81                 fi
82         else
83                 ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
84         fi
85 fi
86 AC_SUBST(ACPPFLAGS)
87 ])dnl
88 dnl ---------------------------------------------------------------------------
89 dnl CF_ADD_CFLAGS version: 9 updated: 2010/01/09 11:05:50
90 dnl -------------
91 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
92 dnl The second parameter if given makes this macro verbose.
93 dnl
94 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
95 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
96 dnl confused by the quotes (which require backslashes to keep them usable).
97 AC_DEFUN([CF_ADD_CFLAGS],
98 [
99 cf_fix_cppflags=no
100 cf_new_cflags=
101 cf_new_cppflags=
102 cf_new_extra_cppflags=
103
104 for cf_add_cflags in $1
105 do
106 case $cf_fix_cppflags in
107 no)
108         case $cf_add_cflags in #(vi
109         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
110                 case $cf_add_cflags in
111                 -D*)
112                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
113
114                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
115                                 && test -z "${cf_tst_cflags}" \
116                                 && cf_fix_cppflags=yes
117
118                         if test $cf_fix_cppflags = yes ; then
119                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
120                                 continue
121                         elif test "${cf_tst_cflags}" = "\"'" ; then
122                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
123                                 continue
124                         fi
125                         ;;
126                 esac
127                 case "$CPPFLAGS" in
128                 *$cf_add_cflags) #(vi
129                         ;;
130                 *) #(vi
131                         case $cf_add_cflags in #(vi
132                         -D*)
133                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
134                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
135                                 ;;
136                         esac
137                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
138                         ;;
139                 esac
140                 ;;
141         *)
142                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
143                 ;;
144         esac
145         ;;
146 yes)
147         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
148
149         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
150
151         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
152                 && test -z "${cf_tst_cflags}" \
153                 && cf_fix_cppflags=no
154         ;;
155 esac
156 done
157
158 if test -n "$cf_new_cflags" ; then
159         ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
160         CFLAGS="$CFLAGS $cf_new_cflags"
161 fi
162
163 if test -n "$cf_new_cppflags" ; then
164         ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
165         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
166 fi
167
168 if test -n "$cf_new_extra_cppflags" ; then
169         ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
170         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
171 fi
172
173 AC_SUBST(EXTRA_CPPFLAGS)
174
175 ])dnl
176 dnl ---------------------------------------------------------------------------
177 dnl CF_ADD_INCDIR version: 12 updated: 2009/01/18 10:00:47
178 dnl -------------
179 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
180 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
181 dnl but old versions (and some misinstalled ones) need that.  To make things
182 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
183 dnl the include-path).
184 AC_DEFUN([CF_ADD_INCDIR],
185 [
186 if test -n "$1" ; then
187   for cf_add_incdir in $1
188   do
189         while test $cf_add_incdir != /usr/include
190         do
191           if test -d $cf_add_incdir
192           then
193                 cf_have_incdir=no
194                 if test -n "$CFLAGS$CPPFLAGS" ; then
195                   # a loop is needed to ensure we can add subdirs of existing dirs
196                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
197                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
198                           cf_have_incdir=yes; break
199                         fi
200                   done
201                 fi
202
203                 if test "$cf_have_incdir" = no ; then
204                   if test "$cf_add_incdir" = /usr/local/include ; then
205                         if test "$GCC" = yes
206                         then
207                           cf_save_CPPFLAGS=$CPPFLAGS
208                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
209                           AC_TRY_COMPILE([#include <stdio.h>],
210                                   [printf("Hello")],
211                                   [],
212                                   [cf_have_incdir=yes])
213                           CPPFLAGS=$cf_save_CPPFLAGS
214                         fi
215                   fi
216                 fi
217
218                 if test "$cf_have_incdir" = no ; then
219                   CF_VERBOSE(adding $cf_add_incdir to include-path)
220                   ifelse($2,,CPPFLAGS,$2)="$ifelse($2,,CPPFLAGS,$2) -I$cf_add_incdir"
221
222                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
223                   test "$cf_top_incdir" = "$cf_add_incdir" && break
224                   cf_add_incdir="$cf_top_incdir"
225                 else
226                   break
227                 fi
228           fi
229         done
230   done
231 fi
232 ])dnl
233 dnl ---------------------------------------------------------------------------
234 dnl CF_ADD_LIBDIR version: 8 updated: 2009/01/18 10:01:08
235 dnl -------------
236 dnl     Adds to the library-path
237 dnl
238 dnl     Some machines have trouble with multiple -L options.
239 dnl
240 dnl $1 is the (list of) directory(s) to add
241 dnl $2 is the optional name of the variable to update (default LDFLAGS)
242 dnl
243 AC_DEFUN([CF_ADD_LIBDIR],
244 [
245 if test -n "$1" ; then
246   for cf_add_libdir in $1
247   do
248     if test $cf_add_libdir = /usr/lib ; then
249       :
250     elif test -d $cf_add_libdir
251     then
252       cf_have_libdir=no
253       if test -n "$LDFLAGS$LIBS" ; then
254         # a loop is needed to ensure we can add subdirs of existing dirs
255         for cf_test_libdir in $LDFLAGS $LIBS ; do
256           if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
257             cf_have_libdir=yes; break
258           fi
259         done
260       fi
261       if test "$cf_have_libdir" = no ; then
262         CF_VERBOSE(adding $cf_add_libdir to library-path)
263         ifelse($2,,LDFLAGS,$2)="-L$cf_add_libdir $ifelse($2,,LDFLAGS,$2)"
264       fi
265     fi
266   done
267 fi
268 ])dnl
269 dnl ---------------------------------------------------------------------------
270 dnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59
271 dnl ------------------
272 dnl Append to a search-list for a nonstandard header/lib-file
273 dnl     $1 = the variable to return as result
274 dnl     $2 = the package name
275 dnl     $3 = the subdirectory, e.g., bin, include or lib
276 dnl $4 = the directory under which we will test for subdirectories
277 dnl $5 = a directory that we do not want $4 to match
278 AC_DEFUN([CF_ADD_SUBDIR_PATH],
279 [
280 test "$4" != "$5" && \
281 test -d "$4" && \
282 ifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) {
283         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
284         test -d $4/$3 &&          $1="[$]$1 $4/$3"
285         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
286         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
287         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
288         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
289 }
290 ])dnl
291 dnl ---------------------------------------------------------------------------
292 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
293 dnl ----------------
294 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
295 dnl in the sharutils 4.2 distribution.
296 AC_DEFUN([CF_ANSI_CC_CHECK],
297 [
298 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
299 cf_cv_ansi_cc=no
300 cf_save_CFLAGS="$CFLAGS"
301 cf_save_CPPFLAGS="$CPPFLAGS"
302 # Don't try gcc -ansi; that turns off useful extensions and
303 # breaks some systems' header files.
304 # AIX                   -qlanglvl=ansi
305 # Ultrix and OSF/1      -std1
306 # HP-UX                 -Aa -D_HPUX_SOURCE
307 # SVR4                  -Xc
308 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
309 for cf_arg in "-DCC_HAS_PROTOS" \
310         "" \
311         -qlanglvl=ansi \
312         -std1 \
313         -Ae \
314         "-Aa -D_HPUX_SOURCE" \
315         -Xc
316 do
317         CF_ADD_CFLAGS($cf_arg)
318         AC_TRY_COMPILE(
319 [
320 #ifndef CC_HAS_PROTOS
321 #if !defined(__STDC__) || (__STDC__ != 1)
322 choke me
323 #endif
324 #endif
325 ],[
326         int test (int i, double x);
327         struct s1 {int (*f) (int a);};
328         struct s2 {int (*f) (double a);};],
329         [cf_cv_ansi_cc="$cf_arg"; break])
330 done
331 CFLAGS="$cf_save_CFLAGS"
332 CPPFLAGS="$cf_save_CPPFLAGS"
333 ])
334
335 if test "$cf_cv_ansi_cc" != "no"; then
336 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
337         CF_ADD_CFLAGS($cf_cv_ansi_cc)
338 else
339         AC_DEFINE(CC_HAS_PROTOS)
340 fi
341 fi
342 ])dnl
343 dnl ---------------------------------------------------------------------------
344 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
345 dnl ---------------
346 dnl For programs that must use an ANSI compiler, obtain compiler options that
347 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
348 dnl macros, since tools such as unproto can fake prototypes, but only part of
349 dnl the preprocessor.
350 AC_DEFUN([CF_ANSI_CC_REQD],
351 [AC_REQUIRE([CF_ANSI_CC_CHECK])
352 if test "$cf_cv_ansi_cc" = "no"; then
353         AC_MSG_ERROR(
354 [Your compiler does not appear to recognize prototypes.
355 You have the following choices:
356         a. adjust your compiler options
357         b. get an up-to-date compiler
358         c. use a wrapper such as unproto])
359 fi
360 ])dnl
361 dnl ---------------------------------------------------------------------------
362 dnl CF_AR_FLAGS version: 4 updated: 2009/02/07 13:42:23
363 dnl -----------
364 dnl Check for suitable "ar" (archiver) options for updating an archive.
365 AC_DEFUN([CF_AR_FLAGS],[
366 AC_REQUIRE([CF_PROG_AR])
367
368 AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
369         cf_cv_ar_flags=unknown
370         for cf_ar_flags in -curv curv -crv crv -cqv cqv -rv rv
371         do
372                 rm -f conftest.$ac_cv_objext
373                 rm -f conftest.a
374
375                 cat >conftest.$ac_ext <<EOF
376 #line __oline__ "configure"
377 int     testdata[[3]] = { 123, 456, 789 };
378 EOF
379                 if AC_TRY_EVAL(ac_compile) ; then
380                         $AR $cf_ar_flags conftest.a conftest.$ac_cv_objext 2>&AC_FD_CC 1>/dev/null
381                         if test -f conftest.a ; then
382                                 cf_cv_ar_flags=$cf_ar_flags
383                                 break
384                         fi
385                 else
386                         CF_VERBOSE(cannot compile test-program)
387                         break
388                 fi
389         done
390         rm -f conftest.a conftest.$ac_ext conftest.$ac_cv_objext
391 ])
392 test -z "$ARFLAGS" && ARFLAGS=$cf_cv_ar_flags
393 AC_SUBST(ARFLAGS,$cf_cv_ar_flags)
394 ])
395 dnl ---------------------------------------------------------------------------
396 dnl CF_AWK_BIG_PRINTF version: 3 updated: 2008/12/27 12:30:03
397 dnl -----------------
398 dnl Check if awk can handle big strings using printf.  Some older versions of
399 dnl awk choke on large strings passed via "%s".
400 dnl
401 dnl $1 = desired string size
402 dnl $2 = variable to set with result
403 AC_DEFUN([CF_AWK_BIG_PRINTF],
404 [
405         case x$AWK in #(vi
406         x)
407                 eval $2=no
408                 ;;
409         *) #(vi
410                 if ( ${AWK} 'BEGIN { xx = "x"; while (length(xx) < $1) { xx = xx "x"; }; printf("%s\n", xx); }' \
411                         | $AWK '{ printf "%d\n", length([$]0); }' | $AWK 'BEGIN { eqls=0; recs=0; } { recs++; if ([$]0 == 12000) eqls++; } END { if (recs != 1 || eqls != 1) exit 1; }' 2>/dev/null >/dev/null ) ; then
412                         eval $2=yes
413                 else
414                         eval $2=no
415                 fi
416                 ;;
417         esac
418 ])dnl
419 dnl ---------------------------------------------------------------------------
420 dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18
421 dnl ------------
422 dnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
423 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
424 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
425 dnl
426 dnl Treat the configuration-variable specially here, since we're directly
427 dnl substituting its value (i.e., 1/0).
428 dnl
429 dnl $1 is the shell variable to store the result in, if not $cv_cv_builtin_bool
430 AC_DEFUN([CF_BOOL_DECL],
431 [
432 AC_MSG_CHECKING(if we should include stdbool.h)
433
434 AC_CACHE_VAL(cf_cv_header_stdbool_h,[
435         AC_TRY_COMPILE([],[bool foo = false],
436                 [cf_cv_header_stdbool_h=0],
437                 [AC_TRY_COMPILE([
438 #ifndef __BEOS__
439 #include <stdbool.h>
440 #endif
441 ],[bool foo = false],
442                         [cf_cv_header_stdbool_h=1],
443                         [cf_cv_header_stdbool_h=0])])])
444
445 if test "$cf_cv_header_stdbool_h" = 1
446 then    AC_MSG_RESULT(yes)
447 else    AC_MSG_RESULT(no)
448 fi
449
450 AC_MSG_CHECKING([for builtin bool type])
451
452 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
453         AC_TRY_COMPILE([
454 #include <stdio.h>
455 #include <sys/types.h>
456 ],[bool x = false],
457                 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
458                 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
459         ])
460
461 if test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1
462 then    AC_MSG_RESULT(yes)
463 else    AC_MSG_RESULT(no)
464 fi
465 ])dnl
466 dnl ---------------------------------------------------------------------------
467 dnl CF_BOOL_SIZE version: 12 updated: 2006/12/16 12:33:30
468 dnl ------------
469 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
470 dnl Don't bother looking for bool.h, since it's been deprecated.
471 dnl
472 dnl If the current compiler is C rather than C++, we get the bool definition
473 dnl from <stdbool.h>.
474 AC_DEFUN([CF_BOOL_SIZE],
475 [
476 AC_MSG_CHECKING([for size of bool])
477 AC_CACHE_VAL(cf_cv_type_of_bool,[
478         rm -f cf_test.out
479         AC_TRY_RUN([
480 #include <stdlib.h>
481 #include <stdio.h>
482
483 #if defined(__cplusplus)
484
485 #ifdef HAVE_GXX_BUILTIN_H
486 #include <g++/builtin.h>
487 #elif HAVE_GPP_BUILTIN_H
488 #include <gpp/builtin.h>
489 #elif HAVE_BUILTIN_H
490 #include <builtin.h>
491 #endif
492
493 #else
494
495 #if $cf_cv_header_stdbool_h
496 #include <stdbool.h>
497 #endif
498
499 #endif
500
501 main()
502 {
503         FILE *fp = fopen("cf_test.out", "w");
504         if (fp != 0) {
505                 bool x = true;
506                 if ((bool)(-x) >= 0)
507                         fputs("unsigned ", fp);
508                 if (sizeof(x) == sizeof(int))       fputs("int",  fp);
509                 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
510                 else if (sizeof(x) == sizeof(short))fputs("short",fp);
511                 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
512                 fclose(fp);
513         }
514         ${cf_cv_main_return:-return}(0);
515 }
516                 ],
517                 [cf_cv_type_of_bool=`cat cf_test.out`
518                  if test -z "$cf_cv_type_of_bool"; then
519                    cf_cv_type_of_bool=unknown
520                  fi],
521                 [cf_cv_type_of_bool=unknown],
522                 [cf_cv_type_of_bool=unknown])
523         ])
524         rm -f cf_test.out
525 AC_MSG_RESULT($cf_cv_type_of_bool)
526 if test "$cf_cv_type_of_bool" = unknown ; then
527         case .$NCURSES_BOOL in #(vi
528         .auto|.) NCURSES_BOOL=unsigned;;
529         esac
530         AC_MSG_WARN(Assuming $NCURSES_BOOL for type of bool)
531         cf_cv_type_of_bool=$NCURSES_BOOL
532 fi
533 ])dnl
534 dnl ---------------------------------------------------------------------------
535 dnl CF_BUILD_CC version: 6 updated: 2006/10/14 15:23:15
536 dnl -----------
537 dnl If we're cross-compiling, allow the user to override the tools and their
538 dnl options.  The configure script is oriented toward identifying the host
539 dnl compiler, etc., but we need a build compiler to generate parts of the
540 dnl source.
541 dnl
542 dnl $1 = default for $CPPFLAGS
543 dnl $2 = default for $LIBS
544 AC_DEFUN([CF_BUILD_CC],[
545 AC_REQUIRE([CF_PROG_EXT])
546 if test "$cross_compiling" = yes ; then
547
548         # defaults that we might want to override
549         : ${BUILD_CFLAGS:=''}
550         : ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
551         : ${BUILD_LDFLAGS:=''}
552         : ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
553         : ${BUILD_EXEEXT:='$x'}
554         : ${BUILD_OBJEXT:='o'}
555
556         AC_ARG_WITH(build-cc,
557                 [  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
558                 [BUILD_CC="$withval"],
559                 [AC_CHECK_PROGS(BUILD_CC, gcc cc cl)])
560         AC_MSG_CHECKING(for native build C compiler)
561         AC_MSG_RESULT($BUILD_CC)
562
563         AC_MSG_CHECKING(for native build C preprocessor)
564         AC_ARG_WITH(build-cpp,
565                 [  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
566                 [BUILD_CPP="$withval"],
567                 [BUILD_CPP='${BUILD_CC} -E'])
568         AC_MSG_RESULT($BUILD_CPP)
569
570         AC_MSG_CHECKING(for native build C flags)
571         AC_ARG_WITH(build-cflags,
572                 [  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
573                 [BUILD_CFLAGS="$withval"])
574         AC_MSG_RESULT($BUILD_CFLAGS)
575
576         AC_MSG_CHECKING(for native build C preprocessor-flags)
577         AC_ARG_WITH(build-cppflags,
578                 [  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
579                 [BUILD_CPPFLAGS="$withval"])
580         AC_MSG_RESULT($BUILD_CPPFLAGS)
581
582         AC_MSG_CHECKING(for native build linker-flags)
583         AC_ARG_WITH(build-ldflags,
584                 [  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
585                 [BUILD_LDFLAGS="$withval"])
586         AC_MSG_RESULT($BUILD_LDFLAGS)
587
588         AC_MSG_CHECKING(for native build linker-libraries)
589         AC_ARG_WITH(build-libs,
590                 [  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
591                 [BUILD_LIBS="$withval"])
592         AC_MSG_RESULT($BUILD_LIBS)
593
594         # this assumes we're on Unix.
595         BUILD_EXEEXT=
596         BUILD_OBJEXT=o
597
598         : ${BUILD_CC:='${CC}'}
599
600         if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
601                 AC_MSG_ERROR([Cross-build requires two compilers.
602 Use --with-build-cc to specify the native compiler.])
603         fi
604
605 else
606         : ${BUILD_CC:='${CC}'}
607         : ${BUILD_CPP:='${CPP}'}
608         : ${BUILD_CFLAGS:='${CFLAGS}'}
609         : ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
610         : ${BUILD_LDFLAGS:='${LDFLAGS}'}
611         : ${BUILD_LIBS:='${LIBS}'}
612         : ${BUILD_EXEEXT:='$x'}
613         : ${BUILD_OBJEXT:='o'}
614 fi
615
616 AC_SUBST(BUILD_CC)
617 AC_SUBST(BUILD_CPP)
618 AC_SUBST(BUILD_CFLAGS)
619 AC_SUBST(BUILD_CPPFLAGS)
620 AC_SUBST(BUILD_LDFLAGS)
621 AC_SUBST(BUILD_LIBS)
622 AC_SUBST(BUILD_EXEEXT)
623 AC_SUBST(BUILD_OBJEXT)
624 ])dnl
625 dnl ---------------------------------------------------------------------------
626 dnl CF_CFG_DEFAULTS version: 7 updated: 2005/09/24 16:15:00
627 dnl ---------------
628 dnl Determine the default configuration into which we'll install ncurses.  This
629 dnl can be overridden by the user's command-line options.  There's two items to
630 dnl look for:
631 dnl     1. the prefix (e.g., /usr)
632 dnl     2. the header files (e.g., /usr/include/ncurses)
633 dnl We'll look for a previous installation of ncurses and use the same defaults.
634 dnl
635 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
636 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
637 dnl programs from a vendor's.
638 AC_DEFUN([CF_CFG_DEFAULTS],
639 [
640 AC_MSG_CHECKING(for prefix)
641 if test "x$prefix" = "xNONE" ; then
642         case "$cf_cv_system_name" in
643                 # non-vendor systems don't have a conflict
644         openbsd*|freebsd*|linux*|cygwin*|k*bsd*-gnu)
645                 prefix=/usr
646                 ;;
647         *)      prefix=$ac_default_prefix
648                 ;;
649         esac
650 fi
651 AC_MSG_RESULT($prefix)
652
653 if test "x$prefix" = "xNONE" ; then
654 AC_MSG_CHECKING(for default include-directory)
655 test -n "$verbose" && echo 1>&AC_FD_MSG
656 for cf_symbol in \
657         $includedir \
658         $includedir/ncurses \
659         $prefix/include \
660         $prefix/include/ncurses \
661         /usr/local/include \
662         /usr/local/include/ncurses \
663         /usr/include \
664         /usr/include/ncurses
665 do
666         cf_dir=`eval echo $cf_symbol`
667         if test -f $cf_dir/curses.h ; then
668         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
669                 includedir="$cf_symbol"
670                 test -n "$verbose"  && echo $ac_n "     found " 1>&AC_FD_MSG
671                 break
672         fi
673         fi
674         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
675 done
676 AC_MSG_RESULT($includedir)
677 fi
678 ])dnl
679 dnl ---------------------------------------------------------------------------
680 dnl CF_CGETENT version: 3 updated: 2000/08/12 23:18:52
681 dnl ----------
682 dnl Check if the terminal-capability database functions are available.  If not,
683 dnl ncurses has a much-reduced version.
684 AC_DEFUN([CF_CGETENT],[
685 AC_MSG_CHECKING(for terminal-capability database functions)
686 AC_CACHE_VAL(cf_cv_cgetent,[
687 AC_TRY_LINK([
688 #include <stdlib.h>],[
689         char temp[128];
690         char *buf = temp;
691         char *db_array = temp;
692         cgetent(&buf, /* int *, */ &db_array, "vt100");
693         cgetcap(buf, "tc", '=');
694         cgetmatch(buf, "tc");
695         ],
696         [cf_cv_cgetent=yes],
697         [cf_cv_cgetent=no])
698 ])
699 AC_MSG_RESULT($cf_cv_cgetent)
700 test "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT)
701 ])dnl
702 dnl ---------------------------------------------------------------------------
703 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
704 dnl --------------
705 dnl Check if we're accidentally using a cache from a different machine.
706 dnl Derive the system name, as a check for reusing the autoconf cache.
707 dnl
708 dnl If we've packaged config.guess and config.sub, run that (since it does a
709 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
710 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
711 dnl which is useful in cross-compiles.
712 dnl
713 dnl Note: we would use $ac_config_sub, but that is one of the places where
714 dnl autoconf 2.5x broke compatibility with autoconf 2.13
715 AC_DEFUN([CF_CHECK_CACHE],
716 [
717 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
718         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
719         system_name="$host_os"
720 else
721         system_name="`(uname -s -r) 2>/dev/null`"
722         if test -z "$system_name" ; then
723                 system_name="`(hostname) 2>/dev/null`"
724         fi
725 fi
726 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
727 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
728
729 test -z "$system_name" && system_name="$cf_cv_system_name"
730 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
731
732 if test ".$system_name" != ".$cf_cv_system_name" ; then
733         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
734         AC_MSG_ERROR("Please remove config.cache and try again.")
735 fi
736 ])dnl
737 dnl ---------------------------------------------------------------------------
738 dnl CF_CHECK_ERRNO version: 10 updated: 2008/08/22 16:33:22
739 dnl --------------
740 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
741 dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
742 dnl ourselves.
743 dnl
744 dnl $1 = the name to check
745 dnl $2 = the assumed type
746 AC_DEFUN([CF_CHECK_ERRNO],
747 [
748 AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
749     AC_TRY_COMPILE([
750 #ifdef HAVE_STDLIB_H
751 #include <stdlib.h>
752 #endif
753 #include <stdio.h>
754 #include <sys/types.h>
755 #include <errno.h> ],
756     ifelse($2,,int,$2) x = (ifelse($2,,int,$2)) $1,
757     [cf_cv_dcl_$1=yes],
758     [cf_cv_dcl_$1=no])
759 ])
760
761 if test "$cf_cv_dcl_$1" = no ; then
762     CF_UPPER(cf_result,decl_$1)
763     AC_DEFINE_UNQUOTED($cf_result)
764 fi
765
766 # It's possible (for near-UNIX clones) that the data doesn't exist
767 CF_CHECK_EXTERN_DATA($1,ifelse($2,,int,$2))
768 ])dnl
769 dnl ---------------------------------------------------------------------------
770 dnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
771 dnl --------------------
772 dnl Check for existence of external data in the current set of libraries.  If
773 dnl we can modify it, it's real enough.
774 dnl $1 = the name to check
775 dnl $2 = its type
776 AC_DEFUN([CF_CHECK_EXTERN_DATA],
777 [
778 AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
779     AC_TRY_LINK([
780 #undef $1
781 extern $2 $1;
782 ],
783     [$1 = 2],
784     [cf_cv_have_$1=yes],
785     [cf_cv_have_$1=no])
786 ])
787
788 if test "$cf_cv_have_$1" = yes ; then
789     CF_UPPER(cf_result,have_$1)
790     AC_DEFINE_UNQUOTED($cf_result)
791 fi
792
793 ])dnl
794 dnl ---------------------------------------------------------------------------
795 dnl CF_CHECK_GPM_WGETCH version: 1 updated: 2007/04/28 14:38:06
796 dnl -------------------
797 dnl Check if GPM is already linked with curses.  If so - and if the linkage
798 dnl is not "weak" - warn about this because it can create problems linking
799 dnl applications with ncurses.
800 AC_DEFUN([CF_CHECK_GPM_WGETCH],[
801 AC_CHECK_LIB(gpm,Gpm_Wgetch,[
802
803 AC_CACHE_CHECK(if GPM is weakly bound to curses library, cf_cv_check_gpm_wgetch,[
804 cf_cv_check_gpm_wgetch=unknown
805 if test "$cross_compiling" != yes ; then
806
807 cat >conftest.$ac_ext <<CF_EOF
808 #include <gpm.h>
809 int main()
810 {
811         Gpm_Wgetch();
812         ${cf_cv_main_return:-return}(0);
813 }
814 CF_EOF
815
816         cf_save_LIBS="$LIBS"
817         # This only works if we can look at the symbol table.  If a shared
818         # library is stripped for install, we cannot use that.  So we're forced
819         # to rely on the static library, noting that some packagers may not
820         # include it.
821         LIBS="-static -lgpm -dynamic $LIBS"
822         if AC_TRY_EVAL(ac_compile) ; then
823                 if AC_TRY_EVAL(ac_link) ; then
824                         cf_cv_check_gpm_wgetch=`nm conftest$ac_exeext | egrep '\<wgetch\>' | egrep '\<[[vVwW]]\>'`
825                         test -n "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=yes
826                         test -z "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=no
827                 fi
828         fi
829         rm -f conftest*
830         LIBS="$cf_save_LIBS"
831 fi
832 ])
833
834 if test "$cf_cv_check_gpm_wgetch" != yes ; then
835         AC_MSG_WARN(GPM library is already linked with curses - read the FAQ)
836 fi
837 ])])dnl
838 dnl ---------------------------------------------------------------------------
839 dnl CF_CPP_PARAM_INIT version: 4 updated: 2001/04/07 22:31:18
840 dnl -----------------
841 dnl Check if the C++ compiler accepts duplicate parameter initialization.  This
842 dnl is a late feature for the standard and is not in some recent compilers
843 dnl (1999/9/11).
844 AC_DEFUN([CF_CPP_PARAM_INIT],
845 [
846 if test -n "$CXX"; then
847 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
848         AC_LANG_SAVE
849         AC_LANG_CPLUSPLUS
850         AC_TRY_RUN([
851 class TEST {
852 private:
853         int value;
854 public:
855         TEST(int x = 1);
856         ~TEST();
857 };
858
859 TEST::TEST(int x = 1)   // some compilers do not like second initializer
860 {
861         value = x;
862 }
863 void main() { }
864 ],
865         [cf_cv_cpp_param_init=yes],
866         [cf_cv_cpp_param_init=no],
867         [cf_cv_cpp_param_init=unknown])
868         AC_LANG_RESTORE
869 ])
870 fi
871 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT)
872 ])dnl
873 dnl ---------------------------------------------------------------------------
874 dnl CF_CPP_STATIC_CAST version: 1 updated: 2005/07/23 16:52:43
875 dnl ------------------
876 dnl Check if the C++ compiler accepts static_cast in generics.  This appears to
877 dnl not be supported in g++ before 3.0
878 AC_DEFUN([CF_CPP_STATIC_CAST],
879 [
880 if test -n "$CXX"; then
881
882 AC_CACHE_CHECK(if $CXX accepts static_cast,cf_cv_cpp_static_cast,[
883         AC_LANG_SAVE
884         AC_LANG_CPLUSPLUS
885
886         AC_TRY_COMPILE([
887 class NCursesPanel
888 {
889 public:
890   NCursesPanel(int nlines,
891                int ncols,
892                int begin_y = 0,
893                int begin_x = 0)
894   {
895   }
896
897   ~NCursesPanel();
898 };
899
900 template<class T> class NCursesUserPanel : public NCursesPanel
901 {
902 public:
903   NCursesUserPanel (int nlines,
904                     int ncols,
905                     int begin_y = 0,
906                     int begin_x = 0,
907                     const T* p_UserData = static_cast<T*>(0))
908     : NCursesPanel (nlines, ncols, begin_y, begin_x)
909   {
910   };
911   NCursesUserPanel(const T* p_UserData = static_cast<T*>(0)) : NCursesPanel()
912   {
913   };
914
915   virtual ~NCursesUserPanel() {};
916 };
917 ],[
918         const char* p_UserData = static_cast<char*>(0)],
919         [cf_cv_cpp_static_cast=yes],
920         [cf_cv_cpp_static_cast=no])
921
922         AC_LANG_RESTORE
923 ])
924
925 fi
926
927 test "$cf_cv_cpp_static_cast" = yes && AC_DEFINE(CPP_HAS_STATIC_CAST)
928 ])dnl
929 dnl ---------------------------------------------------------------------------
930 dnl CF_C_INLINE version: 2 updated: 2007/08/11 14:09:50
931 dnl -----------
932 dnl Check if the C compiler supports "inline".
933 dnl $1 is the name of a shell variable to set if inline is supported
934 dnl $2 is the threshold for gcc 4.x's option controlling maximum inline size
935 AC_DEFUN([CF_C_INLINE],[
936 AC_C_INLINE
937 $1=
938 if test "$ac_cv_c_inline" != no ; then
939   $1=inline
940   if test "$INTEL_COMPILER" = yes
941   then
942     :
943   elif test "$GCC" = yes
944   then
945     AC_CACHE_CHECK(if gcc supports options to tune inlining,cf_cv_gcc_inline,[
946       cf_save_CFLAGS=$CFLAGS
947       CFLAGS="$CFLAGS --param max-inline-insns-single=$2"
948       AC_TRY_COMPILE([inline int foo(void) { return 1; }],
949       [${cf_cv_main_return:-return} foo()],
950       [cf_cv_gcc_inline=yes],
951       [cf_cv_gcc_inline=no])
952       CFLAGS=$cf_save_CFLAGS
953     ])
954     if test "$cf_cv_gcc_inline" = yes ; then
955         CF_ADD_CFLAGS([--param max-inline-insns-single=$2])
956     fi
957   fi
958 fi
959 AC_SUBST($1)
960 ])dnl
961 dnl ---------------------------------------------------------------------------
962 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
963 dnl ----------
964 dnl "dirname" is not portable, so we fake it with a shell script.
965 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
966 dnl ---------------------------------------------------------------------------
967 dnl CF_DIRS_TO_MAKE version: 3 updated: 2002/02/23 20:38:31
968 dnl ---------------
969 AC_DEFUN([CF_DIRS_TO_MAKE],
970 [
971 DIRS_TO_MAKE="lib"
972 for cf_item in $cf_list_models
973 do
974         CF_OBJ_SUBDIR($cf_item,cf_subdir)
975         for cf_item2 in $DIRS_TO_MAKE
976         do
977                 test $cf_item2 = $cf_subdir && break
978         done
979         test ".$cf_item2" != ".$cf_subdir" && DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
980 done
981 for cf_dir in $DIRS_TO_MAKE
982 do
983         test ! -d $cf_dir && mkdir $cf_dir
984 done
985 AC_SUBST(DIRS_TO_MAKE)
986 ])dnl
987 dnl ---------------------------------------------------------------------------
988 dnl CF_DISABLE_LEAKS version: 4 updated: 2006/12/16 15:10:42
989 dnl ----------------
990 dnl Combine no-leak checks with the libraries or tools that are used for the
991 dnl checks.
992 AC_DEFUN([CF_DISABLE_LEAKS],[
993
994 AC_REQUIRE([CF_WITH_DMALLOC])
995 AC_REQUIRE([CF_WITH_DBMALLOC])
996 AC_REQUIRE([CF_WITH_VALGRIND])
997
998 AC_MSG_CHECKING(if you want to perform memory-leak testing)
999 AC_ARG_ENABLE(leaks,
1000         [  --disable-leaks         test: free permanent memory, analyze leaks],
1001         [with_no_leaks=yes],
1002         : ${with_no_leaks:=no})
1003 AC_MSG_RESULT($with_no_leaks)
1004
1005 if test "$with_no_leaks" = yes ; then
1006         AC_DEFINE(NO_LEAKS)
1007 fi
1008 ])dnl
1009 dnl ---------------------------------------------------------------------------
1010 dnl CF_ENABLE_RPATH version: 1 updated: 2008/09/13 10:22:30
1011 dnl ---------------
1012 dnl Check if the rpath option should be used, setting cache variable
1013 dnl cf_cv_ld_rpath if so.
1014 AC_DEFUN([CF_ENABLE_RPATH],
1015 [
1016 AC_MSG_CHECKING(if rpath option should be used)
1017 AC_ARG_ENABLE(rpath,
1018 [  --enable-rpath          use rpath option when generating shared libraries],
1019 [cf_cv_ld_rpath=$enableval],
1020 [cf_cv_ld_rpath=no])
1021 AC_MSG_RESULT($cf_cv_ld_rpath)
1022 ])dnl
1023 dnl ---------------------------------------------------------------------------
1024 dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
1025 dnl --------
1026 dnl Check if 'errno' is declared in <errno.h>
1027 AC_DEFUN([CF_ERRNO],
1028 [
1029 CF_CHECK_ERRNO(errno)
1030 ])dnl
1031 dnl ---------------------------------------------------------------------------
1032 dnl CF_ETIP_DEFINES version: 3 updated: 2003/03/22 19:13:43
1033 dnl ---------------
1034 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
1035 dnl math.h and builtin.h, only for ncurses
1036 AC_DEFUN([CF_ETIP_DEFINES],
1037 [
1038 AC_MSG_CHECKING(for special defines needed for etip.h)
1039 cf_save_CXXFLAGS="$CXXFLAGS"
1040 cf_result="none"
1041 for cf_math in "" MATH_H
1042 do
1043 for cf_excp in "" MATH_EXCEPTION
1044 do
1045         CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -I${srcdir}/include"
1046         test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
1047         test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
1048 AC_TRY_COMPILE([
1049 #include <etip.h.in>
1050 ],[],[
1051         test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
1052         test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
1053         cf_result="$cf_math $cf_excp"
1054         break
1055 ],[])
1056 done
1057 done
1058 AC_MSG_RESULT($cf_result)
1059 CXXFLAGS="$cf_save_CXXFLAGS"
1060 ])
1061 dnl ---------------------------------------------------------------------------
1062 dnl CF_FIND_LINKAGE version: 13 updated: 2008/12/24 07:59:55
1063 dnl ---------------
1064 dnl Find a library (specifically the linkage used in the code fragment),
1065 dnl searching for it if it is not already in the library path.
1066 dnl See also CF_ADD_SEARCHPATH.
1067 dnl
1068 dnl Parameters (4-on are optional):
1069 dnl     $1 = headers for library entrypoint
1070 dnl     $2 = code fragment for library entrypoint
1071 dnl     $3 = the library name without the "-l" option or ".so" suffix.
1072 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1073 dnl     $5 = action to perform if not successful
1074 dnl     $6 = module name, if not the same as the library name
1075 dnl     $7 = extra libraries
1076 dnl
1077 dnl Sets these variables:
1078 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1079 dnl     $cf_cv_header_path_$3 - include-directory if needed
1080 dnl     $cf_cv_library_path_$3 - library-directory if needed
1081 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1082 AC_DEFUN([CF_FIND_LINKAGE],[
1083
1084 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1085 # will be set on completion of the AC_TRY_LINK below.
1086 cf_cv_header_path_$3=
1087 cf_cv_library_path_$3=
1088
1089 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1090
1091 AC_TRY_LINK([$1],[$2],
1092     cf_cv_find_linkage_$3=yes,[
1093     cf_cv_find_linkage_$3=no
1094
1095     CF_VERBOSE(find linkage for $3 library)
1096     CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1097
1098     cf_save_CPPFLAGS="$CPPFLAGS"
1099     cf_test_CPPFLAGS="$CPPFLAGS"
1100
1101     CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1102     for cf_cv_header_path_$3 in $cf_search
1103     do
1104       if test -d $cf_cv_header_path_$3 ; then
1105         CF_VERBOSE(... testing $cf_cv_header_path_$3)
1106         CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1107         AC_TRY_COMPILE([$1],[$2],[
1108             CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1109             cf_cv_find_linkage_$3=maybe
1110             cf_test_CPPFLAGS="$CPPFLAGS"
1111             break],[
1112             CPPFLAGS="$cf_save_CPPFLAGS"
1113             ])
1114       fi
1115     done
1116
1117     if test "$cf_cv_find_linkage_$3" = maybe ; then
1118
1119       CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1120
1121       cf_save_LIBS="$LIBS"
1122       cf_save_LDFLAGS="$LDFLAGS"
1123
1124       ifelse([$6],,,[
1125         CPPFLAGS="$cf_test_CPPFLAGS"
1126         LIBS="-l$3 $7 $cf_save_LIBS"
1127         AC_TRY_LINK([$1],[$2],[
1128             CF_VERBOSE(... found $3 library in system)
1129             cf_cv_find_linkage_$3=yes])
1130             CPPFLAGS="$cf_save_CPPFLAGS"
1131             LIBS="$cf_save_LIBS"
1132             ])
1133
1134       if test "$cf_cv_find_linkage_$3" != yes ; then
1135         CF_LIBRARY_PATH(cf_search,$3)
1136         for cf_cv_library_path_$3 in $cf_search
1137         do
1138           if test -d $cf_cv_library_path_$3 ; then
1139             CF_VERBOSE(... testing $cf_cv_library_path_$3)
1140             CPPFLAGS="$cf_test_CPPFLAGS"
1141             LIBS="-l$3 $7 $cf_save_LIBS"
1142             LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1143             AC_TRY_LINK([$1],[$2],[
1144                 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1145                 cf_cv_find_linkage_$3=yes
1146                 cf_cv_library_file_$3="-l$3"
1147                 break],[
1148                 CPPFLAGS="$cf_save_CPPFLAGS"
1149                 LIBS="$cf_save_LIBS"
1150                 LDFLAGS="$cf_save_LDFLAGS"
1151                 ])
1152           fi
1153         done
1154         LIBS="$cf_save_LIBS"
1155         CPPFLAGS="$cf_save_CPPFLAGS"
1156         LDFLAGS="$cf_save_LDFLAGS"
1157       fi
1158
1159     else
1160       cf_cv_find_linkage_$3=no
1161     fi
1162     ],$7)
1163
1164 if test "$cf_cv_find_linkage_$3" = yes ; then
1165 ifelse([$4],,[
1166   CF_ADD_INCDIR($cf_cv_header_path_$3)
1167   CF_ADD_LIBDIR($cf_cv_library_path_$3)
1168   LIBS="-l$3 $LIBS"
1169 ],[$4])
1170 else
1171 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1172 fi
1173 ])dnl
1174 dnl ---------------------------------------------------------------------------
1175 dnl CF_FUNC_DLSYM version: 1 updated: 2004/06/16 20:52:45
1176 dnl -------------
1177 dnl Test for dlsym() and related functions, as well as libdl.
1178 dnl
1179 dnl Sets
1180 dnl     $cf_have_dlsym
1181 dnl     $cf_have_libdl
1182 AC_DEFUN([CF_FUNC_DLSYM],[
1183 cf_have_dlsym=no
1184 AC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
1185
1186 cf_have_libdl=no
1187 AC_CHECK_LIB(dl,dlsym,[
1188         cf_have_dlsym=yes
1189         cf_have_libdl=yes])])
1190
1191 if test "$cf_have_dlsym" = yes ; then
1192         test "$cf_have_libdl" = yes && LIBS="-ldl $LIBS"
1193
1194         AC_MSG_CHECKING(whether able to link to dl*() functions)
1195         AC_TRY_LINK([#include <dlfcn.h>],[
1196                 void *obj;
1197                 if ((obj = dlopen("filename", 0)) != 0) {
1198                         if (dlsym(obj, "symbolname") == 0) {
1199                         dlclose(obj);
1200                         }
1201                 }],[
1202                 AC_DEFINE(HAVE_LIBDL)],[
1203                 AC_MSG_ERROR(Cannot link test program for libdl)])
1204         AC_MSG_RESULT(ok)
1205 else
1206         AC_MSG_ERROR(Cannot find dlsym function)
1207 fi
1208 ])
1209 dnl ---------------------------------------------------------------------------
1210 dnl CF_FUNC_MEMMOVE version: 7 updated: 2006/12/16 12:33:30
1211 dnl ---------------
1212 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
1213 dnl is found, add our own version of memmove to the list of objects.
1214 AC_DEFUN([CF_FUNC_MEMMOVE],
1215 [
1216 AC_CHECK_FUNC(memmove,,[
1217 AC_CHECK_FUNC(bcopy,[
1218         AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
1219                 AC_TRY_RUN([
1220 int main() {
1221         static char data[] = "abcdefghijklmnopqrstuwwxyz";
1222         char temp[40];
1223         bcopy(data, temp, sizeof(data));
1224         bcopy(temp+10, temp, 15);
1225         bcopy(temp+5, temp+15, 10);
1226         ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
1227 }
1228                 ],
1229                 [cf_cv_good_bcopy=yes],
1230                 [cf_cv_good_bcopy=no],
1231                 [cf_cv_good_bcopy=unknown])
1232                 ])
1233         ],[cf_cv_good_bcopy=no])
1234         if test "$cf_cv_good_bcopy" = yes ; then
1235                 AC_DEFINE(USE_OK_BCOPY)
1236         else
1237                 AC_DEFINE(USE_MY_MEMMOVE)
1238         fi
1239 ])])dnl
1240 dnl ---------------------------------------------------------------------------
1241 dnl CF_FUNC_NANOSLEEP version: 3 updated: 2006/12/16 12:33:30
1242 dnl -----------------
1243 dnl Check for existence of workable nanosleep() function.  Some systems, e.g.,
1244 dnl AIX 4.x, provide a non-working version.
1245 AC_DEFUN([CF_FUNC_NANOSLEEP],[
1246 AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[
1247 AC_TRY_RUN([
1248 #include <stdio.h>
1249 #include <errno.h>
1250 #include <time.h>
1251
1252 #ifdef HAVE_SYS_TIME_H
1253 #include <sys/time.h>
1254 #endif
1255
1256 int main() {
1257         struct timespec ts1, ts2;
1258         int code;
1259         ts1.tv_sec  = 0;
1260         ts1.tv_nsec = 750000000;
1261         ts2.tv_sec  = 0;
1262         ts2.tv_nsec = 0;
1263         errno = 0;
1264         code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */
1265         ${cf_cv_main_return:-return}(code != 0);
1266 }
1267 ],
1268         [cf_cv_func_nanosleep=yes],
1269         [cf_cv_func_nanosleep=no],
1270         [cf_cv_func_nanosleep=unknown])])
1271
1272 test "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP)
1273 ])
1274 dnl ---------------------------------------------------------------------------
1275 dnl CF_FUNC_OPENPTY version: 2 updated: 2008/04/12 19:49:01
1276 dnl ---------------
1277 dnl Check for openpty() function, along with <pty.h> header.  It may need the
1278 dnl "util" library as well.
1279 AC_DEFUN([CF_FUNC_OPENPTY],
1280 [
1281 AC_CHECK_LIB(util,openpty,cf_cv_lib_util=yes,cf_cv_lib_util=no)
1282 AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
1283     cf_save_LIBS="$LIBS"
1284     test $cf_cv_lib_util = yes && LIBS="-lutil $LIBS"
1285     for cf_header in pty.h libutil.h util.h
1286     do
1287     AC_TRY_LINK([
1288 #include <$cf_header>
1289 ],[
1290     int x = openpty((int *)0, (int *)0, (char *)0,
1291                    (struct termios *)0, (struct winsize *)0);
1292 ],[
1293         cf_cv_func_openpty=$cf_header
1294         break
1295 ],[
1296         cf_cv_func_openpty=no
1297 ])
1298     done
1299     LIBS="$cf_save_LIBS"
1300 ])
1301 ])dnl
1302 dnl ---------------------------------------------------------------------------
1303 dnl CF_FUNC_POLL version: 4 updated: 2006/12/16 12:33:30
1304 dnl ------------
1305 dnl See if the poll function really works.  Some platforms have poll(), but
1306 dnl it does not work for terminals or files.
1307 AC_DEFUN([CF_FUNC_POLL],[
1308 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
1309 AC_TRY_RUN([
1310 #include <stdio.h>
1311 #ifdef HAVE_POLL_H
1312 #include <poll.h>
1313 #else
1314 #include <sys/poll.h>
1315 #endif
1316 int main() {
1317         struct pollfd myfds;
1318         int ret;
1319
1320         myfds.fd = 0;
1321         myfds.events = POLLIN;
1322
1323         ret = poll(&myfds, 1, 100);
1324         ${cf_cv_main_return:-return}(ret != 0);
1325 }],
1326         [cf_cv_working_poll=yes],
1327         [cf_cv_working_poll=no],
1328         [cf_cv_working_poll=unknown])])
1329 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL)
1330 ])dnl
1331 dnl ---------------------------------------------------------------------------
1332 dnl CF_FUNC_TERMIOS version: 2 updated: 2000/07/22 23:37:24
1333 dnl ---------------
1334 dnl Some old/broken variations define tcgetattr() only as a macro in
1335 dnl termio(s).h
1336 AC_DEFUN([CF_FUNC_TERMIOS],[
1337 AC_REQUIRE([CF_STRUCT_TERMIOS])
1338 AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
1339 AC_TRY_LINK([
1340 #include <sys/types.h>
1341 #ifdef HAVE_UNISTD_H
1342 #include <unistd.h>
1343 #endif
1344 #ifdef HAVE_TERMIOS_H
1345 #include <termios.h>
1346 #define TTY struct termios
1347 #else
1348 #ifdef HAVE_TERMIO_H
1349 #include <termio.h>
1350 #define TTY struct termio
1351 #endif
1352 #endif
1353 ],[
1354 TTY foo;
1355 tcgetattr(1, &foo);],
1356 [cf_cv_have_tcgetattr=yes],
1357 [cf_cv_have_tcgetattr=no])])
1358 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR)
1359 ])dnl
1360 dnl ---------------------------------------------------------------------------
1361 dnl CF_FUNC_VSSCANF version: 3 updated: 2001/12/19 00:50:10
1362 dnl ---------------
1363 dnl Check for vsscanf() function, which is in c9x but generally not in earlier
1364 dnl versions of C.  It is in the GNU C library, and can often be simulated by
1365 dnl other functions.
1366 AC_DEFUN([CF_FUNC_VSSCANF],
1367 [
1368 AC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
1369 AC_TRY_LINK([
1370 #include <stdarg.h>
1371 #include <stdio.h>],[
1372         va_list ap;
1373         vsscanf("from", "%d", ap)],[cf_cv_func_vsscanf=vsscanf],[
1374 AC_TRY_LINK([
1375 #include <stdarg.h>
1376 #include <stdio.h>],[
1377     FILE strbuf;
1378     char *str = "from";
1379
1380     strbuf._flag = _IOREAD;
1381     strbuf._ptr = strbuf._base = (unsigned char *) str;
1382     strbuf._cnt = strlen(str);
1383     strbuf._file = _NFILE;
1384     return (vfscanf(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=vfscanf],[
1385 AC_TRY_LINK([
1386 #include <stdarg.h>
1387 #include <stdio.h>],[
1388     FILE strbuf;
1389     char *str = "from";
1390
1391     strbuf._flag = _IOREAD;
1392     strbuf._ptr = strbuf._base = (unsigned char *) str;
1393     strbuf._cnt = strlen(str);
1394     strbuf._file = _NFILE;
1395     return (_doscan(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=_doscan],[
1396 cf_cv_func_vsscanf=no])])])])
1397
1398 case $cf_cv_func_vsscanf in #(vi
1399 vsscanf) AC_DEFINE(HAVE_VSSCANF);; #(vi
1400 vfscanf) AC_DEFINE(HAVE_VFSCANF);; #(vi
1401 _doscan) AC_DEFINE(HAVE__DOSCAN);;
1402 esac
1403
1404 ])dnl
1405 dnl ---------------------------------------------------------------------------
1406 dnl CF_GCC_ATTRIBUTES version: 13 updated: 2009/08/11 20:19:56
1407 dnl -----------------
1408 dnl Test for availability of useful gcc __attribute__ directives to quiet
1409 dnl compiler warnings.  Though useful, not all are supported -- and contrary
1410 dnl to documentation, unrecognized directives cause older compilers to barf.
1411 AC_DEFUN([CF_GCC_ATTRIBUTES],
1412 [
1413 if test "$GCC" = yes
1414 then
1415 cat > conftest.i <<EOF
1416 #ifndef GCC_PRINTF
1417 #define GCC_PRINTF 0
1418 #endif
1419 #ifndef GCC_SCANF
1420 #define GCC_SCANF 0
1421 #endif
1422 #ifndef GCC_NORETURN
1423 #define GCC_NORETURN /* nothing */
1424 #endif
1425 #ifndef GCC_UNUSED
1426 #define GCC_UNUSED /* nothing */
1427 #endif
1428 EOF
1429 if test "$GCC" = yes
1430 then
1431         AC_CHECKING([for $CC __attribute__ directives])
1432 cat > conftest.$ac_ext <<EOF
1433 #line __oline__ "${as_me-configure}"
1434 #include "confdefs.h"
1435 #include "conftest.h"
1436 #include "conftest.i"
1437 #if     GCC_PRINTF
1438 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1439 #else
1440 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1441 #endif
1442 #if     GCC_SCANF
1443 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1444 #else
1445 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1446 #endif
1447 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1448 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1449 extern void foo(void) GCC_NORETURN;
1450 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1451 EOF
1452         cf_printf_attribute=no
1453         cf_scanf_attribute=no
1454         for cf_attribute in scanf printf unused noreturn
1455         do
1456                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1457                 cf_directive="__attribute__(($cf_attribute))"
1458                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1459
1460                 case $cf_attribute in #(vi
1461                 printf) #(vi
1462                         cf_printf_attribute=yes
1463                         cat >conftest.h <<EOF
1464 #define GCC_$cf_ATTRIBUTE 1
1465 EOF
1466                         ;;
1467                 scanf) #(vi
1468                         cf_scanf_attribute=yes
1469                         cat >conftest.h <<EOF
1470 #define GCC_$cf_ATTRIBUTE 1
1471 EOF
1472                         ;;
1473                 *) #(vi
1474                         cat >conftest.h <<EOF
1475 #define GCC_$cf_ATTRIBUTE $cf_directive
1476 EOF
1477                         ;;
1478                 esac
1479
1480                 if AC_TRY_EVAL(ac_compile); then
1481                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1482                         cat conftest.h >>confdefs.h
1483                         case $cf_attribute in #(vi
1484                         printf) #(vi
1485                                 if test "$cf_printf_attribute" = no ; then
1486                                         cat >>confdefs.h <<EOF
1487 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
1488 EOF
1489                                 else
1490                                         cat >>confdefs.h <<EOF
1491 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1492 EOF
1493                                 fi
1494                                 ;;
1495                         scanf) #(vi
1496                                 if test "$cf_scanf_attribute" = no ; then
1497                                         cat >>confdefs.h <<EOF
1498 #define GCC_SCANFLIKE(fmt,var) /* nothing */
1499 EOF
1500                                 else
1501                                         cat >>confdefs.h <<EOF
1502 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1503 EOF
1504                                 fi
1505                                 ;;
1506                         esac
1507                 fi
1508         done
1509 else
1510         fgrep define conftest.i >>confdefs.h
1511 fi
1512 rm -rf conftest*
1513 fi
1514 ])dnl
1515 dnl ---------------------------------------------------------------------------
1516 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
1517 dnl --------------
1518 dnl Find version of gcc
1519 AC_DEFUN([CF_GCC_VERSION],[
1520 AC_REQUIRE([AC_PROG_CC])
1521 GCC_VERSION=none
1522 if test "$GCC" = yes ; then
1523         AC_MSG_CHECKING(version of $CC)
1524         GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1525         test -z "$GCC_VERSION" && GCC_VERSION=unknown
1526         AC_MSG_RESULT($GCC_VERSION)
1527 fi
1528 ])dnl
1529 dnl ---------------------------------------------------------------------------
1530 dnl CF_GCC_WARNINGS version: 24 updated: 2009/02/01 15:21:00
1531 dnl ---------------
1532 dnl Check if the compiler supports useful warning options.  There's a few that
1533 dnl we don't use, simply because they're too noisy:
1534 dnl
1535 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1536 dnl     -Wredundant-decls (system headers make this too noisy)
1537 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
1538 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
1539 dnl             is enabled for ncurses using "--enable-const".
1540 dnl     -pedantic
1541 dnl
1542 dnl Parameter:
1543 dnl     $1 is an optional list of gcc warning flags that a particular
1544 dnl             application might want to use, e.g., "no-unused" for
1545 dnl             -Wno-unused
1546 dnl Special:
1547 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1548 dnl
1549 AC_DEFUN([CF_GCC_WARNINGS],
1550 [
1551 AC_REQUIRE([CF_GCC_VERSION])
1552 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1553
1554 cat > conftest.$ac_ext <<EOF
1555 #line __oline__ "${as_me-configure}"
1556 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1557 EOF
1558
1559 if test "$INTEL_COMPILER" = yes
1560 then
1561 # The "-wdXXX" options suppress warnings:
1562 # remark #1419: external declaration in primary source file
1563 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1564 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1565 # remark #193: zero used for undefined preprocessing identifier
1566 # remark #593: variable "curs_sb_left_arrow" was set but never used
1567 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1568 # remark #869: parameter "tw" was never referenced
1569 # remark #981: operands are evaluated in unspecified order
1570 # warning #279: controlling expression is constant
1571
1572         AC_CHECKING([for $CC warning options])
1573         cf_save_CFLAGS="$CFLAGS"
1574         EXTRA_CFLAGS="-Wall"
1575         for cf_opt in \
1576                 wd1419 \
1577                 wd1683 \
1578                 wd1684 \
1579                 wd193 \
1580                 wd593 \
1581                 wd279 \
1582                 wd810 \
1583                 wd869 \
1584                 wd981
1585         do
1586                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1587                 if AC_TRY_EVAL(ac_compile); then
1588                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1589                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1590                 fi
1591         done
1592         CFLAGS="$cf_save_CFLAGS"
1593
1594 elif test "$GCC" = yes
1595 then
1596         AC_CHECKING([for $CC warning options])
1597         cf_save_CFLAGS="$CFLAGS"
1598         EXTRA_CFLAGS="-W -Wall"
1599         cf_warn_CONST=""
1600         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1601         for cf_opt in \
1602                 Wbad-function-cast \
1603                 Wcast-align \
1604                 Wcast-qual \
1605                 Winline \
1606                 Wmissing-declarations \
1607                 Wmissing-prototypes \
1608                 Wnested-externs \
1609                 Wpointer-arith \
1610                 Wshadow \
1611                 Wstrict-prototypes \
1612                 Wundef $cf_warn_CONST $1
1613         do
1614                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1615                 if AC_TRY_EVAL(ac_compile); then
1616                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1617                         case $cf_opt in #(vi
1618                         Wcast-qual) #(vi
1619                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1620                                 ;;
1621                         Winline) #(vi
1622                                 case $GCC_VERSION in
1623                                 [[34]].*)
1624                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1625                                         continue;;
1626                                 esac
1627                                 ;;
1628                         esac
1629                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1630                 fi
1631         done
1632         CFLAGS="$cf_save_CFLAGS"
1633 fi
1634 rm -f conftest*
1635
1636 AC_SUBST(EXTRA_CFLAGS)
1637 ])dnl
1638 dnl ---------------------------------------------------------------------------
1639 dnl CF_GNAT_TRY_LINK version: 1 updated: 2004/08/21 19:02:08
1640 dnl ----------------
1641 dnl Verify that a test program compiles/links with GNAT.
1642 dnl $cf_ada_make is set to the program that compiles/links
1643 dnl $ADAFLAGS may be set to the GNAT flags.
1644 dnl
1645 dnl $1 is the text of the spec
1646 dnl $2 is the text of the body
1647 dnl $3 is the shell command to execute if successful
1648 dnl $4 is the shell command to execute if not successful
1649 AC_DEFUN([CF_GNAT_TRY_LINK],
1650 [
1651 rm -f conftest*
1652 cat >>conftest.ads <<CF_EOF
1653 $1
1654 CF_EOF
1655 cat >>conftest.adb <<CF_EOF
1656 $2
1657 CF_EOF
1658 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1659 ifelse($3,,      :,[      $3])
1660 ifelse($4,,,[else
1661    $4])
1662 fi
1663 rm -f conftest*
1664 ])dnl
1665 dnl ---------------------------------------------------------------------------
1666 dnl CF_GNAT_TRY_RUN version: 3 updated: 2004/08/21 19:02:08
1667 dnl ---------------
1668 dnl Verify that a test program compiles and runs with GNAT
1669 dnl $cf_ada_make is set to the program that compiles/links
1670 dnl $ADAFLAGS may be set to the GNAT flags.
1671 dnl
1672 dnl $1 is the text of the spec
1673 dnl $2 is the text of the body
1674 dnl $3 is the shell command to execute if successful
1675 dnl $4 is the shell command to execute if not successful
1676 AC_DEFUN([CF_GNAT_TRY_RUN],
1677 [
1678 rm -f conftest*
1679 cat >>conftest.ads <<CF_EOF
1680 $1
1681 CF_EOF
1682 cat >>conftest.adb <<CF_EOF
1683 $2
1684 CF_EOF
1685 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1686    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
1687 ifelse($3,,      :,[      $3])
1688 ifelse($4,,,[   else
1689       $4])
1690    fi
1691 ifelse($4,,,[else
1692    $4])
1693 fi
1694 rm -f conftest*
1695 ])dnl
1696 dnl ---------------------------------------------------------------------------
1697 dnl CF_GNAT_VERSION version: 12 updated: 2006/10/14 15:23:15
1698 dnl ---------------
1699 dnl Verify version of GNAT.
1700 AC_DEFUN([CF_GNAT_VERSION],
1701 [
1702 AC_MSG_CHECKING(for gnat version)
1703 cf_gnat_version=`${cf_ada_make-gnatmake} -v 2>&1 | grep '[[0-9]].[[0-9]][[0-9]]*' |\
1704   sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
1705 AC_MSG_RESULT($cf_gnat_version)
1706
1707 case $cf_gnat_version in
1708   3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*)
1709     cf_cv_prog_gnat_correct=yes
1710     ;;
1711   *) echo Unsupported GNAT version $cf_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
1712      cf_cv_prog_gnat_correct=no
1713      ;;
1714 esac
1715 case $cf_gnat_version in
1716   3.[[1-9]]*|[[4-9]].*)
1717       cf_compile_generics=generics
1718       cf_generic_objects="\${GENOBJS}"
1719       ;;
1720   *)  cf_compile_generics=
1721       cf_generic_objects=
1722       ;;
1723 esac
1724 ])
1725 dnl ---------------------------------------------------------------------------
1726 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1727 dnl -------------
1728 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1729 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1730 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1731 dnl since it is interwoven with GNU extensions.
1732 dnl
1733 dnl Well, yes we could work around it...
1734 AC_DEFUN([CF_GNU_SOURCE],
1735 [
1736 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1737 AC_TRY_COMPILE([#include <sys/types.h>],[
1738 #ifndef _XOPEN_SOURCE
1739 make an error
1740 #endif],
1741         [cf_cv_gnu_source=no],
1742         [cf_save="$CPPFLAGS"
1743          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1744          AC_TRY_COMPILE([#include <sys/types.h>],[
1745 #ifdef _XOPEN_SOURCE
1746 make an error
1747 #endif],
1748         [cf_cv_gnu_source=no],
1749         [cf_cv_gnu_source=yes])
1750         CPPFLAGS="$cf_save"
1751         ])
1752 ])
1753 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1754 ])dnl
1755 dnl ---------------------------------------------------------------------------
1756 dnl CF_GPP_LIBRARY version: 9 updated: 2009/12/19 13:46:49
1757 dnl --------------
1758 dnl If we're trying to use g++, test if libg++ is installed (a rather common
1759 dnl problem :-).  If we have the compiler but no library, we'll be able to
1760 dnl configure, but won't be able to build the c++ demo program.
1761 AC_DEFUN([CF_GPP_LIBRARY],
1762 [
1763 cf_cxx_library=unknown
1764 case $cf_cv_system_name in #(vi
1765 os2*) #(vi
1766         cf_gpp_libname=gpp
1767         ;;
1768 *)
1769         cf_gpp_libname=g++
1770         ;;
1771 esac
1772 if test "$GXX" = yes; then
1773         AC_MSG_CHECKING([for lib$cf_gpp_libname])
1774         cf_save="$LIBS"
1775         LIBS="-l$cf_gpp_libname $LIBS"
1776         AC_TRY_LINK([
1777 #include <$cf_gpp_libname/builtin.h>
1778         ],
1779         [two_arg_error_handler_t foo2 = lib_error_handler],
1780         [cf_cxx_library=yes
1781          CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
1782          if test "$cf_gpp_libname" = cpp ; then
1783             AC_DEFINE(HAVE_GPP_BUILTIN_H)
1784          else
1785             AC_DEFINE(HAVE_GXX_BUILTIN_H)
1786          fi],
1787         [AC_TRY_LINK([
1788 #include <builtin.h>
1789         ],
1790         [two_arg_error_handler_t foo2 = lib_error_handler],
1791         [cf_cxx_library=yes
1792          CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
1793          AC_DEFINE(HAVE_BUILTIN_H)],
1794         [cf_cxx_library=no])])
1795         LIBS="$cf_save"
1796         AC_MSG_RESULT($cf_cxx_library)
1797 fi
1798 ])dnl
1799 dnl ---------------------------------------------------------------------------
1800 dnl CF_GXX_VERSION version: 5 updated: 2005/08/27 09:53:42
1801 dnl --------------
1802 dnl Check for version of g++
1803 AC_DEFUN([CF_GXX_VERSION],[
1804 AC_REQUIRE([AC_PROG_CPP])
1805 GXX_VERSION=none
1806 if test "$GXX" = yes; then
1807         AC_MSG_CHECKING(version of g++)
1808         GXX_VERSION="`${CXX-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1809         test -z "$GXX_VERSION" && GXX_VERSION=unknown
1810         AC_MSG_RESULT($GXX_VERSION)
1811 fi
1812 ])dnl
1813 dnl ---------------------------------------------------------------------------
1814 dnl CF_GXX_WARNINGS version: 5 updated: 2005/08/13 14:54:38
1815 dnl ---------------
1816 dnl Check if the compiler supports useful warning options.
1817 dnl
1818 dnl Most of gcc's options apply to g++, except:
1819 dnl     -Wbad-function-cast
1820 dnl     -Wmissing-declarations
1821 dnl     -Wnested-externs
1822 dnl
1823 dnl Omit a few (for now):
1824 dnl     -Winline
1825 dnl
1826 dnl Parameter:
1827 dnl     $1 is an optional list of g++ warning flags that a particular
1828 dnl             application might want to use, e.g., "no-unused" for
1829 dnl             -Wno-unused
1830 dnl Special:
1831 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1832 dnl
1833 AC_DEFUN([CF_GXX_WARNINGS],
1834 [
1835
1836 CF_INTEL_COMPILER(GXX,INTEL_CPLUSPLUS,CXXFLAGS)
1837
1838 AC_REQUIRE([CF_GXX_VERSION])
1839
1840 AC_LANG_SAVE
1841 AC_LANG_CPLUSPLUS
1842
1843 cat > conftest.$ac_ext <<EOF
1844 #line __oline__ "configure"
1845 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1846 EOF
1847
1848 if test "$INTEL_CPLUSPLUS" = yes
1849 then
1850 # The "-wdXXX" options suppress warnings:
1851 # remark #1419: external declaration in primary source file
1852 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1853 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1854 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1855 # remark #193: zero used for undefined preprocessing identifier
1856 # remark #593: variable "curs_sb_left_arrow" was set but never used
1857 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1858 # remark #869: parameter "tw" was never referenced
1859 # remark #981: operands are evaluated in unspecified order
1860 # warning #269: invalid format string conversion
1861
1862         AC_CHECKING([for $CC warning options])
1863         cf_save_CXXFLAGS="$CXXFLAGS"
1864         EXTRA_CXXFLAGS="-Wall"
1865         for cf_opt in \
1866                 wd1419 \
1867                 wd1682 \
1868                 wd1683 \
1869                 wd1684 \
1870                 wd193 \
1871                 wd279 \
1872                 wd593 \
1873                 wd810 \
1874                 wd869 \
1875                 wd981
1876         do
1877                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt"
1878                 if AC_TRY_EVAL(ac_compile); then
1879                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1880                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
1881                 fi
1882         done
1883         CXXFLAGS="$cf_save_CXXFLAGS"
1884
1885 elif test "$GXX" = yes
1886 then
1887         AC_CHECKING([for $CXX warning options])
1888         cf_save_CXXFLAGS="$CXXFLAGS"
1889         EXTRA_CXXFLAGS="-W -Wall"
1890         cf_gxx_extra_warnings=""
1891         test "$with_ext_const" = yes && cf_gxx_extra_warnings="Wwrite-strings"
1892         case "$GCC_VERSION" in
1893         [[1-2]].*)
1894                 ;;
1895         *)
1896                 cf_gxx_extra_warnings="$cf_gxx_extra_warnings Weffc++"
1897                 ;;
1898         esac
1899         for cf_opt in \
1900                 Wabi \
1901                 fabi-version=0 \
1902                 Woverloaded-virtual \
1903                 Wsign-promo \
1904                 Wsynth \
1905                 Wold-style-cast \
1906                 Wcast-align \
1907                 Wcast-qual \
1908                 Wmissing-prototypes \
1909                 Wpointer-arith \
1910                 Wshadow \
1911                 Wstrict-prototypes \
1912                 Wundef $cf_gxx_extra_warnings $1
1913         do
1914                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
1915                 if AC_TRY_EVAL(ac_compile); then
1916                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1917                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
1918                 else
1919                         test -n "$verbose" && AC_MSG_RESULT(... no -$cf_opt)
1920                 fi
1921         done
1922         CXXFLAGS="$cf_save_CXXFLAGS"
1923 fi
1924
1925 rm -f conftest*
1926 AC_LANG_RESTORE
1927 AC_SUBST(EXTRA_CXXFLAGS)
1928 ])dnl
1929 dnl ---------------------------------------------------------------------------
1930 dnl CF_HASHED_DB version: 3 updated: 2007/11/24 17:43:37
1931 dnl ------------
1932 dnl Look for an instance of the Berkeley hashed database.
1933 dnl
1934 dnl $1 = optional parameter, to specify install-prefix for the database.
1935 AC_DEFUN([CF_HASHED_DB],
1936 [
1937 ifelse([$1],,,[
1938 case $1 in #(vi
1939 yes|*able*) #(vi
1940     ;;
1941 *)
1942     if test -d "$1" ; then
1943         CF_ADD_INCDIR($1/include)
1944         CF_ADD_LIBDIR($1/lib)
1945     fi
1946 esac
1947 ])
1948 AC_CHECK_HEADER(db.h,[
1949 CF_HASHED_DB_VERSION
1950 if test "$cf_cv_hashed_db_version" = unknown ; then
1951         AC_MSG_ERROR(Cannot determine version of db)
1952 else
1953         CF_HASHED_DB_LIBS
1954         if test "$cf_cv_hashed_db_libs" = unknown ; then
1955                 AC_MSG_ERROR(Cannot determine library for db)
1956         elif test "$cf_cv_hashed_db_libs" != default ; then
1957                 LIBS="-l$cf_cv_hashed_db_libs $LIBS"
1958         fi
1959 fi
1960 ],[
1961         AC_MSG_ERROR(Cannot find db.h)
1962 ])
1963 ])dnl
1964 dnl ---------------------------------------------------------------------------
1965 dnl CF_HASHED_DB_LIBS version: 8 updated: 2008/08/04 06:18:06
1966 dnl -----------------
1967 dnl Given that we have the header and version for hashed database, find the
1968 dnl library information.
1969 AC_DEFUN([CF_HASHED_DB_LIBS],
1970 [
1971 AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
1972 cf_cv_hashed_db_libs=unknown
1973 for cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
1974 do
1975         cf_save_libs="$LIBS"
1976         if test -n "$cf_db_libs"; then
1977                 LIBS="-l$cf_db_libs $LIBS"
1978         fi
1979         CF_MSG_LOG(checking for library "$cf_db_libs")
1980         AC_TRY_LINK([
1981 $ac_includes_default
1982 #include <db.h>
1983 ],[
1984         char *path = "/tmp/foo";
1985 #ifdef DB_VERSION_MAJOR
1986 #if DB_VERSION_MAJOR >= 4
1987         DB *result = 0;
1988         db_create(&result, NULL, 0);
1989         result->open(result,
1990                 NULL,
1991                 path,
1992                 path,
1993                 DB_HASH,
1994                 DB_CREATE,
1995                 0644);
1996 #elif DB_VERSION_MAJOR >= 3
1997         DB *result = 0;
1998         db_create(&result, NULL, 0);
1999         result->open(result,
2000                 path,
2001                 path,
2002                 DB_HASH,
2003                 DB_CREATE,
2004                 0644);
2005 #elif DB_VERSION_MAJOR >= 2
2006         DB *result = 0;
2007         db_open(path,
2008                 DB_HASH,
2009                 DB_CREATE,
2010                 0644,
2011                 (DB_ENV *) 0,
2012                 (DB_INFO *) 0,
2013                 &result);
2014 #endif /* DB_VERSION_MAJOR */
2015 #else
2016         DB *result = dbopen(path,
2017                      2,
2018                      0644,
2019                      DB_HASH,
2020                      0);
2021 #endif
2022         ${cf_cv_main_return:-return}(result != 0)
2023 ],[
2024         if test -n "$cf_db_libs" ; then
2025                 cf_cv_hashed_db_libs=$cf_db_libs
2026         else
2027                 cf_cv_hashed_db_libs=default
2028         fi
2029         LIBS="$cf_save_libs"
2030         break
2031 ])
2032         LIBS="$cf_save_libs"
2033 done
2034 ])
2035 ])dnl
2036 dnl ---------------------------------------------------------------------------
2037 dnl CF_HASHED_DB_VERSION version: 3 updated: 2007/12/01 15:01:37
2038 dnl --------------------
2039 dnl Given that we have the header file for hashed database, find the version
2040 dnl information.
2041 AC_DEFUN([CF_HASHED_DB_VERSION],
2042 [
2043 AC_CACHE_CHECK(for version of db, cf_cv_hashed_db_version,[
2044 cf_cv_hashed_db_version=unknown
2045
2046 for cf_db_version in 1 2 3 4 5
2047 do
2048         CF_MSG_LOG(checking for db version $cf_db_version)
2049         AC_TRY_COMPILE([
2050 $ac_includes_default
2051 #include <db.h>
2052
2053 #ifdef DB_VERSION_MAJOR
2054         /* db2 (DB_VERSION_MAJOR=2) has also DB_VERSION_MINOR, tested with 7 */
2055 #if $cf_db_version == DB_VERSION_MAJOR
2056         /* ok */
2057 #else
2058         make an error
2059 #endif
2060 #else
2061 #if $cf_db_version == 1
2062         /* ok: assuming this is DB 1.8.5 */
2063 #else
2064         make an error
2065 #endif
2066 #endif
2067 ],[DBT *foo = 0],[
2068         cf_cv_hashed_db_version=$cf_db_version
2069         break
2070         ])
2071 done
2072 ])
2073 ])dnl
2074 dnl ---------------------------------------------------------------------------
2075 dnl CF_HEADER_PATH version: 10 updated: 2010/01/17 20:36:17
2076 dnl --------------
2077 dnl Construct a search-list of directories for a nonstandard header-file
2078 dnl
2079 dnl Parameters
2080 dnl     $1 = the variable to return as result
2081 dnl     $2 = the package name
2082 AC_DEFUN([CF_HEADER_PATH],
2083 [
2084 $1=
2085 cf_header_path_list=""
2086 if test -n "${CFLAGS}${CPPFLAGS}" ; then
2087         for cf_header_path in $CPPFLAGS $CFLAGS
2088         do
2089                 case $cf_header_path in #(vi
2090                 -I*)
2091                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
2092                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
2093                         cf_header_path_list="$cf_header_path_list [$]$1"
2094                         ;;
2095                 esac
2096         done
2097 fi
2098
2099 CF_SUBDIR_PATH($1,$2,include)
2100
2101 test "$includedir" != NONE && \
2102 test "$includedir" != "/usr/include" && \
2103 test -d "$includedir" && {
2104         test -d $includedir &&    $1="[$]$1 $includedir"
2105         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
2106 }
2107
2108 test "$oldincludedir" != NONE && \
2109 test "$oldincludedir" != "/usr/include" && \
2110 test -d "$oldincludedir" && {
2111         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
2112         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
2113 }
2114
2115 $1="$cf_header_path_list [$]$1"
2116 ])dnl
2117 dnl ---------------------------------------------------------------------------
2118 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
2119 dnl ---------------
2120 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
2121 AC_DEFUN([CF_HELP_MESSAGE],
2122 [AC_DIVERT_HELP([$1])dnl
2123 ])dnl
2124 dnl ---------------------------------------------------------------------------
2125 dnl CF_INCLUDE_DIRS version: 6 updated: 2009/01/06 19:37:40
2126 dnl ---------------
2127 dnl Construct the list of include-options according to whether we're building
2128 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
2129 dnl with gcc, don't append the includedir if it happens to be /usr/include,
2130 dnl since that usually breaks gcc's shadow-includes.
2131 AC_DEFUN([CF_INCLUDE_DIRS],
2132 [
2133 CPPFLAGS="$CPPFLAGS -I. -I../include"
2134 if test "$srcdir" != "."; then
2135         CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
2136 fi
2137 if test "$GCC" != yes; then
2138         CPPFLAGS="$CPPFLAGS -I\${includedir}"
2139 elif test "$includedir" != "/usr/include"; then
2140         if test "$includedir" = '${prefix}/include' ; then
2141                 if test $prefix != /usr ; then
2142                         CPPFLAGS="$CPPFLAGS -I\${includedir}"
2143                 fi
2144         else
2145                 CPPFLAGS="$CPPFLAGS -I\${includedir}"
2146         fi
2147 fi
2148 AC_SUBST(CPPFLAGS)
2149 ])dnl
2150 dnl ---------------------------------------------------------------------------
2151 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
2152 dnl -----------------
2153 dnl Check if the given compiler is really the Intel compiler for Linux.  It
2154 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
2155 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2156 dnl
2157 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2158 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2159 dnl the wrappers for gcc and g++ warnings.
2160 dnl
2161 dnl $1 = GCC (default) or GXX
2162 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2163 dnl $3 = CFLAGS (default) or CXXFLAGS
2164 AC_DEFUN([CF_INTEL_COMPILER],[
2165 ifelse($2,,INTEL_COMPILER,[$2])=no
2166
2167 if test "$ifelse($1,,[$1],GCC)" = yes ; then
2168         case $host_os in
2169         linux*|gnu*)
2170                 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
2171                 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
2172                 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
2173                 AC_TRY_COMPILE([],[
2174 #ifdef __INTEL_COMPILER
2175 #else
2176 make an error
2177 #endif
2178 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
2179 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
2180 ],[])
2181                 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
2182                 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
2183                 ;;
2184         esac
2185 fi
2186 ])dnl
2187 dnl ---------------------------------------------------------------------------
2188 dnl CF_ISASCII version: 3 updated: 2000/08/12 23:18:52
2189 dnl ----------
2190 dnl Check if we have either a function or macro for 'isascii()'.
2191 AC_DEFUN([CF_ISASCII],
2192 [
2193 AC_MSG_CHECKING(for isascii)
2194 AC_CACHE_VAL(cf_cv_have_isascii,[
2195         AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
2196         [cf_cv_have_isascii=yes],
2197         [cf_cv_have_isascii=no])
2198 ])dnl
2199 AC_MSG_RESULT($cf_cv_have_isascii)
2200 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII)
2201 ])dnl
2202 dnl ---------------------------------------------------------------------------
2203 dnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
2204 dnl ------------
2205 dnl Add checks for large file support.
2206 AC_DEFUN([CF_LARGEFILE],[
2207 ifdef([AC_FUNC_FSEEKO],[
2208     AC_SYS_LARGEFILE
2209     if test "$enable_largefile" != no ; then
2210         AC_FUNC_FSEEKO
2211
2212         # Normally we would collect these definitions in the config.h,
2213         # but (like _XOPEN_SOURCE), some environments rely on having these
2214         # defined before any of the system headers are included.  Another
2215         # case comes up with C++, e.g., on AIX the compiler compiles the
2216         # header files by themselves before looking at the body files it is
2217         # told to compile.  For ncurses, those header files do not include
2218         # the config.h
2219         test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
2220         test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
2221         test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
2222
2223         AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
2224                 AC_TRY_COMPILE([
2225 #include <sys/types.h>
2226 #include <dirent.h>
2227                 ],[
2228                 /* if transitional largefile support is setup, this is true */
2229                 extern struct dirent64 * readdir(DIR *);
2230                 struct dirent64 *x = readdir((DIR *)0);
2231                 struct dirent *y = readdir((DIR *)0);
2232                 int z = x - y;
2233                 ],
2234                 [cf_cv_struct_dirent64=yes],
2235                 [cf_cv_struct_dirent64=no])
2236         ])
2237         test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
2238     fi
2239 ])
2240 ])
2241 dnl ---------------------------------------------------------------------------
2242 dnl CF_LDFLAGS_STATIC version: 7 updated: 2009/04/04 18:31:04
2243 dnl -----------------
2244 dnl Check for compiler/linker flags used to temporarily force usage of static
2245 dnl libraries.  This depends on the compiler and platform.  Use this to help
2246 dnl ensure that the linker picks up a given library based on its position in
2247 dnl the list of linker options and libraries.
2248 AC_DEFUN([CF_LDFLAGS_STATIC],[
2249
2250 if test "$GCC" = yes ; then
2251         case $cf_cv_system_name in #(
2252         OS/2*|os2*|aix[[4]]*|solaris2.1[[0-9]]|darwin*)         #( vi
2253                 LDFLAGS_STATIC=
2254                 LDFLAGS_SHARED=
2255                 ;;
2256     *)  #( normally, except when broken
2257         LDFLAGS_STATIC=-static
2258         LDFLAGS_SHARED=-dynamic
2259         ;;
2260     esac
2261 else
2262         case $cf_cv_system_name in #(
2263         aix[[456]]*)    #( from ld manpage
2264                 LDFLAGS_STATIC=-bstatic
2265                 LDFLAGS_SHARED=-bdynamic
2266                 ;;
2267         hpux*)          #( from ld manpage for hpux10.20, hpux11.11
2268                 # We could also use just "archive" and "shared".
2269                 LDFLAGS_STATIC=-Wl,-a,archive_shared
2270                 LDFLAGS_SHARED=-Wl,-a,shared_archive
2271                 ;;
2272         irix*)          #( from ld manpage IRIX64
2273                 LDFLAGS_STATIC=-Bstatic
2274                 LDFLAGS_SHARED=-Bdynamic
2275                 ;;
2276         osf[[45]]*)     #( from ld manpage osf4.0d, osf5.1
2277                 # alternative "-oldstyle_liblookup" (not in cc manpage)
2278                 LDFLAGS_STATIC=-noso
2279                 LDFLAGS_SHARED=-so_archive
2280                 ;;
2281         solaris2*)
2282                 LDFLAGS_STATIC=-Bstatic
2283                 LDFLAGS_SHARED=-Bdynamic
2284                 ;;
2285         esac
2286 fi
2287
2288 AC_SUBST(LDFLAGS_STATIC)
2289 AC_SUBST(LDFLAGS_SHARED)
2290 ])
2291 dnl ---------------------------------------------------------------------------
2292 dnl CF_LIBRARY_PATH version: 8 updated: 2008/12/07 19:38:31
2293 dnl ---------------
2294 dnl Construct a search-list of directories for a nonstandard library-file
2295 dnl
2296 dnl Parameters
2297 dnl     $1 = the variable to return as result
2298 dnl     $2 = the package name
2299 AC_DEFUN([CF_LIBRARY_PATH],
2300 [
2301 cf_library_path_list=""
2302 if test -n "${LDFLAGS}${LIBS}" ; then
2303         for cf_library_path in $LDFLAGS $LIBS
2304         do
2305                 case $cf_library_path in #(vi
2306                 -L*)
2307                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
2308                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
2309                         cf_library_path_list="$cf_library_path_list [$]$1"
2310                         ;;
2311                 esac
2312         done
2313 fi
2314
2315 CF_SUBDIR_PATH($1,$2,lib)
2316
2317 $1="$cf_library_path_list [$]$1"
2318 ])dnl
2319 dnl ---------------------------------------------------------------------------
2320 dnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16
2321 dnl -------------
2322 dnl Compute the library-prefix for the given host system
2323 dnl $1 = variable to set
2324 AC_DEFUN([CF_LIB_PREFIX],
2325 [
2326         case $cf_cv_system_name in #(vi
2327         OS/2*|os2*) #(vi
2328         LIB_PREFIX=''
2329         ;;
2330         *)      LIB_PREFIX='lib'
2331         ;;
2332         esac
2333 ifelse($1,,,[$1=$LIB_PREFIX])
2334         AC_SUBST(LIB_PREFIX)
2335 ])dnl
2336 dnl ---------------------------------------------------------------------------
2337 dnl CF_LIB_RULES version: 55 updated: 2008/12/13 16:17:38
2338 dnl ------------
2339 dnl Append definitions and rules for the given models to the subdirectory
2340 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
2341 dnl subdirectory is a library-source directory, modify the LIBS_TO_MAKE list in
2342 dnl the corresponding makefile to list the models that we'll generate.
2343 dnl
2344 dnl For shared libraries, make a list of symbolic links to construct when
2345 dnl generating each library.  The convention used for Linux is the simplest
2346 dnl one:
2347 dnl     lib<name>.so    ->
2348 dnl     lib<name>.so.<major>    ->
2349 dnl     lib<name>.so.<maj>.<minor>
2350 AC_DEFUN([CF_LIB_RULES],
2351 [
2352 CF_LIB_PREFIX(cf_prefix)
2353 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2354
2355 if test $cf_cv_shlib_version = cygdll ; then
2356         TINFO_NAME=$TINFO_ARG_SUFFIX
2357         TINFO_SUFFIX=.dll
2358 fi
2359
2360 for cf_dir in $SRC_SUBDIRS
2361 do
2362         if test ! -d $srcdir/$cf_dir ; then
2363                 continue
2364         elif test -f $srcdir/$cf_dir/modules; then
2365
2366                 SHARED_LIB=
2367                 LIBS_TO_MAKE=
2368                 for cf_item in $cf_LIST_MODELS
2369                 do
2370                         CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
2371                         if test $cf_item = shared ; then
2372                         if test "$cf_cv_do_symlinks" = yes ; then
2373                                 case "$cf_cv_shlib_version" in #(vi
2374                                 rel) #(vi
2375                                         case "$cf_cv_system_name" in #(vi
2376                                         darwin*)
2377                                         case .${LIB_SUFFIX} in
2378                                         .w*)
2379                                                 cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2380                                                 cf_suffix=w'.${REL_VERSION}'"$cf_suffix"
2381                                                 ;;
2382                                         *)
2383                                                 cf_suffix='.${REL_VERSION}'"$cf_suffix"
2384                                                 ;;
2385                                         esac
2386                                         ;; #(vi
2387                                         *) cf_suffix="$cf_suffix"'.${REL_VERSION}' ;;
2388                                         esac
2389                                         ;;
2390                                 abi)
2391                                         case "$cf_cv_system_name" in #(vi
2392                                         darwin*)
2393                                         case .${LIB_SUFFIX} in
2394                                         .w*)
2395                                                 cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2396                                                 cf_suffix=w'.${ABI_VERSION}'"$cf_suffix"
2397                                                 ;;
2398                                         *)
2399                                                 cf_suffix='.${ABI_VERSION}'"$cf_suffix"
2400                                                 ;;
2401                                         esac
2402                                         ;; #(vi
2403                                         *) cf_suffix="$cf_suffix"'.${ABI_VERSION}' ;;
2404                                         esac
2405                                         ;;
2406                                 esac
2407                         fi
2408                         # cygwin needs import library, and has unique naming convention
2409                         # use autodetected ${cf_prefix} for import lib and static lib, but
2410                         # use 'cyg' prefix for shared lib.
2411                         if test $cf_cv_shlib_version = cygdll ; then
2412                                 cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
2413                                 LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/cyg${cf_dir}${cf_cygsuf}"
2414                                 continue
2415                         fi
2416                         fi
2417                         LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
2418                 done
2419
2420                 if test $cf_dir = ncurses ; then
2421                         cf_subsets="$LIB_SUBSETS"
2422                         cf_r_parts="$cf_subsets"
2423                         cf_liblist="$LIBS_TO_MAKE"
2424
2425                         while test -n "$cf_r_parts"
2426                         do
2427                                 cf_l_parts=`echo "$cf_r_parts" |sed -e 's/ .*$//'`
2428                                 cf_r_parts=`echo "$cf_r_parts" |sed -e 's/^[[^ ]]* //'`
2429                                 if test "$cf_l_parts" != "$cf_r_parts" ; then
2430                                         cf_item=
2431                                         case $cf_l_parts in #(vi
2432                                         *termlib*) #(vi
2433                                                 cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
2434                                                 ;;
2435                                         *ticlib*)
2436                                                 cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TICS_LIB_SUFFIX}%g`
2437                                                 ;;
2438                                         *)
2439                                                 break
2440                                                 ;;
2441                                         esac
2442                                         if test -n "$cf_item"; then
2443                                                 LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
2444                                         fi
2445                                 else
2446                                         break
2447                                 fi
2448                         done
2449                 else
2450                         cf_subsets=`echo "$LIB_SUBSETS" | sed -e 's/^termlib.* //'`
2451                 fi
2452
2453                 sed -e "s%@LIBS_TO_MAKE@%$LIBS_TO_MAKE%" \
2454                     -e "s%@SHARED_LIB@%$SHARED_LIB%" \
2455                         $cf_dir/Makefile >$cf_dir/Makefile.out
2456                 mv $cf_dir/Makefile.out $cf_dir/Makefile
2457
2458                 $AWK -f $srcdir/mk-0th.awk \
2459                         libname="${cf_dir}${LIB_SUFFIX}" subsets="$LIB_SUBSETS" \
2460                         $srcdir/$cf_dir/modules >>$cf_dir/Makefile
2461
2462                 for cf_subset in $cf_subsets
2463                 do
2464                         cf_subdirs=
2465                         for cf_item in $cf_LIST_MODELS
2466                         do
2467                         echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})"
2468                         CF_UPPER(cf_ITEM,$cf_item)
2469                         CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
2470                         CF_OBJ_SUBDIR($cf_item,cf_subdir)
2471
2472                         # Test for case where we build libtinfo with a different name.
2473                         cf_libname=$cf_dir
2474                         if test $cf_dir = ncurses ; then
2475                                 case $cf_subset in
2476                                 *base*)
2477                                         cf_libname=${cf_libname}$LIB_SUFFIX
2478                                         ;;
2479                                 *termlib*)
2480                                         cf_libname=$TINFO_LIB_SUFFIX
2481                                         ;;
2482                                 ticlib*)
2483                                         cf_libname=$TICS_LIB_SUFFIX
2484                                         ;;
2485                                 esac
2486                         else
2487                                 cf_libname=${cf_libname}$LIB_SUFFIX
2488                         fi
2489                         if test -n "${DFT_ARG_SUFFIX}" ; then
2490                                 # undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
2491                                 cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
2492                         fi
2493
2494                         # These dependencies really are for development, not
2495                         # builds, but they are useful in porting, too.
2496                         cf_depend="../include/ncurses_cfg.h"
2497                         if test "$srcdir" = "."; then
2498                                 cf_reldir="."
2499                         else
2500                                 cf_reldir="\${srcdir}"
2501                         fi
2502
2503                         if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
2504                                 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
2505                         elif test -f $srcdir/$cf_dir/curses.priv.h; then
2506                                 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
2507                         fi
2508
2509                         cf_dir_suffix=
2510                         old_cf_suffix="$cf_suffix"
2511                         if test "$cf_cv_shlib_version_infix" = yes ; then
2512                         if test -n "$LIB_SUFFIX" ; then
2513                                 case $LIB_SUFFIX in
2514                                 w*)
2515                                         cf_libname=`echo $cf_libname | sed 's/w$//'`
2516                                         cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2517                                         cf_dir_suffix=w
2518                                         ;;
2519                                 esac
2520                         fi
2521                         fi
2522
2523                         $AWK -f $srcdir/mk-1st.awk \
2524                                 name=${cf_libname}${cf_dir_suffix} \
2525                                 traces=$LIB_TRACING \
2526                                 MODEL=$cf_ITEM \
2527                                 model=$cf_subdir \
2528                                 prefix=$cf_prefix \
2529                                 suffix=$cf_suffix \
2530                                 subset=$cf_subset \
2531                                 TermlibRoot=$TINFO_NAME \
2532                                 TermlibSuffix=$TINFO_SUFFIX \
2533                                 ShlibVer=$cf_cv_shlib_version \
2534                                 ShlibVerInfix=$cf_cv_shlib_version_infix \
2535                                 ReLink=${cf_cv_do_relink-no} \
2536                                 DoLinks=$cf_cv_do_symlinks \
2537                                 rmSoLocs=$cf_cv_rm_so_locs \
2538                                 ldconfig="$LDCONFIG" \
2539                                 overwrite=$WITH_OVERWRITE \
2540                                 depend="$cf_depend" \
2541                                 host="$host" \
2542                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
2543
2544                         cf_suffix="$old_cf_suffix"
2545
2546                         for cf_subdir2 in $cf_subdirs lib
2547                         do
2548                                 test $cf_subdir = $cf_subdir2 && break
2549                         done
2550                         test "${cf_subset}.${cf_subdir2}" != "${cf_subset}.${cf_subdir}" && \
2551                         $AWK -f $srcdir/mk-2nd.awk \
2552                                 name=$cf_dir \
2553                                 traces=$LIB_TRACING \
2554                                 MODEL=$cf_ITEM \
2555                                 model=$cf_subdir \
2556                                 subset=$cf_subset \
2557                                 srcdir=$srcdir \
2558                                 echo=$WITH_ECHO \
2559                                 crenames=$cf_cv_prog_CC_c_o \
2560                                 cxxrenames=$cf_cv_prog_CXX_c_o \
2561                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
2562                         cf_subdirs="$cf_subdirs $cf_subdir"
2563                         done
2564                 done
2565         fi
2566
2567         echo '  cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >>Makefile
2568 done
2569
2570 for cf_dir in $SRC_SUBDIRS
2571 do
2572         if test ! -d $srcdir/$cf_dir ; then
2573                 continue
2574         fi
2575
2576         if test -f $cf_dir/Makefile ; then
2577                 case "$cf_dir" in
2578                 Ada95) #(vi
2579                         echo 'libs \' >> Makefile
2580                         echo 'install.libs \' >> Makefile
2581                         echo 'uninstall.libs ::' >> Makefile
2582                         echo '  cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >> Makefile
2583                         ;;
2584                 esac
2585         fi
2586
2587         if test -f $srcdir/$cf_dir/modules; then
2588                 echo >> Makefile
2589                 if test -f $srcdir/$cf_dir/headers; then
2590 cat >> Makefile <<CF_EOF
2591 install.includes \\
2592 uninstall.includes \\
2593 CF_EOF
2594                 fi
2595 if test "$cf_dir" != "c++" ; then
2596 echo 'lint \' >> Makefile
2597 fi
2598 cat >> Makefile <<CF_EOF
2599 libs \\
2600 lintlib \\
2601 install.libs \\
2602 uninstall.libs \\
2603 install.$cf_dir \\
2604 uninstall.$cf_dir ::
2605         cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
2606 CF_EOF
2607         elif test -f $srcdir/$cf_dir/headers; then
2608 cat >> Makefile <<CF_EOF
2609
2610 libs \\
2611 install.libs \\
2612 uninstall.libs \\
2613 install.includes \\
2614 uninstall.includes ::
2615         cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
2616 CF_EOF
2617 fi
2618 done
2619
2620 cat >> Makefile <<CF_EOF
2621
2622 install.libs uninstall.libs \\
2623 install.data uninstall.data ::
2624 $MAKE_TERMINFO  cd misc && \${MAKE} \${CF_MFLAGS} \[$]@
2625 CF_EOF
2626
2627 if test "x$cf_with_manpages" = xyes; then
2628 cat >> Makefile <<CF_EOF
2629
2630 install.man \\
2631 uninstall.man ::
2632         cd man && \${MAKE} \${CF_MFLAGS} \[$]@
2633 CF_EOF
2634 fi
2635
2636 cat >> Makefile <<CF_EOF
2637
2638 distclean ::
2639         rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
2640         rm -f headers.sh headers.sed mk_shared_lib.sh
2641         rm -f edit_man.* man_alias.*
2642         rm -rf \${DIRS_TO_MAKE}
2643 CF_EOF
2644
2645 # Special case: tack's manpage lives in its own directory.
2646 if test "x$cf_with_manpages" = xyes; then
2647 if test -d tack ; then
2648 if test -f $srcdir/$tack.h; then
2649 cat >> Makefile <<CF_EOF
2650
2651 install.man \\
2652 uninstall.man ::
2653         cd tack && \${MAKE} \${CF_MFLAGS} \[$]@
2654 CF_EOF
2655 fi
2656 fi
2657 fi
2658
2659 dnl If we're installing into a subdirectory of /usr/include, etc., we should
2660 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
2661 dnl anything, and will make it more standardized.  It's awkward to decide this
2662 dnl at configuration because of quoting, so we'll simply make all headers
2663 dnl installed via a script that can do the right thing.
2664
2665 rm -f headers.sed headers.sh
2666
2667 dnl ( generating this script makes the makefiles a little tidier :-)
2668 echo creating headers.sh
2669 cat >headers.sh <<CF_EOF
2670 #! /bin/sh
2671 # This shell script is generated by the 'configure' script.  It is invoked in a
2672 # subdirectory of the build tree.  It generates a sed-script in the parent
2673 # directory that is used to adjust includes for header files that reside in a
2674 # subdirectory of /usr/include, etc.
2675 PRG=""
2676 while test \[$]# != 3
2677 do
2678 PRG="\$PRG \[$]1"; shift
2679 done
2680 DST=\[$]1
2681 REF=\[$]2
2682 SRC=\[$]3
2683 TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
2684 TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
2685 echo installing \$SRC in \$DST
2686 CF_EOF
2687
2688 if test $WITH_CURSES_H = yes; then
2689         cat >>headers.sh <<CF_EOF
2690 case \$DST in
2691 /*/include/*)
2692         END=\`basename \$DST\`
2693         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
2694         do
2695                 NAME=\`basename \$i\`
2696                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
2697         done
2698         ;;
2699 *)
2700         echo "" >> \$TMPSED
2701         ;;
2702 esac
2703 CF_EOF
2704
2705 else
2706         cat >>headers.sh <<CF_EOF
2707 case \$DST in
2708 /*/include/*)
2709         END=\`basename \$DST\`
2710         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
2711         do
2712                 NAME=\`basename \$i\`
2713                 if test "\$NAME" = "curses.h"
2714                 then
2715                         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
2716                         NAME=ncurses.h
2717                 fi
2718                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
2719         done
2720         ;;
2721 *)
2722         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
2723         ;;
2724 esac
2725 CF_EOF
2726 fi
2727 cat >>headers.sh <<CF_EOF
2728 rm -f \$TMPSRC
2729 sed -f \$TMPSED \$SRC > \$TMPSRC
2730 NAME=\`basename \$SRC\`
2731 CF_EOF
2732 if test $WITH_CURSES_H != yes; then
2733         cat >>headers.sh <<CF_EOF
2734 test "\$NAME" = "curses.h" && NAME=ncurses.h
2735 CF_EOF
2736 fi
2737 cat >>headers.sh <<CF_EOF
2738 # Just in case someone gzip'd manpages, remove the conflicting copy.
2739 test -f \$DST/\$NAME.gz && rm -f \$DST/\$NAME.gz
2740
2741 eval \$PRG \$TMPSRC \$DST/\$NAME
2742 rm -f \$TMPSRC \$TMPSED
2743 CF_EOF
2744
2745 chmod 0755 headers.sh
2746
2747 for cf_dir in $SRC_SUBDIRS
2748 do
2749         if test ! -d $srcdir/$cf_dir ; then
2750                 continue
2751         fi
2752
2753         if test -f $srcdir/$cf_dir/headers; then
2754                 $AWK -f $srcdir/mk-hdr.awk \
2755                         subset="$LIB_SUBSETS" \
2756                         compat="$WITH_CURSES_H" \
2757                         $srcdir/$cf_dir/headers >>$cf_dir/Makefile
2758         fi
2759
2760         if test -f $srcdir/$cf_dir/modules; then
2761                 if test "$cf_dir" != "c++" ; then
2762                         cat >>$cf_dir/Makefile <<"CF_EOF"
2763 depend : ${AUTO_SRC}
2764         makedepend -- ${CPPFLAGS} -- ${C_SRC}
2765
2766 # DO NOT DELETE THIS LINE -- make depend depends on it.
2767 CF_EOF
2768                 fi
2769         fi
2770 done
2771
2772 ])dnl
2773 dnl ---------------------------------------------------------------------------
2774 dnl CF_LIB_SONAME version: 3 updated: 2006/12/16 15:55:46
2775 dnl -------------
2776 dnl Find the and soname for the given shared library.  Set the cache variable
2777 dnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
2778 dnl variable to "unknown".
2779 dnl
2780 dnl $1 = headers
2781 dnl $2 = code
2782 dnl $3 = library name
2783 AC_DEFUN([CF_LIB_SONAME],
2784 [
2785 AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
2786
2787 cf_cv_$3_soname=unknown
2788 if test "$cross_compiling" != yes ; then
2789 cat >conftest.$ac_ext <<CF_EOF
2790 $1
2791 int main()
2792 {
2793 $2
2794         ${cf_cv_main_return:-return}(0);
2795 }
2796 CF_EOF
2797 cf_save_LIBS="$LIBS"
2798         LIBS="-l$3 $LIBS"
2799         if AC_TRY_EVAL(ac_compile) ; then
2800                 if AC_TRY_EVAL(ac_link) ; then
2801                         cf_cv_$3_soname=`ldd conftest$ac_exeext 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | fgrep lib$3.`
2802                         test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
2803                 fi
2804         fi
2805 rm -f conftest*
2806 LIBS="$cf_save_LIBS"
2807 fi
2808 ])
2809 ])
2810 dnl ---------------------------------------------------------------------------
2811 dnl CF_LIB_SUFFIX version: 16 updated: 2008/12/27 12:30:03
2812 dnl -------------
2813 dnl Compute the library file-suffix from the given model name
2814 dnl $1 = model name
2815 dnl $2 = variable to set (the nominal library suffix)
2816 dnl $3 = dependency variable to set (actual filename)
2817 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
2818 AC_DEFUN([CF_LIB_SUFFIX],
2819 [
2820         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2821         case $1 in #(vi
2822         libtool) #(vi
2823                 $2='.la'
2824                 $3=[$]$2
2825                 ;;
2826         normal) #(vi
2827                 $2='.a'
2828                 $3=[$]$2
2829                 ;;
2830         debug) #(vi
2831                 $2='_g.a'
2832                 $3=[$]$2
2833                 ;;
2834         profile) #(vi
2835                 $2='_p.a'
2836                 $3=[$]$2
2837                 ;;
2838         shared) #(vi
2839                 case $cf_cv_system_name in
2840                 aix[[56]]*) #(vi
2841                         $2='.a'
2842                         $3=[$]$2
2843                         ;;
2844                 cygwin*) #(vi
2845                         $2='.dll'
2846                         $3='.dll.a'
2847                         ;;
2848                 darwin*) #(vi
2849                         $2='.dylib'
2850                         $3=[$]$2
2851                         ;;
2852                 hpux*) #(vi
2853                         case $target in
2854                         ia64*) #(vi
2855                                 $2='.so'
2856                                 $3=[$]$2
2857                                 ;;
2858                         *) #(vi
2859                                 $2='.sl'
2860                                 $3=[$]$2
2861                                 ;;
2862                         esac
2863                         ;;
2864                 *)      $2='.so'
2865                         $3=[$]$2
2866                         ;;
2867                 esac
2868         esac
2869         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
2870         test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}"
2871 ])dnl
2872 dnl ---------------------------------------------------------------------------
2873 dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
2874 dnl -----------
2875 dnl Compute the string to append to -library from the given model name
2876 dnl $1 = model name
2877 dnl $2 = variable to set
2878 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
2879 AC_DEFUN([CF_LIB_TYPE],
2880 [
2881         case $1 in
2882         libtool) $2=''   ;;
2883         normal)  $2=''   ;;
2884         debug)   $2='_g' ;;
2885         profile) $2='_p' ;;
2886         shared)  $2=''   ;;
2887         esac
2888         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
2889 ])dnl
2890 dnl ---------------------------------------------------------------------------
2891 dnl CF_LINK_DATAONLY version: 9 updated: 2009/01/01 20:21:38
2892 dnl ----------------
2893 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
2894 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
2895 dnl have to provide wrappers for global tables to ensure they're linked
2896 dnl properly.
2897 AC_DEFUN([CF_LINK_DATAONLY],
2898 [
2899 AC_MSG_CHECKING([if data-only library module links])
2900 AC_CACHE_VAL(cf_cv_link_dataonly,[
2901         rm -f conftest.a
2902         cat >conftest.$ac_ext <<EOF
2903 #line __oline__ "configure"
2904 int     testdata[[3]] = { 123, 456, 789 };
2905 EOF
2906         if AC_TRY_EVAL(ac_compile) ; then
2907                 mv conftest.o data.o && \
2908                 ( $AR $ARFLAGS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
2909         fi
2910         rm -f conftest.$ac_ext data.o
2911         cat >conftest.$ac_ext <<EOF
2912 #line __oline__ "configure"
2913 int     testfunc()
2914 {
2915 #if defined(NeXT)
2916         ${cf_cv_main_return:-return}(1);        /* I'm told this linker is broken */
2917 #else
2918         extern int testdata[[3]];
2919         return testdata[[0]] == 123
2920            &&  testdata[[1]] == 456
2921            &&  testdata[[2]] == 789;
2922 #endif
2923 }
2924 EOF
2925         if AC_TRY_EVAL(ac_compile); then
2926                 mv conftest.o func.o && \
2927                 ( $AR $ARFLAGS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
2928         fi
2929         rm -f conftest.$ac_ext func.o
2930         ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
2931         cf_saveLIBS="$LIBS"
2932         LIBS="conftest.a $LIBS"
2933         AC_TRY_RUN([
2934         int main()
2935         {
2936                 extern int testfunc();
2937                 ${cf_cv_main_return:-return} (!testfunc());
2938         }
2939         ],
2940         [cf_cv_link_dataonly=yes],
2941         [cf_cv_link_dataonly=no],
2942         [cf_cv_link_dataonly=unknown])
2943         LIBS="$cf_saveLIBS"
2944         ])
2945 AC_MSG_RESULT($cf_cv_link_dataonly)
2946
2947 if test "$cf_cv_link_dataonly" = no ; then
2948         AC_DEFINE(BROKEN_LINKER)
2949         BROKEN_LINKER=1
2950 fi
2951
2952 ])dnl
2953 dnl ---------------------------------------------------------------------------
2954 dnl CF_LINK_FUNCS version: 7 updated: 2006/12/16 12:33:30
2955 dnl -------------
2956 dnl Most Unix systems have both link and symlink, a few don't have symlink.
2957 dnl A few non-Unix systems implement symlink, but not link.
2958 dnl A few non-systems implement neither (or have nonfunctional versions).
2959 AC_DEFUN([CF_LINK_FUNCS],
2960 [
2961 AC_CHECK_FUNCS( \
2962         remove \
2963         unlink )
2964
2965 if test "$cross_compiling" = yes ; then
2966         AC_CHECK_FUNCS( \
2967                 link \
2968                 symlink )
2969 else
2970         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
2971                 cf_cv_link_funcs=
2972                 for cf_func in link symlink ; do
2973                         AC_TRY_RUN([
2974 #include <sys/types.h>
2975 #include <sys/stat.h>
2976 #ifdef HAVE_UNISTD_H
2977 #include <unistd.h>
2978 #endif
2979 int main()
2980 {
2981         int fail = 0;
2982         char *src = "config.log";
2983         char *dst = "conftest.chk";
2984         struct stat src_sb;
2985         struct stat dst_sb;
2986
2987         stat(src, &src_sb);
2988         fail = ($cf_func("config.log", "conftest.chk") < 0)
2989             || (stat(dst, &dst_sb) < 0)
2990             || (dst_sb.st_mtime != src_sb.st_mtime);
2991 #ifdef HAVE_UNLINK
2992         unlink(dst);
2993 #else
2994         remove(dst);
2995 #endif
2996         ${cf_cv_main_return:-return} (fail);
2997 }
2998                         ],[
2999                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
3000                         eval 'ac_cv_func_'$cf_func'=yes'],[
3001                         eval 'ac_cv_func_'$cf_func'=no'],[
3002                         eval 'ac_cv_func_'$cf_func'=error'])
3003                 done
3004                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
3005         ])
3006         test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK)
3007         test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
3008 fi
3009 ])dnl
3010 dnl ---------------------------------------------------------------------------
3011 dnl CF_MAIN_RETURN version: 1 updated: 2006/12/10 09:51:54
3012 dnl --------------
3013 dnl Check if a return from main to the shell actually returns the same exit
3014 dnl code.  This is true for almost any POSIX environment.
3015 dnl
3016 dnl Some very old environments did not flush stdout, etc., on an exit.  That
3017 dnl would be a useful case to test for also.
3018 AC_DEFUN([CF_MAIN_RETURN],
3019 [
3020 cf_cv_main_return=return
3021 ])dnl
3022 dnl ---------------------------------------------------------------------------
3023 dnl CF_MAKEFLAGS version: 12 updated: 2006/10/21 08:27:03
3024 dnl ------------
3025 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
3026 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
3027 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
3028 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
3029 AC_DEFUN([CF_MAKEFLAGS],
3030 [
3031 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
3032         cf_cv_makeflags=''
3033         for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
3034         do
3035                 cat >cf_makeflags.tmp <<CF_EOF
3036 SHELL = /bin/sh
3037 all :
3038         @ echo '.$cf_option'
3039 CF_EOF
3040                 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[       ]]*$,,'`
3041                 case "$cf_result" in
3042                 .*k)
3043                         cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
3044                         case "$cf_result" in
3045                         .*CC=*) cf_cv_makeflags=
3046                                 ;;
3047                         *)      cf_cv_makeflags=$cf_option
3048                                 ;;
3049                         esac
3050                         break
3051                         ;;
3052                 .-)     ;;
3053                 *)      echo "given option \"$cf_option\", no match \"$cf_result\""
3054                         ;;
3055                 esac
3056         done
3057         rm -f cf_makeflags.tmp
3058 ])
3059
3060 AC_SUBST(cf_cv_makeflags)
3061 ])dnl
3062 dnl ---------------------------------------------------------------------------
3063 dnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40
3064 dnl ------------
3065 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
3066 dnl a monocase filesystem.
3067 AC_DEFUN([CF_MAKE_TAGS],[
3068 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
3069 AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
3070
3071 if test "$cf_cv_mixedcase" = yes ; then
3072         AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
3073 else
3074         MAKE_UPPER_TAGS=no
3075 fi
3076
3077 if test "$MAKE_UPPER_TAGS" = yes ; then
3078         MAKE_UPPER_TAGS=
3079 else
3080         MAKE_UPPER_TAGS="#"
3081 fi
3082 AC_SUBST(MAKE_UPPER_TAGS)
3083
3084 if test "$MAKE_LOWER_TAGS" = yes ; then
3085         MAKE_LOWER_TAGS=
3086 else
3087         MAKE_LOWER_TAGS="#"
3088 fi
3089 AC_SUBST(MAKE_LOWER_TAGS)
3090 ])dnl
3091 dnl ---------------------------------------------------------------------------
3092 dnl CF_MANPAGE_FORMAT version: 8 updated: 2009/01/11 20:30:50
3093 dnl -----------------
3094 dnl Option to allow user to override automatic configuration of manpage format.
3095 dnl There are several special cases:
3096 dnl
3097 dnl     gzip - man checks for, can display gzip'd files
3098 dnl     compress - man checks for, can display compressed files
3099 dnl     BSDI - files in the cat-directories are suffixed ".0"
3100 dnl     formatted - installer should format (put files in cat-directory)
3101 dnl     catonly - installer should only format, e.g., for a turnkey system.
3102 dnl
3103 dnl There are other configurations which this macro does not test, e.g., HPUX's
3104 dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
3105 dnl convention would not match our use).
3106 AC_DEFUN([CF_MANPAGE_FORMAT],
3107 [
3108 AC_REQUIRE([CF_PATHSEP])
3109 AC_MSG_CHECKING(format of man-pages)
3110
3111 AC_ARG_WITH(manpage-format,
3112         [  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
3113                           optionally formatted/catonly, e.g., gzip,formatted],
3114         [MANPAGE_FORMAT=$withval],
3115         [MANPAGE_FORMAT=unknown])
3116
3117 test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
3118 MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
3119
3120 cf_unknown=
3121
3122 case $MANPAGE_FORMAT in
3123 unknown)
3124   if test -z "$MANPATH" ; then
3125     MANPATH="/usr/man:/usr/share/man"
3126   fi
3127
3128   # look for the 'date' man-page (it's most likely to be installed!)
3129   MANPAGE_FORMAT=
3130   cf_preform=no
3131   cf_catonly=yes
3132   cf_example=date
3133
3134   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
3135   for cf_dir in $MANPATH; do
3136     test -z "$cf_dir" && cf_dir=/usr/man
3137     for cf_name in $cf_dir/man*/$cf_example.[[01]]* $cf_dir/cat*/$cf_example.[[01]]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
3138     do
3139       cf_test=`echo $cf_name | sed -e 's/*//'`
3140       if test "x$cf_test" = "x$cf_name" ; then
3141
3142         case "$cf_name" in
3143         *.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
3144         *.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
3145         *.0)    MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
3146         *)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
3147         esac
3148
3149         case "$cf_name" in
3150         $cf_dir/man*)
3151           cf_catonly=no
3152           ;;
3153         $cf_dir/cat*)
3154           cf_preform=yes
3155           ;;
3156         esac
3157         break
3158       fi
3159
3160       # if we found a match in either man* or cat*, stop looking
3161       if test -n "$MANPAGE_FORMAT" ; then
3162         cf_found=no
3163         test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
3164         test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
3165         case "$cf_name" in
3166         $cf_dir/cat*)
3167           cf_found=yes
3168           ;;
3169         esac
3170         test $cf_found=yes && break
3171       fi
3172     done
3173     # only check the first directory in $MANPATH where we find manpages
3174     if test -n "$MANPAGE_FORMAT" ; then
3175        break
3176     fi
3177   done
3178   # if we did not find the example, just assume it is normal
3179   test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
3180   IFS="$ac_save_ifs"
3181   ;;
3182 *)
3183   for cf_option in $MANPAGE_FORMAT; do
3184      case $cf_option in #(vi
3185      gzip|compress|BSDI|normal|formatted|catonly)
3186        ;;
3187      *)
3188        cf_unknown="$cf_unknown $cf_option"
3189        ;;
3190      esac
3191   done
3192   ;;
3193 esac
3194
3195 AC_MSG_RESULT($MANPAGE_FORMAT)
3196 if test -n "$cf_unknown" ; then
3197   AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
3198 fi
3199 ])dnl
3200 dnl ---------------------------------------------------------------------------
3201 dnl CF_MANPAGE_RENAMES version: 7 updated: 2005/06/18 18:51:57
3202 dnl ------------------
3203 dnl The Debian people have their own naming convention for manpages.  This
3204 dnl option lets us override the name of the file containing renaming, or
3205 dnl disable it altogether.
3206 AC_DEFUN([CF_MANPAGE_RENAMES],
3207 [
3208 AC_MSG_CHECKING(for manpage renaming)
3209
3210 AC_ARG_WITH(manpage-renames,
3211         [  --with-manpage-renames  specify manpage-renaming],
3212         [MANPAGE_RENAMES=$withval],
3213         [MANPAGE_RENAMES=yes])
3214
3215 case ".$MANPAGE_RENAMES" in #(vi
3216 .no) #(vi
3217   ;;
3218 .|.yes)
3219   # Debian 'man' program?
3220   if test -f /etc/debian_version ; then
3221     MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
3222   else
3223     MANPAGE_RENAMES=no
3224   fi
3225   ;;
3226 esac
3227
3228 if test "$MANPAGE_RENAMES" != no ; then
3229   if test -f $srcdir/man/$MANPAGE_RENAMES ; then
3230     MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
3231   elif test ! -f $MANPAGE_RENAMES ; then
3232     AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
3233   fi
3234
3235   test ! -d man && mkdir man
3236
3237   # Construct a sed-script to perform renaming within man-pages
3238   if test -n "$MANPAGE_RENAMES" ; then
3239     test ! -d man && mkdir man
3240     sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >./edit_man.sed
3241   fi
3242 fi
3243
3244 AC_MSG_RESULT($MANPAGE_RENAMES)
3245 AC_SUBST(MANPAGE_RENAMES)
3246 ])dnl
3247 dnl ---------------------------------------------------------------------------
3248 dnl CF_MANPAGE_SYMLINKS version: 4 updated: 2003/12/13 18:01:58
3249 dnl -------------------
3250 dnl Some people expect each tool to make all aliases for manpages in the
3251 dnl man-directory.  This accommodates the older, less-capable implementations
3252 dnl of 'man', and is optional.
3253 AC_DEFUN([CF_MANPAGE_SYMLINKS],
3254 [
3255 AC_MSG_CHECKING(if manpage aliases will be installed)
3256
3257 AC_ARG_WITH(manpage-aliases,
3258         [  --with-manpage-aliases  specify manpage-aliases using .so],
3259         [MANPAGE_ALIASES=$withval],
3260         [MANPAGE_ALIASES=yes])
3261
3262 AC_MSG_RESULT($MANPAGE_ALIASES)
3263
3264 if test "$LN_S" = "ln -s"; then
3265         cf_use_symlinks=yes
3266 else
3267         cf_use_symlinks=no
3268 fi
3269
3270 MANPAGE_SYMLINKS=no
3271 if test "$MANPAGE_ALIASES" = yes ; then
3272 AC_MSG_CHECKING(if manpage symlinks should be used)
3273
3274 AC_ARG_WITH(manpage-symlinks,
3275         [  --with-manpage-symlinks specify manpage-aliases using symlinks],
3276         [MANPAGE_SYMLINKS=$withval],
3277         [MANPAGE_SYMLINKS=$cf_use_symlinks])
3278
3279 if test "$$cf_use_symlinks" = no; then
3280 if test "$MANPAGE_SYMLINKS" = yes ; then
3281         AC_MSG_WARN(cannot make symlinks, will use .so files)
3282         MANPAGE_SYMLINKS=no
3283 fi
3284 fi
3285
3286 AC_MSG_RESULT($MANPAGE_SYMLINKS)
3287 fi
3288
3289 ])dnl
3290 dnl ---------------------------------------------------------------------------
3291 dnl CF_MANPAGE_TBL version: 3 updated: 2002/01/19 22:51:32
3292 dnl --------------
3293 dnl This option causes manpages to be run through tbl(1) to generate tables
3294 dnl correctly.
3295 AC_DEFUN([CF_MANPAGE_TBL],
3296 [
3297 AC_MSG_CHECKING(for manpage tbl)
3298
3299 AC_ARG_WITH(manpage-tbl,
3300         [  --with-manpage-tbl      specify manpage processing with tbl],
3301         [MANPAGE_TBL=$withval],
3302         [MANPAGE_TBL=no])
3303
3304 AC_MSG_RESULT($MANPAGE_TBL)
3305 ])dnl
3306 dnl ---------------------------------------------------------------------------
3307 dnl CF_MAN_PAGES version: 35 updated: 2007/03/31 11:47:29
3308 dnl ------------
3309 dnl Try to determine if the man-pages on the system are compressed, and if
3310 dnl so, what format is used.  Use this information to construct a script that
3311 dnl will install man-pages.
3312 AC_DEFUN([CF_MAN_PAGES],
3313 [
3314 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
3315 CF_MANPAGE_FORMAT
3316 CF_MANPAGE_RENAMES
3317 CF_MANPAGE_SYMLINKS
3318 CF_MANPAGE_TBL
3319
3320   if test "$prefix" = "NONE" ; then
3321      cf_prefix="$ac_default_prefix"
3322   else
3323      cf_prefix="$prefix"
3324   fi
3325
3326   case "$MANPAGE_FORMAT" in # (vi
3327   *catonly*) # (vi
3328     cf_format=yes
3329     cf_inboth=no
3330     ;;
3331   *formatted*) # (vi
3332     cf_format=yes
3333     cf_inboth=yes
3334     ;;
3335   *)
3336     cf_format=no
3337     cf_inboth=no
3338     ;;
3339   esac
3340
3341 test ! -d man && mkdir man
3342
3343 cf_so_strip=
3344 cf_compress=
3345 case "$MANPAGE_FORMAT" in #(vi
3346 *compress*) #(vi
3347         cf_so_strip="Z"
3348         cf_compress=compress
3349   ;;
3350 *gzip*) #(vi
3351         cf_so_strip="gz"
3352         cf_compress=gzip
3353   ;;
3354 esac
3355
3356 cf_edit_man=./edit_man.sh
3357 cf_man_alias=`pwd`/man_alias.sed
3358
3359 cat >$cf_edit_man <<CF_EOF
3360 #! /bin/sh
3361 # this script is generated by the configure-script CF_MAN_PAGES macro.
3362
3363 prefix="$cf_prefix"
3364 datadir="$datadir"
3365
3366 NCURSES_MAJOR="$NCURSES_MAJOR"
3367 NCURSES_MINOR="$NCURSES_MINOR"
3368 NCURSES_PATCH="$NCURSES_PATCH"
3369
3370 NCURSES_OSPEED="$NCURSES_OSPEED"
3371 TERMINFO="$TERMINFO"
3372
3373 MKDIRS="sh `cd $srcdir && pwd`/mkdirs.sh"
3374
3375 INSTALL="$INSTALL"
3376 INSTALL_DATA="$INSTALL_DATA"
3377
3378 transform="$program_transform_name"
3379
3380 TMP=\${TMPDIR-/tmp}/man\$\$
3381 trap "rm -f \$TMP" 0 1 2 5 15
3382
3383 form=\[$]1
3384 shift || exit 1
3385
3386 verb=\[$]1
3387 shift || exit 1
3388
3389 mandir=\[$]1
3390 shift || exit 1
3391
3392 srcdir=\[$]1
3393 top_srcdir=\[$]srcdir/..
3394 shift || exit 1
3395
3396 if test "\$form" = normal ; then
3397         if test "$cf_format" = yes ; then
3398         if test "$cf_inboth" = no ; then
3399                 sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
3400                 exit $?
3401         fi
3402         fi
3403         cf_subdir=\$mandir/man
3404         cf_tables=$MANPAGE_TBL
3405 else
3406         cf_subdir=\$mandir/cat
3407         cf_tables=yes
3408 fi
3409
3410 # process the list of source-files
3411 for i in \[$]* ; do
3412 case \$i in #(vi
3413 *.orig|*.rej) ;; #(vi
3414 *.[[0-9]]*)
3415         section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`;
3416         if test \$verb = installing ; then
3417         if test ! -d \$cf_subdir\${section} ; then
3418                 \$MKDIRS \$cf_subdir\$section
3419         fi
3420         fi
3421
3422         # replace variables in man page
3423         if test ! -f $cf_man_alias ; then
3424 cat >>$cf_man_alias <<-CF_EOF2
3425                 s,@DATADIR@,\$datadir,g
3426                 s,@TERMINFO@,\$TERMINFO,g
3427                 s,@NCURSES_MAJOR@,\$NCURSES_MAJOR,g
3428                 s,@NCURSES_MINOR@,\$NCURSES_MINOR,g
3429                 s,@NCURSES_PATCH@,\$NCURSES_PATCH,g
3430                 s,@NCURSES_OSPEED@,\$NCURSES_OSPEED,g
3431 CF_EOF
3432         ifelse($1,,,[
3433         for cf_name in $1
3434         do
3435                 cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3436                 cf_name=`echo $cf_name|sed "$program_transform_name"`
3437 cat >>$cf_edit_man <<-CF_EOF
3438                 s,@$cf_NAME@,$cf_name,
3439 CF_EOF
3440         done
3441         ])
3442 cat >>$cf_edit_man <<CF_EOF
3443 CF_EOF2
3444                 echo "...made $cf_man_alias"
3445         fi
3446
3447         aliases=
3448         cf_source=\`basename \$i\`
3449         inalias=\$cf_source
3450         test ! -f \$inalias && inalias="\$srcdir/\$inalias"
3451         if test ! -f \$inalias ; then
3452                 echo .. skipped \$cf_source
3453                 continue
3454         fi
3455 CF_EOF
3456
3457 if test "$MANPAGE_ALIASES" != no ; then
3458 cat >>$cf_edit_man <<CF_EOF
3459         aliases=\`sed -f \$top_srcdir/man/manlinks.sed \$inalias |sed -f $cf_man_alias | sort -u\`
3460 CF_EOF
3461 fi
3462
3463 if test "$MANPAGE_RENAMES" = no ; then
3464 cat >>$cf_edit_man <<CF_EOF
3465         # perform program transformations for section 1 man pages
3466         if test \$section = 1 ; then
3467                 cf_target=\$cf_subdir\${section}/\`echo \$cf_source|sed "\${transform}"\`
3468         else
3469                 cf_target=\$cf_subdir\${section}/\$cf_source
3470         fi
3471 CF_EOF
3472 else
3473 cat >>$cf_edit_man <<CF_EOF
3474         cf_target=\`grep "^\$cf_source" $MANPAGE_RENAMES | $AWK '{print \[$]2}'\`
3475         if test -z "\$cf_target" ; then
3476                 echo '? missing rename for '\$cf_source
3477                 cf_target="\$cf_source"
3478         fi
3479         cf_target="\$cf_subdir\${section}/\${cf_target}"
3480
3481 CF_EOF
3482 fi
3483
3484 cat >>$cf_edit_man <<CF_EOF
3485         sed     -f $cf_man_alias \\
3486 CF_EOF
3487
3488 if test -f $MANPAGE_RENAMES ; then
3489 cat >>$cf_edit_man <<CF_EOF
3490                 < \$i | sed -f `pwd`/edit_man.sed >\$TMP
3491 CF_EOF
3492 else
3493 cat >>$cf_edit_man <<CF_EOF
3494                 < \$i >\$TMP
3495 CF_EOF
3496 fi
3497
3498 cat >>$cf_edit_man <<CF_EOF
3499 if test \$cf_tables = yes ; then
3500         tbl \$TMP >\$TMP.out
3501         mv \$TMP.out \$TMP
3502 fi
3503 CF_EOF
3504
3505 if test $with_curses_h != yes ; then
3506 cat >>$cf_edit_man <<CF_EOF
3507         sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
3508         mv \$TMP.out \$TMP
3509 CF_EOF
3510 fi
3511
3512 cat >>$cf_edit_man <<CF_EOF
3513         if test \$form = format ; then
3514                 nroff -man \$TMP >\$TMP.out
3515                 mv \$TMP.out \$TMP
3516         fi
3517 CF_EOF
3518
3519 if test -n "$cf_compress" ; then
3520 cat >>$cf_edit_man <<CF_EOF
3521         if test \$verb = installing ; then
3522         if ( $cf_compress -f \$TMP )
3523         then
3524                 mv \$TMP.$cf_so_strip \$TMP
3525         fi
3526         fi
3527         cf_target="\$cf_target.$cf_so_strip"
3528 CF_EOF
3529 fi
3530
3531 case "$MANPAGE_FORMAT" in #(vi
3532 *BSDI*)
3533 cat >>$cf_edit_man <<CF_EOF
3534         if test \$form = format ; then
3535                 # BSDI installs only .0 suffixes in the cat directories
3536                 cf_target="\`echo \$cf_target|sed -e 's/\.[[1-9]]\+[[a-z]]*/.0/'\`"
3537         fi
3538 CF_EOF
3539   ;;
3540 esac
3541
3542 cat >>$cf_edit_man <<CF_EOF
3543         suffix=\`basename \$cf_target | sed -e 's%^[[^.]]*%%'\`
3544         if test \$verb = installing ; then
3545                 echo \$verb \$cf_target
3546                 \$INSTALL_DATA \$TMP \$cf_target
3547                 test -d \$cf_subdir\${section} &&
3548                 test -n "\$aliases" && (
3549                         cd \$cf_subdir\${section} && (
3550                                 cf_source=\`echo \$cf_target |sed -e 's%^.*/\([[^/]][[^/]]*/[[^/]][[^/]]*$\)%\1%'\`
3551                                 test -n "$cf_so_strip" && cf_source=\`echo \$cf_source |sed -e 's%\.$cf_so_strip\$%%'\`
3552                                 cf_target=\`basename \$cf_target\`
3553                                 for cf_alias in \$aliases
3554                                 do
3555                                         if test \$section = 1 ; then
3556                                                 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
3557                                         fi
3558
3559                                         if test "$MANPAGE_SYMLINKS" = yes ; then
3560                                                 if test -f \$cf_alias\${suffix} ; then
3561                                                         if ( cmp -s \$cf_target \$cf_alias\${suffix} )
3562                                                         then
3563                                                                 continue
3564                                                         fi
3565                                                 fi
3566                                                 echo .. \$verb alias \$cf_alias\${suffix}
3567                                                 rm -f \$cf_alias\${suffix}
3568                                                 $LN_S \$cf_target \$cf_alias\${suffix}
3569                                         elif test "\$cf_target" != "\$cf_alias\${suffix}" ; then
3570                                                 echo ".so \$cf_source" >\$TMP
3571 CF_EOF
3572 if test -n "$cf_compress" ; then
3573 cat >>$cf_edit_man <<CF_EOF
3574                                                 if test -n "$cf_so_strip" ; then
3575                                                         $cf_compress -f \$TMP
3576                                                         mv \$TMP.$cf_so_strip \$TMP
3577                                                 fi
3578 CF_EOF
3579 fi
3580 cat >>$cf_edit_man <<CF_EOF
3581                                                 echo .. \$verb alias \$cf_alias\${suffix}
3582                                                 rm -f \$cf_alias\${suffix}
3583                                                 \$INSTALL_DATA \$TMP \$cf_alias\${suffix}
3584                                         fi
3585                                 done
3586                         )
3587                 )
3588         elif test \$verb = removing ; then
3589                 test -f \$cf_target && (
3590                         echo \$verb \$cf_target
3591                         rm -f \$cf_target
3592                 )
3593                 test -d \$cf_subdir\${section} &&
3594                 test -n "\$aliases" && (
3595                         cd \$cf_subdir\${section} && (
3596                                 for cf_alias in \$aliases
3597                                 do
3598                                         if test \$section = 1 ; then
3599                                                 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
3600                                         fi
3601
3602                                         echo .. \$verb alias \$cf_alias\${suffix}
3603                                         rm -f \$cf_alias\${suffix}
3604                                 done
3605                         )
3606                 )
3607         else
3608 #               echo ".hy 0"
3609                 cat \$TMP
3610         fi
3611         ;;
3612 esac
3613 done
3614
3615 if test $cf_inboth = yes ; then
3616 if test \$form != format ; then
3617         sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
3618 fi
3619 fi
3620
3621 exit 0
3622 CF_EOF
3623 chmod 755 $cf_edit_man
3624
3625 ])dnl
3626 dnl ---------------------------------------------------------------------------
3627 dnl CF_MATH_LIB version: 6 updated: 2009/12/19 13:46:49
3628 dnl -----------
3629 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
3630 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
3631 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
3632 AC_DEFUN([CF_MATH_LIB],
3633 [
3634 AC_CACHE_CHECK(if -lm needed for math functions,
3635         cf_cv_need_libm,[
3636         AC_TRY_LINK([
3637         #include <stdio.h>
3638         #include <math.h>
3639         ],
3640         [double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
3641         [cf_cv_need_libm=no],
3642         [cf_cv_need_libm=yes])])
3643 if test "$cf_cv_need_libm" = yes
3644 then
3645 ifelse($1,,[
3646         LIBS="-lm $LIBS"
3647 ],[$1=-lm])
3648 fi
3649 ])
3650 dnl ---------------------------------------------------------------------------
3651 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
3652 dnl ----------------------
3653 dnl Check if the file-system supports mixed-case filenames.  If we're able to
3654 dnl create a lowercase name and see it as uppercase, it doesn't support that.
3655 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
3656 [
3657 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
3658 if test "$cross_compiling" = yes ; then
3659         case $target_alias in #(vi
3660         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
3661                 cf_cv_mixedcase=no
3662                 ;;
3663         *)
3664                 cf_cv_mixedcase=yes
3665                 ;;
3666         esac
3667 else
3668         rm -f conftest CONFTEST
3669         echo test >conftest
3670         if test -f CONFTEST ; then
3671                 cf_cv_mixedcase=no
3672         else
3673                 cf_cv_mixedcase=yes
3674         fi
3675         rm -f conftest CONFTEST
3676 fi
3677 ])
3678 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
3679 ])dnl
3680 dnl ---------------------------------------------------------------------------
3681 dnl CF_MKSTEMP version: 5 updated: 2006/12/16 12:33:30
3682 dnl ----------
3683 dnl Check for a working mkstemp.  This creates two files, checks that they are
3684 dnl successfully created and distinct (AmigaOS apparently fails on the last).
3685 AC_DEFUN([CF_MKSTEMP],[
3686 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
3687 rm -f conftest*
3688 AC_TRY_RUN([
3689 #include <sys/types.h>
3690 #include <stdlib.h>
3691 #include <stdio.h>
3692 #include <string.h>
3693 #include <sys/stat.h>
3694 int main()
3695 {
3696         char *tmpl = "conftestXXXXXX";
3697         char name[2][80];
3698         int n;
3699         int result = 0;
3700         int fd;
3701         struct stat sb;
3702
3703         umask(077);
3704         for (n = 0; n < 2; ++n) {
3705                 strcpy(name[n], tmpl);
3706                 if ((fd = mkstemp(name[n])) >= 0) {
3707                         if (!strcmp(name[n], tmpl)
3708                          || stat(name[n], &sb) != 0
3709                          || (sb.st_mode & S_IFMT) != S_IFREG
3710                          || (sb.st_mode & 077) != 0) {
3711                                 result = 1;
3712                         }
3713                         close(fd);
3714                 }
3715         }
3716         if (result == 0
3717          && !strcmp(name[0], name[1]))
3718                 result = 1;
3719         ${cf_cv_main_return:-return}(result);
3720 }
3721 ],[cf_cv_func_mkstemp=yes
3722 ],[cf_cv_func_mkstemp=no
3723 ],[AC_CHECK_FUNC(mkstemp)
3724 ])
3725 ])
3726 if test "$cf_cv_func_mkstemp" = yes ; then
3727         AC_DEFINE(HAVE_MKSTEMP)
3728 fi
3729 ])dnl
3730 dnl ---------------------------------------------------------------------------
3731 dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
3732 dnl ----------
3733 dnl Write a debug message to config.log, along with the line number in the
3734 dnl configure script.
3735 AC_DEFUN([CF_MSG_LOG],[
3736 echo "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
3737 ])dnl
3738 dnl ---------------------------------------------------------------------------
3739 dnl CF_NCURSES_ABI_6 version: 1 updated: 2005/09/17 18:42:49
3740 dnl ----------------
3741 dnl Set ncurses' ABI to 6 unless overridden by explicit configure option, and
3742 dnl warn about this.
3743 AC_DEFUN([CF_NCURSES_ABI_6],[
3744 if test "${with_abi_version+set}" != set; then
3745         case $cf_cv_rel_version in
3746         5.*)
3747                 cf_cv_rel_version=6.0
3748                 cf_cv_abi_version=6
3749                 AC_MSG_WARN(Overriding ABI version to $cf_cv_abi_version)
3750                 ;;
3751         esac
3752 fi
3753 ])dnl
3754 dnl ---------------------------------------------------------------------------
3755 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
3756 dnl ------------------
3757 dnl see CF_WITH_NO_LEAKS
3758 AC_DEFUN([CF_NO_LEAKS_OPTION],[
3759 AC_MSG_CHECKING(if you want to use $1 for testing)
3760 AC_ARG_WITH($1,
3761         [$2],
3762         [AC_DEFINE($3)ifelse([$4],,[
3763          $4
3764 ])
3765         : ${with_cflags:=-g}
3766         : ${with_no_leaks:=yes}
3767          with_$1=yes],
3768         [with_$1=])
3769 AC_MSG_RESULT(${with_$1:-no})
3770
3771 case .$with_cflags in #(vi
3772 .*-g*)
3773         case .$CFLAGS in #(vi
3774         .*-g*) #(vi
3775                 ;;
3776         *)
3777                 CF_ADD_CFLAGS([-g])
3778                 ;;
3779         esac
3780         ;;
3781 esac
3782 ])dnl
3783 dnl ---------------------------------------------------------------------------
3784 dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
3785 dnl ----------------
3786 dnl Check if the given variable is a number.  If not, report an error.
3787 dnl $1 is the variable
3788 dnl $2 is the message
3789 AC_DEFUN([CF_NUMBER_SYNTAX],[
3790 if test -n "$1" ; then
3791   case $1 in #(vi
3792   [[0-9]]*) #(vi
3793         ;;
3794   *)
3795         AC_MSG_ERROR($2 is not a number: $1)
3796         ;;
3797   esac
3798 else
3799   AC_MSG_ERROR($2 value is empty)
3800 fi
3801 ])dnl
3802 dnl ---------------------------------------------------------------------------
3803 dnl CF_OBJ_SUBDIR version: 4 updated: 2002/02/23 20:38:31
3804 dnl -------------
3805 dnl Compute the object-directory name from the given model name
3806 AC_DEFUN([CF_OBJ_SUBDIR],
3807 [
3808         case $1 in
3809         libtool) $2='obj_lo'  ;;
3810         normal)  $2='objects' ;;
3811         debug)   $2='obj_g' ;;
3812         profile) $2='obj_p' ;;
3813         shared)
3814                 case $cf_cv_system_name in #(vi
3815                 cygwin) #(vi
3816                         $2='objects' ;;
3817                 *)
3818                         $2='obj_s' ;;
3819                 esac
3820         esac
3821 ])dnl
3822 dnl ---------------------------------------------------------------------------
3823 dnl CF_PATHSEP version: 4 updated: 2009/01/11 20:30:23
3824 dnl ----------
3825 dnl Provide a value for the $PATH and similar separator
3826 AC_DEFUN([CF_PATHSEP],
3827 [
3828         case $cf_cv_system_name in
3829         os2*)   PATH_SEPARATOR=';'  ;;
3830         *)      PATH_SEPARATOR=':'  ;;
3831         esac
3832 ifelse($1,,,[$1=$PATH_SEPARATOR])
3833         AC_SUBST(PATH_SEPARATOR)
3834 ])dnl
3835 dnl ---------------------------------------------------------------------------
3836 dnl CF_PATH_SYNTAX version: 12 updated: 2008/03/23 14:45:59
3837 dnl --------------
3838 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
3839 dnl begins with one of the prefix/exec_prefix variables, and then again if the
3840 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
3841 dnl delayed evaluation of those symbols.
3842 AC_DEFUN([CF_PATH_SYNTAX],[
3843 if test "x$prefix" != xNONE; then
3844   cf_path_syntax="$prefix"
3845 else
3846   cf_path_syntax="$ac_default_prefix"
3847 fi
3848
3849 case ".[$]$1" in #(vi
3850 .\[$]\(*\)*|.\'*\'*) #(vi
3851   ;;
3852 ..|./*|.\\*) #(vi
3853   ;;
3854 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
3855   ;;
3856 .\[$]{*prefix}*) #(vi
3857   eval $1="[$]$1"
3858   case ".[$]$1" in #(vi
3859   .NONE/*)
3860     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
3861     ;;
3862   esac
3863   ;; #(vi
3864 .no|.NONE/*)
3865   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
3866   ;;
3867 *)
3868   ifelse($2,,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
3869   ;;
3870 esac
3871 ])dnl
3872 dnl ---------------------------------------------------------------------------
3873 dnl CF_PKG_CONFIG version: 3 updated: 2009/01/25 10:55:09
3874 dnl -------------
3875 dnl Check for the package-config program, unless disabled by command-line.
3876 AC_DEFUN([CF_PKG_CONFIG],
3877 [
3878 AC_MSG_CHECKING(if you want to use pkg-config)
3879 AC_ARG_WITH(pkg-config,
3880         [  --with-pkg-config{=path} enable/disable use of pkg-config],
3881         [cf_pkg_config=$withval],
3882         [cf_pkg_config=yes])
3883 AC_MSG_RESULT($cf_pkg_config)
3884
3885 case $cf_pkg_config in #(vi
3886 no) #(vi
3887         PKG_CONFIG=none
3888         ;;
3889 yes) #(vi
3890         AC_PATH_PROG(PKG_CONFIG, pkg-config, none)
3891         ;;
3892 *)
3893         PKG_CONFIG=$withval
3894         ;;
3895 esac
3896
3897 test -z "$PKG_CONFIG" && PKG_CONFIG=none
3898 if test "$PKG_CONFIG" != none ; then
3899         CF_PATH_SYNTAX(PKG_CONFIG)
3900 fi
3901
3902 AC_SUBST(PKG_CONFIG)
3903 ])dnl
3904 dnl ---------------------------------------------------------------------------
3905 dnl CF_POSIX_C_SOURCE version: 7 updated: 2010/01/09 11:05:50
3906 dnl -----------------
3907 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
3908 dnl
3909 dnl     POSIX.1-1990                            _POSIX_SOURCE
3910 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
3911 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
3912 dnl             Bindings Option
3913 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
3914 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
3915 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
3916 dnl
3917 dnl Parameters:
3918 dnl     $1 is the nominal value for _POSIX_C_SOURCE
3919 AC_DEFUN([CF_POSIX_C_SOURCE],
3920 [
3921 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
3922
3923 cf_save_CFLAGS="$CFLAGS"
3924 cf_save_CPPFLAGS="$CPPFLAGS"
3925
3926 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
3927 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
3928
3929 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
3930         CF_MSG_LOG(if the symbol is already defined go no further)
3931         AC_TRY_COMPILE([#include <sys/types.h>],[
3932 #ifndef _POSIX_C_SOURCE
3933 make an error
3934 #endif],
3935         [cf_cv_posix_c_source=no],
3936         [cf_want_posix_source=no
3937          case .$cf_POSIX_C_SOURCE in #(vi
3938          .[[12]]??*) #(vi
3939                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3940                 ;;
3941          .2) #(vi
3942                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3943                 cf_want_posix_source=yes
3944                 ;;
3945          .*)
3946                 cf_want_posix_source=yes
3947                 ;;
3948          esac
3949          if test "$cf_want_posix_source" = yes ; then
3950                 AC_TRY_COMPILE([#include <sys/types.h>],[
3951 #ifdef _POSIX_SOURCE
3952 make an error
3953 #endif],[],
3954                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
3955          fi
3956          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
3957          CFLAGS="$cf_trim_CFLAGS"
3958          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
3959          CF_MSG_LOG(if the second compile does not leave our definition intact error)
3960          AC_TRY_COMPILE([#include <sys/types.h>],[
3961 #ifndef _POSIX_C_SOURCE
3962 make an error
3963 #endif],,
3964          [cf_cv_posix_c_source=no])
3965          CFLAGS="$cf_save_CFLAGS"
3966          CPPFLAGS="$cf_save_CPPFLAGS"
3967         ])
3968 ])
3969
3970 if test "$cf_cv_posix_c_source" != no ; then
3971         CFLAGS="$cf_trim_CFLAGS"
3972         CPPFLAGS="$cf_trim_CPPFLAGS"
3973         CF_ADD_CFLAGS($cf_cv_posix_c_source)
3974 fi
3975
3976 ])dnl
3977 dnl ---------------------------------------------------------------------------
3978 dnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
3979 dnl ------------
3980 dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
3981 dnl
3982 dnl $1 = symbol to test
3983 dnl $2 = value (if any) to use for a predefinition
3984 AC_DEFUN([CF_PREDEFINE],
3985 [
3986 AC_MSG_CHECKING(if we must define $1)
3987 AC_TRY_COMPILE([#include <sys/types.h>
3988 ],[
3989 #ifndef $1
3990 make an error
3991 #endif],[cf_result=no],[cf_result=yes])
3992 AC_MSG_RESULT($cf_result)
3993
3994 if test "$cf_result" = yes ; then
3995         CPPFLAGS="$CPPFLAGS ifelse($2,,-D$1,[-D$1=$2])"
3996 elif test "x$2" != "x" ; then
3997         AC_MSG_CHECKING(checking for compatible value versus $2)
3998         AC_TRY_COMPILE([#include <sys/types.h>
3999 ],[
4000 #if $1-$2 < 0
4001 make an error
4002 #endif],[cf_result=yes],[cf_result=no])
4003         AC_MSG_RESULT($cf_result)
4004         if test "$cf_result" = no ; then
4005                 # perhaps we can override it - try...
4006                 CPPFLAGS="$CPPFLAGS -D$1=$2"
4007         fi
4008 fi
4009 ])dnl
4010 dnl ---------------------------------------------------------------------------
4011 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
4012 dnl ------------
4013 dnl Append definitions and rules for the given programs to the subdirectory
4014 dnl Makefiles, and the recursion rule for the top-level Makefile.
4015 dnl
4016 dnl parameters
4017 dnl     $1 = script to run
4018 dnl     $2 = list of subdirectories
4019 dnl
4020 dnl variables
4021 dnl     $AWK
4022 AC_DEFUN([CF_PRG_RULES],
4023 [
4024 for cf_dir in $2
4025 do
4026         if test ! -d $srcdir/$cf_dir; then
4027                 continue
4028         elif test -f $srcdir/$cf_dir/programs; then
4029                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
4030         fi
4031 done
4032
4033 ])dnl
4034 dnl ---------------------------------------------------------------------------
4035 dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
4036 dnl ----------
4037 dnl Check for archiver "ar".
4038 AC_DEFUN([CF_PROG_AR],[
4039 AC_CHECK_TOOL(AR, ar, ar)
4040 ])
4041 dnl ---------------------------------------------------------------------------
4042 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
4043 dnl -----------
4044 dnl Check for awk, ensure that the check found something.
4045 AC_DEFUN([CF_PROG_AWK],
4046 [
4047 AC_PROG_AWK
4048 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
4049 ])dnl
4050 dnl ---------------------------------------------------------------------------
4051 dnl CF_PROG_CC_C_O version: 2 updated: 2006/12/16 15:55:46
4052 dnl --------------
4053 dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
4054 dnl the output file can be renamed, and allows for a shell variable that can
4055 dnl be used later.  The parameter is either CC or CXX.  The result is the
4056 dnl cache variable:
4057 dnl     $cf_cv_prog_CC_c_o
4058 dnl     $cf_cv_prog_CXX_c_o
4059 AC_DEFUN([CF_PROG_CC_C_O],
4060 [AC_REQUIRE([AC_PROG_CC])dnl
4061 AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
4062 AC_CACHE_VAL(cf_cv_prog_$1_c_o,
4063 [
4064 cat > conftest.$ac_ext <<CF_EOF
4065 #include <stdio.h>
4066 int main()
4067 {
4068         ${cf_cv_main_return:-return}(0);
4069 }
4070 CF_EOF
4071 # We do the test twice because some compilers refuse to overwrite an
4072 # existing .o file with -o, though they will create one.
4073 ac_try='[$]$1 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
4074 if AC_TRY_EVAL(ac_try) &&
4075   test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
4076 then
4077   eval cf_cv_prog_$1_c_o=yes
4078 else
4079   eval cf_cv_prog_$1_c_o=no
4080 fi
4081 rm -f conftest*
4082 ])dnl
4083 if test $cf_cv_prog_$1_c_o = yes; then
4084   AC_MSG_RESULT([yes])
4085 else
4086   AC_MSG_RESULT([no])
4087 fi
4088 ])dnl
4089 dnl ---------------------------------------------------------------------------
4090 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
4091 dnl --------------
4092 dnl Check if C (preprocessor) -U and -D options are processed in the order
4093 dnl given rather than by type of option.  Some compilers insist on apply all
4094 dnl of the -U options after all of the -D options.  Others allow mixing them,
4095 dnl and may predefine symbols that conflict with those we define.
4096 AC_DEFUN([CF_PROG_CC_U_D],
4097 [
4098 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
4099         cf_save_CPPFLAGS="$CPPFLAGS"
4100         CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
4101         AC_TRY_COMPILE([],[
4102 #ifndef U_D_OPTIONS
4103 make an undefined-error
4104 #endif
4105 #ifdef  D_U_OPTIONS
4106 make a defined-error
4107 #endif
4108         ],[
4109         cf_cv_cc_u_d_options=yes],[
4110         cf_cv_cc_u_d_options=no])
4111         CPPFLAGS="$cf_save_CPPFLAGS"
4112 ])
4113 ])dnl
4114 dnl ---------------------------------------------------------------------------
4115 dnl CF_PROG_EGREP version: 1 updated: 2006/09/16 11:40:59
4116 dnl -------------
4117 dnl AC_PROG_EGREP was introduced in autoconf 2.53.
4118 dnl This macro adds a check to ensure the script found something.
4119 AC_DEFUN([CF_PROG_EGREP],
4120 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
4121    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
4122     then ac_cv_prog_egrep='grep -E'
4123     else ac_cv_prog_egrep='egrep'
4124     fi])
4125  EGREP=$ac_cv_prog_egrep
4126  AC_SUBST([EGREP])
4127 test -z "$EGREP" && AC_MSG_ERROR(No egrep program found)
4128 ])dnl
4129 dnl ---------------------------------------------------------------------------
4130 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
4131 dnl -----------
4132 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
4133 AC_DEFUN([CF_PROG_EXT],
4134 [
4135 AC_REQUIRE([CF_CHECK_CACHE])
4136 case $cf_cv_system_name in
4137 os2*)
4138     CFLAGS="$CFLAGS -Zmt"
4139     CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
4140     CXXFLAGS="$CXXFLAGS -Zmt"
4141     # autoconf's macro sets -Zexe and suffix both, which conflict:w
4142     LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
4143     ac_cv_exeext=.exe
4144     ;;
4145 esac
4146
4147 AC_EXEEXT
4148 AC_OBJEXT
4149
4150 PROG_EXT="$EXEEXT"
4151 AC_SUBST(PROG_EXT)
4152 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
4153 ])dnl
4154 dnl ---------------------------------------------------------------------------
4155 dnl CF_PROG_INSTALL version: 5 updated: 2002/12/21 22:46:07
4156 dnl ---------------
4157 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
4158 dnl misc/tabset install won't work properly.  Usually this happens only when
4159 dnl using the fallback mkinstalldirs script
4160 AC_DEFUN([CF_PROG_INSTALL],
4161 [AC_PROG_INSTALL
4162 case $INSTALL in
4163 /*)
4164   ;;
4165 *)
4166   CF_DIRNAME(cf_dir,$INSTALL)
4167   test -z "$cf_dir" && cf_dir=.
4168   INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
4169   ;;
4170 esac
4171 ])dnl
4172 dnl ---------------------------------------------------------------------------
4173 dnl CF_PROG_LDCONFIG version: 2 updated: 2008/12/13 14:08:40
4174 dnl ----------------
4175 dnl Check for ldconfig, needed to fixup shared libraries that would be built
4176 dnl and then used in the install.
4177 AC_DEFUN([CF_PROG_LDCONFIG],[
4178 if test "$cross_compiling" = yes ; then
4179   LDCONFIG=:
4180 else
4181 case "$cf_cv_system_name" in #(vi
4182 dragonfly*|freebsd*) #(vi
4183   test -z "$LDCONFIG" && LDCONFIG="/sbin/ldconfig -R"
4184   ;;
4185 *) LDPATH=$PATH:/sbin:/usr/sbin
4186   AC_PATH_PROG(LDCONFIG,ldconfig,,$LDPATH)
4187   ;;
4188 esac
4189 fi
4190 AC_SUBST(LDCONFIG)
4191 ])dnl
4192 dnl ---------------------------------------------------------------------------
4193 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
4194 dnl ------------
4195 AC_DEFUN([CF_PROG_LINT],
4196 [
4197 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
4198 AC_SUBST(LINT_OPTS)
4199 ])dnl
4200 dnl ---------------------------------------------------------------------------
4201 dnl CF_REGEX version: 3 updated: 1997/11/01 14:26:01
4202 dnl --------
4203 dnl Attempt to determine if we've got one of the flavors of regular-expression
4204 dnl code that we can support.
4205 AC_DEFUN([CF_REGEX],
4206 [
4207 AC_MSG_CHECKING([for regular-expression headers])
4208 AC_CACHE_VAL(cf_cv_regex,[
4209 AC_TRY_LINK([#include <sys/types.h>
4210 #include <regex.h>],[
4211         regex_t *p;
4212         int x = regcomp(p, "", 0);
4213         int y = regexec(p, "", 0, 0, 0);
4214         regfree(p);
4215         ],[cf_cv_regex="regex.h"],[
4216         AC_TRY_LINK([#include <regexp.h>],[
4217                 char *p = compile("", "", "", 0);
4218                 int x = step("", "");
4219         ],[cf_cv_regex="regexp.h"],[
4220                 cf_save_LIBS="$LIBS"
4221                 LIBS="-lgen $LIBS"
4222                 AC_TRY_LINK([#include <regexpr.h>],[
4223                         char *p = compile("", "", "");
4224                         int x = step("", "");
4225                 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
4226 ])
4227 AC_MSG_RESULT($cf_cv_regex)
4228 case $cf_cv_regex in
4229         regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
4230         regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
4231         regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
4232 esac
4233 ])dnl
4234 dnl ---------------------------------------------------------------------------
4235 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
4236 dnl ----------------
4237 dnl Remove all -U and -D options that refer to the given symbol from a list
4238 dnl of C compiler options.  This works around the problem that not all
4239 dnl compilers process -U and -D options from left-to-right, so a -U option
4240 dnl cannot be used to cancel the effect of a preceding -D option.
4241 dnl
4242 dnl $1 = target (which could be the same as the source variable)
4243 dnl $2 = source (including '$')
4244 dnl $3 = symbol to remove
4245 define([CF_REMOVE_DEFINE],
4246 [
4247 $1=`echo "$2" | \
4248         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
4249                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
4250 ])dnl
4251 dnl ---------------------------------------------------------------------------
4252 dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
4253 dnl -------------
4254 dnl Remove the given library from the symbol
4255 dnl
4256 dnl $1 = target (which could be the same as the source variable)
4257 dnl $2 = source (including '$')
4258 dnl $3 = library to remove
4259 define([CF_REMOVE_LIB],
4260 [
4261 # remove $3 library from $2
4262 $1=`echo "$2" | sed -e 's/-l$3[[        ]]//g' -e 's/-l$3[$]//'`
4263 ])dnl
4264 dnl ---------------------------------------------------------------------------
4265 dnl CF_RPATH_HACK version: 4 updated: 2008/09/13 12:53:26
4266 dnl -------------
4267 AC_DEFUN([CF_RPATH_HACK],
4268 [
4269 AC_REQUIRE([CF_SHARED_OPTS])
4270 AC_MSG_CHECKING(for updated LDFLAGS)
4271 if test -n "$LDFLAGS" ; then
4272 AC_MSG_RESULT(maybe)
4273 CF_VERBOSE(...checking LDFLAGS $LDFLAGS)
4274 CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4275 case "$EXTRA_LDFLAGS" in #(vi
4276 -Wl,-rpath,*) #(vi
4277         cf_rpath_hack="-Wl,-rpath,"
4278         ;;
4279 -R\ *)
4280         cf_rpath_hack="-R "
4281         ;;
4282 -R*)
4283         cf_rpath_hack="-R"
4284         ;;
4285 *)
4286         cf_rpath_hack=
4287         ;;
4288 esac
4289 if test -n "$cf_rpath_hack" ; then
4290         cf_rpath_dst=
4291         for cf_rpath_src in $LDFLAGS
4292         do
4293                 CF_VERBOSE(Filtering $cf_rpath_src)
4294                 case $cf_rpath_src in #(vi
4295                 -L*) #(vi
4296                         if test "$cf_rpath_hack" = "-R " ; then
4297                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e 's%-L%-R %'`
4298                         else
4299                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e s%-L%$cf_rpath_hack%`
4300                         fi
4301                         CF_VERBOSE(...Filter $cf_rpath_tmp)
4302                         EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
4303                         ;;
4304                 esac
4305                 cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
4306         done
4307         LDFLAGS=$cf_rpath_dst
4308         CF_VERBOSE(...checked LDFLAGS $LDFLAGS)
4309         CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4310 fi
4311 else
4312 AC_MSG_RESULT(no)
4313 fi
4314 ])dnl
4315 dnl ---------------------------------------------------------------------------
4316 dnl CF_SHARED_OPTS version: 58 updated: 2009/12/19 13:46:49
4317 dnl --------------
4318 dnl --------------
4319 dnl Attempt to determine the appropriate CC/LD options for creating a shared
4320 dnl library.
4321 dnl
4322 dnl Note: ${LOCAL_LDFLAGS} is used to link executables that will run within the
4323 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
4324 dnl We avoid compiling-in a ../lib path for the shared library since that can
4325 dnl lead to unexpected results at runtime.
4326 dnl ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared libraries
4327 dnl are compiled in ../../lib
4328 dnl
4329 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
4330 dnl to install symbolic links to the rel/abi versions of shared libraries.
4331 dnl
4332 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
4333 dnl version when making symbolic links.
4334 dnl
4335 dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
4336 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
4337 dnl (ex: libncurses.so.<ver>).
4338 dnl
4339 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
4340 AC_DEFUN([CF_SHARED_OPTS],
4341 [
4342         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
4343         LOCAL_LDFLAGS=
4344         LOCAL_LDFLAGS2=
4345         LD_RPATH_OPT=
4346         LD_SHARED_OPTS=
4347         INSTALL_LIB="-m 644"
4348
4349         cf_cv_do_symlinks=no
4350
4351         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
4352         AC_ARG_WITH(shlib-version,
4353         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
4354         [test -z "$withval" && withval=auto
4355         case $withval in #(vi
4356         yes) #(vi
4357                 cf_cv_shlib_version=auto
4358                 ;;
4359         rel|abi|auto|no) #(vi
4360                 cf_cv_shlib_version=$withval
4361                 ;;
4362         *)
4363                 AC_MSG_ERROR([option value must be one of: rel, abi, auto or no])
4364                 ;;
4365         esac
4366         ],[cf_cv_shlib_version=auto])
4367         AC_MSG_RESULT($cf_cv_shlib_version)
4368
4369         cf_cv_rm_so_locs=no
4370
4371         # Some less-capable ports of gcc support only -fpic
4372         CC_SHARED_OPTS=
4373         if test "$GCC" = yes
4374         then
4375                 AC_MSG_CHECKING(which $CC option to use)
4376                 cf_save_CFLAGS="$CFLAGS"
4377                 for CC_SHARED_OPTS in -fPIC -fpic ''
4378                 do
4379                         CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
4380                         AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
4381                 done
4382                 AC_MSG_RESULT($CC_SHARED_OPTS)
4383                 CFLAGS="$cf_save_CFLAGS"
4384         fi
4385
4386         cf_cv_shlib_version_infix=no
4387
4388         case $cf_cv_system_name in
4389         aix[[56]]*)
4390                 if test "$GCC" = yes; then
4391                         CC_SHARED_OPTS=
4392                         MK_SHARED_LIB="$(CC) -shared"
4393                 fi
4394                 ;;
4395         beos*)
4396                 MK_SHARED_LIB='${CC} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
4397                 ;;
4398         cygwin*)
4399                 CC_SHARED_OPTS=
4400                 MK_SHARED_LIB='sh ../mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
4401                 cf_cv_shlib_version=cygdll
4402                 cf_cv_shlib_version_infix=cygdll
4403                 cat >mk_shared_lib.sh <<-CF_EOF
4404                 #!/bin/sh
4405                 SHARED_LIB=\[$]1
4406                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4407                 shift
4408                 cat <<-EOF
4409                 Linking shared library
4410                 ** SHARED_LIB \[$]SHARED_LIB
4411                 ** IMPORT_LIB \[$]IMPORT_LIB
4412 EOF
4413                 exec \[$]* -shared -Wl,--out-implib=../lib/\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o ../lib/\[$]{SHARED_LIB}
4414 CF_EOF
4415                 chmod +x mk_shared_lib.sh
4416                 ;;
4417         darwin*)
4418                 EXTRA_CFLAGS="-no-cpp-precomp"
4419                 CC_SHARED_OPTS="-dynamic"
4420                 MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
4421                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
4422                 cf_cv_shlib_version_infix=yes
4423                 AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
4424                         cf_save_LDFLAGS=$LDFLAGS
4425                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4426                         AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
4427                                 LDFLAGS=$cf_save_LDFLAGS])
4428                 if test $cf_cv_ldflags_search_paths_first = yes; then
4429                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4430                 fi
4431                 ;;
4432         hpux*)
4433                 # (tested with gcc 2.7.2 -- I don't have c89)
4434                 if test "$GCC" = yes; then
4435                         LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
4436                 else
4437                         CC_SHARED_OPTS='+Z'
4438                         LD_SHARED_OPTS='-Wl,+b,${libdir}'
4439                 fi
4440                 MK_SHARED_LIB='${LD} +b ${libdir} -b -o $[@]'
4441                 # HP-UX shared libraries must be executable, and should be
4442                 # readonly to exploit a quirk in the memory manager.
4443                 INSTALL_LIB="-m 555"
4444                 ;;
4445         irix*)
4446                 if test "$cf_cv_ld_rpath" = yes ; then
4447                         if test "$GCC" = yes; then
4448                                 LD_RPATH_OPT="-Wl,-rpath,"
4449                                 EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
4450                         else
4451                                 LD_RPATH_OPT="-rpath "
4452                                 EXTRA_LDFLAGS="-rpath \${libdir} $EXTRA_LDFLAGS"
4453                         fi
4454                 fi
4455                 # tested with IRIX 5.2 and 'cc'.
4456                 if test "$GCC" != yes; then
4457                         CC_SHARED_OPTS='-KPIC'
4458                         MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
4459                 else
4460                         MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]'
4461                 fi
4462                 cf_cv_rm_so_locs=yes
4463                 ;;
4464         linux*|gnu*|k*bsd*-gnu)
4465                 if test "$DFT_LWR_MODEL" = "shared" ; then
4466                         LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
4467                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4468                 fi
4469                 if test "$cf_cv_ld_rpath" = yes ; then
4470                         LD_RPATH_OPT="-Wl,-rpath,"
4471                         EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
4472                 fi
4473                 CF_SHARED_SONAME
4474                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
4475                 ;;
4476         openbsd[[2-9]].*)
4477                 if test "$DFT_LWR_MODEL" = "shared" ; then
4478                         LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
4479                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4480                 fi
4481                 if test "$cf_cv_ld_rpath" = yes ; then
4482                         LD_RPATH_OPT="-Wl,-rpath,"
4483                         EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
4484                 fi
4485                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4486                 CF_SHARED_SONAME
4487                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
4488                 ;;
4489         nto-qnx*|openbsd*|freebsd[[12]].*)
4490                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4491                 MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
4492                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4493                 ;;
4494         freebsd*)
4495                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4496                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
4497                         LOCAL_LDFLAGS="-rpath \$(LOCAL_LIBDIR)"
4498                         LOCAL_LDFLAGS2="-rpath \${libdir} $LOCAL_LDFLAGS"
4499                         LD_RPATH_OPT="-rpath "
4500                         EXTRA_LDFLAGS="-rpath \${libdir} $EXTRA_LDFLAGS"
4501                 fi
4502                 CF_SHARED_SONAME
4503                 MK_SHARED_LIB='${LD} -shared -Bshareable -soname=`basename $[@]` -o $[@]'
4504                 ;;
4505         netbsd*)
4506                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4507                 test "$cf_cv_ld_rpath" = yes && LD_RPATH_OPT="-Wl,-rpath,"
4508                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
4509                         LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
4510                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4511                         EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
4512                         if test "$cf_cv_shlib_version" = auto; then
4513                         if test -f /usr/libexec/ld.elf_so; then
4514                                 cf_cv_shlib_version=abi
4515                         else
4516                                 cf_cv_shlib_version=rel
4517                         fi
4518                         fi
4519                         CF_SHARED_SONAME
4520                         MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
4521                 else
4522                         MK_SHARED_LIB='${LD} -shared -Bshareable -o $[@]'
4523                 fi
4524                 ;;
4525         osf*|mls+*)
4526                 # tested with OSF/1 V3.2 and 'cc'
4527                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
4528                 # link with shared libs).
4529                 MK_SHARED_LIB='${LD} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
4530                 case $host_os in
4531                 osf4*)
4532                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
4533                         ;;
4534                 esac
4535                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
4536                 if test "$DFT_LWR_MODEL" = "shared" ; then
4537                         LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
4538                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4539                 fi
4540                 if test "$cf_cv_ld_rpath" = yes ; then
4541                         LD_RPATH_OPT="-rpath"
4542                         # EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
4543                 fi
4544                 cf_cv_rm_so_locs=yes
4545                 ;;
4546         sco3.2v5*)  # (also uw2* and UW7) hops 13-Apr-98
4547                 # tested with osr5.0.5
4548                 if test "$GCC" != yes; then
4549                         CC_SHARED_OPTS='-belf -KPIC'
4550                 fi
4551                 MK_SHARED_LIB='${LD} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
4552                 if test "$cf_cv_ld_rpath" = yes ; then
4553                         # only way is to set LD_RUN_PATH but no switch for it
4554                         RUN_PATH=$libdir
4555                 fi
4556                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4557                 LINK_PROGS='LD_RUN_PATH=${libdir}'
4558                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
4559                 ;;
4560         sunos4*)
4561                 # tested with SunOS 4.1.1 and gcc 2.7.0
4562                 if test "$GCC" != yes; then
4563                         CC_SHARED_OPTS='-KPIC'
4564                 fi
4565                 MK_SHARED_LIB='${LD} -assert pure-text -o $[@]'
4566                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4567                 ;;
4568         solaris2*)
4569                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
4570                 # tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
4571                 if test "$DFT_LWR_MODEL" = "shared" ; then
4572                         LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
4573                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4574                 fi
4575                 if test "$cf_cv_ld_rpath" = yes ; then
4576                         LD_RPATH_OPT="-R"
4577                         EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
4578                 fi
4579                 CF_SHARED_SONAME
4580                 if test "$GCC" != yes; then
4581                         cf_save_CFLAGS="$CFLAGS"
4582                         for cf_shared_opts in -xcode=pic13 -xcode=pic32 -Kpic -KPIC -O
4583                         do
4584                                 CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
4585                                 AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\n");],[break])
4586                         done
4587                         CFLAGS="$cf_save_CFLAGS"
4588                         CC_SHARED_OPTS=$cf_shared_opts
4589                         MK_SHARED_LIB='${CC} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
4590                 else
4591                         MK_SHARED_LIB='${CC} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
4592                 fi
4593                 ;;
4594         sysv5uw7*|unix_sv*)
4595                 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
4596                 if test "$GCC" != yes; then
4597                         CC_SHARED_OPTS='-KPIC'
4598                 fi
4599                 MK_SHARED_LIB='${LD} -d y -G -o [$]@'
4600                 ;;
4601         *)
4602                 CC_SHARED_OPTS='unknown'
4603                 MK_SHARED_LIB='echo unknown'
4604                 ;;
4605         esac
4606
4607         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
4608         case "$cf_cv_shlib_version" in #(vi
4609         rel|abi)
4610                 case "$MK_SHARED_LIB" in #(vi
4611                 *'-o $[@]')
4612                         test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
4613                         ;;
4614                 *)
4615                         AC_MSG_WARN(ignored --with-shlib-version)
4616                         ;;
4617                 esac
4618                 ;;
4619         esac
4620
4621         if test -n "$LD_RPATH_OPT" ; then
4622                 AC_MSG_CHECKING(if we need a space after rpath option)
4623                 cf_save_LIBS="$LIBS"
4624                 LIBS="${LD_RPATH_OPT}$libdir $LIBS"
4625                 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
4626                 LIBS="$cf_save_LIBS"
4627                 AC_MSG_RESULT($cf_rpath_space)
4628                 test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
4629                 MK_SHARED_LIB="$MK_SHARED_LIB $LD_RPATH_OPT\${libdir}"
4630         fi
4631
4632         AC_SUBST(CC_SHARED_OPTS)
4633         AC_SUBST(LD_RPATH_OPT)
4634         AC_SUBST(LD_SHARED_OPTS)
4635         AC_SUBST(MK_SHARED_LIB)
4636         AC_SUBST(LINK_PROGS)
4637         AC_SUBST(LINK_TESTS)
4638         AC_SUBST(EXTRA_LDFLAGS)
4639         AC_SUBST(LOCAL_LDFLAGS)
4640         AC_SUBST(LOCAL_LDFLAGS2)
4641         AC_SUBST(INSTALL_LIB)
4642 ])dnl
4643 dnl ---------------------------------------------------------------------------
4644 dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
4645 dnl ----------------
4646 dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
4647 dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
4648 dnl option.
4649 dnl
4650 dnl $1 is the default that should be used for "$cf_cv_shlib_version".
4651 dnl If missing, use "rel".
4652 define([CF_SHARED_SONAME],
4653 [
4654         test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
4655         if test "$cf_cv_shlib_version" = rel; then
4656                 cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
4657         else
4658                 cf_cv_shared_soname='`basename $[@]`'
4659         fi
4660 ])
4661 dnl ---------------------------------------------------------------------------
4662 dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
4663 dnl -----------
4664 dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
4665 dnl programs need this test).
4666 dnl
4667 dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
4668 dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
4669 dnl winsize declaration is left alone - we may revisit this if Apple choose to
4670 dnl break that part of the interface as well.
4671 AC_DEFUN([CF_SIGWINCH],
4672 [
4673 AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
4674         AC_TRY_COMPILE([
4675 #include <sys/types.h>
4676 #include <sys/signal.h>
4677 ],[int x = SIGWINCH],
4678         [cf_cv_define_sigwinch=yes],
4679         [AC_TRY_COMPILE([
4680 #undef _XOPEN_SOURCE
4681 #undef _POSIX_SOURCE
4682 #undef _POSIX_C_SOURCE
4683 #include <sys/types.h>
4684 #include <sys/signal.h>
4685 ],[int x = SIGWINCH],
4686         [cf_cv_define_sigwinch=maybe],
4687         [cf_cv_define_sigwinch=no])
4688 ])
4689 ])
4690
4691 if test "$cf_cv_define_sigwinch" = maybe ; then
4692 AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
4693 cf_cv_fixup_sigwinch=unknown
4694 cf_sigwinch=32
4695 while test $cf_sigwinch != 1
4696 do
4697         AC_TRY_COMPILE([
4698 #undef _XOPEN_SOURCE
4699 #undef _POSIX_SOURCE
4700 #undef _POSIX_C_SOURCE
4701 #include <sys/types.h>
4702 #include <sys/signal.h>
4703 ],[
4704 #if SIGWINCH != $cf_sigwinch
4705 make an error
4706 #endif
4707 int x = SIGWINCH],
4708         [cf_cv_fixup_sigwinch=$cf_sigwinch
4709          break])
4710
4711 cf_sigwinch=`expr $cf_sigwinch - 1`
4712 done
4713 ])
4714
4715         if test "$cf_cv_fixup_sigwinch" != unknown ; then
4716                 CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
4717         fi
4718 fi
4719 ])dnl
4720 dnl ---------------------------------------------------------------------------
4721 dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
4722 dnl ---------------
4723 dnl signal handler, but there are some gcc depedencies in that recommendation.
4724 dnl Try anyway.
4725 AC_DEFUN([CF_SIG_ATOMIC_T],
4726 [
4727 AC_MSG_CHECKING(for signal global datatype)
4728 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
4729         for cf_type in \
4730                 "volatile sig_atomic_t" \
4731                 "sig_atomic_t" \
4732                 "int"
4733         do
4734         AC_TRY_COMPILE([
4735 #include <sys/types.h>
4736 #include <signal.h>
4737 #include <stdio.h>
4738
4739 extern $cf_type x;
4740 $cf_type x;
4741 static void handler(int sig)
4742 {
4743         x = 5;
4744 }],
4745                 [signal(SIGINT, handler);
4746                  x = 1],
4747                 [cf_cv_sig_atomic_t=$cf_type],
4748                 [cf_cv_sig_atomic_t=no])
4749                 test "$cf_cv_sig_atomic_t" != no && break
4750         done
4751         ])
4752 AC_MSG_RESULT($cf_cv_sig_atomic_t)
4753 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
4754 ])dnl
4755 dnl ---------------------------------------------------------------------------
4756 dnl CF_SIZECHANGE version: 8 updated: 2000/11/04 12:22:16
4757 dnl -------------
4758 dnl Check for definitions & structures needed for window size-changing
4759 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
4760 AC_DEFUN([CF_SIZECHANGE],
4761 [
4762 AC_REQUIRE([CF_STRUCT_TERMIOS])
4763 AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
4764     cf_cv_sizechange=unknown
4765     cf_save_CPPFLAGS="$CPPFLAGS"
4766
4767 for cf_opts in "" "NEED_PTEM_H"
4768 do
4769
4770     CPPFLAGS="$cf_save_CPPFLAGS"
4771     test -n "$cf_opts" && CPPFLAGS="$CPPFLAGS -D$cf_opts"
4772     AC_TRY_COMPILE([#include <sys/types.h>
4773 #ifdef HAVE_TERMIOS_H
4774 #include <termios.h>
4775 #else
4776 #ifdef HAVE_TERMIO_H
4777 #include <termio.h>
4778 #endif
4779 #endif
4780 #ifdef NEED_PTEM_H
4781 /* This is a workaround for SCO:  they neglected to define struct winsize in
4782  * termios.h -- it's only in termio.h and ptem.h
4783  */
4784 #include        <sys/stream.h>
4785 #include        <sys/ptem.h>
4786 #endif
4787 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
4788 #include <sys/ioctl.h>
4789 #endif
4790 ],[
4791 #ifdef TIOCGSIZE
4792         struct ttysize win;     /* FIXME: what system is this? */
4793         int y = win.ts_lines;
4794         int x = win.ts_cols;
4795 #else
4796 #ifdef TIOCGWINSZ
4797         struct winsize win;
4798         int y = win.ws_row;
4799         int x = win.ws_col;
4800 #else
4801         no TIOCGSIZE or TIOCGWINSZ
4802 #endif /* TIOCGWINSZ */
4803 #endif /* TIOCGSIZE */
4804         ],
4805         [cf_cv_sizechange=yes],
4806         [cf_cv_sizechange=no])
4807
4808         CPPFLAGS="$cf_save_CPPFLAGS"
4809         if test "$cf_cv_sizechange" = yes ; then
4810                 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
4811                 test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
4812                 break
4813         fi
4814 done
4815 ])
4816 if test "$cf_cv_sizechange" != no ; then
4817         AC_DEFINE(HAVE_SIZECHANGE)
4818         case $cf_cv_sizechange in #(vi
4819         NEED*)
4820                 AC_DEFINE_UNQUOTED($cf_cv_sizechange )
4821                 ;;
4822         esac
4823 fi
4824 ])dnl
4825 dnl ---------------------------------------------------------------------------
4826 dnl CF_SRC_MODULES version: 20 updated: 2008/12/27 12:30:03
4827 dnl --------------
4828 dnl For each parameter, test if the source-directory exists, and if it contains
4829 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
4830 dnl use in CF_LIB_RULES.
4831 dnl
4832 dnl This uses the configured value to make the lists SRC_SUBDIRS and
4833 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
4834 AC_DEFUN([CF_SRC_MODULES],
4835 [
4836 AC_MSG_CHECKING(for src modules)
4837
4838 # dependencies and linker-arguments for test-programs
4839 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
4840 TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEP2"
4841 if test "$DFT_LWR_MODEL" = "libtool"; then
4842         TEST_ARGS="${TEST_DEPS}"
4843         TEST_ARG2="${TEST_DEP2}"
4844 else
4845         TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
4846         TEST_ARG2="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARG2"
4847 fi
4848
4849 cf_cv_src_modules=
4850 for cf_dir in $1
4851 do
4852         if test -f $srcdir/$cf_dir/modules; then
4853
4854                 # We may/may not have tack in the distribution, though the
4855                 # makefile is.
4856                 if test $cf_dir = tack ; then
4857                         if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
4858                                 continue
4859                         fi
4860                 fi
4861
4862                 if test -z "$cf_cv_src_modules"; then
4863                         cf_cv_src_modules=$cf_dir
4864                 else
4865                         cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
4866                 fi
4867
4868                 # Make the ncurses_cfg.h file record the library interface files as
4869                 # well.  These are header files that are the same name as their
4870                 # directory.  Ncurses is the only library that does not follow
4871                 # that pattern.
4872                 if test $cf_dir = tack ; then
4873                         continue
4874                 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
4875                         CF_UPPER(cf_have_include,$cf_dir)
4876                         AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
4877                         AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
4878                         TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
4879                         TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEP2"
4880                         if test "$DFT_LWR_MODEL" = "libtool"; then
4881                                 TEST_ARGS="${TEST_DEPS}"
4882                                 TEST_ARG2="${TEST_DEP2}"
4883                         else
4884                                 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
4885                                 TEST_ARG2="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARG2"
4886                         fi
4887                 fi
4888         fi
4889 done
4890 AC_MSG_RESULT($cf_cv_src_modules)
4891
4892 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
4893 TEST_ARG2="-L${LIB_2ND} $TEST_ARG2"
4894
4895 AC_SUBST(TEST_ARGS)
4896 AC_SUBST(TEST_DEPS)
4897
4898 AC_SUBST(TEST_ARG2)
4899 AC_SUBST(TEST_DEP2)
4900
4901 SRC_SUBDIRS=
4902 if test "x$cf_with_manpages" != xno ; then
4903         SRC_SUBDIRS="$SRC_SUBDIRS man"
4904 fi
4905 SRC_SUBDIRS="$SRC_SUBDIRS include"
4906 for cf_dir in $cf_cv_src_modules
4907 do
4908         SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
4909 done
4910 SRC_SUBDIRS="$SRC_SUBDIRS test"
4911 test -z "$MAKE_TERMINFO" && SRC_SUBDIRS="$SRC_SUBDIRS misc"
4912 test "$cf_with_cxx_binding" != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
4913
4914 ADA_SUBDIRS=
4915 if test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then
4916         SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
4917         ADA_SUBDIRS="gen src samples"
4918 fi
4919
4920 SUB_MAKEFILES=
4921 for cf_dir in $SRC_SUBDIRS
4922 do
4923         SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
4924 done
4925
4926 if test -n "$ADA_SUBDIRS"; then
4927         for cf_dir in $ADA_SUBDIRS
4928         do
4929                 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
4930         done
4931         AC_SUBST(ADA_SUBDIRS)
4932 fi
4933 ])dnl
4934 dnl ---------------------------------------------------------------------------
4935 dnl CF_STDCPP_LIBRARY version: 6 updated: 2009/12/19 13:46:49
4936 dnl -----------------
4937 dnl Check for -lstdc++, which is GNU's standard C++ library.
4938 AC_DEFUN([CF_STDCPP_LIBRARY],
4939 [
4940 if test -n "$GXX" ; then
4941 case $cf_cv_system_name in #(vi
4942 os2*) #(vi
4943         cf_stdcpp_libname=stdcpp
4944         ;;
4945 *)
4946         cf_stdcpp_libname=stdc++
4947         ;;
4948 esac
4949 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
4950         cf_save="$LIBS"
4951         LIBS="-l$cf_stdcpp_libname $LIBS"
4952 AC_TRY_LINK([
4953 #include <strstream.h>],[
4954 char buf[80];
4955 strstreambuf foo(buf, sizeof(buf))
4956 ],
4957         [cf_cv_libstdcpp=yes],
4958         [cf_cv_libstdcpp=no])
4959         LIBS="$cf_save"
4960 ])
4961 test "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
4962 fi
4963 ])dnl
4964 dnl ---------------------------------------------------------------------------
4965 dnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
4966 dnl --------------
4967 dnl     Remove "-g" option from the compiler options
4968 AC_DEFUN([CF_STRIP_G_OPT],
4969 [$1=`echo ${$1} | sed -e 's%-g %%' -e 's%-g$%%'`])dnl
4970 dnl ---------------------------------------------------------------------------
4971 dnl CF_STRUCT_SIGACTION version: 3 updated: 2000/08/12 23:18:52
4972 dnl -------------------
4973 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
4974 dnl do this if we've found the sigaction function.
4975 dnl
4976 dnl If needed, define SVR4_ACTION.
4977 AC_DEFUN([CF_STRUCT_SIGACTION],[
4978 if test "$ac_cv_func_sigaction" = yes; then
4979 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
4980 AC_TRY_COMPILE([
4981 #include <sys/types.h>
4982 #include <signal.h>],
4983         [struct sigaction act],
4984         [sigact_bad=no],
4985         [
4986 AC_TRY_COMPILE([
4987 #define _POSIX_SOURCE
4988 #include <sys/types.h>
4989 #include <signal.h>],
4990         [struct sigaction act],
4991         [sigact_bad=yes
4992          AC_DEFINE(SVR4_ACTION)],
4993          [sigact_bad=unknown])])
4994 AC_MSG_RESULT($sigact_bad)
4995 fi
4996 ])dnl
4997 dnl ---------------------------------------------------------------------------
4998 dnl CF_STRUCT_TERMIOS version: 5 updated: 2000/11/04 12:22:46
4999 dnl -----------------
5000 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
5001 dnl If so, define SVR4_TERMIO
5002 AC_DEFUN([CF_STRUCT_TERMIOS],[
5003 AC_CHECK_HEADERS( \
5004 termio.h \
5005 termios.h \
5006 unistd.h \
5007 )
5008 if test "$ISC" = yes ; then
5009         AC_CHECK_HEADERS( sys/termio.h )
5010 fi
5011 if test "$ac_cv_header_termios_h" = yes ; then
5012         case "$CFLAGS $CPPFLAGS" in
5013         *-D_POSIX_SOURCE*)
5014                 termios_bad=dunno ;;
5015         *)      termios_bad=maybe ;;
5016         esac
5017         if test "$termios_bad" = maybe ; then
5018         AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
5019         AC_TRY_COMPILE([#include <termios.h>],
5020                 [struct termios foo; int x = foo.c_iflag],
5021                 termios_bad=no, [
5022                 AC_TRY_COMPILE([
5023 #define _POSIX_SOURCE
5024 #include <termios.h>],
5025                         [struct termios foo; int x = foo.c_iflag],
5026                         termios_bad=unknown,
5027                         termios_bad=yes AC_DEFINE(SVR4_TERMIO))
5028                         ])
5029         AC_MSG_RESULT($termios_bad)
5030         fi
5031 fi
5032 ])dnl
5033 dnl ---------------------------------------------------------------------------
5034 dnl CF_SUBDIR_PATH version: 5 updated: 2007/07/29 09:55:12
5035 dnl --------------
5036 dnl Construct a search-list for a nonstandard header/lib-file
5037 dnl     $1 = the variable to return as result
5038 dnl     $2 = the package name
5039 dnl     $3 = the subdirectory, e.g., bin, include or lib
5040 AC_DEFUN([CF_SUBDIR_PATH],
5041 [$1=""
5042
5043 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
5044 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
5045 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
5046 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
5047 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
5048 ])dnl
5049 dnl ---------------------------------------------------------------------------
5050 dnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
5051 dnl --------
5052 dnl     Shorthand macro for substituting things that the user may override
5053 dnl     with an environment variable.
5054 dnl
5055 dnl     $1 = long/descriptive name
5056 dnl     $2 = environment variable
5057 dnl     $3 = default value
5058 AC_DEFUN([CF_SUBST],
5059 [AC_CACHE_VAL(cf_cv_subst_$2,[
5060 AC_MSG_CHECKING(for $1 (symbol $2))
5061 CF_SUBST_IF([-z "[$]$2"], [$2], [$3])
5062 cf_cv_subst_$2=[$]$2
5063 AC_MSG_RESULT([$]$2)
5064 ])
5065 ])dnl
5066 dnl ---------------------------------------------------------------------------
5067 dnl CF_SUBST_IF version: 2 updated: 2006/06/17 12:33:03
5068 dnl -----------
5069 dnl     Shorthand macro for substituting things that the user may override
5070 dnl     with an environment variable.
5071 dnl
5072 dnl     $1 = condition to pass to "test"
5073 dnl     $2 = environment variable
5074 dnl     $3 = value if the test succeeds
5075 dnl     $4 = value if the test fails
5076 AC_DEFUN([CF_SUBST_IF],
5077 [
5078 if test $1 ; then
5079         $2=$3
5080 ifelse($4,,,[else
5081         $2=$4])
5082 fi
5083 AC_SUBST($2)
5084 ])dnl
5085 dnl ---------------------------------------------------------------------------
5086 dnl CF_SUBST_NCURSES_VERSION version: 8 updated: 2006/09/16 11:40:59
5087 dnl ------------------------
5088 dnl Get the version-number for use in shared-library naming, etc.
5089 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
5090 [
5091 AC_REQUIRE([CF_PROG_EGREP])
5092 NCURSES_MAJOR="`$ac_cv_prog_egrep '^NCURSES_MAJOR[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
5093 NCURSES_MINOR="`$ac_cv_prog_egrep '^NCURSES_MINOR[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
5094 NCURSES_PATCH="`$ac_cv_prog_egrep '^NCURSES_PATCH[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
5095 cf_cv_abi_version=${NCURSES_MAJOR}
5096 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
5097 dnl Show the computed version, for logging
5098 cf_cv_timestamp=`date`
5099 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
5100 dnl We need these values in the generated headers
5101 AC_SUBST(NCURSES_MAJOR)
5102 AC_SUBST(NCURSES_MINOR)
5103 AC_SUBST(NCURSES_PATCH)
5104 dnl We need these values in the generated makefiles
5105 AC_SUBST(cf_cv_rel_version)
5106 AC_SUBST(cf_cv_abi_version)
5107 AC_SUBST(cf_cv_builtin_bool)
5108 AC_SUBST(cf_cv_header_stdbool_h)
5109 AC_SUBST(cf_cv_type_of_bool)dnl
5110 ])dnl
5111 dnl ---------------------------------------------------------------------------
5112 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
5113 dnl ------------------
5114 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
5115 dnl older SCO configurations.
5116 AC_DEFUN([CF_SYS_TIME_SELECT],
5117 [
5118 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
5119 AC_CACHE_VAL(cf_cv_sys_time_select,[
5120 AC_TRY_COMPILE([
5121 #include <sys/types.h>
5122 #ifdef HAVE_SYS_TIME_H
5123 #include <sys/time.h>
5124 #endif
5125 #ifdef HAVE_SYS_SELECT_H
5126 #include <sys/select.h>
5127 #endif
5128 ],[],[cf_cv_sys_time_select=yes],
5129      [cf_cv_sys_time_select=no])
5130      ])
5131 AC_MSG_RESULT($cf_cv_sys_time_select)
5132 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
5133 ])dnl
5134 dnl ---------------------------------------------------------------------------
5135 dnl CF_TOP_BUILDDIR version: 1 updated: 2006/10/15 16:33:23
5136 dnl ---------------
5137 dnl Define a top_builddir symbol, for applications that need an absolute path.
5138 AC_DEFUN([CF_TOP_BUILDDIR],
5139 [
5140 top_builddir=`pwd`
5141 AC_SUBST(top_builddir)
5142 ])dnl
5143 dnl ---------------------------------------------------------------------------
5144 dnl CF_TYPEOF_CHTYPE version: 8 updated: 2006/12/16 12:33:30
5145 dnl ----------------
5146 dnl Determine the type we should use for chtype (and attr_t, which is treated
5147 dnl as the same thing).  We want around 32 bits, so on most machines want a
5148 dnl long, but on newer 64-bit machines, probably want an int.  If we're using
5149 dnl wide characters, we have to have a type compatible with that, as well.
5150 AC_DEFUN([CF_TYPEOF_CHTYPE],
5151 [
5152 AC_MSG_CHECKING([for type of chtype])
5153 AC_CACHE_VAL(cf_cv_typeof_chtype,[
5154                 AC_TRY_RUN([
5155 #define WANT_BITS 31
5156 #include <stdio.h>
5157 int main()
5158 {
5159         FILE *fp = fopen("cf_test.out", "w");
5160         if (fp != 0) {
5161                 char *result = "long";
5162                 if (sizeof(unsigned long) > sizeof(unsigned int)) {
5163                         int n;
5164                         unsigned int x, y;
5165                         for (n = 0; n < WANT_BITS; n++) {
5166                                 x = (1 << n);
5167                                 y = (x >> n);
5168                                 if (y != 1 || x == 0) {
5169                                         x = 0;
5170                                         break;
5171                                 }
5172                         }
5173                         /*
5174                          * If x is nonzero, an int is big enough for the bits
5175                          * that we want.
5176                          */
5177                         result = (x != 0) ? "int" : "long";
5178                 }
5179                 fputs(result, fp);
5180                 fclose(fp);
5181         }
5182         ${cf_cv_main_return:-return}(0);
5183 }
5184                 ],
5185                 [cf_cv_typeof_chtype=`cat cf_test.out`],
5186                 [cf_cv_typeof_chtype=long],
5187                 [cf_cv_typeof_chtype=long])
5188                 rm -f cf_test.out
5189         ])
5190 AC_MSG_RESULT($cf_cv_typeof_chtype)
5191
5192 AC_SUBST(cf_cv_typeof_chtype)
5193 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
5194 ])dnl
5195 dnl ---------------------------------------------------------------------------
5196 dnl CF_TYPE_SIGACTION version: 3 updated: 2000/08/12 23:18:52
5197 dnl -----------------
5198 dnl
5199 AC_DEFUN([CF_TYPE_SIGACTION],
5200 [
5201 AC_MSG_CHECKING([for type sigaction_t])
5202 AC_CACHE_VAL(cf_cv_type_sigaction,[
5203         AC_TRY_COMPILE([
5204 #include <signal.h>],
5205                 [sigaction_t x],
5206                 [cf_cv_type_sigaction=yes],
5207                 [cf_cv_type_sigaction=no])])
5208 AC_MSG_RESULT($cf_cv_type_sigaction)
5209 test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
5210 ])dnl
5211 dnl ---------------------------------------------------------------------------
5212 dnl CF_UNSIGNED_LITERALS version: 2 updated: 1998/02/07 22:10:16
5213 dnl --------------------
5214 dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
5215 dnl won't, but they're still there.
5216 AC_DEFUN([CF_UNSIGNED_LITERALS],
5217 [
5218 AC_MSG_CHECKING([if unsigned literals are legal])
5219 AC_CACHE_VAL(cf_cv_unsigned_literals,[
5220         AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
5221                 [cf_cv_unsigned_literals=yes],
5222                 [cf_cv_unsigned_literals=no])
5223         ])
5224 AC_MSG_RESULT($cf_cv_unsigned_literals)
5225 ])dnl
5226 dnl ---------------------------------------------------------------------------
5227 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
5228 dnl --------
5229 dnl Make an uppercase version of a variable
5230 dnl $1=uppercase($2)
5231 AC_DEFUN([CF_UPPER],
5232 [
5233 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
5234 ])dnl
5235 dnl ---------------------------------------------------------------------------
5236 dnl CF_UTF8_LIB version: 5 updated: 2008/10/17 19:37:52
5237 dnl -----------
5238 dnl Check for multibyte support, and if not found, utf8 compatibility library
5239 AC_DEFUN([CF_UTF8_LIB],
5240 [
5241 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
5242         cf_save_LIBS="$LIBS"
5243         AC_TRY_LINK([
5244 #include <stdlib.h>],[putwc(0,0);],
5245         [cf_cv_utf8_lib=yes],
5246         [CF_FIND_LINKAGE([
5247 #include <libutf8.h>],[putwc(0,0);],utf8,
5248                 [cf_cv_utf8_lib=add-on],
5249                 [cf_cv_utf8_lib=no])
5250 ])])
5251
5252 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
5253 # ncurses/ncursesw:
5254 if test "$cf_cv_utf8_lib" = "add-on" ; then
5255         AC_DEFINE(HAVE_LIBUTF8_H)
5256         CF_ADD_INCDIR($cf_cv_header_path_utf8)
5257         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
5258         LIBS="-lutf8 $LIBS"
5259 fi
5260 ])dnl
5261 dnl ---------------------------------------------------------------------------
5262 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
5263 dnl ----------
5264 dnl Use AC_VERBOSE w/o the warnings
5265 AC_DEFUN([CF_VERBOSE],
5266 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
5267 CF_MSG_LOG([$1])
5268 ])dnl
5269 dnl ---------------------------------------------------------------------------
5270 dnl CF_WCHAR_TYPE version: 2 updated: 2004/01/17 19:18:20
5271 dnl -------------
5272 dnl Check if type wide-character type $1 is declared, and if so, which header
5273 dnl file is needed.  The second parameter is used to set a shell variable when
5274 dnl the type is not found.  The first parameter sets a shell variable for the
5275 dnl opposite sense.
5276 AC_DEFUN([CF_WCHAR_TYPE],
5277 [
5278 # This is needed on Tru64 5.0 to declare $1
5279 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
5280 AC_TRY_COMPILE([
5281 #include <stdlib.h>
5282 #include <stdarg.h>
5283 #include <stdio.h>
5284 #ifdef HAVE_LIBUTF8_H
5285 #include <libutf8.h>
5286 #endif],
5287         [$1 state],
5288         [cf_cv_$1=no],
5289         [AC_TRY_COMPILE([
5290 #include <stdlib.h>
5291 #include <stdarg.h>
5292 #include <stdio.h>
5293 #include <wchar.h>
5294 #ifdef HAVE_LIBUTF8_H
5295 #include <libutf8.h>
5296 #endif],
5297         [$1 value],
5298         [cf_cv_$1=yes],
5299         [cf_cv_$1=unknown])])])
5300
5301 if test "$cf_cv_$1" = yes ; then
5302         AC_DEFINE(NEED_WCHAR_H)
5303         NEED_WCHAR_H=1
5304 fi
5305
5306 ifelse($2,,,[
5307 # if we do not find $1 in either place, use substitution to provide a fallback.
5308 if test "$cf_cv_$1" = unknown ; then
5309         $2=1
5310 fi
5311 ])
5312 ifelse($3,,,[
5313 # if we find $1 in either place, use substitution to provide a fallback.
5314 if test "$cf_cv_$1" != unknown ; then
5315         $3=1
5316 fi
5317 ])
5318 ])dnl
5319 dnl ---------------------------------------------------------------------------
5320 dnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06
5321 dnl ---------------
5322 dnl Check for compiler-support for weak symbols.
5323 dnl This works with "recent" gcc.
5324 AC_DEFUN([CF_WEAK_SYMBOLS],[
5325 AC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[
5326
5327 AC_TRY_COMPILE([
5328 #include <stdio.h>],
5329 [
5330 #if defined(__GNUC__)
5331 #  if defined __USE_ISOC99
5332 #    define _cat_pragma(exp)    _Pragma(#exp)
5333 #    define _weak_pragma(exp)   _cat_pragma(weak name)
5334 #  else
5335 #    define _weak_pragma(exp)
5336 #  endif
5337 #  define _declare(name)        __extension__ extern __typeof__(name) name
5338 #  define weak_symbol(name)     _weak_pragma(name) _declare(name) __attribute__((weak))
5339 #endif
5340
5341 weak_symbol(fopen);
5342 ],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
5343 ])
5344 ])dnl
5345 dnl ---------------------------------------------------------------------------
5346 dnl CF_WITH_ABI_VERSION version: 1 updated: 2003/09/20 18:12:49
5347 dnl -------------------
5348 dnl Allow library's ABI to be overridden.  Generally this happens when a
5349 dnl packager has incremented the ABI past that used in the original package,
5350 dnl and wishes to keep doing this.
5351 dnl
5352 dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
5353 dnl symbol.
5354 AC_DEFUN([CF_WITH_ABI_VERSION],[
5355 test -z "$cf_cv_abi_version" && cf_cv_abi_version=0
5356 AC_ARG_WITH(abi-version,
5357 [  --with-abi-version=XXX  override derived ABI version],
5358 [AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
5359  cf_cv_abi_version=$withval])
5360  CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
5361 ifelse($1,,,[
5362 $1_ABI=$cf_cv_abi_version
5363 ])
5364 ])dnl
5365 dnl ---------------------------------------------------------------------------
5366 dnl CF_WITH_DBMALLOC version: 6 updated: 2006/12/16 14:24:05
5367 dnl ----------------
5368 dnl Configure-option for dbmalloc.  The optional parameter is used to override
5369 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
5370 AC_DEFUN([CF_WITH_DBMALLOC],[
5371 CF_NO_LEAKS_OPTION(dbmalloc,
5372         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
5373         [USE_DBMALLOC])
5374
5375 if test "$with_dbmalloc" = yes ; then
5376         AC_CHECK_HEADER(dbmalloc.h,
5377                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))])
5378 fi
5379 ])dnl
5380 dnl ---------------------------------------------------------------------------
5381 dnl CF_WITH_DMALLOC version: 6 updated: 2006/12/16 14:24:05
5382 dnl ---------------
5383 dnl Configure-option for dmalloc.  The optional parameter is used to override
5384 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
5385 AC_DEFUN([CF_WITH_DMALLOC],[
5386 CF_NO_LEAKS_OPTION(dmalloc,
5387         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
5388         [USE_DMALLOC])
5389
5390 if test "$with_dmalloc" = yes ; then
5391         AC_CHECK_HEADER(dmalloc.h,
5392                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))])
5393 fi
5394 ])dnl
5395 dnl ---------------------------------------------------------------------------
5396 dnl CF_WITH_GPM version: 7 updated: 2008/03/23 14:48:54
5397 dnl -----------
5398 dnl
5399 dnl The option parameter (if neither yes/no) is assumed to be the name of
5400 dnl the gpm library, e.g., for dynamic loading.
5401 AC_DEFUN([CF_WITH_GPM],
5402 [
5403 AC_MSG_CHECKING(if you want to link with the GPM mouse library)
5404 AC_ARG_WITH(gpm,
5405         [  --with-gpm              use Alessandro Rubini's GPM library],
5406         [with_gpm=$withval],
5407         [with_gpm=maybe])
5408 AC_MSG_RESULT($with_gpm)
5409
5410 if test "$with_gpm" != no ; then
5411         AC_CHECK_HEADER(gpm.h,[
5412                 AC_DEFINE(HAVE_GPM_H)
5413                 if test "$with_gpm" != yes && test "$with_gpm" != maybe ; then
5414                         CF_VERBOSE(assuming we really have GPM library)
5415                         AC_DEFINE(HAVE_LIBGPM)
5416                 else
5417                         AC_CHECK_LIB(gpm,Gpm_Open,[:],[
5418                                 AC_MSG_ERROR(Cannot link with GPM library)
5419                 fi
5420                 with_gpm=yes
5421                 ])
5422         ],[
5423                 test "$with_gpm" != maybe && AC_MSG_WARN(Cannot find GPM header)
5424                 with_gpm=no
5425         ])
5426 fi
5427 ])
5428 dnl ---------------------------------------------------------------------------
5429 dnl CF_WITH_LIBTOOL version: 23 updated: 2009/03/28 14:26:27
5430 dnl ---------------
5431 dnl Provide a configure option to incorporate libtool.  Define several useful
5432 dnl symbols for the makefile rules.
5433 dnl
5434 dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
5435 dnl macros from libtool.m4 which is in the aclocal directory of automake.
5436 dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
5437 dnl But that still does not work properly since the macro is expanded outside
5438 dnl the CF_WITH_LIBTOOL macro:
5439 dnl
5440 dnl     #!/bin/sh
5441 dnl     ACLOCAL=`aclocal --print-ac-dir`
5442 dnl     if test -z "$ACLOCAL" ; then
5443 dnl             echo cannot find aclocal directory
5444 dnl             exit 1
5445 dnl     elif test ! -f $ACLOCAL/libtool.m4 ; then
5446 dnl             echo cannot find libtool.m4 file
5447 dnl             exit 1
5448 dnl     fi
5449 dnl
5450 dnl     LOCAL=aclocal.m4
5451 dnl     ORIG=aclocal.m4.orig
5452 dnl
5453 dnl     trap "mv $ORIG $LOCAL" 0 1 2 5 15
5454 dnl     rm -f $ORIG
5455 dnl     mv $LOCAL $ORIG
5456 dnl
5457 dnl     # sed the LIBTOOL= assignment to omit the current directory?
5458 dnl     sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
5459 dnl     cat $ORIG >>$LOCAL
5460 dnl
5461 dnl     autoconf-257 $*
5462 dnl
5463 AC_DEFUN([CF_WITH_LIBTOOL],
5464 [
5465 ifdef([AC_PROG_LIBTOOL],,[
5466 LIBTOOL=
5467 ])
5468 # common library maintenance symbols that are convenient for libtool scripts:
5469 LIB_CREATE='${AR} -cr'
5470 LIB_OBJECT='${OBJECTS}'
5471 LIB_SUFFIX=.a
5472 LIB_PREP="$RANLIB"
5473
5474 # symbols used to prop libtool up to enable it to determine what it should be
5475 # doing:
5476 LIB_CLEAN=
5477 LIB_COMPILE=
5478 LIB_LINK='${CC}'
5479 LIB_INSTALL=
5480 LIB_UNINSTALL=
5481
5482 AC_MSG_CHECKING(if you want to build libraries with libtool)
5483 AC_ARG_WITH(libtool,
5484         [  --with-libtool          generate libraries with libtool],
5485         [with_libtool=$withval],
5486         [with_libtool=no])
5487 AC_MSG_RESULT($with_libtool)
5488 if test "$with_libtool" != "no"; then
5489 ifdef([AC_PROG_LIBTOOL],[
5490         # missing_content_AC_PROG_LIBTOOL{{
5491         AC_PROG_LIBTOOL
5492         # missing_content_AC_PROG_LIBTOOL}}
5493 ],[
5494         if test "$with_libtool" != "yes" ; then
5495                 CF_PATH_SYNTAX(with_libtool)
5496                 LIBTOOL=$with_libtool
5497         else
5498                 AC_PATH_PROG(LIBTOOL,libtool)
5499         fi
5500         if test -z "$LIBTOOL" ; then
5501                 AC_MSG_ERROR(Cannot find libtool)
5502         fi
5503 ])dnl
5504         LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${DESTDIR}${libdir} -version-info `cut -f1 ${srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} -o'
5505         LIB_OBJECT='${OBJECTS:.o=.lo}'
5506         LIB_SUFFIX=.la
5507         LIB_CLEAN='${LIBTOOL} --mode=clean'
5508         LIB_COMPILE='${LIBTOOL} --mode=compile'
5509         LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
5510         LIB_INSTALL='${LIBTOOL} --mode=install'
5511         LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
5512         LIB_PREP=:
5513
5514         # Show the version of libtool
5515         AC_MSG_CHECKING(version of libtool)
5516
5517         # Save the version in a cache variable - this is not entirely a good
5518         # thing, but the version string from libtool is very ugly, and for
5519         # bug reports it might be useful to have the original string. "("
5520         cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' |sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
5521         AC_MSG_RESULT($cf_cv_libtool_version)
5522         if test -z "$cf_cv_libtool_version" ; then
5523                 AC_MSG_ERROR(This is not GNU libtool)
5524         fi
5525
5526         # special hack to add -no-undefined (which libtool should do for itself)
5527         LT_UNDEF=
5528         case "$cf_cv_system_name" in #(vi
5529         cygwin*|mingw32*|uwin*|aix[[456]]) #(vi
5530                 LT_UNDEF=-no-undefined
5531                 ;;
5532         esac
5533         AC_SUBST([LT_UNDEF])
5534
5535         # special hack to add --tag option for C++ compiler
5536         case $cf_cv_libtool_version in #(vi
5537         1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*) #(vi
5538                 LIBTOOL_CXX="$LIBTOOL --tag=CXX"
5539                 LIBTOOL="$LIBTOOL --tag=CC"
5540                 ;;
5541         *)
5542                 LIBTOOL_CXX="$LIBTOOL"
5543                 ;;
5544         esac
5545 else
5546         LIBTOOL=""
5547         LIBTOOL_CXX=""
5548 fi
5549
5550 test -z "$LIBTOOL" && ECHO_LT=
5551
5552 AC_SUBST(LIBTOOL)
5553 AC_SUBST(LIBTOOL_CXX)
5554 AC_SUBST(LIBTOOL_OPTS)
5555
5556 AC_SUBST(LIB_CREATE)
5557 AC_SUBST(LIB_OBJECT)
5558 AC_SUBST(LIB_SUFFIX)
5559 AC_SUBST(LIB_PREP)
5560
5561 AC_SUBST(LIB_CLEAN)
5562 AC_SUBST(LIB_COMPILE)
5563 AC_SUBST(LIB_LINK)
5564 AC_SUBST(LIB_INSTALL)
5565 AC_SUBST(LIB_UNINSTALL)
5566
5567 ])dnl
5568 dnl ---------------------------------------------------------------------------
5569 dnl CF_WITH_PATH version: 8 updated: 2007/05/13 13:16:35
5570 dnl ------------
5571 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
5572 dnl defaulting to yes/no.
5573 dnl
5574 dnl $1 = option name
5575 dnl $2 = help-text
5576 dnl $3 = environment variable to set
5577 dnl $4 = default value, shown in the help-message, must be a constant
5578 dnl $5 = default value, if it's an expression & cannot be in the help-message
5579 dnl
5580 AC_DEFUN([CF_WITH_PATH],
5581 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
5582 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
5583 if ifelse($5,,true,[test -n "$5"]) ; then
5584 CF_PATH_SYNTAX(withval)
5585 fi
5586 $3="$withval"
5587 AC_SUBST($3)dnl
5588 ])dnl
5589 dnl ---------------------------------------------------------------------------
5590 dnl CF_WITH_PATHLIST version: 6 updated: 2009/01/11 20:30:23
5591 dnl ----------------
5592 dnl Process an option specifying a list of colon-separated paths.
5593 dnl
5594 dnl $1 = option name
5595 dnl $2 = help-text
5596 dnl $3 = environment variable to set
5597 dnl $4 = default value, shown in the help-message, must be a constant
5598 dnl $5 = default value, if it's an expression & cannot be in the help-message
5599 dnl $6 = flag to tell if we want to define or substitute
5600 dnl
5601 AC_DEFUN([CF_WITH_PATHLIST],[
5602 AC_REQUIRE([CF_PATHSEP])
5603 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
5604 ifelse($4,,[withval=${$3}],[withval=${$3-ifelse($5,,$4,$5)}]))dnl
5605
5606 IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${PATH_SEPARATOR}"
5607 cf_dst_path=
5608 for cf_src_path in $withval
5609 do
5610   CF_PATH_SYNTAX(cf_src_path)
5611   test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
5612   cf_dst_path="${cf_dst_path}${cf_src_path}"
5613 done
5614 IFS="$ac_save_ifs"
5615
5616 ifelse($6,define,[
5617 # Strip single quotes from the value, e.g., when it was supplied as a literal
5618 # for $4 or $5.
5619 case $cf_dst_path in #(vi
5620 \'*)
5621   cf_dst_path=`echo $cf_dst_path |sed -e s/\'// -e s/\'\$//`
5622   ;;
5623 esac
5624 cf_dst_path=`echo "$cf_dst_path" | sed -e 's/\\\\/\\\\\\\\/g'`
5625 ])
5626
5627 eval '$3="$cf_dst_path"'
5628 AC_SUBST($3)dnl
5629
5630 ])dnl
5631 dnl ---------------------------------------------------------------------------
5632 dnl CF_WITH_PTHREAD version: 2 updated: 2008/08/23 18:26:05
5633 dnl ---------------
5634 dnl Check for POSIX thread library.
5635 AC_DEFUN([CF_WITH_PTHREAD],
5636 [
5637 AC_MSG_CHECKING(if you want to link with the pthread library)
5638 AC_ARG_WITH(pthread,
5639     [  --with-pthread          use POSIX thread library],
5640     [with_pthread=$withval],
5641     [with_pthread=no])
5642 AC_MSG_RESULT($with_pthread)
5643
5644 if test "$with_pthread" != no ; then
5645     AC_CHECK_HEADER(pthread.h,[
5646         AC_DEFINE(HAVE_PTHREADS_H)
5647
5648         AC_MSG_CHECKING(if we can link with the pthread library)
5649         cf_save_LIBS="$LIBS"
5650         LIBS="-lpthread $LIBS"
5651         AC_TRY_LINK([
5652 #include <pthread.h>
5653 ],[
5654         int rc = pthread_create(0,0,0,0);
5655 ],[with_pthread=yes],[with_pthread=no])
5656         LIBS="$cf_save_LIBS"
5657         AC_MSG_RESULT($with_pthread)
5658
5659         if test "$with_pthread" = yes ; then
5660             LIBS="-lpthread $LIBS"
5661             AC_DEFINE(HAVE_LIBPTHREADS)
5662         else
5663             AC_MSG_ERROR(Cannot link with pthread library)
5664         fi
5665     ])
5666 fi
5667 ])
5668 dnl ---------------------------------------------------------------------------
5669 dnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
5670 dnl -------------------
5671 dnl Allow library's release-version to be overridden.  Generally this happens when a
5672 dnl packager has incremented the release-version past that used in the original package,
5673 dnl and wishes to keep doing this.
5674 dnl
5675 dnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
5676 dnl and {package}_MINOR symbols
5677 dnl symbol.
5678 AC_DEFUN([CF_WITH_REL_VERSION],[
5679 test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
5680 AC_ARG_WITH(rel-version,
5681 [  --with-rel-version=XXX  override derived release version],
5682 [AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
5683  cf_cv_rel_version=$withval])
5684 ifelse($1,,[
5685  CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
5686 ],[
5687  $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
5688  $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
5689  CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
5690  CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
5691 ])
5692 ])dnl
5693 dnl ---------------------------------------------------------------------------
5694 dnl CF_WITH_SYSMOUSE version: 2 updated: 2003/03/22 19:13:43
5695 dnl ----------------
5696 dnl If we can compile with sysmouse, make it available unless it is not wanted.
5697 AC_DEFUN([CF_WITH_SYSMOUSE],[
5698 # not everyone has "test -c"
5699 if test -c /dev/sysmouse 2>/dev/null ; then
5700 AC_MSG_CHECKING(if you want to use sysmouse)
5701 AC_ARG_WITH(sysmouse,
5702         [  --with-sysmouse         use sysmouse (FreeBSD console)],
5703         [cf_with_sysmouse=$withval],
5704         [cf_with_sysmouse=maybe])
5705         if test "$cf_with_sysmouse" != no ; then
5706         AC_TRY_COMPILE([
5707 #include <osreldate.h>
5708 #if (__FreeBSD_version >= 400017)
5709 #include <sys/consio.h>
5710 #include <sys/fbio.h>
5711 #else
5712 #include <machine/console.h>
5713 #endif
5714 ],[
5715         struct mouse_info the_mouse;
5716         ioctl(0, CONS_MOUSECTL, &the_mouse);
5717 ],[cf_with_sysmouse=yes],[cf_with_sysmouse=no])
5718         fi
5719 AC_MSG_RESULT($cf_with_sysmouse)
5720 test "$cf_with_sysmouse" = yes && AC_DEFINE(USE_SYSMOUSE)
5721 fi
5722 ])dnl
5723 dnl ---------------------------------------------------------------------------
5724 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
5725 dnl ----------------
5726 AC_DEFUN([CF_WITH_VALGRIND],[
5727 CF_NO_LEAKS_OPTION(valgrind,
5728         [  --with-valgrind         test: use valgrind],
5729         [USE_VALGRIND])
5730 ])dnl
5731 dnl ---------------------------------------------------------------------------
5732 dnl CF_XOPEN_SOURCE version: 32 updated: 2010/01/09 11:05:50
5733 dnl ---------------
5734 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
5735 dnl or adapt to the vendor's definitions to get equivalent functionality,
5736 dnl without losing the common non-POSIX features.
5737 dnl
5738 dnl Parameters:
5739 dnl     $1 is the nominal value for _XOPEN_SOURCE
5740 dnl     $2 is the nominal value for _POSIX_C_SOURCE
5741 AC_DEFUN([CF_XOPEN_SOURCE],[
5742
5743 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
5744 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
5745 cf_xopen_source=
5746
5747 case $host_os in #(vi
5748 aix[[456]]*) #(vi
5749         cf_xopen_source="-D_ALL_SOURCE"
5750         ;;
5751 darwin[[0-8]].*) #(vi
5752         cf_xopen_source="-D_APPLE_C_SOURCE"
5753         ;;
5754 darwin*) #(vi
5755         cf_xopen_source="-D_DARWIN_C_SOURCE"
5756         ;;
5757 freebsd*|dragonfly*) #(vi
5758         # 5.x headers associate
5759         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
5760         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
5761         cf_POSIX_C_SOURCE=200112L
5762         cf_XOPEN_SOURCE=600
5763         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
5764         ;;
5765 hpux11*) #(vi
5766         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
5767         ;;
5768 hpux*) #(vi
5769         cf_xopen_source="-D_HPUX_SOURCE"
5770         ;;
5771 irix[[56]].*) #(vi
5772         cf_xopen_source="-D_SGI_SOURCE"
5773         ;;
5774 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
5775         CF_GNU_SOURCE
5776         ;;
5777 mirbsd*) #(vi
5778         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
5779         ;;
5780 netbsd*) #(vi
5781         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
5782         ;;
5783 openbsd*) #(vi
5784         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
5785         ;;
5786 osf[[45]]*) #(vi
5787         cf_xopen_source="-D_OSF_SOURCE"
5788         ;;
5789 nto-qnx*) #(vi
5790         cf_xopen_source="-D_QNX_SOURCE"
5791         ;;
5792 sco*) #(vi
5793         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
5794         ;;
5795 solaris*) #(vi
5796         cf_xopen_source="-D__EXTENSIONS__"
5797         ;;
5798 *)
5799         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
5800         AC_TRY_COMPILE([#include <sys/types.h>],[
5801 #ifndef _XOPEN_SOURCE
5802 make an error
5803 #endif],
5804         [cf_cv_xopen_source=no],
5805         [cf_save="$CPPFLAGS"
5806          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
5807          AC_TRY_COMPILE([#include <sys/types.h>],[
5808 #ifdef _XOPEN_SOURCE
5809 make an error
5810 #endif],
5811         [cf_cv_xopen_source=no],
5812         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
5813         CPPFLAGS="$cf_save"
5814         ])
5815 ])
5816         if test "$cf_cv_xopen_source" != no ; then
5817                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
5818                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
5819                 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
5820                 CF_ADD_CFLAGS($cf_temp_xopen_source)
5821         fi
5822         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
5823         ;;
5824 esac
5825
5826 if test -n "$cf_xopen_source" ; then
5827         CF_ADD_CFLAGS($cf_xopen_source)
5828 fi
5829 ])