configure.in 14 KB

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