aclocal.m4 revision 217309
1217309Snwhitehorndnl macros used for DIALOG configure script
2217309Snwhitehorndnl Copyright 1999-2009,2010 -- Thomas E. Dickey
3217309Snwhitehorndnl
4217309Snwhitehorndnl see
5217309Snwhitehorndnl http://invisible-island.net/autoconf/ 
6217309Snwhitehorndnl
7217309Snwhitehorndnl $Id: aclocal.m4,v 1.75 2010/04/28 20:36:28 tom Exp $
8217309Snwhitehorndnl ---------------------------------------------------------------------------
9217309Snwhitehorndnl ---------------------------------------------------------------------------
10217309Snwhitehorndnl AM_GNU_GETTEXT version: 11 updated: 2004/01/26 20:58:40
11217309Snwhitehorndnl --------------
12217309Snwhitehorndnl Usage: Just like AM_WITH_NLS, which see.
13217309SnwhitehornAC_DEFUN([AM_GNU_GETTEXT],
14217309Snwhitehorn  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
15217309Snwhitehorn   AC_REQUIRE([AC_PROG_CC])dnl
16217309Snwhitehorn   AC_REQUIRE([AC_CANONICAL_HOST])dnl
17217309Snwhitehorn   AC_REQUIRE([AC_PROG_RANLIB])dnl
18217309Snwhitehorn   AC_REQUIRE([AC_ISC_POSIX])dnl
19217309Snwhitehorn   AC_REQUIRE([AC_HEADER_STDC])dnl
20217309Snwhitehorn   AC_REQUIRE([AC_C_CONST])dnl
21217309Snwhitehorn   AC_REQUIRE([AC_C_INLINE])dnl
22217309Snwhitehorn   AC_REQUIRE([AC_TYPE_OFF_T])dnl
23217309Snwhitehorn   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
24217309Snwhitehorn   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
25217309Snwhitehorn   AC_REQUIRE([AC_FUNC_MMAP])dnl
26217309Snwhitehorn   AC_REQUIRE([jm_GLIBC21])dnl
27217309Snwhitehorn
28217309Snwhitehorn   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
29217309Snwhitehornstdlib.h string.h unistd.h sys/param.h])
30217309Snwhitehorn   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
31217309Snwhitehorngetgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
32217309Snwhitehornstrdup strtoul tsearch __argz_count __argz_stringify __argz_next])
33217309Snwhitehorn
34217309Snwhitehorn   AM_ICONV
35217309Snwhitehorn   AM_LANGINFO_CODESET
36217309Snwhitehorn   AM_LC_MESSAGES
37217309Snwhitehorn   AM_WITH_NLS([$1],[$2],[$3],[$4])
38217309Snwhitehorn
39217309Snwhitehorn   if test "x$CATOBJEXT" != "x"; then
40217309Snwhitehorn     if test "x$ALL_LINGUAS" = "x"; then
41217309Snwhitehorn       LINGUAS=
42217309Snwhitehorn     else
43217309Snwhitehorn       AC_MSG_CHECKING(for catalogs to be installed)
44217309Snwhitehorn       NEW_LINGUAS=
45217309Snwhitehorn       for presentlang in $ALL_LINGUAS; do
46217309Snwhitehorn         useit=no
47217309Snwhitehorn         for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
48217309Snwhitehorn           # Use the presentlang catalog if desiredlang is
49217309Snwhitehorn           #   a. equal to presentlang, or
50217309Snwhitehorn           #   b. a variant of presentlang (because in this case,
51217309Snwhitehorn           #      presentlang can be used as a fallback for messages
52217309Snwhitehorn           #      which are not translated in the desiredlang catalog).
53217309Snwhitehorn           case "$desiredlang" in
54217309Snwhitehorn             "$presentlang"*) useit=yes;;
55217309Snwhitehorn           esac
56217309Snwhitehorn         done
57217309Snwhitehorn         if test $useit = yes; then
58217309Snwhitehorn           NEW_LINGUAS="$NEW_LINGUAS $presentlang"
59217309Snwhitehorn         fi
60217309Snwhitehorn       done
61217309Snwhitehorn       LINGUAS=$NEW_LINGUAS
62217309Snwhitehorn       AC_MSG_RESULT($LINGUAS)
63217309Snwhitehorn     fi
64217309Snwhitehorn
65217309Snwhitehorn     dnl Construct list of names of catalog files to be constructed.
66217309Snwhitehorn     if test -n "$LINGUAS"; then
67217309Snwhitehorn       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
68217309Snwhitehorn     fi
69217309Snwhitehorn   fi
70217309Snwhitehorn
71217309Snwhitehorn   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
72217309Snwhitehorn   dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
73217309Snwhitehorn   dnl Try to locate it.
74217309Snwhitehorn   dnl changed mkinstalldirs to mkdirs.sh for Lynx /je spath 1998-Aug-21
75217309Snwhitehorn   dnl added check for separate locations of scripts -mirabile 2004-Jan-18
76217309Snwhitehorn   MKINSTALLDIRS=
77217309Snwhitehorn   if test -n "$ac_aux_dir"; then
78217309Snwhitehorn     MKINSTALLDIRS="$ac_aux_dir/mkdirs.sh"
79217309Snwhitehorn   fi
80217309Snwhitehorn   if test -z "$MKINSTALLDIRS"; then
81217309Snwhitehorn     MKINSTALLDIRS="\$(top_srcdir)/mkdirs.sh"
82217309Snwhitehorn   fi
83217309Snwhitehorn   if test -n "$GNUSYSTEM_AUX_DIR" ; then
84217309Snwhitehorn     if test -e "${GNUSYSTEM_AUX_DIR}/mkinstalldirs"; then
85217309Snwhitehorn       MKINSTALLDIRS="${GNUSYSTEM_AUX_DIR}/mkinstalldirs"
86217309Snwhitehorn     fi
87217309Snwhitehorn   fi
88217309Snwhitehorn   AC_SUBST(MKINSTALLDIRS)
89217309Snwhitehorn
90217309Snwhitehorn   dnl Enable libtool support if the surrounding package wishes it.
91217309Snwhitehorn   INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
92217309Snwhitehorn   AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
93217309Snwhitehorn])dnl
94217309Snwhitehorndnl ---------------------------------------------------------------------------
95217309Snwhitehorndnl AM_ICONV version: 12 updated: 2007/07/30 19:12:03
96217309Snwhitehorndnl --------
97217309Snwhitehorndnl Inserted as requested by gettext 0.10.40
98217309Snwhitehorndnl File from /usr/share/aclocal
99217309Snwhitehorndnl iconv.m4
100217309Snwhitehorndnl ====================
101217309Snwhitehorndnl serial AM2
102217309Snwhitehorndnl
103217309Snwhitehorndnl From Bruno Haible.
104217309Snwhitehorndnl
105217309Snwhitehorndnl ====================
106217309Snwhitehorndnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
107217309Snwhitehorndnl range of locations searched.  Retain the same cache-variable naming to
108217309Snwhitehorndnl allow reuse with the other gettext macros -Thomas E Dickey
109217309SnwhitehornAC_DEFUN([AM_ICONV],
110217309Snwhitehorn[
111217309Snwhitehorn  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
112217309Snwhitehorn  dnl those with the standalone portable GNU libiconv installed).
113217309Snwhitehorn
114217309Snwhitehorn  AC_ARG_WITH([libiconv-prefix],
115217309Snwhitehorn[  --with-libiconv-prefix=DIR
116217309Snwhitehorn                          search for libiconv in DIR/include and DIR/lib], [
117217309Snwhitehorn    CF_ADD_OPTIONAL_PATH($withval, libiconv)
118217309Snwhitehorn   ])
119217309Snwhitehorn
120217309Snwhitehorn  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
121217309Snwhitehorn    CF_FIND_LINKAGE(CF__ICONV_HEAD,
122217309Snwhitehorn      CF__ICONV_BODY,
123217309Snwhitehorn      iconv,
124217309Snwhitehorn      am_cv_func_iconv=yes,
125217309Snwhitehorn      am_cv_func_iconv=["no, consider installing GNU libiconv"])])
126217309Snwhitehorn
127217309Snwhitehorn  if test "$am_cv_func_iconv" = yes; then
128217309Snwhitehorn    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
129217309Snwhitehorn
130217309Snwhitehorn    AC_CACHE_CHECK([if the declaration of iconv() needs const.],
131217309Snwhitehorn		   am_cv_proto_iconv_const,[
132217309Snwhitehorn      AC_TRY_COMPILE(CF__ICONV_HEAD [
133217309Snwhitehornextern
134217309Snwhitehorn#ifdef __cplusplus
135217309Snwhitehorn"C"
136217309Snwhitehorn#endif
137217309Snwhitehorn#if defined(__STDC__) || defined(__cplusplus)
138217309Snwhitehornsize_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
139217309Snwhitehorn#else
140217309Snwhitehornsize_t iconv();
141217309Snwhitehorn#endif
142217309Snwhitehorn],[], am_cv_proto_iconv_const=no,
143217309Snwhitehorn      am_cv_proto_iconv_const=yes)])
144217309Snwhitehorn
145217309Snwhitehorn    if test "$am_cv_proto_iconv_const" = yes ; then
146217309Snwhitehorn      am_cv_proto_iconv_arg1="const"
147217309Snwhitehorn    else
148217309Snwhitehorn      am_cv_proto_iconv_arg1=""
149217309Snwhitehorn    fi
150217309Snwhitehorn
151217309Snwhitehorn    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
152217309Snwhitehorn      [Define as const if the declaration of iconv() needs const.])
153217309Snwhitehorn  fi
154217309Snwhitehorn
155217309Snwhitehorn  LIBICONV=
156217309Snwhitehorn  if test "$cf_cv_find_linkage_iconv" = yes; then
157217309Snwhitehorn    CF_ADD_INCDIR($cf_cv_header_path_iconv)
158217309Snwhitehorn    if test -n "$cf_cv_library_file_iconv" ; then
159217309Snwhitehorn      LIBICONV="-liconv"
160217309Snwhitehorn      CF_ADD_LIBDIR($cf_cv_library_path_iconv)
161217309Snwhitehorn    fi
162217309Snwhitehorn  fi
163217309Snwhitehorn
164217309Snwhitehorn  AC_SUBST(LIBICONV)
165217309Snwhitehorn])dnl
166217309Snwhitehorndnl ---------------------------------------------------------------------------
167217309Snwhitehorndnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
168217309Snwhitehorndnl -------------------
169217309Snwhitehorndnl Inserted as requested by gettext 0.10.40
170217309Snwhitehorndnl File from /usr/share/aclocal
171217309Snwhitehorndnl codeset.m4
172217309Snwhitehorndnl ====================
173217309Snwhitehorndnl serial AM1
174217309Snwhitehorndnl
175217309Snwhitehorndnl From Bruno Haible.
176217309SnwhitehornAC_DEFUN([AM_LANGINFO_CODESET],
177217309Snwhitehorn[
178217309Snwhitehorn  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
179217309Snwhitehorn    [AC_TRY_LINK([#include <langinfo.h>],
180217309Snwhitehorn      [char* cs = nl_langinfo(CODESET);],
181217309Snwhitehorn      am_cv_langinfo_codeset=yes,
182217309Snwhitehorn      am_cv_langinfo_codeset=no)
183217309Snwhitehorn    ])
184217309Snwhitehorn  if test $am_cv_langinfo_codeset = yes; then
185217309Snwhitehorn    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
186217309Snwhitehorn      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
187217309Snwhitehorn  fi
188217309Snwhitehorn])dnl
189217309Snwhitehorndnl ---------------------------------------------------------------------------
190217309Snwhitehorndnl AM_LC_MESSAGES version: 4 updated: 2002/10/27 23:21:42
191217309Snwhitehorndnl --------------
192217309Snwhitehorndnl Inserted as requested by gettext 0.10.40
193217309Snwhitehorndnl File from /usr/share/aclocal
194217309Snwhitehorndnl lcmessage.m4
195217309Snwhitehorndnl ====================
196217309Snwhitehorndnl Check whether LC_MESSAGES is available in <locale.h>.
197217309Snwhitehorndnl Ulrich Drepper <drepper@cygnus.com>, 1995.
198217309Snwhitehorndnl
199217309Snwhitehorndnl This file can be copied and used freely without restrictions.  It can
200217309Snwhitehorndnl be used in projects which are not available under the GNU General Public
201217309Snwhitehorndnl License or the GNU Library General Public License but which still want
202217309Snwhitehorndnl to provide support for the GNU gettext functionality.
203217309Snwhitehorndnl Please note that the actual code of the GNU gettext library is covered
204217309Snwhitehorndnl by the GNU Library General Public License, and the rest of the GNU
205217309Snwhitehorndnl gettext package package is covered by the GNU General Public License.
206217309Snwhitehorndnl They are *not* in the public domain.
207217309Snwhitehorndnl
208217309Snwhitehorndnl serial 2
209217309Snwhitehorndnl
210217309SnwhitehornAC_DEFUN([AM_LC_MESSAGES],
211217309Snwhitehorn  [if test $ac_cv_header_locale_h = yes; then
212217309Snwhitehorn    AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
213217309Snwhitehorn      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
214217309Snwhitehorn       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
215217309Snwhitehorn    if test $am_cv_val_LC_MESSAGES = yes; then
216217309Snwhitehorn      AC_DEFINE(HAVE_LC_MESSAGES, 1,
217217309Snwhitehorn        [Define if your <locale.h> file defines LC_MESSAGES.])
218217309Snwhitehorn    fi
219217309Snwhitehorn  fi])dnl
220217309Snwhitehorndnl ---------------------------------------------------------------------------
221217309Snwhitehorndnl AM_PATH_PROG_WITH_TEST version: 8 updated: 2009/01/11 20:31:12
222217309Snwhitehorndnl ----------------------
223217309Snwhitehorndnl Inserted as requested by gettext 0.10.40
224217309Snwhitehorndnl File from /usr/share/aclocal
225217309Snwhitehorndnl progtest.m4
226217309Snwhitehorndnl ====================
227217309Snwhitehorndnl Search path for a program which passes the given test.
228217309Snwhitehorndnl Ulrich Drepper <drepper@cygnus.com>, 1996.
229217309Snwhitehorndnl
230217309Snwhitehorndnl This file can be copied and used freely without restrictions.  It can
231217309Snwhitehorndnl be used in projects which are not available under the GNU General Public
232217309Snwhitehorndnl License or the GNU Library General Public License but which still want
233217309Snwhitehorndnl to provide support for the GNU gettext functionality.
234217309Snwhitehorndnl Please note that the actual code of the GNU gettext library is covered
235217309Snwhitehorndnl by the GNU Library General Public License, and the rest of the GNU
236217309Snwhitehorndnl gettext package package is covered by the GNU General Public License.
237217309Snwhitehorndnl They are *not* in the public domain.
238217309Snwhitehorndnl
239217309Snwhitehorndnl serial 2
240217309Snwhitehorndnl
241217309Snwhitehorndnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
242217309Snwhitehorndnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
243217309SnwhitehornAC_DEFUN([AM_PATH_PROG_WITH_TEST],
244217309Snwhitehorn[# Extract the first word of "$2", so it can be a program name with args.
245217309SnwhitehornAC_REQUIRE([CF_PATHSEP])
246217309Snwhitehornset dummy $2; ac_word=[$]2
247217309SnwhitehornAC_MSG_CHECKING([for $ac_word])
248217309SnwhitehornAC_CACHE_VAL(ac_cv_path_$1,
249217309Snwhitehorn[case "[$]$1" in
250217309Snwhitehorn  [[\\/]*|?:[\\/]]*)
251217309Snwhitehorn  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
252217309Snwhitehorn  ;;
253217309Snwhitehorn  *)
254217309Snwhitehorn  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
255217309Snwhitehorn  for ac_dir in ifelse([$5], , $PATH, [$5]); do
256217309Snwhitehorn    test -z "$ac_dir" && ac_dir=.
257217309Snwhitehorn    if test -f $ac_dir/$ac_word$ac_exeext; then
258217309Snwhitehorn      if [$3]; then
259217309Snwhitehorn	ac_cv_path_$1="$ac_dir/$ac_word$ac_exeext"
260217309Snwhitehorn	break
261217309Snwhitehorn      fi
262217309Snwhitehorn    fi
263217309Snwhitehorn  done
264217309Snwhitehorn  IFS="$ac_save_ifs"
265217309Snwhitehorndnl If no 4th arg is given, leave the cache variable unset,
266217309Snwhitehorndnl so AC_PATH_PROGS will keep looking.
267217309Snwhitehornifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
268217309Snwhitehorn])dnl
269217309Snwhitehorn  ;;
270217309Snwhitehornesac])dnl
271217309Snwhitehorn$1="$ac_cv_path_$1"
272217309Snwhitehornif test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
273217309Snwhitehorn  AC_MSG_RESULT([$]$1)
274217309Snwhitehornelse
275217309Snwhitehorn  AC_MSG_RESULT(no)
276217309Snwhitehornfi
277217309SnwhitehornAC_SUBST($1)dnl
278217309Snwhitehorn])dnl
279217309Snwhitehorndnl ---------------------------------------------------------------------------
280217309Snwhitehorndnl AM_WITH_NLS version: 23 updated: 2009/01/11 19:52:42
281217309Snwhitehorndnl -----------
282217309Snwhitehorndnl Inserted as requested by gettext 0.10.40
283217309Snwhitehorndnl File from /usr/share/aclocal
284217309Snwhitehorndnl gettext.m4
285217309Snwhitehorndnl ====================
286217309Snwhitehorndnl Macro to add for using GNU gettext.
287217309Snwhitehorndnl Ulrich Drepper <drepper@cygnus.com>, 1995.
288217309Snwhitehorndnl ====================
289217309Snwhitehorndnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
290217309Snwhitehorndnl range of locations searched.  Retain the same cache-variable naming to
291217309Snwhitehorndnl allow reuse with the other gettext macros -Thomas E Dickey
292217309Snwhitehorndnl ====================
293217309Snwhitehorndnl
294217309Snwhitehorndnl This file can be copied and used freely without restrictions.  It can
295217309Snwhitehorndnl be used in projects which are not available under the GNU General Public
296217309Snwhitehorndnl License or the GNU Library General Public License but which still want
297217309Snwhitehorndnl to provide support for the GNU gettext functionality.
298217309Snwhitehorndnl Please note that the actual code of the GNU gettext library is covered
299217309Snwhitehorndnl by the GNU Library General Public License, and the rest of the GNU
300217309Snwhitehorndnl gettext package package is covered by the GNU General Public License.
301217309Snwhitehorndnl They are *not* in the public domain.
302217309Snwhitehorndnl
303217309Snwhitehorndnl serial 10
304217309Snwhitehorndnl
305217309Snwhitehorndnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR], [ENABLED]).
306217309Snwhitehorndnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
307217309Snwhitehorndnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
308217309Snwhitehorndnl    depending on --{enable,disable}-{shared,static} and on the presence of
309217309Snwhitehorndnl    AM-DISABLE-SHARED). Otherwise, a static library
310217309Snwhitehorndnl    $(top_builddir)/intl/libintl.a will be created.
311217309Snwhitehorndnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
312217309Snwhitehorndnl    implementations (in libc or libintl) without the ngettext() function
313217309Snwhitehorndnl    will be ignored.
314217309Snwhitehorndnl LIBDIR is used to find the intl libraries.  If empty,
315217309Snwhitehorndnl    the value `$(top_builddir)/intl/' is used.
316217309Snwhitehorndnl ENABLED is used to control the default for the related --enable-nls, since
317217309Snwhitehorndnl    not all application developers want this feature by default, e.g., lynx.
318217309Snwhitehorndnl
319217309Snwhitehorndnl The result of the configuration is one of three cases:
320217309Snwhitehorndnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
321217309Snwhitehorndnl    and used.
322217309Snwhitehorndnl    Catalog format: GNU --> install in $(datadir)
323217309Snwhitehorndnl    Catalog extension: .mo after installation, .gmo in source tree
324217309Snwhitehorndnl 2) GNU gettext has been found in the system's C library.
325217309Snwhitehorndnl    Catalog format: GNU --> install in $(datadir)
326217309Snwhitehorndnl    Catalog extension: .mo after installation, .gmo in source tree
327217309Snwhitehorndnl 3) No internationalization, always use English msgid.
328217309Snwhitehorndnl    Catalog format: none
329217309Snwhitehorndnl    Catalog extension: none
330217309Snwhitehorndnl The use of .gmo is historical (it was needed to avoid overwriting the
331217309Snwhitehorndnl GNU format catalogs when building on a platform with an X/Open gettext),
332217309Snwhitehorndnl but we keep it in order not to force irrelevant filename changes on the
333217309Snwhitehorndnl maintainers.
334217309Snwhitehorndnl
335217309SnwhitehornAC_DEFUN([AM_WITH_NLS],
336217309Snwhitehorn[AC_MSG_CHECKING([whether NLS is requested])
337217309Snwhitehorn  dnl Default is enabled NLS
338217309Snwhitehorn  ifelse([$4],,[
339217309Snwhitehorn  AC_ARG_ENABLE(nls,
340217309Snwhitehorn    [  --disable-nls           do not use Native Language Support],
341217309Snwhitehorn    USE_NLS=$enableval, USE_NLS=yes)],[
342217309Snwhitehorn  AC_ARG_ENABLE(nls,
343217309Snwhitehorn    [  --enable-nls            use Native Language Support],
344217309Snwhitehorn    USE_NLS=$enableval, USE_NLS=no)])
345217309Snwhitehorn  AC_MSG_RESULT($USE_NLS)
346217309Snwhitehorn  AC_SUBST(USE_NLS)
347217309Snwhitehorn
348217309Snwhitehorn  BUILD_INCLUDED_LIBINTL=no
349217309Snwhitehorn  USE_INCLUDED_LIBINTL=no
350217309Snwhitehorn  INTLLIBS=
351217309Snwhitehorn
352217309Snwhitehorn  dnl If we use NLS figure out what method
353217309Snwhitehorn  if test "$USE_NLS" = "yes"; then
354217309Snwhitehorn    AC_DEFINE(ENABLE_NLS, 1,
355217309Snwhitehorn      [Define to 1 if translation of program messages to the user's native language
356217309Snwhitehorn is requested.])
357217309Snwhitehorn    AC_MSG_CHECKING([whether included gettext is requested])
358217309Snwhitehorn    AC_ARG_WITH(included-gettext,
359217309Snwhitehorn      [  --with-included-gettext use the GNU gettext library included here],
360217309Snwhitehorn      nls_cv_force_use_gnu_gettext=$withval,
361217309Snwhitehorn      nls_cv_force_use_gnu_gettext=no)
362217309Snwhitehorn    AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
363217309Snwhitehorn
364217309Snwhitehorn    nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
365217309Snwhitehorn    if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
366217309Snwhitehorn      dnl User does not insist on using GNU NLS library.  Figure out what
367217309Snwhitehorn      dnl to use.  If GNU gettext is available we use this.  Else we have
368217309Snwhitehorn      dnl to fall back to GNU NLS library.
369217309Snwhitehorn      CATOBJEXT=NONE
370217309Snwhitehorn
371217309Snwhitehorn      cf_save_LIBS_1="$LIBS"
372217309Snwhitehorn      LIBS="$LIBICONV $LIBS"
373217309Snwhitehorn      AC_CACHE_CHECK([for libintl.h and gettext()], cf_cv_func_gettext,[
374217309Snwhitehorn        CF_FIND_LINKAGE(CF__INTL_HEAD,
375217309Snwhitehorn        CF__INTL_BODY,
376217309Snwhitehorn        intl,
377217309Snwhitehorn        cf_cv_func_gettext=yes,
378217309Snwhitehorn        cf_cv_func_gettext=no)
379217309Snwhitehorn      ])
380217309Snwhitehorn      LIBS="$cf_save_LIBS_1"
381217309Snwhitehorn
382217309Snwhitehorn      if test "$cf_cv_func_gettext" = yes ; then
383217309Snwhitehorn        AC_DEFINE(HAVE_LIBINTL_H)
384217309Snwhitehorn
385217309Snwhitehorn        dnl If an already present or preinstalled GNU gettext() is found,
386217309Snwhitehorn        dnl use it.  But if this macro is used in GNU gettext, and GNU
387217309Snwhitehorn        dnl gettext is already preinstalled in libintl, we update this
388217309Snwhitehorn        dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
389217309Snwhitehorn        if test "$PACKAGE" != gettext; then
390217309Snwhitehorn          AC_DEFINE(HAVE_GETTEXT, 1,
391217309Snwhitehorn              [Define if the GNU gettext() function is already present or preinstalled.])
392217309Snwhitehorn
393217309Snwhitehorn          CF_ADD_INCDIR($cf_cv_header_path_intl)
394217309Snwhitehorn
395217309Snwhitehorn          if test -n "$cf_cv_library_file_intl" ; then
396217309Snwhitehorn            dnl If iconv() is in a separate libiconv library, then anyone
397217309Snwhitehorn            dnl linking with libintl{.a,.so} also needs to link with
398217309Snwhitehorn            dnl libiconv.
399217309Snwhitehorn            INTLLIBS="$cf_cv_library_file_intl $LIBICONV"
400217309Snwhitehorn            CF_ADD_LIBDIR($cf_cv_library_path_intl,INTLLIBS)
401217309Snwhitehorn          fi
402217309Snwhitehorn
403217309Snwhitehorn          gt_save_LIBS="$LIBS"
404217309Snwhitehorn          LIBS="$LIBS $INTLLIBS"
405217309Snwhitehorn          AC_CHECK_FUNCS(dcgettext)
406217309Snwhitehorn          LIBS="$gt_save_LIBS"
407217309Snwhitehorn
408217309Snwhitehorn          dnl Search for GNU msgfmt in the PATH.
409217309Snwhitehorn          AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
410217309Snwhitehorn              [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
411217309Snwhitehorn          AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
412217309Snwhitehorn
413217309Snwhitehorn          dnl Search for GNU xgettext in the PATH.
414217309Snwhitehorn          AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
415217309Snwhitehorn              [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
416217309Snwhitehorn
417217309Snwhitehorn          CATOBJEXT=.gmo
418217309Snwhitehorn        fi
419217309Snwhitehorn      fi
420217309Snwhitehorn
421217309Snwhitehorn      if test "$CATOBJEXT" = "NONE"; then
422217309Snwhitehorn        dnl GNU gettext is not found in the C library.
423217309Snwhitehorn        dnl Fall back on GNU gettext library.
424217309Snwhitehorn        nls_cv_use_gnu_gettext=yes
425217309Snwhitehorn      fi
426217309Snwhitehorn    fi
427217309Snwhitehorn
428217309Snwhitehorn    if test "$nls_cv_use_gnu_gettext" = "yes"; then
429217309Snwhitehorn      if test ! -d $srcdir/intl ; then
430217309Snwhitehorn        AC_MSG_ERROR(no NLS library is packaged with this application)
431217309Snwhitehorn      fi
432217309Snwhitehorn      dnl Mark actions used to generate GNU NLS library.
433217309Snwhitehorn      INTLOBJS="\$(GETTOBJS)"
434217309Snwhitehorn      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
435217309Snwhitehorn          [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
436217309Snwhitehorn      AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
437217309Snwhitehorn      AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
438217309Snwhitehorn          [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
439217309Snwhitehorn      AC_SUBST(MSGFMT)
440217309Snwhitehorn      BUILD_INCLUDED_LIBINTL=yes
441217309Snwhitehorn      USE_INCLUDED_LIBINTL=yes
442217309Snwhitehorn      CATOBJEXT=.gmo
443217309Snwhitehorn      INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
444217309Snwhitehorn      LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
445217309Snwhitehorn    fi
446217309Snwhitehorn
447217309Snwhitehorn    dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
448217309Snwhitehorn    dnl Test whether we really found GNU msgfmt.
449217309Snwhitehorn    if test "$GMSGFMT" != ":"; then
450217309Snwhitehorn      dnl If it is no GNU msgfmt we define it as : so that the
451217309Snwhitehorn      dnl Makefiles still can work.
452217309Snwhitehorn      if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
453217309Snwhitehorn        : ;
454217309Snwhitehorn      else
455217309Snwhitehorn        AC_MSG_RESULT(
456217309Snwhitehorn          [found msgfmt program is not GNU msgfmt; ignore it])
457217309Snwhitehorn        GMSGFMT=":"
458217309Snwhitehorn      fi
459217309Snwhitehorn    fi
460217309Snwhitehorn
461217309Snwhitehorn    dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
462217309Snwhitehorn    dnl Test whether we really found GNU xgettext.
463217309Snwhitehorn    if test "$XGETTEXT" != ":"; then
464217309Snwhitehorn        dnl If it is no GNU xgettext we define it as : so that the
465217309Snwhitehorn        dnl Makefiles still can work.
466217309Snwhitehorn      if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
467217309Snwhitehorn        : ;
468217309Snwhitehorn      else
469217309Snwhitehorn        AC_MSG_RESULT(
470217309Snwhitehorn          [found xgettext program is not GNU xgettext; ignore it])
471217309Snwhitehorn        XGETTEXT=":"
472217309Snwhitehorn      fi
473217309Snwhitehorn    fi
474217309Snwhitehorn
475217309Snwhitehorn    dnl We need to process the po/ directory.
476217309Snwhitehorn    POSUB=po
477217309Snwhitehorn  fi
478217309Snwhitehorn
479217309Snwhitehorn  AC_OUTPUT_COMMANDS(
480217309Snwhitehorn   [for ac_file in $CONFIG_FILES; do
481217309Snwhitehorn
482217309Snwhitehorn      # Support "outfile[:infile[:infile...]]"
483217309Snwhitehorn      case "$ac_file" in
484217309Snwhitehorn        *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
485217309Snwhitehorn      esac
486217309Snwhitehorn
487217309Snwhitehorn      # PO directories have a Makefile.in generated from Makefile.inn.
488217309Snwhitehorn      case "$ac_file" in */[Mm]akefile.in)
489217309Snwhitehorn        # Adjust a relative srcdir.
490217309Snwhitehorn        ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
491217309Snwhitehorn        ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
492217309Snwhitehorn        ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
493217309Snwhitehorn        ac_base=`basename $ac_file .in`
494217309Snwhitehorn        # In autoconf-2.13 it is called $ac_given_srcdir.
495217309Snwhitehorn        # In autoconf-2.50 it is called $srcdir.
496217309Snwhitehorn        test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
497217309Snwhitehorn
498217309Snwhitehorn        case "$ac_given_srcdir" in
499217309Snwhitehorn          .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
500217309Snwhitehorn          /*) top_srcdir="$ac_given_srcdir" ;;
501217309Snwhitehorn          *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
502217309Snwhitehorn        esac
503217309Snwhitehorn
504217309Snwhitehorn        if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
505217309Snwhitehorn          rm -f "$ac_dir/POTFILES"
506217309Snwhitehorn          test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
507217309Snwhitehorn          sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
508217309Snwhitehorn          test -n "$as_me" && echo "$as_me: creating $ac_dir/$ac_base" || echo "creating $ac_dir/$ac_base"
509217309Snwhitehorn          sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/$ac_base.in" > "$ac_dir/$ac_base"
510217309Snwhitehorn        fi
511217309Snwhitehorn        ;;
512217309Snwhitehorn      esac
513217309Snwhitehorn    done])
514217309Snwhitehorn
515217309Snwhitehorn  dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
516217309Snwhitehorn  dnl to 'yes' because some of the testsuite requires it.
517217309Snwhitehorn  if test "$PACKAGE" = gettext; then
518217309Snwhitehorn    BUILD_INCLUDED_LIBINTL=yes
519217309Snwhitehorn  fi
520217309Snwhitehorn
521217309Snwhitehorn  dnl intl/plural.c is generated from intl/plural.y. It requires bison,
522217309Snwhitehorn  dnl because plural.y uses bison specific features. It requires at least
523217309Snwhitehorn  dnl bison-1.26 because earlier versions generate a plural.c that doesn't
524217309Snwhitehorn  dnl compile.
525217309Snwhitehorn  dnl bison is only needed for the maintainer (who touches plural.y). But in
526217309Snwhitehorn  dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
527217309Snwhitehorn  dnl the rule in general Makefile. Now, some people carelessly touch the
528217309Snwhitehorn  dnl files or have a broken "make" program, hence the plural.c rule will
529217309Snwhitehorn  dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
530217309Snwhitehorn  dnl present or too old.
531217309Snwhitehorn  if test "$nls_cv_use_gnu_gettext" = "yes"; then
532217309Snwhitehorn    AC_CHECK_PROGS([INTLBISON], [bison])
533217309Snwhitehorn    if test -z "$INTLBISON"; then
534217309Snwhitehorn      ac_verc_fail=yes
535217309Snwhitehorn    else
536217309Snwhitehorn      dnl Found it, now check the version.
537217309Snwhitehorn      AC_MSG_CHECKING([version of bison])
538217309Snwhitehornchangequote(<<,>>)dnl
539217309Snwhitehorn      ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
540217309Snwhitehorn      case $ac_prog_version in
541217309Snwhitehorn        '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
542217309Snwhitehorn        1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
543217309Snwhitehornchangequote([,])dnl
544217309Snwhitehorn           ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
545217309Snwhitehorn        *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
546217309Snwhitehorn      esac
547217309Snwhitehorn    AC_MSG_RESULT([$ac_prog_version])
548217309Snwhitehorn    fi
549217309Snwhitehorn    if test $ac_verc_fail = yes; then
550217309Snwhitehorn      INTLBISON=:
551217309Snwhitehorn    fi
552217309Snwhitehorn  fi
553217309Snwhitehorn
554217309Snwhitehorn  dnl These rules are solely for the distribution goal.  While doing this
555217309Snwhitehorn  dnl we only have to keep exactly one list of the available catalogs
556217309Snwhitehorn  dnl in configure.in.
557217309Snwhitehorn  for lang in $ALL_LINGUAS; do
558217309Snwhitehorn    GMOFILES="$GMOFILES $lang.gmo"
559217309Snwhitehorn    POFILES="$POFILES $lang.po"
560217309Snwhitehorn  done
561217309Snwhitehorn
562217309Snwhitehorn  dnl Make all variables we use known to autoconf.
563217309Snwhitehorn  AC_SUBST(BUILD_INCLUDED_LIBINTL)
564217309Snwhitehorn  AC_SUBST(USE_INCLUDED_LIBINTL)
565217309Snwhitehorn  AC_SUBST(CATALOGS)
566217309Snwhitehorn  AC_SUBST(CATOBJEXT)
567217309Snwhitehorn  AC_SUBST(GMOFILES)
568217309Snwhitehorn  AC_SUBST(INTLLIBS)
569217309Snwhitehorn  AC_SUBST(INTLOBJS)
570217309Snwhitehorn  AC_SUBST(POFILES)
571217309Snwhitehorn  AC_SUBST(POSUB)
572217309Snwhitehorn
573217309Snwhitehorn  dnl For backward compatibility. Some configure.ins may be using this.
574217309Snwhitehorn  nls_cv_header_intl=
575217309Snwhitehorn  nls_cv_header_libgt=
576217309Snwhitehorn
577217309Snwhitehorn  dnl For backward compatibility. Some Makefiles may be using this.
578217309Snwhitehorn  DATADIRNAME=share
579217309Snwhitehorn  AC_SUBST(DATADIRNAME)
580217309Snwhitehorn
581217309Snwhitehorn  dnl For backward compatibility. Some Makefiles may be using this.
582217309Snwhitehorn  INSTOBJEXT=.mo
583217309Snwhitehorn  AC_SUBST(INSTOBJEXT)
584217309Snwhitehorn
585217309Snwhitehorn  dnl For backward compatibility. Some Makefiles may be using this.
586217309Snwhitehorn  GENCAT=gencat
587217309Snwhitehorn  AC_SUBST(GENCAT)
588217309Snwhitehorn])dnl
589217309Snwhitehorndnl ---------------------------------------------------------------------------
590217309Snwhitehorndnl CF_AC_PREREQ version: 2 updated: 1997/09/06 13:24:56
591217309Snwhitehorndnl ------------
592217309Snwhitehorndnl Conditionally generate script according to whether we're using the release
593217309Snwhitehorndnl version of autoconf, or a patched version (using the ternary component as
594217309Snwhitehorndnl the patch-version).
595217309Snwhitehorndefine(CF_AC_PREREQ,
596217309Snwhitehorn[CF_PREREQ_COMPARE(
597217309SnwhitehornAC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)),
598217309SnwhitehornAC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])), [$1], [$2], [$3])])dnl
599217309Snwhitehorndnl ---------------------------------------------------------------------------
600217309Snwhitehorndnl CF_ADD_CFLAGS version: 9 updated: 2010/01/09 11:05:50
601217309Snwhitehorndnl -------------
602217309Snwhitehorndnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
603217309Snwhitehorndnl The second parameter if given makes this macro verbose.
604217309Snwhitehorndnl
605217309Snwhitehorndnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
606217309Snwhitehorndnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
607217309Snwhitehorndnl confused by the quotes (which require backslashes to keep them usable).
608217309SnwhitehornAC_DEFUN([CF_ADD_CFLAGS],
609217309Snwhitehorn[
610217309Snwhitehorncf_fix_cppflags=no
611217309Snwhitehorncf_new_cflags=
612217309Snwhitehorncf_new_cppflags=
613217309Snwhitehorncf_new_extra_cppflags=
614217309Snwhitehorn
615217309Snwhitehornfor cf_add_cflags in $1
616217309Snwhitehorndo
617217309Snwhitehorncase $cf_fix_cppflags in
618217309Snwhitehornno)
619217309Snwhitehorn	case $cf_add_cflags in #(vi
620217309Snwhitehorn	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
621217309Snwhitehorn		case $cf_add_cflags in
622217309Snwhitehorn		-D*)
623217309Snwhitehorn			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
624217309Snwhitehorn
625217309Snwhitehorn			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
626217309Snwhitehorn				&& test -z "${cf_tst_cflags}" \
627217309Snwhitehorn				&& cf_fix_cppflags=yes
628217309Snwhitehorn
629217309Snwhitehorn			if test $cf_fix_cppflags = yes ; then
630217309Snwhitehorn				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
631217309Snwhitehorn				continue
632217309Snwhitehorn			elif test "${cf_tst_cflags}" = "\"'" ; then
633217309Snwhitehorn				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
634217309Snwhitehorn				continue
635217309Snwhitehorn			fi
636217309Snwhitehorn			;;
637217309Snwhitehorn		esac
638217309Snwhitehorn		case "$CPPFLAGS" in
639217309Snwhitehorn		*$cf_add_cflags) #(vi
640217309Snwhitehorn			;;
641217309Snwhitehorn		*) #(vi
642217309Snwhitehorn			case $cf_add_cflags in #(vi
643217309Snwhitehorn			-D*)
644217309Snwhitehorn				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
645217309Snwhitehorn				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
646217309Snwhitehorn				;;
647217309Snwhitehorn			esac
648217309Snwhitehorn			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
649217309Snwhitehorn			;;
650217309Snwhitehorn		esac
651217309Snwhitehorn		;;
652217309Snwhitehorn	*)
653217309Snwhitehorn		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
654217309Snwhitehorn		;;
655217309Snwhitehorn	esac
656217309Snwhitehorn	;;
657217309Snwhitehornyes)
658217309Snwhitehorn	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
659217309Snwhitehorn
660217309Snwhitehorn	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
661217309Snwhitehorn
662217309Snwhitehorn	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
663217309Snwhitehorn		&& test -z "${cf_tst_cflags}" \
664217309Snwhitehorn		&& cf_fix_cppflags=no
665217309Snwhitehorn	;;
666217309Snwhitehornesac
667217309Snwhitehorndone
668217309Snwhitehorn
669217309Snwhitehornif test -n "$cf_new_cflags" ; then
670217309Snwhitehorn	ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
671217309Snwhitehorn	CFLAGS="$CFLAGS $cf_new_cflags"
672217309Snwhitehornfi
673217309Snwhitehorn
674217309Snwhitehornif test -n "$cf_new_cppflags" ; then
675217309Snwhitehorn	ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
676217309Snwhitehorn	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
677217309Snwhitehornfi
678217309Snwhitehorn
679217309Snwhitehornif test -n "$cf_new_extra_cppflags" ; then
680217309Snwhitehorn	ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
681217309Snwhitehorn	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
682217309Snwhitehornfi
683217309Snwhitehorn
684217309SnwhitehornAC_SUBST(EXTRA_CPPFLAGS)
685217309Snwhitehorn
686217309Snwhitehorn])dnl
687217309Snwhitehorndnl ---------------------------------------------------------------------------
688217309Snwhitehorndnl CF_ADD_INCDIR version: 12 updated: 2009/01/18 10:00:47
689217309Snwhitehorndnl -------------
690217309Snwhitehorndnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
691217309Snwhitehorndnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
692217309Snwhitehorndnl but old versions (and some misinstalled ones) need that.  To make things
693217309Snwhitehorndnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
694217309Snwhitehorndnl the include-path).
695217309SnwhitehornAC_DEFUN([CF_ADD_INCDIR],
696217309Snwhitehorn[
697217309Snwhitehornif test -n "$1" ; then
698217309Snwhitehorn  for cf_add_incdir in $1
699217309Snwhitehorn  do
700217309Snwhitehorn	while test $cf_add_incdir != /usr/include
701217309Snwhitehorn	do
702217309Snwhitehorn	  if test -d $cf_add_incdir
703217309Snwhitehorn	  then
704217309Snwhitehorn		cf_have_incdir=no
705217309Snwhitehorn		if test -n "$CFLAGS$CPPFLAGS" ; then
706217309Snwhitehorn		  # a loop is needed to ensure we can add subdirs of existing dirs
707217309Snwhitehorn		  for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
708217309Snwhitehorn			if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
709217309Snwhitehorn			  cf_have_incdir=yes; break
710217309Snwhitehorn			fi
711217309Snwhitehorn		  done
712217309Snwhitehorn		fi
713217309Snwhitehorn
714217309Snwhitehorn		if test "$cf_have_incdir" = no ; then
715217309Snwhitehorn		  if test "$cf_add_incdir" = /usr/local/include ; then
716217309Snwhitehorn			if test "$GCC" = yes
717217309Snwhitehorn			then
718217309Snwhitehorn			  cf_save_CPPFLAGS=$CPPFLAGS
719217309Snwhitehorn			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
720217309Snwhitehorn			  AC_TRY_COMPILE([#include <stdio.h>],
721217309Snwhitehorn				  [printf("Hello")],
722217309Snwhitehorn				  [],
723217309Snwhitehorn				  [cf_have_incdir=yes])
724217309Snwhitehorn			  CPPFLAGS=$cf_save_CPPFLAGS
725217309Snwhitehorn			fi
726217309Snwhitehorn		  fi
727217309Snwhitehorn		fi
728217309Snwhitehorn
729217309Snwhitehorn		if test "$cf_have_incdir" = no ; then
730217309Snwhitehorn		  CF_VERBOSE(adding $cf_add_incdir to include-path)
731217309Snwhitehorn		  ifelse($2,,CPPFLAGS,$2)="$ifelse($2,,CPPFLAGS,$2) -I$cf_add_incdir"
732217309Snwhitehorn
733217309Snwhitehorn		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
734217309Snwhitehorn		  test "$cf_top_incdir" = "$cf_add_incdir" && break
735217309Snwhitehorn		  cf_add_incdir="$cf_top_incdir"
736217309Snwhitehorn		else
737217309Snwhitehorn		  break
738217309Snwhitehorn		fi
739217309Snwhitehorn	  fi
740217309Snwhitehorn	done
741217309Snwhitehorn  done
742217309Snwhitehornfi
743217309Snwhitehorn])dnl
744217309Snwhitehorndnl ---------------------------------------------------------------------------
745217309Snwhitehorndnl CF_ADD_LIBDIR version: 8 updated: 2009/01/18 10:01:08
746217309Snwhitehorndnl -------------
747217309Snwhitehorndnl	Adds to the library-path
748217309Snwhitehorndnl
749217309Snwhitehorndnl	Some machines have trouble with multiple -L options.
750217309Snwhitehorndnl
751217309Snwhitehorndnl $1 is the (list of) directory(s) to add
752217309Snwhitehorndnl $2 is the optional name of the variable to update (default LDFLAGS)
753217309Snwhitehorndnl
754217309SnwhitehornAC_DEFUN([CF_ADD_LIBDIR],
755217309Snwhitehorn[
756217309Snwhitehornif test -n "$1" ; then
757217309Snwhitehorn  for cf_add_libdir in $1
758217309Snwhitehorn  do
759217309Snwhitehorn    if test $cf_add_libdir = /usr/lib ; then
760217309Snwhitehorn      :
761217309Snwhitehorn    elif test -d $cf_add_libdir
762217309Snwhitehorn    then
763217309Snwhitehorn      cf_have_libdir=no
764217309Snwhitehorn      if test -n "$LDFLAGS$LIBS" ; then
765217309Snwhitehorn        # a loop is needed to ensure we can add subdirs of existing dirs
766217309Snwhitehorn        for cf_test_libdir in $LDFLAGS $LIBS ; do
767217309Snwhitehorn          if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
768217309Snwhitehorn            cf_have_libdir=yes; break
769217309Snwhitehorn          fi
770217309Snwhitehorn        done
771217309Snwhitehorn      fi
772217309Snwhitehorn      if test "$cf_have_libdir" = no ; then
773217309Snwhitehorn        CF_VERBOSE(adding $cf_add_libdir to library-path)
774217309Snwhitehorn        ifelse($2,,LDFLAGS,$2)="-L$cf_add_libdir $ifelse($2,,LDFLAGS,$2)"
775217309Snwhitehorn      fi
776217309Snwhitehorn    fi
777217309Snwhitehorn  done
778217309Snwhitehornfi
779217309Snwhitehorn])dnl
780217309Snwhitehorndnl ---------------------------------------------------------------------------
781217309Snwhitehorndnl CF_ADD_OPTIONAL_PATH version: 1 updated: 2007/07/29 12:33:33
782217309Snwhitehorndnl --------------------
783217309Snwhitehorndnl Add an optional search-path to the compile/link variables.
784217309Snwhitehorndnl See CF_WITH_PATH
785217309Snwhitehorndnl
786217309Snwhitehorndnl $1 = shell variable containing the result of --with-XXX=[DIR]
787217309Snwhitehorndnl $2 = module to look for.
788217309SnwhitehornAC_DEFUN([CF_ADD_OPTIONAL_PATH],[
789217309Snwhitehorn  case "$1" in #(vi
790217309Snwhitehorn  no) #(vi
791217309Snwhitehorn      ;;
792217309Snwhitehorn  yes) #(vi
793217309Snwhitehorn      ;;
794217309Snwhitehorn  *)
795217309Snwhitehorn      CF_ADD_SEARCHPATH([$1], [AC_MSG_ERROR(cannot find $2 under $1)])
796217309Snwhitehorn      ;;
797217309Snwhitehorn  esac
798217309Snwhitehorn])dnl
799217309Snwhitehorndnl ---------------------------------------------------------------------------
800217309Snwhitehorndnl CF_ADD_SEARCHPATH version: 5 updated: 2009/01/11 20:40:21
801217309Snwhitehorndnl -----------------
802217309Snwhitehorndnl Set $CPPFLAGS and $LDFLAGS with the directories given via the parameter.
803217309Snwhitehorndnl They can be either the common root of include- and lib-directories, or the
804217309Snwhitehorndnl lib-directory (to allow for things like lib64 directories).
805217309Snwhitehorndnl See also CF_FIND_LINKAGE.
806217309Snwhitehorndnl
807217309Snwhitehorndnl $1 is the list of colon-separated directory names to search.
808217309Snwhitehorndnl $2 is the action to take if a parameter does not yield a directory.
809217309SnwhitehornAC_DEFUN([CF_ADD_SEARCHPATH],
810217309Snwhitehorn[
811217309SnwhitehornAC_REQUIRE([CF_PATHSEP])
812217309Snwhitehornfor cf_searchpath in `echo "$1" | tr $PATH_SEPARATOR ' '`; do
813217309Snwhitehorn	if test -d $cf_searchpath/include; then
814217309Snwhitehorn		CF_ADD_INCDIR($cf_searchpath/include)
815217309Snwhitehorn	elif test -d $cf_searchpath/../include ; then
816217309Snwhitehorn		CF_ADD_INCDIR($cf_searchpath/../include)
817217309Snwhitehorn	ifelse([$2],,,[else
818217309Snwhitehorn$2])
819217309Snwhitehorn	fi
820217309Snwhitehorn	if test -d $cf_searchpath/lib; then
821217309Snwhitehorn		CF_ADD_LIBDIR($cf_searchpath/lib)
822217309Snwhitehorn	elif test -d $cf_searchpath ; then
823217309Snwhitehorn		CF_ADD_LIBDIR($cf_searchpath)
824217309Snwhitehorn	ifelse([$2],,,[else
825217309Snwhitehorn$2])
826217309Snwhitehorn	fi
827217309Snwhitehorndone
828217309Snwhitehorn])
829217309Snwhitehorndnl ---------------------------------------------------------------------------
830217309Snwhitehorndnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59
831217309Snwhitehorndnl ------------------
832217309Snwhitehorndnl Append to a search-list for a nonstandard header/lib-file
833217309Snwhitehorndnl	$1 = the variable to return as result
834217309Snwhitehorndnl	$2 = the package name
835217309Snwhitehorndnl	$3 = the subdirectory, e.g., bin, include or lib
836217309Snwhitehorndnl $4 = the directory under which we will test for subdirectories
837217309Snwhitehorndnl $5 = a directory that we do not want $4 to match
838217309SnwhitehornAC_DEFUN([CF_ADD_SUBDIR_PATH],
839217309Snwhitehorn[
840217309Snwhitehorntest "$4" != "$5" && \
841217309Snwhitehorntest -d "$4" && \
842217309Snwhitehornifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) {
843217309Snwhitehorn	test -n "$verbose" && echo "	... testing for $3-directories under $4"
844217309Snwhitehorn	test -d $4/$3 &&          $1="[$]$1 $4/$3"
845217309Snwhitehorn	test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
846217309Snwhitehorn	test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
847217309Snwhitehorn	test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
848217309Snwhitehorn	test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
849217309Snwhitehorn}
850217309Snwhitehorn])dnl
851217309Snwhitehorndnl ---------------------------------------------------------------------------
852217309Snwhitehorndnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
853217309Snwhitehorndnl --------------
854217309Snwhitehorndnl Allow user to disable a normally-on option.
855217309SnwhitehornAC_DEFUN([CF_ARG_DISABLE],
856217309Snwhitehorn[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
857217309Snwhitehorndnl ---------------------------------------------------------------------------
858217309Snwhitehorndnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
859217309Snwhitehorndnl -------------
860217309Snwhitehorndnl Allow user to enable a normally-off option.
861217309SnwhitehornAC_DEFUN([CF_ARG_ENABLE],
862217309Snwhitehorn[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
863217309Snwhitehorndnl ---------------------------------------------------------------------------
864217309Snwhitehorndnl CF_ARG_MSG_ENABLE version: 2 updated: 2000/07/29 19:32:03
865217309Snwhitehorndnl -----------------
866217309Snwhitehorndnl Verbose form of AC_ARG_ENABLE:
867217309Snwhitehorndnl
868217309Snwhitehorndnl Parameters:
869217309Snwhitehorndnl $1 = message
870217309Snwhitehorndnl $2 = option name
871217309Snwhitehorndnl $3 = help-string
872217309Snwhitehorndnl $4 = action to perform if option is enabled
873217309Snwhitehorndnl $5 = action if perform if option is disabled
874217309Snwhitehorndnl $6 = default option value (either 'yes' or 'no')
875217309SnwhitehornAC_DEFUN([CF_ARG_MSG_ENABLE],[
876217309SnwhitehornAC_MSG_CHECKING($1)
877217309SnwhitehornAC_ARG_ENABLE($2,[$3],,enableval=ifelse($6,,no,$6))
878217309SnwhitehornAC_MSG_RESULT($enableval)
879217309Snwhitehornif test "$enableval" != no ; then
880217309Snwhitehornifelse($4,,[	:],$4)
881217309Snwhitehornelse
882217309Snwhitehornifelse($5,,[	:],$5)
883217309Snwhitehornfi
884217309Snwhitehorn])dnl
885217309Snwhitehorndnl ---------------------------------------------------------------------------
886217309Snwhitehorndnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
887217309Snwhitehorndnl -------------
888217309Snwhitehorndnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
889217309Snwhitehorndnl values.
890217309Snwhitehorndnl
891217309Snwhitehorndnl Parameters:
892217309Snwhitehorndnl $1 = option name
893217309Snwhitehorndnl $2 = help-string
894217309Snwhitehorndnl $3 = action to perform if option is not default
895217309Snwhitehorndnl $4 = action if perform if option is default
896217309Snwhitehorndnl $5 = default option value (either 'yes' or 'no')
897217309SnwhitehornAC_DEFUN([CF_ARG_OPTION],
898217309Snwhitehorn[AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
899217309Snwhitehorn  if test "$enableval" != "$5" ; then
900217309Snwhitehornifelse($3,,[    :]dnl
901217309Snwhitehorn,[    $3]) ifelse($4,,,[
902217309Snwhitehorn  else
903217309Snwhitehorn    $4])
904217309Snwhitehorn  fi],[enableval=$5 ifelse($4,,,[
905217309Snwhitehorn  $4
906217309Snwhitehorn])dnl
907217309Snwhitehorn  ])])dnl
908217309Snwhitehorndnl ---------------------------------------------------------------------------
909217309Snwhitehorndnl CF_BUNDLED_INTL version: 14 updated: 2010/01/17 20:37:27
910217309Snwhitehorndnl ---------------
911217309Snwhitehorndnl Top-level macro for configuring an application with a bundled copy of
912217309Snwhitehorndnl the intl and po directories for gettext.
913217309Snwhitehorndnl
914217309Snwhitehorndnl $1 specifies either Makefile or makefile, defaulting to the former.
915217309Snwhitehorndnl $2 if nonempty sets the option to --enable-nls rather than to --disable-nls
916217309Snwhitehorndnl
917217309Snwhitehorndnl Sets variables which can be used to substitute in makefiles:
918217309Snwhitehorndnl	GT_YES       - "#" comment unless building intl library, otherwise empty
919217309Snwhitehorndnl	GT_NO        - "#" comment if building intl library, otherwise empty
920217309Snwhitehorndnl	INTLDIR_MAKE - to make ./intl directory
921217309Snwhitehorndnl	MSG_DIR_MAKE - to make ./po directory
922217309Snwhitehorndnl	SUB_MAKEFILE - list of makefiles in ./intl, ./po directories
923217309Snwhitehorndnl Defines
924217309Snwhitehorndnl	HAVE_LIBGETTEXT_H if we're using ./intl
925217309Snwhitehorndnl
926217309Snwhitehorndnl Environment:
927217309Snwhitehorndnl	ALL_LINGUAS if set, lists the root names of the ".po" files.
928217309Snwhitehorndnl	CONFIG_H assumed to be "config.h"
929217309Snwhitehorndnl	VERSION may be set, otherwise extract from "VERSION" file.
930217309Snwhitehorndnl
931217309SnwhitehornAC_DEFUN([CF_BUNDLED_INTL],[
932217309Snwhitehorncf_makefile=ifelse($1,,Makefile,$1)
933217309Snwhitehorn
934217309Snwhitehorndnl Set of available languages (based on source distribution).  Note that
935217309Snwhitehorndnl setting $LINGUAS overrides $ALL_LINGUAS.  Some environments set $LINGUAS
936217309Snwhitehorndnl rather than $LC_ALL
937217309Snwhitehorntest -z "$ALL_LINGUAS" && ALL_LINGUAS=`test -d $srcdir/po && cd $srcdir/po && echo *.po|sed -e 's/\.po//g' -e 's/*//'`
938217309Snwhitehorn
939217309Snwhitehorn# Allow override of "config.h" definition:
940217309Snwhitehorn: ${CONFIG_H=config.h}
941217309SnwhitehornAC_SUBST(CONFIG_H)
942217309Snwhitehorn
943217309Snwhitehornif test -z "$VERSION" ; then
944217309Snwhitehornif test -f $srcdir/VERSION ; then
945217309Snwhitehorn	VERSION=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
946217309Snwhitehornelse
947217309Snwhitehorn	VERSION=unknown
948217309Snwhitehornfi
949217309Snwhitehornfi
950217309SnwhitehornAC_SUBST(VERSION)
951217309Snwhitehorn
952217309SnwhitehornAM_GNU_GETTEXT(,,,[$2])
953217309Snwhitehorn
954217309SnwhitehornINTLDIR_MAKE=
955217309SnwhitehornMSG_DIR_MAKE=
956217309SnwhitehornSUB_MAKEFILE=
957217309Snwhitehorn
958217309Snwhitehorndnl this updates SUB_MAKEFILE and MSG_DIR_MAKE:
959217309SnwhitehornCF_OUR_MESSAGES($1)
960217309Snwhitehorn
961217309Snwhitehornif test "$USE_INCLUDED_LIBINTL" = yes ; then
962217309Snwhitehorn        if test "$nls_cv_force_use_gnu_gettext" = yes ; then
963217309Snwhitehorn		:
964217309Snwhitehorn	elif test "$nls_cv_use_gnu_gettext" = yes ; then
965217309Snwhitehorn		:
966217309Snwhitehorn	else
967217309Snwhitehorn		INTLDIR_MAKE="#"
968217309Snwhitehorn	fi
969217309Snwhitehorn	if test -z "$INTLDIR_MAKE"; then
970217309Snwhitehorn		AC_DEFINE(HAVE_LIBGETTEXT_H)
971217309Snwhitehorn		for cf_makefile in \
972217309Snwhitehorn			$srcdir/intl/Makefile.in \
973217309Snwhitehorn			$srcdir/intl/makefile.in
974217309Snwhitehorn		do
975217309Snwhitehorn			if test -f "$cf_makefile" ; then
976217309Snwhitehorn				SUB_MAKEFILE="$SUB_MAKEFILE `echo \"${cf_makefile}\"|sed -e 's,^'$srcdir/',,' -e 's/\.in$//'`:${cf_makefile}"
977217309Snwhitehorn				break
978217309Snwhitehorn			fi
979217309Snwhitehorn		done
980217309Snwhitehorn	fi
981217309Snwhitehornelse
982217309Snwhitehorn	INTLDIR_MAKE="#"
983217309Snwhitehorn	if test "$USE_NLS" = yes ; then
984217309Snwhitehorn		AC_CHECK_HEADERS(libintl.h)
985217309Snwhitehorn	fi
986217309Snwhitehornfi
987217309Snwhitehorn
988217309Snwhitehornif test -z "$INTLDIR_MAKE" ; then
989217309Snwhitehorn	CPPFLAGS="$CPPFLAGS -I../intl"
990217309Snwhitehornfi
991217309Snwhitehorn
992217309Snwhitehorndnl FIXME:  we use this in lynx (the alternative is a spurious dependency upon
993217309Snwhitehorndnl GNU make)
994217309Snwhitehornif test "$BUILD_INCLUDED_LIBINTL" = yes ; then
995217309Snwhitehorn	GT_YES="#"
996217309Snwhitehorn	GT_NO=
997217309Snwhitehornelse
998217309Snwhitehorn	GT_YES=
999217309Snwhitehorn	GT_NO="#"
1000217309Snwhitehornfi
1001217309Snwhitehorn
1002217309SnwhitehornAC_SUBST(INTLDIR_MAKE)
1003217309SnwhitehornAC_SUBST(MSG_DIR_MAKE)
1004217309SnwhitehornAC_SUBST(GT_YES)
1005217309SnwhitehornAC_SUBST(GT_NO)
1006217309Snwhitehorn
1007217309Snwhitehorndnl FIXME:  the underlying AM_GNU_GETTEXT macro either needs some fixes or a
1008217309Snwhitehorndnl little documentation.  It doesn't define anything so that we can ifdef our
1009217309Snwhitehorndnl own code, except ENABLE_NLS, which is too vague to be of any use.
1010217309Snwhitehorn
1011217309Snwhitehornif test "$USE_INCLUDED_LIBINTL" = yes ; then
1012217309Snwhitehorn	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
1013217309Snwhitehorn		AC_DEFINE(HAVE_GETTEXT)
1014217309Snwhitehorn	elif test "$nls_cv_use_gnu_gettext" = yes ; then
1015217309Snwhitehorn		AC_DEFINE(HAVE_GETTEXT)
1016217309Snwhitehorn	fi
1017217309Snwhitehorn	if test -n "$nls_cv_header_intl" ; then
1018217309Snwhitehorn		AC_DEFINE(HAVE_LIBINTL_H)
1019217309Snwhitehorn	fi
1020217309Snwhitehornfi
1021217309Snwhitehorn])dnl
1022217309Snwhitehorndnl ---------------------------------------------------------------------------
1023217309Snwhitehorndnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
1024217309Snwhitehorndnl --------------
1025217309Snwhitehorndnl Check if we're accidentally using a cache from a different machine.
1026217309Snwhitehorndnl Derive the system name, as a check for reusing the autoconf cache.
1027217309Snwhitehorndnl
1028217309Snwhitehorndnl If we've packaged config.guess and config.sub, run that (since it does a
1029217309Snwhitehorndnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
1030217309Snwhitehorndnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
1031217309Snwhitehorndnl which is useful in cross-compiles.
1032217309Snwhitehorndnl
1033217309Snwhitehorndnl Note: we would use $ac_config_sub, but that is one of the places where
1034217309Snwhitehorndnl autoconf 2.5x broke compatibility with autoconf 2.13
1035217309SnwhitehornAC_DEFUN([CF_CHECK_CACHE],
1036217309Snwhitehorn[
1037217309Snwhitehornif test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
1038217309Snwhitehorn	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
1039217309Snwhitehorn	system_name="$host_os"
1040217309Snwhitehornelse
1041217309Snwhitehorn	system_name="`(uname -s -r) 2>/dev/null`"
1042217309Snwhitehorn	if test -z "$system_name" ; then
1043217309Snwhitehorn		system_name="`(hostname) 2>/dev/null`"
1044217309Snwhitehorn	fi
1045217309Snwhitehornfi
1046217309Snwhitehorntest -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
1047217309SnwhitehornAC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
1048217309Snwhitehorn
1049217309Snwhitehorntest -z "$system_name" && system_name="$cf_cv_system_name"
1050217309Snwhitehorntest -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
1051217309Snwhitehorn
1052217309Snwhitehornif test ".$system_name" != ".$cf_cv_system_name" ; then
1053217309Snwhitehorn	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
1054217309Snwhitehorn	AC_MSG_ERROR("Please remove config.cache and try again.")
1055217309Snwhitehornfi
1056217309Snwhitehorn])dnl
1057217309Snwhitehorndnl ---------------------------------------------------------------------------
1058217309Snwhitehorndnl CF_CURSES_CHTYPE version: 6 updated: 2003/11/06 19:59:57
1059217309Snwhitehorndnl ----------------
1060217309Snwhitehorndnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses).
1061217309SnwhitehornAC_DEFUN([CF_CURSES_CHTYPE],
1062217309Snwhitehorn[
1063217309SnwhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1064217309SnwhitehornAC_CACHE_CHECK(for chtype typedef,cf_cv_chtype_decl,[
1065217309Snwhitehorn	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header-curses.h}>],
1066217309Snwhitehorn		[chtype foo],
1067217309Snwhitehorn		[cf_cv_chtype_decl=yes],
1068217309Snwhitehorn		[cf_cv_chtype_decl=no])])
1069217309Snwhitehornif test $cf_cv_chtype_decl = yes ; then
1070217309Snwhitehorn	AC_DEFINE(HAVE_TYPE_CHTYPE)
1071217309Snwhitehorn	AC_CACHE_CHECK(if chtype is scalar or struct,cf_cv_chtype_type,[
1072217309Snwhitehorn		AC_TRY_COMPILE([#include <${cf_cv_ncurses_header-curses.h}>],
1073217309Snwhitehorn			[chtype foo; long x = foo],
1074217309Snwhitehorn			[cf_cv_chtype_type=scalar],
1075217309Snwhitehorn			[cf_cv_chtype_type=struct])])
1076217309Snwhitehorn	if test $cf_cv_chtype_type = scalar ; then
1077217309Snwhitehorn		AC_DEFINE(TYPE_CHTYPE_IS_SCALAR)
1078217309Snwhitehorn	fi
1079217309Snwhitehornfi
1080217309Snwhitehorn])dnl
1081217309Snwhitehorndnl ---------------------------------------------------------------------------
1082217309Snwhitehorndnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
1083217309Snwhitehorndnl ----------------
1084217309Snwhitehorndnl Tie together the configure-script macros for curses.  It may be ncurses,
1085217309Snwhitehorndnl but unless asked, we do not make a special search for ncurses.  However,
1086217309Snwhitehorndnl still check for the ncurses version number, for use in other macros.
1087217309SnwhitehornAC_DEFUN([CF_CURSES_CONFIG],
1088217309Snwhitehorn[
1089217309SnwhitehornCF_CURSES_CPPFLAGS
1090217309SnwhitehornCF_NCURSES_VERSION
1091217309SnwhitehornCF_CURSES_LIBS
1092217309Snwhitehorn])dnl
1093217309Snwhitehorndnl ---------------------------------------------------------------------------
1094217309Snwhitehorndnl CF_CURSES_CPPFLAGS version: 10 updated: 2009/01/06 19:34:11
1095217309Snwhitehorndnl ------------------
1096217309Snwhitehorndnl Look for the curses headers.
1097217309SnwhitehornAC_DEFUN([CF_CURSES_CPPFLAGS],[
1098217309Snwhitehorn
1099217309SnwhitehornAC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
1100217309Snwhitehorncf_cv_curses_incdir=no
1101217309Snwhitehorncase $host_os in #(vi
1102217309Snwhitehornhpux10.*) #(vi
1103217309Snwhitehorn	test -d /usr/include/curses_colr && \
1104217309Snwhitehorn	cf_cv_curses_incdir="-I/usr/include/curses_colr"
1105217309Snwhitehorn	;;
1106217309Snwhitehornsunos3*|sunos4*)
1107217309Snwhitehorn	test -d /usr/5lib && \
1108217309Snwhitehorn	test -d /usr/5include && \
1109217309Snwhitehorn	cf_cv_curses_incdir="-I/usr/5include"
1110217309Snwhitehorn	;;
1111217309Snwhitehornesac
1112217309Snwhitehorn])
1113217309Snwhitehorntest "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
1114217309Snwhitehorn
1115217309SnwhitehornCF_CURSES_HEADER
1116217309SnwhitehornCF_TERM_HEADER
1117217309Snwhitehorn])dnl
1118217309Snwhitehorndnl ---------------------------------------------------------------------------
1119217309Snwhitehorndnl CF_CURSES_FUNCS version: 14 updated: 2009/07/16 19:34:55
1120217309Snwhitehorndnl ---------------
1121217309Snwhitehorndnl Curses-functions are a little complicated, since a lot of them are macros.
1122217309SnwhitehornAC_DEFUN([CF_CURSES_FUNCS],
1123217309Snwhitehorn[
1124217309SnwhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1125217309SnwhitehornAC_REQUIRE([CF_XOPEN_CURSES])
1126217309SnwhitehornAC_REQUIRE([CF_CURSES_TERM_H])
1127217309Snwhitehornfor cf_func in $1
1128217309Snwhitehorndo
1129217309Snwhitehorn	CF_UPPER(cf_tr_func,$cf_func)
1130217309Snwhitehorn	AC_MSG_CHECKING(for ${cf_func})
1131217309Snwhitehorn	CF_MSG_LOG(${cf_func})
1132217309Snwhitehorn	AC_CACHE_VAL(cf_cv_func_$cf_func,[
1133217309Snwhitehorn		eval cf_result='$ac_cv_func_'$cf_func
1134217309Snwhitehorn		if test ".$cf_result" != ".no"; then
1135217309Snwhitehorn			AC_TRY_LINK(CF__CURSES_HEAD,
1136217309Snwhitehorn			[
1137217309Snwhitehorn#ifndef ${cf_func}
1138217309Snwhitehornlong foo = (long)(&${cf_func});
1139217309Snwhitehorn${cf_cv_main_return-return}(foo == 0);
1140217309Snwhitehorn#endif
1141217309Snwhitehorn			],
1142217309Snwhitehorn			[cf_result=yes],
1143217309Snwhitehorn			[cf_result=no])
1144217309Snwhitehorn		fi
1145217309Snwhitehorn		eval 'cf_cv_func_'$cf_func'=$cf_result'
1146217309Snwhitehorn	])
1147217309Snwhitehorn	# use the computed/retrieved cache-value:
1148217309Snwhitehorn	eval 'cf_result=$cf_cv_func_'$cf_func
1149217309Snwhitehorn	AC_MSG_RESULT($cf_result)
1150217309Snwhitehorn	if test $cf_result != no; then
1151217309Snwhitehorn		AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
1152217309Snwhitehorn	fi
1153217309Snwhitehorndone
1154217309Snwhitehorn])dnl
1155217309Snwhitehorndnl ---------------------------------------------------------------------------
1156217309Snwhitehorndnl CF_CURSES_HEADER version: 2 updated: 2010/04/28 06:02:16
1157217309Snwhitehorndnl ----------------
1158217309Snwhitehorndnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1159217309Snwhitehorndnl variations of ncurses' installs.
1160217309Snwhitehorndnl
1161217309Snwhitehorndnl $1 = ncurses when looking for ncurses, or is empty
1162217309SnwhitehornAC_DEFUN([CF_CURSES_HEADER],[
1163217309SnwhitehornAC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
1164217309Snwhitehorncf_cv_ncurses_header=none
1165217309Snwhitehornfor cf_header in ifelse($1,,,[ \
1166217309Snwhitehorn    $1/curses.h \
1167217309Snwhitehorn	$1/ncurses.h]) \
1168217309Snwhitehorn	curses.h \
1169217309Snwhitehorn	ncurses.h ifelse($1,,[ncurses/curses.h ncurses/ncurses.h])
1170217309Snwhitehorndo
1171217309SnwhitehornAC_TRY_COMPILE([#include <${cf_header}>],
1172217309Snwhitehorn	[initscr(); tgoto("?", 0,0)],
1173217309Snwhitehorn	[cf_cv_ncurses_header=$cf_header; break],[])
1174217309Snwhitehorndone
1175217309Snwhitehorn])
1176217309Snwhitehorn
1177217309Snwhitehornif test "$cf_cv_ncurses_header" = none ; then
1178217309Snwhitehorn	AC_MSG_ERROR(No curses header-files found)
1179217309Snwhitehornfi
1180217309Snwhitehorn
1181217309Snwhitehorn# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
1182217309SnwhitehornAC_CHECK_HEADERS($cf_cv_ncurses_header)
1183217309Snwhitehorn])dnl
1184217309Snwhitehorndnl ---------------------------------------------------------------------------
1185217309Snwhitehorndnl CF_CURSES_LIBS version: 29 updated: 2009/01/06 19:34:57
1186217309Snwhitehorndnl --------------
1187217309Snwhitehorndnl Look for the curses libraries.  Older curses implementations may require
1188217309Snwhitehorndnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
1189217309SnwhitehornAC_DEFUN([CF_CURSES_LIBS],[
1190217309Snwhitehorn
1191217309SnwhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1192217309SnwhitehornAC_MSG_CHECKING(if we have identified curses libraries)
1193217309SnwhitehornAC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1194217309Snwhitehorn    [initscr(); tgoto("?", 0,0)],
1195217309Snwhitehorn    cf_result=yes,
1196217309Snwhitehorn    cf_result=no)
1197217309SnwhitehornAC_MSG_RESULT($cf_result)
1198217309Snwhitehorn
1199217309Snwhitehornif test "$cf_result" = no ; then
1200217309Snwhitehorncase $host_os in #(vi
1201217309Snwhitehornfreebsd*) #(vi
1202217309Snwhitehorn    AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
1203217309Snwhitehorn    ;;
1204217309Snwhitehornhpux10.*) #(vi
1205217309Snwhitehorn    AC_CHECK_LIB(cur_colr,initscr,[
1206217309Snwhitehorn        LIBS="-lcur_colr $LIBS"
1207217309Snwhitehorn        ac_cv_func_initscr=yes
1208217309Snwhitehorn        ],[
1209217309Snwhitehorn    AC_CHECK_LIB(Hcurses,initscr,[
1210217309Snwhitehorn        # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
1211217309Snwhitehorn        LIBS="-lHcurses $LIBS"
1212217309Snwhitehorn        CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
1213217309Snwhitehorn        ac_cv_func_initscr=yes
1214217309Snwhitehorn        ])])
1215217309Snwhitehorn    ;;
1216217309Snwhitehornlinux*) # Suse Linux does not follow /usr/lib convention
1217217309Snwhitehorn    CF_ADD_LIBDIR(/lib)
1218217309Snwhitehorn    ;;
1219217309Snwhitehornsunos3*|sunos4*)
1220217309Snwhitehorn    if test -d /usr/5lib ; then
1221217309Snwhitehorn      CF_ADD_LIBDIR(/usr/5lib)
1222217309Snwhitehorn      LIBS="$LIBS -lcurses -ltermcap"
1223217309Snwhitehorn    fi
1224217309Snwhitehorn    ac_cv_func_initscr=yes
1225217309Snwhitehorn    ;;
1226217309Snwhitehornesac
1227217309Snwhitehorn
1228217309Snwhitehornif test ".$ac_cv_func_initscr" != .yes ; then
1229217309Snwhitehorn    cf_save_LIBS="$LIBS"
1230217309Snwhitehorn    cf_term_lib=""
1231217309Snwhitehorn    cf_curs_lib=""
1232217309Snwhitehorn
1233217309Snwhitehorn    if test ".${cf_cv_ncurses_version-no}" != .no
1234217309Snwhitehorn    then
1235217309Snwhitehorn        cf_check_list="ncurses curses cursesX"
1236217309Snwhitehorn    else
1237217309Snwhitehorn        cf_check_list="cursesX curses ncurses"
1238217309Snwhitehorn    fi
1239217309Snwhitehorn
1240217309Snwhitehorn    # Check for library containing tgoto.  Do this before curses library
1241217309Snwhitehorn    # because it may be needed to link the test-case for initscr.
1242217309Snwhitehorn    AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
1243217309Snwhitehorn        for cf_term_lib in $cf_check_list termcap termlib unknown
1244217309Snwhitehorn        do
1245217309Snwhitehorn            AC_CHECK_LIB($cf_term_lib,tgoto,[break])
1246217309Snwhitehorn        done
1247217309Snwhitehorn    ])
1248217309Snwhitehorn
1249217309Snwhitehorn    # Check for library containing initscr
1250217309Snwhitehorn    test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
1251217309Snwhitehorn 	for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
1252217309Snwhitehorn    do
1253217309Snwhitehorn        AC_CHECK_LIB($cf_curs_lib,initscr,[break])
1254217309Snwhitehorn    done
1255217309Snwhitehorn    test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
1256217309Snwhitehorn
1257217309Snwhitehorn    LIBS="-l$cf_curs_lib $cf_save_LIBS"
1258217309Snwhitehorn    if test "$cf_term_lib" = unknown ; then
1259217309Snwhitehorn        AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
1260217309Snwhitehorn        AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1261217309Snwhitehorn            [initscr()],
1262217309Snwhitehorn            [cf_result=yes],
1263217309Snwhitehorn            [cf_result=no])
1264217309Snwhitehorn        AC_MSG_RESULT($cf_result)
1265217309Snwhitehorn        test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
1266217309Snwhitehorn    elif test "$cf_curs_lib" = "$cf_term_lib" ; then
1267217309Snwhitehorn        :
1268217309Snwhitehorn    elif test "$cf_term_lib" != predefined ; then
1269217309Snwhitehorn        AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
1270217309Snwhitehorn        AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1271217309Snwhitehorn            [initscr(); tgoto((char *)0, 0, 0);],
1272217309Snwhitehorn            [cf_result=no],
1273217309Snwhitehorn            [
1274217309Snwhitehorn            LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
1275217309Snwhitehorn            AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1276217309Snwhitehorn                [initscr()],
1277217309Snwhitehorn                [cf_result=yes],
1278217309Snwhitehorn                [cf_result=error])
1279217309Snwhitehorn            ])
1280217309Snwhitehorn        AC_MSG_RESULT($cf_result)
1281217309Snwhitehorn    fi
1282217309Snwhitehornfi
1283217309Snwhitehornfi
1284217309Snwhitehorn
1285217309Snwhitehorn])dnl
1286217309Snwhitehorndnl ---------------------------------------------------------------------------
1287217309Snwhitehorndnl CF_CURSES_TERM_H version: 7 updated: 2010/01/24 18:40:06
1288217309Snwhitehorndnl ----------------
1289217309Snwhitehorndnl SVr4 curses should have term.h as well (where it puts the definitions of
1290217309Snwhitehorndnl the low-level interface).  This may not be true in old/broken implementations,
1291217309Snwhitehorndnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
1292217309Snwhitehorndnl running with Solaris 2.5.1).
1293217309SnwhitehornAC_DEFUN([CF_CURSES_TERM_H],
1294217309Snwhitehorn[
1295217309SnwhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1296217309Snwhitehorn
1297217309SnwhitehornAC_CACHE_CHECK(for term.h, cf_cv_term_header,[
1298217309Snwhitehorn
1299217309Snwhitehorn# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
1300217309Snwhitehorn# for <term.h> if we do not find the variant.
1301217309Snwhitehornfor cf_header in \
1302217309Snwhitehorn	`echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \
1303217309Snwhitehorn	term.h
1304217309Snwhitehorndo
1305217309Snwhitehorn	AC_TRY_COMPILE([
1306217309Snwhitehorn#include <${cf_cv_ncurses_header-curses.h}>
1307217309Snwhitehorn#include <${cf_header}>],
1308217309Snwhitehorn	[WINDOW *x],
1309217309Snwhitehorn	[cf_cv_term_header=$cf_header
1310217309Snwhitehorn	 break],
1311217309Snwhitehorn	[cf_cv_term_header=no])
1312217309Snwhitehorndone
1313217309Snwhitehorn
1314217309Snwhitehorncase $cf_cv_term_header in #(vi
1315217309Snwhitehornno)
1316217309Snwhitehorn	# If curses is ncurses, some packagers still mess it up by trying to make
1317217309Snwhitehorn	# us use GNU termcap.  This handles the most common case.
1318217309Snwhitehorn	for cf_header in ncurses/term.h ncursesw/term.h
1319217309Snwhitehorn	do
1320217309Snwhitehorn		AC_TRY_COMPILE([
1321217309Snwhitehorn#include <${cf_cv_ncurses_header-curses.h}>
1322217309Snwhitehorn#ifdef NCURSES_VERSION
1323217309Snwhitehorn#include <${cf_header}>
1324217309Snwhitehorn#else
1325217309Snwhitehornmake an error
1326217309Snwhitehorn#endif],
1327217309Snwhitehorn			[WINDOW *x],
1328217309Snwhitehorn			[cf_cv_term_header=$cf_header
1329217309Snwhitehorn			 break],
1330217309Snwhitehorn			[cf_cv_term_header=no])
1331217309Snwhitehorn	done
1332217309Snwhitehorn	;;
1333217309Snwhitehornesac
1334217309Snwhitehorn])
1335217309Snwhitehorn
1336217309Snwhitehorncase $cf_cv_term_header in #(vi
1337217309Snwhitehornterm.h) #(vi
1338217309Snwhitehorn	AC_DEFINE(HAVE_TERM_H)
1339217309Snwhitehorn	;;
1340217309Snwhitehornncurses/term.h) #(vi
1341217309Snwhitehorn	AC_DEFINE(HAVE_NCURSES_TERM_H)
1342217309Snwhitehorn	;;
1343217309Snwhitehornncursesw/term.h)
1344217309Snwhitehorn	AC_DEFINE(HAVE_NCURSESW_TERM_H)
1345217309Snwhitehorn	;;
1346217309Snwhitehornesac
1347217309Snwhitehorn])dnl
1348217309Snwhitehorndnl ---------------------------------------------------------------------------
1349217309Snwhitehorndnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
1350217309Snwhitehorndnl ----------
1351217309Snwhitehorndnl "dirname" is not portable, so we fake it with a shell script.
1352217309SnwhitehornAC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
1353217309Snwhitehorndnl ---------------------------------------------------------------------------
1354217309Snwhitehorndnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
1355217309Snwhitehorndnl ---------------
1356217309Snwhitehorndnl You can always use "make -n" to see the actual options, but it's hard to
1357217309Snwhitehorndnl pick out/analyze warning messages when the compile-line is long.
1358217309Snwhitehorndnl
1359217309Snwhitehorndnl Sets:
1360217309Snwhitehorndnl	ECHO_LT - symbol to control if libtool is verbose
1361217309Snwhitehorndnl	ECHO_LD - symbol to prefix "cc -o" lines
1362217309Snwhitehorndnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1363217309Snwhitehorndnl	SHOW_CC - symbol to put before explicit "cc -c" lines
1364217309Snwhitehorndnl	ECHO_CC - symbol to put before any "cc" line
1365217309Snwhitehorndnl
1366217309SnwhitehornAC_DEFUN([CF_DISABLE_ECHO],[
1367217309SnwhitehornAC_MSG_CHECKING(if you want to see long compiling messages)
1368217309SnwhitehornCF_ARG_DISABLE(echo,
1369217309Snwhitehorn	[  --disable-echo          display "compiling" commands],
1370217309Snwhitehorn	[
1371217309Snwhitehorn    ECHO_LT='--silent'
1372217309Snwhitehorn    ECHO_LD='@echo linking [$]@;'
1373217309Snwhitehorn    RULE_CC='@echo compiling [$]<'
1374217309Snwhitehorn    SHOW_CC='@echo compiling [$]@'
1375217309Snwhitehorn    ECHO_CC='@'
1376217309Snwhitehorn],[
1377217309Snwhitehorn    ECHO_LT=''
1378217309Snwhitehorn    ECHO_LD=''
1379217309Snwhitehorn    RULE_CC=''
1380217309Snwhitehorn    SHOW_CC=''
1381217309Snwhitehorn    ECHO_CC=''
1382217309Snwhitehorn])
1383217309SnwhitehornAC_MSG_RESULT($enableval)
1384217309SnwhitehornAC_SUBST(ECHO_LT)
1385217309SnwhitehornAC_SUBST(ECHO_LD)
1386217309SnwhitehornAC_SUBST(RULE_CC)
1387217309SnwhitehornAC_SUBST(SHOW_CC)
1388217309SnwhitehornAC_SUBST(ECHO_CC)
1389217309Snwhitehorn])dnl
1390217309Snwhitehorndnl ---------------------------------------------------------------------------
1391217309Snwhitehorndnl CF_DISABLE_RPATH_HACK version: 1 updated: 2010/04/11 10:54:00
1392217309Snwhitehorndnl ---------------------
1393217309Snwhitehorndnl The rpath-hack makes it simpler to build programs, particularly with the
1394217309Snwhitehorndnl *BSD ports which may have essential libraries in unusual places.  But it
1395217309Snwhitehorndnl can interfere with building an executable for the base system.  Use this
1396217309Snwhitehorndnl option in that case.
1397217309SnwhitehornAC_DEFUN([CF_DISABLE_RPATH_HACK],
1398217309Snwhitehorn[
1399217309SnwhitehornAC_MSG_CHECKING(if rpath should be not be set)
1400217309SnwhitehornCF_ARG_DISABLE(rpath-hack,
1401217309Snwhitehorn	[  --disable-rpath-hack    don't add rpath options for additional libraries],
1402217309Snwhitehorn	[cf_disable_rpath_hack=yes],
1403217309Snwhitehorn	[cf_disable_rpath_hack=no])
1404217309SnwhitehornAC_MSG_RESULT($cf_disable_rpath_hack)
1405217309Snwhitehornif test "$cf_disable_rpath_hack" = no ; then
1406217309Snwhitehorn	CF_RPATH_HACK
1407217309Snwhitehornfi
1408217309Snwhitehorn])
1409217309Snwhitehorndnl ---------------------------------------------------------------------------
1410217309Snwhitehorndnl CF_FIND_HEADER version: 2 updated: 2007/07/29 11:32:00
1411217309Snwhitehorndnl --------------
1412217309Snwhitehorndnl Find a header file, searching for it if it is not already in the include
1413217309Snwhitehorndnl path.
1414217309Snwhitehorndnl
1415217309Snwhitehorndnl	$1 = the header filename
1416217309Snwhitehorndnl	$2 = the package name
1417217309Snwhitehorndnl	$3 = action to perform if successful
1418217309Snwhitehorndnl	$4 = action to perform if not successful
1419217309SnwhitehornAC_DEFUN([CF_FIND_HEADER],[
1420217309SnwhitehornAC_CHECK_HEADER([$1],
1421217309Snwhitehorn	cf_find_header=yes,[
1422217309Snwhitehorn	cf_find_header=no
1423217309SnwhitehornCF_HEADER_PATH(cf_search,$2)
1424217309Snwhitehornfor cf_incdir in $cf_search
1425217309Snwhitehorndo
1426217309Snwhitehorn	if test -f $cf_incdir/$1 ; then
1427217309Snwhitehorn		CF_ADD_INCDIR($cf_incdir)
1428217309Snwhitehorn		CF_VERBOSE(... found in $cf_incdir)
1429217309Snwhitehorn		cf_find_header=yes
1430217309Snwhitehorn		break
1431217309Snwhitehorn	fi
1432217309Snwhitehorn	CF_VERBOSE(... tested $cf_incdir)
1433217309Snwhitehorndone
1434217309Snwhitehorn])
1435217309Snwhitehornif test "$cf_find_header" = yes ; then
1436217309Snwhitehornifelse([$3],,:,[$3])
1437217309Snwhitehornifelse([$4],,,[else
1438217309Snwhitehorn$4])
1439217309Snwhitehornfi
1440217309Snwhitehorn])dnl
1441217309Snwhitehorndnl ---------------------------------------------------------------------------
1442217309Snwhitehorndnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
1443217309Snwhitehorndnl ---------------
1444217309Snwhitehorndnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
1445217309Snwhitehorndnl prefer a standard location, and use -L options only if we do not find the
1446217309Snwhitehorndnl library in the standard library location(s).
1447217309Snwhitehorndnl	$1 = library name
1448217309Snwhitehorndnl	$2 = library class, usually the same as library name
1449217309Snwhitehorndnl	$3 = includes
1450217309Snwhitehorndnl	$4 = code fragment to compile/link
1451217309Snwhitehorndnl	$5 = corresponding function-name
1452217309Snwhitehorndnl	$6 = flag, nonnull if failure should not cause an error-exit
1453217309Snwhitehorndnl
1454217309Snwhitehorndnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
1455217309Snwhitehorndnl to use a -L option.
1456217309SnwhitehornAC_DEFUN([CF_FIND_LIBRARY],
1457217309Snwhitehorn[
1458217309Snwhitehorn	eval 'cf_cv_have_lib_'$1'=no'
1459217309Snwhitehorn	cf_libdir=""
1460217309Snwhitehorn	AC_CHECK_FUNC($5,
1461217309Snwhitehorn		eval 'cf_cv_have_lib_'$1'=yes',[
1462217309Snwhitehorn		cf_save_LIBS="$LIBS"
1463217309Snwhitehorn		AC_MSG_CHECKING(for $5 in -l$1)
1464217309Snwhitehorn		LIBS="-l$1 $LIBS"
1465217309Snwhitehorn		AC_TRY_LINK([$3],[$4],
1466217309Snwhitehorn			[AC_MSG_RESULT(yes)
1467217309Snwhitehorn			 eval 'cf_cv_have_lib_'$1'=yes'
1468217309Snwhitehorn			],
1469217309Snwhitehorn			[AC_MSG_RESULT(no)
1470217309Snwhitehorn			CF_LIBRARY_PATH(cf_search,$2)
1471217309Snwhitehorn			for cf_libdir in $cf_search
1472217309Snwhitehorn			do
1473217309Snwhitehorn				AC_MSG_CHECKING(for -l$1 in $cf_libdir)
1474217309Snwhitehorn				LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
1475217309Snwhitehorn				AC_TRY_LINK([$3],[$4],
1476217309Snwhitehorn					[AC_MSG_RESULT(yes)
1477217309Snwhitehorn			 		 eval 'cf_cv_have_lib_'$1'=yes'
1478217309Snwhitehorn					 break],
1479217309Snwhitehorn					[AC_MSG_RESULT(no)
1480217309Snwhitehorn					 LIBS="$cf_save_LIBS"])
1481217309Snwhitehorn			done
1482217309Snwhitehorn			])
1483217309Snwhitehorn		])
1484217309Snwhitehorneval 'cf_found_library=[$]cf_cv_have_lib_'$1
1485217309Snwhitehornifelse($6,,[
1486217309Snwhitehornif test $cf_found_library = no ; then
1487217309Snwhitehorn	AC_MSG_ERROR(Cannot link $1 library)
1488217309Snwhitehornfi
1489217309Snwhitehorn])
1490217309Snwhitehorn])dnl
1491217309Snwhitehorndnl ---------------------------------------------------------------------------
1492217309Snwhitehorndnl CF_FIND_LINKAGE version: 16 updated: 2010/04/21 06:20:50
1493217309Snwhitehorndnl ---------------
1494217309Snwhitehorndnl Find a library (specifically the linkage used in the code fragment),
1495217309Snwhitehorndnl searching for it if it is not already in the library path.
1496217309Snwhitehorndnl See also CF_ADD_SEARCHPATH.
1497217309Snwhitehorndnl
1498217309Snwhitehorndnl Parameters (4-on are optional):
1499217309Snwhitehorndnl     $1 = headers for library entrypoint
1500217309Snwhitehorndnl     $2 = code fragment for library entrypoint
1501217309Snwhitehorndnl     $3 = the library name without the "-l" option or ".so" suffix.
1502217309Snwhitehorndnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1503217309Snwhitehorndnl     $5 = action to perform if not successful
1504217309Snwhitehorndnl     $6 = module name, if not the same as the library name
1505217309Snwhitehorndnl     $7 = extra libraries
1506217309Snwhitehorndnl
1507217309Snwhitehorndnl Sets these variables:
1508217309Snwhitehorndnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1509217309Snwhitehorndnl     $cf_cv_header_path_$3 - include-directory if needed
1510217309Snwhitehorndnl     $cf_cv_library_path_$3 - library-directory if needed
1511217309Snwhitehorndnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1512217309SnwhitehornAC_DEFUN([CF_FIND_LINKAGE],[
1513217309Snwhitehorn
1514217309Snwhitehorn# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1515217309Snwhitehorn# will be set on completion of the AC_TRY_LINK below.
1516217309Snwhitehorncf_cv_header_path_$3=
1517217309Snwhitehorncf_cv_library_path_$3=
1518217309Snwhitehorn
1519217309SnwhitehornCF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1520217309Snwhitehorn
1521217309SnwhitehornAC_TRY_LINK([$1],[$2],[
1522217309Snwhitehorn	cf_cv_find_linkage_$3=yes
1523217309Snwhitehorn],[
1524217309Snwhitehorn
1525217309Snwhitehorncf_save_LIBS="$LIBS"
1526217309SnwhitehornLIBS="-l$3 $7 $cf_save_LIBS"
1527217309Snwhitehorn
1528217309SnwhitehornAC_TRY_LINK([$1],[$2],[
1529217309Snwhitehorn	cf_cv_find_linkage_$3=yes
1530217309Snwhitehorn	cf_cv_library_file_$3="-l$3"
1531217309Snwhitehorn],[
1532217309Snwhitehorn    cf_cv_find_linkage_$3=no
1533217309Snwhitehorn	LIBS="$cf_save_LIBS"
1534217309Snwhitehorn
1535217309Snwhitehorn    CF_VERBOSE(find linkage for $3 library)
1536217309Snwhitehorn    CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1537217309Snwhitehorn
1538217309Snwhitehorn    cf_save_CPPFLAGS="$CPPFLAGS"
1539217309Snwhitehorn    cf_test_CPPFLAGS="$CPPFLAGS"
1540217309Snwhitehorn
1541217309Snwhitehorn    CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1542217309Snwhitehorn    for cf_cv_header_path_$3 in $cf_search
1543217309Snwhitehorn    do
1544217309Snwhitehorn      if test -d $cf_cv_header_path_$3 ; then
1545217309Snwhitehorn        CF_VERBOSE(... testing $cf_cv_header_path_$3)
1546217309Snwhitehorn        CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1547217309Snwhitehorn        AC_TRY_COMPILE([$1],[$2],[
1548217309Snwhitehorn            CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1549217309Snwhitehorn            cf_cv_find_linkage_$3=maybe
1550217309Snwhitehorn            cf_test_CPPFLAGS="$CPPFLAGS"
1551217309Snwhitehorn            break],[
1552217309Snwhitehorn            CPPFLAGS="$cf_save_CPPFLAGS"
1553217309Snwhitehorn            ])
1554217309Snwhitehorn      fi
1555217309Snwhitehorn    done
1556217309Snwhitehorn
1557217309Snwhitehorn    if test "$cf_cv_find_linkage_$3" = maybe ; then
1558217309Snwhitehorn
1559217309Snwhitehorn      CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1560217309Snwhitehorn
1561217309Snwhitehorn      cf_save_LIBS="$LIBS"
1562217309Snwhitehorn      cf_save_LDFLAGS="$LDFLAGS"
1563217309Snwhitehorn
1564217309Snwhitehorn      ifelse([$6],,,[
1565217309Snwhitehorn        CPPFLAGS="$cf_test_CPPFLAGS"
1566217309Snwhitehorn        LIBS="-l$3 $7 $cf_save_LIBS"
1567217309Snwhitehorn        AC_TRY_LINK([$1],[$2],[
1568217309Snwhitehorn            CF_VERBOSE(... found $3 library in system)
1569217309Snwhitehorn            cf_cv_find_linkage_$3=yes])
1570217309Snwhitehorn            CPPFLAGS="$cf_save_CPPFLAGS"
1571217309Snwhitehorn            LIBS="$cf_save_LIBS"
1572217309Snwhitehorn            ])
1573217309Snwhitehorn
1574217309Snwhitehorn      if test "$cf_cv_find_linkage_$3" != yes ; then
1575217309Snwhitehorn        CF_LIBRARY_PATH(cf_search,$3)
1576217309Snwhitehorn        for cf_cv_library_path_$3 in $cf_search
1577217309Snwhitehorn        do
1578217309Snwhitehorn          if test -d $cf_cv_library_path_$3 ; then
1579217309Snwhitehorn            CF_VERBOSE(... testing $cf_cv_library_path_$3)
1580217309Snwhitehorn            CPPFLAGS="$cf_test_CPPFLAGS"
1581217309Snwhitehorn            LIBS="-l$3 $7 $cf_save_LIBS"
1582217309Snwhitehorn            LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1583217309Snwhitehorn            AC_TRY_LINK([$1],[$2],[
1584217309Snwhitehorn                CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1585217309Snwhitehorn                cf_cv_find_linkage_$3=yes
1586217309Snwhitehorn                cf_cv_library_file_$3="-l$3"
1587217309Snwhitehorn                break],[
1588217309Snwhitehorn                CPPFLAGS="$cf_save_CPPFLAGS"
1589217309Snwhitehorn                LIBS="$cf_save_LIBS"
1590217309Snwhitehorn                LDFLAGS="$cf_save_LDFLAGS"
1591217309Snwhitehorn                ])
1592217309Snwhitehorn          fi
1593217309Snwhitehorn        done
1594217309Snwhitehorn        LIBS="$cf_save_LIBS"
1595217309Snwhitehorn        CPPFLAGS="$cf_save_CPPFLAGS"
1596217309Snwhitehorn        LDFLAGS="$cf_save_LDFLAGS"
1597217309Snwhitehorn      fi
1598217309Snwhitehorn
1599217309Snwhitehorn    else
1600217309Snwhitehorn      cf_cv_find_linkage_$3=no
1601217309Snwhitehorn    fi
1602217309Snwhitehorn    ],$7)
1603217309Snwhitehorn])
1604217309Snwhitehorn
1605217309Snwhitehornif test "$cf_cv_find_linkage_$3" = yes ; then
1606217309Snwhitehornifelse([$4],,[
1607217309Snwhitehorn	CF_ADD_INCDIR($cf_cv_header_path_$3)
1608217309Snwhitehorn	CF_ADD_LIBDIR($cf_cv_library_path_$3)
1609217309Snwhitehorn	LIBS="-l$3 $LIBS"
1610217309Snwhitehorn],[$4])
1611217309Snwhitehornelse
1612217309Snwhitehornifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1613217309Snwhitehornfi
1614217309Snwhitehorn])dnl
1615217309Snwhitehorndnl ---------------------------------------------------------------------------
1616217309Snwhitehorndnl CF_FUNC_WAIT version: 2 updated: 1997/10/21 19:45:33
1617217309Snwhitehorndnl ------------
1618217309Snwhitehorndnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'
1619217309Snwhitehorndnl and/or 'waitpid()'.
1620217309Snwhitehorndnl
1621217309Snwhitehorndnl Note that we cannot simply grep for 'union wait' in the wait.h file,
1622217309Snwhitehorndnl because some Posix systems turn this on only when a BSD variable is
1623217309Snwhitehorndnl defined.
1624217309Snwhitehorndnl
1625217309Snwhitehorndnl I don't use AC_HEADER_SYS_WAIT, because it defines HAVE_SYS_WAIT_H, which
1626217309Snwhitehorndnl would conflict with an attempt to test that header directly.
1627217309Snwhitehorndnl
1628217309SnwhitehornAC_DEFUN([CF_FUNC_WAIT],
1629217309Snwhitehorn[
1630217309SnwhitehornAC_REQUIRE([CF_UNION_WAIT])
1631217309Snwhitehornif test $cf_cv_type_unionwait = yes; then
1632217309Snwhitehorn
1633217309Snwhitehorn	AC_MSG_CHECKING(if union wait can be used as wait-arg)
1634217309Snwhitehorn	AC_CACHE_VAL(cf_cv_arg_union_wait,[
1635217309Snwhitehorn		AC_TRY_COMPILE($cf_wait_headers,
1636217309Snwhitehorn 			[union wait x; wait(&x)],
1637217309Snwhitehorn			[cf_cv_arg_union_wait=yes],
1638217309Snwhitehorn			[cf_cv_arg_union_wait=no])
1639217309Snwhitehorn		])
1640217309Snwhitehorn	AC_MSG_RESULT($cf_cv_arg_union_wait)
1641217309Snwhitehorn	test $cf_cv_arg_union_wait = yes && AC_DEFINE(WAIT_USES_UNION)
1642217309Snwhitehorn
1643217309Snwhitehorn	AC_MSG_CHECKING(if union wait can be used as waitpid-arg)
1644217309Snwhitehorn	AC_CACHE_VAL(cf_cv_arg_union_waitpid,[
1645217309Snwhitehorn		AC_TRY_COMPILE($cf_wait_headers,
1646217309Snwhitehorn 			[union wait x; waitpid(0, &x, 0)],
1647217309Snwhitehorn			[cf_cv_arg_union_waitpid=yes],
1648217309Snwhitehorn			[cf_cv_arg_union_waitpid=no])
1649217309Snwhitehorn		])
1650217309Snwhitehorn	AC_MSG_RESULT($cf_cv_arg_union_waitpid)
1651217309Snwhitehorn	test $cf_cv_arg_union_waitpid = yes && AC_DEFINE(WAITPID_USES_UNION)
1652217309Snwhitehorn
1653217309Snwhitehornfi
1654217309Snwhitehorn])dnl
1655217309Snwhitehorndnl ---------------------------------------------------------------------------
1656217309Snwhitehorndnl CF_GCC_ATTRIBUTES version: 13 updated: 2009/08/11 20:19:56
1657217309Snwhitehorndnl -----------------
1658217309Snwhitehorndnl Test for availability of useful gcc __attribute__ directives to quiet
1659217309Snwhitehorndnl compiler warnings.  Though useful, not all are supported -- and contrary
1660217309Snwhitehorndnl to documentation, unrecognized directives cause older compilers to barf.
1661217309SnwhitehornAC_DEFUN([CF_GCC_ATTRIBUTES],
1662217309Snwhitehorn[
1663217309Snwhitehornif test "$GCC" = yes
1664217309Snwhitehornthen
1665217309Snwhitehorncat > conftest.i <<EOF
1666217309Snwhitehorn#ifndef GCC_PRINTF
1667217309Snwhitehorn#define GCC_PRINTF 0
1668217309Snwhitehorn#endif
1669217309Snwhitehorn#ifndef GCC_SCANF
1670217309Snwhitehorn#define GCC_SCANF 0
1671217309Snwhitehorn#endif
1672217309Snwhitehorn#ifndef GCC_NORETURN
1673217309Snwhitehorn#define GCC_NORETURN /* nothing */
1674217309Snwhitehorn#endif
1675217309Snwhitehorn#ifndef GCC_UNUSED
1676217309Snwhitehorn#define GCC_UNUSED /* nothing */
1677217309Snwhitehorn#endif
1678217309SnwhitehornEOF
1679217309Snwhitehornif test "$GCC" = yes
1680217309Snwhitehornthen
1681217309Snwhitehorn	AC_CHECKING([for $CC __attribute__ directives])
1682217309Snwhitehorncat > conftest.$ac_ext <<EOF
1683217309Snwhitehorn#line __oline__ "${as_me-configure}"
1684217309Snwhitehorn#include "confdefs.h"
1685217309Snwhitehorn#include "conftest.h"
1686217309Snwhitehorn#include "conftest.i"
1687217309Snwhitehorn#if	GCC_PRINTF
1688217309Snwhitehorn#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1689217309Snwhitehorn#else
1690217309Snwhitehorn#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1691217309Snwhitehorn#endif
1692217309Snwhitehorn#if	GCC_SCANF
1693217309Snwhitehorn#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1694217309Snwhitehorn#else
1695217309Snwhitehorn#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1696217309Snwhitehorn#endif
1697217309Snwhitehornextern void wow(char *,...) GCC_SCANFLIKE(1,2);
1698217309Snwhitehornextern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1699217309Snwhitehornextern void foo(void) GCC_NORETURN;
1700217309Snwhitehornint main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1701217309SnwhitehornEOF
1702217309Snwhitehorn	cf_printf_attribute=no
1703217309Snwhitehorn	cf_scanf_attribute=no
1704217309Snwhitehorn	for cf_attribute in scanf printf unused noreturn
1705217309Snwhitehorn	do
1706217309Snwhitehorn		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1707217309Snwhitehorn		cf_directive="__attribute__(($cf_attribute))"
1708217309Snwhitehorn		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1709217309Snwhitehorn
1710217309Snwhitehorn		case $cf_attribute in #(vi
1711217309Snwhitehorn		printf) #(vi
1712217309Snwhitehorn			cf_printf_attribute=yes
1713217309Snwhitehorn			cat >conftest.h <<EOF
1714217309Snwhitehorn#define GCC_$cf_ATTRIBUTE 1
1715217309SnwhitehornEOF
1716217309Snwhitehorn			;;
1717217309Snwhitehorn		scanf) #(vi
1718217309Snwhitehorn			cf_scanf_attribute=yes
1719217309Snwhitehorn			cat >conftest.h <<EOF
1720217309Snwhitehorn#define GCC_$cf_ATTRIBUTE 1
1721217309SnwhitehornEOF
1722217309Snwhitehorn			;;
1723217309Snwhitehorn		*) #(vi
1724217309Snwhitehorn			cat >conftest.h <<EOF
1725217309Snwhitehorn#define GCC_$cf_ATTRIBUTE $cf_directive
1726217309SnwhitehornEOF
1727217309Snwhitehorn			;;
1728217309Snwhitehorn		esac
1729217309Snwhitehorn
1730217309Snwhitehorn		if AC_TRY_EVAL(ac_compile); then
1731217309Snwhitehorn			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1732217309Snwhitehorn			cat conftest.h >>confdefs.h
1733217309Snwhitehorn			case $cf_attribute in #(vi
1734217309Snwhitehorn			printf) #(vi
1735217309Snwhitehorn				if test "$cf_printf_attribute" = no ; then
1736217309Snwhitehorn					cat >>confdefs.h <<EOF
1737217309Snwhitehorn#define GCC_PRINTFLIKE(fmt,var) /* nothing */
1738217309SnwhitehornEOF
1739217309Snwhitehorn				else
1740217309Snwhitehorn					cat >>confdefs.h <<EOF
1741217309Snwhitehorn#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1742217309SnwhitehornEOF
1743217309Snwhitehorn				fi
1744217309Snwhitehorn				;;
1745217309Snwhitehorn			scanf) #(vi
1746217309Snwhitehorn				if test "$cf_scanf_attribute" = no ; then
1747217309Snwhitehorn					cat >>confdefs.h <<EOF
1748217309Snwhitehorn#define GCC_SCANFLIKE(fmt,var) /* nothing */
1749217309SnwhitehornEOF
1750217309Snwhitehorn				else
1751217309Snwhitehorn					cat >>confdefs.h <<EOF
1752217309Snwhitehorn#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1753217309SnwhitehornEOF
1754217309Snwhitehorn				fi
1755217309Snwhitehorn				;;
1756217309Snwhitehorn			esac
1757217309Snwhitehorn		fi
1758217309Snwhitehorn	done
1759217309Snwhitehornelse
1760217309Snwhitehorn	fgrep define conftest.i >>confdefs.h
1761217309Snwhitehornfi
1762217309Snwhitehornrm -rf conftest*
1763217309Snwhitehornfi
1764217309Snwhitehorn])dnl
1765217309Snwhitehorndnl ---------------------------------------------------------------------------
1766217309Snwhitehorndnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
1767217309Snwhitehorndnl --------------
1768217309Snwhitehorndnl Find version of gcc
1769217309SnwhitehornAC_DEFUN([CF_GCC_VERSION],[
1770217309SnwhitehornAC_REQUIRE([AC_PROG_CC])
1771217309SnwhitehornGCC_VERSION=none
1772217309Snwhitehornif test "$GCC" = yes ; then
1773217309Snwhitehorn	AC_MSG_CHECKING(version of $CC)
1774217309Snwhitehorn	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1775217309Snwhitehorn	test -z "$GCC_VERSION" && GCC_VERSION=unknown
1776217309Snwhitehorn	AC_MSG_RESULT($GCC_VERSION)
1777217309Snwhitehornfi
1778217309Snwhitehorn])dnl
1779217309Snwhitehorndnl ---------------------------------------------------------------------------
1780217309Snwhitehorndnl CF_GCC_WARNINGS version: 25 updated: 2010/04/24 11:03:31
1781217309Snwhitehorndnl ---------------
1782217309Snwhitehorndnl Check if the compiler supports useful warning options.  There's a few that
1783217309Snwhitehorndnl we don't use, simply because they're too noisy:
1784217309Snwhitehorndnl
1785217309Snwhitehorndnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1786217309Snwhitehorndnl	-Wredundant-decls (system headers make this too noisy)
1787217309Snwhitehorndnl	-Wtraditional (combines too many unrelated messages, only a few useful)
1788217309Snwhitehorndnl	-Wwrite-strings (too noisy, but should review occasionally).  This
1789217309Snwhitehorndnl		is enabled for ncurses using "--enable-const".
1790217309Snwhitehorndnl	-pedantic
1791217309Snwhitehorndnl
1792217309Snwhitehorndnl Parameter:
1793217309Snwhitehorndnl	$1 is an optional list of gcc warning flags that a particular
1794217309Snwhitehorndnl		application might want to use, e.g., "no-unused" for
1795217309Snwhitehorndnl		-Wno-unused
1796217309Snwhitehorndnl Special:
1797217309Snwhitehorndnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
1798217309Snwhitehorndnl
1799217309SnwhitehornAC_DEFUN([CF_GCC_WARNINGS],
1800217309Snwhitehorn[
1801217309SnwhitehornAC_REQUIRE([CF_GCC_VERSION])
1802217309SnwhitehornCF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1803217309Snwhitehorn
1804217309Snwhitehorncat > conftest.$ac_ext <<EOF
1805217309Snwhitehorn#line __oline__ "${as_me-configure}"
1806217309Snwhitehornint main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1807217309SnwhitehornEOF
1808217309Snwhitehorn
1809217309Snwhitehornif test "$INTEL_COMPILER" = yes
1810217309Snwhitehornthen
1811217309Snwhitehorn# The "-wdXXX" options suppress warnings:
1812217309Snwhitehorn# remark #1419: external declaration in primary source file
1813217309Snwhitehorn# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1814217309Snwhitehorn# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1815217309Snwhitehorn# remark #193: zero used for undefined preprocessing identifier
1816217309Snwhitehorn# remark #593: variable "curs_sb_left_arrow" was set but never used
1817217309Snwhitehorn# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1818217309Snwhitehorn# remark #869: parameter "tw" was never referenced
1819217309Snwhitehorn# remark #981: operands are evaluated in unspecified order
1820217309Snwhitehorn# warning #279: controlling expression is constant
1821217309Snwhitehorn
1822217309Snwhitehorn	AC_CHECKING([for $CC warning options])
1823217309Snwhitehorn	cf_save_CFLAGS="$CFLAGS"
1824217309Snwhitehorn	EXTRA_CFLAGS="-Wall"
1825217309Snwhitehorn	for cf_opt in \
1826217309Snwhitehorn		wd1419 \
1827217309Snwhitehorn		wd1683 \
1828217309Snwhitehorn		wd1684 \
1829217309Snwhitehorn		wd193 \
1830217309Snwhitehorn		wd593 \
1831217309Snwhitehorn		wd279 \
1832217309Snwhitehorn		wd810 \
1833217309Snwhitehorn		wd869 \
1834217309Snwhitehorn		wd981
1835217309Snwhitehorn	do
1836217309Snwhitehorn		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1837217309Snwhitehorn		if AC_TRY_EVAL(ac_compile); then
1838217309Snwhitehorn			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1839217309Snwhitehorn			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1840217309Snwhitehorn		fi
1841217309Snwhitehorn	done
1842217309Snwhitehorn	CFLAGS="$cf_save_CFLAGS"
1843217309Snwhitehorn
1844217309Snwhitehornelif test "$GCC" = yes
1845217309Snwhitehornthen
1846217309Snwhitehorn	AC_CHECKING([for $CC warning options])
1847217309Snwhitehorn	cf_save_CFLAGS="$CFLAGS"
1848217309Snwhitehorn	EXTRA_CFLAGS=
1849217309Snwhitehorn	cf_warn_CONST=""
1850217309Snwhitehorn	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1851217309Snwhitehorn	for cf_opt in W Wall \
1852217309Snwhitehorn		Wbad-function-cast \
1853217309Snwhitehorn		Wcast-align \
1854217309Snwhitehorn		Wcast-qual \
1855217309Snwhitehorn		Winline \
1856217309Snwhitehorn		Wmissing-declarations \
1857217309Snwhitehorn		Wmissing-prototypes \
1858217309Snwhitehorn		Wnested-externs \
1859217309Snwhitehorn		Wpointer-arith \
1860217309Snwhitehorn		Wshadow \
1861217309Snwhitehorn		Wstrict-prototypes \
1862217309Snwhitehorn		Wundef $cf_warn_CONST $1
1863217309Snwhitehorn	do
1864217309Snwhitehorn		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1865217309Snwhitehorn		if AC_TRY_EVAL(ac_compile); then
1866217309Snwhitehorn			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1867217309Snwhitehorn			case $cf_opt in #(vi
1868217309Snwhitehorn			Wcast-qual) #(vi
1869217309Snwhitehorn				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1870217309Snwhitehorn				;;
1871217309Snwhitehorn			Winline) #(vi
1872217309Snwhitehorn				case $GCC_VERSION in
1873217309Snwhitehorn				[[34]].*)
1874217309Snwhitehorn					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1875217309Snwhitehorn					continue;;
1876217309Snwhitehorn				esac
1877217309Snwhitehorn				;;
1878217309Snwhitehorn			esac
1879217309Snwhitehorn			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1880217309Snwhitehorn		fi
1881217309Snwhitehorn	done
1882217309Snwhitehorn	CFLAGS="$cf_save_CFLAGS"
1883217309Snwhitehornfi
1884217309Snwhitehornrm -f conftest*
1885217309Snwhitehorn
1886217309SnwhitehornAC_SUBST(EXTRA_CFLAGS)
1887217309Snwhitehorn])dnl
1888217309Snwhitehorndnl ---------------------------------------------------------------------------
1889217309Snwhitehorndnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1890217309Snwhitehorndnl -------------
1891217309Snwhitehorndnl Check if we must define _GNU_SOURCE to get a reasonable value for
1892217309Snwhitehorndnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1893217309Snwhitehorndnl (or misfeature) of glibc2, which breaks portability of many applications,
1894217309Snwhitehorndnl since it is interwoven with GNU extensions.
1895217309Snwhitehorndnl
1896217309Snwhitehorndnl Well, yes we could work around it...
1897217309SnwhitehornAC_DEFUN([CF_GNU_SOURCE],
1898217309Snwhitehorn[
1899217309SnwhitehornAC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1900217309SnwhitehornAC_TRY_COMPILE([#include <sys/types.h>],[
1901217309Snwhitehorn#ifndef _XOPEN_SOURCE
1902217309Snwhitehornmake an error
1903217309Snwhitehorn#endif],
1904217309Snwhitehorn	[cf_cv_gnu_source=no],
1905217309Snwhitehorn	[cf_save="$CPPFLAGS"
1906217309Snwhitehorn	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1907217309Snwhitehorn	 AC_TRY_COMPILE([#include <sys/types.h>],[
1908217309Snwhitehorn#ifdef _XOPEN_SOURCE
1909217309Snwhitehornmake an error
1910217309Snwhitehorn#endif],
1911217309Snwhitehorn	[cf_cv_gnu_source=no],
1912217309Snwhitehorn	[cf_cv_gnu_source=yes])
1913217309Snwhitehorn	CPPFLAGS="$cf_save"
1914217309Snwhitehorn	])
1915217309Snwhitehorn])
1916217309Snwhitehorntest "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1917217309Snwhitehorn])dnl
1918217309Snwhitehorndnl ---------------------------------------------------------------------------
1919217309Snwhitehorndnl CF_HEADERS_SH version: 1 updated: 2007/07/04 15:37:05
1920217309Snwhitehorndnl -------------
1921217309Snwhitehorndnl Setup variables needed to construct headers-sh
1922217309SnwhitehornAC_DEFUN([CF_HEADERS_SH],[
1923217309SnwhitehornPACKAGE_PREFIX=$1
1924217309SnwhitehornPACKAGE_CONFIG=$2
1925217309SnwhitehornAC_SUBST(PACKAGE_PREFIX)
1926217309SnwhitehornAC_SUBST(PACKAGE_CONFIG)
1927217309SnwhitehornEXTRA_OUTPUT="$EXTRA_OUTPUT headers-sh:$srcdir/headers-sh.in"
1928217309Snwhitehorn])
1929217309Snwhitehorndnl ---------------------------------------------------------------------------
1930217309Snwhitehorndnl CF_HEADER_PATH version: 11 updated: 2010/04/21 06:20:50
1931217309Snwhitehorndnl --------------
1932217309Snwhitehorndnl Construct a search-list of directories for a nonstandard header-file
1933217309Snwhitehorndnl
1934217309Snwhitehorndnl Parameters
1935217309Snwhitehorndnl	$1 = the variable to return as result
1936217309Snwhitehorndnl	$2 = the package name
1937217309SnwhitehornAC_DEFUN([CF_HEADER_PATH],
1938217309Snwhitehorn[
1939217309Snwhitehorn$1=
1940217309Snwhitehorn
1941217309Snwhitehorn# collect the current set of include-directories from compiler flags
1942217309Snwhitehorncf_header_path_list=""
1943217309Snwhitehornif test -n "${CFLAGS}${CPPFLAGS}" ; then
1944217309Snwhitehorn	for cf_header_path in $CPPFLAGS $CFLAGS
1945217309Snwhitehorn	do
1946217309Snwhitehorn		case $cf_header_path in #(vi
1947217309Snwhitehorn		-I*)
1948217309Snwhitehorn			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1949217309Snwhitehorn			cf_header_path_list="$cf_header_path_list $cf_header_path"
1950217309Snwhitehorn			;;
1951217309Snwhitehorn		esac
1952217309Snwhitehorn	done
1953217309Snwhitehornfi
1954217309Snwhitehorn
1955217309Snwhitehorn# add the variations for the package we are looking for
1956217309SnwhitehornCF_SUBDIR_PATH($1,$2,include)
1957217309Snwhitehorn
1958217309Snwhitehorntest "$includedir" != NONE && \
1959217309Snwhitehorntest "$includedir" != "/usr/include" && \
1960217309Snwhitehorntest -d "$includedir" && {
1961217309Snwhitehorn	test -d $includedir &&    $1="[$]$1 $includedir"
1962217309Snwhitehorn	test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1963217309Snwhitehorn}
1964217309Snwhitehorn
1965217309Snwhitehorntest "$oldincludedir" != NONE && \
1966217309Snwhitehorntest "$oldincludedir" != "/usr/include" && \
1967217309Snwhitehorntest -d "$oldincludedir" && {
1968217309Snwhitehorn	test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
1969217309Snwhitehorn	test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1970217309Snwhitehorn}
1971217309Snwhitehorn
1972217309Snwhitehorn$1="[$]$1 $cf_header_path_list"
1973217309Snwhitehorn])dnl
1974217309Snwhitehorndnl ---------------------------------------------------------------------------
1975217309Snwhitehorndnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1976217309Snwhitehorndnl ---------------
1977217309Snwhitehorndnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1978217309SnwhitehornAC_DEFUN([CF_HELP_MESSAGE],
1979217309Snwhitehorn[AC_DIVERT_HELP([$1])dnl
1980217309Snwhitehorn])dnl
1981217309Snwhitehorndnl ---------------------------------------------------------------------------
1982217309Snwhitehorndnl CF_INCLUDE_DIRS version: 6 updated: 2009/01/06 19:37:40
1983217309Snwhitehorndnl ---------------
1984217309Snwhitehorndnl Construct the list of include-options according to whether we're building
1985217309Snwhitehorndnl in the source directory or using '--srcdir=DIR' option.  If we're building
1986217309Snwhitehorndnl with gcc, don't append the includedir if it happens to be /usr/include,
1987217309Snwhitehorndnl since that usually breaks gcc's shadow-includes.
1988217309SnwhitehornAC_DEFUN([CF_INCLUDE_DIRS],
1989217309Snwhitehorn[
1990217309SnwhitehornCPPFLAGS="$CPPFLAGS -I. -I../include"
1991217309Snwhitehornif test "$srcdir" != "."; then
1992217309Snwhitehorn	CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
1993217309Snwhitehornfi
1994217309Snwhitehornif test "$GCC" != yes; then
1995217309Snwhitehorn	CPPFLAGS="$CPPFLAGS -I\${includedir}"
1996217309Snwhitehornelif test "$includedir" != "/usr/include"; then
1997217309Snwhitehorn	if test "$includedir" = '${prefix}/include' ; then
1998217309Snwhitehorn		if test $prefix != /usr ; then
1999217309Snwhitehorn			CPPFLAGS="$CPPFLAGS -I\${includedir}"
2000217309Snwhitehorn		fi
2001217309Snwhitehorn	else
2002217309Snwhitehorn		CPPFLAGS="$CPPFLAGS -I\${includedir}"
2003217309Snwhitehorn	fi
2004217309Snwhitehornfi
2005217309SnwhitehornAC_SUBST(CPPFLAGS)
2006217309Snwhitehorn])dnl
2007217309Snwhitehorndnl ---------------------------------------------------------------------------
2008217309Snwhitehorndnl CF_INCLUDE_PATH version: 5 updated: 2010/01/17 20:36:17
2009217309Snwhitehorndnl ---------------
2010217309Snwhitehorndnl	Adds to the include-path
2011217309Snwhitehorndnl
2012217309Snwhitehorndnl	Autoconf 1.11 should have provided a way to add include path options to
2013217309Snwhitehorndnl	the cpp-tests.
2014217309Snwhitehorndnl
2015217309SnwhitehornAC_DEFUN([CF_INCLUDE_PATH],
2016217309Snwhitehorn[
2017217309Snwhitehorn$1=
2018217309Snwhitehornfor cf_path in $1
2019217309Snwhitehorndo
2020217309Snwhitehorn	cf_result="no"
2021217309Snwhitehorn	AC_MSG_CHECKING(for directory $cf_path)
2022217309Snwhitehorn	if test -d $cf_path
2023217309Snwhitehorn	then
2024217309Snwhitehorn		INCLUDES="$INCLUDES -I$cf_path"
2025217309Snwhitehorn		ac_cpp="${ac_cpp} -I$cf_path"
2026217309Snwhitehorn		CFLAGS="$CFLAGS -I$cf_path"
2027217309Snwhitehorn		cf_result="yes"
2028217309Snwhitehorn		case $cf_path in
2029217309Snwhitehorn		/usr/include|/usr/include/*)
2030217309Snwhitehorn			;;
2031217309Snwhitehorn		*)
2032217309Snwhitehorn			CF_DIRNAME(cf_temp,$cf_path)
2033217309Snwhitehorn			case $cf_temp in
2034217309Snwhitehorn			*/include)
2035217309Snwhitehorn				INCLUDES="$INCLUDES -I$cf_temp"
2036217309Snwhitehorn				ac_cpp="${ac_cpp} -I$cf_temp"
2037217309Snwhitehorn				CFLAGS="$CFLAGS -I$cf_temp"
2038217309Snwhitehorn				;;
2039217309Snwhitehorn			esac
2040217309Snwhitehorn		esac
2041217309Snwhitehorn	fi
2042217309Snwhitehorn	AC_MSG_RESULT($cf_result)
2043217309Snwhitehorndone
2044217309Snwhitehorn])dnl
2045217309Snwhitehorndnl ---------------------------------------------------------------------------
2046217309Snwhitehorndnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
2047217309Snwhitehorndnl -----------------
2048217309Snwhitehorndnl Check if the given compiler is really the Intel compiler for Linux.  It
2049217309Snwhitehorndnl tries to imitate gcc, but does not return an error when it finds a mismatch
2050217309Snwhitehorndnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2051217309Snwhitehorndnl
2052217309Snwhitehorndnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2053217309Snwhitehorndnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2054217309Snwhitehorndnl the wrappers for gcc and g++ warnings.
2055217309Snwhitehorndnl
2056217309Snwhitehorndnl $1 = GCC (default) or GXX
2057217309Snwhitehorndnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2058217309Snwhitehorndnl $3 = CFLAGS (default) or CXXFLAGS
2059217309SnwhitehornAC_DEFUN([CF_INTEL_COMPILER],[
2060217309Snwhitehornifelse($2,,INTEL_COMPILER,[$2])=no
2061217309Snwhitehorn
2062217309Snwhitehornif test "$ifelse($1,,[$1],GCC)" = yes ; then
2063217309Snwhitehorn	case $host_os in
2064217309Snwhitehorn	linux*|gnu*)
2065217309Snwhitehorn		AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
2066217309Snwhitehorn		cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
2067217309Snwhitehorn		ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
2068217309Snwhitehorn		AC_TRY_COMPILE([],[
2069217309Snwhitehorn#ifdef __INTEL_COMPILER
2070217309Snwhitehorn#else
2071217309Snwhitehornmake an error
2072217309Snwhitehorn#endif
2073217309Snwhitehorn],[ifelse($2,,INTEL_COMPILER,[$2])=yes
2074217309Snwhitehorncf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
2075217309Snwhitehorn],[])
2076217309Snwhitehorn		ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
2077217309Snwhitehorn		AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
2078217309Snwhitehorn		;;
2079217309Snwhitehorn	esac
2080217309Snwhitehornfi
2081217309Snwhitehorn])dnl
2082217309Snwhitehorndnl ---------------------------------------------------------------------------
2083217309Snwhitehorndnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
2084217309Snwhitehorndnl ------------
2085217309Snwhitehorndnl Add checks for large file support.
2086217309SnwhitehornAC_DEFUN([CF_LARGEFILE],[
2087217309Snwhitehornifdef([AC_FUNC_FSEEKO],[
2088217309Snwhitehorn    AC_SYS_LARGEFILE
2089217309Snwhitehorn    if test "$enable_largefile" != no ; then
2090217309Snwhitehorn	AC_FUNC_FSEEKO
2091217309Snwhitehorn
2092217309Snwhitehorn	# Normally we would collect these definitions in the config.h,
2093217309Snwhitehorn	# but (like _XOPEN_SOURCE), some environments rely on having these
2094217309Snwhitehorn	# defined before any of the system headers are included.  Another
2095217309Snwhitehorn	# case comes up with C++, e.g., on AIX the compiler compiles the
2096217309Snwhitehorn	# header files by themselves before looking at the body files it is
2097217309Snwhitehorn	# told to compile.  For ncurses, those header files do not include
2098217309Snwhitehorn	# the config.h
2099217309Snwhitehorn	test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
2100217309Snwhitehorn	test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
2101217309Snwhitehorn	test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
2102217309Snwhitehorn
2103217309Snwhitehorn	AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
2104217309Snwhitehorn		AC_TRY_COMPILE([
2105217309Snwhitehorn#include <sys/types.h>
2106217309Snwhitehorn#include <dirent.h>
2107217309Snwhitehorn		],[
2108217309Snwhitehorn		/* if transitional largefile support is setup, this is true */
2109217309Snwhitehorn		extern struct dirent64 * readdir(DIR *);
2110217309Snwhitehorn		struct dirent64 *x = readdir((DIR *)0);
2111217309Snwhitehorn		struct dirent *y = readdir((DIR *)0);
2112217309Snwhitehorn		int z = x - y;
2113217309Snwhitehorn		],
2114217309Snwhitehorn		[cf_cv_struct_dirent64=yes],
2115217309Snwhitehorn		[cf_cv_struct_dirent64=no])
2116217309Snwhitehorn	])
2117217309Snwhitehorn	test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
2118217309Snwhitehorn    fi
2119217309Snwhitehorn])
2120217309Snwhitehorn])
2121217309Snwhitehorndnl ---------------------------------------------------------------------------
2122217309Snwhitehorndnl CF_LD_RPATH_OPT version: 2 updated: 2010/03/27 19:27:54
2123217309Snwhitehorndnl ---------------
2124217309Snwhitehorndnl For the given system and compiler, find the compiler flags to pass to the
2125217309Snwhitehorndnl loader to use the "rpath" feature.
2126217309SnwhitehornAC_DEFUN([CF_LD_RPATH_OPT],
2127217309Snwhitehorn[
2128217309SnwhitehornAC_REQUIRE([CF_CHECK_CACHE])
2129217309Snwhitehorn
2130217309SnwhitehornLD_RPATH_OPT=
2131217309SnwhitehornAC_MSG_CHECKING(for an rpath option)
2132217309Snwhitehorncase $cf_cv_system_name in #(vi
2133217309Snwhitehornirix*) #(vi
2134217309Snwhitehorn	if test "$GCC" = yes; then
2135217309Snwhitehorn		LD_RPATH_OPT="-Wl,-rpath,"
2136217309Snwhitehorn	else
2137217309Snwhitehorn		LD_RPATH_OPT="-rpath "
2138217309Snwhitehorn	fi
2139217309Snwhitehorn	;;
2140217309Snwhitehornlinux*|gnu*|k*bsd*-gnu) #(vi
2141217309Snwhitehorn	LD_RPATH_OPT="-Wl,-rpath,"
2142217309Snwhitehorn	;;
2143217309Snwhitehornopenbsd[[2-9]].*) #(vi
2144217309Snwhitehorn	LD_RPATH_OPT="-Wl,-rpath,"
2145217309Snwhitehorn	;;
2146217309Snwhitehornfreebsd*) #(vi
2147217309Snwhitehorn	LD_RPATH_OPT="-rpath "
2148217309Snwhitehorn	;;
2149217309Snwhitehornnetbsd*) #(vi
2150217309Snwhitehorn	LD_RPATH_OPT="-Wl,-rpath,"
2151217309Snwhitehorn	;;
2152217309Snwhitehornosf*|mls+*) #(vi
2153217309Snwhitehorn	LD_RPATH_OPT="-rpath "
2154217309Snwhitehorn	;;
2155217309Snwhitehornsolaris2*) #(vi
2156217309Snwhitehorn	LD_RPATH_OPT="-R"
2157217309Snwhitehorn	;;
2158217309Snwhitehorn*)
2159217309Snwhitehorn	;;
2160217309Snwhitehornesac
2161217309SnwhitehornAC_MSG_RESULT($LD_RPATH_OPT)
2162217309Snwhitehorn
2163217309Snwhitehorncase "x$LD_RPATH_OPT" in #(vi
2164217309Snwhitehornx-R*)
2165217309Snwhitehorn	AC_MSG_CHECKING(if we need a space after rpath option)
2166217309Snwhitehorn	cf_save_LIBS="$LIBS"
2167217309Snwhitehorn	LIBS="${LD_RPATH_OPT}$libdir $LIBS"
2168217309Snwhitehorn	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
2169217309Snwhitehorn	LIBS="$cf_save_LIBS"
2170217309Snwhitehorn	AC_MSG_RESULT($cf_rpath_space)
2171217309Snwhitehorn	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
2172217309Snwhitehorn	;;
2173217309Snwhitehornesac
2174217309Snwhitehorn])dnl
2175217309Snwhitehorndnl ---------------------------------------------------------------------------
2176217309Snwhitehorndnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
2177217309Snwhitehorndnl ---------------
2178217309Snwhitehorndnl Construct a search-list of directories for a nonstandard library-file
2179217309Snwhitehorndnl
2180217309Snwhitehorndnl Parameters
2181217309Snwhitehorndnl	$1 = the variable to return as result
2182217309Snwhitehorndnl	$2 = the package name
2183217309SnwhitehornAC_DEFUN([CF_LIBRARY_PATH],
2184217309Snwhitehorn[
2185217309Snwhitehorn$1=
2186217309Snwhitehorncf_library_path_list=""
2187217309Snwhitehornif test -n "${LDFLAGS}${LIBS}" ; then
2188217309Snwhitehorn	for cf_library_path in $LDFLAGS $LIBS
2189217309Snwhitehorn	do
2190217309Snwhitehorn		case $cf_library_path in #(vi
2191217309Snwhitehorn		-L*)
2192217309Snwhitehorn			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
2193217309Snwhitehorn			CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
2194217309Snwhitehorn			cf_library_path_list="$cf_library_path_list [$]$1"
2195217309Snwhitehorn			;;
2196217309Snwhitehorn		esac
2197217309Snwhitehorn	done
2198217309Snwhitehornfi
2199217309Snwhitehorn
2200217309SnwhitehornCF_SUBDIR_PATH($1,$2,lib)
2201217309Snwhitehorn
2202217309Snwhitehorn$1="$cf_library_path_list [$]$1"
2203217309Snwhitehorn])dnl
2204217309Snwhitehorndnl ---------------------------------------------------------------------------
2205217309Snwhitehorndnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16
2206217309Snwhitehorndnl -------------
2207217309Snwhitehorndnl Compute the library-prefix for the given host system
2208217309Snwhitehorndnl $1 = variable to set
2209217309SnwhitehornAC_DEFUN([CF_LIB_PREFIX],
2210217309Snwhitehorn[
2211217309Snwhitehorn	case $cf_cv_system_name in #(vi
2212217309Snwhitehorn	OS/2*|os2*) #(vi
2213217309Snwhitehorn        LIB_PREFIX=''
2214217309Snwhitehorn        ;;
2215217309Snwhitehorn	*)	LIB_PREFIX='lib'
2216217309Snwhitehorn        ;;
2217217309Snwhitehorn	esac
2218217309Snwhitehornifelse($1,,,[$1=$LIB_PREFIX])
2219217309Snwhitehorn	AC_SUBST(LIB_PREFIX)
2220217309Snwhitehorn])dnl
2221217309Snwhitehorndnl ---------------------------------------------------------------------------
2222217309Snwhitehorndnl CF_MAKEFLAGS version: 12 updated: 2006/10/21 08:27:03
2223217309Snwhitehorndnl ------------
2224217309Snwhitehorndnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
2225217309Snwhitehorndnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
2226217309Snwhitehorndnl (GNU 'make' does both, something POSIX 'make', which happens to make the
2227217309Snwhitehorndnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
2228217309SnwhitehornAC_DEFUN([CF_MAKEFLAGS],
2229217309Snwhitehorn[
2230217309SnwhitehornAC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
2231217309Snwhitehorn	cf_cv_makeflags=''
2232217309Snwhitehorn	for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
2233217309Snwhitehorn	do
2234217309Snwhitehorn		cat >cf_makeflags.tmp <<CF_EOF
2235217309SnwhitehornSHELL = /bin/sh
2236217309Snwhitehornall :
2237217309Snwhitehorn	@ echo '.$cf_option'
2238217309SnwhitehornCF_EOF
2239217309Snwhitehorn		cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[ 	]]*$,,'`
2240217309Snwhitehorn		case "$cf_result" in
2241217309Snwhitehorn		.*k)
2242217309Snwhitehorn			cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
2243217309Snwhitehorn			case "$cf_result" in
2244217309Snwhitehorn			.*CC=*)	cf_cv_makeflags=
2245217309Snwhitehorn				;;
2246217309Snwhitehorn			*)	cf_cv_makeflags=$cf_option
2247217309Snwhitehorn				;;
2248217309Snwhitehorn			esac
2249217309Snwhitehorn			break
2250217309Snwhitehorn			;;
2251217309Snwhitehorn		.-)	;;
2252217309Snwhitehorn		*)	echo "given option \"$cf_option\", no match \"$cf_result\""
2253217309Snwhitehorn			;;
2254217309Snwhitehorn		esac
2255217309Snwhitehorn	done
2256217309Snwhitehorn	rm -f cf_makeflags.tmp
2257217309Snwhitehorn])
2258217309Snwhitehorn
2259217309SnwhitehornAC_SUBST(cf_cv_makeflags)
2260217309Snwhitehorn])dnl
2261217309Snwhitehorndnl ---------------------------------------------------------------------------
2262217309Snwhitehorndnl CF_MAKE_TAGS version: 5 updated: 2010/04/03 20:07:32
2263217309Snwhitehorndnl ------------
2264217309Snwhitehorndnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
2265217309Snwhitehorndnl a monocase filesystem.
2266217309SnwhitehornAC_DEFUN([CF_MAKE_TAGS],[
2267217309SnwhitehornAC_REQUIRE([CF_MIXEDCASE_FILENAMES])
2268217309Snwhitehorn
2269217309SnwhitehornAC_CHECK_PROGS(CTAGS, exctags ctags)
2270217309SnwhitehornAC_CHECK_PROGS(ETAGS, exetags etags)
2271217309Snwhitehorn
2272217309SnwhitehornAC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS-ctags}, yes, no)
2273217309Snwhitehorn
2274217309Snwhitehornif test "$cf_cv_mixedcase" = yes ; then
2275217309Snwhitehorn	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS-etags}, yes, no)
2276217309Snwhitehornelse
2277217309Snwhitehorn	MAKE_UPPER_TAGS=no
2278217309Snwhitehornfi
2279217309Snwhitehorn
2280217309Snwhitehornif test "$MAKE_UPPER_TAGS" = yes ; then
2281217309Snwhitehorn	MAKE_UPPER_TAGS=
2282217309Snwhitehornelse
2283217309Snwhitehorn	MAKE_UPPER_TAGS="#"
2284217309Snwhitehornfi
2285217309Snwhitehorn
2286217309Snwhitehornif test "$MAKE_LOWER_TAGS" = yes ; then
2287217309Snwhitehorn	MAKE_LOWER_TAGS=
2288217309Snwhitehornelse
2289217309Snwhitehorn	MAKE_LOWER_TAGS="#"
2290217309Snwhitehornfi
2291217309Snwhitehorn
2292217309SnwhitehornAC_SUBST(CTAGS)
2293217309SnwhitehornAC_SUBST(ETAGS)
2294217309Snwhitehorn
2295217309SnwhitehornAC_SUBST(MAKE_UPPER_TAGS)
2296217309SnwhitehornAC_SUBST(MAKE_LOWER_TAGS)
2297217309Snwhitehorn])dnl
2298217309Snwhitehorndnl ---------------------------------------------------------------------------
2299217309Snwhitehorndnl CF_MATH_LIB version: 6 updated: 2009/12/19 13:46:49
2300217309Snwhitehorndnl -----------
2301217309Snwhitehorndnl Checks for libraries.  At least one UNIX system, Apple Macintosh
2302217309Snwhitehorndnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
2303217309Snwhitehorndnl AC_CHECK_LIB(m,sin), because that fails for C++.
2304217309SnwhitehornAC_DEFUN([CF_MATH_LIB],
2305217309Snwhitehorn[
2306217309SnwhitehornAC_CACHE_CHECK(if -lm needed for math functions,
2307217309Snwhitehorn	cf_cv_need_libm,[
2308217309Snwhitehorn	AC_TRY_LINK([
2309217309Snwhitehorn	#include <stdio.h>
2310217309Snwhitehorn	#include <math.h>
2311217309Snwhitehorn	],
2312217309Snwhitehorn	[double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
2313217309Snwhitehorn	[cf_cv_need_libm=no],
2314217309Snwhitehorn	[cf_cv_need_libm=yes])])
2315217309Snwhitehornif test "$cf_cv_need_libm" = yes
2316217309Snwhitehornthen
2317217309Snwhitehornifelse($1,,[
2318217309Snwhitehorn	LIBS="-lm $LIBS"
2319217309Snwhitehorn],[$1=-lm])
2320217309Snwhitehornfi
2321217309Snwhitehorn])
2322217309Snwhitehorndnl ---------------------------------------------------------------------------
2323217309Snwhitehorndnl CF_MBSTATE_T version: 3 updated: 2007/03/25 15:55:36
2324217309Snwhitehorndnl ------------
2325217309Snwhitehorndnl Check if mbstate_t is declared, and if so, which header file.
2326217309Snwhitehorndnl This (including wchar.h) is needed on Tru64 5.0 to declare mbstate_t,
2327217309Snwhitehorndnl as well as include stdio.h to work around a misuse of varargs in wchar.h
2328217309SnwhitehornAC_DEFUN([CF_MBSTATE_T],
2329217309Snwhitehorn[
2330217309SnwhitehornAC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_mbstate_t,[
2331217309SnwhitehornAC_TRY_COMPILE([
2332217309Snwhitehorn#include <stdlib.h>
2333217309Snwhitehorn#include <stdio.h>
2334217309Snwhitehorn#ifdef HAVE_LIBUTF8_H
2335217309Snwhitehorn#include <libutf8.h>
2336217309Snwhitehorn#endif],
2337217309Snwhitehorn	[mbstate_t state],
2338217309Snwhitehorn	[cf_cv_mbstate_t=no],
2339217309Snwhitehorn	[AC_TRY_COMPILE([
2340217309Snwhitehorn#include <stdlib.h>
2341217309Snwhitehorn#include <stdio.h>
2342217309Snwhitehorn#include <wchar.h>
2343217309Snwhitehorn#ifdef HAVE_LIBUTF8_H
2344217309Snwhitehorn#include <libutf8.h>
2345217309Snwhitehorn#endif],
2346217309Snwhitehorn	[mbstate_t value],
2347217309Snwhitehorn	[cf_cv_mbstate_t=yes],
2348217309Snwhitehorn	[cf_cv_mbstate_t=unknown])])])
2349217309Snwhitehorn
2350217309Snwhitehornif test "$cf_cv_mbstate_t" = yes ; then
2351217309Snwhitehorn	AC_DEFINE(NEED_WCHAR_H)
2352217309Snwhitehornfi
2353217309Snwhitehorn
2354217309Snwhitehornif test "$cf_cv_mbstate_t" != unknown ; then
2355217309Snwhitehorn	AC_DEFINE(HAVE_MBSTATE_T)
2356217309Snwhitehornfi
2357217309Snwhitehorn])dnl
2358217309Snwhitehorndnl ---------------------------------------------------------------------------
2359217309Snwhitehorndnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
2360217309Snwhitehorndnl ----------------------
2361217309Snwhitehorndnl Check if the file-system supports mixed-case filenames.  If we're able to
2362217309Snwhitehorndnl create a lowercase name and see it as uppercase, it doesn't support that.
2363217309SnwhitehornAC_DEFUN([CF_MIXEDCASE_FILENAMES],
2364217309Snwhitehorn[
2365217309SnwhitehornAC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
2366217309Snwhitehornif test "$cross_compiling" = yes ; then
2367217309Snwhitehorn	case $target_alias in #(vi
2368217309Snwhitehorn	*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
2369217309Snwhitehorn		cf_cv_mixedcase=no
2370217309Snwhitehorn		;;
2371217309Snwhitehorn	*)
2372217309Snwhitehorn		cf_cv_mixedcase=yes
2373217309Snwhitehorn		;;
2374217309Snwhitehorn	esac
2375217309Snwhitehornelse
2376217309Snwhitehorn	rm -f conftest CONFTEST
2377217309Snwhitehorn	echo test >conftest
2378217309Snwhitehorn	if test -f CONFTEST ; then
2379217309Snwhitehorn		cf_cv_mixedcase=no
2380217309Snwhitehorn	else
2381217309Snwhitehorn		cf_cv_mixedcase=yes
2382217309Snwhitehorn	fi
2383217309Snwhitehorn	rm -f conftest CONFTEST
2384217309Snwhitehornfi
2385217309Snwhitehorn])
2386217309Snwhitehorntest "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
2387217309Snwhitehorn])dnl
2388217309Snwhitehorndnl ---------------------------------------------------------------------------
2389217309Snwhitehorndnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
2390217309Snwhitehorndnl ----------
2391217309Snwhitehorndnl Write a debug message to config.log, along with the line number in the
2392217309Snwhitehorndnl configure script.
2393217309SnwhitehornAC_DEFUN([CF_MSG_LOG],[
2394217309Snwhitehornecho "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
2395217309Snwhitehorn])dnl
2396217309Snwhitehorndnl ---------------------------------------------------------------------------
2397217309Snwhitehorndnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
2398217309Snwhitehorndnl -------------------
2399217309Snwhitehorndnl Check if we can compile with ncurses' header file
2400217309Snwhitehorndnl $1 is the cache variable to set
2401217309Snwhitehorndnl $2 is the header-file to include
2402217309Snwhitehorndnl $3 is the root name (ncurses or ncursesw)
2403217309SnwhitehornAC_DEFUN([CF_NCURSES_CC_CHECK],[
2404217309Snwhitehorn	AC_TRY_COMPILE([
2405217309Snwhitehorn]ifelse($3,ncursesw,[
2406217309Snwhitehorn#define _XOPEN_SOURCE_EXTENDED
2407217309Snwhitehorn#undef  HAVE_LIBUTF8_H	/* in case we used CF_UTF8_LIB */
2408217309Snwhitehorn#define HAVE_LIBUTF8_H	/* to force ncurses' header file to use cchar_t */
2409217309Snwhitehorn])[
2410217309Snwhitehorn#include <$2>],[
2411217309Snwhitehorn#ifdef NCURSES_VERSION
2412217309Snwhitehorn]ifelse($3,ncursesw,[
2413217309Snwhitehorn#ifndef WACS_BSSB
2414217309Snwhitehorn	make an error
2415217309Snwhitehorn#endif
2416217309Snwhitehorn])[
2417217309Snwhitehornprintf("%s\n", NCURSES_VERSION);
2418217309Snwhitehorn#else
2419217309Snwhitehorn#ifdef __NCURSES_H
2420217309Snwhitehornprintf("old\n");
2421217309Snwhitehorn#else
2422217309Snwhitehorn	make an error
2423217309Snwhitehorn#endif
2424217309Snwhitehorn#endif
2425217309Snwhitehorn	]
2426217309Snwhitehorn	,[$1=$2]
2427217309Snwhitehorn	,[$1=no])
2428217309Snwhitehorn])dnl
2429217309Snwhitehorndnl ---------------------------------------------------------------------------
2430217309Snwhitehorndnl CF_NCURSES_CONFIG version: 6 updated: 2010/04/28 06:02:16
2431217309Snwhitehorndnl -----------------
2432217309Snwhitehorndnl Tie together the configure-script macros for ncurses.
2433217309Snwhitehorndnl Prefer the "-config" script from ncurses 5.6, to simplify analysis.
2434217309Snwhitehorndnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
2435217309Snwhitehorndnl
2436217309Snwhitehorndnl $1 is the root library name (default: "ncurses")
2437217309SnwhitehornAC_DEFUN([CF_NCURSES_CONFIG],
2438217309Snwhitehorn[
2439217309Snwhitehorncf_ncuconfig_root=ifelse($1,,ncurses,$1)
2440217309Snwhitehorn
2441217309Snwhitehornecho "Looking for ${cf_ncuconfig_root}-config"
2442217309SnwhitehornAC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
2443217309Snwhitehorn
2444217309Snwhitehornif test "$NCURSES_CONFIG" != none ; then
2445217309Snwhitehorn
2446217309SnwhitehornCPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
2447217309SnwhitehornLIBS="`$NCURSES_CONFIG --libs` $LIBS"
2448217309Snwhitehorn
2449217309Snwhitehorn# even with config script, some packages use no-override for curses.h
2450217309SnwhitehornCF_CURSES_HEADER(ifelse($1,,ncurses,$1))
2451217309Snwhitehorn
2452217309Snwhitehorndnl like CF_NCURSES_CPPFLAGS
2453217309SnwhitehornAC_DEFINE(NCURSES)
2454217309Snwhitehorn
2455217309Snwhitehorndnl like CF_NCURSES_LIBS
2456217309SnwhitehornCF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
2457217309SnwhitehornAC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2458217309Snwhitehorn
2459217309Snwhitehorndnl like CF_NCURSES_VERSION
2460217309Snwhitehorncf_cv_ncurses_version=`$NCURSES_CONFIG --version`
2461217309Snwhitehorn
2462217309Snwhitehornelse
2463217309Snwhitehorn
2464217309SnwhitehornCF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
2465217309SnwhitehornCF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
2466217309Snwhitehorn
2467217309Snwhitehornfi
2468217309Snwhitehorn])dnl
2469217309Snwhitehorndnl ---------------------------------------------------------------------------
2470217309Snwhitehorndnl CF_NCURSES_CPPFLAGS version: 19 updated: 2007/07/29 13:35:20
2471217309Snwhitehorndnl -------------------
2472217309Snwhitehorndnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
2473217309Snwhitehorndnl the CPPFLAGS variable so we can include its header.
2474217309Snwhitehorndnl
2475217309Snwhitehorndnl The header files may be installed as either curses.h, or ncurses.h (would
2476217309Snwhitehorndnl be obsolete, except that some packagers prefer this name to distinguish it
2477217309Snwhitehorndnl from a "native" curses implementation).  If not installed for overwrite,
2478217309Snwhitehorndnl the curses.h file would be in an ncurses subdirectory (e.g.,
2479217309Snwhitehorndnl /usr/include/ncurses), but someone may have installed overwriting the
2480217309Snwhitehorndnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
2481217309Snwhitehorndnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2482217309Snwhitehorndnl the header.
2483217309Snwhitehorndnl
2484217309Snwhitehorndnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2485217309Snwhitehorndnl is already in the include-path, don't even bother with this, since we cannot
2486217309Snwhitehorndnl easily determine which file it is.  In this case, it has to be <curses.h>.
2487217309Snwhitehorndnl
2488217309Snwhitehorndnl The optional parameter gives the root name of the library, in case it is
2489217309Snwhitehorndnl not installed as the default curses library.  That is how the
2490217309Snwhitehorndnl wide-character version of ncurses is installed.
2491217309SnwhitehornAC_DEFUN([CF_NCURSES_CPPFLAGS],
2492217309Snwhitehorn[AC_REQUIRE([CF_WITH_CURSES_DIR])
2493217309Snwhitehorn
2494217309SnwhitehornAC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2495217309Snwhitehorncf_ncuhdr_root=ifelse($1,,ncurses,$1)
2496217309Snwhitehorn
2497217309Snwhitehorntest -n "$cf_cv_curses_dir" && \
2498217309Snwhitehorntest "$cf_cv_curses_dir" != "no" && { \
2499217309Snwhitehorn  CF_ADD_INCDIR($cf_cv_curses_dir/include $cf_cv_curses_dir/include/$cf_ncuhdr_root)
2500217309Snwhitehorn}
2501217309Snwhitehorn
2502217309SnwhitehornAC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2503217309Snwhitehorn	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2504217309Snwhitehorn	( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2505217309Snwhitehorn	for cf_header in $cf_header_list
2506217309Snwhitehorn	do
2507217309Snwhitehorn		CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2508217309Snwhitehorn		test "$cf_cv_ncurses_h" != no && break
2509217309Snwhitehorn	done
2510217309Snwhitehorn])
2511217309Snwhitehorn
2512217309SnwhitehornCF_NCURSES_HEADER
2513217309SnwhitehornCF_TERM_HEADER
2514217309Snwhitehorn
2515217309Snwhitehorn# some applications need this, but should check for NCURSES_VERSION
2516217309SnwhitehornAC_DEFINE(NCURSES)
2517217309Snwhitehorn
2518217309SnwhitehornCF_NCURSES_VERSION
2519217309Snwhitehorn])dnl
2520217309Snwhitehorndnl ---------------------------------------------------------------------------
2521217309Snwhitehorndnl CF_NCURSES_HEADER version: 2 updated: 2008/03/23 14:48:54
2522217309Snwhitehorndnl -----------------
2523217309Snwhitehorndnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2524217309Snwhitehorndnl variations of ncurses' installs.
2525217309Snwhitehorndnl
2526217309Snwhitehorndnl See also CF_CURSES_HEADER, which sets the same cache variable.
2527217309SnwhitehornAC_DEFUN([CF_NCURSES_HEADER],[
2528217309Snwhitehorn
2529217309Snwhitehornif test "$cf_cv_ncurses_h" != no ; then
2530217309Snwhitehorn	cf_cv_ncurses_header=$cf_cv_ncurses_h
2531217309Snwhitehornelse
2532217309Snwhitehorn
2533217309SnwhitehornAC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2534217309Snwhitehorn	test -n "$verbose" && echo
2535217309Snwhitehorn	CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2536217309Snwhitehorn	test -n "$verbose" && echo search path $cf_search
2537217309Snwhitehorn	cf_save2_CPPFLAGS="$CPPFLAGS"
2538217309Snwhitehorn	for cf_incdir in $cf_search
2539217309Snwhitehorn	do
2540217309Snwhitehorn		CF_ADD_INCDIR($cf_incdir)
2541217309Snwhitehorn		for cf_header in \
2542217309Snwhitehorn			ncurses.h \
2543217309Snwhitehorn			curses.h
2544217309Snwhitehorn		do
2545217309Snwhitehorn			CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2546217309Snwhitehorn			if test "$cf_cv_ncurses_h2" != no ; then
2547217309Snwhitehorn				cf_cv_ncurses_h2=$cf_incdir/$cf_header
2548217309Snwhitehorn				test -n "$verbose" && echo $ac_n "	... found $ac_c" 1>&AC_FD_MSG
2549217309Snwhitehorn				break
2550217309Snwhitehorn			fi
2551217309Snwhitehorn			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2552217309Snwhitehorn		done
2553217309Snwhitehorn		CPPFLAGS="$cf_save2_CPPFLAGS"
2554217309Snwhitehorn		test "$cf_cv_ncurses_h2" != no && break
2555217309Snwhitehorn	done
2556217309Snwhitehorn	test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2557217309Snwhitehorn	])
2558217309Snwhitehorn
2559217309Snwhitehorn	CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2560217309Snwhitehorn	cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2561217309Snwhitehorn	if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2562217309Snwhitehorn		cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2563217309Snwhitehorn	fi
2564217309Snwhitehorn	CF_ADD_INCDIR($cf_1st_incdir)
2565217309Snwhitehorn
2566217309Snwhitehornfi
2567217309Snwhitehorn
2568217309Snwhitehorn# Set definitions to allow ifdef'ing for ncurses.h
2569217309Snwhitehorn
2570217309Snwhitehorncase $cf_cv_ncurses_header in # (vi
2571217309Snwhitehorn*ncurses.h)
2572217309Snwhitehorn	AC_DEFINE(HAVE_NCURSES_H)
2573217309Snwhitehorn	;;
2574217309Snwhitehornesac
2575217309Snwhitehorn
2576217309Snwhitehorncase $cf_cv_ncurses_header in # (vi
2577217309Snwhitehornncurses/curses.h|ncurses/ncurses.h)
2578217309Snwhitehorn	AC_DEFINE(HAVE_NCURSES_NCURSES_H)
2579217309Snwhitehorn	;;
2580217309Snwhitehornncursesw/curses.h|ncursesw/ncurses.h)
2581217309Snwhitehorn	AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
2582217309Snwhitehorn	;;
2583217309Snwhitehornesac
2584217309Snwhitehorn
2585217309Snwhitehorn])dnl
2586217309Snwhitehorndnl ---------------------------------------------------------------------------
2587217309Snwhitehorndnl CF_NCURSES_LIBS version: 13 updated: 2007/07/29 10:29:20
2588217309Snwhitehorndnl ---------------
2589217309Snwhitehorndnl Look for the ncurses library.  This is a little complicated on Linux,
2590217309Snwhitehorndnl because it may be linked with the gpm (general purpose mouse) library.
2591217309Snwhitehorndnl Some distributions have gpm linked with (bsd) curses, which makes it
2592217309Snwhitehorndnl unusable with ncurses.  However, we don't want to link with gpm unless
2593217309Snwhitehorndnl ncurses has a dependency, since gpm is normally set up as a shared library,
2594217309Snwhitehorndnl and the linker will record a dependency.
2595217309Snwhitehorndnl
2596217309Snwhitehorndnl The optional parameter gives the root name of the library, in case it is
2597217309Snwhitehorndnl not installed as the default curses library.  That is how the
2598217309Snwhitehorndnl wide-character version of ncurses is installed.
2599217309SnwhitehornAC_DEFUN([CF_NCURSES_LIBS],
2600217309Snwhitehorn[AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2601217309Snwhitehorn
2602217309Snwhitehorncf_nculib_root=ifelse($1,,ncurses,$1)
2603217309Snwhitehorn	# This works, except for the special case where we find gpm, but
2604217309Snwhitehorn	# ncurses is in a nonstandard location via $LIBS, and we really want
2605217309Snwhitehorn	# to link gpm.
2606217309Snwhitehorncf_ncurses_LIBS=""
2607217309Snwhitehorncf_ncurses_SAVE="$LIBS"
2608217309SnwhitehornAC_CHECK_LIB(gpm,Gpm_Open,
2609217309Snwhitehorn	[AC_CHECK_LIB(gpm,initscr,
2610217309Snwhitehorn		[LIBS="$cf_ncurses_SAVE"],
2611217309Snwhitehorn		[cf_ncurses_LIBS="-lgpm"])])
2612217309Snwhitehorn
2613217309Snwhitehorncase $host_os in #(vi
2614217309Snwhitehornfreebsd*)
2615217309Snwhitehorn	# This is only necessary if you are linking against an obsolete
2616217309Snwhitehorn	# version of ncurses (but it should do no harm, since it's static).
2617217309Snwhitehorn	if test "$cf_nculib_root" = ncurses ; then
2618217309Snwhitehorn		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2619217309Snwhitehorn	fi
2620217309Snwhitehorn	;;
2621217309Snwhitehornesac
2622217309Snwhitehorn
2623217309SnwhitehornLIBS="$cf_ncurses_LIBS $LIBS"
2624217309Snwhitehorn
2625217309Snwhitehornif ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2626217309Snwhitehornthen
2627217309Snwhitehorn	CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
2628217309Snwhitehorn	LIBS="-l$cf_nculib_root $LIBS"
2629217309Snwhitehornelse
2630217309Snwhitehorn	CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2631217309Snwhitehorn		[#include <${cf_cv_ncurses_header-curses.h}>],
2632217309Snwhitehorn		[initscr()],
2633217309Snwhitehorn		initscr)
2634217309Snwhitehornfi
2635217309Snwhitehorn
2636217309Snwhitehornif test -n "$cf_ncurses_LIBS" ; then
2637217309Snwhitehorn	AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2638217309Snwhitehorn	cf_ncurses_SAVE="$LIBS"
2639217309Snwhitehorn	for p in $cf_ncurses_LIBS ; do
2640217309Snwhitehorn		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2641217309Snwhitehorn		if test "$q" != "$LIBS" ; then
2642217309Snwhitehorn			LIBS="$q"
2643217309Snwhitehorn		fi
2644217309Snwhitehorn	done
2645217309Snwhitehorn	AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
2646217309Snwhitehorn		[initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2647217309Snwhitehorn		[AC_MSG_RESULT(yes)],
2648217309Snwhitehorn		[AC_MSG_RESULT(no)
2649217309Snwhitehorn		 LIBS="$cf_ncurses_SAVE"])
2650217309Snwhitehornfi
2651217309Snwhitehorn
2652217309SnwhitehornCF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2653217309SnwhitehornAC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2654217309Snwhitehorn])dnl
2655217309Snwhitehorndnl ---------------------------------------------------------------------------
2656217309Snwhitehorndnl CF_NCURSES_VERSION version: 12 updated: 2007/04/28 09:15:55
2657217309Snwhitehorndnl ------------------
2658217309Snwhitehorndnl Check for the version of ncurses, to aid in reporting bugs, etc.
2659217309Snwhitehorndnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
2660217309Snwhitehorndnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2661217309SnwhitehornAC_DEFUN([CF_NCURSES_VERSION],
2662217309Snwhitehorn[
2663217309SnwhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2664217309SnwhitehornAC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2665217309Snwhitehorn	cf_cv_ncurses_version=no
2666217309Snwhitehorn	cf_tempfile=out$$
2667217309Snwhitehorn	rm -f $cf_tempfile
2668217309Snwhitehorn	AC_TRY_RUN([
2669217309Snwhitehorn#include <${cf_cv_ncurses_header-curses.h}>
2670217309Snwhitehorn#include <stdio.h>
2671217309Snwhitehornint main()
2672217309Snwhitehorn{
2673217309Snwhitehorn	FILE *fp = fopen("$cf_tempfile", "w");
2674217309Snwhitehorn#ifdef NCURSES_VERSION
2675217309Snwhitehorn# ifdef NCURSES_VERSION_PATCH
2676217309Snwhitehorn	fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2677217309Snwhitehorn# else
2678217309Snwhitehorn	fprintf(fp, "%s\n", NCURSES_VERSION);
2679217309Snwhitehorn# endif
2680217309Snwhitehorn#else
2681217309Snwhitehorn# ifdef __NCURSES_H
2682217309Snwhitehorn	fprintf(fp, "old\n");
2683217309Snwhitehorn# else
2684217309Snwhitehorn	make an error
2685217309Snwhitehorn# endif
2686217309Snwhitehorn#endif
2687217309Snwhitehorn	${cf_cv_main_return-return}(0);
2688217309Snwhitehorn}],[
2689217309Snwhitehorn	cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2690217309Snwhitehorn
2691217309Snwhitehorn	# This will not work if the preprocessor splits the line after the
2692217309Snwhitehorn	# Autoconf token.  The 'unproto' program does that.
2693217309Snwhitehorn	cat > conftest.$ac_ext <<EOF
2694217309Snwhitehorn#include <${cf_cv_ncurses_header-curses.h}>
2695217309Snwhitehorn#undef Autoconf
2696217309Snwhitehorn#ifdef NCURSES_VERSION
2697217309SnwhitehornAutoconf NCURSES_VERSION
2698217309Snwhitehorn#else
2699217309Snwhitehorn#ifdef __NCURSES_H
2700217309SnwhitehornAutoconf "old"
2701217309Snwhitehorn#endif
2702217309Snwhitehorn;
2703217309Snwhitehorn#endif
2704217309SnwhitehornEOF
2705217309Snwhitehorn	cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2706217309Snwhitehorn	AC_TRY_EVAL(cf_try)
2707217309Snwhitehorn	if test -f conftest.out ; then
2708217309Snwhitehorn		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2709217309Snwhitehorn		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2710217309Snwhitehorn		rm -f conftest.out
2711217309Snwhitehorn	fi
2712217309Snwhitehorn])
2713217309Snwhitehorn	rm -f $cf_tempfile
2714217309Snwhitehorn])
2715217309Snwhitehorntest "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
2716217309Snwhitehorn])dnl
2717217309Snwhitehorndnl ---------------------------------------------------------------------------
2718217309Snwhitehorndnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
2719217309Snwhitehorndnl ------------------
2720217309Snwhitehorndnl see CF_WITH_NO_LEAKS
2721217309SnwhitehornAC_DEFUN([CF_NO_LEAKS_OPTION],[
2722217309SnwhitehornAC_MSG_CHECKING(if you want to use $1 for testing)
2723217309SnwhitehornAC_ARG_WITH($1,
2724217309Snwhitehorn	[$2],
2725217309Snwhitehorn	[AC_DEFINE($3)ifelse([$4],,[
2726217309Snwhitehorn	 $4
2727217309Snwhitehorn])
2728217309Snwhitehorn	: ${with_cflags:=-g}
2729217309Snwhitehorn	: ${with_no_leaks:=yes}
2730217309Snwhitehorn	 with_$1=yes],
2731217309Snwhitehorn	[with_$1=])
2732217309SnwhitehornAC_MSG_RESULT(${with_$1:-no})
2733217309Snwhitehorn
2734217309Snwhitehorncase .$with_cflags in #(vi
2735217309Snwhitehorn.*-g*)
2736217309Snwhitehorn	case .$CFLAGS in #(vi
2737217309Snwhitehorn	.*-g*) #(vi
2738217309Snwhitehorn		;;
2739217309Snwhitehorn	*)
2740217309Snwhitehorn		CF_ADD_CFLAGS([-g])
2741217309Snwhitehorn		;;
2742217309Snwhitehorn	esac
2743217309Snwhitehorn	;;
2744217309Snwhitehornesac
2745217309Snwhitehorn])dnl
2746217309Snwhitehorndnl ---------------------------------------------------------------------------
2747217309Snwhitehorndnl CF_OUR_MESSAGES version: 7 updated: 2004/09/12 19:45:55
2748217309Snwhitehorndnl ---------------
2749217309Snwhitehorndnl Check if we use the messages included with this program
2750217309Snwhitehorndnl
2751217309Snwhitehorndnl $1 specifies either Makefile or makefile, defaulting to the former.
2752217309Snwhitehorndnl
2753217309Snwhitehorndnl Sets variables which can be used to substitute in makefiles:
2754217309Snwhitehorndnl	MSG_DIR_MAKE - to make ./po directory
2755217309Snwhitehorndnl	SUB_MAKEFILE - makefile in ./po directory (see CF_BUNDLED_INTL)
2756217309Snwhitehorndnl
2757217309SnwhitehornAC_DEFUN([CF_OUR_MESSAGES],
2758217309Snwhitehorn[
2759217309Snwhitehorncf_makefile=ifelse($1,,Makefile,$1)
2760217309Snwhitehorn
2761217309Snwhitehornuse_our_messages=no
2762217309Snwhitehornif test "$USE_NLS" = yes ; then
2763217309Snwhitehornif test -d $srcdir/po ; then
2764217309SnwhitehornAC_MSG_CHECKING(if we should use included message-library)
2765217309Snwhitehorn	AC_ARG_ENABLE(included-msgs,
2766217309Snwhitehorn	[  --disable-included-msgs use included messages, for i18n support],
2767217309Snwhitehorn	[use_our_messages=$enableval],
2768217309Snwhitehorn	[use_our_messages=yes])
2769217309Snwhitehornfi
2770217309SnwhitehornAC_MSG_RESULT($use_our_messages)
2771217309Snwhitehornfi
2772217309Snwhitehorn
2773217309SnwhitehornMSG_DIR_MAKE="#"
2774217309Snwhitehornif test "$use_our_messages" = yes
2775217309Snwhitehornthen
2776217309Snwhitehorn	SUB_MAKEFILE="$SUB_MAKEFILE po/$cf_makefile.in:$srcdir/po/$cf_makefile.inn"
2777217309Snwhitehorn	MSG_DIR_MAKE=
2778217309Snwhitehornfi
2779217309Snwhitehorn
2780217309SnwhitehornAC_SUBST(MSG_DIR_MAKE)
2781217309SnwhitehornAC_SUBST(SUB_MAKEFILE)
2782217309Snwhitehorn])dnl
2783217309Snwhitehorndnl ---------------------------------------------------------------------------
2784217309Snwhitehorndnl CF_PATHSEP version: 4 updated: 2009/01/11 20:30:23
2785217309Snwhitehorndnl ----------
2786217309Snwhitehorndnl Provide a value for the $PATH and similar separator
2787217309SnwhitehornAC_DEFUN([CF_PATHSEP],
2788217309Snwhitehorn[
2789217309Snwhitehorn	case $cf_cv_system_name in
2790217309Snwhitehorn	os2*)	PATH_SEPARATOR=';'  ;;
2791217309Snwhitehorn	*)	PATH_SEPARATOR=':'  ;;
2792217309Snwhitehorn	esac
2793217309Snwhitehornifelse($1,,,[$1=$PATH_SEPARATOR])
2794217309Snwhitehorn	AC_SUBST(PATH_SEPARATOR)
2795217309Snwhitehorn])dnl
2796217309Snwhitehorndnl ---------------------------------------------------------------------------
2797217309Snwhitehorndnl CF_PATH_SYNTAX version: 12 updated: 2008/03/23 14:45:59
2798217309Snwhitehorndnl --------------
2799217309Snwhitehorndnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2800217309Snwhitehorndnl begins with one of the prefix/exec_prefix variables, and then again if the
2801217309Snwhitehorndnl result begins with 'NONE'.  This is necessary to work around autoconf's
2802217309Snwhitehorndnl delayed evaluation of those symbols.
2803217309SnwhitehornAC_DEFUN([CF_PATH_SYNTAX],[
2804217309Snwhitehornif test "x$prefix" != xNONE; then
2805217309Snwhitehorn  cf_path_syntax="$prefix"
2806217309Snwhitehornelse
2807217309Snwhitehorn  cf_path_syntax="$ac_default_prefix"
2808217309Snwhitehornfi
2809217309Snwhitehorn
2810217309Snwhitehorncase ".[$]$1" in #(vi
2811217309Snwhitehorn.\[$]\(*\)*|.\'*\'*) #(vi
2812217309Snwhitehorn  ;;
2813217309Snwhitehorn..|./*|.\\*) #(vi
2814217309Snwhitehorn  ;;
2815217309Snwhitehorn.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
2816217309Snwhitehorn  ;;
2817217309Snwhitehorn.\[$]{*prefix}*) #(vi
2818217309Snwhitehorn  eval $1="[$]$1"
2819217309Snwhitehorn  case ".[$]$1" in #(vi
2820217309Snwhitehorn  .NONE/*)
2821217309Snwhitehorn    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2822217309Snwhitehorn    ;;
2823217309Snwhitehorn  esac
2824217309Snwhitehorn  ;; #(vi
2825217309Snwhitehorn.no|.NONE/*)
2826217309Snwhitehorn  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2827217309Snwhitehorn  ;;
2828217309Snwhitehorn*)
2829217309Snwhitehorn  ifelse($2,,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2830217309Snwhitehorn  ;;
2831217309Snwhitehornesac
2832217309Snwhitehorn])dnl
2833217309Snwhitehorndnl ---------------------------------------------------------------------------
2834217309Snwhitehorndnl CF_POSIX_C_SOURCE version: 7 updated: 2010/01/09 11:05:50
2835217309Snwhitehorndnl -----------------
2836217309Snwhitehorndnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2837217309Snwhitehorndnl
2838217309Snwhitehorndnl	POSIX.1-1990				_POSIX_SOURCE
2839217309Snwhitehorndnl	POSIX.1-1990 and			_POSIX_SOURCE and
2840217309Snwhitehorndnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
2841217309Snwhitehorndnl		Bindings Option
2842217309Snwhitehorndnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
2843217309Snwhitehorndnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
2844217309Snwhitehorndnl	X/Open 2000				_POSIX_C_SOURCE=200112L
2845217309Snwhitehorndnl
2846217309Snwhitehorndnl Parameters:
2847217309Snwhitehorndnl	$1 is the nominal value for _POSIX_C_SOURCE
2848217309SnwhitehornAC_DEFUN([CF_POSIX_C_SOURCE],
2849217309Snwhitehorn[
2850217309Snwhitehorncf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
2851217309Snwhitehorn
2852217309Snwhitehorncf_save_CFLAGS="$CFLAGS"
2853217309Snwhitehorncf_save_CPPFLAGS="$CPPFLAGS"
2854217309Snwhitehorn
2855217309SnwhitehornCF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2856217309SnwhitehornCF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2857217309Snwhitehorn
2858217309SnwhitehornAC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2859217309Snwhitehorn	CF_MSG_LOG(if the symbol is already defined go no further)
2860217309Snwhitehorn	AC_TRY_COMPILE([#include <sys/types.h>],[
2861217309Snwhitehorn#ifndef _POSIX_C_SOURCE
2862217309Snwhitehornmake an error
2863217309Snwhitehorn#endif],
2864217309Snwhitehorn	[cf_cv_posix_c_source=no],
2865217309Snwhitehorn	[cf_want_posix_source=no
2866217309Snwhitehorn	 case .$cf_POSIX_C_SOURCE in #(vi
2867217309Snwhitehorn	 .[[12]]??*) #(vi
2868217309Snwhitehorn		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2869217309Snwhitehorn		;;
2870217309Snwhitehorn	 .2) #(vi
2871217309Snwhitehorn		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2872217309Snwhitehorn		cf_want_posix_source=yes
2873217309Snwhitehorn		;;
2874217309Snwhitehorn	 .*)
2875217309Snwhitehorn		cf_want_posix_source=yes
2876217309Snwhitehorn		;;
2877217309Snwhitehorn	 esac
2878217309Snwhitehorn	 if test "$cf_want_posix_source" = yes ; then
2879217309Snwhitehorn		AC_TRY_COMPILE([#include <sys/types.h>],[
2880217309Snwhitehorn#ifdef _POSIX_SOURCE
2881217309Snwhitehornmake an error
2882217309Snwhitehorn#endif],[],
2883217309Snwhitehorn		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2884217309Snwhitehorn	 fi
2885217309Snwhitehorn	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2886217309Snwhitehorn	 CFLAGS="$cf_trim_CFLAGS"
2887217309Snwhitehorn	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2888217309Snwhitehorn	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
2889217309Snwhitehorn	 AC_TRY_COMPILE([#include <sys/types.h>],[
2890217309Snwhitehorn#ifndef _POSIX_C_SOURCE
2891217309Snwhitehornmake an error
2892217309Snwhitehorn#endif],,
2893217309Snwhitehorn	 [cf_cv_posix_c_source=no])
2894217309Snwhitehorn	 CFLAGS="$cf_save_CFLAGS"
2895217309Snwhitehorn	 CPPFLAGS="$cf_save_CPPFLAGS"
2896217309Snwhitehorn	])
2897217309Snwhitehorn])
2898217309Snwhitehorn
2899217309Snwhitehornif test "$cf_cv_posix_c_source" != no ; then
2900217309Snwhitehorn	CFLAGS="$cf_trim_CFLAGS"
2901217309Snwhitehorn	CPPFLAGS="$cf_trim_CPPFLAGS"
2902217309Snwhitehorn	CF_ADD_CFLAGS($cf_cv_posix_c_source)
2903217309Snwhitehornfi
2904217309Snwhitehorn
2905217309Snwhitehorn])dnl
2906217309Snwhitehorndnl ---------------------------------------------------------------------------
2907217309Snwhitehorndnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
2908217309Snwhitehorndnl --------------
2909217309Snwhitehorndnl Check if C (preprocessor) -U and -D options are processed in the order
2910217309Snwhitehorndnl given rather than by type of option.  Some compilers insist on apply all
2911217309Snwhitehorndnl of the -U options after all of the -D options.  Others allow mixing them,
2912217309Snwhitehorndnl and may predefine symbols that conflict with those we define.
2913217309SnwhitehornAC_DEFUN([CF_PROG_CC_U_D],
2914217309Snwhitehorn[
2915217309SnwhitehornAC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
2916217309Snwhitehorn	cf_save_CPPFLAGS="$CPPFLAGS"
2917217309Snwhitehorn	CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
2918217309Snwhitehorn	AC_TRY_COMPILE([],[
2919217309Snwhitehorn#ifndef U_D_OPTIONS
2920217309Snwhitehornmake an undefined-error
2921217309Snwhitehorn#endif
2922217309Snwhitehorn#ifdef  D_U_OPTIONS
2923217309Snwhitehornmake a defined-error
2924217309Snwhitehorn#endif
2925217309Snwhitehorn	],[
2926217309Snwhitehorn	cf_cv_cc_u_d_options=yes],[
2927217309Snwhitehorn	cf_cv_cc_u_d_options=no])
2928217309Snwhitehorn	CPPFLAGS="$cf_save_CPPFLAGS"
2929217309Snwhitehorn])
2930217309Snwhitehorn])dnl
2931217309Snwhitehorndnl ---------------------------------------------------------------------------
2932217309Snwhitehorndnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
2933217309Snwhitehorndnl -----------
2934217309Snwhitehorndnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
2935217309SnwhitehornAC_DEFUN([CF_PROG_EXT],
2936217309Snwhitehorn[
2937217309SnwhitehornAC_REQUIRE([CF_CHECK_CACHE])
2938217309Snwhitehorncase $cf_cv_system_name in
2939217309Snwhitehornos2*)
2940217309Snwhitehorn    CFLAGS="$CFLAGS -Zmt"
2941217309Snwhitehorn    CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
2942217309Snwhitehorn    CXXFLAGS="$CXXFLAGS -Zmt"
2943217309Snwhitehorn    # autoconf's macro sets -Zexe and suffix both, which conflict:w
2944217309Snwhitehorn    LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
2945217309Snwhitehorn    ac_cv_exeext=.exe
2946217309Snwhitehorn    ;;
2947217309Snwhitehornesac
2948217309Snwhitehorn
2949217309SnwhitehornAC_EXEEXT
2950217309SnwhitehornAC_OBJEXT
2951217309Snwhitehorn
2952217309SnwhitehornPROG_EXT="$EXEEXT"
2953217309SnwhitehornAC_SUBST(PROG_EXT)
2954217309Snwhitehorntest -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
2955217309Snwhitehorn])dnl
2956217309Snwhitehorndnl ---------------------------------------------------------------------------
2957217309Snwhitehorndnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2958217309Snwhitehorndnl ----------------
2959217309Snwhitehorndnl Remove all -U and -D options that refer to the given symbol from a list
2960217309Snwhitehorndnl of C compiler options.  This works around the problem that not all
2961217309Snwhitehorndnl compilers process -U and -D options from left-to-right, so a -U option
2962217309Snwhitehorndnl cannot be used to cancel the effect of a preceding -D option.
2963217309Snwhitehorndnl
2964217309Snwhitehorndnl $1 = target (which could be the same as the source variable)
2965217309Snwhitehorndnl $2 = source (including '$')
2966217309Snwhitehorndnl $3 = symbol to remove
2967217309Snwhitehorndefine([CF_REMOVE_DEFINE],
2968217309Snwhitehorn[
2969217309Snwhitehorn$1=`echo "$2" | \
2970217309Snwhitehorn	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
2971217309Snwhitehorn		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
2972217309Snwhitehorn])dnl
2973217309Snwhitehorndnl ---------------------------------------------------------------------------
2974217309Snwhitehorndnl CF_RPATH_HACK version: 8 updated: 2010/04/17 15:38:58
2975217309Snwhitehorndnl -------------
2976217309SnwhitehornAC_DEFUN([CF_RPATH_HACK],
2977217309Snwhitehorn[
2978217309SnwhitehornAC_REQUIRE([CF_LD_RPATH_OPT])
2979217309SnwhitehornAC_MSG_CHECKING(for updated LDFLAGS)
2980217309Snwhitehornif test -n "$LD_RPATH_OPT" ; then
2981217309Snwhitehorn	AC_MSG_RESULT(maybe)
2982217309Snwhitehorn
2983217309Snwhitehorn	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
2984217309Snwhitehorn	cf_rpath_list="/usr/lib /lib"
2985217309Snwhitehorn	if test "$cf_ldd_prog" != no
2986217309Snwhitehorn	then
2987217309SnwhitehornAC_TRY_LINK([#include <stdio.h>],
2988217309Snwhitehorn		[printf("Hello");],
2989217309Snwhitehorn		[cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort -u`])
2990217309Snwhitehorn	fi
2991217309Snwhitehorn
2992217309Snwhitehorn	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2993217309Snwhitehorn
2994217309Snwhitehorn	CF_RPATH_HACK_2(LDFLAGS)
2995217309Snwhitehorn	CF_RPATH_HACK_2(LIBS)
2996217309Snwhitehorn
2997217309Snwhitehorn	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2998217309Snwhitehornfi
2999217309SnwhitehornAC_SUBST(EXTRA_LDFLAGS)
3000217309Snwhitehorn])dnl
3001217309Snwhitehorndnl ---------------------------------------------------------------------------
3002217309Snwhitehorndnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
3003217309Snwhitehorndnl ---------------
3004217309Snwhitehorndnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
3005217309Snwhitehorndnl EXTRA_LDFLAGS for each -L option found.
3006217309Snwhitehorndnl
3007217309Snwhitehorndnl $cf_rpath_list contains a list of directories to ignore.
3008217309Snwhitehorndnl
3009217309Snwhitehorndnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
3010217309Snwhitehorndnl      but LIBS often has misplaced -L options.
3011217309SnwhitehornAC_DEFUN([CF_RPATH_HACK_2],
3012217309Snwhitehorn[
3013217309SnwhitehornCF_VERBOSE(...checking $1 [$]$1)
3014217309Snwhitehorn
3015217309Snwhitehorncf_rpath_dst=
3016217309Snwhitehornfor cf_rpath_src in [$]$1
3017217309Snwhitehorndo
3018217309Snwhitehorn	case $cf_rpath_src in #(vi
3019217309Snwhitehorn	-L*) #(vi
3020217309Snwhitehorn
3021217309Snwhitehorn		# check if this refers to a directory which we will ignore
3022217309Snwhitehorn		cf_rpath_skip=no
3023217309Snwhitehorn		if test -n "$cf_rpath_list"
3024217309Snwhitehorn		then
3025217309Snwhitehorn			for cf_rpath_item in $cf_rpath_list
3026217309Snwhitehorn			do
3027217309Snwhitehorn				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
3028217309Snwhitehorn				then
3029217309Snwhitehorn					cf_rpath_skip=yes
3030217309Snwhitehorn					break
3031217309Snwhitehorn				fi
3032217309Snwhitehorn			done
3033217309Snwhitehorn		fi
3034217309Snwhitehorn
3035217309Snwhitehorn		if test "$cf_rpath_skip" = no
3036217309Snwhitehorn		then
3037217309Snwhitehorn			# transform the option
3038217309Snwhitehorn			if test "$LD_RPATH_OPT" = "-R " ; then
3039217309Snwhitehorn				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
3040217309Snwhitehorn			else
3041217309Snwhitehorn				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
3042217309Snwhitehorn			fi
3043217309Snwhitehorn
3044217309Snwhitehorn			# if we have not already added this, add it now
3045217309Snwhitehorn			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
3046217309Snwhitehorn			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
3047217309Snwhitehorn			then
3048217309Snwhitehorn				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
3049217309Snwhitehorn				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
3050217309Snwhitehorn			fi
3051217309Snwhitehorn		fi
3052217309Snwhitehorn		;;
3053217309Snwhitehorn	esac
3054217309Snwhitehorn	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
3055217309Snwhitehorndone
3056217309Snwhitehorn$1=$cf_rpath_dst
3057217309Snwhitehorn
3058217309SnwhitehornCF_VERBOSE(...checked $1 [$]$1)
3059217309SnwhitehornAC_SUBST(EXTRA_LDFLAGS)
3060217309Snwhitehorn])dnl
3061217309Snwhitehorndnl ---------------------------------------------------------------------------
3062217309Snwhitehorndnl CF_SUBDIR_PATH version: 6 updated: 2010/04/21 06:20:50
3063217309Snwhitehorndnl --------------
3064217309Snwhitehorndnl Construct a search-list for a nonstandard header/lib-file
3065217309Snwhitehorndnl	$1 = the variable to return as result
3066217309Snwhitehorndnl	$2 = the package name
3067217309Snwhitehorndnl	$3 = the subdirectory, e.g., bin, include or lib
3068217309SnwhitehornAC_DEFUN([CF_SUBDIR_PATH],
3069217309Snwhitehorn[
3070217309Snwhitehorn$1=
3071217309Snwhitehorn
3072217309SnwhitehornCF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
3073217309SnwhitehornCF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
3074217309SnwhitehornCF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
3075217309SnwhitehornCF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
3076217309SnwhitehornCF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
3077217309Snwhitehorn])dnl
3078217309Snwhitehorndnl ---------------------------------------------------------------------------
3079217309Snwhitehorndnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
3080217309Snwhitehorndnl --------
3081217309Snwhitehorndnl	Shorthand macro for substituting things that the user may override
3082217309Snwhitehorndnl	with an environment variable.
3083217309Snwhitehorndnl
3084217309Snwhitehorndnl	$1 = long/descriptive name
3085217309Snwhitehorndnl	$2 = environment variable
3086217309Snwhitehorndnl	$3 = default value
3087217309SnwhitehornAC_DEFUN([CF_SUBST],
3088217309Snwhitehorn[AC_CACHE_VAL(cf_cv_subst_$2,[
3089217309SnwhitehornAC_MSG_CHECKING(for $1 (symbol $2))
3090217309SnwhitehornCF_SUBST_IF([-z "[$]$2"], [$2], [$3])
3091217309Snwhitehorncf_cv_subst_$2=[$]$2
3092217309SnwhitehornAC_MSG_RESULT([$]$2)
3093217309Snwhitehorn])
3094217309Snwhitehorn])dnl
3095217309Snwhitehorndnl ---------------------------------------------------------------------------
3096217309Snwhitehorndnl CF_SYSTYPE version: 3 updated: 2001/02/03 00:14:59
3097217309Snwhitehorndnl ----------
3098217309Snwhitehorndnl Derive the system-type (our main clue to the method of building shared
3099217309Snwhitehorndnl libraries).
3100217309SnwhitehornAC_DEFUN([CF_SYSTYPE],
3101217309Snwhitehorn[
3102217309SnwhitehornAC_MSG_CHECKING(for system type)
3103217309SnwhitehornAC_CACHE_VAL(cf_cv_systype,[
3104217309SnwhitehornAC_ARG_WITH(system-type,
3105217309Snwhitehorn[  --with-system-type=XXX  test: override derived host system-type],
3106217309Snwhitehorn[cf_cv_systype=$withval],
3107217309Snwhitehorn[
3108217309Snwhitehorncf_cv_systype="`(uname -s || hostname || echo unknown) 2>/dev/null |sed -e s'/[[:\/.-]]/_/'g  | sed 1q`"
3109217309Snwhitehornif test -z "$cf_cv_systype"; then cf_cv_systype=unknown;fi
3110217309Snwhitehorn])])
3111217309SnwhitehornAC_MSG_RESULT($cf_cv_systype)
3112217309Snwhitehorn])dnl
3113217309Snwhitehorndnl ---------------------------------------------------------------------------
3114217309Snwhitehorndnl CF_SYS_NAME version: 3 updated: 2008/03/23 14:48:54
3115217309Snwhitehorndnl -----------
3116217309Snwhitehorndnl Derive the system name, as a check for reusing the autoconf cache
3117217309SnwhitehornAC_DEFUN([CF_SYS_NAME],
3118217309Snwhitehorn[
3119217309SnwhitehornSYS_NAME=`(uname -s -r || uname -a || hostname) 2>/dev/null | sed 1q`
3120217309Snwhitehorntest -z "$SYS_NAME" && SYS_NAME=unknown
3121217309SnwhitehornAC_DEFINE_UNQUOTED(SYS_NAME,"$SYS_NAME")
3122217309Snwhitehorn
3123217309SnwhitehornAC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$SYS_NAME"])
3124217309Snwhitehorn
3125217309Snwhitehornif test ".$SYS_NAME" != ".$cf_cv_system_name" ; then
3126217309Snwhitehorn	AC_MSG_RESULT("Cached system name does not agree with actual")
3127217309Snwhitehorn	AC_MSG_ERROR("Please remove config.cache and try again.")
3128217309Snwhitehornfi])
3129217309Snwhitehorndnl ---------------------------------------------------------------------------
3130217309Snwhitehorndnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
3131217309Snwhitehorndnl --------------
3132217309Snwhitehorndnl Look for term.h, which is part of X/Open curses.  It defines the interface
3133217309Snwhitehorndnl to terminfo database.  Usually it is in the same include-path as curses.h,
3134217309Snwhitehorndnl but some packagers change this, breaking various applications.
3135217309SnwhitehornAC_DEFUN([CF_TERM_HEADER],[
3136217309SnwhitehornAC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
3137217309Snwhitehorncase ${cf_cv_ncurses_header} in #(vi
3138217309Snwhitehorn*/ncurses.h|*/ncursesw.h) #(vi
3139217309Snwhitehorn	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
3140217309Snwhitehorn	;;
3141217309Snwhitehorn*)
3142217309Snwhitehorn	cf_term_header=term.h
3143217309Snwhitehorn	;;
3144217309Snwhitehornesac
3145217309Snwhitehorn
3146217309Snwhitehornfor cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
3147217309Snwhitehorndo
3148217309SnwhitehornAC_TRY_COMPILE([#include <stdio.h>
3149217309Snwhitehorn#include <${cf_cv_ncurses_header-curses.h}>
3150217309Snwhitehorn#include <$cf_test>
3151217309Snwhitehorn],[int x = auto_left_margin],[
3152217309Snwhitehorn	cf_cv_term_header="$cf_test"],[
3153217309Snwhitehorn	cf_cv_term_header=unknown
3154217309Snwhitehorn	])
3155217309Snwhitehorn	test "$cf_cv_term_header" != unknown && break
3156217309Snwhitehorndone
3157217309Snwhitehorn])
3158217309Snwhitehorn
3159217309Snwhitehorn# Set definitions to allow ifdef'ing to accommodate subdirectories
3160217309Snwhitehorn
3161217309Snwhitehorncase $cf_cv_term_header in # (vi
3162217309Snwhitehorn*term.h)
3163217309Snwhitehorn	AC_DEFINE(HAVE_TERM_H)
3164217309Snwhitehorn	;;
3165217309Snwhitehornesac
3166217309Snwhitehorn
3167217309Snwhitehorncase $cf_cv_term_header in # (vi
3168217309Snwhitehornncurses/term.h) #(vi
3169217309Snwhitehorn	AC_DEFINE(HAVE_NCURSES_TERM_H)
3170217309Snwhitehorn	;;
3171217309Snwhitehornncursesw/term.h)
3172217309Snwhitehorn	AC_DEFINE(HAVE_NCURSESW_TERM_H)
3173217309Snwhitehorn	;;
3174217309Snwhitehornesac
3175217309Snwhitehorn])dnl
3176217309Snwhitehorndnl ---------------------------------------------------------------------------
3177217309Snwhitehorndnl CF_UNION_WAIT version: 5 updated: 1997/11/23 14:49:44
3178217309Snwhitehorndnl -------------
3179217309Snwhitehorndnl Check to see if the BSD-style union wait is declared.  Some platforms may
3180217309Snwhitehorndnl use this, though it is deprecated in favor of the 'int' type in Posix.
3181217309Snwhitehorndnl Some vendors provide a bogus implementation that declares union wait, but
3182217309Snwhitehorndnl uses the 'int' type instead; we try to spot these by checking for the
3183217309Snwhitehorndnl associated macros.
3184217309Snwhitehorndnl
3185217309Snwhitehorndnl Ahem.  Some implementers cast the status value to an int*, as an attempt to
3186217309Snwhitehorndnl use the macros for either union wait or int.  So we do a check compile to
3187217309Snwhitehorndnl see if the macros are defined and apply to an int.
3188217309Snwhitehorndnl
3189217309Snwhitehorndnl Sets: $cf_cv_type_unionwait
3190217309Snwhitehorndnl Defines: HAVE_TYPE_UNIONWAIT
3191217309SnwhitehornAC_DEFUN([CF_UNION_WAIT],
3192217309Snwhitehorn[
3193217309SnwhitehornAC_REQUIRE([CF_WAIT_HEADERS])
3194217309SnwhitehornAC_MSG_CHECKING([for union wait])
3195217309SnwhitehornAC_CACHE_VAL(cf_cv_type_unionwait,[
3196217309Snwhitehorn	AC_TRY_LINK($cf_wait_headers,
3197217309Snwhitehorn	[int x;
3198217309Snwhitehorn	 int y = WEXITSTATUS(x);
3199217309Snwhitehorn	 int z = WTERMSIG(x);
3200217309Snwhitehorn	 wait(&x);
3201217309Snwhitehorn	],
3202217309Snwhitehorn	[cf_cv_type_unionwait=no
3203217309Snwhitehorn	 echo compiles ok w/o union wait 1>&AC_FD_CC
3204217309Snwhitehorn	],[
3205217309Snwhitehorn	AC_TRY_LINK($cf_wait_headers,
3206217309Snwhitehorn	[union wait x;
3207217309Snwhitehorn#ifdef WEXITSTATUS
3208217309Snwhitehorn	 int y = WEXITSTATUS(x);
3209217309Snwhitehorn#endif
3210217309Snwhitehorn#ifdef WTERMSIG
3211217309Snwhitehorn	 int z = WTERMSIG(x);
3212217309Snwhitehorn#endif
3213217309Snwhitehorn	 wait(&x);
3214217309Snwhitehorn	],
3215217309Snwhitehorn	[cf_cv_type_unionwait=yes
3216217309Snwhitehorn	 echo compiles ok with union wait and possibly macros too 1>&AC_FD_CC
3217217309Snwhitehorn	],
3218217309Snwhitehorn	[cf_cv_type_unionwait=no])])])
3219217309SnwhitehornAC_MSG_RESULT($cf_cv_type_unionwait)
3220217309Snwhitehorntest $cf_cv_type_unionwait = yes && AC_DEFINE(HAVE_TYPE_UNIONWAIT)
3221217309Snwhitehorn])dnl
3222217309Snwhitehorndnl ---------------------------------------------------------------------------
3223217309Snwhitehorndnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3224217309Snwhitehorndnl --------
3225217309Snwhitehorndnl Make an uppercase version of a variable
3226217309Snwhitehorndnl $1=uppercase($2)
3227217309SnwhitehornAC_DEFUN([CF_UPPER],
3228217309Snwhitehorn[
3229217309Snwhitehorn$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3230217309Snwhitehorn])dnl
3231217309Snwhitehorndnl ---------------------------------------------------------------------------
3232217309Snwhitehorndnl CF_UTF8_LIB version: 6 updated: 2010/04/21 06:20:50
3233217309Snwhitehorndnl -----------
3234217309Snwhitehorndnl Check for multibyte support, and if not found, utf8 compatibility library
3235217309SnwhitehornAC_DEFUN([CF_UTF8_LIB],
3236217309Snwhitehorn[
3237217309SnwhitehornAC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3238217309Snwhitehorn	cf_save_LIBS="$LIBS"
3239217309Snwhitehorn	AC_TRY_LINK([
3240217309Snwhitehorn#include <stdlib.h>],[putwc(0,0);],
3241217309Snwhitehorn	[cf_cv_utf8_lib=yes],
3242217309Snwhitehorn	[CF_FIND_LINKAGE([
3243217309Snwhitehorn#include <libutf8.h>],[putwc(0,0);],utf8,
3244217309Snwhitehorn		[cf_cv_utf8_lib=add-on],
3245217309Snwhitehorn		[cf_cv_utf8_lib=no])
3246217309Snwhitehorn])])
3247217309Snwhitehorn
3248217309Snwhitehorn# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3249217309Snwhitehorn# ncurses/ncursesw:
3250217309Snwhitehornif test "$cf_cv_utf8_lib" = "add-on" ; then
3251217309Snwhitehorn	AC_DEFINE(HAVE_LIBUTF8_H)
3252217309Snwhitehorn	CF_ADD_INCDIR($cf_cv_header_path_utf8)
3253217309Snwhitehorn	CF_ADD_LIBDIR($cf_cv_library_path_utf8)
3254217309Snwhitehorn	LIBS="$cf_cv_library_file_utf8 $LIBS"
3255217309Snwhitehornfi
3256217309Snwhitehorn])dnl
3257217309Snwhitehorndnl ---------------------------------------------------------------------------
3258217309Snwhitehorndnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3259217309Snwhitehorndnl ----------
3260217309Snwhitehorndnl Use AC_VERBOSE w/o the warnings
3261217309SnwhitehornAC_DEFUN([CF_VERBOSE],
3262217309Snwhitehorn[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
3263217309SnwhitehornCF_MSG_LOG([$1])
3264217309Snwhitehorn])dnl
3265217309Snwhitehorndnl ---------------------------------------------------------------------------
3266217309Snwhitehorndnl CF_VERSION_INFO version: 3 updated: 2003/11/22 12:22:45
3267217309Snwhitehorndnl ---------------
3268217309Snwhitehorndnl Define several useful symbols derived from the VERSION file.  A separate
3269217309Snwhitehorndnl file is preferred to embedding the version numbers in various scripts.
3270217309Snwhitehorndnl (automake is a textbook-example of why the latter is a bad idea, but there
3271217309Snwhitehorndnl are others).
3272217309Snwhitehorndnl
3273217309Snwhitehorndnl The file contents are:
3274217309Snwhitehorndnl	libtool-version	release-version	patch-version
3275217309Snwhitehorndnl or
3276217309Snwhitehorndnl	release-version
3277217309Snwhitehorndnl where
3278217309Snwhitehorndnl	libtool-version (see ?) consists of 3 integers separated by '.'
3279217309Snwhitehorndnl	release-version consists of a major version and minor version
3280217309Snwhitehorndnl		separated by '.', optionally followed by a patch-version
3281217309Snwhitehorndnl		separated by '-'.  The minor version need not be an
3282217309Snwhitehorndnl		integer (but it is preferred).
3283217309Snwhitehorndnl	patch-version is an integer in the form yyyymmdd, so ifdef's and
3284217309Snwhitehorndnl		scripts can easily compare versions.
3285217309Snwhitehorndnl
3286217309Snwhitehorndnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
3287217309Snwhitehorndnl simply extracts the first field using 'cut -f1'.
3288217309SnwhitehornAC_DEFUN([CF_VERSION_INFO],
3289217309Snwhitehorn[
3290217309Snwhitehornif test -f $srcdir/VERSION ; then
3291217309Snwhitehorn	AC_MSG_CHECKING(for package version)
3292217309Snwhitehorn
3293217309Snwhitehorn	# if there are not enough fields, cut returns the last one...
3294217309Snwhitehorn	cf_field1=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
3295217309Snwhitehorn	cf_field2=`sed -e '2,$d' $srcdir/VERSION|cut -f2`
3296217309Snwhitehorn	cf_field3=`sed -e '2,$d' $srcdir/VERSION|cut -f3`
3297217309Snwhitehorn
3298217309Snwhitehorn	# this is how CF_BUNDLED_INTL uses $VERSION:
3299217309Snwhitehorn	VERSION="$cf_field1"
3300217309Snwhitehorn
3301217309Snwhitehorn	VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
3302217309Snwhitehorn	test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version)
3303217309Snwhitehorn
3304217309Snwhitehorn	VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'`
3305217309Snwhitehorn	test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version)
3306217309Snwhitehorn
3307217309Snwhitehorn	AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR})
3308217309Snwhitehorn
3309217309Snwhitehorn	AC_MSG_CHECKING(for package patch date)
3310217309Snwhitehorn	VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'`
3311217309Snwhitehorn	case .$VERSION_PATCH in
3312217309Snwhitehorn	.)
3313217309Snwhitehorn		AC_MSG_ERROR(missing patch-date $VERSION_PATCH)
3314217309Snwhitehorn		;;
3315217309Snwhitehorn	.[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
3316217309Snwhitehorn		;;
3317217309Snwhitehorn	*)
3318217309Snwhitehorn		AC_MSG_ERROR(illegal patch-date $VERSION_PATCH)
3319217309Snwhitehorn		;;
3320217309Snwhitehorn	esac
3321217309Snwhitehorn	AC_MSG_RESULT($VERSION_PATCH)
3322217309Snwhitehornelse
3323217309Snwhitehorn	AC_MSG_ERROR(did not find $srcdir/VERSION)
3324217309Snwhitehornfi
3325217309Snwhitehorn
3326217309Snwhitehorn# show the actual data that we have for versions:
3327217309SnwhitehornCF_VERBOSE(VERSION $VERSION)
3328217309SnwhitehornCF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
3329217309SnwhitehornCF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
3330217309SnwhitehornCF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
3331217309Snwhitehorn
3332217309SnwhitehornAC_SUBST(VERSION)
3333217309SnwhitehornAC_SUBST(VERSION_MAJOR)
3334217309SnwhitehornAC_SUBST(VERSION_MINOR)
3335217309SnwhitehornAC_SUBST(VERSION_PATCH)
3336217309Snwhitehorn
3337217309Snwhitehorndnl if a package name is given, define its corresponding version info.  We
3338217309Snwhitehorndnl need the package name to ensure that the defined symbols are unique.
3339217309Snwhitehornifelse($1,,,[
3340217309Snwhitehorn	PACKAGE=$1
3341217309Snwhitehorn	AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
3342217309Snwhitehorn	AC_SUBST(PACKAGE)
3343217309Snwhitehorn	CF_UPPER(cf_PACKAGE,$PACKAGE)
3344217309Snwhitehorn	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}")
3345217309Snwhitehorn	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_PATCHDATE,${VERSION_PATCH})
3346217309Snwhitehorn])
3347217309Snwhitehorn])dnl
3348217309Snwhitehorndnl ---------------------------------------------------------------------------
3349217309Snwhitehorndnl CF_WAIT_HEADERS version: 2 updated: 1997/10/21 19:45:33
3350217309Snwhitehorndnl ---------------
3351217309Snwhitehorndnl Build up an expression $cf_wait_headers with the header files needed to
3352217309Snwhitehorndnl compile against the prototypes for 'wait()', 'waitpid()', etc.  Assume it's
3353217309Snwhitehorndnl Posix, which uses <sys/types.h> and <sys/wait.h>, but allow SVr4 variation
3354217309Snwhitehorndnl with <wait.h>.
3355217309SnwhitehornAC_DEFUN([CF_WAIT_HEADERS],
3356217309Snwhitehorn[
3357217309SnwhitehornAC_HAVE_HEADERS(sys/wait.h)
3358217309Snwhitehorncf_wait_headers="#include <sys/types.h>
3359217309Snwhitehorn"
3360217309Snwhitehornif test $ac_cv_header_sys_wait_h = yes; then
3361217309Snwhitehorncf_wait_headers="$cf_wait_headers
3362217309Snwhitehorn#include <sys/wait.h>
3363217309Snwhitehorn"
3364217309Snwhitehornelse
3365217309SnwhitehornAC_HAVE_HEADERS(wait.h)
3366217309SnwhitehornAC_HAVE_HEADERS(waitstatus.h)
3367217309Snwhitehornif test $ac_cv_header_wait_h = yes; then
3368217309Snwhitehorncf_wait_headers="$cf_wait_headers
3369217309Snwhitehorn#include <wait.h>
3370217309Snwhitehorn"
3371217309Snwhitehornfi
3372217309Snwhitehornif test $ac_cv_header_waitstatus_h = yes; then
3373217309Snwhitehorncf_wait_headers="$cf_wait_headers
3374217309Snwhitehorn#include <waitstatus.h>
3375217309Snwhitehorn"
3376217309Snwhitehornfi
3377217309Snwhitehornfi
3378217309Snwhitehorn])dnl
3379217309Snwhitehorndnl ---------------------------------------------------------------------------
3380217309Snwhitehorndnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
3381217309Snwhitehorndnl ------------------
3382217309Snwhitehorndnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3383217309Snwhitehorndnl libraries.
3384217309SnwhitehornAC_DEFUN([CF_WITH_CURSES_DIR],[
3385217309SnwhitehornAC_ARG_WITH(curses-dir,
3386217309Snwhitehorn	[  --with-curses-dir=DIR   directory in which (n)curses is installed],
3387217309Snwhitehorn	[CF_PATH_SYNTAX(withval)
3388217309Snwhitehorn	 cf_cv_curses_dir=$withval],
3389217309Snwhitehorn	[cf_cv_curses_dir=no])
3390217309Snwhitehorn])dnl
3391217309Snwhitehorndnl ---------------------------------------------------------------------------
3392217309Snwhitehorndnl CF_WITH_DBMALLOC version: 6 updated: 2006/12/16 14:24:05
3393217309Snwhitehorndnl ----------------
3394217309Snwhitehorndnl Configure-option for dbmalloc.  The optional parameter is used to override
3395217309Snwhitehorndnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3396217309SnwhitehornAC_DEFUN([CF_WITH_DBMALLOC],[
3397217309SnwhitehornCF_NO_LEAKS_OPTION(dbmalloc,
3398217309Snwhitehorn	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3399217309Snwhitehorn	[USE_DBMALLOC])
3400217309Snwhitehorn
3401217309Snwhitehornif test "$with_dbmalloc" = yes ; then
3402217309Snwhitehorn	AC_CHECK_HEADER(dbmalloc.h,
3403217309Snwhitehorn		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))])
3404217309Snwhitehornfi
3405217309Snwhitehorn])dnl
3406217309Snwhitehorndnl ---------------------------------------------------------------------------
3407217309Snwhitehorndnl CF_WITH_DMALLOC version: 6 updated: 2006/12/16 14:24:05
3408217309Snwhitehorndnl ---------------
3409217309Snwhitehorndnl Configure-option for dmalloc.  The optional parameter is used to override
3410217309Snwhitehorndnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3411217309SnwhitehornAC_DEFUN([CF_WITH_DMALLOC],[
3412217309SnwhitehornCF_NO_LEAKS_OPTION(dmalloc,
3413217309Snwhitehorn	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
3414217309Snwhitehorn	[USE_DMALLOC])
3415217309Snwhitehorn
3416217309Snwhitehornif test "$with_dmalloc" = yes ; then
3417217309Snwhitehorn	AC_CHECK_HEADER(dmalloc.h,
3418217309Snwhitehorn		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))])
3419217309Snwhitehornfi
3420217309Snwhitehorn])dnl
3421217309Snwhitehorndnl ---------------------------------------------------------------------------
3422217309Snwhitehorndnl CF_WITH_LIBTOOL version: 23 updated: 2009/03/28 14:26:27
3423217309Snwhitehorndnl ---------------
3424217309Snwhitehorndnl Provide a configure option to incorporate libtool.  Define several useful
3425217309Snwhitehorndnl symbols for the makefile rules.
3426217309Snwhitehorndnl
3427217309Snwhitehorndnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
3428217309Snwhitehorndnl macros from libtool.m4 which is in the aclocal directory of automake.
3429217309Snwhitehorndnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
3430217309Snwhitehorndnl But that still does not work properly since the macro is expanded outside
3431217309Snwhitehorndnl the CF_WITH_LIBTOOL macro:
3432217309Snwhitehorndnl
3433217309Snwhitehorndnl	#!/bin/sh
3434217309Snwhitehorndnl	ACLOCAL=`aclocal --print-ac-dir`
3435217309Snwhitehorndnl	if test -z "$ACLOCAL" ; then
3436217309Snwhitehorndnl		echo cannot find aclocal directory
3437217309Snwhitehorndnl		exit 1
3438217309Snwhitehorndnl	elif test ! -f $ACLOCAL/libtool.m4 ; then
3439217309Snwhitehorndnl		echo cannot find libtool.m4 file
3440217309Snwhitehorndnl		exit 1
3441217309Snwhitehorndnl	fi
3442217309Snwhitehorndnl
3443217309Snwhitehorndnl	LOCAL=aclocal.m4
3444217309Snwhitehorndnl	ORIG=aclocal.m4.orig
3445217309Snwhitehorndnl
3446217309Snwhitehorndnl	trap "mv $ORIG $LOCAL" 0 1 2 5 15
3447217309Snwhitehorndnl	rm -f $ORIG
3448217309Snwhitehorndnl	mv $LOCAL $ORIG
3449217309Snwhitehorndnl
3450217309Snwhitehorndnl	# sed the LIBTOOL= assignment to omit the current directory?
3451217309Snwhitehorndnl	sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
3452217309Snwhitehorndnl	cat $ORIG >>$LOCAL
3453217309Snwhitehorndnl
3454217309Snwhitehorndnl	autoconf-257 $*
3455217309Snwhitehorndnl
3456217309SnwhitehornAC_DEFUN([CF_WITH_LIBTOOL],
3457217309Snwhitehorn[
3458217309Snwhitehornifdef([AC_PROG_LIBTOOL],,[
3459217309SnwhitehornLIBTOOL=
3460217309Snwhitehorn])
3461217309Snwhitehorn# common library maintenance symbols that are convenient for libtool scripts:
3462217309SnwhitehornLIB_CREATE='${AR} -cr'
3463217309SnwhitehornLIB_OBJECT='${OBJECTS}'
3464217309SnwhitehornLIB_SUFFIX=.a
3465217309SnwhitehornLIB_PREP="$RANLIB"
3466217309Snwhitehorn
3467217309Snwhitehorn# symbols used to prop libtool up to enable it to determine what it should be
3468217309Snwhitehorn# doing:
3469217309SnwhitehornLIB_CLEAN=
3470217309SnwhitehornLIB_COMPILE=
3471217309SnwhitehornLIB_LINK='${CC}'
3472217309SnwhitehornLIB_INSTALL=
3473217309SnwhitehornLIB_UNINSTALL=
3474217309Snwhitehorn
3475217309SnwhitehornAC_MSG_CHECKING(if you want to build libraries with libtool)
3476217309SnwhitehornAC_ARG_WITH(libtool,
3477217309Snwhitehorn	[  --with-libtool          generate libraries with libtool],
3478217309Snwhitehorn	[with_libtool=$withval],
3479217309Snwhitehorn	[with_libtool=no])
3480217309SnwhitehornAC_MSG_RESULT($with_libtool)
3481217309Snwhitehornif test "$with_libtool" != "no"; then
3482217309Snwhitehornifdef([AC_PROG_LIBTOOL],[
3483217309Snwhitehorn	# missing_content_AC_PROG_LIBTOOL{{
3484217309Snwhitehorn	AC_PROG_LIBTOOL
3485217309Snwhitehorn	# missing_content_AC_PROG_LIBTOOL}}
3486217309Snwhitehorn],[
3487217309Snwhitehorn	if test "$with_libtool" != "yes" ; then
3488217309Snwhitehorn		CF_PATH_SYNTAX(with_libtool)
3489217309Snwhitehorn		LIBTOOL=$with_libtool
3490217309Snwhitehorn	else
3491217309Snwhitehorn		AC_PATH_PROG(LIBTOOL,libtool)
3492217309Snwhitehorn	fi
3493217309Snwhitehorn	if test -z "$LIBTOOL" ; then
3494217309Snwhitehorn		AC_MSG_ERROR(Cannot find libtool)
3495217309Snwhitehorn	fi
3496217309Snwhitehorn])dnl
3497217309Snwhitehorn	LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${DESTDIR}${libdir} -version-info `cut -f1 ${srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} -o'
3498217309Snwhitehorn	LIB_OBJECT='${OBJECTS:.o=.lo}'
3499217309Snwhitehorn	LIB_SUFFIX=.la
3500217309Snwhitehorn	LIB_CLEAN='${LIBTOOL} --mode=clean'
3501217309Snwhitehorn	LIB_COMPILE='${LIBTOOL} --mode=compile'
3502217309Snwhitehorn	LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
3503217309Snwhitehorn	LIB_INSTALL='${LIBTOOL} --mode=install'
3504217309Snwhitehorn	LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
3505217309Snwhitehorn	LIB_PREP=:
3506217309Snwhitehorn
3507217309Snwhitehorn	# Show the version of libtool
3508217309Snwhitehorn	AC_MSG_CHECKING(version of libtool)
3509217309Snwhitehorn
3510217309Snwhitehorn	# Save the version in a cache variable - this is not entirely a good
3511217309Snwhitehorn	# thing, but the version string from libtool is very ugly, and for
3512217309Snwhitehorn	# bug reports it might be useful to have the original string. "("
3513217309Snwhitehorn	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.]].*//'`
3514217309Snwhitehorn	AC_MSG_RESULT($cf_cv_libtool_version)
3515217309Snwhitehorn	if test -z "$cf_cv_libtool_version" ; then
3516217309Snwhitehorn		AC_MSG_ERROR(This is not GNU libtool)
3517217309Snwhitehorn	fi
3518217309Snwhitehorn
3519217309Snwhitehorn	# special hack to add -no-undefined (which libtool should do for itself)
3520217309Snwhitehorn	LT_UNDEF=
3521217309Snwhitehorn	case "$cf_cv_system_name" in #(vi
3522217309Snwhitehorn	cygwin*|mingw32*|uwin*|aix[[456]]) #(vi
3523217309Snwhitehorn		LT_UNDEF=-no-undefined
3524217309Snwhitehorn		;;
3525217309Snwhitehorn	esac
3526217309Snwhitehorn	AC_SUBST([LT_UNDEF])
3527217309Snwhitehorn
3528217309Snwhitehorn	# special hack to add --tag option for C++ compiler
3529217309Snwhitehorn	case $cf_cv_libtool_version in #(vi
3530217309Snwhitehorn	1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*) #(vi
3531217309Snwhitehorn		LIBTOOL_CXX="$LIBTOOL --tag=CXX"
3532217309Snwhitehorn		LIBTOOL="$LIBTOOL --tag=CC"
3533217309Snwhitehorn		;;
3534217309Snwhitehorn	*)
3535217309Snwhitehorn		LIBTOOL_CXX="$LIBTOOL"
3536217309Snwhitehorn		;;
3537217309Snwhitehorn	esac
3538217309Snwhitehornelse
3539217309Snwhitehorn	LIBTOOL=""
3540217309Snwhitehorn	LIBTOOL_CXX=""
3541217309Snwhitehornfi
3542217309Snwhitehorn
3543217309Snwhitehorntest -z "$LIBTOOL" && ECHO_LT=
3544217309Snwhitehorn
3545217309SnwhitehornAC_SUBST(LIBTOOL)
3546217309SnwhitehornAC_SUBST(LIBTOOL_CXX)
3547217309SnwhitehornAC_SUBST(LIBTOOL_OPTS)
3548217309Snwhitehorn
3549217309SnwhitehornAC_SUBST(LIB_CREATE)
3550217309SnwhitehornAC_SUBST(LIB_OBJECT)
3551217309SnwhitehornAC_SUBST(LIB_SUFFIX)
3552217309SnwhitehornAC_SUBST(LIB_PREP)
3553217309Snwhitehorn
3554217309SnwhitehornAC_SUBST(LIB_CLEAN)
3555217309SnwhitehornAC_SUBST(LIB_COMPILE)
3556217309SnwhitehornAC_SUBST(LIB_LINK)
3557217309SnwhitehornAC_SUBST(LIB_INSTALL)
3558217309SnwhitehornAC_SUBST(LIB_UNINSTALL)
3559217309Snwhitehorn
3560217309Snwhitehorn])dnl
3561217309Snwhitehorndnl ---------------------------------------------------------------------------
3562217309Snwhitehorndnl CF_WITH_LIBTOOL_OPTS version: 2 updated: 2007/04/08 18:14:54
3563217309Snwhitehorndnl --------------------
3564217309Snwhitehorndnl Allow user to pass additional libtool options into the library creation
3565217309Snwhitehorndnl and link steps.  The main use for this is to do something like
3566217309Snwhitehorndnl	./configure --with-libtool-opts=-static
3567217309Snwhitehorndnl to get the same behavior as automake-flavored
3568217309Snwhitehorndnl	./configure --enable-static
3569217309SnwhitehornAC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
3570217309SnwhitehornAC_MSG_CHECKING(for additional libtool options)
3571217309SnwhitehornAC_ARG_WITH(libtool-opts,
3572217309Snwhitehorn	[  --with-libtool-opts=XXX specify additional libtool options],
3573217309Snwhitehorn	[with_libtool_opts=$withval],
3574217309Snwhitehorn	[with_libtool_opts=no])
3575217309SnwhitehornAC_MSG_RESULT($with_libtool_opts)
3576217309Snwhitehorn
3577217309Snwhitehorncase .$with_libtool_opts in
3578217309Snwhitehorn.yes|.no|.)
3579217309Snwhitehorn	;;
3580217309Snwhitehorn*)
3581217309Snwhitehorn	LIBTOOL_OPTS=$with_libtool_opts
3582217309Snwhitehorn	;;
3583217309Snwhitehornesac
3584217309Snwhitehorn
3585217309SnwhitehornAC_SUBST(LIBTOOL_OPTS)
3586217309Snwhitehorn])dnl
3587217309Snwhitehorndnl ---------------------------------------------------------------------------
3588217309Snwhitehorndnl CF_WITH_NO_LEAKS version: 1 updated: 2006/12/14 18:00:21
3589217309Snwhitehorndnl ----------------
3590217309SnwhitehornAC_DEFUN([CF_WITH_NO_LEAKS],[
3591217309Snwhitehorn
3592217309SnwhitehornAC_REQUIRE([CF_WITH_DMALLOC])
3593217309SnwhitehornAC_REQUIRE([CF_WITH_DBMALLOC])
3594217309SnwhitehornAC_REQUIRE([CF_WITH_PURIFY])
3595217309SnwhitehornAC_REQUIRE([CF_WITH_VALGRIND])
3596217309Snwhitehorn
3597217309SnwhitehornAC_MSG_CHECKING(if you want to perform memory-leak testing)
3598217309SnwhitehornAC_ARG_WITH(no-leaks,
3599217309Snwhitehorn	[  --with-no-leaks         test: free permanent memory, analyze leaks],
3600217309Snwhitehorn	[AC_DEFINE(NO_LEAKS)
3601217309Snwhitehorn	 cf_doalloc=".${with_dmalloc}${with_dbmalloc}${with_purify}${with_valgrind}"
3602217309Snwhitehorn	 case ${cf_doalloc} in #(vi
3603217309Snwhitehorn	 *yes*) ;;
3604217309Snwhitehorn	 *) AC_DEFINE(DOALLOC,10000) ;;
3605217309Snwhitehorn	 esac
3606217309Snwhitehorn	 with_no_leaks=yes],
3607217309Snwhitehorn	[with_no_leaks=])
3608217309SnwhitehornAC_MSG_RESULT($with_no_leaks)
3609217309Snwhitehorn])dnl
3610217309Snwhitehorndnl ---------------------------------------------------------------------------
3611217309Snwhitehorndnl CF_WITH_PURIFY version: 2 updated: 2006/12/14 18:43:43
3612217309Snwhitehorndnl --------------
3613217309SnwhitehornAC_DEFUN([CF_WITH_PURIFY],[
3614217309SnwhitehornCF_NO_LEAKS_OPTION(purify,
3615217309Snwhitehorn	[  --with-purify           test: use Purify],
3616217309Snwhitehorn	[USE_PURIFY],
3617217309Snwhitehorn	[LINK_PREFIX="$LINK_PREFIX purify"])
3618217309SnwhitehornAC_SUBST(LINK_PREFIX)
3619217309Snwhitehorn])dnl
3620217309Snwhitehorndnl ---------------------------------------------------------------------------
3621217309Snwhitehorndnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3622217309Snwhitehorndnl ----------------
3623217309SnwhitehornAC_DEFUN([CF_WITH_VALGRIND],[
3624217309SnwhitehornCF_NO_LEAKS_OPTION(valgrind,
3625217309Snwhitehorn	[  --with-valgrind         test: use valgrind],
3626217309Snwhitehorn	[USE_VALGRIND])
3627217309Snwhitehorn])dnl
3628217309Snwhitehorndnl ---------------------------------------------------------------------------
3629217309Snwhitehorndnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
3630217309Snwhitehorndnl ----------------
3631217309Snwhitehorndnl Combine the checks for gcc features into a configure-script option
3632217309Snwhitehorndnl
3633217309Snwhitehorndnl Parameters:
3634217309Snwhitehorndnl	$1 - see CF_GCC_WARNINGS
3635217309SnwhitehornAC_DEFUN([CF_WITH_WARNINGS],
3636217309Snwhitehorn[
3637217309Snwhitehornif ( test "$GCC" = yes || test "$GXX" = yes )
3638217309Snwhitehornthen
3639217309SnwhitehornAC_MSG_CHECKING(if you want to check for gcc warnings)
3640217309SnwhitehornAC_ARG_WITH(warnings,
3641217309Snwhitehorn	[  --with-warnings         test: turn on gcc warnings],
3642217309Snwhitehorn	[cf_opt_with_warnings=$withval],
3643217309Snwhitehorn	[cf_opt_with_warnings=no])
3644217309SnwhitehornAC_MSG_RESULT($cf_opt_with_warnings)
3645217309Snwhitehornif test "$cf_opt_with_warnings" != no ; then
3646217309Snwhitehorn	CF_GCC_ATTRIBUTES
3647217309Snwhitehorn	CF_GCC_WARNINGS([$1])
3648217309Snwhitehornfi
3649217309Snwhitehornfi
3650217309Snwhitehorn])dnl
3651217309Snwhitehorndnl ---------------------------------------------------------------------------
3652217309Snwhitehorndnl CF_XOPEN_CURSES version: 9 updated: 2010/04/28 06:02:16
3653217309Snwhitehorndnl ---------------
3654217309Snwhitehorndnl Test if we should define X/Open source for curses, needed on Digital Unix
3655217309Snwhitehorndnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
3656217309Snwhitehorndnl
3657217309Snwhitehorndnl The getbegyx() check is needed for HPUX, which omits legacy macros such
3658217309Snwhitehorndnl as getbegy().  The latter is better design, but the former is standard.
3659217309SnwhitehornAC_DEFUN([CF_XOPEN_CURSES],
3660217309Snwhitehorn[
3661217309SnwhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3662217309SnwhitehornAC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
3663217309SnwhitehornAC_TRY_LINK([
3664217309Snwhitehorn#include <stdlib.h>
3665217309Snwhitehorn#include <${cf_cv_ncurses_header-curses.h}>],[
3666217309Snwhitehorn#if defined(NCURSES_VERSION_PATCH)
3667217309Snwhitehornif (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
3668217309Snwhitehorn	make an error
3669217309Snwhitehorn#endif
3670217309Snwhitehorn#endif
3671217309Snwhitehorn	long x = winnstr(stdscr, "", 0);
3672217309Snwhitehorn	int x1, y1;
3673217309Snwhitehorn	getbegyx(stdscr, y1, x1)],
3674217309Snwhitehorn	[cf_cv_need_xopen_extension=no],
3675217309Snwhitehorn	[AC_TRY_LINK([
3676217309Snwhitehorn#define _XOPEN_SOURCE_EXTENDED
3677217309Snwhitehorn#include <stdlib.h>
3678217309Snwhitehorn#include <${cf_cv_ncurses_header-curses.h}>],[
3679217309Snwhitehorn#ifdef NCURSES_VERSION
3680217309Snwhitehorn	cchar_t check;
3681217309Snwhitehorn	int check2 = curs_set((int)sizeof(check));
3682217309Snwhitehorn#endif
3683217309Snwhitehorn	long x = winnstr(stdscr, "", 0);
3684217309Snwhitehorn	int x1, y1;
3685217309Snwhitehorn	getbegyx(stdscr, y1, x1)],
3686217309Snwhitehorn	[cf_cv_need_xopen_extension=yes],
3687217309Snwhitehorn	[cf_cv_need_xopen_extension=unknown])])])
3688217309Snwhitehorntest $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
3689217309Snwhitehorn])dnl
3690217309Snwhitehorndnl ---------------------------------------------------------------------------
3691217309Snwhitehorndnl CF_XOPEN_SOURCE version: 33 updated: 2010/03/28 15:35:52
3692217309Snwhitehorndnl ---------------
3693217309Snwhitehorndnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3694217309Snwhitehorndnl or adapt to the vendor's definitions to get equivalent functionality,
3695217309Snwhitehorndnl without losing the common non-POSIX features.
3696217309Snwhitehorndnl
3697217309Snwhitehorndnl Parameters:
3698217309Snwhitehorndnl	$1 is the nominal value for _XOPEN_SOURCE
3699217309Snwhitehorndnl	$2 is the nominal value for _POSIX_C_SOURCE
3700217309SnwhitehornAC_DEFUN([CF_XOPEN_SOURCE],[
3701217309Snwhitehorn
3702217309Snwhitehorncf_XOPEN_SOURCE=ifelse($1,,500,$1)
3703217309Snwhitehorncf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
3704217309Snwhitehorncf_xopen_source=
3705217309Snwhitehorn
3706217309Snwhitehorncase $host_os in #(vi
3707217309Snwhitehornaix[[456]]*) #(vi
3708217309Snwhitehorn	cf_xopen_source="-D_ALL_SOURCE"
3709217309Snwhitehorn	;;
3710217309Snwhitehorndarwin[[0-8]].*) #(vi
3711217309Snwhitehorn	cf_xopen_source="-D_APPLE_C_SOURCE"
3712217309Snwhitehorn	;;
3713217309Snwhitehorndarwin*) #(vi
3714217309Snwhitehorn	cf_xopen_source="-D_DARWIN_C_SOURCE"
3715217309Snwhitehorn	;;
3716217309Snwhitehornfreebsd*|dragonfly*) #(vi
3717217309Snwhitehorn	# 5.x headers associate
3718217309Snwhitehorn	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3719217309Snwhitehorn	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3720217309Snwhitehorn	cf_POSIX_C_SOURCE=200112L
3721217309Snwhitehorn	cf_XOPEN_SOURCE=600
3722217309Snwhitehorn	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3723217309Snwhitehorn	;;
3724217309Snwhitehornhpux11*) #(vi
3725217309Snwhitehorn	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3726217309Snwhitehorn	;;
3727217309Snwhitehornhpux*) #(vi
3728217309Snwhitehorn	cf_xopen_source="-D_HPUX_SOURCE"
3729217309Snwhitehorn	;;
3730217309Snwhitehornirix[[56]].*) #(vi
3731217309Snwhitehorn	cf_xopen_source="-D_SGI_SOURCE"
3732217309Snwhitehorn	;;
3733217309Snwhitehornlinux*|gnu*|mint*|k*bsd*-gnu) #(vi
3734217309Snwhitehorn	CF_GNU_SOURCE
3735217309Snwhitehorn	;;
3736217309Snwhitehornmirbsd*) #(vi
3737217309Snwhitehorn	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
3738217309Snwhitehorn	;;
3739217309Snwhitehornnetbsd*) #(vi
3740217309Snwhitehorn	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3741217309Snwhitehorn	;;
3742217309Snwhitehornopenbsd*) #(vi
3743217309Snwhitehorn	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3744217309Snwhitehorn	;;
3745217309Snwhitehornosf[[45]]*) #(vi
3746217309Snwhitehorn	cf_xopen_source="-D_OSF_SOURCE"
3747217309Snwhitehorn	;;
3748217309Snwhitehornnto-qnx*) #(vi
3749217309Snwhitehorn	cf_xopen_source="-D_QNX_SOURCE"
3750217309Snwhitehorn	;;
3751217309Snwhitehornsco*) #(vi
3752217309Snwhitehorn	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3753217309Snwhitehorn	;;
3754217309Snwhitehornsolaris2.1[[0-9]]) #(vi
3755217309Snwhitehorn	cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3756217309Snwhitehorn	;;
3757217309Snwhitehornsolaris2.[[1-9]]) #(vi
3758217309Snwhitehorn	cf_xopen_source="-D__EXTENSIONS__"
3759217309Snwhitehorn	;;
3760217309Snwhitehorn*)
3761217309Snwhitehorn	AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
3762217309Snwhitehorn	AC_TRY_COMPILE([#include <sys/types.h>],[
3763217309Snwhitehorn#ifndef _XOPEN_SOURCE
3764217309Snwhitehornmake an error
3765217309Snwhitehorn#endif],
3766217309Snwhitehorn	[cf_cv_xopen_source=no],
3767217309Snwhitehorn	[cf_save="$CPPFLAGS"
3768217309Snwhitehorn	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3769217309Snwhitehorn	 AC_TRY_COMPILE([#include <sys/types.h>],[
3770217309Snwhitehorn#ifdef _XOPEN_SOURCE
3771217309Snwhitehornmake an error
3772217309Snwhitehorn#endif],
3773217309Snwhitehorn	[cf_cv_xopen_source=no],
3774217309Snwhitehorn	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3775217309Snwhitehorn	CPPFLAGS="$cf_save"
3776217309Snwhitehorn	])
3777217309Snwhitehorn])
3778217309Snwhitehorn	if test "$cf_cv_xopen_source" != no ; then
3779217309Snwhitehorn		CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3780217309Snwhitehorn		CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3781217309Snwhitehorn		cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3782217309Snwhitehorn		CF_ADD_CFLAGS($cf_temp_xopen_source)
3783217309Snwhitehorn	fi
3784217309Snwhitehorn	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3785217309Snwhitehorn	;;
3786217309Snwhitehornesac
3787217309Snwhitehorn
3788217309Snwhitehornif test -n "$cf_xopen_source" ; then
3789217309Snwhitehorn	CF_ADD_CFLAGS($cf_xopen_source)
3790217309Snwhitehornfi
3791217309Snwhitehorn])
3792217309Snwhitehorndnl ---------------------------------------------------------------------------
3793217309Snwhitehorndnl CF__CURSES_HEAD version: 1 updated: 2009/07/16 19:32:31
3794217309Snwhitehorndnl ---------------
3795217309Snwhitehorndnl Define a reusable chunk which includes <curses.h> and <term.h> when they
3796217309Snwhitehorndnl are both available.
3797217309Snwhitehorndefine([CF__CURSES_HEAD],[
3798217309Snwhitehorn#ifdef HAVE_XCURSES
3799217309Snwhitehorn#include <xcurses.h>
3800217309Snwhitehornchar * XCursesProgramName = "test";
3801217309Snwhitehorn#else
3802217309Snwhitehorn#include <${cf_cv_ncurses_header-curses.h}>
3803217309Snwhitehorn#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
3804217309Snwhitehorn#include <ncursesw/term.h>
3805217309Snwhitehorn#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
3806217309Snwhitehorn#include <ncurses/term.h>
3807217309Snwhitehorn#elif defined(HAVE_TERM_H)
3808217309Snwhitehorn#include <term.h>
3809217309Snwhitehorn#endif
3810217309Snwhitehorn#endif
3811217309Snwhitehorn])
3812217309Snwhitehorndnl ---------------------------------------------------------------------------
3813217309Snwhitehorndnl CF__ICONV_BODY version: 2 updated: 2007/07/26 17:35:47
3814217309Snwhitehorndnl --------------
3815217309Snwhitehorndnl Test-code needed for iconv compile-checks
3816217309Snwhitehorndefine([CF__ICONV_BODY],[
3817217309Snwhitehorn	iconv_t cd = iconv_open("","");
3818217309Snwhitehorn	iconv(cd,NULL,NULL,NULL,NULL);
3819217309Snwhitehorn	iconv_close(cd);]
3820217309Snwhitehorn)dnl
3821217309Snwhitehorndnl ---------------------------------------------------------------------------
3822217309Snwhitehorndnl CF__ICONV_HEAD version: 1 updated: 2007/07/26 15:57:03
3823217309Snwhitehorndnl --------------
3824217309Snwhitehorndnl Header-files needed for iconv compile-checks
3825217309Snwhitehorndefine([CF__ICONV_HEAD],[
3826217309Snwhitehorn#include <stdlib.h>
3827217309Snwhitehorn#include <iconv.h>]
3828217309Snwhitehorn)dnl
3829217309Snwhitehorndnl ---------------------------------------------------------------------------
3830217309Snwhitehorndnl CF__INTL_BODY version: 1 updated: 2007/07/26 17:35:47
3831217309Snwhitehorndnl -------------
3832217309Snwhitehorndnl Test-code needed for libintl compile-checks
3833217309Snwhitehorndnl $1 = parameter 2 from AM_WITH_NLS
3834217309Snwhitehorndefine([CF__INTL_BODY],[
3835217309Snwhitehorn    bindtextdomain ("", "");
3836217309Snwhitehorn    return (int) gettext ("")
3837217309Snwhitehorn            ifelse([$1], need-ngettext, [ + (int) ngettext ("", "", 0)], [])
3838217309Snwhitehorn            [ + _nl_msg_cat_cntr]
3839217309Snwhitehorn])
3840217309Snwhitehorndnl ---------------------------------------------------------------------------
3841217309Snwhitehorndnl CF__INTL_HEAD version: 1 updated: 2007/07/26 17:35:47
3842217309Snwhitehorndnl -------------
3843217309Snwhitehorndnl Header-files needed for libintl compile-checks
3844217309Snwhitehorndefine([CF__INTL_HEAD],[
3845217309Snwhitehorn#include <libintl.h>
3846217309Snwhitehornextern int _nl_msg_cat_cntr;
3847217309Snwhitehorn])dnl
3848217309Snwhitehorndnl ---------------------------------------------------------------------------
3849217309Snwhitehorndnl jm_GLIBC21 version: 3 updated: 2002/10/27 23:21:42
3850217309Snwhitehorndnl ----------
3851217309Snwhitehorndnl Inserted as requested by gettext 0.10.40
3852217309Snwhitehorndnl File from /usr/share/aclocal
3853217309Snwhitehorndnl glibc21.m4
3854217309Snwhitehorndnl ====================
3855217309Snwhitehorndnl serial 2
3856217309Snwhitehorndnl
3857217309Snwhitehorndnl Test for the GNU C Library, version 2.1 or newer.
3858217309Snwhitehorndnl From Bruno Haible.
3859217309SnwhitehornAC_DEFUN([jm_GLIBC21],
3860217309Snwhitehorn  [
3861217309Snwhitehorn    AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
3862217309Snwhitehorn      ac_cv_gnu_library_2_1,
3863217309Snwhitehorn      [AC_EGREP_CPP([Lucky GNU user],
3864217309Snwhitehorn	[
3865217309Snwhitehorn#include <features.h>
3866217309Snwhitehorn#ifdef __GNU_LIBRARY__
3867217309Snwhitehorn #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
3868217309Snwhitehorn  Lucky GNU user
3869217309Snwhitehorn #endif
3870217309Snwhitehorn#endif
3871217309Snwhitehorn	],
3872217309Snwhitehorn	ac_cv_gnu_library_2_1=yes,
3873217309Snwhitehorn	ac_cv_gnu_library_2_1=no)
3874217309Snwhitehorn      ]
3875217309Snwhitehorn    )
3876217309Snwhitehorn    AC_SUBST(GLIBC21)
3877217309Snwhitehorn    GLIBC21="$ac_cv_gnu_library_2_1"
3878217309Snwhitehorn  ]
3879217309Snwhitehorn)
3880