]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libjpeg/lib/contrib/configure.ac
Inital import
[l4.git] / l4 / pkg / libjpeg / lib / contrib / configure.ac
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], [8.0.2])
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 ansi2knr 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 # This is required when using the de-ANSI-fication feature.
32 AM_C_PROTOTYPES
33
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.
37 AM_MAINTAINER_MODE
38
39 # Check for programs
40 AC_PROG_CC
41 AC_PROG_CC_STDC
42 AC_PROG_CPP
43 AC_PROG_INSTALL
44 AC_PROG_MAKE_SET
45 AC_PROG_LN_S
46
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
58 VERS_1 {
59         global: sym;
60 };
61
62 VERS_2 {
63         global: sym;
64 } VERS_1;
65 EOF
66   AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
67                  [have_ld_version_script=yes], [have_ld_version_script=no])
68   rm -f conftest.map
69   LDFLAGS="$save_LDFLAGS"
70   AC_MSG_RESULT($have_ld_version_script)
71 fi
72 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
73
74 # See if compiler supports prototypes.
75 AC_MSG_CHECKING(for function prototypes)
76 AC_CACHE_VAL(ijg_cv_have_prototypes,
77 [AC_TRY_COMPILE([
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);
83 };
84 int testfunction (int arg1, int * arg2) /* check definitions */
85 { return arg2[arg1]; }
86 int test2function (void)        /* check void arg list */
87 { return 0; }
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.])
92 else
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.
98 fi
99
100 # Check header files
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>.]))
103
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)
107 AC_TRY_COMPILE([
108 #ifdef HAVE_STDDEF_H
109 #include <stddef.h>
110 #endif
111 #ifdef HAVE_STDLIB_H
112 #include <stdlib.h>
113 #endif
114 #include <stdio.h>
115 #ifdef NEED_BSD_STRINGS
116 #include <strings.h>
117 #else
118 #include <string.h>
119 #endif
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)],
128 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.
133 fi
134 fi
135
136 # Check compiler characteristics
137 AC_MSG_CHECKING(for type unsigned char)
138 AC_TRY_COMPILE(, [ unsigned char un_char; ],
139 [AC_MSG_RESULT(yes)
140 AC_DEFINE([HAVE_UNSIGNED_CHAR],[1],[Compiler supports 'unsigned char'.])], AC_MSG_RESULT(no))
141 dnl
142 AC_MSG_CHECKING(for type unsigned short)
143 AC_TRY_COMPILE(, [ unsigned short un_short; ],
144 [AC_MSG_RESULT(yes)
145 AC_DEFINE([HAVE_UNSIGNED_SHORT],[1],[Compiler supports 'unsigned short'.])], AC_MSG_RESULT(no))
146 dnl
147 AC_MSG_CHECKING(for type void)
148 AC_TRY_COMPILE([
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);
153 #else
154 typedef void (*void_func) ();
155 #endif
156
157 #ifdef HAVE_PROTOTYPES          /* check void function result */
158 void test3function (void_ptr arg1, void_func arg2)
159 #else
160 void test3function (arg1, arg2)
161      void_ptr arg1;
162      void_func arg2;
163 #endif
164 {
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 */
168 }
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.])])
171 AC_C_CONST
172
173 # Check for non-broken inline under various spellings
174 AC_MSG_CHECKING(for inline)
175 ijg_cv_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.])
184
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; ], ,
188 AC_MSG_RESULT(ok),
189 [AC_MSG_RESULT(broken)
190 AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to unspecified structures.])])
191
192 # Test whether global names are unique to at least 15 chars
193 AC_MSG_CHECKING(for short external names)
194 AC_TRY_LINK([
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.])])
199
200 # Run-time checks
201 AC_MSG_CHECKING(to see if char is signed)
202 AC_TRY_RUN([
203 #ifdef HAVE_PROTOTYPES
204 int is_char_signed (int arg)
205 #else
206 int is_char_signed (arg)
207      int arg;
208 #endif
209 {
210   if (arg == 189) {             /* expected result for unsigned char */
211     return 0;                   /* type char is unsigned */
212   }
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");
216   }
217   return 1;                     /* assume char is signed otherwise */
218 }
219 char signed_char_check = (char) (-67);
220 int main() {
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.
226 ])
227 dnl
228 AC_MSG_CHECKING(to see if right shift is signed)
229 AC_TRY_RUN([
230 #ifdef HAVE_PROTOTYPES
231 int is_shifting_signed (long arg)
232 #else
233 int is_shifting_signed (arg)
234      long arg;
235 #endif
236 /* See whether right-shift on a long is signed or not. */
237 {
238   long res = arg >> 4;
239
240   if (res == -0x7F7E80CL) {     /* expected result for signed shift */
241     return 1;                   /* right shift is signed */
242   }
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 */
248   }
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 */
252 }
253 int main() {
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.))
258 dnl
259 AC_MSG_CHECKING(to see if fopen accepts b spec)
260 AC_TRY_RUN([
261 #include <stdio.h>
262 int main() {
263   if (fopen("conftestdata", "wb") != NULL)
264     exit(0);
265   exit(1);
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.))
269
270 # Configure libtool
271 AC_LIBTOOL_WIN32_DLL
272 AC_PROG_LIBTOOL
273
274 # Select memory manager depending on user input.
275 # If no "-enable-maxmem", use jmemnobs
276 MEMORYMGR='jmemnobs'
277 MAXMEM="no"
278 AC_ARG_ENABLE(maxmem,
279 [  --enable-maxmem[=N]     enable use of temp files, set max mem usage to N MB],
280 MAXMEM="$enableval")
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
284   MAXMEM=1
285 fi
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)
289   fi
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(); ],
294 [AC_MSG_RESULT(yes)
295 MEMORYMGR='jmemansi'],
296 [AC_MSG_RESULT(no)
297 dnl if tmpfile is not present, must use jmemname.
298 MEMORYMGR='jmemname'
299
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),
304 [AC_MSG_RESULT(no)
305 AC_DEFINE([NO_MKTEMP],[1],[The mktemp() function is not available.])])])
306 fi
307 AC_SUBST(MEMORYMGR)
308
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])
315
316 AC_CONFIG_FILES([Makefile])
317 AC_OUTPUT