1AC_INIT([libwebp], [1.3.0], 2 [https://bugs.chromium.org/p/webp],, 3 [https://developers.google.com/speed/webp]) 4AC_CANONICAL_HOST 5AC_PREREQ([2.60]) 6AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) 7 8dnl === automake >= 1.12 requires this for 'unusual archivers' support. 9dnl === it must occur before LT_INIT (AC_PROG_LIBTOOL). 10m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 11 12dnl === AC_PROG_LIBTOOL is deprecated. 13m4_ifdef([LT_INIT], [LT_INIT], [AC_PROG_LIBTOOL]) 14AC_PROG_SED 15AM_PROG_CC_C_O 16 17dnl === Enable less verbose output when building. 18m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 19 20dnl == test endianness 21AC_C_BIGENDIAN 22 23dnl === SET_IF_UNSET(shell_var, value) 24dnl === Set the shell variable 'shell_var' to 'value' if it is unset. 25AC_DEFUN([SET_IF_UNSET], [test "${$1+set}" = "set" || $1=$2]) 26 27AC_ARG_ENABLE([everything], 28 AS_HELP_STRING([--enable-everything], 29 [Enable all optional targets. These can still be 30 disabled with --disable-target]), 31 [SET_IF_UNSET([enable_libsharpyuv], [$enableval]) 32 SET_IF_UNSET([enable_libwebpdecoder], [$enableval]) 33 SET_IF_UNSET([enable_libwebpdemux], [$enableval]) 34 SET_IF_UNSET([enable_libwebpextras], [$enableval]) 35 SET_IF_UNSET([enable_libwebpmux], [$enableval])]) 36 37dnl === Check whether libwebpmux should be built 38AC_MSG_CHECKING(whether libwebpmux is to be built) 39AC_ARG_ENABLE([libwebpmux], 40 AS_HELP_STRING([--disable-libwebpmux], 41 [Disable libwebpmux @<:@default=no@:>@]), 42 [], [enable_libwebpmux=yes]) 43AC_MSG_RESULT(${enable_libwebpmux-no}) 44AM_CONDITIONAL([BUILD_MUX], [test "$enable_libwebpmux" = "yes"]) 45 46dnl === Check whether libwebpdemux should be built 47AC_MSG_CHECKING(whether libwebpdemux is to be built) 48AC_ARG_ENABLE([libwebpdemux], 49 AS_HELP_STRING([--disable-libwebpdemux], 50 [Disable libwebpdemux @<:@default=no@:>@]), 51 [], [enable_libwebpdemux=yes]) 52AC_MSG_RESULT(${enable_libwebpdemux-no}) 53AM_CONDITIONAL([BUILD_DEMUX], [test "$enable_libwebpdemux" = "yes"]) 54 55dnl === Check whether decoder library should be built. 56AC_MSG_CHECKING(whether decoder library is to be built) 57AC_ARG_ENABLE([libwebpdecoder], 58 AS_HELP_STRING([--enable-libwebpdecoder], 59 [Build libwebpdecoder @<:@default=no@:>@])) 60AC_MSG_RESULT(${enable_libwebpdecoder-no}) 61AM_CONDITIONAL([BUILD_LIBWEBPDECODER], [test "$enable_libwebpdecoder" = "yes"]) 62 63dnl === Check whether libwebpextras should be built 64AC_MSG_CHECKING(whether libwebpextras is to be built) 65AC_ARG_ENABLE([libwebpextras], 66 AS_HELP_STRING([--enable-libwebpextras], 67 [Build libwebpextras @<:@default=no@:>@])) 68AC_MSG_RESULT(${enable_libwebpextras-no}) 69AM_CONDITIONAL([BUILD_EXTRAS], [test "$enable_libwebpextras" = "yes"]) 70 71dnl === If --enable-asserts is not defined, define NDEBUG 72 73AC_MSG_CHECKING(whether asserts are enabled) 74AC_ARG_ENABLE([asserts], 75 AS_HELP_STRING([--enable-asserts], 76 [Enable assert checks])) 77if test "x${enable_asserts-no}" = "xno"; then 78 AM_CPPFLAGS="${AM_CPPFLAGS} -DNDEBUG" 79fi 80AC_MSG_RESULT(${enable_asserts-no}) 81AC_SUBST([AM_CPPFLAGS]) 82 83AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR], 84 [Path to the pkgconfig directory @<:@LIBDIR/pkgconfig@:>@]), 85 [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) 86AC_SUBST([pkgconfigdir]) 87 88dnl === TEST_AND_ADD_CFLAGS(var, flag) 89dnl === Checks whether $CC supports 'flag' and adds it to 'var' 90dnl === on success. 91AC_DEFUN([TEST_AND_ADD_CFLAGS], 92 [SAVED_CFLAGS="$CFLAGS" 93 CFLAGS="-Werror $2" 94 AC_MSG_CHECKING([whether $CC supports $2]) 95 dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition. 96 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], 97 [AC_MSG_RESULT([yes])] 98 dnl Simply append the variable avoiding a 99 dnl compatibility ifdef for AS_VAR_APPEND as this 100 dnl variable shouldn't grow all that large. 101 [$1="${$1} $2"], 102 [AC_MSG_RESULT([no])]) 103 CFLAGS="$SAVED_CFLAGS"]) 104TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-fvisibility=hidden]) 105TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wall]) 106TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wconstant-conversion]) 107TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wdeclaration-after-statement]) 108TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wextra]) 109TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wfloat-conversion]) 110TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wformat -Wformat-nonliteral]) 111TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wformat -Wformat-security]) 112TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wmissing-declarations]) 113TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wmissing-prototypes]) 114TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wold-style-definition]) 115TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wparentheses-equality]) 116TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wshadow]) 117TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wshorten-64-to-32]) 118TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wundef]) 119TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wunreachable-code-aggressive]) 120TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wunreachable-code]) 121TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wunused-but-set-variable]) 122TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wunused]) 123TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wvla]) 124# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62040 125# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61622 126AS_IF([test "$GCC" = "yes" ], [ 127 gcc_version=`$CC -dumpversion` 128 gcc_wht_bug="" 129 case "$host_cpu" in 130 aarch64|arm64) 131 case "$gcc_version" in 132 4.9|4.9.0|4.9.1) gcc_wht_bug=yes ;; 133 esac 134 esac 135 AS_IF([test "$gcc_wht_bug" = "yes"], [ 136 TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-frename-registers])])]) 137# Use -flax-vector-conversions, if available, when building intrinsics with 138# older versions of gcc. The flag appeared in 4.3.x, but if backported, and 139# -fno-lax-vector-conversions is set, errors may occur with the intrinsics 140# files along with the older system includes, e.g., emmintrin.h. 141# Originally observed with cc (GCC) 4.2.1 20070831 patched [FreeBSD] (9.3). 142# https://bugs.chromium.org/p/webp/issues/detail?id=274 143AS_IF([test "$GCC" = "yes" ], [ 144 case "$host_cpu" in 145 amd64|i?86|x86_64) 146 AC_COMPILE_IFELSE( 147 dnl only check for -flax-vector-conversions with older gcc, skip 148 dnl clang as it reports itself as 4.2.1, but the flag isn't needed. 149 [AC_LANG_SOURCE([#if !defined(__clang__) && defined(__GNUC__) && \ 150 ((__GNUC__ << 8) | __GNUC_MINOR__) < 0x403 151 #error old gcc 152 #endif 153 int main(void) { return 0; } 154 ])],, 155 [TEST_AND_ADD_CFLAGS([INTRINSICS_CFLAGS], 156 [-flax-vector-conversions])]) 157 ;; 158 esac]) 159AC_SUBST([AM_CFLAGS]) 160 161dnl === Check for machine specific flags 162AC_ARG_ENABLE([sse4.1], 163 AS_HELP_STRING([--disable-sse4.1], 164 [Disable detection of SSE4.1 support 165 @<:@default=auto@:>@])) 166 167AS_IF([test "x$enable_sse4_1" != "xno" -a "x$enable_sse2" != "xno"], [ 168 SSE41_FLAGS="$INTRINSICS_CFLAGS $SSE41_FLAGS" 169 TEST_AND_ADD_CFLAGS([SSE41_FLAGS], [-msse4.1]) 170 AS_IF([test -n "$SSE41_FLAGS"], [ 171 SAVED_CFLAGS=$CFLAGS 172 CFLAGS="$CFLAGS $SSE41_FLAGS" 173 AC_CHECK_HEADER([smmintrin.h], 174 [AC_DEFINE(WEBP_HAVE_SSE41, [1], 175 [Set to 1 if SSE4.1 is supported])], 176 [SSE41_FLAGS=""]) 177 CFLAGS=$SAVED_CFLAGS]) 178 AC_SUBST([SSE41_FLAGS])]) 179 180AC_ARG_ENABLE([sse2], 181 AS_HELP_STRING([--disable-sse2], 182 [Disable detection of SSE2 support 183 @<:@default=auto@:>@])) 184 185AS_IF([test "x$enable_sse2" != "xno"], [ 186 SSE2_FLAGS="$INTRINSICS_CFLAGS $SSE2_FLAGS" 187 TEST_AND_ADD_CFLAGS([SSE2_FLAGS], [-msse2]) 188 AS_IF([test -n "$SSE2_FLAGS"], [ 189 SAVED_CFLAGS=$CFLAGS 190 CFLAGS="$CFLAGS $SSE2_FLAGS" 191 AC_CHECK_HEADER([emmintrin.h], 192 [AC_DEFINE(WEBP_HAVE_SSE2, [1], 193 [Set to 1 if SSE2 is supported])], 194 [SSE2_FLAGS=""]) 195 CFLAGS=$SAVED_CFLAGS]) 196 AC_SUBST([SSE2_FLAGS])]) 197 198AC_ARG_ENABLE([neon], 199 AS_HELP_STRING([--disable-neon], 200 [Disable detection of NEON support 201 @<:@default=auto@:>@])) 202 203AC_ARG_ENABLE([neon_rtcd], 204 AS_HELP_STRING([--disable-neon-rtcd], 205 [Disable runtime detection of NEON support via 206 /proc/cpuinfo on Linux hosts 207 @<:@default=auto@:>@])) 208# For ARM(7) hosts: 209# Both NEON flags unset and NEON support detected = build all modules with NEON 210# NEON detected with the use of -mfpu=neon = build only NEON modules with NEON 211AS_IF([test "x$enable_neon" != "xno"], [ 212 case "$host_cpu" in 213 arm|armv7*) 214 # Test for NEON support without flags before falling back to -mfpu=neon 215 for flag in '' '-mfpu=neon'; do 216 LOCAL_NEON_FLAGS="$INTRINSICS_CFLAGS $NEON_FLAGS" 217 TEST_AND_ADD_CFLAGS([LOCAL_NEON_FLAGS], [$flag]) 218 SAVED_CFLAGS=$CFLAGS 219 CFLAGS="$CFLAGS $LOCAL_NEON_FLAGS" 220 221 dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition. 222 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 223 #include <arm_neon.h> 224 int main(void) { 225 int8x8_t v = vdup_n_s8(0); 226 (void)v; 227 return 0; 228 }])], 229 [NEON_FLAGS="$(echo $LOCAL_NEON_FLAGS | $SED 's/^ *//')" 230 AS_IF([test -n "$NEON_FLAGS"], [ 231 AS_IF([test "${host_os%%-*}" = "linux" -o \ 232 "x$enable_neon_rtcd" = "xno"], [ 233 CFLAGS=$SAVED_CFLAGS 234 AC_DEFINE(WEBP_HAVE_NEON, [1], [Set to 1 if NEON is supported]) 235 break 236 ],[ 237 AC_MSG_WARN(m4_normalize([NEON runtime cpu-detection is 238 unavailable for ${host_os%%-*}. Force 239 with CFLAGS=-mfpu=neon or 240 --disable-neon-rtcd.])) 241 enable_neon_rtcd=no 242 NEON_FLAGS="" 243 ]) 244 ],[ 245 CFLAGS=$SAVED_CFLAGS 246 AC_DEFINE(WEBP_HAVE_NEON, [1], [Set to 1 if NEON is supported]) 247 break 248 ])]) 249 CFLAGS=$SAVED_CFLAGS 250 done 251 252 AS_IF([test -n "$NEON_FLAGS"], [ 253 # If NEON is available and rtcd is disabled apply NEON_FLAGS globally. 254 AS_IF([test "x$enable_neon_rtcd" = "xno"], [ 255 AM_CFLAGS="$AM_CFLAGS $NEON_FLAGS" 256 NEON_FLAGS=""], 257 [AC_DEFINE(WEBP_HAVE_NEON_RTCD, [1], 258 [Set to 1 if runtime detection of NEON is enabled])])]) 259 260 case "$host_os" in 261 *android*) AC_CHECK_HEADERS([cpu-features.h]) ;; 262 esac 263 ;; 264 aarch64*|arm64*) 265 AC_DEFINE(WEBP_HAVE_NEON, [1], [Set to 1 if NEON is supported]) 266 ;; 267 esac 268 AC_SUBST([NEON_FLAGS])]) 269 270dnl === CLEAR_LIBVARS([var_pfx]) 271dnl === Clears <var_pfx>_{INCLUDES,LIBS}. 272AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""]) 273 274dnl === WITHLIB_OPTION([opt_pfx], [outvar_pfx]) 275dnl === Defines --with-<opt_pfx>{include,lib}dir options which set 276dnl === the variables <outvar_pfx>_{INCLUDES,LIBS}. 277AC_DEFUN([WITHLIB_OPTION], 278 [AC_ARG_WITH([$1includedir], 279 AS_HELP_STRING([--with-$1includedir=DIR], 280 [use $2 includes from DIR]), 281 $2_INCLUDES="-I$withval") 282 AC_ARG_WITH([$1libdir], 283 AS_HELP_STRING([--with-$1libdir=DIR], 284 [use $2 libraries from DIR]), 285 [$2_LIBS="-L$withval"])]) 286 287dnl === LIBCHECK_PROLOGUE([var_pfx]) 288dnl === Caches the current values of CPPFLAGS/LIBS in SAVED_* then 289dnl === prepends the current values with <var_pfx>_{INCLUDES,LIBS}. 290AC_DEFUN([LIBCHECK_PROLOGUE], 291 [SAVED_CPPFLAGS=$CPPFLAGS 292 SAVED_LIBS=$LIBS 293 CPPFLAGS="$$1_INCLUDES $CPPFLAGS" 294 LIBS="$$1_LIBS $LIBS"]) 295 296dnl === LIBCHECK_EPILOGUE([var_pfx]) 297dnl === Restores the values of CPPFLAGS/LIBS from SAVED_* and exports 298dnl === <var_pfx>_{INCLUDES,LIBS} with AC_SUBST. 299AC_DEFUN([LIBCHECK_EPILOGUE], 300 [AC_SUBST($1_LIBS) 301 AC_SUBST($1_INCLUDES) 302 CPPFLAGS=$SAVED_CPPFLAGS 303 LIBS=$SAVED_LIBS]) 304 305dnl === Check for gcc builtins 306 307dnl === CHECK_FOR_BUILTIN([builtin], [param], [define]) 308dnl === links a C AC_LANG_PROGRAM, with <builtin>(<param>) 309dnl === AC_DEFINE'ing <define> if successful. 310AC_DEFUN([CHECK_FOR_BUILTIN], 311 [AC_LANG_PUSH([C]) 312 AC_MSG_CHECKING([for $1]) 313 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [(void)$1($2)])], 314 [AC_MSG_RESULT([yes]) 315 AC_DEFINE([$3], [1], 316 [Set to 1 if $1 is available])], 317 [AC_MSG_RESULT([no])]), 318 AC_LANG_POP]) 319 320dnl AC_CHECK_FUNC doesn't work with builtin's. 321CHECK_FOR_BUILTIN([__builtin_bswap16], [1u << 15], [HAVE_BUILTIN_BSWAP16]) 322CHECK_FOR_BUILTIN([__builtin_bswap32], [1u << 31], [HAVE_BUILTIN_BSWAP32]) 323CHECK_FOR_BUILTIN([__builtin_bswap64], [1ull << 63], [HAVE_BUILTIN_BSWAP64]) 324 325dnl === Check for pthread support 326AC_ARG_ENABLE([threading], 327 AS_HELP_STRING([--disable-threading], 328 [Disable detection of thread support]),, 329 [enable_threading=yes]) 330if test "$enable_threading" = "yes"; then 331 AC_MSG_NOTICE([checking for threading support...]) 332 AX_PTHREAD([AC_DEFINE([WEBP_USE_THREAD], [1], 333 [Undefine this to disable thread support.]) 334 LIBS="$PTHREAD_LIBS $LIBS" 335 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 336 CC="$PTHREAD_CC" 337 ], 338 [AC_CHECK_FUNC([_beginthreadex], 339 [AC_DEFINE([WEBP_USE_THREAD], [1], 340 [Undefine this to disable thread 341 support.])], 342 [enable_threading=no])]) 343fi 344AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}]) 345 346dnl === check for OpenGL/GLUT support === 347 348AC_ARG_ENABLE([gl], AS_HELP_STRING([--disable-gl], 349 [Disable detection of OpenGL support 350 @<:@default=auto@:>@])) 351AS_IF([test "x$enable_gl" != "xno"], [ 352 CLEAR_LIBVARS([GL]) 353 WITHLIB_OPTION([gl], [GL]) 354 355 LIBCHECK_PROLOGUE([GL]) 356 357 glut_cflags="none" 358 glut_ldflags="none" 359 case $host_os in 360 darwin*) 361 # Special case for OSX builds. Append these to give the user a chance to 362 # override with --with-gl* 363 glut_cflags="$glut_cflags|-framework GLUT -framework OpenGL" 364 glut_ldflags="$glut_ldflags|-framework GLUT -framework OpenGL" 365 # quiet deprecation warnings for glut 366 TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wno-deprecated-declarations]) 367 ;; 368 esac 369 370 GLUT_SAVED_CPPFLAGS="$CPPFLAGS" 371 SAVED_IFS="$IFS" 372 IFS="|" 373 for flag in $glut_cflags; do 374 # restore IFS immediately as the autoconf macros may need the default. 375 IFS="$SAVED_IFS" 376 unset ac_cv_header_GL_glut_h 377 unset ac_cv_header_OpenGL_glut_h 378 379 case $flag in 380 none) ;; 381 *) CPPFLAGS="$flag $CPPFLAGS";; 382 esac 383 AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h OpenGL/glut.h], 384 [glut_headers=yes; 385 test "$flag" = "none" || GL_INCLUDES="$CPPFLAGS"; 386 break]) 387 CPPFLAGS="$GLUT_SAVED_CPPFLAGS" 388 test "$glut_headers" = "yes" && break 389 done 390 IFS="$SAVED_IFS" 391 392 if test "$glut_headers" = "yes"; then 393 AC_LANG_PUSH([C]) 394 GLUT_SAVED_LDFLAGS="$LDFLAGS" 395 SAVED_IFS="$IFS" 396 IFS="|" 397 for flag in $glut_ldflags; do 398 # restore IFS immediately as the autoconf macros may need the default. 399 IFS="$SAVED_IFS" 400 unset ac_cv_search_glBegin 401 402 case $flag in 403 none) ;; 404 *) LDFLAGS="$flag $LDFLAGS";; 405 esac 406 407 # find libGL 408 GL_SAVED_LIBS="$LIBS" 409 AC_SEARCH_LIBS([glBegin], [GL OpenGL opengl32]) 410 LIBS="$GL_SAVED_LIBS" 411 412 # A direct link to libGL may not be necessary on e.g., linux. 413 GLUT_SAVED_LIBS="$LIBS" 414 for lib in "" "-lglut" "-lglut $ac_cv_search_glBegin"; do 415 LIBS="$lib" 416 AC_LINK_IFELSE( 417 [AC_LANG_PROGRAM([ 418 #ifdef __cplusplus 419 # define EXTERN_C extern "C" 420 #else 421 # define EXTERN_C 422 #endif 423 EXTERN_C char glOrtho(); 424 EXTERN_C char glutMainLoop(); 425 ],[ 426 glOrtho(); 427 glutMainLoop(); 428 ]) 429 ], 430 AC_DEFINE(WEBP_HAVE_GL, [1], 431 [Set to 1 if OpenGL is supported]) 432 [glut_support=yes], [] 433 ) 434 if test "$glut_support" = "yes"; then 435 GL_LIBS="$LDFLAGS $lib" 436 break 437 fi 438 done 439 LIBS="$GLUT_SAVED_LIBS" 440 LDFLAGS="$GLUT_SAVED_LDFLAGS" 441 test "$glut_support" = "yes" && break 442 done 443 IFS="$SAVED_IFS" 444 AC_LANG_POP 445 fi 446 447 LIBCHECK_EPILOGUE([GL]) 448 449 if test "$glut_support" = "yes" -a "$enable_libwebpdemux" = "yes"; then 450 build_vwebp=yes 451 else 452 AC_MSG_NOTICE( 453 m4_normalize([Not building vwebp. 454 OpenGL libraries and --enable-libwebpdemux are required.])) 455 fi 456]) 457AM_CONDITIONAL([BUILD_VWEBP], [test "$build_vwebp" = "yes"]) 458 459dnl === check for SDL support === 460 461AC_ARG_ENABLE([sdl], 462 AS_HELP_STRING([--disable-sdl], 463 [Disable detection of SDL support 464 @<:@default=auto@:>@])) 465AS_IF([test "x$enable_sdl" != "xno"], [ 466 CLEAR_LIBVARS([SDL]) 467 AC_PATH_PROGS([LIBSDL_CONFIG], [sdl-config]) 468 if test -n "$LIBSDL_CONFIG"; then 469 SDL_INCLUDES=`$LIBSDL_CONFIG --cflags` 470 SDL_LIBS="`$LIBSDL_CONFIG --libs`" 471 fi 472 473 WITHLIB_OPTION([sdl], [SDL]) 474 475 sdl_header="no" 476 LIBCHECK_PROLOGUE([SDL]) 477 AC_CHECK_HEADER([SDL/SDL.h], [sdl_header="SDL/SDL.h"], 478 [AC_CHECK_HEADER([SDL.h], [sdl_header="SDL.h"], 479 [AC_MSG_WARN(SDL library not available - no sdl.h)])]) 480 if test x"$sdl_header" != "xno"; then 481 AC_LANG_PUSH(C) 482 SDL_SAVED_LIBS="$LIBS" 483 for lib in "" "-lSDL" "-lSDLmain -lSDL"; do 484 LIBS="$SDL_SAVED_LIBS $lib" 485 # Perform a full link to ensure SDL_main is resolved if needed. 486 AC_LINK_IFELSE( 487 [AC_LANG_SOURCE([ 488 #include <$sdl_header> 489 int main(int argc, char** argv) { 490 SDL_Init(0); 491 return 0; 492 }])], 493 [SDL_LIBS="$LDFLAGS $LIBS" 494 SDL_INCLUDES="$SDL_INCLUDES -DWEBP_HAVE_SDL" 495 AC_DEFINE(WEBP_HAVE_SDL, [1], 496 [Set to 1 if SDL library is installed]) 497 sdl_support=yes] 498 ) 499 if test x"$sdl_support" = "xyes"; then 500 break 501 fi 502 done 503 # LIBS is restored by LIBCHECK_EPILOGUE 504 AC_LANG_POP 505 if test x"$sdl_header" = "xSDL.h"; then 506 SDL_INCLUDES="$SDL_INCLUDES -DWEBP_HAVE_JUST_SDL_H" 507 fi 508 fi 509 LIBCHECK_EPILOGUE([SDL]) 510 511 if test x"$sdl_support" = "xyes"; then 512 build_vwebp_sdl=yes 513 else 514 AC_MSG_NOTICE([Not building vwebp-sdl. SDL library is required.]) 515 fi 516]) 517 518AM_CONDITIONAL([BUILD_VWEBP_SDL], [test "$build_vwebp_sdl" = "yes"]) 519 520dnl === check for PNG support === 521 522AC_ARG_ENABLE([png], AS_HELP_STRING([--disable-png], 523 [Disable detection of PNG format support 524 @<:@default=auto@:>@])) 525AS_IF([test "x$enable_png" != "xno"], [ 526 CLEAR_LIBVARS([PNG]) 527 AC_PATH_PROGS([LIBPNG_CONFIG], 528 [libpng-config libpng16-config libpng15-config libpng14-config \ 529 libpng12-config]) 530 if test -n "$LIBPNG_CONFIG"; then 531 PNG_INCLUDES=`$LIBPNG_CONFIG --cflags` 532 PNG_LIBS="`$LIBPNG_CONFIG --ldflags`" 533 fi 534 535 WITHLIB_OPTION([png], [PNG]) 536 537 LIBCHECK_PROLOGUE([PNG]) 538 AC_CHECK_HEADER(png.h, 539 AC_SEARCH_LIBS(png_get_libpng_ver, [png], 540 [test "$ac_cv_search_png_get_libpng_ver" = "none required" \ 541 || PNG_LIBS="$PNG_LIBS $ac_cv_search_png_get_libpng_ver" 542 PNG_INCLUDES="$PNG_INCLUDES -DWEBP_HAVE_PNG" 543 AC_DEFINE(WEBP_HAVE_PNG, [1], 544 [Set to 1 if PNG library is installed]) 545 png_support=yes 546 ], 547 [AC_MSG_WARN(Optional png library not found) 548 PNG_LIBS="" 549 PNG_INCLUDES="" 550 ], 551 [$MATH_LIBS]), 552 [AC_MSG_WARN(png library not available - no png.h) 553 PNG_LIBS="" 554 PNG_INCLUDES="" 555 ], 556 ) 557 LIBCHECK_EPILOGUE([PNG]) 558]) 559 560dnl === check for JPEG support === 561 562AC_ARG_ENABLE([jpeg], 563 AS_HELP_STRING([--disable-jpeg], 564 [Disable detection of JPEG format support 565 @<:@default=auto@:>@])) 566AS_IF([test "x$enable_jpeg" != "xno"], [ 567 CLEAR_LIBVARS([JPEG]) 568 WITHLIB_OPTION([jpeg], [JPEG]) 569 570 LIBCHECK_PROLOGUE([JPEG]) 571 AC_CHECK_HEADER(jpeglib.h, 572 AC_CHECK_LIB(jpeg, jpeg_set_defaults, 573 [JPEG_LIBS="$JPEG_LIBS -ljpeg" 574 JPEG_INCLUDES="$JPEG_INCLUDES -DWEBP_HAVE_JPEG" 575 AC_DEFINE(WEBP_HAVE_JPEG, [1], 576 [Set to 1 if JPEG library is installed]) 577 jpeg_support=yes 578 ], 579 AC_MSG_WARN(Optional jpeg library not found), 580 [$MATH_LIBS]), 581 AC_MSG_WARN(jpeg library not available - no jpeglib.h) 582 ) 583 LIBCHECK_EPILOGUE([JPEG]) 584]) 585 586dnl === check for TIFF support === 587 588AC_ARG_ENABLE([tiff], 589 AS_HELP_STRING([--disable-tiff], 590 [Disable detection of TIFF format support 591 @<:@default=auto@:>@])) 592AS_IF([test "x$enable_tiff" != "xno"], [ 593 CLEAR_LIBVARS([TIFF]) 594 WITHLIB_OPTION([tiff], [TIFF]) 595 596 LIBCHECK_PROLOGUE([TIFF]) 597 AC_CHECK_HEADER(tiffio.h, 598 AC_CHECK_LIB(tiff, TIFFGetVersion, 599 [TIFF_LIBS="$TIFF_LIBS -ltiff" 600 TIFF_INCLUDES="$TIFF_INCLUDES -DWEBP_HAVE_TIFF" 601 AC_DEFINE(WEBP_HAVE_TIFF, [1], 602 [Set to 1 if TIFF library is installed]) 603 tiff_support=yes 604 ], 605 AC_MSG_WARN(Optional tiff library not found), 606 [$MATH_LIBS]), 607 AC_MSG_WARN(tiff library not available - no tiffio.h) 608 ) 609 LIBCHECK_EPILOGUE([TIFF]) 610]) 611 612dnl === check for GIF support === 613 614AC_ARG_ENABLE([gif], AS_HELP_STRING([--disable-gif], 615 [Disable detection of GIF format support 616 @<:@default=auto@:>@])) 617AS_IF([test "x$enable_gif" != "xno"], [ 618 CLEAR_LIBVARS([GIF]) 619 WITHLIB_OPTION([gif], [GIF]) 620 621 LIBCHECK_PROLOGUE([GIF]) 622 AC_CHECK_HEADER(gif_lib.h, 623 AC_CHECK_LIB([gif], [DGifOpenFileHandle], 624 [GIF_LIBS="$GIF_LIBS -lgif" 625 AC_DEFINE(WEBP_HAVE_GIF, [1], 626 [Set to 1 if GIF library is installed]) 627 gif_support=yes 628 ], 629 AC_MSG_WARN(Optional gif library not found), 630 [$MATH_LIBS]), 631 AC_MSG_WARN(gif library not available - no gif_lib.h) 632 ) 633 LIBCHECK_EPILOGUE([GIF]) 634 635 if test "$gif_support" = "yes" -a \ 636 "$enable_libwebpdemux" = "yes"; then 637 build_anim_diff=yes 638 else 639 AC_MSG_NOTICE( 640 [Not building anim_diff. libgif and --enable-libwebpdemux are required.]) 641 fi 642 643 if test "$gif_support" = "yes" -a \ 644 "$enable_libwebpmux" = "yes"; then 645 build_gif2webp=yes 646 else 647 AC_MSG_NOTICE( 648 [Not building gif2webp. libgif and --enable-libwebpmux are required.]) 649 fi 650]) 651AM_CONDITIONAL([BUILD_ANIMDIFF], [test "${build_anim_diff}" = "yes"]) 652AM_CONDITIONAL([BUILD_GIF2WEBP], [test "${build_gif2webp}" = "yes"]) 653 654if test "$enable_libwebpdemux" = "yes" -a "$enable_libwebpmux" = "yes"; then 655 build_img2webp=yes 656else 657 AC_MSG_NOTICE( 658 m4_normalize([Not building img2webp. 659 --enable-libwebpdemux & --enable-libwebpmux are required.])) 660fi 661AM_CONDITIONAL([BUILD_IMG2WEBP], [test "${build_img2webp}" = "yes"]) 662 663if test "$enable_libwebpmux" = "yes"; then 664 build_webpinfo=yes 665else 666 AC_MSG_NOTICE([Not building webpinfo. --enable-libwebpdemux is required.]) 667fi 668AM_CONDITIONAL([BUILD_WEBPINFO], [test "${build_webpinfo}" = "yes"]) 669 670dnl === check for WIC support === 671 672AC_ARG_ENABLE([wic], 673 AS_HELP_STRING([--disable-wic], 674 [Disable Windows Imaging Component (WIC) detection. 675 @<:@default=auto@:>@]),, 676 [enable_wic=yes]) 677 678case $host_os in 679mingw*) 680if test "$enable_wic" = "yes"; then 681 AC_CHECK_HEADERS([wincodec.h shlwapi.h windows.h]) 682 if test "$ac_cv_header_wincodec_h" = "yes"; then 683 AC_MSG_CHECKING(for Windows Imaging Component support) 684 SAVED_LIBS=$LIBS 685 LIBS="-lshlwapi -lole32 $LIBS" 686 # match include structure from [cd]webp.c 687 wic_headers=" 688 #define INITGUID 689 #define CINTERFACE 690 #define COBJMACROS 691 #define _WIN32_IE 0x500 692 693 #include <shlwapi.h> 694 #include <windows.h> 695 #include <wincodec.h> 696 " 697 # test for functions from each lib and the GUID is created properly 698 wic_main=" 699 int main(void) { 700 CLSID_WICImagingFactory; 701 CoInitialize(NULL); 702 SHCreateStreamOnFile(NULL, 0, NULL); 703 return 0; 704 } 705 " 706 AC_LANG_PUSH(C) 707 AC_LINK_IFELSE( 708 [AC_LANG_SOURCE([ 709 $wic_headers 710 $wic_main])], 711 [wic_support=yes], 712 [wic_support=no] 713 ) 714 AC_LANG_POP 715 716 test "$wic_support" = "yes" || LIBS=$SAVED_LIBS 717 AC_MSG_RESULT(${wic_support-no}) 718 fi 719fi 720esac 721 722dnl === If --enable-swap-16bit-csp is defined, add -DWEBP_SWAP_16BIT_CSP=1 723 724USE_SWAP_16BIT_CSP="" 725AC_MSG_CHECKING(if --enable-swap-16bit-csp option is specified) 726AC_ARG_ENABLE([swap-16bit-csp], 727 AS_HELP_STRING([--enable-swap-16bit-csp], 728 [Enable byte swap for 16 bit colorspaces])) 729if test "$enable_swap_16bit_csp" = "yes"; then 730 USE_SWAP_16BIT_CSP="-DWEBP_SWAP_16BIT_CSP=1" 731fi 732AC_MSG_RESULT(${enable_swap_16bit_csp-no}) 733AC_SUBST(USE_SWAP_16BIT_CSP) 734 735dnl === If --disable-near-lossless is defined, add -DWEBP_NEAR_LOSSLESS=0 736 737AC_DEFINE(WEBP_NEAR_LOSSLESS, [1], [Enable near lossless encoding]) 738AC_MSG_CHECKING(if --disable-near-lossless option is specified) 739AC_ARG_ENABLE([near_lossless], 740 AS_HELP_STRING([--disable-near-lossless], 741 [Disable near lossless encoding]), 742 [], [enable_near_lossless=yes]) 743if test "$enable_near_lossless" = "no"; then 744 AC_DEFINE(WEBP_NEAR_LOSSLESS, [0], [Enable near lossless encoding]) 745 AC_MSG_RESULT([yes]) 746else 747 AC_MSG_RESULT([no]) 748fi 749 750dnl ========================= 751 752dnl Add an empty webp_libname_prefix variable for use in *.pc.in. 753AC_SUBST([webp_libname_prefix]) 754AC_CONFIG_MACRO_DIR([m4]) 755AC_CONFIG_HEADERS([src/webp/config.h]) 756AC_CONFIG_FILES([Makefile src/Makefile man/Makefile \ 757 examples/Makefile extras/Makefile imageio/Makefile \ 758 sharpyuv/Makefile sharpyuv/libsharpyuv.pc \ 759 src/dec/Makefile src/enc/Makefile src/dsp/Makefile \ 760 src/demux/Makefile src/mux/Makefile \ 761 src/utils/Makefile \ 762 src/libwebp.pc src/libwebpdecoder.pc \ 763 src/demux/libwebpdemux.pc src/mux/libwebpmux.pc]) 764 765 766AC_OUTPUT 767 768AC_MSG_NOTICE([ 769WebP Configuration Summary 770-------------------------- 771 772Shared libraries: ${enable_shared} 773Static libraries: ${enable_static} 774Threading support: ${enable_threading-no} 775libwebp: yes 776libwebpdecoder: ${enable_libwebpdecoder-no} 777libwebpdemux: ${enable_libwebpdemux-no} 778libwebpmux: ${enable_libwebpmux-no} 779libwebpextras: ${enable_libwebpextras-no} 780 781Tools: 782cwebp : ${enable_libwebpdemux-no} 783 Input format support 784 ==================== 785 JPEG : ${jpeg_support-no} 786 PNG : ${png_support-no} 787 TIFF : ${tiff_support-no} 788 WIC : ${wic_support-no} 789dwebp : ${enable_libwebpdemux-no} 790 Output format support 791 ===================== 792 PNG : ${png_support-no} 793 WIC : ${wic_support-no} 794GIF support : ${gif_support-no} 795anim_diff : ${build_anim_diff-no} 796gif2webp : ${build_gif2webp-no} 797img2webp : ${build_img2webp-no} 798webpmux : ${enable_libwebpmux-no} 799vwebp : ${build_vwebp-no} 800webpinfo : ${build_webpinfo-no} 801SDL support : ${sdl_support-no} 802vwebp_sdl : ${build_vwebp_sdl-no} 803]) 804