configure.ac revision bf0bdac1d392aaa0ec6dc636bbc224d3f449f15d
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.56])
5AC_INIT([libjpeg-turbo], [1.2.80])
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# Check whether compiler supports pointers to undefined structures
25AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
26AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
27AC_MSG_RESULT(yes),
28[AC_MSG_RESULT(no)
29AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to undefined structures.])])
30
31if test "x${GCC}" = "xyes"; then
32  if test "x${SAVED_CFLAGS}" = "x"; then
33    CFLAGS=-O3
34  fi
35  if test "x${SAVED_CPPFLAGS}" = "x"; then
36    CPPFLAGS=-Wall
37  fi
38fi
39
40AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
41if test "x${SUNCC}" = "xyes"; then
42  if test "x${SAVED_CFLAGS}" = "x"; then
43    CFLAGS=-xO5
44  fi
45fi
46
47# Checks for libraries.
48
49# Checks for header files.
50AC_HEADER_STDC
51AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
52AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
53
54# Checks for typedefs, structures, and compiler characteristics.
55AC_C_CONST
56AC_C_CHAR_UNSIGNED
57AC_C_INLINE
58AC_TYPE_SIZE_T
59AC_CHECK_TYPES([unsigned char, unsigned short])
60
61AC_MSG_CHECKING([if right shift is signed])
62AC_TRY_RUN(
63	[#include <stdio.h>
64	 int is_shifting_signed (long arg) {
65	 long res = arg >> 4;
66
67	 if (res == -0x7F7E80CL)
68		return 1; /* right shift is signed */
69
70	 /* see if unsigned-shift hack will fix it. */
71	 /* we can't just test exact value since it depends on width of long... */
72	 res |= (~0L) << (32-4);
73	 if (res == -0x7F7E80CL)
74		return 0; /* right shift is unsigned */
75
76	 printf("Right shift isn't acting as I expect it to.\n");
77	 printf("I fear the JPEG software will not work at all.\n\n");
78	 return 0; /* try it with unsigned anyway */
79	 }
80	 int main (void) {
81		exit(is_shifting_signed(-0x7F7E80B1L));
82	 }],
83	[AC_MSG_RESULT(no)
84	 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
85	[AC_MSG_RESULT(yes)],
86	[AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
87
88# test whether global names are unique to at least 15 chars
89AC_MSG_CHECKING([for short external names])
90AC_TRY_LINK(
91	[int possibly_duplicate_function () { return 0; }
92	 int possibly_dupli_function () { return 1; }], [ ],
93	[AC_MSG_RESULT(ok)],
94	[AC_MSG_RESULT(short)
95	 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
96
97# Checks for library functions.
98AC_CHECK_FUNCS([memset memcpy], [],
99	[AC_DEFINE([NEED_BSD_STRINGS], 1,
100		   [Define if you have BSD-like bzero and bcopy])])
101
102AC_MSG_CHECKING([libjpeg API version])
103AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
104if test "x$JPEG_LIB_VERSION" = "x"; then
105    AC_ARG_WITH([jpeg7],
106        AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
107    AC_ARG_WITH([jpeg8],
108        AC_HELP_STRING([--with-jpeg8], [Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
109    if test "x${with_jpeg8}" = "xyes"; then
110        JPEG_LIB_VERSION=80
111    else
112        if test "x${with_jpeg7}" = "xyes"; then
113            JPEG_LIB_VERSION=70
114        else
115            JPEG_LIB_VERSION=62
116        fi
117    fi
118fi
119JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
120AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
121AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
122AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION], [libjpeg API version])
123
124AC_MSG_CHECKING([libjpeg shared library version])
125AC_ARG_VAR(SO_MAJOR_VERSION, [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
126AC_ARG_VAR(SO_MINOR_VERSION, [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
127if test "x$SO_MAJOR_VERSION" = "x"; then
128    case "$JPEG_LIB_VERSION" in
129        62)  SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
130        *)   SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
131    esac
132fi
133if test "x$SO_MINOR_VERSION" = "x"; then
134    case "$JPEG_LIB_VERSION" in
135        80)  SO_MINOR_VERSION=2 ;;
136        *)   SO_MINOR_VERSION=0 ;;
137    esac
138fi
139AC_MSG_RESULT([$SO_MAJOR_VERSION:$SO_MINOR_VERSION])
140AC_SUBST(SO_MAJOR_VERSION)
141AC_SUBST(SO_MINOR_VERSION)
142
143AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
144
145VERSION_SCRIPT=yes
146AC_ARG_ENABLE([ld-version-script],
147  AS_HELP_STRING([--disable-ld-version-script],
148    [Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
149    [VERSION_SCRIPT=$enableval], [])
150
151AC_MSG_CHECKING([whether the linker supports version scripts])
152SAVED_LDFLAGS="$LDFLAGS"
153LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
154cat > conftest.map <<EOF
155VERS_1 {
156  global: *;
157};
158EOF
159AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
160  [VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], [])
161if test "x$VERSION_SCRIPT_FLAG" = "x"; then
162  LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
163  AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
164    [VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], [])
165fi
166if test "x$VERSION_SCRIPT_FLAG" = "x"; then
167  VERSION_SCRIPT=no
168  AC_MSG_RESULT(no)
169fi
170LDFLAGS="$SAVED_LDFLAGS"
171
172AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
173AC_MSG_RESULT($VERSION_SCRIPT)
174
175AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
176AC_SUBST(VERSION_SCRIPT_FLAG)
177
178# Check for non-broken inline under various spellings
179AC_MSG_CHECKING(for inline)
180ljt_cv_inline=""
181AC_TRY_COMPILE(, [} __attribute__((always_inline)) int foo() { return 0; }
182int bar() { return foo();], ljt_cv_inline="__attribute__((always_inline))",
183AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
184int bar() { return foo();], ljt_cv_inline="__inline__",
185AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
186int bar() { return foo();], ljt_cv_inline="__inline",
187AC_TRY_COMPILE(, [} inline int foo() { return 0; }
188int bar() { return foo();], ljt_cv_inline="inline"))))
189AC_MSG_RESULT($ljt_cv_inline)
190AC_DEFINE_UNQUOTED([INLINE],[$ljt_cv_inline],[How to obtain function inlining.])
191
192AC_MSG_CHECKING([whether to include arithmetic encoding support])
193AC_ARG_WITH([arith-enc],
194    AC_HELP_STRING([--without-arith-enc], [Omit arithmetic encoding support]))
195if test "x$with_arith_enc" = "xno"; then
196    AC_MSG_RESULT(no)
197else
198    AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
199    AC_MSG_RESULT(yes)
200fi
201AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
202
203AC_MSG_CHECKING([whether to include arithmetic decoding support])
204AC_ARG_WITH([arith-dec],
205    AC_HELP_STRING([--without-arith-dec], [Omit arithmetic decoding support]))
206if test "x$with_arith_dec" = "xno"; then
207    AC_MSG_RESULT(no)
208else
209    AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
210    AC_MSG_RESULT(yes)
211fi
212AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
213
214AM_CONDITIONAL([WITH_ARITH], [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
215
216AC_ARG_VAR(JAVAC, [Java compiler command (default: javac)])
217if test "x$JAVAC" = "x"; then
218  JAVAC=javac
219fi
220AC_SUBST(JAVAC)
221AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
222AC_SUBST(JAVACFLAGS)
223AC_ARG_VAR(JAR, [Java archive command (default: jar)])
224if test "x$JAR" = "x"; then
225  JAR=jar
226fi
227AC_SUBST(JAR)
228AC_ARG_VAR(JAVA, [Java runtime command (default: java)])
229if test "x$JAVA" = "x"; then
230  JAVA=java
231fi
232AC_SUBST(JAVA)
233AC_ARG_VAR(JNI_CFLAGS, [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)])
234
235AC_MSG_CHECKING([whether to build TurboJPEG/OSS Java wrapper])
236AC_ARG_WITH([java],
237    AC_HELP_STRING([--with-java],[Build Java wrapper for the TurboJPEG/OSS library]))
238
239RPM_CONFIG_ARGS=
240WITH_JAVA=0
241if test "x$with_java" = "xyes"; then
242    AC_MSG_RESULT(yes)
243
244    case $host_os in
245      darwin*)
246        DEFAULT_JNI_CFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
247        ;;
248      solaris*)
249        DEFAULT_JNI_CFLAGS='-I/usr/java/include -I/usr/java/include/solaris'
250        ;;
251      linux*)
252        DEFAULT_JNI_CFLAGS='-I/usr/java/default/include -I/usr/java/default/include/linux'
253        ;;
254    esac
255    if test "x$JNI_CFLAGS" = "x"; then
256        JNI_CFLAGS=$DEFAULT_JNI_CFLAGS
257    fi
258
259    SAVE_CPPFLAGS=${CPPFLAGS}
260    CPPFLAGS="${CPPFLAGS} ${JNI_CFLAGS}"
261    AC_CHECK_HEADERS([jni.h], [DUMMY=1],
262        [AC_MSG_ERROR([Could not find JNI header file])])
263    CPPFLAGS=${SAVE_CPPFLAGS}
264    AC_SUBST(JNI_CFLAGS)
265
266    RPM_CONFIG_ARGS=--with-java
267    JAVA_RPM_CONTENTS_1='%dir /opt/%{name}/classes'
268    JAVA_RPM_CONTENTS_2=/opt/%{name}/classes/turbojpeg.jar
269    WITH_JAVA=1
270else
271    AC_MSG_RESULT(no)
272fi
273AM_CONDITIONAL([WITH_JAVA], [test "x$with_java" = "xyes"])
274AC_SUBST(WITH_JAVA)
275AC_SUBST(JAVA_RPM_CONTENTS_1)
276AC_SUBST(JAVA_RPM_CONTENTS_2)
277AC_SUBST(RPM_CONFIG_ARGS)
278
279# optionally force using gas-preprocessor.pl for compatibility testing
280AC_ARG_WITH([gas-preprocessor],
281    AC_HELP_STRING([--with-gas-preprocessor],[Force using gas-preprocessor.pl on ARM.]))
282if test "x${with_gas_preprocessor}" = "xyes"; then
283  case $host_os in
284    darwin*)
285      CCAS="gas-preprocessor.pl -fix-unreq $CC"
286      ;;
287    *)
288      CCAS="gas-preprocessor.pl -no-fix-unreq $CC"
289      ;;
290  esac
291  AC_SUBST([CCAS])
292fi
293
294# SIMD is optional
295AC_ARG_WITH([simd],
296    AC_HELP_STRING([--without-simd],[Omit SIMD extensions.]))
297if test "x${with_simd}" != "xno"; then
298  # Check if we're on a supported CPU
299  AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
300  case "$host_cpu" in
301    x86_64 | amd64)
302      AC_MSG_RESULT([yes (x86_64)])
303      AC_PROG_NASM
304      simd_arch=x86_64
305    ;;
306    i*86 | x86 | ia32)
307      AC_MSG_RESULT([yes (i386)])
308      AC_PROG_NASM
309      simd_arch=i386
310    ;;
311    arm*)
312      AC_MSG_RESULT([yes (arm)])
313      AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
314      AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE(
315        [AC_MSG_RESULT([yes])
316         simd_arch=arm],
317        [AC_MSG_RESULT([no])
318         with_simd=no
319         AC_MSG_WARN([SIMD support can't be enabled.  Performance will suffer.])])
320    ;;
321    *)
322      AC_MSG_RESULT([no ("$host_cpu")])
323      AC_MSG_WARN([SIMD support not available for this CPU.  Performance will suffer.])
324      with_simd=no;
325    ;;
326  esac
327
328  if test "x${with_simd}" != "xno"; then
329    AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
330  fi
331fi
332
333AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
334AM_CONDITIONAL([WITH_SSE_FLOAT_DCT], [test "x$simd_arch" = "xx86_64" -o "x$simd_arch" = "xi386"])
335AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
336AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
337AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
338AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
339
340case "$host_cpu" in
341  x86_64)
342    RPMARCH=x86_64
343    DEBARCH=amd64
344    ;;
345  i*86 | x86 | ia32)
346    RPMARCH=i386
347    DEBARCH=i386
348    ;;
349esac
350
351AC_SUBST(RPMARCH)
352AC_SUBST(DEBARCH)
353AC_SUBST(BUILD)
354AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
355
356# jconfig.h is the file we use, but we have another before that to
357# fool autoheader. the reason is that we include this header in our
358# API headers, which can screw things up for users of the lib.
359# jconfig.h is a minimal version that allows this package to be built
360AC_CONFIG_HEADERS([config.h])
361AC_CONFIG_HEADERS([jconfig.h])
362AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec:release/libjpeg-turbo.spec.in])
363AC_CONFIG_FILES([pkgscripts/makecygwinpkg:release/makecygwinpkg.in])
364AC_CONFIG_FILES([pkgscripts/makedpkg:release/makedpkg.in])
365AC_CONFIG_FILES([pkgscripts/makemacpkg:release/makemacpkg.in])
366AC_CONFIG_FILES([pkgscripts/Description.plist:release/Description.plist.in])
367AC_CONFIG_FILES([pkgscripts/Info.plist:release/Info.plist.in])
368AC_CONFIG_FILES([pkgscripts/uninstall:release/uninstall.in])
369AC_CONFIG_FILES([pkgscripts/makesunpkg:release/makesunpkg.in])
370AC_CONFIG_FILES([pkgscripts/pkginfo:release/pkginfo.in])
371AC_CONFIG_FILES([libjpeg.map])
372AC_CONFIG_FILES([Makefile simd/Makefile])
373AC_CONFIG_FILES([java/Makefile])
374AC_OUTPUT
375