2 # Process this file with autoconf to produce a configure script.
5 AC_INIT([libjpeg-turbo], [1.4.2])
7 AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
8 AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
10 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
12 # Checks for programs.
13 SAVED_CFLAGS=${CFLAGS}
14 SAVED_CPPFLAGS=${CPPFLAGS}
17 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
24 AC_ARG_WITH([build-date], [Use custom build string to enable reproducible builds (default: YYMMDD)],
25 [BUILD="$with_build_date"],
26 [BUILD=`date +%Y%m%d`])
28 # When the prefix is /opt/libjpeg-turbo, we assume that an "official" binary is
29 # being created, and thus we install things into specific locations.
32 if test "x$prefix" = "xNONE" -a "x$ac_default_prefix" != "x"; then
33 prefix=$ac_default_prefix
35 DATADIR=`eval echo ${datadir}`
36 DATADIR=`eval echo $DATADIR`
37 if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
40 DATADIR=`eval echo ${datarootdir}`
41 DATADIR=`eval echo $DATADIR`
42 if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
43 datarootdir='${prefix}'
45 DOCDIR=`eval echo ${docdir}`
46 DOCDIR=`eval echo $DOCDIR`
47 if test "$DOCDIR" = "/opt/libjpeg-turbo/doc/libjpeg-turbo"; then
48 docdir='${datadir}/doc'
51 old_exec_prefix=${exec_prefix}
52 if test "x$exec_prefix" = "xNONE"; then
56 AC_CHECK_SIZEOF(size_t)
58 if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; then
59 LIBDIR=`eval echo ${libdir}`
60 LIBDIR=`eval echo $LIBDIR`
61 if test "$LIBDIR" = "/opt/libjpeg-turbo/lib"; then
66 if test "${ac_cv_sizeof_size_t}" = "8"; then
67 libdir='${exec_prefix}/lib64'
68 elif test "${ac_cv_sizeof_size_t}" = "4"; then
69 libdir='${exec_prefix}/lib32'
75 exec_prefix=${old_exec_prefix}
78 # Check whether compiler supports pointers to undefined structures
79 AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
80 AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
83 AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
84 [Compiler does not support pointers to undefined structures.])])
86 if test "x${GCC}" = "xyes"; then
87 if test "x${SAVED_CFLAGS}" = "x"; then
90 if test "x${SAVED_CPPFLAGS}" = "x"; then
95 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
96 if test "x${SUNCC}" = "xyes"; then
97 if test "x${SAVED_CFLAGS}" = "x"; then
102 AC_CHECK_DECL([_TIZEN_PRODUCT_TV], [with_pkg_config="yes"], [with_pkg_config="no"])
103 if test "x${with_pkg_config}" = "xyes"; then
104 AC_DEFINE_UNQUOTED(COLOR_PICKER_ENABLE, [1], [tizen coloer picker enable])
106 AC_DEFINE_UNQUOTED(COLOR_PICKER_ENABLE, [0], [tizen coloer picker disable])
108 # Checks for libraries.
109 # Checks for header files.
111 AC_CHECK_HEADERS([stddef.h stdlib.h locale.h string.h])
112 AC_CHECK_HEADER([sys/types.h],
113 AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you need to include <sys/types.h> to get size_t.]))
115 # Checks for typedefs, structures, and compiler characteristics.
120 AC_CHECK_TYPES([unsigned char, unsigned short])
122 AC_MSG_CHECKING([if right shift is signed])
125 int is_shifting_signed (long arg) {
128 if (res == -0x7F7E80CL)
129 return 1; /* right shift is signed */
131 /* see if unsigned-shift hack will fix it. */
132 /* we can't just test exact value since it depends on width of long... */
133 res |= (~0L) << (32-4);
134 if (res == -0x7F7E80CL)
135 return 0; /* right shift is unsigned */
137 printf("Right shift isn't acting as I expect it to.\n");
138 printf("I fear the JPEG software will not work at all.\n\n");
139 return 0; /* try it with unsigned anyway */
142 exit(is_shifting_signed(-0x7F7E80B1L));
145 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1,
146 [Define if your (broken) compiler shifts signed values as if they were unsigned.])],
147 [AC_MSG_RESULT(yes)],
148 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
150 # Checks for library functions.
151 AC_CHECK_FUNCS([memset memcpy], [],
152 [AC_DEFINE([NEED_BSD_STRINGS], 1,
153 [Define if you have BSD-like bzero and bcopy in <strings.h> rather than memset/memcpy in <string.h>.])])
155 AC_MSG_CHECKING([libjpeg API version])
156 AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
157 if test "x$JPEG_LIB_VERSION" = "x"; then
159 AC_HELP_STRING([--with-jpeg7],
160 [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
162 AC_HELP_STRING([--with-jpeg8],
163 [Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
164 if test "x${with_jpeg8}" = "xyes"; then
167 if test "x${with_jpeg7}" = "xyes"; then
174 JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
175 AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
176 AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
177 AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION],
178 [libjpeg API version])
180 AC_ARG_VAR(SO_MAJOR_VERSION,
181 [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
182 AC_ARG_VAR(SO_MINOR_VERSION,
183 [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
184 if test "x$SO_MAJOR_VERSION" = "x"; then
185 case "$JPEG_LIB_VERSION" in
186 62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
187 *) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
190 if test "x$SO_MINOR_VERSION" = "x"; then
191 case "$JPEG_LIB_VERSION" in
192 80) SO_MINOR_VERSION=2 ;;
193 *) SO_MINOR_VERSION=0 ;;
199 # Memory source/destination managers
201 MEM_SRCDST_FUNCTIONS=
202 if test "x${with_jpeg8}" != "xyes"; then
203 AC_MSG_CHECKING([whether to include in-memory source/destination managers])
204 AC_ARG_WITH([mem-srcdst],
205 AC_HELP_STRING([--without-mem-srcdst],
206 [Do not include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI]))
207 if test "x$with_mem_srcdst" != "xno"; then
209 AC_DEFINE([MEM_SRCDST_SUPPORTED], [1],
210 [Support in-memory source/destination managers])
212 MEM_SRCDST_FUNCTIONS="global: jpeg_mem_dest; jpeg_mem_src;";
215 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-mem-srcdst"
219 AC_MSG_CHECKING([libjpeg shared library version])
220 AC_MSG_RESULT([$SO_MAJOR_VERSION.$SO_AGE.$SO_MINOR_VERSION])
221 LIBTOOL_CURRENT=`expr $SO_MAJOR_VERSION + $SO_AGE`
222 AC_SUBST(LIBTOOL_CURRENT)
223 AC_SUBST(SO_MAJOR_VERSION)
224 AC_SUBST(SO_MINOR_VERSION)
226 AC_SUBST(MEM_SRCDST_FUNCTIONS)
228 AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
231 AC_ARG_ENABLE([ld-version-script],
232 AS_HELP_STRING([--disable-ld-version-script],
233 [Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
234 [VERSION_SCRIPT=$enableval], [])
236 AC_MSG_CHECKING([whether the linker supports version scripts])
237 SAVED_LDFLAGS="$LDFLAGS"
238 LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
239 cat > conftest.map <<EOF
244 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
245 [VERSION_SCRIPT_FLAG=-Wl,--version-script,;
246 AC_MSG_RESULT([yes (GNU style)])],
248 if test "x$VERSION_SCRIPT_FLAG" = "x"; then
249 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
250 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
251 [VERSION_SCRIPT_FLAG=-Wl,-M,;
252 AC_MSG_RESULT([yes (Sun style)])],
255 if test "x$VERSION_SCRIPT_FLAG" = "x"; then
259 LDFLAGS="$SAVED_LDFLAGS"
261 AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
262 AC_MSG_RESULT($VERSION_SCRIPT)
264 AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
265 AC_SUBST(VERSION_SCRIPT_FLAG)
267 # Check for non-broken inline under various spellings
268 AC_MSG_CHECKING(for inline)
270 AC_TRY_COMPILE(, [} inline __attribute__((always_inline)) int foo() { return 0; }
271 int bar() { return foo();], ljt_cv_inline="inline __attribute__((always_inline))",
272 AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
273 int bar() { return foo();], ljt_cv_inline="__inline__",
274 AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
275 int bar() { return foo();], ljt_cv_inline="__inline",
276 AC_TRY_COMPILE(, [} inline int foo() { return 0; }
277 int bar() { return foo();], ljt_cv_inline="inline"))))
278 AC_MSG_RESULT($ljt_cv_inline)
279 AC_DEFINE_UNQUOTED([INLINE],[$ljt_cv_inline],[How to obtain function inlining.])
281 # Arithmetic coding support
282 AC_MSG_CHECKING([whether to include arithmetic encoding support])
283 AC_ARG_WITH([arith-enc],
284 AC_HELP_STRING([--without-arith-enc],
285 [Do not include arithmetic encoding support]))
286 if test "x$with_12bit" = "xyes"; then
289 if test "x$with_arith_enc" = "xno"; then
291 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-enc"
293 AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
296 AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
298 AC_MSG_CHECKING([whether to include arithmetic decoding support])
299 AC_ARG_WITH([arith-dec],
300 AC_HELP_STRING([--without-arith-dec],
301 [Do not include arithmetic decoding support]))
302 if test "x$with_12bit" = "xyes"; then
305 if test "x$with_arith_dec" = "xno"; then
307 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-dec"
309 AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
312 AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
314 AM_CONDITIONAL([WITH_ARITH],
315 [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
317 # 12-bit component support
318 AC_MSG_CHECKING([whether to use 12-bit samples])
320 AC_HELP_STRING([--with-12bit], [Encode/decode JPEG images with 12-bit samples (implies --without-simd --without-turbojpeg --without-arith-dec --without-arith-enc)]))
321 if test "x$with_12bit" = "xyes"; then
322 AC_DEFINE([BITS_IN_JSAMPLE], [12], [use 8 or 12])
327 AM_CONDITIONAL([WITH_12BIT], [test "x$with_12bit" = "xyes"])
330 AC_MSG_CHECKING([whether to build TurboJPEG C wrapper])
331 AC_ARG_WITH([turbojpeg],
332 AC_HELP_STRING([--without-turbojpeg],
333 [Do not include the TurboJPEG wrapper library and associated test programs]))
334 if test "x$with_12bit" = "xyes"; then
337 if test "x$with_turbojpeg" = "xno"; then
339 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-turbojpeg"
345 AC_ARG_VAR(JAVAC, [Java compiler command (default: javac)])
346 if test "x$JAVAC" = "x"; then
350 AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
352 AC_ARG_VAR(JAR, [Java archive command (default: jar)])
353 if test "x$JAR" = "x"; then
357 AC_ARG_VAR(JAVA, [Java runtime command (default: java)])
358 if test "x$JAVA" = "x"; then
362 AC_ARG_VAR(JNI_CFLAGS,
363 [C compiler flags needed to include jni.h (default: -I/System/Library/Frameworks/JavaVM.framework/Headers on OS X, '-I/usr/java/include -I/usr/java/include/solaris' on Solaris, and '-I/usr/java/default/include -I/usr/java/default/include/linux' on Linux)])
365 AC_MSG_CHECKING([whether to build TurboJPEG Java wrapper])
367 AC_HELP_STRING([--with-java], [Build Java wrapper for the TurboJPEG library]))
368 if test "x$with_12bit" = "xyes" -o "x$with_turbojpeg" = "xno"; then
373 if test "x$with_java" = "xyes"; then
378 DEFAULT_JNI_CFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
381 DEFAULT_JNI_CFLAGS='-I/usr/java/include -I/usr/java/include/solaris'
384 DEFAULT_JNI_CFLAGS='-I/usr/java/default/include -I/usr/java/default/include/linux'
387 if test "x$JNI_CFLAGS" = "x"; then
388 JNI_CFLAGS=$DEFAULT_JNI_CFLAGS
391 SAVE_CPPFLAGS=${CPPFLAGS}
392 CPPFLAGS="${CPPFLAGS} ${JNI_CFLAGS}"
393 AC_CHECK_HEADERS([jni.h], [DUMMY=1],
394 [AC_MSG_ERROR([Could not find JNI header file])])
395 CPPFLAGS=${SAVE_CPPFLAGS}
398 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --with-java"
399 JAVA_RPM_CONTENTS_1='%dir %{_datadir}/classes'
400 JAVA_RPM_CONTENTS_2=%{_datadir}/classes/turbojpeg.jar
405 AM_CONDITIONAL([WITH_JAVA], [test "x$with_java" = "xyes"])
407 AC_SUBST(JAVA_RPM_CONTENTS_1)
408 AC_SUBST(JAVA_RPM_CONTENTS_2)
410 # optionally force using gas-preprocessor.pl for compatibility testing
411 AC_ARG_WITH([gas-preprocessor],
412 AC_HELP_STRING([--with-gas-preprocessor],
413 [Force using gas-preprocessor.pl on ARM.]))
414 if test "x${with_gas_preprocessor}" = "xyes"; then
417 CCAS="gas-preprocessor.pl -fix-unreq $CC"
420 CCAS="gas-preprocessor.pl -no-fix-unreq $CC"
428 AC_HELP_STRING([--without-simd], [Do not include SIMD extensions]))
429 if test "x$with_12bit" = "xyes"; then
432 if test "x${with_simd}" != "xno"; then
434 if test "x${with_simd}" = "xyes"; then
437 # Check if we're on a supported CPU
438 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
441 AC_MSG_RESULT([yes (x86_64)])
446 AC_MSG_RESULT([yes (i386)])
451 AC_MSG_RESULT([yes (arm)])
452 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
453 AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE(
454 [if test "x$ac_use_gas_preprocessor" = "xyes"; then
455 AC_MSG_RESULT([yes (with gas-preprocessor)])
462 if test "x${with_simd}" = "xno"; then
463 if test "x${require_simd}" = "xyes"; then
464 AC_MSG_ERROR([SIMD support can't be enabled.])
466 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
471 AC_MSG_RESULT([yes (arm64)])
472 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
473 AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE(
474 [if test "x$ac_use_gas_preprocessor" = "xyes"; then
475 AC_MSG_RESULT([yes (with gas-preprocessor)])
482 if test "x${with_simd}" = "xno"; then
483 if test "x${require_simd}" = "xyes"; then
484 AC_MSG_ERROR([SIMD support can't be enabled.])
486 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
491 AC_MSG_RESULT([yes (mips)])
492 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
493 AC_CHECK_COMPATIBLE_MIPS_ASSEMBLER_IFELSE(
494 [AC_MSG_RESULT([yes])
498 if test "x${with_simd}" = "xno"; then
499 if test "x${require_simd}" = "xyes"; then
500 AC_MSG_ERROR([SIMD support can't be enabled.])
502 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
507 AC_MSG_RESULT([no ("$host_cpu")])
509 if test "x${require_simd}" = "xyes"; then
510 AC_MSG_ERROR([SIMD support not available for this CPU.])
512 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
517 if test "x${with_simd}" != "xno"; then
518 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
521 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-simd"
524 AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
525 AM_CONDITIONAL([WITH_SSE_FLOAT_DCT], [test "x$simd_arch" = "xx86_64" -o "x$simd_arch" = "xi386"])
526 AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
527 AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
528 AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
529 AM_CONDITIONAL([SIMD_ARM_64], [test "x$simd_arch" = "xaarch64"])
530 AM_CONDITIONAL([SIMD_MIPS], [test "x$simd_arch" = "xmips"])
531 AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
532 AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
534 AC_ARG_VAR(PKGNAME, [distribution package name (default: libjpeg-turbo)])
535 if test "x$PKGNAME" = "x"; then
536 PKGNAME=$PACKAGE_NAME
555 if test "${docdir}" = ""; then
556 docdir=${datadir}/doc
561 AC_SUBST(RPM_CONFIG_ARGS)
564 AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [libjpeg-turbo build number])
566 # NOTE: autoheader automatically modifies the input file of the first
567 # invocation of AC_CONFIG_HEADERS, so we put config.h first to prevent
568 # jconfig.h.in from being clobbered. config.h is used only internally, whereas
569 # jconfig.h contains macros that are relevant to external programs (macros that
570 # specify which features were built into the library.)
571 AC_CONFIG_HEADERS([config.h])
572 AC_CONFIG_HEADERS([jconfig.h])
573 AC_CONFIG_HEADERS([jconfigint.h])
574 AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.in])
575 AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in])
576 AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
577 AC_CONFIG_FILES([pkgscripts/makemacpkg.tmpl:release/makemacpkg.in])
578 AC_CONFIG_FILES([pkgscripts/uninstall.tmpl:release/uninstall.in])
579 if test "x$with_turbojpeg" != "xno"; then
580 AC_CONFIG_FILES([tjbenchtest])
582 if test "x$with_java" = "xyes"; then
583 AC_CONFIG_FILES([tjbenchtest.java])
584 AC_CONFIG_FILES([tjexampletest])
586 AC_CONFIG_FILES([libjpeg.map])
587 AC_CONFIG_FILES([Makefile simd/Makefile])
588 AC_CONFIG_FILES([java/Makefile])
589 AC_CONFIG_FILES([md5/Makefile])
590 AC_CONFIG_FILES([pkgconfig/Makefile pkgconfig/turbojpeg.pc])