blob: 6d0e5bdbf8f753c686104bf5edce08d798354f08 [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
DRC6f8c6682010-02-16 05:03:51 +000031AC_MSG_CHECKING([whether the linker supports version scripts])
DRCd86e4d92010-02-16 22:40:26 +000032VERSION_SCRIPT=no
33LDVER=`$LD --help </dev/null 2>&1 | grep "\-\-version-script"`
DRC6f8c6682010-02-16 05:03:51 +000034if test "$LDVER"; then
35 VERSION_SCRIPT=yes
DRCd86e4d92010-02-16 22:40:26 +000036 VERSION_SCRIPT_FLAG=-Wl,--version-script,
DRC6f8c6682010-02-16 05:03:51 +000037 AC_MSG_RESULT(yes)
38else
DRCd86e4d92010-02-16 22:40:26 +000039 LDVER=`$LD --help </dev/null 2>&1 | grep "\-M"`
40 if test "$LDVER"; then
41 VERSION_SCRIPT=yes
42 VERSION_SCRIPT_FLAG=-Wl,-M,
43 AC_MSG_RESULT(yes)
44 else
45 AC_MSG_RESULT(no)
46 fi
DRC6f8c6682010-02-16 05:03:51 +000047fi
DRCd86e4d92010-02-16 22:40:26 +000048
DRC6f8c6682010-02-16 05:03:51 +000049AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
DRCd86e4d92010-02-16 22:40:26 +000050AC_SUBST(VERSION_SCRIPT_FLAG)
DRC6f8c6682010-02-16 05:03:51 +000051
DRCe7b699d2010-02-14 07:39:07 +000052if test "x${GCC}" = "xyes"; then
53 if test "x${SAVED_CFLAGS}" = "x"; then
54 CFLAGS=-O3
55 fi
56 if test "x${SAVED_CXXFLAGS}" = "x"; then
57 CXXFLAGS=-O3
58 fi
59fi
60
DRC1e2f2982010-02-16 22:35:25 +000061AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
62if test "x${SUNCC}" = "xyes"; then
63 if test "x${SAVED_CFLAGS}" = "x"; then
64 CFLAGS=-xO5
65 fi
66 if test "x${SAVED_CXXFLAGS}" = "x"; then
67 CXXFLAGS=-xO5
68 fi
69fi
70
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000071# Checks for libraries.
72
73# Checks for header files.
74AC_HEADER_STDC
75AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
76AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
77
78# Checks for typedefs, structures, and compiler characteristics.
79AC_C_CONST
80AC_C_CHAR_UNSIGNED
81AC_C_INLINE
82AC_TYPE_SIZE_T
83AC_CHECK_TYPES([unsigned char, unsigned short])
84
85AC_MSG_CHECKING([if right shift is signed])
86AC_TRY_RUN(
87 [#include <stdio.h>
88 int is_shifting_signed (long arg) {
89 long res = arg >> 4;
90
91 if (res == -0x7F7E80CL)
92 return 1; /* right shift is signed */
93
94 /* see if unsigned-shift hack will fix it. */
95 /* we can't just test exact value since it depends on width of long... */
96 res |= (~0L) << (32-4);
97 if (res == -0x7F7E80CL)
98 return 0; /* right shift is unsigned */
99
100 printf("Right shift isn't acting as I expect it to.\n");
101 printf("I fear the JPEG software will not work at all.\n\n");
102 return 0; /* try it with unsigned anyway */
103 }
104 int main (void) {
105 exit(is_shifting_signed(-0x7F7E80B1L));
106 }],
107 [AC_MSG_RESULT(no)
108 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
109 [AC_MSG_RESULT(yes)],
110 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
111
112# test whether global names are unique to at least 15 chars
113AC_MSG_CHECKING([for short external names])
114AC_TRY_LINK(
115 [int possibly_duplicate_function () { return 0; }
116 int possibly_dupli_function () { return 1; }], [ ],
117 [AC_MSG_RESULT(ok)],
118 [AC_MSG_RESULT(short)
119 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
120
121# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000122AC_CHECK_FUNCS([memset memcpy], [],
123 [AC_DEFINE([NEED_BSD_STRINGS], 1,
124 [Define if you have BSD-like bzero and bcopy])])
125
Pierre Ossman2ae181c2009-03-09 13:21:27 +0000126# Set flags to indicate platform
127case "$host_os" in
128 cygwin* | mingw* | pw32* | interix*)
129 is_win32=1
130 ;;
131esac
132AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
133
DRC1f80a102010-10-18 00:15:31 +0000134AC_MSG_CHECKING([libjpeg API version])
135AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
136if test "x$JPEG_LIB_VERSION" = "x"; then
137 AC_ARG_WITH([jpeg7],
138 AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
139 AC_ARG_WITH([jpeg8],
140 AC_HELP_STRING([--with-jpeg8], [Emulate libjpeg v8b API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
141 if test "x${with_jpeg8}" = "xyes"; then
142 JPEG_LIB_VERSION=80
DRC36a6eec2010-10-08 08:05:44 +0000143 else
DRC1f80a102010-10-18 00:15:31 +0000144 if test "x${with_jpeg7}" = "xyes"; then
145 JPEG_LIB_VERSION=70
146 else
147 JPEG_LIB_VERSION=62
148 fi
DRC36a6eec2010-10-08 08:05:44 +0000149 fi
150fi
DRC1f80a102010-10-18 00:15:31 +0000151JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
152AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
153AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION], [libjpeg API version])
154
155AC_MSG_CHECKING([libjpeg shared library version])
156AC_ARG_VAR(SO_MAJOR_VERSION, [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
157AC_ARG_VAR(SO_MINOR_VERSION, [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
158if test "x$SO_MAJOR_VERSION" = "x"; then
159 case "$JPEG_LIB_VERSION" in
160 62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
161 *) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
162 esac
163fi
164if test "x$SO_MINOR_VERSION" = "x"; then
165 case "$JPEG_LIB_VERSION" in
166 80) SO_MINOR_VERSION=2 ;;
167 *) SO_MINOR_VERSION=0 ;;
168 esac
169fi
170AC_MSG_RESULT([$SO_MAJOR_VERSION:$SO_MINOR_VERSION])
171AC_SUBST(SO_MAJOR_VERSION)
172AC_SUBST(SO_MINOR_VERSION)
DRC36a6eec2010-10-08 08:05:44 +0000173
DRC60cddeb2010-02-12 05:37:07 +0000174# SIMD is optional
175AC_ARG_WITH([simd],
176 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
177if test "x${with_simd}" != "xno"; then
178 # Check if we're on a supported CPU
179 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
180 case "$host_cpu" in
DRC49597872010-05-17 20:47:57 +0000181 x86_64 | amd64)
DRC60cddeb2010-02-12 05:37:07 +0000182 AC_MSG_RESULT([yes (x86_64)])
183 AC_PROG_NASM
184 simd_arch=x86_64
185 ;;
186 i*86 | x86 | ia32)
187 AC_MSG_RESULT([yes (i386)])
188 AC_PROG_NASM
189 simd_arch=i386
190 ;;
191 *)
192 AC_MSG_RESULT([no ("$host_cpu")])
DRC83f21442010-06-10 18:52:41 +0000193 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
194 with_simd=no;
DRC60cddeb2010-02-12 05:37:07 +0000195 ;;
196 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000197
DRC60cddeb2010-02-12 05:37:07 +0000198 if test "x${with_simd}" != "xno"; then
199 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
200 fi
201fi
DRC411dcf52010-02-12 04:28:29 +0000202
DRC60cddeb2010-02-12 05:37:07 +0000203AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000204AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
205AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC49597872010-05-17 20:47:57 +0000206AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000207
DRC079b4342010-02-15 11:32:23 +0000208case "$host_cpu" in
209 x86_64)
210 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000211 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000212 ;;
213 i*86 | x86 | ia32)
214 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000215 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000216 ;;
217esac
218
219AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000220AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000221AC_SUBST(BUILD)
DRC2cdd2ae2010-10-10 06:54:21 +0000222AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
DRC079b4342010-02-15 11:32:23 +0000223
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000224# jconfig.h is the file we use, but we have another before that to
225# fool autoheader. the reason is that we include this header in our
226# API headers, which can screw things up for users of the lib.
227# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000228AC_CONFIG_HEADERS([config.h])
229AC_CONFIG_HEADERS([jconfig.h])
DRC1f80a102010-10-18 00:15:31 +0000230AC_CONFIG_FILES([libjpeg-turbo.spec:release/libjpeg-turbo.spec.in])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000231AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000232AC_OUTPUT