blob: 7bf1ee66fa0cfed9c3b4a4ebcde9b5477466d21e [file] [log] [blame]
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
DRCec84a6b2010-02-15 11:05:53 +00004echo prefix=$prefix
5echo libdir=$libdir
6
DRCbf0fab92010-02-12 22:22:01 +00007AC_PREREQ([2.56])
DRCec84a6b2010-02-15 11:05:53 +00008AC_INIT([libjpeg-turbo], [0.0.90])
DRC079b4342010-02-15 11:32:23 +00009BUILD=`date +%Y%m%d`
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000010
11AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
DRC8ff1f252010-02-15 11:08:57 +000012AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000013
14# Always build with prototypes
15AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
16# Don't use undefined types
17AC_DEFINE([INCOMPLETE_TYPES_BROKEN], 1, [Define if you want use complete types])
18
19# Checks for programs.
DRCe7b699d2010-02-14 07:39:07 +000020SAVED_CFLAGS=${CFLAGS}
21SAVED_CXXFLAGS=${CXXFLAGS}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000022AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000023AC_PROG_CC
Adam Tkac6e075fc2009-04-03 14:47:50 +000024AC_PROG_CXX
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000025AC_PROG_INSTALL
26AC_PROG_LIBTOOL
27AC_PROG_LN_S
28
DRC6f8c6682010-02-16 05:03:51 +000029AC_MSG_CHECKING([whether the linker supports version scripts])
30LDVER=`$LD --help < /dev/null 2>/dev/null | grep version-script`
31if test "$LDVER"; then
32 VERSION_SCRIPT=yes
33 AC_MSG_RESULT(yes)
34else
35 VERSION_SCRIPT=no
36 AC_MSG_RESULT(no)
37fi
38AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
39
DRCe7b699d2010-02-14 07:39:07 +000040if test "x${GCC}" = "xyes"; then
41 if test "x${SAVED_CFLAGS}" = "x"; then
42 CFLAGS=-O3
43 fi
44 if test "x${SAVED_CXXFLAGS}" = "x"; then
45 CXXFLAGS=-O3
46 fi
47fi
48
DRC1e2f2982010-02-16 22:35:25 +000049AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
50if test "x${SUNCC}" = "xyes"; then
51 if test "x${SAVED_CFLAGS}" = "x"; then
52 CFLAGS=-xO5
53 fi
54 if test "x${SAVED_CXXFLAGS}" = "x"; then
55 CXXFLAGS=-xO5
56 fi
57fi
58
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000059# Checks for libraries.
60
61# Checks for header files.
62AC_HEADER_STDC
63AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
64AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
65
66# Checks for typedefs, structures, and compiler characteristics.
67AC_C_CONST
68AC_C_CHAR_UNSIGNED
69AC_C_INLINE
70AC_TYPE_SIZE_T
71AC_CHECK_TYPES([unsigned char, unsigned short])
72
73AC_MSG_CHECKING([if right shift is signed])
74AC_TRY_RUN(
75 [#include <stdio.h>
76 int is_shifting_signed (long arg) {
77 long res = arg >> 4;
78
79 if (res == -0x7F7E80CL)
80 return 1; /* right shift is signed */
81
82 /* see if unsigned-shift hack will fix it. */
83 /* we can't just test exact value since it depends on width of long... */
84 res |= (~0L) << (32-4);
85 if (res == -0x7F7E80CL)
86 return 0; /* right shift is unsigned */
87
88 printf("Right shift isn't acting as I expect it to.\n");
89 printf("I fear the JPEG software will not work at all.\n\n");
90 return 0; /* try it with unsigned anyway */
91 }
92 int main (void) {
93 exit(is_shifting_signed(-0x7F7E80B1L));
94 }],
95 [AC_MSG_RESULT(no)
96 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
97 [AC_MSG_RESULT(yes)],
98 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
99
100# test whether global names are unique to at least 15 chars
101AC_MSG_CHECKING([for short external names])
102AC_TRY_LINK(
103 [int possibly_duplicate_function () { return 0; }
104 int possibly_dupli_function () { return 1; }], [ ],
105 [AC_MSG_RESULT(ok)],
106 [AC_MSG_RESULT(short)
107 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
108
109# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000110AC_CHECK_FUNCS([memset memcpy], [],
111 [AC_DEFINE([NEED_BSD_STRINGS], 1,
112 [Define if you have BSD-like bzero and bcopy])])
113
Pierre Ossman2ae181c2009-03-09 13:21:27 +0000114# Set flags to indicate platform
115case "$host_os" in
116 cygwin* | mingw* | pw32* | interix*)
117 is_win32=1
118 ;;
119esac
120AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
121
DRC60cddeb2010-02-12 05:37:07 +0000122# SIMD is optional
123AC_ARG_WITH([simd],
124 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
125if test "x${with_simd}" != "xno"; then
126 # Check if we're on a supported CPU
127 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
128 case "$host_cpu" in
129 x86_64)
130 AC_MSG_RESULT([yes (x86_64)])
131 AC_PROG_NASM
132 simd_arch=x86_64
133 ;;
134 i*86 | x86 | ia32)
135 AC_MSG_RESULT([yes (i386)])
136 AC_PROG_NASM
137 simd_arch=i386
138 ;;
139 *)
140 AC_MSG_RESULT([no ("$host_cpu")])
141 AC_MSG_ERROR([CPU is not supported])
142 ;;
143 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000144
DRC60cddeb2010-02-12 05:37:07 +0000145 if test "x${with_simd}" != "xno"; then
146 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
147 fi
148fi
DRC411dcf52010-02-12 04:28:29 +0000149
DRC60cddeb2010-02-12 05:37:07 +0000150AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000151AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
152AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC315123f2010-02-15 16:14:26 +0000153AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000154
DRC079b4342010-02-15 11:32:23 +0000155case "$host_cpu" in
156 x86_64)
157 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000158 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000159 ;;
160 i*86 | x86 | ia32)
161 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000162 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000163 ;;
164esac
165
166AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000167AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000168AC_SUBST(BUILD)
169
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000170# jconfig.h is the file we use, but we have another before that to
171# fool autoheader. the reason is that we include this header in our
172# API headers, which can screw things up for users of the lib.
173# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000174AC_CONFIG_HEADERS([config.h])
175AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000176AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000177AC_OUTPUT