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