blob: 4a718c5b5f301dd8c7ea18c2407a46bc432b2195 [file] [log] [blame]
Emeric Vigiereebea672012-08-06 17:36:30 -04001# Copyright (C) 2002-2011 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
2
3dnl Require autoconf version
4AC_PREREQ(2.57)
5
6AC_INIT([libsamplerate],[0.1.8],[erikd@mega-nerd.com],
7 [libsamplerate],[http://www.mega-nerd.com/libsamplerate/])
8
9# Put config stuff in Cfg.
10AC_CONFIG_AUX_DIR(Cfg)
11
12AC_CONFIG_SRCDIR([src/samplerate.c])
13AC_CANONICAL_TARGET([])
14
15AC_CONFIG_MACRO_DIR([M4])
16AC_CONFIG_HEADERS([src/config.h])
17
18AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION)
19AM_SILENT_RULES([yes])
20
21dnl Add parameters for aclocal
22AC_SUBST(ACLOCAL_AMFLAGS, "-I M4")
23
24AC_LANG([C])
25
26AC_PROG_CC
27AM_PROG_CC_C_O
28AC_PROG_CXX
29AC_PROG_SED
30
31# Do not check for F77.
32define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
33
34AM_PROG_LIBTOOL
35LT_PROG_RC
36
37AC_PROG_INSTALL
38AC_PROG_LN_S
39
40#------------------------------------------------------------------------------------
41# Rules for library version information:
42#
43# 1. Start with version information of `0:0:0' for each libtool library.
44# 2. Update the version information only immediately before a public release of
45# your software. More frequent updates are unnecessary, and only guarantee
46# that the current interface number gets larger faster.
47# 3. If the library source code has changed at all since the last update, then
48# increment revision (`c:r:a' becomes `c:r+1:a').
49# 4. If any interfaces have been added, removed, or changed since the last update,
50# increment current, and set revision to 0.
51# 5. If any interfaces have been added since the last public release, then increment
52# age.
53# 6. If any interfaces have been removed since the last public release, then set age
54# to 0.
55
56SHARED_VERSION_INFO="1:8:1"
57
58
59
60
61
62AC_PROG_MAKE_SET
63AC_PROG_LN_S
64AC_PROG_MKDIR_P
65
66if test "x-$build_os-$host_os-$target_os" = x-mingw32-mingw32-mingw32 ; then
67 AC_CHECK_PROG(DLLTOOL, dlltool, dlltool)
68 AC_CHECK_PROG(DLLWRAP, dllwrap, dllwrap)
69 AC_CHECK_PROG(PEXPORTS, pexports, pexports)
70 fi
71
72AC_HEADER_STDC
73
74AC_CHECK_HEADERS(stdint.h sys/times.h)
75
76#====================================================================================
77# Couple of initializations here. Fill in real values later.
78
79SHLIB_VERSION_ARG=""
80
81#====================================================================================
82# Finished checking, handle options.
83
84AC_ARG_ENABLE(gcc-werror,
85 AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]),
86 ac_arg_gcc_werror=yes, ac_arg_gcc_werror=no)
87
88AC_ARG_ENABLE(gcc-pipe,
89 AC_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option ]),
90 ac_arg_gcc_pipe="N", ac_arg_gcc_pipe="Y")
91
92AC_ARG_ENABLE(gcc-opt,
93 AC_HELP_STRING([--disable-gcc-opt], [disable gcc optimisations ]),
94 ac_arg_gcc_opt="N", ac_arg_gcc_opt="Y")
95
96AC_ARG_ENABLE(fftw,
97 AC_HELP_STRING([--disable-fftw], [disable usage of FFTW ]),
98 ac_arg_fftw="N", ac_arg_fftw="Y")
99
100AC_ARG_ENABLE(cpu-clip,
101 AC_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper]),
102 ac_arg_cpu_clip="N", ac_arg_cpu_clip="Y")
103
104#====================================================================================
105# Check types and their sizes.
106
107AC_CHECK_SIZEOF(int,0)
108AC_CHECK_SIZEOF(long,0)
109AC_CHECK_SIZEOF(float,4)
110AC_CHECK_SIZEOF(double,8)
111
112#====================================================================================
113# Determine endian-ness of target processor.
114
115AC_C_FIND_ENDIAN
116
117AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
118 [Target processor is big endian.])
119AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
120 [Target processor is little endian.])
121
122#====================================================================================
123# Check for functions.
124
125AC_CHECK_FUNCS(malloc calloc free memcpy memmove alarm signal)
126
127AC_CHECK_LIB([m],floor)
128AC_CHECK_FUNCS(floor ceil fmod)
129
130AC_CHECK_SIGNAL(SIGALRM)
131
132AC_C99_FUNC_LRINT
133AC_C99_FUNC_LRINTF
134# AC_C99_FUNC_LLRINT Don't need this (yet?).
135
136case "x$ac_cv_c99_lrint$ac_cv_c99_lrintf" in
137 xyesyes)
138 ;;
139 *)
140 AC_MSG_WARN([[*** Missing C99 standard functions lrint() and lrintf().]])
141 AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
142 ;;
143 esac
144
145#====================================================================================
146# Determine if the processor can do clipping on float to int conversions.
147
148if test x$ac_arg_cpu_clip = "xY" ; then
149 AC_C_CLIP_MODE
150else
151 echo "checking processor clipping capabilities... disabled"
152 ac_cv_c_clip_positive=0
153 ac_cv_c_clip_negative=0
154 fi
155
156AC_DEFINE_UNQUOTED(CPU_CLIPS_POSITIVE, ${ac_cv_c_clip_positive},
157 [Target processor clips on positive float to int conversion.])
158AC_DEFINE_UNQUOTED(CPU_CLIPS_NEGATIVE, ${ac_cv_c_clip_negative},
159 [Target processor clips on negative float to int conversion.])
160
161#====================================================================================
162# Check for libsndfile which is required for the test and example programs.
163
164AC_ARG_ENABLE(sndfile,
165 AC_HELP_STRING([--disable-sndfile], [disable support for sndfile (default=autodetect)]),
166 [ enable_sndfile=$enableval ], [ enable_sndfile=yes ])
167
168# Check for pkg-config outside the if statement.
169PKG_PROG_PKG_CONFIG
170
171if test "x$enable_sndfile" = "xyes"; then
172 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.6, ac_cv_sndfile=1, ac_cv_sndfile=0)
173else
174 ac_cv_sndfile=0
175fi
176
177AC_DEFINE_UNQUOTED([HAVE_SNDFILE],$ac_cv_sndfile,[Set to 1 if you have libsndfile.])
178
179if test x$ac_cv_sndfile = x1 ; then
180 ac_cv_sndfile=yes
181 HAVE_SNDFILE=1
182else
183 ac_cv_sndfile=no
184 HAVE_SNDFILE=0
185 fi
186
187#====================================================================================
188# Check for libfftw3 which is required for the test and example programs.
189
190if test $ac_arg_fftw = "Y" ; then
191 PKG_CHECK_MODULES(FFTW3, fftw3 >= 0.15.0, ac_cv_fftw3=1, ac_cv_fftw3=0)
192 AC_DEFINE_UNQUOTED([HAVE_FFTW3],$ac_cv_fftw3,[Set to 1 if you have libfftw3.])
193
194 if test x$ac_cv_fftw3 = x1 ; then
195 ac_cv_fftw3=yes
196 HAVE_FFTW3=1
197 fi
198 fi
199
200if test x$ac_cv_fftw3 != xyes ; then
201 ac_cv_fftw3=no
202 HAVE_FFTW3=0
203 fi
204
205#====================================================================================
206# GCC stuff.
207
208if test $ac_cv_c_compiler_gnu = yes ; then
209 CFLAGS="$CFLAGS -std=gnu99 -W -Wstrict-prototypes -Wmissing-prototypes -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wpointer-arith"
210 # -Wundef -Wbad-function-cast -Wmissing-declarations -Wconversion -Winline"
211 if test "$ac_arg_gcc_opt" = "N" ; then
212 temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"`
213 CFLAGS=$temp_CFLAGS
214 AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
215 fi
216
217 # Disable -Wall for Apple Darwin/Rhapsody.
218 # System headers on these systems are broken.
219 case "$target_os" in
220 darwin* | rhapsody*)
221 temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall//"`
222 CFLAGS=$temp_CFLAGS
223 ;;
224
225 linux*|kfreebsd*-gnu*|gnu*)
226 SHLIB_VERSION_ARG="-Wl,--version-script=Version_script"
227 ;;
228 *)
229 ;;
230 esac
231 if test x$ac_arg_gcc_pipe != "xN" ; then
232 CFLAGS="$CFLAGS -pipe"
233 fi
234
235 if test x$ac_arg_gcc_werror = "xyes" ; then
236 CFLAGS="-Werror $CFLAGS"
237 fi
238
239 AC_DEFINE([COMPILER_IS_GCC],1, [Set to 1 if the compile is GNU GCC.])
240 GCC_MAJOR_VERSION=`$CC -dumpversion | sed "s/\..*//"`
241 AC_DEFINE_UNQUOTED([GCC_MAJOR_VERSION],${GCC_MAJOR_VERSION}, [Major version of GCC or 3 otherwise.])
242 fi
243
244#====================================================================================
245# Find known target OS.
246
247OS_SPECIFIC_INCLUDES=""
248os_is_win32=0
249
250case "$target_os" in
251 darwin* | rhapsody*)
252 OS_SPECIFIC_INCLUDES="-fpascal-strings -I/Developer/Headers/FlatCarbon"
253 OS_SPECIFIC_LINKS="-framework CoreAudio"
254 ;;
255 mingw32*)
256 OS_SPECIFIC_LINKS="-lwinmm"
257 os_is_win32=1
258 ;;
259 *)
260 OS_SPECIFIC_INCLUDES=""
261 OS_SPECIFIC_LINKS=""
262 ;;
263 esac
264
265htmldocdir=$prefix/share/doc/libsamplerate0-dev/html
266
267if test $prefix = "NONE" ; then
268 htmldocdir=/usr/local/share/doc/libsamplerate0-dev/html
269else
270 htmldocdir=$prefix/share/doc/libsamplerate0-dev/html
271 fi
272
273#====================================================================================
274# Now use the information from the checking stage.
275
276AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32])
277
278AC_SUBST(htmldocdir)
279
280AC_SUBST(SHLIB_VERSION_ARG)
281AC_SUBST(SHARED_VERSION_INFO)
282AC_SUBST(OS_SPECIFIC_INCLUDES)
283AC_SUBST(OS_SPECIFIC_LINKS)
284
285AC_SUBST(COMPILER_IS_GCC)
286AC_SUBST(GCC_MAJOR_VERSION)
287
288AC_SUBST(HAVE_FFTW3)
289AC_SUBST(FFTW3_CFLAGS)
290AC_SUBST(FFTW3_LIBS)
291
292AC_SUBST(HAVE_SNDFILE)
293AC_SUBST(SNDFILE_CFLAGS)
294AC_SUBST(SNDFILE_LIBS)
295
296AC_CONFIG_FILES([Makefile M4/Makefile src/Version_script \
297 Win32/Makefile Win32/Makefile.mingw \
298 src/Makefile examples/Makefile tests/Makefile doc/Makefile \
299 libsamplerate.spec samplerate.pc])
300AC_OUTPUT
301
302#====================================================================================
303
304AC_MSG_RESULT([
305-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-=-
306
307 Configuration summary :
308
309 Version : ..................... ${VERSION}
310
311 Host CPU : .................... ${host_cpu}
312 Host Vendor : ................. ${host_vendor}
313 Host OS : ..................... ${host_os}
314])
315
316if test x$ac_cv_c_compiler_gnu = xyes ; then
317 echo -e " Tools :\n"
318 echo " Compiler is GCC : ............. ${ac_cv_c_compiler_gnu}"
319 echo " GCC major version : ........... ${GCC_MAJOR_VERSION}"
320 fi
321
322AC_MSG_RESULT([
323 Extra tools required for testing and examples :
324
325 Use FFTW : .................... ${ac_cv_fftw3}])
326
327AC_MSG_RESULT([ Have libsndfile : ............. ${ac_cv_sndfile}
328])
329
330AC_MSG_RESULT([ Installation directories :
331
332 Library directory : ........... ${prefix}/lib
333 Program directory : ........... ${prefix}/bin
334 Pkgconfig directory : ......... ${prefix}/lib/pkgconfig
335])
336
337if test x$prefix != "x/usr" ; then
338 echo "Compiling some other packages against ${PACKAGE} may require "
339 echo -e "the addition of \"${prefix}/lib/pkgconfig\" to the "
340 echo -e "PKG_CONFIG_PATH environment variable.\n"
341 fi
342