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