configure.in 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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_CXX
  45. AC_PROG_INSTALL
  46. AC_PROG_LN_S
  47. AC_PROG_LIBTOOL
  48. dnl ---------------------------------------------------------------------
  49. dnl Debug mode?
  50. dnl ---------------------------------------------------------------------
  51. AC_ARG_ENABLE(debug,
  52. [ --enable-debug enable debug mode [default=yes]],
  53. , enable_debug=yes)
  54. if test x$enable_debug = xyes; then
  55. if test x$ac_cv_prog_cc_g = xyes; then
  56. CFLAGS="-g -O0"
  57. else
  58. CFLAGS="-O0"
  59. fi
  60. CFLAGS="$CFLAGS -Werror -Wall"
  61. AC_DEFINE(DEBUG)
  62. AC_DEFINE(DEBUG_CHATTER)
  63. else
  64. CFLAGS="-O2"
  65. AC_DEFINE(NDEBUG)
  66. fi
  67. dnl ---------------------------------------------------------------------
  68. dnl Build test program?
  69. dnl ---------------------------------------------------------------------
  70. AC_ARG_ENABLE(testprog,
  71. [ --enable-testprog build test program [default=yes]],
  72. , enable_testprog=yes)
  73. dnl ---------------------------------------------------------------------
  74. dnl Checks for libraries.
  75. dnl ---------------------------------------------------------------------
  76. require_zlib="no"
  77. dnl Check for zip archiver inclusion...
  78. AC_ARG_ENABLE(zip,
  79. [ --enable-zip enable ZIP support [default=yes]],
  80. , enable_zip=yes)
  81. if test x$enable_zip = xyes; then
  82. AC_DEFINE(PHYSFS_SUPPORTS_ZIP)
  83. require_zlib="yes"
  84. fi
  85. dnl Check for zip archiver inclusion...
  86. AC_ARG_ENABLE(grp,
  87. [ --enable-grp enable Build Engine GRP support [default=yes]],
  88. , enable_grp=yes)
  89. if test x$enable_grp = xyes; then
  90. AC_DEFINE(PHYSFS_SUPPORTS_GRP)
  91. fi
  92. AC_ARG_ENABLE(internal-zlib,
  93. [ --enable-internal-zlib use included zlib [default=only if needed]],
  94. , enable_internal_zlib=maybe)
  95. dnl Check for zlib if needed.
  96. have_external_zlib="no"
  97. if test x$enable_internal_zlib != xyes; then
  98. if test x$require_zlib = xyes; then
  99. AC_CHECK_HEADER(zlib.h, have_zlib_hdr=yes)
  100. AC_CHECK_LIB(z, zlibVersion, have_zlib_lib=yes)
  101. if test x$have_zlib_hdr = xyes -a x$have_zlib_lib = xyes; then
  102. have_external_zlib="yes"
  103. fi
  104. fi
  105. fi
  106. AC_MSG_CHECKING([what zlib to use])
  107. dnl no zlib is needed at all if we aren't supporting ZIP files.
  108. if test x$require_zlib = xno; then
  109. enable_internal_zlib="no"
  110. enable_external_zlib="no"
  111. AC_MSG_RESULT([no zlib needed])
  112. else
  113. if test x$enable_internal_zlib = xmaybe; then
  114. if test x$have_external_zlib = xyes; then
  115. enable_internal_zlib="no"
  116. enable_external_zlib="yes"
  117. else
  118. enable_internal_zlib="yes"
  119. enable_external_zlib="no"
  120. fi
  121. else
  122. if test x$enable_internal_zlib = xno -a x$have_external_zlib = xyes; then
  123. enable_internal_zlib="no"
  124. enable_external_zlib="yes"
  125. fi
  126. fi
  127. if test x$enable_internal_zlib = xyes; then
  128. AC_MSG_RESULT([internal zlib])
  129. else
  130. if test x$enable_external_zlib = xyes; then
  131. AC_MSG_RESULT([external zlib])
  132. LIBS="$LIBS -lz"
  133. else
  134. AC_MSG_ERROR([Need zlib, but you disabled our copy and have no system lib])
  135. fi
  136. fi
  137. fi
  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, , -lcurses)
  145. AC_CHECK_HEADER(readline/history.h, have_history_hdr=yes)
  146. AC_CHECK_LIB(readline, add_history, have_history_lib=yes, , -lcurses)
  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 -lcurses"
  151. fi
  152. fi
  153. fi
  154. AC_CHECK_HEADER(be/kernel/OS.h, this_is_beos=yes)
  155. if test x$this_is_beos = xyes; then
  156. LIBS="$LIBS -lroot -lbe"
  157. fi
  158. # Checks for header files.
  159. AC_HEADER_STDC
  160. AC_CHECK_HEADERS([stdlib.h string.h])
  161. # Checks for typedefs, structures, and compiler characteristics.
  162. AC_C_CONST
  163. AC_TYPE_SIZE_T
  164. # Checks for library functions.
  165. # This is only in the bleeding edge autoconf distro...
  166. #AC_FUNC_MALLOC
  167. AC_FUNC_MEMCMP
  168. AC_CHECK_FUNCS([memset strrchr])
  169. dnl Add Makefile conditionals
  170. AM_CONDITIONAL(BUILD_ZLIB, test x$enable_internal_zlib = xyes)
  171. AM_CONDITIONAL(BUILD_TEST_PHYSFS, test x$enable_testprog = xyes)
  172. AM_CONDITIONAL(BUILD_BEOS_CPP, test x$this_is_beos = xyes)
  173. AC_OUTPUT([
  174. Makefile
  175. platform/Makefile
  176. archivers/Makefile
  177. test/Makefile
  178. zlib114/Makefile
  179. extras/Makefile
  180. ])