pulling trunk
[ardour.git] / libs / libsndfile / configure.ac
1 # Copyright (C) 1999-2006 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
2
3 dnl Require autoconf version
4 AC_PREREQ(2.59)
5
6 AC_INIT([libsndfile],[ardour-special],[ardour@ardour.org])
7 AC_CONFIG_SRCDIR([src/sndfile.c])
8 AC_CANONICAL_TARGET([])
9
10 AC_CONFIG_HEADERS(src/config.h)
11
12 AC_LANG([C])
13
14 #------------------------------------------------------------------------------------
15 # Rules for library version information:
16 #
17 #  1. Start with version information of `0:0:0' for each libtool library.
18 #  2. Update the version information only immediately before a public release of
19 #     your software. More frequent updates are unnecessary, and only guarantee
20 #     that the current interface number gets larger faster.
21 #  3. If the library source code has changed at all since the last update, then
22 #     increment revision (`c:r:a' becomes `c:r+1:a').
23 #  4. If any interfaces have been added, removed, or changed since the last update,
24 #     increment current, and set revision to 0.
25 #  5. If any interfaces have been added since the last public release, then increment
26 #     age.
27 #  6. If any interfaces have been removed since the last public release, then set age
28 #     to 0.
29
30 SHARED_VERSION_INFO="1:16:0"
31
32 AC_PROG_CC
33 #AM_PROG_LIBTOOL
34
35 AC_CHECK_PROG(autogen, autogen, yes, no)
36
37 AC_PROG_INSTALL
38 AC_PROG_LN_S
39
40 AC_HEADER_STDC
41
42 AC_CHECK_HEADERS(endian.h)
43 AC_CHECK_HEADERS(byteswap.h)
44 AC_CHECK_HEADERS(locale.h)
45 AC_CHECK_HEADERS(inttypes.h)
46
47 AC_HEADER_SYS_WAIT
48
49 AC_CHECK_DECLS(S_IRGRP)
50 AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP],${HAVE_DECL_S_IRGRP},
51                 [Set to 1 if S_IRGRP is defined.])
52
53 #====================================================================================
54 # Check for support of the struct hack.
55
56 AC_C99_FLEXIBLE_ARRAY
57
58 if test x$ac_cv_c99_flexible_array = xyes ; then
59         AC_DEFINE([HAVE_FLEXIBLE_ARRAY],1, [Set to 1 if the compile supports the struct hack.])
60 else
61         AC_MSG_WARN([[*** This compiler does not support the 1999 ISO C Standard ***]])
62         AC_MSG_WARN([[*** feature known as the flexible array struct member.     ***]])
63         AC_DEFINE([HAVE_FLEXIBLE_ARRAY],0)
64         fi
65
66 #====================================================================================
67 # Couple of initializations here. Fill in real values later.
68
69 SHLIB_VERSION_ARG=""
70
71 #====================================================================================
72 # Finished checking, handle options.
73
74 AC_ARG_ENABLE(experimental,
75         AC_HELP_STRING([--enable-experimental], [enable experimental code]))
76
77 EXPERIMENTAL_CODE=0
78 if test x$enable_experimental = xyes ; then
79         EXPERIMENTAL_CODE=1
80         fi
81 AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE],${EXPERIMENTAL_CODE}, [Set to 1 to enable experimental code.])
82
83 AC_ARG_ENABLE(gcc-werror,
84         AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]))
85
86 AC_ARG_ENABLE(gcc-pipe,
87         AC_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option]))
88
89 AC_ARG_ENABLE(gcc-opt,
90         AC_HELP_STRING([--disable-gcc-opt], [disable gcc optimisations]))
91
92 AC_ARG_ENABLE(cpu-clip,
93         AC_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper]))
94
95 AC_ARG_ENABLE(bow-docs,
96         AC_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs]))
97
98 AC_ARG_ENABLE(sqlite,
99         AC_HELP_STRING([--disable-sqlite], [disable use of sqlite]))
100
101 AC_ARG_ENABLE(flac,
102         AC_HELP_STRING([--disable-flac], [disable use of FLAC]))
103
104 AC_ARG_ENABLE(alsa,
105         AC_HELP_STRING([--disable-alsa], [disable use of ALSA]))
106
107 #====================================================================================
108 # Check types and their sizes.
109
110 AC_CHECK_SIZEOF(short,2)
111 AC_CHECK_SIZEOF(int,4)
112 AC_CHECK_SIZEOF(long,4)
113 AC_CHECK_SIZEOF(float,4)
114 AC_CHECK_SIZEOF(double,4)
115 AC_CHECK_SIZEOF(void*,8)
116 AC_CHECK_SIZEOF(size_t,4)
117 AC_CHECK_SIZEOF(int64_t,8)
118 AC_CHECK_SIZEOF(long long,8)
119
120 #====================================================================================
121 # Find an appropriate type for sf_count_t.
122 # On systems supporting files larger than 2 Gig, sf_count_t must be a 64 bit value.
123 # Unfortunately there is more than one way of ensuring this so need to do some
124 # pretty rigourous testing here.
125
126 unset ac_cv_sizeof_off_t
127
128 AC_CHECK_SIZEOF(off_t,1)        # Fake default value.
129
130 case "$host_os" in
131         mingw*)
132                 TYPEOF_SF_COUNT_T="__int64"
133                 SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
134                 SIZEOF_SF_COUNT_T=8
135                 ;;
136         *)
137                 if test "x$ac_cv_sizeof_off_t" = "x8" ; then
138                         # If sizeof (off_t) is 8, no further checking is needed.
139                         TYPEOF_SF_COUNT_T="off_t"
140                         SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
141                         SIZEOF_SF_COUNT_T=8
142                 else
143                         # Check for common 64 bit file offset types.
144                         AC_CHECK_SIZEOF(loff_t,1)       # Fake default value.
145                         AC_CHECK_SIZEOF(off64_t,1)      # Fake default value.
146
147                         TYPEOF_SF_COUNT_T="unknown"
148                         if test "x$ac_cv_sizeof_loff_t" = "x8" ; then
149                                 TYPEOF_SF_COUNT_T="loff_t"
150                                 SIZEOF_SF_COUNT_T=8
151                         elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then
152                                 TYPEOF_SF_COUNT_T="off64_t"
153                                 SIZEOF_SF_COUNT_T=8
154                                 fi
155
156                         # Save the old sizeof (off_t) value  and then unset it to see if it
157                         # changes when Large File Support is enabled.
158
159                         pre_largefile_sizeof_off_t=$ac_cv_sizeof_off_t
160                         unset ac_cv_sizeof_off_t
161
162                         AC_SYS_EXTRA_LARGEFILE
163
164                         if test "x$ac_cv_sys_largefile_CFLAGS" = "xno" ; then
165                                 ac_cv_sys_largefile_CFLAGS=""
166                                 fi
167                         if test "x$ac_cv_sys_largefile_LDFLAGS" = "xno" ; then
168                                 ac_cv_sys_largefile_LDFLAGS=""
169                                 fi
170                         if test "x$ac_cv_sys_largefile_LIBS" = "xno" ; then
171                                 ac_cv_sys_largefile_LIBS=""
172                                 fi
173
174                         AC_CHECK_SIZEOF(off_t,1)        # Fake default value.
175
176                         if test "x$ac_cv_sizeof_off_t" = "x8" ; then
177                                 SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
178                         elif test "x$ac_cv_sizeof_off_t" = "x$pre_largefile_sizeof_off_t" ; then
179                                 AC_MSG_WARN([[This machine does not seem to support 64 bit file offsets.]])
180                                 TYPEOF_SF_COUNT_T="off_t"
181                                 SIZEOF_SF_COUNT_T=$ac_cv_sizeof_off_t
182                         elif test "x$TYPEOF_SF_COUNT_T" = "xunknown" ; then
183                                 echo
184                                 echo "*** The configure process has determined that this system is capable"
185                                 echo "*** of Large File Support but has not been able to find a type which"
186                                 echo "*** is an unambiguous 64 bit file offset."
187                                 echo "*** Please contact the author to help resolve this problem."
188                                 echo
189                                 AC_MSG_ERROR([[Bad file offset type.]])
190                                 fi
191                         fi
192                 ;;
193         esac
194
195 if test $SIZEOF_SF_COUNT_T = 4 ; then
196         SF_COUNT_MAX="0x7FFFFFFF"
197         fi
198
199 AC_DEFINE_UNQUOTED([TYPEOF_SF_COUNT_T],${TYPEOF_SF_COUNT_T}, [Set to long if unknown.])
200 AC_SUBST(TYPEOF_SF_COUNT_T)
201
202 AC_DEFINE_UNQUOTED([SIZEOF_SF_COUNT_T],${SIZEOF_SF_COUNT_T}, [Set to sizeof (long) if unknown.])
203 AC_SUBST(SIZEOF_SF_COUNT_T)
204
205 AC_DEFINE_UNQUOTED([SF_COUNT_MAX],${SF_COUNT_MAX}, [Set to maximum allowed value of sf_count_t type.])
206 AC_SUBST(SF_COUNT_MAX)
207
208 AC_CHECK_TYPES(ssize_t)
209 AC_CHECK_SIZEOF(ssize_t,4)
210
211 #====================================================================================
212 # Determine endian-ness of target processor.
213
214 AC_C_FIND_ENDIAN
215
216 AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
217         [Target processor is big endian.])
218 AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
219         [Target processor is little endian.])
220
221 #====================================================================================
222 # Check for functions.
223
224 AC_CHECK_FUNCS(malloc calloc realloc free)
225 AC_CHECK_FUNCS(open read write lseek pread pwrite)
226 AC_CHECK_FUNCS(fstat ftruncate fsync fdatasync)
227 AC_CHECK_FUNCS(snprintf vsnprintf)
228 AC_CHECK_FUNCS(gmtime gmtime_r)
229 AC_CHECK_FUNCS(mmap getpagesize)
230 AC_CHECK_FUNCS(setlocale)
231
232 AC_CHECK_LIB([m],floor)
233 AC_CHECK_FUNCS(floor ceil fmod)
234
235 case "$host_os" in
236         cygwin*)
237                 AC_MSG_WARN([[Not using built-in lrint() and lrintf() because they are broken on Cygwin.]])
238                 ;;
239         *)
240                 AC_C99_FUNC_LRINT
241                 AC_C99_FUNC_LRINTF
242
243                 if test "x$ac_cv_c99_lrint" = "xno" ; then
244                         if test "x$ac_cv_c99_lrintf" = "xno" ; then
245                                 AC_MSG_WARN([[*** Missing C99 standard functions lrint() and lrintf().]])
246                                 AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
247                                 fi
248                         fi
249                 ;;
250         esac
251
252 #====================================================================================
253 # Check for libsqlite3 (only used in regtest).
254
255 ac_cv_sqlite3=no
256 if test x$enable_sqlite != xno ; then
257         PKG_CHECK_MODULES(SQLITE3, sqlite3 >= 3.2, ac_cv_sqlite3=yes, ac_cv_sqlite3=no)
258         fi
259
260 if test x$ac_cv_sqlite3 = "xyes" ; then
261         HAVE_SQLITE3=1
262 else
263         HAVE_SQLITE3=0
264         fi
265
266 AC_DEFINE_UNQUOTED([HAVE_SQLITE3],$HAVE_SQLITE3,[Set to 1 if you have libsqlite3.])
267
268 #====================================================================================
269 # Determine if the processor can do clipping on float to int conversions.
270
271 if test x$enable_cpu_clip != "xno" ; then
272         AC_C_CLIP_MODE
273 else
274         echo "checking processor clipping capabilities... disabled"
275         ac_cv_c_clip_positive=0
276         ac_cv_c_clip_negative=0
277         fi
278
279 AC_DEFINE_UNQUOTED(CPU_CLIPS_POSITIVE, ${ac_cv_c_clip_positive},
280         [Target processor clips on positive float to int conversion.])
281 AC_DEFINE_UNQUOTED(CPU_CLIPS_NEGATIVE, ${ac_cv_c_clip_negative},
282         [Target processor clips on negative float to int conversion.])
283
284 #====================================================================================
285 # Target OS specific stuff.
286
287 OS_SPECIFIC_CFLAGS=""
288 OS_SPECIFIC_LINKS=""
289 os_is_win32=0
290 os_is_macosx=0
291 use_windows_api=0
292
293 case "$host_os" in
294         darwin* | rhapsody*)
295                 os_is_macosx=1
296                 OS_SPECIFIC_CFLAGS="-fpascal-strings -I/Developer/Headers/FlatCarbon"
297                 OS_SPECIFIC_LINKS="-framework CoreAudio"
298                 ;;
299         mingw*)
300                 os_is_win32=1
301                 use_windows_api=1
302                 OS_SPECIFIC_LINKS="-lwinmm"
303                 ;;
304         cygwin*)
305                 os_is_win32=1
306                 OS_SPECIFIC_LINKS="-lwinmm"
307                 ;;
308         esac
309
310 AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32])
311 AC_DEFINE_UNQUOTED(OS_IS_MACOSX, ${os_is_macosx}, [Set to 1 if compiling for MacOSX])
312 AC_DEFINE_UNQUOTED(USE_WINDOWS_API, ${use_windows_api}, [Set to 1 to use the native windows API])
313
314 #====================================================================================
315 # Check for ALSA.
316
317 ALSA_LIBS=""
318
319 if test x$enable_alsa != xno ; then
320         AC_CHECK_HEADERS(alsa/asoundlib.h)
321         if test x$ac_cv_header_alsa_asoundlib_h = xyes ; then
322                 ALSA_LIBS="-lasound"
323                 fi
324         fi
325
326 #====================================================================================
327 # Check for FLAC
328
329 FLAC_LIBS=""
330
331 if test x$enable_flac != xno ; then
332         AC_CHECK_HEADERS(FLAC/all.h)
333         if test x$ac_cv_header_FLAC_all_h = xyes ; then
334                 AC_CHECK_LIB(FLAC, FLAC__seekable_stream_encoder_set_tell_callback, HAVE_FLAC_1_1_1="yes")
335                 if test "x$HAVE_FLAC_1_1_1" = xyes ; then
336                         AC_DEFINE(HAVE_FLAC_1_1_1, [1], [Define to 1 if you have libflac 1.1.1])
337                         fi
338                 FLAC_LIBS="-lFLAC"
339                 fi
340         fi
341
342 #====================================================================================
343 # Test for sanity when cross-compiling.
344
345 if test x$cross_compiling = xyes ; then
346         AC_MSG_WARN([[******************************************************************]])
347         AC_MSG_WARN([[*** We are cross-compiling, so have to assume sizeof (short) == 2 ]])
348         AC_MSG_WARN([[*** and sizeof (int) == 4. If this is not the case there is no    ]])
349         AC_MSG_WARN([[*** chance of this working. Please contact the mantainer.         ]])
350         AC_MSG_WARN([[******************************************************************]])
351         fi
352
353 if test $ac_cv_sizeof_short != 2 ; then
354         AC_MSG_WARN([[******************************************************************]])
355         AC_MSG_WARN([[*** sizeof (short) != 2.                                          ]])
356         AC_MSG_WARN([[******************************************************************]])
357         fi
358
359 if test $ac_cv_sizeof_int != 4 ; then
360         AC_MSG_WARN([[******************************************************************]])
361         AC_MSG_WARN([[*** sizeof (int) != 4                                             ]])
362         AC_MSG_WARN([[******************************************************************]])
363         fi
364
365 if test $ac_cv_sizeof_float != 4 ; then
366         AC_MSG_WARN([[******************************************************************]])
367         AC_MSG_WARN([[*** sizeof (float) != 4.                                          ]])
368         AC_MSG_WARN([[******************************************************************]])
369         fi
370
371 if test $ac_cv_sizeof_double != 8 ; then
372         AC_MSG_WARN([[******************************************************************]])
373         AC_MSG_WARN([[*** sizeof (double) != 8.                                         ]])
374         AC_MSG_WARN([[******************************************************************]])
375         fi
376
377 if test x"$ac_cv_prog_autogen" = "xno" ; then
378         AC_MSG_WARN([[Touching files in directory tests/.]])
379         touch tests/*.c tests/*.h
380         fi
381
382 #====================================================================================
383 # Settings for the HTML documentation.
384
385 htmldocdir=$prefix/share/doc/libsndfile1-dev/html
386
387 if test $prefix = "NONE" ; then
388         htmldocdir=/usr/local/share/doc/libsndfile1-dev/html
389 else
390         htmldocdir=$prefix/share/doc/libsndfile1-dev/html
391         fi
392
393 if test x$enable_bow_docs = "xyes" ; then
394         HTML_BGCOLOUR="white"
395         HTML_FGCOLOUR="black"
396 else
397         HTML_BGCOLOUR="black"
398         HTML_FGCOLOUR="white"
399         fi
400
401 #====================================================================================
402 # Now use the information from the checking stage.
403
404 if test x$ac_cv_c_compiler_gnu = xyes ; then
405         AC_ADD_CFLAGS(-std=gnu99)
406
407         CFLAGS="$CFLAGS -W -Wall"
408
409         AC_ADD_CFLAGS(-Wdeclaration-after-statement)
410
411         if test x$enable_gcc_werror = "xyes" ; then
412                 CFLAGS="-Werror $CFLAGS"
413                 fi
414
415         CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast -Wwrite-strings"
416         # -Wpointer-arith -Wundef -Wmissing-declarations -Winline -Wconversion"
417
418         if test "x$enable_gcc_opt" = "xno" ; then
419                 temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"`
420                 CFLAGS=$temp_CFLAGS
421                 AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
422                 fi
423
424         # OS specific tweaks.
425         case "$host_os" in
426                 darwin* | rhapsody*)
427                         # Disable -Wall, -pedantic and -Wshadow for Apple Darwin/Rhapsody.
428                         # System headers on these systems are broken.
429                         temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall -pedantic//" | sed "s/-Wshadow//" | sed "s/-Waggregate-return//"`
430                         CFLAGS=$temp_CFLAGS
431                         SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(srcdir)/Symbols.darwin"
432                         ;;
433                 linux*)
434                         SHLIB_VERSION_ARG="-Wl,--version-script=\$(srcdir)/Symbols.linux"
435                         ;;
436                 mingw*)
437                         SHLIB_VERSION_ARG="-Wl,\$(srcdir)/libsndfile.def"
438                         ;;
439                 cygwin*)
440                         SHLIB_VERSION_ARG="-Wl,\$(srcdir)/cygsndfile.def"
441                         ;;
442                 *)
443                         ;;
444                 esac
445         if test x$enable_gcc_pipe != "xno" ; then
446                 CFLAGS="$CFLAGS -pipe"
447                 fi
448
449         AC_DEFINE([COMPILER_IS_GCC],1, [Set to 1 if the compile is GNU GCC.])
450         GCC_MAJOR_VERSION=`$CC -dumpversion | sed "s/\..*//"`
451         AC_DEFINE_UNQUOTED([GCC_MAJOR_VERSION],${GCC_MAJOR_VERSION}, [Major version of GCC or 3 otherwise.])
452         fi
453
454 CFLAGS="$CFLAGS $OS_SPECIFIC_CFLAGS"
455
456 if test x"$CFLAGS" = x ; then
457         echo "Error in configure script. CFLAGS has been screwed up."
458         exit
459         fi
460
461 AC_SUBST(htmldocdir)
462 AC_SUBST(HTML_BGCOLOUR)
463 AC_SUBST(HTML_FGCOLOUR)
464
465 AC_SUBST(SHLIB_VERSION_ARG)
466 AC_SUBST(SHARED_VERSION_INFO)
467 AC_SUBST(OS_SPECIFIC_CFLAGS)
468 AC_SUBST(OS_SPECIFIC_LINKS)
469 AC_SUBST(ALSA_LIBS)
470 AC_SUBST(FLAC_LIBS)
471 AC_SUBST(ENABLE_EXPERIMENTAL_CODE)
472
473 AC_SUBST(COMPILER_IS_GCC)
474 AC_SUBST(GCC_MAJOR_VERSION)
475
476 dnl The following line causes the libtool distributed with the source
477 dnl to be replaced if the build system has a more recent version.
478 AC_SUBST(LIBTOOL_DEPS)
479
480 AC_CONFIG_FILES([ \
481                         src/sndfile.h 
482                         sndfile.pc \
483                         ])
484 AC_OUTPUT
485
486 #====================================================================================
487
488 AC_MSG_RESULT([
489 -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
490
491   Configuration summary :
492
493     Version : ..................... ${VERSION}
494     Experimental code : ........... ${enable_experimental:-no}
495 ])
496
497 if test x$ac_cv_c_compiler_gnu = xyes ; then
498         echo -e "  Tools :\n"
499         echo "    Compiler is GCC : ............. ${ac_cv_c_compiler_gnu}"
500         echo "    GCC major version : ........... ${GCC_MAJOR_VERSION}"
501         if test $GCC_MAJOR_VERSION -lt 3 ; then
502                 echo -e "\n    ** This compiler version allows applications to write"
503                 echo "    ** to static strings within the library."
504                 echo "    ** Compile with GCC version 3.X to avoid this problem."
505                 fi
506         fi
507
508 if test $libdir = "\${exec_prefix}/lib" ; then
509         libdir="$prefix/lib"
510         fi
511
512 if test $bindir = "\${exec_prefix}/bin" ; then
513         bindir="$prefix/bin"
514         fi
515
516 AC_MSG_RESULT([[
517   Installation directories :
518
519     Library directory : ........... $libdir
520     Program directory : ........... $bindir
521     Pkgconfig directory : ......... $libdir/pkgconfig
522     HTML docs directory : ......... $htmldocdir
523 ]])
524
525 if test x$prefix != "x/usr" ; then
526         echo "Compiling some other packages against libsndfile may require"
527         echo -e "the addition of \"$libdir/pkgconfig\" to the"
528         echo -e "PKG_CONFIG_PATH environment variable.\n"
529         fi
530
531 #====================================================================================
532
533 ifelse(dnl
534
535  Do not edit or modify anything in this comment block.
536  The arch-tag line is a file identity tag for the GNU Arch
537  revision control system.
538
539  arch-tag: 6391b316-6cfc-43c2-a18a-8defdc4ee359
540
541 )dnl