1
# IJG auto-configuration source file.
2
# Process this file with autoconf to produce a configure script.
5
# Configure script for IJG libjpeg
8
AC_INIT([libjpeg], [8.0.2])
10
# Directory where autotools helper scripts lives.
11
AC_CONFIG_AUX_DIR([.])
13
# Generate configuration headers.
14
AC_CONFIG_HEADERS([jconfig.h:jconfig.cfg])
16
# Hack: disable autoheader so that it doesn't overwrite our cfg template.
17
AUTOHEADER="echo autoheader ignored"
23
# Don't require all the GNU mandated files
24
AM_INIT_AUTOMAKE([-Wall -Werror ansi2knr no-dist foreign])
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])
31
# This is required when using the de-ANSI-fication feature.
34
# Add configure option --enable-maintainer-mode which enables
35
# dependency checking and generation useful to package maintainers.
36
# This is made an option to avoid confusing end users.
47
# Check if LD supports linker scripts,
48
# and define automake conditional HAVE_LD_VERSION_SCRIPT if so.
49
AC_ARG_ENABLE([ld-version-script],
50
AS_HELP_STRING([--enable-ld-version-script],
51
[enable linker version script (default is enabled when possible)]),
52
[have_ld_version_script=$enableval], [])
53
if test -z "$have_ld_version_script"; then
54
AC_MSG_CHECKING([if LD -Wl,--version-script works])
55
save_LDFLAGS="$LDFLAGS"
56
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
57
cat > conftest.map <<EOF
66
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
67
[have_ld_version_script=yes], [have_ld_version_script=no])
69
LDFLAGS="$save_LDFLAGS"
70
AC_MSG_RESULT($have_ld_version_script)
72
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
74
# See if compiler supports prototypes.
75
AC_MSG_CHECKING(for function prototypes)
76
AC_CACHE_VAL(ijg_cv_have_prototypes,
78
int testfunction (int arg1, int * arg2); /* check prototypes */
79
struct methods_struct { /* check method-pointer declarations */
80
int (*error_exit) (char *msgtext);
81
int (*trace_message) (char *msgtext);
82
int (*another_method) (void);
84
int testfunction (int arg1, int * arg2) /* check definitions */
85
{ return arg2[arg1]; }
86
int test2function (void) /* check void arg list */
88
], [ ], ijg_cv_have_prototypes=yes, 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.])
93
echo Your compiler does not seem to know about function prototypes.
94
echo Perhaps it needs a special switch to enable ANSI C mode.
95
echo If so, we recommend running configure like this:
96
echo " ./configure CC='cc -switch'"
97
echo where -switch is the proper switch.
101
AC_CHECK_HEADERS(stddef.h stdlib.h locale.h)
102
AC_CHECK_HEADER(string.h, , AC_DEFINE([NEED_BSD_STRINGS],[1],[Compiler has <strings.h> rather than standard <string.h>.]))
104
# See whether type size_t is defined in any ANSI-standard places;
105
# if not, perhaps it is defined in <sys/types.h>.
106
AC_MSG_CHECKING(for size_t)
115
#ifdef NEED_BSD_STRINGS
120
typedef size_t my_size_t;
121
], [ my_size_t foovar; ], ijg_size_t_ok=yes,
122
[ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"])
123
AC_MSG_RESULT($ijg_size_t_ok)
124
if test "$ijg_size_t_ok" != yes; then
125
AC_CHECK_HEADER(sys/types.h, [AC_DEFINE([NEED_SYS_TYPES_H],[1],[Need to include <sys/types.h> in order to obtain size_t.])
126
AC_EGREP_CPP(size_t, [#include <sys/types.h>],
127
[ijg_size_t_ok="size_t is in sys/types.h"], ijg_size_t_ok=no)],
129
AC_MSG_RESULT($ijg_size_t_ok)
130
if test "$ijg_size_t_ok" = no; then
131
echo Type size_t is not defined in any of the usual places.
132
echo Try putting '"typedef unsigned int size_t;"' in jconfig.h.
136
# Check compiler characteristics
137
AC_MSG_CHECKING(for type unsigned char)
138
AC_TRY_COMPILE(, [ unsigned char un_char; ],
140
AC_DEFINE([HAVE_UNSIGNED_CHAR],[1],[Compiler supports 'unsigned char'.])], AC_MSG_RESULT(no))
142
AC_MSG_CHECKING(for type unsigned short)
143
AC_TRY_COMPILE(, [ unsigned short un_short; ],
145
AC_DEFINE([HAVE_UNSIGNED_SHORT],[1],[Compiler supports 'unsigned short'.])], AC_MSG_RESULT(no))
147
AC_MSG_CHECKING(for type void)
149
/* Caution: a C++ compiler will insist on valid prototypes */
150
typedef void * void_ptr; /* check void * */
151
#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */
152
typedef void (*void_func) (int a, int b);
154
typedef void (*void_func) ();
157
#ifdef HAVE_PROTOTYPES /* check void function result */
158
void test3function (void_ptr arg1, void_func arg2)
160
void test3function (arg1, arg2)
165
char * locptr = (char *) arg1; /* check casting to and from void * */
166
arg1 = (void *) locptr;
167
(*arg2) (1, 2); /* check call of fcn returning void */
169
], [ ], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
170
AC_DEFINE([void],[char],[Define 'void' as 'char' for archaic compilers that don't understand it.])])
173
# Check for non-broken inline under various spellings
174
AC_MSG_CHECKING(for inline)
176
AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
177
int bar() { return foo();], ijg_cv_inline="__inline__",
178
AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
179
int bar() { return foo();], ijg_cv_inline="__inline",
180
AC_TRY_COMPILE(, [} inline int foo() { return 0; }
181
int bar() { return foo();], ijg_cv_inline="inline")))
182
AC_MSG_RESULT($ijg_cv_inline)
183
AC_DEFINE_UNQUOTED([INLINE],[$ijg_cv_inline],[How to obtain function inlining.])
185
# We cannot check for bogus warnings, but at least we can check for errors
186
AC_MSG_CHECKING(for broken incomplete types)
187
AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
189
[AC_MSG_RESULT(broken)
190
AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to unspecified structures.])])
192
# Test whether global names are unique to at least 15 chars
193
AC_MSG_CHECKING(for short external names)
195
int possibly_duplicate_function () { return 0; }
196
int possibly_dupli_function () { return 1; }
197
], [ ], AC_MSG_RESULT(ok), [AC_MSG_RESULT(short)
198
AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES],[1],[Linker requires that global names be unique in first 15 characters.])])
201
AC_MSG_CHECKING(to see if char is signed)
203
#ifdef HAVE_PROTOTYPES
204
int is_char_signed (int arg)
206
int is_char_signed (arg)
210
if (arg == 189) { /* expected result for unsigned char */
211
return 0; /* type char is unsigned */
213
else if (arg != -67) { /* expected result for signed char */
214
printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
215
printf("I fear the JPEG software will not work at all.\n\n");
217
return 1; /* assume char is signed otherwise */
219
char signed_char_check = (char) (-67);
221
exit(is_char_signed((int) signed_char_check));
222
}], [AC_MSG_RESULT(no)
223
AC_DEFINE([CHAR_IS_UNSIGNED],[1],[Characters are unsigned])], AC_MSG_RESULT(yes),
224
[echo Assuming that char is signed on target machine.
225
echo If it is unsigned, this will be a little bit inefficient.
228
AC_MSG_CHECKING(to see if right shift is signed)
230
#ifdef HAVE_PROTOTYPES
231
int is_shifting_signed (long arg)
233
int is_shifting_signed (arg)
236
/* See whether right-shift on a long is signed or not. */
240
if (res == -0x7F7E80CL) { /* expected result for signed shift */
241
return 1; /* right shift is signed */
243
/* see if unsigned-shift hack will fix it. */
244
/* we can't just test exact value since it depends on width of long... */
245
res |= (~0L) << (32-4);
246
if (res == -0x7F7E80CL) { /* expected result now? */
247
return 0; /* right shift is unsigned */
249
printf("Right shift isn't acting as I expect it to.\n");
250
printf("I fear the JPEG software will not work at all.\n\n");
251
return 0; /* try it with unsigned anyway */
254
exit(is_shifting_signed(-0x7F7E80B1L));
255
}], [AC_MSG_RESULT(no)
256
AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED],[1],[Broken compiler shifts signed values as an unsigned shift.])], AC_MSG_RESULT(yes),
257
AC_MSG_RESULT(Assuming that right shift is signed on target machine.))
259
AC_MSG_CHECKING(to see if fopen accepts b spec)
263
if (fopen("conftestdata", "wb") != NULL)
266
}], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
267
AC_DEFINE([DONT_USE_B_MODE],[1],[Don't open files in binary mode.])],
268
AC_MSG_RESULT(Assuming that it does.))
274
# Select memory manager depending on user input.
275
# If no "-enable-maxmem", use jmemnobs
278
AC_ARG_ENABLE(maxmem,
279
[ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB],
281
dnl [# support --with-maxmem for backwards compatibility with IJG V5.]
282
dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval")
283
if test "x$MAXMEM" = xyes; then
286
if test "x$MAXMEM" != xno; then
287
if test -n "`echo $MAXMEM | sed 's/[[0-9]]//g'`"; then
288
AC_MSG_ERROR(non-numeric argument to --enable-maxmem)
290
DEFAULTMAXMEM=`expr $MAXMEM \* 1048576`
291
AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}], [Maximum data space library will allocate.])
292
AC_MSG_CHECKING([for 'tmpfile()'])
293
AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ],
295
MEMORYMGR='jmemansi'],
297
dnl if tmpfile is not present, must use jmemname.
300
# Test for the need to remove temporary files using a signal handler (for cjpeg/djpeg)
301
AC_DEFINE([NEED_SIGNAL_CATCHER],[1],[Need signal handler to clean up temporary files.])
302
AC_MSG_CHECKING([for 'mktemp()'])
303
AC_TRY_LINK(, [ char fname[80]; mktemp(fname); ], AC_MSG_RESULT(yes),
305
AC_DEFINE([NO_MKTEMP],[1],[The mktemp() function is not available.])])])
309
# Extract the library version ID from jpeglib.h.
310
AC_MSG_CHECKING([libjpeg version number])
311
[JPEG_LIB_VERSION=`sed -e '/^#define JPEG_LIB_VERSION/!d' -e 's/^[^0-9]*\([0-9][0-9]*\).*$/\1/' $srcdir/jpeglib.h`]
312
[JPEG_LIB_VERSION="`expr $JPEG_LIB_VERSION / 10`:2"]
313
AC_MSG_RESULT([$JPEG_LIB_VERSION])
314
AC_SUBST([JPEG_LIB_VERSION])
316
AC_CONFIG_FILES([Makefile])