]> icculus.org git repositories - mikachu/openbox.git/blob - configure.ac
wrapper updates
[mikachu/openbox.git] / configure.ac
1 AC_INIT([src/main.cc])
2 AM_CONFIG_HEADER(config.h)
3 AM_INIT_AUTOMAKE([openbox], [2.90.0cvs])
4
5 AC_PREREQ([2.50])
6
7 AC_PATH_PROG([regex_cmd], [sed])
8 test "$regex_cmd" || AC_MSG_ERROR([sed not found])
9
10 AC_PROG_CC
11 AC_PROG_CXX
12 AC_PROG_LIBTOOL
13 LIBTOOL="$LIBTOOL --silent"
14 AC_PROG_INSTALL
15
16 ALL_LINGUAS=""
17 AM_GNU_GETTEXT_VERSION(0.11.5)
18 AM_GNU_GETTEXT([external])
19
20 AC_LANG(C++)
21         
22 # Check what compiler we are using
23 AC_MSG_CHECKING([for GCC])
24 if test "$GCC" = "yes"; then
25   AC_MSG_RESULT([yes])
26   CXXFLAGS="$CXXFLAGS -Wall -W"
27 # -pedantic"
28 else
29   AC_MSG_RESULT([no, trying other compilers])
30   AC_MSG_CHECKING(for MIPSpro)
31   mips_pro_ver=`$CXX -version 2>&1 | grep -i mipspro | cut -f4 -d ' '`
32   if test -z "$mips_pro_ver"; then
33     AC_MSG_RESULT([no])
34   else
35     AC_MSG_RESULT([yes, version $mips_pro_ver.])
36     AC_MSG_CHECKING(for -LANG:std in CXXFLAGS)
37     lang_std_not_set=`echo $CXXFLAGS | grep "\-LANG:std"`
38     if test "x$lang_std_not_set" = "x"; then
39       AC_MSG_RESULT([not set, setting.])
40       CXXFLAGS="${CXXFLAGS} -LANG:std"
41     else
42       AC_MSG_RESULT([already set.])
43     fi
44   fi
45 fi
46
47 # Determine if maintainer portions of the Makefiles should be included.
48 AM_MAINTAINER_MODE
49
50 # Check for system header files
51 AC_CHECK_HEADERS(ctype.h dirent.h fcntl.h libgen.h locale.h nl_types.h process.h signal.h stdarg.h stdio.h stdlib.h string.h time.h unistd.h sys/param.h sys/select.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/wait.h)
52 AC_HEADER_TIME
53
54 # Determine the return type of signal handlers
55 # AC_TYPE_SIGNAL
56
57 # Check whether to include debugging code
58 DEBUG=""
59 AC_MSG_CHECKING([whether to include verbose debugging code])
60 AC_ARG_ENABLE([debug],
61   [  --enable-debug          include verbose debugging code @<:@default=no@:>@],
62   if test "$enableval" = "yes"; then
63     AC_MSG_RESULT([yes])
64     if test "$GCC" = "yes"; then
65        DEBUG="-DDEBUG -fno-inline -g"
66     else
67        DEBUG="-DDEBUG"
68     fi
69   else
70     AC_MSG_RESULT([no])
71     DEBUG="-DNDEBUG"
72   fi,
73   AC_MSG_RESULT([no])
74   DEBUG="-DNDEBUG"
75 )
76 CXXFLAGS="$CXXFLAGS $DEBUG"
77
78 # Check for Python
79 AC_ARG_WITH([python],
80         [  --with-python=path      Set location of Python executable],
81         [PYTHON="$withval"],
82         [PYTHON=])
83
84 # Find the python bin
85 if ! test "$PYTHON"; then
86   AC_CHECK_PROGS(PYTHON, $prefix/bin/python python python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4)
87 fi
88 if ! test "$PYTHON"; then
89    AC_MSG_ERROR([Openbox requires the use of Python. This is its secret special formula for extreme sexiness.
90 See http://www.python.org
91 ])
92 fi
93
94 # Find our python paths
95 AC_MSG_CHECKING([for Python version])
96 # Need to do this hack since autoconf replaces __file__ with the name of the configure file
97 filehack="file__"
98 PYVERSION=`($PYTHON -c "import string,operator; print operator.getitem(string.split(string.__$filehack,'/'),-2)")`
99 AC_MSG_RESULT([$PYVERSION])
100
101 AC_MSG_CHECKING([for Python prefix])
102 PYPREFIX=`($PYTHON -c "import sys; print sys.prefix") 2>/dev/null`
103 AC_MSG_RESULT([$PYPREFIX])
104 AC_MSG_CHECKING([for Python exec-prefix])
105 PYEPREFIX=`($PYTHON -c "import sys; print sys.exec_prefix") 2>/dev/null`
106 AC_MSG_RESULT([$PYEPREFIX])
107
108 # Find the include directory
109 AC_MSG_CHECKING([for Python header files])
110 if test -r "$PYPREFIX/include/$PYVERSION/Python.h"; then
111   PYTHON_CFLAGS="-I$PYPREFIX/include/$PYVERSION"
112 fi
113 if test -z "$PYTHON_CFLAGS"; then
114   if test -r "$PYPREFIX/include/Py/Python.h"; then
115     PYTHON_CFLAGS="-I$PYPREFIX/include/Py"
116   fi
117 fi
118 if ! test "$PYTHON_CFLAGS"; then
119   AC_MSG_ERROR([Not found])
120 else
121   AC_MSG_RESULT([$PYTHON_CFLAGS])
122 fi
123
124 # Set the library directory blindly.   This probably won't work with older versions
125 AC_MSG_CHECKING([for Python library])
126 dirs="$PYVERSION/config $PYVERSION/lib python/lib"
127 for i in $dirs; do
128   if test -d "$PYEPREFIX/lib/$i"; then
129     PYLIB="$PYEPREFIX/lib/$i"
130     break
131   fi
132 done
133 if ! test "$PYLIB"; then
134   AC_MSG_ERROR([Not found])
135 else
136   AC_MSG_RESULT([$PYLIB])
137 fi
138
139 # Check for really old versions
140 if test -r "$PYLIB/libPython.a"; then
141     PYTHON_LIBS="-L$PYLIB -lModules -lPython -lObjects -lParser"
142 else
143     PYTHON_LIBS="-L$PYLIB -l$PYVERSION"
144 fi
145
146 AC_SUBST([PYTHON_CFLAGS])
147 AC_SUBST([PYTHON_LIBS])
148
149 # Check for X headers and libraries
150 AC_PATH_X
151 AC_PATH_XTRA
152 test "$no_x" = "yes" && AC_MSG_ERROR([No Xlibs found.])
153 test -z "$x_includes" && x_includes="/usr/include"
154 test -z "$x_libraries" && x_libraries="/usr/lib"
155      
156 CXXFLAGS="$CXXFLAGS $X_CFLAGS"
157 LIBS="$LIBS $X_LIBS $X_EXTRA_LIBS"
158 LDFLAGS="$LDFLAGS $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
159
160 # Check for required functions in -lX11
161 AC_CHECK_LIB([X11], [XOpenDisplay],
162   ,
163   AC_MSG_ERROR([Could not find XOpenDisplay in -lX11.])
164 )
165
166
167 # Check for Xft >= 2
168 XFT_MIN_MAJOR=2
169 XFT_MIN_MINOR=0
170 XFT_MIN_REVISION=0
171 XFT_MIN=$XFT_MIN_MAJOR.$XFT_MIN_MINOR.$XFT_MIN_REVISION
172 AC_MSG_CHECKING([for Xft version >= $XFT_MIN])
173 if ! pkg-config --atleast-version $XFT_MIN xft; then
174   AC_MSG_RESULT([no])
175   AC_MSG_ERROR([Openbox requires the Xft version >= $XFT_MIN font library.
176 See http://www.fontconfig.org/
177 ])
178 fi
179
180 AC_MSG_RESULT([yes])
181
182 # Store these
183 OLDLIBS=$LIBS
184 OLDCXXFLAGS=$CXXFLAGS
185
186 XFT_CFLAGS="`pkg-config --cflags xft`"
187 XFT_LIBS="`pkg-config --libs xft`"
188
189 # Set these for checking with the tests below. They'll be restored after
190 LIBS="$LIBS $XFT_LIBS"
191 CXXFLAGS="$XFT_CFLAGS $CXXFLAGS"
192
193 AC_CHECK_LIB([Xft], [XftFontOpenName],
194   AC_MSG_CHECKING([for X11/Xft/Xft.h for Xft >= $XFT_MIN])
195   AC_TRY_COMPILE(
196     [
197       #include <X11/Xlib.h>
198       #include <X11/Xft/Xft.h>
199     ],
200     [
201       #if !defined(XFT_MAJOR)
202       # error Xft.h is too old
203       #endif
204       #if XFT_MAJOR < $XFT_MIN_MAJOR
205       # error Xft.h is too old
206       #endif
207       #if XFT_MAJOR == $XFT_MIN_MAJOR
208       # if XFT_MINOR < $XFT_MIN_MINOR
209       #  error Xft.h is too old
210       # endif
211       #endif
212       #if XFT_MAJOR == $XFT_MIN_MAJOR
213       # if XFT_MAJOR == $XFT_MIN_MINOR
214       #  if XFT_REVISION < $XFT_MIN_REVISION
215       #   error Xft.h is too old
216       #  endif
217       # endif
218       #endif
219       
220       int i = XFT_MAJOR;
221       XftFont foo;
222     ],
223     [
224       AC_MSG_RESULT([yes])
225     ],
226     [
227       AC_MSG_RESULT([no])
228       AC_MSG_ERROR([Openbox requires the Xft version >= $XFT_MIN font library.
229 See http://www.fontconfig.org/
230 ])
231     ]
232   )
233
234   AC_MSG_CHECKING([if we can compile with Xft])
235   AC_TRY_LINK(
236     [
237       #include <X11/Xlib.h>
238       #include <X11/Xft/Xft.h>
239     ],
240     [
241       int i = XFT_MAJOR;
242       XftFont foo
243     ],
244     [
245       AC_MSG_RESULT([yes])
246     ],
247     [ 
248       AC_MSG_RESULT([no])
249       AC_MSG_ERROR([Unable to compile with the Xft library.
250 ])
251     ]
252   )
253 )
254 # Restore the old values. Use XFT_CFLAGS and XFT_LIBS in the Makefile.am's
255 LIBS=$OLDLIBS
256 CXXFLAGS=$OLDCXXFLAGS
257
258 AC_SUBST([XFT_CFLAGS])
259 AC_SUBST([XFT_LIBS])
260
261 # Check for XKB extension support
262 AC_CHECK_LIB([X11], [XkbBell],
263   AC_MSG_CHECKING([for X11/XKBlib.h])
264   AC_TRY_LINK(
265     [
266       #include <X11/Xlib.h>
267       #include <X11/Xutil.h>
268       #include <X11/XKBlib.h>
269     ],
270     [
271       Display *d;
272       Window w;
273       XkbBell(d, w, 0, 0);
274     ],
275     [
276       AC_MSG_RESULT([yes])
277       XKB="yes"
278       AC_DEFINE([XKB], [1], [Found the XKB extension])
279     ],
280     [ 
281       AC_MSG_RESULT([no])
282       XKB="no"
283     ]
284   )
285 )
286 AC_MSG_CHECKING([for the XKB extension])
287 if test "$XKB" = "yes"; then
288   AC_MSG_RESULT([yes])
289 else
290   AC_MSG_RESULT([no])
291 fi
292
293 # Check for XShape extension support
294 AC_CHECK_LIB([Xext], [XShapeCombineShape],
295   AC_MSG_CHECKING([for X11/extensions/shape.h])
296   AC_TRY_LINK(
297     [
298       #include <X11/Xlib.h>
299       #include <X11/Xutil.h>
300       #include <X11/extensions/shape.h>
301     ],
302     [
303       long foo = ShapeSet
304     ],
305     [
306       AC_MSG_RESULT([yes])
307       SHAPE="yes"
308       AC_DEFINE([SHAPE], [1], [Found the XShape extension])
309       LIBS="$LIBS -lXext"
310     ],
311     [ 
312       AC_MSG_RESULT([no])
313       SHAPE="no"
314     ]
315   )
316 )
317 AC_MSG_CHECKING([for the XShape extension])
318 if test "$SHAPE" = "yes"; then
319   AC_MSG_RESULT([yes])
320 else
321   AC_MSG_RESULT([no])
322 fi
323
324 # Check for Xinerama extension support
325 AC_MSG_CHECKING([whether to build support for the Xinerama extension])
326 XINERAMA="no"
327 AC_ARG_ENABLE([xinerama],
328 [  --enable-xinerama       enable support of the Xinerama extension @<:@default=no@:>@],
329   if test "$enableval" = "yes"; then
330         AC_MSG_RESULT([yes])
331
332         AC_CHECK_LIB([Xinerama], [XineramaQueryExtension],
333           [
334             AC_MSG_CHECKING([for X11/extensions/Xinerama.h])
335             AC_TRY_LINK(
336               [
337                 #include <X11/Xlib.h>
338                 #include <X11/extensions/Xinerama.h>
339               ],
340               [
341                 XineramaScreenInfo foo
342               ],
343               [
344                 AC_MSG_RESULT([yes])
345                 XINERAMA="yes"
346                 AC_DEFINE([XINERAMA], [1],
347                           [Enable support of the Xinerama extension])
348                 LIBS="$LIBS -lXinerama"
349               ],
350               [
351                 AC_MSG_RESULT([no])
352               ]
353             )
354           ]
355         )
356
357     AC_MSG_CHECKING([for the Xinerama extension])
358     if test "$XINRERAMA" = "yes"; then
359       AC_MSG_RESULT([yes])
360     else
361       AC_MSG_RESULT([no])
362     fi
363   else
364         AC_MSG_RESULT([no])
365   fi,
366   AC_MSG_RESULT([no])
367 )
368
369 AC_CONFIG_FILES([Makefile po/Makefile.in
370                 otk/Makefile
371                 src/Makefile
372                 scripts/Makefile
373                 util/Makefile
374                 util/epist/Makefile
375                 doc/Makefile
376                 doc/doxygen/Makefile
377                 data/Makefile
378                 data/buttons/Makefile
379                 data/styles/Makefile
380                 version.h
381                 ])
382 AC_OUTPUT
383
384 AC_MSG_RESULT
385 AC_MSG_RESULT([$PACKAGE version $VERSION configured successfully.])
386
387 AC_MSG_RESULT
388 AC_MSG_RESULT([Using '$prefix' for installation.])
389 AC_MSG_RESULT([Using '$CXX' for C++ compiler.])
390 AC_MSG_RESULT([Building with '$CXXFLAGS' for C++ compiler flags.])
391 AC_MSG_RESULT([Building with '$LIBS' for linker flags.])
392 AC_MSG_RESULT
393 AC_MSG_RESULT([configure complete, now type \"make\"])
394 AC_MSG_RESULT