blob: 0a4cf5cc3a43dac4750202c2fe23d06a6040a70a [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])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00009
10AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
11
12# Always build with prototypes
13AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
14# Don't use undefined types
15AC_DEFINE([INCOMPLETE_TYPES_BROKEN], 1, [Define if you want use complete types])
16
17# Checks for programs.
DRCe7b699d2010-02-14 07:39:07 +000018SAVED_CFLAGS=${CFLAGS}
19SAVED_CXXFLAGS=${CXXFLAGS}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000020AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000021AC_PROG_CC
Adam Tkac6e075fc2009-04-03 14:47:50 +000022AC_PROG_CXX
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000023AC_PROG_INSTALL
24AC_PROG_LIBTOOL
25AC_PROG_LN_S
26
DRCe7b699d2010-02-14 07:39:07 +000027if test "x${GCC}" = "xyes"; then
28 if test "x${SAVED_CFLAGS}" = "x"; then
29 CFLAGS=-O3
30 fi
31 if test "x${SAVED_CXXFLAGS}" = "x"; then
32 CXXFLAGS=-O3
33 fi
34fi
35
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000036# Checks for libraries.
37
38# Checks for header files.
39AC_HEADER_STDC
40AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
41AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
42
43# Checks for typedefs, structures, and compiler characteristics.
44AC_C_CONST
45AC_C_CHAR_UNSIGNED
46AC_C_INLINE
47AC_TYPE_SIZE_T
48AC_CHECK_TYPES([unsigned char, unsigned short])
49
50AC_MSG_CHECKING([if right shift is signed])
51AC_TRY_RUN(
52 [#include <stdio.h>
53 int is_shifting_signed (long arg) {
54 long res = arg >> 4;
55
56 if (res == -0x7F7E80CL)
57 return 1; /* right shift is signed */
58
59 /* see if unsigned-shift hack will fix it. */
60 /* we can't just test exact value since it depends on width of long... */
61 res |= (~0L) << (32-4);
62 if (res == -0x7F7E80CL)
63 return 0; /* right shift is unsigned */
64
65 printf("Right shift isn't acting as I expect it to.\n");
66 printf("I fear the JPEG software will not work at all.\n\n");
67 return 0; /* try it with unsigned anyway */
68 }
69 int main (void) {
70 exit(is_shifting_signed(-0x7F7E80B1L));
71 }],
72 [AC_MSG_RESULT(no)
73 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
74 [AC_MSG_RESULT(yes)],
75 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
76
77# test whether global names are unique to at least 15 chars
78AC_MSG_CHECKING([for short external names])
79AC_TRY_LINK(
80 [int possibly_duplicate_function () { return 0; }
81 int possibly_dupli_function () { return 1; }], [ ],
82 [AC_MSG_RESULT(ok)],
83 [AC_MSG_RESULT(short)
84 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
85
86# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000087AC_CHECK_FUNCS([memset memcpy], [],
88 [AC_DEFINE([NEED_BSD_STRINGS], 1,
89 [Define if you have BSD-like bzero and bcopy])])
90
Pierre Ossman2ae181c2009-03-09 13:21:27 +000091# Set flags to indicate platform
92case "$host_os" in
93 cygwin* | mingw* | pw32* | interix*)
94 is_win32=1
95 ;;
96esac
97AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
98
DRC60cddeb2010-02-12 05:37:07 +000099# SIMD is optional
100AC_ARG_WITH([simd],
101 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
102if test "x${with_simd}" != "xno"; then
103 # Check if we're on a supported CPU
104 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
105 case "$host_cpu" in
106 x86_64)
107 AC_MSG_RESULT([yes (x86_64)])
108 AC_PROG_NASM
109 simd_arch=x86_64
110 ;;
111 i*86 | x86 | ia32)
112 AC_MSG_RESULT([yes (i386)])
113 AC_PROG_NASM
114 simd_arch=i386
115 ;;
116 *)
117 AC_MSG_RESULT([no ("$host_cpu")])
118 AC_MSG_ERROR([CPU is not supported])
119 ;;
120 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000121
DRC60cddeb2010-02-12 05:37:07 +0000122 if test "x${with_simd}" != "xno"; then
123 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
124 fi
125fi
DRC411dcf52010-02-12 04:28:29 +0000126
DRC60cddeb2010-02-12 05:37:07 +0000127AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000128AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
129AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000130
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000131# jconfig.h is the file we use, but we have another before that to
132# fool autoheader. the reason is that we include this header in our
133# API headers, which can screw things up for users of the lib.
134# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000135AC_CONFIG_HEADERS([config.h])
136AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000137AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000138AC_OUTPUT