blob: dc0a9deeb475fbb8a99493f4cebb859cf322d488 [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])
DRC86d8c0a2010-04-20 18:12:38 +00005AC_INIT([libjpeg-turbo], [0.0.93])
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])
13# Don't use undefined types
14AC_DEFINE([INCOMPLETE_TYPES_BROKEN], 1, [Define if you want use complete types])
15
16# Checks for programs.
DRCe7b699d2010-02-14 07:39:07 +000017SAVED_CFLAGS=${CFLAGS}
18SAVED_CXXFLAGS=${CXXFLAGS}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000019AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000020AC_PROG_CC
Adam Tkac6e075fc2009-04-03 14:47:50 +000021AC_PROG_CXX
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000022AC_PROG_INSTALL
23AC_PROG_LIBTOOL
24AC_PROG_LN_S
25
DRC6f8c6682010-02-16 05:03:51 +000026AC_MSG_CHECKING([whether the linker supports version scripts])
DRCd86e4d92010-02-16 22:40:26 +000027VERSION_SCRIPT=no
28LDVER=`$LD --help </dev/null 2>&1 | grep "\-\-version-script"`
DRC6f8c6682010-02-16 05:03:51 +000029if test "$LDVER"; then
30 VERSION_SCRIPT=yes
DRCd86e4d92010-02-16 22:40:26 +000031 VERSION_SCRIPT_FLAG=-Wl,--version-script,
DRC6f8c6682010-02-16 05:03:51 +000032 AC_MSG_RESULT(yes)
33else
DRCd86e4d92010-02-16 22:40:26 +000034 LDVER=`$LD --help </dev/null 2>&1 | grep "\-M"`
35 if test "$LDVER"; then
36 VERSION_SCRIPT=yes
37 VERSION_SCRIPT_FLAG=-Wl,-M,
38 AC_MSG_RESULT(yes)
39 else
40 AC_MSG_RESULT(no)
41 fi
DRC6f8c6682010-02-16 05:03:51 +000042fi
DRCd86e4d92010-02-16 22:40:26 +000043
DRC6f8c6682010-02-16 05:03:51 +000044AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
DRCd86e4d92010-02-16 22:40:26 +000045AC_SUBST(VERSION_SCRIPT_FLAG)
DRC6f8c6682010-02-16 05:03:51 +000046
DRCe7b699d2010-02-14 07:39:07 +000047if test "x${GCC}" = "xyes"; then
48 if test "x${SAVED_CFLAGS}" = "x"; then
49 CFLAGS=-O3
50 fi
51 if test "x${SAVED_CXXFLAGS}" = "x"; then
52 CXXFLAGS=-O3
53 fi
54fi
55
DRC1e2f2982010-02-16 22:35:25 +000056AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
57if test "x${SUNCC}" = "xyes"; then
58 if test "x${SAVED_CFLAGS}" = "x"; then
59 CFLAGS=-xO5
60 fi
61 if test "x${SAVED_CXXFLAGS}" = "x"; then
62 CXXFLAGS=-xO5
63 fi
64fi
65
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000066# Checks for libraries.
67
68# Checks for header files.
69AC_HEADER_STDC
70AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
71AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
72
73# Checks for typedefs, structures, and compiler characteristics.
74AC_C_CONST
75AC_C_CHAR_UNSIGNED
76AC_C_INLINE
77AC_TYPE_SIZE_T
78AC_CHECK_TYPES([unsigned char, unsigned short])
79
80AC_MSG_CHECKING([if right shift is signed])
81AC_TRY_RUN(
82 [#include <stdio.h>
83 int is_shifting_signed (long arg) {
84 long res = arg >> 4;
85
86 if (res == -0x7F7E80CL)
87 return 1; /* right shift is signed */
88
89 /* see if unsigned-shift hack will fix it. */
90 /* we can't just test exact value since it depends on width of long... */
91 res |= (~0L) << (32-4);
92 if (res == -0x7F7E80CL)
93 return 0; /* right shift is unsigned */
94
95 printf("Right shift isn't acting as I expect it to.\n");
96 printf("I fear the JPEG software will not work at all.\n\n");
97 return 0; /* try it with unsigned anyway */
98 }
99 int main (void) {
100 exit(is_shifting_signed(-0x7F7E80B1L));
101 }],
102 [AC_MSG_RESULT(no)
103 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
104 [AC_MSG_RESULT(yes)],
105 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
106
107# test whether global names are unique to at least 15 chars
108AC_MSG_CHECKING([for short external names])
109AC_TRY_LINK(
110 [int possibly_duplicate_function () { return 0; }
111 int possibly_dupli_function () { return 1; }], [ ],
112 [AC_MSG_RESULT(ok)],
113 [AC_MSG_RESULT(short)
114 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
115
116# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000117AC_CHECK_FUNCS([memset memcpy], [],
118 [AC_DEFINE([NEED_BSD_STRINGS], 1,
119 [Define if you have BSD-like bzero and bcopy])])
120
Pierre Ossman2ae181c2009-03-09 13:21:27 +0000121# Set flags to indicate platform
122case "$host_os" in
123 cygwin* | mingw* | pw32* | interix*)
124 is_win32=1
125 ;;
126esac
127AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
128
DRC60cddeb2010-02-12 05:37:07 +0000129# SIMD is optional
130AC_ARG_WITH([simd],
131 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
132if test "x${with_simd}" != "xno"; then
133 # Check if we're on a supported CPU
134 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
135 case "$host_cpu" in
DRC49597872010-05-17 20:47:57 +0000136 x86_64 | amd64)
DRC60cddeb2010-02-12 05:37:07 +0000137 AC_MSG_RESULT([yes (x86_64)])
138 AC_PROG_NASM
139 simd_arch=x86_64
140 ;;
141 i*86 | x86 | ia32)
142 AC_MSG_RESULT([yes (i386)])
143 AC_PROG_NASM
144 simd_arch=i386
145 ;;
146 *)
147 AC_MSG_RESULT([no ("$host_cpu")])
148 AC_MSG_ERROR([CPU is not supported])
149 ;;
150 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000151
DRC60cddeb2010-02-12 05:37:07 +0000152 if test "x${with_simd}" != "xno"; then
153 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
154 fi
155fi
DRC411dcf52010-02-12 04:28:29 +0000156
DRC60cddeb2010-02-12 05:37:07 +0000157AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000158AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
159AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC49597872010-05-17 20:47:57 +0000160AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000161
DRC079b4342010-02-15 11:32:23 +0000162case "$host_cpu" in
163 x86_64)
164 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000165 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000166 ;;
167 i*86 | x86 | ia32)
168 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000169 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000170 ;;
171esac
172
173AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000174AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000175AC_SUBST(BUILD)
DRC991c2fc2010-05-17 20:42:51 +0000176AC_SUBST(RM)
DRC079b4342010-02-15 11:32:23 +0000177
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000178# jconfig.h is the file we use, but we have another before that to
179# fool autoheader. the reason is that we include this header in our
180# API headers, which can screw things up for users of the lib.
181# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000182AC_CONFIG_HEADERS([config.h])
183AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000184AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000185AC_OUTPUT