blob: a2b4f3f983530210e2222967c8f5d102573dfbdb [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])
DRCeafbe8a2010-10-08 08:07:10 +00005AC_INIT([libjpeg-turbo], [1.0.80])
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
DRC36a6eec2010-10-08 08:05:44 +0000134AC_ARG_WITH([jpeg7],
135 AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
136AC_ARG_WITH([jpeg8],
137 AC_HELP_STRING([--with-jpeg8], [Emulate libjpeg v8b API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
DRCc54275c2010-10-10 00:40:37 +0000138AC_MSG_CHECKING([libjpeg version number])
DRC36a6eec2010-10-08 08:05:44 +0000139if test "x${with_jpeg8}" == "xyes"; then
140 JPEG_LIB_VERSION=80
141 AC_DEFINE([JPEG_LIB_VERSION], [80], [Version 8.0])
DRCc54275c2010-10-10 00:40:37 +0000142 [JPEG_LIB_VERSION="`expr $JPEG_LIB_VERSION / 10`:2"]
DRC36a6eec2010-10-08 08:05:44 +0000143else
144 if test "x${with_jpeg7}" == "xyes"; then
145 JPEG_LIB_VERSION=70
146 AC_DEFINE([JPEG_LIB_VERSION], [70], [Version 7.0])
DRCc54275c2010-10-10 00:40:37 +0000147 [JPEG_LIB_VERSION="`expr $JPEG_LIB_VERSION / 10`:`expr $JPEG_LIB_VERSION % 10`"]
DRC36a6eec2010-10-08 08:05:44 +0000148 else
149 JPEG_LIB_VERSION=62
150 AC_DEFINE([JPEG_LIB_VERSION], [62], [Version 6b])
DRCc54275c2010-10-10 00:40:37 +0000151 [JPEG_LIB_VERSION="$JPEG_LIB_VERSION:0:0"]
DRC36a6eec2010-10-08 08:05:44 +0000152 fi
153fi
DRCc54275c2010-10-10 00:40:37 +0000154AC_MSG_RESULT([$JPEG_LIB_VERSION])
DRC36a6eec2010-10-08 08:05:44 +0000155AC_SUBST(JPEG_LIB_VERSION)
156
DRC60cddeb2010-02-12 05:37:07 +0000157# SIMD is optional
158AC_ARG_WITH([simd],
159 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
160if test "x${with_simd}" != "xno"; then
161 # Check if we're on a supported CPU
162 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
163 case "$host_cpu" in
DRC49597872010-05-17 20:47:57 +0000164 x86_64 | amd64)
DRC60cddeb2010-02-12 05:37:07 +0000165 AC_MSG_RESULT([yes (x86_64)])
166 AC_PROG_NASM
167 simd_arch=x86_64
168 ;;
169 i*86 | x86 | ia32)
170 AC_MSG_RESULT([yes (i386)])
171 AC_PROG_NASM
172 simd_arch=i386
173 ;;
174 *)
175 AC_MSG_RESULT([no ("$host_cpu")])
DRC83f21442010-06-10 18:52:41 +0000176 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
177 with_simd=no;
DRC60cddeb2010-02-12 05:37:07 +0000178 ;;
179 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000180
DRC60cddeb2010-02-12 05:37:07 +0000181 if test "x${with_simd}" != "xno"; then
182 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
183 fi
184fi
DRC411dcf52010-02-12 04:28:29 +0000185
DRC60cddeb2010-02-12 05:37:07 +0000186AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000187AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
188AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC49597872010-05-17 20:47:57 +0000189AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000190
DRC079b4342010-02-15 11:32:23 +0000191case "$host_cpu" in
192 x86_64)
193 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000194 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000195 ;;
196 i*86 | x86 | ia32)
197 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000198 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000199 ;;
200esac
201
202AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000203AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000204AC_SUBST(BUILD)
DRC2cdd2ae2010-10-10 06:54:21 +0000205AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
DRC079b4342010-02-15 11:32:23 +0000206
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000207# jconfig.h is the file we use, but we have another before that to
208# fool autoheader. the reason is that we include this header in our
209# API headers, which can screw things up for users of the lib.
210# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000211AC_CONFIG_HEADERS([config.h])
212AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000213AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000214AC_OUTPUT