Update Serbian translation from master branch
[wmaker-crm.git] / m4 / wm_xext_check.m4
blob751d831458556b8acfd357f73bbc503a93a4a05d
1 # wm_xext_check.m4 - Macros to check for X extensions support libraries
3 # Copyright (c) 2013 Christophe CURIS
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 # WM_XEXT_CHECK_XRES
20 # --------------------
22 # Check for the X Resource Window extension
23 # The check depends on variable 'enable_xshape' being either:
24 #   yes  - detect, fail if not found
25 #   no   - do not detect, disable support
26 #   auto - detect, disable if not found
28 # When found, append appropriate stuff in XLIBS, and append info to
29 # the variable 'supported_xext'
30 # When not found, append info to variable 'unsupported'
31 AC_DEFUN_ONCE([WM_XEXT_CHECK_XRES],
32 [WM_LIB_CHECK([XRes], [-lXRes], [XResQueryClientIds], [$XLIBS],
33     [wm_save_CFLAGS="$CFLAGS"
34      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl
35 @%:@include <X11/extensions/XRes.h>
36 ], [dnl
38   XResQueryClientIds(NULL, 0, NULL, NULL, NULL);])]
39         [],
40         [AC_MSG_ERROR([found $CACHEVAR but cannot compile using XRes header])])
41      CFLAGS="$wm_save_CFLAGS"],
42     [supported_xext], [XLIBS], [enable_res], [-])dnl
43 ]) dnl AC_DEFUN
46 # WM_XEXT_CHECK_XSHAPE
47 # --------------------
49 # Check for the X Shaped Window extension
50 # The check depends on variable 'enable_xshape' being either:
51 #   yes  - detect, fail if not found
52 #   no   - do not detect, disable support
53 #   auto - detect, disable if not found
55 # When found, append appropriate stuff in XLIBS, and append info to
56 # the variable 'supported_xext'
57 # When not found, append info to variable 'unsupported'
58 AC_DEFUN_ONCE([WM_XEXT_CHECK_XSHAPE],
59 [WM_LIB_CHECK([XShape], [-lXext], [XShapeSelectInput], [$XLIBS],
60     [wm_save_CFLAGS="$CFLAGS"
61      AS_IF([wm_fn_lib_try_compile "X11/extensions/shape.h" "Window win;" "XShapeSelectInput(NULL, win, 0)" ""],
62         [],
63         [AC_MSG_ERROR([found $CACHEVAR but cannot compile using XShape header])])
64      CFLAGS="$wm_save_CFLAGS"],
65     [supported_xext], [XLIBS], [enable_shape], [-])dnl
66 ]) dnl AC_DEFUN
69 # WM_XEXT_CHECK_XSHM
70 # ------------------
72 # Check for the MIT-SHM extension for Shared Memory support
73 # The check depends on variable 'enable_shm' being either:
74 #   yes  - detect, fail if not found
75 #   no   - do not detect, disable support
76 #   auto - detect, disable if not found
78 # When found, append appropriate stuff in XLIBS, and append info to
79 # the variable 'supported_xext'
80 # When not found, append info to variable 'unsupported'
81 AC_DEFUN_ONCE([WM_XEXT_CHECK_XSHM],
82 [WM_LIB_CHECK([XShm], [-lXext], [XShmAttach], [$XLIBS],
83     [wm_save_CFLAGS="$CFLAGS"
84      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl
85 @%:@include <X11/Xlib.h>
86 @%:@include <X11/extensions/XShm.h>
87 ], [dnl
88   XShmSegmentInfo si;
90   XShmAttach(NULL, &si);])],
91         [],
92         [AC_MSG_ERROR([found $CACHEVAR but cannot compile using XShm header])])
93      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl
94 @%:@include <sys/ipc.h>
95 @%:@include <sys/shm.h>
96 ], [dnl
97   shmget(IPC_PRIVATE, 1024, IPC_CREAT);])],
98         [],
99         [AC_MSG_ERROR([found $CACHEVAR but cannot compile using ipc/shm headers])])
100      CFLAGS="$wm_save_CFLAGS"],
101     [supported_xext], [XLIBS], [enable_shm], [-])dnl
102 ]) dnl AC_DEFUN
105 # WM_XEXT_CHECK_XMU
106 # -----------------
108 # Check for the libXmu (X Misceleanous Utilities)
109 # When found, append it to LIBXMU
110 # When not found, generate an error because we have no work-around for it
111 AC_DEFUN_ONCE([WM_EXT_CHECK_XMU],
112 [AC_CACHE_CHECK([for Xmu library], [wm_cv_xext_xmu],
113     [wm_cv_xext_xmu=no
114      dnl
115      dnl We check that the library is available
116      wm_save_LIBS="$LIBS"
117      AS_IF([wm_fn_lib_try_link "XmuLookupStandardColormap" "-lXmu"],
118          [wm_cv_xext_xmu="-lXmu"])
119      LIBS="$wm_save_LIBS"
120      AS_IF([test "x$wm_cv_xext_xmu" != "xno"],
121        [dnl
122        dnl A library was found, check if header is available and compile
123        wm_save_CFLAGS="$CFLAGS"
124        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl
125 @%:@include <X11/Xlib.h>
126 @%:@include <X11/Xutil.h>
127 @%:@include <X11/Xmu/StdCmap.h>
129 Display *dpy;
130 Atom prop;
131 ], [dnl
132   XmuLookupStandardColormap(dpy, 0, 0, 0, prop, False, True);]) ],
133            [],
134            [AC_MSG_ERROR([found $wm_cv_xext_xmu but cannot compile with the header])])
135        CFLAGS="$wm_save_CFLAGS"])
136     ])
137 dnl The cached check already reported problems when not found
138 AS_IF([test "x$wm_cv_xext_xmu" = "xno"],
139   [LIBXMU=""
140    unsupported="$unsupported Xmu"],
141   [AC_DEFINE([HAVE_LIBXMU], [1],
142        [defined when the libXmu library was found])
143    LIBXMU="$wm_cv_xext_xmu"
144    supported_xext="$supported_xext Xmu"])
145 AC_SUBST(LIBXMU)dnl
149 # WM_XEXT_CHECK_XINERAMA
150 # ----------------------
152 # Check for the Xinerama extension for multiscreen-as-one support
153 # The check depends on variable 'enable_xinerama' being either:
154 #   yes  - detect, fail if not found
155 #   no   - do not detect, disable support
156 #   auto - detect, disable if not found
158 # When found, append appropriate stuff in LIBXINERAMA, and append info to
159 # the variable 'supported_xext'
160 # When not found, append info to variable 'unsupported'
161 AC_DEFUN_ONCE([WM_XEXT_CHECK_XINERAMA],
162 [LIBXINERAMA=""
163 AS_IF([test "x$enable_xinerama" = "xno"],
164     [unsupported="$unsupported Xinerama"],
165     [AC_CACHE_CHECK([for Xinerama support library], [wm_cv_xext_xinerama],
166         [wm_cv_xext_xinerama=no
167          dnl
168          dnl We check that the library is available
169          wm_save_LIBS="$LIBS"
170          for wm_arg in dnl
171 dnl           Lib flag   % Function name        % info
172              "-lXinerama % XineramaQueryScreens" dnl
173              "-lXext     % XineramaGetInfo      % solaris" ; do
174            AS_IF([wm_fn_lib_try_link "`echo "$wm_arg" | dnl
175 sed -e 's,^[[^%]]*% *,,' | sed -e 's, *%.*$,,' `" dnl
176 "$XLFLAGS $XLIBS `echo "$wm_arg" | sed -e 's, *%.*$,,' `"],
177              [wm_cv_xext_xinerama="`echo "$wm_arg" | sed -e 's, *%[[^%]]*, ,' `"
178               break])
179          done
180          LIBS="$wm_save_LIBS"
181          AS_IF([test "x$wm_cv_xext_xinerama" = "xno"],
182              [AS_IF([test "x$enable_xinerama" = "xyesno"],
183                  [AC_MSG_ERROR([explicit Xinerama support requested but no library found])])],
184              [dnl
185               dnl A library was found, check if header is available and compiles
186               wm_save_CFLAGS="$CFLAGS"
187               AS_CASE([`echo "$wm_cv_xext_xinerama" | sed -e 's,^[[^%]]*,,' `],
188                   [*solaris*], [wm_header="X11/extensions/xinerama.h" ; wm_fct="XineramaGetInfo(NULL, 0, NULL, NULL, &intval)"],
189                   [wm_header="X11/extensions/Xinerama.h" ; wm_fct="XineramaQueryScreens(NULL, &intval)"])
190               AS_IF([wm_fn_lib_try_compile "$wm_header" "int intval;" "$wm_fct" ""],
191                   [],
192                   [AC_MSG_ERROR([found $wm_cv_xext_xinerama but cannot compile with the header])])
193               AS_UNSET([wm_header])
194               AS_UNSET([wm_fct])
195               CFLAGS="$wm_save_CFLAGS" dnl
196          ]) dnl
197      ])
198      AS_IF([test "x$wm_cv_xext_xinerama" = "xno"],
199         [unsupported="$unsupported Xinerama"
200          enable_xinerama="no"],
201         [LIBXINERAMA="`echo "$wm_cv_xext_xinerama" | sed -e 's, *%.*$,,' `"
202          AC_DEFINE([USE_XINERAMA], [1],
203              [defined when usable Xinerama library with header was found])
204          AS_CASE([`echo "$wm_cv_xext_xinerama" | sed -e 's,^[[^%]]*,,' `],
205              [*solaris*], [AC_DEFINE([SOLARIS_XINERAMA], [1],
206                  [defined when the Solaris Xinerama extension was detected])])
207          supported_xext="$supported_xext Xinerama"])
208     ])
209 AC_SUBST(LIBXINERAMA)dnl
213 # WM_XEXT_CHECK_XRANDR
214 # --------------------
216 # Check for the X RandR (Resize-and-Rotate) extension
217 # The check depends on variable 'enable_randr' being either:
218 #   yes  - detect, fail if not found
219 #   no   - do not detect, disable support
220 #   auto - detect, disable if not found
222 # When found, append appropriate stuff in LIBXRANDR, and append info to
223 # the variable 'supported_xext'
224 # When not found, append info to variable 'unsupported'
225 AC_DEFUN_ONCE([WM_XEXT_CHECK_XRANDR],
226 [WM_LIB_CHECK([RandR], [-lXrandr], [XRRQueryExtension], [$XLIBS],
227     [wm_save_CFLAGS="$CFLAGS"
228      AS_IF([wm_fn_lib_try_compile "X11/extensions/Xrandr.h" "Display *dpy;" "XRRQueryExtension(dpy, NULL, NULL)" ""],
229         [],
230         [AC_MSG_ERROR([found $CACHEVAR but cannot compile using XRandR header])])
231      CFLAGS="$wm_save_CFLAGS"],
232     [supported_xext], [LIBXRANDR], [], [-])dnl
233 AC_SUBST([LIBXRANDR])dnl
234 ]) dnl AC_DEFUN