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 | |
Adam Tkac | d07a0a6 | 2009-03-13 13:58:44 +0000 | [diff] [blame] | 4 | AC_PREREQ([2.57]) |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 5 | AC_INIT([libjpeg], [6.b]) |
| 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. |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 15 | AC_PROG_CPP |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 16 | AC_PROG_CC |
| 17 | AC_PROG_INSTALL |
| 18 | AC_PROG_LIBTOOL |
| 19 | AC_PROG_LN_S |
| 20 | |
| 21 | # Checks for libraries. |
| 22 | |
| 23 | # Checks for header files. |
| 24 | AC_HEADER_STDC |
| 25 | AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) |
| 26 | AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h])) |
| 27 | |
| 28 | # Checks for typedefs, structures, and compiler characteristics. |
| 29 | AC_C_CONST |
| 30 | AC_C_CHAR_UNSIGNED |
| 31 | AC_C_INLINE |
| 32 | AC_TYPE_SIZE_T |
| 33 | AC_CHECK_TYPES([unsigned char, unsigned short]) |
| 34 | |
| 35 | AC_MSG_CHECKING([if right shift is signed]) |
| 36 | AC_TRY_RUN( |
| 37 | [#include <stdio.h> |
| 38 | int is_shifting_signed (long arg) { |
| 39 | long res = arg >> 4; |
| 40 | |
| 41 | if (res == -0x7F7E80CL) |
| 42 | return 1; /* right shift is signed */ |
| 43 | |
| 44 | /* see if unsigned-shift hack will fix it. */ |
| 45 | /* we can't just test exact value since it depends on width of long... */ |
| 46 | res |= (~0L) << (32-4); |
| 47 | if (res == -0x7F7E80CL) |
| 48 | return 0; /* right shift is unsigned */ |
| 49 | |
| 50 | printf("Right shift isn't acting as I expect it to.\n"); |
| 51 | printf("I fear the JPEG software will not work at all.\n\n"); |
| 52 | return 0; /* try it with unsigned anyway */ |
| 53 | } |
| 54 | int main (void) { |
| 55 | exit(is_shifting_signed(-0x7F7E80B1L)); |
| 56 | }], |
| 57 | [AC_MSG_RESULT(no) |
| 58 | AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])], |
| 59 | [AC_MSG_RESULT(yes)], |
| 60 | [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)]) |
| 61 | |
| 62 | # test whether global names are unique to at least 15 chars |
| 63 | AC_MSG_CHECKING([for short external names]) |
| 64 | AC_TRY_LINK( |
| 65 | [int possibly_duplicate_function () { return 0; } |
| 66 | int possibly_dupli_function () { return 1; }], [ ], |
| 67 | [AC_MSG_RESULT(ok)], |
| 68 | [AC_MSG_RESULT(short) |
| 69 | AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])]) |
| 70 | |
| 71 | # Checks for library functions. |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 72 | AC_CHECK_FUNCS([memset memcpy], [], |
| 73 | [AC_DEFINE([NEED_BSD_STRINGS], 1, |
| 74 | [Define if you have BSD-like bzero and bcopy])]) |
| 75 | |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 76 | # Set flags to indicate platform |
| 77 | case "$host_os" in |
| 78 | cygwin* | mingw* | pw32* | interix*) |
| 79 | is_win32=1 |
| 80 | ;; |
| 81 | esac |
| 82 | AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"]) |
| 83 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 84 | # SIMD is optional |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 85 | AC_ARG_WITH([simd], |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 86 | AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.])) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 87 | if test "x${with_simd}" != "xno"; then |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 88 | # Check if we're on a supported CPU |
| 89 | AC_MSG_CHECKING([if host cpu type is i386 or compatible]) |
| 90 | case "$host_cpu" in |
| 91 | i*86 | x86 | ia32) |
| 92 | AC_MSG_RESULT(yes) |
| 93 | AC_PROG_NASM |
| 94 | AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.]) |
| 95 | ;; |
| 96 | *) |
| 97 | AC_MSG_RESULT([no ("$host_cpu")]) |
| 98 | with_simd=no |
| 99 | ;; |
| 100 | esac |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 101 | fi |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 102 | AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"]) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 103 | |
Pierre Ossman | ba0ce39 | 2009-03-06 15:30:42 +0000 | [diff] [blame] | 104 | # jconfig.h is the file we use, but we have another before that to |
| 105 | # fool autoheader. the reason is that we include this header in our |
| 106 | # API headers, which can screw things up for users of the lib. |
| 107 | # 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] | 108 | AC_CONFIG_HEADERS([config.h]) |
| 109 | AC_CONFIG_HEADERS([jconfig.h]) |
Pierre Ossman | 3a65ef4 | 2009-03-16 13:34:18 +0000 | [diff] [blame^] | 110 | AC_CONFIG_FILES([Makefile simd/Makefile]) |
Constantin Kaplinsky | 0ca4425 | 2008-09-28 05:08:48 +0000 | [diff] [blame] | 111 | AC_OUTPUT |