| 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 |
|
| 8 |
AC_INIT([libjpeg], [9.2.0]) |
| 9 |
|
| 10 |
# Directory where autotools helper scripts lives. |
| 11 |
AC_CONFIG_AUX_DIR([.]) |
| 12 |
|
| 13 |
# Generate configuration headers. |
| 14 |
AC_CONFIG_HEADERS([jconfig.h:jconfig.cfg]) |
| 15 |
|
| 16 |
# Hack: disable autoheader so that it doesn't overwrite our cfg template. |
| 17 |
AUTOHEADER="echo autoheader ignored" |
| 18 |
|
| 19 |
# Check system type |
| 20 |
AC_CANONICAL_TARGET |
| 21 |
|
| 22 |
# Initialize Automake |
| 23 |
# Don't require all the GNU mandated files |
| 24 |
AM_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". |
| 29 |
AM_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. |
| 34 |
AM_MAINTAINER_MODE |
| 35 |
|
| 36 |
# Check for programs |
| 37 |
AC_PROG_CC |
| 38 |
AC_PROG_CC_STDC |
| 39 |
AC_PROG_CPP |
| 40 |
AC_PROG_INSTALL |
| 41 |
AC_PROG_MAKE_SET |
| 42 |
AC_PROG_LN_S |
| 43 |
AM_PROG_AR |
| 44 |
|
| 45 |
# Check if LD supports linker scripts, |
| 46 |
# and define automake conditional HAVE_LD_VERSION_SCRIPT if so. |
| 47 |
AC_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], []) |
| 51 |
if 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 |
| 56 |
VERS_1 { |
| 57 |
global: sym; |
| 58 |
}; |
| 59 |
|
| 60 |
VERS_2 { |
| 61 |
global: sym; |
| 62 |
} VERS_1; |
| 63 |
EOF |
| 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) |
| 69 |
fi |
| 70 |
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") |
| 71 |
|
| 72 |
# See if compiler supports prototypes. |
| 73 |
AC_MSG_CHECKING([for function prototypes]) |
| 74 |
AC_CACHE_VAL([ijg_cv_have_prototypes], |
| 75 |
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ |
| 76 |
int testfunction (int arg1, int * arg2); /* check prototypes */ |
| 77 |
struct methods_struct { /* check method-pointer declarations */ |
| 78 |
int (*error_exit) (char *msgtext); |
| 79 |
int (*trace_message) (char *msgtext); |
| 80 |
int (*another_method) (void); |
| 81 |
}; |
| 82 |
int testfunction (int arg1, int * arg2) /* check definitions */ |
| 83 |
{ return arg2[arg1]; } |
| 84 |
int test2function (void) /* check void arg list */ |
| 85 |
{ return 0; } |
| 86 |
]])], |
| 87 |
[ijg_cv_have_prototypes=yes], |
| 88 |
[ijg_cv_have_prototypes=no])]) |
| 89 |
AC_MSG_RESULT([$ijg_cv_have_prototypes]) |
| 90 |
if test $ijg_cv_have_prototypes = yes; then |
| 91 |
AC_DEFINE([HAVE_PROTOTYPES],[1],[Compiler supports function prototypes.]) |
| 92 |
else |
| 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.]) |
| 98 |
fi |
| 99 |
|
| 100 |
# Check header files |
| 101 |
AC_CHECK_HEADERS([stddef.h stdlib.h locale.h]) |
| 102 |
AC_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>. |
| 108 |
AC_MSG_CHECKING([for size_t]) |
| 109 |
AC_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 |
| 122 |
typedef 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"]) |
| 127 |
AC_MSG_RESULT([$ijg_size_t_ok]) |
| 128 |
if 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 |
| 141 |
fi |
| 142 |
|
| 143 |
# Check compiler characteristics |
| 144 |
AC_MSG_CHECKING([for type unsigned char]) |
| 145 |
AC_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 |
|
| 151 |
AC_MSG_CHECKING([for type unsigned short]) |
| 152 |
AC_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 |
|
| 158 |
AC_MSG_CHECKING([for type void]) |
| 159 |
AC_TRY_COMPILE([ |
| 160 |
/* Caution: a C++ compiler will insist on valid prototypes */ |
| 161 |
typedef void * void_ptr; /* check void * */ |
| 162 |
#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ |
| 163 |
typedef void (*void_func) (int a, int b); |
| 164 |
#else |
| 165 |
typedef void (*void_func) (); |
| 166 |
#endif |
| 167 |
|
| 168 |
#ifdef HAVE_PROTOTYPES /* check void function result */ |
| 169 |
void test3function (void_ptr arg1, void_func arg2) |
| 170 |
#else |
| 171 |
void 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.])]) |
| 186 |
AC_C_CONST |
| 187 |
|
| 188 |
# Check for non-broken inline under various spellings |
| 189 |
AC_MSG_CHECKING([for inline]) |
| 190 |
ijg_cv_inline="" |
| 191 |
AC_TRY_COMPILE([], [} __inline__ int foo() { return 0; } |
| 192 |
int bar() { return foo();], ijg_cv_inline="__inline__", |
| 193 |
[AC_TRY_COMPILE(, [} __inline int foo() { return 0; } |
| 194 |
int bar() { return foo();], ijg_cv_inline="__inline", |
| 195 |
[AC_TRY_COMPILE(, [} inline int foo() { return 0; } |
| 196 |
int bar() { return foo();], ijg_cv_inline="inline")])]) |
| 197 |
AC_MSG_RESULT($ijg_cv_inline) |
| 198 |
AC_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 |
| 202 |
AC_MSG_CHECKING([for broken incomplete types]) |
| 203 |
AC_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 |
| 212 |
AC_MSG_CHECKING([for short external names]) |
| 213 |
AC_TRY_LINK([ |
| 214 |
int possibly_duplicate_function () { return 0; } |
| 215 |
int 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 |
| 224 |
AC_MSG_CHECKING([to see if char is signed]) |
| 225 |
AC_TRY_RUN([ |
| 226 |
#ifdef HAVE_STDLIB_H |
| 227 |
#include <stdlib.h> |
| 228 |
#endif |
| 229 |
#include <stdio.h> |
| 230 |
#ifdef HAVE_PROTOTYPES |
| 231 |
int is_char_signed (int arg) |
| 232 |
#else |
| 233 |
int 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 |
} |
| 246 |
char signed_char_check = (char) (-67); |
| 247 |
int 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 |
|
| 257 |
AC_MSG_CHECKING([to see if right shift is signed]) |
| 258 |
AC_TRY_RUN([ |
| 259 |
#ifdef HAVE_STDLIB_H |
| 260 |
#include <stdlib.h> |
| 261 |
#endif |
| 262 |
#include <stdio.h> |
| 263 |
#ifdef HAVE_PROTOTYPES |
| 264 |
int is_shifting_signed (long arg) |
| 265 |
#else |
| 266 |
int 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 |
} |
| 286 |
int 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 |
|
| 295 |
AC_MSG_CHECKING([to see if fopen accepts b spec]) |
| 296 |
AC_TRY_RUN([ |
| 297 |
#ifdef HAVE_STDLIB_H |
| 298 |
#include <stdlib.h> |
| 299 |
#endif |
| 300 |
#include <stdio.h> |
| 301 |
int 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 |
| 313 |
AC_LIBTOOL_WIN32_DLL |
| 314 |
AC_PROG_LIBTOOL |
| 315 |
|
| 316 |
# Select memory manager depending on user input. |
| 317 |
# If no "-enable-maxmem", use jmemnobs |
| 318 |
MEMORYMGR='jmemnobs' |
| 319 |
MAXMEM="no" |
| 320 |
AC_ARG_ENABLE([maxmem], |
| 321 |
[ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB], |
| 322 |
[MAXMEM="$enableval"]) |
| 323 |
dnl [# support --with-maxmem for backwards compatibility with IJG V5.] |
| 324 |
dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval") |
| 325 |
if test "x$MAXMEM" = xyes; then |
| 326 |
MAXMEM=1 |
| 327 |
fi |
| 328 |
if 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.])])]) |
| 353 |
fi |
| 354 |
AC_SUBST([MEMORYMGR]) |
| 355 |
|
| 356 |
# Extract the library version IDs from jpeglib.h. |
| 357 |
AC_MSG_CHECKING([libjpeg version number]) |
| 358 |
[major=`sed -ne 's/^#define JPEG_LIB_VERSION_MAJOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h` |
| 359 |
minor=`sed -ne 's/^#define JPEG_LIB_VERSION_MINOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`] |
| 360 |
AC_SUBST([JPEG_LIB_VERSION], |
| 361 |
[`expr $major + $minor`:0:$minor]) |
| 362 |
AC_MSG_RESULT([$JPEG_LIB_VERSION]) |
| 363 |
|
| 364 |
AC_CONFIG_FILES([Makefile]) |
| 365 |
AC_OUTPUT |