1# IJG auto-configuration source file. 2# Process this file with autoconf to produce a configure script. 3 4# 5# Configure script for IJG libjpeg 6# 7 8AC_INIT([libjpeg], [9.4.0]) 9 10# Directory where autotools helper scripts lives. 11AC_CONFIG_AUX_DIR([.]) 12 13# Generate configuration headers. 14AC_CONFIG_HEADERS([jconfig.h:jconfig.cfg]) 15 16# Hack: disable autoheader so that it doesn't overwrite our cfg template. 17AUTOHEADER="echo autoheader ignored" 18 19# Check system type 20AC_CANONICAL_TARGET 21 22# Initialize Automake 23# Don't require all the GNU mandated files 24AM_INIT_AUTOMAKE([-Wall -Werror no-dist foreign]) 25 26# Make --enable-silent-rules the default. 27# To get verbose build output you may configure 28# with --disable-silent-rules or use "make V=1". 29AM_SILENT_RULES([yes]) 30 31# Add configure option --enable-maintainer-mode which enables 32# dependency checking and generation useful to package maintainers. 33# This is made an option to avoid confusing end users. 34AM_MAINTAINER_MODE 35 36# Check for programs 37AC_PROG_CC 38AC_PROG_CC_STDC 39AC_PROG_CPP 40AC_PROG_INSTALL 41AC_PROG_MAKE_SET 42AC_PROG_LN_S 43AM_PROG_AR 44 45# Check if LD supports linker scripts, 46# and define automake conditional HAVE_LD_VERSION_SCRIPT if so. 47AC_ARG_ENABLE([ld-version-script], 48 AS_HELP_STRING([--enable-ld-version-script], 49 [enable linker version script (default is enabled when possible)]), 50 [have_ld_version_script=$enableval], []) 51if test -z "$have_ld_version_script"; then 52 AC_MSG_CHECKING([if LD -Wl,--version-script works]) 53 save_LDFLAGS="$LDFLAGS" 54 LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" 55 cat > conftest.map <<EOF 56VERS_1 { 57 global: sym; 58}; 59 60VERS_2 { 61 global: sym; 62} VERS_1; 63EOF 64 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], 65 [have_ld_version_script=yes], [have_ld_version_script=no]) 66 rm -f conftest.map 67 LDFLAGS="$save_LDFLAGS" 68 AC_MSG_RESULT($have_ld_version_script) 69fi 70AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") 71 72# See if compiler supports prototypes. 73AC_MSG_CHECKING([for function prototypes]) 74AC_CACHE_VAL([ijg_cv_have_prototypes], 75[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 76int testfunction (int arg1, int * arg2); /* check prototypes */ 77struct methods_struct { /* check method-pointer declarations */ 78 int (*error_exit) (char *msgtext); 79 int (*trace_message) (char *msgtext); 80 int (*another_method) (void); 81}; 82int testfunction (int arg1, int * arg2) /* check definitions */ 83{ return arg2[arg1]; } 84int test2function (void) /* check void arg list */ 85{ return 0; } 86]])], 87 [ijg_cv_have_prototypes=yes], 88 [ijg_cv_have_prototypes=no])]) 89AC_MSG_RESULT([$ijg_cv_have_prototypes]) 90if test $ijg_cv_have_prototypes = yes; then 91 AC_DEFINE([HAVE_PROTOTYPES],[1],[Compiler supports function prototypes.]) 92else 93 AC_MSG_WARN([Your compiler does not seem to know about function prototypes. 94 Perhaps it needs a special switch to enable ANSI C mode. 95 If so, we recommend running configure like this: 96 ./configure CC='cc -switch' 97 where -switch is the proper switch.]) 98fi 99 100# Check header files 101AC_CHECK_HEADERS([stddef.h stdlib.h locale.h]) 102AC_CHECK_HEADER([string.h], [], 103 [AC_DEFINE([NEED_BSD_STRINGS], [1], 104 [Compiler has <strings.h> rather than standard <string.h>.])]) 105 106# See whether type size_t is defined in any ANSI-standard places; 107# if not, perhaps it is defined in <sys/types.h>. 108AC_MSG_CHECKING([for size_t]) 109AC_TRY_COMPILE([ 110#ifdef HAVE_STDDEF_H 111#include <stddef.h> 112#endif 113#ifdef HAVE_STDLIB_H 114#include <stdlib.h> 115#endif 116#include <stdio.h> 117#ifdef NEED_BSD_STRINGS 118#include <strings.h> 119#else 120#include <string.h> 121#endif 122typedef size_t my_size_t; 123], 124 [ my_size_t foovar; ], 125 [ijg_size_t_ok=yes], 126 [ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"]) 127AC_MSG_RESULT([$ijg_size_t_ok]) 128if test "$ijg_size_t_ok" != yes; then 129 AC_CHECK_HEADER([sys/types.h], 130 [AC_DEFINE([NEED_SYS_TYPES_H], [1], 131 [Need to include <sys/types.h> in order to obtain size_t.]) 132 AC_EGREP_CPP([size_t], [#include <sys/types.h>], 133 [ijg_size_t_ok="size_t is in sys/types.h"], 134 [ijg_size_t_ok=no])], 135 [ijg_size_t_ok=no]) 136 AC_MSG_RESULT([$ijg_size_t_ok]) 137 if test "$ijg_size_t_ok" = no; then 138 AC_MSG_WARN([Type size_t is not defined in any of the usual places. 139 Try putting '"typedef unsigned int size_t;"' in jconfig.h.]) 140 fi 141fi 142 143# Check compiler characteristics 144AC_MSG_CHECKING([for type unsigned char]) 145AC_TRY_COMPILE([], [ unsigned char un_char; ], 146 [AC_MSG_RESULT(yes) 147 AC_DEFINE([HAVE_UNSIGNED_CHAR], [1], 148 [Compiler supports 'unsigned char'.])], 149 [AC_MSG_RESULT(no)]) 150 151AC_MSG_CHECKING([for type unsigned short]) 152AC_TRY_COMPILE([], [ unsigned short un_short; ], 153 [AC_MSG_RESULT(yes) 154 AC_DEFINE([HAVE_UNSIGNED_SHORT], [1], 155 [Compiler supports 'unsigned short'.])], 156 [AC_MSG_RESULT(no)]) 157 158AC_MSG_CHECKING([for type void]) 159AC_TRY_COMPILE([ 160/* Caution: a C++ compiler will insist on valid prototypes */ 161typedef void * void_ptr; /* check void * */ 162#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ 163typedef void (*void_func) (int a, int b); 164#else 165typedef void (*void_func) (); 166#endif 167 168#ifdef HAVE_PROTOTYPES /* check void function result */ 169void test3function (void_ptr arg1, void_func arg2) 170#else 171void test3function (arg1, arg2) 172 void_ptr arg1; 173 void_func arg2; 174#endif 175{ 176 char * locptr = (char *) arg1; /* check casting to and from void * */ 177 arg1 = (void *) locptr; 178 (*arg2) (1, 2); /* check call of fcn returning void */ 179} 180], [ ], 181 [AC_MSG_RESULT(yes)], 182 [AC_MSG_RESULT(no) 183 AC_DEFINE([void], [char], 184 [Define 'void' as 'char' for archaic compilers 185 that don't understand it.])]) 186AC_C_CONST 187 188# Check for non-broken inline under various spellings 189AC_MSG_CHECKING([for inline]) 190ijg_cv_inline="" 191AC_TRY_COMPILE([], [} __inline__ int foo() { return 0; } 192int bar() { return foo();], ijg_cv_inline="__inline__", 193[AC_TRY_COMPILE(, [} __inline int foo() { return 0; } 194int bar() { return foo();], ijg_cv_inline="__inline", 195[AC_TRY_COMPILE(, [} inline int foo() { return 0; } 196int bar() { return foo();], ijg_cv_inline="inline")])]) 197AC_MSG_RESULT($ijg_cv_inline) 198AC_DEFINE_UNQUOTED([INLINE], [$ijg_cv_inline], 199 [How to obtain function inlining.]) 200 201# We cannot check for bogus warnings, but at least we can check for errors 202AC_MSG_CHECKING([for broken incomplete types]) 203AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], 204 [], 205 [AC_MSG_RESULT(ok)], 206 [AC_MSG_RESULT(broken) 207 AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1], 208 [Compiler does not support pointers to unspecified 209 structures.])]) 210 211# Test whether global names are unique to at least 15 chars 212AC_MSG_CHECKING([for short external names]) 213AC_TRY_LINK([ 214int possibly_duplicate_function () { return 0; } 215int possibly_dupli_function () { return 1; } 216], [], 217 [AC_MSG_RESULT(ok)], 218 [AC_MSG_RESULT(short) 219 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], [1], 220 [Linker requires that global names be unique in 221 first 15 characters.])]) 222 223# Run-time checks 224AC_MSG_CHECKING([to see if char is signed]) 225AC_TRY_RUN([ 226#ifdef HAVE_STDLIB_H 227#include <stdlib.h> 228#endif 229#include <stdio.h> 230#ifdef HAVE_PROTOTYPES 231int is_char_signed (int arg) 232#else 233int is_char_signed (arg) 234 int arg; 235#endif 236{ 237 if (arg == 189) { /* expected result for unsigned char */ 238 return 0; /* type char is unsigned */ 239 } 240 else if (arg != -67) { /* expected result for signed char */ 241 printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); 242 printf("I fear the JPEG software will not work at all.\n\n"); 243 } 244 return 1; /* assume char is signed otherwise */ 245} 246char signed_char_check = (char) (-67); 247int main() { 248 exit(is_char_signed((int) signed_char_check)); 249}], [AC_MSG_RESULT(no) 250 AC_DEFINE([CHAR_IS_UNSIGNED], [1], 251 [Characters are unsigned])], 252 [AC_MSG_RESULT(yes)], 253[AC_MSG_WARN([Assuming that char is signed on target machine. 254 If it is unsigned, this will be a little bit inefficient.]) 255]) 256 257AC_MSG_CHECKING([to see if right shift is signed]) 258AC_TRY_RUN([ 259#ifdef HAVE_STDLIB_H 260#include <stdlib.h> 261#endif 262#include <stdio.h> 263#ifdef HAVE_PROTOTYPES 264int is_shifting_signed (long arg) 265#else 266int is_shifting_signed (arg) 267 long arg; 268#endif 269/* See whether right-shift on a long is signed or not. */ 270{ 271 long res = arg >> 4; 272 273 if (res == -0x7F7E80CL) { /* expected result for signed shift */ 274 return 1; /* right shift is signed */ 275 } 276 /* see if unsigned-shift hack will fix it. */ 277 /* we can't just test exact value since it depends on width of long... */ 278 res |= (~0L) << (32-4); 279 if (res == -0x7F7E80CL) { /* expected result now? */ 280 return 0; /* right shift is unsigned */ 281 } 282 printf("Right shift isn't acting as I expect it to.\n"); 283 printf("I fear the JPEG software will not work at all.\n\n"); 284 return 0; /* try it with unsigned anyway */ 285} 286int main() { 287 exit(is_shifting_signed(-0x7F7E80B1L)); 288}], 289 [AC_MSG_RESULT(no) 290 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], [1], 291 [Broken compiler shifts signed values as an unsigned shift.])], 292 [AC_MSG_RESULT(yes)], 293 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)]) 294 295AC_MSG_CHECKING([to see if fopen accepts b spec]) 296AC_TRY_RUN([ 297#ifdef HAVE_STDLIB_H 298#include <stdlib.h> 299#endif 300#include <stdio.h> 301int main() { 302 if (fopen("conftestdata", "wb") != NULL) 303 exit(0); 304 exit(1); 305}], 306 [AC_MSG_RESULT(yes)], 307 [AC_MSG_RESULT(no) 308 AC_DEFINE([DONT_USE_B_MODE], [1], 309 [Don't open files in binary mode.])], 310 [AC_MSG_RESULT(Assuming that it does.)]) 311 312# Configure libtool 313AC_LIBTOOL_WIN32_DLL 314AC_PROG_LIBTOOL 315 316# Select memory manager depending on user input. 317# If no "-enable-maxmem", use jmemnobs 318MEMORYMGR='jmemnobs' 319MAXMEM="no" 320AC_ARG_ENABLE([maxmem], 321[ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB], 322[MAXMEM="$enableval"]) 323dnl [# support --with-maxmem for backwards compatibility with IJG V5.] 324dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval") 325if test "x$MAXMEM" = xyes; then 326 MAXMEM=1 327fi 328if test "x$MAXMEM" != xno; then 329 if test -n "`echo $MAXMEM | sed 's/[[0-9]]//g'`"; then 330 AC_MSG_ERROR(non-numeric argument to --enable-maxmem) 331 fi 332 DEFAULTMAXMEM=`expr $MAXMEM \* 1048576` 333 AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}], 334 [Maximum data space library will allocate.]) 335 AC_MSG_CHECKING([for 'tmpfile()']) 336 AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ], 337 [AC_MSG_RESULT(yes) 338 MEMORYMGR='jmemansi'], 339 [AC_MSG_RESULT(no) 340 dnl if tmpfile is not present, must use jmemname. 341 MEMORYMGR='jmemname' 342 343 # Test for the need to remove temporary files using a signal handler 344 # (for cjpeg/djpeg) 345 AC_DEFINE([NEED_SIGNAL_CATCHER], [1], 346 [Need signal handler to clean up temporary files.]) 347 AC_MSG_CHECKING([for 'mktemp()']) 348 AC_TRY_LINK([], [ char fname[80]; mktemp(fname); ], 349 [AC_MSG_RESULT(yes)], 350 [AC_MSG_RESULT(no) 351 AC_DEFINE([NO_MKTEMP], [1], 352 [The mktemp() function is not available.])])]) 353fi 354AC_SUBST([MEMORYMGR]) 355 356# Extract the library version IDs from jpeglib.h. 357AC_MSG_CHECKING([libjpeg version number]) 358[major=`sed -ne 's/^#define JPEG_LIB_VERSION_MAJOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h` 359minor=`sed -ne 's/^#define JPEG_LIB_VERSION_MINOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`] 360AC_SUBST([JPEG_LIB_VERSION], [`expr $major + $minor`:0:$minor]) 361AC_SUBST([JPEG_LIB_VERSION_MAJOR], [$major]) 362AC_SUBST([JPEG_LIB_VERSION_MINOR], [$minor]) 363AC_MSG_RESULT([$major.$minor.0]) 364 365AC_CONFIG_FILES([Makefile libjpeg.pc]) 366AC_OUTPUT 367