]> git.decadent.org.uk Git - ion3.git/blob - build/ac/configure.ac
88a8d4daf3ad4683c9f11a1314c1a9d37a0bef1e
[ion3.git] / build / ac / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl Please report bugs in this autoconf script Tom Payne <ion@tompayne.org>
3 dnl $Header: /home/twp/cvsroot/twp/ion/ion-devel-autoconf/configure.ac,v 1.16 2004/01/14 11:32:19 twp Exp $
4
5 AC_INIT([Ion Window Manager],
6         [3ds-20070318],
7         [nobody@nowhere.invalid],
8         [ion3])
9 AC_PREREQ([2.58])
10 AC_REVISION([$Revision: 1.16 $])
11
12 dnl Checks for programs. {{{
13 AC_PROG_CC()
14 AC_PROG_EGREP()
15 AC_PROG_INSTALL()
16 AC_PROG_RANLIB()
17 AC_CHECK_TOOL([STRIP], [strip], [:])
18 AC_CHECK_TOOL([AR], [ar], [])
19 AC_CHECK_PROG(XMESSAGE, xmessage, xmessage)
20 if test "x${XMESSAGE}" = "x"; then
21    AC_MSG_WARN([*** ion needs xmessage to run correctly])
22 fi
23 dnl }}}
24
25 dnl Checks for libraries. {{{
26 AC_PATH_XTRA()
27 AC_CHECK_HEADER([libintl.h], [],
28                 [AC_MSG_ERROR([*** libintl.h not found.
29                   *** You probably need to install libc6-dev])])
30 dnl Perhaps we should check for -lintl, but on my machine, 
31 dnl the library isn't needed. Only the #include is necessary.
32
33 test "${X_DISPLAY_MISSING+set}" = set && exit 1
34 AC_CHECK_HEADER([X11/SM/SMlib.h], [], 
35                 [AC_MSG_ERROR([*** SMlib.h not found.
36                   *** You probably need to install libsm-dev])])
37 AC_CHECK_HEADER([X11/Xresource.h], [], 
38                 [AC_MSG_ERROR([*** Xresource.h.h not found.
39                   *** You probably need to install libx11-dev])])
40 AC_CHECK_LIB([Xext],
41              [XMissingExtension],
42              [X_LIBS="$X_LIBS -lXext"],
43              [AC_MSG_ERROR([*** Missing symbol XMissingExtension in Xext])],
44              [$X_PRE_LIBS -lX11 $X_LIBS $X_EXTRA_LIBS])
45 dnl }}}
46
47 dnl XINERAMA_LIBS, _DCF_NO_XINERAMA {{{
48
49 AC_SUBST([XINERAMA_LIBS])
50 AC_SUBST([_DCF_NO_XINERAMA])
51
52 AC_ARG_ENABLE([xinerama],
53               [AS_HELP_STRING([--disable-xinerama],
54                               [Disable Xinerama support])])
55
56 if test "x$enable_xinerama" != xno; then
57     AC_CHECK_LIB([Xinerama],
58                  [XineramaQueryExtension],
59                  [XINERAMA_LIBS="-lXinerama"],
60                  [AC_MSG_WARN([*** Xinerama disabled (not available)])
61                   enable_xinerama="no"],
62                  [$X_PRE_LIBS -lX11 $X_LIBS $X_EXTRA_LIBS])
63
64 fi
65
66 if test "x$enable_xinerama" = xno; then
67     _DCF_NO_XINERAMA="-DCF_NO_XINERAMA"
68 fi
69
70 dnl }}}
71
72 dnl _DCF_XFREE86_TEXTPROP_BUG_WORKAROUND {{{
73
74 AC_SUBST([_DCF_XFREE86_TEXTPROP_BUG_WORKAROUND])
75
76 AC_ARG_ENABLE([xfree86-textprop-bug-workaround],
77               [AS_HELP_STRING([--disable-xfree86-textprop-bug-workaround],
78                               [Disable the XFree86 textprop bug workaround])])
79
80 if test "x$enable_xfree86_textprop_bug_workaround" != xno; then
81     _DCF_XFREE86_TEXTPROP_BUG_WORKAROUND="-DCF_XFREE86_TEXTPROP_BUG_WORKAROUND"
82 fi
83
84 dnl }}}
85
86 dnl _DCF_DE_USE_XUTF8 {{{
87
88 AC_SUBST([_DCF_DE_USE_XUTF8])
89
90 AC_ARG_ENABLE([Xutf8],
91               [AS_HELP_STRING([--enable-Xutf8],
92                               [Use the Xutf8 routines (XFree86 extension)
93                                instead of Xmb routines in an UTF-8 locale.])])
94
95 if test "x$enable_Xutf8" = xyes; then
96     AC_MSG_CHECKING([for Xutf8*])
97     save_CFLAGS="$CFLAGS"
98     CFLAGS="$CFLAGS $X_CFLAGS"
99     AC_RUN_IFELSE([AC_LANG_SOURCE([[
100 #include <X11/Xlib.h>
101
102 int main()
103 {
104 #ifdef X_HAVE_UTF8_STRING
105     exit(0);
106 #else
107     exit(1);
108 #endif
109 }
110                   ]])],
111                   [AC_MSG_RESULT([yes])
112                    _DCF_DE_USE_XUTF8="-DCF_DE_USE_XUTF8"],
113                   [AC_MSG_RESULT([no])
114                    exit 1])
115     CFLAGS="$save_CFLAGS"
116 fi
117
118 dnl }}}
119
120 dnl _DCF_SUN_F1X_REMAP {{{
121
122 AC_SUBST([_DCF_SUN_F1X_REMAP])
123
124 AC_ARG_ENABLE([sun-f1x-remap],
125                           [AS_HELP_STRING([--enable-sun-f1x-remap],
126                                                           [Remap F11 key to SunF36 and F12 to SunF37])])
127
128 if test "x$enable_sun_f1x_remap" == xyes; then
129         _DCF_SUN_F1X_REMAP="-DCF_SUN_F1X_REMAP"
130 fi
131
132 dnl }}}
133
134 dnl DL_LIBS {{{
135
136 AC_SUBST([DL_LIBS])
137
138 AC_CHECK_HEADER([dlfcn.h], [], [AC_MSG_ERROR([*** missing header dlfcn.h])])
139 AC_CHECK_LIB([dl], [dlopen], [DL_LIBS="-ldl"],
140              [AC_MSG_ERROR([*** missing library dl])])
141
142 dnl }}}
143
144 dnl PRELOAD_MODULES {{{
145
146 AC_SUBST(PRELOAD_MODULES)
147
148 AC_ARG_ENABLE([shared],
149               [AS_HELP_STRING([--disable-shared],
150                               [Do not dynamically load modules (preload modules
151                                instead)])])
152
153 if test "x$enable_shared" = xno; then
154     PRELOAD_MODULES="1"
155 fi
156
157 dnl }}}
158
159 dnl LUA, LUAC, LUA_INCLUDES, LUA_LIBS {{{
160
161 AC_SUBST([LUA])
162 AC_SUBST([LUAC])
163 AC_SUBST([LUA_INCLUDES])
164 AC_SUBST([LUA_LIBS])
165
166 dnl Arguments {{{
167 AC_ARG_WITH([lua-prefix],
168             [AS_HELP_STRING([--with-lua-prefix=DIR],
169                             [Lua files are in DIR])])
170 AC_ARG_WITH([lua-includes],
171             [AS_HELP_STRING([--with-lua-includes=DIR],
172                             [Lua include files are in DIR])])
173 AC_ARG_WITH([lua-libraries],
174             [AS_HELP_STRING([--with-lua-libraries=DIR],
175                             [Lua library files are in DIR])])
176 AC_ARG_WITH([lua-suffix],
177             [AS_HELP_STRING([--with-lua-suffix=ARG],
178                             [Lua binary and library files are suffixed with
179                              ARG])])
180 dnl }}}
181
182 dnl LUA {{{
183 if test "x$with_lua_prefix" = x; then
184     lua_search_path="$PATH"
185 else
186     lua_search_path="$with_lua_prefix/bin"
187 fi
188 if test "x$LUA" = x; then
189     AC_PATH_PROG([LUA], [lua$with_lua_suffix], [], [$lua_search_path])
190     test "x$LUA" = x && AC_MSG_ERROR([*** Can't build ion without lua])
191 fi
192 dnl }}}
193
194 dnl lua_version {{{
195 AC_MSG_CHECKING([for lua version >= 5.1])
196 lua_version=$($LUA -v 2>&1 | head -n 1 | cut -d' ' -f2)
197 dnl lua_version=$($LUA -v 2>&1 >/dev/null | head -n 1 | $EGREP -o '[0-9]+(\.[0-9]+)+')
198 case $lua_version in
199 0.* | 1.* | 2.* | 3.* | 4.* | 5.0)
200     AC_MSG_RESULT([no (found $lua_version)])
201     AC_MSG_ERROR([*** can't build ion with this version of lua])
202     ;;
203 *)
204     AC_MSG_RESULT([yes (found $lua_version)])
205     ;;
206 esac
207 dnl }}}
208
209 dnl LUAC {{{
210 if test "x$LUAC" = x; then
211     AC_PATH_PROG([LUAC], [luac$with_lua_suffix], [], [$lua_search_path])
212     test "x$LUAC" = x && exit 1
213 fi
214 dnl }}}
215
216 dnl luac_version {{{
217 AC_MSG_CHECKING([for lua version = luac version])
218 luac_version=$($LUAC -v 2>&1 | head -n 1 | cut -d' ' -f2)
219 if test "x$lua_version" = "x$luac_version"; then
220     AC_MSG_RESULT([yes (found $luac_version)])
221 else
222     AC_MSG_RESULT([no (found $luac_version)])
223     exit 1
224 fi
225 dnl }}}
226
227 dnl LUA_INCLUDES {{{
228 if test "x$with_lua_includes" != x; then
229     LUA_INCLUDES="-I$with_lua_includes"
230 elif test "x$with_lua_prefix" != x; then
231     LUA_INCLUDES="-I$with_lua_prefix/include"
232 fi
233 save_CFLAGS="$CFLAGS"
234 CFLAGS="$CFLAGS $LUA_INCLUDES"
235 AC_CHECK_HEADERS([lua.h lualib.h], [],
236                  [AC_MSG_ERROR([*** missing headers lua.h or lualib.h.
237                   *** install the lua's -dev package or check --with-lua-includes option.])], [])
238 CFLAGS="$save_CFLAGS"
239 dnl }}}
240
241 dnl LUA_LIBS {{{
242 if test "x$with_lua_libraries" != x; then
243     LUA_LIBS="-L$with_lua_libraries"
244 elif test "x$with_lua_prefix" != x; then
245     LUA_LIBS="-L$with_lua_prefix/lib"
246 fi
247 AC_CHECK_LIB([m], [exp], [lua_extra_libs="$lua_extra_libs -lm"], [])
248 AC_CHECK_LIB([dl], [dlopen], [lua_extra_libs="$lua_extra_libs -ldl"], [])
249 AC_CHECK_LIB([lua$with_lua_suffix],
250              [lua_call],
251              [LUA_LIBS="$LUA_LIBS -llua$with_lua_suffix $lua_extra_libs"],
252              [AC_MSG_ERROR([*** Can't find lua_call in lua$with_lua_suffix.
253                   *** Check for liblua installation or --with-lua-libraries or --with-lua-suffix options])],
254              [$LUA_LIBS $lua_extra_libs])
255 dnl }}}
256
257 dnl liblua_version {{{
258 AC_MSG_CHECKING([for liblua version >= 5.1])
259 save_CFLAGS="$CFLAGS"
260 save_LIBS="$LIBS"
261 CFLAGS="$CFLAGS $LUA_INCLUDES"
262 LIBS="$LIBS $LUA_LIBS"
263 AC_RUN_IFELSE([AC_LANG_SOURCE([[
264
265 #include <lua.h>
266 #include <stdlib.h>
267 #include <string.h>
268 #include <stdio.h>
269
270 int main()
271 {
272     printf("(found %s, %d)... ", LUA_VERSION, LUA_VERSION_NUM);
273     if(LUA_VERSION_NUM >= 501)
274         exit(EXIT_SUCCESS);
275     exit(EXIT_FAILURE);
276 }
277
278 ]])],
279               [AC_MSG_RESULT([yes])],
280               [AC_MSG_RESULT([no])
281                exit 1])
282 CFLAGS="$save_CFLAGS"
283 LIBS="$save_LIBS"
284 dnl }}}
285
286 dnl }}}
287
288 dnl HAS_SYSTEM_ASPRINTF {{{
289
290 AC_SUBST([HAS_SYSTEM_ASPRINTF])
291
292 AC_CHECK_FUNC([asprintf],
293               [AC_CHECK_FUNC([vasprintf],
294                              [HAS_SYSTEM_ASPRINTF="1"])])
295
296 dnl }}}
297
298 dnl XOPEN_SOURCE {{{
299
300 AC_SUBST([XOPEN_SOURCE])
301
302 AC_ARG_ENABLE([xopen-source],
303               [AS_HELP_STRING([--enable-xopen-source],
304                               [Enable X/Open C flags (development use only)])])
305
306 if test "x$enable_xopen_source" = xyes; then
307     AC_MSG_CHECKING([for $CC flags to accept X/Open C])
308     case $host in
309     # FIXME: what flags are required for other hosts/compilers?
310     *-*-solaris* | *-*-sunos*)
311         XOPEN_SOURCE="-D__EXTENSIONS__"
312         ;;
313     *)
314         XOPEN_SOURCE="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
315         ;;
316     esac
317     AC_MSG_RESULT([$XOPEN_SOURCE])
318 fi
319
320 dnl }}}
321
322 dnl C99_SOURCE {{{
323
324 AC_SUBST([C99_SOURCE])
325
326 AC_ARG_ENABLE([c99-source],
327               [AS_HELP_STRING([--enable-c99-source],
328                               [Enable C99 source (development use only)])])
329
330 if test "x$enable_c99_source" = xyes; then
331     AC_MSG_CHECKING([for $CC flags to accept C99])
332     case $CC in
333     # FIXME: what flags are required for other hosts/compilers?
334     gcc*)
335         C99_SOURCE="-std=c99"
336         ;;
337     esac
338     AC_MSG_RESULT([$C99_SOURCE])
339 fi
340
341 dnl }}}
342
343 dnl _DCF_HAS_VA_COPY {{{
344
345 AC_SUBST([_DCF_HAS_VA_COPY])
346
347 dnl check for va_copy {{{
348
349 AC_MSG_CHECKING([for va_copy])
350 save_CFLAGS="$CFLAGS"
351 CFLAGS="$CFLAGS $C99_SOURCE"
352 AC_RUN_IFELSE([AC_LANG_SOURCE([[
353
354 #include <stdarg.h>
355 #include <stdlib.h>
356
357 void f(void *last, ...)
358 {
359     va_list ap, aq;
360     va_start(ap, last);
361     va_copy(aq, ap);
362     va_end(ap);
363     exit(va_arg(aq, int));
364 }
365
366 int main()
367 {
368     f(NULL, EXIT_SUCCESS);
369     exit(EXIT_FAILURE);
370 }
371
372 ]])],
373                   [AC_MSG_RESULT([yes])
374                    _DCF_HAS_VA_COPY="-DCF_HAVE_VA_COPY"],
375                   [AC_MSG_RESULT([no])])
376 CFLAGS="$save_CFLAGS"
377
378 dnl }}}
379
380 dnl check whether -ansi breaks va_copy {{{
381
382 if test "x${XOPEN_SOURCE}" != "x"; then
383     AC_MSG_CHECKING([whether XOPEN_SOURCE breaks va_copy])
384     save_CFLAGS="$CFLAGS"
385     CFLAGS="$CFLAGS $XOPEN_SOURCE $C99_SOURCE"
386     AC_LINK_IFELSE([AC_LANG_SOURCE([[
387
388 #include <stdarg.h>
389 #include <stdlib.h>
390
391 void f(void *last, ...)
392 {
393     va_list ap, aq;
394     va_start(ap, last);
395     va_copy(aq, ap);
396     va_end(ap);
397     va_end(aq);
398 }
399
400 int main()
401 {
402     f(NULL);
403     exit(EXIT_SUCCESS);
404 }
405
406 ]])],
407                       [AC_MSG_RESULT([no])],
408                       [AC_MSG_RESULT([yes, clearing XOPEN_SOURCE])
409                        XOPEN_SOURCE=""])
410     CFLAGS="$save_CFLAGS"
411 fi
412 dnl }}}
413
414 dnl }}}
415
416 dnl _DCF_NO_LOCALE {{{
417
418 AC_SUBST([_DCF_NO_LOCALE])
419
420 AC_ARG_ENABLE([locale],
421                           [AS_HELP_STRING([--disable-locale],
422                                                           [Disable locale support])])
423
424 if test "x$enable_locale" == xno; then
425         _DCF_NO_LOCALE="-DCF_NO_LOCALE"
426 fi
427
428 dnl }}}
429
430
431 AC_OUTPUT([system-ac.mk])
432
433 if test "x$lua_version" = "x5.0"; then
434     AC_MSG_NOTICE([**])
435     AC_MSG_NOTICE([** lua version 5.0 is buggy, consider upgrading to 5.0.1])
436     AC_MSG_NOTICE([** see http://lua-users.org/lists/lua-l/2003-10/msg00039.html])
437     AC_MSG_NOTICE([**])
438 fi
439
440 dnl vim: foldmethod=marker tabstop=4 shiftwidth=4