blob: 08996134c8a9eb511842f538dd7249b499630078 [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
DRCe7b699d2010-02-14 07:39:07 +000029if test "x${GCC}" = "xyes"; then
30 if test "x${SAVED_CFLAGS}" = "x"; then
31 CFLAGS=-O3
32 fi
33 if test "x${SAVED_CXXFLAGS}" = "x"; then
34 CXXFLAGS=-O3
35 fi
36fi
37
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000038# Checks for libraries.
39
40# Checks for header files.
41AC_HEADER_STDC
42AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
43AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
44
45# Checks for typedefs, structures, and compiler characteristics.
46AC_C_CONST
47AC_C_CHAR_UNSIGNED
48AC_C_INLINE
49AC_TYPE_SIZE_T
50AC_CHECK_TYPES([unsigned char, unsigned short])
51
52AC_MSG_CHECKING([if right shift is signed])
53AC_TRY_RUN(
54 [#include <stdio.h>
55 int is_shifting_signed (long arg) {
56 long res = arg >> 4;
57
58 if (res == -0x7F7E80CL)
59 return 1; /* right shift is signed */
60
61 /* see if unsigned-shift hack will fix it. */
62 /* we can't just test exact value since it depends on width of long... */
63 res |= (~0L) << (32-4);
64 if (res == -0x7F7E80CL)
65 return 0; /* right shift is unsigned */
66
67 printf("Right shift isn't acting as I expect it to.\n");
68 printf("I fear the JPEG software will not work at all.\n\n");
69 return 0; /* try it with unsigned anyway */
70 }
71 int main (void) {
72 exit(is_shifting_signed(-0x7F7E80B1L));
73 }],
74 [AC_MSG_RESULT(no)
75 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
76 [AC_MSG_RESULT(yes)],
77 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
78
79# test whether global names are unique to at least 15 chars
80AC_MSG_CHECKING([for short external names])
81AC_TRY_LINK(
82 [int possibly_duplicate_function () { return 0; }
83 int possibly_dupli_function () { return 1; }], [ ],
84 [AC_MSG_RESULT(ok)],
85 [AC_MSG_RESULT(short)
86 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
87
88# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000089AC_CHECK_FUNCS([memset memcpy], [],
90 [AC_DEFINE([NEED_BSD_STRINGS], 1,
91 [Define if you have BSD-like bzero and bcopy])])
92
Pierre Ossman2ae181c2009-03-09 13:21:27 +000093# Set flags to indicate platform
94case "$host_os" in
95 cygwin* | mingw* | pw32* | interix*)
96 is_win32=1
97 ;;
98esac
99AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
100
DRC60cddeb2010-02-12 05:37:07 +0000101# SIMD is optional
102AC_ARG_WITH([simd],
103 AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
104if test "x${with_simd}" != "xno"; then
105 # Check if we're on a supported CPU
106 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
107 case "$host_cpu" in
108 x86_64)
109 AC_MSG_RESULT([yes (x86_64)])
110 AC_PROG_NASM
111 simd_arch=x86_64
112 ;;
113 i*86 | x86 | ia32)
114 AC_MSG_RESULT([yes (i386)])
115 AC_PROG_NASM
116 simd_arch=i386
117 ;;
118 *)
119 AC_MSG_RESULT([no ("$host_cpu")])
120 AC_MSG_ERROR([CPU is not supported])
121 ;;
122 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000123
DRC60cddeb2010-02-12 05:37:07 +0000124 if test "x${with_simd}" != "xno"; then
125 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
126 fi
127fi
DRC411dcf52010-02-12 04:28:29 +0000128
DRC60cddeb2010-02-12 05:37:07 +0000129AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000130AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
131AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC315123f2010-02-15 16:14:26 +0000132AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000133
DRC079b4342010-02-15 11:32:23 +0000134case "$host_cpu" in
135 x86_64)
136 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000137 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000138 ;;
139 i*86 | x86 | ia32)
140 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000141 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000142 ;;
143esac
144
145AC_SUBST(RPMARCH)
DRC52a19f22010-02-15 12:06:27 +0000146AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000147AC_SUBST(BUILD)
148
Pierre Ossmanba0ce392009-03-06 15:30:42 +0000149# jconfig.h is the file we use, but we have another before that to
150# fool autoheader. the reason is that we include this header in our
151# API headers, which can screw things up for users of the lib.
152# jconfig.h is a minimal version that allows this package to be built
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000153AC_CONFIG_HEADERS([config.h])
154AC_CONFIG_HEADERS([jconfig.h])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000155AC_CONFIG_FILES([Makefile simd/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000156AC_OUTPUT