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