blob: 050cebdae03c64965253abb7f59b679da7bd6aa4 [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])
DRCfc97cfe2011-02-18 05:42:10 +00005AC_INIT([libjpeg-turbo], [1.0.2])
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])
Adam Tkac251cf672008-04-03 13:29:28 +000011
12# Checks for programs.
DRC589901b2010-02-14 07:59:44 +000013SAVED_CFLAGS=${CFLAGS}
14SAVED_CXXFLAGS=${CXXFLAGS}
Pierre Ossman82c7f312009-03-09 13:21:27 +000015AC_PROG_CPP
Adam Tkac251cf672008-04-03 13:29:28 +000016AC_PROG_CC
Adam Tkac4b0794d2009-04-03 14:47:50 +000017AC_PROG_CXX
Adam Tkac251cf672008-04-03 13:29:28 +000018AC_PROG_INSTALL
19AC_PROG_LIBTOOL
20AC_PROG_LN_S
21
DRCdb18b742010-09-30 06:42:45 +000022# Check whether compiler supports pointers to undefined structures
23AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
24AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
25AC_MSG_RESULT(yes),
26[AC_MSG_RESULT(no)
27AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to undefined structures.])])
28
DRC589901b2010-02-14 07:59:44 +000029if test "x${GCC}" = "xyes"; then
30 if test "x${SAVED_CFLAGS}" = "x"; then
31 CFLAGS=-O3
32 fi
33 if test "x${SAVED_CXXFLAGS}" = "x"; then
34 CXXFLAGS=-O3
35 fi
36fi
37
DRCeb4a2462010-02-16 23:27:41 +000038AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
39if test "x${SUNCC}" = "xyes"; then
40 if test "x${SAVED_CFLAGS}" = "x"; then
41 CFLAGS=-xO5
42 fi
43 if test "x${SAVED_CXXFLAGS}" = "x"; then
44 CXXFLAGS=-xO5
45 fi
46fi
47
Adam Tkac251cf672008-04-03 13:29:28 +000048# Checks for libraries.
49
50# Checks for header files.
51AC_HEADER_STDC
52AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
53AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
54
55# Checks for typedefs, structures, and compiler characteristics.
56AC_C_CONST
57AC_C_CHAR_UNSIGNED
58AC_C_INLINE
59AC_TYPE_SIZE_T
60AC_CHECK_TYPES([unsigned char, unsigned short])
61
62AC_MSG_CHECKING([if right shift is signed])
63AC_TRY_RUN(
64 [#include <stdio.h>
65 int is_shifting_signed (long arg) {
66 long res = arg >> 4;
67
68 if (res == -0x7F7E80CL)
69 return 1; /* right shift is signed */
70
71 /* see if unsigned-shift hack will fix it. */
72 /* we can't just test exact value since it depends on width of long... */
73 res |= (~0L) << (32-4);
74 if (res == -0x7F7E80CL)
75 return 0; /* right shift is unsigned */
76
77 printf("Right shift isn't acting as I expect it to.\n");
78 printf("I fear the JPEG software will not work at all.\n\n");
79 return 0; /* try it with unsigned anyway */
80 }
81 int main (void) {
82 exit(is_shifting_signed(-0x7F7E80B1L));
83 }],
84 [AC_MSG_RESULT(no)
85 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
86 [AC_MSG_RESULT(yes)],
87 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
88
89# test whether global names are unique to at least 15 chars
90AC_MSG_CHECKING([for short external names])
91AC_TRY_LINK(
92 [int possibly_duplicate_function () { return 0; }
93 int possibly_dupli_function () { return 1; }], [ ],
94 [AC_MSG_RESULT(ok)],
95 [AC_MSG_RESULT(short)
96 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
97
98# Checks for library functions.
Adam Tkac251cf672008-04-03 13:29:28 +000099AC_CHECK_FUNCS([memset memcpy], [],
100 [AC_DEFINE([NEED_BSD_STRINGS], 1,
101 [Define if you have BSD-like bzero and bcopy])])
102
Pierre Ossman82c7f312009-03-09 13:21:27 +0000103# Set flags to indicate platform
104case "$host_os" in
105 cygwin* | mingw* | pw32* | interix*)
106 is_win32=1
107 ;;
108esac
109AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
110
Pierre Ossman9ad52342009-03-09 13:15:56 +0000111# SIMD is optional
Pierre Ossman9ad52342009-03-09 13:15:56 +0000112AC_ARG_WITH([simd],
Pierre Ossman82c7f312009-03-09 13:21:27 +0000113 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
Pierre Ossman9ad52342009-03-09 13:15:56 +0000114if test "x${with_simd}" != "xno"; then
Pierre Ossman82c7f312009-03-09 13:21:27 +0000115 # Check if we're on a supported CPU
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000116 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
Pierre Ossman82c7f312009-03-09 13:21:27 +0000117 case "$host_cpu" in
DRC50469f92010-05-17 20:57:48 +0000118 x86_64 | amd64)
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000119 AC_MSG_RESULT([yes (x86_64)])
DRC64add652010-04-23 15:53:16 +0000120 AC_PROG_NASM
121 simd_arch=x86_64
DRC246c3d92009-06-25 20:38:31 +0000122 ;;
Pierre Ossman82c7f312009-03-09 13:21:27 +0000123 i*86 | x86 | ia32)
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000124 AC_MSG_RESULT([yes (i386)])
Pierre Ossman82c7f312009-03-09 13:21:27 +0000125 AC_PROG_NASM
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000126 simd_arch=i386
Pierre Ossman82c7f312009-03-09 13:21:27 +0000127 ;;
128 *)
129 AC_MSG_RESULT([no ("$host_cpu")])
DRCc875a0d2010-06-22 02:55:40 +0000130 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
131 with_simd=no;
Pierre Ossman82c7f312009-03-09 13:21:27 +0000132 ;;
133 esac
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000134
135 if test "x${with_simd}" != "xno"; then
136 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
137 fi
Pierre Ossman9ad52342009-03-09 13:15:56 +0000138fi
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000139
Pierre Ossman82c7f312009-03-09 13:21:27 +0000140AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000141AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
142AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
Pierre Ossman9ad52342009-03-09 13:15:56 +0000143
Pierre Ossmand678fb32009-03-06 15:30:42 +0000144# jconfig.h is the file we use, but we have another before that to
145# fool autoheader. the reason is that we include this header in our
146# API headers, which can screw things up for users of the lib.
147# jconfig.h is a minimal version that allows this package to be built
Adam Tkac8a2c8112008-04-14 13:11:58 +0000148AC_CONFIG_HEADERS([config.h])
149AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman39170cf2009-03-16 13:34:18 +0000150AC_CONFIG_FILES([Makefile simd/Makefile])
Adam Tkac251cf672008-04-03 13:29:28 +0000151AC_OUTPUT