configure.ac: switch on host rather than host_os, do nothing on arm-apple-darwin
[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}" 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 arm-apple-darwin)
101   dnl nothing to do here 
102   ;;
103 *darwin* | *rhapsody* | *macosx*)
104   dnl on macosx, cosf went to -lmx
105   LDFLAGS="$LDFLAGS -lmx"
106   dnl as long double doesn't sit well with -Wall -Werror
107   AUBIO_CFLAGS="$AUBIO_CFLAGS -Wno-long-double"
108   dnl Workaround darwin autoconf bug
109   CPPFLAGS="$CPPFLAGS -I${prefix}/include"
110   AC_ISC_POSIX
111   AM_CONDITIONAL(DARWIN, true)
112   ;;
113 *)
114   AC_ISC_POSIX
115   ;;
116 esac
117
118 dnl Check for required libraries
119 AC_CHECK_LIB(pthread, pthread_create)
120
121 dnl Check for header files
122 AC_CHECK_HEADERS([string.h stdlib.h stdio.h math.h errno.h stdarg.h unistd.h signal.h],,)
123 AC_CHECK_HEADERS(fftw3.h,,AC_MSG_ERROR([Ouch! missing fftw3.h header]))
124 AC_ARG_ENABLE(complex,
125   AC_HELP_STRING([--enable-complex],[compile with complex.h [[default=auto]]]),
126   [with_complex=$enableval],
127   with_complex="yes")
128 if test "$with_complex" = "yes"; then
129   AC_CHECK_HEADERS(complex.h,,AC_MSG_WARN([Ouch! missing complex.h header]))
130 fi
131
132 dnl Check for __VAR_ARGS__ support
133 AC_CACHE_CHECK(for C99 __VA_ARGS__ macro,
134     ac_cv_varargs_macros,
135 AC_TRY_COMPILE([
136   #include <stdio.h>
137   #define AUBIO_ERR(...)                       fprintf(stderr, __VA_ARGS__)
138 ],
139 [
140   AUBIO_ERR("%s\n", "ERR");
141 ],
142         ac_cv_varargs_macros=yes,
143         ac_cv_varargs_macros=no)
144 )
145 if test "$ac_cv_varargs_macros" = "yes"; then
146     AC_DEFINE(HAVE_C99_VARARGS_MACROS, 1,
147             [Defined when c99 style varargs macros are supported])
148 fi
149
150 dnl Check for pkg-config
151 AC_PATH_PROG(PKG_CONFIG,pkg-config,no)
152
153 PKG_CHECK_MODULES(SNDLIB,     sndfile >= 1.0.4,       SNDLIB_SUPPORT=1)
154 PKG_CHECK_MODULES(SAMPLERATE, samplerate  >= 0.0.15,  SAMPLERATE_SUPPORT=1)
155
156 if test "${SNDLIB_SUPPORT}" = "1"; then
157   AC_DEFINE(SNDLIB_SUPPORT,1,[Define to enable libsndfile support])
158 fi
159
160 dnl Check for fftw3 (required)
161 AC_ARG_ENABLE(fftw3f,
162   AC_HELP_STRING([--enable-fftw3f],[compile with fftw3f [[default=auto]]]),
163   [with_fftw3f=$enableval],
164   with_fftw3f="yes")
165 if test "$with_fftw3f" = "yes"; then
166   PKG_CHECK_MODULES(FFTWLIB,    fftw3f >= 3.0.0,     FFTW3F_SUPPORT=1, FFTW3F_SUPPORT=0)
167 else
168   PKG_CHECK_MODULES(FFTWLIB,    fftw3  >= 3.0.0,     FFTW3_SUPPORT=1)
169 fi
170 if test "${FFTW3F_SUPPORT}" = "0"; then
171   PKG_CHECK_MODULES(FFTWLIB,    fftw3  >= 3.0.0,     FFTW3_SUPPORT=1)
172 fi
173 if test "${FFTW3_SUPPORT}" = "1"; then
174   AC_DEFINE(FFTW3_SUPPORT,1,[Define to enable fftw3 support])
175 fi
176 if test "${FFTW3F_SUPPORT}" = "1"; then
177   AC_DEFINE(FFTW3F_SUPPORT,1,[Define to enable fftw3f support])
178 fi
179
180 dnl Enable jack support (auto)
181 AC_ARG_ENABLE(jack,
182   AC_HELP_STRING([--enable-jack],[compile with jack [[default=auto]]]),
183   [with_jack=$enableval],
184   with_jack="yes")
185 if test "$with_jack" = "yes"
186 then
187   PKG_CHECK_MODULES(JACK,       jack  >= 0.15.0,     JACK_SUPPORT=1, JACK_SUPPORT=0)
188   if test "${JACK_SUPPORT}" = "1"; then
189     AC_DEFINE(JACK_SUPPORT,1,[Define to enable jack support])
190   fi
191 fi
192
193 dnl Enable alsa support (auto)
194 AC_ARG_ENABLE(alsa,
195   AC_HELP_STRING([--enable-alsa],[compile with alsa [[default=auto]]]),
196   [with_alsa=$enableval],
197   with_alsa="yes")
198 if test "$with_alsa" = "yes"
199 then
200   if test "$with_jack" = "yes"
201   then
202     PKG_CHECK_MODULES(ALSA,      alsa >= 0.0.9,      ALSA_SUPPORT=1, ALSA_SUPPORT=0)
203     if test "${ALSA_SUPPORT}" = "1"; then
204       AC_DEFINE(ALSA_SUPPORT,1,[Define to enable alsa support])
205     fi
206   else
207     AC_MSG_WARN([Disabling alsa as jack was not found])
208   fi
209 fi
210
211 dnl Enable lash support
212 AC_ARG_ENABLE(lash,
213   AC_HELP_STRING([--enable-lash],[compile with lash [[default=auto]]]),
214   [with_lash=$enableval],
215   with_lash="yes")
216 if test "$with_lash" = "yes"
217 then
218   PKG_CHECK_MODULES(LASH,   lash-1.0 >= 0.5.0,   LASH_SUPPORT=1, LASH_SUPPORT=0)
219   if test "${LASH_SUPPORT}" = "1"; then
220     LASH_CFLAGS+="-DLASH_SUPPORT"
221   fi
222 fi
223   
224 dnl Enable unit tests 
225 AC_ARG_ENABLE(testprogs,
226   AC_HELP_STRING([--enable-testprogs],[compile test programs [[default=no]]]),
227   [with_testprogs=$enableval],
228   with_testprogs="no")
229 AM_CONDITIONAL(COMPILE_TESTS,test "${with_testprogs}" != "no")
230
231 AC_SUBST(AUBIO_CFLAGS)
232
233 dnl Check for swig and python
234 dnl should check for swig version and python headers
235 AC_PATH_PROG(SWIG,swig,no)
236 AM_CONDITIONAL(SWIGFOUND, test "${SWIG}" != "no")
237 AM_PATH_PYTHON
238 AM_CONDITIONAL(PYTHONFOUND, test "${PYTHON}" != "no")
239
240 dnl Check for docbook-to-man
241 AC_PATH_PROG(DOCBOOK_TO_MAN,docbook-to-man,no)
242 AM_CONDITIONAL(DOCBOOKFOUND, test "${DOCBOOK_TO_MAN}" != "no")
243
244 dnl Check for Puredata
245 AC_CHECK_HEADER(m_pd.h,PUREDATA=y,AC_MSG_WARN([Puredata header not found.]))
246 AM_CONDITIONAL(PUREDATAFOUND, test "${PUREDATA}" = "y")
247
248 dnl Create Makefiles
249 AC_OUTPUT([
250     Makefile
251     src/Makefile
252     ext/Makefile
253     cpp/Makefile
254     examples/Makefile
255     tests/Makefile
256     tests/src/Makefile
257     tests/cpp/Makefile
258     sounds/Makefile
259     swig/Makefile
260     python/Makefile
261     python/aubio/Makefile
262     java/Makefile
263     java/aubio/Makefile
264     plugins/Makefile
265     plugins/audacity/Makefile
266     plugins/audacity/plug-ins/Makefile
267     plugins/wavesurfer/Makefile
268     plugins/puredata/Makefile
269     doc/Makefile
270   ])
271
272 dnl Print summary
273 echo
274 echo "**************************************************************"
275 echo "Summary:"
276 if test "${FFTW3F_SUPPORT}" = "1"; then
277   echo "Fftw3:                   yes (using fftw3f)"
278 else
279 if test "${FFTW3_SUPPORT}" = "1"; then
280   echo "Fftw3:                   yes (not using fftw3f)"
281 else
282   echo "Fftw3:                   no (that should not happen)"
283 fi
284 fi
285 if test "${SNDLIB_SUPPORT}" = "1"; then
286   echo "Libsndfile:              yes"
287 else
288   echo "Libsndfile:              no"
289 fi
290 if test "${SAMPLERATE_SUPPORT}" = "1"; then
291   echo "Libsamplerate:           yes"
292 else
293   echo "Libsamplerate:           no"
294 fi
295 if test "${JACK_SUPPORT}" = "1"; then
296   echo "JACK:                    yes"
297 else
298   echo "JACK:                    no"
299 fi
300 if test "${ALSA_SUPPORT}" = "1"; then
301   echo "ALSA midi:               yes"
302 else
303   echo "ALSA midi:               no"
304 fi
305 if test "${LASH_SUPPORT}" = "1"; then
306   echo "Lash:                    yes"
307 else
308   echo "Lash:                    no"
309 fi
310 if test "${PUREDATA}" = "y"; then
311   echo "PureData:                yes"
312 else
313   echo "PureData:                no"
314 fi
315 echo "**************************************************************"
316 echo Configuration completed successfully. Type \'make\' to build ${PACKAGE}