]> Dogcows Code - chaz/openbox/blob - m4/x11.m4
reorganize --help. dont error if they use a --sm stuff and sm isn't enabled
[chaz/openbox] / 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
33 AC_DEFUN([XFT_ERROR],
34 [
35 if test "$XFT_MIN"; then
36 AC_MSG_ERROR([$PACKAGE requires the Xft font library >= $XFT_MIN.
37 See http://www.fontconfig.org/
38 ])
39 else
40 AC_MSG_ERROR([$PACKAGE requires the Xft font library.
41 See http://www.fontconfig.org/
42 ])
43 fi
44 ])
45
46 # XFT_DEVEL([required-version])
47 #
48 # Check for the XFT development package.
49 # You can use the optional argument to check for a library of at least the
50 # given version.
51 # It provides the $(PYTHON_CFLAGS) $(PYTHON_LIBS) output variables.
52 AC_DEFUN([XFT_DEVEL],
53 [
54 AC_REQUIRE([X11_DEVEL])
55
56 if test "$1"; then
57 XFT_MIN="$1"
58 XFT_MIN_MAJOR=${XFT_MIN%.*.*}
59 XFT_MIN_MINOR=${XFT_MIN%.*}
60 XFT_MIN_MINOR=${XFT_MIN_MINOR#*.}
61 XFT_MIN_REVISION=${XFT_MIN#*.*.}
62 XFT_MIN="$XFT_MIN_MAJOR.$XFT_MIN_MINOR.$XFT_MIN_REVISION"
63 else
64 XFT_MIN=""
65 fi
66
67 if test -z "$XFT_MIN"; then
68 AC_MSG_CHECKING([for Xft])
69 if ! pkg-config xft; then
70 AC_MSG_RESULT([no])
71 XFT_ERROR
72 fi
73 else
74 AC_MSG_CHECKING([for Xft version >= $XFT_MIN])
75 if ! pkg-config --atleast-version $XFT_MIN xft; then
76 AC_MSG_RESULT([no])
77 XFT_ERROR
78 fi
79 fi
80 AC_MSG_RESULT([yes])
81
82
83 # Store these
84 OLDLIBS=$LIBS
85 OLDCPPFLAGS=$CPPFLAGS
86
87 XFT_CFLAGS="`pkg-config --cflags xft`"
88 XFT_LIBS="`pkg-config --libs xft`"
89
90 # Set these for checking with the tests below. They'll be restored after
91 LIBS="$LIBS $XFT_LIBS"
92 CPPFLAGS="$XFT_CFLAGS $CPPFLAGS"
93
94 AC_CHECK_LIB([Xft], [XftGetVersion], # this was not defined in < 2.0
95 if test "$XFT_MIN"; then
96 AC_MSG_CHECKING([for X11/Xft/Xft.h for Xft >= $XFT_MIN])
97 AC_TRY_COMPILE(
98 [
99 #include <X11/Xlib.h>
100 #include <X11/Xft/Xft.h>
101 ],
102 [
103 #if !defined(XFT_MAJOR)
104 # error Xft.h is too old
105 #endif
106 #if XFT_MAJOR < $XFT_MIN_MAJOR
107 # error Xft.h is too old
108 #endif
109 #if XFT_MAJOR == $XFT_MIN_MAJOR
110 # if XFT_MINOR < $XFT_MIN_MINOR
111 # error Xft.h is too old
112 # endif
113 #endif
114 #if XFT_MAJOR == $XFT_MIN_MAJOR
115 # if XFT_MAJOR == $XFT_MIN_MINOR
116 # if XFT_REVISION < $XFT_MIN_REVISION
117 # error Xft.h is too old
118 # endif
119 # endif
120 #endif
121
122 int i = XFT_MAJOR;
123 XftFont foo;
124 ],
125 [
126 AC_MSG_RESULT([yes])
127 ],
128 [
129 AC_MSG_RESULT([no])
130 XFT_ERROR
131 ])
132 else
133 AC_MSG_CHECKING([for X11/Xft/Xft.h])
134 AC_TRY_COMPILE(
135 [
136 #include <X11/Xlib.h>
137 #include <X11/Xft/Xft.h>
138 ],
139 [
140 int i = XFT_MAJOR; /* make sure were using Xft 2, not 1 */
141 XftFont foo;
142 ],
143 [
144 AC_MSG_RESULT([yes])
145 ],
146 [
147 AC_MSG_RESULT([no])
148 XFT_ERROR
149 ])
150 fi
151
152 AC_MSG_CHECKING([if we can compile with Xft])
153 AC_TRY_LINK(
154 [
155 #include <X11/Xlib.h>
156 #include <X11/Xft/Xft.h>
157 ],
158 [
159 int i = XFT_MAJOR;
160 XftFont foo
161 ],
162 [
163 AC_MSG_RESULT([yes])
164 ],
165 [
166 AC_MSG_RESULT([no])
167 AC_MSG_ERROR([Unable to compile with the Xft font library.
168 ])
169 ])
170 )
171
172 # Restore the old values. Use XFT_CFLAGS and XFT_LIBS in the Makefiles
173 LIBS=$OLDLIBS
174 CPPFLAGS=$OLDCPPFLAGS
175
176 AC_SUBST([XFT_CFLAGS])
177 AC_SUBST([XFT_LIBS])
178 ])
179
180
181 # X11_EXT_XKB()
182 #
183 # Check for the presence of the "Xkb" X Window System extension.
184 # Defines "XKB" and sets the $(XKB) variable to "yes" if the extension is
185 # present.
186 AC_DEFUN([X11_EXT_XKB],
187 [
188 AC_REQUIRE([X11_DEVEL])
189
190 # Store these
191 OLDLIBS=$LIBS
192 OLDCPPFLAGS=$CPPFLAGS
193
194 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
195 LIBS="$LIBS $X_LIBS"
196
197 AC_CHECK_LIB([X11], [XkbBell],
198 AC_MSG_CHECKING([for X11/XKBlib.h])
199 AC_TRY_LINK(
200 [
201 #include <X11/Xlib.h>
202 #include <X11/Xutil.h>
203 #include <X11/XKBlib.h>
204 ],
205 [
206 Display *d;
207 Window w;
208 XkbBell(d, w, 0, 0);
209 ],
210 [
211 AC_MSG_RESULT([yes])
212 XKB="yes"
213 AC_DEFINE([XKB], [1], [Found the XKB extension])
214
215 XKB_CFLAGS=""
216 XKB_LIBS=""
217 AC_SUBST(XKB_CFLAGS)
218 AC_SUBST(XKB_LIBS)
219 ],
220 [
221 AC_MSG_RESULT([no])
222 XKB="no"
223 ])
224 )
225
226 LIBS=$OLDLIBS
227 CPPFLAGS=$OLDCPPFLAGS
228
229 AC_MSG_CHECKING([for the Xkb extension])
230 if test "$XKB" = "yes"; then
231 AC_MSG_RESULT([yes])
232 else
233 AC_MSG_RESULT([no])
234 fi
235 ])
236
237 # X11_EXT_XRANDR()
238 #
239 # Check for the presence of the "XRandR" X Window System extension.
240 # Defines "XRANDR" and sets the $(XRANDR) variable to "yes" if the extension is
241 # present.
242 AC_DEFUN([X11_EXT_XRANDR],
243 [
244 AC_REQUIRE([X11_DEVEL])
245
246 # Store these
247 OLDLIBS=$LIBS
248 OLDCPPFLAGS=$CPPFLAGS
249
250 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
251 LIBS="$LIBS $X_LIBS -lXext -lXrender -lXrandr"
252
253 AC_CHECK_LIB([Xrandr], [XRRSelectInput],
254 AC_MSG_CHECKING([for X11/extensions/Xrandr.h])
255 AC_TRY_LINK(
256 [
257 #include <X11/Xlib.h>
258 #include <X11/extensions/Xrandr.h>
259 ],
260 [
261 Display *d;
262 Drawable r;
263 int i;
264 XRRQueryExtension(d, &i, &i);
265 XRRGetScreenInfo(d, r);
266 ],
267 [
268 AC_MSG_RESULT([yes])
269 XRANDR="yes"
270 AC_DEFINE([XRANDR], [1], [Found the XRandR extension])
271
272 XRANDR_CFLAGS=""
273 XRANDR_LIBS="-lXext -lXrender -lXrandr"
274 AC_SUBST(XRANDR_CFLAGS)
275 AC_SUBST(XRANDR_LIBS)
276 ],
277 [
278 AC_MSG_RESULT([no])
279 XRANDR="no"
280 ])
281 )
282
283 LIBS=$OLDLIBS
284 CPPFLAGS=$OLDCPPFLAGS
285
286 AC_MSG_CHECKING([for the XRandR extension])
287 if test "$XRANDR" = "yes"; then
288 AC_MSG_RESULT([yes])
289 else
290 AC_MSG_RESULT([no])
291 fi
292 ])
293
294 # X11_EXT_SHAPE()
295 #
296 # Check for the presence of the "Shape" X Window System extension.
297 # Defines "SHAPE", sets the $(SHAPE) variable to "yes", and sets the $(LIBS)
298 # appropriately if the extension is present.
299 AC_DEFUN([X11_EXT_SHAPE],
300 [
301 AC_REQUIRE([X11_DEVEL])
302
303 # Store these
304 OLDLIBS=$LIBS
305 OLDCPPFLAGS=$CPPFLAGS
306
307 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
308 LIBS="$LIBS $X_LIBS"
309
310 AC_CHECK_LIB([Xext], [XShapeCombineShape],
311 AC_MSG_CHECKING([for X11/extensions/shape.h])
312 AC_TRY_LINK(
313 [
314 #include <X11/Xlib.h>
315 #include <X11/Xutil.h>
316 #include <X11/extensions/shape.h>
317 ],
318 [
319 long foo = ShapeSet;
320 ],
321 [
322 AC_MSG_RESULT([yes])
323 SHAPE="yes"
324 AC_DEFINE([SHAPE], [1], [Found the XShape extension])
325
326 XSHAPE_CFLAGS=""
327 XSHAPE_LIBS="-lXext"
328 AC_SUBST(XSHAPE_CFLAGS)
329 AC_SUBST(XSHAPE_LIBS)
330 ],
331 [
332 AC_MSG_RESULT([no])
333 SHAPE="no"
334 ])
335 )
336
337 LIBS=$OLDLIBS
338 CPPFLAGS=$OLDCPPFLAGS
339
340 AC_MSG_CHECKING([for the Shape extension])
341 if test "$SHAPE" = "yes"; then
342 AC_MSG_RESULT([yes])
343 else
344 AC_MSG_RESULT([no])
345 fi
346 ])
347
348
349 # X11_EXT_XINERAMA()
350 #
351 # Check for the presence of the "Xinerama" X Window System extension.
352 # Defines "XINERAMA", sets the $(XINERAMA) variable to "yes", and sets the
353 # $(LIBS) appropriately if the extension is present.
354 AC_DEFUN([X11_EXT_XINERAMA],
355 [
356 AC_REQUIRE([X11_DEVEL])
357
358 # Store these
359 OLDLIBS=$LIBS
360 OLDCPPFLAGS=$CPPFLAGS
361
362 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
363 LIBS="$LIBS $X_LIBS -lXext"
364
365 AC_CHECK_LIB([Xinerama], [XineramaQueryExtension],
366 [
367 AC_MSG_CHECKING([for X11/extensions/Xinerama.h])
368 AC_TRY_LINK(
369 [
370 #include <X11/Xlib.h>
371 #include <X11/extensions/Xinerama.h>
372 ],
373 [
374 XineramaScreenInfo foo;
375 ],
376 [
377 AC_MSG_RESULT([yes])
378 XINERAMA="yes"
379 AC_DEFINE([XINERAMA], [1], [Enable support of the Xinerama extension])
380 XINERAMA_LIBS="-lXext -lXinerama"
381 AC_SUBST(XINERAMA_LIBS)
382 ],
383 [
384 AC_MSG_RESULT([no])
385 XINERAMA="no"
386 ])
387 ])
388
389 LIBS=$OLDLIBS
390 CPPFLAGS=$OLDCPPFLAGS
391
392 AC_MSG_CHECKING([for the Xinerama extension])
393 if test "$XINERAMA" = "yes"; then
394 AC_MSG_RESULT([yes])
395 else
396 AC_MSG_RESULT([no])
397 fi
398 ])
399
400 # X11_EXT_SYNC()
401 #
402 # Check for the presence of the "Sync" X Window System extension.
403 # Defines "SYNC", sets the $(SYNC) variable to "yes", and sets the $(LIBS)
404 # appropriately if the extension is present.
405 AC_DEFUN([X11_EXT_SYNC],
406 [
407 AC_REQUIRE([X11_DEVEL])
408
409 # Store these
410 OLDLIBS=$LIBS
411 OLDCPPFLAGS=$CPPFLAGS
412
413 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
414 LIBS="$LIBS $X_LIBS"
415
416 AC_CHECK_LIB([Xext], [XSyncInitialize],
417 AC_MSG_CHECKING([for X11/extensions/sync.h])
418 AC_TRY_LINK(
419 [
420 #include <X11/Xlib.h>
421 #include <X11/Xutil.h>
422 #include <X11/extensions/sync.h>
423 ],
424 [
425 XSyncValueType foo;
426 ],
427 [
428 AC_MSG_RESULT([yes])
429 SYNC="yes"
430 AC_DEFINE([SYNC], [1], [Found the XSync extension])
431
432 XSYNC_CFLAGS=""
433 XSYNC_LIBS="-lXext"
434 AC_SUBST(XSYNC_CFLAGS)
435 AC_SUBST(XSYNC_LIBS)
436 ],
437 [
438 AC_MSG_RESULT([no])
439 SYNC="no"
440 ])
441 )
442
443 LIBS=$OLDLIBS
444 CPPFLAGS=$OLDCPPFLAGS
445
446 AC_MSG_CHECKING([for the Sync extension])
447 if test "$SYNC" = "yes"; then
448 AC_MSG_RESULT([yes])
449 else
450 AC_MSG_RESULT([no])
451 fi
452 ])
453
454 # X11_SM()
455 #
456 # Check for the presence of SMlib for session management.
457 # Defines "USE_SM" if SMlib is present.
458 AC_DEFUN([X11_SM],
459 [
460 AC_REQUIRE([X11_DEVEL])
461
462 AC_ARG_ENABLE([session-management],
463 AC_HELP_STRING(
464 [--disable-session-management], [build without support for session managers [[default=enabled]]]),
465 [SM=$enableval], [SM="yes"])
466
467 if test "$SM" = "yes"; then
468 # Store these
469 OLDLIBS=$LIBS
470 OLDCPPFLAGS=$CPPFLAGS
471
472 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
473 LIBS="$LIBS $X_LIBS"
474
475 SM="no"
476
477 AC_CHECK_LIB([SM], [SmcSaveYourselfDone], [
478 AC_CHECK_HEADERS([X11/SM/SMlib.h], [
479 SM_CFLAGS="$X_CFLAGS"
480 SM_LIBS="-lSM -lICE"
481 AC_DEFINE(USE_SM, 1, [Use session management])
482 AC_SUBST(SM_CFLAGS)
483 AC_SUBST(SM_LIBS)
484 SM="yes"
485 ])
486 ])
487 fi
488
489 LIBS=$OLDLIBS
490 CPPFLAGS=$OLDCPPFLAGS
491
492 AC_MSG_CHECKING([for session management support])
493 if test "$SM" = "yes"; then
494 AC_MSG_RESULT([yes])
495 else
496 AC_MSG_RESULT([no])
497 fi
498 ])
This page took 0.05459 seconds and 4 git commands to generate.