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