1 dnl By default, many hosts won't let programs access large files;
2 dnl one must use special compiler options to get large-file access to work.
3 dnl For more details about this brain damage please see:
4 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
6 dnl Written by Paul Eggert <eggert@twinsun.com>.
8 dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
9 dnl AC_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME)
10 AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_FLAGS],
11 [AC_CACHE_CHECK([for $1 value to request large file support],
12 ac_cv_sys_largefile_$1,
13 [ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
14 ac_cv_sys_largefile_$1=no
17 # IRIX 6.2 and later require cc -n32.
19 irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
21 if test "$GCC" != yes; then
22 ac_cv_sys_largefile_CFLAGS=-n32
25 CC="$CC $ac_cv_sys_largefile_CFLAGS"
26 AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
31 dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
32 dnl AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(VAR, VAL)
33 AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND],
43 dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
44 dnl AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
45 AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE],
46 [AC_CACHE_CHECK([for $1], $2,
50 for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
55 $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
60 if test "[$]$2" != no; then
61 AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
64 AC_DEFUN([AC_SYS_EXTRA_LARGEFILE],
65 [AC_REQUIRE([AC_CANONICAL_HOST])
66 AC_ARG_ENABLE(largefile,
67 [ --disable-largefile omit support for large files])
68 if test "$enable_largefile" != no; then
69 AC_CHECK_TOOL(GETCONF, getconf)
70 AC_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS)
71 AC_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS)
72 AC_SYS_EXTRA_LARGEFILE_FLAGS(LIBS)
74 for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
77 -D_FILE_OFFSET_BITS=*) ;;
78 -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
79 -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
81 AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
83 AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
86 AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
87 AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
88 AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
89 ac_cv_sys_file_offset_bits,
90 [[Number of bits in a file offset, on hosts where this is settable.]])
92 # HP-UX 10.20 and later
93 hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
94 ac_cv_sys_file_offset_bits=64 ;;
96 AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
97 ac_cv_sys_largefile_source,
98 [Define to make fseeko etc. visible, on some hosts.],
100 # HP-UX 10.20 and later
101 hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
102 ac_cv_sys_largefile_source=1 ;;
104 AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
105 ac_cv_sys_large_files,
106 [Define for large files, on AIX-style hosts.],
109 aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
110 ac_cv_sys_large_files=1 ;;
114 dnl @synopsis AC_C_FIND_ENDIAN
116 dnl Determine endian-ness of target processor.
117 dnl @version 1.1 Mar 03 2002
118 dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
120 dnl Majority written from scratch to replace the standard autoconf macro
121 dnl AC_C_BIGENDIAN. Only part remaining from the original it the invocation
122 dnl of the AC_TRY_RUN macro.
124 dnl Permission to use, copy, modify, distribute, and sell this file for any
125 dnl purpose is hereby granted without fee, provided that the above copyright
126 dnl and this permission notice appear in all copies. No representations are
127 dnl made about the suitability of this software for any purpose. It is
128 dnl provided "as is" without express or implied warranty.
130 dnl Find endian-ness in the following way:
131 dnl 1) Look in <endian.h>.
132 dnl 2) If 1) fails, look in <sys/types.h> and <sys/param.h>.
133 dnl 3) If 1) and 2) fails and not cross compiling run a test program.
134 dnl 4) If 1) and 2) fails and cross compiling then guess based on target.
136 AC_DEFUN([AC_C_FIND_ENDIAN],
137 [AC_CACHE_CHECK(determining processor byte ordering,
140 # Initialize to unknown
141 ac_cv_c_byte_order=unknown
143 if test x$ac_cv_header_endian_h = xyes ; then
145 # First try <endian.h> which should set BYTE_ORDER.
149 #if BYTE_ORDER != LITTLE_ENDIAN
153 ac_cv_c_byte_order=little
158 #if BYTE_ORDER != BIG_ENDIAN
162 ac_cv_c_byte_order=big
167 if test $ac_cv_c_byte_order = unknown ; then
170 #include <sys/types.h>
171 #include <sys/param.h>
172 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
178 #include <sys/types.h>
179 #include <sys/param.h>
180 #if BYTE_ORDER != LITTLE_ENDIAN
184 ac_cv_c_byte_order=little
188 #include <sys/types.h>
189 #include <sys/param.h>
190 #if BYTE_ORDER != LITTLE_ENDIAN
194 ac_cv_c_byte_order=little
201 if test $ac_cv_c_byte_order = unknown ; then
202 if test $cross_compiling = yes ; then
203 # This is the last resort. Try to guess the target processor endian-ness
204 # by looking at the target CPU type.
206 case "$target_cpu" in
207 alpha* | i?86* | mipsel* | ia64*)
209 ac_cv_c_little_endian=1
212 m68* | mips* | powerpc* | hppa* | sparc*)
214 ac_cv_c_little_endian=0
223 { /* Are we little or big endian? From Harbison&Steele. */
226 char c [sizeof (long)] ;
229 return (u.c [sizeof (long) - 1] == 1);
231 ]], , ac_cv_c_byte_order=big,
232 ac_cv_c_byte_order=unknown
237 { /* Are we little or big endian? From Harbison&Steele. */
240 char c [sizeof (long)] ;
243 return (u.c [0] == 1);
244 }]], , ac_cv_c_byte_order=little,
245 ac_cv_c_byte_order=unknown
253 if test $ac_cv_c_byte_order = big ; then
255 ac_cv_c_little_endian=0
256 elif test $ac_cv_c_byte_order = little ; then
258 ac_cv_c_little_endian=1
261 ac_cv_c_little_endian=0
263 AC_MSG_WARN([[*****************************************************************]])
264 AC_MSG_WARN([[*** Not able to determine endian-ness of target processor. ]])
265 AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in ]])
266 AC_MSG_WARN([[*** src/config.h may need to be hand editied. ]])
267 AC_MSG_WARN([[*****************************************************************]])
272 dnl @synopsis AC_C99_FUNC_LRINT
274 dnl Check whether C99's lrint function is available.
275 dnl @version 1.3 Feb 12 2002
276 dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
278 dnl Permission to use, copy, modify, distribute, and sell this file for any
279 dnl purpose is hereby granted without fee, provided that the above copyright
280 dnl and this permission notice appear in all copies. No representations are
281 dnl made about the suitability of this software for any purpose. It is
282 dnl provided "as is" without express or implied warranty.
284 AC_DEFUN([AC_C99_FUNC_LRINT],
285 [AC_CACHE_CHECK(for lrint,
288 lrint_save_CFLAGS=$CFLAGS
291 #define _ISOC9X_SOURCE 1
292 #define _ISOC99_SOURCE 1
293 #define __USE_ISOC99 1
294 #define __USE_ISOC9X 1
297 ], if (!lrint(3.14159)) lrint(2.7183);, ac_cv_c99_lrint=yes, ac_cv_c99_lrint=no)
299 CFLAGS=$lrint_save_CFLAGS
303 if test "$ac_cv_c99_lrint" = yes; then
304 AC_DEFINE(HAVE_LRINT, 1,
305 [Define if you have C99's lrint function.])
307 ])# AC_C99_FUNC_LRINT
308 dnl @synopsis AC_C99_FUNC_LRINTF
310 dnl Check whether C99's lrintf function is available.
311 dnl @version 1.3 Feb 12 2002
312 dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
314 dnl Permission to use, copy, modify, distribute, and sell this file for any
315 dnl purpose is hereby granted without fee, provided that the above copyright
316 dnl and this permission notice appear in all copies. No representations are
317 dnl made about the suitability of this software for any purpose. It is
318 dnl provided "as is" without express or implied warranty.
320 AC_DEFUN([AC_C99_FUNC_LRINTF],
321 [AC_CACHE_CHECK(for lrintf,
324 lrintf_save_CFLAGS=$CFLAGS
327 #define _ISOC9X_SOURCE 1
328 #define _ISOC99_SOURCE 1
329 #define __USE_ISOC99 1
330 #define __USE_ISOC9X 1
333 ], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no)
335 CFLAGS=$lrintf_save_CFLAGS
339 if test "$ac_cv_c99_lrintf" = yes; then
340 AC_DEFINE(HAVE_LRINTF, 1,
341 [Define if you have C99's lrintf function.])
343 ])# AC_C99_FUNC_LRINTF