Don't need to explicitly check for xft.
[dana/openbox.git] / m4 / x11.m4
1 # X11_DEVEL()
2 #
3 # Check for the presence of the X Window System headers and libraries.
4 # Sets the CPPFLAGS and LIBS variables as appropriate.
5 AC_DEFUN([X11_DEVEL],
6 [
7   AC_PATH_XTRA
8   test "$no_x" = "yes" && \
9     AC_MSG_ERROR([The X Window System could not be found.])
10
11   # Store these
12   OLDLIBS=$LIBS
13   OLDCPPFLAGS=$CPPFLAGS
14      
15   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
16   X_LIBS="$X_PRE_LIBS $X_LIBS -lX11"
17   LIBS="$LIBS $X_LIBS"
18
19   # Check for required functions in -lX11
20   AC_CHECK_LIB(
21     [X11], [XOpenDisplay],
22     ,
23     AC_MSG_ERROR([Could not find XOpenDisplay in -lX11.])
24   )
25
26   # Restore the old values. Use X_CFLAGS and X_LIBS in
27   # the Makefiles
28   LIBS=$OLDLIBS
29   CPPFLAGS=$OLDCPPFLAGS
30 ])
31
32 # X11_EXT_XKB()
33 #
34 # Check for the presence of the "Xkb" X Window System extension.
35 # Defines "XKB" and sets the $(XKB) variable to "yes" if the extension is
36 # present.
37 AC_DEFUN([X11_EXT_XKB],
38 [
39   AC_REQUIRE([X11_DEVEL])
40
41   # Store these
42   OLDLIBS=$LIBS
43   OLDCPPFLAGS=$CPPFLAGS
44      
45   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
46   LIBS="$LIBS $X_LIBS"
47
48   AC_CHECK_LIB([X11], [XkbBell],
49     AC_MSG_CHECKING([for X11/XKBlib.h])
50     AC_TRY_LINK(
51     [
52       #include <X11/Xlib.h>
53       #include <X11/Xutil.h>
54       #include <X11/XKBlib.h>
55     ],
56     [
57       Display *d;
58       Window w;
59       XkbBell(d, w, 0, 0);
60     ],
61     [
62       AC_MSG_RESULT([yes])
63       XKB="yes"
64       AC_DEFINE([XKB], [1], [Found the XKB extension])
65
66       XKB_CFLAGS=""
67       XKB_LIBS=""
68       AC_SUBST(XKB_CFLAGS)
69       AC_SUBST(XKB_LIBS)
70     ],
71     [ 
72       AC_MSG_RESULT([no])
73       XKB="no"
74     ])
75   )
76
77   LIBS=$OLDLIBS
78   CPPFLAGS=$OLDCPPFLAGS
79
80   AC_MSG_CHECKING([for the Xkb extension])
81   if test "$XKB" = "yes"; then
82     AC_MSG_RESULT([yes])
83   else
84     AC_MSG_RESULT([no])
85   fi
86 ])
87
88 # X11_EXT_XRANDR()
89 #
90 # Check for the presence of the "XRandR" X Window System extension.
91 # Defines "XRANDR" and sets the $(XRANDR) variable to "yes" if the extension is
92 # present.
93 AC_DEFUN([X11_EXT_XRANDR],
94 [
95   AC_REQUIRE([X11_DEVEL])
96
97   # Store these
98   OLDLIBS=$LIBS
99   OLDCPPFLAGS=$CPPFLAGS
100      
101   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
102   LIBS="$LIBS $X_LIBS -lXext -lXrender -lXrandr"
103
104   AC_CHECK_LIB([Xrandr], [XRRSelectInput],
105     AC_MSG_CHECKING([for X11/extensions/Xrandr.h])
106     AC_TRY_LINK(
107     [
108       #include <X11/Xlib.h>
109       #include <X11/extensions/Xrandr.h>
110     ],
111     [
112       Display *d;
113       Drawable r;
114       int i;
115       XRRQueryExtension(d, &i, &i);
116       XRRGetScreenInfo(d, r);
117     ],
118     [
119       AC_MSG_RESULT([yes])
120       XRANDR="yes"
121       AC_DEFINE([XRANDR], [1], [Found the XRandR extension])
122
123       XRANDR_CFLAGS=""
124       XRANDR_LIBS="-lXext -lXrender -lXrandr"
125       AC_SUBST(XRANDR_CFLAGS)
126       AC_SUBST(XRANDR_LIBS)
127     ],
128     [ 
129       AC_MSG_RESULT([no])
130       XRANDR="no"
131     ])
132   )
133
134   LIBS=$OLDLIBS
135   CPPFLAGS=$OLDCPPFLAGS
136
137   AC_MSG_CHECKING([for the XRandR extension])
138   if test "$XRANDR" = "yes"; then
139     AC_MSG_RESULT([yes])
140   else
141     AC_MSG_RESULT([no])
142   fi
143 ])
144
145 # X11_EXT_SHAPE()
146 #
147 # Check for the presence of the "Shape" X Window System extension.
148 # Defines "SHAPE", sets the $(SHAPE) variable to "yes", and sets the $(LIBS)
149 # appropriately if the extension is present.
150 AC_DEFUN([X11_EXT_SHAPE],
151 [
152   AC_REQUIRE([X11_DEVEL])
153
154   # Store these
155   OLDLIBS=$LIBS
156   OLDCPPFLAGS=$CPPFLAGS
157      
158   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
159   LIBS="$LIBS $X_LIBS"
160
161   AC_CHECK_LIB([Xext], [XShapeCombineShape],
162     AC_MSG_CHECKING([for X11/extensions/shape.h])
163     AC_TRY_LINK(
164     [
165       #include <X11/Xlib.h>
166       #include <X11/Xutil.h>
167       #include <X11/extensions/shape.h>
168     ],
169     [
170       long foo = ShapeSet;
171     ],
172     [
173       AC_MSG_RESULT([yes])
174       SHAPE="yes"
175       AC_DEFINE([SHAPE], [1], [Found the XShape extension])
176
177       XSHAPE_CFLAGS=""
178       XSHAPE_LIBS="-lXext"
179       AC_SUBST(XSHAPE_CFLAGS)
180       AC_SUBST(XSHAPE_LIBS)
181     ],
182     [ 
183       AC_MSG_RESULT([no])
184       SHAPE="no"
185     ])
186   )
187
188   LIBS=$OLDLIBS
189   CPPFLAGS=$OLDCPPFLAGS
190  
191   AC_MSG_CHECKING([for the Shape extension])
192   if test "$SHAPE" = "yes"; then
193     AC_MSG_RESULT([yes])
194   else
195     AC_MSG_RESULT([no])
196   fi
197 ])
198
199
200 # X11_EXT_XINERAMA()
201 #
202 # Check for the presence of the "Xinerama" X Window System extension.
203 # Defines "XINERAMA", sets the $(XINERAMA) variable to "yes", and sets the
204 # $(LIBS) appropriately if the extension is present.
205 AC_DEFUN([X11_EXT_XINERAMA],
206 [
207   AC_REQUIRE([X11_DEVEL])
208
209   # Store these
210   OLDLIBS=$LIBS
211   OLDCPPFLAGS=$CPPFLAGS
212      
213   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
214   LIBS="$LIBS $X_LIBS -lXext"
215
216   AC_CHECK_LIB([Xinerama], [XineramaQueryExtension],
217   [
218     AC_MSG_CHECKING([for X11/extensions/Xinerama.h])
219     AC_TRY_LINK(
220     [
221       #include <X11/Xlib.h>
222       #include <X11/extensions/Xinerama.h>
223     ],
224     [
225       XineramaScreenInfo foo;
226     ],
227     [
228       AC_MSG_RESULT([yes])
229       XINERAMA="yes"
230       AC_DEFINE([XINERAMA], [1], [Enable support of the Xinerama extension])
231       XINERAMA_LIBS="-lXext -lXinerama"
232       AC_SUBST(XINERAMA_LIBS)
233     ],
234     [
235       AC_MSG_RESULT([no])
236       XINERAMA="no"
237     ])
238   ])
239
240   LIBS=$OLDLIBS
241   CPPFLAGS=$OLDCPPFLAGS
242
243   AC_MSG_CHECKING([for the Xinerama extension])
244   if test "$XINERAMA" = "yes"; then
245     AC_MSG_RESULT([yes])
246   else
247     AC_MSG_RESULT([no])
248   fi
249 ])
250
251 # X11_EXT_SYNC()
252 #
253 # Check for the presence of the "Sync" X Window System extension.
254 # Defines "SYNC", sets the $(SYNC) variable to "yes", and sets the $(LIBS)
255 # appropriately if the extension is present.
256 AC_DEFUN([X11_EXT_SYNC],
257 [
258   AC_REQUIRE([X11_DEVEL])
259
260   # Store these
261   OLDLIBS=$LIBS
262   OLDCPPFLAGS=$CPPFLAGS
263      
264   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
265   LIBS="$LIBS $X_LIBS"
266
267   AC_CHECK_LIB([Xext], [XSyncInitialize],
268     AC_MSG_CHECKING([for X11/extensions/sync.h])
269     AC_TRY_LINK(
270     [
271       #include <X11/Xlib.h>
272       #include <X11/Xutil.h>
273       #include <X11/extensions/sync.h>
274     ],
275     [
276       XSyncValueType foo;
277     ],
278     [
279       AC_MSG_RESULT([yes])
280       SYNC="yes"
281       AC_DEFINE([SYNC], [1], [Found the XSync extension])
282
283       XSYNC_CFLAGS=""
284       XSYNC_LIBS="-lXext"
285       AC_SUBST(XSYNC_CFLAGS)
286       AC_SUBST(XSYNC_LIBS)
287     ],
288     [ 
289       AC_MSG_RESULT([no])
290       SYNC="no"
291     ])
292   )
293
294   LIBS=$OLDLIBS
295   CPPFLAGS=$OLDCPPFLAGS
296  
297   AC_MSG_CHECKING([for the Sync extension])
298   if test "$SYNC" = "yes"; then
299     AC_MSG_RESULT([yes])
300   else
301     AC_MSG_RESULT([no])
302   fi
303 ])
304
305 # X11_SM()
306 #
307 # Check for the presence of SMlib for session management.
308 # Defines "USE_SM" if SMlib is present.
309 AC_DEFUN([X11_SM],
310 [
311   AC_REQUIRE([X11_DEVEL])
312
313   AC_ARG_ENABLE([session-management],
314   AC_HELP_STRING(
315   [--disable-session-management], [build without support for session managers [[default=enabled]]]),
316   [SM=$enableval], [SM="yes"])
317   
318   if test "$SM" = "yes"; then
319     # Store these
320     OLDLIBS=$LIBS
321     OLDCPPFLAGS=$CPPFLAGS
322      
323     CPPFLAGS="$CPPFLAGS $X_CFLAGS"
324     LIBS="$LIBS $X_LIBS"
325
326     SM="no"
327
328     AC_CHECK_LIB([SM], [SmcSaveYourselfDone], [
329       AC_CHECK_HEADERS([X11/SM/SMlib.h], [
330         SM_CFLAGS="$X_CFLAGS"
331         SM_LIBS="-lSM -lICE"
332         AC_DEFINE(USE_SM, 1, [Use session management])
333         AC_SUBST(SM_CFLAGS)
334         AC_SUBST(SM_LIBS)
335         SM="yes"
336       ])
337     ])
338   fi
339
340   LIBS=$OLDLIBS
341   CPPFLAGS=$OLDCPPFLAGS
342
343   AC_MSG_CHECKING([for session management support])
344   if test "$SM" = "yes"; then
345     AC_MSG_RESULT([yes])
346   else
347     AC_MSG_RESULT([no])
348   fi
349 ])