configure.in 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # Process this file with autoconf to produce a configure script.
  2. AC_INIT(physfs.c)
  3. dnl ---------------------------------------------------------------------
  4. dnl System/version info
  5. dnl ---------------------------------------------------------------------
  6. # Making releases:
  7. # MICRO_VERSION += 1;
  8. # INTERFACE_AGE += 1;
  9. # BINARY_AGE += 1;
  10. # if any functions have been added, set INTERFACE_AGE to 0.
  11. # if backwards compatibility has been broken,
  12. # set BINARY_AGE and INTERFACE_AGE to 0.
  13. MAJOR_VERSION=0
  14. MINOR_VERSION=1
  15. MICRO_VERSION=6
  16. INTERFACE_AGE=0
  17. BINARY_AGE=0
  18. VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
  19. AC_SUBST(MAJOR_VERSION)
  20. AC_SUBST(MINOR_VERSION)
  21. AC_SUBST(MICRO_VERSION)
  22. AC_SUBST(INTERFACE_AGE)
  23. AC_SUBST(BINARY_AGE)
  24. AC_SUBST(VERSION)
  25. # libtool versioning
  26. LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
  27. LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
  28. LT_REVISION=$INTERFACE_AGE
  29. LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
  30. AC_SUBST(LT_RELEASE)
  31. AC_SUBST(LT_CURRENT)
  32. AC_SUBST(LT_REVISION)
  33. AC_SUBST(LT_AGE)
  34. dnl Detect the canonical host and target build environment
  35. AC_CANONICAL_HOST
  36. AC_CANONICAL_TARGET
  37. dnl Setup for automake
  38. AM_CONFIG_HEADER(config.h)
  39. AM_INIT_AUTOMAKE(physfs, $VERSION)
  40. dnl ---------------------------------------------------------------------
  41. dnl Compilers and other tools
  42. dnl ---------------------------------------------------------------------
  43. AC_PROG_CC
  44. AC_PROG_INSTALL
  45. AC_PROG_LN_S
  46. AC_PROG_LIBTOOL
  47. dnl ---------------------------------------------------------------------
  48. dnl Debug mode?
  49. dnl ---------------------------------------------------------------------
  50. AC_ARG_ENABLE(debug,
  51. [ --enable-debug enable debug mode [default=no]],
  52. , enable_debug=no)
  53. if test x$enable_debug = xyes; then
  54. if test x$ac_cv_prog_cc_g = xyes; then
  55. CFLAGS="-g -O0"
  56. else
  57. CFLAGS="-O0"
  58. fi
  59. CFLAGS="$CFLAGS -Werror"
  60. AC_DEFINE(DEBUG)
  61. AC_DEFINE(DEBUG_CHATTER)
  62. else
  63. CFLAGS="-O2"
  64. AC_DEFINE(NDEBUG)
  65. fi
  66. dnl ---------------------------------------------------------------------
  67. dnl Build test program?
  68. dnl ---------------------------------------------------------------------
  69. AC_ARG_ENABLE(testprog,
  70. [ --enable-testprog build test program [default=yes]],
  71. , enable_testprog=yes)
  72. dnl ---------------------------------------------------------------------
  73. dnl Checks for libraries.
  74. dnl ---------------------------------------------------------------------
  75. require_zlib="no"
  76. dnl Check for zip archiver inclusion...
  77. AC_ARG_ENABLE(zip,
  78. [ --enable-zip enable ZIP support [default=yes]],
  79. , enable_zip=yes)
  80. if test x$enable_zip = xyes; then
  81. AC_DEFINE(PHYSFS_SUPPORTS_ZIP)
  82. require_zlib="yes"
  83. fi
  84. dnl Check for zip archiver inclusion...
  85. AC_ARG_ENABLE(grp,
  86. [ --enable-grp enable Build Engine GRP support [default=yes]],
  87. , enable_grp=yes)
  88. if test x$enable_grp = xyes; then
  89. AC_DEFINE(PHYSFS_SUPPORTS_GRP)
  90. fi
  91. AC_ARG_ENABLE(internal-zlib,
  92. [ --enable-internal-zlib use included zlib [default=only if needed]],
  93. , enable_internal_zlib=maybe)
  94. dnl Check for zlib if needed.
  95. have_external_zlib="no"
  96. if test x$enable_internal_zlib != xyes; then
  97. if test x$require_zlib = xyes; then
  98. AC_CHECK_HEADER(zlib.h, have_zlib_hdr=yes)
  99. AC_CHECK_LIB(z, zlibVersion, have_zlib_lib=yes)
  100. if test x$have_zlib_hdr = xyes -a x$have_zlib_lib = xyes; then
  101. have_external_zlib="yes"
  102. fi
  103. fi
  104. fi
  105. AC_MSG_CHECKING([what zlib to use])
  106. dnl no zlib is needed at all if we aren't supporting ZIP files.
  107. if test x$require_zlib = xno; then
  108. enable_internal_zlib="no"
  109. enable_external_zlib="no"
  110. AC_MSG_RESULT([no zlib needed])
  111. else
  112. if test x$enable_internal_zlib = xmaybe; then
  113. if test x$have_external_zlib = xyes; then
  114. enable_internal_zlib="no"
  115. enable_external_zlib="yes"
  116. else
  117. enable_internal_zlib="yes"
  118. enable_external_zlib="no"
  119. fi
  120. else
  121. if test x$enable_internal_zlib = xno -a x$have_external_zlib = xyes; then
  122. enable_internal_zlib="no"
  123. enable_external_zlib="yes"
  124. fi
  125. fi
  126. if test x$enable_internal_zlib = xyes; then
  127. AC_MSG_RESULT([internal zlib])
  128. else
  129. if test x$enable_external_zlib = xyes; then
  130. AC_MSG_RESULT([external zlib])
  131. LIBS="$LIBS -lz"
  132. else
  133. AC_MSG_ERROR([Need zlib, but you disabled our copy and have no system lib])
  134. fi
  135. fi
  136. fi
  137. dnl !!! FIXME: separate checks for history and readline...
  138. dnl determine if we should include readline support...
  139. AC_ARG_ENABLE(readline,
  140. [ --enable-readline use GNU readline in test program [default=yes]],
  141. , enable_readline=yes)
  142. if test x$enable_readline = xyes; then
  143. AC_CHECK_HEADER(readline/readline.h, have_readline_hdr=yes)
  144. AC_CHECK_LIB(readline, readline, have_readline_lib=yes)
  145. AC_CHECK_HEADER(readline/history.h, have_history_hdr=yes)
  146. AC_CHECK_LIB(readline, add_history, have_history_lib=yes)
  147. if test x$have_readline_hdr = xyes -a x$have_readline_lib = xyes; then
  148. if test x$have_history_hdr = xyes -a x$have_history_lib = xyes; then
  149. AC_DEFINE(PHYSFS_HAVE_READLINE)
  150. LIBS="$LIBS -lreadline"
  151. fi
  152. fi
  153. fi
  154. # Checks for header files.
  155. AC_HEADER_STDC
  156. AC_CHECK_HEADERS([stdlib.h string.h])
  157. # Checks for typedefs, structures, and compiler characteristics.
  158. AC_C_CONST
  159. AC_TYPE_SIZE_T
  160. # Checks for library functions.
  161. # This is only in the bleeding edge autoconf distro...
  162. #AC_FUNC_MALLOC
  163. AC_FUNC_MEMCMP
  164. AC_CHECK_FUNCS([memset strrchr])
  165. dnl Add Makefile conditionals
  166. AM_CONDITIONAL(BUILD_ZLIB, test x$enable_internal_zlib = xyes)
  167. AM_CONDITIONAL(BUILD_TEST_PHYSFS, test x$enable_testprog = xyes)
  168. AC_OUTPUT([
  169. Makefile
  170. platform/Makefile
  171. archivers/Makefile
  172. test/Makefile
  173. zlib114/Makefile
  174. ])