blob: 364c579df482a063be321d36b61097a4dd7ce89f [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])
Adam Tkac251cf672008-04-03 13:29:28 +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.
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
Adam Tkac251cf672008-04-03 13:29:28 +000033# Checks for libraries.
34
35# Checks for header files.
36AC_HEADER_STDC
37AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
38AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
39
40# Checks for typedefs, structures, and compiler characteristics.
41AC_C_CONST
42AC_C_CHAR_UNSIGNED
43AC_C_INLINE
44AC_TYPE_SIZE_T
45AC_CHECK_TYPES([unsigned char, unsigned short])
46
47AC_MSG_CHECKING([if right shift is signed])
48AC_TRY_RUN(
49 [#include <stdio.h>
50 int is_shifting_signed (long arg) {
51 long res = arg >> 4;
52
53 if (res == -0x7F7E80CL)
54 return 1; /* right shift is signed */
55
56 /* see if unsigned-shift hack will fix it. */
57 /* we can't just test exact value since it depends on width of long... */
58 res |= (~0L) << (32-4);
59 if (res == -0x7F7E80CL)
60 return 0; /* right shift is unsigned */
61
62 printf("Right shift isn't acting as I expect it to.\n");
63 printf("I fear the JPEG software will not work at all.\n\n");
64 return 0; /* try it with unsigned anyway */
65 }
66 int main (void) {
67 exit(is_shifting_signed(-0x7F7E80B1L));
68 }],
69 [AC_MSG_RESULT(no)
70 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
71 [AC_MSG_RESULT(yes)],
72 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
73
74# test whether global names are unique to at least 15 chars
75AC_MSG_CHECKING([for short external names])
76AC_TRY_LINK(
77 [int possibly_duplicate_function () { return 0; }
78 int possibly_dupli_function () { return 1; }], [ ],
79 [AC_MSG_RESULT(ok)],
80 [AC_MSG_RESULT(short)
81 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
82
83# Checks for library functions.
Adam Tkac251cf672008-04-03 13:29:28 +000084AC_CHECK_FUNCS([memset memcpy], [],
85 [AC_DEFINE([NEED_BSD_STRINGS], 1,
86 [Define if you have BSD-like bzero and bcopy])])
87
Pierre Ossman82c7f312009-03-09 13:21:27 +000088# Set flags to indicate platform
89case "$host_os" in
90 cygwin* | mingw* | pw32* | interix*)
91 is_win32=1
92 ;;
93esac
94AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
95
Pierre Ossman9ad52342009-03-09 13:15:56 +000096# SIMD is optional
Pierre Ossman9ad52342009-03-09 13:15:56 +000097AC_ARG_WITH([simd],
Pierre Ossman82c7f312009-03-09 13:21:27 +000098 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
Pierre Ossman9ad52342009-03-09 13:15:56 +000099if test "x${with_simd}" != "xno"; then
Pierre Ossman82c7f312009-03-09 13:21:27 +0000100 # Check if we're on a supported CPU
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000101 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
Pierre Ossman82c7f312009-03-09 13:21:27 +0000102 case "$host_cpu" in
DRC246c3d92009-06-25 20:38:31 +0000103 x86_64)
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000104 AC_MSG_RESULT([yes (x86_64)])
DRC246c3d92009-06-25 20:38:31 +0000105 AC_PROG_NASM
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000106 simd_arch=x86_64
DRC246c3d92009-06-25 20:38:31 +0000107 ;;
Pierre Ossman82c7f312009-03-09 13:21:27 +0000108 i*86 | x86 | ia32)
Pierre Ossman8f0289b2009-06-26 14:09:47 +0000109 AC_MSG_RESULT([yes (i386)])
Pierre Ossman82c7f312009-03-09 13:21:27 +0000110 AC_PROG_NASM
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000111 simd_arch=i386
Pierre Ossman82c7f312009-03-09 13:21:27 +0000112 ;;
113 *)
114 AC_MSG_RESULT([no ("$host_cpu")])
115 with_simd=no
116 ;;
117 esac
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000118
119 if test "x${with_simd}" != "xno"; then
120 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
121 fi
Pierre Ossman9ad52342009-03-09 13:15:56 +0000122fi
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000123
Pierre Ossman82c7f312009-03-09 13:21:27 +0000124AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossman0b7301e2009-06-29 11:20:42 +0000125AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
126AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
Pierre Ossman9ad52342009-03-09 13:15:56 +0000127
Pierre Ossmand678fb32009-03-06 15:30:42 +0000128# jconfig.h is the file we use, but we have another before that to
129# fool autoheader. the reason is that we include this header in our
130# API headers, which can screw things up for users of the lib.
131# jconfig.h is a minimal version that allows this package to be built
Adam Tkac8a2c8112008-04-14 13:11:58 +0000132AC_CONFIG_HEADERS([config.h])
133AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman39170cf2009-03-16 13:34:18 +0000134AC_CONFIG_FILES([Makefile simd/Makefile])
Adam Tkac251cf672008-04-03 13:29:28 +0000135AC_OUTPUT