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.4.0])
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 -Wno-obsolete 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],
77 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
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 */
89 [ijg_cv_have_prototypes=yes],
90 [ijg_cv_have_prototypes=no])])
91 AC_MSG_RESULT([$ijg_cv_have_prototypes])
92 if test $ijg_cv_have_prototypes = yes; then
93 AC_DEFINE([HAVE_PROTOTYPES],[1],[Compiler supports function prototypes.])
95 AC_MSG_WARN([Your compiler does not seem to know about function prototypes.
96 Perhaps it needs a special switch to enable ANSI C mode.
97 If so, we recommend running configure like this:
98 ./configure CC='cc -switch'
99 where -switch is the proper switch.])
103 AC_CHECK_HEADERS([stddef.h stdlib.h locale.h])
104 AC_CHECK_HEADER([string.h], [],
105 [AC_DEFINE([NEED_BSD_STRINGS], [1],
106 [Compiler has <strings.h> rather than standard <string.h>.])])
108 # See whether type size_t is defined in any ANSI-standard places;
109 # if not, perhaps it is defined in <sys/types.h>.
110 AC_MSG_CHECKING([for size_t])
119 #ifdef NEED_BSD_STRINGS
124 typedef size_t my_size_t;
126 [ my_size_t foovar; ],
128 [ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"])
129 AC_MSG_RESULT([$ijg_size_t_ok])
130 if test "$ijg_size_t_ok" != yes; then
131 AC_CHECK_HEADER([sys/types.h],
132 [AC_DEFINE([NEED_SYS_TYPES_H], [1],
133 [Need to include <sys/types.h> in order to obtain size_t.])
134 AC_EGREP_CPP([size_t], [#include <sys/types.h>],
135 [ijg_size_t_ok="size_t is in sys/types.h"],
136 [ijg_size_t_ok=no])],
138 AC_MSG_RESULT([$ijg_size_t_ok])
139 if test "$ijg_size_t_ok" = no; then
140 AC_MSG_WARN([Type size_t is not defined in any of the usual places.
141 Try putting '"typedef unsigned int size_t;"' in jconfig.h.])
145 # Check compiler characteristics
146 AC_MSG_CHECKING([for type unsigned char])
147 AC_TRY_COMPILE([], [ unsigned char un_char; ],
149 AC_DEFINE([HAVE_UNSIGNED_CHAR], [1],
150 [Compiler supports 'unsigned char'.])],
153 AC_MSG_CHECKING([for type unsigned short])
154 AC_TRY_COMPILE([], [ unsigned short un_short; ],
156 AC_DEFINE([HAVE_UNSIGNED_SHORT], [1],
157 [Compiler supports 'unsigned short'.])],
160 AC_MSG_CHECKING([for type void])
162 /* Caution: a C++ compiler will insist on valid prototypes */
163 typedef void * void_ptr; /* check void * */
164 #ifdef HAVE_PROTOTYPES /* check ptr to function returning void */
165 typedef void (*void_func) (int a, int b);
167 typedef void (*void_func) ();
170 #ifdef HAVE_PROTOTYPES /* check void function result */
171 void test3function (void_ptr arg1, void_func arg2)
173 void test3function (arg1, arg2)
178 char * locptr = (char *) arg1; /* check casting to and from void * */
179 arg1 = (void *) locptr;
180 (*arg2) (1, 2); /* check call of fcn returning void */
183 [AC_MSG_RESULT(yes)],
185 AC_DEFINE([void], [char],
186 [Define 'void' as 'char' for archaic compilers
187 that don't understand it.])])
190 # Check for non-broken inline under various spellings
191 AC_MSG_CHECKING([for 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_TRY_COMPILE(, [} inline int foo() { return 0; }
198 int bar() { return foo();], ijg_cv_inline="inline")])])
199 AC_MSG_RESULT($ijg_cv_inline)
200 AC_DEFINE_UNQUOTED([INLINE], [$ijg_cv_inline],
201 [How to obtain function inlining.])
203 # We cannot check for bogus warnings, but at least we can check for errors
204 AC_MSG_CHECKING([for broken incomplete types])
205 AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ],
208 [AC_MSG_RESULT(broken)
209 AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
210 [Compiler does not support pointers to unspecified
213 # Test whether global names are unique to at least 15 chars
214 AC_MSG_CHECKING([for short external names])
216 int possibly_duplicate_function () { return 0; }
217 int possibly_dupli_function () { return 1; }
220 [AC_MSG_RESULT(short)
221 AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], [1],
222 [Linker requires that global names be unique in
223 first 15 characters.])])
226 AC_MSG_CHECKING([to see if char is signed])
228 #ifdef HAVE_PROTOTYPES
229 int is_char_signed (int arg)
231 int is_char_signed (arg)
235 if (arg == 189) { /* expected result for unsigned char */
236 return 0; /* type char is unsigned */
238 else if (arg != -67) { /* expected result for signed char */
239 printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
240 printf("I fear the JPEG software will not work at all.\n\n");
242 return 1; /* assume char is signed otherwise */
244 char signed_char_check = (char) (-67);
246 exit(is_char_signed((int) signed_char_check));
247 }], [AC_MSG_RESULT(no)
248 AC_DEFINE([CHAR_IS_UNSIGNED], [1],
249 [Characters are unsigned])],
250 [AC_MSG_RESULT(yes)],
251 [AC_MSG_WARN([Assuming that char is signed on target machine.
252 If it is unsigned, this will be a little bit inefficient.])
255 AC_MSG_CHECKING([to see if right shift is signed])
257 #ifdef HAVE_PROTOTYPES
258 int is_shifting_signed (long arg)
260 int is_shifting_signed (arg)
263 /* See whether right-shift on a long is signed or not. */
267 if (res == -0x7F7E80CL) { /* expected result for signed shift */
268 return 1; /* right shift is signed */
270 /* see if unsigned-shift hack will fix it. */
271 /* we can't just test exact value since it depends on width of long... */
272 res |= (~0L) << (32-4);
273 if (res == -0x7F7E80CL) { /* expected result now? */
274 return 0; /* right shift is unsigned */
276 printf("Right shift isn't acting as I expect it to.\n");
277 printf("I fear the JPEG software will not work at all.\n\n");
278 return 0; /* try it with unsigned anyway */
281 exit(is_shifting_signed(-0x7F7E80B1L));
284 AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], [1],
285 [Broken compiler shifts signed values as an unsigned shift.])],
286 [AC_MSG_RESULT(yes)],
287 [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
289 AC_MSG_CHECKING([to see if fopen accepts b spec])
293 if (fopen("conftestdata", "wb") != NULL)
297 [AC_MSG_RESULT(yes)],
299 AC_DEFINE([DONT_USE_B_MODE], [1],
300 [Don't open files in binary mode.])],
301 [AC_MSG_RESULT(Assuming that it does.)])
307 # Select memory manager depending on user input.
308 # If no "-enable-maxmem", use jmemnobs
311 AC_ARG_ENABLE([maxmem],
312 [ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB],
313 [MAXMEM="$enableval"])
314 dnl [# support --with-maxmem for backwards compatibility with IJG V5.]
315 dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval")
316 if test "x$MAXMEM" = xyes; then
319 if test "x$MAXMEM" != xno; then
320 if test -n "`echo $MAXMEM | sed 's/[[0-9]]//g'`"; then
321 AC_MSG_ERROR(non-numeric argument to --enable-maxmem)
323 DEFAULTMAXMEM=`expr $MAXMEM \* 1048576`
324 AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}],
325 [Maximum data space library will allocate.])
326 AC_MSG_CHECKING([for 'tmpfile()'])
327 AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ],
329 MEMORYMGR='jmemansi'],
331 dnl if tmpfile is not present, must use jmemname.
334 # Test for the need to remove temporary files using a signal handler
336 AC_DEFINE([NEED_SIGNAL_CATCHER], [1],
337 [Need signal handler to clean up temporary files.])
338 AC_MSG_CHECKING([for 'mktemp()'])
339 AC_TRY_LINK([], [ char fname[80]; mktemp(fname); ],
340 [AC_MSG_RESULT(yes)],
342 AC_DEFINE([NO_MKTEMP], [1],
343 [The mktemp() function is not available.])])])
345 AC_SUBST([MEMORYMGR])
347 # Extract the library version IDs from jpeglib.h.
348 AC_MSG_CHECKING([libjpeg version number])
349 [major=`sed -ne 's/^#define JPEG_LIB_VERSION_MAJOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`
350 minor=`sed -ne 's/^#define JPEG_LIB_VERSION_MINOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`]
351 AC_SUBST([JPEG_LIB_VERSION],
352 [`expr $major + $minor`:0:$minor])
353 AC_MSG_RESULT([$JPEG_LIB_VERSION])
355 AC_CONFIG_FILES([Makefile])