blob: 2b6a87edf98542e225a8eb5420373941a97003ac [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])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00005AC_INIT([libjpeg], [6.b])
6
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.
Pierre Ossman2ae181c2009-03-09 13:21:27 +000015AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000016AC_PROG_CC
Adam Tkac6e075fc2009-04-03 14:47:50 +000017AC_PROG_CXX
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000018AC_PROG_INSTALL
19AC_PROG_LIBTOOL
20AC_PROG_LN_S
21
22# Checks for libraries.
23
24# Checks for header files.
25AC_HEADER_STDC
26AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
27AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
28
29# Checks for typedefs, structures, and compiler characteristics.
30AC_C_CONST
31AC_C_CHAR_UNSIGNED
32AC_C_INLINE
33AC_TYPE_SIZE_T
34AC_CHECK_TYPES([unsigned char, unsigned short])
35
36AC_MSG_CHECKING([if right shift is signed])
37AC_TRY_RUN(
38 [#include <stdio.h>
39 int is_shifting_signed (long arg) {
40 long res = arg >> 4;
41
42 if (res == -0x7F7E80CL)
43 return 1; /* right shift is signed */
44
45 /* see if unsigned-shift hack will fix it. */
46 /* we can't just test exact value since it depends on width of long... */
47 res |= (~0L) << (32-4);
48 if (res == -0x7F7E80CL)
49 return 0; /* right shift is unsigned */
50
51 printf("Right shift isn't acting as I expect it to.\n");
52 printf("I fear the JPEG software will not work at all.\n\n");
53 return 0; /* try it with unsigned anyway */
54 }
55 int main (void) {
56 exit(is_shifting_signed(-0x7F7E80B1L));
57 }],
58 [AC_MSG_RESULT(no)
59 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
60 [AC_MSG_RESULT(yes)],
61 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
62
63# test whether global names are unique to at least 15 chars
64AC_MSG_CHECKING([for short external names])
65AC_TRY_LINK(
66 [int possibly_duplicate_function () { return 0; }
67 int possibly_dupli_function () { return 1; }], [ ],
68 [AC_MSG_RESULT(ok)],
69 [AC_MSG_RESULT(short)
70 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
71
72# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000073AC_CHECK_FUNCS([memset memcpy], [],
74 [AC_DEFINE([NEED_BSD_STRINGS], 1,
75 [Define if you have BSD-like bzero and bcopy])])
76
Pierre Ossman2ae181c2009-03-09 13:21:27 +000077# Set flags to indicate platform
78case "$host_os" in
79 cygwin* | mingw* | pw32* | interix*)
80 is_win32=1
81 ;;
82esac
83AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
84
DRC60cddeb2010-02-12 05:37:07 +000085# SIMD is optional
86AC_ARG_WITH([simd],
87 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
88if test "x${with_simd}" != "xno"; then
89 # Check if we're on a supported CPU
90 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
91 case "$host_cpu" in
92 x86_64)
93 AC_MSG_RESULT([yes (x86_64)])
94 AC_PROG_NASM
95 simd_arch=x86_64
96 ;;
97 i*86 | x86 | ia32)
98 AC_MSG_RESULT([yes (i386)])
99 AC_PROG_NASM
100 simd_arch=i386
101 ;;
102 *)
103 AC_MSG_RESULT([no ("$host_cpu")])
104 AC_MSG_ERROR([CPU is not supported])
105 ;;
106 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000107
DRC60cddeb2010-02-12 05:37:07 +0000108 if test "x${with_simd}" != "xno"; then
109 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
110 fi
111fi
DRC411dcf52010-02-12 04:28:29 +0000112
DRC60cddeb2010-02-12 05:37:07 +0000113AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000114AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
115AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000116
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000117# jconfig.h is the file we use, but we have another before that to
118# fool autoheader. the reason is that we include this header in our
119# API headers, which can screw things up for users of the lib.
120# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000121AC_CONFIG_HEADERS([config.h])
122AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000123AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000124AC_OUTPUT