configure.ac: do not call AC_HEADER_STDC, obsolete and uneeded
[aubio.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script
2
3 dnl Init autoconf
4 AC_INIT(src/aubio.h)
5
6 dnl Package name and version
7 PACKAGE=aubio
8 . $srcdir/VERSION
9 AUBIO_VERSION=${AUBIO_MAJOR_VERSION}.${AUBIO_MINOR_VERSION}.${AUBIO_PATCH_VERSION}${AUBIO_VERSION_STATUS}
10 VERSION=${AUBIO_VERSION}
11
12 dnl Shared library version
13 SHARED_VERSION_INFO=${LIBAUBIO_LT_CUR}:${LIBAUBIO_LT_REV}:${LIBAUBIO_LT_AGE}
14 AC_SUBST(SHARED_VERSION_INFO)
15
16 dnl Init automake
17 AM_INIT_AUTOMAKE(${PACKAGE}, ${VERSION})
18
19 dnl Maintainer mode
20 AM_MAINTAINER_MODE
21
22 dnl Guess the host
23 AC_CANONICAL_HOST
24
25 dnl Check for programs
26 AC_PROG_CC
27 AM_PROG_CC_C_O dnl compiling with per-target flag 
28 if test "$ac_cv_prog_cc" = "no" ; then
29    AC_MSG_ERROR([*** No C compiler found !])
30 fi
31 AC_PROG_INSTALL
32
33 AUBIO_CFLAGS=
34
35 dnl Enable debugging (no)
36 AC_ARG_ENABLE(debug,
37   AC_HELP_STRING([--enable-debug],[compile in debug mode [[default=no]]]),
38   with_debug="yes",
39   with_debug="no")
40 if test "$with_debug" = "yes"
41 then
42   AC_DEFINE(DEBUG,1,[Define to enable debug])
43   AUBIO_CFLAGS="$AUBIO_CFLAGS -g"
44 fi
45
46 dnl Enable full warnings (yes)
47 AC_ARG_ENABLE(warnings,
48   AC_HELP_STRING([--enable-warnings],[compile with all gcc warnings [[default=yes]]]),
49   with_warnme="no",
50   with_warnme="yes")
51 if test "$with_warnme" = "yes"
52 then
53   dnl Check for -Wextra support to allow compilation on gcc <= 3.4
54   AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, 
55   [old_CFLAGS="$CFLAGS"
56   CFLAGS="$CFLAGS -Wextra"
57   AC_COMPILE_IFELSE([void foo (void) {}],
58           ac_cv_cc_wextra=yes, ac_cv_cc_wextra=no)
59   CFLAGS="$old_CFLAGS"
60   ])
61   if test "$ac_cv_cc_wextra" = "yes"
62   then
63     AUBIO_CFLAGS="$AUBIO_CFLAGS -Wall -Wextra"
64   else 
65     AUBIO_CFLAGS="$AUBIO_CFLAGS -Wall"
66   fi
67 fi
68
69 dnl fail on compilation warnings 
70 AC_ARG_ENABLE(errorfail,
71   AC_HELP_STRING([--enable-errorfail],[fail on compilation warnings [[default=no]]]),
72   AUBIO_CFLAGS="$AUBIO_CFLAGS -Werror -Wmissing-prototypes -Wmissing-declarations -Wno-unused-parameter",
73   with_errorfail="no")
74
75 dnl add gcov/lcov profiling and coverage flags
76 AC_ARG_ENABLE(lcov,
77   AC_HELP_STRING([--enable-lcov],[compile with gcov/lcov profiling flags [[default=no]]]),
78   AUBIO_CFLAGS="$AUBIO_CFLAGS -fprofile-arcs -ftest-coverage",
79   with_lcov="no")
80
81 dnl Check for libtool
82 AC_LIBTOOL_DLOPEN
83 dnl AC_DISABLE_STATIC
84 dnl allow cross compiling
85 AC_LIBTOOL_WIN32_DLL
86 AC_PROG_LIBTOOL
87
88 AC_CONFIG_HEADERS(src/config.h)
89 AC_CONFIG_FILES(aubio.pc)
90
91 AM_CONDITIONAL(MINGW, false)
92 AM_CONDITIONAL(DARWIN, false)
93 case "${host_os}" in
94 *mingw* | *cygwin*)
95   mingw32_support="yes"
96   AC_CHECK_HEADER(windows.h)
97   AM_CONDITIONAL(MINGW, true)
98   LDFLAGS="$LDFLAGS -no-undefined"
99   ;;
100 *darwin* | *rhapsody* | *macosx*)
101   dnl on macosx, cosf went to -lmx
102   LDFLAGS="$LDFLAGS -lmx"
103   dnl as long double doesn't sit well with -Wall -Werror
104   AUBIO_CFLAGS="$AUBIO_CFLAGS -Wno-long-double"
105   dnl Workaround darwin autoconf bug
106   CPPFLAGS="$CPPFLAGS -I${prefix}/include"
107   AC_ISC_POSIX
108   AM_CONDITIONAL(DARWIN, true)
109   ;;
110 *)
111   AC_ISC_POSIX
112   ;;
113 esac
114
115 dnl Check for required libraries
116 AC_CHECK_LIB(pthread, pthread_create)
117
118 dnl Check for header files
119 AC_CHECK_HEADERS([string.h stdlib.h stdio.h math.h errno.h stdarg.h unistd.h signal.h],,)
120 AC_CHECK_HEADERS(fftw3.h,,AC_MSG_ERROR([Ouch! missing fftw3.h header]))
121 AC_ARG_ENABLE(complex,
122   AC_HELP_STRING([--enable-complex],[compile with complex.h [[default=auto]]]),
123   [with_complex=$enableval],
124   with_complex="yes")
125 if test "$with_complex" = "yes"; then
126   AC_CHECK_HEADERS(complex.h,,AC_MSG_WARN([Ouch! missing complex.h header]))
127 fi
128
129 dnl Check for __VAR_ARGS__ support
130 AC_CACHE_CHECK(for C99 __VA_ARGS__ macro,
131     ac_cv_varargs_macros,
132 AC_TRY_COMPILE([
133   #include <stdio.h>
134   #define AUBIO_ERR(...)                       fprintf(stderr, __VA_ARGS__)
135 ],
136 [
137   AUBIO_ERR("%s\n", "ERR");
138 ],
139         ac_cv_varargs_macros=yes,
140         ac_cv_varargs_macros=no)
141 )
142 if test "$ac_cv_varargs_macros" = "yes"; then
143     AC_DEFINE(HAVE_C99_VARARGS_MACROS, 1,
144             [Defined when c99 style varargs macros are supported])
145 fi
146
147 dnl Check for pkg-config
148 AC_PATH_PROG(PKG_CONFIG,pkg-config,no)
149
150 PKG_CHECK_MODULES(SNDLIB,     sndfile >= 1.0.4,       SNDLIB_SUPPORT=1)
151 PKG_CHECK_MODULES(SAMPLERATE, samplerate  >= 0.0.15,  SAMPLERATE_SUPPORT=1)
152
153 if test "${SNDLIB_SUPPORT}" = "1"; then
154   AC_DEFINE(SNDLIB_SUPPORT,1,[Define to enable libsndfile support])
155 fi
156
157 dnl Check for fftw3 (required)
158 AC_ARG_ENABLE(fftw3f,
159   AC_HELP_STRING([--enable-fftw3f],[compile with fftw3f [[default=auto]]]),
160   [with_fftw3f=$enableval],
161   with_fftw3f="yes")
162 if test "$with_fftw3f" = "yes"; then
163   PKG_CHECK_MODULES(FFTWLIB,    fftw3f >= 3.0.0,     FFTW3F_SUPPORT=1, FFTW3F_SUPPORT=0)
164 else
165   PKG_CHECK_MODULES(FFTWLIB,    fftw3  >= 3.0.0,     FFTW3_SUPPORT=1)
166 fi
167 if test "${FFTW3F_SUPPORT}" = "0"; then
168   PKG_CHECK_MODULES(FFTWLIB,    fftw3  >= 3.0.0,     FFTW3_SUPPORT=1)
169 fi
170 if test "${FFTW3_SUPPORT}" = "1"; then
171   AC_DEFINE(FFTW3_SUPPORT,1,[Define to enable fftw3 support])
172 fi
173 if test "${FFTW3F_SUPPORT}" = "1"; then
174   AC_DEFINE(FFTW3F_SUPPORT,1,[Define to enable fftw3f support])
175 fi
176
177 dnl Enable jack support (auto)
178 AC_ARG_ENABLE(jack,
179   AC_HELP_STRING([--enable-jack],[compile with jack [[default=auto]]]),
180   [with_jack=$enableval],
181   with_jack="yes")
182 if test "$with_jack" = "yes"
183 then
184   PKG_CHECK_MODULES(JACK,       jack  >= 0.15.0,     JACK_SUPPORT=1, JACK_SUPPORT=0)
185   if test "${JACK_SUPPORT}" = "1"; then
186     AC_DEFINE(JACK_SUPPORT,1,[Define to enable jack support])
187   fi
188 fi
189
190 dnl Enable alsa support (auto)
191 AC_ARG_ENABLE(alsa,
192   AC_HELP_STRING([--enable-alsa],[compile with alsa [[default=auto]]]),
193   [with_alsa=$enableval],
194   with_alsa="yes")
195 if test "$with_alsa" = "yes"
196 then
197   if test "$with_jack" = "yes"
198   then
199     PKG_CHECK_MODULES(ALSA,      alsa >= 0.0.9,      ALSA_SUPPORT=1, ALSA_SUPPORT=0)
200     if test "${ALSA_SUPPORT}" = "1"; then
201       AC_DEFINE(ALSA_SUPPORT,1,[Define to enable alsa support])
202     fi
203   else
204     AC_MSG_WARN([Disabling alsa as jack was not found])
205   fi
206 fi
207
208 dnl Enable lash support
209 AC_ARG_ENABLE(lash,
210   AC_HELP_STRING([--enable-lash],[compile with lash [[default=auto]]]),
211   [with_lash=$enableval],
212   with_lash="yes")
213 if test "$with_lash" = "yes"
214 then
215   PKG_CHECK_MODULES(LASH,   lash-1.0 >= 0.5.0,   LASH_SUPPORT=1, LASH_SUPPORT=0)
216   if test "${LASH_SUPPORT}" = "1"; then
217     LASH_CFLAGS+="-DLASH_SUPPORT"
218   fi
219 fi
220   
221 dnl Enable unit tests 
222 AC_ARG_ENABLE(testprogs,
223   AC_HELP_STRING([--enable-testprogs],[compile test programs [[default=no]]]),
224   [with_testprogs=$enableval],
225   with_testprogs="no")
226 AM_CONDITIONAL(COMPILE_TESTS,test "${with_testprogs}" != "no")
227
228 AC_SUBST(AUBIO_CFLAGS)
229
230 dnl Check for swig and python
231 dnl should check for swig version and python headers
232 AC_PATH_PROG(SWIG,swig,no)
233 AM_CONDITIONAL(SWIGFOUND, test "${SWIG}" != "no")
234 AM_PATH_PYTHON
235 AM_CONDITIONAL(PYTHONFOUND, test "${PYTHON}" != "no")
236
237 dnl Check for docbook-to-man
238 AC_PATH_PROG(DOCBOOK_TO_MAN,docbook-to-man,no)
239 AM_CONDITIONAL(DOCBOOKFOUND, test "${DOCBOOK_TO_MAN}" != "no")
240
241 dnl Check for Puredata
242 AC_CHECK_HEADER(m_pd.h,PUREDATA=y,AC_MSG_WARN([Puredata header not found.]))
243 AM_CONDITIONAL(PUREDATAFOUND, test "${PUREDATA}" = "y")
244
245 dnl Create Makefiles
246 AC_OUTPUT([
247     Makefile
248     src/Makefile
249     ext/Makefile
250     cpp/Makefile
251     examples/Makefile
252     tests/Makefile
253     tests/src/Makefile
254     tests/cpp/Makefile
255     sounds/Makefile
256     swig/Makefile
257     python/Makefile
258     python/aubio/Makefile
259     java/Makefile
260     java/aubio/Makefile
261     plugins/Makefile
262     plugins/audacity/Makefile
263     plugins/audacity/plug-ins/Makefile
264     plugins/wavesurfer/Makefile
265     plugins/puredata/Makefile
266     doc/Makefile
267   ])
268
269 dnl Print summary
270 echo
271 echo "**************************************************************"
272 echo "Summary:"
273 if test "${FFTW3F_SUPPORT}" = "1"; then
274   echo "Fftw3:                   yes (using fftw3f)"
275 else
276 if test "${FFTW3_SUPPORT}" = "1"; then
277   echo "Fftw3:                   yes (not using fftw3f)"
278 else
279   echo "Fftw3:                   no (that should not happen)"
280 fi
281 fi
282 if test "${SNDLIB_SUPPORT}" = "1"; then
283   echo "Libsndfile:              yes"
284 else
285   echo "Libsndfile:              no"
286 fi
287 if test "${SAMPLERATE_SUPPORT}" = "1"; then
288   echo "Libsamplerate:           yes"
289 else
290   echo "Libsamplerate:           no"
291 fi
292 if test "${JACK_SUPPORT}" = "1"; then
293   echo "JACK:                    yes"
294 else
295   echo "JACK:                    no"
296 fi
297 if test "${ALSA_SUPPORT}" = "1"; then
298   echo "ALSA midi:               yes"
299 else
300   echo "ALSA midi:               no"
301 fi
302 if test "${LASH_SUPPORT}" = "1"; then
303   echo "Lash:                    yes"
304 else
305   echo "Lash:                    no"
306 fi
307 if test "${PUREDATA}" = "y"; then
308   echo "PureData:                yes"
309 else
310   echo "PureData:                no"
311 fi
312 echo "**************************************************************"
313 echo Configuration completed successfully. Type \'make\' to build ${PACKAGE}