1 AC_INIT([libwebp], [0.3.0],
2 [http://code.google.com/p/webp/issues],,
3 [http://developers.google.com/speed/webp])
5 AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
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])
14 dnl === Enable less verbose output when building.
15 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
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])
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])])
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])
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"
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])
58 dnl === CLEAR_LIBVARS([var_pfx])
59 dnl === Clears <var_pfx>_{INCLUDES,LIBS}.
60 AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""])
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"])])
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
81 CPPFLAGS="$$1_INCLUDES $CPPFLAGS"
82 LIBS="$$1_LIBS $LIBS"])
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],
90 CPPFLAGS=$SAVED_CPPFLAGS
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"
106 [enable_threading=no])
108 AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}])
110 dnl === check for OpenGL/GLUT support ===
112 WITHLIB_OPTION([gl], [GL])
114 LIBCHECK_PROLOGUE([GL])
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"
127 GLUT_SAVED_CPPFLAGS="$CPPFLAGS"
130 for flag in $glut_cflags; do
131 # restore IFS immediately as the autoconf macros may need the default.
133 unset ac_cv_header_GL_glut_h
134 unset ac_cv_header_OpenGL_glut_h
138 *) CPPFLAGS="$flag $CPPFLAGS";;
140 AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h OpenGL/glut.h],
142 test "$flag" = "none" || GL_INCLUDES="$CPPFLAGS";
144 CPPFLAGS="$GLUT_SAVED_CPPFLAGS"
145 test "$glut_headers" = "yes" && break
149 if test "$glut_headers" = "yes"; then
151 GLUT_SAVED_LDFLAGS="$LDFLAGS"
154 for flag in $glut_ldflags; do
155 # restore IFS immediately as the autoconf macros may need the default.
157 unset ac_cv_search_glBegin
161 *) LDFLAGS="$flag $LDFLAGS";;
165 GL_SAVED_LIBS="$LIBS"
166 AC_SEARCH_LIBS([glBegin], [GL OpenGL])
167 LIBS="$GL_SAVED_LIBS"
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
175 if test "$ac_cv_search_glutMainLoop" != "none required"; then
176 GL_LIBS="$GL_LIBS $ac_cv_search_glutMainLoop"
178 GL_LIBS="$GL_LIBS $lib"
182 LDFLAGS="$GLUT_SAVED_LDFLAGS"
183 test "$glut_support" = "yes" && break
189 LIBCHECK_EPILOGUE([GL])
191 if test "$glut_support" = "yes" -a "$enable_libwebpdemux" = "yes"; then
194 AM_CONDITIONAL([BUILD_VWEBP], [test "$build_vwebp" = "yes"])
196 dnl === check for PNG support ===
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"
207 PNG_LIBS="$PNG_LIBS `$LIBPNG_CONFIG --libs`"
210 WITHLIB_OPTION([png], [PNG])
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])
222 [AC_MSG_WARN(Optional png library not found)
227 [AC_MSG_WARN(png library not available - no png.h)
232 LIBCHECK_EPILOGUE([PNG])
234 dnl === check for JPEG support ===
236 CLEAR_LIBVARS([JPEG])
237 WITHLIB_OPTION([jpeg], [JPEG])
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])
248 AC_MSG_WARN(Optional jpeg library not found),
250 AC_MSG_WARN(jpeg library not available - no jpeglib.h)
252 LIBCHECK_EPILOGUE([JPEG])
254 dnl === check for TIFF support ===
256 CLEAR_LIBVARS([TIFF])
257 WITHLIB_OPTION([tiff], [TIFF])
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])
268 AC_MSG_WARN(Optional tiff library not found),
270 AC_MSG_WARN(tiff library not available - no tiffio.h)
272 LIBCHECK_EPILOGUE([TIFF])
274 dnl === check for GIF support ===
277 WITHLIB_OPTION([gif], [GIF])
279 LIBCHECK_PROLOGUE([GIF])
280 AC_CHECK_HEADER(gif_lib.h,
281 AC_CHECK_LIB([gif], [DGifOpenFileHandle],
282 [GIF_LIBS="$GIF_LIBS -lgif"
285 AC_MSG_WARN(Optional gif library not found),
287 AC_MSG_WARN(gif library not available - no gif_lib.h)
289 LIBCHECK_EPILOGUE([GIF])
291 if test "$gif_support" = "yes" -a \
292 "$enable_libwebpmux" = "yes"; then
295 AM_CONDITIONAL([BUILD_GIF2WEBP], [test "${build_gif2webp}" = "yes"])
297 dnl === check for WIC support ===
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)
304 LIBS="-lshlwapi -lole32 $LIBS"
305 # match include structure from [cd]webp.c
310 #define _WIN32_IE 0x500
314 #include <wincodec.h>
316 # test for functions from each lib and the GUID is created properly
319 CLSID_WICImagingFactory;
321 SHCreateStreamOnFile(NULL, 0, NULL);
335 test "$wic_support" = "yes" || LIBS=$SAVED_LIBS
336 AC_MSG_RESULT(${wic_support-no})
340 dnl === If --enable-swap-16bit-csp is defined, add -DWEBP_SWAP_16BIT_CSP
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"
350 AC_MSG_RESULT(${enable_swap_16bit_csp-no})
351 AC_SUBST(USE_SWAP_16BIT_CSP)
353 dnl === If --enable-experimental is defined, add -DWEBP_EXPERIMENTAL_FEATURES
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"
363 AC_MSG_RESULT(${enable_experimental-no})
364 AC_SUBST(USE_EXPERIMENTAL_CODE)
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"])
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"])
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"])
390 dnl =========================
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 \
399 src/libwebp.pc src/libwebpdecoder.pc \
400 src/demux/libwebpdemux.pc src/mux/libwebpmux.pc])
406 WebP Configuration Summary
407 --------------------------
409 Shared libraries: ${enable_shared}
410 Static libraries: ${enable_static}
411 Threaded decode: ${enable_threading-no}
413 libwebpdecoder: ${enable_libwebpdecoder-no}
414 libwebpdemux: ${enable_libwebpdemux-no}
415 libwebpmux: ${enable_libwebpmux-no}
421 JPEG : ${jpeg_support-no}
422 PNG : ${png_support-no}
423 TIFF : ${tiff_support-no}
424 WIC : ${wic_support-no}
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}