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], [9.0.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 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 # 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.
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
64 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
65 [have_ld_version_script=yes], [have_ld_version_script=no])
67 LDFLAGS="$save_LDFLAGS"
68 AC_MSG_RESULT($have_ld_version_script)
70 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
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);
82 int testfunction (int arg1, int * arg2) /* check definitions */
83 { return arg2[arg1]; }
84 int test2function (void) /* check void arg list */
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.])
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.])
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>.])])
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])
117 #ifdef NEED_BSD_STRINGS
122 typedef size_t my_size_t;
124 [ my_size_t foovar; ],
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])],
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.])
143 # Check compiler characteristics
144 AC_MSG_CHECKING([for type unsigned char])
145 AC_TRY_COMPILE([], [ unsigned char un_char; ],
147 AC_DEFINE([HAVE_UNSIGNED_CHAR], [1],
148 [Compiler supports 'unsigned char'.])],
151 AC_MSG_CHECKING([for type unsigned short])
152 AC_TRY_COMPILE([], [ unsigned short un_short; ],
154 AC_DEFINE([HAVE_UNSIGNED_SHORT], [1],
155 [Compiler supports 'unsigned short'.])],
158 AC_MSG_CHECKING([for type void])
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);
165 typedef void (*void_func) ();
168 #ifdef HAVE_PROTOTYPES /* check void function result */
169 void test3function (void_ptr arg1, void_func arg2)
171 void test3function (arg1, arg2)
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 */
181 [AC_MSG_RESULT(yes)],
183 AC_DEFINE([void], [char],
184 [Define 'void' as 'char' for archaic compilers
185 that don't understand it.])])
188 # Check for non-broken inline under various spellings
189 AC_MSG_CHECKING([for 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.])
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; ],
206 [AC_MSG_RESULT(broken)
207 AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
208 [Compiler does not support pointers to unspecified
211 # Test whether global names are unique to at least 15 chars
212 AC_MSG_CHECKING([for short external names])
214 int possibly_duplicate_function () { return 0; }
215 int possibly_dupli_function () { return 1; }
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.])])
224 AC_MSG_CHECKING([to see if char is signed])
230 #ifdef HAVE_PROTOTYPES
231 int is_char_signed (int arg)
233 int is_char_signed (arg)
237 if (arg == 189) { /* expected result for unsigned char */
238 return 0; /* type char is unsigned */
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");
244 return 1; /* assume char is signed otherwise */
246 char signed_char_check = (char) (-67);
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.])
257 AC_MSG_CHECKING([to see if right shift is signed])
263 #ifdef HAVE_PROTOTYPES
264 int is_shifting_signed (long arg)
266 int is_shifting_signed (arg)
269 /* See whether right-shift on a long is signed or not. */
273 if (res == -0x7F7E80CL) { /* expected result for signed shift */
274 return 1; /* right shift is signed */
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 */
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 */
287 exit(is_shifting_signed(-0x7F7E80B1L));
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.)])
295 AC_MSG_CHECKING([to see if fopen accepts b spec])
302 if (fopen("conftestdata", "wb") != NULL)
306 [AC_MSG_RESULT(yes)],
308 AC_DEFINE([DONT_USE_B_MODE], [1],
309 [Don't open files in binary mode.])],
310 [AC_MSG_RESULT(Assuming that it does.)])
316 # Select memory manager depending on user input.
317 # If no "-enable-maxmem", use jmemnobs
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
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)
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(); ],
338 MEMORYMGR='jmemansi'],
340 dnl if tmpfile is not present, must use jmemname.
343 # Test for the need to remove temporary files using a signal handler
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)],
351 AC_DEFINE([NO_MKTEMP], [1],
352 [The mktemp() function is not available.])])])
354 AC_SUBST([MEMORYMGR])
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])
364 AC_CONFIG_FILES([Makefile])