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