blob: 06b3859579e5e646de497dcf1f6b9da8911f7d18 [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])
DRC3a606242010-10-18 08:27:04 +00005AC_INIT([libjpeg-turbo], [1.0.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}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000016AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000017AC_PROG_CC
18AC_PROG_INSTALL
19AC_PROG_LIBTOOL
20AC_PROG_LN_S
21
DRCbdb12882010-08-21 21:14:17 +000022# Check whether compiler supports pointers to undefined structures
23AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
24AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
25AC_MSG_RESULT(yes),
26[AC_MSG_RESULT(no)
27AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to undefined structures.])])
28
DRCe7b699d2010-02-14 07:39:07 +000029if test "x${GCC}" = "xyes"; then
30 if test "x${SAVED_CFLAGS}" = "x"; then
31 CFLAGS=-O3
32 fi
DRCe7b699d2010-02-14 07:39:07 +000033fi
34
DRC1e2f2982010-02-16 22:35:25 +000035AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
36if test "x${SUNCC}" = "xyes"; then
37 if test "x${SAVED_CFLAGS}" = "x"; then
38 CFLAGS=-xO5
39 fi
DRC1e2f2982010-02-16 22:35:25 +000040fi
41
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000042# Checks for libraries.
43
44# Checks for header files.
45AC_HEADER_STDC
46AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
47AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
48
49# Checks for typedefs, structures, and compiler characteristics.
50AC_C_CONST
51AC_C_CHAR_UNSIGNED
52AC_C_INLINE
53AC_TYPE_SIZE_T
54AC_CHECK_TYPES([unsigned char, unsigned short])
55
56AC_MSG_CHECKING([if right shift is signed])
57AC_TRY_RUN(
58 [#include <stdio.h>
59 int is_shifting_signed (long arg) {
60 long res = arg >> 4;
61
62 if (res == -0x7F7E80CL)
63 return 1; /* right shift is signed */
64
65 /* see if unsigned-shift hack will fix it. */
66 /* we can't just test exact value since it depends on width of long... */
67 res |= (~0L) << (32-4);
68 if (res == -0x7F7E80CL)
69 return 0; /* right shift is unsigned */
70
71 printf("Right shift isn't acting as I expect it to.\n");
72 printf("I fear the JPEG software will not work at all.\n\n");
73 return 0; /* try it with unsigned anyway */
74 }
75 int main (void) {
76 exit(is_shifting_signed(-0x7F7E80B1L));
77 }],
78 [AC_MSG_RESULT(no)
79 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
80 [AC_MSG_RESULT(yes)],
81 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
82
83# test whether global names are unique to at least 15 chars
84AC_MSG_CHECKING([for short external names])
85AC_TRY_LINK(
86 [int possibly_duplicate_function () { return 0; }
87 int possibly_dupli_function () { return 1; }], [ ],
88 [AC_MSG_RESULT(ok)],
89 [AC_MSG_RESULT(short)
90 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
91
92# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000093AC_CHECK_FUNCS([memset memcpy], [],
94 [AC_DEFINE([NEED_BSD_STRINGS], 1,
95 [Define if you have BSD-like bzero and bcopy])])
96
Pierre Ossman2ae181c2009-03-09 13:21:27 +000097# Set flags to indicate platform
98case "$host_os" in
99 cygwin* | mingw* | pw32* | interix*)
100 is_win32=1
101 ;;
102esac
103AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
104
DRC1f80a102010-10-18 00:15:31 +0000105AC_MSG_CHECKING([libjpeg API version])
106AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
107if test "x$JPEG_LIB_VERSION" = "x"; then
108 AC_ARG_WITH([jpeg7],
109 AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
110 AC_ARG_WITH([jpeg8],
DRCf38eee02011-02-18 07:00:38 +0000111 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 +0000112 if test "x${with_jpeg8}" = "xyes"; then
113 JPEG_LIB_VERSION=80
DRC36a6eec2010-10-08 08:05:44 +0000114 else
DRC1f80a102010-10-18 00:15:31 +0000115 if test "x${with_jpeg7}" = "xyes"; then
116 JPEG_LIB_VERSION=70
117 else
118 JPEG_LIB_VERSION=62
119 fi
DRC36a6eec2010-10-08 08:05:44 +0000120 fi
121fi
DRC1f80a102010-10-18 00:15:31 +0000122JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
DRC8515d3d2010-10-19 06:38:57 +0000123AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
DRC1f80a102010-10-18 00:15:31 +0000124AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
125AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION], [libjpeg API version])
126
127AC_MSG_CHECKING([libjpeg shared library version])
128AC_ARG_VAR(SO_MAJOR_VERSION, [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
129AC_ARG_VAR(SO_MINOR_VERSION, [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
130if test "x$SO_MAJOR_VERSION" = "x"; then
131 case "$JPEG_LIB_VERSION" in
132 62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
133 *) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
134 esac
135fi
136if test "x$SO_MINOR_VERSION" = "x"; then
137 case "$JPEG_LIB_VERSION" in
138 80) SO_MINOR_VERSION=2 ;;
139 *) SO_MINOR_VERSION=0 ;;
140 esac
141fi
142AC_MSG_RESULT([$SO_MAJOR_VERSION:$SO_MINOR_VERSION])
143AC_SUBST(SO_MAJOR_VERSION)
144AC_SUBST(SO_MINOR_VERSION)
DRC36a6eec2010-10-08 08:05:44 +0000145
DRC7a0478e2010-11-07 19:12:30 +0000146VERSION_SCRIPT=yes
147AC_ARG_ENABLE([ld-version-script],
148 AS_HELP_STRING([--disable-ld-version-script],
149 [Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
150 [VERSION_SCRIPT=$enableval], [])
DRC8515d3d2010-10-19 06:38:57 +0000151
152AC_MSG_CHECKING([whether the linker supports version scripts])
153SAVED_LDFLAGS="$LDFLAGS"
154LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
155cat > conftest.map <<EOF
156VERS_1 {
157 global: *;
158};
159EOF
160AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
161 [VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], [])
162if test "x$VERSION_SCRIPT_FLAG" = "x"; then
163 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
164 AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
165 [VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], [])
166fi
167if test "x$VERSION_SCRIPT_FLAG" = "x"; then
168 VERSION_SCRIPT=no
169 AC_MSG_RESULT(no)
170fi
171
172ANON_VERSION_SCRIPT=yes
173AC_MSG_CHECKING([whether the linker supports anonymous version scripts])
174LDFLAGS="$SAVED_LDFLAGS -Wl,--version-script,conftest.map"
175cat > conftest.map <<EOF
176{
177 global: main;
178 local: *;
179};
180EOF
181AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
182 [ANON_VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], [])
183if test "x$ANON_VERSION_SCRIPT_FLAG" = "x"; then
184 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
185 AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
186 [ANON_VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], [])
187fi
188if test "x$ANON_VERSION_SCRIPT_FLAG" = "x"; then
189 ANON_VERSION_SCRIPT=no
190 AC_MSG_RESULT(no)
191fi
192LDFLAGS="$SAVED_LDFLAGS"
193
194AC_MSG_CHECKING([whether to use version script when building libjpeg])
195AC_MSG_RESULT($VERSION_SCRIPT)
196
197AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
198AM_CONDITIONAL(ANON_VERSION_SCRIPT, test "x$ANON_VERSION_SCRIPT" = "xyes")
199AC_SUBST(VERSION_SCRIPT_FLAG)
200AC_SUBST(ANON_VERSION_SCRIPT_FLAG)
201
DRC990e28d2011-01-04 21:40:11 +0000202AC_MSG_CHECKING([whether to include arithmetic encoding support])
DRCe3720042010-11-23 06:50:14 +0000203AC_ARG_WITH([arith-enc],
204 AC_HELP_STRING([--without-arith-enc], [Omit arithmetic encoding support]))
205if test "x$with_arith_enc" = "xno"; then
206 AC_MSG_RESULT(no)
207else
208 AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
209 AC_MSG_RESULT(yes)
210fi
211AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
212
DRC990e28d2011-01-04 21:40:11 +0000213AC_MSG_CHECKING([whether to include arithmetic decoding support])
DRCe3720042010-11-23 06:50:14 +0000214AC_ARG_WITH([arith-dec],
215 AC_HELP_STRING([--without-arith-dec], [Omit arithmetic decoding support]))
216if test "x$with_arith_dec" = "xno"; then
217 AC_MSG_RESULT(no)
218else
219 AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
220 AC_MSG_RESULT(yes)
221fi
222AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
223
224AM_CONDITIONAL([WITH_ARITH], [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
225
DRC60cddeb2010-02-12 05:37:07 +0000226# SIMD is optional
227AC_ARG_WITH([simd],
228 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
229if test "x${with_simd}" != "xno"; then
230 # Check if we're on a supported CPU
231 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
232 case "$host_cpu" in
DRC49597872010-05-17 20:47:57 +0000233 x86_64 | amd64)
DRC60cddeb2010-02-12 05:37:07 +0000234 AC_MSG_RESULT([yes (x86_64)])
235 AC_PROG_NASM
236 simd_arch=x86_64
237 ;;
238 i*86 | x86 | ia32)
239 AC_MSG_RESULT([yes (i386)])
240 AC_PROG_NASM
241 simd_arch=i386
242 ;;
243 *)
244 AC_MSG_RESULT([no ("$host_cpu")])
DRC83f21442010-06-10 18:52:41 +0000245 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
246 with_simd=no;
DRC60cddeb2010-02-12 05:37:07 +0000247 ;;
248 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000249
DRC60cddeb2010-02-12 05:37:07 +0000250 if test "x${with_simd}" != "xno"; then
251 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
252 fi
253fi
DRC411dcf52010-02-12 04:28:29 +0000254
DRC60cddeb2010-02-12 05:37:07 +0000255AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000256AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
257AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC49597872010-05-17 20:47:57 +0000258AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000259
DRC079b4342010-02-15 11:32:23 +0000260case "$host_cpu" in
261 x86_64)
262 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000263 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000264 ;;
265 i*86 | x86 | ia32)
266 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000267 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000268 ;;
269esac
270
271AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000272AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000273AC_SUBST(BUILD)
DRC2cdd2ae2010-10-10 06:54:21 +0000274AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
DRC079b4342010-02-15 11:32:23 +0000275
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000276# jconfig.h is the file we use, but we have another before that to
277# fool autoheader. the reason is that we include this header in our
278# API headers, which can screw things up for users of the lib.
279# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000280AC_CONFIG_HEADERS([config.h])
281AC_CONFIG_HEADERS([jconfig.h])
DRC1f80a102010-10-18 00:15:31 +0000282AC_CONFIG_FILES([libjpeg-turbo.spec:release/libjpeg-turbo.spec.in])
DRC0f53df82010-10-21 19:47:06 +0000283AC_CONFIG_FILES([makemacpkg:release/makemacpkg.in])
284AC_CONFIG_FILES([makesunpkg:release/makesunpkg.in])
DRC8515d3d2010-10-19 06:38:57 +0000285AC_CONFIG_FILES([libjpeg.map])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000286AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000287AC_OUTPUT