trunk: changeset 1861
[notion/jeffpc.git] / configure.ac
blob83d7f7a36ccfd3921208069a8361b87e03dc93b2
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 $
5 AC_INIT([Ion Window Manager],
6         [ION_VERSION],
7         [tuomov@iki.fi],
8         [ion3])
9 AC_PREREQ([2.58])
10 AC_REVISION([$Revision: 1.16 $])
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 dnl }}}
21 dnl Checks for libraries. {{{
22 AC_PATH_XTRA()
23 test "${X_DISPLAY_MISSING+set}" = set && exit 1
24 AC_CHECK_LIB([Xext],
25              [XMissingExtension],
26              [X_LIBS="$X_LIBS -lXext"],
27              [exit 1],
28              [$X_PRE_LIBS -lX11 $X_LIBS $X_EXTRA_LIBS])
29 dnl }}}
31 dnl XINERAMA_LIBS, _DCF_NO_XINERAMA {{{
33 AC_SUBST([XINERAMA_LIBS])
34 AC_SUBST([_DCF_NO_XINERAMA])
36 AC_ARG_ENABLE([xinerama],
37               [AS_HELP_STRING([--disable-xinerama],
38                               [Disable Xinerama support])])
40 if test "x$enable_xinerama" != xno; then
41     AC_CHECK_LIB([Xinerama],
42                  [XineramaQueryExtension],
43                  [XINERAMA_LIBS="-lXinerama"],
44                  [exit 1],
45                  [$X_PRE_LIBS -lX11 $X_LIBS $X_EXTRA_LIBS])
46 else
47     _DCF_NO_XINERAMA="-DCF_NO_XINERAMA"
50 dnl }}}
52 dnl _DCF_XFREE86_TEXTPROP_BUG_WORKAROUND {{{
54 AC_SUBST([_DCF_XFREE86_TEXTPROP_BUG_WORKAROUND])
56 AC_ARG_ENABLE([xfree86-textprop-bug-workaround],
57               [AS_HELP_STRING([--disable-xfree86-textprop-bug-workaround],
58                               [Disable the XFree86 textprop bug workaround])])
60 if test "x$enable_xfree86_textprop_bug_workaround" != xno; then
61     _DCF_XFREE86_TEXTPROP_BUG_WORKAROUND="-DCF_XFREE86_TEXTPROP_BUG_WORKAROUND"
64 dnl }}}
66 dnl _DCF_DE_USE_XUTF8 {{{
68 AC_SUBST([_DCF_DE_USE_XUTF8])
70 AC_ARG_ENABLE([Xutf8],
71               [AS_HELP_STRING([--enable-Xutf8],
72                               [Use the Xutf8 routines (XFree86 extension)
73                                instead of Xmb routines in an UTF-8 locale given
74                                the -i18n command line option])])
76 if test "x$enable_Xutf8" = xyes; then
77     AC_MSG_CHECKING([for Xutf8*])
78     save_CFLAGS="$CFLAGS"
79     CFLAGS="$CFLAGS $X_CFLAGS"
80     AC_RUN_IFELSE([AC_LANG_SOURCE([[
81 #include <X11/Xlib.h>
83 int main()
85 #ifdef X_HAVE_UTF8_STRING
86     exit(0);
87 #else
88     exit(1);
89 #endif
91                   ]])],
92                   [AC_MSG_RESULT([yes])
93                    _DCF_DE_USE_XUTF8="-DCF_DE_USE_XUTF8"],
94                   [AC_MSG_RESULT([no])
95                    exit 1])
96     CFLAGS="$save_CFLAGS"
99 dnl }}}
101 dnl _DCF_SUN_F1X_REMAP {{{
103 AC_SUBST([_DCF_SUN_F1X_REMAP])
105 AC_ARG_ENABLE([sun-f1x-remap],
106                           [AS_HELP_STRING([--enable-sun-f1x-remap],
107                                                           [Remap F11 key to SunF36 and F12 to SunF37])])
109 if test "x$enable_sun_f1x_remap" == xyes; then
110         _DCF_SUN_F1X_REMAP="1"
113 dnl }}}
115 dnl DL_LIBS {{{
117 AC_SUBST([DL_LIBS])
119 AC_CHECK_HEADER([dlfcn.h], [], [exit 1])
120 AC_CHECK_LIB([dl], [dlopen], [DL_LIBS="-ldl"], [exit 1])
122 dnl }}}
124 dnl PRELOAD_MODULES {{{
126 AC_SUBST(PRELOAD_MODULES)
128 AC_ARG_ENABLE([shared],
129               [AS_HELP_STRING([--disable-shared],
130                               [Do not dynamically load modules (preload modules
131                                instead)])])
133 if test "x$enable_shared" = xno; then
134     PRELOAD_MODULES="1"
137 dnl }}}
139 dnl LUA, LUAC, LUA_INCLUDES, LUA_LIBS {{{
141 AC_SUBST([LUA])
142 AC_SUBST([LUAC])
143 AC_SUBST([LUA_INCLUDES])
144 AC_SUBST([LUA_LIBS])
146 dnl Arguments {{{
147 AC_ARG_WITH([lua-prefix],
148             [AS_HELP_STRING([--with-lua-prefix=DIR],
149                             [Lua files are in DIR])])
150 AC_ARG_WITH([lua-includes],
151             [AS_HELP_STRING([--with-lua-includes=DIR],
152                             [Lua include files are in DIR])])
153 AC_ARG_WITH([lua-libraries],
154             [AS_HELP_STRING([--with-lua-libraries=DIR],
155                             [Lua library files are in DIR])])
156 AC_ARG_WITH([lua-suffix],
157             [AS_HELP_STRING([--with-lua-suffix=ARG],
158                             [Lua binary and library files are suffixed with
159                              ARG])])
160 dnl }}}
162 dnl LUA {{{
163 if test "x$with_lua_prefix" = x; then
164     lua_search_path="$PATH"
165 else
166     lua_search_path="$with_lua_prefix/bin"
168 if test "x$LUA" = x; then
169     AC_PATH_PROG([LUA], [lua$with_lua_suffix], [], [$lua_search_path])
170     test "x$LUA" = x && exit 1
172 dnl }}}
174 dnl lua_version {{{
175 AC_MSG_CHECKING([for lua version >= 5.0])
176 lua_version=$($LUA -v 2>&1 | head -n 1 | cut -d' ' -f2)
177 dnl lua_version=$($LUA -v 2>&1 >/dev/null | head -n 1 | $EGREP -o '[0-9]+(\.[0-9]+)+')
178 case $lua_version in
179 0.* | 1.* | 2.* | 3.* | 4.*)
180     AC_MSG_RESULT([no (found $lua_version)])
181     exit 1
182     ;;
184     AC_MSG_RESULT([yes (found $lua_version)])
185     ;;
186 esac
187 dnl }}}
189 dnl LUAC {{{
190 if test "x$LUAC" = x; then
191     AC_PATH_PROG([LUAC], [luac$with_lua_suffix], [], [$lua_search_path])
192     test "x$LUAC" = x && exit 1
194 dnl }}}
196 dnl luac_version {{{
197 AC_MSG_CHECKING([for lua version = luac version])
198 luac_version=$($LUAC -v 2>&1 | head -n 1 | cut -d' ' -f2)
199 if test "x$lua_version" = "x$luac_version"; then
200     AC_MSG_RESULT([yes (found $luac_version)])
201 else
202     AC_MSG_RESULT([no (found $luac_version)])
203     exit 1
205 dnl }}}
207 dnl LUA_INCLUDES {{{
208 if test "x$with_lua_includes" != x; then
209     LUA_INCLUDES="-I$with_lua_includes"
210 elif test "x$with_lua_prefix" != x; then
211     LUA_INCLUDES="-I$with_lua_prefix/include"
213 save_CFLAGS="$CFLAGS"
214 CFLAGS="$CFLAGS $LUA_INCLUDES"
215 AC_CHECK_HEADERS([lua.h lualib.h], [], [exit 1], [])
216 CFLAGS="$save_CFLAGS"
217 dnl }}}
219 dnl LUA_LIBS {{{
220 if test "x$with_lua_libraries" != x; then
221     LUA_LIBS="-L$with_lua_libraries"
222 elif test "x$with_lua" != x; then
223     LUA_LIBS="-L$with_lua_prefix/lib"
225 AC_CHECK_LIB([lua$with_lua_suffix],
226              [lua_open],
227              [LUA_LIBS="$LUA_LIBS -llua$with_lua_suffix"],
228              [exit 1],
229              [$LUA_LIBS])
230 AC_CHECK_LIB([dl], [dlopen], [lua_extra_libs="$lua_extra_libs -ldl"], [])
231 AC_CHECK_LIB([m], [exp], [lua_extra_libs="$lua_extra_libs -lm"], [])
232 AC_CHECK_LIB([lualib$with_lua_suffix],
233              [luaopen_loadlib],
234              [LUA_LIBS="$LUA_LIBS $lua_extra_libs -llualib$with_lua_suffix"],
235              [exit 1],
236              [$LUA_LIBS $lua_extra_libs])
237 dnl }}}
239 dnl liblua_version {{{
240 AC_MSG_CHECKING([for liblua version >= 5.0])
241 save_CFLAGS="$CFLAGS"
242 save_LIBS="$LIBS"
243 CFLAGS="$CFLAGS $LUA_INCLUDES"
244 LIBS="$LIBS $LUA_LIBS"
245 AC_RUN_IFELSE([AC_LANG_SOURCE([[
247 #include <lua.h>
248 #include <stdlib.h>
249 #include <string.h>
251 int main()
253     if(strcmp(lua_version(), LUA_VERSION)!=0){
254         printf("Error: lua_version() does not match LUA_VERSION. ");
255         exit(EXIT_FAILURE);
256     }
257     printf("(found %s)... ", lua_version());
258     if(strcmp(lua_version(), "Lua 5.0")<0)
259         exit(EXIT_FAILURE);
260     exit(EXIT_SUCCESS);
263 ]])],
264               [AC_MSG_RESULT([yes])],
265               [AC_MSG_RESULT([no])
266                exit 1])
267 CFLAGS="$save_CFLAGS"
268 LIBS="$save_LIBS"
269 dnl }}}
271 dnl }}}
273 dnl HAS_SYSTEM_ASPRINTF {{{
275 AC_SUBST([HAS_SYSTEM_ASPRINTF])
277 AC_CHECK_FUNC([asprintf],
278               [AC_CHECK_FUNC([vasprintf],
279                              [HAS_SYSTEM_ASPRINTF="1"])])
281 dnl }}}
283 dnl XOPEN_SOURCE {{{
285 AC_SUBST([XOPEN_SOURCE])
287 AC_ARG_ENABLE([xopen-source],
288               [AS_HELP_STRING([--enable-xopen-source],
289                               [Enable X/Open C flags (development use only)])])
291 if test "x$enable_xopen_source" = xyes; then
292     AC_MSG_CHECKING([for $CC flags to accept X/Open C])
293     case $host in
294     # FIXME: what flags are required for other hosts/compilers?
295     *-*-solaris* | *-*-sunos*)
296         XOPEN_SOURCE="-D__EXTENSIONS__"
297         ;;
298     *)
299         XOPEN_SOURCE="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
300         ;;
301     esac
302     AC_MSG_RESULT([$XOPEN_SOURCE])
305 dnl }}}
307 dnl C99_SOURCE {{{
309 AC_SUBST([C99_SOURCE])
311 AC_ARG_ENABLE([c99-source],
312               [AS_HELP_STRING([--enable-c99-source],
313                               [Enable C99 source (development use only)])])
315 if test "x$enable_c99_source" = xyes; then
316     AC_MSG_CHECKING([for $CC flags to accept C99])
317     case $CC in
318     # FIXME: what flags are required for other hosts/compilers?
319     gcc*)
320         C99_SOURCE="-std=c99"
321         ;;
322     esac
323     AC_MSG_RESULT([$C99_SOURCE])
326 dnl }}}
328 dnl _DCF_HAS_VA_COPY {{{
330 AC_SUBST([_DCF_HAS_VA_COPY])
332 dnl check for va_copy {{{
334 AC_MSG_CHECKING([for va_copy])
335 save_CFLAGS="$CFLAGS"
336 CFLAGS="$CFLAGS $C99_SOURCE"
337 AC_RUN_IFELSE([AC_LANG_SOURCE([[
339 #include <stdarg.h>
340 #include <stdlib.h>
342 void f(void *last, ...)
344     va_list ap, aq;
345     va_start(ap, last);
346     va_copy(aq, ap);
347     va_end(ap);
348     exit(va_arg(aq, int));
351 int main()
353     f(NULL, EXIT_SUCCESS);
354     exit(EXIT_FAILURE);
357 ]])],
358                   [AC_MSG_RESULT([yes])
359                    _DCF_HAS_VA_COPY="-DCF_HAVE_VA_COPY"],
360                   [AC_MSG_RESULT([no])])
361 CFLAGS="$save_CFLAGS"
363 dnl }}}
365 dnl check whether -ansi breaks va_copy {{{
367 if test "x${XOPEN_SOURCE}" != "x"; then
368     AC_MSG_CHECKING([whether XOPEN_SOURCE breaks va_copy])
369     save_CFLAGS="$CFLAGS"
370     CFLAGS="$CFLAGS $XOPEN_SOURCE $C99_SOURCE"
371     AC_LINK_IFELSE([AC_LANG_SOURCE([[
373 #include <stdarg.h>
374 #include <stdlib.h>
376 void f(void *last, ...)
378     va_list ap, aq;
379     va_start(ap, last);
380     va_copy(aq, ap);
381     va_end(ap);
382     va_end(aq);
385 int main()
387     f(NULL);
388     exit(EXIT_SUCCESS);
391 ]])],
392                       [AC_MSG_RESULT([no])],
393                       [AC_MSG_RESULT([yes, clearing XOPEN_SOURCE])
394                        XOPEN_SOURCE=""])
395     CFLAGS="$save_CFLAGS"
397 dnl }}}
399 dnl }}}
401 dnl _DCF_NO_LOCALE {{{
403 AC_SUBST([_DCF_NO_LOCALE])
405 AC_ARG_ENABLE([locale],
406                           [AS_HELP_STRING([--disable-locale],
407                                                           [Disable locale support])])
409 if test "x$enable_locale" == xno; then
410         _DCF_NO_LOCALE="-DCF_NO_LOCALE"
413 dnl }}}
416 AC_OUTPUT([system-ac.mk])
418 if test "x$lua_version" = "x5.0"; then
419     AC_MSG_NOTICE([**])
420     AC_MSG_NOTICE([** lua version 5.0 is buggy, consider upgrading to 5.0.1])
421     AC_MSG_NOTICE([** see http://lua-users.org/lists/lua-l/2003-10/msg00039.html])
422     AC_MSG_NOTICE([**])
425 dnl vim: foldmethod=marker tabstop=4 shiftwidth=4