blob: 64f32655ccdce9b8fc605b6b4f0f0ade93ef49ee [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])
DRC17745dd2013-04-25 09:45:50 +00005AC_INIT([libjpeg-turbo], [1.3.80])
DRC079b4342010-02-15 11:32:23 +00006BUILD=`date +%Y%m%d`
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +00007
8AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
DRC8ff1f252010-02-15 11:08:57 +00009AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000010
DRCc7e10b22014-03-21 08:36:06 +000011m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
12
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000013# Checks for programs.
DRCe7b699d2010-02-14 07:39:07 +000014SAVED_CFLAGS=${CFLAGS}
DRCb4a50ce2011-02-26 21:07:50 +000015SAVED_CPPFLAGS=${CPPFLAGS}
Pierre Ossman2ae181c2009-03-09 13:21:27 +000016AC_PROG_CPP
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000017AC_PROG_CC
DRC6f75a352014-02-20 19:33:44 +000018m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
DRC321e0682011-05-03 08:47:43 +000019AM_PROG_AS
DRCc56cb472014-02-15 07:02:04 +000020AM_PROG_CC_C_O
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000021AC_PROG_INSTALL
22AC_PROG_LIBTOOL
23AC_PROG_LN_S
24
DRC764e1e22013-04-19 04:25:14 +000025# When the prefix is /opt/libjpeg-turbo, we assume that an "official" binary is
26# being created, and thus we install things into specific locations.
27
28old_prefix=${prefix}
29if test "x$prefix" = "xNONE" -a "x$ac_default_prefix" != "x"; then
30 prefix=$ac_default_prefix
31fi
32DATADIR=`eval echo ${datadir}`
33DATADIR=`eval echo $DATADIR`
34if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
35 datadir='${prefix}'
36fi
DRC7175e512013-04-23 22:29:00 +000037DATADIR=`eval echo ${datarootdir}`
38DATADIR=`eval echo $DATADIR`
39if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
40 datarootdir='${prefix}'
41fi
DRC764e1e22013-04-19 04:25:14 +000042
43old_exec_prefix=${exec_prefix}
44if test "x$exec_prefix" = "xNONE"; then
45 exec_prefix=${prefix}
46fi
47
48if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; then
49 LIBDIR=`eval echo ${libdir}`
50 LIBDIR=`eval echo $LIBDIR`
51 if test "$LIBDIR" = "/opt/libjpeg-turbo/lib"; then
52 case $host_os in
53 darwin*)
54 ;;
55 *)
DRCc32e0c22013-08-11 22:57:19 +000056 AC_CHECK_SIZEOF(long)
57 if test "${ac_cv_sizeof_long}" = "8"; then
58 libdir='${exec_prefix}/lib64'
59 elif test "${ac_cv_sizeof_long}" = "4"; then
60 libdir='${exec_prefix}/lib32'
61 fi
DRC764e1e22013-04-19 04:25:14 +000062 ;;
63 esac
64 fi
65fi
66exec_prefix=${old_exec_prefix}
67prefix=${old_prefix}
68
DRCbdb12882010-08-21 21:14:17 +000069# Check whether compiler supports pointers to undefined structures
70AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
71AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
DRC0ddff3b2013-04-11 05:17:53 +000072 AC_MSG_RESULT(yes),
73 [AC_MSG_RESULT(no)
74 AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
75 [Compiler does not support pointers to undefined structures.])])
DRCbdb12882010-08-21 21:14:17 +000076
DRCe7b699d2010-02-14 07:39:07 +000077if test "x${GCC}" = "xyes"; then
78 if test "x${SAVED_CFLAGS}" = "x"; then
79 CFLAGS=-O3
80 fi
DRCb4a50ce2011-02-26 21:07:50 +000081 if test "x${SAVED_CPPFLAGS}" = "x"; then
82 CPPFLAGS=-Wall
83 fi
DRCe7b699d2010-02-14 07:39:07 +000084fi
85
DRC1e2f2982010-02-16 22:35:25 +000086AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
87if test "x${SUNCC}" = "xyes"; then
88 if test "x${SAVED_CFLAGS}" = "x"; then
89 CFLAGS=-xO5
90 fi
DRC1e2f2982010-02-16 22:35:25 +000091fi
92
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +000093# Checks for libraries.
94
95# Checks for header files.
96AC_HEADER_STDC
DRCff6961f2014-04-20 09:17:11 +000097AC_CHECK_HEADERS([stddef.h stdlib.h locale.h string.h])
DRC0ddff3b2013-04-11 05:17:53 +000098AC_CHECK_HEADER([sys/types.h],
DRCff6961f2014-04-20 09:17:11 +000099 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 +0000100
101# Checks for typedefs, structures, and compiler characteristics.
102AC_C_CONST
103AC_C_CHAR_UNSIGNED
104AC_C_INLINE
105AC_TYPE_SIZE_T
106AC_CHECK_TYPES([unsigned char, unsigned short])
107
108AC_MSG_CHECKING([if right shift is signed])
109AC_TRY_RUN(
DRC0ddff3b2013-04-11 05:17:53 +0000110 [#include <stdio.h>
111 int is_shifting_signed (long arg) {
112 long res = arg >> 4;
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000113
DRC0ddff3b2013-04-11 05:17:53 +0000114 if (res == -0x7F7E80CL)
115 return 1; /* right shift is signed */
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000116
DRC0ddff3b2013-04-11 05:17:53 +0000117 /* see if unsigned-shift hack will fix it. */
118 /* we can't just test exact value since it depends on width of long... */
119 res |= (~0L) << (32-4);
120 if (res == -0x7F7E80CL)
121 return 0; /* right shift is unsigned */
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000122
DRC0ddff3b2013-04-11 05:17:53 +0000123 printf("Right shift isn't acting as I expect it to.\n");
124 printf("I fear the JPEG software will not work at all.\n\n");
125 return 0; /* try it with unsigned anyway */
126 }
127 int main (void) {
128 exit(is_shifting_signed(-0x7F7E80B1L));
129 }],
130 [AC_MSG_RESULT(no)
DRCff6961f2014-04-20 09:17:11 +0000131 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1,
132 [Define if your (broken) compiler shifts signed values as if they were unsigned.])],
DRC0ddff3b2013-04-11 05:17:53 +0000133 [AC_MSG_RESULT(yes)],
134 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000135
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000136# Checks for library functions.
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000137AC_CHECK_FUNCS([memset memcpy], [],
DRC0ddff3b2013-04-11 05:17:53 +0000138 [AC_DEFINE([NEED_BSD_STRINGS], 1,
DRCff6961f2014-04-20 09:17:11 +0000139 [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 +0000140
DRC1f80a102010-10-18 00:15:31 +0000141AC_MSG_CHECKING([libjpeg API version])
142AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
143if test "x$JPEG_LIB_VERSION" = "x"; then
DRC0ddff3b2013-04-11 05:17:53 +0000144 AC_ARG_WITH([jpeg7],
145 AC_HELP_STRING([--with-jpeg7],
146 [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
147 AC_ARG_WITH([jpeg8],
148 AC_HELP_STRING([--with-jpeg8],
149 [Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
150 if test "x${with_jpeg8}" = "xyes"; then
151 JPEG_LIB_VERSION=80
152 else
153 if test "x${with_jpeg7}" = "xyes"; then
154 JPEG_LIB_VERSION=70
DRC36a6eec2010-10-08 08:05:44 +0000155 else
DRC0ddff3b2013-04-11 05:17:53 +0000156 JPEG_LIB_VERSION=62
DRC36a6eec2010-10-08 08:05:44 +0000157 fi
DRC0ddff3b2013-04-11 05:17:53 +0000158 fi
DRC36a6eec2010-10-08 08:05:44 +0000159fi
DRC1f80a102010-10-18 00:15:31 +0000160JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
DRC8515d3d2010-10-19 06:38:57 +0000161AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
DRC1f80a102010-10-18 00:15:31 +0000162AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
DRC0ddff3b2013-04-11 05:17:53 +0000163AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION],
164 [libjpeg API version])
DRC1f80a102010-10-18 00:15:31 +0000165
DRC0ddff3b2013-04-11 05:17:53 +0000166AC_ARG_VAR(SO_MAJOR_VERSION,
167 [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
168AC_ARG_VAR(SO_MINOR_VERSION,
169 [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
DRC1f80a102010-10-18 00:15:31 +0000170if test "x$SO_MAJOR_VERSION" = "x"; then
DRC0ddff3b2013-04-11 05:17:53 +0000171 case "$JPEG_LIB_VERSION" in
172 62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
173 *) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
174 esac
DRC1f80a102010-10-18 00:15:31 +0000175fi
176if test "x$SO_MINOR_VERSION" = "x"; then
DRC0ddff3b2013-04-11 05:17:53 +0000177 case "$JPEG_LIB_VERSION" in
178 80) SO_MINOR_VERSION=2 ;;
179 *) SO_MINOR_VERSION=0 ;;
180 esac
DRC1f80a102010-10-18 00:15:31 +0000181fi
DRCab706232013-01-18 23:42:31 +0000182
DRC6da61db2013-01-19 01:06:46 +0000183RPM_CONFIG_ARGS=
184
DRCab706232013-01-18 23:42:31 +0000185# Memory source/destination managers
186SO_AGE=0
187MEM_SRCDST_FUNCTIONS=
188if test "x${with_jpeg8}" != "xyes"; then
189 AC_MSG_CHECKING([whether to include in-memory source/destination managers])
190 AC_ARG_WITH([mem-srcdst],
DRC0ddff3b2013-04-11 05:17:53 +0000191 AC_HELP_STRING([--without-mem-srcdst],
192 [Do not include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI]))
DRCab706232013-01-18 23:42:31 +0000193 if test "x$with_mem_srcdst" != "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000194 AC_MSG_RESULT(yes)
195 AC_DEFINE([MEM_SRCDST_SUPPORTED], [1],
196 [Support in-memory source/destination managers])
197 SO_AGE=1
198 MEM_SRCDST_FUNCTIONS="global: jpeg_mem_dest; jpeg_mem_src;";
DRCab706232013-01-18 23:42:31 +0000199 else
DRC0ddff3b2013-04-11 05:17:53 +0000200 AC_MSG_RESULT(no)
201 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-mem-srcdst"
DRCab706232013-01-18 23:42:31 +0000202 fi
203fi
204
205AC_MSG_CHECKING([libjpeg shared library version])
206AC_MSG_RESULT([$SO_MAJOR_VERSION.$SO_AGE.$SO_MINOR_VERSION])
DRC6da61db2013-01-19 01:06:46 +0000207LIBTOOL_CURRENT=`expr $SO_MAJOR_VERSION + $SO_AGE`
208AC_SUBST(LIBTOOL_CURRENT)
DRC1f80a102010-10-18 00:15:31 +0000209AC_SUBST(SO_MAJOR_VERSION)
210AC_SUBST(SO_MINOR_VERSION)
DRCab706232013-01-18 23:42:31 +0000211AC_SUBST(SO_AGE)
212AC_SUBST(MEM_SRCDST_FUNCTIONS)
DRC36a6eec2010-10-08 08:05:44 +0000213
DRCab64b622011-12-18 16:29:35 +0000214AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
215
DRC7a0478e2010-11-07 19:12:30 +0000216VERSION_SCRIPT=yes
217AC_ARG_ENABLE([ld-version-script],
218 AS_HELP_STRING([--disable-ld-version-script],
219 [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 +0000220 [VERSION_SCRIPT=$enableval], [])
DRC8515d3d2010-10-19 06:38:57 +0000221
222AC_MSG_CHECKING([whether the linker supports version scripts])
223SAVED_LDFLAGS="$LDFLAGS"
224LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
225cat > conftest.map <<EOF
226VERS_1 {
227 global: *;
228};
229EOF
DRCc56cb472014-02-15 07:02:04 +0000230AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
DRC0ddff3b2013-04-11 05:17:53 +0000231 [VERSION_SCRIPT_FLAG=-Wl,--version-script,;
232 AC_MSG_RESULT([yes (GNU style)])],
233 [])
DRC8515d3d2010-10-19 06:38:57 +0000234if test "x$VERSION_SCRIPT_FLAG" = "x"; then
235 LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
DRCc56cb472014-02-15 07:02:04 +0000236 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
DRC0ddff3b2013-04-11 05:17:53 +0000237 [VERSION_SCRIPT_FLAG=-Wl,-M,;
238 AC_MSG_RESULT([yes (Sun style)])],
239 [])
DRC8515d3d2010-10-19 06:38:57 +0000240fi
241if test "x$VERSION_SCRIPT_FLAG" = "x"; then
242 VERSION_SCRIPT=no
243 AC_MSG_RESULT(no)
244fi
DRC8515d3d2010-10-19 06:38:57 +0000245LDFLAGS="$SAVED_LDFLAGS"
246
DRC9fa95592011-02-25 00:23:44 +0000247AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
DRC8515d3d2010-10-19 06:38:57 +0000248AC_MSG_RESULT($VERSION_SCRIPT)
249
250AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
DRC8515d3d2010-10-19 06:38:57 +0000251AC_SUBST(VERSION_SCRIPT_FLAG)
DRC8515d3d2010-10-19 06:38:57 +0000252
DRCb4570bb2011-09-07 06:31:00 +0000253# Check for non-broken inline under various spellings
254AC_MSG_CHECKING(for inline)
255ljt_cv_inline=""
DRCff6961f2014-04-20 09:17:11 +0000256AC_TRY_COMPILE(, [} inline __attribute__((always_inline)) int foo() { return 0; }
DRCad64b5a2014-03-21 09:22:21 +0000257int bar() { return foo();], ljt_cv_inline="inline __attribute__((always_inline))",
DRCb4570bb2011-09-07 06:31:00 +0000258AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
259int bar() { return foo();], ljt_cv_inline="__inline__",
260AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
261int bar() { return foo();], ljt_cv_inline="__inline",
262AC_TRY_COMPILE(, [} inline int foo() { return 0; }
263int bar() { return foo();], ljt_cv_inline="inline"))))
264AC_MSG_RESULT($ljt_cv_inline)
265AC_DEFINE_UNQUOTED([INLINE],[$ljt_cv_inline],[How to obtain function inlining.])
266
DRC211d1e72013-01-13 11:25:20 +0000267# Arithmetic coding support
DRC990e28d2011-01-04 21:40:11 +0000268AC_MSG_CHECKING([whether to include arithmetic encoding support])
DRCe3720042010-11-23 06:50:14 +0000269AC_ARG_WITH([arith-enc],
DRC0ddff3b2013-04-11 05:17:53 +0000270 AC_HELP_STRING([--without-arith-enc],
271 [Do not include arithmetic encoding support]))
DRCaee4f722014-08-09 23:06:07 +0000272if test "x$with_12bit" = "xyes"; then
273 with_arith_enc=no
274fi
DRCe3720042010-11-23 06:50:14 +0000275if test "x$with_arith_enc" = "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000276 AC_MSG_RESULT(no)
277 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-enc"
DRCe3720042010-11-23 06:50:14 +0000278else
DRC0ddff3b2013-04-11 05:17:53 +0000279 AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
280 AC_MSG_RESULT(yes)
DRCe3720042010-11-23 06:50:14 +0000281fi
282AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
283
DRC990e28d2011-01-04 21:40:11 +0000284AC_MSG_CHECKING([whether to include arithmetic decoding support])
DRCe3720042010-11-23 06:50:14 +0000285AC_ARG_WITH([arith-dec],
DRC0ddff3b2013-04-11 05:17:53 +0000286 AC_HELP_STRING([--without-arith-dec],
287 [Do not include arithmetic decoding support]))
DRCaee4f722014-08-09 23:06:07 +0000288if test "x$with_12bit" = "xyes"; then
289 with_arith_dec=no
290fi
DRCe3720042010-11-23 06:50:14 +0000291if test "x$with_arith_dec" = "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000292 AC_MSG_RESULT(no)
293 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-dec"
DRCe3720042010-11-23 06:50:14 +0000294else
DRC0ddff3b2013-04-11 05:17:53 +0000295 AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
296 AC_MSG_RESULT(yes)
DRCe3720042010-11-23 06:50:14 +0000297fi
298AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
299
DRC0ddff3b2013-04-11 05:17:53 +0000300AM_CONDITIONAL([WITH_ARITH],
301 [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
DRCe3720042010-11-23 06:50:14 +0000302
DRCaee4f722014-08-09 23:06:07 +0000303# 12-bit component support
304AC_MSG_CHECKING([whether to use 12-bit samples])
305AC_ARG_WITH([12bit],
306 AC_HELP_STRING([--with-12bit], [Encode/decode JPEG images with 12-bit samples (implies --without-simd --without-turbojpeg --without-arith-dec --without-arith-enc)]))
307if test "x$with_12bit" = "xyes"; then
308 AC_DEFINE([BITS_IN_JSAMPLE], [12], [use 8 or 12])
309 AC_MSG_RESULT(yes)
310else
311 AC_MSG_RESULT(no)
312fi
313AM_CONDITIONAL([WITH_12BIT], [test "x$with_12bit" = "xyes"])
314
DRC211d1e72013-01-13 11:25:20 +0000315# TurboJPEG support
DRC5039d732013-01-21 23:42:12 +0000316AC_MSG_CHECKING([whether to build TurboJPEG C wrapper])
DRC211d1e72013-01-13 11:25:20 +0000317AC_ARG_WITH([turbojpeg],
DRC0ddff3b2013-04-11 05:17:53 +0000318 AC_HELP_STRING([--without-turbojpeg],
319 [Do not include the TurboJPEG wrapper library and associated test programs]))
DRCaee4f722014-08-09 23:06:07 +0000320if test "x$with_12bit" = "xyes"; then
321 with_turbojpeg=no
322fi
DRC211d1e72013-01-13 11:25:20 +0000323if test "x$with_turbojpeg" = "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000324 AC_MSG_RESULT(no)
325 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-turbojpeg"
DRC211d1e72013-01-13 11:25:20 +0000326else
DRC0ddff3b2013-04-11 05:17:53 +0000327 AC_MSG_RESULT(yes)
DRC211d1e72013-01-13 11:25:20 +0000328fi
329
330# Java support
DRCf2602ce2011-04-01 00:20:33 +0000331AC_ARG_VAR(JAVAC, [Java compiler command (default: javac)])
332if test "x$JAVAC" = "x"; then
333 JAVAC=javac
334fi
335AC_SUBST(JAVAC)
336AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
337AC_SUBST(JAVACFLAGS)
338AC_ARG_VAR(JAR, [Java archive command (default: jar)])
339if test "x$JAR" = "x"; then
340 JAR=jar
341fi
342AC_SUBST(JAR)
343AC_ARG_VAR(JAVA, [Java runtime command (default: java)])
344if test "x$JAVA" = "x"; then
345 JAVA=java
346fi
347AC_SUBST(JAVA)
DRC0ddff3b2013-04-11 05:17:53 +0000348AC_ARG_VAR(JNI_CFLAGS,
349 [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 +0000350
DRC5039d732013-01-21 23:42:12 +0000351AC_MSG_CHECKING([whether to build TurboJPEG Java wrapper])
DRCf2602ce2011-04-01 00:20:33 +0000352AC_ARG_WITH([java],
DRC0ddff3b2013-04-11 05:17:53 +0000353 AC_HELP_STRING([--with-java], [Build Java wrapper for the TurboJPEG library]))
DRCaee4f722014-08-09 23:06:07 +0000354if test "x$with_12bit" = "xyes" -o "x$with_turbojpeg" = "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000355 with_java=no
DRC211d1e72013-01-13 11:25:20 +0000356fi
DRC1421a262011-02-06 15:35:38 +0000357
DRCf2602ce2011-04-01 00:20:33 +0000358WITH_JAVA=0
359if test "x$with_java" = "xyes"; then
DRC0ddff3b2013-04-11 05:17:53 +0000360 AC_MSG_RESULT(yes)
DRC1421a262011-02-06 15:35:38 +0000361
DRC0ddff3b2013-04-11 05:17:53 +0000362 case $host_os in
363 darwin*)
364 DEFAULT_JNI_CFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
365 ;;
366 solaris*)
367 DEFAULT_JNI_CFLAGS='-I/usr/java/include -I/usr/java/include/solaris'
368 ;;
369 linux*)
370 DEFAULT_JNI_CFLAGS='-I/usr/java/default/include -I/usr/java/default/include/linux'
371 ;;
372 esac
373 if test "x$JNI_CFLAGS" = "x"; then
374 JNI_CFLAGS=$DEFAULT_JNI_CFLAGS
375 fi
DRC1421a262011-02-06 15:35:38 +0000376
DRC0ddff3b2013-04-11 05:17:53 +0000377 SAVE_CPPFLAGS=${CPPFLAGS}
378 CPPFLAGS="${CPPFLAGS} ${JNI_CFLAGS}"
379 AC_CHECK_HEADERS([jni.h], [DUMMY=1],
380 [AC_MSG_ERROR([Could not find JNI header file])])
381 CPPFLAGS=${SAVE_CPPFLAGS}
382 AC_SUBST(JNI_CFLAGS)
DRC1b0c3b02011-02-06 15:51:27 +0000383
DRC0ddff3b2013-04-11 05:17:53 +0000384 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --with-java"
DRC764e1e22013-04-19 04:25:14 +0000385 JAVA_RPM_CONTENTS_1='%dir %{_datadir}/classes'
386 JAVA_RPM_CONTENTS_2=%{_datadir}/classes/turbojpeg.jar
DRC0ddff3b2013-04-11 05:17:53 +0000387 WITH_JAVA=1
DRCf8e00552011-02-04 11:06:36 +0000388else
DRC0ddff3b2013-04-11 05:17:53 +0000389 AC_MSG_RESULT(no)
DRCf8e00552011-02-04 11:06:36 +0000390fi
DRCf2602ce2011-04-01 00:20:33 +0000391AM_CONDITIONAL([WITH_JAVA], [test "x$with_java" = "xyes"])
392AC_SUBST(WITH_JAVA)
393AC_SUBST(JAVA_RPM_CONTENTS_1)
394AC_SUBST(JAVA_RPM_CONTENTS_2)
DRCf8e00552011-02-04 11:06:36 +0000395
DRC4346f912011-06-14 22:16:50 +0000396# optionally force using gas-preprocessor.pl for compatibility testing
397AC_ARG_WITH([gas-preprocessor],
DRC0ddff3b2013-04-11 05:17:53 +0000398 AC_HELP_STRING([--with-gas-preprocessor],
399 [Force using gas-preprocessor.pl on ARM.]))
DRC4346f912011-06-14 22:16:50 +0000400if test "x${with_gas_preprocessor}" = "xyes"; then
401 case $host_os in
402 darwin*)
403 CCAS="gas-preprocessor.pl -fix-unreq $CC"
404 ;;
405 *)
406 CCAS="gas-preprocessor.pl -no-fix-unreq $CC"
407 ;;
408 esac
409 AC_SUBST([CCAS])
410fi
411
DRC60cddeb2010-02-12 05:37:07 +0000412# SIMD is optional
413AC_ARG_WITH([simd],
DRC0ddff3b2013-04-11 05:17:53 +0000414 AC_HELP_STRING([--without-simd], [Do not include SIMD extensions]))
DRCaee4f722014-08-09 23:06:07 +0000415if test "x$with_12bit" = "xyes"; then
416 with_simd=no
417fi
DRC60cddeb2010-02-12 05:37:07 +0000418if test "x${with_simd}" != "xno"; then
DRC8ca34d42013-09-25 04:36:44 +0000419 require_simd=no
420 if test "x${with_simd}" = "xyes"; then
421 require_simd=yes
422 fi
DRC60cddeb2010-02-12 05:37:07 +0000423 # Check if we're on a supported CPU
424 AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
425 case "$host_cpu" in
DRC49597872010-05-17 20:47:57 +0000426 x86_64 | amd64)
DRC60cddeb2010-02-12 05:37:07 +0000427 AC_MSG_RESULT([yes (x86_64)])
428 AC_PROG_NASM
429 simd_arch=x86_64
DRC0ddff3b2013-04-11 05:17:53 +0000430 ;;
DRC60cddeb2010-02-12 05:37:07 +0000431 i*86 | x86 | ia32)
432 AC_MSG_RESULT([yes (i386)])
433 AC_PROG_NASM
434 simd_arch=i386
DRC0ddff3b2013-04-11 05:17:53 +0000435 ;;
DRC321e0682011-05-03 08:47:43 +0000436 arm*)
437 AC_MSG_RESULT([yes (arm)])
438 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
439 AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE(
440 [AC_MSG_RESULT([yes])
441 simd_arch=arm],
442 [AC_MSG_RESULT([no])
DRC8ca34d42013-09-25 04:36:44 +0000443 with_simd=no])
DRC596b9662013-10-26 00:29:53 +0000444 if test "x${with_simd}" = "xno"; then
445 if test "x${require_simd}" = "xyes"; then
446 AC_MSG_ERROR([SIMD support can't be enabled.])
447 else
448 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
DRCba55b2c2014-02-05 08:15:44 +0000449 fi
DRC596b9662013-10-26 00:29:53 +0000450 fi
DRCba55b2c2014-02-05 08:15:44 +0000451 ;;
452 aarch64*)
453 AC_MSG_RESULT([yes (arm64)])
454 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
455 AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE(
456 [AC_MSG_RESULT([yes])
457 simd_arch=aarch64],
458 [AC_MSG_RESULT([no])
459 with_simd=no])
460 if test "x${with_simd}" = "xno"; then
461 if test "x${require_simd}" = "xyes"; then
462 AC_MSG_ERROR([SIMD support can't be enabled.])
463 else
464 AC_MSG_WARN([SIMD support can't be enabled. Performance will suffer.])
465 fi
DRC8ca34d42013-09-25 04:36:44 +0000466 fi
DRC0ddff3b2013-04-11 05:17:53 +0000467 ;;
DRC495e4342014-05-19 19:13:22 +0000468 mips*)
469 AC_MSG_RESULT([yes (mips)])
DRC0be9fa52013-07-24 21:50:20 +0000470 AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
DRC495e4342014-05-19 19:13:22 +0000471 AC_CHECK_COMPATIBLE_MIPS_ASSEMBLER_IFELSE(
DRC0be9fa52013-07-24 21:50:20 +0000472 [AC_MSG_RESULT([yes])
DRC495e4342014-05-19 19:13:22 +0000473 simd_arch=mips],
DRC0be9fa52013-07-24 21:50:20 +0000474 [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.])
481 fi
DRC8ca34d42013-09-25 04:36:44 +0000482 fi
DRC0be9fa52013-07-24 21:50:20 +0000483 ;;
DRC60cddeb2010-02-12 05:37:07 +0000484 *)
485 AC_MSG_RESULT([no ("$host_cpu")])
DRC83f21442010-06-10 18:52:41 +0000486 with_simd=no;
DRC596b9662013-10-26 00:29:53 +0000487 if test "x${require_simd}" = "xyes"; then
DRC8ca34d42013-09-25 04:36:44 +0000488 AC_MSG_ERROR([SIMD support not available for this CPU.])
489 else
490 AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
491 fi
DRC0ddff3b2013-04-11 05:17:53 +0000492 ;;
DRC60cddeb2010-02-12 05:37:07 +0000493 esac
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000494
DRC60cddeb2010-02-12 05:37:07 +0000495 if test "x${with_simd}" != "xno"; then
496 AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
497 fi
DRC6da61db2013-01-19 01:06:46 +0000498else
499 RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-simd"
DRC60cddeb2010-02-12 05:37:07 +0000500fi
DRC411dcf52010-02-12 04:28:29 +0000501
DRC60cddeb2010-02-12 05:37:07 +0000502AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
DRC321e0682011-05-03 08:47:43 +0000503AM_CONDITIONAL([WITH_SSE_FLOAT_DCT], [test "x$simd_arch" = "xx86_64" -o "x$simd_arch" = "xi386"])
Pierre Ossmanba82ddf2009-06-29 11:20:42 +0000504AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
505AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
DRC321e0682011-05-03 08:47:43 +0000506AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
DRCba55b2c2014-02-05 08:15:44 +0000507AM_CONDITIONAL([SIMD_ARM_64], [test "x$simd_arch" = "xaarch64"])
DRC495e4342014-05-19 19:13:22 +0000508AM_CONDITIONAL([SIMD_MIPS], [test "x$simd_arch" = "xmips"])
DRC49597872010-05-17 20:47:57 +0000509AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
DRC211d1e72013-01-13 11:25:20 +0000510AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
Pierre Ossman59a39382009-03-09 13:15:56 +0000511
DRC764e1e22013-04-19 04:25:14 +0000512AC_ARG_VAR(PKGNAME, [distribution package name (default: libjpeg-turbo)])
513if test "x$PKGNAME" = "x"; then
514 PKGNAME=$PACKAGE_NAME
515fi
516AC_SUBST(PKGNAME)
517
DRC079b4342010-02-15 11:32:23 +0000518case "$host_cpu" in
519 x86_64)
520 RPMARCH=x86_64
DRC52a19f22010-02-15 12:06:27 +0000521 DEBARCH=amd64
DRC079b4342010-02-15 11:32:23 +0000522 ;;
523 i*86 | x86 | ia32)
524 RPMARCH=i386
DRC52a19f22010-02-15 12:06:27 +0000525 DEBARCH=i386
DRC079b4342010-02-15 11:32:23 +0000526 ;;
527esac
528
529AC_SUBST(RPMARCH)
DRC6da61db2013-01-19 01:06:46 +0000530AC_SUBST(RPM_CONFIG_ARGS)
DRC52a19f22010-02-15 12:06:27 +0000531AC_SUBST(DEBARCH)
DRC079b4342010-02-15 11:32:23 +0000532AC_SUBST(BUILD)
DRCff6961f2014-04-20 09:17:11 +0000533AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [libjpeg-turbo build number])
DRC079b4342010-02-15 11:32:23 +0000534
DRC990342c2014-04-15 03:41:31 +0000535# NOTE: autoheader automatically modifies the input file of the first
536# invocation of AC_CONFIG_HEADERS, so we put config.h first to prevent
537# jconfig.h.in from being clobbered. config.h is used only internally, whereas
538# jconfig.h contains macros that are relevant to external programs (macros that
539# specify which features were built into the library.)
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000540AC_CONFIG_HEADERS([config.h])
541AC_CONFIG_HEADERS([jconfig.h])
DRCff6961f2014-04-20 09:17:11 +0000542AC_CONFIG_HEADERS([jconfigint.h])
DRC764e1e22013-04-19 04:25:14 +0000543AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.in])
DRC7175e512013-04-23 22:29:00 +0000544AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in])
DRC764e1e22013-04-19 04:25:14 +0000545AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
DRC7175e512013-04-23 22:29:00 +0000546AC_CONFIG_FILES([pkgscripts/makemacpkg.tmpl:release/makemacpkg.in])
DRC7175e512013-04-23 22:29:00 +0000547AC_CONFIG_FILES([pkgscripts/uninstall.tmpl:release/uninstall.in])
DRC211d1e72013-01-13 11:25:20 +0000548if test "x$with_turbojpeg" != "xno"; then
DRC0ddff3b2013-04-11 05:17:53 +0000549 AC_CONFIG_FILES([tjbenchtest])
DRC211d1e72013-01-13 11:25:20 +0000550fi
551if test "x$with_java" = "xyes"; then
DRC0ddff3b2013-04-11 05:17:53 +0000552 AC_CONFIG_FILES([tjbenchtest.java])
553 AC_CONFIG_FILES([tjexampletest])
DRC211d1e72013-01-13 11:25:20 +0000554fi
DRC8515d3d2010-10-19 06:38:57 +0000555AC_CONFIG_FILES([libjpeg.map])
Pierre Ossman3a65ef42009-03-16 13:34:18 +0000556AC_CONFIG_FILES([Makefile simd/Makefile])
DRCdffd53d2011-04-01 00:37:20 +0000557AC_CONFIG_FILES([java/Makefile])
DRC0bf58f22013-02-06 23:51:08 +0000558AC_CONFIG_FILES([md5/Makefile])
Constantin Kaplinsky0ca44252008-09-28 05:08:48 +0000559AC_OUTPUT