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