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