LADSPA configure tweaks. Alex
[terminatorX.git] / terminatorX / 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
25 dnl Checks for programs.
26 AC_PROG_AWK
27 AC_PROG_CC
28 AC_PROG_CXX
29 AC_PROG_INSTALL
30 AC_PROG_LN_S
31 AC_PROG_RANLIB
32
33 dnl Checks for libraries.
34 AC_CHECK_LIB(m, floor,, AC_MSG_ERROR([** math-lib not installed or broken **]))
35
36 dnl Checking whether -pthreads, -lpthreads or simply nothing
37
38 tX_threads=no
39
40 dnl Some machines don't require any switches for pthread support...
41
42 AC_MSG_CHECKING([whether pthreads works without switches])
43         no_threads_flags=no
44         AC_LANG_SAVE
45         AC_LANG_C
46         AC_TRY_LINK([#include <pthread.h>], [ pthread_t thread; pthread_create(&thread, NULL, NULL, NULL);],
47                 no_threads_flags=yes,
48                 no_threads_flags=no
49         )
50         AC_LANG_RESTORE
51 AC_MSG_RESULT([$no_threads_flags])
52
53 if test "$no_threads_flags" = "yes"; then
54         tX_threads=auto
55 fi
56
57 dnl Some machines prefer a -pthread...
58
59 if test "$tX_threads" = "no"; then
60         AC_MSG_CHECKING([whether -pthread is required for pthreads])
61                 use_gcc_threads=no
62                 ac_save_CFLAGS=$CFLAGS
63                 CFLAGS="$CFLAGS -pthread"
64                 AC_LANG_SAVE
65                 AC_LANG_C
66                 AC_TRY_LINK([#include <pthread.h>], [ pthread_t thread; pthread_create(&thread, NULL, NULL, NULL);],
67                         use_gcc_threads=yes,
68                         use_gcc_threads=no
69                 )
70                 AC_LANG_RESTORE
71                 CFLAGS=$ac_save_CFLAGS
72         AC_MSG_RESULT([$use_gcc_threads])
73         
74         if test "$use_gcc_threads" = "yes"; then
75                 tX_threads=gcc
76                 CFLAGS="$CFLAGS -pthread"
77         fi
78 fi
79
80 dnl If we haven't found pthreads yet will try -lpthread...
81
82 if test "$tX_threads" = "no"; then
83         pthread_lib=no
84         AC_CHECK_LIB(pthread, pthread_detach, pthread_lib=yes, pthread_lib=no)
85         
86         if test "$pthread_lib" = "yes"; then
87                 tX_threads=lpthread
88         fi
89 fi
90
91 dnl If we still haven't found pthreads, we panic...
92
93 if test "$tX_threads" = "no"; then
94         AC_MSG_ERROR([** failed to detect pthreads implementation **])
95 fi
96
97 gtk2="no"
98 gtk12="no"
99
100 if test "$enable_gtk2" != "no"; then
101         AM_PATH_GTK_2_0(, [
102           GTK2_CFLAGS="$GTK_CFLAGS"
103           GTK2_LIBS="$GTK_LIBS"
104           gtk2="yes"
105           GTK2_VERSION="`$PKG_CONFIG --modversion gtk+-2.0`"], [ gtk2="no" ]) 
106 fi
107
108 if test "$gtk2" = "no"; then
109         AM_PATH_GTK([1.2.5], [
110           GTK12_CFLAGS="$GTK_CFLAGS"
111           GTK12_LIBS="$GTK_LIBS"
112           gtk12="yes"
113           GTK12_VERSION="`$GTK_CONFIG $gtk_config_args --version`"], [ gtk12="no" ])
114 fi
115
116 if test "$gtk2" = "yes"; then
117         AC_MSG_RESULT([using gtk+ version 2 as widget toolkit.])
118         AC_DEFINE(USE_GTK2)
119 else
120         if test "$gtk12" = "yes"; then
121                 AC_MSG_RESULT([using gtk+ version 1.2 as widget toolkit.])
122         else
123                 AC_MSG_ERROR([** couldn't find gtk+ > Version 1.2.5 **])
124         fi
125 fi
126
127 dnl Checks for header files.
128 AC_HEADER_STDC
129 AC_CHECK_HEADERS(fcntl.h limits.h malloc.h unistd.h)
130
131 dnl Disable LADSPA caching..
132 unset ac_cv_header_ladspa_h
133
134 have_ladspa=no
135 AC_CHECK_HEADERS(ladspa.h, have_ladspa=yes, have_ladspa=no)
136
137 dnl Disable LADSPA caching..
138 unset ac_cv_header_ladspa_h
139
140 dnl Some people install LADSPA in /usr/local
141
142 if test "$have_ladspa" = "no"; then
143         ac_save_CFLAGS=$CFLAGS
144         CFLAGS="$CFLAGS -I/usr/local/include"
145         AC_CHECK_HEADERS(ladspa.h, have_ladspa=yes, have_ladspa=no)
146         CFLAGS=$ac_save_CFLAGS
147         
148         if test "$have_ladspa" = "yes"; then
149                 CFLAGS="$CFLAGS -I/usr/local/include"
150         fi
151 fi
152
153 if test "$have_ladspa" = "no"; then
154         AC_MSG_ERROR([** couldn't find ladspa.h - Install the LADSPA SDK from http://www.ladspa.org first. **])
155 fi
156
157 dnl Checks for typedefs, structures, and compiler characteristics.
158 AC_C_BIGENDIAN
159 AC_TYPE_SIZE_T
160
161 dnl Checks for library functions.
162 AC_PROG_GCC_TRADITIONAL
163
164 dnl Eval args
165 if test "$enable_closedev" = "no"; then
166         AC_DEFINE(KEEP_DEV_OPEN)
167 fi
168
169
170 if test "$enable_sox" != "no"; then
171         AC_CHECK_PROG(SOX_PROG, sox, yes)
172         if test "$SOX_PROG" = "yes"; then
173                 AC_DEFINE(USE_SOX_INPUT)
174         fi
175 fi
176
177 if test "$enable_mpg123" != "no"; then
178         AC_CHECK_PROG(MPG123_PROG, mpg123, yes)
179         if test "$MPG123_PROG" = "yes"; then
180                 if test "$SOX_PROG" = "yes"; then       
181                         AC_DEFINE(USE_MPG123_INPUT)
182                 else
183                         AC_CHECK_PROG(SOX_PROG, sox, yes)
184                         if test "$SOX_PROG" = "yes"; then       
185                                 AC_DEFINE(USE_MPG123_INPUT)
186                         else
187                                 AC_MSG_RESULT([** mpg123 support disabled: couldn't find sox! **])
188                         fi
189                 fi
190         fi
191 fi
192
193 if test "$enable_ogg123" != "no"; then
194         AC_CHECK_PROG(OGG123_PROG, ogg123, yes)
195         if test "$OGG123_PROG" = "yes"; then
196                 AC_DEFINE(USE_OGG123_INPUT)
197         fi
198 fi
199
200 if test "$enable_xsetpointer" != "no"; then
201         AC_CHECK_PROG(XSETPOINTER_PROG, xsetpointer, yes)
202         if test "$XSETPOINTER_PROG" = "yes"; then
203                 AC_DEFINE(USE_XSETPOINTER)
204         else
205                 if test "$enable_xsetpointer" = "yes"; then
206                         AC_MSG_ERROR([** xsetpointer not found. **])
207                 fi
208         fi
209 fi
210
211 if test "$enable_movqfix" = "no"; then
212         AC_DEFINE(OVERRIDE_MOVQ_AUTODETECT)
213 fi
214
215 using_alsa=no
216 using_oss=no
217
218 dnl if test "$enable_alsa" != "no"; then
219 dnl     AC_CHECK_LIB(asound, snd_ctl_open,alsalib=yes,alsalib=no)
220 dnl     AC_CHECK_HEADERS(sys/asoundlib.h,alsaheader=yes,alsaheader=no)
221 dnl
222 dnl     if test "$alsalib" = "yes"; then
223 dnl             if test "$alsaheader" = "yes"; then
224 dnl                     AC_DEFINE(USE_ALSA)
225 dnl                     using_alsa=yes;
226 dnl             else 
227 dnl                     if test "$enable_alsa" = "yes"; then
228 dnl                             AC_MSG_ERROR([** Coulnd't find ALSA header file sys/asoundlib.h **])
229 dnl                     fi
230 dnl             fi
231 dnl     else
232 dnl             if test "$enable_alsa" = "yes"; then
233 dnl                     AC_MSG_ERROR([** Coulnd'f find ALSA library libasound. **])
234 dnl             fi
235 dnl     fi
236 dnl fi
237
238 if test "$enable_oss" != "no"; then
239         AC_CHECK_HEADERS(sys/ioctl.h sys/soundcard.h,oss=yes,oss=no)
240         
241         if test "$oss" = "yes"; then
242                 AC_DEFINE(USE_OSS)
243                 using_oss=yes;
244         else
245                 if test "$enable_oss" = "yes"; then
246                         AC_MSG_ERROR([** Couldn't find OSS header files. ***])
247                 fi
248         fi
249 fi
250
251 dnl if test "$using_alsa" = "yes"; then
252 dnl     AC_MSG_RESULT([termnatorX audiodevice: using ALSA.])
253 dnl fi
254
255 if test "$using_oss" = "yes"; then
256         AC_MSG_RESULT([termnatorX audiodevice: using OSS.])
257 fi
258
259 if test "$using_alsa" != "yes"; then
260         if test "$using_oss" != "yes"; then
261                 AC_MSG_ERROR([** Found neither OSS nor ALSA! **])
262         fi
263 fi      
264         
265 if test "$enable_wav" != "no";
266 then
267         AC_DEFINE(USE_BUILTIN_WAV)
268 fi
269
270 if test "$enable_flash" = "no"; then
271         AC_DEFINE(DONT_USE_FLASH)
272 fi 
273
274 if test "$enable_3dnow" = "yes"; then
275         AC_DEFINE(USE_3DNOW)
276 fi 
277
278 if test "$enable_scheduler" != "no"; then
279         AC_DEFINE(USE_SCHEDULER)
280 fi
281
282 if test "$enable_debug" = yes; then
283         AC_DEFINE(ENABLE_DEBUG_OUTPUT)
284 fi
285
286 if test "$enable_benchmark" = yes; then
287         AC_DEFINE(CREATE_BENCHMARK)
288 fi
289
290 dnl AC_MSG_CHECKING(whether to use dials)
291 dnl if test "$enable_dial" = no; then
292 dnl     AC_MSG_RESULT(no)
293 dnl else
294 dnl     AC_MSG_RESULT(yes)
295         AC_DEFINE(USE_DIAL)
296 dnl fi
297
298 AC_MSG_CHECKING(for necessary scratching skillz)
299 AC_MSG_RESULT(yes)
300
301 if test "$enable_bigdial" = yes; then
302         AC_DEFINE(USE_DIAL)
303         AC_DEFINE(USE_BIG_BUTTONS)
304 fi
305
306 if test "$enable_dga2" = yes; then
307         AC_DEFINE(USE_DGA2)
308 fi
309
310 AC_MSG_CHECKING(for GNOME)
311         AC_MSG_RESULT([in progress])
312         AC_CHECK_PROG(gnomepresent, gnome-name-service, yes, no)
313         if test "$gnomepresent" = yes; then
314                 AC_CHECK_PROG(gnomeconfig, gnome-config, yes)
315                 if test "$gnomeconfig" = yes; then
316                         gnomedatadir=`gnome-config --datadir`
317                 else
318                         gnomedatadir=${datadir}
319                 fi
320                 AC_SUBST(gnomedatadir)
321                 AM_CONDITIONAL(GNOMEpresent, test "$gnomepresent" = yes)
322                 AC_MSG_RESULT([Found GNOME - installing terminatorX.desktop.])
323         else
324                 AC_MSG_RESULT([GNOME not found.])
325         fi
326
327
328 dnl Now Check for Xlibs - I do this here as other tests fail if these run earlier
329 AC_PATH_XTRA
330
331 AC_SUBST(X_CFLAGS)
332 AC_SUBST(X_PRE_LIBS)
333 AC_SUBST(X_EXTRA_LIBS)
334 AC_SUBST(X_LIBS)
335 AC_SUBST(x_libraries)
336
337 GTK_LIBS="$GTK_LIBS $X_LIBS"
338 AC_CHECK_LIB(X11, XOpenDisplay,, AC_MSG_ERROR([** X11-libs not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
339 AC_CHECK_LIB(Xext, XShmQueryExtension,, AC_MSG_ERROR([** Xext-libs not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
340 AC_CHECK_LIB(Xi, XOpenDevice,, AC_MSG_ERROR([** XInput not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
341 AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension,, AC_MSG_ERROR([** DGA not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
342 if test "$enable_dga2" = yes; then
343         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)
344 fi
345 AC_OUTPUT(Makefile src/Makefile gnome-support/Makefile gnome-support/terminatorX.keys src/gui_icons/Makefile src/smallknob/Makefile doc/Makefile doc/img/Makefile debian/Makefile terminatorX.spec terminatorX.1)