Adam Tkac | 251cf67 | 2008-04-03 13:29:28 +0000 | [diff] [blame] | 1 | # -*- Autoconf -*- |
| 2 | # Process this file with autoconf to produce a configure script. |
| 3 | |
DRC | e338bf8 | 2010-02-14 02:09:03 +0000 | [diff] [blame] | 4 | AC_PREREQ([2.56]) |
DRC | c875a0d | 2010-06-22 02:55:40 +0000 | [diff] [blame^] | 5 | AC_INIT([libjpeg-turbo], [1.0.0]) |
Adam Tkac | 251cf67 | 2008-04-03 13:29:28 +0000 | [diff] [blame] | 6 | |
| 7 | AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2]) |
| 8 | |
| 9 | # Always build with prototypes |
| 10 | AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes]) |
| 11 | # Don't use undefined types |
| 12 | AC_DEFINE([INCOMPLETE_TYPES_BROKEN], 1, [Define if you want use complete types]) |
| 13 | |
| 14 | # Checks for programs. |
DRC | 589901b | 2010-02-14 07:59:44 +0000 | [diff] [blame] | 15 | SAVED_CFLAGS=${CFLAGS} |
| 16 | SAVED_CXXFLAGS=${CXXFLAGS} |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 17 | AC_PROG_CPP |
Adam Tkac | 251cf67 | 2008-04-03 13:29:28 +0000 | [diff] [blame] | 18 | AC_PROG_CC |
Adam Tkac | 4b0794d | 2009-04-03 14:47:50 +0000 | [diff] [blame] | 19 | AC_PROG_CXX |
Adam Tkac | 251cf67 | 2008-04-03 13:29:28 +0000 | [diff] [blame] | 20 | AC_PROG_INSTALL |
| 21 | AC_PROG_LIBTOOL |
| 22 | AC_PROG_LN_S |
| 23 | |
DRC | 589901b | 2010-02-14 07:59:44 +0000 | [diff] [blame] | 24 | if test "x${GCC}" = "xyes"; then |
| 25 | if test "x${SAVED_CFLAGS}" = "x"; then |
| 26 | CFLAGS=-O3 |
| 27 | fi |
| 28 | if test "x${SAVED_CXXFLAGS}" = "x"; then |
| 29 | CXXFLAGS=-O3 |
| 30 | fi |
| 31 | fi |
| 32 | |
DRC | eb4a246 | 2010-02-16 23:27:41 +0000 | [diff] [blame] | 33 | AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) |
| 34 | if test "x${SUNCC}" = "xyes"; then |
| 35 | if test "x${SAVED_CFLAGS}" = "x"; then |
| 36 | CFLAGS=-xO5 |
| 37 | fi |
| 38 | if test "x${SAVED_CXXFLAGS}" = "x"; then |
| 39 | CXXFLAGS=-xO5 |
| 40 | fi |
| 41 | fi |
| 42 | |
Adam Tkac | 251cf67 | 2008-04-03 13:29:28 +0000 | [diff] [blame] | 43 | # Checks for libraries. |
| 44 | |
| 45 | # Checks for header files. |
| 46 | AC_HEADER_STDC |
| 47 | AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) |
| 48 | AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h])) |
| 49 | |
| 50 | # Checks for typedefs, structures, and compiler characteristics. |
| 51 | AC_C_CONST |
| 52 | AC_C_CHAR_UNSIGNED |
| 53 | AC_C_INLINE |
| 54 | AC_TYPE_SIZE_T |
| 55 | AC_CHECK_TYPES([unsigned char, unsigned short]) |
| 56 | |
| 57 | AC_MSG_CHECKING([if right shift is signed]) |
| 58 | AC_TRY_RUN( |
| 59 | [#include <stdio.h> |
| 60 | int is_shifting_signed (long arg) { |
| 61 | long res = arg >> 4; |
| 62 | |
| 63 | if (res == -0x7F7E80CL) |
| 64 | return 1; /* right shift is signed */ |
| 65 | |
| 66 | /* see if unsigned-shift hack will fix it. */ |
| 67 | /* we can't just test exact value since it depends on width of long... */ |
| 68 | res |= (~0L) << (32-4); |
| 69 | if (res == -0x7F7E80CL) |
| 70 | return 0; /* right shift is unsigned */ |
| 71 | |
| 72 | printf("Right shift isn't acting as I expect it to.\n"); |
| 73 | printf("I fear the JPEG software will not work at all.\n\n"); |
| 74 | return 0; /* try it with unsigned anyway */ |
| 75 | } |
| 76 | int main (void) { |
| 77 | exit(is_shifting_signed(-0x7F7E80B1L)); |
| 78 | }], |
| 79 | [AC_MSG_RESULT(no) |
| 80 | AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])], |
| 81 | [AC_MSG_RESULT(yes)], |
| 82 | [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)]) |
| 83 | |
| 84 | # test whether global names are unique to at least 15 chars |
| 85 | AC_MSG_CHECKING([for short external names]) |
| 86 | AC_TRY_LINK( |
| 87 | [int possibly_duplicate_function () { return 0; } |
| 88 | int possibly_dupli_function () { return 1; }], [ ], |
| 89 | [AC_MSG_RESULT(ok)], |
| 90 | [AC_MSG_RESULT(short) |
| 91 | AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])]) |
| 92 | |
| 93 | # Checks for library functions. |
Adam Tkac | 251cf67 | 2008-04-03 13:29:28 +0000 | [diff] [blame] | 94 | AC_CHECK_FUNCS([memset memcpy], [], |
| 95 | [AC_DEFINE([NEED_BSD_STRINGS], 1, |
| 96 | [Define if you have BSD-like bzero and bcopy])]) |
| 97 | |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 98 | # Set flags to indicate platform |
| 99 | case "$host_os" in |
| 100 | cygwin* | mingw* | pw32* | interix*) |
| 101 | is_win32=1 |
| 102 | ;; |
| 103 | esac |
| 104 | AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"]) |
| 105 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 106 | # SIMD is optional |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 107 | AC_ARG_WITH([simd], |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 108 | AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.])) |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 109 | if test "x${with_simd}" != "xno"; then |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 110 | # Check if we're on a supported CPU |
Pierre Ossman | 8f0289b | 2009-06-26 14:09:47 +0000 | [diff] [blame] | 111 | AC_MSG_CHECKING([if we have SIMD optimisations for cpu type]) |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 112 | case "$host_cpu" in |
DRC | 50469f9 | 2010-05-17 20:57:48 +0000 | [diff] [blame] | 113 | x86_64 | amd64) |
Pierre Ossman | 8f0289b | 2009-06-26 14:09:47 +0000 | [diff] [blame] | 114 | AC_MSG_RESULT([yes (x86_64)]) |
DRC | 64add65 | 2010-04-23 15:53:16 +0000 | [diff] [blame] | 115 | AC_PROG_NASM |
| 116 | simd_arch=x86_64 |
DRC | 246c3d9 | 2009-06-25 20:38:31 +0000 | [diff] [blame] | 117 | ;; |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 118 | i*86 | x86 | ia32) |
Pierre Ossman | 8f0289b | 2009-06-26 14:09:47 +0000 | [diff] [blame] | 119 | AC_MSG_RESULT([yes (i386)]) |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 120 | AC_PROG_NASM |
Pierre Ossman | 0b7301e | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 121 | simd_arch=i386 |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 122 | ;; |
| 123 | *) |
| 124 | AC_MSG_RESULT([no ("$host_cpu")]) |
DRC | c875a0d | 2010-06-22 02:55:40 +0000 | [diff] [blame^] | 125 | AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.]) |
| 126 | with_simd=no; |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 127 | ;; |
| 128 | esac |
Pierre Ossman | 0b7301e | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 129 | |
| 130 | if test "x${with_simd}" != "xno"; then |
| 131 | AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.]) |
| 132 | fi |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 133 | fi |
Pierre Ossman | 0b7301e | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 134 | |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 135 | AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"]) |
Pierre Ossman | 0b7301e | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 136 | AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"]) |
| 137 | AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"]) |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 138 | |
Pierre Ossman | d678fb3 | 2009-03-06 15:30:42 +0000 | [diff] [blame] | 139 | # jconfig.h is the file we use, but we have another before that to |
| 140 | # fool autoheader. the reason is that we include this header in our |
| 141 | # API headers, which can screw things up for users of the lib. |
| 142 | # jconfig.h is a minimal version that allows this package to be built |
Adam Tkac | 8a2c811 | 2008-04-14 13:11:58 +0000 | [diff] [blame] | 143 | AC_CONFIG_HEADERS([config.h]) |
| 144 | AC_CONFIG_HEADERS([jconfig.h]) |
Pierre Ossman | 39170cf | 2009-03-16 13:34:18 +0000 | [diff] [blame] | 145 | AC_CONFIG_FILES([Makefile simd/Makefile]) |
Adam Tkac | 251cf67 | 2008-04-03 13:29:28 +0000 | [diff] [blame] | 146 | AC_OUTPUT |