blob: af80ee5d6d3bc99a3ce7ddf545ae3e9455d14728 [file] [log] [blame]
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
DRCbf0fab92010-02-12 22:22:01 +00004AC_PREREQ([2.56])
Leon Scroggins IIIbd7903e2018-02-28 14:05:04 -05005AC_INIT([libjpeg-turbo], [1.5.3])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00006
7AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
DRC8ff1f252010-02-15 11:08:57 +00008AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00009
DRCc7e10b22014-03-21 08:36:06 +000010m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000012# Checks for programs.
DRCe7b699d2010-02-14 07:39:07 +000013SAVED_CFLAGS=${CFLAGS}
DRCb4a50ce2011-02-26 21:07:50 +000014SAVED_CPPFLAGS=${CPPFLAGS}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000015AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000016AC_PROG_CC
DRC6f75a352014-02-20 19:33:44 +000017m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
DRC321e0682011-05-03 08:47:43 +000018AM_PROG_AS
DRCc56cb472014-02-15 07:02:04 +000019AM_PROG_CC_C_O
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000020AC_PROG_INSTALL
21AC_PROG_LIBTOOL
22AC_PROG_LN_S
23
Ondřej Surýb6590d62015-07-28 09:19:13 +020024AC_ARG_WITH([build-date], [Use custom build string to enable reproducible builds (default: YYMMDD)],
25 [BUILD="$with_build_date"],
26 [BUILD=`date +%Y%m%d`])
27
Alex Naidis6eb7d372016-10-16 23:10:08 +020028PKG_PROG_PKG_CONFIG
29
DRC764e1e22013-04-19 04:25:14 +000030# When the prefix is /opt/libjpeg-turbo, we assume that an "official" binary is
31# being created, and thus we install things into specific locations.
32
33old_prefix=${prefix}
34if test "x$prefix" = "xNONE" -a "x$ac_default_prefix" != "x"; then
35 prefix=$ac_default_prefix
36fi
37DATADIR=`eval echo ${datadir}`
38DATADIR=`eval echo $DATADIR`
39if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
40 datadir='${prefix}'
41fi
DRC7175e512013-04-23 22:29:00 +000042DATADIR=`eval echo ${datarootdir}`
43DATADIR=`eval echo $DATADIR`
44if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
45 datarootdir='${prefix}'
46fi
DRCc69a1cd2015-02-23 19:06:44 +000047DOCDIR=`eval echo ${docdir}`
48DOCDIR=`eval echo $DOCDIR`
49if test "$DOCDIR" = "/opt/libjpeg-turbo/doc/libjpeg-turbo"; then
50 docdir='${datadir}/doc'
51fi
DRC764e1e22013-04-19 04:25:14 +000052
53old_exec_prefix=${exec_prefix}
54if test "x$exec_prefix" = "xNONE"; then
55 exec_prefix=${prefix}
56fi
57
DRC3ebcc322015-05-15 19:09:44 +000058AC_CHECK_SIZEOF(size_t)
59
DRC764e1e22013-04-19 04:25:14 +000060if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; then
61 LIBDIR=`eval echo ${libdir}`
62 LIBDIR=`eval echo $LIBDIR`
63 if test "$LIBDIR" = "/opt/libjpeg-turbo/lib"; then
64 case $host_os in
65 darwin*)
66 ;;
67 *)
DRC3ebcc322015-05-15 19:09:44 +000068 if test "${ac_cv_sizeof_size_t}" = "8"; then
DRCc32e0c22013-08-11 22:57:19 +000069 libdir='${exec_prefix}/lib64'
DRC3ebcc322015-05-15 19:09:44 +000070 elif test "${ac_cv_sizeof_size_t}" = "4"; then
DRCc32e0c22013-08-11 22:57:19 +000071 libdir='${exec_prefix}/lib32'
72 fi
DRC764e1e22013-04-19 04:25:14 +000073 ;;
74 esac
75 fi
76fi
77exec_prefix=${old_exec_prefix}
78prefix=${old_prefix}
79
DRCbdb12882010-08-21 21:14:17 +000080# Check whether compiler supports pointers to undefined structures
81AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
Alex Naidis6eb7d372016-10-16 23:10:08 +020082AC_TRY_COMPILE([ typedef struct undefined_structure *undef_struct_ptr; ], ,
DRC0ddff3b2013-04-11 05:17:53 +000083 AC_MSG_RESULT(yes),
84 [AC_MSG_RESULT(no)
85 AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
86 [Compiler does not support pointers to undefined structures.])])
DRCbdb12882010-08-21 21:14:17 +000087
DRCe7b699d2010-02-14 07:39:07 +000088if test "x${GCC}" = "xyes"; then
89 if test "x${SAVED_CFLAGS}" = "x"; then
90 CFLAGS=-O3
91 fi
DRCb4a50ce2011-02-26 21:07:50 +000092 if test "x${SAVED_CPPFLAGS}" = "x"; then
93 CPPFLAGS=-Wall
94 fi
DRCe7b699d2010-02-14 07:39:07 +000095fi
96
DRC1e2f2982010-02-16 22:35:25 +000097AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
98if test "x${SUNCC}" = "xyes"; then
99 if test "x${SAVED_CFLAGS}" = "x"; then
100 CFLAGS=-xO5
101 fi
DRC1e2f2982010-02-16 22:35:25 +0000102fi
103
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000104# Checks for libraries.
105
106# Checks for header files.
107AC_HEADER_STDC
DRCff6961f2014-04-20 09:17:11 +0000108AC_CHECK_HEADERS([stddef.h stdlib.h locale.h string.h])
DRC0ddff3b2013-04-11 05:17:53 +0000109AC_CHECK_HEADER([sys/types.h],
DRCff6961f2014-04-20 09:17:11 +0000110 AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you need to include <sys/types.h> to get size_t.]))
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000111
112# Checks for typedefs, structures, and compiler characteristics.
113AC_C_CONST
114AC_C_CHAR_UNSIGNED
115AC_C_INLINE
116AC_TYPE_SIZE_T
117AC_CHECK_TYPES([unsigned char, unsigned short])
118
119AC_MSG_CHECKING([if right shift is signed])
120AC_TRY_RUN(
DRC0ddff3b2013-04-11 05:17:53 +0000121 [#include <stdio.h>
122 int is_shifting_signed (long arg) {
123 long res = arg >> 4;
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000124
DRC0ddff3b2013-04-11 05:17:53 +0000125 if (res == -0x7F7E80CL)
126 return 1; /* right shift is signed */
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000127
DRC0ddff3b2013-04-11 05:17:53 +0000128 /* see if unsigned-shift hack will fix it. */
129 /* we can't just test exact value since it depends on width of long... */
130 res |= (~0L) << (32-4);
131 if (res == -0x7F7E80CL)
132 return 0; /* right shift is unsigned */
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000133
DRC0ddff3b2013-04-11 05:17:53 +0000134 printf("Right shift isn't acting as I expect it to.\n");
135 printf("I fear the JPEG software will not work at all.\n\n");
136 return 0; /* try it with unsigned anyway */
137 }
138 int main (void) {
139 exit(is_shifting_signed(-0x7F7E80B1L));
140 }],
141 [AC_MSG_RESULT(no)
DRCff6961f2014-04-20 09:17:11 +0000142 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1,
143 [Define if your (broken) compiler shifts signed values as if they were unsigned.])],
DRC0ddff3b2013-04-11 05:17:53 +0000144 [AC_MSG_RESULT(yes)],
145 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000146
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000147# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000148AC_CHECK_FUNCS([memset memcpy], [],
DRC0ddff3b2013-04-11 05:17:53 +0000149 [AC_DEFINE([NEED_BSD_STRINGS], 1,
DRCff6961f2014-04-20 09:17:11 +0000150 [Define if you have BSD-like bzero and bcopy in <strings.h> rather than memset/memcpy in <string.h>.])])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000151
DRC1f80a102010-10-18 00:15:31 +0000152AC_MSG_CHECKING([libjpeg API version])
153AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
154if test "x$JPEG_LIB_VERSION" = "x"; then
DRC0ddff3b2013-04-11 05:17:53 +0000155 AC_ARG_WITH([jpeg7],
156 AC_HELP_STRING([--with-jpeg7],
157 [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
158 AC_ARG_WITH([jpeg8],
159 AC_HELP_STRING([--with-jpeg8],
160 [Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
161 if test "x${with_jpeg8}" = "xyes"; then
162 JPEG_LIB_VERSION=80
163 else
164 if test "x${with_jpeg7}" = "xyes"; then
165 JPEG_LIB_VERSION=70
DRC36a6eec2010-10-08 08:05:44 +0000166 else
DRC0ddff3b2013-04-11 05:17:53 +0000167 JPEG_LIB_VERSION=62
DRC36a6eec2010-10-08 08:05:44 +0000168 fi
DRC0ddff3b2013-04-11 05:17:53 +0000169 fi
DRC36a6eec2010-10-08 08:05:44 +0000170fi
DRC1f80a102010-10-18 00:15:31 +0000171JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
DRC8515d3d2010-10-19 06:38:57 +0000172AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
DRC1f80a102010-10-18 00:15:31 +0000173AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
DRC0ddff3b2013-04-11 05:17:53 +0000174AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION],
175 [libjpeg API version])
DRC1f80a102010-10-18 00:15:31 +0000176
DRC0ddff3b2013-04-11 05:17:53 +0000177AC_ARG_VAR(SO_MAJOR_VERSION,
178 [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
179AC_ARG_VAR(SO_MINOR_VERSION,
180 [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
DRC1f80a102010-10-18 00:15:31 +0000181if test "x$SO_MAJOR_VERSION" = "x"; then
DRC0ddff3b2013-04-11 05:17:53 +0000182 case "$JPEG_LIB_VERSION" in
183 62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
184 *) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
185 esac
DRC1f80a102010-10-18 00:15:31 +0000186fi
187if test "x$SO_MINOR_VERSION" = "x"; then
DRC0ddff3b2013-04-11 05:17:53 +0000188 case "$JPEG_LIB_VERSION" in
189 80) SO_MINOR_VERSION=2 ;;
190 *) SO_MINOR_VERSION=0 ;;
191 esac
DRC1f80a102010-10-18 00:15:31 +0000192fi
DRCab706232013-01-18 23:42:31 +0000193
DRC6da61db2013-01-19 01:06:46 +0000194RPM_CONFIG_ARGS=
195
DRCab706232013-01-18 23:42:31 +0000196# Memory source/destination managers
Alex Naidis6eb7d372016-10-16 23:10:08 +0200197SO_AGE=1
DRCab706232013-01-18 23:42:31 +0000198MEM_SRCDST_FUNCTIONS=
199if test "x${with_jpeg8}" != "xyes"; then
200 AC_MSG_CHECKING([whether to include in-memory source/destination managers])
201 AC_ARG_WITH([mem-srcdst],
DRC0ddff3b2013-04-11 05:17:53 +0000202 AC_HELP_STRING([--without-mem-srcdst],
203 [Do not include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI]))
DRCab706232013-01-18 23:42:31 +0000204 if test "x$with_mem_srcdst" != "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000205 AC_MSG_RESULT(yes)
206 AC_DEFINE([MEM_SRCDST_SUPPORTED], [1],
207 [Support in-memory source/destination managers])
Alex Naidis6eb7d372016-10-16 23:10:08 +0200208 SO_AGE=2
DRC0ddff3b2013-04-11 05:17:53 +0000209 MEM_SRCDST_FUNCTIONS="global: jpeg_mem_dest; jpeg_mem_src;";
DRCab706232013-01-18 23:42:31 +0000210 else
DRC0ddff3b2013-04-11 05:17:53 +0000211 AC_MSG_RESULT(no)
212 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-mem-srcdst"
DRCab706232013-01-18 23:42:31 +0000213 fi
214fi
215
216AC_MSG_CHECKING([libjpeg shared library version])
217AC_MSG_RESULT([$SO_MAJOR_VERSION.$SO_AGE.$SO_MINOR_VERSION])
DRC6da61db2013-01-19 01:06:46 +0000218LIBTOOL_CURRENT=`expr $SO_MAJOR_VERSION + $SO_AGE`
219AC_SUBST(LIBTOOL_CURRENT)
DRC1f80a102010-10-18 00:15:31 +0000220AC_SUBST(SO_MAJOR_VERSION)
221AC_SUBST(SO_MINOR_VERSION)
DRCab706232013-01-18 23:42:31 +0000222AC_SUBST(SO_AGE)
223AC_SUBST(MEM_SRCDST_FUNCTIONS)
DRC36a6eec2010-10-08 08:05:44 +0000224
DRCab64b622011-12-18 16:29:35 +0000225AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
226
Alex Naidis6eb7d372016-10-16 23:10:08 +0200227m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
Leon Scroggins IIIbd7903e2018-02-28 14:05:04 -0500228m4_define(version_major,m4_car(m4_shiftn(1,[],version_triplet)))
229m4_define(version_minor,m4_car(m4_shiftn(2,[],version_triplet)))
230m4_define(version_revision,m4_car(m4_shiftn(3,[],version_triplet)))
Alex Naidis6eb7d372016-10-16 23:10:08 +0200231VERSION_MAJOR=version_major
232VERSION_MINOR=version_minor
233VERSION_REVISION=version_revision
234LIBJPEG_TURBO_VERSION_NUMBER=`printf "%d%03d%03d" $VERSION_MAJOR $VERSION_MINOR $VERSION_REVISION`
235AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION_NUMBER, [$LIBJPEG_TURBO_VERSION_NUMBER], [libjpeg-turbo version in integer form])
236
DRC7a0478e2010-11-07 19:12:30 +0000237VERSION_SCRIPT=yes
238AC_ARG_ENABLE([ld-version-script],
239 AS_HELP_STRING([--disable-ld-version-script],
240 [Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
DRC0ddff3b2013-04-11 05:17:53 +0000241 [VERSION_SCRIPT=$enableval], [])
DRC8515d3d2010-10-19 06:38:57 +0000242
243AC_MSG_CHECKING([whether the linker supports version scripts])
244SAVED_LDFLAGS="$LDFLAGS"
245LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
246cat > conftest.map <<EOF
247VERS_1 {
248 global: *;
249};
250EOF
DRCc56cb472014-02-15 07:02:04 +0000251AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
DRC0ddff3b2013-04-11 05:17:53 +0000252 [VERSION_SCRIPT_FLAG=-Wl,--version-script,;
253 AC_MSG_RESULT([yes (GNU style)])],
254 [])
DRC8515d3d2010-10-19 06:38:57 +0000255if test "x$VERSION_SCRIPT_FLAG" = "x"; then
256 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
DRCc56cb472014-02-15 07:02:04 +0000257 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
DRC0ddff3b2013-04-11 05:17:53 +0000258 [VERSION_SCRIPT_FLAG=-Wl,-M,;
259 AC_MSG_RESULT([yes (Sun style)])],
260 [])
DRC8515d3d2010-10-19 06:38:57 +0000261fi
262if test "x$VERSION_SCRIPT_FLAG" = "x"; then
263 VERSION_SCRIPT=no
264 AC_MSG_RESULT(no)
265fi
DRC8515d3d2010-10-19 06:38:57 +0000266LDFLAGS="$SAVED_LDFLAGS"
267
DRC9fa95592011-02-25 00:23:44 +0000268AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
DRC8515d3d2010-10-19 06:38:57 +0000269AC_MSG_RESULT($VERSION_SCRIPT)
270
271AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
DRC8515d3d2010-10-19 06:38:57 +0000272AC_SUBST(VERSION_SCRIPT_FLAG)
DRC8515d3d2010-10-19 06:38:57 +0000273
DRCb4570bb2011-09-07 06:31:00 +0000274# Check for non-broken inline under various spellings
275AC_MSG_CHECKING(for inline)
276ljt_cv_inline=""
DRCff6961f2014-04-20 09:17:11 +0000277AC_TRY_COMPILE(, [} inline __attribute__((always_inline)) int foo() { return 0; }
DRCad64b5a2014-03-21 09:22:21 +0000278int bar() { return foo();], ljt_cv_inline="inline __attribute__((always_inline))",
DRCb4570bb2011-09-07 06:31:00 +0000279AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
280int bar() { return foo();], ljt_cv_inline="__inline__",
281AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
282int bar() { return foo();], ljt_cv_inline="__inline",
283AC_TRY_COMPILE(, [} inline int foo() { return 0; }
284int bar() { return foo();], ljt_cv_inline="inline"))))
285AC_MSG_RESULT($ljt_cv_inline)
286AC_DEFINE_UNQUOTED([INLINE],[$ljt_cv_inline],[How to obtain function inlining.])
287
DRC211d1e72013-01-13 11:25:20 +0000288# Arithmetic coding support
DRC990e28d2011-01-04 21:40:11 +0000289AC_MSG_CHECKING([whether to include arithmetic encoding support])
DRCe3720042010-11-23 06:50:14 +0000290AC_ARG_WITH([arith-enc],
DRC0ddff3b2013-04-11 05:17:53 +0000291 AC_HELP_STRING([--without-arith-enc],
Alex Naidis6eb7d372016-10-16 23:10:08 +0200292 [Do not include arithmetic encoding support when emulating the libjpeg v6b API/ABI]))
DRCaee4f722014-08-09 23:06:07 +0000293if test "x$with_12bit" = "xyes"; then
294 with_arith_enc=no
295fi
Alex Naidis6eb7d372016-10-16 23:10:08 +0200296if test "x${with_jpeg8}" = "xyes" -o "x${with_jpeg7}" = "xyes"; then
297 with_arith_enc=yes
298fi
DRCe3720042010-11-23 06:50:14 +0000299if test "x$with_arith_enc" = "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000300 AC_MSG_RESULT(no)
301 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-enc"
DRCe3720042010-11-23 06:50:14 +0000302else
DRC0ddff3b2013-04-11 05:17:53 +0000303 AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
304 AC_MSG_RESULT(yes)
DRCe3720042010-11-23 06:50:14 +0000305fi
306AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
307
DRC990e28d2011-01-04 21:40:11 +0000308AC_MSG_CHECKING([whether to include arithmetic decoding support])
DRCe3720042010-11-23 06:50:14 +0000309AC_ARG_WITH([arith-dec],
DRC0ddff3b2013-04-11 05:17:53 +0000310 AC_HELP_STRING([--without-arith-dec],
Alex Naidis6eb7d372016-10-16 23:10:08 +0200311 [Do not include arithmetic decoding support when emulating the libjpeg v6b API/ABI]))
DRCaee4f722014-08-09 23:06:07 +0000312if test "x$with_12bit" = "xyes"; then
313 with_arith_dec=no
314fi
Alex Naidis6eb7d372016-10-16 23:10:08 +0200315if test "x${with_jpeg8}" = "xyes" -o "x${with_jpeg7}" = "xyes"; then
316 with_arith_dec=yes
317fi
DRCe3720042010-11-23 06:50:14 +0000318if test "x$with_arith_dec" = "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000319 AC_MSG_RESULT(no)
320 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-dec"
DRCe3720042010-11-23 06:50:14 +0000321else
DRC0ddff3b2013-04-11 05:17:53 +0000322 AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
323 AC_MSG_RESULT(yes)
DRCe3720042010-11-23 06:50:14 +0000324fi
325AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
326
DRC0ddff3b2013-04-11 05:17:53 +0000327AM_CONDITIONAL([WITH_ARITH],
328 [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
DRCe3720042010-11-23 06:50:14 +0000329
DRCaee4f722014-08-09 23:06:07 +0000330# 12-bit component support
331AC_MSG_CHECKING([whether to use 12-bit samples])
332AC_ARG_WITH([12bit],
333 AC_HELP_STRING([--with-12bit], [Encode/decode JPEG images with 12-bit samples (implies --without-simd --without-turbojpeg --without-arith-dec --without-arith-enc)]))
334if test "x$with_12bit" = "xyes"; then
335 AC_DEFINE([BITS_IN_JSAMPLE], [12], [use 8 or 12])
336 AC_MSG_RESULT(yes)
337else
338 AC_MSG_RESULT(no)
339fi
340AM_CONDITIONAL([WITH_12BIT], [test "x$with_12bit" = "xyes"])
341
DRC211d1e72013-01-13 11:25:20 +0000342# TurboJPEG support
DRC5039d732013-01-21 23:42:12 +0000343AC_MSG_CHECKING([whether to build TurboJPEG C wrapper])
DRC211d1e72013-01-13 11:25:20 +0000344AC_ARG_WITH([turbojpeg],
DRC0ddff3b2013-04-11 05:17:53 +0000345 AC_HELP_STRING([--without-turbojpeg],
346 [Do not include the TurboJPEG wrapper library and associated test programs]))
DRCaee4f722014-08-09 23:06:07 +0000347if test "x$with_12bit" = "xyes"; then
348 with_turbojpeg=no
349fi
DRC211d1e72013-01-13 11:25:20 +0000350if test "x$with_turbojpeg" = "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000351 AC_MSG_RESULT(no)
352 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-turbojpeg"
DRC211d1e72013-01-13 11:25:20 +0000353else
DRC0ddff3b2013-04-11 05:17:53 +0000354 AC_MSG_RESULT(yes)
DRC211d1e72013-01-13 11:25:20 +0000355fi
356
357# Java support
DRCf2602ce2011-04-01 00:20:33 +0000358AC_ARG_VAR(JAVAC, [Java compiler command (default: javac)])
359if test "x$JAVAC" = "x"; then
360 JAVAC=javac
361fi
362AC_SUBST(JAVAC)
363AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
Leon Scroggins IIIbd7903e2018-02-28 14:05:04 -0500364JAVACFLAGS="$JAVACFLAGS -J-Dfile.encoding=UTF8"
DRCf2602ce2011-04-01 00:20:33 +0000365AC_SUBST(JAVACFLAGS)
366AC_ARG_VAR(JAR, [Java archive command (default: jar)])
367if test "x$JAR" = "x"; then
368 JAR=jar
369fi
370AC_SUBST(JAR)
371AC_ARG_VAR(JAVA, [Java runtime command (default: java)])
372if test "x$JAVA" = "x"; then
373 JAVA=java
374fi
375AC_SUBST(JAVA)
DRC0ddff3b2013-04-11 05:17:53 +0000376AC_ARG_VAR(JNI_CFLAGS,
377 [C compiler flags needed to include jni.h (default: -I/System/Library/Frameworks/JavaVM.framework/Headers on OS X, '-I/usr/java/include -I/usr/java/include/solaris' on Solaris, and '-I/usr/java/default/include -I/usr/java/default/include/linux' on Linux)])
DRC063ab492011-02-04 22:16:41 +0000378
DRC5039d732013-01-21 23:42:12 +0000379AC_MSG_CHECKING([whether to build TurboJPEG Java wrapper])
DRCf2602ce2011-04-01 00:20:33 +0000380AC_ARG_WITH([java],
DRC0ddff3b2013-04-11 05:17:53 +0000381 AC_HELP_STRING([--with-java], [Build Java wrapper for the TurboJPEG library]))
DRCaee4f722014-08-09 23:06:07 +0000382if test "x$with_12bit" = "xyes" -o "x$with_turbojpeg" = "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000383 with_java=no
DRC211d1e72013-01-13 11:25:20 +0000384fi
DRC1421a262011-02-06 15:35:38 +0000385
DRCf2602ce2011-04-01 00:20:33 +0000386WITH_JAVA=0
387if test "x$with_java" = "xyes"; then
DRC0ddff3b2013-04-11 05:17:53 +0000388 AC_MSG_RESULT(yes)
DRC1421a262011-02-06 15:35:38 +0000389
DRC0ddff3b2013-04-11 05:17:53 +0000390 case $host_os in
391 darwin*)
392 DEFAULT_JNI_CFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
393 ;;
394 solaris*)
395 DEFAULT_JNI_CFLAGS='-I/usr/java/include -I/usr/java/include/solaris'
396 ;;
397 linux*)
398 DEFAULT_JNI_CFLAGS='-I/usr/java/default/include -I/usr/java/default/include/linux'
399 ;;
400 esac
401 if test "x$JNI_CFLAGS" = "x"; then
402 JNI_CFLAGS=$DEFAULT_JNI_CFLAGS
403 fi
DRC1421a262011-02-06 15:35:38 +0000404
DRC0ddff3b2013-04-11 05:17:53 +0000405 SAVE_CPPFLAGS=${CPPFLAGS}
406 CPPFLAGS="${CPPFLAGS} ${JNI_CFLAGS}"
407 AC_CHECK_HEADERS([jni.h], [DUMMY=1],
408 [AC_MSG_ERROR([Could not find JNI header file])])
409 CPPFLAGS=${SAVE_CPPFLAGS}
410 AC_SUBST(JNI_CFLAGS)
DRC1b0c3b02011-02-06 15:51:27 +0000411
DRC0ddff3b2013-04-11 05:17:53 +0000412 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --with-java"
DRC764e1e22013-04-19 04:25:14 +0000413 JAVA_RPM_CONTENTS_1='%dir %{_datadir}/classes'
414 JAVA_RPM_CONTENTS_2=%{_datadir}/classes/turbojpeg.jar
DRC0ddff3b2013-04-11 05:17:53 +0000415 WITH_JAVA=1
DRCf8e00552011-02-04 11:06:36 +0000416else
DRC0ddff3b2013-04-11 05:17:53 +0000417 AC_MSG_RESULT(no)
DRCf8e00552011-02-04 11:06:36 +0000418fi
DRCf2602ce2011-04-01 00:20:33 +0000419AM_CONDITIONAL([WITH_JAVA], [test "x$with_java" = "xyes"])
420AC_SUBST(WITH_JAVA)
421AC_SUBST(JAVA_RPM_CONTENTS_1)
422AC_SUBST(JAVA_RPM_CONTENTS_2)
DRCf8e00552011-02-04 11:06:36 +0000423
DRC4346f912011-06-14 22:16:50 +0000424# optionally force using gas-preprocessor.pl for compatibility testing
425AC_ARG_WITH([gas-preprocessor],
DRC0ddff3b2013-04-11 05:17:53 +0000426 AC_HELP_STRING([--with-gas-preprocessor],
427 [Force using gas-preprocessor.pl on ARM.]))
DRC4346f912011-06-14 22:16:50 +0000428if test "x${with_gas_preprocessor}" = "xyes"; then
429 case $host_os in
430 darwin*)
431 CCAS="gas-preprocessor.pl -fix-unreq $CC"
432 ;;
433 *)
434 CCAS="gas-preprocessor.pl -no-fix-unreq $CC"
435 ;;
436 esac
437 AC_SUBST([CCAS])
438fi
439
DRC60cddeb2010-02-12 05:37:07 +0000440# SIMD is optional
441AC_ARG_WITH([simd],
DRC0ddff3b2013-04-11 05:17:53 +0000442 AC_HELP_STRING([--without-simd], [Do not include SIMD extensions]))
DRCaee4f722014-08-09 23:06:07 +0000443if test "x$with_12bit" = "xyes"; then
444 with_simd=no
445fi
DRC60cddeb2010-02-12 05:37:07 +0000446if test "x${with_simd}" != "xno"; then
DRC8ca34d42013-09-25 04:36:44 +0000447 require_simd=no
448 if test "x${with_simd}" = "xyes"; then
449 require_simd=yes
450 fi
DRC60cddeb2010-02-12 05:37:07 +0000451 # Check if we're on a supported CPU
452 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
453 case "$host_cpu" in
DRC49597872010-05-17 20:47:57 +0000454 x86_64 | amd64)
DRC60cddeb2010-02-12 05:37:07 +0000455 AC_MSG_RESULT([yes (x86_64)])
456 AC_PROG_NASM
457 simd_arch=x86_64
DRC0ddff3b2013-04-11 05:17:53 +0000458 ;;
DRC60cddeb2010-02-12 05:37:07 +0000459 i*86 | x86 | ia32)
460 AC_MSG_RESULT([yes (i386)])
461 AC_PROG_NASM
462 simd_arch=i386
DRC0ddff3b2013-04-11 05:17:53 +0000463 ;;
DRC321e0682011-05-03 08:47:43 +0000464 arm*)
465 AC_MSG_RESULT([yes (arm)])
466 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
467 AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE(
DRCb9c4b582014-12-19 15:40:21 +0000468 [if test "x$ac_use_gas_preprocessor" = "xyes"; then
469 AC_MSG_RESULT([yes (with gas-preprocessor)])
470 else
471 AC_MSG_RESULT([yes])
472 fi
DRC321e0682011-05-03 08:47:43 +0000473 simd_arch=arm],
474 [AC_MSG_RESULT([no])
DRC8ca34d42013-09-25 04:36:44 +0000475 with_simd=no])
DRC596b9662013-10-26 00:29:53 +0000476 if test "x${with_simd}" = "xno"; then
477 if test "x${require_simd}" = "xyes"; then
478 AC_MSG_ERROR([SIMD support can't be enabled.])
479 else
480 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
DRCba55b2c2014-02-05 08:15:44 +0000481 fi
DRC596b9662013-10-26 00:29:53 +0000482 fi
DRCba55b2c2014-02-05 08:15:44 +0000483 ;;
484 aarch64*)
485 AC_MSG_RESULT([yes (arm64)])
486 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
487 AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE(
DRCb9c4b582014-12-19 15:40:21 +0000488 [if test "x$ac_use_gas_preprocessor" = "xyes"; then
489 AC_MSG_RESULT([yes (with gas-preprocessor)])
490 else
491 AC_MSG_RESULT([yes])
492 fi
DRCba55b2c2014-02-05 08:15:44 +0000493 simd_arch=aarch64],
494 [AC_MSG_RESULT([no])
495 with_simd=no])
496 if test "x${with_simd}" = "xno"; then
497 if test "x${require_simd}" = "xyes"; then
498 AC_MSG_ERROR([SIMD support can't be enabled.])
499 else
500 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
501 fi
DRC8ca34d42013-09-25 04:36:44 +0000502 fi
DRC0ddff3b2013-04-11 05:17:53 +0000503 ;;
DRC495e4342014-05-19 19:13:22 +0000504 mips*)
505 AC_MSG_RESULT([yes (mips)])
DRC0be9fa52013-07-24 21:50:20 +0000506 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
DRC495e4342014-05-19 19:13:22 +0000507 AC_CHECK_COMPATIBLE_MIPS_ASSEMBLER_IFELSE(
DRC0be9fa52013-07-24 21:50:20 +0000508 [AC_MSG_RESULT([yes])
DRC495e4342014-05-19 19:13:22 +0000509 simd_arch=mips],
DRC0be9fa52013-07-24 21:50:20 +0000510 [AC_MSG_RESULT([no])
DRC8ca34d42013-09-25 04:36:44 +0000511 with_simd=no])
DRC596b9662013-10-26 00:29:53 +0000512 if test "x${with_simd}" = "xno"; then
513 if test "x${require_simd}" = "xyes"; then
514 AC_MSG_ERROR([SIMD support can't be enabled.])
515 else
516 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
517 fi
DRC8ca34d42013-09-25 04:36:44 +0000518 fi
DRC0be9fa52013-07-24 21:50:20 +0000519 ;;
Alex Naidis6eb7d372016-10-16 23:10:08 +0200520 powerpc*)
Leon Scroggins IIIbd7903e2018-02-28 14:05:04 -0500521 AC_CHECK_ALTIVEC(
522 [AC_MSG_RESULT([yes (powerpc)])
523 simd_arch=powerpc],
524 [AC_NO_SIMD(PowerPC SPE)])
Alex Naidis6eb7d372016-10-16 23:10:08 +0200525 ;;
DRC60cddeb2010-02-12 05:37:07 +0000526 *)
Leon Scroggins IIIbd7903e2018-02-28 14:05:04 -0500527 AC_NO_SIMD($host_cpu)
DRC0ddff3b2013-04-11 05:17:53 +0000528 ;;
DRC60cddeb2010-02-12 05:37:07 +0000529 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000530
DRC60cddeb2010-02-12 05:37:07 +0000531 if test "x${with_simd}" != "xno"; then
532 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
533 fi
DRC6da61db2013-01-19 01:06:46 +0000534else
535 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-simd"
DRC60cddeb2010-02-12 05:37:07 +0000536fi
DRC411dcf52010-02-12 04:28:29 +0000537
DRC60cddeb2010-02-12 05:37:07 +0000538AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
DRC321e0682011-05-03 08:47:43 +0000539AM_CONDITIONAL([WITH_SSE_FLOAT_DCT], [test "x$simd_arch" = "xx86_64" -o "x$simd_arch" = "xi386"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000540AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
541AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC321e0682011-05-03 08:47:43 +0000542AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
DRCba55b2c2014-02-05 08:15:44 +0000543AM_CONDITIONAL([SIMD_ARM_64], [test "x$simd_arch" = "xaarch64"])
DRC495e4342014-05-19 19:13:22 +0000544AM_CONDITIONAL([SIMD_MIPS], [test "x$simd_arch" = "xmips"])
Alex Naidis6eb7d372016-10-16 23:10:08 +0200545AM_CONDITIONAL([SIMD_POWERPC], [test "x$simd_arch" = "xpowerpc"])
DRC49597872010-05-17 20:47:57 +0000546AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
DRC211d1e72013-01-13 11:25:20 +0000547AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
Alex Naidis6eb7d372016-10-16 23:10:08 +0200548AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = "xyes"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000549
DRC764e1e22013-04-19 04:25:14 +0000550AC_ARG_VAR(PKGNAME, [distribution package name (default: libjpeg-turbo)])
551if test "x$PKGNAME" = "x"; then
552 PKGNAME=$PACKAGE_NAME
553fi
554AC_SUBST(PKGNAME)
555
DRC079b4342010-02-15 11:32:23 +0000556case "$host_cpu" in
557 x86_64)
558 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000559 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000560 ;;
561 i*86 | x86 | ia32)
562 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000563 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000564 ;;
Leon Scroggins IIIbd7903e2018-02-28 14:05:04 -0500565 powerpc64le)
566 RPMARCH=`uname -m`
567 DEBARCH=ppc64el
568 ;;
569 powerpc)
570 RPMARCH=ppc
571 DEBARCH=ppc
572 ;;
DRCcab2a852015-02-20 20:12:15 +0000573 *)
574 RPMARCH=`uname -m`
575 DEBARCH=$RPMARCH
576 ;;
DRC079b4342010-02-15 11:32:23 +0000577esac
578
DRCc69a1cd2015-02-23 19:06:44 +0000579if test "${docdir}" = ""; then
580 docdir=${datadir}/doc
581 AC_SUBST(docdir)
582fi
583
DRC079b4342010-02-15 11:32:23 +0000584AC_SUBST(RPMARCH)
DRC6da61db2013-01-19 01:06:46 +0000585AC_SUBST(RPM_CONFIG_ARGS)
DRC52a19f22010-02-15 12:06:27 +0000586AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000587AC_SUBST(BUILD)
DRCff6961f2014-04-20 09:17:11 +0000588AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [libjpeg-turbo build number])
DRC079b4342010-02-15 11:32:23 +0000589
DRC990342c2014-04-15 03:41:31 +0000590# NOTE: autoheader automatically modifies the input file of the first
591# invocation of AC_CONFIG_HEADERS, so we put config.h first to prevent
592# jconfig.h.in from being clobbered. config.h is used only internally, whereas
593# jconfig.h contains macros that are relevant to external programs (macros that
594# specify which features were built into the library.)
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000595AC_CONFIG_HEADERS([config.h])
596AC_CONFIG_HEADERS([jconfig.h])
DRCff6961f2014-04-20 09:17:11 +0000597AC_CONFIG_HEADERS([jconfigint.h])
DRC764e1e22013-04-19 04:25:14 +0000598AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.in])
DRC7175e512013-04-23 22:29:00 +0000599AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in])
DRC764e1e22013-04-19 04:25:14 +0000600AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
DRC7175e512013-04-23 22:29:00 +0000601AC_CONFIG_FILES([pkgscripts/makemacpkg.tmpl:release/makemacpkg.in])
DRC7175e512013-04-23 22:29:00 +0000602AC_CONFIG_FILES([pkgscripts/uninstall.tmpl:release/uninstall.in])
Alex Naidis6eb7d372016-10-16 23:10:08 +0200603AC_CONFIG_FILES([pkgscripts/libjpeg.pc:release/libjpeg.pc.in])
604AC_CONFIG_FILES([pkgscripts/libturbojpeg.pc:release/libturbojpeg.pc.in])
DRC211d1e72013-01-13 11:25:20 +0000605if test "x$with_turbojpeg" != "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000606 AC_CONFIG_FILES([tjbenchtest])
DRC211d1e72013-01-13 11:25:20 +0000607fi
608if test "x$with_java" = "xyes"; then
DRC0ddff3b2013-04-11 05:17:53 +0000609 AC_CONFIG_FILES([tjbenchtest.java])
610 AC_CONFIG_FILES([tjexampletest])
DRC211d1e72013-01-13 11:25:20 +0000611fi
DRC8515d3d2010-10-19 06:38:57 +0000612AC_CONFIG_FILES([libjpeg.map])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000613AC_CONFIG_FILES([Makefile simd/Makefile])
DRCdffd53d2011-04-01 00:37:20 +0000614AC_CONFIG_FILES([java/Makefile])
DRC0bf58f22013-02-06 23:51:08 +0000615AC_CONFIG_FILES([md5/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000616AC_OUTPUT