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