Merge from vendor branch OPENSSH:
[dragonfly.git] / contrib / awk / aclocal.m4
1 dnl
2 dnl aclocal.m4 --- autoconf input file for gawk
3 dnl 
4 dnl Copyright (C) 1995, 1996, 1998, 1999, 2000 the Free Software Foundation, Inc.
5 dnl 
6 dnl This file is part of GAWK, the GNU implementation of the
7 dnl AWK Progamming Language.
8 dnl 
9 dnl GAWK is free software; you can redistribute it and/or modify
10 dnl it under the terms of the GNU General Public License as published by
11 dnl the Free Software Foundation; either version 2 of the License, or
12 dnl (at your option) any later version.
13 dnl 
14 dnl GAWK is distributed in the hope that it will be useful,
15 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
16 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 dnl GNU General Public License for more details.
18 dnl 
19 dnl You should have received a copy of the GNU General Public License
20 dnl along with this program; if not, write to the Free Software
21 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
22 dnl
23
24 dnl gawk-specific macros for autoconf. one day hopefully part of autoconf
25
26 AC_DEFUN(GAWK_AC_C_STRINGIZE, [
27 AC_REQUIRE([AC_PROG_CPP])
28 AC_MSG_CHECKING([for ANSI stringizing capability])
29 AC_CACHE_VAL(gawk_cv_c_stringize, 
30 AC_EGREP_CPP([#teststring],[
31 #define x(y) #y
32
33 char *s = x(teststring);
34 ], gawk_cv_c_stringize=no, gawk_cv_c_stringize=yes))
35 if test "${gawk_cv_c_stringize}" = yes
36 then
37         AC_DEFINE(HAVE_STRINGIZE)
38 fi
39 AC_MSG_RESULT([${gawk_cv_c_stringize}])
40 ])dnl
41
42
43 dnl By default, many hosts won't let programs access large files;
44 dnl one must use special compiler options to get large-file access to work.
45 dnl For more details about this brain damage please see:
46 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
47
48 dnl Written by Paul Eggert <eggert@twinsun.com>.
49
50 dnl Internal subroutine of GAWK_AC_SYS_LARGEFILE.
51 dnl GAWK_AC_SYS_LARGEFILE_TEST_INCLUDES
52 AC_DEFUN(GAWK_AC_SYS_LARGEFILE_TEST_INCLUDES,
53   [[#include <sys/types.h>
54     int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1];
55   ]])
56
57 dnl Internal subroutine of GAWK_AC_SYS_LARGEFILE.
58 dnl GAWK_AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
59 AC_DEFUN(GAWK_AC_SYS_LARGEFILE_MACRO_VALUE,
60   [AC_CACHE_CHECK([for $1 value needed for large files], $3,
61      [$3=no
62       AC_TRY_COMPILE(GAWK_AC_SYS_LARGEFILE_TEST_INCLUDES
63 $5
64         ,
65         [$6], 
66         ,
67         [AC_TRY_COMPILE([#define $1 $2]
68 GAWK_AC_SYS_LARGEFILE_TEST_INCLUDES
69 $5
70            ,
71            [$6],
72            [$3=$2])])])
73    if test "[$]$3" != no; then
74      AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
75    fi])
76
77 AC_DEFUN(GAWK_AC_SYS_LARGEFILE,
78   [AC_ARG_ENABLE(largefile,
79      [  --disable-largefile     omit support for large files])
80    if test "$enable_largefile" != no; then
81
82      AC_CACHE_CHECK([for special C compiler options needed for large files],
83        gawk_cv_sys_largefile_CC,
84        [gawk_cv_sys_largefile_CC=no
85         if test "$GCC" != yes; then
86           # IRIX 6.2 and later do not support large files by default,
87           # so use the C compiler's -n32 option if that helps.
88           AC_TRY_COMPILE(GAWK_AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
89             [ac_save_CC="$CC"
90              CC="$CC -n32"
91              AC_TRY_COMPILE(GAWK_AC_SYS_LARGEFILE_TEST_INCLUDES, ,
92                gawk_cv_sys_largefile_CC=' -n32')
93              CC="$ac_save_CC"])
94         fi])
95      if test "$gawk_cv_sys_largefile_CC" != no; then
96        CC="$CC$gawk_cv_sys_largefile_CC"
97      fi
98
99      GAWK_AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
100        gawk_cv_sys_file_offset_bits,
101        [Number of bits in a file offset, on hosts where this is settable.])
102      GAWK_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
103        gawk_cv_sys_largefile_source,
104        [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).],
105        [#include <stdio.h>], [return !ftello;])
106      GAWK_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
107        gawk_cv_sys_large_files,
108        [Define for large files, on AIX-style hosts.])
109      GAWK_AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500,
110        gawk_cv_sys_xopen_source,
111        [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).],
112        [#include <stdio.h>], [return !ftello;])
113    fi
114   ])
115
116 dnl Check for AIX and add _XOPEN_SOURCE_EXTENDED
117 AC_DEFUN(GAWK_AC_AIX_TWEAK, [
118 AC_MSG_CHECKING([for AIX compilation hacks])
119 AC_CACHE_VAL(gawk_cv_aix_hack, [
120 if test -d /lpp/bos
121 then
122         CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
123         gawk_cv_aix_hack=yes
124 else
125         gawk_cv_aix_hack=no
126 fi
127 ])dnl
128 AC_MSG_RESULT([${gawk_cv_aix_hack}])
129 ])dnl