blob: c3d682953436b482169f6ffe35a9ce267886516a [file] [log] [blame]
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
DRCbf0fab92010-02-12 22:22:01 +00004AC_PREREQ([2.56])
DRCde3c8612011-02-04 11:07:34 +00005AC_INIT([libjpeg-turbo], [1.1.90])
DRC079b4342010-02-15 11:32:23 +00006BUILD=`date +%Y%m%d`
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00007
8AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
DRC8ff1f252010-02-15 11:08:57 +00009AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000010
11# Always build with prototypes
12AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000013
14# Checks for programs.
DRCe7b699d2010-02-14 07:39:07 +000015SAVED_CFLAGS=${CFLAGS}
DRCb4a50ce2011-02-26 21:07:50 +000016SAVED_CPPFLAGS=${CPPFLAGS}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000017AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000018AC_PROG_CC
19AC_PROG_INSTALL
20AC_PROG_LIBTOOL
21AC_PROG_LN_S
22
DRCbdb12882010-08-21 21:14:17 +000023# Check whether compiler supports pointers to undefined structures
24AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
25AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
26AC_MSG_RESULT(yes),
27[AC_MSG_RESULT(no)
28AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to undefined structures.])])
29
DRCe7b699d2010-02-14 07:39:07 +000030if test "x${GCC}" = "xyes"; then
31 if test "x${SAVED_CFLAGS}" = "x"; then
32 CFLAGS=-O3
33 fi
DRCb4a50ce2011-02-26 21:07:50 +000034 if test "x${SAVED_CPPFLAGS}" = "x"; then
35 CPPFLAGS=-Wall
36 fi
DRCe7b699d2010-02-14 07:39:07 +000037fi
38
DRC1e2f2982010-02-16 22:35:25 +000039AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
40if test "x${SUNCC}" = "xyes"; then
41 if test "x${SAVED_CFLAGS}" = "x"; then
42 CFLAGS=-xO5
43 fi
DRC1e2f2982010-02-16 22:35:25 +000044fi
45
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000046# Checks for libraries.
47
48# Checks for header files.
49AC_HEADER_STDC
50AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
51AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
52
53# Checks for typedefs, structures, and compiler characteristics.
54AC_C_CONST
55AC_C_CHAR_UNSIGNED
56AC_C_INLINE
57AC_TYPE_SIZE_T
58AC_CHECK_TYPES([unsigned char, unsigned short])
59
60AC_MSG_CHECKING([if right shift is signed])
61AC_TRY_RUN(
62 [#include <stdio.h>
63 int is_shifting_signed (long arg) {
64 long res = arg >> 4;
65
66 if (res == -0x7F7E80CL)
67 return 1; /* right shift is signed */
68
69 /* see if unsigned-shift hack will fix it. */
70 /* we can't just test exact value since it depends on width of long... */
71 res |= (~0L) << (32-4);
72 if (res == -0x7F7E80CL)
73 return 0; /* right shift is unsigned */
74
75 printf("Right shift isn't acting as I expect it to.\n");
76 printf("I fear the JPEG software will not work at all.\n\n");
77 return 0; /* try it with unsigned anyway */
78 }
79 int main (void) {
80 exit(is_shifting_signed(-0x7F7E80B1L));
81 }],
82 [AC_MSG_RESULT(no)
83 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
84 [AC_MSG_RESULT(yes)],
85 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
86
87# test whether global names are unique to at least 15 chars
88AC_MSG_CHECKING([for short external names])
89AC_TRY_LINK(
90 [int possibly_duplicate_function () { return 0; }
91 int possibly_dupli_function () { return 1; }], [ ],
92 [AC_MSG_RESULT(ok)],
93 [AC_MSG_RESULT(short)
94 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
95
96# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000097AC_CHECK_FUNCS([memset memcpy], [],
98 [AC_DEFINE([NEED_BSD_STRINGS], 1,
99 [Define if you have BSD-like bzero and bcopy])])
100
DRC1f80a102010-10-18 00:15:31 +0000101AC_MSG_CHECKING([libjpeg API version])
102AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
103if test "x$JPEG_LIB_VERSION" = "x"; then
104 AC_ARG_WITH([jpeg7],
105 AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
106 AC_ARG_WITH([jpeg8],
DRCf38eee02011-02-18 07:00:38 +0000107 AC_HELP_STRING([--with-jpeg8], [Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
DRC1f80a102010-10-18 00:15:31 +0000108 if test "x${with_jpeg8}" = "xyes"; then
109 JPEG_LIB_VERSION=80
DRC36a6eec2010-10-08 08:05:44 +0000110 else
DRC1f80a102010-10-18 00:15:31 +0000111 if test "x${with_jpeg7}" = "xyes"; then
112 JPEG_LIB_VERSION=70
113 else
114 JPEG_LIB_VERSION=62
115 fi
DRC36a6eec2010-10-08 08:05:44 +0000116 fi
117fi
DRC1f80a102010-10-18 00:15:31 +0000118JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
DRC8515d3d2010-10-19 06:38:57 +0000119AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
DRC1f80a102010-10-18 00:15:31 +0000120AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
121AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION], [libjpeg API version])
122
123AC_MSG_CHECKING([libjpeg shared library version])
124AC_ARG_VAR(SO_MAJOR_VERSION, [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
125AC_ARG_VAR(SO_MINOR_VERSION, [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
126if test "x$SO_MAJOR_VERSION" = "x"; then
127 case "$JPEG_LIB_VERSION" in
128 62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
129 *) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
130 esac
131fi
132if test "x$SO_MINOR_VERSION" = "x"; then
133 case "$JPEG_LIB_VERSION" in
134 80) SO_MINOR_VERSION=2 ;;
135 *) SO_MINOR_VERSION=0 ;;
136 esac
137fi
138AC_MSG_RESULT([$SO_MAJOR_VERSION:$SO_MINOR_VERSION])
139AC_SUBST(SO_MAJOR_VERSION)
140AC_SUBST(SO_MINOR_VERSION)
DRC36a6eec2010-10-08 08:05:44 +0000141
DRC7a0478e2010-11-07 19:12:30 +0000142VERSION_SCRIPT=yes
143AC_ARG_ENABLE([ld-version-script],
144 AS_HELP_STRING([--disable-ld-version-script],
145 [Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
146 [VERSION_SCRIPT=$enableval], [])
DRC8515d3d2010-10-19 06:38:57 +0000147
148AC_MSG_CHECKING([whether the linker supports version scripts])
149SAVED_LDFLAGS="$LDFLAGS"
150LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
151cat > conftest.map <<EOF
152VERS_1 {
153 global: *;
154};
155EOF
156AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
157 [VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], [])
158if test "x$VERSION_SCRIPT_FLAG" = "x"; then
159 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
160 AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
161 [VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], [])
162fi
163if test "x$VERSION_SCRIPT_FLAG" = "x"; then
164 VERSION_SCRIPT=no
165 AC_MSG_RESULT(no)
166fi
DRC8515d3d2010-10-19 06:38:57 +0000167LDFLAGS="$SAVED_LDFLAGS"
168
DRC9fa95592011-02-25 00:23:44 +0000169AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
DRC8515d3d2010-10-19 06:38:57 +0000170AC_MSG_RESULT($VERSION_SCRIPT)
171
172AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
DRC8515d3d2010-10-19 06:38:57 +0000173AC_SUBST(VERSION_SCRIPT_FLAG)
DRC8515d3d2010-10-19 06:38:57 +0000174
DRC990e28d2011-01-04 21:40:11 +0000175AC_MSG_CHECKING([whether to include arithmetic encoding support])
DRCe3720042010-11-23 06:50:14 +0000176AC_ARG_WITH([arith-enc],
177 AC_HELP_STRING([--without-arith-enc], [Omit arithmetic encoding support]))
178if test "x$with_arith_enc" = "xno"; then
179 AC_MSG_RESULT(no)
180else
181 AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
182 AC_MSG_RESULT(yes)
183fi
184AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
185
DRC990e28d2011-01-04 21:40:11 +0000186AC_MSG_CHECKING([whether to include arithmetic decoding support])
DRCe3720042010-11-23 06:50:14 +0000187AC_ARG_WITH([arith-dec],
188 AC_HELP_STRING([--without-arith-dec], [Omit arithmetic decoding support]))
189if test "x$with_arith_dec" = "xno"; then
190 AC_MSG_RESULT(no)
191else
192 AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
193 AC_MSG_RESULT(yes)
194fi
195AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
196
197AM_CONDITIONAL([WITH_ARITH], [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
198
DRCe08c05f2011-03-31 08:03:26 +0000199AC_ARG_VAR(JNI_CFLAGS, [Compiler flags needed to find 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)])
DRC063ab492011-02-04 22:16:41 +0000200
DRCf8e00552011-02-04 11:06:36 +0000201AC_MSG_CHECKING([whether to include JNI wrapper in TurboJPEG/OSS])
202AC_ARG_WITH([jni],
203 AC_HELP_STRING([--with-jni],[Include JNI wrapper in the TurboJPEG/OSS library]))
DRC1421a262011-02-06 15:35:38 +0000204
205BUILDJNILIB=0
DRC1b0c3b02011-02-06 15:51:27 +0000206RPM_CONFIG_ARGS=
DRCf8e00552011-02-04 11:06:36 +0000207if test "x$with_jni" = "xyes"; then
208 AC_MSG_RESULT(yes)
DRC1421a262011-02-06 15:35:38 +0000209
210 case $host_os in
211 darwin*)
DRCe08c05f2011-03-31 08:03:26 +0000212 DEFAULT_JNI_CFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
DRC1421a262011-02-06 15:35:38 +0000213 BUILDJNILIB=1
214 ;;
215 solaris*)
DRCe08c05f2011-03-31 08:03:26 +0000216 DEFAULT_JNI_CFLAGS='-I/usr/java/include -I/usr/java/include/solaris'
DRC1421a262011-02-06 15:35:38 +0000217 ;;
218 linux*)
DRCe08c05f2011-03-31 08:03:26 +0000219 DEFAULT_JNI_CFLAGS='-I/usr/java/default/include -I/usr/java/default/include/linux'
DRC1421a262011-02-06 15:35:38 +0000220 ;;
221 esac
DRCe08c05f2011-03-31 08:03:26 +0000222 if test "x$JNI_CFLAGS" = "x"; then
223 JNI_CFLAGS=$DEFAULT_JNI_CFLAGS
DRC1421a262011-02-06 15:35:38 +0000224 fi
225
DRC063ab492011-02-04 22:16:41 +0000226 SAVE_CPPFLAGS=${CPPFLAGS}
DRCe08c05f2011-03-31 08:03:26 +0000227 CPPFLAGS="${CPPFLAGS} ${JNI_CFLAGS}"
DRC063ab492011-02-04 22:16:41 +0000228 AC_CHECK_HEADERS([jni.h], [DUMMY=1],
229 [AC_MSG_ERROR([Could not find JNI header file])])
230 CPPFLAGS=${SAVE_CPPFLAGS}
DRCe08c05f2011-03-31 08:03:26 +0000231 AC_SUBST(JNI_CFLAGS)
DRC1b0c3b02011-02-06 15:51:27 +0000232
233 RPM_CONFIG_ARGS=--with-jni
DRCf8e00552011-02-04 11:06:36 +0000234else
235 AC_MSG_RESULT(no)
236fi
237AM_CONDITIONAL([WITH_JNI], [test "x$with_jni" = "xyes"])
DRC25c58702011-02-05 04:41:36 +0000238AC_SUBST(BUILDJNILIB)
DRC1b0c3b02011-02-06 15:51:27 +0000239AC_SUBST(RPM_CONFIG_ARGS)
DRCf8e00552011-02-04 11:06:36 +0000240
DRC60cddeb2010-02-12 05:37:07 +0000241# SIMD is optional
242AC_ARG_WITH([simd],
243 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
244if test "x${with_simd}" != "xno"; then
245 # Check if we're on a supported CPU
246 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
247 case "$host_cpu" in
DRC49597872010-05-17 20:47:57 +0000248 x86_64 | amd64)
DRC60cddeb2010-02-12 05:37:07 +0000249 AC_MSG_RESULT([yes (x86_64)])
250 AC_PROG_NASM
251 simd_arch=x86_64
252 ;;
253 i*86 | x86 | ia32)
254 AC_MSG_RESULT([yes (i386)])
255 AC_PROG_NASM
256 simd_arch=i386
257 ;;
258 *)
259 AC_MSG_RESULT([no ("$host_cpu")])
DRC83f21442010-06-10 18:52:41 +0000260 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
261 with_simd=no;
DRC60cddeb2010-02-12 05:37:07 +0000262 ;;
263 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000264
DRC60cddeb2010-02-12 05:37:07 +0000265 if test "x${with_simd}" != "xno"; then
266 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
267 fi
268fi
DRC411dcf52010-02-12 04:28:29 +0000269
DRC60cddeb2010-02-12 05:37:07 +0000270AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000271AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
272AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC49597872010-05-17 20:47:57 +0000273AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000274
DRC079b4342010-02-15 11:32:23 +0000275case "$host_cpu" in
276 x86_64)
277 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000278 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000279 ;;
280 i*86 | x86 | ia32)
281 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000282 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000283 ;;
284esac
285
286AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000287AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000288AC_SUBST(BUILD)
DRC2cdd2ae2010-10-10 06:54:21 +0000289AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
DRC079b4342010-02-15 11:32:23 +0000290
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000291# jconfig.h is the file we use, but we have another before that to
292# fool autoheader. the reason is that we include this header in our
293# API headers, which can screw things up for users of the lib.
294# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000295AC_CONFIG_HEADERS([config.h])
296AC_CONFIG_HEADERS([jconfig.h])
DRCb94f2de2011-03-22 09:31:25 +0000297AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec:release/libjpeg-turbo.spec.in])
298AC_CONFIG_FILES([pkgscripts/makecygwinpkg:release/makecygwinpkg.in])
299AC_CONFIG_FILES([pkgscripts/makedpkg:release/makedpkg.in])
300AC_CONFIG_FILES([pkgscripts/deb-control:release/deb-control.in])
301AC_CONFIG_FILES([pkgscripts/makemacpkg:release/makemacpkg.in])
302AC_CONFIG_FILES([pkgscripts/Description.plist:release/Description.plist.in])
303AC_CONFIG_FILES([pkgscripts/Info.plist:release/Info.plist.in])
304AC_CONFIG_FILES([pkgscripts/uninstall:release/uninstall.in])
305AC_CONFIG_FILES([pkgscripts/makesunpkg:release/makesunpkg.in])
306AC_CONFIG_FILES([pkgscripts/pkginfo:release/pkginfo.in])
DRC8515d3d2010-10-19 06:38:57 +0000307AC_CONFIG_FILES([libjpeg.map])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000308AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000309AC_OUTPUT