configure.in 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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 grp 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. dnl Check for qpak archiver inclusion...
  97. AC_ARG_ENABLE(qpak,
  98. [ --enable-qpak enable Quake PAK support [default=yes]],
  99. , enable_qpak=yes)
  100. if test x$enable_qpak = xyes; then
  101. AC_DEFINE([PHYSFS_SUPPORTS_QPAK], 1, [define if qpak support is enabled])
  102. fi
  103. AC_ARG_ENABLE(internal-zlib,
  104. [ --enable-internal-zlib use included zlib [default=only if needed]],
  105. , enable_internal_zlib=maybe)
  106. dnl Check for zlib if needed.
  107. have_external_zlib="no"
  108. if test x$enable_internal_zlib != xyes; then
  109. if test x$require_zlib = xyes; then
  110. AC_CHECK_HEADER(zlib.h, have_zlib_hdr=yes)
  111. AC_CHECK_LIB(z, zlibVersion, have_zlib_lib=yes)
  112. if test x$have_zlib_hdr = xyes -a x$have_zlib_lib = xyes; then
  113. have_external_zlib="yes"
  114. fi
  115. fi
  116. fi
  117. AC_MSG_CHECKING([what zlib to use])
  118. dnl no zlib is needed at all if we aren't supporting ZIP files.
  119. if test x$require_zlib = xno; then
  120. enable_internal_zlib="no"
  121. enable_external_zlib="no"
  122. AC_MSG_RESULT([no zlib needed])
  123. else
  124. if test x$enable_internal_zlib = xmaybe; then
  125. if test x$have_external_zlib = xyes; then
  126. enable_internal_zlib="no"
  127. enable_external_zlib="yes"
  128. else
  129. enable_internal_zlib="yes"
  130. enable_external_zlib="no"
  131. fi
  132. else
  133. if test x$enable_internal_zlib = xno -a x$have_external_zlib = xyes; then
  134. enable_internal_zlib="no"
  135. enable_external_zlib="yes"
  136. fi
  137. fi
  138. if test x$enable_internal_zlib = xyes; then
  139. AC_MSG_RESULT([internal zlib])
  140. else
  141. if test x$enable_external_zlib = xyes; then
  142. AC_MSG_RESULT([external zlib])
  143. LIBS="$LIBS -lz"
  144. else
  145. AC_MSG_ERROR([Need zlib, but you disabled our copy and have no system lib])
  146. fi
  147. fi
  148. fi
  149. dnl determine if we should include readline support...
  150. AC_ARG_ENABLE(readline,
  151. [ --enable-readline use GNU readline in test program [default=yes]],
  152. , enable_readline=yes)
  153. if test x$enable_readline = xyes; then
  154. AC_CHECK_HEADER(readline/readline.h, have_readline_hdr=yes)
  155. AC_CHECK_LIB(readline, readline, have_readline_lib=yes, , -lcurses)
  156. AC_CHECK_HEADER(readline/history.h, have_history_hdr=yes)
  157. AC_CHECK_LIB(readline, add_history, have_history_lib=yes, , -lcurses)
  158. if test x$have_readline_hdr = xyes -a x$have_readline_lib = xyes; then
  159. if test x$have_history_hdr = xyes -a x$have_history_lib = xyes; then
  160. AC_DEFINE([PHYSFS_HAVE_READLINE], 1, [define if we have readline])
  161. LIBS="$LIBS -lreadline -lcurses"
  162. fi
  163. fi
  164. fi
  165. dnl !!! FIXME: Not sure how to detect this...
  166. dnl check for 64-bit llseek()...
  167. dnl AC_CHECK_LIB(c, llseek, have_llseek=yes)
  168. if test x$have_llseek = xyes; then
  169. AC_DEFINE([PHYSFS_HAVE_LLSEEK], 1, [define if we have llseek])
  170. fi
  171. dnl determine if we should use the stubbed pthread code.
  172. AC_ARG_ENABLE(pthreads,
  173. [ --enable-pthreads include POSIX threads support [default=yes]],
  174. , enable_pthreads=yes)
  175. if test x$enable_pthreads = xyes; then
  176. AC_CHECK_HEADER(pthread.h, have_pthread_hdr=yes)
  177. if test x$have_pthread_hdr != xyes; then
  178. enable_pthreads=no
  179. fi
  180. fi
  181. dnl determine if we should use the stubbed CD-ROM detection code.
  182. AC_ARG_ENABLE(cdrom,
  183. [ --enable-cdrom include CD-ROM support [default=yes]],
  184. , enable_cdrom=yes)
  185. if test x$enable_cdrom = xyes; then
  186. dnl reset this and let header detection reenable...
  187. enable_cdrom=no
  188. dnl BSD systems use sys/ucred.h for getting mounted volumes.
  189. dnl Linux and others use mntent.h.
  190. AC_CHECK_HEADER(sys/ucred.h, have_ucred_hdr=yes)
  191. if test x$have_ucred_hdr = xyes; then
  192. AC_DEFINE([PHYSFS_HAVE_SYS_UCRED_H], 1, [define if we have sys/ucred.h])
  193. enable_cdrom=yes
  194. fi
  195. AC_CHECK_HEADER(mntent.h, have_mntent_hdr=yes)
  196. if test x$have_mntent_hdr = xyes; then
  197. AC_DEFINE([PHYSFS_HAVE_MNTENT_H], 1, [define if we have mntent.h])
  198. enable_cdrom=yes
  199. fi
  200. fi
  201. dnl determine language.
  202. physfslang=english
  203. AC_ARG_ENABLE(language,
  204. [ --enable-language=lang Select natural language. [default=english]],
  205. physfslang=`echo $enable_language |tr A-Z a-z`)
  206. AC_MSG_CHECKING([if language choice is supported])
  207. physfs_valid_lang=no
  208. if test x$physfslang = xenglish; then
  209. physfs_valid_lang=yes
  210. AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_ENGLISH, [define desired natural language])
  211. fi
  212. if test x$physfslang = xrussian-koi8-r; then
  213. physfs_valid_lang=yes
  214. AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_RUSSIAN_KOI8_R, [define desired natural language])
  215. fi
  216. if test x$physfslang = xrussian-cp1251; then
  217. physfs_valid_lang=yes
  218. AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_RUSSIAN_CP866, [define desired natural language])
  219. fi
  220. if test x$physfslang = xrussian-cp866; then
  221. physfs_valid_lang=yes
  222. AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_RUSSIAN_CP866, [define desired natural language])
  223. fi
  224. if test x$physfslang = xrussian-iso-8859-5; then
  225. physfs_valid_lang=yes
  226. AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_RUSSIAN_ISO_8859_5, [define desired natural language])
  227. fi
  228. if test x$physfslang = xspanish; then
  229. physfs_valid_lang=yes
  230. AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_SPANISH, [define desired natural language])
  231. fi
  232. if test x$physfslang = xfrench; then
  233. physfs_valid_lang=yes
  234. AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_FRENCH, [define desired natural language])
  235. fi
  236. dnl Add other language checks here...
  237. AC_MSG_RESULT([$physfs_valid_lang])
  238. if test x$physfs_valid_lang = xno; then
  239. AC_MSG_WARN([***])
  240. AC_MSG_WARN([*** You've asked for "$physfslang" language support...])
  241. AC_MSG_WARN([*** ...but we don't support that.])
  242. AC_MSG_WARN([*** You could choose another language,])
  243. AC_MSG_WARN([*** but is this what you REALLY wanted?])
  244. AC_MSG_WARN([*** Please see the LANG section of physfs_internal.h])
  245. AC_MSG_WARN([*** for info on writing a translation.])
  246. AC_MSG_WARN([***])
  247. AC_MSG_WARN([*** Currently known languages:])
  248. AC_MSG_WARN([*** --enable-language=english])
  249. AC_MSG_WARN([*** --enable-language=spanish])
  250. AC_MSG_WARN([*** --enable-language=russian-koi8-r])
  251. AC_MSG_WARN([*** --enable-language=russian-cp1251])
  252. AC_MSG_WARN([*** --enable-language=russian-cp866])
  253. AC_MSG_WARN([*** --enable-language=russian-iso-8859-5])
  254. AC_MSG_WARN([*** --enable-language=french])
  255. AC_MSG_WARN([***])
  256. AC_MSG_ERROR([*** unsupported language. stop.])
  257. fi
  258. have_non_posix_threads=no
  259. AC_MSG_CHECKING([if this is BeOS])
  260. if test x$build_os = xbeos; then
  261. this_is_beos=yes
  262. enable_pthreads=no
  263. have_non_posix_threads=yes
  264. LIBS="$LIBS -lroot -lbe"
  265. else
  266. this_is_beos=no
  267. fi
  268. AC_MSG_RESULT([$this_is_beos])
  269. AC_MSG_CHECKING([if this is Cygwin])
  270. if test x$build_os = xcygwin; then
  271. this_is_cygwin=yes
  272. CFLAGS="$CFLAGS -DWIN32"
  273. enable_pthreads=no
  274. have_non_posix_threads=yes
  275. else
  276. this_is_cygwin=no
  277. fi
  278. AC_MSG_RESULT([$this_is_cygwin])
  279. this_is_macosx=no
  280. if test x$we_have_sed = xyes; then
  281. AC_MSG_CHECKING([if this is MacOS X])
  282. x=`echo $build_os |sed "s/darwin.*/darwin/"`
  283. if test x$x = xdarwin -a x$build_vendor = xapple; then
  284. this_is_macosx=yes
  285. fi
  286. AC_MSG_RESULT([$this_is_macosx])
  287. fi
  288. this_is_freebsd=no
  289. if test x$we_have_sed = xyes; then
  290. AC_MSG_CHECKING([if this is FreeBSD])
  291. x=`echo $build_os |tr A-Z a-z |sed "s/.*freebsd.*/freebsd/"`
  292. if test x$x = xfreebsd; then
  293. this_is_freebsd=yes
  294. LDFLAGS="$LDFLAGS -pthread"
  295. fi
  296. AC_MSG_RESULT([$this_is_freebsd])
  297. fi
  298. this_is_openbsd=no
  299. if test x$we_have_sed = xyes; then
  300. AC_MSG_CHECKING([if this is OpenBSD])
  301. x=`echo $build_os |tr A-Z a-z |sed "s/.*openbsd.*/openbsd/"`
  302. if test x$x = xopenbsd; then
  303. this_is_openbsd=yes
  304. LDFLAGS="$LDFLAGS -pthread"
  305. fi
  306. AC_MSG_RESULT([$this_is_openbsd])
  307. fi
  308. this_is_atheos=no
  309. if test x$we_have_sed = xyes; then
  310. AC_MSG_CHECKING([if this is AtheOS])
  311. x=`echo $build_os |tr A-Z a-z |sed "s/.*atheos.*/atheos/"`
  312. if test x$x = xatheos; then
  313. this_is_atheos=yes
  314. enable_cdrom=no
  315. enable_pthreads=no
  316. fi
  317. AC_MSG_RESULT([$this_is_atheos])
  318. fi
  319. dnl Some platform might disable this, so check this down here...
  320. if test x$enable_cdrom != xyes; then
  321. AC_DEFINE([PHYSFS_NO_CDROM_SUPPORT], 1, [define if we have no CD support])
  322. AC_MSG_WARN([***])
  323. AC_MSG_WARN([*** There is no CD-ROM support in this build!])
  324. AC_MSG_WARN([*** PhysicsFS will just pretend there are no discs.])
  325. AC_MSG_WARN([*** This may be fine, depending on how PhysicsFS is used,])
  326. AC_MSG_WARN([*** but is this what you REALLY wanted?])
  327. AC_MSG_WARN([*** (Maybe fix configure.in, or write a platform driver?)])
  328. AC_MSG_WARN([***])
  329. fi
  330. if test x$enable_pthreads != xyes; then
  331. AC_DEFINE([PHYSFS_NO_PTHREADS_SUPPORT], 1, [define if we have no POSIX threads support])
  332. if test x$have_non_posix_threads != xyes; then
  333. AC_MSG_WARN([***])
  334. AC_MSG_WARN([*** There is no thread support in this build!])
  335. AC_MSG_WARN([*** PhysicsFS will NOT be reentrant!])
  336. AC_MSG_WARN([*** This may be fine, depending on how PhysicsFS is used,])
  337. AC_MSG_WARN([*** but is this what you REALLY wanted?])
  338. AC_MSG_WARN([*** (Maybe fix configure.in, or write a platform driver?)])
  339. AC_MSG_WARN([***])
  340. fi
  341. fi
  342. # Checks for header files.
  343. AC_HEADER_STDC
  344. AC_CHECK_HEADERS([stdlib.h string.h])
  345. # Checks for typedefs, structures, and compiler characteristics.
  346. dnl AC_C_CONST
  347. dnl AC_TYPE_SIZE_T
  348. # Checks for library functions.
  349. # This is only in the bleeding edge autoconf distro...
  350. #AC_FUNC_MALLOC
  351. AC_FUNC_MEMCMP
  352. AC_CHECK_FUNCS([memset strrchr])
  353. AC_CHECK_SIZEOF(int, 4)
  354. CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"
  355. LDFLAGS="$LDFLAGS -no-undefined"
  356. dnl Add Makefile conditionals
  357. AM_CONDITIONAL(BUILD_ZLIB, test x$enable_internal_zlib = xyes)
  358. AM_CONDITIONAL(BUILD_TEST_PHYSFS, test x$enable_testprog = xyes)
  359. AM_CONDITIONAL(BUILD_MACOSX, test x$this_is_macosx = xyes)
  360. AM_CONDITIONAL(BUILD_BEOS, test x$this_is_beos = xyes)
  361. AM_CONDITIONAL(BUILD_CYGWIN, test x$this_is_cygwin = xyes)
  362. AC_OUTPUT([
  363. Makefile
  364. archivers/Makefile
  365. platform/Makefile
  366. zlib114/Makefile
  367. test/Makefile
  368. extras/Makefile
  369. physfs.spec
  370. ])
  371. dnl end of configure.in ...