audiofile support + improved sample rate support + results of a -Wall -Werr
[terminatorX.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(src/tX_global.h)
3 AM_INIT_AUTOMAKE(terminatorX, 3.73)
4 AM_CONFIG_HEADER(config.h)
5
6 dnl AC_ARG_ENABLE(closedev, [  --enable-closedev       close audio device if not in use. [default=yes] ])
7 AC_ARG_ENABLE(sox, [  --enable-sox            use sox as input converter. (default=auto) ])
8 AC_ARG_ENABLE(mpg123, [  --enable-mpg123         use mpg123 as input converter. (default=auto) ])
9 AC_ARG_ENABLE(ogg123, [  --enable-ogg123         use ogg123 as input converter. (default=auto) ])
10 dnl AC_ARG_ENABLE(wavonly,  [  --enable-wavonly        enable the builtin wav routines. ])
11 dnl AC_ARG_ENABLE(scheduler,[  --enable-scheduler      enable rt-scheduling (req. root-priv). (default=yes) ])
12 AC_ARG_ENABLE(debug,    [  --enable-debug          enable debug output. (default=no) ])
13 dnl AC_ARG_ENABLE(3dnow,    [  --enable-3dnow          enables 3DNow! support. (default=no) ])
14 dnl AC_ARG_ENABLE(benchmark,[  --enable-benchmark      creates a non-functional test version (default=no) ])
15 AC_ARG_ENABLE(wav,          [  --enable-wav            enables the builtin wav-loader (default=yes) ])
16 AC_ARG_ENABLE(xsetpointer,  [  --enable-xsetpointer    enables executing of xsetpointer (default=auto) ])
17 dnl AC_ARG_ENABLE(alsa,         [  --enable-alsa           use ALSA for sound output (default=auto) ])
18 AC_ARG_ENABLE(oss,          [  --enable-oss            use OSS for sound output (default=auto) ])
19 dnl AC_ARG_ENABLE(movqfix,          [  --disable-movqfix       don't use movq fix for gcc >= 2.96 [default=on] ])
20 AC_ARG_ENABLE(gtk2,         [  --disable-gtk2          use gtk+ 1.2 even if verion 2 detected (default=auto) ])
21 dnl AC_ARG_ENABLE(dial,         [  --enable-dial           use dials instead of scales for effects (default=yes) ])
22 dnl AC_ARG_ENABLE(bigdial,      [  --enable-bigdial        use BIG dials (default=yes) ])
23 dnl AC_ARG_ENABLE(dga2,     [  --enable-dga2           use DGA2 instead of DGA1. (experimental) (default=no) ])
24 AC_ARG_ENABLE(libxml2,      [  --disable-libxml2       use libxml even if verion 2 detected (default=auto) ])
25 AC_ARG_ENABLE(mad,              [  --disable-mad           disable mad for mp3 support (default=auto) ])
26 AC_ARG_ENABLE(vorbis,   [  --disable-vorbis        disable libvorbis support (default=auto) ])
27 AC_ARG_ENABLE(audiofile,        [  --disable-audiofile     disable audiofile support (default=auto) ])
28
29 dnl Checks for programs.
30 AC_PROG_AWK
31 AC_PROG_CC
32 AC_PROG_CXX
33 AC_PROG_INSTALL
34 AC_PROG_LN_S
35 AC_PROG_RANLIB
36
37 OPTION_SOX="no"
38 OPTION_MPG123="no"
39 OPTION_MAD="no"
40 OPTION_OGG123="no"
41 OPTION_VORBIS="no"
42 OPTION_AUDIOFILE="no"
43 OPTION_WAV="no"
44 OPTION_GTK_VERSION="none"
45 OPTION_GNOME="no"
46
47 dnl Checks for libraries.
48 AC_CHECK_LIB(m, floor,, AC_MSG_ERROR([** math-lib not installed or broken **]))
49
50 dnl Checking whether -pthreads, -lpthreads or simply nothing
51
52 tX_threads=no
53
54 dnl Some machines don't require any switches for pthread support...
55
56 AC_MSG_CHECKING([whether pthreads works without switches])
57         no_threads_flags=no
58         AC_LANG_SAVE
59         AC_LANG_C
60         AC_TRY_LINK([#include <pthread.h>], [ pthread_t thread; pthread_create(&thread, NULL, NULL, NULL);],
61                 no_threads_flags=yes,
62                 no_threads_flags=no
63         )
64         AC_LANG_RESTORE
65 AC_MSG_RESULT([$no_threads_flags])
66
67 if test "$no_threads_flags" = "yes"; then
68         tX_threads=auto
69 fi
70
71 dnl Some machines prefer the -lpthread...
72
73 if test "$tX_threads" = "no"; then
74         pthread_lib=no
75         AC_CHECK_LIB(pthread, pthread_detach, pthread_lib=yes, pthread_lib=no)
76         
77         if test "$pthread_lib" = "yes"; then
78                 tX_threads=lpthread
79                 LIBS="$LIBS -lpthread"
80         fi
81 fi
82
83 dnl Some machines prefer a -pthread...
84
85 if test "$tX_threads" = "no"; then
86         AC_MSG_CHECKING([whether -pthread is required for pthreads])
87                 use_gcc_threads=no
88                 ac_save_CFLAGS=$CFLAGS
89                 CFLAGS="$CFLAGS -pthread"
90                 AC_LANG_SAVE
91                 AC_LANG_C
92                 AC_TRY_LINK([#include <pthread.h>], [ pthread_t thread; pthread_create(&thread, NULL, NULL, NULL);],
93                         use_gcc_threads=yes,
94                         use_gcc_threads=no
95                 )
96                 AC_LANG_RESTORE
97                 CFLAGS=$ac_save_CFLAGS
98         AC_MSG_RESULT([$use_gcc_threads])
99         
100         if test "$use_gcc_threads" = "yes"; then
101                 tX_threads=gcc
102                 CFLAGS="$CFLAGS -pthread"
103         fi
104 fi
105
106 dnl If we still haven't found pthreads, we panic...
107
108 if test "$tX_threads" = "no"; then
109         AC_MSG_ERROR([** failed to detect pthreads implementation **])
110 fi
111
112 gtk2="no"
113 gtk12="no"
114
115 if test "$enable_gtk2" != "no"; then
116         AM_PATH_GTK_2_0(, [
117           GTK2_CFLAGS="$GTK_CFLAGS"
118           GTK2_LIBS="$GTK_LIBS"
119           gtk2="yes"
120           GTK2_VERSION="`$PKG_CONFIG --modversion gtk+-2.0`"], [ gtk2="no" ]) 
121           OPTION_GTK_VERSION="Version 2 - ($GTK2_VERSION)"
122 fi
123
124 if test "$gtk2" = "no"; then
125         AM_PATH_GTK([1.2.5], [
126           GTK12_CFLAGS="$GTK_CFLAGS"
127           GTK12_LIBS="$GTK_LIBS"
128           gtk12="yes"
129           GTK12_VERSION="`$GTK_CONFIG $gtk_config_args --version`"], [ gtk12="no" ])
130           OPTION_GTK_VERSION="Version 1.2 - ($GTK12_VERSION)"     
131 fi
132
133 if test "$gtk2" = "yes"; then
134         AC_MSG_RESULT([using gtk+ version 2 as widget toolkit.])
135         AC_DEFINE(USE_GTK2)
136 else
137         if test "$gtk12" = "yes"; then
138                 AC_MSG_RESULT([using gtk+ version 1.2 as widget toolkit.])
139         else
140                 AC_MSG_ERROR([** couldn't find gtk+ > Version 1.2.5 **])
141         fi
142 fi
143
144 dnl Checks for header files.
145 AC_HEADER_STDC
146 AC_CHECK_HEADERS(fcntl.h limits.h malloc.h unistd.h)
147
148 dnl Disable LADSPA caching..
149 unset ac_cv_header_ladspa_h
150
151 have_ladspa=no
152 AC_CHECK_HEADERS(ladspa.h, have_ladspa=yes, have_ladspa=no)
153
154 dnl Disable LADSPA caching..
155 unset ac_cv_header_ladspa_h
156
157 dnl Some people install LADSPA in /usr/local
158
159 if test "$have_ladspa" = "no"; then
160         ac_save_CFLAGS=$CFLAGS
161         CFLAGS="$CFLAGS -I/usr/local/include"
162         AC_CHECK_HEADERS(ladspa.h, have_ladspa=yes, have_ladspa=no)
163         CFLAGS=$ac_save_CFLAGS
164         
165         if test "$have_ladspa" = "yes"; then
166                 CFLAGS="$CFLAGS -I/usr/local/include"
167         fi
168 fi
169
170 if test "$have_ladspa" = "no"; then
171         AC_MSG_ERROR([** couldn't find ladspa.h - Install the LADSPA SDK from http://www.ladspa.org first. **])
172 fi
173
174 dnl Checks for typedefs, structures, and compiler characteristics.
175 AC_C_BIGENDIAN
176 AC_TYPE_SIZE_T
177
178 dnl Checks for library functions.
179 AC_PROG_GCC_TRADITIONAL
180
181 dnl Eval args
182 if test "$enable_closedev" = "no"; then
183         AC_DEFINE(KEEP_DEV_OPEN)
184 fi
185
186
187 if test "$enable_sox" != "no"; then
188         AC_CHECK_PROG(SOX_PROG, sox, yes)
189         if test "$SOX_PROG" = "yes"; then
190                 AC_DEFINE(USE_SOX_INPUT)
191                 OPTION_SOX="yes"
192         fi
193 fi
194
195 if test "$enable_mad" != "no"; then
196         AC_CHECK_HEADERS(mad.h,madheader=yes,madheader=no)
197         if test "$madheader" = "yes"; then
198                 AC_CHECK_LIB(mad,mad_decoder_init,madlib=yes,madlib=no)
199                 if test "$madlib" = "yes"; then
200                         LIBS="$LIBS -lmad"
201                         AC_DEFINE(USE_MAD_INPUT)
202                         OPTION_MAD="yes"
203                 fi
204         fi
205 fi
206
207 if test "$enable_vorbis" != "no"; then
208         AC_CHECK_HEADERS(vorbis/codec.h vorbis/vorbisfile.h,vorbis_headers=yes,vorbis_headers="no")
209         if test "$vorbis_headers" = "yes"; then
210                 AC_CHECK_LIB(vorbis,vorbis_info_init,vorbis_libs=yes,vorbis_libs=no)
211                 if test "$vorbis_libs" = "yes"; then
212                         PREV_LIBS=LIBS
213                         LIBS="$LIBS -lvorbis"
214                         AC_CHECK_LIB(vorbisfile,ov_open_callbacks,vorbisfile_libs=yes,vorbisfile_libs=no)
215                         if test "$vorbisfile_libs" = "yes"; then
216                                 LIBS="$LIBS -lvorbisfile"
217                                 AC_DEFINE(USE_VORBIS_INPUT)
218                                 OPTION_VORBIS="yes"
219                         else
220                                 LIBS=PREV_LIBS
221                         fi
222                 fi
223         fi
224 fi
225
226 if test "$enable_audiofile" != "no"; then
227         AC_CHECK_PROG(af_config,audiofile-config,yes,no)
228         if test "$af_config" = "yes"; then
229                 af_cflags=`audiofile-config --cflags`
230                 if test "$af_cflags" != ""; then
231                         CFLAGS="$CFLAGS $af_cflags"
232                 fi
233                 af_libs=`audiofile-config --libs`
234                 LIBS="$LIBS $af_libs"
235                 AC_DEFINE(USE_AUDIOFILE_INPUT)
236                 OPTION_AUDIOFILE="yes"
237         else
238                 AC_CHECK_HEADERS(audiofile.h,audiofile_headers=yes,audiofile_headers=no)
239                 if test "$audiofile_headers" = "yes"; then
240                         AC_CHECK_LIB(audiofile,afOpenFile,audiofile_libs=yes,audiofile_libs=no)
241                         if test "$audiofile_libs" = "yes"; then
242                                 LIBS="$LIBS -laudiofile"
243                                 AC_DEFINE(USE_AUDIOFILE_INPUT)
244                                 OPTION_AUDIOFILE="yes"
245                         fi
246                 fi
247         fi
248 fi
249
250 if test "$enable_mpg123" != "no"; then
251         AC_CHECK_PROG(MPG123_PROG, mpg123, yes)
252         if test "$MPG123_PROG" = "yes"; then
253                 if test "$SOX_PROG" = "yes"; then       
254                         AC_DEFINE(USE_MPG123_INPUT)
255                         OPTION_MPG123="yes"
256                 else
257                         AC_CHECK_PROG(SOX_PROG, sox, yes)
258                         if test "$SOX_PROG" = "yes"; then       
259                                 AC_DEFINE(USE_MPG123_INPUT)
260                                 OPTION_MPG123="yes"
261                         else
262                                 AC_MSG_RESULT([** mpg123 support disabled: couldn't find sox! **])
263                         fi
264                 fi
265         fi
266 fi
267
268 if test "$enable_ogg123" != "no"; then
269         AC_CHECK_PROG(OGG123_PROG, ogg123, yes)
270         if test "$OGG123_PROG" = "yes"; then
271                 AC_DEFINE(USE_OGG123_INPUT)
272                 OPTION_OGG123="yes"
273         fi
274 fi
275
276 if test "$enable_xsetpointer" != "no"; then
277         AC_CHECK_PROG(XSETPOINTER_PROG, xsetpointer, yes)
278         if test "$XSETPOINTER_PROG" = "yes"; then
279                 AC_DEFINE(USE_XSETPOINTER)
280         else
281                 if test "$enable_xsetpointer" = "yes"; then
282                         AC_MSG_ERROR([** xsetpointer not found. **])
283                 fi
284         fi
285 fi
286
287 if test "$enable_movqfix" = "no"; then
288         AC_DEFINE(OVERRIDE_MOVQ_AUTODETECT)
289 fi
290
291 using_alsa=no
292 using_oss=no
293
294 dnl if test "$enable_alsa" != "no"; then
295 dnl     AC_CHECK_LIB(asound, snd_ctl_open,alsalib=yes,alsalib=no)
296 dnl     AC_CHECK_HEADERS(sys/asoundlib.h,alsaheader=yes,alsaheader=no)
297 dnl
298 dnl     if test "$alsalib" = "yes"; then
299 dnl             if test "$alsaheader" = "yes"; then
300 dnl                     AC_DEFINE(USE_ALSA)
301 dnl                     using_alsa=yes;
302 dnl             else 
303 dnl                     if test "$enable_alsa" = "yes"; then
304 dnl                             AC_MSG_ERROR([** Coulnd't find ALSA header file sys/asoundlib.h **])
305 dnl                     fi
306 dnl             fi
307 dnl     else
308 dnl             if test "$enable_alsa" = "yes"; then
309 dnl                     AC_MSG_ERROR([** Coulnd'f find ALSA library libasound. **])
310 dnl             fi
311 dnl     fi
312 dnl fi
313
314 if test "$enable_oss" != "no"; then
315         AC_CHECK_HEADERS(sys/ioctl.h sys/soundcard.h,oss=yes,oss=no)
316         
317         if test "$oss" = "yes"; then
318                 AC_DEFINE(USE_OSS)
319                 using_oss=yes;
320         else
321                 if test "$enable_oss" = "yes"; then
322                         AC_MSG_ERROR([** Couldn't find OSS header files. ***])
323                 fi
324         fi
325 fi
326
327 dnl if test "$using_alsa" = "yes"; then
328 dnl     AC_MSG_RESULT([termnatorX audiodevice: using ALSA.])
329 dnl fi
330
331 if test "$using_oss" = "yes"; then
332         AC_MSG_RESULT([termnatorX audiodevice: using OSS.])
333 fi
334
335 if test "$using_alsa" != "yes"; then
336         if test "$using_oss" != "yes"; then
337                 AC_MSG_ERROR([** Found neither OSS nor ALSA! **])
338         fi
339 fi      
340         
341 if test "$enable_wav" != "no";
342 then
343         AC_DEFINE(USE_BUILTIN_WAV)
344         OPTION_WAV="yes"
345 fi
346
347 if test "$enable_flash" = "no"; then
348         AC_DEFINE(DONT_USE_FLASH)
349 fi 
350
351 if test "$enable_3dnow" = "yes"; then
352         AC_DEFINE(USE_3DNOW)
353 fi 
354
355 if test "$enable_scheduler" != "no"; then
356         AC_DEFINE(USE_SCHEDULER)
357 fi
358
359 if test "$enable_debug" = yes; then
360         AC_DEFINE(ENABLE_DEBUG_OUTPUT)
361 fi
362
363 if test "$enable_benchmark" = yes; then
364         AC_DEFINE(CREATE_BENCHMARK)
365 fi
366
367 dnl AC_MSG_CHECKING(whether to use dials)
368 dnl if test "$enable_dial" = no; then
369 dnl     AC_MSG_RESULT(no)
370 dnl else
371 dnl     AC_MSG_RESULT(yes)
372         AC_DEFINE(USE_DIAL)
373 dnl fi
374
375 AC_MSG_CHECKING(for necessary scratching skillz)
376 AC_MSG_RESULT(yes)
377
378 if test "$enable_bigdial" = yes; then
379         AC_DEFINE(USE_DIAL)
380         AC_DEFINE(USE_BIG_BUTTONS)
381 fi
382
383 if test "$enable_dga2" = yes; then
384         AC_DEFINE(USE_DGA2)
385 fi
386
387 AC_MSG_CHECKING(for GNOME)
388         AC_MSG_RESULT([in progress])
389         AC_CHECK_PROG(gnomepresent, gnome-name-service, yes, no)
390         if test "$gnomepresent" = yes; then
391                 AC_CHECK_PROG(gnomeconfig, gnome-config, yes)
392                 if test "$gnomeconfig" = yes; then
393                         gnomedatadir=`gnome-config --datadir`
394                 else
395                         gnomedatadir=${datadir}
396                 fi
397                 AC_SUBST(gnomedatadir)
398                 AM_CONDITIONAL(GNOMEpresent, test "$gnomepresent" = yes)
399                 AC_MSG_RESULT([Found GNOME - installing terminatorX.desktop.])
400                 OPTION_GNOME="yes"
401         else
402                 AC_MSG_RESULT([GNOME not found.])
403         fi
404
405
406 dnl Detecting libxml. Based on dia's test.
407 found_libxml=false
408
409 if test "$enable_libxml2" != "no"; then
410         if ! $found_libxml; then
411           AC_CHECK_PROG(XML2_CONFIG, xml2-config, xml2-config)
412           if test "x$XML2_CONFIG" != x ; then
413             AC_MSG_CHECKING(for libxml >= 2.3.9)
414             vers=`$XML2_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
415
416             if test "$vers" -ge 2003009; then
417               AC_MSG_RESULT(yes)
418               found_libxml=true
419               XML_LIBS="`$XML2_CONFIG --libs`"
420               XML_CFLAGS="`$XML2_CONFIG --cflags`"
421             else
422               AC_MSG_RESULT(no)
423             fi
424           fi
425         fi
426 fi      
427
428 if ! $found_libxml 
429 then
430         AC_CHECK_PROG(XML_CONFIG, xml-config, xml-config)
431         if test "x$XML_CONFIG" != x ; then
432           AC_MSG_CHECKING(for libxml >= 1.8.14)
433           vers=`$XML_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
434
435           dnl 1.18.14 is required for xmlUseNewParser()    
436           if test "$vers" -ge 1008014; then
437             AC_MSG_RESULT(yes)
438             found_libxml=true
439             XML_LIBS="`$XML_CONFIG --libs`"
440             XML_CFLAGS="`$XML_CONFIG --cflags`"
441           else
442             AC_MSG_RESULT(no)
443           fi
444         fi
445 fi
446
447 if ! $found_libxml; then
448     AC_MSG_ERROR([** libxml not found. Get libxml(2) at http://www.libxml.org **])
449 fi
450
451 AC_SUBST(XML_LIBS)
452 AC_SUBST(XML_CFLAGS)
453
454 CFLAGS="$XML_CFLAGS $CFLAGS"
455 LIBS="$XML_LIBS $LIBS"
456
457 dnl Now Check for Xlibs - I do this here as other tests fail if these run earlier
458 AC_PATH_XTRA
459
460 AC_SUBST(X_CFLAGS)
461 AC_SUBST(X_PRE_LIBS)
462 AC_SUBST(X_EXTRA_LIBS)
463 AC_SUBST(X_LIBS)
464 AC_SUBST(x_libraries)
465
466 GTK_LIBS="$GTK_LIBS $X_LIBS"
467 AC_CHECK_LIB(X11, XOpenDisplay,, AC_MSG_ERROR([** X11-libs not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
468 AC_CHECK_LIB(Xext, XShmQueryExtension,, AC_MSG_ERROR([** Xext-libs not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
469 AC_CHECK_LIB(Xi, XOpenDevice,, AC_MSG_ERROR([** XInput not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
470 AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension,, AC_MSG_ERROR([** DGA not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
471 if test "$enable_dga2" = yes; then
472         AC_CHECK_LIB(Xxf86dga, XDGASelectInput,, AC_MSG_ERROR([** DGA2 not installed. Try using dga1 instead. **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
473 fi
474 AC_OUTPUT(Makefile src/Makefile gnome-support/Makefile gnome-support/terminatorX.keys src/gui_icons/Makefile src/smallknob/Makefile doc/Makefile doc/img/Makefile terminatorX.spec terminatorX.1)
475
476 echo
477 echo configured terminatorX for:
478 echo ---------------------------
479 echo
480 echo "sox support:              $OPTION_SOX"
481 echo "mpg123 support:           $OPTION_MPG123"
482 echo "mad support:              $OPTION_MAD"
483 echo "ogg123 support:           $OPTION_OGG123"
484 echo "vorbis support:           $OPTION_VORBIS"
485 echo "audiofile support:        $OPTION_AUDIOFILE"
486 echo "builtin-wav support:      $OPTION_WAV"
487 echo "gtk+ Version:             $OPTION_GTK_VERSION"
488 echo "GNOME support:            $OPTION_GNOME"
489 echo
490 echo You can now run \'make\' to compile terminatorX