blob: b152a671d7a081a4c18b9e26fb84a28506f67cf1 [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])
DRCd86e4d92010-02-16 22:40:26 +000030VERSION_SCRIPT=no
31LDVER=`$LD --help </dev/null 2>&1 | grep "\-\-version-script"`
DRC6f8c6682010-02-16 05:03:51 +000032if test "$LDVER"; then
33 VERSION_SCRIPT=yes
DRCd86e4d92010-02-16 22:40:26 +000034 VERSION_SCRIPT_FLAG=-Wl,--version-script,
DRC6f8c6682010-02-16 05:03:51 +000035 AC_MSG_RESULT(yes)
36else
DRCd86e4d92010-02-16 22:40:26 +000037 LDVER=`$LD --help </dev/null 2>&1 | grep "\-M"`
38 if test "$LDVER"; then
39 VERSION_SCRIPT=yes
40 VERSION_SCRIPT_FLAG=-Wl,-M,
41 AC_MSG_RESULT(yes)
42 else
43 AC_MSG_RESULT(no)
44 fi
DRC6f8c6682010-02-16 05:03:51 +000045fi
DRCd86e4d92010-02-16 22:40:26 +000046
DRC6f8c6682010-02-16 05:03:51 +000047AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
DRCd86e4d92010-02-16 22:40:26 +000048AC_SUBST(VERSION_SCRIPT_FLAG)
DRC6f8c6682010-02-16 05:03:51 +000049
DRCe7b699d2010-02-14 07:39:07 +000050if test "x${GCC}" = "xyes"; then
51 if test "x${SAVED_CFLAGS}" = "x"; then
52 CFLAGS=-O3
53 fi
54 if test "x${SAVED_CXXFLAGS}" = "x"; then
55 CXXFLAGS=-O3
56 fi
57fi
58
DRC1e2f2982010-02-16 22:35:25 +000059AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
60if test "x${SUNCC}" = "xyes"; then
61 if test "x${SAVED_CFLAGS}" = "x"; then
62 CFLAGS=-xO5
63 fi
64 if test "x${SAVED_CXXFLAGS}" = "x"; then
65 CXXFLAGS=-xO5
66 fi
67fi
68
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000069# Checks for libraries.
70
71# Checks for header files.
72AC_HEADER_STDC
73AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
74AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
75
76# Checks for typedefs, structures, and compiler characteristics.
77AC_C_CONST
78AC_C_CHAR_UNSIGNED
79AC_C_INLINE
80AC_TYPE_SIZE_T
81AC_CHECK_TYPES([unsigned char, unsigned short])
82
83AC_MSG_CHECKING([if right shift is signed])
84AC_TRY_RUN(
85 [#include <stdio.h>
86 int is_shifting_signed (long arg) {
87 long res = arg >> 4;
88
89 if (res == -0x7F7E80CL)
90 return 1; /* right shift is signed */
91
92 /* see if unsigned-shift hack will fix it. */
93 /* we can't just test exact value since it depends on width of long... */
94 res |= (~0L) << (32-4);
95 if (res == -0x7F7E80CL)
96 return 0; /* right shift is unsigned */
97
98 printf("Right shift isn't acting as I expect it to.\n");
99 printf("I fear the JPEG software will not work at all.\n\n");
100 return 0; /* try it with unsigned anyway */
101 }
102 int main (void) {
103 exit(is_shifting_signed(-0x7F7E80B1L));
104 }],
105 [AC_MSG_RESULT(no)
106 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
107 [AC_MSG_RESULT(yes)],
108 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
109
110# test whether global names are unique to at least 15 chars
111AC_MSG_CHECKING([for short external names])
112AC_TRY_LINK(
113 [int possibly_duplicate_function () { return 0; }
114 int possibly_dupli_function () { return 1; }], [ ],
115 [AC_MSG_RESULT(ok)],
116 [AC_MSG_RESULT(short)
117 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
118
119# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000120AC_CHECK_FUNCS([memset memcpy], [],
121 [AC_DEFINE([NEED_BSD_STRINGS], 1,
122 [Define if you have BSD-like bzero and bcopy])])
123
Pierre Ossman2ae181c2009-03-09 13:21:27 +0000124# Set flags to indicate platform
125case "$host_os" in
126 cygwin* | mingw* | pw32* | interix*)
127 is_win32=1
128 ;;
129esac
130AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
131
DRC60cddeb2010-02-12 05:37:07 +0000132# SIMD is optional
133AC_ARG_WITH([simd],
134 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
135if test "x${with_simd}" != "xno"; then
136 # Check if we're on a supported CPU
137 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
138 case "$host_cpu" in
139 x86_64)
140 AC_MSG_RESULT([yes (x86_64)])
141 AC_PROG_NASM
142 simd_arch=x86_64
143 ;;
144 i*86 | x86 | ia32)
145 AC_MSG_RESULT([yes (i386)])
146 AC_PROG_NASM
147 simd_arch=i386
148 ;;
149 *)
150 AC_MSG_RESULT([no ("$host_cpu")])
151 AC_MSG_ERROR([CPU is not supported])
152 ;;
153 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000154
DRC60cddeb2010-02-12 05:37:07 +0000155 if test "x${with_simd}" != "xno"; then
156 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
157 fi
158fi
DRC411dcf52010-02-12 04:28:29 +0000159
DRC60cddeb2010-02-12 05:37:07 +0000160AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000161AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
162AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC315123f2010-02-15 16:14:26 +0000163AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000164
DRC079b4342010-02-15 11:32:23 +0000165case "$host_cpu" in
166 x86_64)
167 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000168 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000169 ;;
170 i*86 | x86 | ia32)
171 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000172 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000173 ;;
174esac
175
176AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000177AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000178AC_SUBST(BUILD)
179
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000180# jconfig.h is the file we use, but we have another before that to
181# fool autoheader. the reason is that we include this header in our
182# API headers, which can screw things up for users of the lib.
183# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000184AC_CONFIG_HEADERS([config.h])
185AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000186AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000187AC_OUTPUT