Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 1 | # -*- Autoconf -*- |
| 2 | # Process this file with autoconf to produce a configure script. |
| 3 | |
DRC | bf0fab9 | 2010-02-12 22:22:01 +0000 | [diff] [blame] | 4 | AC_PREREQ([2.56]) |
DRC | 86d8c0a | 2010-04-20 18:12:38 +0000 | [diff] [blame] | 5 | AC_INIT([libjpeg-turbo], [0.0.93]) |
DRC | 079b434 | 2010-02-15 11:32:23 +0000 | [diff] [blame] | 6 | BUILD=`date +%Y%m%d` |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 7 | |
| 8 | AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2]) |
DRC | 8ff1f25 | 2010-02-15 11:08:57 +0000 | [diff] [blame] | 9 | AC_PREFIX_DEFAULT(/opt/libjpeg-turbo) |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 10 | |
| 11 | # Always build with prototypes |
| 12 | AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes]) |
| 13 | # Don't use undefined types |
| 14 | AC_DEFINE([INCOMPLETE_TYPES_BROKEN], 1, [Define if you want use complete types]) |
| 15 | |
| 16 | # Checks for programs. |
DRC | e7b699d | 2010-02-14 07:39:07 +0000 | [diff] [blame] | 17 | SAVED_CFLAGS=${CFLAGS} |
| 18 | SAVED_CXXFLAGS=${CXXFLAGS} |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 19 | AC_PROG_CPP |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 20 | AC_PROG_CC |
Adam Tkac | 6e075fc | 2009-04-03 14:47:50 +0000 | [diff] [blame] | 21 | AC_PROG_CXX |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 22 | AC_PROG_INSTALL |
| 23 | AC_PROG_LIBTOOL |
| 24 | AC_PROG_LN_S |
| 25 | |
DRC | 6f8c668 | 2010-02-16 05:03:51 +0000 | [diff] [blame] | 26 | AC_MSG_CHECKING([whether the linker supports version scripts]) |
DRC | d86e4d9 | 2010-02-16 22:40:26 +0000 | [diff] [blame] | 27 | VERSION_SCRIPT=no |
| 28 | LDVER=`$LD --help </dev/null 2>&1 | grep "\-\-version-script"` |
DRC | 6f8c668 | 2010-02-16 05:03:51 +0000 | [diff] [blame] | 29 | if test "$LDVER"; then |
| 30 | VERSION_SCRIPT=yes |
DRC | d86e4d9 | 2010-02-16 22:40:26 +0000 | [diff] [blame] | 31 | VERSION_SCRIPT_FLAG=-Wl,--version-script, |
DRC | 6f8c668 | 2010-02-16 05:03:51 +0000 | [diff] [blame] | 32 | AC_MSG_RESULT(yes) |
| 33 | else |
DRC | d86e4d9 | 2010-02-16 22:40:26 +0000 | [diff] [blame] | 34 | LDVER=`$LD --help </dev/null 2>&1 | grep "\-M"` |
| 35 | if test "$LDVER"; then |
| 36 | VERSION_SCRIPT=yes |
| 37 | VERSION_SCRIPT_FLAG=-Wl,-M, |
| 38 | AC_MSG_RESULT(yes) |
| 39 | else |
| 40 | AC_MSG_RESULT(no) |
| 41 | fi |
DRC | 6f8c668 | 2010-02-16 05:03:51 +0000 | [diff] [blame] | 42 | fi |
DRC | d86e4d9 | 2010-02-16 22:40:26 +0000 | [diff] [blame] | 43 | |
DRC | 6f8c668 | 2010-02-16 05:03:51 +0000 | [diff] [blame] | 44 | AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes") |
DRC | d86e4d9 | 2010-02-16 22:40:26 +0000 | [diff] [blame] | 45 | AC_SUBST(VERSION_SCRIPT_FLAG) |
DRC | 6f8c668 | 2010-02-16 05:03:51 +0000 | [diff] [blame] | 46 | |
DRC | e7b699d | 2010-02-14 07:39:07 +0000 | [diff] [blame] | 47 | if test "x${GCC}" = "xyes"; then |
| 48 | if test "x${SAVED_CFLAGS}" = "x"; then |
| 49 | CFLAGS=-O3 |
| 50 | fi |
| 51 | if test "x${SAVED_CXXFLAGS}" = "x"; then |
| 52 | CXXFLAGS=-O3 |
| 53 | fi |
| 54 | fi |
| 55 | |
DRC | 1e2f298 | 2010-02-16 22:35:25 +0000 | [diff] [blame] | 56 | AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) |
| 57 | if test "x${SUNCC}" = "xyes"; then |
| 58 | if test "x${SAVED_CFLAGS}" = "x"; then |
| 59 | CFLAGS=-xO5 |
| 60 | fi |
| 61 | if test "x${SAVED_CXXFLAGS}" = "x"; then |
| 62 | CXXFLAGS=-xO5 |
| 63 | fi |
| 64 | fi |
| 65 | |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 66 | # Checks for libraries. |
| 67 | |
| 68 | # Checks for header files. |
| 69 | AC_HEADER_STDC |
| 70 | AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) |
| 71 | AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h])) |
| 72 | |
| 73 | # Checks for typedefs, structures, and compiler characteristics. |
| 74 | AC_C_CONST |
| 75 | AC_C_CHAR_UNSIGNED |
| 76 | AC_C_INLINE |
| 77 | AC_TYPE_SIZE_T |
| 78 | AC_CHECK_TYPES([unsigned char, unsigned short]) |
| 79 | |
| 80 | AC_MSG_CHECKING([if right shift is signed]) |
| 81 | AC_TRY_RUN( |
| 82 | [#include <stdio.h> |
| 83 | int is_shifting_signed (long arg) { |
| 84 | long res = arg >> 4; |
| 85 | |
| 86 | if (res == -0x7F7E80CL) |
| 87 | return 1; /* right shift is signed */ |
| 88 | |
| 89 | /* see if unsigned-shift hack will fix it. */ |
| 90 | /* we can't just test exact value since it depends on width of long... */ |
| 91 | res |= (~0L) << (32-4); |
| 92 | if (res == -0x7F7E80CL) |
| 93 | return 0; /* right shift is unsigned */ |
| 94 | |
| 95 | printf("Right shift isn't acting as I expect it to.\n"); |
| 96 | printf("I fear the JPEG software will not work at all.\n\n"); |
| 97 | return 0; /* try it with unsigned anyway */ |
| 98 | } |
| 99 | int main (void) { |
| 100 | exit(is_shifting_signed(-0x7F7E80B1L)); |
| 101 | }], |
| 102 | [AC_MSG_RESULT(no) |
| 103 | AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])], |
| 104 | [AC_MSG_RESULT(yes)], |
| 105 | [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)]) |
| 106 | |
| 107 | # test whether global names are unique to at least 15 chars |
| 108 | AC_MSG_CHECKING([for short external names]) |
| 109 | AC_TRY_LINK( |
| 110 | [int possibly_duplicate_function () { return 0; } |
| 111 | int possibly_dupli_function () { return 1; }], [ ], |
| 112 | [AC_MSG_RESULT(ok)], |
| 113 | [AC_MSG_RESULT(short) |
| 114 | AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])]) |
| 115 | |
| 116 | # Checks for library functions. |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 117 | AC_CHECK_FUNCS([memset memcpy], [], |
| 118 | [AC_DEFINE([NEED_BSD_STRINGS], 1, |
| 119 | [Define if you have BSD-like bzero and bcopy])]) |
| 120 | |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 121 | # Set flags to indicate platform |
| 122 | case "$host_os" in |
| 123 | cygwin* | mingw* | pw32* | interix*) |
| 124 | is_win32=1 |
| 125 | ;; |
| 126 | esac |
| 127 | AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"]) |
| 128 | |
DRC | 60cddeb | 2010-02-12 05:37:07 +0000 | [diff] [blame] | 129 | # SIMD is optional |
| 130 | AC_ARG_WITH([simd], |
| 131 | AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.])) |
| 132 | if test "x${with_simd}" != "xno"; then |
| 133 | # Check if we're on a supported CPU |
| 134 | AC_MSG_CHECKING([if we have SIMD optimisations for cpu type]) |
| 135 | case "$host_cpu" in |
| 136 | x86_64) |
| 137 | AC_MSG_RESULT([yes (x86_64)]) |
| 138 | AC_PROG_NASM |
| 139 | simd_arch=x86_64 |
| 140 | ;; |
| 141 | i*86 | x86 | ia32) |
| 142 | AC_MSG_RESULT([yes (i386)]) |
| 143 | AC_PROG_NASM |
| 144 | simd_arch=i386 |
| 145 | ;; |
| 146 | *) |
| 147 | AC_MSG_RESULT([no ("$host_cpu")]) |
| 148 | AC_MSG_ERROR([CPU is not supported]) |
| 149 | ;; |
| 150 | esac |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 151 | |
DRC | 60cddeb | 2010-02-12 05:37:07 +0000 | [diff] [blame] | 152 | if test "x${with_simd}" != "xno"; then |
| 153 | AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.]) |
| 154 | fi |
| 155 | fi |
DRC | 411dcf5 | 2010-02-12 04:28:29 +0000 | [diff] [blame] | 156 | |
DRC | 60cddeb | 2010-02-12 05:37:07 +0000 | [diff] [blame] | 157 | AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"]) |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 158 | AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"]) |
| 159 | AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"]) |
DRC | 315123f | 2010-02-15 16:14:26 +0000 | [diff] [blame] | 160 | AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64"]) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 161 | |
DRC | 079b434 | 2010-02-15 11:32:23 +0000 | [diff] [blame] | 162 | case "$host_cpu" in |
| 163 | x86_64) |
| 164 | RPMARCH=x86_64 |
DRC | 52a19f2 | 2010-02-15 12:06:27 +0000 | [diff] [blame] | 165 | DEBARCH=amd64 |
DRC | 079b434 | 2010-02-15 11:32:23 +0000 | [diff] [blame] | 166 | ;; |
| 167 | i*86 | x86 | ia32) |
| 168 | RPMARCH=i386 |
DRC | 52a19f2 | 2010-02-15 12:06:27 +0000 | [diff] [blame] | 169 | DEBARCH=i386 |
DRC | 079b434 | 2010-02-15 11:32:23 +0000 | [diff] [blame] | 170 | ;; |
| 171 | esac |
| 172 | |
| 173 | AC_SUBST(RPMARCH) |
DRC | 52a19f2 | 2010-02-15 12:06:27 +0000 | [diff] [blame] | 174 | AC_SUBST(DEBARCH) |
DRC | 079b434 | 2010-02-15 11:32:23 +0000 | [diff] [blame] | 175 | AC_SUBST(BUILD) |
| 176 | |
Pierre Ossman | ba0ce39 | 2009-03-06 15:30:42 +0000 | [diff] [blame] | 177 | # jconfig.h is the file we use, but we have another before that to |
| 178 | # fool autoheader. the reason is that we include this header in our |
| 179 | # API headers, which can screw things up for users of the lib. |
| 180 | # jconfig.h is a minimal version that allows this package to be built |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 181 | AC_CONFIG_HEADERS([config.h]) |
| 182 | AC_CONFIG_HEADERS([jconfig.h]) |
Pierre Ossman | 3a65ef4 | 2009-03-16 13:34:18 +0000 | [diff] [blame] | 183 | AC_CONFIG_FILES([Makefile simd/Makefile]) |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 184 | AC_OUTPUT |