1dnl Process this file with autoconf to produce a configure script.
2dnl Copyright (C) 2000, 2001, 2002, 2003, 2004 Shawn Betts <sabetts@vcn.bc.ca>
3dnl
4dnl This file is part of ratpoison.
5dnl
6dnl ratpoison is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 2 of the License, or
9dnl (at your option) any later version.
10dnl
11dnl ratpoison is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program; if not, write to the Free Software
18dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20AC_INIT([ratpoison], [1.4.9], [ratpoison-devel@nongnu.org])
21AC_CONFIG_AUX_DIR([build-aux])
22AC_CONFIG_MACRO_DIR([m4])
23AC_CONFIG_SRCDIR([src/main.c])
24AM_INIT_AUTOMAKE([-Wall -Werror gnu])
25
26AM_MAINTAINER_MODE([enable])
27
28AC_CONFIG_HEADER(src/config.h)
29
30dnl by default turn off debugging
31AC_MSG_CHECKING([whether to enable debugging])
32AC_ARG_ENABLE([debug],
33  [AS_HELP_STRING([--enable-debug],[build with extra debugging messages])],
34  [], [enable_debug=no])
35AS_CASE([$enable_debug],
36  [yes], [AC_MSG_RESULT([yes])
37   	  AC_DEFINE([DEBUG], 1, [Define this to enable debugging messages])],
38  [no], [AC_MSG_RESULT([no])],
39  [AC_MSG_ERROR([invalid --enable-debug="$enable_debug" parameter])])
40
41AC_ARG_WITH([electric-fence],
42  [AS_HELP_STRING([--with-electric-fence],
43    [Use the Electric Fence library (memory allocation debugging).])])
44
45AC_ARG_WITH([xterm],
46  [AS_HELP_STRING([--with-xterm=PROG],
47    [set the x terminal emulator used by ratpoison])],
48  [term_prog=$withval],
49  [term_prog=xterm])
50AC_DEFINE_UNQUOTED([TERM_PROG], ["$term_prog"], [X terminal emulator to use])
51
52XFT_CFLAGS=
53XFT_LIBS=
54AC_ARG_WITH(xft,AS_HELP_STRING([--without-xft],[Don't use the Xft library even if available]),
55                xft=$withval, xft=default)
56if test "x$xft" != "xno"; then
57    dnl Configure Xft.
58    PKG_CHECK_MODULES([XFT], [xft],,[noop=noop])
59    AC_MSG_CHECKING(whether to use Xft)
60    echo "pkg_failed is $pkg_failed" >&5
61dnl pkg_failed can be yes, no or untried (if there is no pkg-config or that does not work).
62    if test "$pkg_failed" = "no" ; then
63       AC_DEFINE_UNQUOTED(USE_XFT_FONT, 1, [Define this to use Xft])
64       AC_MSG_RESULT(yes)
65    elif test "x$xft" != "xdefault" ; then
66dnl if explicitly requested but not found, bail out:
67    	AC_MSG_RESULT(no)
68    	if test "$pkg_failed" = "untried" ; then
69	    AC_MSG_ERROR([Not Xft library found (this needs a working pkg-config)!])
70	else
71	    AC_MSG_ERROR([No Xft library found!])
72	fi
73    else
74    	AC_MSG_RESULT(no)
75    fi
76else
77    AC_MSG_CHECKING(whether to use Xft)
78    AC_MSG_RESULT(no)
79fi
80AC_SUBST(XFT_CFLAGS)
81AC_SUBST(XFT_LIBS)
82
83AC_ARG_WITH([xkb],
84  [AS_HELP_STRING([--without-xkb], [Don't build XKB support for keyboard input.])],
85  [xkb=$withval],
86  [xkb=yes])
87AS_IF([test "X$xkb" = "Xyes"],
88  [AC_DEFINE([WANT_XKB], 1,
89    [Define to 1 if you want to build XKB support for keyboard input.])])
90
91AC_MSG_CHECKING([manpage format])
92AC_ARG_ENABLE([mdoc],
93  [AS_HELP_STRING([--disable-mdoc],
94    [install man(7) manpages, useful if you don't have a mdoc(7) formatter\
95     such as mandoc(1) or groff(1)])],
96  [], [enable_mdoc=yes])
97AS_CASE([$enable_mdoc],
98  [yes], [manpage_format=mdoc],
99  [no],  [manpage_format=man],
100  [AC_MSG_ERROR([invalid --enable-mdoc="$enable_mdoc" parameter])])
101AC_MSG_RESULT([$manpage_format])
102AC_SUBST([manpage_format])
103
104AC_MSG_CHECKING([Xrandr support])
105AC_ARG_WITH([xrandr],
106  [AS_HELP_STRING([--without-xrandr],
107    [Build without Xrandr support, default is to require and use it.])],
108  [with_xrandr=$withval],
109  [with_xrandr=check])
110AC_MSG_RESULT([$with_xrandr])
111
112dnl Checks for programs.
113AC_PROG_CC
114AM_MISSING_PROG([MANDOC], [mandoc])
115AC_ARG_VAR([MANDOC],
116  [path to mandoc(1), only used when regenerating doc/ratpoison.man.1 \
117   after editing doc/ratpoison.mdoc.1])
118
119AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="-Wall $CFLAGS"], [], [], [])
120
121dnl check for an x terminal emulator
122AC_MSG_CHECKING(terminal emulator)
123AC_MSG_RESULT($term_prog)
124
125dnl Check for the X libs
126AC_PATH_X
127AC_PATH_XTRA
128
129if test "x$no_x" = "xyes"; then
130	AC_MSG_ERROR([*** Can't find X11 headers and libs])
131fi
132
133
134dnl Those who do not learn the lessons of history
135dnl are doomed to delete it...  yuk yuk.  --ttn
136AC_ARG_ENABLE([history],
137  AS_HELP_STRING([--enable-history],
138    [Link with libhistory (default: disabled. Note: only used for ! expansion)]),
139  [], [enable_history=no])
140
141HISTORY_LIBS=
142have_history=no
143AS_CASE([$enable_history],
144  [no], [],
145  [yes],
146    [AC_CHECK_HEADERS([readline/history.h],
147      [AC_CHECK_LIB([history], [add_history], [have_history=yes], [])],
148      [])],
149   [AC_MSG_ERROR([invalid --disable-history="$enable_history" parameter])])
150
151AC_MSG_CHECKING([whether to use libhistory])
152AS_CASE([$enable_history:$have_history],
153  [yes:no], [AC_MSG_ERROR([Can't find history headers/lib. \
154Install readline dev libs for history expansion.])],
155  [no:*], [AC_MSG_RESULT([no])],
156  [yes:yes], [AC_MSG_RESULT([yes])
157            AC_DEFINE_UNQUOTED(HAVE_HISTORY, 1, Define this to enable history)
158  	    HISTORY_LIBS="-lhistory"])
159
160AC_SUBST(HISTORY_LIBS)
161
162AC_CHECK_LIB(X11, XOpenDisplay, [X_LIBS="-lX11 $X_LIBS"],
163	AC_MSG_ERROR([*** Can't find libX11]),$X_LIBS $X_EXTRA_LIBS)
164
165mysavedCPPFLAGS="$CPPFLAGS"
166CPPFLAGS="$CPPFLAGS $X_CFLAGS"
167AC_CHECK_HEADERS([X11/XKBlib.h], [], [], [
168#include <X11/Xlib.h>
169])
170CPPFLAGS="$mysavedCPPFLAGS"
171
172AC_CHECK_LIB(Xtst, XTestFakeButtonEvent, [X_LIBS="-lXtst $X_LIBS"; AC_DEFINE(HAVE_LIBXTST,1,[Xtst])],,$X_LIBS $X_EXTRA_LIBS)
173AC_CHECK_LIB([X11], [XkbKeycodeToKeysym],
174  [AC_DEFINE(HAVE_XKBKEYCODETOKEYSYM, 1,
175    [Define to 1 if you have the `XkbKeycodeToKeysym' function.])],
176  [], [$X_LIBS $X_EXTRA_LIBS])
177
178mysavedCPPFLAGS="$CPPFLAGS"
179CPPFLAGS="$CPPFLAGS $X_CFLAGS"
180AC_CHECK_HEADERS([X11/extensions/Xrandr.h], [xrandr_h=yes], [xrandr_h=no], [
181#include <X11/Xlib.h>
182])
183CPPFLAGS="$mysavedCPPFLAGS"
184
185AC_CHECK_LIB(Xrandr, XRRGetScreenResources, [libxrandr=yes], [libxrandr=no], [$X_LIBS $X_EXTRA_LIBS])
186
187compile_xrandr=no
188AS_CASE(["$with_xrandr:$xrandr_h:$libxrandr"],
189  [yes:no:*], [AC_MSG_ERROR([*** Can't enable Xrandr support, header Xrandr.h not found.])],
190  [yes:*:no], [AC_MSG_ERROR([*** Can't enable Xrandr support, libXrandr not found.])],
191  [check:no:*], [AC_MSG_ERROR([*** Header Xrandr.h not found, use ./configure --without-xrandr to build without multiple screens support.])],
192  [check:*:no], [AC_MSG_ERROR([*** libXrandr not found, use ./configure --without-xrandr to build without multiple screens support.])],
193  [yes:yes:yes|check:yes:yes], [X_LIBS="-lXrandr $X_LIBS"
194  			        AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you want Xrandr support.])
195				compile_xrandr=yes])
196
197AM_CONDITIONAL(HAVE_XRANDR, [test "$compile_xrandr" = yes])
198
199AC_SUBST(X_LIBS)
200AC_SUBST(X_EXTRA_LIBS)
201AC_SUBST(X_CFLAGS)
202
203AS_IF([test "$with_electric_fence" = yes],
204  [AC_CHECK_LIB([efence], [malloc], [],
205    [AC_MSG_ERROR([Couldn't find the Electric Fence library (-lefence)])])])
206
207dnl Checks for header files.
208AC_HEADER_STDC
209AC_CHECK_HEADERS([pwd.h sys/ioctl.h sys/stat.h])
210
211dnl Checks for typedefs, structures, and compiler characteristics.
212AC_C_TYPEOF
213
214AH_TEMPLATE([HAVE___BUILTIN_PREFETCH],
215  [Define to 1 if your compiler supports the `__builtin_prefetch' function.])
216AC_MSG_CHECKING([for __builtin_prefetch()])
217AC_LINK_IFELSE([AC_LANG_PROGRAM([],
218  [
219    int a = 9;
220    __builtin_prefetch(&a);
221    return 0;
222  ])],
223  [AC_DEFINE([HAVE___BUILTIN_PREFETCH], 1)
224   AC_MSG_RESULT(yes)],
225  [AC_MSG_RESULT(no)])
226
227dnl Checks for library functions.
228AC_CHECK_FUNCS(getline getopt_long getpwuid setenv setpgid setpgrp setsid)
229AC_CHECK_FUNCS(unsetenv vsnprintf)
230
231AM_LANGINFO_CODESET
232
233lispdir='${datarootdir}/emacs/site-lisp'
234AC_SUBST([lispdir])
235
236AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile contrib/Makefile])
237AC_OUTPUT
238