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