add c99 varargs checks, thanks to Mo DeJong
[aubio.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script
2
3 AC_INIT(src/aubio.h)
4
5 . $srcdir/VERSION
6 AUBIO_VERSION=${AUBIO_MAJOR_VERSION}.${AUBIO_MINOR_VERSION}.${AUBIO_PATCH_VERSION}${AUBIO_VERSION_STATUS}
7 VERSION=${AUBIO_VERSION}
8 PACKAGE=aubio
9
10 AM_INIT_AUTOMAKE(${PACKAGE}, ${VERSION})
11 AM_MAINTAINER_MODE
12
13 AC_PREFIX_DEFAULT(/usr)
14
15 dnl enable optimization
16 CFLAGS="$CFLAGS -O2"
17
18 dnl Check for debug
19 AC_ARG_ENABLE(debug,
20   [  --enable-debug[[=value]]   compile with debug [[default=no]]],
21   with_debug="yes",
22   with_debug="no")
23 if test "$with_debug" = "yes"
24 then
25   AC_DEFINE(DEBUG,1,[Define to enable debug])
26   CFLAGS="$CFLAGS -g"
27 fi
28
29 dnl
30 AC_ARG_ENABLE(warnme,
31   [  --enable-warnme[[=value]]   compile with all -W [[default=yes]]],
32   with_warnme="no",
33   with_warnme="yes")
34 if test "$with_warnme" = "yes"
35 then
36   ALL_CWARNINGS="-Wall -Werror -Wmissing-prototypes -Wmissing-declarations -Wno-char-subscripts -Wno-unknown-pragmas"
37   CFLAGS="$CFLAGS $ALL_CWARNINGS"
38 fi
39
40
41 dnl Guess the host
42 AC_CANONICAL_HOST
43
44 dnl Check for programs
45 AC_PROG_CC
46 if test "$ac_cv_prog_cc" = "no" ; then
47    AC_MSG_ERROR([*** No C compiler found !])
48 fi
49 AC_PROG_INSTALL
50
51 dnl Check for libtool
52 AC_LIBTOOL_DLOPEN
53 dnl AC_DISABLE_STATIC
54 AC_PROG_LIBTOOL
55
56 AC_CONFIG_HEADERS(src/config.h)
57 AC_CONFIG_FILES(aubio.pc)
58
59 case "${host_os}" in
60 mingw*)
61   mingw32_support="yes"
62   AC_CHECK_HEADER(windows.h)
63   ;;
64 darwin*)
65   dnl on macosx, cosf went to -lmx
66   LDFLAGS="$LDFLAGS -lmx"
67   dnl as long double doesn't sit well with -Wall -Werror
68   CFLAGS="$CLFAGS -Wno-long-double"
69   AC_ISC_POSIX
70   ;;
71 *)
72   AC_ISC_POSIX
73   ;;
74 esac
75
76 dnl Check for required libraries
77 AC_CHECK_LIB(pthread, pthread_create)
78
79 dnl Check for header files
80 AC_HEADER_STDC
81 AC_CHECK_HEADERS([string.h stdlib.h stdio.h math.h errno.h stdarg.h unistd.h signal.h],,)
82 AC_CHECK_HEADERS(complex.h,,AC_MSG_ERROR([Ouch! missing complex.h header]))
83 AC_CHECK_HEADERS(fftw3.h  ,,AC_MSG_ERROR([Ouch! missing fftw3.h headeri]))
84
85 AC_CACHE_CHECK(for C99 __VA_ARGS__ macro,
86     ac_cv_varargs_macros,
87 AC_TRY_COMPILE([
88   #include <stdio.h>
89   #define AUBIO_ERR(...)                       fprintf(stderr, __VA_ARGS__)
90 ],
91 [
92   AUBIO_ERR("%s\n", "ERR");
93 ],
94         ac_cv_varargs_macros=yes,
95         ac_cv_varargs_macros=no)
96 )
97 if test "$ac_cv_varargs_macros" = "yes"; then
98     AC_DEFINE(HAVE_C99_VARARGS_MACROS, 1,
99             [Defined when c99 style varargs macros are supported])
100 fi
101
102
103 dnl check for pkg-config
104 AC_PATH_PROG(PKG_CONFIG,pkg-config,no)
105
106 PKG_CHECK_MODULES(SNDLIB,     sndfile >= 1.0.4,       SNDLIB_SUPPORT=1)
107 PKG_CHECK_MODULES(SAMPLERATE, samplerate  >= 0.0.15,  SAMPLERATE_SUPPORT=1)
108
109 if test "${SNDLIB_SUPPORT}" = "1"; then
110   AC_DEFINE(SNDLIB_SUPPORT,1,[Define to enable libsndfile support])
111 fi
112
113
114 dnl Check for optional libraries
115 AC_ARG_ENABLE(fftw3f,
116   AC_HELP_STRING([--enable-fftw3f],[compile with fftw3f [[default=auto]]]),
117   [with_fftw3f=$enableval],
118   with_fftw3f="yes")
119 if test "$with_fftw3f" = "yes"; then
120         PKG_CHECK_MODULES(FFTWLIB,    fftw3f  >= 3.0.0,     FFTW3F_SUPPORT=1, FFTW3F_SUPPORT=0)
121 else
122         PKG_CHECK_MODULES(FFTWLIB,    fftw3  >= 3.0.0,      FFTW3_SUPPORT=1)
123 fi
124 if test "${FFTW3F_SUPPORT}" = "0"; then
125         PKG_CHECK_MODULES(FFTWLIB,    fftw3  >= 3.0.0,      FFTW3_SUPPORT=1)
126 fi
127 if test "${FFTW3_SUPPORT}" = "1"; then
128   AC_DEFINE(FFTW3_SUPPORT,1,[Define to enable fftw3 support])
129 fi
130 if test "${FFTW3F_SUPPORT}" = "1"; then
131   AC_DEFINE(FFTW3F_SUPPORT,1,[Define to enable fftw3f support])
132 fi
133
134 AC_ARG_ENABLE(jack,
135   AC_HELP_STRING([--enable-jack],[compile with jack [[default=auto]]]),
136   [with_jack=$enableval],
137   with_jack="yes")
138 if test "$with_jack" = "yes"
139 then
140         PKG_CHECK_MODULES(JACK,       jack  >= 0.15.0,        JACK_SUPPORT=1, JACK_SUPPORT=0)
141         if test "${JACK_SUPPORT}" = "1"; then
142           AC_DEFINE(JACK_SUPPORT,1,[Define to enable jack support])
143         fi
144 fi
145
146 AC_ARG_ENABLE(alsa,
147   AC_HELP_STRING([--enable-alsa],[compile with alsa [[default=auto]]]),
148   [with_alsa=$enableval],
149   with_alsa="yes")
150 if test "$with_alsa" = "yes"
151 then
152         if test "$with_jack" = "yes"
153         then
154         PKG_CHECK_MODULES(ALSA,       alsa >= 0.0.9,          ALSA_SUPPORT=1, ALSA_SUPPORT=0)
155         if test "${ALSA_SUPPORT}" = "1"; then
156           AC_DEFINE(ALSA_SUPPORT,1,[Define to enable alsa support])
157         fi
158         else
159         AC_MSG_WARN([Disabling alsa as jack was not found])
160         fi
161 fi
162
163 AC_ARG_ENABLE(ladcca,
164   AC_HELP_STRING([--enable-ladcca],[compile with ladcca [[default=no]]]),
165   [with_ladcca=$enableval],
166   with_ladcca="no")
167 if test "$with_ladcca" = "yes"
168 then
169         PKG_CHECK_MODULES(LADCCA,       ladcca-1.0 >= 0.4.0,          LADCCA_SUPPORT=1)
170         if test "${LADCCA_SUPPORT}" = "1"; then
171           AC_DEFINE(LADCCA_SUPPORT,1,[Define to enable ladcca support])
172         fi
173 fi
174   
175 AC_ARG_ENABLE(testprogs,
176   AC_HELP_STRING([--enable-testprogs],[compile test programs [[default=no]]]),
177   [with_testprogs=$enableval],
178   with_testprogs="no")
179 AM_CONDITIONAL(COMPILE_TESTS,test "${with_testprogs}" != "no")
180
181 dnl Check for optional programs
182
183 dnl should check for swig version and python headers
184 AC_PATH_PROG(SWIG,swig,no)
185 AM_CONDITIONAL(SWIGFOUND, test "${SWIG}" != "no")
186 AM_PATH_PYTHON
187 AM_CONDITIONAL(PYTHONFOUND, test "${PYTHON}" != "no")
188
189 #if PYTHONFOUND
190 case "${host_os}" in
191 darwin*)
192   SWCFLAGS="-Wno-long-double"
193   SWLDFLAGS="-bundle -framework python -L${prefix}/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
194   ;;
195 *)
196   SWLDFLAGS="-shared"
197   ;;
198 esac
199
200 AC_SUBST(SWCFLAGS)
201 AC_SUBST(SWLDFLAGS)
202
203 AC_PATH_PROG(DOCBOOK_TO_MAN,docbook-to-man,no)
204 AM_CONDITIONAL(DOCBOOKFOUND, test "${DOCBOOK_TO_MAN}" != "no")
205
206 AC_CHECK_HEADER(m_pd.h,PUREDATA=y,AC_MSG_WARN([Puredata header not found.]))
207 AM_CONDITIONAL(PUREDATAFOUND, test "${PUREDATA}" = "y")
208
209 AC_OUTPUT([
210                 Makefile
211                 src/Makefile
212                 ext/Makefile
213                 examples/Makefile
214                 examples/tests/Makefile
215                 sounds/Makefile
216                 swig/Makefile
217                 python/Makefile
218                 python/aubio/Makefile
219                 plugins/Makefile
220                 plugins/audacity/Makefile
221                 plugins/audacity/plug-ins/Makefile
222                 plugins/wavesurfer/Makefile
223                 plugins/puredata/Makefile
224                 doc/Makefile
225         ])
226
227 echo
228 echo "**************************************************************"
229 echo "Summary:"
230 if test "${FFTW3F_SUPPORT}" = "1"; then
231   echo "Fftw3:                   yes (using fftw3f)"
232 else
233 if test "${FFTW3_SUPPORT}" = "1"; then
234   echo "Fftw3:                   yes (not using fftw3f)"
235 else
236   echo "Fftw3:                   no (that should not happen)"
237 fi
238 fi
239 if test "${SNDLIB_SUPPORT}" = "1"; then
240   echo "Libsndfile:              yes"
241 else
242   echo "Libsndfile:              no"
243 fi
244 if test "${SAMPLERATE_SUPPORT}" = "1"; then
245   echo "Libsamplerate:           yes"
246 else
247   echo "Libsamplerate:           no"
248 fi
249 if test "${JACK_SUPPORT}" = "1"; then
250   echo "JACK:                    yes"
251 else
252   echo "JACK:                    no"
253 fi
254 if test "${ALSA_SUPPORT}" = "1"; then
255   echo "ALSA midi:               yes"
256 else
257   echo "ALSA midi:               no"
258 fi
259 if test "${LADCCA_SUPPORT}" = "1"; then
260   echo "Ladcca:                  yes"
261 else
262   echo "Ladcca:                  no"
263 fi
264 echo "**************************************************************"
265 echo Configuration completed successfully. Type \'make\' to build ${PACKAGE}