r602: Fix baver's code... don't insert timecode when show_tc is not set
[cinelerra_cv/mob.git] / libsndfile / acinclude.m4
blobcf8985d8b6bd4ae1d97d0ebf4b7e2714f967057d
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
15         ifelse($1, CFLAGS,
16           [case "$host_os" in
17            # IRIX 6.2 and later require cc -n32.
18 changequote(, )dnl
19            irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
20 changequote([, ])dnl
21              if test "$GCC" != yes; then
22                ac_cv_sys_largefile_CFLAGS=-n32
23              fi
24              ac_save_CC="$CC"
25              CC="$CC $ac_cv_sys_largefile_CFLAGS"
26              AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
27              CC="$ac_save_CC"
28            esac])
29       }])])
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],
34   [case $2 in
35    no) ;;
36    ?*)
37      case "[$]$1" in
38      '') $1=$2 ;;
39      *) $1=[$]$1' '$2 ;;
40      esac ;;
41    esac])
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,
47      [$2=no
48 changequote(, )dnl
49       $4
50       for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
51         case "$ac_flag" in
52         -D$1)
53           $2=1 ;;
54         -D$1=*)
55           $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
56         esac
57       done
58 changequote([, ])dnl
59       ])
60    if test "[$]$2" != no; then
61      AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
62    fi])
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)
73         
74      for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
75        case "$ac_flag" in
76        no) ;;
77        -D_FILE_OFFSET_BITS=*) ;;
78        -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
79        -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
80        -D?* | -I?*)
81          AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
82        *)
83          AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
84        esac
85      done
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.]])
91        [case "$host_os" in
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 ;;
95         esac]
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.],
99        [case "$host_os" in
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 ;;
103         esac])
104      AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
105        ac_cv_sys_large_files,
106        [Define for large files, on AIX-style hosts.],
107        [case "$host_os" in
108         # AIX 4.2 and later
109         aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
110           ac_cv_sys_large_files=1 ;;
111         esac])
112    fi
113   ])
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, 
138         ac_cv_c_byte_order,
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.
147         [AC_TRY_LINK([
148                 #include <endian.h>
149                 #if BYTE_ORDER != LITTLE_ENDIAN
150                         not big endian
151                 #endif
152                 ], return 0 ;, 
153                         ac_cv_c_byte_order=little
154                 )]
155                                 
156         [AC_TRY_LINK([
157                 #include <endian.h>
158                 #if BYTE_ORDER != BIG_ENDIAN
159                         not big endian
160                 #endif
161                 ], return 0 ;, 
162                         ac_cv_c_byte_order=big
163                 )]
165         fi
167 if test $ac_cv_c_byte_order = unknown ; then
169         [AC_TRY_LINK([
170                 #include <sys/types.h>
171                 #include <sys/param.h>
172                 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
173                         bogus endian macros
174                 #endif
175                 ], return 0 ;, 
177                 [AC_TRY_LINK([
178                         #include <sys/types.h>
179                         #include <sys/param.h>
180                         #if BYTE_ORDER != LITTLE_ENDIAN
181                                 not big endian
182                         #endif
183                         ], return 0 ;, 
184                                 ac_cv_c_byte_order=little
185                         )]
186                                 
187                 [AC_TRY_LINK([
188                         #include <sys/types.h>
189                         #include <sys/param.h>
190                         #if BYTE_ORDER != LITTLE_ENDIAN
191                                 not big endian
192                         #endif
193                         ], return 0 ;, 
194                                 ac_cv_c_byte_order=little
195                         )]
197                 )]
199         fi
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.    
205                 [
206                 case "$target_cpu" in
207                         alpha* | i?86* | mipsel* | ia64*)
208                                 ac_cv_c_big_endian=0
209                                 ac_cv_c_little_endian=1
210                                 ;;
211                         
212                         m68* | mips* | powerpc* | hppa* | sparc*)
213                                 ac_cv_c_big_endian=1
214                                 ac_cv_c_little_endian=0
215                                 ;;
216         
217                         esac
218                 ]
219         else
220                 AC_TRY_RUN(
221                 [[
222                 int main (void) 
223                 {       /* Are we little or big endian?  From Harbison&Steele.  */
224                         union
225                         {       long l ;
226                                 char c [sizeof (long)] ;
227                         } u ;
228                         u.l = 1 ;
229                         return (u.c [sizeof (long) - 1] == 1);
230                         }
231                         ]], , ac_cv_c_byte_order=big, 
232                         ac_cv_c_byte_order=unknown
233                         )
235                 AC_TRY_RUN(
236                 [[int main (void) 
237                 {       /* Are we little or big endian?  From Harbison&Steele.  */
238                         union
239                         {       long l ;
240                                 char c [sizeof (long)] ;
241                         } u ;
242                         u.l = 1 ;
243                         return (u.c [0] == 1);
244                         }]], , ac_cv_c_byte_order=little, 
245                         ac_cv_c_byte_order=unknown
246                         )
247                 fi      
248         fi
253 if test $ac_cv_c_byte_order = big ; then
254         ac_cv_c_big_endian=1
255         ac_cv_c_little_endian=0
256 elif test $ac_cv_c_byte_order = little ; then
257         ac_cv_c_big_endian=0
258         ac_cv_c_little_endian=1
259 else
260         ac_cv_c_big_endian=0
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([[*****************************************************************]])
268         fi
270 )# AC_C_FIND_ENDIAN
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,
286   ac_cv_c99_lrint,
288 lrint_save_CFLAGS=$CFLAGS
289 CFLAGS="-O2 -lm"
290 AC_TRY_LINK([
291 #define         _ISOC9X_SOURCE  1
292 #define         _ISOC99_SOURCE  1
293 #define         __USE_ISOC99    1
294 #define         __USE_ISOC9X    1
296 #include <math.h>
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,
322   ac_cv_c99_lrintf,
324 lrintf_save_CFLAGS=$CFLAGS
325 CFLAGS="-O2 -lm"
326 AC_TRY_LINK([
327 #define         _ISOC9X_SOURCE  1
328 #define         _ISOC99_SOURCE  1
329 #define         __USE_ISOC99    1
330 #define         __USE_ISOC9X    1
332 #include <math.h>
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