configure.ac 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. # IJG auto-configuration source file.
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. # Configure script for IJG libjpeg
  5. #
  6. AC_INIT([libjpeg], [9.2.0])
  7. # Directory where autotools helper scripts lives.
  8. AC_CONFIG_AUX_DIR([.])
  9. # Generate configuration headers.
  10. AC_CONFIG_HEADERS([jconfig.h:jconfig.cfg])
  11. # Hack: disable autoheader so that it doesn't overwrite our cfg template.
  12. AUTOHEADER="echo autoheader ignored"
  13. # Check system type
  14. AC_CANONICAL_TARGET
  15. # Initialize Automake
  16. # Don't require all the GNU mandated files
  17. AM_INIT_AUTOMAKE([-Wall -Werror no-dist foreign])
  18. # Make --enable-silent-rules the default.
  19. # To get verbose build output you may configure
  20. # with --disable-silent-rules or use "make V=1".
  21. AM_SILENT_RULES([yes])
  22. # Add configure option --enable-maintainer-mode which enables
  23. # dependency checking and generation useful to package maintainers.
  24. # This is made an option to avoid confusing end users.
  25. AM_MAINTAINER_MODE
  26. # Check for programs
  27. AC_PROG_CC
  28. AC_PROG_CC_STDC
  29. AC_PROG_CPP
  30. AC_PROG_INSTALL
  31. AC_PROG_MAKE_SET
  32. AC_PROG_LN_S
  33. AM_PROG_AR
  34. # Check if LD supports linker scripts,
  35. # and define automake conditional HAVE_LD_VERSION_SCRIPT if so.
  36. AC_ARG_ENABLE([ld-version-script],
  37. AS_HELP_STRING([--enable-ld-version-script],
  38. [enable linker version script (default is enabled when possible)]),
  39. [have_ld_version_script=$enableval], [])
  40. if test -z "$have_ld_version_script"; then
  41. AC_MSG_CHECKING([if LD -Wl,--version-script works])
  42. save_LDFLAGS="$LDFLAGS"
  43. LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
  44. cat > conftest.map <<EOF
  45. VERS_1 {
  46. global: sym;
  47. };
  48. VERS_2 {
  49. global: sym;
  50. } VERS_1;
  51. EOF
  52. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
  53. [have_ld_version_script=yes], [have_ld_version_script=no])
  54. rm -f conftest.map
  55. LDFLAGS="$save_LDFLAGS"
  56. AC_MSG_RESULT($have_ld_version_script)
  57. fi
  58. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  59. # See if compiler supports prototypes.
  60. AC_MSG_CHECKING([for function prototypes])
  61. AC_CACHE_VAL([ijg_cv_have_prototypes],
  62. [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  63. int testfunction (int arg1, int * arg2); /* check prototypes */
  64. struct methods_struct { /* check method-pointer declarations */
  65. int (*error_exit) (char *msgtext);
  66. int (*trace_message) (char *msgtext);
  67. int (*another_method) (void);
  68. };
  69. int testfunction (int arg1, int * arg2) /* check definitions */
  70. { return arg2[arg1]; }
  71. int test2function (void) /* check void arg list */
  72. { return 0; }
  73. ]])],
  74. [ijg_cv_have_prototypes=yes],
  75. [ijg_cv_have_prototypes=no])])
  76. AC_MSG_RESULT([$ijg_cv_have_prototypes])
  77. if test $ijg_cv_have_prototypes = yes; then
  78. AC_DEFINE([HAVE_PROTOTYPES],[1],[Compiler supports function prototypes.])
  79. else
  80. AC_MSG_WARN([Your compiler does not seem to know about function prototypes.
  81. Perhaps it needs a special switch to enable ANSI C mode.
  82. If so, we recommend running configure like this:
  83. ./configure CC='cc -switch'
  84. where -switch is the proper switch.])
  85. fi
  86. # Check header files
  87. AC_CHECK_HEADERS([stddef.h stdlib.h locale.h])
  88. AC_CHECK_HEADER([string.h], [],
  89. [AC_DEFINE([NEED_BSD_STRINGS], [1],
  90. [Compiler has <strings.h> rather than standard <string.h>.])])
  91. # See whether type size_t is defined in any ANSI-standard places;
  92. # if not, perhaps it is defined in <sys/types.h>.
  93. AC_MSG_CHECKING([for size_t])
  94. AC_TRY_COMPILE([
  95. #ifdef HAVE_STDDEF_H
  96. #include <stddef.h>
  97. #endif
  98. #ifdef HAVE_STDLIB_H
  99. #include <stdlib.h>
  100. #endif
  101. #include <stdio.h>
  102. #ifdef NEED_BSD_STRINGS
  103. #include <strings.h>
  104. #else
  105. #include <string.h>
  106. #endif
  107. typedef size_t my_size_t;
  108. ],
  109. [ my_size_t foovar; ],
  110. [ijg_size_t_ok=yes],
  111. [ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"])
  112. AC_MSG_RESULT([$ijg_size_t_ok])
  113. if test "$ijg_size_t_ok" != yes; then
  114. AC_CHECK_HEADER([sys/types.h],
  115. [AC_DEFINE([NEED_SYS_TYPES_H], [1],
  116. [Need to include <sys/types.h> in order to obtain size_t.])
  117. AC_EGREP_CPP([size_t], [#include <sys/types.h>],
  118. [ijg_size_t_ok="size_t is in sys/types.h"],
  119. [ijg_size_t_ok=no])],
  120. [ijg_size_t_ok=no])
  121. AC_MSG_RESULT([$ijg_size_t_ok])
  122. if test "$ijg_size_t_ok" = no; then
  123. AC_MSG_WARN([Type size_t is not defined in any of the usual places.
  124. Try putting '"typedef unsigned int size_t;"' in jconfig.h.])
  125. fi
  126. fi
  127. # Check compiler characteristics
  128. AC_MSG_CHECKING([for type unsigned char])
  129. AC_TRY_COMPILE([], [ unsigned char un_char; ],
  130. [AC_MSG_RESULT(yes)
  131. AC_DEFINE([HAVE_UNSIGNED_CHAR], [1],
  132. [Compiler supports 'unsigned char'.])],
  133. [AC_MSG_RESULT(no)])
  134. AC_MSG_CHECKING([for type unsigned short])
  135. AC_TRY_COMPILE([], [ unsigned short un_short; ],
  136. [AC_MSG_RESULT(yes)
  137. AC_DEFINE([HAVE_UNSIGNED_SHORT], [1],
  138. [Compiler supports 'unsigned short'.])],
  139. [AC_MSG_RESULT(no)])
  140. AC_MSG_CHECKING([for type void])
  141. AC_TRY_COMPILE([
  142. /* Caution: a C++ compiler will insist on valid prototypes */
  143. typedef void * void_ptr; /* check void * */
  144. #ifdef HAVE_PROTOTYPES /* check ptr to function returning void */
  145. typedef void (*void_func) (int a, int b);
  146. #else
  147. typedef void (*void_func) ();
  148. #endif
  149. #ifdef HAVE_PROTOTYPES /* check void function result */
  150. void test3function (void_ptr arg1, void_func arg2)
  151. #else
  152. void test3function (arg1, arg2)
  153. void_ptr arg1;
  154. void_func arg2;
  155. #endif
  156. {
  157. char * locptr = (char *) arg1; /* check casting to and from void * */
  158. arg1 = (void *) locptr;
  159. (*arg2) (1, 2); /* check call of fcn returning void */
  160. }
  161. ], [ ],
  162. [AC_MSG_RESULT(yes)],
  163. [AC_MSG_RESULT(no)
  164. AC_DEFINE([void], [char],
  165. [Define 'void' as 'char' for archaic compilers
  166. that don't understand it.])])
  167. AC_C_CONST
  168. # Check for non-broken inline under various spellings
  169. AC_MSG_CHECKING([for inline])
  170. ijg_cv_inline=""
  171. AC_TRY_COMPILE([], [} __inline__ int foo() { return 0; }
  172. int bar() { return foo();], ijg_cv_inline="__inline__",
  173. [AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
  174. int bar() { return foo();], ijg_cv_inline="__inline",
  175. [AC_TRY_COMPILE(, [} inline int foo() { return 0; }
  176. int bar() { return foo();], ijg_cv_inline="inline")])])
  177. AC_MSG_RESULT($ijg_cv_inline)
  178. AC_DEFINE_UNQUOTED([INLINE], [$ijg_cv_inline],
  179. [How to obtain function inlining.])
  180. # We cannot check for bogus warnings, but at least we can check for errors
  181. AC_MSG_CHECKING([for broken incomplete types])
  182. AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ],
  183. [],
  184. [AC_MSG_RESULT(ok)],
  185. [AC_MSG_RESULT(broken)
  186. AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
  187. [Compiler does not support pointers to unspecified
  188. structures.])])
  189. # Test whether global names are unique to at least 15 chars
  190. AC_MSG_CHECKING([for short external names])
  191. AC_TRY_LINK([
  192. int possibly_duplicate_function () { return 0; }
  193. int possibly_dupli_function () { return 1; }
  194. ], [],
  195. [AC_MSG_RESULT(ok)],
  196. [AC_MSG_RESULT(short)
  197. AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], [1],
  198. [Linker requires that global names be unique in
  199. first 15 characters.])])
  200. # Run-time checks
  201. AC_MSG_CHECKING([to see if char is signed])
  202. AC_TRY_RUN([
  203. #ifdef HAVE_STDLIB_H
  204. #include <stdlib.h>
  205. #endif
  206. #include <stdio.h>
  207. #ifdef HAVE_PROTOTYPES
  208. int is_char_signed (int arg)
  209. #else
  210. int is_char_signed (arg)
  211. int arg;
  212. #endif
  213. {
  214. if (arg == 189) { /* expected result for unsigned char */
  215. return 0; /* type char is unsigned */
  216. }
  217. else if (arg != -67) { /* expected result for signed char */
  218. printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
  219. printf("I fear the JPEG software will not work at all.\n\n");
  220. }
  221. return 1; /* assume char is signed otherwise */
  222. }
  223. char signed_char_check = (char) (-67);
  224. int main() {
  225. exit(is_char_signed((int) signed_char_check));
  226. }], [AC_MSG_RESULT(no)
  227. AC_DEFINE([CHAR_IS_UNSIGNED], [1],
  228. [Characters are unsigned])],
  229. [AC_MSG_RESULT(yes)],
  230. [AC_MSG_WARN([Assuming that char is signed on target machine.
  231. If it is unsigned, this will be a little bit inefficient.])
  232. ])
  233. AC_MSG_CHECKING([to see if right shift is signed])
  234. AC_TRY_RUN([
  235. #ifdef HAVE_STDLIB_H
  236. #include <stdlib.h>
  237. #endif
  238. #include <stdio.h>
  239. #ifdef HAVE_PROTOTYPES
  240. int is_shifting_signed (long arg)
  241. #else
  242. int is_shifting_signed (arg)
  243. long arg;
  244. #endif
  245. /* See whether right-shift on a long is signed or not. */
  246. {
  247. long res = arg >> 4;
  248. if (res == -0x7F7E80CL) { /* expected result for signed shift */
  249. return 1; /* right shift is signed */
  250. }
  251. /* see if unsigned-shift hack will fix it. */
  252. /* we can't just test exact value since it depends on width of long... */
  253. res |= (~0L) << (32-4);
  254. if (res == -0x7F7E80CL) { /* expected result now? */
  255. return 0; /* right shift is unsigned */
  256. }
  257. printf("Right shift isn't acting as I expect it to.\n");
  258. printf("I fear the JPEG software will not work at all.\n\n");
  259. return 0; /* try it with unsigned anyway */
  260. }
  261. int main() {
  262. exit(is_shifting_signed(-0x7F7E80B1L));
  263. }],
  264. [AC_MSG_RESULT(no)
  265. AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], [1],
  266. [Broken compiler shifts signed values as an unsigned shift.])],
  267. [AC_MSG_RESULT(yes)],
  268. [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
  269. AC_MSG_CHECKING([to see if fopen accepts b spec])
  270. AC_TRY_RUN([
  271. #ifdef HAVE_STDLIB_H
  272. #include <stdlib.h>
  273. #endif
  274. #include <stdio.h>
  275. int main() {
  276. if (fopen("conftestdata", "wb") != NULL)
  277. exit(0);
  278. exit(1);
  279. }],
  280. [AC_MSG_RESULT(yes)],
  281. [AC_MSG_RESULT(no)
  282. AC_DEFINE([DONT_USE_B_MODE], [1],
  283. [Don't open files in binary mode.])],
  284. [AC_MSG_RESULT(Assuming that it does.)])
  285. # Configure libtool
  286. AC_LIBTOOL_WIN32_DLL
  287. AC_PROG_LIBTOOL
  288. # Select memory manager depending on user input.
  289. # If no "-enable-maxmem", use jmemnobs
  290. MEMORYMGR='jmemnobs'
  291. MAXMEM="no"
  292. AC_ARG_ENABLE([maxmem],
  293. [ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB],
  294. [MAXMEM="$enableval"])
  295. dnl [# support --with-maxmem for backwards compatibility with IJG V5.]
  296. dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval")
  297. if test "x$MAXMEM" = xyes; then
  298. MAXMEM=1
  299. fi
  300. if test "x$MAXMEM" != xno; then
  301. if test -n "`echo $MAXMEM | sed 's/[[0-9]]//g'`"; then
  302. AC_MSG_ERROR(non-numeric argument to --enable-maxmem)
  303. fi
  304. DEFAULTMAXMEM=`expr $MAXMEM \* 1048576`
  305. AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}],
  306. [Maximum data space library will allocate.])
  307. AC_MSG_CHECKING([for 'tmpfile()'])
  308. AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ],
  309. [AC_MSG_RESULT(yes)
  310. MEMORYMGR='jmemansi'],
  311. [AC_MSG_RESULT(no)
  312. dnl if tmpfile is not present, must use jmemname.
  313. MEMORYMGR='jmemname'
  314. # Test for the need to remove temporary files using a signal handler
  315. # (for cjpeg/djpeg)
  316. AC_DEFINE([NEED_SIGNAL_CATCHER], [1],
  317. [Need signal handler to clean up temporary files.])
  318. AC_MSG_CHECKING([for 'mktemp()'])
  319. AC_TRY_LINK([], [ char fname[80]; mktemp(fname); ],
  320. [AC_MSG_RESULT(yes)],
  321. [AC_MSG_RESULT(no)
  322. AC_DEFINE([NO_MKTEMP], [1],
  323. [The mktemp() function is not available.])])])
  324. fi
  325. AC_SUBST([MEMORYMGR])
  326. # Extract the library version IDs from jpeglib.h.
  327. AC_MSG_CHECKING([libjpeg version number])
  328. [major=`sed -ne 's/^#define JPEG_LIB_VERSION_MAJOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`
  329. minor=`sed -ne 's/^#define JPEG_LIB_VERSION_MINOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`]
  330. AC_SUBST([JPEG_LIB_VERSION],
  331. [`expr $major + $minor`:0:$minor])
  332. AC_MSG_RESULT([$JPEG_LIB_VERSION])
  333. AC_CONFIG_FILES([Makefile])
  334. AC_OUTPUT