Imported Upstream version 1.5.3
[platform/upstream/libjpeg-turbo.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.56])
5 AC_INIT([libjpeg-turbo], [1.5.3])
6
7 AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
8 AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
9
10 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11
12 # Checks for programs.
13 SAVED_CFLAGS=${CFLAGS}
14 SAVED_CPPFLAGS=${CPPFLAGS}
15 AC_PROG_CPP
16 AC_PROG_CC
17 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
18 AM_PROG_AS
19 AM_PROG_CC_C_O
20 AC_PROG_INSTALL
21 AC_PROG_LIBTOOL
22 AC_PROG_LN_S
23
24 AC_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
28 PKG_PROG_PKG_CONFIG
29
30 # 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
33 old_prefix=${prefix}
34 if test "x$prefix" = "xNONE" -a "x$ac_default_prefix" != "x"; then
35   prefix=$ac_default_prefix
36 fi
37 DATADIR=`eval echo ${datadir}`
38 DATADIR=`eval echo $DATADIR`
39 if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
40   datadir='${prefix}'
41 fi
42 DATADIR=`eval echo ${datarootdir}`
43 DATADIR=`eval echo $DATADIR`
44 if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
45   datarootdir='${prefix}'
46 fi
47 DOCDIR=`eval echo ${docdir}`
48 DOCDIR=`eval echo $DOCDIR`
49 if test "$DOCDIR" = "/opt/libjpeg-turbo/doc/libjpeg-turbo"; then
50   docdir='${datadir}/doc'
51 fi
52
53 old_exec_prefix=${exec_prefix}
54 if test "x$exec_prefix" = "xNONE"; then
55   exec_prefix=${prefix}
56 fi
57
58 AC_CHECK_SIZEOF(size_t)
59
60 if 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       *)
68         if test "${ac_cv_sizeof_size_t}" = "8"; then
69           libdir='${exec_prefix}/lib64'
70         elif test "${ac_cv_sizeof_size_t}" = "4"; then
71           libdir='${exec_prefix}/lib32'
72         fi
73         ;;
74     esac
75   fi
76 fi
77 exec_prefix=${old_exec_prefix}
78 prefix=${old_prefix}
79
80 # Check whether compiler supports pointers to undefined structures
81 AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
82 AC_TRY_COMPILE([ typedef struct undefined_structure *undef_struct_ptr; ], ,
83   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.])])
87
88 if test "x${GCC}" = "xyes"; then
89   if test "x${SAVED_CFLAGS}" = "x"; then
90     CFLAGS=-O3
91   fi
92   if test "x${SAVED_CPPFLAGS}" = "x"; then
93     CPPFLAGS=-Wall
94   fi
95 fi
96
97 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
98 if test "x${SUNCC}" = "xyes"; then
99   if test "x${SAVED_CFLAGS}" = "x"; then
100     CFLAGS=-xO5
101   fi
102 fi
103
104 # Checks for libraries.
105
106 # Checks for header files.
107 AC_HEADER_STDC
108 AC_CHECK_HEADERS([stddef.h stdlib.h locale.h string.h])
109 AC_CHECK_HEADER([sys/types.h],
110   AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you need to include <sys/types.h> to get size_t.]))
111
112 # Checks for typedefs, structures, and compiler characteristics.
113 AC_C_CONST
114 AC_C_CHAR_UNSIGNED
115 AC_C_INLINE
116 AC_TYPE_SIZE_T
117 AC_CHECK_TYPES([unsigned char, unsigned short])
118
119 AC_MSG_CHECKING([if right shift is signed])
120 AC_TRY_RUN(
121   [#include <stdio.h>
122    int is_shifting_signed (long arg) {
123      long res = arg >> 4;
124
125      if (res == -0x7F7E80CL)
126        return 1; /* right shift is signed */
127
128      /* 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 */
133
134      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)
142    AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1,
143      [Define if your (broken) compiler shifts signed values as if they were unsigned.])],
144   [AC_MSG_RESULT(yes)],
145   [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
146
147 # Checks for library functions.
148 AC_CHECK_FUNCS([memset memcpy], [],
149   [AC_DEFINE([NEED_BSD_STRINGS], 1,
150      [Define if you have BSD-like bzero and bcopy in <strings.h> rather than memset/memcpy in <string.h>.])])
151
152 AC_MSG_CHECKING([libjpeg API version])
153 AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
154 if test "x$JPEG_LIB_VERSION" = "x"; then
155   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
166     else
167       JPEG_LIB_VERSION=62
168     fi
169   fi
170 fi
171 JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
172 AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
173 AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
174 AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION],
175   [libjpeg API version])
176
177 AC_ARG_VAR(SO_MAJOR_VERSION,
178   [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
179 AC_ARG_VAR(SO_MINOR_VERSION,
180   [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
181 if test "x$SO_MAJOR_VERSION" = "x"; then
182   case "$JPEG_LIB_VERSION" in
183     62)  SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
184     *)   SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
185   esac
186 fi
187 if test "x$SO_MINOR_VERSION" = "x"; then
188   case "$JPEG_LIB_VERSION" in
189     80)  SO_MINOR_VERSION=2 ;;
190     *)   SO_MINOR_VERSION=0 ;;
191   esac
192 fi
193
194 RPM_CONFIG_ARGS=
195
196 # Memory source/destination managers
197 SO_AGE=1
198 MEM_SRCDST_FUNCTIONS=
199 if test "x${with_jpeg8}" != "xyes"; then
200   AC_MSG_CHECKING([whether to include in-memory source/destination managers])
201   AC_ARG_WITH([mem-srcdst],
202     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]))
204   if test "x$with_mem_srcdst" != "xno"; then
205     AC_MSG_RESULT(yes)
206     AC_DEFINE([MEM_SRCDST_SUPPORTED], [1],
207       [Support in-memory source/destination managers])
208     SO_AGE=2
209     MEM_SRCDST_FUNCTIONS="global:  jpeg_mem_dest;  jpeg_mem_src;";
210   else
211     AC_MSG_RESULT(no)
212     RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-mem-srcdst"
213   fi
214 fi
215
216 AC_MSG_CHECKING([libjpeg shared library version])
217 AC_MSG_RESULT([$SO_MAJOR_VERSION.$SO_AGE.$SO_MINOR_VERSION])
218 LIBTOOL_CURRENT=`expr $SO_MAJOR_VERSION + $SO_AGE`
219 AC_SUBST(LIBTOOL_CURRENT)
220 AC_SUBST(SO_MAJOR_VERSION)
221 AC_SUBST(SO_MINOR_VERSION)
222 AC_SUBST(SO_AGE)
223 AC_SUBST(MEM_SRCDST_FUNCTIONS)
224
225 AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
226
227 m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
228 m4_define(version_major,m4_car(m4_shiftn(1,[],version_triplet)))
229 m4_define(version_minor,m4_car(m4_shiftn(2,[],version_triplet)))
230 m4_define(version_revision,m4_car(m4_shiftn(3,[],version_triplet)))
231 VERSION_MAJOR=version_major
232 VERSION_MINOR=version_minor
233 VERSION_REVISION=version_revision
234 LIBJPEG_TURBO_VERSION_NUMBER=`printf "%d%03d%03d" $VERSION_MAJOR $VERSION_MINOR $VERSION_REVISION`
235 AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION_NUMBER, [$LIBJPEG_TURBO_VERSION_NUMBER], [libjpeg-turbo version in integer form])
236
237 VERSION_SCRIPT=yes
238 AC_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)]),
241   [VERSION_SCRIPT=$enableval], [])
242
243 AC_MSG_CHECKING([whether the linker supports version scripts])
244 SAVED_LDFLAGS="$LDFLAGS"
245 LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
246 cat > conftest.map <<EOF
247 VERS_1 {
248   global: *;
249 };
250 EOF
251 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
252   [VERSION_SCRIPT_FLAG=-Wl,--version-script,;
253    AC_MSG_RESULT([yes (GNU style)])],
254   [])
255 if test "x$VERSION_SCRIPT_FLAG" = "x"; then
256   LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
257   AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
258     [VERSION_SCRIPT_FLAG=-Wl,-M,;
259      AC_MSG_RESULT([yes (Sun style)])],
260     [])
261 fi
262 if test "x$VERSION_SCRIPT_FLAG" = "x"; then
263   VERSION_SCRIPT=no
264   AC_MSG_RESULT(no)
265 fi
266 LDFLAGS="$SAVED_LDFLAGS"
267
268 AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
269 AC_MSG_RESULT($VERSION_SCRIPT)
270
271 AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
272 AC_SUBST(VERSION_SCRIPT_FLAG)
273
274 # Check for non-broken inline under various spellings
275 AC_MSG_CHECKING(for inline)
276 ljt_cv_inline=""
277 AC_TRY_COMPILE(, [} inline __attribute__((always_inline)) int foo() { return 0; }
278 int bar() { return foo();], ljt_cv_inline="inline __attribute__((always_inline))",
279 AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
280 int bar() { return foo();], ljt_cv_inline="__inline__",
281 AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
282 int bar() { return foo();], ljt_cv_inline="__inline",
283 AC_TRY_COMPILE(, [} inline int foo() { return 0; }
284 int bar() { return foo();], ljt_cv_inline="inline"))))
285 AC_MSG_RESULT($ljt_cv_inline)
286 AC_DEFINE_UNQUOTED([INLINE],[$ljt_cv_inline],[How to obtain function inlining.])
287
288 # Arithmetic coding support
289 AC_MSG_CHECKING([whether to include arithmetic encoding support])
290 AC_ARG_WITH([arith-enc],
291   AC_HELP_STRING([--without-arith-enc],
292     [Do not include arithmetic encoding support when emulating the libjpeg v6b API/ABI]))
293 if test "x$with_12bit" = "xyes"; then
294   with_arith_enc=no
295 fi
296 if test "x${with_jpeg8}" = "xyes" -o "x${with_jpeg7}" = "xyes"; then
297   with_arith_enc=yes
298 fi
299 if test "x$with_arith_enc" = "xno"; then
300   AC_MSG_RESULT(no)
301   RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-enc"
302 else
303   AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
304   AC_MSG_RESULT(yes)
305 fi
306 AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
307
308 AC_MSG_CHECKING([whether to include arithmetic decoding support])
309 AC_ARG_WITH([arith-dec],
310   AC_HELP_STRING([--without-arith-dec],
311     [Do not include arithmetic decoding support when emulating the libjpeg v6b API/ABI]))
312 if test "x$with_12bit" = "xyes"; then
313   with_arith_dec=no
314 fi
315 if test "x${with_jpeg8}" = "xyes" -o "x${with_jpeg7}" = "xyes"; then
316   with_arith_dec=yes
317 fi
318 if test "x$with_arith_dec" = "xno"; then
319   AC_MSG_RESULT(no)
320   RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-dec"
321 else
322   AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
323   AC_MSG_RESULT(yes)
324 fi
325 AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
326
327 AM_CONDITIONAL([WITH_ARITH],
328   [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
329
330 # 12-bit component support
331 AC_MSG_CHECKING([whether to use 12-bit samples])
332 AC_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)]))
334 if test "x$with_12bit" = "xyes"; then
335   AC_DEFINE([BITS_IN_JSAMPLE], [12], [use 8 or 12])
336   AC_MSG_RESULT(yes)
337 else
338   AC_MSG_RESULT(no)
339 fi
340 AM_CONDITIONAL([WITH_12BIT], [test "x$with_12bit" = "xyes"])
341
342 # TurboJPEG support
343 AC_MSG_CHECKING([whether to build TurboJPEG C wrapper])
344 AC_ARG_WITH([turbojpeg],
345   AC_HELP_STRING([--without-turbojpeg],
346     [Do not include the TurboJPEG wrapper library and associated test programs]))
347 if test "x$with_12bit" = "xyes"; then
348   with_turbojpeg=no
349 fi
350 if test "x$with_turbojpeg" = "xno"; then
351   AC_MSG_RESULT(no)
352   RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-turbojpeg"
353 else
354   AC_MSG_RESULT(yes)
355 fi
356
357 # Java support
358 AC_ARG_VAR(JAVAC, [Java compiler command (default: javac)])
359 if test "x$JAVAC" = "x"; then
360   JAVAC=javac
361 fi
362 AC_SUBST(JAVAC)
363 AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
364 JAVACFLAGS="$JAVACFLAGS -J-Dfile.encoding=UTF8"
365 AC_SUBST(JAVACFLAGS)
366 AC_ARG_VAR(JAR, [Java archive command (default: jar)])
367 if test "x$JAR" = "x"; then
368   JAR=jar
369 fi
370 AC_SUBST(JAR)
371 AC_ARG_VAR(JAVA, [Java runtime command (default: java)])
372 if test "x$JAVA" = "x"; then
373   JAVA=java
374 fi
375 AC_SUBST(JAVA)
376 AC_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)])
378
379 AC_MSG_CHECKING([whether to build TurboJPEG Java wrapper])
380 AC_ARG_WITH([java],
381   AC_HELP_STRING([--with-java], [Build Java wrapper for the TurboJPEG library]))
382 if test "x$with_12bit" = "xyes" -o "x$with_turbojpeg" = "xno"; then
383   with_java=no
384 fi
385
386 WITH_JAVA=0
387 if test "x$with_java" = "xyes"; then
388   AC_MSG_RESULT(yes)
389
390   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
404
405   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)
411
412   RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --with-java"
413   JAVA_RPM_CONTENTS_1='%dir %{_datadir}/classes'
414   JAVA_RPM_CONTENTS_2=%{_datadir}/classes/turbojpeg.jar
415   WITH_JAVA=1
416 else
417   AC_MSG_RESULT(no)
418 fi
419 AM_CONDITIONAL([WITH_JAVA], [test "x$with_java" = "xyes"])
420 AC_SUBST(WITH_JAVA)
421 AC_SUBST(JAVA_RPM_CONTENTS_1)
422 AC_SUBST(JAVA_RPM_CONTENTS_2)
423
424 # optionally force using gas-preprocessor.pl for compatibility testing
425 AC_ARG_WITH([gas-preprocessor],
426   AC_HELP_STRING([--with-gas-preprocessor],
427     [Force using gas-preprocessor.pl on ARM.]))
428 if 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])
438 fi
439
440 # SIMD is optional
441 AC_ARG_WITH([simd],
442   AC_HELP_STRING([--without-simd], [Do not include SIMD extensions]))
443 if test "x$with_12bit" = "xyes"; then
444   with_simd=no
445 fi
446 if test "x${with_simd}" != "xno"; then
447   require_simd=no
448   if test "x${with_simd}" = "xyes"; then
449     require_simd=yes
450   fi
451   # 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
454     x86_64 | amd64)
455       AC_MSG_RESULT([yes (x86_64)])
456       AC_PROG_NASM
457       simd_arch=x86_64
458       ;;
459     i*86 | x86 | ia32)
460       AC_MSG_RESULT([yes (i386)])
461       AC_PROG_NASM
462       simd_arch=i386
463       ;;
464     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(
468         [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
473          simd_arch=arm],
474         [AC_MSG_RESULT([no])
475          with_simd=no])
476       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
482       fi
483       ;;
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(
488         [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
493          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
502       fi
503       ;;
504     mips*)
505       AC_MSG_RESULT([yes (mips)])
506       AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
507       AC_CHECK_COMPATIBLE_MIPS_ASSEMBLER_IFELSE(
508         [AC_MSG_RESULT([yes])
509          simd_arch=mips],
510         [AC_MSG_RESULT([no])
511          with_simd=no])
512       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
518       fi
519       ;;
520     powerpc*)
521       AC_CHECK_ALTIVEC(
522         [AC_MSG_RESULT([yes (powerpc)])
523          simd_arch=powerpc],
524         [AC_NO_SIMD(PowerPC SPE)])
525       ;;
526     *)
527       AC_NO_SIMD($host_cpu)
528       ;;
529   esac
530
531   if test "x${with_simd}" != "xno"; then
532     AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
533   fi
534 else
535   RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-simd"
536 fi
537
538 AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
539 AM_CONDITIONAL([WITH_SSE_FLOAT_DCT], [test "x$simd_arch" = "xx86_64" -o "x$simd_arch" = "xi386"])
540 AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
541 AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
542 AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
543 AM_CONDITIONAL([SIMD_ARM_64], [test "x$simd_arch" = "xaarch64"])
544 AM_CONDITIONAL([SIMD_MIPS], [test "x$simd_arch" = "xmips"])
545 AM_CONDITIONAL([SIMD_POWERPC], [test "x$simd_arch" = "xpowerpc"])
546 AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
547 AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
548 AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = "xyes"])
549
550 AC_ARG_VAR(PKGNAME, [distribution package name (default: libjpeg-turbo)])
551 if test "x$PKGNAME" = "x"; then
552   PKGNAME=$PACKAGE_NAME
553 fi
554 AC_SUBST(PKGNAME)
555
556 case "$host_cpu" in
557   x86_64)
558     RPMARCH=x86_64
559     DEBARCH=amd64
560     ;;
561   i*86 | x86 | ia32)
562     RPMARCH=i386
563     DEBARCH=i386
564     ;;
565   powerpc64le)
566     RPMARCH=`uname -m`
567     DEBARCH=ppc64el
568     ;;
569   powerpc)
570     RPMARCH=ppc
571     DEBARCH=ppc
572     ;;
573   *)
574     RPMARCH=`uname -m`
575     DEBARCH=$RPMARCH
576     ;;
577 esac
578
579 if test "${docdir}" = ""; then
580   docdir=${datadir}/doc
581   AC_SUBST(docdir)
582 fi
583
584 AC_SUBST(RPMARCH)
585 AC_SUBST(RPM_CONFIG_ARGS)
586 AC_SUBST(DEBARCH)
587 AC_SUBST(BUILD)
588 AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [libjpeg-turbo build number])
589
590 # 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.)
595 AC_CONFIG_HEADERS([config.h])
596 AC_CONFIG_HEADERS([jconfig.h])
597 AC_CONFIG_HEADERS([jconfigint.h])
598 AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.in])
599 AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in])
600 AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
601 AC_CONFIG_FILES([pkgscripts/makemacpkg.tmpl:release/makemacpkg.in])
602 AC_CONFIG_FILES([pkgscripts/uninstall.tmpl:release/uninstall.in])
603 AC_CONFIG_FILES([pkgscripts/libjpeg.pc:release/libjpeg.pc.in])
604 AC_CONFIG_FILES([pkgscripts/libturbojpeg.pc:release/libturbojpeg.pc.in])
605 if test "x$with_turbojpeg" != "xno"; then
606   AC_CONFIG_FILES([tjbenchtest])
607 fi
608 if test "x$with_java" = "xyes"; then
609   AC_CONFIG_FILES([tjbenchtest.java])
610   AC_CONFIG_FILES([tjexampletest])
611 fi
612 AC_CONFIG_FILES([libjpeg.map])
613 AC_CONFIG_FILES([Makefile simd/Makefile])
614 AC_CONFIG_FILES([java/Makefile])
615 AC_CONFIG_FILES([md5/Makefile])
616 AC_OUTPUT