1 dnl IJG auto-configuration source file.
2 dnl Process this file with autoconf to produce a configure script.
4 AC_CONFIG_HEADER(jconfig.h:jconfig.cfg)
6 dnl do these first since other macros rely on them
10 dnl See if compiler supports prototypes.
11 AC_MSG_CHECKING(for function prototypes)
12 AC_CACHE_VAL(ijg_cv_have_prototypes,
14 int testfunction (int arg1, int * arg2); /* check prototypes */
15 struct methods_struct { /* check method-pointer declarations */
16 int (*error_exit) (char *msgtext);
17 int (*trace_message) (char *msgtext);
18 int (*another_method) (void);
20 int testfunction (int arg1, int * arg2) /* check definitions */
21 { return arg2[arg1]; }
22 int test2function (void) /* check void arg list */
24 ], [ ], ijg_cv_have_prototypes=yes, ijg_cv_have_prototypes=no)])
25 AC_MSG_RESULT($ijg_cv_have_prototypes)
26 if test $ijg_cv_have_prototypes = yes; then
27 AC_DEFINE(HAVE_PROTOTYPES,1)
29 echo Your compiler does not seem to know about function prototypes.
30 echo Perhaps it needs a special switch to enable ANSI C mode.
31 echo If so, we recommend running configure like this:
32 echo " ./configure CC='cc -switch'"
33 echo where -switch is the proper switch.
36 dnl check header files
37 AC_CHECK_HEADER(stddef.h, AC_DEFINE(HAVE_STDDEF_H,1))
38 AC_CHECK_HEADER(stdlib.h, AC_DEFINE(HAVE_STDLIB_H,1))
39 AC_CHECK_HEADER(string.h,, AC_DEFINE(NEED_BSD_STRINGS,1))
40 dnl See whether type size_t is defined in any ANSI-standard places;
41 dnl if not, perhaps it is defined in <sys/types.h>.
42 AC_MSG_CHECKING(for size_t)
51 #ifdef NEED_BSD_STRINGS
56 typedef size_t my_size_t;
57 ], [ my_size_t foovar; ], ijg_size_t_ok=yes,
58 [ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"])
59 AC_MSG_RESULT($ijg_size_t_ok)
60 if test "$ijg_size_t_ok" != yes; then
61 AC_CHECK_HEADER(sys/types.h, [AC_DEFINE(NEED_SYS_TYPES_H,1)
62 AC_EGREP_CPP(size_t, [#include <sys/types.h>],
63 [ijg_size_t_ok="size_t is in sys/types.h"], ijg_size_t_ok=no)],
65 AC_MSG_RESULT($ijg_size_t_ok)
66 if test "$ijg_size_t_ok" = no; then
67 echo Type size_t is not defined in any of the usual places.
68 echo Try putting '"typedef unsigned int size_t;"' in jconfig.h.
72 dnl check compiler characteristics
73 AC_MSG_CHECKING(for type unsigned char)
74 AC_TRY_COMPILE(, [ unsigned char un_char; ],
76 AC_DEFINE(HAVE_UNSIGNED_CHAR,1)], AC_MSG_RESULT(no))
77 AC_MSG_CHECKING(for type unsigned short)
78 AC_TRY_COMPILE(, [ unsigned short un_short; ],
80 AC_DEFINE(HAVE_UNSIGNED_SHORT,1)], AC_MSG_RESULT(no))
81 AC_MSG_CHECKING(for type void)
83 /* Caution: a C++ compiler will insist on valid prototypes */
84 typedef void * void_ptr; /* check void * */
85 #ifdef HAVE_PROTOTYPES /* check ptr to function returning void */
86 typedef void (*void_func) (int a, int b);
88 typedef void (*void_func) ();
91 #ifdef HAVE_PROTOTYPES /* check void function result */
92 void test3function (void_ptr arg1, void_func arg2)
94 void test3function (arg1, arg2)
99 char * locptr = (char *) arg1; /* check casting to and from void * */
100 arg1 = (void *) locptr;
101 (*arg2) (1, 2); /* check call of fcn returning void */
103 ], [ ], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
104 AC_DEFINE(void,char)])
107 dnl check for non-broken inline under various spellings
108 AC_MSG_CHECKING(for inline)
110 AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
111 int bar() { return foo();], ijg_cv_inline="__inline__",
112 AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
113 int bar() { return foo();], ijg_cv_inline="__inline",
114 AC_TRY_COMPILE(, [} inline int foo() { return 0; }
115 int bar() { return foo();], ijg_cv_inline="inline")))
116 AC_MSG_RESULT($ijg_cv_inline)
117 AC_DEFINE_UNQUOTED(INLINE,$ijg_cv_inline)
118 dnl we cannot check for bogus warnings, but at least we can check for errors
119 AC_MSG_CHECKING(for broken incomplete types)
120 AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
122 [AC_MSG_RESULT(broken)
123 AC_DEFINE(INCOMPLETE_TYPES_BROKEN,1)])
124 dnl test whether global names are unique to at least 15 chars
125 AC_MSG_CHECKING(for short external names)
127 int possibly_duplicate_function () { return 0; }
128 int possibly_dupli_function () { return 1; }
129 ], [ ], AC_MSG_RESULT(ok), [AC_MSG_RESULT(short)
130 AC_DEFINE(NEED_SHORT_EXTERNAL_NAMES,1)])
133 AC_MSG_CHECKING(to see if char is signed)
135 #ifdef HAVE_PROTOTYPES
136 int is_char_signed (int arg)
138 int is_char_signed (arg)
142 if (arg == 189) { /* expected result for unsigned char */
143 return 0; /* type char is unsigned */
145 else if (arg != -67) { /* expected result for signed char */
146 printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
147 printf("I fear the JPEG software will not work at all.\n\n");
149 return 1; /* assume char is signed otherwise */
151 char signed_char_check = (char) (-67);
153 exit(is_char_signed((int) signed_char_check));
154 }], [AC_MSG_RESULT(no)
155 AC_DEFINE(CHAR_IS_UNSIGNED,1)], AC_MSG_RESULT(yes),
156 [echo Assuming that char is signed on target machine.
157 echo If it is unsigned, this will be a little bit inefficient.
160 AC_MSG_CHECKING(to see if right shift is signed)
162 #ifdef HAVE_PROTOTYPES
163 int is_shifting_signed (long arg)
165 int is_shifting_signed (arg)
168 /* See whether right-shift on a long is signed or not. */
172 if (res == -0x7F7E80CL) { /* expected result for signed shift */
173 return 1; /* right shift is signed */
175 /* see if unsigned-shift hack will fix it. */
176 /* we can't just test exact value since it depends on width of long... */
177 res |= (~0L) << (32-4);
178 if (res == -0x7F7E80CL) { /* expected result now? */
179 return 0; /* right shift is unsigned */
181 printf("Right shift isn't acting as I expect it to.\n");
182 printf("I fear the JPEG software will not work at all.\n\n");
183 return 0; /* try it with unsigned anyway */
186 exit(is_shifting_signed(-0x7F7E80B1L));
187 }], [AC_MSG_RESULT(no)
188 AC_DEFINE(RIGHT_SHIFT_IS_UNSIGNED,1)], AC_MSG_RESULT(yes),
189 AC_MSG_RESULT(Assuming that right shift is signed on target machine.))
191 AC_MSG_CHECKING(to see if fopen accepts b spec)
195 if (fopen("conftestdata", "wb") != NULL)
198 }], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
199 AC_DEFINE(DONT_USE_B_MODE,1)],
200 AC_MSG_RESULT(Assuming that it does.))
206 # Decide whether to use libtool,
207 # and if so whether to build shared, static, or both flavors of library.
210 if test "x$enable_shared" != xno -o "x$enable_static" != xno; then
219 LN='$(LIBTOOL) --mode=link $(CC)'
220 INSTALL_LIB='$(LIBTOOL) --mode=install ${INSTALL}'
221 INSTALL_PROGRAM="\$(LIBTOOL) --mode=install $INSTALL_PROGRAM"
228 INSTALL_LIB="$INSTALL_DATA"
234 AC_SUBST(INSTALL_LIB)
236 # Select memory manager depending on user input.
237 # If no "-enable-maxmem", use jmemnobs
238 MEMORYMGR='jmemnobs.$(O)'
240 AC_ARG_ENABLE(maxmem,
241 [ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB],
243 dnl [# support --with-maxmem for backwards compatibility with IJG V5.]
244 dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval")
245 if test "x$MAXMEM" = xyes; then
248 if test "x$MAXMEM" != xno; then
250 if test -n "`echo $MAXMEM | sed 's/[0-9]//g'`"; then
252 AC_MSG_ERROR(non-numeric argument to --enable-maxmem)
254 DEFAULTMAXMEM=`expr $MAXMEM \* 1048576`
255 AC_DEFINE_UNQUOTED(DEFAULT_MAX_MEM, ${DEFAULTMAXMEM})
256 AC_MSG_CHECKING([for 'tmpfile()'])
257 AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ],
259 MEMORYMGR='jmemansi.$(O)'],
261 dnl if tmpfile is not present, must use jmemname.
262 MEMORYMGR='jmemname.$(O)'
263 AC_DEFINE(NEED_SIGNAL_CATCHER,1)
264 AC_MSG_CHECKING([for 'mktemp()'])
265 AC_TRY_LINK(, [ char fname[80]; mktemp(fname); ], AC_MSG_RESULT(yes),
267 AC_DEFINE(NO_MKTEMP,1)])])
271 # Include PNG support in cjpeg/djpeg if appropriate.
273 [ --with-png enable PNG support in cjpeg/djpeg],
274 [#], [with_png="maybe"])
276 # try to detect whether libpng is present
277 if test "x$with_png" = xmaybe ; then
278 AC_CHECK_HEADER(png.h, [: ok so far], [with_png="no"])
280 if test "x$with_png" = xmaybe ; then
281 AC_CHECK_HEADER(zlib.h, [: ok so far], [with_png="no"])
283 if test "x$with_png" = xmaybe ; then
284 AC_CHECK_LIB(z, deflate, [: ok so far], [with_png="no"])
286 if test "x$with_png" = xmaybe ; then
287 AC_CHECK_LIB(png, png_create_info_struct,
288 [with_png="yes"], [with_png="no"], [-lz -lm])
291 if test "x$with_png" = xyes ; then
292 AC_DEFINE(PNG_SUPPORTED,1)
293 LIBS="-lpng -lz -lm $LIBS"
296 # Extract the library version ID from jpeglib.h.
297 AC_MSG_CHECKING([libjpeg version number])
298 [JPEG_LIB_VERSION=`sed -e '/^#define JPEG_LIB_VERSION/!d' -e 's/^[^0-9]*\([0-9][0-9]*\).*$/\1/' $srcdir/jpeglib.h`]
299 AC_MSG_RESULT($JPEG_LIB_VERSION)
300 AC_SUBST(JPEG_LIB_VERSION)
302 # Prepare to massage makefile.cfg correctly.
303 if test $ijg_cv_have_prototypes = yes; then
312 # ansi2knr needs -DBSD if string.h is missing
313 if test $ac_cv_header_string_h = no; then
314 ANSI2KNRFLAGS="-DBSD"
318 AC_SUBST(ANSI2KNRFLAGS)
320 # Substitutions to enable or disable libtool-related stuff
321 if test $USELIBTOOL = yes -a $ijg_cv_have_prototypes = yes; then
327 if test "x$enable_shared" != xno; then
328 FORCE_INSTALL_LIB="install-lib"
332 AC_SUBST(FORCE_INSTALL_LIB)
334 # Set up -I directives
335 if test "x$srcdir" = x.; then
336 INCLUDEFLAGS='-I$(srcdir)'
338 if test "x$GCC" = xyes; then
339 INCLUDEFLAGS='-I- -I. -I$(srcdir)'
341 INCLUDEFLAGS='-I. -I$(srcdir)'
344 AC_SUBST(INCLUDEFLAGS)
346 AC_OUTPUT(Makefile:makefile.cfg)