configure.ac revision 6e0bbbf7e6287a10606d5c118bcf5c56b2a1a758
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.56])
5AC_INIT([libjpeg-turbo], [1.3.0])
6BUILD=`date +%Y%m%d`
7
8AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
9AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
10
11# Always build with prototypes
12AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
13
14# Checks for programs.
15SAVED_CFLAGS=${CFLAGS}
16SAVED_CPPFLAGS=${CPPFLAGS}
17AC_PROG_CPP
18AC_PROG_CC
19AM_PROG_AS
20AC_PROG_INSTALL
21AC_PROG_LIBTOOL
22AC_PROG_LN_S
23
24# When the prefix is /opt/libjpeg-turbo, we assume that an "official" binary is
25# being created, and thus we install things into specific locations.
26
27old_prefix=${prefix}
28if test "x$prefix" = "xNONE" -a "x$ac_default_prefix" != "x"; then
29  prefix=$ac_default_prefix
30fi
31DATADIR=`eval echo ${datadir}`
32DATADIR=`eval echo $DATADIR`
33if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
34  datadir='${prefix}'
35fi
36DATADIR=`eval echo ${datarootdir}`
37DATADIR=`eval echo $DATADIR`
38if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
39  datarootdir='${prefix}'
40fi
41
42old_exec_prefix=${exec_prefix}
43if test "x$exec_prefix" = "xNONE"; then
44  exec_prefix=${prefix}
45fi
46
47if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; then
48  LIBDIR=`eval echo ${libdir}`
49  LIBDIR=`eval echo $LIBDIR`
50  if test "$LIBDIR" = "/opt/libjpeg-turbo/lib"; then
51    case $host_os in
52      darwin*)
53        ;;
54      *)
55        case "$host_cpu" in
56          x86_64 | amd64)
57            libdir='${exec_prefix}/lib64'
58            ;;
59          i*86 | x86 | ia32)
60            libdir='${exec_prefix}/lib32'
61            ;;
62        esac
63        ;;
64    esac
65  fi
66fi
67exec_prefix=${old_exec_prefix}
68prefix=${old_prefix}
69
70# Check whether compiler supports pointers to undefined structures
71AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
72AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
73  AC_MSG_RESULT(yes),
74  [AC_MSG_RESULT(no)
75   AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
76     [Compiler does not support pointers to undefined structures.])])
77
78if test "x${GCC}" = "xyes"; then
79  if test "x${SAVED_CFLAGS}" = "x"; then
80    CFLAGS=-O3
81  fi
82  if test "x${SAVED_CPPFLAGS}" = "x"; then
83    CPPFLAGS=-Wall
84  fi
85fi
86
87AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
88if test "x${SUNCC}" = "xyes"; then
89  if test "x${SAVED_CFLAGS}" = "x"; then
90    CFLAGS=-xO5
91  fi
92fi
93
94# Checks for libraries.
95
96# Checks for header files.
97AC_HEADER_STDC
98AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
99AC_CHECK_HEADER([sys/types.h],
100  AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
101
102# Checks for typedefs, structures, and compiler characteristics.
103AC_C_CONST
104AC_C_CHAR_UNSIGNED
105AC_C_INLINE
106AC_TYPE_SIZE_T
107AC_CHECK_TYPES([unsigned char, unsigned short])
108
109AC_MSG_CHECKING([if right shift is signed])
110AC_TRY_RUN(
111  [#include <stdio.h>
112   int is_shifting_signed (long arg) {
113     long res = arg >> 4;
114
115     if (res == -0x7F7E80CL)
116       return 1; /* right shift is signed */
117
118     /* see if unsigned-shift hack will fix it. */
119     /* we can't just test exact value since it depends on width of long... */
120     res |= (~0L) << (32-4);
121     if (res == -0x7F7E80CL)
122       return 0; /* right shift is unsigned */
123
124     printf("Right shift isn't acting as I expect it to.\n");
125     printf("I fear the JPEG software will not work at all.\n\n");
126     return 0; /* try it with unsigned anyway */
127   }
128   int main (void) {
129     exit(is_shifting_signed(-0x7F7E80B1L));
130   }],
131  [AC_MSG_RESULT(no)
132   AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
133  [AC_MSG_RESULT(yes)],
134  [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
135
136# test whether global names are unique to at least 15 chars
137AC_MSG_CHECKING([for short external names])
138AC_TRY_LINK(
139  [int possibly_duplicate_function () { return 0; }
140   int possibly_dupli_function () { return 1; }], [ ],
141  [AC_MSG_RESULT(ok)],
142  [AC_MSG_RESULT(short)
143   AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1,
144     [Define if you need short function names])])
145
146# Checks for library functions.
147AC_CHECK_FUNCS([memset memcpy], [],
148  [AC_DEFINE([NEED_BSD_STRINGS], 1,
149     [Define if you have BSD-like bzero and bcopy])])
150
151AC_MSG_CHECKING([libjpeg API version])
152AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
153if test "x$JPEG_LIB_VERSION" = "x"; then
154  AC_ARG_WITH([jpeg7],
155    AC_HELP_STRING([--with-jpeg7],
156      [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
157  AC_ARG_WITH([jpeg8],
158    AC_HELP_STRING([--with-jpeg8],
159      [Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
160  if test "x${with_jpeg8}" = "xyes"; then
161    JPEG_LIB_VERSION=80
162  else
163    if test "x${with_jpeg7}" = "xyes"; then
164      JPEG_LIB_VERSION=70
165    else
166      JPEG_LIB_VERSION=62
167    fi
168  fi
169fi
170JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
171AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
172AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
173AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION],
174  [libjpeg API version])
175
176AC_ARG_VAR(SO_MAJOR_VERSION,
177  [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
178AC_ARG_VAR(SO_MINOR_VERSION,
179  [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
180if test "x$SO_MAJOR_VERSION" = "x"; then
181  case "$JPEG_LIB_VERSION" in
182    62)  SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
183    *)   SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
184  esac
185fi
186if test "x$SO_MINOR_VERSION" = "x"; then
187  case "$JPEG_LIB_VERSION" in
188    80)  SO_MINOR_VERSION=2 ;;
189    *)   SO_MINOR_VERSION=0 ;;
190  esac
191fi
192
193RPM_CONFIG_ARGS=
194
195# Memory source/destination managers
196SO_AGE=0
197MEM_SRCDST_FUNCTIONS=
198if test "x${with_jpeg8}" != "xyes"; then
199  AC_MSG_CHECKING([whether to include in-memory source/destination managers])
200  AC_ARG_WITH([mem-srcdst],
201    AC_HELP_STRING([--without-mem-srcdst],
202      [Do not include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI]))
203  if test "x$with_mem_srcdst" != "xno"; then
204    AC_MSG_RESULT(yes)
205    AC_DEFINE([MEM_SRCDST_SUPPORTED], [1],
206      [Support in-memory source/destination managers])
207    SO_AGE=1
208    MEM_SRCDST_FUNCTIONS="global:  jpeg_mem_dest;  jpeg_mem_src;";
209  else
210    AC_MSG_RESULT(no)
211    RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-mem-srcdst"
212  fi
213fi
214
215AC_MSG_CHECKING([libjpeg shared library version])
216AC_MSG_RESULT([$SO_MAJOR_VERSION.$SO_AGE.$SO_MINOR_VERSION])
217LIBTOOL_CURRENT=`expr $SO_MAJOR_VERSION + $SO_AGE`
218AC_SUBST(LIBTOOL_CURRENT)
219AC_SUBST(SO_MAJOR_VERSION)
220AC_SUBST(SO_MINOR_VERSION)
221AC_SUBST(SO_AGE)
222AC_SUBST(MEM_SRCDST_FUNCTIONS)
223
224AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
225
226VERSION_SCRIPT=yes
227AC_ARG_ENABLE([ld-version-script],
228  AS_HELP_STRING([--disable-ld-version-script],
229    [Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
230  [VERSION_SCRIPT=$enableval], [])
231
232AC_MSG_CHECKING([whether the linker supports version scripts])
233SAVED_LDFLAGS="$LDFLAGS"
234LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
235cat > conftest.map <<EOF
236VERS_1 {
237  global: *;
238};
239EOF
240AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
241  [VERSION_SCRIPT_FLAG=-Wl,--version-script,;
242   AC_MSG_RESULT([yes (GNU style)])],
243  [])
244if test "x$VERSION_SCRIPT_FLAG" = "x"; then
245  LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
246  AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
247    [VERSION_SCRIPT_FLAG=-Wl,-M,;
248     AC_MSG_RESULT([yes (Sun style)])],
249    [])
250fi
251if test "x$VERSION_SCRIPT_FLAG" = "x"; then
252  VERSION_SCRIPT=no
253  AC_MSG_RESULT(no)
254fi
255LDFLAGS="$SAVED_LDFLAGS"
256
257AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
258AC_MSG_RESULT($VERSION_SCRIPT)
259
260AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
261AC_SUBST(VERSION_SCRIPT_FLAG)
262
263# Check for non-broken inline under various spellings
264AC_MSG_CHECKING(for inline)
265ljt_cv_inline=""
266AC_TRY_COMPILE(, [} __attribute__((always_inline)) int foo() { return 0; }
267int bar() { return foo();], ljt_cv_inline="__attribute__((always_inline))",
268AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
269int bar() { return foo();], ljt_cv_inline="__inline__",
270AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
271int bar() { return foo();], ljt_cv_inline="__inline",
272AC_TRY_COMPILE(, [} inline int foo() { return 0; }
273int bar() { return foo();], ljt_cv_inline="inline"))))
274AC_MSG_RESULT($ljt_cv_inline)
275AC_DEFINE_UNQUOTED([INLINE],[$ljt_cv_inline],[How to obtain function inlining.])
276
277# Arithmetic coding support
278AC_MSG_CHECKING([whether to include arithmetic encoding support])
279AC_ARG_WITH([arith-enc],
280  AC_HELP_STRING([--without-arith-enc],
281    [Do not include arithmetic encoding support]))
282if test "x$with_arith_enc" = "xno"; then
283  AC_MSG_RESULT(no)
284  RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-enc"
285else
286  AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
287  AC_MSG_RESULT(yes)
288fi
289AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
290
291AC_MSG_CHECKING([whether to include arithmetic decoding support])
292AC_ARG_WITH([arith-dec],
293  AC_HELP_STRING([--without-arith-dec],
294    [Do not include arithmetic decoding support]))
295if test "x$with_arith_dec" = "xno"; then
296  AC_MSG_RESULT(no)
297  RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-arith-dec"
298else
299  AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
300  AC_MSG_RESULT(yes)
301fi
302AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
303
304AM_CONDITIONAL([WITH_ARITH],
305  [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
306
307# TurboJPEG support
308AC_MSG_CHECKING([whether to build TurboJPEG C wrapper])
309AC_ARG_WITH([turbojpeg],
310  AC_HELP_STRING([--without-turbojpeg],
311    [Do not include the TurboJPEG wrapper library and associated test programs]))
312if test "x$with_turbojpeg" = "xno"; then
313  AC_MSG_RESULT(no)
314  RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-turbojpeg"
315else
316  AC_MSG_RESULT(yes)
317fi
318
319# Java support
320AC_ARG_VAR(JAVAC, [Java compiler command (default: javac)])
321if test "x$JAVAC" = "x"; then
322  JAVAC=javac
323fi
324AC_SUBST(JAVAC)
325AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
326AC_SUBST(JAVACFLAGS)
327AC_ARG_VAR(JAR, [Java archive command (default: jar)])
328if test "x$JAR" = "x"; then
329  JAR=jar
330fi
331AC_SUBST(JAR)
332AC_ARG_VAR(JAVA, [Java runtime command (default: java)])
333if test "x$JAVA" = "x"; then
334  JAVA=java
335fi
336AC_SUBST(JAVA)
337AC_ARG_VAR(JNI_CFLAGS,
338  [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)])
339
340AC_MSG_CHECKING([whether to build TurboJPEG Java wrapper])
341AC_ARG_WITH([java],
342  AC_HELP_STRING([--with-java], [Build Java wrapper for the TurboJPEG library]))
343if test "x$with_turbojpeg" = "xno"; then
344  with_java=no
345fi
346
347WITH_JAVA=0
348if test "x$with_java" = "xyes"; then
349  AC_MSG_RESULT(yes)
350
351  case $host_os in
352    darwin*)
353      DEFAULT_JNI_CFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
354      ;;
355    solaris*)
356      DEFAULT_JNI_CFLAGS='-I/usr/java/include -I/usr/java/include/solaris'
357      ;;
358    linux*)
359      DEFAULT_JNI_CFLAGS='-I/usr/java/default/include -I/usr/java/default/include/linux'
360      ;;
361  esac
362  if test "x$JNI_CFLAGS" = "x"; then
363    JNI_CFLAGS=$DEFAULT_JNI_CFLAGS
364  fi
365
366  SAVE_CPPFLAGS=${CPPFLAGS}
367  CPPFLAGS="${CPPFLAGS} ${JNI_CFLAGS}"
368  AC_CHECK_HEADERS([jni.h], [DUMMY=1],
369    [AC_MSG_ERROR([Could not find JNI header file])])
370  CPPFLAGS=${SAVE_CPPFLAGS}
371  AC_SUBST(JNI_CFLAGS)
372
373  RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --with-java"
374  JAVA_RPM_CONTENTS_1='%dir %{_datadir}/classes'
375  JAVA_RPM_CONTENTS_2=%{_datadir}/classes/turbojpeg.jar
376  WITH_JAVA=1
377else
378  AC_MSG_RESULT(no)
379fi
380AM_CONDITIONAL([WITH_JAVA], [test "x$with_java" = "xyes"])
381AC_SUBST(WITH_JAVA)
382AC_SUBST(JAVA_RPM_CONTENTS_1)
383AC_SUBST(JAVA_RPM_CONTENTS_2)
384
385# optionally force using gas-preprocessor.pl for compatibility testing
386AC_ARG_WITH([gas-preprocessor],
387  AC_HELP_STRING([--with-gas-preprocessor],
388    [Force using gas-preprocessor.pl on ARM.]))
389if test "x${with_gas_preprocessor}" = "xyes"; then
390  case $host_os in
391    darwin*)
392      CCAS="gas-preprocessor.pl -fix-unreq $CC"
393      ;;
394    *)
395      CCAS="gas-preprocessor.pl -no-fix-unreq $CC"
396      ;;
397  esac
398  AC_SUBST([CCAS])
399fi
400
401# SIMD is optional
402AC_ARG_WITH([simd],
403  AC_HELP_STRING([--without-simd], [Do not include SIMD extensions]))
404if test "x${with_simd}" != "xno"; then
405  # Check if we're on a supported CPU
406  AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
407  case "$host_cpu" in
408    x86_64 | amd64)
409      AC_MSG_RESULT([yes (x86_64)])
410      AC_PROG_NASM
411      simd_arch=x86_64
412      ;;
413    i*86 | x86 | ia32)
414      AC_MSG_RESULT([yes (i386)])
415      AC_PROG_NASM
416      simd_arch=i386
417      ;;
418    arm*)
419      AC_MSG_RESULT([yes (arm)])
420      AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
421      AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE(
422        [AC_MSG_RESULT([yes])
423         simd_arch=arm],
424        [AC_MSG_RESULT([no])
425         with_simd=no
426         AC_MSG_WARN([SIMD support can't be enabled.  Performance will suffer.])])
427      ;;
428    *)
429      AC_MSG_RESULT([no ("$host_cpu")])
430      AC_MSG_WARN([SIMD support not available for this CPU.  Performance will suffer.])
431      with_simd=no;
432      ;;
433  esac
434
435  if test "x${with_simd}" != "xno"; then
436    AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
437  fi
438else
439  RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --without-simd"
440fi
441
442AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
443AM_CONDITIONAL([WITH_SSE_FLOAT_DCT], [test "x$simd_arch" = "xx86_64" -o "x$simd_arch" = "xi386"])
444AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
445AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
446AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
447AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
448AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
449
450AC_ARG_VAR(PKGNAME, [distribution package name (default: libjpeg-turbo)])
451if test "x$PKGNAME" = "x"; then
452  PKGNAME=$PACKAGE_NAME
453fi
454AC_SUBST(PKGNAME)
455
456case "$host_cpu" in
457  x86_64)
458    RPMARCH=x86_64
459    DEBARCH=amd64
460    ;;
461  i*86 | x86 | ia32)
462    RPMARCH=i386
463    DEBARCH=i386
464    ;;
465esac
466
467AC_SUBST(RPMARCH)
468AC_SUBST(RPM_CONFIG_ARGS)
469AC_SUBST(DEBARCH)
470AC_SUBST(BUILD)
471AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
472
473# jconfig.h is the file we use, but we have another before that to
474# fool autoheader. the reason is that we include this header in our
475# API headers, which can screw things up for users of the lib.
476# jconfig.h is a minimal version that allows this package to be built
477AC_CONFIG_HEADERS([config.h])
478AC_CONFIG_HEADERS([jconfig.h])
479AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.in])
480AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in])
481AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
482AC_CONFIG_FILES([pkgscripts/makemacpkg.tmpl:release/makemacpkg.in])
483AC_CONFIG_FILES([pkgscripts/Description.plist:release/Description.plist.in])
484AC_CONFIG_FILES([pkgscripts/Info.plist:release/Info.plist.in])
485AC_CONFIG_FILES([pkgscripts/uninstall.tmpl:release/uninstall.in])
486if test "x$with_turbojpeg" != "xno"; then
487  AC_CONFIG_FILES([tjbenchtest])
488fi
489if test "x$with_java" = "xyes"; then
490  AC_CONFIG_FILES([tjbenchtest.java])
491  AC_CONFIG_FILES([tjexampletest])
492fi
493AC_CONFIG_FILES([libjpeg.map])
494AC_CONFIG_FILES([Makefile simd/Makefile])
495AC_CONFIG_FILES([java/Makefile])
496AC_CONFIG_FILES([md5/Makefile])
497AC_OUTPUT
498