Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

317 lines
11 KiB

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