configure.ac 28 KB

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