trunk: changeset 1970
[notion/jeffpc.git] / configure.ac
blob44b27bcbe9a21dd585e3654e300a7c8474b115db
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              [AC_MSG_ERROR([*** Missing symbol XMissingExtension in Xext])],
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                  [AC_MSG_WARN([*** Xinerama disabled (not available)])
45                   enable_xinerama="no"],
46                  [$X_PRE_LIBS -lX11 $X_LIBS $X_EXTRA_LIBS])
50 if test "x$enable_xinerama" = xno; then
51     _DCF_NO_XINERAMA="-DCF_NO_XINERAMA"
54 dnl }}}
56 dnl _DCF_XFREE86_TEXTPROP_BUG_WORKAROUND {{{
58 AC_SUBST([_DCF_XFREE86_TEXTPROP_BUG_WORKAROUND])
60 AC_ARG_ENABLE([xfree86-textprop-bug-workaround],
61               [AS_HELP_STRING([--disable-xfree86-textprop-bug-workaround],
62                               [Disable the XFree86 textprop bug workaround])])
64 if test "x$enable_xfree86_textprop_bug_workaround" != xno; then
65     _DCF_XFREE86_TEXTPROP_BUG_WORKAROUND="-DCF_XFREE86_TEXTPROP_BUG_WORKAROUND"
68 dnl }}}
70 dnl _DCF_DE_USE_XUTF8 {{{
72 AC_SUBST([_DCF_DE_USE_XUTF8])
74 AC_ARG_ENABLE([Xutf8],
75               [AS_HELP_STRING([--enable-Xutf8],
76                               [Use the Xutf8 routines (XFree86 extension)
77                                instead of Xmb routines in an UTF-8 locale given
78                                the -i18n command line option])])
80 if test "x$enable_Xutf8" = xyes; then
81     AC_MSG_CHECKING([for Xutf8*])
82     save_CFLAGS="$CFLAGS"
83     CFLAGS="$CFLAGS $X_CFLAGS"
84     AC_RUN_IFELSE([AC_LANG_SOURCE([[
85 #include <X11/Xlib.h>
87 int main()
89 #ifdef X_HAVE_UTF8_STRING
90     exit(0);
91 #else
92     exit(1);
93 #endif
95                   ]])],
96                   [AC_MSG_RESULT([yes])
97                    _DCF_DE_USE_XUTF8="-DCF_DE_USE_XUTF8"],
98                   [AC_MSG_RESULT([no])
99                    exit 1])
100     CFLAGS="$save_CFLAGS"
103 dnl }}}
105 dnl _DCF_SUN_F1X_REMAP {{{
107 AC_SUBST([_DCF_SUN_F1X_REMAP])
109 AC_ARG_ENABLE([sun-f1x-remap],
110                           [AS_HELP_STRING([--enable-sun-f1x-remap],
111                                                           [Remap F11 key to SunF36 and F12 to SunF37])])
113 if test "x$enable_sun_f1x_remap" == xyes; then
114         _DCF_SUN_F1X_REMAP="-DCF_SUN_F1X_REMAP"
117 dnl }}}
119 dnl DL_LIBS {{{
121 AC_SUBST([DL_LIBS])
123 AC_CHECK_HEADER([dlfcn.h], [], [AC_MSG_ERROR([*** missing header dlfcn.h])])
124 AC_CHECK_LIB([dl], [dlopen], [DL_LIBS="-ldl"],
125              [AC_MSG_ERROR([*** missing library dl])])
127 dnl }}}
129 dnl PRELOAD_MODULES {{{
131 AC_SUBST(PRELOAD_MODULES)
133 AC_ARG_ENABLE([shared],
134               [AS_HELP_STRING([--disable-shared],
135                               [Do not dynamically load modules (preload modules
136                                instead)])])
138 if test "x$enable_shared" = xno; then
139     PRELOAD_MODULES="1"
142 dnl }}}
144 dnl LUA, LUAC, LUA_INCLUDES, LUA_LIBS {{{
146 AC_SUBST([LUA])
147 AC_SUBST([LUAC])
148 AC_SUBST([LUA_INCLUDES])
149 AC_SUBST([LUA_LIBS])
151 dnl Arguments {{{
152 AC_ARG_WITH([lua-prefix],
153             [AS_HELP_STRING([--with-lua-prefix=DIR],
154                             [Lua files are in DIR])])
155 AC_ARG_WITH([lua-includes],
156             [AS_HELP_STRING([--with-lua-includes=DIR],
157                             [Lua include files are in DIR])])
158 AC_ARG_WITH([lua-libraries],
159             [AS_HELP_STRING([--with-lua-libraries=DIR],
160                             [Lua library files are in DIR])])
161 AC_ARG_WITH([lua-suffix],
162             [AS_HELP_STRING([--with-lua-suffix=ARG],
163                             [Lua binary and library files are suffixed with
164                              ARG])])
165 dnl }}}
167 dnl LUA {{{
168 if test "x$with_lua_prefix" = x; then
169     lua_search_path="$PATH"
170 else
171     lua_search_path="$with_lua_prefix/bin"
173 if test "x$LUA" = x; then
174     AC_PATH_PROG([LUA], [lua$with_lua_suffix], [], [$lua_search_path])
175     test "x$LUA" = x && AC_MSG_ERROR([*** Can't build ion without lua])
177 dnl }}}
179 dnl lua_version {{{
180 AC_MSG_CHECKING([for lua version >= 5.0])
181 lua_version=$($LUA -v 2>&1 | head -n 1 | cut -d' ' -f2)
182 dnl lua_version=$($LUA -v 2>&1 >/dev/null | head -n 1 | $EGREP -o '[0-9]+(\.[0-9]+)+')
183 case $lua_version in
184 0.* | 1.* | 2.* | 3.* | 4.*)
185     AC_MSG_RESULT([no (found $lua_version)])
186     AC_MSG_ERROR([*** can't build ion with this version of lua])
187     ;;
189     AC_MSG_RESULT([yes (found $lua_version)])
190     ;;
191 esac
192 dnl }}}
194 dnl LUAC {{{
195 if test "x$LUAC" = x; then
196     AC_PATH_PROG([LUAC], [luac$with_lua_suffix], [], [$lua_search_path])
197     test "x$LUAC" = x && exit 1
199 dnl }}}
201 dnl luac_version {{{
202 AC_MSG_CHECKING([for lua version = luac version])
203 luac_version=$($LUAC -v 2>&1 | head -n 1 | cut -d' ' -f2)
204 if test "x$lua_version" = "x$luac_version"; then
205     AC_MSG_RESULT([yes (found $luac_version)])
206 else
207     AC_MSG_RESULT([no (found $luac_version)])
208     exit 1
210 dnl }}}
212 dnl LUA_INCLUDES {{{
213 if test "x$with_lua_includes" != x; then
214     LUA_INCLUDES="-I$with_lua_includes"
215 elif test "x$with_lua_prefix" != x; then
216     LUA_INCLUDES="-I$with_lua_prefix/include"
218 save_CFLAGS="$CFLAGS"
219 CFLAGS="$CFLAGS $LUA_INCLUDES"
220 AC_CHECK_HEADERS([lua.h lualib.h], [],
221                  [AC_MSG_ERROR([*** missing headers lua.h or lualib.h.
222                   *** install the lua's -dev package or check --with-lua-includes option.])], [])
223 CFLAGS="$save_CFLAGS"
224 dnl }}}
226 dnl LUA_LIBS {{{
227 if test "x$with_lua_libraries" != x; then
228     LUA_LIBS="-L$with_lua_libraries"
229 elif test "x$with_lua" != x; then
230     LUA_LIBS="-L$with_lua_prefix/lib"
232 AC_CHECK_LIB([lua$with_lua_suffix],
233              [lua_open],
234              [LUA_LIBS="$LUA_LIBS -llua$with_lua_suffix"],
235              [AC_MSG_ERROR([*** Can't find lua_open in lua$with_lua_suffix.
236                   *** Check for liblua installation or --with-lua-libraries or --with-lua-suffix options])],
237              [$LUA_LIBS])
238 AC_CHECK_LIB([dl], [dlopen], [lua_extra_libs="$lua_extra_libs -ldl"], [])
239 AC_CHECK_LIB([m], [exp], [lua_extra_libs="$lua_extra_libs -lm"], [])
240 AC_CHECK_LIB([lualib$with_lua_suffix],
241              [luaopen_loadlib],
242              [LUA_LIBS="$LUA_LIBS $lua_extra_libs -llualib$with_lua_suffix"],
243              [exit 1],
244              [$LUA_LIBS $lua_extra_libs])
245 dnl }}}
247 dnl liblua_version {{{
248 AC_MSG_CHECKING([for liblua version >= 5.0])
249 save_CFLAGS="$CFLAGS"
250 save_LIBS="$LIBS"
251 CFLAGS="$CFLAGS $LUA_INCLUDES"
252 LIBS="$LIBS $LUA_LIBS"
253 AC_RUN_IFELSE([AC_LANG_SOURCE([[
255 #include <lua.h>
256 #include <stdlib.h>
257 #include <string.h>
259 int main()
261     if(strcmp(lua_version(), LUA_VERSION)!=0){
262         printf("Error: lua_version() does not match LUA_VERSION. ");
263         exit(EXIT_FAILURE);
264     }
265     printf("(found %s)... ", lua_version());
266     if(strcmp(lua_version(), "Lua 5.0")<0)
267         exit(EXIT_FAILURE);
268     exit(EXIT_SUCCESS);
271 ]])],
272               [AC_MSG_RESULT([yes])],
273               [AC_MSG_RESULT([no])
274                exit 1])
275 CFLAGS="$save_CFLAGS"
276 LIBS="$save_LIBS"
277 dnl }}}
279 dnl }}}
281 dnl HAS_SYSTEM_ASPRINTF {{{
283 AC_SUBST([HAS_SYSTEM_ASPRINTF])
285 AC_CHECK_FUNC([asprintf],
286               [AC_CHECK_FUNC([vasprintf],
287                              [HAS_SYSTEM_ASPRINTF="1"])])
289 dnl }}}
291 dnl XOPEN_SOURCE {{{
293 AC_SUBST([XOPEN_SOURCE])
295 AC_ARG_ENABLE([xopen-source],
296               [AS_HELP_STRING([--enable-xopen-source],
297                               [Enable X/Open C flags (development use only)])])
299 if test "x$enable_xopen_source" = xyes; then
300     AC_MSG_CHECKING([for $CC flags to accept X/Open C])
301     case $host in
302     # FIXME: what flags are required for other hosts/compilers?
303     *-*-solaris* | *-*-sunos*)
304         XOPEN_SOURCE="-D__EXTENSIONS__"
305         ;;
306     *)
307         XOPEN_SOURCE="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
308         ;;
309     esac
310     AC_MSG_RESULT([$XOPEN_SOURCE])
313 dnl }}}
315 dnl C99_SOURCE {{{
317 AC_SUBST([C99_SOURCE])
319 AC_ARG_ENABLE([c99-source],
320               [AS_HELP_STRING([--enable-c99-source],
321                               [Enable C99 source (development use only)])])
323 if test "x$enable_c99_source" = xyes; then
324     AC_MSG_CHECKING([for $CC flags to accept C99])
325     case $CC in
326     # FIXME: what flags are required for other hosts/compilers?
327     gcc*)
328         C99_SOURCE="-std=c99"
329         ;;
330     esac
331     AC_MSG_RESULT([$C99_SOURCE])
334 dnl }}}
336 dnl _DCF_HAS_VA_COPY {{{
338 AC_SUBST([_DCF_HAS_VA_COPY])
340 dnl check for va_copy {{{
342 AC_MSG_CHECKING([for va_copy])
343 save_CFLAGS="$CFLAGS"
344 CFLAGS="$CFLAGS $C99_SOURCE"
345 AC_RUN_IFELSE([AC_LANG_SOURCE([[
347 #include <stdarg.h>
348 #include <stdlib.h>
350 void f(void *last, ...)
352     va_list ap, aq;
353     va_start(ap, last);
354     va_copy(aq, ap);
355     va_end(ap);
356     exit(va_arg(aq, int));
359 int main()
361     f(NULL, EXIT_SUCCESS);
362     exit(EXIT_FAILURE);
365 ]])],
366                   [AC_MSG_RESULT([yes])
367                    _DCF_HAS_VA_COPY="-DCF_HAVE_VA_COPY"],
368                   [AC_MSG_RESULT([no])])
369 CFLAGS="$save_CFLAGS"
371 dnl }}}
373 dnl check whether -ansi breaks va_copy {{{
375 if test "x${XOPEN_SOURCE}" != "x"; then
376     AC_MSG_CHECKING([whether XOPEN_SOURCE breaks va_copy])
377     save_CFLAGS="$CFLAGS"
378     CFLAGS="$CFLAGS $XOPEN_SOURCE $C99_SOURCE"
379     AC_LINK_IFELSE([AC_LANG_SOURCE([[
381 #include <stdarg.h>
382 #include <stdlib.h>
384 void f(void *last, ...)
386     va_list ap, aq;
387     va_start(ap, last);
388     va_copy(aq, ap);
389     va_end(ap);
390     va_end(aq);
393 int main()
395     f(NULL);
396     exit(EXIT_SUCCESS);
399 ]])],
400                       [AC_MSG_RESULT([no])],
401                       [AC_MSG_RESULT([yes, clearing XOPEN_SOURCE])
402                        XOPEN_SOURCE=""])
403     CFLAGS="$save_CFLAGS"
405 dnl }}}
407 dnl }}}
409 dnl _DCF_NO_LOCALE {{{
411 AC_SUBST([_DCF_NO_LOCALE])
413 AC_ARG_ENABLE([locale],
414                           [AS_HELP_STRING([--disable-locale],
415                                                           [Disable locale support])])
417 if test "x$enable_locale" == xno; then
418         _DCF_NO_LOCALE="-DCF_NO_LOCALE"
421 dnl }}}
424 AC_OUTPUT([system-ac.mk])
426 if test "x$lua_version" = "x5.0"; then
427     AC_MSG_NOTICE([**])
428     AC_MSG_NOTICE([** lua version 5.0 is buggy, consider upgrading to 5.0.1])
429     AC_MSG_NOTICE([** see http://lua-users.org/lists/lua-l/2003-10/msg00039.html])
430     AC_MSG_NOTICE([**])
433 dnl vim: foldmethod=marker tabstop=4 shiftwidth=4