blob: 1b4917d7bdb38bb2aa04f9d5cece1cca3e382c46 [file] [log] [blame]
Adam Tkac251cf672008-04-03 13:29:28 +00001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
DRCe338bf82010-02-14 02:09:03 +00004AC_PREREQ([2.56])
DRC64add652010-04-23 15:53:16 +00005AC_INIT([libjpeg-turbo], [0.0.93])
Adam Tkac251cf672008-04-03 13:29:28 +00006
7AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
8
9# Always build with prototypes
10AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
11# Don't use undefined types
12AC_DEFINE([INCOMPLETE_TYPES_BROKEN], 1, [Define if you want use complete types])
13
14# Checks for programs.
DRC589901b2010-02-14 07:59:44 +000015SAVED_CFLAGS=${CFLAGS}
16SAVED_CXXFLAGS=${CXXFLAGS}
Pierre Ossman82c7f312009-03-09 13:21:27 +000017AC_PROG_CPP
Adam Tkac251cf672008-04-03 13:29:28 +000018AC_PROG_CC
Adam Tkac4b0794d2009-04-03 14:47:50 +000019AC_PROG_CXX
Adam Tkac251cf672008-04-03 13:29:28 +000020AC_PROG_INSTALL
21AC_PROG_LIBTOOL
22AC_PROG_LN_S
23
DRC589901b2010-02-14 07:59:44 +000024if test "x${GCC}" = "xyes"; then
25 if test "x${SAVED_CFLAGS}" = "x"; then
26 CFLAGS=-O3
27 fi
28 if test "x${SAVED_CXXFLAGS}" = "x"; then
29 CXXFLAGS=-O3
30 fi
31fi
32
DRCeb4a2462010-02-16 23:27:41 +000033AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
34if test "x${SUNCC}" = "xyes"; then
35 if test "x${SAVED_CFLAGS}" = "x"; then
36 CFLAGS=-xO5
37 fi
38 if test "x${SAVED_CXXFLAGS}" = "x"; then
39 CXXFLAGS=-xO5
40 fi
41fi
42
Adam Tkac251cf672008-04-03 13:29:28 +000043# Checks for libraries.
44
45# Checks for header files.
46AC_HEADER_STDC
47AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
48AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
49
50# Checks for typedefs, structures, and compiler characteristics.
51AC_C_CONST
52AC_C_CHAR_UNSIGNED
53AC_C_INLINE
54AC_TYPE_SIZE_T
55AC_CHECK_TYPES([unsigned char, unsigned short])
56
57AC_MSG_CHECKING([if right shift is signed])
58AC_TRY_RUN(
59 [#include <stdio.h>
60 int is_shifting_signed (long arg) {
61 long res = arg >> 4;
62
63 if (res == -0x7F7E80CL)
64 return 1; /* right shift is signed */
65
66 /* see if unsigned-shift hack will fix it. */
67 /* we can't just test exact value since it depends on width of long... */
68 res |= (~0L) << (32-4);
69 if (res == -0x7F7E80CL)
70 return 0; /* right shift is unsigned */
71
72 printf("Right shift isn't acting as I expect it to.\n");
73 printf("I fear the JPEG software will not work at all.\n\n");
74 return 0; /* try it with unsigned anyway */
75 }
76 int main (void) {
77 exit(is_shifting_signed(-0x7F7E80B1L));
78 }],
79 [AC_MSG_RESULT(no)
80 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
81 [AC_MSG_RESULT(yes)],
82 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
83
84# test whether global names are unique to at least 15 chars
85AC_MSG_CHECKING([for short external names])
86AC_TRY_LINK(
87 [int possibly_duplicate_function () { return 0; }
88 int possibly_dupli_function () { return 1; }], [ ],
89 [AC_MSG_RESULT(ok)],
90 [AC_MSG_RESULT(short)
91 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
92
93# Checks for library functions.
Adam Tkac251cf672008-04-03 13:29:28 +000094AC_CHECK_FUNCS([memset memcpy], [],
95 [AC_DEFINE([NEED_BSD_STRINGS], 1,
96 [Define if you have BSD-like bzero and bcopy])])
97
Pierre Ossman82c7f312009-03-09 13:21:27 +000098# Set flags to indicate platform
99case "$host_os" in
100 cygwin* | mingw* | pw32* | interix*)
101 is_win32=1
102 ;;
103esac
104AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
105
Pierre Ossman9ad52342009-03-09 13:15:56 +0000106# SIMD is optional
Pierre Ossman9ad52342009-03-09 13:15:56 +0000107AC_ARG_WITH([simd],
Pierre Ossman82c7f312009-03-09 13:21:27 +0000108 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
Pierre Ossman9ad52342009-03-09 13:15:56 +0000109if test "x${with_simd}" != "xno"; then
Pierre Ossman82c7f312009-03-09 13:21:27 +0000110 # Check if we're on a supported CPU
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000111 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
Pierre Ossman82c7f312009-03-09 13:21:27 +0000112 case "$host_cpu" in
DRC50469f92010-05-17 20:57:48 +0000113 x86_64 | amd64)
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000114 AC_MSG_RESULT([yes (x86_64)])
DRC64add652010-04-23 15:53:16 +0000115 AC_PROG_NASM
116 simd_arch=x86_64
DRC246c3d92009-06-25 20:38:31 +0000117 ;;
Pierre Ossman82c7f312009-03-09 13:21:27 +0000118 i*86 | x86 | ia32)
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000119 AC_MSG_RESULT([yes (i386)])
Pierre Ossman82c7f312009-03-09 13:21:27 +0000120 AC_PROG_NASM
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000121 simd_arch=i386
Pierre Ossman82c7f312009-03-09 13:21:27 +0000122 ;;
123 *)
124 AC_MSG_RESULT([no ("$host_cpu")])
125 with_simd=no
126 ;;
127 esac
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000128
129 if test "x${with_simd}" != "xno"; then
130 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
131 fi
Pierre Ossman9ad52342009-03-09 13:15:56 +0000132fi
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000133
Pierre Ossman82c7f312009-03-09 13:21:27 +0000134AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000135AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
136AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
Pierre Ossman9ad52342009-03-09 13:15:56 +0000137
Pierre Ossmand678fb32009-03-06 15:30:42 +0000138# jconfig.h is the file we use, but we have another before that to
139# fool autoheader. the reason is that we include this header in our
140# API headers, which can screw things up for users of the lib.
141# jconfig.h is a minimal version that allows this package to be built
Adam Tkac8a2c8112008-04-14 13:11:58 +0000142AC_CONFIG_HEADERS([config.h])
143AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman39170cf2009-03-16 13:34:18 +0000144AC_CONFIG_FILES([Makefile simd/Makefile])
Adam Tkac251cf672008-04-03 13:29:28 +0000145AC_OUTPUT