configure.ac.in 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Process this file with autoconf to produce a configure script.
  2. AC_INIT([jbig2dec], [unknown-version], [gs-devel@ghostscript.com])
  3. AC_PREREQ(2.53)
  4. AC_CONFIG_SRCDIR([jbig2dec.c])
  5. AM_SILENT_RULES([yes])
  6. AM_INIT_AUTOMAKE([-Wall])
  7. AM_CONFIG_HEADER(config.h)
  8. dnl Library versioning - Adapted from the libtool info page
  9. dnl
  10. dnl 1. If source has changed at all: increment revision
  11. dnl 2. If the ABI changed: increment current, reset revision to 0
  12. dnl 3. If interfaces have been added since last public release: increment age
  13. dnl 4. If interfaces have been removed: reset age to 0
  14. AC_SUBST([JBIG2DEC_LT_CURRENT], [0])
  15. AC_SUBST([JBIG2DEC_LT_REVISION], [0])
  16. AC_SUBST([JBIG2DEC_LT_AGE], [0])
  17. # Checks for programs.
  18. AC_PROG_CC
  19. AM_PROG_CC_C_O
  20. AM_PROG_AR
  21. AC_LIBTOOL_WIN32_DLL
  22. AC_PROG_LIBTOOL
  23. # platform specific compiler flags
  24. if test "x$GCC" = xyes; then
  25. CFLAGS="$CFLAGS -Wall -Wsign-compare"
  26. fi
  27. # Checks for libraries.
  28. dnl by default we want png support if possible
  29. AC_ARG_WITH([libpng],
  30. AC_HELP_STRING([--with-libpng[=prefix]],
  31. [include support for png output (if libpng is available)]),
  32. [ac_cv_want_libpng="$withval"], [ac_cv_want_libpng="yes"])
  33. save_cflags="$CFLAGS"
  34. save_ldflags="$LDFLAGS"
  35. have_libpng="no"
  36. if test "x$ac_cv_want_libpng" != "xno"; then
  37. if test "x$ac_cv_want_libpng" != "xyes"; then
  38. dnl if it's not yes or no, treat as a prefix
  39. CFLAGS="$CFLAGS -I$ac_cv_want_libpng/include"
  40. LDFLAGS="$LDFLAGS -L$ac_cv_want_libpng/lib"
  41. fi
  42. dnl libpng requires pow() which may be in libm
  43. AC_SEARCH_LIBS([pow], [m])
  44. AC_CHECK_LIB([png], [png_create_write_struct], [
  45. AC_CHECK_LIB([z], [deflate], [
  46. AC_DEFINE(HAVE_LIBPNG, 1, [Define if libpng is available (-lpng)])
  47. PNG_LIBS="-lpng -lz"
  48. AC_LIBOBJ([jbig2_image_png])
  49. have_libpng="yes"
  50. ])
  51. ])
  52. fi
  53. dnl restore (possibly changed) flags if we didn't find working libpng
  54. if test "x$have_libpng" != "xyes"; then
  55. CFLAGS="$save_cflags"
  56. LDFLAGS="$save_ldflags"
  57. fi
  58. AC_SUBST(PNG_LIBS)
  59. # Checks for header files.
  60. AC_HEADER_STDC
  61. AC_CHECK_HEADERS([libintl.h stddef.h unistd.h strings.h])
  62. dnl We assume the fixed-size types from stdint.h. If that header is
  63. dnl not available, look for the same types in a few other headers.
  64. dnl We also attempt to define them ourselves, but only use those if
  65. dnl the native versions aren't available. The substitutions happen
  66. dnl in a file config_types.h, whose template is created by autogen.sh
  67. stdint_types_in="no_replacement_found"
  68. stdint_types_discovered="yes"
  69. AC_CHECK_SIZEOF(char)
  70. AC_CHECK_SIZEOF(short)
  71. AC_CHECK_SIZEOF(int)
  72. AC_CHECK_SIZEOF(long)
  73. case 1 in
  74. $ac_cv_sizeof_char) int8_type="char";;
  75. *) stdint_types_discovered="no"
  76. esac
  77. case 2 in
  78. $ac_cv_sizeof_short) int16_type="short";;
  79. $ac_cv_sizeof_char) int16_type="char";;
  80. $ac_cv_sizeof_int) int16_type="char";;
  81. *) stdint_types_discovered="no";;
  82. esac
  83. case 4 in
  84. $ac_cv_sizeof_int) int32_type="int";;
  85. $ac_cv_sizeof_long) int32_type="long";;
  86. $ac_cv_sizeof_short) int32_type="short";;
  87. *) stdint_types_discovered="no";;
  88. esac
  89. AC_CHECK_HEADER([stdint.h])
  90. if test "x$ac_cv_header_stdint_h" != "xyes"; then
  91. for include in sys/types.h inttypes.h sys/inttypes.h sys/int_types.h ; do
  92. AC_MSG_CHECKING([for uint32_t in $include])
  93. AC_TRY_COMPILE([#include <$include>], [uint32_t canary;], [
  94. AC_MSG_RESULT([yes])
  95. stdint_types_in="$include"
  96. break;
  97. ], AC_MSG_RESULT([no])
  98. )
  99. done
  100. if test "x$stdint_types_in" != "xno_replacement_found"; then
  101. AC_MSG_RESULT([Adding $stdint_types_in to config header for stdint types])
  102. AC_DEFINE([JBIG2_REPLACE_STDINT_H],,
  103. [set by configure if an alternate header with the stdint.h types is found])
  104. elif test "x$stdint_types_discovered" = "xno"; then
  105. AC_MSG_ERROR([
  106. Unable to find suitable definitions of the stdint.h types (uint32_t and friends)
  107. You will have to define these yourself in a separate header.
  108. See config_win32.h for an example.
  109. ])
  110. fi
  111. fi
  112. AC_SUBST(JBIG2_INT32_T, [$int32_type])
  113. AC_SUBST(JBIG2_INT16_T, [$int16_type])
  114. AC_SUBST(JBIG2_INT8_T, [$int8_type])
  115. AC_SUBST(JBIG2_STDINT_H, [$stdint_types_in])
  116. # Checks for typedefs, structures, and compiler characteristics.
  117. AC_C_CONST
  118. AC_TYPE_SIZE_T
  119. AC_C_BIGENDIAN
  120. # Checks for library functions.
  121. AC_FUNC_MEMCMP
  122. dnl we use realloc() but don't depend on the zero-length behavior
  123. dnl tested by AC_FUNC_REALLOC
  124. AC_CHECK_FUNCS([memset strdup])
  125. dnl use our included getopt if the system doesn't have getopt_long()
  126. AC_CHECK_FUNC(getopt_long,
  127. AC_DEFINE(HAVE_GETOPT_LONG,,
  128. [Define if the local libc includes getopt_long()]
  129. ),[
  130. AC_LIBOBJ([getopt])
  131. AC_LIBOBJ([getopt1])
  132. ])
  133. # generate output
  134. AC_CONFIG_FILES([Makefile config_types.h jbig2dec.pc])
  135. AC_OUTPUT