1
0

configure.in 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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=7
  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_BUILD
  36. AC_CANONICAL_HOST
  37. AC_CANONICAL_TARGET
  38. dnl Setup for automake
  39. AM_CONFIG_HEADER(config.h)
  40. AM_INIT_AUTOMAKE(physfs, $VERSION)
  41. dnl ---------------------------------------------------------------------
  42. dnl Compilers and other tools
  43. dnl ---------------------------------------------------------------------
  44. AC_PROG_CC
  45. AC_PROG_CXX
  46. AC_PROG_INSTALL
  47. AC_PROG_LN_S
  48. AC_LIBTOOL_WIN32_DLL
  49. LIBTOOL="libtool"
  50. AM_PROG_LIBTOOL
  51. AC_CHECK_PROG(we_have_sed, sed, yes, no)
  52. dnl ---------------------------------------------------------------------
  53. dnl Debug mode?
  54. dnl ---------------------------------------------------------------------
  55. AC_ARG_ENABLE(debug,
  56. [ --enable-debug enable debug mode [default=yes]],
  57. , enable_debug=yes)
  58. if test x$enable_debug = xyes; then
  59. if test x$ac_cv_prog_cc_g = xyes; then
  60. CFLAGS="-g -O0"
  61. else
  62. CFLAGS="-O0"
  63. fi
  64. CFLAGS="$CFLAGS -Werror -Wall"
  65. AC_DEFINE([DEBUG], 1, [define if debug build is enabled])
  66. AC_DEFINE([DEBUG_CHATTER], 1, [define if debug chatter is enabled])
  67. else
  68. CFLAGS="-O2"
  69. AC_DEFINE([NDEBUG], 1, [define if debug build is disabled])
  70. fi
  71. dnl ---------------------------------------------------------------------
  72. dnl Build test program?
  73. dnl ---------------------------------------------------------------------
  74. AC_ARG_ENABLE(testprog,
  75. [ --enable-testprog build test program [default=yes]],
  76. , enable_testprog=yes)
  77. dnl ---------------------------------------------------------------------
  78. dnl Checks for libraries.
  79. dnl ---------------------------------------------------------------------
  80. require_zlib="no"
  81. dnl Check for zip archiver inclusion...
  82. AC_ARG_ENABLE(zip,
  83. [ --enable-zip enable ZIP support [default=yes]],
  84. , enable_zip=yes)
  85. if test x$enable_zip = xyes; then
  86. AC_DEFINE([PHYSFS_SUPPORTS_ZIP], 1, [define if zip support is enabled])
  87. require_zlib="yes"
  88. fi
  89. dnl Check for zip archiver inclusion...
  90. AC_ARG_ENABLE(grp,
  91. [ --enable-grp enable Build Engine GRP support [default=yes]],
  92. , enable_grp=yes)
  93. if test x$enable_grp = xyes; then
  94. AC_DEFINE([PHYSFS_SUPPORTS_GRP], 1, [define if grp support is enabled])
  95. fi
  96. AC_ARG_ENABLE(internal-zlib,
  97. [ --enable-internal-zlib use included zlib [default=only if needed]],
  98. , enable_internal_zlib=maybe)
  99. dnl Check for zlib if needed.
  100. have_external_zlib="no"
  101. if test x$enable_internal_zlib != xyes; then
  102. if test x$require_zlib = xyes; then
  103. AC_CHECK_HEADER(zlib.h, have_zlib_hdr=yes)
  104. AC_CHECK_LIB(z, zlibVersion, have_zlib_lib=yes)
  105. if test x$have_zlib_hdr = xyes -a x$have_zlib_lib = xyes; then
  106. have_external_zlib="yes"
  107. fi
  108. fi
  109. fi
  110. AC_MSG_CHECKING([what zlib to use])
  111. dnl no zlib is needed at all if we aren't supporting ZIP files.
  112. if test x$require_zlib = xno; then
  113. enable_internal_zlib="no"
  114. enable_external_zlib="no"
  115. AC_MSG_RESULT([no zlib needed])
  116. else
  117. if test x$enable_internal_zlib = xmaybe; then
  118. if test x$have_external_zlib = xyes; then
  119. enable_internal_zlib="no"
  120. enable_external_zlib="yes"
  121. else
  122. enable_internal_zlib="yes"
  123. enable_external_zlib="no"
  124. fi
  125. else
  126. if test x$enable_internal_zlib = xno -a x$have_external_zlib = xyes; then
  127. enable_internal_zlib="no"
  128. enable_external_zlib="yes"
  129. fi
  130. fi
  131. if test x$enable_internal_zlib = xyes; then
  132. AC_MSG_RESULT([internal zlib])
  133. else
  134. if test x$enable_external_zlib = xyes; then
  135. AC_MSG_RESULT([external zlib])
  136. LIBS="$LIBS -lz"
  137. else
  138. AC_MSG_ERROR([Need zlib, but you disabled our copy and have no system lib])
  139. fi
  140. fi
  141. fi
  142. dnl determine if we should include readline support...
  143. AC_ARG_ENABLE(readline,
  144. [ --enable-readline use GNU readline in test program [default=yes]],
  145. , enable_readline=yes)
  146. if test x$enable_readline = xyes; then
  147. AC_CHECK_HEADER(readline/readline.h, have_readline_hdr=yes)
  148. AC_CHECK_LIB(readline, readline, have_readline_lib=yes, , -lcurses)
  149. AC_CHECK_HEADER(readline/history.h, have_history_hdr=yes)
  150. AC_CHECK_LIB(readline, add_history, have_history_lib=yes, , -lcurses)
  151. if test x$have_readline_hdr = xyes -a x$have_readline_lib = xyes; then
  152. if test x$have_history_hdr = xyes -a x$have_history_lib = xyes; then
  153. AC_DEFINE([PHYSFS_HAVE_READLINE], 1, [define if we have readline])
  154. LIBS="$LIBS -lreadline -lcurses"
  155. fi
  156. fi
  157. fi
  158. dnl !!! FIXME: Not sure how to detect this...
  159. dnl check for 64-bit llseek()...
  160. dnl AC_CHECK_LIB(c, llseek, have_llseek=yes)
  161. if test x$have_llseek = xyes; then
  162. AC_DEFINE([PHYSFS_HAVE_LLSEEK], 1, [define if we have llseek])
  163. fi
  164. dnl determine if we should use the stubbed pthread code.
  165. AC_ARG_ENABLE(pthreads,
  166. [ --enable-pthreads include POSIX threads support [default=yes]],
  167. , enable_pthreads=yes)
  168. if test x$enable_pthreads = xyes; then
  169. AC_CHECK_HEADER(pthread.h, have_pthread_hdr=yes)
  170. if test x$have_pthread_hdr != xyes; then
  171. enable_pthreads=no
  172. fi
  173. fi
  174. dnl determine if we should use the stubbed CD-ROM detection code.
  175. AC_ARG_ENABLE(cdrom,
  176. [ --enable-cdrom include CD-ROM support [default=yes]],
  177. , enable_cdrom=yes)
  178. if test x$enable_cdrom = xyes; then
  179. dnl reset this and let header detection reenable...
  180. enable_cdrom=no
  181. dnl BSD systems use sys/ucred.h for getting mounted volumes.
  182. dnl Linux and others use mntent.h.
  183. AC_CHECK_HEADER(sys/ucred.h, have_ucred_hdr=yes)
  184. if test x$have_ucred_hdr = xyes; then
  185. AC_DEFINE([PHYSFS_HAVE_SYS_UCRED_H], 1, [define if we have sys/ucred.h])
  186. enable_cdrom=yes
  187. fi
  188. AC_CHECK_HEADER(mntent.h, have_mntent_hdr=yes)
  189. if test x$have_mntent_hdr = xyes; then
  190. AC_DEFINE([PHYSFS_HAVE_MNTENT_H], 1, [define if we have mntent.h])
  191. enable_cdrom=yes
  192. fi
  193. fi
  194. have_non_posix_threads=no
  195. dnl AC_CHECK_HEADER(be/kernel/OS.h, this_is_beos=yes)
  196. AC_MSG_CHECKING([if this is BeOS])
  197. if test x$build_os = xbeos; then
  198. this_is_beos=yes
  199. enable_pthreads=no
  200. have_non_posix_threads=yes
  201. LIBS="$LIBS -lroot -lbe"
  202. else
  203. this_is_beos=no
  204. fi
  205. AC_MSG_RESULT([$this_is_beos])
  206. AC_MSG_CHECKING([if this is Cygwin])
  207. if test x$build_os = xcygwin; then
  208. this_is_cygwin=yes
  209. CFLAGS="$CFLAGS -DWIN32"
  210. enable_pthreads=no
  211. have_non_posix_threads=yes
  212. else
  213. this_is_cygwin=no
  214. fi
  215. AC_MSG_RESULT([$this_is_cygwin])
  216. this_is_macosx=no
  217. if test x$we_have_sed = xyes; then
  218. AC_MSG_CHECKING([if this is MacOS X])
  219. x=`echo $build_os |sed "s/darwin.*/darwin/"`
  220. if test x$x = xdarwin -a x$build_vendor = xapple; then
  221. this_is_macosx=yes
  222. fi
  223. AC_MSG_RESULT([$this_is_macosx])
  224. fi
  225. this_is_freebsd=no
  226. if test x$we_have_sed = xyes; then
  227. AC_MSG_CHECKING([if this is FreeBSD])
  228. x=`echo $build_os |tr A-Z a-z |sed "s/.*freebsd.*/freebsd/"`
  229. if test x$x = xfreebsd; then
  230. this_is_freebsd=yes
  231. LDFLAGS="$LDFLAGS -pthread"
  232. fi
  233. AC_MSG_RESULT([$this_is_freebsd])
  234. fi
  235. this_is_openbsd=no
  236. if test x$we_have_sed = xyes; then
  237. AC_MSG_CHECKING([if this is OpenBSD])
  238. x=`echo $build_os |tr A-Z a-z |sed "s/.*openbsd.*/openbsd/"`
  239. if test x$x = xopenbsd; then
  240. this_is_openbsd=yes
  241. LDFLAGS="$LDFLAGS -pthread"
  242. fi
  243. AC_MSG_RESULT([$this_is_openbsd])
  244. fi
  245. this_is_atheos=no
  246. if test x$we_have_sed = xyes; then
  247. AC_MSG_CHECKING([if this is AtheOS])
  248. x=`echo $build_os |tr A-Z a-z |sed "s/.*atheos.*/atheos/"`
  249. if test x$x = xatheos; then
  250. this_is_atheos=yes
  251. enable_cdrom=no
  252. enable_pthreads=no
  253. fi
  254. AC_MSG_RESULT([$this_is_atheos])
  255. fi
  256. dnl Some platform might disable this, so check this down here...
  257. if test x$enable_cdrom != xyes; then
  258. AC_DEFINE([PHYSFS_NO_CDROM_SUPPORT], 1, [define if we have no CD support])
  259. AC_MSG_WARN([***])
  260. AC_MSG_WARN([*** There is no CD-ROM support in this build!])
  261. AC_MSG_WARN([*** PhysicsFS will just pretend there are no discs.])
  262. AC_MSG_WARN([*** This may be fine, depending on how PhysicsFS is used,])
  263. AC_MSG_WARN([*** but is this what you REALLY wanted?])
  264. AC_MSG_WARN([*** (Maybe fix configure.in, or write a platform driver?)])
  265. AC_MSG_WARN([***])
  266. fi
  267. if test x$enable_pthreads != xyes; then
  268. AC_DEFINE([PHYSFS_NO_PTHREADS_SUPPORT], 1, [define if we have no POSIX threads support])
  269. if test x$have_non_posix_threads != xyes; then
  270. AC_MSG_WARN([***])
  271. AC_MSG_WARN([*** There is no thread support in this build!])
  272. AC_MSG_WARN([*** PhysicsFS will NOT be reentrant!])
  273. AC_MSG_WARN([*** This may be fine, depending on how PhysicsFS is used,])
  274. AC_MSG_WARN([*** but is this what you REALLY wanted?])
  275. AC_MSG_WARN([*** (Maybe fix configure.in, or write a platform driver?)])
  276. AC_MSG_WARN([***])
  277. fi
  278. fi
  279. # Checks for header files.
  280. AC_HEADER_STDC
  281. AC_CHECK_HEADERS([stdlib.h string.h])
  282. # Checks for typedefs, structures, and compiler characteristics.
  283. dnl AC_C_CONST
  284. dnl AC_TYPE_SIZE_T
  285. # Checks for library functions.
  286. # This is only in the bleeding edge autoconf distro...
  287. #AC_FUNC_MALLOC
  288. AC_FUNC_MEMCMP
  289. AC_CHECK_FUNCS([memset strrchr])
  290. CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"
  291. LDFLAGS="$LDFLAGS -no-undefined"
  292. dnl Add Makefile conditionals
  293. AM_CONDITIONAL(BUILD_ZLIB, test x$enable_internal_zlib = xyes)
  294. AM_CONDITIONAL(BUILD_TEST_PHYSFS, test x$enable_testprog = xyes)
  295. AM_CONDITIONAL(BUILD_MACOSX, test x$this_is_macosx = xyes)
  296. AM_CONDITIONAL(BUILD_BEOS, test x$this_is_beos = xyes)
  297. AM_CONDITIONAL(BUILD_CYGWIN, test x$this_is_cygwin = xyes)
  298. AC_OUTPUT([
  299. Makefile
  300. archivers/Makefile
  301. platform/Makefile
  302. zlib114/Makefile
  303. test/Makefile
  304. extras/Makefile
  305. physfs.spec
  306. ])
  307. dnl end of configure.in ...