move dock/icons size adjustments, to fix window placement
[wmaker-crm.git] / m4 / wm_imgfmt_check.m4
blob02245d28a6000e38941d6f8bc0d4890ac01cd23c
1 # wm_imgfmt_check.m4 - Macros to check for image file format 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_IMGFMT_CHECK_GIF
20 # -------------------
22 # Check for GIF file support through 'libgif', 'libungif' or 'giflib v5'
23 # The check depends on variable 'enable_gif' 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 GFXLIBS, and append info to
29 # the variable 'supported_gfx'
30 # When not found, append info to variable 'unsupported'
31 AC_DEFUN_ONCE([WM_IMGFMT_CHECK_GIF],
32 [AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
33 AS_IF([test "x$enable_gif" = "xno"],
34     [unsupported="$unsupported GIF"],
35     [AC_CACHE_CHECK([for GIF support library], [wm_cv_imgfmt_gif],
36         [wm_cv_imgfmt_gif=no
37          wm_save_LIBS="$LIBS"
38          dnl
39          dnl We check first if one of the known libraries is available
40          for wm_arg in "-lgif" "-lungif" ; do
41            AS_IF([wm_fn_lib_try_link "DGifOpenFileName" "$XLFLAGS $XLIBS $wm_arg"],
42              [wm_cv_imgfmt_gif="$wm_arg" ; break])
43          done
44          LIBS="$wm_save_LIBS"
45          AS_IF([test "x$enable_gif$wm_cv_imgfmt_gif" = "xyesno"],
46            [AC_MSG_ERROR([explicit GIF support requested but no library found])])
47          AS_IF([test "x$wm_cv_imgfmt_gif" != "xno"],
48            [dnl
49             dnl A library was found, now check for the appropriate header
50             wm_save_CFLAGS="$CFLAGS"
51             AS_IF([wm_fn_lib_try_compile "gif_lib.h" "" "return 0" ""],
52               [],
53               [AC_MSG_ERROR([found $wm_cv_imgfmt_gif but could not find appropriate header - are you missing libgif-dev package?])])
54             AS_IF([wm_fn_lib_try_compile "gif_lib.h" 'const char *filename = "dummy";' "DGifOpenFileName(filename)" ""],
55               [wm_cv_imgfmt_gif="$wm_cv_imgfmt_gif version:4"],
56               [AC_COMPILE_IFELSE(
57                 [AC_LANG_PROGRAM(
58                   [@%:@include <gif_lib.h>
60 const char *filename = "dummy";],
61                   [  int error_code;
62   DGifOpenFileName(filename, &error_code);] )],
63                 [wm_cv_imgfmt_gif="$wm_cv_imgfmt_gif version:5"],
64                 [AC_MSG_ERROR([found $wm_cv_imgfmt_gif and header, but cannot compile - unsupported version?])])dnl
65               ]
66             )
67             CFLAGS="$wm_save_CFLAGS"])
68          ])
69     AS_IF([test "x$wm_cv_imgfmt_gif" = "xno"],
70         [unsupported="$unsupported GIF"
71          enable_gif="no"],
72         [supported_gfx="$supported_gfx GIF"
73          WM_APPEND_ONCE([`echo "$wm_cv_imgfmt_gif" | sed -e 's, *version:.*,,' `], [GFXLIBS])
74          AC_DEFINE_UNQUOTED([USE_GIF],
75            [`echo "$wm_cv_imgfmt_gif" | sed -e 's,.*version:,,' `],
76            [defined when valid GIF library with header was found])])
77     ])
78 AM_CONDITIONAL([USE_GIF], [test "x$enable_gif" != "xno"])dnl
79 ]) dnl AC_DEFUN
82 # WM_IMGFMT_CHECK_JPEG
83 # --------------------
85 # Check for JPEG file support through 'libjpeg'
86 # The check depends on variable 'enable_jpeg' being either:
87 #   yes  - detect, fail if not found
88 #   no   - do not detect, disable support
89 #   auto - detect, disable if not found
91 # When found, append appropriate stuff in GFXLIBS, and append info to
92 # the variable 'supported_gfx'
93 # When not found, append info to variable 'unsupported'
94 AC_DEFUN_ONCE([WM_IMGFMT_CHECK_JPEG],
95 [WM_LIB_CHECK([JPEG], [-ljpeg], [jpeg_destroy_compress], [$XLFLAGS $XLIBS],
96     [AC_COMPILE_IFELSE(
97                 [AC_LANG_PROGRAM(
98                     [@%:@include <stdlib.h>
99 @%:@include <stdio.h>
100 @%:@include <jpeglib.h>],
101                     [  struct jpeg_decompress_struct cinfo;
103   jpeg_destroy_decompress(&cinfo);])],
104                 [],
105                 [AS_ECHO([failed])
106                  AS_ECHO(["$as_me: error: found $CACHEVAR but cannot compile header"])
107                  AS_ECHO(["$as_me: error:   - does header 'jpeglib.h' exists? (is package 'jpeg-dev' missing?)"])
108                  AS_ECHO(["$as_me: error:   - version of header is not supported? (report to dev team)"])
109                  AC_MSG_ERROR([JPEG library is not usable, cannot continue])])
110            ],
111     [supported_gfx], [GFXLIBS])dnl
112 ]) dnl AC_DEFUN
115 # WM_IMGFMT_CHECK_PNG
116 # -------------------
118 # Check for PNG file support through 'libpng'
119 # The check depends on variable 'enable_png' being either:
120 #   yes  - detect, fail if not found
121 #   no   - do not detect, disable support
122 #   auto - detect, disable if not found
124 # When found, append appropriate stuff in GFXLIBS, and append info to
125 # the variable 'supported_gfx'
126 # When not found, append info to variable 'unsupported'
127 AC_DEFUN_ONCE([WM_IMGFMT_CHECK_PNG],
128 [WM_LIB_CHECK([PNG], ["-lpng" "-lpng -lz" "-lpng -lz -lm"], [png_get_valid], [$XLFLAGS $XLIBS],
129     [wm_save_CFLAGS="$CFLAGS"
130      AS_IF([wm_fn_lib_try_compile "png.h" "" "return 0" ""],
131          [],
132          [AC_MSG_ERROR([found $CACHEVAR but could not find appropriate header - are you missing libpng-dev package?])])
133      AS_IF([wm_fn_lib_try_compile "png.h" "" "png_get_valid(NULL, NULL, PNG_INFO_tRNS)" ""],
134          [],
135          [AC_MSG_ERROR([found $CACHEVAR and header, but cannot compile - unsupported version?])])
136      CFLAGS="$wm_save_CFLAGS"],
137     [supported_gfx], [GFXLIBS])dnl
138 ]) dnl AC_DEFUN
141 # WM_IMGFMT_CHECK_TIFF
142 # --------------------
144 # Check for TIFF file support through 'libtiff'
145 # The check depends on variable 'enable_tiff' being either:
146 #   yes  - detect, fail if not found
147 #   no   - do not detect, disable support
148 #   auto - detect, disable if not found
150 # When found, append appropriate stuff in GFXLIBS, and append info to
151 # the variable 'supported_gfx'
152 # When not found, append info to variable 'unsupported'
153 AC_DEFUN_ONCE([WM_IMGFMT_CHECK_TIFF],
154 [WM_LIB_CHECK([TIFF],
155     ["-ltiff"  \
156      dnl TIFF can have a dependancy over zlib
157      "-ltiff -lz" "-ltiff -lz -lm"  \
158      dnl It may also have a dependancy to jpeg_lib
159      "-ltiff -ljpeg" "-ltiff -ljpeg -lz" "-ltiff -ljpeg -lz -lm"  \
160      dnl There is also a possible dependancy on JBIGKit
161      "-ltiff -ljpeg -ljbig -lz"  \
162      dnl Probably for historical reasons?
163      "-ltiff34" "-ltiff34 -ljpeg" "-ltiff34 -ljpeg -lm"],
164     [TIFFGetVersion], [$XLFLAGS $XLIBS],
165     [wm_save_CFLAGS="$CFLAGS"
166      AS_IF([wm_fn_lib_try_compile "tiffio.h" "" "return 0" ""],
167          [],
168          [AC_MSG_ERROR([found $CACHEVAR but could not find appropriate header - are you missing libtiff-dev package?])])
169      AS_IF([wm_fn_lib_try_compile "tiffio.h" 'const char *filename = "dummy";' 'TIFFOpen(filename, "r")' ""],
170          [],
171          [AC_MSG_ERROR([found $CACHEVAR and header, but cannot compile - unsupported version?])])
172      CFLAGS="$wm_save_CFLAGS"],
173     [supported_gfx], [GFXLIBS])dnl
174 ]) dnl AC_DEFUN
177 # WM_IMGFMT_CHECK_XPM
178 # -------------------
180 # Check for XPM file support through 'libXpm'
181 # The check depends on variable 'enable_xpm' being either:
182 #   yes  - detect, fail if not found
183 #   no   - do not detect, use internal support
184 #   auto - detect, use internal if not found
186 # When found, append appropriate stuff in GFXLIBS, and append info to
187 # the variable 'supported_gfx'
188 AC_DEFUN_ONCE([WM_IMGFMT_CHECK_XPM],
189 [AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
190 AS_IF([test "x$enable_xpm" = "xno"],
191     [supported_gfx="$supported_gfx builtin-XPM"],
192     [AC_CACHE_CHECK([for XPM support library], [wm_cv_imgfmt_xpm],
193         [wm_cv_imgfmt_xpm=no
194          dnl
195          dnl We check first if one of the known libraries is available
196          wm_save_LIBS="$LIBS"
197          AS_IF([wm_fn_lib_try_link "XpmCreatePixmapFromData" "$XLFLAGS $XLIBS -lXpm"],
198            [wm_cv_imgfmt_xpm="-lXpm" ; break])
199          LIBS="$wm_save_LIBS"
200          AS_IF([test "x$enable_xpm$wm_cv_imgfmt_xpm" = "xyesno"],
201            [AC_MSG_ERROR([explicit libXpm support requested but no library found])])
202          AS_IF([test "x$wm_cv_imgfmt_xpm" != "xno"],
203            [dnl
204             dnl A library was found, now check for the appropriate header
205             wm_save_CFLAGS="$CFLAGS"
206             AS_IF([wm_fn_lib_try_compile "X11/xpm.h" "" "return 0" "$XCFLAGS"],
207               [],
208               [AC_MSG_ERROR([found $wm_cv_imgfmt_xpm but could not find appropriate header - are you missing libXpm-dev package?])])
209             AS_IF([wm_fn_lib_try_compile "X11/xpm.h" 'char *filename = "dummy";' 'XpmReadFileToXpmImage(filename, NULL, NULL)' "$XCFLAGS"],
210               [],
211               [AC_MSG_ERROR([found $wm_cv_imgfmt_xpm and header, but cannot compile - unsupported version?])])
212             CFLAGS="$wm_save_CFLAGS"])
213          ])
214     AS_IF([test "x$wm_cv_imgfmt_xpm" = "xno"],
215         [supported_gfx="$supported_gfx builtin-XPM"
216          enable_xpm="no"],
217         [supported_gfx="$supported_gfx XPM"
218          WM_APPEND_ONCE([$wm_cv_imgfmt_xpm], [GFXLIBS])
219          AC_DEFINE([USE_XPM], [1],
220            [defined when valid XPM library with header was found])])
221     ])
222 AM_CONDITIONAL([USE_XPM], [test "x$enable_xpm" != "xno"])dnl
223 ]) dnl AC_DEFUN