150276Speterdnl***************************************************************************
2178866Srafandnl Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
350276Speterdnl                                                                          *
450276Speterdnl Permission is hereby granted, free of charge, to any person obtaining a  *
550276Speterdnl copy of this software and associated documentation files (the            *
650276Speterdnl "Software"), to deal in the Software without restriction, including      *
750276Speterdnl without limitation the rights to use, copy, modify, merge, publish,      *
850276Speterdnl distribute, distribute with modifications, sublicense, and/or sell       *
950276Speterdnl copies of the Software, and to permit persons to whom the Software is    *
1050276Speterdnl furnished to do so, subject to the following conditions:                 *
1150276Speterdnl                                                                          *
1250276Speterdnl The above copyright notice and this permission notice shall be included  *
1350276Speterdnl in all copies or substantial portions of the Software.                   *
1450276Speterdnl                                                                          *
1550276Speterdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
1650276Speterdnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
1750276Speterdnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
1850276Speterdnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
1950276Speterdnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
2050276Speterdnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
2150276Speterdnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
2250276Speterdnl                                                                          *
2350276Speterdnl Except as contained in this notice, the name(s) of the above copyright   *
2450276Speterdnl holders shall not be used in advertising or otherwise to promote the     *
2550276Speterdnl sale, use or other dealings in this Software without prior written       *
2650276Speterdnl authorization.                                                           *
2750276Speterdnl***************************************************************************
2850276Speterdnl
29166124Srafandnl Author: Thomas E. Dickey 1995-on
3050276Speterdnl
31184989Srafandnl $Id: aclocal.m4,v 1.470 2008/10/25 22:15:32 tom Exp $
3250276Speterdnl Macros used in NCURSES auto-configuration script.
3350276Speterdnl
34166124Srafandnl These macros are maintained separately from NCURSES.  The copyright on
35166124Srafandnl this file applies to the aggregation of macros and does not affect use of
36166124Srafandnl these macros in other applications.
3766963Speterdnl
38166124Srafandnl See http://invisible-island.net/autoconf/ for additional information.
39166124Srafandnl
4050276Speterdnl ---------------------------------------------------------------------------
4150276Speterdnl ---------------------------------------------------------------------------
42166124Srafandnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
43166124Srafandnl -------------------
44166124Srafandnl Inserted as requested by gettext 0.10.40
45166124Srafandnl File from /usr/share/aclocal
46166124Srafandnl codeset.m4
47166124Srafandnl ====================
48166124Srafandnl serial AM1
49166124Srafandnl
50166124Srafandnl From Bruno Haible.
51166124SrafanAC_DEFUN([AM_LANGINFO_CODESET],
52166124Srafan[
53166124Srafan  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
54166124Srafan    [AC_TRY_LINK([#include <langinfo.h>],
55166124Srafan      [char* cs = nl_langinfo(CODESET);],
56166124Srafan      am_cv_langinfo_codeset=yes,
57166124Srafan      am_cv_langinfo_codeset=no)
58166124Srafan    ])
59166124Srafan  if test $am_cv_langinfo_codeset = yes; then
60166124Srafan    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
61166124Srafan      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
62166124Srafan  fi
63166124Srafan])dnl
64166124Srafandnl ---------------------------------------------------------------------------
65166124Srafandnl CF_ADA_INCLUDE_DIRS version: 5 updated: 2006/10/14 15:23:15
66166124Srafandnl -------------------
6750276Speterdnl Construct the list of include-options for the C programs in the Ada95
6850276Speterdnl binding.
6950276SpeterAC_DEFUN([CF_ADA_INCLUDE_DIRS],
7050276Speter[
71166124SrafanACPPFLAGS="-I. -I../../include $ACPPFLAGS"
7250276Speterif test "$srcdir" != "."; then
73166124Srafan	ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
7450276Speterfi
7566963Speterif test "$GCC" != yes; then
76166124Srafan	ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
7750276Speterelif test "$includedir" != "/usr/include"; then
7850276Speter	if test "$includedir" = '${prefix}/include' ; then
7950276Speter		if test $prefix != /usr ; then
80166124Srafan			ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
8150276Speter		fi
8250276Speter	else
83166124Srafan		ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
8450276Speter	fi
8550276Speterfi
8650276SpeterAC_SUBST(ACPPFLAGS)
8750276Speter])dnl
8850276Speterdnl ---------------------------------------------------------------------------
89166124Srafandnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
90166124Srafandnl -------------
9176726Speterdnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
9297049Speterdnl The second parameter if given makes this macro verbose.
93166124Srafandnl
94166124Srafandnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
95166124Srafandnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
96166124Srafandnl confused by the quotes (which require backslashes to keep them usable).
9776726SpeterAC_DEFUN([CF_ADD_CFLAGS],
9876726Speter[
99166124Srafancf_fix_cppflags=no
10097049Spetercf_new_cflags=
10197049Spetercf_new_cppflags=
102166124Srafancf_new_extra_cppflags=
103166124Srafan
10476726Speterfor cf_add_cflags in $1
10576726Speterdo
106166124Srafancase $cf_fix_cppflags in
107166124Srafanno)
10876726Speter	case $cf_add_cflags in #(vi
10976726Speter	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
110166124Srafan		case $cf_add_cflags in
111166124Srafan		-D*)
112166124Srafan			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
113166124Srafan
114166124Srafan			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
115166124Srafan			&& test -z "${cf_tst_cflags}" \
116166124Srafan			&& cf_fix_cppflags=yes
117166124Srafan
118166124Srafan			if test $cf_fix_cppflags = yes ; then
119166124Srafan				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
120166124Srafan				continue
121166124Srafan			elif test "${cf_tst_cflags}" = "\"'" ; then
122166124Srafan				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
123166124Srafan				continue
124166124Srafan			fi
125166124Srafan			;;
126166124Srafan		esac
12776726Speter		case "$CPPFLAGS" in
12897049Speter		*$cf_add_cflags) #(vi
12976726Speter			;;
13097049Speter		*) #(vi
13197049Speter			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
13276726Speter			;;
13376726Speter		esac
13476726Speter		;;
13576726Speter	*)
13697049Speter		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
13776726Speter		;;
13876726Speter	esac
139166124Srafan	;;
140166124Srafanyes)
141166124Srafan	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
142166124Srafan
143166124Srafan	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
144166124Srafan
145166124Srafan	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
146166124Srafan	&& test -z "${cf_tst_cflags}" \
147166124Srafan	&& cf_fix_cppflags=no
148166124Srafan	;;
149166124Srafanesac
15076726Speterdone
15197049Speter
15297049Speterif test -n "$cf_new_cflags" ; then
15397049Speter	ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
15497049Speter	CFLAGS="$CFLAGS $cf_new_cflags"
15597049Speterfi
15697049Speter
15797049Speterif test -n "$cf_new_cppflags" ; then
15897049Speter	ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
159166124Srafan	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
16097049Speterfi
16197049Speter
162166124Srafanif test -n "$cf_new_extra_cppflags" ; then
163166124Srafan	ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
164166124Srafan	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
165166124Srafanfi
166166124Srafan
167166124SrafanAC_SUBST(EXTRA_CPPFLAGS)
168166124Srafan
16976726Speter])dnl
17076726Speterdnl ---------------------------------------------------------------------------
171178866Srafandnl CF_ADD_INCDIR version: 9 updated: 2008/02/09 13:15:34
172174993Srafandnl -------------
173174993Srafandnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
174174993Srafandnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
175174993Srafandnl but old versions (and some misinstalled ones) need that.  To make things
176174993Srafandnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
177174993Srafandnl the include-path).
178174993SrafanAC_DEFUN([CF_ADD_INCDIR],
179174993Srafan[
180174993Srafanif test -n "$1" ; then
181174993Srafan  for cf_add_incdir in $1
182174993Srafan  do
183174993Srafan	while test $cf_add_incdir != /usr/include
184174993Srafan	do
185174993Srafan	  if test -d $cf_add_incdir
186174993Srafan	  then
187174993Srafan		cf_have_incdir=no
188174993Srafan		if test -n "$CFLAGS$CPPFLAGS" ; then
189174993Srafan		  # a loop is needed to ensure we can add subdirs of existing dirs
190174993Srafan		  for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
191174993Srafan			if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
192174993Srafan			  cf_have_incdir=yes; break
193174993Srafan			fi
194174993Srafan		  done
195174993Srafan		fi
196174993Srafan
197174993Srafan		if test "$cf_have_incdir" = no ; then
198174993Srafan          if test "$cf_add_incdir" = /usr/local/include ; then
199174993Srafan			if test "$GCC" = yes
200174993Srafan			then
201174993Srafan			  cf_save_CPPFLAGS=$CPPFLAGS
202174993Srafan			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
203174993Srafan			  AC_TRY_COMPILE([#include <stdio.h>],
204174993Srafan				  [printf("Hello")],
205174993Srafan				  [],
206174993Srafan				  [cf_have_incdir=yes])
207174993Srafan			  CPPFLAGS=$cf_save_CPPFLAGS
208174993Srafan			fi
209174993Srafan		  fi
210174993Srafan		fi
211174993Srafan
212174993Srafan		if test "$cf_have_incdir" = no ; then
213178866Srafan		  CF_VERBOSE(adding $cf_add_incdir to include-path)
214174993Srafan		  ifelse($2,,CPPFLAGS,$2)="-I$cf_add_incdir $ifelse($2,,CPPFLAGS,[$]$2)"
215174993Srafan
216174993Srafan          cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
217174993Srafan          test "$cf_top_incdir" = "$cf_add_incdir" && break
218174993Srafan          cf_add_incdir="$cf_top_incdir"
219174993Srafan		else
220174993Srafan		  break
221174993Srafan		fi
222174993Srafan	  fi
223174993Srafan	done
224174993Srafan  done
225174993Srafanfi
226174993Srafan])dnl
227174993Srafandnl ---------------------------------------------------------------------------
228178866Srafandnl CF_ADD_LIBDIR version: 6 updated: 2008/02/09 13:15:34
229174993Srafandnl -------------
230174993Srafandnl	Adds to the library-path
231174993Srafandnl
232174993Srafandnl	Some machines have trouble with multiple -L options.
233174993Srafandnl
234174993Srafandnl $1 is the (list of) directory(s) to add
235174993Srafandnl $2 is the optional name of the variable to update (default LDFLAGS)
236174993Srafandnl
237174993SrafanAC_DEFUN([CF_ADD_LIBDIR],
238174993Srafan[
239174993Srafanif test -n "$1" ; then
240174993Srafan  for cf_add_libdir in $1
241174993Srafan  do
242174993Srafan    if test $cf_add_libdir = /usr/lib ; then
243174993Srafan      :
244174993Srafan    elif test -d $cf_add_libdir
245174993Srafan    then
246174993Srafan      cf_have_libdir=no
247174993Srafan      if test -n "$LDFLAGS$LIBS" ; then
248174993Srafan        # a loop is needed to ensure we can add subdirs of existing dirs
249174993Srafan        for cf_test_libdir in $LDFLAGS $LIBS ; do
250174993Srafan          if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
251174993Srafan            cf_have_libdir=yes; break
252174993Srafan          fi
253174993Srafan        done
254174993Srafan      fi
255174993Srafan      if test "$cf_have_libdir" = no ; then
256178866Srafan        CF_VERBOSE(adding $cf_add_libdir to library-path)
257174993Srafan        ifelse($2,,LDFLAGS,$2)="-L$cf_add_libdir $ifelse($2,,LDFLAGS,[$]$2)"
258174993Srafan      fi
259174993Srafan    fi
260174993Srafan  done
261174993Srafanfi
262174993Srafan])dnl
263174993Srafandnl ---------------------------------------------------------------------------
264184989Srafandnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59
265184989Srafandnl ------------------
266184989Srafandnl Append to a search-list for a nonstandard header/lib-file
267184989Srafandnl	$1 = the variable to return as result
268184989Srafandnl	$2 = the package name
269184989Srafandnl	$3 = the subdirectory, e.g., bin, include or lib
270184989Srafandnl $4 = the directory under which we will test for subdirectories
271184989Srafandnl $5 = a directory that we do not want $4 to match
272184989SrafanAC_DEFUN([CF_ADD_SUBDIR_PATH],
273184989Srafan[
274184989Srafantest "$4" != "$5" && \
275184989Srafantest -d "$4" && \
276184989Srafanifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) {
277184989Srafan	test -n "$verbose" && echo "	... testing for $3-directories under $4"
278184989Srafan	test -d $4/$3 &&          $1="[$]$1 $4/$3"
279184989Srafan	test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
280184989Srafan	test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
281184989Srafan	test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
282184989Srafan	test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
283184989Srafan}
284184989Srafan])dnl
285184989Srafandnl ---------------------------------------------------------------------------
286166124Srafandnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
287166124Srafandnl ----------------
28850276Speterdnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
28950276Speterdnl in the sharutils 4.2 distribution.
29050276SpeterAC_DEFUN([CF_ANSI_CC_CHECK],
29150276Speter[
29297049SpeterAC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
29350276Spetercf_cv_ansi_cc=no
29450276Spetercf_save_CFLAGS="$CFLAGS"
29576726Spetercf_save_CPPFLAGS="$CPPFLAGS"
29650276Speter# Don't try gcc -ansi; that turns off useful extensions and
29750276Speter# breaks some systems' header files.
29850276Speter# AIX			-qlanglvl=ansi
29950276Speter# Ultrix and OSF/1	-std1
30050276Speter# HP-UX			-Aa -D_HPUX_SOURCE
30150276Speter# SVR4			-Xc
30250276Speter# UnixWare 1.2		(cannot use -Xc, since ANSI/POSIX clashes)
30350276Speterfor cf_arg in "-DCC_HAS_PROTOS" \
30450276Speter	"" \
30550276Speter	-qlanglvl=ansi \
30650276Speter	-std1 \
30762449Speter	-Ae \
30850276Speter	"-Aa -D_HPUX_SOURCE" \
30950276Speter	-Xc
31050276Speterdo
31176726Speter	CF_ADD_CFLAGS($cf_arg)
31250276Speter	AC_TRY_COMPILE(
31350276Speter[
31450276Speter#ifndef CC_HAS_PROTOS
31550276Speter#if !defined(__STDC__) || (__STDC__ != 1)
31650276Speterchoke me
31750276Speter#endif
31850276Speter#endif
31950276Speter],[
32050276Speter	int test (int i, double x);
32150276Speter	struct s1 {int (*f) (int a);};
32250276Speter	struct s2 {int (*f) (double a);};],
32350276Speter	[cf_cv_ansi_cc="$cf_arg"; break])
32450276Speterdone
32550276SpeterCFLAGS="$cf_save_CFLAGS"
32676726SpeterCPPFLAGS="$cf_save_CPPFLAGS"
32750276Speter])
32850276Speter
32950276Speterif test "$cf_cv_ansi_cc" != "no"; then
33050276Speterif test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
33176726Speter	CF_ADD_CFLAGS($cf_cv_ansi_cc)
33250276Speterelse
33350276Speter	AC_DEFINE(CC_HAS_PROTOS)
33450276Speterfi
33550276Speterfi
33650276Speter])dnl
33750276Speterdnl ---------------------------------------------------------------------------
338178866Srafandnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
339166124Srafandnl ---------------
34050276Speterdnl For programs that must use an ANSI compiler, obtain compiler options that
34150276Speterdnl will make it recognize prototypes.  We'll do preprocessor checks in other
34250276Speterdnl macros, since tools such as unproto can fake prototypes, but only part of
34350276Speterdnl the preprocessor.
34450276SpeterAC_DEFUN([CF_ANSI_CC_REQD],
34550276Speter[AC_REQUIRE([CF_ANSI_CC_CHECK])
34650276Speterif test "$cf_cv_ansi_cc" = "no"; then
347178866Srafan	AC_MSG_ERROR(
34850276Speter[Your compiler does not appear to recognize prototypes.
34950276SpeterYou have the following choices:
35050276Speter	a. adjust your compiler options
35150276Speter	b. get an up-to-date compiler
35250276Speter	c. use a wrapper such as unproto])
35350276Speterfi
35450276Speter])dnl
35550276Speterdnl ---------------------------------------------------------------------------
356184989Srafandnl CF_AWK_BIG_PRINTF version: 2 updated: 2008/10/04 17:16:18
357184989Srafandnl -----------------
358184989Srafandnl Check if awk can handle big strings using printf.  Some older versions of
359184989Srafandnl awk choke on large strings passed via "%s".
360184989Srafandnl
361184989Srafandnl $1 = desired string size
362184989Srafandnl $2 = variable to set with result
363184989SrafanAC_DEFUN([CF_AWK_BIG_PRINTF],
364184989Srafan[
365184989Srafan    case x$AWK in #(vi
366184989Srafan    x)
367184989Srafan        eval $2=no
368184989Srafan        ;;
369184989Srafan    *) #(vi
370184989Srafan        if ( ${AWK} 'BEGIN { xx = "x"; while (length(xx) < $1) { xx = xx "x"; }; printf("%s\n", xx); }' \
371184989Srafan            | $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
372184989Srafan            eval $2=yes
373184989Srafan        else
374184989Srafan            eval $2=no
375184989Srafan        fi
376184989Srafan        ;;
377184989Srafan    esac
378184989Srafan])dnl
379184989Srafandnl ---------------------------------------------------------------------------
380166124Srafandnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18
381166124Srafandnl ------------
38250276Speterdnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
38350276Speterdnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
38450276Speterdnl 2.6.3 does, in anticipation of the ANSI C++ standard.
38550276Speterdnl
38650276Speterdnl Treat the configuration-variable specially here, since we're directly
38750276Speterdnl substituting its value (i.e., 1/0).
388166124Srafandnl
389166124Srafandnl $1 is the shell variable to store the result in, if not $cv_cv_builtin_bool
39050276SpeterAC_DEFUN([CF_BOOL_DECL],
39150276Speter[
392166124SrafanAC_MSG_CHECKING(if we should include stdbool.h)
393166124Srafan
394166124SrafanAC_CACHE_VAL(cf_cv_header_stdbool_h,[
395166124Srafan	AC_TRY_COMPILE([],[bool foo = false],
396166124Srafan		[cf_cv_header_stdbool_h=0],
397166124Srafan		[AC_TRY_COMPILE([
398166124Srafan#ifndef __BEOS__
399166124Srafan#include <stdbool.h>
400166124Srafan#endif
401166124Srafan],[bool foo = false],
402166124Srafan			[cf_cv_header_stdbool_h=1],
403166124Srafan			[cf_cv_header_stdbool_h=0])])])
404166124Srafan
405166124Srafanif test "$cf_cv_header_stdbool_h" = 1
406166124Srafanthen	AC_MSG_RESULT(yes)
407166124Srafanelse	AC_MSG_RESULT(no)
408166124Srafanfi
409166124Srafan
41066963SpeterAC_MSG_CHECKING([for builtin bool type])
411166124Srafan
41250276SpeterAC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
41350276Speter	AC_TRY_COMPILE([
41450276Speter#include <stdio.h>
41550276Speter#include <sys/types.h>
41650276Speter],[bool x = false],
41750276Speter		[ifelse($1,,cf_cv_builtin_bool,[$1])=1],
41850276Speter		[ifelse($1,,cf_cv_builtin_bool,[$1])=0])
41950276Speter	])
420166124Srafan
42166963Speterif test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1
42250276Speterthen	AC_MSG_RESULT(yes)
42350276Speterelse	AC_MSG_RESULT(no)
42450276Speterfi
42550276Speter])dnl
42650276Speterdnl ---------------------------------------------------------------------------
427166124Srafandnl CF_BOOL_SIZE version: 12 updated: 2006/12/16 12:33:30
428166124Srafandnl ------------
42950276Speterdnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
43050276Speterdnl Don't bother looking for bool.h, since it's been deprecated.
43197049Speterdnl
43297049Speterdnl If the current compiler is C rather than C++, we get the bool definition
43397049Speterdnl from <stdbool.h>.
43450276SpeterAC_DEFUN([CF_BOOL_SIZE],
43550276Speter[
43666963SpeterAC_MSG_CHECKING([for size of bool])
43750276SpeterAC_CACHE_VAL(cf_cv_type_of_bool,[
43850276Speter	rm -f cf_test.out
43950276Speter	AC_TRY_RUN([
44050276Speter#include <stdlib.h>
44150276Speter#include <stdio.h>
44297049Speter
44397049Speter#if defined(__cplusplus)
44497049Speter
44566963Speter#ifdef HAVE_GXX_BUILTIN_H
44656639Speter#include <g++/builtin.h>
44756639Speter#elif HAVE_GPP_BUILTIN_H
44856639Speter#include <gpp/builtin.h>
44956639Speter#elif HAVE_BUILTIN_H
45050276Speter#include <builtin.h>
45150276Speter#endif
45297049Speter
45397049Speter#else
45497049Speter
45597049Speter#if $cf_cv_header_stdbool_h
45697049Speter#include <stdbool.h>
45797049Speter#endif
45897049Speter
45997049Speter#endif
46097049Speter
46150276Spetermain()
46250276Speter{
46350276Speter	FILE *fp = fopen("cf_test.out", "w");
46450276Speter	if (fp != 0) {
46550276Speter		bool x = true;
46650276Speter		if ((bool)(-x) >= 0)
46750276Speter			fputs("unsigned ", fp);
46850276Speter		if (sizeof(x) == sizeof(int))       fputs("int",  fp);
46950276Speter		else if (sizeof(x) == sizeof(char)) fputs("char", fp);
47050276Speter		else if (sizeof(x) == sizeof(short))fputs("short",fp);
47150276Speter		else if (sizeof(x) == sizeof(long)) fputs("long", fp);
47250276Speter		fclose(fp);
47350276Speter	}
474166124Srafan	${cf_cv_main_return:-return}(0);
47550276Speter}
47650276Speter		],
47797049Speter		[cf_cv_type_of_bool=`cat cf_test.out`
47897049Speter		 if test -z "$cf_cv_type_of_bool"; then
47997049Speter		   cf_cv_type_of_bool=unknown
48097049Speter		 fi],
48150276Speter		[cf_cv_type_of_bool=unknown],
48250276Speter		[cf_cv_type_of_bool=unknown])
48350276Speter	])
48450276Speter	rm -f cf_test.out
48550276SpeterAC_MSG_RESULT($cf_cv_type_of_bool)
48650276Speterif test "$cf_cv_type_of_bool" = unknown ; then
48797049Speter	case .$NCURSES_BOOL in #(vi
48897049Speter	.auto|.) NCURSES_BOOL=unsigned;;
48997049Speter	esac
49097049Speter	AC_MSG_WARN(Assuming $NCURSES_BOOL for type of bool)
49197049Speter	cf_cv_type_of_bool=$NCURSES_BOOL
49250276Speterfi
49350276Speter])dnl
49450276Speterdnl ---------------------------------------------------------------------------
495166124Srafandnl CF_BUILD_CC version: 6 updated: 2006/10/14 15:23:15
496166124Srafandnl -----------
497166124Srafandnl If we're cross-compiling, allow the user to override the tools and their
498166124Srafandnl options.  The configure script is oriented toward identifying the host
499166124Srafandnl compiler, etc., but we need a build compiler to generate parts of the
500166124Srafandnl source.
501166124Srafandnl
502166124Srafandnl $1 = default for $CPPFLAGS
503166124Srafandnl $2 = default for $LIBS
504166124SrafanAC_DEFUN([CF_BUILD_CC],[
505166124SrafanAC_REQUIRE([CF_PROG_EXT])
506166124Srafanif test "$cross_compiling" = yes ; then
507166124Srafan
508166124Srafan	# defaults that we might want to override
509166124Srafan	: ${BUILD_CFLAGS:=''}
510166124Srafan	: ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
511166124Srafan	: ${BUILD_LDFLAGS:=''}
512166124Srafan	: ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
513166124Srafan	: ${BUILD_EXEEXT:='$x'}
514166124Srafan	: ${BUILD_OBJEXT:='o'}
515166124Srafan
516166124Srafan	AC_ARG_WITH(build-cc,
517166124Srafan		[  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
518166124Srafan		[BUILD_CC="$withval"],
519166124Srafan		[AC_CHECK_PROGS(BUILD_CC, gcc cc cl)])
520166124Srafan	AC_MSG_CHECKING(for native build C compiler)
521166124Srafan	AC_MSG_RESULT($BUILD_CC)
522166124Srafan
523166124Srafan	AC_MSG_CHECKING(for native build C preprocessor)
524166124Srafan	AC_ARG_WITH(build-cpp,
525166124Srafan		[  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
526166124Srafan		[BUILD_CPP="$withval"],
527166124Srafan		[BUILD_CPP='${BUILD_CC} -E'])
528166124Srafan	AC_MSG_RESULT($BUILD_CPP)
529166124Srafan
530166124Srafan	AC_MSG_CHECKING(for native build C flags)
531166124Srafan	AC_ARG_WITH(build-cflags,
532166124Srafan		[  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
533166124Srafan		[BUILD_CFLAGS="$withval"])
534166124Srafan	AC_MSG_RESULT($BUILD_CFLAGS)
535166124Srafan
536166124Srafan	AC_MSG_CHECKING(for native build C preprocessor-flags)
537166124Srafan	AC_ARG_WITH(build-cppflags,
538166124Srafan		[  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
539166124Srafan		[BUILD_CPPFLAGS="$withval"])
540166124Srafan	AC_MSG_RESULT($BUILD_CPPFLAGS)
541166124Srafan
542166124Srafan	AC_MSG_CHECKING(for native build linker-flags)
543166124Srafan	AC_ARG_WITH(build-ldflags,
544166124Srafan		[  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
545166124Srafan		[BUILD_LDFLAGS="$withval"])
546166124Srafan	AC_MSG_RESULT($BUILD_LDFLAGS)
547166124Srafan
548166124Srafan	AC_MSG_CHECKING(for native build linker-libraries)
549166124Srafan	AC_ARG_WITH(build-libs,
550166124Srafan		[  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
551166124Srafan		[BUILD_LIBS="$withval"])
552166124Srafan	AC_MSG_RESULT($BUILD_LIBS)
553166124Srafan
554166124Srafan	# this assumes we're on Unix.
555166124Srafan	BUILD_EXEEXT=
556166124Srafan	BUILD_OBJEXT=o
557166124Srafan
558166124Srafan	: ${BUILD_CC:='${CC}'}
559166124Srafan
560166124Srafan	if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
561166124Srafan		AC_MSG_ERROR([Cross-build requires two compilers.
562166124SrafanUse --with-build-cc to specify the native compiler.])
563166124Srafan	fi
564166124Srafan
565166124Srafanelse
566166124Srafan	: ${BUILD_CC:='${CC}'}
567166124Srafan	: ${BUILD_CPP:='${CPP}'}
568166124Srafan	: ${BUILD_CFLAGS:='${CFLAGS}'}
569166124Srafan	: ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
570166124Srafan	: ${BUILD_LDFLAGS:='${LDFLAGS}'}
571166124Srafan	: ${BUILD_LIBS:='${LIBS}'}
572166124Srafan	: ${BUILD_EXEEXT:='$x'}
573166124Srafan	: ${BUILD_OBJEXT:='o'}
574166124Srafanfi
575166124Srafan
576166124SrafanAC_SUBST(BUILD_CC)
577166124SrafanAC_SUBST(BUILD_CPP)
578166124SrafanAC_SUBST(BUILD_CFLAGS)
579166124SrafanAC_SUBST(BUILD_CPPFLAGS)
580166124SrafanAC_SUBST(BUILD_LDFLAGS)
581166124SrafanAC_SUBST(BUILD_LIBS)
582166124SrafanAC_SUBST(BUILD_EXEEXT)
583166124SrafanAC_SUBST(BUILD_OBJEXT)
584166124Srafan])dnl
585166124Srafandnl ---------------------------------------------------------------------------
586166124Srafandnl CF_CFG_DEFAULTS version: 7 updated: 2005/09/24 16:15:00
587166124Srafandnl ---------------
58850276Speterdnl Determine the default configuration into which we'll install ncurses.  This
58950276Speterdnl can be overridden by the user's command-line options.  There's two items to
59050276Speterdnl look for:
59150276Speterdnl	1. the prefix (e.g., /usr)
59250276Speterdnl	2. the header files (e.g., /usr/include/ncurses)
59350276Speterdnl We'll look for a previous installation of ncurses and use the same defaults.
59450276Speterdnl
59550276Speterdnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
59650276Speterdnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
59750276Speterdnl programs from a vendor's.
59850276SpeterAC_DEFUN([CF_CFG_DEFAULTS],
59950276Speter[
60050276SpeterAC_MSG_CHECKING(for prefix)
60150276Speterif test "x$prefix" = "xNONE" ; then
60250276Speter	case "$cf_cv_system_name" in
60350276Speter		# non-vendor systems don't have a conflict
604166124Srafan	openbsd*|freebsd*|linux*|cygwin*|k*bsd*-gnu)
60550276Speter		prefix=/usr
60650276Speter		;;
60750276Speter	*)	prefix=$ac_default_prefix
60850276Speter		;;
60950276Speter	esac
61050276Speterfi
61150276SpeterAC_MSG_RESULT($prefix)
61250276Speter
61350276Speterif test "x$prefix" = "xNONE" ; then
61450276SpeterAC_MSG_CHECKING(for default include-directory)
61550276Spetertest -n "$verbose" && echo 1>&AC_FD_MSG
61650276Speterfor cf_symbol in \
61750276Speter	$includedir \
61850276Speter	$includedir/ncurses \
61950276Speter	$prefix/include \
62050276Speter	$prefix/include/ncurses \
62150276Speter	/usr/local/include \
62250276Speter	/usr/local/include/ncurses \
62350276Speter	/usr/include \
62450276Speter	/usr/include/ncurses
62550276Speterdo
62650276Speter	cf_dir=`eval echo $cf_symbol`
62750276Speter	if test -f $cf_dir/curses.h ; then
62850276Speter	if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
62950276Speter		includedir="$cf_symbol"
63050276Speter		test -n "$verbose"  && echo $ac_n "	found " 1>&AC_FD_MSG
63150276Speter		break
63250276Speter	fi
63350276Speter	fi
63450276Speter	test -n "$verbose"  && echo "	tested $cf_dir" 1>&AC_FD_MSG
63550276Speterdone
63650276SpeterAC_MSG_RESULT($includedir)
63750276Speterfi
63850276Speter])dnl
63950276Speterdnl ---------------------------------------------------------------------------
640166124Srafandnl CF_CGETENT version: 3 updated: 2000/08/12 23:18:52
641166124Srafandnl ----------
64250276Speterdnl Check if the terminal-capability database functions are available.  If not,
64350276Speterdnl ncurses has a much-reduced version.
64450276SpeterAC_DEFUN([CF_CGETENT],[
64550276SpeterAC_MSG_CHECKING(for terminal-capability database functions)
64650276SpeterAC_CACHE_VAL(cf_cv_cgetent,[
64750276SpeterAC_TRY_LINK([
64850276Speter#include <stdlib.h>],[
64950276Speter	char temp[128];
65050276Speter	char *buf = temp;
65150276Speter	char *db_array = temp;
65250276Speter	cgetent(&buf, /* int *, */ &db_array, "vt100");
65350276Speter	cgetcap(buf, "tc", '=');
65450276Speter	cgetmatch(buf, "tc");
65550276Speter	],
65650276Speter	[cf_cv_cgetent=yes],
65750276Speter	[cf_cv_cgetent=no])
65850276Speter])
65950276SpeterAC_MSG_RESULT($cf_cv_cgetent)
66066963Spetertest "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT)
66150276Speter])dnl
66250276Speterdnl ---------------------------------------------------------------------------
663178866Srafandnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
664166124Srafandnl --------------
66550276Speterdnl Check if we're accidentally using a cache from a different machine.
66650276Speterdnl Derive the system name, as a check for reusing the autoconf cache.
66750276Speterdnl
66850276Speterdnl If we've packaged config.guess and config.sub, run that (since it does a
66966963Speterdnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
67066963Speterdnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
67166963Speterdnl which is useful in cross-compiles.
672166124Srafandnl
673166124Srafandnl Note: we would use $ac_config_sub, but that is one of the places where
674166124Srafandnl autoconf 2.5x broke compatibility with autoconf 2.13
67550276SpeterAC_DEFUN([CF_CHECK_CACHE],
67650276Speter[
677166124Srafanif test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
67866963Speter	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
67950276Speter	system_name="$host_os"
68050276Speterelse
68150276Speter	system_name="`(uname -s -r) 2>/dev/null`"
68250276Speter	if test -z "$system_name" ; then
68350276Speter		system_name="`(hostname) 2>/dev/null`"
68450276Speter	fi
68550276Speterfi
68650276Spetertest -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
68750276SpeterAC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
68850276Speter
68950276Spetertest -z "$system_name" && system_name="$cf_cv_system_name"
69097049Spetertest -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
69150276Speter
69250276Speterif test ".$system_name" != ".$cf_cv_system_name" ; then
69350276Speter	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
694178866Srafan	AC_MSG_ERROR("Please remove config.cache and try again.")
69550276Speterfi
69650276Speter])dnl
69750276Speterdnl ---------------------------------------------------------------------------
698184989Srafandnl CF_CHECK_ERRNO version: 10 updated: 2008/08/22 16:33:22
699166124Srafandnl --------------
70050276Speterdnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
70150276Speterdnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
70250276Speterdnl ourselves.
70350276Speterdnl
70450276Speterdnl $1 = the name to check
705184989Srafandnl $2 = the assumed type
70650276SpeterAC_DEFUN([CF_CHECK_ERRNO],
70750276Speter[
70897049SpeterAC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
70950276Speter    AC_TRY_COMPILE([
71062449Speter#ifdef HAVE_STDLIB_H
71150276Speter#include <stdlib.h>
71250276Speter#endif
71350276Speter#include <stdio.h>
71450276Speter#include <sys/types.h>
71550276Speter#include <errno.h> ],
716184989Srafan    ifelse($2,,int,$2) x = (ifelse($2,,int,$2)) $1,
71797049Speter    [cf_cv_dcl_$1=yes],
71897049Speter    [cf_cv_dcl_$1=no])
71950276Speter])
72050276Speter
72197049Speterif test "$cf_cv_dcl_$1" = no ; then
72297049Speter    CF_UPPER(cf_result,decl_$1)
72350276Speter    AC_DEFINE_UNQUOTED($cf_result)
72450276Speterfi
72550276Speter
72650276Speter# It's possible (for near-UNIX clones) that the data doesn't exist
727184989SrafanCF_CHECK_EXTERN_DATA($1,ifelse($2,,int,$2))
72850276Speter])dnl
72950276Speterdnl ---------------------------------------------------------------------------
730166124Srafandnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
731166124Srafandnl --------------------
73250276Speterdnl Check for existence of external data in the current set of libraries.  If
73350276Speterdnl we can modify it, it's real enough.
73450276Speterdnl $1 = the name to check
73550276Speterdnl $2 = its type
73650276SpeterAC_DEFUN([CF_CHECK_EXTERN_DATA],
73750276Speter[
73897049SpeterAC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
73950276Speter    AC_TRY_LINK([
74050276Speter#undef $1
74150276Speterextern $2 $1;
74250276Speter],
74350276Speter    [$1 = 2],
74497049Speter    [cf_cv_have_$1=yes],
74597049Speter    [cf_cv_have_$1=no])
74697049Speter])
74750276Speter
74897049Speterif test "$cf_cv_have_$1" = yes ; then
74997049Speter    CF_UPPER(cf_result,have_$1)
75050276Speter    AC_DEFINE_UNQUOTED($cf_result)
75150276Speterfi
75250276Speter
75350276Speter])dnl
75450276Speterdnl ---------------------------------------------------------------------------
755174993Srafandnl CF_CHECK_GPM_WGETCH version: 1 updated: 2007/04/28 14:38:06
756174993Srafandnl -------------------
757174993Srafandnl Check if GPM is already linked with curses.  If so - and if the linkage
758174993Srafandnl is not "weak" - warn about this because it can create problems linking
759174993Srafandnl applications with ncurses.
760174993SrafanAC_DEFUN([CF_CHECK_GPM_WGETCH],[
761174993SrafanAC_CHECK_LIB(gpm,Gpm_Wgetch,[
762174993Srafan
763174993SrafanAC_CACHE_CHECK(if GPM is weakly bound to curses library, cf_cv_check_gpm_wgetch,[
764174993Srafancf_cv_check_gpm_wgetch=unknown
765174993Srafanif test "$cross_compiling" != yes ; then
766174993Srafan
767174993Srafancat >conftest.$ac_ext <<CF_EOF
768174993Srafan#include <gpm.h>
769174993Srafanint main()
770174993Srafan{
771174993Srafan	Gpm_Wgetch();
772174993Srafan	${cf_cv_main_return:-return}(0);
773174993Srafan}
774174993SrafanCF_EOF
775174993Srafan
776174993Srafan	cf_save_LIBS="$LIBS"
777174993Srafan	# This only works if we can look at the symbol table.  If a shared
778174993Srafan	# library is stripped for install, we cannot use that.  So we're forced
779174993Srafan	# to rely on the static library, noting that some packagers may not
780174993Srafan	# include it.
781174993Srafan	LIBS="-static -lgpm -dynamic $LIBS"
782174993Srafan	if AC_TRY_EVAL(ac_compile) ; then
783174993Srafan		if AC_TRY_EVAL(ac_link) ; then
784174993Srafan			cf_cv_check_gpm_wgetch=`nm conftest$ac_exeext | egrep '\<wgetch\>' | egrep '\<[[vVwW]]\>'`
785174993Srafan			test -n "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=yes
786174993Srafan			test -z "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=no
787174993Srafan		fi
788174993Srafan	fi
789174993Srafan	rm -f conftest*
790174993Srafan	LIBS="$cf_save_LIBS"
791174993Srafanfi
792174993Srafan])
793174993Srafan
794174993Srafanif test "$cf_cv_check_gpm_wgetch" != yes ; then
795174993Srafan	AC_MSG_WARN(GPM library is already linked with curses - read the FAQ)
796174993Srafanfi
797174993Srafan])])dnl
798174993Srafandnl ---------------------------------------------------------------------------
799166124Srafandnl CF_CPP_PARAM_INIT version: 4 updated: 2001/04/07 22:31:18
800166124Srafandnl -----------------
80156639Speterdnl Check if the C++ compiler accepts duplicate parameter initialization.  This
80256639Speterdnl is a late feature for the standard and is not in some recent compilers
80356639Speterdnl (1999/9/11).
80456639SpeterAC_DEFUN([CF_CPP_PARAM_INIT],
80550276Speter[
80676726Speterif test -n "$CXX"; then
80756639SpeterAC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
80876726Speter	AC_LANG_SAVE
80956639Speter	AC_LANG_CPLUSPLUS
81056639Speter	AC_TRY_RUN([
81156639Speterclass TEST {
81256639Speterprivate:
81356639Speter	int value;
81456639Speterpublic:
81556639Speter	TEST(int x = 1);
81656639Speter	~TEST();
81756639Speter};
81856639Speter
81956639SpeterTEST::TEST(int x = 1)	// some compilers do not like second initializer
82056639Speter{
82156639Speter	value = x;
82256639Speter}
82356639Spetervoid main() { }
82456639Speter],
82556639Speter	[cf_cv_cpp_param_init=yes],
82656639Speter	[cf_cv_cpp_param_init=no],
82756639Speter	[cf_cv_cpp_param_init=unknown])
82876726Speter	AC_LANG_RESTORE
82956639Speter])
83050276Speterfi
83156639Spetertest "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT)
83250276Speter])dnl
83350276Speterdnl ---------------------------------------------------------------------------
834166124Srafandnl CF_CPP_STATIC_CAST version: 1 updated: 2005/07/23 16:52:43
835166124Srafandnl ------------------
836166124Srafandnl Check if the C++ compiler accepts static_cast in generics.  This appears to
837166124Srafandnl not be supported in g++ before 3.0
838166124SrafanAC_DEFUN([CF_CPP_STATIC_CAST],
839166124Srafan[
840166124Srafanif test -n "$CXX"; then
841166124Srafan
842166124SrafanAC_CACHE_CHECK(if $CXX accepts static_cast,cf_cv_cpp_static_cast,[
843166124Srafan	AC_LANG_SAVE
844166124Srafan	AC_LANG_CPLUSPLUS
845166124Srafan
846166124Srafan	AC_TRY_COMPILE([
847166124Srafanclass NCursesPanel
848166124Srafan{
849166124Srafanpublic:
850166124Srafan  NCursesPanel(int nlines,
851166124Srafan	       int ncols,
852166124Srafan	       int begin_y = 0,
853166124Srafan	       int begin_x = 0)
854166124Srafan  {
855166124Srafan  }
856166124Srafan
857166124Srafan  ~NCursesPanel();
858166124Srafan};
859166124Srafan
860166124Srafantemplate<class T> class NCursesUserPanel : public NCursesPanel
861166124Srafan{
862166124Srafanpublic:
863166124Srafan  NCursesUserPanel (int nlines,
864166124Srafan		    int ncols,
865166124Srafan		    int begin_y = 0,
866166124Srafan		    int begin_x = 0,
867166124Srafan		    const T* p_UserData = static_cast<T*>(0))
868166124Srafan    : NCursesPanel (nlines, ncols, begin_y, begin_x)
869166124Srafan  {
870166124Srafan  };
871166124Srafan  NCursesUserPanel(const T* p_UserData = static_cast<T*>(0)) : NCursesPanel()
872166124Srafan  {
873166124Srafan  };
874166124Srafan
875166124Srafan  virtual ~NCursesUserPanel() {};
876166124Srafan};
877166124Srafan],[
878166124Srafan	const char* p_UserData = static_cast<char*>(0)],
879166124Srafan	[cf_cv_cpp_static_cast=yes],
880166124Srafan	[cf_cv_cpp_static_cast=no])
881166124Srafan
882166124Srafan	AC_LANG_RESTORE
883166124Srafan])
884166124Srafan
885166124Srafanfi
886166124Srafan
887166124Srafantest "$cf_cv_cpp_static_cast" = yes && AC_DEFINE(CPP_HAS_STATIC_CAST)
888166124Srafan])dnl
889166124Srafandnl ---------------------------------------------------------------------------
890174993Srafandnl CF_C_INLINE version: 2 updated: 2007/08/11 14:09:50
891174993Srafandnl -----------
892174993Srafandnl Check if the C compiler supports "inline".
893174993Srafandnl $1 is the name of a shell variable to set if inline is supported
894174993Srafandnl $2 is the threshold for gcc 4.x's option controlling maximum inline size
895174993SrafanAC_DEFUN([CF_C_INLINE],[
896174993SrafanAC_C_INLINE
897174993Srafan$1=
898174993Srafanif test "$ac_cv_c_inline" != no ; then
899174993Srafan  $1=inline
900174993Srafan  if test "$INTEL_COMPILER" = yes
901174993Srafan  then
902174993Srafan    :
903174993Srafan  elif test "$GCC" = yes
904174993Srafan  then
905174993Srafan    AC_CACHE_CHECK(if gcc supports options to tune inlining,cf_cv_gcc_inline,[
906174993Srafan      cf_save_CFLAGS=$CFLAGS
907174993Srafan      CFLAGS="$CFLAGS --param max-inline-insns-single=$2"
908174993Srafan      AC_TRY_COMPILE([inline int foo(void) { return 1; }],
909174993Srafan      [${cf_cv_main_return:-return} foo()],
910174993Srafan      [cf_cv_gcc_inline=yes],
911174993Srafan      [cf_cv_gcc_inline=no])
912174993Srafan      CFLAGS=$cf_save_CFLAGS
913174993Srafan    ])
914174993Srafan    if test "$cf_cv_gcc_inline" = yes ; then
915174993Srafan        CF_ADD_CFLAGS([--param max-inline-insns-single=$2])
916174993Srafan    fi
917174993Srafan  fi
91876726Speterfi
919174993SrafanAC_SUBST($1)
92076726Speter])dnl
92176726Speterdnl ---------------------------------------------------------------------------
922166124Srafandnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
923166124Srafandnl ----------
92476726Speterdnl "dirname" is not portable, so we fake it with a shell script.
925166124SrafanAC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
92676726Speterdnl ---------------------------------------------------------------------------
927166124Srafandnl CF_DIRS_TO_MAKE version: 3 updated: 2002/02/23 20:38:31
928166124Srafandnl ---------------
92950276SpeterAC_DEFUN([CF_DIRS_TO_MAKE],
93050276Speter[
93150276SpeterDIRS_TO_MAKE="lib"
93250276Speterfor cf_item in $cf_list_models
93350276Speterdo
93450276Speter	CF_OBJ_SUBDIR($cf_item,cf_subdir)
93597049Speter	for cf_item2 in $DIRS_TO_MAKE
93697049Speter	do
93797049Speter		test $cf_item2 = $cf_subdir && break
93897049Speter	done
93997049Speter	test ".$cf_item2" != ".$cf_subdir" && DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
94050276Speterdone
94150276Speterfor cf_dir in $DIRS_TO_MAKE
94250276Speterdo
94350276Speter	test ! -d $cf_dir && mkdir $cf_dir
94450276Speterdone
94550276SpeterAC_SUBST(DIRS_TO_MAKE)
94650276Speter])dnl
94750276Speterdnl ---------------------------------------------------------------------------
948166124Srafandnl CF_DISABLE_LEAKS version: 4 updated: 2006/12/16 15:10:42
949166124Srafandnl ----------------
950166124Srafandnl Combine no-leak checks with the libraries or tools that are used for the
951166124Srafandnl checks.
952166124SrafanAC_DEFUN([CF_DISABLE_LEAKS],[
953166124Srafan
954166124SrafanAC_REQUIRE([CF_WITH_DMALLOC])
955166124SrafanAC_REQUIRE([CF_WITH_DBMALLOC])
956166124SrafanAC_REQUIRE([CF_WITH_VALGRIND])
957166124Srafan
958166124SrafanAC_MSG_CHECKING(if you want to perform memory-leak testing)
959166124SrafanAC_ARG_ENABLE(leaks,
960166124Srafan	[  --disable-leaks         test: free permanent memory, analyze leaks],
961166124Srafan	[with_no_leaks=yes],
962166124Srafan	: ${with_no_leaks:=no})
963166124SrafanAC_MSG_RESULT($with_no_leaks)
964166124Srafan
965166124Srafanif test "$with_no_leaks" = yes ; then
966166124Srafan	AC_DEFINE(NO_LEAKS)
967166124Srafanfi
968166124Srafan])dnl
969166124Srafandnl ---------------------------------------------------------------------------
970184989Srafandnl CF_ENABLE_RPATH version: 1 updated: 2008/09/13 10:22:30
971184989Srafandnl ---------------
972184989Srafandnl Check if the rpath option should be used, setting cache variable
973184989Srafandnl cf_cv_ld_rpath if so.
974184989SrafanAC_DEFUN([CF_ENABLE_RPATH],
975184989Srafan[
976184989SrafanAC_MSG_CHECKING(if rpath option should be used)
977184989SrafanAC_ARG_ENABLE(rpath,
978184989Srafan[  --enable-rpath          use rpath option when generating shared libraries],
979184989Srafan[cf_cv_ld_rpath=$enableval],
980184989Srafan[cf_cv_ld_rpath=no])
981184989SrafanAC_MSG_RESULT($cf_cv_ld_rpath)
982184989Srafan])dnl
983184989Srafandnl ---------------------------------------------------------------------------
984166124Srafandnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
985166124Srafandnl --------
98650276Speterdnl Check if 'errno' is declared in <errno.h>
98750276SpeterAC_DEFUN([CF_ERRNO],
98850276Speter[
98950276SpeterCF_CHECK_ERRNO(errno)
99050276Speter])dnl
99150276Speterdnl ---------------------------------------------------------------------------
992166124Srafandnl CF_ETIP_DEFINES version: 3 updated: 2003/03/22 19:13:43
993166124Srafandnl ---------------
99450276Speterdnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
99550276Speterdnl math.h and builtin.h, only for ncurses
99650276SpeterAC_DEFUN([CF_ETIP_DEFINES],
99750276Speter[
99850276SpeterAC_MSG_CHECKING(for special defines needed for etip.h)
99950276Spetercf_save_CXXFLAGS="$CXXFLAGS"
100050276Spetercf_result="none"
100150276Speterfor cf_math in "" MATH_H
100250276Speterdo
100350276Speterfor cf_excp in "" MATH_EXCEPTION
100450276Speterdo
1005166124Srafan	CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -I${srcdir}/include"
100650276Speter	test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
100750276Speter	test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
100850276SpeterAC_TRY_COMPILE([
100950276Speter#include <etip.h.in>
101050276Speter],[],[
101156639Speter	test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
101256639Speter	test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
101350276Speter	cf_result="$cf_math $cf_excp"
101450276Speter	break
101550276Speter],[])
101650276Speterdone
101750276Speterdone
101850276SpeterAC_MSG_RESULT($cf_result)
101950276SpeterCXXFLAGS="$cf_save_CXXFLAGS"
102050276Speter])
102150276Speterdnl ---------------------------------------------------------------------------
1022184989Srafandnl CF_FIND_LINKAGE version: 12 updated: 2007/07/29 20:13:53
1023184989Srafandnl ---------------
1024184989Srafandnl Find a library (specifically the linkage used in the code fragment),
1025184989Srafandnl searching for it if it is not already in the library path.
1026184989Srafandnl See also CF_ADD_SEARCHPATH.
1027184989Srafandnl
1028184989Srafandnl Parameters (4-on are optional):
1029184989Srafandnl     $1 = headers for library entrypoint
1030184989Srafandnl     $2 = code fragment for library entrypoint
1031184989Srafandnl     $3 = the library name without the "-l" option or ".so" suffix.
1032184989Srafandnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1033184989Srafandnl     $5 = action to perform if not successful
1034184989Srafandnl     $6 = module name, if not the same as the library name
1035184989Srafandnl     $7 = extra libraries
1036184989Srafandnl
1037184989Srafandnl Sets these variables:
1038184989Srafandnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1039184989Srafandnl     $cf_cv_header_path_$3 - include-directory if needed
1040184989Srafandnl     $cf_cv_library_path_$3 - library-directory if needed
1041184989Srafandnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1042184989SrafanAC_DEFUN([CF_FIND_LINKAGE],[
1043184989Srafan
1044184989Srafan# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1045184989Srafan# will be set on completion of the AC_TRY_LINK below.
1046184989Srafancf_cv_header_path_$3=
1047184989Srafancf_cv_library_path_$3=
1048184989Srafan
1049184989SrafanCF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1050184989Srafan
1051184989SrafanAC_TRY_LINK([$1],[$2],
1052184989Srafan    cf_cv_find_linkage_$3=yes,[
1053184989Srafan    cf_cv_find_linkage_$3=no
1054184989Srafan
1055184989Srafan    CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1056184989Srafan
1057184989Srafan    cf_save_CPPFLAGS="$CPPFLAGS"
1058184989Srafan    cf_test_CPPFLAGS="$CPPFLAGS"
1059184989Srafan
1060184989Srafan    CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1061184989Srafan    for cf_cv_header_path_$3 in $cf_search
1062184989Srafan    do
1063184989Srafan      if test -d $cf_cv_header_path_$3 ; then
1064184989Srafan        CF_VERBOSE(... testing $cf_cv_header_path_$3)
1065184989Srafan        CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1066184989Srafan        AC_TRY_COMPILE([$1],[$2],[
1067184989Srafan            CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1068184989Srafan            cf_cv_find_linkage_$3=maybe
1069184989Srafan            cf_test_CPPFLAGS="$CPPFLAGS"
1070184989Srafan            break],[
1071184989Srafan            CPPFLAGS="$cf_save_CPPFLAGS"
1072184989Srafan            ])
1073184989Srafan      fi
1074184989Srafan    done
1075184989Srafan
1076184989Srafan    if test "$cf_cv_find_linkage_$3" = maybe ; then
1077184989Srafan
1078184989Srafan      CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1079184989Srafan
1080184989Srafan      cf_save_LIBS="$LIBS"
1081184989Srafan      cf_save_LDFLAGS="$LDFLAGS"
1082184989Srafan
1083184989Srafan      ifelse([$6],,,[
1084184989Srafan        CPPFLAGS="$cf_test_CPPFLAGS"
1085184989Srafan        LIBS="-l$3 $7 $cf_save_LIBS"
1086184989Srafan        AC_TRY_LINK([$1],[$2],[
1087184989Srafan            CF_VERBOSE(... found $3 library in system)
1088184989Srafan            cf_cv_find_linkage_$3=yes])
1089184989Srafan            CPPFLAGS="$cf_save_CPPFLAGS"
1090184989Srafan            LIBS="$cf_save_LIBS"
1091184989Srafan            ])
1092184989Srafan
1093184989Srafan      if test "$cf_cv_find_linkage_$3" != yes ; then
1094184989Srafan        CF_LIBRARY_PATH(cf_search,$3)
1095184989Srafan        for cf_cv_library_path_$3 in $cf_search
1096184989Srafan        do
1097184989Srafan          if test -d $cf_cv_library_path_$3 ; then
1098184989Srafan            CF_VERBOSE(... testing $cf_cv_library_path_$3)
1099184989Srafan            CPPFLAGS="$cf_test_CPPFLAGS"
1100184989Srafan            LIBS="-l$3 $7 $cf_save_LIBS"
1101184989Srafan            LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1102184989Srafan            AC_TRY_LINK([$1],[$2],[
1103184989Srafan                CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1104184989Srafan                cf_cv_find_linkage_$3=yes
1105184989Srafan                cf_cv_library_file_$3="-l$3"
1106184989Srafan                break],[
1107184989Srafan                CPPFLAGS="$cf_save_CPPFLAGS"
1108184989Srafan                LIBS="$cf_save_LIBS"
1109184989Srafan                LDFLAGS="$cf_save_LDFLAGS"
1110184989Srafan                ])
1111184989Srafan          fi
1112184989Srafan        done
1113184989Srafan        LIBS="$cf_save_LIBS"
1114184989Srafan        CPPFLAGS="$cf_save_CPPFLAGS"
1115184989Srafan        LDFLAGS="$cf_save_LDFLAGS"
1116184989Srafan      fi
1117184989Srafan
1118184989Srafan    else
1119184989Srafan      cf_cv_find_linkage_$3=no
1120184989Srafan    fi
1121184989Srafan    ],$7)
1122184989Srafan
1123184989Srafanif test "$cf_cv_find_linkage_$3" = yes ; then
1124184989Srafanifelse([$4],,[
1125184989Srafan  CF_ADD_INCDIR($cf_cv_header_path_$3)
1126184989Srafan  CF_ADD_LIBDIR($cf_cv_library_path_$3)
1127184989Srafan  LIBS="-l$3 $LIBS"
1128184989Srafan],[$4])
1129184989Srafanelse
1130184989Srafanifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1131184989Srafanfi
1132184989Srafan])dnl
1133184989Srafandnl ---------------------------------------------------------------------------
1134166124Srafandnl CF_FUNC_DLSYM version: 1 updated: 2004/06/16 20:52:45
1135166124Srafandnl -------------
1136166124Srafandnl Test for dlsym() and related functions, as well as libdl.
1137166124Srafandnl
1138166124Srafandnl Sets
1139166124Srafandnl	$cf_have_dlsym
1140166124Srafandnl	$cf_have_libdl
1141166124SrafanAC_DEFUN([CF_FUNC_DLSYM],[
1142166124Srafancf_have_dlsym=no
1143166124SrafanAC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
1144166124Srafan
1145166124Srafancf_have_libdl=no
1146166124SrafanAC_CHECK_LIB(dl,dlsym,[
1147166124Srafan	cf_have_dlsym=yes
1148166124Srafan	cf_have_libdl=yes])])
1149166124Srafan
1150166124Srafanif test "$cf_have_dlsym" = yes ; then
1151166124Srafan	test "$cf_have_libdl" = yes && LIBS="-ldl $LIBS"
1152166124Srafan
1153166124Srafan	AC_MSG_CHECKING(whether able to link to dl*() functions)
1154166124Srafan	AC_TRY_LINK([#include <dlfcn.h>],[
1155166124Srafan		void *obj;
1156166124Srafan		if ((obj = dlopen("filename", 0)) != 0) {
1157166124Srafan			if (dlsym(obj, "symbolname") == 0) {
1158166124Srafan			dlclose(obj);
1159166124Srafan			}
1160166124Srafan		}],[
1161166124Srafan		AC_DEFINE(HAVE_LIBDL)],[
1162166124Srafan		AC_MSG_ERROR(Cannot link test program for libdl)])
1163166124Srafan	AC_MSG_RESULT(ok)
1164166124Srafanelse
1165166124Srafan	AC_MSG_ERROR(Cannot find dlsym function)
1166166124Srafanfi
1167166124Srafan])
1168166124Srafandnl ---------------------------------------------------------------------------
1169166124Srafandnl CF_FUNC_MEMMOVE version: 7 updated: 2006/12/16 12:33:30
1170166124Srafandnl ---------------
117150276Speterdnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
117250276Speterdnl is found, add our own version of memmove to the list of objects.
117350276SpeterAC_DEFUN([CF_FUNC_MEMMOVE],
117450276Speter[
117550276SpeterAC_CHECK_FUNC(memmove,,[
117650276SpeterAC_CHECK_FUNC(bcopy,[
117750276Speter	AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
117850276Speter		AC_TRY_RUN([
117950276Speterint main() {
118050276Speter	static char data[] = "abcdefghijklmnopqrstuwwxyz";
118150276Speter	char temp[40];
118250276Speter	bcopy(data, temp, sizeof(data));
118350276Speter	bcopy(temp+10, temp, 15);
118450276Speter	bcopy(temp+5, temp+15, 10);
1185166124Srafan	${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
118650276Speter}
118750276Speter		],
118850276Speter		[cf_cv_good_bcopy=yes],
118950276Speter		[cf_cv_good_bcopy=no],
119050276Speter		[cf_cv_good_bcopy=unknown])
119150276Speter		])
119250276Speter	],[cf_cv_good_bcopy=no])
119366963Speter	if test "$cf_cv_good_bcopy" = yes ; then
119450276Speter		AC_DEFINE(USE_OK_BCOPY)
119550276Speter	else
119650276Speter		AC_DEFINE(USE_MY_MEMMOVE)
119750276Speter	fi
119850276Speter])])dnl
119950276Speterdnl ---------------------------------------------------------------------------
1200166124Srafandnl CF_FUNC_NANOSLEEP version: 3 updated: 2006/12/16 12:33:30
1201166124Srafandnl -----------------
1202166124Srafandnl Check for existence of workable nanosleep() function.  Some systems, e.g.,
1203166124Srafandnl AIX 4.x, provide a non-working version.
1204166124SrafanAC_DEFUN([CF_FUNC_NANOSLEEP],[
1205166124SrafanAC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[
1206166124SrafanAC_TRY_RUN([
1207166124Srafan#include <stdio.h>
1208166124Srafan#include <errno.h>
1209166124Srafan#include <time.h>
1210166124Srafan
1211166124Srafan#ifdef HAVE_SYS_TIME_H
1212166124Srafan#include <sys/time.h>
1213166124Srafan#endif
1214166124Srafan
1215166124Srafanint main() {
1216166124Srafan	struct timespec ts1, ts2;
1217166124Srafan	int code;
1218166124Srafan	ts1.tv_sec  = 0;
1219166124Srafan	ts1.tv_nsec = 750000000;
1220166124Srafan	ts2.tv_sec  = 0;
1221166124Srafan	ts2.tv_nsec = 0;
1222166124Srafan	errno = 0;
1223166124Srafan	code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */
1224166124Srafan	${cf_cv_main_return:-return}(code != 0);
1225166124Srafan}
1226166124Srafan],
1227166124Srafan	[cf_cv_func_nanosleep=yes],
1228166124Srafan	[cf_cv_func_nanosleep=no],
1229166124Srafan	[cf_cv_func_nanosleep=unknown])])
1230166124Srafan
1231166124Srafantest "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP)
1232166124Srafan])
1233166124Srafandnl ---------------------------------------------------------------------------
1234178866Srafandnl CF_FUNC_OPENPTY version: 2 updated: 2008/04/12 19:49:01
1235178866Srafandnl ---------------
1236178866Srafandnl Check for openpty() function, along with <pty.h> header.  It may need the
1237178866Srafandnl "util" library as well.
1238178866SrafanAC_DEFUN([CF_FUNC_OPENPTY],
1239178866Srafan[
1240178866SrafanAC_CHECK_LIB(util,openpty,cf_cv_lib_util=yes,cf_cv_lib_util=no)
1241178866SrafanAC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
1242178866Srafan    cf_save_LIBS="$LIBS"
1243178866Srafan    test $cf_cv_lib_util = yes && LIBS="-lutil $LIBS"
1244178866Srafan    for cf_header in pty.h libutil.h util.h
1245178866Srafan    do
1246178866Srafan    AC_TRY_LINK([
1247178866Srafan#include <$cf_header>
1248178866Srafan],[
1249178866Srafan    int x = openpty((int *)0, (int *)0, (char *)0,
1250178866Srafan                   (struct termios *)0, (struct winsize *)0);
1251178866Srafan],[
1252178866Srafan        cf_cv_func_openpty=$cf_header
1253178866Srafan        break
1254178866Srafan],[
1255178866Srafan        cf_cv_func_openpty=no
1256178866Srafan])
1257178866Srafan    done
1258178866Srafan    LIBS="$cf_save_LIBS"
1259178866Srafan])
1260178866Srafan])dnl
1261178866Srafandnl ---------------------------------------------------------------------------
1262166124Srafandnl CF_FUNC_POLL version: 4 updated: 2006/12/16 12:33:30
1263166124Srafandnl ------------
126462449Speterdnl See if the poll function really works.  Some platforms have poll(), but
126562449Speterdnl it does not work for terminals or files.
126662449SpeterAC_DEFUN([CF_FUNC_POLL],[
126762449SpeterAC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
126862449SpeterAC_TRY_RUN([
126962449Speter#include <stdio.h>
127062449Speter#ifdef HAVE_POLL_H
127162449Speter#include <poll.h>
127262449Speter#else
127362449Speter#include <sys/poll.h>
127462449Speter#endif
127562449Speterint main() {
127662449Speter	struct pollfd myfds;
127762449Speter	int ret;
127862449Speter
127962449Speter	myfds.fd = 0;
128062449Speter	myfds.events = POLLIN;
128162449Speter
128262449Speter	ret = poll(&myfds, 1, 100);
1283166124Srafan	${cf_cv_main_return:-return}(ret != 0);
128462449Speter}],
128562449Speter	[cf_cv_working_poll=yes],
128662449Speter	[cf_cv_working_poll=no],
128762449Speter	[cf_cv_working_poll=unknown])])
128862449Spetertest "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL)
128962449Speter])dnl
129062449Speterdnl ---------------------------------------------------------------------------
1291166124Srafandnl CF_FUNC_TERMIOS version: 2 updated: 2000/07/22 23:37:24
1292166124Srafandnl ---------------
129366963Speterdnl Some old/broken variations define tcgetattr() only as a macro in
129466963Speterdnl termio(s).h
129566963SpeterAC_DEFUN([CF_FUNC_TERMIOS],[
129666963SpeterAC_REQUIRE([CF_STRUCT_TERMIOS])
129766963SpeterAC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
129866963SpeterAC_TRY_LINK([
129966963Speter#include <sys/types.h>
130066963Speter#ifdef HAVE_UNISTD_H
130166963Speter#include <unistd.h>
130266963Speter#endif
130366963Speter#ifdef HAVE_TERMIOS_H
130466963Speter#include <termios.h>
130566963Speter#define TTY struct termios
130666963Speter#else
130766963Speter#ifdef HAVE_TERMIO_H
130866963Speter#include <termio.h>
130966963Speter#define TTY struct termio
131066963Speter#endif
131166963Speter#endif
131266963Speter],[
131366963SpeterTTY foo;
131466963Spetertcgetattr(1, &foo);],
131566963Speter[cf_cv_have_tcgetattr=yes],
131666963Speter[cf_cv_have_tcgetattr=no])])
131766963Spetertest "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR)
131866963Speter])dnl
131966963Speterdnl ---------------------------------------------------------------------------
1320166124Srafandnl CF_FUNC_VSSCANF version: 3 updated: 2001/12/19 00:50:10
1321166124Srafandnl ---------------
132297049Speterdnl Check for vsscanf() function, which is in c9x but generally not in earlier
132397049Speterdnl versions of C.  It is in the GNU C library, and can often be simulated by
132497049Speterdnl other functions.
132597049SpeterAC_DEFUN([CF_FUNC_VSSCANF],
132697049Speter[
132797049SpeterAC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
132897049SpeterAC_TRY_LINK([
132997049Speter#include <stdarg.h>
133097049Speter#include <stdio.h>],[
133197049Speter	va_list ap;
133297049Speter	vsscanf("from", "%d", ap)],[cf_cv_func_vsscanf=vsscanf],[
133397049SpeterAC_TRY_LINK([
133497049Speter#include <stdarg.h>
133597049Speter#include <stdio.h>],[
133697049Speter    FILE strbuf;
133797049Speter    char *str = "from";
133897049Speter
133997049Speter    strbuf._flag = _IOREAD;
134097049Speter    strbuf._ptr = strbuf._base = (unsigned char *) str;
134197049Speter    strbuf._cnt = strlen(str);
134297049Speter    strbuf._file = _NFILE;
134397049Speter    return (vfscanf(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=vfscanf],[
134497049SpeterAC_TRY_LINK([
134597049Speter#include <stdarg.h>
134697049Speter#include <stdio.h>],[
134797049Speter    FILE strbuf;
134897049Speter    char *str = "from";
134997049Speter
135097049Speter    strbuf._flag = _IOREAD;
135197049Speter    strbuf._ptr = strbuf._base = (unsigned char *) str;
135297049Speter    strbuf._cnt = strlen(str);
135397049Speter    strbuf._file = _NFILE;
135497049Speter    return (_doscan(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=_doscan],[
135597049Spetercf_cv_func_vsscanf=no])])])])
135697049Speter
135797049Spetercase $cf_cv_func_vsscanf in #(vi
135897049Spetervsscanf) AC_DEFINE(HAVE_VSSCANF);; #(vi
135997049Spetervfscanf) AC_DEFINE(HAVE_VFSCANF);; #(vi
136097049Speter_doscan) AC_DEFINE(HAVE__DOSCAN);;
136197049Speteresac
136297049Speter
136397049Speter])dnl
136497049Speterdnl ---------------------------------------------------------------------------
1365174993Srafandnl CF_GCC_ATTRIBUTES version: 11 updated: 2007/07/29 09:55:12
1366166124Srafandnl -----------------
136750276Speterdnl Test for availability of useful gcc __attribute__ directives to quiet
136850276Speterdnl compiler warnings.  Though useful, not all are supported -- and contrary
136950276Speterdnl to documentation, unrecognized directives cause older compilers to barf.
137050276SpeterAC_DEFUN([CF_GCC_ATTRIBUTES],
137150276Speter[
137266963Speterif test "$GCC" = yes
137350276Speterthen
137450276Spetercat > conftest.i <<EOF
137550276Speter#ifndef GCC_PRINTF
137650276Speter#define GCC_PRINTF 0
137750276Speter#endif
137850276Speter#ifndef GCC_SCANF
137950276Speter#define GCC_SCANF 0
138050276Speter#endif
138150276Speter#ifndef GCC_NORETURN
138250276Speter#define GCC_NORETURN /* nothing */
138350276Speter#endif
138450276Speter#ifndef GCC_UNUSED
138550276Speter#define GCC_UNUSED /* nothing */
138650276Speter#endif
138750276SpeterEOF
138866963Speterif test "$GCC" = yes
138950276Speterthen
139056639Speter	AC_CHECKING([for $CC __attribute__ directives])
139150276Spetercat > conftest.$ac_ext <<EOF
1392174993Srafan#line __oline__ "${as_me-configure}"
139350276Speter#include "confdefs.h"
139450276Speter#include "conftest.h"
139550276Speter#include "conftest.i"
139650276Speter#if	GCC_PRINTF
139750276Speter#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
139850276Speter#else
139950276Speter#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
140050276Speter#endif
140150276Speter#if	GCC_SCANF
140250276Speter#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
140350276Speter#else
140450276Speter#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
140550276Speter#endif
140650276Speterextern void wow(char *,...) GCC_SCANFLIKE(1,2);
140750276Speterextern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
140850276Speterextern void foo(void) GCC_NORETURN;
140976726Speterint main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
141050276SpeterEOF
141150276Speter	for cf_attribute in scanf printf unused noreturn
141250276Speter	do
1413166124Srafan		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
141450276Speter		cf_directive="__attribute__(($cf_attribute))"
141556639Speter		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
141650276Speter		case $cf_attribute in
141750276Speter		scanf|printf)
141850276Speter		cat >conftest.h <<EOF
1419166124Srafan#define GCC_$cf_ATTRIBUTE 1
142050276SpeterEOF
142150276Speter			;;
142250276Speter		*)
142350276Speter		cat >conftest.h <<EOF
1424166124Srafan#define GCC_$cf_ATTRIBUTE $cf_directive
142550276SpeterEOF
142650276Speter			;;
142750276Speter		esac
142850276Speter		if AC_TRY_EVAL(ac_compile); then
142950276Speter			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
143050276Speter			cat conftest.h >>confdefs.h
143150276Speter		fi
143250276Speter	done
143350276Speterelse
143450276Speter	fgrep define conftest.i >>confdefs.h
143550276Speterfi
143650276Speterrm -rf conftest*
143750276Speterfi
143850276Speter])dnl
143950276Speterdnl ---------------------------------------------------------------------------
1440166124Srafandnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
1441166124Srafandnl --------------
1442166124Srafandnl Find version of gcc
1443166124SrafanAC_DEFUN([CF_GCC_VERSION],[
1444166124SrafanAC_REQUIRE([AC_PROG_CC])
1445166124SrafanGCC_VERSION=none
1446166124Srafanif test "$GCC" = yes ; then
1447166124Srafan	AC_MSG_CHECKING(version of $CC)
1448166124Srafan	GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1449166124Srafan	test -z "$GCC_VERSION" && GCC_VERSION=unknown
1450166124Srafan	AC_MSG_RESULT($GCC_VERSION)
1451166124Srafanfi
1452166124Srafan])dnl
1453166124Srafandnl ---------------------------------------------------------------------------
1454184989Srafandnl CF_GCC_WARNINGS version: 23 updated: 2008/07/26 17:54:02
1455166124Srafandnl ---------------
145650276Speterdnl Check if the compiler supports useful warning options.  There's a few that
145750276Speterdnl we don't use, simply because they're too noisy:
145850276Speterdnl
145950276Speterdnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
146050276Speterdnl	-Wredundant-decls (system headers make this too noisy)
146150276Speterdnl	-Wtraditional (combines too many unrelated messages, only a few useful)
1462166124Srafandnl	-Wwrite-strings (too noisy, but should review occasionally).  This
1463166124Srafandnl		is enabled for ncurses using "--enable-const".
146450276Speterdnl	-pedantic
146550276Speterdnl
1466166124Srafandnl Parameter:
1467166124Srafandnl	$1 is an optional list of gcc warning flags that a particular
1468166124Srafandnl		application might want to use, e.g., "no-unused" for
1469166124Srafandnl		-Wno-unused
1470166124Srafandnl Special:
1471166124Srafandnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
1472166124Srafandnl
147350276SpeterAC_DEFUN([CF_GCC_WARNINGS],
147450276Speter[
1475166124SrafanAC_REQUIRE([CF_GCC_VERSION])
1476166124SrafanCF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1477166124Srafan
1478166124Srafancat > conftest.$ac_ext <<EOF
1479174993Srafan#line __oline__ "${as_me-configure}"
148076726Speterint main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
148150276SpeterEOF
1482166124Srafan
1483166124Srafanif test "$INTEL_COMPILER" = yes
1484166124Srafanthen
1485166124Srafan# The "-wdXXX" options suppress warnings:
1486166124Srafan# remark #1419: external declaration in primary source file
1487166124Srafan# remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1488166124Srafan# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1489166124Srafan# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1490166124Srafan# remark #193: zero used for undefined preprocessing identifier
1491166124Srafan# remark #593: variable "curs_sb_left_arrow" was set but never used
1492166124Srafan# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1493166124Srafan# remark #869: parameter "tw" was never referenced
1494166124Srafan# remark #981: operands are evaluated in unspecified order
1495166124Srafan# warning #269: invalid format string conversion
1496166124Srafan
149756639Speter	AC_CHECKING([for $CC warning options])
149850276Speter	cf_save_CFLAGS="$CFLAGS"
1499166124Srafan	EXTRA_CFLAGS="-Wall"
1500174993Srafan	for cf_opt in \
1501166124Srafan		wd1419 \
1502166124Srafan		wd1682 \
1503166124Srafan		wd1683 \
1504166124Srafan		wd1684 \
1505166124Srafan		wd193 \
1506166124Srafan		wd279 \
1507166124Srafan		wd593 \
1508166124Srafan		wd810 \
1509166124Srafan		wd869 \
1510166124Srafan		wd981
1511166124Srafan	do
1512166124Srafan		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1513166124Srafan		if AC_TRY_EVAL(ac_compile); then
1514166124Srafan			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1515166124Srafan			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1516166124Srafan		fi
1517166124Srafan	done
1518166124Srafan	CFLAGS="$cf_save_CFLAGS"
1519166124Srafan
1520166124Srafanelif test "$GCC" = yes
1521166124Srafanthen
1522166124Srafan	AC_CHECKING([for $CC warning options])
1523166124Srafan	cf_save_CFLAGS="$CFLAGS"
152450276Speter	EXTRA_CFLAGS="-W -Wall"
152550276Speter	cf_warn_CONST=""
152650276Speter	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
152750276Speter	for cf_opt in \
152850276Speter		Wbad-function-cast \
152950276Speter		Wcast-align \
153050276Speter		Wcast-qual \
153150276Speter		Winline \
153250276Speter		Wmissing-declarations \
153350276Speter		Wmissing-prototypes \
153450276Speter		Wnested-externs \
153550276Speter		Wpointer-arith \
153650276Speter		Wshadow \
1537166124Srafan		Wstrict-prototypes \
1538166124Srafan		Wundef $cf_warn_CONST $1
153950276Speter	do
154050276Speter		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
154150276Speter		if AC_TRY_EVAL(ac_compile); then
154250276Speter			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1543166124Srafan			case $cf_opt in #(vi
1544166124Srafan			Wcast-qual) #(vi
1545166124Srafan				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1546166124Srafan				;;
1547166124Srafan			Winline) #(vi
1548166124Srafan				case $GCC_VERSION in
1549184989Srafan				[[34]].*)
1550166124Srafan					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1551166124Srafan					continue;;
1552166124Srafan				esac
1553166124Srafan				;;
1554166124Srafan			esac
155550276Speter			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
155650276Speter		fi
155750276Speter	done
155850276Speter	CFLAGS="$cf_save_CFLAGS"
155950276Speterfi
1560166124Srafanrm -f conftest*
1561166124Srafan
156250276SpeterAC_SUBST(EXTRA_CFLAGS)
156350276Speter])dnl
156450276Speterdnl ---------------------------------------------------------------------------
1565166124Srafandnl CF_GNAT_TRY_LINK version: 1 updated: 2004/08/21 19:02:08
1566166124Srafandnl ----------------
1567166124Srafandnl Verify that a test program compiles/links with GNAT.
1568166124Srafandnl $cf_ada_make is set to the program that compiles/links
1569166124Srafandnl $ADAFLAGS may be set to the GNAT flags.
1570166124Srafandnl
1571166124Srafandnl $1 is the text of the spec
1572166124Srafandnl $2 is the text of the body
1573166124Srafandnl $3 is the shell command to execute if successful
1574166124Srafandnl $4 is the shell command to execute if not successful
1575166124SrafanAC_DEFUN([CF_GNAT_TRY_LINK],
1576166124Srafan[
1577166124Srafanrm -f conftest*
1578166124Srafancat >>conftest.ads <<CF_EOF
1579166124Srafan$1
1580166124SrafanCF_EOF
1581166124Srafancat >>conftest.adb <<CF_EOF
1582166124Srafan$2
1583166124SrafanCF_EOF
1584166124Srafanif ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1585166124Srafanifelse($3,,      :,[      $3])
1586166124Srafanifelse($4,,,[else
1587166124Srafan   $4])
1588166124Srafanfi
1589166124Srafanrm -f conftest*
1590166124Srafan])dnl
1591166124Srafandnl ---------------------------------------------------------------------------
1592166124Srafandnl CF_GNAT_TRY_RUN version: 3 updated: 2004/08/21 19:02:08
1593166124Srafandnl ---------------
159450276Speterdnl Verify that a test program compiles and runs with GNAT
159550276Speterdnl $cf_ada_make is set to the program that compiles/links
1596166124Srafandnl $ADAFLAGS may be set to the GNAT flags.
1597166124Srafandnl
1598166124Srafandnl $1 is the text of the spec
1599166124Srafandnl $2 is the text of the body
1600166124Srafandnl $3 is the shell command to execute if successful
1601166124Srafandnl $4 is the shell command to execute if not successful
160250276SpeterAC_DEFUN([CF_GNAT_TRY_RUN],
160350276Speter[
160450276Speterrm -f conftest*
160550276Spetercat >>conftest.ads <<CF_EOF
160650276Speter$1
160750276SpeterCF_EOF
160850276Spetercat >>conftest.adb <<CF_EOF
160950276Speter$2
161050276SpeterCF_EOF
1611166124Srafanif ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
161250276Speter   if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
161350276Speterifelse($3,,      :,[      $3])
161450276Speterifelse($4,,,[   else
161550276Speter      $4])
161650276Speter   fi
161750276Speterifelse($4,,,[else
161850276Speter   $4])
161950276Speterfi
162050276Speterrm -f conftest*
162150276Speter])dnl
162250276Speterdnl ---------------------------------------------------------------------------
1623166124Srafandnl CF_GNAT_VERSION version: 12 updated: 2006/10/14 15:23:15
1624166124Srafandnl ---------------
1625166124Srafandnl Verify version of GNAT.
162650276SpeterAC_DEFUN([CF_GNAT_VERSION],
162750276Speter[
1628166124SrafanAC_MSG_CHECKING(for gnat version)
1629166124Srafancf_gnat_version=`${cf_ada_make-gnatmake} -v 2>&1 | grep '[[0-9]].[[0-9]][[0-9]]*' |\
1630166124Srafan  sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
1631166124SrafanAC_MSG_RESULT($cf_gnat_version)
1632166124Srafan
1633166124Srafancase $cf_gnat_version in
163476726Speter  3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*)
163550276Speter    cf_cv_prog_gnat_correct=yes
163650276Speter    ;;
1637166124Srafan  *) echo Unsupported GNAT version $cf_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
163850276Speter     cf_cv_prog_gnat_correct=no
163950276Speter     ;;
164050276Speteresac
1641166124Srafancase $cf_gnat_version in
1642166124Srafan  3.[[1-9]]*|[[4-9]].*)
164350276Speter      cf_compile_generics=generics
1644166124Srafan      cf_generic_objects="\${GENOBJS}"
164550276Speter      ;;
164650276Speter  *)  cf_compile_generics=
164750276Speter      cf_generic_objects=
164850276Speter      ;;
164950276Speteresac
165050276Speter])
165150276Speterdnl ---------------------------------------------------------------------------
1652166124Srafandnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1653166124Srafandnl -------------
165497049Speterdnl Check if we must define _GNU_SOURCE to get a reasonable value for
165597049Speterdnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
165697049Speterdnl (or misfeature) of glibc2, which breaks portability of many applications,
165797049Speterdnl since it is interwoven with GNU extensions.
165897049Speterdnl
165997049Speterdnl Well, yes we could work around it...
166097049SpeterAC_DEFUN([CF_GNU_SOURCE],
166197049Speter[
166297049SpeterAC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
166397049SpeterAC_TRY_COMPILE([#include <sys/types.h>],[
166497049Speter#ifndef _XOPEN_SOURCE
166597049Spetermake an error
166697049Speter#endif],
166797049Speter	[cf_cv_gnu_source=no],
166897049Speter	[cf_save="$CPPFLAGS"
166997049Speter	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
167097049Speter	 AC_TRY_COMPILE([#include <sys/types.h>],[
167197049Speter#ifdef _XOPEN_SOURCE
167297049Spetermake an error
167397049Speter#endif],
167497049Speter	[cf_cv_gnu_source=no],
167597049Speter	[cf_cv_gnu_source=yes])
167697049Speter	CPPFLAGS="$cf_save"
167797049Speter	])
167897049Speter])
167997049Spetertest "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
168097049Speter])dnl
168197049Speterdnl ---------------------------------------------------------------------------
1682166124Srafandnl CF_GPP_LIBRARY version: 8 updated: 2003/02/02 01:41:46
1683166124Srafandnl --------------
168456639Speterdnl If we're trying to use g++, test if libg++ is installed (a rather common
168556639Speterdnl problem :-).  If we have the compiler but no library, we'll be able to
168656639Speterdnl configure, but won't be able to build the c++ demo program.
168756639SpeterAC_DEFUN([CF_GPP_LIBRARY],
168856639Speter[
168956639Spetercf_cxx_library=unknown
169056639Spetercase $cf_cv_system_name in #(vi
169156639Speteros2*) #(vi
169256639Speter	cf_gpp_libname=gpp
169356639Speter	;;
169456639Speter*)
169556639Speter	cf_gpp_libname=g++
169656639Speter	;;
169756639Speteresac
1698166124Srafanif test "$GXX" = yes; then
169956639Speter	AC_MSG_CHECKING([for lib$cf_gpp_libname])
170056639Speter	cf_save="$LIBS"
170162449Speter	LIBS="$LIBS -l$cf_gpp_libname"
170256639Speter	AC_TRY_LINK([
170356639Speter#include <$cf_gpp_libname/builtin.h>
170456639Speter	],
170562449Speter	[two_arg_error_handler_t foo2 = lib_error_handler],
170656639Speter	[cf_cxx_library=yes
170762449Speter	 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
170856639Speter	 if test "$cf_gpp_libname" = cpp ; then
170956639Speter	    AC_DEFINE(HAVE_GPP_BUILTIN_H)
171056639Speter	 else
171156639Speter	    AC_DEFINE(HAVE_GXX_BUILTIN_H)
171256639Speter	 fi],
171356639Speter	[AC_TRY_LINK([
171456639Speter#include <builtin.h>
171556639Speter	],
171662449Speter	[two_arg_error_handler_t foo2 = lib_error_handler],
171756639Speter	[cf_cxx_library=yes
171862449Speter	 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
171956639Speter	 AC_DEFINE(HAVE_BUILTIN_H)],
172056639Speter	[cf_cxx_library=no])])
172156639Speter	LIBS="$cf_save"
172256639Speter	AC_MSG_RESULT($cf_cxx_library)
172356639Speterfi
172456639Speter])dnl
172556639Speterdnl ---------------------------------------------------------------------------
1726166124Srafandnl CF_GXX_VERSION version: 5 updated: 2005/08/27 09:53:42
1727166124Srafandnl --------------
1728166124Srafandnl Check for version of g++
1729166124SrafanAC_DEFUN([CF_GXX_VERSION],[
1730166124SrafanAC_REQUIRE([AC_PROG_CPP])
1731166124SrafanGXX_VERSION=none
1732166124Srafanif test "$GXX" = yes; then
1733166124Srafan	AC_MSG_CHECKING(version of g++)
1734166124Srafan	GXX_VERSION="`${CXX-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1735166124Srafan	test -z "$GXX_VERSION" && GXX_VERSION=unknown
1736166124Srafan	AC_MSG_RESULT($GXX_VERSION)
1737166124Srafanfi
1738166124Srafan])dnl
1739166124Srafandnl ---------------------------------------------------------------------------
1740166124Srafandnl CF_GXX_WARNINGS version: 5 updated: 2005/08/13 14:54:38
1741166124Srafandnl ---------------
1742166124Srafandnl Check if the compiler supports useful warning options.
1743166124Srafandnl
1744166124Srafandnl Most of gcc's options apply to g++, except:
1745166124Srafandnl	-Wbad-function-cast
1746166124Srafandnl	-Wmissing-declarations
1747166124Srafandnl	-Wnested-externs
1748166124Srafandnl
1749166124Srafandnl Omit a few (for now):
1750166124Srafandnl	-Winline
1751166124Srafandnl
1752166124Srafandnl Parameter:
1753166124Srafandnl	$1 is an optional list of g++ warning flags that a particular
1754166124Srafandnl		application might want to use, e.g., "no-unused" for
1755166124Srafandnl		-Wno-unused
1756166124Srafandnl Special:
1757166124Srafandnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
1758166124Srafandnl
1759166124SrafanAC_DEFUN([CF_GXX_WARNINGS],
1760166124Srafan[
1761166124Srafan
1762166124SrafanCF_INTEL_COMPILER(GXX,INTEL_CPLUSPLUS,CXXFLAGS)
1763166124Srafan
1764166124SrafanAC_REQUIRE([CF_GXX_VERSION])
1765166124Srafan
1766166124SrafanAC_LANG_SAVE
1767166124SrafanAC_LANG_CPLUSPLUS
1768166124Srafan
1769166124Srafancat > conftest.$ac_ext <<EOF
1770166124Srafan#line __oline__ "configure"
1771166124Srafanint main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1772166124SrafanEOF
1773166124Srafan
1774166124Srafanif test "$INTEL_CPLUSPLUS" = yes
1775166124Srafanthen
1776166124Srafan# The "-wdXXX" options suppress warnings:
1777166124Srafan# remark #1419: external declaration in primary source file
1778166124Srafan# remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1779166124Srafan# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1780166124Srafan# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1781166124Srafan# remark #193: zero used for undefined preprocessing identifier
1782166124Srafan# remark #593: variable "curs_sb_left_arrow" was set but never used
1783166124Srafan# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1784166124Srafan# remark #869: parameter "tw" was never referenced
1785166124Srafan# remark #981: operands are evaluated in unspecified order
1786166124Srafan# warning #269: invalid format string conversion
1787166124Srafan
1788166124Srafan	AC_CHECKING([for $CC warning options])
1789166124Srafan	cf_save_CXXFLAGS="$CXXFLAGS"
1790166124Srafan	EXTRA_CXXFLAGS="-Wall"
1791166124Srafan	for cf_opt in \
1792166124Srafan		wd1419 \
1793166124Srafan		wd1682 \
1794166124Srafan		wd1683 \
1795166124Srafan		wd1684 \
1796166124Srafan		wd193 \
1797166124Srafan		wd279 \
1798166124Srafan		wd593 \
1799166124Srafan		wd810 \
1800166124Srafan		wd869 \
1801166124Srafan		wd981
1802166124Srafan	do
1803166124Srafan		CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt"
1804166124Srafan		if AC_TRY_EVAL(ac_compile); then
1805166124Srafan			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1806166124Srafan			EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
1807166124Srafan		fi
1808166124Srafan	done
1809166124Srafan	CXXFLAGS="$cf_save_CXXFLAGS"
1810166124Srafan
1811166124Srafanelif test "$GXX" = yes
1812166124Srafanthen
1813166124Srafan	AC_CHECKING([for $CXX warning options])
1814166124Srafan	cf_save_CXXFLAGS="$CXXFLAGS"
1815166124Srafan	EXTRA_CXXFLAGS="-W -Wall"
1816166124Srafan	cf_gxx_extra_warnings=""
1817166124Srafan	test "$with_ext_const" = yes && cf_gxx_extra_warnings="Wwrite-strings"
1818166124Srafan	case "$GCC_VERSION" in
1819166124Srafan	[[1-2]].*)
1820166124Srafan		;;
1821166124Srafan	*)
1822166124Srafan		cf_gxx_extra_warnings="$cf_gxx_extra_warnings Weffc++"
1823166124Srafan		;;
1824166124Srafan	esac
1825166124Srafan	for cf_opt in \
1826166124Srafan		Wabi \
1827166124Srafan		fabi-version=0 \
1828166124Srafan		Woverloaded-virtual \
1829166124Srafan		Wsign-promo \
1830166124Srafan		Wsynth \
1831166124Srafan		Wold-style-cast \
1832166124Srafan		Wcast-align \
1833166124Srafan		Wcast-qual \
1834166124Srafan		Wmissing-prototypes \
1835166124Srafan		Wpointer-arith \
1836166124Srafan		Wshadow \
1837166124Srafan		Wstrict-prototypes \
1838166124Srafan		Wundef $cf_gxx_extra_warnings $1
1839166124Srafan	do
1840166124Srafan		CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
1841166124Srafan		if AC_TRY_EVAL(ac_compile); then
1842166124Srafan			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1843166124Srafan			EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
1844166124Srafan		else
1845166124Srafan			test -n "$verbose" && AC_MSG_RESULT(... no -$cf_opt)
1846166124Srafan		fi
1847166124Srafan	done
1848166124Srafan	CXXFLAGS="$cf_save_CXXFLAGS"
1849166124Srafanfi
1850166124Srafan
1851166124Srafanrm -f conftest*
1852166124SrafanAC_LANG_RESTORE
1853166124SrafanAC_SUBST(EXTRA_CXXFLAGS)
1854166124Srafan])dnl
1855166124Srafandnl ---------------------------------------------------------------------------
1856174993Srafandnl CF_HASHED_DB version: 3 updated: 2007/11/24 17:43:37
1857166124Srafandnl ------------
1858166124Srafandnl Look for an instance of the Berkeley hashed database.
1859174993Srafandnl
1860174993Srafandnl $1 = optional parameter, to specify install-prefix for the database.
1861166124SrafanAC_DEFUN([CF_HASHED_DB],
1862166124Srafan[
1863174993Srafanifelse([$1],,,[
1864174993Srafancase $1 in #(vi
1865174993Srafanyes|*able*) #(vi
1866174993Srafan    ;;
1867174993Srafan*)
1868174993Srafan    if test -d "$1" ; then
1869174993Srafan        CF_ADD_INCDIR($1/include)
1870174993Srafan        CF_ADD_LIBDIR($1/lib)
1871174993Srafan    fi
1872174993Srafanesac
1873174993Srafan])
1874166124SrafanAC_CHECK_HEADER(db.h,[
1875166124SrafanCF_HASHED_DB_VERSION
1876166124Srafanif test "$cf_cv_hashed_db_version" = unknown ; then
1877166124Srafan	AC_MSG_ERROR(Cannot determine version of db)
1878166124Srafanelse
1879166124Srafan	CF_HASHED_DB_LIBS
1880166124Srafan	if test "$cf_cv_hashed_db_libs" = unknown ; then
1881166124Srafan		AC_MSG_ERROR(Cannot determine library for db)
1882166124Srafan	elif test "$cf_cv_hashed_db_libs" != default ; then
1883166124Srafan		LIBS="-l$cf_cv_hashed_db_libs $LIBS"
1884166124Srafan	fi
1885166124Srafanfi
1886166124Srafan],[
1887166124Srafan	AC_MSG_ERROR(Cannot find db.h)
1888166124Srafan])
1889166124Srafan])dnl
1890166124Srafandnl ---------------------------------------------------------------------------
1891184989Srafandnl CF_HASHED_DB_LIBS version: 8 updated: 2008/08/04 06:18:06
1892166124Srafandnl -----------------
1893166124Srafandnl Given that we have the header and version for hashed database, find the
1894166124Srafandnl library information.
1895166124SrafanAC_DEFUN([CF_HASHED_DB_LIBS],
1896166124Srafan[
1897166124SrafanAC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
1898166124Srafancf_cv_hashed_db_libs=unknown
1899184989Srafanfor cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
1900166124Srafando
1901166124Srafan	cf_save_libs="$LIBS"
1902166124Srafan	if test -n "$cf_db_libs"; then
1903166124Srafan		LIBS="-l$cf_db_libs $LIBS"
1904166124Srafan	fi
1905166124Srafan	CF_MSG_LOG(checking for library "$cf_db_libs")
1906166124Srafan	AC_TRY_LINK([
1907166124Srafan$ac_includes_default
1908166124Srafan#include <db.h>
1909166124Srafan],[
1910166124Srafan	char *path = "/tmp/foo";
1911166124Srafan#ifdef DB_VERSION_MAJOR
1912166124Srafan#if DB_VERSION_MAJOR >= 4
1913166124Srafan	DB *result = 0;
1914166124Srafan	db_create(&result, NULL, 0);
1915166124Srafan	result->open(result,
1916166124Srafan		NULL,
1917166124Srafan		path,
1918166124Srafan		path,
1919166124Srafan		DB_HASH,
1920166124Srafan		DB_CREATE,
1921166124Srafan		0644);
1922166124Srafan#elif DB_VERSION_MAJOR >= 3
1923166124Srafan	DB *result = 0;
1924166124Srafan	db_create(&result, NULL, 0);
1925166124Srafan	result->open(result,
1926166124Srafan		path,
1927166124Srafan		path,
1928166124Srafan		DB_HASH,
1929166124Srafan		DB_CREATE,
1930166124Srafan		0644);
1931166124Srafan#elif DB_VERSION_MAJOR >= 2
1932166124Srafan	DB *result = 0;
1933166124Srafan	db_open(path,
1934166124Srafan		DB_HASH,
1935166124Srafan		DB_CREATE,
1936166124Srafan		0644,
1937166124Srafan		(DB_ENV *) 0,
1938166124Srafan		(DB_INFO *) 0,
1939166124Srafan		&result);
1940166124Srafan#endif /* DB_VERSION_MAJOR */
1941166124Srafan#else
1942166124Srafan	DB *result = dbopen(path,
1943166124Srafan		     2,
1944166124Srafan		     0644,
1945166124Srafan		     DB_HASH,
1946166124Srafan		     0);
1947166124Srafan#endif
1948166124Srafan	${cf_cv_main_return:-return}(result != 0)
1949166124Srafan],[
1950166124Srafan	if test -n "$cf_db_libs" ; then
1951166124Srafan		cf_cv_hashed_db_libs=$cf_db_libs
1952166124Srafan	else
1953166124Srafan		cf_cv_hashed_db_libs=default
1954166124Srafan	fi
1955166124Srafan	LIBS="$cf_save_libs"
1956166124Srafan	break
1957166124Srafan])
1958166124Srafan	LIBS="$cf_save_libs"
1959166124Srafandone
1960166124Srafan])
1961166124Srafan])dnl
1962166124Srafandnl ---------------------------------------------------------------------------
1963174993Srafandnl CF_HASHED_DB_VERSION version: 3 updated: 2007/12/01 15:01:37
1964166124Srafandnl --------------------
1965166124Srafandnl Given that we have the header file for hashed database, find the version
1966166124Srafandnl information.
1967166124SrafanAC_DEFUN([CF_HASHED_DB_VERSION],
1968166124Srafan[
1969166124SrafanAC_CACHE_CHECK(for version of db, cf_cv_hashed_db_version,[
1970166124Srafancf_cv_hashed_db_version=unknown
1971166124Srafan
1972174993Srafanfor cf_db_version in 1 2 3 4 5
1973166124Srafando
1974166124Srafan	CF_MSG_LOG(checking for db version $cf_db_version)
1975166124Srafan	AC_TRY_COMPILE([
1976166124Srafan$ac_includes_default
1977166124Srafan#include <db.h>
1978166124Srafan
1979166124Srafan#ifdef DB_VERSION_MAJOR
1980166124Srafan	/* db2 (DB_VERSION_MAJOR=2) has also DB_VERSION_MINOR, tested with 7 */
1981166124Srafan#if $cf_db_version == DB_VERSION_MAJOR
1982166124Srafan	/* ok */
1983166124Srafan#else
1984166124Srafan	make an error
1985166124Srafan#endif
1986166124Srafan#else
1987166124Srafan#if $cf_db_version == 1
1988166124Srafan	/* ok: assuming this is DB 1.8.5 */
1989166124Srafan#else
1990166124Srafan	make an error
1991166124Srafan#endif
1992166124Srafan#endif
1993166124Srafan],[DBT *foo = 0],[
1994166124Srafan	cf_cv_hashed_db_version=$cf_db_version
1995166124Srafan	break
1996166124Srafan	])
1997166124Srafandone
1998166124Srafan])
1999166124Srafan])dnl
2000166124Srafandnl ---------------------------------------------------------------------------
2001184989Srafandnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
2002184989Srafandnl --------------
2003184989Srafandnl Construct a search-list for a nonstandard header-file
2004184989SrafanAC_DEFUN([CF_HEADER_PATH],
2005184989Srafan[CF_SUBDIR_PATH($1,$2,include)
2006184989Srafantest "$includedir" != NONE && \
2007184989Srafantest "$includedir" != "/usr/include" && \
2008184989Srafantest -d "$includedir" && {
2009184989Srafan	test -d $includedir &&    $1="[$]$1 $includedir"
2010184989Srafan	test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
2011184989Srafan}
2012184989Srafan
2013184989Srafantest "$oldincludedir" != NONE && \
2014184989Srafantest "$oldincludedir" != "/usr/include" && \
2015184989Srafantest -d "$oldincludedir" && {
2016184989Srafan	test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
2017184989Srafan	test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
2018184989Srafan}
2019184989Srafan
2020184989Srafan])dnl
2021184989Srafandnl ---------------------------------------------------------------------------
2022166124Srafandnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
2023166124Srafandnl ---------------
202450276Speterdnl Insert text into the help-message, for readability, from AC_ARG_WITH.
202550276SpeterAC_DEFUN([CF_HELP_MESSAGE],
202650276Speter[AC_DIVERT_HELP([$1])dnl
202750276Speter])dnl
202850276Speterdnl ---------------------------------------------------------------------------
2029166124Srafandnl CF_INCLUDE_DIRS version: 5 updated: 2006/10/14 15:23:15
2030166124Srafandnl ---------------
203150276Speterdnl Construct the list of include-options according to whether we're building
203250276Speterdnl in the source directory or using '--srcdir=DIR' option.  If we're building
203350276Speterdnl with gcc, don't append the includedir if it happens to be /usr/include,
203450276Speterdnl since that usually breaks gcc's shadow-includes.
203550276SpeterAC_DEFUN([CF_INCLUDE_DIRS],
203650276Speter[
2037166124SrafanCPPFLAGS="-I. -I../include $CPPFLAGS"
203850276Speterif test "$srcdir" != "."; then
2039166124Srafan	CPPFLAGS="-I\${srcdir}/../include $CPPFLAGS"
204050276Speterfi
204166963Speterif test "$GCC" != yes; then
2042166124Srafan	CPPFLAGS="$CPPFLAGS -I\${includedir}"
204350276Speterelif test "$includedir" != "/usr/include"; then
204450276Speter	if test "$includedir" = '${prefix}/include' ; then
204550276Speter		if test $prefix != /usr ; then
2046166124Srafan			CPPFLAGS="$CPPFLAGS -I\${includedir}"
204750276Speter		fi
204850276Speter	else
2049166124Srafan		CPPFLAGS="$CPPFLAGS -I\${includedir}"
205050276Speter	fi
205150276Speterfi
205250276SpeterAC_SUBST(CPPFLAGS)
205350276Speter])dnl
205450276Speterdnl ---------------------------------------------------------------------------
2055166124Srafandnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
2056166124Srafandnl -----------------
2057166124Srafandnl Check if the given compiler is really the Intel compiler for Linux.  It
2058166124Srafandnl tries to imitate gcc, but does not return an error when it finds a mismatch
2059166124Srafandnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2060166124Srafandnl
2061166124Srafandnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2062166124Srafandnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2063166124Srafandnl the wrappers for gcc and g++ warnings.
2064166124Srafandnl
2065166124Srafandnl $1 = GCC (default) or GXX
2066166124Srafandnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2067166124Srafandnl $3 = CFLAGS (default) or CXXFLAGS
2068166124SrafanAC_DEFUN([CF_INTEL_COMPILER],[
2069166124Srafanifelse($2,,INTEL_COMPILER,[$2])=no
2070166124Srafan
2071166124Srafanif test "$ifelse($1,,[$1],GCC)" = yes ; then
2072166124Srafan	case $host_os in
2073166124Srafan	linux*|gnu*)
2074166124Srafan		AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
2075166124Srafan		cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
2076166124Srafan		ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
2077166124Srafan		AC_TRY_COMPILE([],[
2078166124Srafan#ifdef __INTEL_COMPILER
2079166124Srafan#else
2080166124Srafanmake an error
2081166124Srafan#endif
2082166124Srafan],[ifelse($2,,INTEL_COMPILER,[$2])=yes
2083166124Srafancf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
2084166124Srafan],[])
2085166124Srafan		ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
2086166124Srafan		AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
2087166124Srafan		;;
2088166124Srafan	esac
2089166124Srafanfi
2090166124Srafan])dnl
2091166124Srafandnl ---------------------------------------------------------------------------
2092166124Srafandnl CF_ISASCII version: 3 updated: 2000/08/12 23:18:52
2093166124Srafandnl ----------
209450276Speterdnl Check if we have either a function or macro for 'isascii()'.
209550276SpeterAC_DEFUN([CF_ISASCII],
209650276Speter[
209750276SpeterAC_MSG_CHECKING(for isascii)
209850276SpeterAC_CACHE_VAL(cf_cv_have_isascii,[
209950276Speter	AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
210050276Speter	[cf_cv_have_isascii=yes],
210150276Speter	[cf_cv_have_isascii=no])
210250276Speter])dnl
210350276SpeterAC_MSG_RESULT($cf_cv_have_isascii)
210466963Spetertest "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII)
210550276Speter])dnl
210650276Speterdnl ---------------------------------------------------------------------------
2107174993Srafandnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
2108166124Srafandnl ------------
2109166124Srafandnl Add checks for large file support.
2110166124SrafanAC_DEFUN([CF_LARGEFILE],[
2111166124Srafanifdef([AC_FUNC_FSEEKO],[
2112166124Srafan    AC_SYS_LARGEFILE
2113166124Srafan    if test "$enable_largefile" != no ; then
2114166124Srafan	AC_FUNC_FSEEKO
2115166124Srafan
2116166124Srafan	# Normally we would collect these definitions in the config.h,
2117166124Srafan	# but (like _XOPEN_SOURCE), some environments rely on having these
2118166124Srafan	# defined before any of the system headers are included.  Another
2119166124Srafan	# case comes up with C++, e.g., on AIX the compiler compiles the
2120166124Srafan	# header files by themselves before looking at the body files it is
2121166124Srafan	# told to compile.  For ncurses, those header files do not include
2122166124Srafan	# the config.h
2123166124Srafan	test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
2124166124Srafan	test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
2125174993Srafan	test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
2126166124Srafan
2127166124Srafan	AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
2128166124Srafan		AC_TRY_COMPILE([
2129166124Srafan#include <sys/types.h>
2130166124Srafan#include <dirent.h>
2131166124Srafan		],[
2132166124Srafan		/* if transitional largefile support is setup, this is true */
2133166124Srafan		extern struct dirent64 * readdir(DIR *);
2134166124Srafan		struct dirent64 *x = readdir((DIR *)0);
2135166124Srafan		struct dirent *y = readdir((DIR *)0);
2136166124Srafan		int z = x - y;
2137166124Srafan		],
2138166124Srafan		[cf_cv_struct_dirent64=yes],
2139166124Srafan		[cf_cv_struct_dirent64=no])
2140166124Srafan	])
2141166124Srafan	test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
2142166124Srafan    fi
2143166124Srafan])
2144166124Srafan])
2145166124Srafandnl ---------------------------------------------------------------------------
2146184989Srafandnl CF_LDFLAGS_STATIC version: 4 updated: 2008/10/18 17:58:20
2147174993Srafandnl -----------------
2148174993Srafandnl Check for compiler/linker flags used to temporarily force usage of static
2149174993Srafandnl libraries.  This depends on the compiler and platform.  Use this to help
2150174993Srafandnl ensure that the linker picks up a given library based on its position in
2151174993Srafandnl the list of linker options and libraries.
2152174993SrafanAC_DEFUN([CF_LDFLAGS_STATIC],[
2153174993Srafan
2154174993Srafanif test "$GCC" = yes ; then
2155184989Srafan	case $cf_cv_system_name in #(
2156184989Srafan	OS/2*|os2*|aix[[45]]*) 	#( vi
2157184989Srafan		LDFLAGS_STATIC=
2158184989Srafan		LDFLAGS_SHARED=
2159184989Srafan		;;
2160184989Srafan    *) 	#( normally, except when broken
2161184989Srafan        LDFLAGS_STATIC=-static
2162184989Srafan        LDFLAGS_SHARED=-dynamic
2163184989Srafan        ;;
2164184989Srafan    esac
2165174993Srafanelse
2166174993Srafan	case $cf_cv_system_name in #(
2167174993Srafan	aix[[45]]*) 	#( from ld manpage
2168174993Srafan		LDFLAGS_STATIC=-bstatic
2169174993Srafan		LDFLAGS_SHARED=-bdynamic
2170174993Srafan		;;
2171174993Srafan	hpux*)		#( from ld manpage for hpux10.20, hpux11.11
2172174993Srafan		# We could also use just "archive" and "shared".
2173174993Srafan		LDFLAGS_STATIC=-Wl,-a,archive_shared
2174174993Srafan		LDFLAGS_SHARED=-Wl,-a,shared_archive
2175174993Srafan		;;
2176174993Srafan	irix*)		#( from ld manpage IRIX64
2177174993Srafan		LDFLAGS_STATIC=-Bstatic
2178174993Srafan		LDFLAGS_SHARED=-Bdynamic
2179174993Srafan		;;
2180174993Srafan	osf[[45]]*)	#( from ld manpage osf4.0d, osf5.1
2181174993Srafan		# alternative "-oldstyle_liblookup" (not in cc manpage)
2182174993Srafan		LDFLAGS_STATIC=-noso 
2183174993Srafan		LDFLAGS_SHARED=-so_archive
2184174993Srafan		;;
2185174993Srafan	solaris2*)
2186174993Srafan		LDFLAGS_STATIC=-Bstatic
2187174993Srafan		LDFLAGS_SHARED=-Bdynamic
2188174993Srafan		;;
2189174993Srafan	esac
2190174993Srafanfi
2191174993Srafan
2192174993SrafanAC_SUBST(LDFLAGS_STATIC)
2193174993SrafanAC_SUBST(LDFLAGS_SHARED)
2194174993Srafan])
2195174993Srafandnl ---------------------------------------------------------------------------
2196184989Srafandnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
2197184989Srafandnl ---------------
2198184989Srafandnl Construct a search-list for a nonstandard library-file
2199184989SrafanAC_DEFUN([CF_LIBRARY_PATH],
2200184989Srafan[CF_SUBDIR_PATH($1,$2,lib)])dnl
220197049Speterdnl ---------------------------------------------------------------------------
2202184989Srafandnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16
2203166124Srafandnl -------------
220450276Speterdnl Compute the library-prefix for the given host system
220550276Speterdnl $1 = variable to set
220650276SpeterAC_DEFUN([CF_LIB_PREFIX],
220750276Speter[
2208184989Srafan	case $cf_cv_system_name in #(vi
2209184989Srafan	OS/2*|os2*) #(vi
2210184989Srafan        LIB_PREFIX=''
2211184989Srafan        ;;
2212184989Srafan	*)	LIB_PREFIX='lib'
2213184989Srafan        ;;
221450276Speter	esac
221562449Speterifelse($1,,,[$1=$LIB_PREFIX])
221656639Speter	AC_SUBST(LIB_PREFIX)
221750276Speter])dnl
221850276Speterdnl ---------------------------------------------------------------------------
2219184989Srafandnl CF_LIB_RULES version: 53 updated: 2008/09/20 19:51:59
2220166124Srafandnl ------------
222150276Speterdnl Append definitions and rules for the given models to the subdirectory
222250276Speterdnl Makefiles, and the recursion rule for the top-level Makefile.  If the
2223174993Srafandnl subdirectory is a library-source directory, modify the LIBS_TO_MAKE list in
222450276Speterdnl the corresponding makefile to list the models that we'll generate.
222550276Speterdnl
222650276Speterdnl For shared libraries, make a list of symbolic links to construct when
222750276Speterdnl generating each library.  The convention used for Linux is the simplest
222850276Speterdnl one:
222950276Speterdnl	lib<name>.so	->
223050276Speterdnl	lib<name>.so.<major>	->
223150276Speterdnl	lib<name>.so.<maj>.<minor>
223250276SpeterAC_DEFUN([CF_LIB_RULES],
223350276Speter[
223450276SpeterCF_LIB_PREFIX(cf_prefix)
223550276SpeterAC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2236184989Srafan
2237184989Srafanif test $cf_cv_shlib_version = cygdll ; then
2238184989Srafan	TINFO_NAME=$TINFO_ARG_SUFFIX
2239184989Srafan	TINFO_SUFFIX=.dll
2240184989Srafanfi
2241184989Srafan
224250276Speterfor cf_dir in $SRC_SUBDIRS
224350276Speterdo
2244166124Srafan	if test ! -d $srcdir/$cf_dir ; then
2245166124Srafan		continue
2246166124Srafan	elif test -f $srcdir/$cf_dir/modules; then
224750276Speter
224897049Speter		SHARED_LIB=
224997049Speter		LIBS_TO_MAKE=
2250166124Srafan		for cf_item in $cf_LIST_MODELS
225150276Speter		do
2252184989Srafan			CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
225366963Speter			if test $cf_item = shared ; then
225466963Speter			if test "$cf_cv_do_symlinks" = yes ; then
225566963Speter				case "$cf_cv_shlib_version" in #(vi
225697049Speter				rel) #(vi
225797049Speter					case "$cf_cv_system_name" in #(vi
2258166124Srafan					darwin*)
2259166124Srafan					case .${LIB_SUFFIX} in
2260166124Srafan					.w*)
2261166124Srafan						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2262166124Srafan						cf_suffix=w'.${REL_VERSION}'"$cf_suffix"
2263166124Srafan						;;
2264166124Srafan					*)
2265166124Srafan						cf_suffix='.${REL_VERSION}'"$cf_suffix"
2266166124Srafan						;;
226797049Speter					esac
2268166124Srafan					;; #(vi
2269166124Srafan					*) cf_suffix="$cf_suffix"'.${REL_VERSION}' ;;
2270166124Srafan					esac
227197049Speter					;;
227297049Speter				abi)
227397049Speter					case "$cf_cv_system_name" in #(vi
2274166124Srafan					darwin*)
2275166124Srafan					case .${LIB_SUFFIX} in
2276166124Srafan					.w*)
2277166124Srafan						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2278166124Srafan						cf_suffix=w'.${ABI_VERSION}'"$cf_suffix"
2279166124Srafan						;;
2280166124Srafan					*)
2281166124Srafan						cf_suffix='.${ABI_VERSION}'"$cf_suffix"
2282166124Srafan						;;
228397049Speter					esac
2284166124Srafan					;; #(vi
2285166124Srafan					*) cf_suffix="$cf_suffix"'.${ABI_VERSION}' ;;
2286166124Srafan					esac
228797049Speter					;;
228866963Speter				esac
228966963Speter			fi
229097049Speter			# cygwin needs import library, and has unique naming convention
2291166124Srafan			# use autodetected ${cf_prefix} for import lib and static lib, but
2292166124Srafan			# use 'cyg' prefix for shared lib.
229397049Speter			if test $cf_cv_shlib_version = cygdll ; then
2294184989Srafan				cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
2295184989Srafan				LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/cyg${cf_dir}${cf_cygsuf}"
229697049Speter				continue
229766963Speter			fi
229897049Speter			fi
229997049Speter			LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
230050276Speter		done
230150276Speter
230250276Speter		if test $cf_dir = ncurses ; then
230397049Speter			cf_subsets="$LIB_SUBSETS"
2304174993Srafan			cf_r_parts="$cf_subsets"
2305184989Srafan			cf_liblist="$LIBS_TO_MAKE"
2306174993Srafan
2307174993Srafan			while test -n "$cf_r_parts"
2308174993Srafan			do
2309174993Srafan				cf_l_parts=`echo "$cf_r_parts" |sed -e 's/ .*$//'`
2310174993Srafan				cf_r_parts=`echo "$cf_r_parts" |sed -e 's/^[[^ ]]* //'`
2311174993Srafan				if test "$cf_l_parts" != "$cf_r_parts" ; then
2312184989Srafan					cf_item=
2313174993Srafan					case $cf_l_parts in #(vi
2314174993Srafan					*termlib*) #(vi
2315184989Srafan						cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
2316174993Srafan						;;
2317174993Srafan					*ticlib*)
2318184989Srafan						cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TICS_LIB_SUFFIX}%g`
2319174993Srafan						;;
2320174993Srafan					*)
2321174993Srafan						break
2322174993Srafan						;;
2323174993Srafan					esac
2324184989Srafan					if test -n "$cf_item"; then
2325184989Srafan						LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
2326184989Srafan					fi
2327174993Srafan				else
2328174993Srafan					break
2329174993Srafan				fi
2330174993Srafan			done
233197049Speter		else
2332166124Srafan			cf_subsets=`echo "$LIB_SUBSETS" | sed -e 's/^termlib.* //'`
233350276Speter		fi
233450276Speter
2335166124Srafan		sed -e "s%@LIBS_TO_MAKE@%$LIBS_TO_MAKE%" \
2336166124Srafan		    -e "s%@SHARED_LIB@%$SHARED_LIB%" \
233750276Speter			$cf_dir/Makefile >$cf_dir/Makefile.out
233850276Speter		mv $cf_dir/Makefile.out $cf_dir/Makefile
233950276Speter
234050276Speter		$AWK -f $srcdir/mk-0th.awk \
234197049Speter			libname="${cf_dir}${LIB_SUFFIX}" subsets="$LIB_SUBSETS" \
234250276Speter			$srcdir/$cf_dir/modules >>$cf_dir/Makefile
234350276Speter
234497049Speter		for cf_subset in $cf_subsets
234550276Speter		do
234697049Speter			cf_subdirs=
2347166124Srafan			for cf_item in $cf_LIST_MODELS
234897049Speter			do
234997049Speter			echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})"
2350166124Srafan			CF_UPPER(cf_ITEM,$cf_item)
2351184989Srafan			CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
235250276Speter			CF_OBJ_SUBDIR($cf_item,cf_subdir)
235350276Speter
2354166124Srafan			# Test for case where we build libtinfo with a different name.
2355166124Srafan			cf_libname=$cf_dir
2356166124Srafan			if test $cf_dir = ncurses ; then
2357166124Srafan				case $cf_subset in
2358166124Srafan				*base*)
2359184989Srafan					cf_libname=${cf_libname}$LIB_SUFFIX
2360166124Srafan					;;
2361174993Srafan				*termlib*)
2362166124Srafan					cf_libname=$TINFO_LIB_SUFFIX
2363174993Srafan					;;
2364174993Srafan				ticlib*)
2365174993Srafan					cf_libname=$TICS_LIB_SUFFIX
2366174993Srafan					;;
2367166124Srafan				esac
2368184989Srafan			else
2369184989Srafan				cf_libname=${cf_libname}$LIB_SUFFIX
2370166124Srafan			fi
2371184989Srafan			if test -n "${DFT_ARG_SUFFIX}" ; then
2372184989Srafan				# undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
2373184989Srafan				cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
2374184989Srafan			fi
2375166124Srafan
237650276Speter			# These dependencies really are for development, not
237750276Speter			# builds, but they are useful in porting, too.
237850276Speter			cf_depend="../include/ncurses_cfg.h"
237950276Speter			if test "$srcdir" = "."; then
238050276Speter				cf_reldir="."
238150276Speter			else
2382166124Srafan				cf_reldir="\${srcdir}"
238350276Speter			fi
238450276Speter
238550276Speter			if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
238650276Speter				cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
238750276Speter			elif test -f $srcdir/$cf_dir/curses.priv.h; then
238850276Speter				cf_depend="$cf_depend $cf_reldir/curses.priv.h"
238950276Speter			fi
239050276Speter
2391166124Srafan 			cf_dir_suffix=
2392166124Srafan 			old_cf_suffix="$cf_suffix"
2393166124Srafan 			if test "$cf_cv_shlib_version_infix" = yes ; then
2394166124Srafan			if test -n "$LIB_SUFFIX" ; then
2395166124Srafan				case $LIB_SUFFIX in
2396166124Srafan				w*)
2397166124Srafan					cf_libname=`echo $cf_libname | sed 's/w$//'`
2398166124Srafan					cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2399166124Srafan					cf_dir_suffix=w
2400166124Srafan					;;
2401166124Srafan				esac
2402166124Srafan			fi
2403166124Srafan 			fi
2404166124Srafan
240550276Speter			$AWK -f $srcdir/mk-1st.awk \
2406166124Srafan				name=${cf_libname}${cf_dir_suffix} \
240762449Speter				traces=$LIB_TRACING \
2408166124Srafan				MODEL=$cf_ITEM \
240950276Speter				model=$cf_subdir \
241050276Speter				prefix=$cf_prefix \
241150276Speter				suffix=$cf_suffix \
241250276Speter				subset=$cf_subset \
2413174993Srafan				TermlibRoot=$TINFO_NAME \
2414174993Srafan				TermlibSuffix=$TINFO_SUFFIX \
241566963Speter				ShlibVer=$cf_cv_shlib_version \
241697049Speter				ShlibVerInfix=$cf_cv_shlib_version_infix \
2417174993Srafan				ReLink=${cf_cv_do_relink-no} \
241850276Speter				DoLinks=$cf_cv_do_symlinks \
241950276Speter				rmSoLocs=$cf_cv_rm_so_locs \
242050276Speter				ldconfig="$LDCONFIG" \
242150276Speter				overwrite=$WITH_OVERWRITE \
242250276Speter				depend="$cf_depend" \
2423166124Srafan				host="$host" \
242450276Speter				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
2425166124Srafan
2426166124Srafan			cf_suffix="$old_cf_suffix"
2427166124Srafan
242897049Speter			for cf_subdir2 in $cf_subdirs lib
242997049Speter			do
243097049Speter				test $cf_subdir = $cf_subdir2 && break
243197049Speter			done
243297049Speter			test "${cf_subset}.${cf_subdir2}" != "${cf_subset}.${cf_subdir}" && \
243350276Speter			$AWK -f $srcdir/mk-2nd.awk \
243450276Speter				name=$cf_dir \
243562449Speter				traces=$LIB_TRACING \
2436166124Srafan				MODEL=$cf_ITEM \
243750276Speter				model=$cf_subdir \
243850276Speter				subset=$cf_subset \
243950276Speter				srcdir=$srcdir \
244050276Speter				echo=$WITH_ECHO \
2441166124Srafan				crenames=$cf_cv_prog_CC_c_o \
2442166124Srafan				cxxrenames=$cf_cv_prog_CXX_c_o \
244350276Speter				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
244497049Speter			cf_subdirs="$cf_subdirs $cf_subdir"
244550276Speter			done
244650276Speter		done
244750276Speter	fi
244850276Speter
2449166124Srafan	echo '	cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >>Makefile
245050276Speterdone
245150276Speter
245250276Speterfor cf_dir in $SRC_SUBDIRS
245350276Speterdo
2454166124Srafan	if test ! -d $srcdir/$cf_dir ; then
2455166124Srafan		continue
2456166124Srafan	fi
2457166124Srafan
245850276Speter	if test -f $cf_dir/Makefile ; then
245950276Speter		case "$cf_dir" in
246050276Speter		Ada95) #(vi
246162449Speter			echo 'libs \' >> Makefile
246250276Speter			echo 'install.libs \' >> Makefile
246350276Speter			echo 'uninstall.libs ::' >> Makefile
2464166124Srafan			echo '	cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >> Makefile
246550276Speter			;;
246650276Speter		esac
246750276Speter	fi
246850276Speter
246950276Speter	if test -f $srcdir/$cf_dir/modules; then
247050276Speter		echo >> Makefile
247150276Speter		if test -f $srcdir/$cf_dir/headers; then
247250276Spetercat >> Makefile <<CF_EOF
247350276Speterinstall.includes \\
247450276Speteruninstall.includes \\
247550276SpeterCF_EOF
247650276Speter		fi
247750276Speterif test "$cf_dir" != "c++" ; then
247850276Speterecho 'lint \' >> Makefile
247950276Speterfi
248050276Spetercat >> Makefile <<CF_EOF
248162449Speterlibs \\
248250276Speterlintlib \\
248350276Speterinstall.libs \\
248450276Speteruninstall.libs \\
248550276Speterinstall.$cf_dir \\
248650276Speteruninstall.$cf_dir ::
2487166124Srafan	cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
248850276SpeterCF_EOF
248950276Speter	elif test -f $srcdir/$cf_dir/headers; then
249050276Spetercat >> Makefile <<CF_EOF
249150276Speter
249262449Speterlibs \\
249350276Speterinstall.libs \\
249450276Speteruninstall.libs \\
249550276Speterinstall.includes \\
249650276Speteruninstall.includes ::
2497166124Srafan	cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
249850276SpeterCF_EOF
249950276Speterfi
250050276Speterdone
250150276Speter
250250276Spetercat >> Makefile <<CF_EOF
250350276Speter
2504174993Srafaninstall.libs uninstall.libs \\
2505174993Srafaninstall.data uninstall.data ::
2506166124Srafan$MAKE_TERMINFO	cd misc && \${MAKE} \${CF_MFLAGS} \[$]@
250750276Speter
250897049Speterinstall.man \\
250956639Speteruninstall.man ::
2510166124Srafan	cd man && \${MAKE} \${CF_MFLAGS} \[$]@
251150276Speter
251250276Speterdistclean ::
251350276Speter	rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
2514174993Srafan	rm -f headers.sh headers.sed mk_shared_lib.sh
2515166124Srafan	rm -rf \${DIRS_TO_MAKE}
251650276SpeterCF_EOF
251750276Speter
251866963Speter# Special case: tack's manpage lives in its own directory.
251966963Speterif test -d tack ; then
252066963Speterif test -f $srcdir/$tack.h; then
252166963Spetercat >> Makefile <<CF_EOF
252266963Speter
252397049Speterinstall.man \\
252466963Speteruninstall.man ::
2525166124Srafan	cd tack && \${MAKE} \${CF_MFLAGS} \[$]@
252666963SpeterCF_EOF
252766963Speterfi
252866963Speterfi
252966963Speter
253050276Speterdnl If we're installing into a subdirectory of /usr/include, etc., we should
253150276Speterdnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
253250276Speterdnl anything, and will make it more standardized.  It's awkward to decide this
253350276Speterdnl at configuration because of quoting, so we'll simply make all headers
253450276Speterdnl installed via a script that can do the right thing.
253550276Speter
253650276Speterrm -f headers.sed headers.sh
253750276Speter
253850276Speterdnl ( generating this script makes the makefiles a little tidier :-)
253950276Speterecho creating headers.sh
254050276Spetercat >headers.sh <<CF_EOF
254150276Speter#! /bin/sh
254250276Speter# This shell script is generated by the 'configure' script.  It is invoked in a
254350276Speter# subdirectory of the build tree.  It generates a sed-script in the parent
254450276Speter# directory that is used to adjust includes for header files that reside in a
254550276Speter# subdirectory of /usr/include, etc.
254650276SpeterPRG=""
254750276Speterwhile test \[$]# != 3
254850276Speterdo
254950276SpeterPRG="\$PRG \[$]1"; shift
255050276Speterdone
255150276SpeterDST=\[$]1
255250276SpeterREF=\[$]2
255350276SpeterSRC=\[$]3
255476726SpeterTMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
255576726SpeterTMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
255650276Speterecho installing \$SRC in \$DST
255776726SpeterCF_EOF
2558166124Srafan
255976726Speterif test $WITH_CURSES_H = yes; then
256076726Speter	cat >>headers.sh <<CF_EOF
256150276Spetercase \$DST in
256250276Speter/*/include/*)
256362449Speter	END=\`basename \$DST\`
256462449Speter	for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
256562449Speter	do
256662449Speter		NAME=\`basename \$i\`
256762449Speter		echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
256862449Speter	done
256950276Speter	;;
257050276Speter*)
257176726Speter	echo "" >> \$TMPSED
257250276Speter	;;
257350276Speteresac
257450276SpeterCF_EOF
2575166124Srafan
257676726Speterelse
257776726Speter	cat >>headers.sh <<CF_EOF
257876726Spetercase \$DST in
257976726Speter/*/include/*)
258076726Speter	END=\`basename \$DST\`
258176726Speter	for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
258276726Speter	do
258376726Speter		NAME=\`basename \$i\`
258476726Speter		if test "\$NAME" = "curses.h"
258576726Speter		then
258676726Speter			echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
258776726Speter			NAME=ncurses.h
258876726Speter		fi
258976726Speter		echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
259076726Speter	done
259176726Speter	;;
259276726Speter*)
259376726Speter	echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
259476726Speter	;;
259576726Speteresac
259676726SpeterCF_EOF
259776726Speterfi
259876726Spetercat >>headers.sh <<CF_EOF
259976726Speterrm -f \$TMPSRC
260076726Spetersed -f \$TMPSED \$SRC > \$TMPSRC
260176726SpeterNAME=\`basename \$SRC\`
260276726SpeterCF_EOF
260376726Speterif test $WITH_CURSES_H != yes; then
260476726Speter	cat >>headers.sh <<CF_EOF
260576726Spetertest "\$NAME" = "curses.h" && NAME=ncurses.h
260676726SpeterCF_EOF
260776726Speterfi
260876726Spetercat >>headers.sh <<CF_EOF
260997049Speter# Just in case someone gzip'd manpages, remove the conflicting copy.
261097049Spetertest -f \$DST/\$NAME.gz && rm -f \$DST/\$NAME.gz
261197049Speter
261276726Spetereval \$PRG \$TMPSRC \$DST/\$NAME
261376726Speterrm -f \$TMPSRC \$TMPSED
261476726SpeterCF_EOF
261550276Speter
261650276Speterchmod 0755 headers.sh
261750276Speter
261850276Speterfor cf_dir in $SRC_SUBDIRS
261950276Speterdo
2620166124Srafan	if test ! -d $srcdir/$cf_dir ; then
2621166124Srafan		continue
2622166124Srafan	fi
2623166124Srafan
262450276Speter	if test -f $srcdir/$cf_dir/headers; then
2625174993Srafan		$AWK -f $srcdir/mk-hdr.awk \
2626174993Srafan			subset="$LIB_SUBSETS" \
2627174993Srafan			compat="$WITH_CURSES_H" \
2628174993Srafan			$srcdir/$cf_dir/headers >>$cf_dir/Makefile
262950276Speter	fi
263097049Speter
263197049Speter	if test -f $srcdir/$cf_dir/modules; then
263297049Speter		if test "$cf_dir" != "c++" ; then
263397049Speter			cat >>$cf_dir/Makefile <<"CF_EOF"
2634166124Srafandepend : ${AUTO_SRC}
2635166124Srafan	makedepend -- ${CPPFLAGS} -- ${C_SRC}
263697049Speter
263797049Speter# DO NOT DELETE THIS LINE -- make depend depends on it.
263897049SpeterCF_EOF
263997049Speter		fi
264097049Speter	fi
264150276Speterdone
264250276Speter
264350276Speter])dnl
264450276Speterdnl ---------------------------------------------------------------------------
2645166124Srafandnl CF_LIB_SONAME version: 3 updated: 2006/12/16 15:55:46
2646166124Srafandnl -------------
2647166124Srafandnl Find the and soname for the given shared library.  Set the cache variable
2648166124Srafandnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
2649166124Srafandnl variable to "unknown".
2650166124Srafandnl
2651166124Srafandnl $1 = headers
2652166124Srafandnl $2 = code
2653166124Srafandnl $3 = library name
2654166124SrafanAC_DEFUN([CF_LIB_SONAME],
2655166124Srafan[
2656166124SrafanAC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
2657166124Srafan
2658166124Srafancf_cv_$3_soname=unknown
2659166124Srafanif test "$cross_compiling" != yes ; then
2660166124Srafancat >conftest.$ac_ext <<CF_EOF
2661166124Srafan$1
2662166124Srafanint main()
2663166124Srafan{
2664166124Srafan$2
2665166124Srafan	${cf_cv_main_return:-return}(0);
2666166124Srafan}
2667166124SrafanCF_EOF
2668166124Srafancf_save_LIBS="$LIBS"
2669166124Srafan	LIBS="-l$3 $LIBS"
2670166124Srafan	if AC_TRY_EVAL(ac_compile) ; then
2671166124Srafan		if AC_TRY_EVAL(ac_link) ; then
2672166124Srafan			cf_cv_$3_soname=`ldd conftest$ac_exeext 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | fgrep lib$3.`
2673166124Srafan			test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
2674166124Srafan		fi
2675166124Srafan	fi
2676166124Srafanrm -f conftest*
2677166124SrafanLIBS="$cf_save_LIBS"
2678166124Srafanfi
2679166124Srafan])
2680166124Srafan])
2681166124Srafandnl ---------------------------------------------------------------------------
2682184989Srafandnl CF_LIB_SUFFIX version: 15 updated: 2008/09/13 11:54:48
2683166124Srafandnl -------------
268462449Speterdnl Compute the library file-suffix from the given model name
268550276Speterdnl $1 = model name
2686184989Srafandnl $2 = variable to set (the nominal library suffix)
2687184989Srafandnl $3 = dependency variable to set (actual filename)
268862449Speterdnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
268950276SpeterAC_DEFUN([CF_LIB_SUFFIX],
269050276Speter[
269150276Speter	AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
269250276Speter	case $1 in
2693184989Srafan	libtool)
2694184989Srafan		$2='.la'
2695184989Srafan		$3=[$]$2
2696184989Srafan		;;
2697184989Srafan	normal)
2698184989Srafan		$2='.a'
2699184989Srafan		$3=[$]$2
2700184989Srafan		;;
2701184989Srafan	debug)
2702184989Srafan		$2='_g.a'
2703184989Srafan		$3=[$]$2
2704184989Srafan		;;
2705184989Srafan	profile)
2706184989Srafan		$2='_p.a'
2707184989Srafan		$3=[$]$2
2708184989Srafan		;;
270950276Speter	shared)
271050276Speter		case $cf_cv_system_name in
2711184989Srafan		cygwin*)
2712184989Srafan			$2='.dll'
2713184989Srafan			$3='.dll.a'
2714184989Srafan			;;
2715184989Srafan		darwin*)
2716184989Srafan			$2='.dylib'
2717184989Srafan			$3=[$]$2
2718184989Srafan			;;
2719166124Srafan		hpux*)
2720166124Srafan			case $target in
2721184989Srafan			ia64*)
2722184989Srafan				$2='.so'
2723184989Srafan				$3=[$]$2
2724184989Srafan				;;
2725184989Srafan			*)
2726184989Srafan				$2='.sl'
2727184989Srafan				$3=[$]$2
2728184989Srafan				;;
2729166124Srafan			esac
2730166124Srafan			;;
2731184989Srafan		*)	$2='.so'
2732184989Srafan			$3=[$]$2
2733184989Srafan			;;
273450276Speter		esac
273550276Speter	esac
273662449Speter	test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
2737184989Srafan	test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}"
273850276Speter])dnl
273950276Speterdnl ---------------------------------------------------------------------------
2740166124Srafandnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
2741166124Srafandnl -----------
274250276Speterdnl Compute the string to append to -library from the given model name
274362449Speterdnl $1 = model name
274462449Speterdnl $2 = variable to set
274562449Speterdnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
274650276SpeterAC_DEFUN([CF_LIB_TYPE],
274750276Speter[
274850276Speter	case $1 in
274976726Speter	libtool) $2=''   ;;
275050276Speter	normal)  $2=''   ;;
275150276Speter	debug)   $2='_g' ;;
275250276Speter	profile) $2='_p' ;;
275350276Speter	shared)  $2=''   ;;
275450276Speter	esac
275562449Speter	test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
275650276Speter])dnl
275750276Speterdnl ---------------------------------------------------------------------------
2758166124Srafandnl CF_LINK_DATAONLY version: 8 updated: 2006/12/16 12:33:30
2759166124Srafandnl ----------------
276050276Speterdnl Some systems have a non-ANSI linker that doesn't pull in modules that have
276150276Speterdnl only data (i.e., no functions), for example NeXT.  On those systems we'll
276250276Speterdnl have to provide wrappers for global tables to ensure they're linked
276350276Speterdnl properly.
276450276SpeterAC_DEFUN([CF_LINK_DATAONLY],
276550276Speter[
276650276SpeterAC_MSG_CHECKING([if data-only library module links])
276750276SpeterAC_CACHE_VAL(cf_cv_link_dataonly,[
276850276Speter	rm -f conftest.a
276950276Speter	cat >conftest.$ac_ext <<EOF
277050276Speter#line __oline__ "configure"
277176726Speterint	testdata[[3]] = { 123, 456, 789 };
277250276SpeterEOF
277350276Speter	if AC_TRY_EVAL(ac_compile) ; then
277450276Speter		mv conftest.o data.o && \
2775166124Srafan		( $AR $AR_OPTS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
277650276Speter	fi
277750276Speter	rm -f conftest.$ac_ext data.o
277850276Speter	cat >conftest.$ac_ext <<EOF
277950276Speter#line __oline__ "configure"
278050276Speterint	testfunc()
278150276Speter{
278250276Speter#if defined(NeXT)
2783166124Srafan	${cf_cv_main_return:-return}(1);	/* I'm told this linker is broken */
278450276Speter#else
278576726Speter	extern int testdata[[3]];
278676726Speter	return testdata[[0]] == 123
278776726Speter	   &&  testdata[[1]] == 456
278876726Speter	   &&  testdata[[2]] == 789;
278950276Speter#endif
279050276Speter}
279150276SpeterEOF
279250276Speter	if AC_TRY_EVAL(ac_compile); then
279350276Speter		mv conftest.o func.o && \
2794166124Srafan		( $AR $AR_OPTS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
279550276Speter	fi
279650276Speter	rm -f conftest.$ac_ext func.o
2797166124Srafan	( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
279850276Speter	cf_saveLIBS="$LIBS"
279950276Speter	LIBS="conftest.a $LIBS"
280050276Speter	AC_TRY_RUN([
280150276Speter	int main()
280250276Speter	{
280350276Speter		extern int testfunc();
2804166124Srafan		${cf_cv_main_return:-return} (!testfunc());
280550276Speter	}
280650276Speter	],
280750276Speter	[cf_cv_link_dataonly=yes],
280850276Speter	[cf_cv_link_dataonly=no],
280950276Speter	[cf_cv_link_dataonly=unknown])
281050276Speter	LIBS="$cf_saveLIBS"
281150276Speter	])
281250276SpeterAC_MSG_RESULT($cf_cv_link_dataonly)
281397049Speter
281497049Speterif test "$cf_cv_link_dataonly" = no ; then
281597049Speter	AC_DEFINE(BROKEN_LINKER)
281697049Speter	BROKEN_LINKER=1
281797049Speterfi
281897049Speter
281950276Speter])dnl
282050276Speterdnl ---------------------------------------------------------------------------
2821166124Srafandnl CF_LINK_FUNCS version: 7 updated: 2006/12/16 12:33:30
2822166124Srafandnl -------------
282350276Speterdnl Most Unix systems have both link and symlink, a few don't have symlink.
282450276Speterdnl A few non-Unix systems implement symlink, but not link.
282550276Speterdnl A few non-systems implement neither (or have nonfunctional versions).
282650276SpeterAC_DEFUN([CF_LINK_FUNCS],
282750276Speter[
282850276SpeterAC_CHECK_FUNCS( \
282950276Speter	remove \
283050276Speter	unlink )
283150276Speter
2832166124Srafanif test "$cross_compiling" = yes ; then
283350276Speter	AC_CHECK_FUNCS( \
283450276Speter		link \
283550276Speter		symlink )
283650276Speterelse
283750276Speter	AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
283850276Speter		cf_cv_link_funcs=
283950276Speter		for cf_func in link symlink ; do
284050276Speter			AC_TRY_RUN([
284150276Speter#include <sys/types.h>
284250276Speter#include <sys/stat.h>
284350276Speter#ifdef HAVE_UNISTD_H
284450276Speter#include <unistd.h>
284550276Speter#endif
284650276Speterint main()
284750276Speter{
284850276Speter	int fail = 0;
284950276Speter	char *src = "config.log";
285050276Speter	char *dst = "conftest.chk";
285150276Speter	struct stat src_sb;
285250276Speter	struct stat dst_sb;
285350276Speter
285450276Speter	stat(src, &src_sb);
285550276Speter	fail = ($cf_func("config.log", "conftest.chk") < 0)
285650276Speter	    || (stat(dst, &dst_sb) < 0)
285750276Speter	    || (dst_sb.st_mtime != src_sb.st_mtime);
285850276Speter#ifdef HAVE_UNLINK
285950276Speter	unlink(dst);
286050276Speter#else
286150276Speter	remove(dst);
286250276Speter#endif
2863166124Srafan	${cf_cv_main_return:-return} (fail);
286450276Speter}
286550276Speter			],[
286650276Speter			cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
286766963Speter			eval 'ac_cv_func_'$cf_func'=yes'],[
286850276Speter			eval 'ac_cv_func_'$cf_func'=no'],[
286950276Speter			eval 'ac_cv_func_'$cf_func'=error'])
287050276Speter		done
287150276Speter		test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
287250276Speter	])
287366963Speter	test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK)
287466963Speter	test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
287550276Speterfi
287650276Speter])dnl
287750276Speterdnl ---------------------------------------------------------------------------
2878166124Srafandnl CF_MAIN_RETURN version: 1 updated: 2006/12/10 09:51:54
2879166124Srafandnl --------------
2880166124Srafandnl Check if a return from main to the shell actually returns the same exit
2881166124Srafandnl code.  This is true for almost any POSIX environment.
2882166124Srafandnl
2883166124Srafandnl Some very old environments did not flush stdout, etc., on an exit.  That
2884166124Srafandnl would be a useful case to test for also.
2885166124SrafanAC_DEFUN([CF_MAIN_RETURN],
2886166124Srafan[
2887166124Srafancf_cv_main_return=return
2888166124Srafan])dnl
2889166124Srafandnl ---------------------------------------------------------------------------
2890166124Srafandnl CF_MAKEFLAGS version: 12 updated: 2006/10/21 08:27:03
2891166124Srafandnl ------------
2892166124Srafandnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
289350276Speterdnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
289450276Speterdnl (GNU 'make' does both, something POSIX 'make', which happens to make the
2895166124Srafandnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
289650276SpeterAC_DEFUN([CF_MAKEFLAGS],
289750276Speter[
289897049SpeterAC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
289950276Speter	cf_cv_makeflags=''
2900166124Srafan	for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
290150276Speter	do
290250276Speter		cat >cf_makeflags.tmp <<CF_EOF
290397049SpeterSHELL = /bin/sh
290450276Speterall :
290550276Speter	@ echo '.$cf_option'
290650276SpeterCF_EOF
2907166124Srafan		cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[ 	]]*$,,'`
290850276Speter		case "$cf_result" in
290950276Speter		.*k)
291050276Speter			cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
291150276Speter			case "$cf_result" in
291250276Speter			.*CC=*)	cf_cv_makeflags=
291350276Speter				;;
291450276Speter			*)	cf_cv_makeflags=$cf_option
291550276Speter				;;
291650276Speter			esac
291750276Speter			break
291850276Speter			;;
2919166124Srafan		.-)	;;
2920166124Srafan		*)	echo "given option \"$cf_option\", no match \"$cf_result\""
292150276Speter			;;
292250276Speter		esac
292350276Speter	done
292497049Speter	rm -f cf_makeflags.tmp
292597049Speter])
292697049Speter
292750276SpeterAC_SUBST(cf_cv_makeflags)
292850276Speter])dnl
292950276Speterdnl ---------------------------------------------------------------------------
2930166124Srafandnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40
2931166124Srafandnl ------------
293266963Speterdnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
293366963Speterdnl a monocase filesystem.
293466963SpeterAC_DEFUN([CF_MAKE_TAGS],[
293566963SpeterAC_REQUIRE([CF_MIXEDCASE_FILENAMES])
293666963SpeterAC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
293766963Speter
293866963Speterif test "$cf_cv_mixedcase" = yes ; then
293966963Speter	AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
294066963Speterelse
294166963Speter	MAKE_UPPER_TAGS=no
294266963Speterfi
294366963Speter
294466963Speterif test "$MAKE_UPPER_TAGS" = yes ; then
294566963Speter	MAKE_UPPER_TAGS=
294666963Speterelse
294766963Speter	MAKE_UPPER_TAGS="#"
294866963Speterfi
294966963SpeterAC_SUBST(MAKE_UPPER_TAGS)
295066963Speter
295166963Speterif test "$MAKE_LOWER_TAGS" = yes ; then
295266963Speter	MAKE_LOWER_TAGS=
295366963Speterelse
295466963Speter	MAKE_LOWER_TAGS="#"
295566963Speterfi
295666963SpeterAC_SUBST(MAKE_LOWER_TAGS)
295766963Speter])dnl
295866963Speterdnl ---------------------------------------------------------------------------
2959166124Srafandnl CF_MANPAGE_FORMAT version: 7 updated: 2003/12/20 19:30:34
2960166124Srafandnl -----------------
296150276Speterdnl Option to allow user to override automatic configuration of manpage format.
2962166124Srafandnl There are several special cases:
2963166124Srafandnl
2964166124Srafandnl	gzip - man checks for, can display gzip'd files
2965166124Srafandnl	compress - man checks for, can display compressed files
2966166124Srafandnl	BSDI - files in the cat-directories are suffixed ".0"
2967166124Srafandnl	formatted - installer should format (put files in cat-directory)
2968166124Srafandnl	catonly - installer should only format, e.g., for a turnkey system.
2969166124Srafandnl
2970166124Srafandnl There are other configurations which this macro does not test, e.g., HPUX's
2971166124Srafandnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
2972166124Srafandnl convention would not match our use).
297350276SpeterAC_DEFUN([CF_MANPAGE_FORMAT],
297476726Speter[
297576726SpeterAC_REQUIRE([CF_PATHSEP])
297676726SpeterAC_MSG_CHECKING(format of man-pages)
297750276Speter
297850276SpeterAC_ARG_WITH(manpage-format,
297950276Speter	[  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
2980166124Srafan                          optionally formatted/catonly, e.g., gzip,formatted],
298197049Speter	[MANPAGE_FORMAT=$withval],
298297049Speter	[MANPAGE_FORMAT=unknown])
298350276Speter
2984166124Srafantest -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
2985166124SrafanMANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
2986166124Srafan
2987166124Srafancf_unknown=
2988166124Srafan
2989166124Srafancase $MANPAGE_FORMAT in
2990166124Srafanunknown)
299150276Speter  if test -z "$MANPATH" ; then
299250276Speter    MANPATH="/usr/man:/usr/share/man"
299350276Speter  fi
2994166124Srafan
299550276Speter  # look for the 'date' man-page (it's most likely to be installed!)
2996166124Srafan  MANPAGE_FORMAT=
2997166124Srafan  cf_preform=no
2998166124Srafan  cf_catonly=yes
2999166124Srafan  cf_example=date
3000166124Srafan
300176726Speter  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
300250276Speter  for cf_dir in $MANPATH; do
300350276Speter    test -z "$cf_dir" && cf_dir=/usr/man
3004166124Srafan    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
300550276Speter    do
3006166124Srafan      cf_test=`echo $cf_name | sed -e 's/*//'`
3007166124Srafan      if test "x$cf_test" = "x$cf_name" ; then
3008166124Srafan
3009166124Srafan	case "$cf_name" in
3010166124Srafan	*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
3011166124Srafan	*.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
3012166124Srafan	*.0)	MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
3013166124Srafan	*)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
3014166124Srafan	esac
3015166124Srafan
3016166124Srafan	case "$cf_name" in
3017166124Srafan	$cf_dir/man*)
3018166124Srafan	  cf_catonly=no
3019166124Srafan	  ;;
3020166124Srafan	$cf_dir/cat*)
3021166124Srafan	  cf_preform=yes
3022166124Srafan	  ;;
3023166124Srafan	esac
3024166124Srafan	break
3025166124Srafan      fi
3026166124Srafan
3027166124Srafan      # if we found a match in either man* or cat*, stop looking
3028166124Srafan      if test -n "$MANPAGE_FORMAT" ; then
3029166124Srafan	cf_found=no
3030166124Srafan	test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
3031166124Srafan	test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
3032166124Srafan	case "$cf_name" in
3033166124Srafan	$cf_dir/cat*)
3034166124Srafan	  cf_found=yes
3035166124Srafan	  ;;
3036166124Srafan	esac
3037166124Srafan	test $cf_found=yes && break
3038166124Srafan      fi
303950276Speter    done
3040166124Srafan    # only check the first directory in $MANPATH where we find manpages
3041166124Srafan    if test -n "$MANPAGE_FORMAT" ; then
304250276Speter       break
304350276Speter    fi
304450276Speter  done
3045166124Srafan  # if we did not find the example, just assume it is normal
3046166124Srafan  test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
304750276Speter  IFS="$ac_save_ifs"
304850276Speter  ;;
3049166124Srafan*)
3050166124Srafan  for cf_option in $MANPAGE_FORMAT; do
3051166124Srafan     case $cf_option in #(vi
3052166124Srafan     gzip|compress|BSDI|normal|formatted|catonly)
3053166124Srafan       ;;
3054166124Srafan     *)
3055166124Srafan       cf_unknown="$cf_unknown $cf_option"
3056166124Srafan       ;;
3057166124Srafan     esac
3058166124Srafan  done
305950276Speter  ;;
306050276Speteresac
306150276Speter
306297049SpeterAC_MSG_RESULT($MANPAGE_FORMAT)
3063166124Srafanif test -n "$cf_unknown" ; then
3064166124Srafan  AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
3065166124Srafanfi
306650276Speter])dnl
306750276Speterdnl ---------------------------------------------------------------------------
3068166124Srafandnl CF_MANPAGE_RENAMES version: 7 updated: 2005/06/18 18:51:57
3069166124Srafandnl ------------------
307050276Speterdnl The Debian people have their own naming convention for manpages.  This
307150276Speterdnl option lets us override the name of the file containing renaming, or
307250276Speterdnl disable it altogether.
307350276SpeterAC_DEFUN([CF_MANPAGE_RENAMES],
307450276Speter[
307550276SpeterAC_MSG_CHECKING(for manpage renaming)
307650276Speter
307750276SpeterAC_ARG_WITH(manpage-renames,
307850276Speter	[  --with-manpage-renames  specify manpage-renaming],
307997049Speter	[MANPAGE_RENAMES=$withval],
308097049Speter	[MANPAGE_RENAMES=yes])
308150276Speter
308297049Spetercase ".$MANPAGE_RENAMES" in #(vi
308350276Speter.no) #(vi
308450276Speter  ;;
308550276Speter.|.yes)
308650276Speter  # Debian 'man' program?
308750276Speter  if test -f /etc/debian_version ; then
308897049Speter    MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
308950276Speter  else
309097049Speter    MANPAGE_RENAMES=no
309150276Speter  fi
309250276Speter  ;;
309350276Speteresac
309450276Speter
309597049Speterif test "$MANPAGE_RENAMES" != no ; then
309697049Speter  if test -f $srcdir/man/$MANPAGE_RENAMES ; then
309797049Speter    MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
309897049Speter  elif test ! -f $MANPAGE_RENAMES ; then
309997049Speter    AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
310050276Speter  fi
310150276Speter
310250276Speter  test ! -d man && mkdir man
310350276Speter
310450276Speter  # Construct a sed-script to perform renaming within man-pages
310597049Speter  if test -n "$MANPAGE_RENAMES" ; then
310650276Speter    test ! -d man && mkdir man
3107166124Srafan    sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >./edit_man.sed
310850276Speter  fi
310950276Speterfi
311050276Speter
311197049SpeterAC_MSG_RESULT($MANPAGE_RENAMES)
311297049SpeterAC_SUBST(MANPAGE_RENAMES)
311350276Speter])dnl
311450276Speterdnl ---------------------------------------------------------------------------
3115166124Srafandnl CF_MANPAGE_SYMLINKS version: 4 updated: 2003/12/13 18:01:58
3116166124Srafandnl -------------------
311762449Speterdnl Some people expect each tool to make all aliases for manpages in the
311862449Speterdnl man-directory.  This accommodates the older, less-capable implementations
311962449Speterdnl of 'man', and is optional.
312062449SpeterAC_DEFUN([CF_MANPAGE_SYMLINKS],
312162449Speter[
3122166124SrafanAC_MSG_CHECKING(if manpage aliases will be installed)
312362449Speter
3124166124SrafanAC_ARG_WITH(manpage-aliases,
3125166124Srafan	[  --with-manpage-aliases  specify manpage-aliases using .so],
3126166124Srafan	[MANPAGE_ALIASES=$withval],
3127166124Srafan	[MANPAGE_ALIASES=yes])
3128166124Srafan
3129166124SrafanAC_MSG_RESULT($MANPAGE_ALIASES)
3130166124Srafan
3131166124Srafanif test "$LN_S" = "ln -s"; then
3132166124Srafan	cf_use_symlinks=yes
3133166124Srafanelse
3134166124Srafan	cf_use_symlinks=no
3135166124Srafanfi
3136166124Srafan
3137166124SrafanMANPAGE_SYMLINKS=no
3138166124Srafanif test "$MANPAGE_ALIASES" = yes ; then
3139166124SrafanAC_MSG_CHECKING(if manpage symlinks should be used)
3140166124Srafan
314162449SpeterAC_ARG_WITH(manpage-symlinks,
3142166124Srafan	[  --with-manpage-symlinks specify manpage-aliases using symlinks],
314397049Speter	[MANPAGE_SYMLINKS=$withval],
3144166124Srafan	[MANPAGE_SYMLINKS=$cf_use_symlinks])
314562449Speter
3146166124Srafanif test "$$cf_use_symlinks" = no; then
3147166124Srafanif test "$MANPAGE_SYMLINKS" = yes ; then
3148166124Srafan	AC_MSG_WARN(cannot make symlinks, will use .so files)
3149166124Srafan	MANPAGE_SYMLINKS=no
3150166124Srafanfi
3151166124Srafanfi
3152166124Srafan
315397049SpeterAC_MSG_RESULT($MANPAGE_SYMLINKS)
3154166124Srafanfi
3155166124Srafan
315662449Speter])dnl
315762449Speterdnl ---------------------------------------------------------------------------
3158166124Srafandnl CF_MANPAGE_TBL version: 3 updated: 2002/01/19 22:51:32
3159166124Srafandnl --------------
316076726Speterdnl This option causes manpages to be run through tbl(1) to generate tables
316176726Speterdnl correctly.
316276726SpeterAC_DEFUN([CF_MANPAGE_TBL],
316376726Speter[
316476726SpeterAC_MSG_CHECKING(for manpage tbl)
316576726Speter
316676726SpeterAC_ARG_WITH(manpage-tbl,
316776726Speter	[  --with-manpage-tbl      specify manpage processing with tbl],
316897049Speter	[MANPAGE_TBL=$withval],
316997049Speter	[MANPAGE_TBL=no])
317076726Speter
317197049SpeterAC_MSG_RESULT($MANPAGE_TBL)
317276726Speter])dnl
317376726Speterdnl ---------------------------------------------------------------------------
3174174993Srafandnl CF_MAN_PAGES version: 35 updated: 2007/03/31 11:47:29
3175166124Srafandnl ------------
317650276Speterdnl Try to determine if the man-pages on the system are compressed, and if
317750276Speterdnl so, what format is used.  Use this information to construct a script that
317850276Speterdnl will install man-pages.
317950276SpeterAC_DEFUN([CF_MAN_PAGES],
318050276Speter[
318150276SpeterCF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
318250276SpeterCF_MANPAGE_FORMAT
318350276SpeterCF_MANPAGE_RENAMES
318462449SpeterCF_MANPAGE_SYMLINKS
318576726SpeterCF_MANPAGE_TBL
318650276Speter
318750276Speter  if test "$prefix" = "NONE" ; then
318850276Speter     cf_prefix="$ac_default_prefix"
318950276Speter  else
319050276Speter     cf_prefix="$prefix"
319150276Speter  fi
319250276Speter
319397049Speter  case "$MANPAGE_FORMAT" in # (vi
3194166124Srafan  *catonly*) # (vi
3195166124Srafan    cf_format=yes
3196166124Srafan    cf_inboth=no
3197166124Srafan    ;;
319850276Speter  *formatted*) # (vi
319950276Speter    cf_format=yes
3200166124Srafan    cf_inboth=yes
320150276Speter    ;;
320250276Speter  *)
320350276Speter    cf_format=no
3204166124Srafan    cf_inboth=no
320550276Speter    ;;
320650276Speter  esac
320750276Speter
320850276Spetertest ! -d man && mkdir man
3209166124Srafan
3210166124Srafancf_so_strip=
3211166124Srafancf_compress=
3212166124Srafancase "$MANPAGE_FORMAT" in #(vi
3213166124Srafan*compress*) #(vi
3214166124Srafan	cf_so_strip="Z"
3215166124Srafan	cf_compress=compress
3216166124Srafan  ;;
3217166124Srafan*gzip*) #(vi
3218166124Srafan	cf_so_strip="gz"
3219166124Srafan	cf_compress=gzip
3220166124Srafan  ;;
3221166124Srafanesac
3222166124Srafan
3223166124Srafancf_edit_man=./edit_man.sh
3224174993Srafancf_man_alias=`pwd`/man_alias.sed
3225166124Srafan
3226166124Srafancat >$cf_edit_man <<CF_EOF
322750276Speter#! /bin/sh
3228166124Srafan# this script is generated by the configure-script CF_MAN_PAGES macro.
3229166124Srafan
323050276Speterprefix="$cf_prefix"
323150276Speterdatadir="$datadir"
3232166124Srafan
3233166124SrafanNCURSES_MAJOR="$NCURSES_MAJOR"
3234166124SrafanNCURSES_MINOR="$NCURSES_MINOR"
3235166124SrafanNCURSES_PATCH="$NCURSES_PATCH"
3236166124Srafan
323797049SpeterNCURSES_OSPEED="$NCURSES_OSPEED"
323866963SpeterTERMINFO="$TERMINFO"
3239166124Srafan
3240174993SrafanMKDIRS="sh `cd $srcdir && pwd`/mkdirs.sh"
3241166124Srafan
324250276SpeterINSTALL="$INSTALL"
324350276SpeterINSTALL_DATA="$INSTALL_DATA"
3244166124Srafan
324566963Spetertransform="$program_transform_name"
324662449Speter
324750276SpeterTMP=\${TMPDIR-/tmp}/man\$\$
324850276Spetertrap "rm -f \$TMP" 0 1 2 5 15
324950276Speter
3250166124Srafanform=\[$]1
3251166124Srafanshift || exit 1
3252166124Srafan
325376726Speterverb=\[$]1
3254166124Srafanshift || exit 1
325550276Speter
325676726Spetermandir=\[$]1
3257166124Srafanshift || exit 1
325850276Speter
325976726Spetersrcdir=\[$]1
3260166124Srafantop_srcdir=\[$]srcdir/..
3261166124Srafanshift || exit 1
326262449Speter
3263166124Srafanif test "\$form" = normal ; then
3264166124Srafan	if test "$cf_format" = yes ; then
3265166124Srafan	if test "$cf_inboth" = no ; then
3266166124Srafan		sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
3267166124Srafan		exit $?
3268166124Srafan	fi
3269166124Srafan	fi
3270166124Srafan	cf_subdir=\$mandir/man
3271166124Srafan	cf_tables=$MANPAGE_TBL
3272166124Srafanelse
3273166124Srafan	cf_subdir=\$mandir/cat
3274166124Srafan	cf_tables=yes
3275166124Srafanfi
3276166124Srafan
3277166124Srafan# process the list of source-files
327876726Speterfor i in \[$]* ; do
327950276Spetercase \$i in #(vi
328050276Speter*.orig|*.rej) ;; #(vi
328176726Speter*.[[0-9]]*)
328276726Speter	section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`;
328350276Speter	if test \$verb = installing ; then
3284166124Srafan	if test ! -d \$cf_subdir\${section} ; then
3285166124Srafan		\$MKDIRS \$cf_subdir\$section
328650276Speter	fi
328750276Speter	fi
3288174993Srafan
3289174993Srafan	# replace variables in man page
3290174993Srafan	if test ! -f $cf_man_alias ; then
3291174993Srafancat >>$cf_man_alias <<-CF_EOF2
3292174993Srafan		s,@DATADIR@,\$datadir,g
3293174993Srafan		s,@TERMINFO@,\$TERMINFO,g
3294174993Srafan		s,@NCURSES_MAJOR@,\$NCURSES_MAJOR,g
3295174993Srafan		s,@NCURSES_MINOR@,\$NCURSES_MINOR,g
3296174993Srafan		s,@NCURSES_PATCH@,\$NCURSES_PATCH,g
3297174993Srafan		s,@NCURSES_OSPEED@,\$NCURSES_OSPEED,g
3298174993SrafanCF_EOF
3299174993Srafan	ifelse($1,,,[
3300174993Srafan	for cf_name in $1
3301174993Srafan	do
3302174993Srafan		cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3303174993Srafan		cf_name=`echo $cf_name|sed "$program_transform_name"`
3304174993Srafancat >>$cf_edit_man <<-CF_EOF
3305174993Srafan		s,@$cf_NAME@,$cf_name,
3306174993SrafanCF_EOF
3307174993Srafan	done
3308174993Srafan	])
3309174993Srafancat >>$cf_edit_man <<CF_EOF
3310174993SrafanCF_EOF2
3311174993Srafan		echo "...made $cf_man_alias"
3312174993Srafan	fi
3313174993Srafan
331462449Speter	aliases=
3315166124Srafan	cf_source=\`basename \$i\`
3316166124Srafan	inalias=\$cf_source
331766963Speter	test ! -f \$inalias && inalias="\$srcdir/\$inalias"
331866963Speter	if test ! -f \$inalias ; then
3319166124Srafan		echo .. skipped \$cf_source
332066963Speter		continue
332166963Speter	fi
332250276SpeterCF_EOF
3323166124Srafan
3324166124Srafanif test "$MANPAGE_ALIASES" != no ; then
3325166124Srafancat >>$cf_edit_man <<CF_EOF
3326174993Srafan	aliases=\`sed -f \$top_srcdir/man/manlinks.sed \$inalias |sed -f $cf_man_alias | sort -u\`
332762449SpeterCF_EOF
332862449Speterfi
332976726Speter
333097049Speterif test "$MANPAGE_RENAMES" = no ; then
3331166124Srafancat >>$cf_edit_man <<CF_EOF
333266963Speter	# perform program transformations for section 1 man pages
333366963Speter	if test \$section = 1 ; then
3334166124Srafan		cf_target=\$cf_subdir\${section}/\`echo \$cf_source|sed "\${transform}"\`
333566963Speter	else
3336166124Srafan		cf_target=\$cf_subdir\${section}/\$cf_source
333766963Speter	fi
333876726SpeterCF_EOF
333976726Speterelse
3340166124Srafancat >>$cf_edit_man <<CF_EOF
3341166124Srafan	cf_target=\`grep "^\$cf_source" $MANPAGE_RENAMES | $AWK '{print \[$]2}'\`
3342166124Srafan	if test -z "\$cf_target" ; then
3343166124Srafan		echo '? missing rename for '\$cf_source
3344166124Srafan		cf_target="\$cf_source"
334576726Speter	fi
3346166124Srafan	cf_target="\$cf_subdir\${section}/\${cf_target}"
3347174993Srafan
334876726SpeterCF_EOF
334976726Speterfi
335066963Speter
3351166124Srafancat >>$cf_edit_man <<CF_EOF
3352174993Srafan	sed	-f $cf_man_alias \\
335366963SpeterCF_EOF
3354166124Srafan
335597049Speterif test -f $MANPAGE_RENAMES ; then
3356166124Srafancat >>$cf_edit_man <<CF_EOF
3357166124Srafan		< \$i | sed -f `pwd`/edit_man.sed >\$TMP
335897049SpeterCF_EOF
335997049Speterelse
3360166124Srafancat >>$cf_edit_man <<CF_EOF
336166963Speter		< \$i >\$TMP
336266963SpeterCF_EOF
336397049Speterfi
3364166124Srafan
3365166124Srafancat >>$cf_edit_man <<CF_EOF
3366166124Srafanif test \$cf_tables = yes ; then
336776726Speter	tbl \$TMP >\$TMP.out
336876726Speter	mv \$TMP.out \$TMP
3369166124Srafanfi
337050276SpeterCF_EOF
3371166124Srafan
337276726Speterif test $with_curses_h != yes ; then
3373166124Srafancat >>$cf_edit_man <<CF_EOF
337476726Speter	sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
337576726Speter	mv \$TMP.out \$TMP
337676726SpeterCF_EOF
337776726Speterfi
3378166124Srafan
3379166124Srafancat >>$cf_edit_man <<CF_EOF
3380166124Srafan	if test \$form = format ; then
3381166124Srafan		nroff -man \$TMP >\$TMP.out
3382166124Srafan		mv \$TMP.out \$TMP
338350276Speter	fi
338450276SpeterCF_EOF
3385166124Srafan
3386166124Srafanif test -n "$cf_compress" ; then
3387166124Srafancat >>$cf_edit_man <<CF_EOF
338850276Speter	if test \$verb = installing ; then
3389166124Srafan	if ( $cf_compress -f \$TMP )
339050276Speter	then
3391166124Srafan		mv \$TMP.$cf_so_strip \$TMP
339250276Speter	fi
339350276Speter	fi
3394166124Srafan	cf_target="\$cf_target.$cf_so_strip"
339550276SpeterCF_EOF
3396166124Srafanfi
3397166124Srafan
3398166124Srafancase "$MANPAGE_FORMAT" in #(vi
339950276Speter*BSDI*)
3400166124Srafancat >>$cf_edit_man <<CF_EOF
3401166124Srafan	if test \$form = format ; then
3402166124Srafan		# BSDI installs only .0 suffixes in the cat directories
3403166124Srafan		cf_target="\`echo \$cf_target|sed -e 's/\.[[1-9]]\+[[a-z]]*/.0/'\`"
3404166124Srafan	fi
340550276SpeterCF_EOF
340650276Speter  ;;
340750276Speteresac
3408166124Srafan
3409166124Srafancat >>$cf_edit_man <<CF_EOF
3410166124Srafan	suffix=\`basename \$cf_target | sed -e 's%^[[^.]]*%%'\`
341150276Speter	if test \$verb = installing ; then
3412166124Srafan		echo \$verb \$cf_target
3413166124Srafan		\$INSTALL_DATA \$TMP \$cf_target
3414174993Srafan		test -d \$cf_subdir\${section} &&
341562449Speter		test -n "\$aliases" && (
3416166124Srafan			cd \$cf_subdir\${section} && (
3417166124Srafan				cf_source=\`echo \$cf_target |sed -e 's%^.*/\([[^/]][[^/]]*/[[^/]][[^/]]*$\)%\1%'\`
3418166124Srafan				test -n "$cf_so_strip" && cf_source=\`echo \$cf_source |sed -e 's%\.$cf_so_strip\$%%'\`
3419166124Srafan				cf_target=\`basename \$cf_target\`
342062449Speter				for cf_alias in \$aliases
342162449Speter				do
342266963Speter					if test \$section = 1 ; then
342366963Speter						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
342466963Speter					fi
342566963Speter
3426166124Srafan					if test "$MANPAGE_SYMLINKS" = yes ; then
3427166124Srafan						if test -f \$cf_alias\${suffix} ; then
3428166124Srafan							if ( cmp -s \$cf_target \$cf_alias\${suffix} )
3429166124Srafan							then
3430166124Srafan								continue
3431166124Srafan							fi
343262449Speter						fi
343362449Speter						echo .. \$verb alias \$cf_alias\${suffix}
343462449Speter						rm -f \$cf_alias\${suffix}
3435166124Srafan						$LN_S \$cf_target \$cf_alias\${suffix}
3436166124Srafan					elif test "\$cf_target" != "\$cf_alias\${suffix}" ; then
3437166124Srafan						echo ".so \$cf_source" >\$TMP
3438166124SrafanCF_EOF
3439166124Srafanif test -n "$cf_compress" ; then
3440166124Srafancat >>$cf_edit_man <<CF_EOF
3441166124Srafan						if test -n "$cf_so_strip" ; then
3442166124Srafan							$cf_compress -f \$TMP
3443166124Srafan							mv \$TMP.$cf_so_strip \$TMP
3444166124Srafan						fi
3445166124SrafanCF_EOF
3446166124Srafanfi
3447166124Srafancat >>$cf_edit_man <<CF_EOF
3448166124Srafan						echo .. \$verb alias \$cf_alias\${suffix}
3449166124Srafan						rm -f \$cf_alias\${suffix}
3450166124Srafan						\$INSTALL_DATA \$TMP \$cf_alias\${suffix}
345162449Speter					fi
345262449Speter				done
345362449Speter			)
345462449Speter		)
345576726Speter	elif test \$verb = removing ; then
3456174993Srafan		test -f \$cf_target && (
3457174993Srafan			echo \$verb \$cf_target
3458174993Srafan			rm -f \$cf_target
3459174993Srafan		)
3460174993Srafan		test -d \$cf_subdir\${section} &&
346162449Speter		test -n "\$aliases" && (
3462166124Srafan			cd \$cf_subdir\${section} && (
346362449Speter				for cf_alias in \$aliases
346462449Speter				do
346566963Speter					if test \$section = 1 ; then
346666963Speter						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
346766963Speter					fi
346866963Speter
346962449Speter					echo .. \$verb alias \$cf_alias\${suffix}
347062449Speter					rm -f \$cf_alias\${suffix}
347162449Speter				done
347262449Speter			)
347362449Speter		)
347476726Speter	else
347576726Speter#		echo ".hy 0"
347676726Speter		cat \$TMP
347750276Speter	fi
347850276Speter	;;
347950276Speteresac
348050276Speterdone
3481166124Srafan
3482166124Srafanif test $cf_inboth = yes ; then
3483166124Srafanif test \$form != format ; then
3484166124Srafan	sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
3485166124Srafanfi
3486166124Srafanfi
3487166124Srafan
348862449Speterexit 0
348950276SpeterCF_EOF
3490166124Srafanchmod 755 $cf_edit_man
349150276Speter
349250276Speter])dnl
349350276Speterdnl ---------------------------------------------------------------------------
3494166124Srafandnl CF_MATH_LIB version: 5 updated: 2000/05/28 01:39:10
3495166124Srafandnl -----------
349662449Speterdnl Checks for libraries.  At least one UNIX system, Apple Macintosh
349762449Speterdnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
349862449Speterdnl AC_CHECK_LIB(m,sin), because that fails for C++.
349962449SpeterAC_DEFUN([CF_MATH_LIB],
350062449Speter[
350162449SpeterAC_CACHE_CHECK(if -lm needed for math functions,
350262449Speter	cf_cv_need_libm,[
350362449Speter	AC_TRY_LINK([
350462449Speter	#include <stdio.h>
350562449Speter	#include <math.h>
350662449Speter	],
350762449Speter	[double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
350862449Speter	[cf_cv_need_libm=no],
350962449Speter	[cf_cv_need_libm=yes])])
351062449Speterif test "$cf_cv_need_libm" = yes
351162449Speterthen
351262449Speterifelse($1,,[
351362449Speter	LIBS="$LIBS -lm"
351462449Speter],[$1=-lm])
351562449Speterfi
351662449Speter])
351762449Speterdnl ---------------------------------------------------------------------------
3518166124Srafandnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
3519166124Srafandnl ----------------------
352066963Speterdnl Check if the file-system supports mixed-case filenames.  If we're able to
352166963Speterdnl create a lowercase name and see it as uppercase, it doesn't support that.
352266963SpeterAC_DEFUN([CF_MIXEDCASE_FILENAMES],
352366963Speter[
352466963SpeterAC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
3525166124Srafanif test "$cross_compiling" = yes ; then
3526166124Srafan	case $target_alias in #(vi
3527166124Srafan	*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
3528166124Srafan		cf_cv_mixedcase=no
3529166124Srafan		;;
3530166124Srafan	*)
3531166124Srafan		cf_cv_mixedcase=yes
3532166124Srafan		;;
3533166124Srafan	esac
3534166124Srafanelse
353566963Speter	rm -f conftest CONFTEST
353666963Speter	echo test >conftest
353766963Speter	if test -f CONFTEST ; then
353866963Speter		cf_cv_mixedcase=no
353966963Speter	else
354066963Speter		cf_cv_mixedcase=yes
354166963Speter	fi
354266963Speter	rm -f conftest CONFTEST
3543166124Srafanfi
354466963Speter])
354566963Spetertest "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
354666963Speter])dnl
354766963Speterdnl ---------------------------------------------------------------------------
3548166124Srafandnl CF_MKSTEMP version: 5 updated: 2006/12/16 12:33:30
3549166124Srafandnl ----------
355097049Speterdnl Check for a working mkstemp.  This creates two files, checks that they are
355197049Speterdnl successfully created and distinct (AmigaOS apparently fails on the last).
355297049SpeterAC_DEFUN([CF_MKSTEMP],[
355397049SpeterAC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
355497049Speterrm -f conftest*
355597049SpeterAC_TRY_RUN([
355697049Speter#include <sys/types.h>
355797049Speter#include <stdlib.h>
355897049Speter#include <stdio.h>
355997049Speter#include <string.h>
356097049Speter#include <sys/stat.h>
356197049Speterint main()
356297049Speter{
356397049Speter	char *tmpl = "conftestXXXXXX";
356497049Speter	char name[2][80];
356597049Speter	int n;
356697049Speter	int result = 0;
356797049Speter	int fd;
356897049Speter	struct stat sb;
356997049Speter
357097049Speter	umask(077);
357197049Speter	for (n = 0; n < 2; ++n) {
357297049Speter		strcpy(name[n], tmpl);
357397049Speter		if ((fd = mkstemp(name[n])) >= 0) {
357497049Speter			if (!strcmp(name[n], tmpl)
357597049Speter			 || stat(name[n], &sb) != 0
357697049Speter			 || (sb.st_mode & S_IFMT) != S_IFREG
357797049Speter			 || (sb.st_mode & 077) != 0) {
357897049Speter				result = 1;
357997049Speter			}
358097049Speter			close(fd);
358197049Speter		}
358297049Speter	}
358397049Speter	if (result == 0
358497049Speter	 && !strcmp(name[0], name[1]))
358597049Speter		result = 1;
3586166124Srafan	${cf_cv_main_return:-return}(result);
358797049Speter}
358897049Speter],[cf_cv_func_mkstemp=yes
358997049Speter],[cf_cv_func_mkstemp=no
359097049Speter],[AC_CHECK_FUNC(mkstemp)
359197049Speter])
359297049Speter])
359397049Speterif test "$cf_cv_func_mkstemp" = yes ; then
359497049Speter	AC_DEFINE(HAVE_MKSTEMP)
359597049Speterfi
359697049Speter])dnl
359797049Speterdnl ---------------------------------------------------------------------------
3598174993Srafandnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
3599166124Srafandnl ----------
3600166124Srafandnl Write a debug message to config.log, along with the line number in the
3601166124Srafandnl configure script.
3602166124SrafanAC_DEFUN([CF_MSG_LOG],[
3603174993Srafanecho "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
3604166124Srafan])dnl
3605166124Srafandnl ---------------------------------------------------------------------------
3606166124Srafandnl CF_NCURSES_ABI_6 version: 1 updated: 2005/09/17 18:42:49
3607166124Srafandnl ----------------
3608166124Srafandnl Set ncurses' ABI to 6 unless overridden by explicit configure option, and
3609166124Srafandnl warn about this.
3610166124SrafanAC_DEFUN([CF_NCURSES_ABI_6],[
3611166124Srafanif test "${with_abi_version+set}" != set; then
3612166124Srafan	case $cf_cv_rel_version in
3613166124Srafan	5.*)
3614166124Srafan		cf_cv_rel_version=6.0
3615166124Srafan		cf_cv_abi_version=6
3616166124Srafan		AC_MSG_WARN(Overriding ABI version to $cf_cv_abi_version)
3617166124Srafan		;;
3618166124Srafan	esac
3619166124Srafanfi
3620166124Srafan])dnl
3621166124Srafandnl ---------------------------------------------------------------------------
3622166124Srafandnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
3623166124Srafandnl ------------------
3624166124Srafandnl see CF_WITH_NO_LEAKS
3625166124SrafanAC_DEFUN([CF_NO_LEAKS_OPTION],[
3626166124SrafanAC_MSG_CHECKING(if you want to use $1 for testing)
3627166124SrafanAC_ARG_WITH($1,
3628166124Srafan	[$2],
3629166124Srafan	[AC_DEFINE($3)ifelse([$4],,[
3630166124Srafan	 $4
3631166124Srafan])
3632166124Srafan	: ${with_cflags:=-g}
3633166124Srafan	: ${with_no_leaks:=yes}
3634166124Srafan	 with_$1=yes],
3635166124Srafan	[with_$1=])
3636166124SrafanAC_MSG_RESULT(${with_$1:-no})
3637166124Srafan
3638166124Srafancase .$with_cflags in #(vi
3639166124Srafan.*-g*)
3640166124Srafan	case .$CFLAGS in #(vi
3641166124Srafan	.*-g*) #(vi
3642166124Srafan		;;
3643166124Srafan	*)
3644166124Srafan		CF_ADD_CFLAGS([-g])
3645166124Srafan		;;
3646166124Srafan	esac
3647166124Srafan	;;
3648166124Srafanesac
3649166124Srafan])dnl
3650166124Srafandnl ---------------------------------------------------------------------------
3651166124Srafandnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
3652166124Srafandnl ----------------
3653166124Srafandnl Check if the given variable is a number.  If not, report an error.
3654166124Srafandnl $1 is the variable
3655166124Srafandnl $2 is the message
3656166124SrafanAC_DEFUN([CF_NUMBER_SYNTAX],[
3657166124Srafanif test -n "$1" ; then
3658166124Srafan  case $1 in #(vi
3659166124Srafan  [[0-9]]*) #(vi
3660166124Srafan 	;;
3661166124Srafan  *)
3662166124Srafan	AC_MSG_ERROR($2 is not a number: $1)
3663166124Srafan 	;;
3664166124Srafan  esac
3665166124Srafanelse
3666166124Srafan  AC_MSG_ERROR($2 value is empty)
3667166124Srafanfi
3668166124Srafan])dnl
3669166124Srafandnl ---------------------------------------------------------------------------
3670166124Srafandnl CF_OBJ_SUBDIR version: 4 updated: 2002/02/23 20:38:31
3671166124Srafandnl -------------
367250276Speterdnl Compute the object-directory name from the given model name
367350276SpeterAC_DEFUN([CF_OBJ_SUBDIR],
367450276Speter[
367550276Speter	case $1 in
367676726Speter	libtool) $2='obj_lo'  ;;
367750276Speter	normal)  $2='objects' ;;
367850276Speter	debug)   $2='obj_g' ;;
367950276Speter	profile) $2='obj_p' ;;
368097049Speter	shared)
368197049Speter		case $cf_cv_system_name in #(vi
368297049Speter		cygwin) #(vi
368397049Speter			$2='objects' ;;
368497049Speter		*)
368597049Speter			$2='obj_s' ;;
368697049Speter		esac
368750276Speter	esac
368850276Speter])dnl
368950276Speterdnl ---------------------------------------------------------------------------
3690166124Srafandnl CF_PATHSEP version: 3 updated: 2001/01/12 01:23:53
3691166124Srafandnl ----------
369276726Speterdnl Provide a value for the $PATH and similar separator
369376726SpeterAC_DEFUN([CF_PATHSEP],
369476726Speter[
369576726Speter	case $cf_cv_system_name in
369676726Speter	os2*)	PATHSEP=';'  ;;
369776726Speter	*)	PATHSEP=':'  ;;
369876726Speter	esac
369976726Speterifelse($1,,,[$1=$PATHSEP])
370076726Speter	AC_SUBST(PATHSEP)
370176726Speter])dnl
370276726Speterdnl ---------------------------------------------------------------------------
3703178866Srafandnl CF_PATH_SYNTAX version: 12 updated: 2008/03/23 14:45:59
3704166124Srafandnl --------------
370550276Speterdnl Check the argument to see that it looks like a pathname.  Rewrite it if it
370650276Speterdnl begins with one of the prefix/exec_prefix variables, and then again if the
370797049Speterdnl result begins with 'NONE'.  This is necessary to work around autoconf's
370850276Speterdnl delayed evaluation of those symbols.
370950276SpeterAC_DEFUN([CF_PATH_SYNTAX],[
3710166124Srafanif test "x$prefix" != xNONE; then
3711166124Srafan  cf_path_syntax="$prefix"
3712166124Srafanelse
3713166124Srafan  cf_path_syntax="$ac_default_prefix"
3714166124Srafanfi
3715166124Srafan
371650276Spetercase ".[$]$1" in #(vi
371797049Speter.\[$]\(*\)*|.\'*\'*) #(vi
371850276Speter  ;;
371997049Speter..|./*|.\\*) #(vi
372097049Speter  ;;
372176726Speter.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
372262449Speter  ;;
372350276Speter.\[$]{*prefix}*) #(vi
372450276Speter  eval $1="[$]$1"
372550276Speter  case ".[$]$1" in #(vi
372650276Speter  .NONE/*)
3727166124Srafan    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
372850276Speter    ;;
372950276Speter  esac
373050276Speter  ;; #(vi
3731166124Srafan.no|.NONE/*)
3732166124Srafan  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
373350276Speter  ;;
373450276Speter*)
3735178866Srafan  ifelse($2,,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
373650276Speter  ;;
373750276Speteresac
373850276Speter])dnl
373950276Speterdnl ---------------------------------------------------------------------------
3740166124Srafandnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
3741166124Srafandnl -----------------
3742166124Srafandnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
3743166124Srafandnl
3744166124Srafandnl	POSIX.1-1990				_POSIX_SOURCE
3745166124Srafandnl	POSIX.1-1990 and			_POSIX_SOURCE and
3746166124Srafandnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
3747166124Srafandnl		Bindings Option
3748166124Srafandnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
3749166124Srafandnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
3750166124Srafandnl	X/Open 2000				_POSIX_C_SOURCE=200112L
3751166124Srafandnl
3752166124Srafandnl Parameters:
3753166124Srafandnl	$1 is the nominal value for _POSIX_C_SOURCE
3754166124SrafanAC_DEFUN([CF_POSIX_C_SOURCE],
3755166124Srafan[
3756166124Srafancf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
3757166124Srafan
3758166124Srafancf_save_CFLAGS="$CFLAGS"
3759166124Srafancf_save_CPPFLAGS="$CPPFLAGS"
3760166124Srafan
3761166124SrafanCF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
3762166124SrafanCF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
3763166124Srafan
3764166124SrafanAC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
3765166124Srafan	CF_MSG_LOG(if the symbol is already defined go no further)
3766166124Srafan	AC_TRY_COMPILE([#include <sys/types.h>],[
3767166124Srafan#ifndef _POSIX_C_SOURCE
3768166124Srafanmake an error
3769166124Srafan#endif],
3770166124Srafan	[cf_cv_posix_c_source=no],
3771166124Srafan	[cf_want_posix_source=no
3772166124Srafan	 case .$cf_POSIX_C_SOURCE in #(vi
3773166124Srafan	 .[[12]]??*) #(vi
3774166124Srafan		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3775166124Srafan		;;
3776166124Srafan	 .2) #(vi
3777166124Srafan		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3778166124Srafan		cf_want_posix_source=yes
3779166124Srafan		;;
3780166124Srafan	 .*)
3781166124Srafan		cf_want_posix_source=yes
3782166124Srafan		;;
3783166124Srafan	 esac
3784166124Srafan	 if test "$cf_want_posix_source" = yes ; then
3785166124Srafan		AC_TRY_COMPILE([#include <sys/types.h>],[
3786166124Srafan#ifdef _POSIX_SOURCE
3787166124Srafanmake an error
3788166124Srafan#endif],[],
3789166124Srafan		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
3790166124Srafan	 fi
3791166124Srafan	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
3792166124Srafan	 CFLAGS="$cf_trim_CFLAGS"
3793166124Srafan	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
3794166124Srafan	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
3795166124Srafan	 AC_TRY_COMPILE([#include <sys/types.h>],[
3796166124Srafan#ifndef _POSIX_C_SOURCE
3797166124Srafanmake an error
3798166124Srafan#endif],,
3799166124Srafan	 [cf_cv_posix_c_source=no])
3800166124Srafan	 CFLAGS="$cf_save_CFLAGS"
3801166124Srafan	 CPPFLAGS="$cf_save_CPPFLAGS"
3802166124Srafan	])
3803166124Srafan])
3804166124Srafan
3805166124Srafanif test "$cf_cv_posix_c_source" != no ; then
3806166124Srafan	CFLAGS="$cf_trim_CFLAGS"
3807166124Srafan	CPPFLAGS="$cf_trim_CPPFLAGS"
3808166124Srafan	if test "$cf_cv_cc_u_d_options" = yes ; then
3809166124Srafan		cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
3810166124Srafan				sed -e 's/-D/-U/g' -e 's/=[[^ 	]]*//g'`
3811166124Srafan		CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
3812166124Srafan	fi
3813166124Srafan	CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
3814166124Srafanfi
3815166124Srafan
3816166124Srafan])dnl
3817166124Srafandnl ---------------------------------------------------------------------------
3818166124Srafandnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
3819166124Srafandnl ------------
3820166124Srafandnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
3821166124Srafandnl
3822166124Srafandnl $1 = symbol to test
3823166124Srafandnl $2 = value (if any) to use for a predefinition
3824166124SrafanAC_DEFUN([CF_PREDEFINE],
3825166124Srafan[
3826166124SrafanAC_MSG_CHECKING(if we must define $1)
3827166124SrafanAC_TRY_COMPILE([#include <sys/types.h>
3828166124Srafan],[
3829166124Srafan#ifndef $1
3830166124Srafanmake an error
3831166124Srafan#endif],[cf_result=no],[cf_result=yes])
3832166124SrafanAC_MSG_RESULT($cf_result)
3833166124Srafan
3834166124Srafanif test "$cf_result" = yes ; then
3835166124Srafan	CPPFLAGS="$CPPFLAGS ifelse($2,,-D$1,[-D$1=$2])"
3836166124Srafanelif test "x$2" != "x" ; then
3837166124Srafan	AC_MSG_CHECKING(checking for compatible value versus $2)
3838166124Srafan	AC_TRY_COMPILE([#include <sys/types.h>
3839166124Srafan],[
3840166124Srafan#if $1-$2 < 0
3841166124Srafanmake an error
3842166124Srafan#endif],[cf_result=yes],[cf_result=no])
3843166124Srafan	AC_MSG_RESULT($cf_result)
3844166124Srafan	if test "$cf_result" = no ; then
3845166124Srafan		# perhaps we can override it - try...
3846166124Srafan		CPPFLAGS="$CPPFLAGS -D$1=$2"
3847166124Srafan	fi
3848166124Srafanfi
3849166124Srafan])dnl
3850166124Srafandnl ---------------------------------------------------------------------------
3851166124Srafandnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
3852166124Srafandnl ------------
3853166124Srafandnl Append definitions and rules for the given programs to the subdirectory
3854166124Srafandnl Makefiles, and the recursion rule for the top-level Makefile.
3855166124Srafandnl
3856166124Srafandnl parameters
3857166124Srafandnl	$1 = script to run
3858166124Srafandnl	$2 = list of subdirectories
3859166124Srafandnl
3860166124Srafandnl variables
3861166124Srafandnl	$AWK
3862166124SrafanAC_DEFUN([CF_PRG_RULES],
3863166124Srafan[
3864166124Srafanfor cf_dir in $2
3865166124Srafando
3866166124Srafan	if test ! -d $srcdir/$cf_dir; then
3867166124Srafan		continue
3868166124Srafan	elif test -f $srcdir/$cf_dir/programs; then
3869166124Srafan		$AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
3870166124Srafan	fi
3871166124Srafandone
3872166124Srafan
3873166124Srafan])dnl
3874166124Srafandnl ---------------------------------------------------------------------------
3875166124Srafandnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
3876166124Srafandnl -----------
3877166124Srafandnl Check for awk, ensure that the check found something.
3878166124SrafanAC_DEFUN([CF_PROG_AWK],
3879166124Srafan[
3880166124SrafanAC_PROG_AWK
3881166124Srafantest -z "$AWK" && AC_MSG_ERROR(No awk program found)
3882166124Srafan])dnl
3883166124Srafandnl ---------------------------------------------------------------------------
3884166124Srafandnl CF_PROG_CC_C_O version: 2 updated: 2006/12/16 15:55:46
3885166124Srafandnl --------------
3886166124Srafandnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
3887166124Srafandnl the output file can be renamed, and allows for a shell variable that can
3888166124Srafandnl be used later.  The parameter is either CC or CXX.  The result is the
3889166124Srafandnl cache variable:
3890166124Srafandnl	$cf_cv_prog_CC_c_o
3891166124Srafandnl	$cf_cv_prog_CXX_c_o
3892166124SrafanAC_DEFUN([CF_PROG_CC_C_O],
3893166124Srafan[AC_REQUIRE([AC_PROG_CC])dnl
3894166124SrafanAC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
3895166124SrafanAC_CACHE_VAL(cf_cv_prog_$1_c_o,
3896166124Srafan[
3897166124Srafancat > conftest.$ac_ext <<CF_EOF
3898166124Srafan#include <stdio.h>
3899166124Srafanint main()
3900166124Srafan{
3901166124Srafan	${cf_cv_main_return:-return}(0);
3902166124Srafan}
3903166124SrafanCF_EOF
3904166124Srafan# We do the test twice because some compilers refuse to overwrite an
3905166124Srafan# existing .o file with -o, though they will create one.
3906166124Srafanac_try='[$]$1 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
3907166124Srafanif AC_TRY_EVAL(ac_try) &&
3908166124Srafan  test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
3909166124Srafanthen
3910166124Srafan  eval cf_cv_prog_$1_c_o=yes
3911166124Srafanelse
3912166124Srafan  eval cf_cv_prog_$1_c_o=no
3913166124Srafanfi
3914166124Srafanrm -f conftest*
3915166124Srafan])dnl
3916166124Srafanif test $cf_cv_prog_$1_c_o = yes; then
3917166124Srafan  AC_MSG_RESULT([yes])
3918166124Srafanelse
3919166124Srafan  AC_MSG_RESULT([no])
3920166124Srafanfi
3921166124Srafan])dnl
3922166124Srafandnl ---------------------------------------------------------------------------
3923166124Srafandnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
3924166124Srafandnl --------------
3925166124Srafandnl Check if C (preprocessor) -U and -D options are processed in the order
3926166124Srafandnl given rather than by type of option.  Some compilers insist on apply all
3927166124Srafandnl of the -U options after all of the -D options.  Others allow mixing them,
3928166124Srafandnl and may predefine symbols that conflict with those we define.
3929166124SrafanAC_DEFUN([CF_PROG_CC_U_D],
3930166124Srafan[
3931166124SrafanAC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
3932166124Srafan	cf_save_CPPFLAGS="$CPPFLAGS"
3933166124Srafan	CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
3934166124Srafan	AC_TRY_COMPILE([],[
3935166124Srafan#ifndef U_D_OPTIONS
3936166124Srafanmake an undefined-error
3937166124Srafan#endif
3938166124Srafan#ifdef  D_U_OPTIONS
3939166124Srafanmake a defined-error
3940166124Srafan#endif
3941166124Srafan	],[
3942166124Srafan	cf_cv_cc_u_d_options=yes],[
3943166124Srafan	cf_cv_cc_u_d_options=no])
3944166124Srafan	CPPFLAGS="$cf_save_CPPFLAGS"
3945166124Srafan])
3946166124Srafan])dnl
3947166124Srafandnl ---------------------------------------------------------------------------
3948166124Srafandnl CF_PROG_EGREP version: 1 updated: 2006/09/16 11:40:59
3949166124Srafandnl -------------
3950166124Srafandnl AC_PROG_EGREP was introduced in autoconf 2.53.
3951166124Srafandnl This macro adds a check to ensure the script found something.
3952166124SrafanAC_DEFUN([CF_PROG_EGREP],
3953166124Srafan[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
3954166124Srafan   [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
3955166124Srafan    then ac_cv_prog_egrep='grep -E'
3956166124Srafan    else ac_cv_prog_egrep='egrep'
3957166124Srafan    fi])
3958166124Srafan EGREP=$ac_cv_prog_egrep
3959166124Srafan AC_SUBST([EGREP])
3960166124Srafantest -z "$EGREP" && AC_MSG_ERROR(No egrep program found)
3961166124Srafan])dnl
3962166124Srafandnl ---------------------------------------------------------------------------
3963166124Srafandnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
3964166124Srafandnl -----------
396550276Speterdnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
396650276SpeterAC_DEFUN([CF_PROG_EXT],
396750276Speter[
396850276SpeterAC_REQUIRE([CF_CHECK_CACHE])
396950276Spetercase $cf_cv_system_name in
397050276Speteros2*)
397176726Speter    CFLAGS="$CFLAGS -Zmt"
397276726Speter    CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
397376726Speter    CXXFLAGS="$CXXFLAGS -Zmt"
3974166124Srafan    # autoconf's macro sets -Zexe and suffix both, which conflict:w
3975166124Srafan    LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
3976166124Srafan    ac_cv_exeext=.exe
397750276Speter    ;;
397850276Speteresac
3979166124Srafan
3980166124SrafanAC_EXEEXT
3981166124SrafanAC_OBJEXT
3982166124Srafan
3983166124SrafanPROG_EXT="$EXEEXT"
398450276SpeterAC_SUBST(PROG_EXT)
398597049Spetertest -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
398650276Speter])dnl
398750276Speterdnl ---------------------------------------------------------------------------
3988166124Srafandnl CF_PROG_INSTALL version: 5 updated: 2002/12/21 22:46:07
3989166124Srafandnl ---------------
399050276Speterdnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
399150276Speterdnl misc/tabset install won't work properly.  Usually this happens only when
399250276Speterdnl using the fallback mkinstalldirs script
399350276SpeterAC_DEFUN([CF_PROG_INSTALL],
399450276Speter[AC_PROG_INSTALL
399550276Spetercase $INSTALL in
399650276Speter/*)
399750276Speter  ;;
399850276Speter*)
399976726Speter  CF_DIRNAME(cf_dir,$INSTALL)
400050276Speter  test -z "$cf_dir" && cf_dir=.
4001166124Srafan  INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
400250276Speter  ;;
400350276Speteresac
400450276Speter])dnl
400550276Speterdnl ---------------------------------------------------------------------------
4006166124Srafandnl CF_PROG_LDCONFIG version: 1 updated: 2003/09/20 17:07:55
4007166124Srafandnl ----------------
4008166124Srafandnl Check for ldconfig, needed to fixup shared libraries that would be built
4009166124Srafandnl and then used in the install.
4010166124SrafanAC_DEFUN([CF_PROG_LDCONFIG],[
4011166124Srafanif test "$cross_compiling" = yes ; then
4012166124Srafan  LDCONFIG=:
4013166124Srafanelse
4014166124Srafancase "$cf_cv_system_name" in #(vi
4015166124Srafanfreebsd*) #(vi
4016166124Srafan  test -z "$LDCONFIG" && LDCONFIG="/sbin/ldconfig -R"
4017166124Srafan  ;;
4018166124Srafan*) LDPATH=$PATH:/sbin:/usr/sbin
4019166124Srafan  AC_PATH_PROG(LDCONFIG,ldconfig,,$LDPATH)
4020166124Srafan  ;;
4021166124Srafanesac
4022166124Srafanfi
4023166124SrafanAC_SUBST(LDCONFIG)
4024166124Srafan])dnl
4025166124Srafandnl ---------------------------------------------------------------------------
4026166124Srafandnl CF_PROG_LINT version: 1 updated: 2006/09/16 11:40:59
4027166124Srafandnl ------------
4028166124SrafanAC_DEFUN([CF_PROG_LINT],
4029166124Srafan[
4030166124SrafanAC_CHECK_PROGS(LINT, tdlint lint alint)
4031166124SrafanAC_SUBST(LINT_OPTS)
4032166124Srafan])dnl
4033166124Srafandnl ---------------------------------------------------------------------------
4034166124Srafandnl CF_REGEX version: 3 updated: 1997/11/01 14:26:01
4035166124Srafandnl --------
403650276Speterdnl Attempt to determine if we've got one of the flavors of regular-expression
403750276Speterdnl code that we can support.
403850276SpeterAC_DEFUN([CF_REGEX],
403950276Speter[
404050276SpeterAC_MSG_CHECKING([for regular-expression headers])
404150276SpeterAC_CACHE_VAL(cf_cv_regex,[
404250276SpeterAC_TRY_LINK([#include <sys/types.h>
404350276Speter#include <regex.h>],[
404450276Speter	regex_t *p;
404550276Speter	int x = regcomp(p, "", 0);
404650276Speter	int y = regexec(p, "", 0, 0, 0);
404750276Speter	regfree(p);
404850276Speter	],[cf_cv_regex="regex.h"],[
404950276Speter	AC_TRY_LINK([#include <regexp.h>],[
405050276Speter		char *p = compile("", "", "", 0);
405150276Speter		int x = step("", "");
405250276Speter	],[cf_cv_regex="regexp.h"],[
405350276Speter		cf_save_LIBS="$LIBS"
405450276Speter		LIBS="-lgen $LIBS"
405550276Speter		AC_TRY_LINK([#include <regexpr.h>],[
405650276Speter			char *p = compile("", "", "");
405750276Speter			int x = step("", "");
405850276Speter		],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
405950276Speter])
406050276SpeterAC_MSG_RESULT($cf_cv_regex)
406150276Spetercase $cf_cv_regex in
406250276Speter	regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
406350276Speter	regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
406450276Speter	regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
406550276Speteresac
406650276Speter])dnl
406750276Speterdnl ---------------------------------------------------------------------------
4068166124Srafandnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
4069166124Srafandnl ----------------
4070166124Srafandnl Remove all -U and -D options that refer to the given symbol from a list
4071166124Srafandnl of C compiler options.  This works around the problem that not all
4072166124Srafandnl compilers process -U and -D options from left-to-right, so a -U option
4073166124Srafandnl cannot be used to cancel the effect of a preceding -D option.
4074166124Srafandnl
4075166124Srafandnl $1 = target (which could be the same as the source variable)
4076166124Srafandnl $2 = source (including '$')
4077166124Srafandnl $3 = symbol to remove
4078166124Srafandefine([CF_REMOVE_DEFINE],
4079166124Srafan[
4080166124Srafan# remove $3 symbol from $2
4081166124Srafan$1=`echo "$2" | \
4082166124Srafan	sed	-e 's/-[[UD]]$3\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
4083166124Srafan		-e 's/-[[UD]]$3\(=[[^ 	]]*\)\?[$]//g'`
4084166124Srafan])dnl
4085166124Srafandnl ---------------------------------------------------------------------------
4086174993Srafandnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
4087174993Srafandnl -------------
4088174993Srafandnl Remove the given library from the symbol
4089174993Srafandnl
4090174993Srafandnl $1 = target (which could be the same as the source variable)
4091174993Srafandnl $2 = source (including '$')
4092174993Srafandnl $3 = library to remove
4093174993Srafandefine([CF_REMOVE_LIB],
4094174993Srafan[
4095174993Srafan# remove $3 library from $2
4096174993Srafan$1=`echo "$2" | sed -e 's/-l$3[[ 	]]//g' -e 's/-l$3[$]//'`
4097174993Srafan])dnl
4098174993Srafandnl ---------------------------------------------------------------------------
4099184989Srafandnl CF_RPATH_HACK version: 4 updated: 2008/09/13 12:53:26
4100174993Srafandnl -------------
4101174993SrafanAC_DEFUN([CF_RPATH_HACK],
4102174993Srafan[
4103174993SrafanAC_REQUIRE([CF_SHARED_OPTS])
4104174993SrafanAC_MSG_CHECKING(for updated LDFLAGS)
4105174993Srafanif test -n "$LDFLAGS" ; then
4106174993SrafanAC_MSG_RESULT(maybe)
4107174993SrafanCF_VERBOSE(...checking LDFLAGS $LDFLAGS)
4108174993SrafanCF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4109174993Srafancase "$EXTRA_LDFLAGS" in #(vi
4110174993Srafan-Wl,-rpath,*) #(vi
4111184989Srafan	cf_rpath_hack="-Wl,-rpath,"
4112184989Srafan	;;
4113174993Srafan-R\ *)
4114184989Srafan	cf_rpath_hack="-R "
4115184989Srafan	;;
4116174993Srafan-R*)
4117184989Srafan	cf_rpath_hack="-R"
4118184989Srafan	;;
4119174993Srafan*)
4120184989Srafan	cf_rpath_hack=
4121184989Srafan	;;
4122174993Srafanesac
4123174993Srafanif test -n "$cf_rpath_hack" ; then
4124184989Srafan	cf_rpath_dst=
4125184989Srafan	for cf_rpath_src in $LDFLAGS
4126184989Srafan	do
4127184989Srafan		CF_VERBOSE(Filtering $cf_rpath_src)
4128184989Srafan		case $cf_rpath_src in #(vi
4129184989Srafan		-L*) #(vi
4130184989Srafan			if test "$cf_rpath_hack" = "-R " ; then
4131184989Srafan				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e 's%-L%-R %'`
4132184989Srafan			else
4133184989Srafan				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e s%-L%$cf_rpath_hack%`
4134184989Srafan			fi
4135184989Srafan			CF_VERBOSE(...Filter $cf_rpath_tmp)
4136184989Srafan			EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
4137184989Srafan			;;
4138184989Srafan		esac
4139184989Srafan		cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
4140184989Srafan	done
4141184989Srafan	LDFLAGS=$cf_rpath_dst
4142184989Srafan	CF_VERBOSE(...checked LDFLAGS $LDFLAGS)
4143184989Srafan	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4144174993Srafanfi
4145174993Srafanelse
4146174993SrafanAC_MSG_RESULT(no)
4147174993Srafanfi
4148174993Srafan])dnl
4149174993Srafandnl ---------------------------------------------------------------------------
4150184989Srafandnl CF_SHARED_OPTS version: 53 updated: 2008/10/25 18:14:20
4151166124Srafandnl --------------
4152166124Srafandnl --------------
415350276Speterdnl Attempt to determine the appropriate CC/LD options for creating a shared
415450276Speterdnl library.
415550276Speterdnl
4156166124Srafandnl Note: ${LOCAL_LDFLAGS} is used to link executables that will run within the
415750276Speterdnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
415850276Speterdnl We avoid compiling-in a ../lib path for the shared library since that can
415950276Speterdnl lead to unexpected results at runtime.
4160166124Srafandnl ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared libraries
416150276Speterdnl are compiled in ../../lib
416250276Speterdnl
416350276Speterdnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
416450276Speterdnl to install symbolic links to the rel/abi versions of shared libraries.
416550276Speterdnl
416650276Speterdnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
416750276Speterdnl version when making symbolic links.
416850276Speterdnl
416997049Speterdnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
417097049Speterdnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
417197049Speterdnl (ex: libncurses.so.<ver>).
417297049Speterdnl
417350276Speterdnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
417450276SpeterAC_DEFUN([CF_SHARED_OPTS],
417550276Speter[
417650276Speter	AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
417797049Speter	LOCAL_LDFLAGS=
417897049Speter	LOCAL_LDFLAGS2=
417950276Speter	LD_SHARED_OPTS=
418050276Speter	INSTALL_LIB="-m 644"
418150276Speter
418250276Speter	cf_cv_do_symlinks=no
418350276Speter
418450276Speter	AC_MSG_CHECKING(if release/abi version should be used for shared libs)
418550276Speter	AC_ARG_WITH(shlib-version,
418650276Speter	[  --with-shlib-version=X  Specify rel or abi version for shared libs],
418750276Speter	[test -z "$withval" && withval=auto
418850276Speter	case $withval in #(vi
418950276Speter	yes) #(vi
419050276Speter		cf_cv_shlib_version=auto
419150276Speter		;;
419250276Speter	rel|abi|auto|no) #(vi
419350276Speter		cf_cv_shlib_version=$withval
419450276Speter		;;
419550276Speter	*)
4196178866Srafan		AC_MSG_ERROR([option value must be one of: rel, abi, auto or no])
419750276Speter		;;
419850276Speter	esac
419950276Speter	],[cf_cv_shlib_version=auto])
420050276Speter	AC_MSG_RESULT($cf_cv_shlib_version)
420150276Speter
420250276Speter	cf_cv_rm_so_locs=no
420350276Speter
420462449Speter	# Some less-capable ports of gcc support only -fpic
420562449Speter	CC_SHARED_OPTS=
420666963Speter	if test "$GCC" = yes
420762449Speter	then
420862449Speter		AC_MSG_CHECKING(which $CC option to use)
420962449Speter		cf_save_CFLAGS="$CFLAGS"
421062449Speter		for CC_SHARED_OPTS in -fPIC -fpic ''
421162449Speter		do
421262449Speter			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
421362449Speter			AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
421462449Speter		done
421562449Speter		AC_MSG_RESULT($CC_SHARED_OPTS)
421662449Speter		CFLAGS="$cf_save_CFLAGS"
421762449Speter	fi
421862449Speter
421997049Speter	cf_cv_shlib_version_infix=no
422097049Speter
422150276Speter	case $cf_cv_system_name in
422262449Speter	beos*)
4223166124Srafan		MK_SHARED_LIB='${CC} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
422462449Speter		;;
422597049Speter	cygwin*)
422697049Speter		CC_SHARED_OPTS=
4227174993Srafan		MK_SHARED_LIB='sh ../mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
422897049Speter		cf_cv_shlib_version=cygdll
422997049Speter		cf_cv_shlib_version_infix=cygdll
4230174993Srafan		cat >mk_shared_lib.sh <<-CF_EOF
4231174993Srafan		#!/bin/sh
4232174993Srafan		SHARED_LIB=\[$]1
4233174993Srafan		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4234174993Srafan		shift
4235174993Srafan		cat <<-EOF
4236174993Srafan		Linking shared library
4237174993Srafan		** SHARED_LIB \[$]SHARED_LIB
4238174993Srafan		** IMPORT_LIB \[$]IMPORT_LIB
4239174993SrafanEOF
4240174993Srafan		exec \[$]* -shared -Wl,--out-implib=../lib/\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o ../lib/\[$]{SHARED_LIB}
4241174993SrafanCF_EOF
4242174993Srafan		chmod +x mk_shared_lib.sh 
424397049Speter		;;
424497049Speter	darwin*)
424597049Speter		EXTRA_CFLAGS="-no-cpp-precomp"
424697049Speter		CC_SHARED_OPTS="-dynamic"
4247174993Srafan		MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
424897049Speter		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
424997049Speter		cf_cv_shlib_version_infix=yes
4250166124Srafan		AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
4251166124Srafan			cf_save_LDFLAGS=$LDFLAGS
4252166124Srafan			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4253166124Srafan			AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
4254166124Srafan				LDFLAGS=$cf_save_LDFLAGS])
4255166124Srafan		if test $cf_cv_ldflags_search_paths_first = yes; then
4256166124Srafan			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4257166124Srafan		fi
425897049Speter		;;
425950276Speter	hpux*)
426050276Speter		# (tested with gcc 2.7.2 -- I don't have c89)
426166963Speter		if test "$GCC" = yes; then
4262166124Srafan			LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
426350276Speter		else
426450276Speter			CC_SHARED_OPTS='+Z'
4265166124Srafan			LD_SHARED_OPTS='-Wl,+b,${libdir}'
426650276Speter		fi
4267166124Srafan		MK_SHARED_LIB='${LD} +b ${libdir} -b -o $[@]'
426850276Speter		# HP-UX shared libraries must be executable, and should be
426950276Speter		# readonly to exploit a quirk in the memory manager.
427050276Speter		INSTALL_LIB="-m 555"
427150276Speter		;;
427250276Speter	irix*)
427366963Speter		if test "$cf_cv_ld_rpath" = yes ; then
4274166124Srafan			if test "$GCC" = yes; then
4275166124Srafan				cf_ld_rpath_opt="-Wl,-rpath,"
4276166124Srafan				EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
4277166124Srafan			else
4278166124Srafan				cf_ld_rpath_opt="-rpath "
4279166124Srafan				EXTRA_LDFLAGS="-rpath \${libdir} $EXTRA_LDFLAGS"
4280166124Srafan			fi
428166963Speter		fi
428250276Speter		# tested with IRIX 5.2 and 'cc'.
428366963Speter		if test "$GCC" != yes; then
428450276Speter			CC_SHARED_OPTS='-KPIC'
4285184989Srafan			MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
4286184989Srafan		else
4287184989Srafan			MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]'
428850276Speter		fi
428950276Speter		cf_cv_rm_so_locs=yes
429050276Speter		;;
4291166124Srafan	linux*|gnu*|k*bsd*-gnu)
429266963Speter		if test "$DFT_LWR_MODEL" = "shared" ; then
4293166124Srafan			LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
429497049Speter			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
429550276Speter		fi
429666963Speter		if test "$cf_cv_ld_rpath" = yes ; then
429766963Speter			cf_ld_rpath_opt="-Wl,-rpath,"
4298166124Srafan			EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
429950276Speter		fi
4300166124Srafan		CF_SHARED_SONAME
4301184989Srafan		MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
430250276Speter		;;
4303174993Srafan	openbsd[[2-9]].*)
4304184989Srafan		if test "$DFT_LWR_MODEL" = "shared" ; then
4305184989Srafan			LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
4306184989Srafan			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4307184989Srafan		fi
4308184989Srafan		if test "$cf_cv_ld_rpath" = yes ; then
4309184989Srafan			cf_ld_rpath_opt="-Wl,-rpath,"
4310184989Srafan			EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
4311184989Srafan		fi
431266963Speter		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4313184989Srafan		CF_SHARED_SONAME
4314184989Srafan		MK_SHARED_LIB='${CC} ${CFLAGS} -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
431550276Speter		;;
4316184989Srafan	nto-qnx*|openbsd*|freebsd[[12]].*)
431766963Speter		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4318166124Srafan		MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
431966963Speter		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
432050276Speter		;;
4321166124Srafan	freebsd*)
4322166124Srafan		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4323166124Srafan		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
4324166124Srafan			LOCAL_LDFLAGS="-rpath \$(LOCAL_LIBDIR)"
4325166124Srafan			LOCAL_LDFLAGS2="-rpath \${libdir} $LOCAL_LDFLAGS"
4326166124Srafan			cf_ld_rpath_opt="-rpath "
4327166124Srafan			EXTRA_LDFLAGS="-rpath \${libdir} $EXTRA_LDFLAGS"
4328166124Srafan		fi
4329166124Srafan		CF_SHARED_SONAME
4330166124Srafan		MK_SHARED_LIB='${LD} -Bshareable -soname=`basename $[@]` -o $[@]'
4331166124Srafan		;;
433256639Speter	netbsd*)
433366963Speter		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
433466963Speter		test "$cf_cv_ld_rpath" = yes && cf_ld_rpath_opt="-Wl,-rpath,"
433566963Speter		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
4336166124Srafan			LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
433797049Speter			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4338166124Srafan			EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
433966963Speter			if test "$cf_cv_shlib_version" = auto; then
4340166124Srafan			if test -f /usr/libexec/ld.elf_so; then
4341166124Srafan				cf_cv_shlib_version=abi
4342166124Srafan			else
434366963Speter				cf_cv_shlib_version=rel
434466963Speter			fi
434566963Speter			fi
4346166124Srafan			CF_SHARED_SONAME
4347184989Srafan			MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
434856639Speter		else
4349166124Srafan			MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
435056639Speter		fi
435156639Speter		;;
435250276Speter	osf*|mls+*)
435350276Speter		# tested with OSF/1 V3.2 and 'cc'
435450276Speter		# tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
435550276Speter		# link with shared libs).
4356166124Srafan		MK_SHARED_LIB='${LD} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
435750276Speter		case $host_os in
435850276Speter		osf4*)
435997049Speter			MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
436050276Speter			;;
436150276Speter		esac
436250276Speter		MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
436366963Speter		if test "$DFT_LWR_MODEL" = "shared" ; then
4364166124Srafan			LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
436597049Speter			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
436650276Speter		fi
436766963Speter		if test "$cf_cv_ld_rpath" = yes ; then
436866963Speter			cf_ld_rpath_opt="-rpath"
436966963Speter			# EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
437066963Speter		fi
437150276Speter		cf_cv_rm_so_locs=yes
437250276Speter		;;
437350276Speter	sco3.2v5*)  # (also uw2* and UW7) hops 13-Apr-98
437450276Speter		# tested with osr5.0.5
4375166124Srafan		if test "$GCC" != yes; then
437656639Speter			CC_SHARED_OPTS='-belf -KPIC'
437750276Speter		fi
4378166124Srafan		MK_SHARED_LIB='${LD} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
437966963Speter		if test "$cf_cv_ld_rpath" = yes ; then
438050276Speter			# only way is to set LD_RUN_PATH but no switch for it
438150276Speter			RUN_PATH=$libdir
438250276Speter		fi
438366963Speter		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4384166124Srafan		LINK_PROGS='LD_RUN_PATH=${libdir}'
438550276Speter		LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
438650276Speter		;;
438750276Speter	sunos4*)
438850276Speter		# tested with SunOS 4.1.1 and gcc 2.7.0
4389166124Srafan		if test "$GCC" != yes; then
439050276Speter			CC_SHARED_OPTS='-KPIC'
439150276Speter		fi
4392166124Srafan		MK_SHARED_LIB='${LD} -assert pure-text -o $[@]'
439366963Speter		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
439450276Speter		;;
439550276Speter	solaris2*)
439650276Speter		# tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
4397184989Srafan		# tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
439866963Speter		if test "$DFT_LWR_MODEL" = "shared" ; then
4399166124Srafan			LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
440097049Speter			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
440166963Speter		fi
440266963Speter		if test "$cf_cv_ld_rpath" = yes ; then
440350276Speter			cf_ld_rpath_opt="-R"
440466963Speter			EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
440550276Speter		fi
4406166124Srafan		CF_SHARED_SONAME
4407184989Srafan		if test "$GCC" != yes; then
4408184989Srafan			CC_SHARED_OPTS='-xcode=pic32'
4409184989Srafan			MK_SHARED_LIB='${CC} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
4410184989Srafan		else
4411184989Srafan			MK_SHARED_LIB='${CC} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
4412184989Srafan		fi
441350276Speter		;;
441462449Speter	sysv5uw7*|unix_sv*)
441562449Speter		# tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
4416166124Srafan		if test "$GCC" != yes; then
441762449Speter			CC_SHARED_OPTS='-KPIC'
441862449Speter		fi
4419166124Srafan		MK_SHARED_LIB='${LD} -d y -G -o [$]@'
442050276Speter		;;
442150276Speter	*)
442250276Speter		CC_SHARED_OPTS='unknown'
442350276Speter		MK_SHARED_LIB='echo unknown'
442450276Speter		;;
442550276Speter	esac
442650276Speter
442750276Speter	# This works if the last tokens in $MK_SHARED_LIB are the -o target.
442850276Speter	case "$cf_cv_shlib_version" in #(vi
442950276Speter	rel|abi)
443050276Speter		case "$MK_SHARED_LIB" in #(vi
443150276Speter		*'-o $[@]')
443266963Speter			test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
443350276Speter			;;
443450276Speter		*)
443550276Speter			AC_MSG_WARN(ignored --with-shlib-version)
443650276Speter			;;
443750276Speter		esac
443850276Speter		;;
443950276Speter	esac
444050276Speter
444150276Speter	if test -n "$cf_ld_rpath_opt" ; then
444250276Speter		AC_MSG_CHECKING(if we need a space after rpath option)
444350276Speter		cf_save_LIBS="$LIBS"
444466963Speter		LIBS="$LIBS ${cf_ld_rpath_opt}$libdir"
444550276Speter		AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
444650276Speter		LIBS="$cf_save_LIBS"
444750276Speter		AC_MSG_RESULT($cf_rpath_space)
444866963Speter		test "$cf_rpath_space" = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
4449166124Srafan		MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${libdir}"
445050276Speter	fi
445150276Speter
445250276Speter	AC_SUBST(CC_SHARED_OPTS)
445350276Speter	AC_SUBST(LD_SHARED_OPTS)
445450276Speter	AC_SUBST(MK_SHARED_LIB)
445550276Speter	AC_SUBST(LINK_PROGS)
445650276Speter	AC_SUBST(LINK_TESTS)
445750276Speter	AC_SUBST(EXTRA_LDFLAGS)
445850276Speter	AC_SUBST(LOCAL_LDFLAGS)
445950276Speter	AC_SUBST(LOCAL_LDFLAGS2)
446050276Speter	AC_SUBST(INSTALL_LIB)
446150276Speter])dnl
446250276Speterdnl ---------------------------------------------------------------------------
4463184989Srafandnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
4464166124Srafandnl ----------------
4465184989Srafandnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
4466166124Srafandnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
4467166124Srafandnl option.
4468166124Srafandnl
4469166124Srafandnl $1 is the default that should be used for "$cf_cv_shlib_version".
4470166124Srafandnl If missing, use "rel".
4471166124Srafandefine([CF_SHARED_SONAME],
4472166124Srafan[
4473166124Srafan	test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
4474166124Srafan	if test "$cf_cv_shlib_version" = rel; then
4475184989Srafan		cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
4476166124Srafan	else
4477184989Srafan		cf_cv_shared_soname='`basename $[@]`'
4478166124Srafan	fi
4479166124Srafan])
4480166124Srafandnl ---------------------------------------------------------------------------
4481166124Srafandnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
4482166124Srafandnl -----------
4483166124Srafandnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
4484166124Srafandnl programs need this test).
4485166124Srafandnl
4486166124Srafandnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
4487166124Srafandnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
4488166124Srafandnl winsize declaration is left alone - we may revisit this if Apple choose to
4489166124Srafandnl break that part of the interface as well.
4490166124SrafanAC_DEFUN([CF_SIGWINCH],
4491166124Srafan[
4492166124SrafanAC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
4493166124Srafan	AC_TRY_COMPILE([
4494166124Srafan#include <sys/types.h>
4495166124Srafan#include <sys/signal.h>
4496166124Srafan],[int x = SIGWINCH],
4497166124Srafan	[cf_cv_define_sigwinch=yes],
4498166124Srafan	[AC_TRY_COMPILE([
4499166124Srafan#undef _XOPEN_SOURCE
4500166124Srafan#undef _POSIX_SOURCE
4501166124Srafan#undef _POSIX_C_SOURCE
4502166124Srafan#include <sys/types.h>
4503166124Srafan#include <sys/signal.h>
4504166124Srafan],[int x = SIGWINCH],
4505166124Srafan	[cf_cv_define_sigwinch=maybe],
4506166124Srafan	[cf_cv_define_sigwinch=no])
4507166124Srafan])
4508166124Srafan])
4509166124Srafan
4510166124Srafanif test "$cf_cv_define_sigwinch" = maybe ; then
4511166124SrafanAC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
4512166124Srafancf_cv_fixup_sigwinch=unknown
4513166124Srafancf_sigwinch=32
4514166124Srafanwhile test $cf_sigwinch != 1
4515166124Srafando
4516166124Srafan	AC_TRY_COMPILE([
4517166124Srafan#undef _XOPEN_SOURCE
4518166124Srafan#undef _POSIX_SOURCE
4519166124Srafan#undef _POSIX_C_SOURCE
4520166124Srafan#include <sys/types.h>
4521166124Srafan#include <sys/signal.h>
4522166124Srafan],[
4523166124Srafan#if SIGWINCH != $cf_sigwinch
4524166124Srafanmake an error
4525166124Srafan#endif
4526166124Srafanint x = SIGWINCH],
4527166124Srafan	[cf_cv_fixup_sigwinch=$cf_sigwinch
4528166124Srafan	 break])
4529166124Srafan
4530166124Srafancf_sigwinch=`expr $cf_sigwinch - 1`
4531166124Srafandone
4532166124Srafan])
4533166124Srafan
4534166124Srafan	if test "$cf_cv_fixup_sigwinch" != unknown ; then
4535166124Srafan		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
4536166124Srafan	fi
4537166124Srafanfi
4538166124Srafan])dnl
4539166124Srafandnl ---------------------------------------------------------------------------
4540174993Srafandnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
4541174993Srafandnl ---------------
4542174993Srafandnl signal handler, but there are some gcc depedencies in that recommendation.
4543174993Srafandnl Try anyway.
4544174993SrafanAC_DEFUN([CF_SIG_ATOMIC_T],
4545174993Srafan[
4546174993SrafanAC_MSG_CHECKING(for signal global datatype)
4547174993SrafanAC_CACHE_VAL(cf_cv_sig_atomic_t,[
4548174993Srafan	for cf_type in \
4549174993Srafan		"volatile sig_atomic_t" \
4550174993Srafan		"sig_atomic_t" \
4551174993Srafan		"int"
4552174993Srafan	do
4553174993Srafan	AC_TRY_COMPILE([
4554174993Srafan#include <sys/types.h>
4555174993Srafan#include <signal.h>
4556174993Srafan#include <stdio.h>
4557174993Srafan
4558174993Srafanextern $cf_type x;
4559174993Srafan$cf_type x;
4560174993Srafanstatic void handler(int sig)
4561174993Srafan{
4562174993Srafan	x = 5;
4563174993Srafan}],
4564174993Srafan		[signal(SIGINT, handler);
4565174993Srafan		 x = 1],
4566174993Srafan		[cf_cv_sig_atomic_t=$cf_type],
4567174993Srafan		[cf_cv_sig_atomic_t=no])
4568174993Srafan		test "$cf_cv_sig_atomic_t" != no && break
4569174993Srafan	done
4570174993Srafan	])
4571174993SrafanAC_MSG_RESULT($cf_cv_sig_atomic_t)
4572174993Srafantest "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
4573174993Srafan])dnl
4574174993Srafandnl ---------------------------------------------------------------------------
4575166124Srafandnl CF_SIZECHANGE version: 8 updated: 2000/11/04 12:22:16
4576166124Srafandnl -------------
457750276Speterdnl Check for definitions & structures needed for window size-changing
457850276Speterdnl FIXME: check that this works with "snake" (HP-UX 10.x)
457950276SpeterAC_DEFUN([CF_SIZECHANGE],
458050276Speter[
458166963SpeterAC_REQUIRE([CF_STRUCT_TERMIOS])
458266963SpeterAC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
458350276Speter    cf_cv_sizechange=unknown
458476726Speter    cf_save_CPPFLAGS="$CPPFLAGS"
458550276Speter
458650276Speterfor cf_opts in "" "NEED_PTEM_H"
458750276Speterdo
458850276Speter
458976726Speter    CPPFLAGS="$cf_save_CPPFLAGS"
459076726Speter    test -n "$cf_opts" && CPPFLAGS="$CPPFLAGS -D$cf_opts"
459150276Speter    AC_TRY_COMPILE([#include <sys/types.h>
459266963Speter#ifdef HAVE_TERMIOS_H
459350276Speter#include <termios.h>
459450276Speter#else
459566963Speter#ifdef HAVE_TERMIO_H
459650276Speter#include <termio.h>
459750276Speter#endif
459850276Speter#endif
459966963Speter#ifdef NEED_PTEM_H
460050276Speter/* This is a workaround for SCO:  they neglected to define struct winsize in
460150276Speter * termios.h -- it's only in termio.h and ptem.h
460250276Speter */
460350276Speter#include        <sys/stream.h>
460450276Speter#include        <sys/ptem.h>
460550276Speter#endif
460650276Speter#if !defined(sun) || !defined(HAVE_TERMIOS_H)
460750276Speter#include <sys/ioctl.h>
460850276Speter#endif
460950276Speter],[
461050276Speter#ifdef TIOCGSIZE
461150276Speter	struct ttysize win;	/* FIXME: what system is this? */
461250276Speter	int y = win.ts_lines;
461350276Speter	int x = win.ts_cols;
461450276Speter#else
461550276Speter#ifdef TIOCGWINSZ
461650276Speter	struct winsize win;
461750276Speter	int y = win.ws_row;
461850276Speter	int x = win.ws_col;
461950276Speter#else
462050276Speter	no TIOCGSIZE or TIOCGWINSZ
462150276Speter#endif /* TIOCGWINSZ */
462250276Speter#endif /* TIOCGSIZE */
462350276Speter	],
462450276Speter	[cf_cv_sizechange=yes],
462550276Speter	[cf_cv_sizechange=no])
462650276Speter
462776726Speter	CPPFLAGS="$cf_save_CPPFLAGS"
462850276Speter	if test "$cf_cv_sizechange" = yes ; then
462950276Speter		echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
463066963Speter		test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
463150276Speter		break
463250276Speter	fi
463350276Speterdone
463466963Speter])
463566963Speterif test "$cf_cv_sizechange" != no ; then
463666963Speter	AC_DEFINE(HAVE_SIZECHANGE)
463766963Speter	case $cf_cv_sizechange in #(vi
463866963Speter	NEED*)
463966963Speter		AC_DEFINE_UNQUOTED($cf_cv_sizechange )
464066963Speter		;;
464166963Speter	esac
464250276Speterfi
464350276Speter])dnl
464450276Speterdnl ---------------------------------------------------------------------------
4645166124Srafandnl CF_SRC_MODULES version: 18 updated: 2005/05/28 12:58:54
4646166124Srafandnl --------------
464750276Speterdnl For each parameter, test if the source-directory exists, and if it contains
464850276Speterdnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
464950276Speterdnl use in CF_LIB_RULES.
465050276Speterdnl
465150276Speterdnl This uses the configured value to make the lists SRC_SUBDIRS and
465250276Speterdnl SUB_MAKEFILES which are used in the makefile-generation scheme.
465350276SpeterAC_DEFUN([CF_SRC_MODULES],
465450276Speter[
465550276SpeterAC_MSG_CHECKING(for src modules)
465650276Speter
465750276Speter# dependencies and linker-arguments for test-programs
465862449SpeterTEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
4659166124SrafanTEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEP2"
466076726Speterif test "$DFT_LWR_MODEL" = "libtool"; then
466176726Speter	TEST_ARGS="${TEST_DEPS}"
4662166124Srafan	TEST_ARG2="${TEST_DEP2}"
466376726Speterelse
466476726Speter	TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
4665166124Srafan	TEST_ARG2="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARG2"
466676726Speterfi
466750276Speter
466850276Spetercf_cv_src_modules=
466950276Speterfor cf_dir in $1
467050276Speterdo
467150276Speter	if test -f $srcdir/$cf_dir/modules; then
467250276Speter
467350276Speter		# We may/may not have tack in the distribution, though the
467450276Speter		# makefile is.
467550276Speter		if test $cf_dir = tack ; then
467650276Speter			if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
467750276Speter				continue
467850276Speter			fi
467950276Speter		fi
468050276Speter
468150276Speter		if test -z "$cf_cv_src_modules"; then
468250276Speter			cf_cv_src_modules=$cf_dir
468350276Speter		else
468450276Speter			cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
468550276Speter		fi
468650276Speter
468750276Speter		# Make the ncurses_cfg.h file record the library interface files as
468850276Speter		# well.  These are header files that are the same name as their
468950276Speter		# directory.  Ncurses is the only library that does not follow
469050276Speter		# that pattern.
469150276Speter		if test $cf_dir = tack ; then
469250276Speter			continue
469350276Speter		elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
469450276Speter			CF_UPPER(cf_have_include,$cf_dir)
469550276Speter			AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
469650276Speter			AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
469762449Speter			TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
4698166124Srafan			TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEP2"
469976726Speter			if test "$DFT_LWR_MODEL" = "libtool"; then
470076726Speter				TEST_ARGS="${TEST_DEPS}"
4701166124Srafan				TEST_ARG2="${TEST_DEP2}"
470276726Speter			else
470376726Speter				TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
4704166124Srafan				TEST_ARG2="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARG2"
470576726Speter			fi
470650276Speter		fi
470750276Speter	fi
470850276Speterdone
470950276SpeterAC_MSG_RESULT($cf_cv_src_modules)
4710166124Srafan
471197049SpeterTEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
4712166124SrafanTEST_ARG2="-L${LIB_2ND} $TEST_ARG2"
4713166124Srafan
4714166124SrafanAC_SUBST(TEST_ARGS)
471550276SpeterAC_SUBST(TEST_DEPS)
471650276Speter
4717166124SrafanAC_SUBST(TEST_ARG2)
4718166124SrafanAC_SUBST(TEST_DEP2)
471950276Speter
472050276SpeterSRC_SUBDIRS="man include"
472150276Speterfor cf_dir in $cf_cv_src_modules
472250276Speterdo
472350276Speter	SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
472450276Speterdone
472597049SpeterSRC_SUBDIRS="$SRC_SUBDIRS test"
472697049Spetertest -z "$MAKE_TERMINFO" && SRC_SUBDIRS="$SRC_SUBDIRS misc"
472766963Spetertest "$cf_with_cxx_binding" != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
472850276Speter
472950276SpeterADA_SUBDIRS=
473062449Speterif test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then
473150276Speter   SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
473250276Speter   ADA_SUBDIRS="gen src samples"
473350276Speterfi
473450276Speter
473550276SpeterSUB_MAKEFILES=
473650276Speterfor cf_dir in $SRC_SUBDIRS
473750276Speterdo
473850276Speter	SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
473950276Speterdone
474050276Speter
474150276Speterif test -n "$ADA_SUBDIRS"; then
474250276Speter   for cf_dir in $ADA_SUBDIRS
474350276Speter   do
474450276Speter      SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
474550276Speter   done
474650276Speter   AC_SUBST(ADA_SUBDIRS)
474750276Speterfi
474850276Speter])dnl
474950276Speterdnl ---------------------------------------------------------------------------
4750166124Srafandnl CF_STDCPP_LIBRARY version: 5 updated: 2000/08/12 23:18:52
4751166124Srafandnl -----------------
475256639Speterdnl Check for -lstdc++, which is GNU's standard C++ library.
475356639SpeterAC_DEFUN([CF_STDCPP_LIBRARY],
475456639Speter[
475556639Speterif test -n "$GXX" ; then
475656639Spetercase $cf_cv_system_name in #(vi
475756639Speteros2*) #(vi
475856639Speter	cf_stdcpp_libname=stdcpp
475956639Speter	;;
476056639Speter*)
476156639Speter	cf_stdcpp_libname=stdc++
476256639Speter	;;
476356639Speteresac
476456639SpeterAC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
476556639Speter	cf_save="$LIBS"
476662449Speter	LIBS="$LIBS -l$cf_stdcpp_libname"
476756639SpeterAC_TRY_LINK([
476856639Speter#include <strstream.h>],[
476956639Speterchar buf[80];
477056639Speterstrstreambuf foo(buf, sizeof(buf))
477156639Speter],
477256639Speter	[cf_cv_libstdcpp=yes],
477356639Speter	[cf_cv_libstdcpp=no])
477456639Speter	LIBS="$cf_save"
477556639Speter])
477666963Spetertest "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
477756639Speterfi
477856639Speter])dnl
477956639Speterdnl ---------------------------------------------------------------------------
4780166124Srafandnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
4781166124Srafandnl --------------
478250276Speterdnl	Remove "-g" option from the compiler options
478350276SpeterAC_DEFUN([CF_STRIP_G_OPT],
4784166124Srafan[$1=`echo ${$1} | sed -e 's%-g %%' -e 's%-g$%%'`])dnl
478550276Speterdnl ---------------------------------------------------------------------------
4786166124Srafandnl CF_STRUCT_SIGACTION version: 3 updated: 2000/08/12 23:18:52
4787166124Srafandnl -------------------
478850276Speterdnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
478950276Speterdnl do this if we've found the sigaction function.
479050276Speterdnl
479150276Speterdnl If needed, define SVR4_ACTION.
479250276SpeterAC_DEFUN([CF_STRUCT_SIGACTION],[
479366963Speterif test "$ac_cv_func_sigaction" = yes; then
479450276SpeterAC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
479550276SpeterAC_TRY_COMPILE([
479650276Speter#include <sys/types.h>
479750276Speter#include <signal.h>],
479850276Speter	[struct sigaction act],
479950276Speter	[sigact_bad=no],
480050276Speter	[
480150276SpeterAC_TRY_COMPILE([
480250276Speter#define _POSIX_SOURCE
480350276Speter#include <sys/types.h>
480450276Speter#include <signal.h>],
480550276Speter	[struct sigaction act],
480650276Speter	[sigact_bad=yes
480750276Speter	 AC_DEFINE(SVR4_ACTION)],
480850276Speter	 [sigact_bad=unknown])])
480950276SpeterAC_MSG_RESULT($sigact_bad)
481050276Speterfi
481150276Speter])dnl
481250276Speterdnl ---------------------------------------------------------------------------
4813166124Srafandnl CF_STRUCT_TERMIOS version: 5 updated: 2000/11/04 12:22:46
4814166124Srafandnl -----------------
481550276Speterdnl Some machines require _POSIX_SOURCE to completely define struct termios.
481650276Speterdnl If so, define SVR4_TERMIO
481750276SpeterAC_DEFUN([CF_STRUCT_TERMIOS],[
481866963SpeterAC_CHECK_HEADERS( \
481966963Spetertermio.h \
482066963Spetertermios.h \
482166963Speterunistd.h \
482266963Speter)
482366963Speterif test "$ISC" = yes ; then
482466963Speter	AC_CHECK_HEADERS( sys/termio.h )
482566963Speterfi
482666963Speterif test "$ac_cv_header_termios_h" = yes ; then
482776726Speter	case "$CFLAGS $CPPFLAGS" in
482850276Speter	*-D_POSIX_SOURCE*)
482950276Speter		termios_bad=dunno ;;
483050276Speter	*)	termios_bad=maybe ;;
483150276Speter	esac
483266963Speter	if test "$termios_bad" = maybe ; then
483350276Speter	AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
483450276Speter	AC_TRY_COMPILE([#include <termios.h>],
483550276Speter		[struct termios foo; int x = foo.c_iflag],
483650276Speter		termios_bad=no, [
483750276Speter		AC_TRY_COMPILE([
483850276Speter#define _POSIX_SOURCE
483950276Speter#include <termios.h>],
484050276Speter			[struct termios foo; int x = foo.c_iflag],
484150276Speter			termios_bad=unknown,
484250276Speter			termios_bad=yes AC_DEFINE(SVR4_TERMIO))
484350276Speter			])
484450276Speter	AC_MSG_RESULT($termios_bad)
484550276Speter	fi
484650276Speterfi
484750276Speter])dnl
484850276Speterdnl ---------------------------------------------------------------------------
4849184989Srafandnl CF_SUBDIR_PATH version: 5 updated: 2007/07/29 09:55:12
4850184989Srafandnl --------------
4851184989Srafandnl Construct a search-list for a nonstandard header/lib-file
4852184989Srafandnl	$1 = the variable to return as result
4853184989Srafandnl	$2 = the package name
4854184989Srafandnl	$3 = the subdirectory, e.g., bin, include or lib
4855184989SrafanAC_DEFUN([CF_SUBDIR_PATH],
4856184989Srafan[$1=""
4857184989Srafan
4858184989SrafanCF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
4859184989SrafanCF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
4860184989SrafanCF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
4861184989SrafanCF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
4862184989SrafanCF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
4863184989Srafan])dnl
4864184989Srafandnl ---------------------------------------------------------------------------
4865166124Srafandnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
4866166124Srafandnl --------
486750276Speterdnl	Shorthand macro for substituting things that the user may override
486850276Speterdnl	with an environment variable.
486950276Speterdnl
487050276Speterdnl	$1 = long/descriptive name
487150276Speterdnl	$2 = environment variable
487250276Speterdnl	$3 = default value
487350276SpeterAC_DEFUN([CF_SUBST],
487450276Speter[AC_CACHE_VAL(cf_cv_subst_$2,[
487550276SpeterAC_MSG_CHECKING(for $1 (symbol $2))
4876166124SrafanCF_SUBST_IF([-z "[$]$2"], [$2], [$3])
4877166124Srafancf_cv_subst_$2=[$]$2
487850276SpeterAC_MSG_RESULT([$]$2)
4879166124Srafan])
4880166124Srafan])dnl
4881166124Srafandnl ---------------------------------------------------------------------------
4882166124Srafandnl CF_SUBST_IF version: 2 updated: 2006/06/17 12:33:03
4883166124Srafandnl -----------
4884166124Srafandnl	Shorthand macro for substituting things that the user may override
4885166124Srafandnl	with an environment variable.
4886166124Srafandnl
4887166124Srafandnl	$1 = condition to pass to "test"
4888166124Srafandnl	$2 = environment variable
4889166124Srafandnl	$3 = value if the test succeeds
4890166124Srafandnl	$4 = value if the test fails
4891166124SrafanAC_DEFUN([CF_SUBST_IF],
4892166124Srafan[
4893166124Srafanif test $1 ; then
4894166124Srafan	$2=$3
4895166124Srafanifelse($4,,,[else
4896166124Srafan	$2=$4])
4897166124Srafanfi
489850276SpeterAC_SUBST($2)
489950276Speter])dnl
490050276Speterdnl ---------------------------------------------------------------------------
4901166124Srafandnl CF_SUBST_NCURSES_VERSION version: 8 updated: 2006/09/16 11:40:59
4902166124Srafandnl ------------------------
490350276Speterdnl Get the version-number for use in shared-library naming, etc.
490450276SpeterAC_DEFUN([CF_SUBST_NCURSES_VERSION],
490550276Speter[
4906166124SrafanAC_REQUIRE([CF_PROG_EGREP])
4907166124SrafanNCURSES_MAJOR="`$ac_cv_prog_egrep '^NCURSES_MAJOR[[ 	]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
4908166124SrafanNCURSES_MINOR="`$ac_cv_prog_egrep '^NCURSES_MINOR[[ 	]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
4909166124SrafanNCURSES_PATCH="`$ac_cv_prog_egrep '^NCURSES_PATCH[[ 	]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
491050276Spetercf_cv_abi_version=${NCURSES_MAJOR}
491150276Spetercf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
491250276Speterdnl Show the computed version, for logging
491397049Spetercf_cv_timestamp=`date`
491497049SpeterAC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
491550276Speterdnl We need these values in the generated headers
491650276SpeterAC_SUBST(NCURSES_MAJOR)
491750276SpeterAC_SUBST(NCURSES_MINOR)
491850276SpeterAC_SUBST(NCURSES_PATCH)
491950276Speterdnl We need these values in the generated makefiles
492050276SpeterAC_SUBST(cf_cv_rel_version)
492150276SpeterAC_SUBST(cf_cv_abi_version)
492250276SpeterAC_SUBST(cf_cv_builtin_bool)
492397049SpeterAC_SUBST(cf_cv_header_stdbool_h)
492450276SpeterAC_SUBST(cf_cv_type_of_bool)dnl
492550276Speter])dnl
492650276Speterdnl ---------------------------------------------------------------------------
4927166124Srafandnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
4928166124Srafandnl ------------------
492950276Speterdnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
493050276Speterdnl older SCO configurations.
493150276SpeterAC_DEFUN([CF_SYS_TIME_SELECT],
493250276Speter[
493350276SpeterAC_MSG_CHECKING(if sys/time.h works with sys/select.h)
493450276SpeterAC_CACHE_VAL(cf_cv_sys_time_select,[
493550276SpeterAC_TRY_COMPILE([
493650276Speter#include <sys/types.h>
493766963Speter#ifdef HAVE_SYS_TIME_H
493850276Speter#include <sys/time.h>
493950276Speter#endif
494066963Speter#ifdef HAVE_SYS_SELECT_H
494150276Speter#include <sys/select.h>
494250276Speter#endif
494350276Speter],[],[cf_cv_sys_time_select=yes],
494450276Speter     [cf_cv_sys_time_select=no])
494550276Speter     ])
494650276SpeterAC_MSG_RESULT($cf_cv_sys_time_select)
494766963Spetertest "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
494850276Speter])dnl
494950276Speterdnl ---------------------------------------------------------------------------
4950166124Srafandnl CF_TOP_BUILDDIR version: 1 updated: 2006/10/15 16:33:23
4951166124Srafandnl ---------------
4952166124Srafandnl Define a top_builddir symbol, for applications that need an absolute path.
4953166124SrafanAC_DEFUN([CF_TOP_BUILDDIR],
4954166124Srafan[
4955166124Srafantop_builddir=`pwd`
4956166124SrafanAC_SUBST(top_builddir)
4957166124Srafan])dnl
4958166124Srafandnl ---------------------------------------------------------------------------
4959166124Srafandnl CF_TYPEOF_CHTYPE version: 8 updated: 2006/12/16 12:33:30
4960166124Srafandnl ----------------
496150276Speterdnl Determine the type we should use for chtype (and attr_t, which is treated
496250276Speterdnl as the same thing).  We want around 32 bits, so on most machines want a
496350276Speterdnl long, but on newer 64-bit machines, probably want an int.  If we're using
496450276Speterdnl wide characters, we have to have a type compatible with that, as well.
496550276SpeterAC_DEFUN([CF_TYPEOF_CHTYPE],
496650276Speter[
496750276SpeterAC_MSG_CHECKING([for type of chtype])
496850276SpeterAC_CACHE_VAL(cf_cv_typeof_chtype,[
496950276Speter		AC_TRY_RUN([
497050276Speter#define WANT_BITS 31
497150276Speter#include <stdio.h>
497250276Speterint main()
497350276Speter{
497450276Speter	FILE *fp = fopen("cf_test.out", "w");
497550276Speter	if (fp != 0) {
497650276Speter		char *result = "long";
497750276Speter		if (sizeof(unsigned long) > sizeof(unsigned int)) {
497850276Speter			int n;
4979166124Srafan			unsigned int x, y;
498050276Speter			for (n = 0; n < WANT_BITS; n++) {
4981166124Srafan				x = (1 << n);
4982166124Srafan				y = (x >> n);
498350276Speter				if (y != 1 || x == 0) {
498450276Speter					x = 0;
498550276Speter					break;
498650276Speter				}
498750276Speter			}
498850276Speter			/*
498950276Speter			 * If x is nonzero, an int is big enough for the bits
499050276Speter			 * that we want.
499150276Speter			 */
499250276Speter			result = (x != 0) ? "int" : "long";
499350276Speter		}
499450276Speter		fputs(result, fp);
499550276Speter		fclose(fp);
499650276Speter	}
4997166124Srafan	${cf_cv_main_return:-return}(0);
499850276Speter}
499950276Speter		],
500050276Speter		[cf_cv_typeof_chtype=`cat cf_test.out`],
500150276Speter		[cf_cv_typeof_chtype=long],
500250276Speter		[cf_cv_typeof_chtype=long])
500350276Speter		rm -f cf_test.out
500450276Speter	])
500550276SpeterAC_MSG_RESULT($cf_cv_typeof_chtype)
500650276Speter
500750276SpeterAC_SUBST(cf_cv_typeof_chtype)
500850276SpeterAC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
500950276Speter])dnl
501050276Speterdnl ---------------------------------------------------------------------------
5011166124Srafandnl CF_TYPE_SIGACTION version: 3 updated: 2000/08/12 23:18:52
5012166124Srafandnl -----------------
501350276Speterdnl
501450276SpeterAC_DEFUN([CF_TYPE_SIGACTION],
501550276Speter[
501650276SpeterAC_MSG_CHECKING([for type sigaction_t])
501750276SpeterAC_CACHE_VAL(cf_cv_type_sigaction,[
501850276Speter	AC_TRY_COMPILE([
501950276Speter#include <signal.h>],
502050276Speter		[sigaction_t x],
502150276Speter		[cf_cv_type_sigaction=yes],
502250276Speter		[cf_cv_type_sigaction=no])])
502350276SpeterAC_MSG_RESULT($cf_cv_type_sigaction)
502466963Spetertest "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
502550276Speter])dnl
502650276Speterdnl ---------------------------------------------------------------------------
5027166124Srafandnl CF_UNSIGNED_LITERALS version: 2 updated: 1998/02/07 22:10:16
5028166124Srafandnl --------------------
502950276Speterdnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
503050276Speterdnl won't, but they're still there.
503150276SpeterAC_DEFUN([CF_UNSIGNED_LITERALS],
503250276Speter[
503350276SpeterAC_MSG_CHECKING([if unsigned literals are legal])
503450276SpeterAC_CACHE_VAL(cf_cv_unsigned_literals,[
503550276Speter	AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
503650276Speter		[cf_cv_unsigned_literals=yes],
503750276Speter		[cf_cv_unsigned_literals=no])
503850276Speter	])
503950276SpeterAC_MSG_RESULT($cf_cv_unsigned_literals)
504050276Speter])dnl
504150276Speterdnl ---------------------------------------------------------------------------
5042166124Srafandnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
5043166124Srafandnl --------
504450276Speterdnl Make an uppercase version of a variable
504550276Speterdnl $1=uppercase($2)
504650276SpeterAC_DEFUN([CF_UPPER],
504750276Speter[
504866963Speter$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
504950276Speter])dnl
505050276Speterdnl ---------------------------------------------------------------------------
5051184989Srafandnl CF_UTF8_LIB version: 5 updated: 2008/10/17 19:37:52
5052184989Srafandnl -----------
5053184989Srafandnl Check for multibyte support, and if not found, utf8 compatibility library
5054184989SrafanAC_DEFUN([CF_UTF8_LIB],
5055184989Srafan[
5056184989SrafanAC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
5057184989Srafan	cf_save_LIBS="$LIBS"
5058184989Srafan	AC_TRY_LINK([
5059184989Srafan#include <stdlib.h>],[putwc(0,0);],
5060184989Srafan	[cf_cv_utf8_lib=yes],
5061184989Srafan	[CF_FIND_LINKAGE([
5062184989Srafan#include <libutf8.h>],[putwc(0,0);],utf8,
5063184989Srafan		[cf_cv_utf8_lib=add-on],
5064184989Srafan		[cf_cv_utf8_lib=no])
5065184989Srafan])])
5066184989Srafan
5067184989Srafan# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
5068184989Srafan# ncurses/ncursesw:
5069184989Srafanif test "$cf_cv_utf8_lib" = "add-on" ; then
5070184989Srafan	AC_DEFINE(HAVE_LIBUTF8_H)
5071184989Srafan	CF_ADD_INCDIR($cf_cv_header_path_utf8)
5072184989Srafan	CF_ADD_LIBDIR($cf_cv_library_path_utf8)
5073184989Srafan	LIBS="-lutf8 $LIBS"
5074184989Srafanfi
5075184989Srafan])dnl
5076184989Srafandnl ---------------------------------------------------------------------------
5077174993Srafandnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
5078166124Srafandnl ----------
507997049Speterdnl Use AC_VERBOSE w/o the warnings
508097049SpeterAC_DEFUN([CF_VERBOSE],
508197049Speter[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
5082174993SrafanCF_MSG_LOG([$1])
508350276Speter])dnl
508450276Speterdnl ---------------------------------------------------------------------------
5085166124Srafandnl CF_WCHAR_TYPE version: 2 updated: 2004/01/17 19:18:20
5086166124Srafandnl -------------
5087166124Srafandnl Check if type wide-character type $1 is declared, and if so, which header
5088166124Srafandnl file is needed.  The second parameter is used to set a shell variable when
5089166124Srafandnl the type is not found.  The first parameter sets a shell variable for the
5090166124Srafandnl opposite sense.
5091166124SrafanAC_DEFUN([CF_WCHAR_TYPE],
5092166124Srafan[
5093166124Srafan# This is needed on Tru64 5.0 to declare $1
5094166124SrafanAC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
5095166124SrafanAC_TRY_COMPILE([
5096166124Srafan#include <stdlib.h>
5097166124Srafan#include <stdarg.h>
5098166124Srafan#include <stdio.h>
5099166124Srafan#ifdef HAVE_LIBUTF8_H
5100166124Srafan#include <libutf8.h>
5101166124Srafan#endif],
5102166124Srafan	[$1 state],
5103166124Srafan	[cf_cv_$1=no],
5104166124Srafan	[AC_TRY_COMPILE([
5105166124Srafan#include <stdlib.h>
5106166124Srafan#include <stdarg.h>
5107166124Srafan#include <stdio.h>
5108166124Srafan#include <wchar.h>
5109166124Srafan#ifdef HAVE_LIBUTF8_H
5110166124Srafan#include <libutf8.h>
5111166124Srafan#endif],
5112166124Srafan	[$1 value],
5113166124Srafan	[cf_cv_$1=yes],
5114166124Srafan	[cf_cv_$1=unknown])])])
5115166124Srafan
5116166124Srafanif test "$cf_cv_$1" = yes ; then
5117166124Srafan	AC_DEFINE(NEED_WCHAR_H)
5118166124Srafan	NEED_WCHAR_H=1
5119166124Srafanfi
5120166124Srafan
5121166124Srafanifelse($2,,,[
5122166124Srafan# if we do not find $1 in either place, use substitution to provide a fallback.
5123166124Srafanif test "$cf_cv_$1" = unknown ; then
5124166124Srafan	$2=1
5125166124Srafanfi
5126166124Srafan])
5127166124Srafanifelse($3,,,[
5128166124Srafan# if we find $1 in either place, use substitution to provide a fallback.
5129166124Srafanif test "$cf_cv_$1" != unknown ; then
5130166124Srafan	$3=1
5131166124Srafanfi
5132166124Srafan])
5133166124Srafan])dnl
5134166124Srafandnl ---------------------------------------------------------------------------
5135184989Srafandnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06
5136184989Srafandnl ---------------
5137184989Srafandnl Check for compiler-support for weak symbols.
5138184989Srafandnl This works with "recent" gcc.
5139184989SrafanAC_DEFUN([CF_WEAK_SYMBOLS],[
5140184989SrafanAC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[
5141184989Srafan
5142184989SrafanAC_TRY_COMPILE([
5143184989Srafan#include <stdio.h>],
5144184989Srafan[
5145184989Srafan#if defined(__GNUC__)
5146184989Srafan#  if defined __USE_ISOC99
5147184989Srafan#    define _cat_pragma(exp)	_Pragma(#exp)
5148184989Srafan#    define _weak_pragma(exp)	_cat_pragma(weak name)
5149184989Srafan#  else
5150184989Srafan#    define _weak_pragma(exp)
5151184989Srafan#  endif
5152184989Srafan#  define _declare(name)	__extension__ extern __typeof__(name) name
5153184989Srafan#  define weak_symbol(name)	_weak_pragma(name) _declare(name) __attribute__((weak))
5154184989Srafan#endif
5155184989Srafan
5156184989Srafanweak_symbol(fopen);
5157184989Srafan],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
5158184989Srafan])
5159184989Srafan])dnl
5160184989Srafandnl ---------------------------------------------------------------------------
5161166124Srafandnl CF_WITH_ABI_VERSION version: 1 updated: 2003/09/20 18:12:49
5162166124Srafandnl -------------------
5163166124Srafandnl Allow library's ABI to be overridden.  Generally this happens when a
5164166124Srafandnl packager has incremented the ABI past that used in the original package,
5165166124Srafandnl and wishes to keep doing this.
5166166124Srafandnl
5167166124Srafandnl $1 is the package name, if any, to derive a corresponding {package}_ABI
5168166124Srafandnl symbol.
5169166124SrafanAC_DEFUN([CF_WITH_ABI_VERSION],[
5170166124Srafantest -z "$cf_cv_abi_version" && cf_cv_abi_version=0
5171166124SrafanAC_ARG_WITH(abi-version,
5172166124Srafan[  --with-abi-version=XXX  override derived ABI version],
5173166124Srafan[AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
5174166124Srafan cf_cv_abi_version=$withval])
5175166124Srafan CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
5176166124Srafanifelse($1,,,[
5177166124Srafan$1_ABI=$cf_cv_abi_version
5178166124Srafan])
5179166124Srafan])dnl
5180166124Srafandnl ---------------------------------------------------------------------------
5181166124Srafandnl CF_WITH_DBMALLOC version: 6 updated: 2006/12/16 14:24:05
5182166124Srafandnl ----------------
5183166124Srafandnl Configure-option for dbmalloc.  The optional parameter is used to override
5184166124Srafandnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
5185166124SrafanAC_DEFUN([CF_WITH_DBMALLOC],[
5186166124SrafanCF_NO_LEAKS_OPTION(dbmalloc,
5187166124Srafan	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
5188166124Srafan	[USE_DBMALLOC])
5189166124Srafan
5190166124Srafanif test "$with_dbmalloc" = yes ; then
5191166124Srafan	AC_CHECK_HEADER(dbmalloc.h,
5192166124Srafan		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))])
5193166124Srafanfi
5194166124Srafan])dnl
5195166124Srafandnl ---------------------------------------------------------------------------
5196166124Srafandnl CF_WITH_DMALLOC version: 6 updated: 2006/12/16 14:24:05
5197166124Srafandnl ---------------
5198166124Srafandnl Configure-option for dmalloc.  The optional parameter is used to override
5199166124Srafandnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
5200166124SrafanAC_DEFUN([CF_WITH_DMALLOC],[
5201166124SrafanCF_NO_LEAKS_OPTION(dmalloc,
5202166124Srafan	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
5203166124Srafan	[USE_DMALLOC])
5204166124Srafan
5205166124Srafanif test "$with_dmalloc" = yes ; then
5206166124Srafan	AC_CHECK_HEADER(dmalloc.h,
5207166124Srafan		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))])
5208166124Srafanfi
5209166124Srafan])dnl
5210166124Srafandnl ---------------------------------------------------------------------------
5211178866Srafandnl CF_WITH_GPM version: 7 updated: 2008/03/23 14:48:54
5212166124Srafandnl -----------
5213166124Srafandnl
5214166124Srafandnl The option parameter (if neither yes/no) is assumed to be the name of
5215166124Srafandnl the gpm library, e.g., for dynamic loading.
5216166124SrafanAC_DEFUN([CF_WITH_GPM],
5217166124Srafan[
5218166124SrafanAC_MSG_CHECKING(if you want to link with the GPM mouse library)
5219166124SrafanAC_ARG_WITH(gpm,
5220166124Srafan	[  --with-gpm              use Alessandro Rubini's GPM library],
5221166124Srafan	[with_gpm=$withval],
5222166124Srafan	[with_gpm=maybe])
5223166124SrafanAC_MSG_RESULT($with_gpm)
5224166124Srafan
5225166124Srafanif test "$with_gpm" != no ; then
5226166124Srafan	AC_CHECK_HEADER(gpm.h,[
5227166124Srafan		AC_DEFINE(HAVE_GPM_H)
5228166124Srafan		if test "$with_gpm" != yes && test "$with_gpm" != maybe ; then
5229166124Srafan			CF_VERBOSE(assuming we really have GPM library)
5230166124Srafan			AC_DEFINE(HAVE_LIBGPM)
5231166124Srafan		else
5232166124Srafan			AC_CHECK_LIB(gpm,Gpm_Open,[:],[
5233178866Srafan				AC_MSG_ERROR(Cannot link with GPM library)
5234166124Srafan		fi
5235166124Srafan		with_gpm=yes
5236166124Srafan		])
5237166124Srafan	],[
5238166124Srafan		test "$with_gpm" != maybe && AC_MSG_WARN(Cannot find GPM header)
5239166124Srafan		with_gpm=no
5240166124Srafan	])
5241166124Srafanfi
5242166124Srafan])
5243166124Srafandnl ---------------------------------------------------------------------------
5244178866Srafandnl CF_WITH_LIBTOOL version: 19 updated: 2008/03/29 15:46:43
5245166124Srafandnl ---------------
5246166124Srafandnl Provide a configure option to incorporate libtool.  Define several useful
5247166124Srafandnl symbols for the makefile rules.
5248166124Srafandnl
5249166124Srafandnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
5250166124Srafandnl macros from libtool.m4 which is in the aclocal directory of automake.
5251166124Srafandnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
5252166124Srafandnl But that still does not work properly since the macro is expanded outside
5253166124Srafandnl the CF_WITH_LIBTOOL macro:
5254166124Srafandnl
5255166124Srafandnl	#!/bin/sh
5256166124Srafandnl	ACLOCAL=`aclocal --print-ac-dir`
5257166124Srafandnl	if test -z "$ACLOCAL" ; then
5258166124Srafandnl		echo cannot find aclocal directory
5259166124Srafandnl		exit 1
5260166124Srafandnl	elif test ! -f $ACLOCAL/libtool.m4 ; then
5261166124Srafandnl		echo cannot find libtool.m4 file
5262166124Srafandnl		exit 1
5263166124Srafandnl	fi
5264166124Srafandnl	
5265166124Srafandnl	LOCAL=aclocal.m4
5266166124Srafandnl	ORIG=aclocal.m4.orig
5267166124Srafandnl	
5268166124Srafandnl	trap "mv $ORIG $LOCAL" 0 1 2 5 15
5269166124Srafandnl	rm -f $ORIG
5270166124Srafandnl	mv $LOCAL $ORIG
5271166124Srafandnl	
5272166124Srafandnl	# sed the LIBTOOL= assignment to omit the current directory?
5273166124Srafandnl	sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
5274166124Srafandnl	cat $ORIG >>$LOCAL
5275166124Srafandnl	
5276166124Srafandnl	autoconf-257 $*
5277166124Srafandnl
5278166124SrafanAC_DEFUN([CF_WITH_LIBTOOL],
5279166124Srafan[
5280166124Srafanifdef([AC_PROG_LIBTOOL],,[
5281166124SrafanLIBTOOL=
5282166124Srafan])
5283166124Srafan# common library maintenance symbols that are convenient for libtool scripts:
5284166124SrafanLIB_CREATE='${AR} -cr'
5285166124SrafanLIB_OBJECT='${OBJECTS}'
5286166124SrafanLIB_SUFFIX=.a
5287166124SrafanLIB_PREP="$RANLIB"
5288166124Srafan
5289166124Srafan# symbols used to prop libtool up to enable it to determine what it should be
5290166124Srafan# doing:
5291166124SrafanLIB_CLEAN=
5292166124SrafanLIB_COMPILE=
5293174993SrafanLIB_LINK='${CC}'
5294166124SrafanLIB_INSTALL=
5295166124SrafanLIB_UNINSTALL=
5296166124Srafan
5297166124SrafanAC_MSG_CHECKING(if you want to build libraries with libtool)
5298166124SrafanAC_ARG_WITH(libtool,
5299166124Srafan	[  --with-libtool          generate libraries with libtool],
5300166124Srafan	[with_libtool=$withval],
5301166124Srafan	[with_libtool=no])
5302166124SrafanAC_MSG_RESULT($with_libtool)
5303166124Srafanif test "$with_libtool" != "no"; then
5304166124Srafanifdef([AC_PROG_LIBTOOL],[
5305166124Srafan	# missing_content_AC_PROG_LIBTOOL{{
5306166124Srafan	AC_PROG_LIBTOOL
5307166124Srafan	# missing_content_AC_PROG_LIBTOOL}}
5308166124Srafan],[
5309166124Srafan 	if test "$with_libtool" != "yes" ; then
5310166124Srafan		CF_PATH_SYNTAX(with_libtool)
5311166124Srafan		LIBTOOL=$with_libtool
5312166124Srafan	else
5313166124Srafan 		AC_PATH_PROG(LIBTOOL,libtool)
5314166124Srafan 	fi
5315166124Srafan 	if test -z "$LIBTOOL" ; then
5316166124Srafan 		AC_MSG_ERROR(Cannot find libtool)
5317166124Srafan 	fi
5318166124Srafan])dnl
5319174993Srafan	LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${DESTDIR}${libdir} -version-info `cut -f1 ${srcdir}/VERSION` ${LIBTOOL_OPTS} -o'
5320174993Srafan	LIB_OBJECT='${OBJECTS:.o=.lo}'
5321166124Srafan	LIB_SUFFIX=.la
5322166124Srafan	LIB_CLEAN='${LIBTOOL} --mode=clean'
5323166124Srafan	LIB_COMPILE='${LIBTOOL} --mode=compile'
5324174993Srafan	LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
5325166124Srafan	LIB_INSTALL='${LIBTOOL} --mode=install'
5326166124Srafan	LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
5327166124Srafan	LIB_PREP=:
5328166124Srafan
5329166124Srafan	# Show the version of libtool
5330166124Srafan	AC_MSG_CHECKING(version of libtool)
5331166124Srafan
5332166124Srafan	# Save the version in a cache variable - this is not entirely a good
5333166124Srafan	# thing, but the version string from libtool is very ugly, and for
5334166124Srafan	# bug reports it might be useful to have the original string.
5335174993Srafan	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.]].*//'`
5336166124Srafan	AC_MSG_RESULT($cf_cv_libtool_version)
5337166124Srafan	if test -z "$cf_cv_libtool_version" ; then
5338174993Srafan		AC_MSG_ERROR(This is not GNU libtool)
5339166124Srafan	fi
5340166124Srafan
5341166124Srafan	# special hack to add --tag option for C++ compiler
5342166124Srafan	case $cf_cv_libtool_version in
5343166124Srafan	1.[[5-9]]*|[[2-9]]*)
5344166124Srafan		LIBTOOL_CXX="$LIBTOOL --tag=CXX"
5345178866Srafan		LIBTOOL="$LIBTOOL --tag=CC"
5346166124Srafan		;;
5347166124Srafan	*)
5348166124Srafan		LIBTOOL_CXX="$LIBTOOL"
5349166124Srafan		;;
5350166124Srafan	esac
5351166124Srafanelse
5352166124Srafan	LIBTOOL=""
5353166124Srafan	LIBTOOL_CXX=""
5354166124Srafanfi
5355166124Srafan
5356166124Srafantest -z "$LIBTOOL" && ECHO_LT=
5357166124Srafan
5358166124SrafanAC_SUBST(LIBTOOL)
5359166124SrafanAC_SUBST(LIBTOOL_CXX)
5360174993SrafanAC_SUBST(LIBTOOL_OPTS)
5361166124Srafan
5362166124SrafanAC_SUBST(LIB_CREATE)
5363166124SrafanAC_SUBST(LIB_OBJECT)
5364166124SrafanAC_SUBST(LIB_SUFFIX)
5365166124SrafanAC_SUBST(LIB_PREP)
5366166124Srafan
5367166124SrafanAC_SUBST(LIB_CLEAN)
5368166124SrafanAC_SUBST(LIB_COMPILE)
5369166124SrafanAC_SUBST(LIB_LINK)
5370166124SrafanAC_SUBST(LIB_INSTALL)
5371166124SrafanAC_SUBST(LIB_UNINSTALL)
5372166124Srafan
5373166124Srafan])dnl
5374166124Srafandnl ---------------------------------------------------------------------------
5375174993Srafandnl CF_WITH_PATH version: 8 updated: 2007/05/13 13:16:35
5376166124Srafandnl ------------
537750276Speterdnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
537850276Speterdnl defaulting to yes/no.
537950276Speterdnl
538050276Speterdnl $1 = option name
538150276Speterdnl $2 = help-text
538250276Speterdnl $3 = environment variable to set
538350276Speterdnl $4 = default value, shown in the help-message, must be a constant
538450276Speterdnl $5 = default value, if it's an expression & cannot be in the help-message
538550276Speterdnl
538650276SpeterAC_DEFUN([CF_WITH_PATH],
538750276Speter[AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
538850276Speterifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
5389174993Srafanif ifelse($5,,true,[test -n "$5"]) ; then
539050276SpeterCF_PATH_SYNTAX(withval)
5391174993Srafanfi
5392166124Srafan$3="$withval"
539350276SpeterAC_SUBST($3)dnl
539450276Speter])dnl
539550276Speterdnl ---------------------------------------------------------------------------
5396166124Srafandnl CF_WITH_PATHLIST version: 5 updated: 2001/12/10 01:28:30
5397166124Srafandnl ----------------
539850276Speterdnl Process an option specifying a list of colon-separated paths.
539950276Speterdnl
540050276Speterdnl $1 = option name
540150276Speterdnl $2 = help-text
540250276Speterdnl $3 = environment variable to set
540350276Speterdnl $4 = default value, shown in the help-message, must be a constant
540450276Speterdnl $5 = default value, if it's an expression & cannot be in the help-message
540597049Speterdnl $6 = flag to tell if we want to define or substitute
540650276Speterdnl
540750276SpeterAC_DEFUN([CF_WITH_PATHLIST],[
540876726SpeterAC_REQUIRE([CF_PATHSEP])
540950276SpeterAC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
541097049Speterifelse($4,,[withval=${$3}],[withval=${$3-ifelse($5,,$4,$5)}]))dnl
541150276Speter
541297049SpeterIFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${PATHSEP}"
541350276Spetercf_dst_path=
541450276Speterfor cf_src_path in $withval
541550276Speterdo
541650276Speter  CF_PATH_SYNTAX(cf_src_path)
541750276Speter  test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
541850276Speter  cf_dst_path="${cf_dst_path}${cf_src_path}"
541950276Speterdone
542050276SpeterIFS="$ac_save_ifs"
542150276Speter
542297049Speterifelse($6,define,[
542397049Speter# Strip single quotes from the value, e.g., when it was supplied as a literal
542497049Speter# for $4 or $5.
542597049Spetercase $cf_dst_path in #(vi
542697049Speter\'*)
542797049Speter  cf_dst_path=`echo $cf_dst_path |sed -e s/\'// -e s/\'\$//`
542897049Speter  ;;
542997049Speteresac
543097049Spetercf_dst_path=`echo "$cf_dst_path" | sed -e 's/\\\\/\\\\\\\\/g'`
543197049Speter])
543297049Speter
543397049Spetereval '$3="$cf_dst_path"'
543450276SpeterAC_SUBST($3)dnl
543597049Speter
543650276Speter])dnl
5437166124Srafandnl ---------------------------------------------------------------------------
5438184989Srafandnl CF_WITH_PTHREAD version: 2 updated: 2008/08/23 18:26:05
5439178866Srafandnl ---------------
5440178866Srafandnl Check for POSIX thread library.
5441178866SrafanAC_DEFUN([CF_WITH_PTHREAD],
5442178866Srafan[
5443178866SrafanAC_MSG_CHECKING(if you want to link with the pthread library)
5444178866SrafanAC_ARG_WITH(pthread,
5445178866Srafan    [  --with-pthread          use POSIX thread library],
5446178866Srafan    [with_pthread=$withval],
5447178866Srafan    [with_pthread=no])
5448178866SrafanAC_MSG_RESULT($with_pthread)
5449178866Srafan
5450178866Srafanif test "$with_pthread" != no ; then
5451178866Srafan    AC_CHECK_HEADER(pthread.h,[
5452178866Srafan        AC_DEFINE(HAVE_PTHREADS_H)
5453184989Srafan
5454184989Srafan        AC_MSG_CHECKING(if we can link with the pthread library)
5455184989Srafan        cf_save_LIBS="$LIBS"
5456184989Srafan        LIBS="-lpthread $LIBS"
5457184989Srafan        AC_TRY_LINK([
5458184989Srafan#include <pthread.h>
5459184989Srafan],[
5460184989Srafan        int rc = pthread_create(0,0,0,0);
5461184989Srafan],[with_pthread=yes],[with_pthread=no])
5462184989Srafan        LIBS="$cf_save_LIBS"
5463184989Srafan        AC_MSG_RESULT($with_pthread)
5464184989Srafan
5465184989Srafan        if test "$with_pthread" = yes ; then
5466178866Srafan            LIBS="-lpthread $LIBS"
5467178866Srafan            AC_DEFINE(HAVE_LIBPTHREADS)
5468184989Srafan        else
5469178866Srafan            AC_MSG_ERROR(Cannot link with pthread library)
5470184989Srafan        fi
5471178866Srafan    ])
5472178866Srafanfi
5473178866Srafan])
5474178866Srafandnl ---------------------------------------------------------------------------
5475166124Srafandnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
5476166124Srafandnl -------------------
5477166124Srafandnl Allow library's release-version to be overridden.  Generally this happens when a
5478166124Srafandnl packager has incremented the release-version past that used in the original package,
5479166124Srafandnl and wishes to keep doing this.
5480166124Srafandnl
5481166124Srafandnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
5482166124Srafandnl and {package}_MINOR symbols
5483166124Srafandnl symbol.
5484166124SrafanAC_DEFUN([CF_WITH_REL_VERSION],[
5485166124Srafantest -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
5486166124SrafanAC_ARG_WITH(rel-version,
5487166124Srafan[  --with-rel-version=XXX  override derived release version],
5488166124Srafan[AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
5489166124Srafan cf_cv_rel_version=$withval])
5490166124Srafanifelse($1,,[
5491166124Srafan CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
5492166124Srafan],[
5493166124Srafan $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
5494166124Srafan $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
5495166124Srafan CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
5496166124Srafan CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
5497166124Srafan])
5498166124Srafan])dnl
5499166124Srafandnl ---------------------------------------------------------------------------
5500166124Srafandnl CF_WITH_SYSMOUSE version: 2 updated: 2003/03/22 19:13:43
5501166124Srafandnl ----------------
5502166124Srafandnl If we can compile with sysmouse, make it available unless it is not wanted.
5503166124SrafanAC_DEFUN([CF_WITH_SYSMOUSE],[
5504166124Srafan# not everyone has "test -c"
5505166124Srafanif test -c /dev/sysmouse 2>/dev/null ; then
5506166124SrafanAC_MSG_CHECKING(if you want to use sysmouse)
5507166124SrafanAC_ARG_WITH(sysmouse,
5508166124Srafan	[  --with-sysmouse         use sysmouse (FreeBSD console)],
5509166124Srafan	[cf_with_sysmouse=$withval],
5510166124Srafan	[cf_with_sysmouse=maybe])
5511166124Srafan	if test "$cf_with_sysmouse" != no ; then
5512166124Srafan	AC_TRY_COMPILE([
5513166124Srafan#include <osreldate.h>
5514166124Srafan#if (__FreeBSD_version >= 400017)
5515166124Srafan#include <sys/consio.h>
5516166124Srafan#include <sys/fbio.h>
5517166124Srafan#else
5518166124Srafan#include <machine/console.h>
5519166124Srafan#endif
5520166124Srafan],[
5521166124Srafan	struct mouse_info the_mouse;
5522166124Srafan	ioctl(0, CONS_MOUSECTL, &the_mouse);
5523166124Srafan],[cf_with_sysmouse=yes],[cf_with_sysmouse=no])
5524166124Srafan	fi
5525166124SrafanAC_MSG_RESULT($cf_with_sysmouse)
5526166124Srafantest "$cf_with_sysmouse" = yes && AC_DEFINE(USE_SYSMOUSE)
5527166124Srafanfi
5528166124Srafan])dnl
5529166124Srafandnl ---------------------------------------------------------------------------
5530166124Srafandnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
5531166124Srafandnl ----------------
5532166124SrafanAC_DEFUN([CF_WITH_VALGRIND],[
5533166124SrafanCF_NO_LEAKS_OPTION(valgrind,
5534166124Srafan	[  --with-valgrind         test: use valgrind],
5535166124Srafan	[USE_VALGRIND])
5536166124Srafan])dnl
5537166124Srafandnl ---------------------------------------------------------------------------
5538184989Srafandnl CF_XOPEN_SOURCE version: 26 updated: 2008/07/27 11:26:57
5539166124Srafandnl ---------------
5540166124Srafandnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
5541166124Srafandnl or adapt to the vendor's definitions to get equivalent functionality,
5542166124Srafandnl without losing the common non-POSIX features.
5543166124Srafandnl
5544166124Srafandnl Parameters:
5545166124Srafandnl	$1 is the nominal value for _XOPEN_SOURCE
5546166124Srafandnl	$2 is the nominal value for _POSIX_C_SOURCE
5547166124SrafanAC_DEFUN([CF_XOPEN_SOURCE],[
5548166124Srafan
5549166124SrafanAC_REQUIRE([CF_PROG_CC_U_D])
5550166124Srafan
5551166124Srafancf_XOPEN_SOURCE=ifelse($1,,500,$1)
5552166124Srafancf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
5553166124Srafan
5554166124Srafancase $host_os in #(vi
5555166124Srafanaix[[45]]*) #(vi
5556166124Srafan	CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
5557166124Srafan	;;
5558184989Srafanfreebsd*|dragonfly*) #(vi
5559166124Srafan	# 5.x headers associate
5560166124Srafan	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
5561166124Srafan	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
5562166124Srafan	cf_POSIX_C_SOURCE=200112L
5563166124Srafan	cf_XOPEN_SOURCE=600
5564166124Srafan	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
5565166124Srafan	;;
5566166124Srafanhpux*) #(vi
5567166124Srafan	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
5568166124Srafan	;;
5569166124Srafanirix[[56]].*) #(vi
5570166124Srafan	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
5571166124Srafan	;;
5572174993Srafanlinux*|gnu*|k*bsd*-gnu) #(vi
5573166124Srafan	CF_GNU_SOURCE
5574166124Srafan	;;
5575166124Srafanmirbsd*) #(vi
5576166124Srafan	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
5577166124Srafan	;;
5578166124Srafannetbsd*) #(vi
5579166124Srafan	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
5580166124Srafan	;;
5581166124Srafanopenbsd*) #(vi
5582166124Srafan	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
5583166124Srafan	;;
5584166124Srafanosf[[45]]*) #(vi
5585166124Srafan	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
5586166124Srafan	;;
5587166124Srafannto-qnx*) #(vi
5588166124Srafan	CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
5589166124Srafan	;;
5590166124Srafansco*) #(vi
5591166124Srafan	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
5592166124Srafan	;;
5593166124Srafansolaris*) #(vi
5594166124Srafan	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
5595166124Srafan	;;
5596166124Srafan*)
5597166124Srafan	AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
5598166124Srafan	AC_TRY_COMPILE([#include <sys/types.h>],[
5599166124Srafan#ifndef _XOPEN_SOURCE
5600166124Srafanmake an error
5601166124Srafan#endif],
5602166124Srafan	[cf_cv_xopen_source=no],
5603166124Srafan	[cf_save="$CPPFLAGS"
5604166124Srafan	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
5605166124Srafan	 AC_TRY_COMPILE([#include <sys/types.h>],[
5606166124Srafan#ifdef _XOPEN_SOURCE
5607166124Srafanmake an error
5608166124Srafan#endif],
5609166124Srafan	[cf_cv_xopen_source=no],
5610166124Srafan	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
5611166124Srafan	CPPFLAGS="$cf_save"
5612166124Srafan	])
5613166124Srafan])
5614166124Srafan	if test "$cf_cv_xopen_source" != no ; then
5615166124Srafan		CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
5616166124Srafan		CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
5617166124Srafan		test "$cf_cv_cc_u_d_options" = yes && \
5618166124Srafan			CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
5619166124Srafan		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
5620166124Srafan	fi
5621166124Srafan	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
5622166124Srafan	;;
5623166124Srafanesac
5624166124Srafan])
5625