2 # Process this file with autoconf to produce a configure script.
5 AC_INIT([libjpeg-turbo], [1.3.1])
8 AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
9 AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
11 # Always build with prototypes
12 AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
14 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
16 # Checks for programs.
17 SAVED_CFLAGS=${CFLAGS}
18 SAVED_CPPFLAGS=${CPPFLAGS}
21 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
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}'
46 old_exec_prefix=${exec_prefix}
47 if test "x$exec_prefix" = "xNONE"; then
51 if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; then
52 LIBDIR=`eval echo ${libdir}`
53 LIBDIR=`eval echo $LIBDIR`
54 if test "$LIBDIR" = "/opt/libjpeg-turbo/lib"; then
60 if test "${ac_cv_sizeof_long}" = "8"; then
61 libdir='${exec_prefix}/lib64'
62 elif test "${ac_cv_sizeof_long}" = "4"; then
63 libdir='${exec_prefix}/lib32'
69 exec_prefix=${old_exec_prefix}
72 # Check whether compiler supports pointers to undefined structures
73 AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
74 AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
77 AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
78 [Compiler does not support pointers to undefined structures.])])
80 if test "x${GCC}" = "xyes"; then
81 if test "x${SAVED_CFLAGS}" = "x"; then
84 if test "x${SAVED_CPPFLAGS}" = "x"; then
89 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
90 if test "x${SUNCC}" = "xyes"; then
91 if test "x${SAVED_CFLAGS}" = "x"; then
96 # Checks for libraries.
98 # Checks for header files.
100 AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
101 AC_CHECK_HEADER([sys/types.h],
102 AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
104 # Checks for typedefs, structures, and compiler characteristics.
109 AC_CHECK_TYPES([unsigned char, unsigned short])
111 AC_MSG_CHECKING([if right shift is signed])
114 int is_shifting_signed (long arg) {
117 if (res == -0x7F7E80CL)
118 return 1; /* right shift is signed */
120 /* see if unsigned-shift hack will fix it. */
121 /* we can't just test exact value since it depends on width of long... */
122 res |= (~0L) << (32-4);
123 if (res == -0x7F7E80CL)
124 return 0; /* right shift is unsigned */
126 printf("Right shift isn't acting as I expect it to.\n");
127 printf("I fear the JPEG software will not work at all.\n\n");
128 return 0; /* try it with unsigned anyway */
131 exit(is_shifting_signed(-0x7F7E80B1L));
134 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
135 [AC_MSG_RESULT(yes)],
136 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
138 # test whether global names are unique to at least 15 chars
139 AC_MSG_CHECKING([for short external names])
141 [int possibly_duplicate_function () { return 0; }
142 int possibly_dupli_function () { return 1; }], [ ],
144 [AC_MSG_RESULT(short)
145 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1,
146 [Define if you need short function names])])
148 # Checks for library functions.
149 AC_CHECK_FUNCS([memset memcpy], [],
150 [AC_DEFINE([NEED_BSD_STRINGS], 1,
151 [Define if you have BSD-like bzero and bcopy])])
153 AC_MSG_CHECKING([libjpeg API version])
154 AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
155 if test "x$JPEG_LIB_VERSION" = "x"; then
157 AC_HELP_STRING([--with-jpeg7],
158 [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
160 AC_HELP_STRING([--with-jpeg8],
161 [Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
162 if test "x${with_jpeg8}" = "xyes"; then
165 if test "x${with_jpeg7}" = "xyes"; then
172 JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
173 AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
174 AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
175 AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION],
176 [libjpeg API version])
178 AC_ARG_VAR(SO_MAJOR_VERSION,
179 [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
180 AC_ARG_VAR(SO_MINOR_VERSION,
181 [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
182 if test "x$SO_MAJOR_VERSION" = "x"; then
183 case "$JPEG_LIB_VERSION" in
184 62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
185 *) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
188 if test "x$SO_MINOR_VERSION" = "x"; then
189 case "$JPEG_LIB_VERSION" in
190 80) SO_MINOR_VERSION=2 ;;
191 *) SO_MINOR_VERSION=0 ;;
197 # Memory source/destination managers
199 MEM_SRCDST_FUNCTIONS=
200 if test "x${with_jpeg8}" != "xyes"; then
201 AC_MSG_CHECKING([whether to include in-memory source/destination managers])
202 AC_ARG_WITH([mem-srcdst],
203 AC_HELP_STRING([--without-mem-srcdst],
204 [Do not include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI]))
205 if test "x$with_mem_srcdst" != "xno"; then
207 AC_DEFINE([MEM_SRCDST_SUPPORTED], [1],
208 [Support in-memory source/destination managers])
210 MEM_SRCDST_FUNCTIONS="global: jpeg_mem_dest; jpeg_mem_src;";
213 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-mem-srcdst"
217 AC_MSG_CHECKING([libjpeg shared library version])
218 AC_MSG_RESULT([$SO_MAJOR_VERSION.$SO_AGE.$SO_MINOR_VERSION])
219 LIBTOOL_CURRENT=`expr $SO_MAJOR_VERSION + $SO_AGE`
220 AC_SUBST(LIBTOOL_CURRENT)
221 AC_SUBST(SO_MAJOR_VERSION)
222 AC_SUBST(SO_MINOR_VERSION)
224 AC_SUBST(MEM_SRCDST_FUNCTIONS)
226 AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
229 AC_ARG_ENABLE([ld-version-script],
230 AS_HELP_STRING([--disable-ld-version-script],
231 [Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
232 [VERSION_SCRIPT=$enableval], [])
234 AC_MSG_CHECKING([whether the linker supports version scripts])
235 SAVED_LDFLAGS="$LDFLAGS"
236 LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
237 cat > conftest.map <<EOF
242 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
243 [VERSION_SCRIPT_FLAG=-Wl,--version-script,;
244 AC_MSG_RESULT([yes (GNU style)])],
246 if test "x$VERSION_SCRIPT_FLAG" = "x"; then
247 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
248 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
249 [VERSION_SCRIPT_FLAG=-Wl,-M,;
250 AC_MSG_RESULT([yes (Sun style)])],
253 if test "x$VERSION_SCRIPT_FLAG" = "x"; then
257 LDFLAGS="$SAVED_LDFLAGS"
259 AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
260 AC_MSG_RESULT($VERSION_SCRIPT)
262 AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
263 AC_SUBST(VERSION_SCRIPT_FLAG)
265 # Check for non-broken inline under various spellings
266 AC_MSG_CHECKING(for inline)
268 AC_TRY_COMPILE(, [} __attribute__((always_inline)) int foo() { return 0; }
269 int bar() { return foo();], ljt_cv_inline="inline __attribute__((always_inline))",
270 AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
271 int bar() { return foo();], ljt_cv_inline="__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_MSG_RESULT($ljt_cv_inline)
277 AC_DEFINE_UNQUOTED([INLINE],[$ljt_cv_inline],[How to obtain function inlining.])
279 # Arithmetic coding support
280 AC_MSG_CHECKING([whether to include arithmetic encoding support])
281 AC_ARG_WITH([arith-enc],
282 AC_HELP_STRING([--without-arith-enc],
283 [Do not include arithmetic encoding support]))
284 if test "x$with_arith_enc" = "xno"; then
286 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-enc"
288 AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
291 AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
293 AC_MSG_CHECKING([whether to include arithmetic decoding support])
294 AC_ARG_WITH([arith-dec],
295 AC_HELP_STRING([--without-arith-dec],
296 [Do not include arithmetic decoding support]))
297 if test "x$with_arith_dec" = "xno"; then
299 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-dec"
301 AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
304 AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
306 AM_CONDITIONAL([WITH_ARITH],
307 [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
310 AC_MSG_CHECKING([whether to build TurboJPEG C wrapper])
311 AC_ARG_WITH([turbojpeg],
312 AC_HELP_STRING([--without-turbojpeg],
313 [Do not include the TurboJPEG wrapper library and associated test programs]))
314 if test "x$with_turbojpeg" = "xno"; then
316 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-turbojpeg"
322 AC_ARG_VAR(JAVAC, [Java compiler command (default: javac)])
323 if test "x$JAVAC" = "x"; then
327 AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
329 AC_ARG_VAR(JAR, [Java archive command (default: jar)])
330 if test "x$JAR" = "x"; then
334 AC_ARG_VAR(JAVA, [Java runtime command (default: java)])
335 if test "x$JAVA" = "x"; then
339 AC_ARG_VAR(JNI_CFLAGS,
340 [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)])
342 AC_MSG_CHECKING([whether to build TurboJPEG Java wrapper])
344 AC_HELP_STRING([--with-java], [Build Java wrapper for the TurboJPEG library]))
345 if test "x$with_turbojpeg" = "xno"; then
350 if test "x$with_java" = "xyes"; then
355 DEFAULT_JNI_CFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
358 DEFAULT_JNI_CFLAGS='-I/usr/java/include -I/usr/java/include/solaris'
361 DEFAULT_JNI_CFLAGS='-I/usr/java/default/include -I/usr/java/default/include/linux'
364 if test "x$JNI_CFLAGS" = "x"; then
365 JNI_CFLAGS=$DEFAULT_JNI_CFLAGS
368 SAVE_CPPFLAGS=${CPPFLAGS}
369 CPPFLAGS="${CPPFLAGS} ${JNI_CFLAGS}"
370 AC_CHECK_HEADERS([jni.h], [DUMMY=1],
371 [AC_MSG_ERROR([Could not find JNI header file])])
372 CPPFLAGS=${SAVE_CPPFLAGS}
375 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --with-java"
376 JAVA_RPM_CONTENTS_1='%dir %{_datadir}/classes'
377 JAVA_RPM_CONTENTS_2=%{_datadir}/classes/turbojpeg.jar
382 AM_CONDITIONAL([WITH_JAVA], [test "x$with_java" = "xyes"])
384 AC_SUBST(JAVA_RPM_CONTENTS_1)
385 AC_SUBST(JAVA_RPM_CONTENTS_2)
387 # optionally force using gas-preprocessor.pl for compatibility testing
388 AC_ARG_WITH([gas-preprocessor],
389 AC_HELP_STRING([--with-gas-preprocessor],
390 [Force using gas-preprocessor.pl on ARM.]))
391 if test "x${with_gas_preprocessor}" = "xyes"; then
394 CCAS="gas-preprocessor.pl -fix-unreq $CC"
397 CCAS="gas-preprocessor.pl -no-fix-unreq $CC"
405 AC_HELP_STRING([--without-simd], [Do not include SIMD extensions]))
406 if test "x${with_simd}" != "xno"; then
408 if test "x${with_simd}" = "xyes"; then
411 # Check if we're on a supported CPU
412 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
415 AC_MSG_RESULT([yes (x86_64)])
420 AC_MSG_RESULT([yes (i386)])
425 AC_MSG_RESULT([yes (arm)])
426 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
427 AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE(
428 [AC_MSG_RESULT([yes])
432 if test "x${with_simd}" = "xno"; then
433 if test "x${require_simd}" = "xyes"; then
434 AC_MSG_ERROR([SIMD support can't be enabled.])
436 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
441 AC_MSG_RESULT([no ("$host_cpu")])
443 if test "x${require_simd}" = "xyes"; then
444 AC_MSG_ERROR([SIMD support not available for this CPU.])
446 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
451 if test "x${with_simd}" != "xno"; then
452 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
455 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-simd"
458 AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
459 AM_CONDITIONAL([WITH_SSE_FLOAT_DCT], [test "x$simd_arch" = "xx86_64" -o "x$simd_arch" = "xi386"])
460 AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
461 AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
462 AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
463 AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
464 AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
466 AC_ARG_VAR(PKGNAME, [distribution package name (default: libjpeg-turbo)])
467 if test "x$PKGNAME" = "x"; then
468 PKGNAME=$PACKAGE_NAME
484 AC_SUBST(RPM_CONFIG_ARGS)
487 AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
489 # jconfig.h is the file we use, but we have another before that to
490 # fool autoheader. the reason is that we include this header in our
491 # API headers, which can screw things up for users of the lib.
492 # jconfig.h is a minimal version that allows this package to be built
493 AC_CONFIG_HEADERS([config.h])
494 AC_CONFIG_HEADERS([jconfig.h])
495 AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.in])
496 AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in])
497 AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
498 AC_CONFIG_FILES([pkgscripts/makemacpkg.tmpl:release/makemacpkg.in])
499 AC_CONFIG_FILES([pkgscripts/Description.plist:release/Description.plist.in])
500 AC_CONFIG_FILES([pkgscripts/Info.plist:release/Info.plist.in])
501 AC_CONFIG_FILES([pkgscripts/uninstall.tmpl:release/uninstall.in])
502 if test "x$with_turbojpeg" != "xno"; then
503 AC_CONFIG_FILES([tjbenchtest])
505 if test "x$with_java" = "xyes"; then
506 AC_CONFIG_FILES([tjbenchtest.java])
507 AC_CONFIG_FILES([tjexampletest])
509 AC_CONFIG_FILES([libjpeg.map])
510 AC_CONFIG_FILES([Makefile simd/Makefile])
511 AC_CONFIG_FILES([java/Makefile])
512 AC_CONFIG_FILES([md5/Makefile])