New comit of SDL2
[supertux.git] / src / SDL2 / external / libwebp-0.3.0 / configure.ac
1 AC_INIT([libwebp], [0.3.0],
2         [http://code.google.com/p/webp/issues],,
3         [http://developers.google.com/speed/webp])
4 AC_CANONICAL_TARGET
5 AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
6
7 dnl === automake >= 1.12 requires this for 'unusual archivers' support.
8 dnl === it must occur before LT_INIT (AC_PROG_LIBTOOL).
9 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
10
11 AC_PROG_LIBTOOL
12 AM_PROG_CC_C_O
13
14 dnl === Enable less verbose output when building.
15 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
16
17 dnl === SET_IF_UNSET(shell_var, value)
18 dnl ===   Set the shell variable 'shell_var' to 'value' if it is unset.
19 AC_DEFUN([SET_IF_UNSET], [test "${$1+set}" = "set" || $1=$2])
20
21 AC_ARG_ENABLE([everything],
22               AS_HELP_STRING([--enable-everything],
23                              [Enable all optional targets. These can still be
24                               disabled with --disable-target]),
25               [SET_IF_UNSET([enable_libwebpdecoder], [$enableval])
26                SET_IF_UNSET([enable_libwebpdemux], [$enableval])
27                SET_IF_UNSET([enable_libwebpmux], [$enableval])])
28
29 AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR],
30             [Path to the pkgconfig directory @<:@LIBDIR/pkgconfig@:>@]),
31             [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
32 AC_SUBST([pkgconfigdir])
33
34 dnl === TEST_AND_ADD_CFLAGS(flag)
35 dnl ===   Checks whether $CC supports 'flag' and adds it to AM_CFLAGS on success.
36 AC_DEFUN([TEST_AND_ADD_CFLAGS],
37          [SAVED_CFLAGS="$CFLAGS"
38           CFLAGS="-Werror $1"
39           AC_MSG_CHECKING([whether $CC supports $1])
40           dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition.
41           AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
42                             [AC_MSG_RESULT([yes])]
43                             [AS_VAR_APPEND([AM_CFLAGS], [" $1"])],
44                             [AC_MSG_RESULT([no])])
45           CFLAGS="$SAVED_CFLAGS"])
46 TEST_AND_ADD_CFLAGS([-Wall])
47 TEST_AND_ADD_CFLAGS([-Wdeclaration-after-statement])
48 TEST_AND_ADD_CFLAGS([-Wextra])
49 TEST_AND_ADD_CFLAGS([-Wmissing-declarations])
50 TEST_AND_ADD_CFLAGS([-Wmissing-prototypes])
51 TEST_AND_ADD_CFLAGS([-Wold-style-definition])
52 TEST_AND_ADD_CFLAGS([-Wshadow])
53 TEST_AND_ADD_CFLAGS([-Wunused-but-set-variable])
54 TEST_AND_ADD_CFLAGS([-Wunused])
55 TEST_AND_ADD_CFLAGS([-Wvla])
56 AC_SUBST([AM_CFLAGS])
57
58 dnl === CLEAR_LIBVARS([var_pfx])
59 dnl ===   Clears <var_pfx>_{INCLUDES,LIBS}.
60 AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""])
61
62 dnl === WITHLIB_OPTION([opt_pfx], [outvar_pfx])
63 dnl ===   Defines --with-<opt_pfx>{include,lib}dir options which set
64 dnl ===   the variables <outvar_pfx>_{INCLUDES,LIBS}.
65 AC_DEFUN([WITHLIB_OPTION],
66   [AC_ARG_WITH([$1includedir],
67                AS_HELP_STRING([--with-$1includedir=DIR],
68                               [use $2 includes from DIR]),
69                $2_INCLUDES="-I$withval")
70    AC_ARG_WITH([$1libdir],
71                AS_HELP_STRING([--with-$1libdir=DIR],
72                               [use $2 libraries from DIR]),
73                [$2_LIBS="-L$withval"])])
74
75 dnl === LIBCHECK_PROLOGUE([var_pfx])
76 dnl ===   Caches the current values of CPPFLAGS/LIBS in SAVED_* then
77 dnl ===   prepends the current values with <var_pfx>_{INCLUDES,LIBS}.
78 AC_DEFUN([LIBCHECK_PROLOGUE],
79          [SAVED_CPPFLAGS=$CPPFLAGS
80           SAVED_LIBS=$LIBS
81           CPPFLAGS="$$1_INCLUDES $CPPFLAGS"
82           LIBS="$$1_LIBS $LIBS"])
83
84 dnl === LIBCHECK_EPILOGUE([var_pfx])
85 dnl ===   Restores the values of CPPFLAGS/LIBS from SAVED_* and exports
86 dnl ===   <var_pfx>_{INCLUDES,LIBS} with AC_SUBST.
87 AC_DEFUN([LIBCHECK_EPILOGUE],
88          [AC_SUBST($1_LIBS)
89           AC_SUBST($1_INCLUDES)
90           CPPFLAGS=$SAVED_CPPFLAGS
91           LIBS=$SAVED_LIBS])
92
93 dnl === Check for pthread support
94 AC_ARG_ENABLE([threading],
95               AS_HELP_STRING([--disable-threading],
96                              [Disable detection of thread support]),,
97               [enable_threading=yes])
98 if test "$enable_threading" = "yes"; then
99   AC_MSG_NOTICE([checking for threading support...])
100   AX_PTHREAD([AC_DEFINE([WEBP_USE_THREAD], [1],
101                         [Undefine this to disable thread support.])
102               LIBS="$PTHREAD_LIBS $LIBS"
103               CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
104               CC="$PTHREAD_CC"
105              ],
106              [enable_threading=no])
107 fi
108 AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}])
109
110 dnl === check for OpenGL/GLUT support ===
111 CLEAR_LIBVARS([GL])
112 WITHLIB_OPTION([gl], [GL])
113
114 LIBCHECK_PROLOGUE([GL])
115
116 glut_cflags="none"
117 glut_ldflags="none"
118 case $host_os in
119   darwin*)
120     # Special case for OSX builds. Append these to give the user a chance to
121     # override with --with-gl*
122     glut_cflags="$glut_cflags|-framework GLUT -framework OpenGL"
123     glut_ldflags="$glut_ldflags|-framework GLUT -framework OpenGL"
124     ;;
125 esac
126
127 GLUT_SAVED_CPPFLAGS="$CPPFLAGS"
128 SAVED_IFS="$IFS"
129 IFS="|"
130 for flag in $glut_cflags; do
131   # restore IFS immediately as the autoconf macros may need the default.
132   IFS="$SAVED_IFS"
133   unset ac_cv_header_GL_glut_h
134   unset ac_cv_header_OpenGL_glut_h
135
136   case $flag in
137     none) ;;
138     *) CPPFLAGS="$flag $CPPFLAGS";;
139   esac
140   AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h OpenGL/glut.h],
141                    [glut_headers=yes;
142                     test "$flag" = "none" || GL_INCLUDES="$CPPFLAGS";
143                     break])
144   CPPFLAGS="$GLUT_SAVED_CPPFLAGS"
145   test "$glut_headers" = "yes" && break
146 done
147 IFS="$SAVED_IFS"
148
149 if test "$glut_headers" = "yes"; then
150   AC_LANG_PUSH([C])
151   GLUT_SAVED_LDFLAGS="$LDFLAGS"
152   SAVED_IFS="$IFS"
153   IFS="|"
154   for flag in $glut_ldflags; do
155     # restore IFS immediately as the autoconf macros may need the default.
156     IFS="$SAVED_IFS"
157     unset ac_cv_search_glBegin
158
159     case $flag in
160       none) ;;
161       *) LDFLAGS="$flag $LDFLAGS";;
162     esac
163
164     # find libGL
165     GL_SAVED_LIBS="$LIBS"
166     AC_SEARCH_LIBS([glBegin], [GL OpenGL])
167     LIBS="$GL_SAVED_LIBS"
168
169     # A direct link to libGL may not be necessary on e.g., linux.
170     for lib in "" $ac_cv_search_glBegin; do
171       unset ac_cv_search_glutMainLoop
172       AC_SEARCH_LIBS([glutMainLoop], [glut], [glut_support=yes], [], [$lib])
173       if test "$glut_support" = "yes"; then
174         GL_LIBS="$LDFLAGS"
175         if test "$ac_cv_search_glutMainLoop" != "none required"; then
176           GL_LIBS="$GL_LIBS $ac_cv_search_glutMainLoop"
177         fi
178         GL_LIBS="$GL_LIBS $lib"
179         break
180       fi
181     done
182     LDFLAGS="$GLUT_SAVED_LDFLAGS"
183     test "$glut_support" = "yes" && break
184   done
185   IFS="$SAVED_IFS"
186   AC_LANG_POP
187 fi
188
189 LIBCHECK_EPILOGUE([GL])
190
191 if test "$glut_support" = "yes" -a "$enable_libwebpdemux" = "yes"; then
192   build_vwebp=yes
193 fi
194 AM_CONDITIONAL([BUILD_VWEBP], [test "$build_vwebp" = "yes"])
195
196 dnl === check for PNG support ===
197
198 CLEAR_LIBVARS([PNG])
199 AC_PATH_PROGS(LIBPNG_CONFIG,
200               [libpng-config libpng15-config libpng14-config libpng12-config])
201 if test -n "$LIBPNG_CONFIG"; then
202   PNG_INCLUDES=`$LIBPNG_CONFIG --cflags`
203   PNG_PREFIX=`$LIBPNG_CONFIG --prefix`
204   if test "${PNG_PREFIX}/lib" != "/usr/lib" ; then
205     PNG_LIBS="-L${PNG_PREFIX}/lib"
206   fi
207   PNG_LIBS="$PNG_LIBS `$LIBPNG_CONFIG --libs`"
208 fi
209
210 WITHLIB_OPTION([png], [PNG])
211
212 LIBCHECK_PROLOGUE([PNG])
213 AC_CHECK_HEADER(png.h,
214   AC_SEARCH_LIBS(png_get_libpng_ver, [png],
215                  [test "$ac_cv_search_png_get_libpng_ver" = "none required" \
216                     || PNG_LIBS="$PNG_LIBS $ac_cv_search_png_get_libpng_ver"
217                   PNG_INCLUDES="$PNG_INCLUDES -DWEBP_HAVE_PNG"
218                   AC_DEFINE(WEBP_HAVE_PNG, [1],
219                             [Set to 1 if PNG library is installed])
220                   png_support=yes
221                  ],
222                  [AC_MSG_WARN(Optional png library not found)
223                   PNG_LIBS=""
224                   PNG_INCLUDES=""
225                  ],
226                  [$MATH_LIBS]),
227   [AC_MSG_WARN(png library not available - no png.h)
228    PNG_LIBS=""
229    PNG_INCLUDES=""
230   ],
231 )
232 LIBCHECK_EPILOGUE([PNG])
233
234 dnl === check for JPEG support ===
235
236 CLEAR_LIBVARS([JPEG])
237 WITHLIB_OPTION([jpeg], [JPEG])
238
239 LIBCHECK_PROLOGUE([JPEG])
240 AC_CHECK_HEADER(jpeglib.h,
241   AC_CHECK_LIB(jpeg, jpeg_set_defaults,
242                [JPEG_LIBS="$JPEG_LIBS -ljpeg"
243                 JPEG_INCLUDES="$JPEG_INCLUDES -DWEBP_HAVE_JPEG"
244                 AC_DEFINE(WEBP_HAVE_JPEG, [1],
245                           [Set to 1 if JPEG library is installed])
246                 jpeg_support=yes
247                ],
248                AC_MSG_WARN(Optional jpeg library not found),
249                [$MATH_LIBS]),
250   AC_MSG_WARN(jpeg library not available - no jpeglib.h)
251 )
252 LIBCHECK_EPILOGUE([JPEG])
253
254 dnl === check for TIFF support ===
255
256 CLEAR_LIBVARS([TIFF])
257 WITHLIB_OPTION([tiff], [TIFF])
258
259 LIBCHECK_PROLOGUE([TIFF])
260 AC_CHECK_HEADER(tiffio.h,
261   AC_CHECK_LIB(tiff, TIFFGetVersion,
262                [TIFF_LIBS="$TIFF_LIBS -ltiff"
263                 TIFF_INCLUDES="$TIFF_INCLUDES -DWEBP_HAVE_TIFF"
264                 AC_DEFINE(WEBP_HAVE_TIFF, [1],
265                           [Set to 1 if TIFF library is installed])
266                 tiff_support=yes
267                ],
268                AC_MSG_WARN(Optional tiff library not found),
269                [$MATH_LIBS]),
270   AC_MSG_WARN(tiff library not available - no tiffio.h)
271 )
272 LIBCHECK_EPILOGUE([TIFF])
273
274 dnl === check for GIF support ===
275
276 CLEAR_LIBVARS([GIF])
277 WITHLIB_OPTION([gif], [GIF])
278
279 LIBCHECK_PROLOGUE([GIF])
280 AC_CHECK_HEADER(gif_lib.h,
281   AC_CHECK_LIB([gif], [DGifOpenFileHandle],
282                [GIF_LIBS="$GIF_LIBS -lgif"
283                 gif_support=yes
284                ],
285                AC_MSG_WARN(Optional gif library not found),
286                [$MATH_LIBS]),
287   AC_MSG_WARN(gif library not available - no gif_lib.h)
288 )
289 LIBCHECK_EPILOGUE([GIF])
290
291 if test "$gif_support" = "yes" -a \
292         "$enable_libwebpmux" = "yes"; then
293   build_gif2webp=yes
294 fi
295 AM_CONDITIONAL([BUILD_GIF2WEBP], [test "${build_gif2webp}" = "yes"])
296
297 dnl === check for WIC support ===
298
299 if test "$target_os" = "mingw32"; then
300   AC_CHECK_HEADERS([wincodec.h shlwapi.h windows.h])
301   if test "$ac_cv_header_wincodec_h" = "yes"; then
302     AC_MSG_CHECKING(for Windows Imaging Component support)
303     SAVED_LIBS=$LIBS
304     LIBS="-lshlwapi -lole32 $LIBS"
305     # match include structure from [cd]webp.c
306     wic_headers="
307       #define INITGUID
308       #define CINTERFACE
309       #define COBJMACROS
310       #define _WIN32_IE 0x500
311
312       #include <shlwapi.h>
313       #include <windows.h>
314       #include <wincodec.h>
315       "
316     # test for functions from each lib and the GUID is created properly
317     wic_main="
318       int main(void) {
319         CLSID_WICImagingFactory;
320         CoInitialize(NULL);
321         SHCreateStreamOnFile(NULL, 0, NULL);
322         return 0;
323       }
324       "
325     AC_LANG_PUSH(C)
326     AC_LINK_IFELSE(
327       [AC_LANG_SOURCE([
328          $wic_headers
329          $wic_main])],
330       [wic_support=yes],
331       [wic_support=no]
332     )
333     AC_LANG_POP
334
335     test "$wic_support" = "yes" || LIBS=$SAVED_LIBS
336     AC_MSG_RESULT(${wic_support-no})
337   fi
338 fi
339
340 dnl === If --enable-swap-16bit-csp is defined, add -DWEBP_SWAP_16BIT_CSP
341
342 USE_SWAP_16BIT_CSP=""
343 AC_MSG_CHECKING(if --enable-swap-16bit-csp option is specified)
344 AC_ARG_ENABLE([swap-16bit-csp],
345               AS_HELP_STRING([--enable-swap-16bit-csp],
346                              [Enable byte swap for 16 bit colorspaces]))
347 if test "$enable_swap_16bit_csp" = "yes"; then
348   USE_SWAP_16BIT_CSP="-DWEBP_SWAP_16BIT_CSP"
349 fi
350 AC_MSG_RESULT(${enable_swap_16bit_csp-no})
351 AC_SUBST(USE_SWAP_16BIT_CSP)
352
353 dnl === If --enable-experimental is defined, add -DWEBP_EXPERIMENTAL_FEATURES
354
355 USE_EXPERIMENTAL_CODE=""
356 AC_MSG_CHECKING(if --enable-experimental option is specified)
357 AC_ARG_ENABLE([experimental], AS_HELP_STRING([--enable-experimental],
358                                              [Activate experimental features]))
359 if test "$enable_experimental" = "yes"; then
360   AC_DEFINE(WEBP_EXPERIMENTAL_FEATURES, [1], [Enable experimental code])
361   USE_EXPERIMENTAL_CODE="-DWEBP_EXPERIMENTAL_FEATURES"
362 fi
363 AC_MSG_RESULT(${enable_experimental-no})
364 AC_SUBST(USE_EXPERIMENTAL_CODE)
365
366 dnl === Check whether libwebpmux should be built
367 AC_MSG_CHECKING(whether libwebpmux is to be built)
368 AC_ARG_ENABLE([libwebpmux],
369               AS_HELP_STRING([--enable-libwebpmux],
370                              [Build libwebpmux @<:@default=no@:>@]))
371 AC_MSG_RESULT(${enable_libwebpmux-no})
372 AM_CONDITIONAL([WANT_MUX], [test "$enable_libwebpmux" = "yes"])
373
374 dnl === Check whether libwebpdemux should be built
375 AC_MSG_CHECKING(whether libwebpdemux is to be built)
376 AC_ARG_ENABLE([libwebpdemux],
377               AS_HELP_STRING([--enable-libwebpdemux],
378                              [Build libwebpdemux @<:@default=no@:>@]))
379 AC_MSG_RESULT(${enable_libwebpdemux-no})
380 AM_CONDITIONAL([WANT_DEMUX], [test "$enable_libwebpdemux" = "yes"])
381
382 dnl === Check whether decoder library should be built.
383 AC_MSG_CHECKING(whether decoder library is to be built)
384 AC_ARG_ENABLE([libwebpdecoder],
385               AS_HELP_STRING([--enable-libwebpdecoder],
386                              [Build libwebpdecoder @<:@default=no@:>@]))
387 AC_MSG_RESULT(${enable_libwebpdecoder-no})
388 AM_CONDITIONAL([BUILD_LIBWEBPDECODER], [test "$enable_libwebpdecoder" = "yes"])
389
390 dnl =========================
391
392 AC_CONFIG_MACRO_DIR([m4])
393 AC_CONFIG_HEADERS([config.h])
394 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile \
395                  examples/Makefile src/dec/Makefile \
396                  src/enc/Makefile src/dsp/Makefile \
397                  src/demux/Makefile src/mux/Makefile \
398                  src/utils/Makefile \
399                  src/libwebp.pc src/libwebpdecoder.pc \
400                  src/demux/libwebpdemux.pc src/mux/libwebpmux.pc])
401
402
403 AC_OUTPUT
404
405 AC_MSG_NOTICE([
406 WebP Configuration Summary
407 --------------------------
408
409 Shared libraries: ${enable_shared}
410 Static libraries: ${enable_static}
411 Threaded decode: ${enable_threading-no}
412 libwebp: yes
413 libwebpdecoder: ${enable_libwebpdecoder-no}
414 libwebpdemux: ${enable_libwebpdemux-no}
415 libwebpmux: ${enable_libwebpmux-no}
416
417 Tools:
418 cwebp : yes
419   Input format support
420   ====================
421   JPEG : ${jpeg_support-no}
422   PNG  : ${png_support-no}
423   TIFF : ${tiff_support-no}
424   WIC  : ${wic_support-no}
425 dwebp : yes
426   Output format support
427   =====================
428   PNG  : ${png_support-no}
429   WIC  : ${wic_support-no}
430 gif2webp : ${build_gif2webp-no}
431 webpmux  : ${enable_libwebpmux-no}
432 vwebp    : ${build_vwebp-no}
433 ])