blob: fb022f2b7521989d37eddd5e9510091d3100503d [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}
16SAVED_CXXFLAGS=${CXXFLAGS}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000017AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000018AC_PROG_CC
Adam Tkac6e075fc2009-04-03 14:47:50 +000019AC_PROG_CXX
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000020AC_PROG_INSTALL
21AC_PROG_LIBTOOL
22AC_PROG_LN_S
23
DRCbdb12882010-08-21 21:14:17 +000024# Check whether compiler supports pointers to undefined structures
25AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
26AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
27AC_MSG_RESULT(yes),
28[AC_MSG_RESULT(no)
29AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to undefined structures.])])
30
DRCe7b699d2010-02-14 07:39:07 +000031if test "x${GCC}" = "xyes"; then
32 if test "x${SAVED_CFLAGS}" = "x"; then
33 CFLAGS=-O3
34 fi
35 if test "x${SAVED_CXXFLAGS}" = "x"; then
36 CXXFLAGS=-O3
37 fi
38fi
39
DRC1e2f2982010-02-16 22:35:25 +000040AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
41if test "x${SUNCC}" = "xyes"; then
42 if test "x${SAVED_CFLAGS}" = "x"; then
43 CFLAGS=-xO5
44 fi
45 if test "x${SAVED_CXXFLAGS}" = "x"; then
46 CXXFLAGS=-xO5
47 fi
48fi
49
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000050# Checks for libraries.
51
52# Checks for header files.
53AC_HEADER_STDC
54AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
55AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
56
57# Checks for typedefs, structures, and compiler characteristics.
58AC_C_CONST
59AC_C_CHAR_UNSIGNED
60AC_C_INLINE
61AC_TYPE_SIZE_T
62AC_CHECK_TYPES([unsigned char, unsigned short])
63
64AC_MSG_CHECKING([if right shift is signed])
65AC_TRY_RUN(
66 [#include <stdio.h>
67 int is_shifting_signed (long arg) {
68 long res = arg >> 4;
69
70 if (res == -0x7F7E80CL)
71 return 1; /* right shift is signed */
72
73 /* see if unsigned-shift hack will fix it. */
74 /* we can't just test exact value since it depends on width of long... */
75 res |= (~0L) << (32-4);
76 if (res == -0x7F7E80CL)
77 return 0; /* right shift is unsigned */
78
79 printf("Right shift isn't acting as I expect it to.\n");
80 printf("I fear the JPEG software will not work at all.\n\n");
81 return 0; /* try it with unsigned anyway */
82 }
83 int main (void) {
84 exit(is_shifting_signed(-0x7F7E80B1L));
85 }],
86 [AC_MSG_RESULT(no)
87 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
88 [AC_MSG_RESULT(yes)],
89 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
90
91# test whether global names are unique to at least 15 chars
92AC_MSG_CHECKING([for short external names])
93AC_TRY_LINK(
94 [int possibly_duplicate_function () { return 0; }
95 int possibly_dupli_function () { return 1; }], [ ],
96 [AC_MSG_RESULT(ok)],
97 [AC_MSG_RESULT(short)
98 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
99
100# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000101AC_CHECK_FUNCS([memset memcpy], [],
102 [AC_DEFINE([NEED_BSD_STRINGS], 1,
103 [Define if you have BSD-like bzero and bcopy])])
104
Pierre Ossman2ae181c2009-03-09 13:21:27 +0000105# Set flags to indicate platform
106case "$host_os" in
107 cygwin* | mingw* | pw32* | interix*)
108 is_win32=1
109 ;;
110esac
111AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
112
DRC1f80a102010-10-18 00:15:31 +0000113AC_MSG_CHECKING([libjpeg API version])
114AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
115if test "x$JPEG_LIB_VERSION" = "x"; then
116 AC_ARG_WITH([jpeg7],
117 AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
118 AC_ARG_WITH([jpeg8],
119 AC_HELP_STRING([--with-jpeg8], [Emulate libjpeg v8b API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
120 if test "x${with_jpeg8}" = "xyes"; then
121 JPEG_LIB_VERSION=80
DRC36a6eec2010-10-08 08:05:44 +0000122 else
DRC1f80a102010-10-18 00:15:31 +0000123 if test "x${with_jpeg7}" = "xyes"; then
124 JPEG_LIB_VERSION=70
125 else
126 JPEG_LIB_VERSION=62
127 fi
DRC36a6eec2010-10-08 08:05:44 +0000128 fi
129fi
DRC1f80a102010-10-18 00:15:31 +0000130JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
DRC8515d3d2010-10-19 06:38:57 +0000131AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
DRC1f80a102010-10-18 00:15:31 +0000132AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
133AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION], [libjpeg API version])
134
135AC_MSG_CHECKING([libjpeg shared library version])
136AC_ARG_VAR(SO_MAJOR_VERSION, [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
137AC_ARG_VAR(SO_MINOR_VERSION, [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
138if test "x$SO_MAJOR_VERSION" = "x"; then
139 case "$JPEG_LIB_VERSION" in
140 62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
141 *) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
142 esac
143fi
144if test "x$SO_MINOR_VERSION" = "x"; then
145 case "$JPEG_LIB_VERSION" in
146 80) SO_MINOR_VERSION=2 ;;
147 *) SO_MINOR_VERSION=0 ;;
148 esac
149fi
150AC_MSG_RESULT([$SO_MAJOR_VERSION:$SO_MINOR_VERSION])
151AC_SUBST(SO_MAJOR_VERSION)
152AC_SUBST(SO_MINOR_VERSION)
DRC36a6eec2010-10-08 08:05:44 +0000153
DRC7a0478e2010-11-07 19:12:30 +0000154VERSION_SCRIPT=yes
155AC_ARG_ENABLE([ld-version-script],
156 AS_HELP_STRING([--disable-ld-version-script],
157 [Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
158 [VERSION_SCRIPT=$enableval], [])
DRC8515d3d2010-10-19 06:38:57 +0000159
160AC_MSG_CHECKING([whether the linker supports version scripts])
161SAVED_LDFLAGS="$LDFLAGS"
162LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
163cat > conftest.map <<EOF
164VERS_1 {
165 global: *;
166};
167EOF
168AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
169 [VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], [])
170if test "x$VERSION_SCRIPT_FLAG" = "x"; then
171 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
172 AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
173 [VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], [])
174fi
175if test "x$VERSION_SCRIPT_FLAG" = "x"; then
176 VERSION_SCRIPT=no
177 AC_MSG_RESULT(no)
178fi
179
180ANON_VERSION_SCRIPT=yes
181AC_MSG_CHECKING([whether the linker supports anonymous version scripts])
182LDFLAGS="$SAVED_LDFLAGS -Wl,--version-script,conftest.map"
183cat > conftest.map <<EOF
184{
185 global: main;
186 local: *;
187};
188EOF
189AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
190 [ANON_VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], [])
191if test "x$ANON_VERSION_SCRIPT_FLAG" = "x"; then
192 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
193 AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
194 [ANON_VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], [])
195fi
196if test "x$ANON_VERSION_SCRIPT_FLAG" = "x"; then
197 ANON_VERSION_SCRIPT=no
198 AC_MSG_RESULT(no)
199fi
200LDFLAGS="$SAVED_LDFLAGS"
201
202AC_MSG_CHECKING([whether to use version script when building libjpeg])
203AC_MSG_RESULT($VERSION_SCRIPT)
204
205AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
206AM_CONDITIONAL(ANON_VERSION_SCRIPT, test "x$ANON_VERSION_SCRIPT" = "xyes")
207AC_SUBST(VERSION_SCRIPT_FLAG)
208AC_SUBST(ANON_VERSION_SCRIPT_FLAG)
209
DRC60cddeb2010-02-12 05:37:07 +0000210# SIMD is optional
211AC_ARG_WITH([simd],
212 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
213if test "x${with_simd}" != "xno"; then
214 # Check if we're on a supported CPU
215 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
216 case "$host_cpu" in
DRC49597872010-05-17 20:47:57 +0000217 x86_64 | amd64)
DRC60cddeb2010-02-12 05:37:07 +0000218 AC_MSG_RESULT([yes (x86_64)])
219 AC_PROG_NASM
220 simd_arch=x86_64
221 ;;
222 i*86 | x86 | ia32)
223 AC_MSG_RESULT([yes (i386)])
224 AC_PROG_NASM
225 simd_arch=i386
226 ;;
227 *)
228 AC_MSG_RESULT([no ("$host_cpu")])
DRC83f21442010-06-10 18:52:41 +0000229 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
230 with_simd=no;
DRC60cddeb2010-02-12 05:37:07 +0000231 ;;
232 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000233
DRC60cddeb2010-02-12 05:37:07 +0000234 if test "x${with_simd}" != "xno"; then
235 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
236 fi
237fi
DRC411dcf52010-02-12 04:28:29 +0000238
DRC60cddeb2010-02-12 05:37:07 +0000239AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000240AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
241AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC49597872010-05-17 20:47:57 +0000242AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000243
DRC079b4342010-02-15 11:32:23 +0000244case "$host_cpu" in
245 x86_64)
246 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000247 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000248 ;;
249 i*86 | x86 | ia32)
250 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000251 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000252 ;;
253esac
254
255AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000256AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000257AC_SUBST(BUILD)
DRC2cdd2ae2010-10-10 06:54:21 +0000258AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
DRC079b4342010-02-15 11:32:23 +0000259
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000260# jconfig.h is the file we use, but we have another before that to
261# fool autoheader. the reason is that we include this header in our
262# API headers, which can screw things up for users of the lib.
263# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000264AC_CONFIG_HEADERS([config.h])
265AC_CONFIG_HEADERS([jconfig.h])
DRC1f80a102010-10-18 00:15:31 +0000266AC_CONFIG_FILES([libjpeg-turbo.spec:release/libjpeg-turbo.spec.in])
DRC0f53df82010-10-21 19:47:06 +0000267AC_CONFIG_FILES([makemacpkg:release/makemacpkg.in])
268AC_CONFIG_FILES([makesunpkg:release/makesunpkg.in])
DRC8515d3d2010-10-19 06:38:57 +0000269AC_CONFIG_FILES([libjpeg.map])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000270AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000271AC_OUTPUT