blob: a315e0788b613b4d8358a3d53b8d0392e11ee893 [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])
DRC079b4342010-02-15 11:32:23 +00009BUILD=`date +%Y%m%d`
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000010
11AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
DRC8ff1f252010-02-15 11:08:57 +000012AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000013
14# Always build with prototypes
15AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
16# Don't use undefined types
17AC_DEFINE([INCOMPLETE_TYPES_BROKEN], 1, [Define if you want use complete types])
18
19# Checks for programs.
DRCe7b699d2010-02-14 07:39:07 +000020SAVED_CFLAGS=${CFLAGS}
21SAVED_CXXFLAGS=${CXXFLAGS}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000022AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000023AC_PROG_CC
Adam Tkac6e075fc2009-04-03 14:47:50 +000024AC_PROG_CXX
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000025AC_PROG_INSTALL
26AC_PROG_LIBTOOL
27AC_PROG_LN_S
28
DRC6f8c6682010-02-16 05:03:51 +000029AC_MSG_CHECKING([whether the linker supports version scripts])
30LDVER=`$LD --help < /dev/null 2>/dev/null | grep version-script`
31if test "$LDVER"; then
32 VERSION_SCRIPT=yes
33 AC_MSG_RESULT(yes)
34else
35 VERSION_SCRIPT=no
36 AC_MSG_RESULT(no)
37fi
38AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
39
DRCe7b699d2010-02-14 07:39:07 +000040if test "x${GCC}" = "xyes"; then
41 if test "x${SAVED_CFLAGS}" = "x"; then
42 CFLAGS=-O3
43 fi
44 if test "x${SAVED_CXXFLAGS}" = "x"; then
45 CXXFLAGS=-O3
46 fi
47fi
48
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000049# Checks for libraries.
50
51# Checks for header files.
52AC_HEADER_STDC
53AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
54AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
55
56# Checks for typedefs, structures, and compiler characteristics.
57AC_C_CONST
58AC_C_CHAR_UNSIGNED
59AC_C_INLINE
60AC_TYPE_SIZE_T
61AC_CHECK_TYPES([unsigned char, unsigned short])
62
63AC_MSG_CHECKING([if right shift is signed])
64AC_TRY_RUN(
65 [#include <stdio.h>
66 int is_shifting_signed (long arg) {
67 long res = arg >> 4;
68
69 if (res == -0x7F7E80CL)
70 return 1; /* right shift is signed */
71
72 /* see if unsigned-shift hack will fix it. */
73 /* we can't just test exact value since it depends on width of long... */
74 res |= (~0L) << (32-4);
75 if (res == -0x7F7E80CL)
76 return 0; /* right shift is unsigned */
77
78 printf("Right shift isn't acting as I expect it to.\n");
79 printf("I fear the JPEG software will not work at all.\n\n");
80 return 0; /* try it with unsigned anyway */
81 }
82 int main (void) {
83 exit(is_shifting_signed(-0x7F7E80B1L));
84 }],
85 [AC_MSG_RESULT(no)
86 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
87 [AC_MSG_RESULT(yes)],
88 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
89
90# test whether global names are unique to at least 15 chars
91AC_MSG_CHECKING([for short external names])
92AC_TRY_LINK(
93 [int possibly_duplicate_function () { return 0; }
94 int possibly_dupli_function () { return 1; }], [ ],
95 [AC_MSG_RESULT(ok)],
96 [AC_MSG_RESULT(short)
97 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
98
99# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000100AC_CHECK_FUNCS([memset memcpy], [],
101 [AC_DEFINE([NEED_BSD_STRINGS], 1,
102 [Define if you have BSD-like bzero and bcopy])])
103
Pierre Ossman2ae181c2009-03-09 13:21:27 +0000104# Set flags to indicate platform
105case "$host_os" in
106 cygwin* | mingw* | pw32* | interix*)
107 is_win32=1
108 ;;
109esac
110AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
111
DRC60cddeb2010-02-12 05:37:07 +0000112# SIMD is optional
113AC_ARG_WITH([simd],
114 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
115if test "x${with_simd}" != "xno"; then
116 # Check if we're on a supported CPU
117 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
118 case "$host_cpu" in
119 x86_64)
120 AC_MSG_RESULT([yes (x86_64)])
121 AC_PROG_NASM
122 simd_arch=x86_64
123 ;;
124 i*86 | x86 | ia32)
125 AC_MSG_RESULT([yes (i386)])
126 AC_PROG_NASM
127 simd_arch=i386
128 ;;
129 *)
130 AC_MSG_RESULT([no ("$host_cpu")])
131 AC_MSG_ERROR([CPU is not supported])
132 ;;
133 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000134
DRC60cddeb2010-02-12 05:37:07 +0000135 if test "x${with_simd}" != "xno"; then
136 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
137 fi
138fi
DRC411dcf52010-02-12 04:28:29 +0000139
DRC60cddeb2010-02-12 05:37:07 +0000140AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-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"])
DRC315123f2010-02-15 16:14:26 +0000143AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000144
DRC079b4342010-02-15 11:32:23 +0000145case "$host_cpu" in
146 x86_64)
147 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000148 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000149 ;;
150 i*86 | x86 | ia32)
151 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000152 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000153 ;;
154esac
155
156AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000157AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000158AC_SUBST(BUILD)
159
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000160# jconfig.h is the file we use, but we have another before that to
161# fool autoheader. the reason is that we include this header in our
162# API headers, which can screw things up for users of the lib.
163# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000164AC_CONFIG_HEADERS([config.h])
165AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000166AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000167AC_OUTPUT