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