Fixing pthreads again - 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 (outdated) 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 AC_CHECK_HEADERS(ladspa.h,, AC_MSG_ERROR([** couldn't find ladspa.h - install the ladspa SDK - get it from http://www.ladspa.org **]))
131
132 dnl Checks for typedefs, structures, and compiler characteristics.
133 AC_C_BIGENDIAN
134 AC_TYPE_SIZE_T
135
136 dnl Checks for library functions.
137 AC_PROG_GCC_TRADITIONAL
138
139 dnl Eval args
140 if test "$enable_closedev" = "no"; then
141         AC_DEFINE(KEEP_DEV_OPEN)
142 fi
143
144
145 if test "$enable_sox" != "no"; then
146         AC_CHECK_PROG(SOX_PROG, sox, yes)
147         if test "$SOX_PROG" = "yes"; then
148                 AC_DEFINE(USE_SOX_INPUT)
149         fi
150 fi
151
152 if test "$enable_mpg123" != "no"; then
153         AC_CHECK_PROG(MPG123_PROG, mpg123, yes)
154         if test "$MPG123_PROG" = "yes"; then
155                 if test "$SOX_PROG" = "yes"; then       
156                         AC_DEFINE(USE_MPG123_INPUT)
157                 else
158                         AC_CHECK_PROG(SOX_PROG, sox, yes)
159                         if test "$SOX_PROG" = "yes"; then       
160                                 AC_DEFINE(USE_MPG123_INPUT)
161                         else
162                                 AC_MSG_RESULT([** mpg123 support disabled: couldn't find sox! **])
163                         fi
164                 fi
165         fi
166 fi
167
168 if test "$enable_ogg123" != "no"; then
169         AC_CHECK_PROG(OGG123_PROG, ogg123, yes)
170         if test "$OGG123_PROG" = "yes"; then
171                 AC_DEFINE(USE_OGG123_INPUT)
172         fi
173 fi
174
175 if test "$enable_xsetpointer" != "no"; then
176         AC_CHECK_PROG(XSETPOINTER_PROG, xsetpointer, yes)
177         if test "$XSETPOINTER_PROG" = "yes"; then
178                 AC_DEFINE(USE_XSETPOINTER)
179         else
180                 if test "$enable_xsetpointer" = "yes"; then
181                         AC_MSG_ERROR([** xsetpointer not found. **])
182                 fi
183         fi
184 fi
185
186 if test "$enable_movqfix" = "no"; then
187         AC_DEFINE(OVERRIDE_MOVQ_AUTODETECT)
188 fi
189
190 using_alsa=no
191 using_oss=no
192
193 dnl if test "$enable_alsa" != "no"; then
194 dnl     AC_CHECK_LIB(asound, snd_ctl_open,alsalib=yes,alsalib=no)
195 dnl     AC_CHECK_HEADERS(sys/asoundlib.h,alsaheader=yes,alsaheader=no)
196 dnl
197 dnl     if test "$alsalib" = "yes"; then
198 dnl             if test "$alsaheader" = "yes"; then
199 dnl                     AC_DEFINE(USE_ALSA)
200 dnl                     using_alsa=yes;
201 dnl             else 
202 dnl                     if test "$enable_alsa" = "yes"; then
203 dnl                             AC_MSG_ERROR([** Coulnd't find ALSA header file sys/asoundlib.h **])
204 dnl                     fi
205 dnl             fi
206 dnl     else
207 dnl             if test "$enable_alsa" = "yes"; then
208 dnl                     AC_MSG_ERROR([** Coulnd'f find ALSA library libasound. **])
209 dnl             fi
210 dnl     fi
211 dnl fi
212
213 if test "$enable_oss" != "no"; then
214         AC_CHECK_HEADERS(sys/ioctl.h sys/soundcard.h,oss=yes,oss=no)
215         
216         if test "$oss" = "yes"; then
217                 AC_DEFINE(USE_OSS)
218                 using_oss=yes;
219         else
220                 if test "$enable_oss" = "yes"; then
221                         AC_MSG_ERROR([** Couldn't find OSS header files. ***])
222                 fi
223         fi
224 fi
225
226 dnl if test "$using_alsa" = "yes"; then
227 dnl     AC_MSG_RESULT([termnatorX audiodevice: using ALSA.])
228 dnl fi
229
230 if test "$using_oss" = "yes"; then
231         AC_MSG_RESULT([termnatorX audiodevice: using OSS.])
232 fi
233
234 if test "$using_alsa" != "yes"; then
235         if test "$using_oss" != "yes"; then
236                 AC_MSG_ERROR([** Found neither OSS nor ALSA! **])
237         fi
238 fi      
239         
240 if test "$enable_wav" != "no";
241 then
242         AC_DEFINE(USE_BUILTIN_WAV)
243 fi
244
245 if test "$enable_flash" = "no"; then
246         AC_DEFINE(DONT_USE_FLASH)
247 fi 
248
249 if test "$enable_3dnow" = "yes"; then
250         AC_DEFINE(USE_3DNOW)
251 fi 
252
253 if test "$enable_scheduler" != "no"; then
254         AC_DEFINE(USE_SCHEDULER)
255 fi
256
257 if test "$enable_debug" = yes; then
258         AC_DEFINE(ENABLE_DEBUG_OUTPUT)
259 fi
260
261 if test "$enable_benchmark" = yes; then
262         AC_DEFINE(CREATE_BENCHMARK)
263 fi
264
265 dnl AC_MSG_CHECKING(whether to use dials)
266 dnl if test "$enable_dial" = no; then
267 dnl     AC_MSG_RESULT(no)
268 dnl else
269 dnl     AC_MSG_RESULT(yes)
270         AC_DEFINE(USE_DIAL)
271 dnl fi
272
273 AC_MSG_CHECKING(for necessary scratching skillz)
274 AC_MSG_RESULT(yes)
275
276 if test "$enable_bigdial" = yes; then
277         AC_DEFINE(USE_DIAL)
278         AC_DEFINE(USE_BIG_BUTTONS)
279 fi
280
281 if test "$enable_dga2" = yes; then
282         AC_DEFINE(USE_DGA2)
283 fi
284
285 AC_MSG_CHECKING(for GNOME)
286         AC_MSG_RESULT([in progress])
287         AC_CHECK_PROG(gnomepresent, gnome-name-service, yes, no)
288         if test "$gnomepresent" = yes; then
289                 AC_CHECK_PROG(gnomeconfig, gnome-config, yes)
290                 if test "$gnomeconfig" = yes; then
291                         gnomedatadir=`gnome-config --datadir`
292                 else
293                         gnomedatadir=${datadir}
294                 fi
295                 AC_SUBST(gnomedatadir)
296                 AM_CONDITIONAL(GNOMEpresent, test "$gnomepresent" = yes)
297                 AC_MSG_RESULT([Found GNOME - installing terminatorX.desktop.])
298         else
299                 AC_MSG_RESULT([GNOME not found.])
300         fi
301
302
303 dnl Now Check for Xlibs - I do this here as other tests fail if these run earlier
304 AC_PATH_XTRA
305
306 AC_SUBST(X_CFLAGS)
307 AC_SUBST(X_PRE_LIBS)
308 AC_SUBST(X_EXTRA_LIBS)
309 AC_SUBST(X_LIBS)
310 AC_SUBST(x_libraries)
311
312 GTK_LIBS="$GTK_LIBS $X_LIBS"
313 AC_CHECK_LIB(X11, XOpenDisplay,, AC_MSG_ERROR([** X11-libs not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
314 AC_CHECK_LIB(Xext, XShmQueryExtension,, AC_MSG_ERROR([** Xext-libs not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
315 AC_CHECK_LIB(Xi, XOpenDevice,, AC_MSG_ERROR([** XInput not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
316 AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension,, AC_MSG_ERROR([** DGA not installed or broken **]), $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
317 if test "$enable_dga2" = yes; then
318         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)
319 fi
320 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)