PageRenderTime 34ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/CS/migrated/tags/PRE_CSARRAY_SIZE_T_INDICES/configure.ac

#
m4 | 1622 lines | 925 code | 272 blank | 425 comment | 0 complexity | 6ac3c0ce8db342ef34d21c7b36940c09 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0
  1. # -*- Autoconf -*-
  2. #==============================================================================
  3. # Copyright (C)2003,2004 by Eric Sunshine <sunshine@sunshineco.com>
  4. #
  5. # Autoconf input script for Crystal Space. Process this file with
  6. # CS/bin/autogen.sh to produce a configure script.
  7. #==============================================================================
  8. AC_PREREQ([2.56])
  9. #------------------------------------------------------------------------------
  10. # cs_version_number
  11. # Keep this value synchronized with CS/include/csver.h.
  12. #------------------------------------------------------------------------------
  13. m4_define([cs_version_number], [0.98])
  14. #------------------------------------------------------------------------------
  15. # cs_lib_paths_default
  16. # Whitespace delimited list of directory tuples in which to search, by
  17. # default, for external libraries. Each list item can specify an
  18. # include|library directory tuple (for example, "/usr/include|/usr/lib"),
  19. # or a single directory (for example, "/usr"). If the second form is
  20. # used, then the directory itself is searched first. If the external
  21. # resource is not found, then "include" and "lib" subdirectories of the
  22. # directory are searched. Thus, specifying "/proj" is shorthand for
  23. # "/proj|/proj /proj/include|/proj/lib".
  24. #
  25. # Present Cases:
  26. # /usr/local -- Not all compilers search here by default, so we specify
  27. # it manually.
  28. # /sw -- Fink, the MacOS/X manager of Unix packages, installs here by
  29. # default.
  30. #------------------------------------------------------------------------------
  31. m4_define([cs_lib_paths_default],
  32. [/usr/local/include|/usr/local/lib /sw/include|/sw/lib])
  33. #==============================================================================
  34. # INITIALIZATION
  35. #==============================================================================
  36. AC_INIT([crystal], [cs_version_number], [crystal-main@lists.sourceforge.net])
  37. CS_PACKAGEINFO([Crystal Space],
  38. [Copyright (C)1998-2004 Jorrit Tyberghein and others],
  39. [http://crystal.sourceforge.net/])
  40. AC_CONFIG_SRCDIR([libs/csutil/Jamfile])
  41. AC_CONFIG_AUX_DIR([mk/autoconf])
  42. AC_CANONICAL_HOST
  43. #------------------------------------------------------------------------------
  44. # Check for compilers and common tools.
  45. #------------------------------------------------------------------------------
  46. AC_PROG_CC
  47. CS_EMIT_BUILD_PROPERTY([CMD.CC], [$CC])
  48. AC_PROG_CXX
  49. CS_EMIT_BUILD_PROPERTY([CMD.C++], [$CXX])
  50. # C++ compiler is used as linker.
  51. CS_EMIT_BUILD_PROPERTY([CMD.LINK], [AS_ESCAPE([$(CMD.C++)])])
  52. AS_IF([test $ac_compiler_gnu = yes],
  53. [cs_compiler_name=GCC CS_HEADER_PROPERTY([COMP_GCC])],
  54. [cs_compiler_name="AS_TR_CPP([$CXX])"])
  55. CS_EMIT_BUILD_PROPERTY([COMPILER.TYPE], [$cs_compiler_name])
  56. CS_HEADER_PROPERTY([CS_COMPILER_NAME],
  57. [AS_ESCAPE(["])$cs_compiler_name[]AS_ESCAPE(["])])
  58. AC_PROG_RANLIB
  59. CS_EMIT_BUILD_PROPERTY([RANLIB], [$RANLIB])
  60. AC_CHECK_TOOLS([DLLTOOL], [dlltool])
  61. CS_EMIT_BUILD_PROPERTY([CMD.DLLTOOL], [$DLLTOOL])
  62. AC_CHECK_TOOLS([DLLWRAP], [dllwrap])
  63. CS_EMIT_BUILD_PROPERTY([CMD.DLLWRAP], [$DLLWRAP])
  64. AC_CHECK_TOOLS([WINDRES], [windres])
  65. CS_EMIT_BUILD_PROPERTY([CMD.WINDRES], [$WINDRES])
  66. AC_CHECK_TOOLS([OBJCOPY], [objcopy])
  67. AS_IF([test -n "$OBJCOPY"],
  68. [CS_EMIT_BUILD_PROPERTY([OBJCOPY.AVAILABLE], [yes])
  69. CS_EMIT_BUILD_PROPERTY([CMD.OBJCOPY], [$OBJCOPY])])
  70. AC_CHECK_PROGS([FLEX], [flex])
  71. CS_EMIT_BUILD_PROPERTY([CMD.FLEX], [$FLEX])
  72. AC_CHECK_PROGS([BISON], [bison])
  73. AS_IF([test -n "$BISON"],
  74. [CS_CHECK_PROG_VERSION([bison], [$BISON --version], [1.35], [9.9],
  75. [CS_EMIT_BUILD_PROPERTY([CMD.BISON], [$BISON])])])
  76. AC_CHECK_PROGS([DOXYGEN], [doxygen])
  77. CS_EMIT_BUILD_PROPERTY([CMD.DOXYGEN], [$DOXYGEN])
  78. AC_CHECK_PROGS([TEXI2DVI], [texi2dvi])
  79. CS_EMIT_BUILD_PROPERTY([CMD.TEXI2DVI], [$TEXI2DVI])
  80. AC_CHECK_PROGS([DVIPS], [dvips])
  81. CS_EMIT_BUILD_PROPERTY([CMD.DVIPS], [$DVIPS])
  82. AC_CHECK_PROGS([DVIPDF], [dvipdf])
  83. CS_EMIT_BUILD_PROPERTY([CMD.DVIPDF], [$DVIPDF])
  84. AC_CHECK_PROGS([MAKEINFO], [makeinfo])
  85. CS_EMIT_BUILD_PROPERTY([CMD.MAKEINFO], [$MAKEINFO])
  86. AC_CHECK_PROGS([INSTALL], [install])
  87. CS_EMIT_BUILD_PROPERTY([INSTALL], [$INSTALL])
  88. AC_CHECK_PROGS([SWIG], [swig])
  89. AS_IF([test -n "$SWIG"],
  90. [CS_CHECK_PROG_VERSION([swig], [$SWIG -version 2>&1], [1.3.14],
  91. [9.9|.9], [CS_EMIT_BUILD_PROPERTY([CMD.SWIG], [$SWIG])])])
  92. CS_CHECK_LIBTOOL
  93. CS_EMIT_BUILD_PROPERTY([LIBTOOL], [$LIBTOOL])
  94. CS_EMIT_BUILD_PROPERTY([APPLE_LIBTOOL], [$APPLE_LIBTOOL])
  95. CS_CHECK_MKDIR
  96. CS_EMIT_BUILD_PROPERTY([CMD.MKDIR], [$MKDIR])
  97. CS_EMIT_BUILD_PROPERTY([CMD.MKDIRS], [$MKDIRS])
  98. #------------------------------------------------------------------------------
  99. # In order to avoid alienating users by forcing them to install and use Jam,
  100. # config.status is instructed (see far below) to build Jam on the user's behalf
  101. # from local sources, and to place the executable in the root of the build
  102. # directory. When checking for Jam, in addition to PATH, we also look in root
  103. # of the build directory since we might already have built Jam on a previous
  104. # configure run.
  105. #
  106. # IMPLEMENTATION NOTES
  107. #
  108. # The Crystal Space build system supports Jam versions starting with 2.4.
  109. # Earlier versions are rejected. Examples of rejected versions include Apple's
  110. # highly modified Jam (based upon 2.2.1), and ftjam (based upon
  111. # 2.3.2). BoostJam reports its version number as 3.1.9 (or greater), though it
  112. # is actually based upon Jam 2.4. Since we accept 2.4, and since 3.1.9 passes
  113. # the "jam -v >= 2.4" assertion, this version anomaly is not a problem.
  114. #
  115. # We also check for 'make', since it is used to build Jam locally, when needed.
  116. #------------------------------------------------------------------------------
  117. m4_define([cs_jam_local_exe], [jam$EXEEXT])
  118. AC_PATH_PROGS([JAM], [jam], [], [$PATH$PATH_SEPARATOR.])
  119. AS_IF([test -n "$JAM"],
  120. [CS_CHECK_PROG_VERSION([jam], ["$JAM" -v 2>&1], [2.4], [9.9|.9],
  121. [cs_prog_jam_okay=yes], [cs_prog_jam_okay=no])],
  122. [cs_prog_jam_okay=no])
  123. AS_IF([test $cs_prog_jam_okay != yes],
  124. [JAM=./cs_jam_local_exe CS_NEED_LOCAL_JAM=yes])
  125. CS_EMIT_BUILD_PROPERTY([JAM], [$JAM])
  126. AC_CHECK_PROGS([MAKE], [gnumake gmake make])
  127. #------------------------------------------------------------------------------
  128. # The cs-win32libs package is a convenience archive made available to Windows
  129. # users of Crystal Space. It contains common libraries, headers, and tools
  130. # (such as zlib, libjpeg, cal3d, etc.) usable by MSVC, Mingw/MSYS, and Cygwin
  131. # users. It saves users the bother of having to install these packages
  132. # manually one at a time.
  133. #------------------------------------------------------------------------------
  134. AC_CHECK_TOOLS([CSLIBS_CONFIG], [cslibs-config])
  135. AS_IF([test $ac_compiler_gnu = yes],
  136. [cs_cv_cslibs_compiler="--compiler gcc-`$CXX -dumpversion`"])
  137. AC_CACHE_CHECK([for cslibs package], [cs_cv_cslibs],
  138. [AS_IF([test -n "$CSLIBS_CONFIG"],
  139. [cs_cv_cslibs=yes
  140. cs_cv_cslibs_cflags=`
  141. AC_RUN_LOG([$CSLIBS_CONFIG --cflags $cs_cv_cslibs_compiler])`
  142. cs_cv_cslibs_lflags=`
  143. AC_RUN_LOG([$CSLIBS_CONFIG --lflags $cs_cv_cslibs_compiler])`
  144. cs_cv_cslibs_binpath=`
  145. AC_RUN_LOG([$CSLIBS_CONFIG --binpath $cs_cv_cslibs_compiler])`],
  146. [cs_cv_cslibs=no])])
  147. AS_IF([test $cs_cv_cslibs = yes],
  148. [CFLAGS="$CFLAGS $cs_cv_cslibs_cflags"
  149. CPPFLAGS="$CPPFLAGS $cs_cv_cslibs_cflags"
  150. LDFLAGS="$LDFLAGS $cs_cv_cslibs_lflags"
  151. PATH="$cs_cv_cslibs_binpath$PATH_SEPARATOR$PATH"])
  152. #------------------------------------------------------------------------------
  153. # Check for NASM and extensions (such as %xdefine) which we require.
  154. #------------------------------------------------------------------------------
  155. AC_CHECK_TOOLS([NASM], [nasmw nasm])
  156. AS_IF([test -n "$NASM"],
  157. [AC_CACHE_CHECK([if nasm is sufficiently recent], [cs_cv_prog_nasm_ok],
  158. [echo "%xdefine TEST" > conftest.asm
  159. AS_IF([AC_RUN_LOG(
  160. [$NASM conftest.asm -o conftest.$OBJEXT 1>&2])],
  161. [cs_cv_prog_nasm_ok=yes], [cs_cv_prog_nasm_ok=no])
  162. rm -f conftest.*])
  163. AS_IF([test $cs_cv_prog_nasm_ok = yes],
  164. [CS_EMIT_BUILD_PROPERTY([NASM.AVAILABLE], [yes])
  165. CS_EMIT_BUILD_PROPERTY([CMD.NASM], [$NASM])
  166. CS_HEADER_PROPERTY([DO_NASM])])])
  167. #------------------------------------------------------------------------------
  168. # Check for typical required libraries (libm, libmx, libdl, libnsl).
  169. #------------------------------------------------------------------------------
  170. AC_DEFUN([CS_CHECK_COMMON_LIBS],
  171. [AC_LANG_PUSH([C])
  172. AC_CHECK_LIB([m], [pow], [cs_cv_libm_libs=-lm], [cs_cv_libm_libs=])
  173. AC_CHECK_LIB([m], [cosf], [cs_cv_libm_libs=-lm])
  174. AC_CHECK_LIB([mx], [cosf])
  175. AC_CHECK_LIB([dl], [dlopen], [cs_cv_libdl_libs=-ldl], [cs_cv_libdl_libs=])
  176. AC_CHECK_LIB([nsl], [gethostbyname])
  177. AC_LANG_POP([C])])
  178. CS_CHECK_COMMON_LIBS
  179. AS_IF([test $ac_cv_lib_m_pow = yes || test $ac_cv_lib_m_cosf = yes],
  180. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-lm], [+])])
  181. AS_IF([test $ac_cv_lib_mx_cosf = yes],
  182. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-lmx], [+])])
  183. AS_IF([test $ac_cv_lib_dl_dlopen = yes],
  184. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-ldl], [+])])
  185. AS_IF([test $ac_cv_lib_nsl_gethostbyname = yes],
  186. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-lnsl], [+])])
  187. AS_IF([test $ac_cv_lib_m_cosf = no && test $ac_cv_lib_mx_cosf = no],
  188. [CS_HEADER_PROPERTY([CS_USE_FAKE_MATH_H_FLOAT_FUNCS])])
  189. #------------------------------------------------------------------------------
  190. # Check for pthread. Also check if pthread implementation supports the
  191. # recursive mutex extension.
  192. #------------------------------------------------------------------------------
  193. CS_CHECK_PTHREAD([cygwin*])
  194. CS_EMIT_BUILD_RESULT([cs_cv_sys_pthread], [PTHREAD])
  195. AS_IF([test $cs_cv_sys_pthread_recursive != no],
  196. [CS_HEADER_PROPERTY([CS_PTHREAD_MUTEX_RECURSIVE],
  197. [$cs_cv_sys_pthread_recursive])])
  198. #------------------------------------------------------------------------------
  199. # Check if RTLD_NOW dlopen() flag is available; some installations (OpenBSD,
  200. # for example) provide only RTLD_LAZY.
  201. #------------------------------------------------------------------------------
  202. AC_DEFUN([CS_CHECK_RTLD],
  203. [AC_REQUIRE([CS_CHECK_COMMON_LIBS])
  204. CS_CHECK_BUILD([for RTLD_NOW], [cs_cv_sys_rtld_now],
  205. [AC_LANG_PROGRAM([[#include <dlfcn.h>]], [dlopen(0, RTLD_NOW)])],
  206. [], [], [CS_HEADER_PROPERTY([CS_RTLD_NOW_AVAILABLE])], [], [],
  207. [], [], [$cs_cv_libdl_libs])])
  208. CS_CHECK_RTLD
  209. #------------------------------------------------------------------------------
  210. # Determine host platform. Recognized families: Unix, Windows, MacOS/X.
  211. #
  212. # CS_CHECK_HOST
  213. # Sets the shell variables cs_host_target and cs_host_family. Client
  214. # code can use these variables to emit appropriate Jam variables and
  215. # OS_FOO header define.
  216. #------------------------------------------------------------------------------
  217. AC_DEFUN([CS_CHECK_HOST],
  218. [AC_REQUIRE([AC_CANONICAL_HOST])
  219. cs_host_os_normalized=''
  220. case $host_os in
  221. mingw*|cygwin*)
  222. cs_host_target=win32gcc
  223. cs_host_family=windows
  224. ;;
  225. darwin*)
  226. _CS_CHECK_HOST_DARWIN
  227. ;;
  228. *)
  229. # Everything else is assumed to be Unix or Unix-like.
  230. cs_host_target=unix
  231. cs_host_family=unix
  232. ;;
  233. esac])
  234. AC_DEFUN([_CS_CHECK_HOST_DARWIN],
  235. [AC_REQUIRE([AC_PROG_CC])
  236. AC_REQUIRE([AC_PROG_CXX])
  237. # Both MacOS/X and Darwin are identified via $host_os as "darwin". We need
  238. # a way to distinguish between the two. If Carbon.h is present, then
  239. # assume MacOX/S; if not, assume Darwin. If --with-x=yes was invoked, and
  240. # Carbon.h is present, then assume that user wants to cross-build for
  241. # Darwin even though build host is MacOS/X. Implementation note: At least
  242. # one MacOS/X user switches between gcc 2.95 and gcc 3.3 with a script
  243. # which toggles the values of CC, CXX, and CPP. Unfortunately, CPP was
  244. # being set to run the preprocessor directly ("cpp", for instance) rather
  245. # than running it via the compiler ("gcc -E", for instance). The problem
  246. # with running the preprocessor directly is that __APPLE__ and __GNUC__ are
  247. # not defined, which causes the Carbon.h check to fail. We avoid this
  248. # problem by supplying a non-empty fourth argument to AC_CHECK_HEADER(),
  249. # which causes it to test compile the header only (which is a more robust
  250. # test), rather than also testing it via the preprocessor.
  251. AC_CHECK_HEADER([Carbon/Carbon.h],
  252. [cs_host_macosx=yes], [cs_host_macosx=no], [/* force compile */])
  253. AS_IF([test $cs_host_macosx = yes],
  254. [AC_MSG_CHECKING([for --with-x])
  255. AS_IF([test "${with_x+set}" = set && test "$with_x" = "yes"],
  256. [AC_MSG_RESULT([yes (assume Darwin)])
  257. cs_host_macosx=no],
  258. [AC_MSG_RESULT([no])])])
  259. AS_IF([test $cs_host_macosx = yes],
  260. [cs_host_target=macosx
  261. cs_host_family=unix
  262. cs_host_os_normalized='MacOS/X'
  263. CS_HEADER_PROPERTY([OS_MACOSX])
  264. CS_HEADER_PROPERTY([CS_24BIT_PIXEL_LAYOUT], [CS_24BIT_PIXEL_ARGB])
  265. # We assume that we always have CoreAudio available on MacOS/X.
  266. CS_EMIT_BUILD_PROPERTY([COREAUDIO.AVAILABLE], [yes])
  267. CS_EMIT_BUILD_PROPERTY([COREAUDIO.LFLAGS], [-framework CoreAudio])
  268. AC_CACHE_CHECK([for Objective-C compiler], [cs_cv_prog_objc],
  269. [cs_cv_prog_objc="$CC"])
  270. CS_EMIT_BUILD_PROPERTY([CMD.OBJC], [$cs_cv_prog_objc])
  271. AC_CACHE_CHECK([for Objective-C++ compiler], [cs_cv_prog_objcxx],
  272. [cs_cv_prog_objcxx="$CXX"])
  273. CS_EMIT_BUILD_PROPERTY([CMD.OBJC++], [$cs_cv_prog_objcxx])],
  274. [cs_host_target=unix
  275. cs_host_family=unix])])
  276. CS_CHECK_HOST
  277. case $cs_host_family in
  278. windows)
  279. CS_HEADER_PROPERTY([OS_WIN32])
  280. AS_IF([test -z "$cs_host_os_normalized"],
  281. [cs_host_os_normalized='Win32'])
  282. ;;
  283. unix)
  284. CS_HEADER_PROPERTY([OS_UNIX])
  285. AS_IF([test -z "$cs_host_os_normalized"],
  286. [cs_host_os_normalized='Unix'])
  287. ;;
  288. esac
  289. cs_host_os_normalized_uc="AS_TR_CPP([$cs_host_os_normalized])"
  290. CS_EMIT_BUILD_PROPERTY([TARGET.OS], [$cs_host_os_normalized_uc])
  291. CS_EMIT_BUILD_PROPERTY([TARGET.OS.NORMALIZED], [$cs_host_os_normalized])
  292. CS_HEADER_PROPERTY([CS_PLATFORM_NAME],
  293. [AS_ESCAPE(["])$cs_host_os_normalized[]AS_ESCAPE(["])])
  294. #------------------------------------------------------------------------------
  295. # Check if Perl SDK is installed and which compiler and linker flags are
  296. # required to embed Perl. Also determine if the glue file can be created with
  297. # ExtUtils::Embed or if it must be created manually.
  298. #------------------------------------------------------------------------------
  299. AC_CHECK_PROGS([PERL], [perl5 perl])
  300. CS_EMIT_BUILD_PROPERTY([PERL5], [$PERL])
  301. CS_EMIT_BUILD_PROPERTY([PERL], [$PERL])
  302. CS_EMIT_BUILD_PROPERTY([CMD.PERL5], [$PERL])
  303. # csperl5 fails to build on many platforms, so default is NO for now.
  304. AC_ARG_WITH([perl], [AC_HELP_STRING([--with-perl],
  305. [use Perl5 scripting interface (default NO)])])
  306. AS_IF([test -z "$with_perl"], [with_perl=no])
  307. AS_IF([test -n "$PERL" && test "$with_perl" != no],
  308. [AC_CACHE_CHECK([for perl ExtUtils::Embed module], [cs_cv_perl_mod_embed],
  309. [AS_IF([AC_RUN_LOG([$PERL -MExtUtils::Embed -e 0 1>&2])],
  310. [cs_cv_perl_mod_embed=yes], [cs_cv_perl_mod_embed=no])])
  311. AS_IF([test $cs_cv_perl_mod_embed = yes],
  312. [CS_EMIT_BUILD_PROPERTY([PERL5.EXTUTILS.EMBED.AVAILABLE], [yes])
  313. AC_CACHE_CHECK([for perl DynaLoader module],
  314. [cs_cv_perl_mod_dynaloader],
  315. [AS_IF([AC_RUN_LOG([$PERL -MDynaLoader -e 0 1>&2])],
  316. [cs_cv_perl_mod_dynaloader=yes],
  317. [cs_cv_perl_mod_dynaloader=no])])
  318. AS_IF([test $cs_cv_perl_mod_dynaloader = yes],
  319. [CS_EMIT_BUILD_PROPERTY([PERL5.DYNALOADER.AVAILABLE], [yes])])],
  320. [# ExtUtils::Embed absent.
  321. AC_MSG_NOTICE([Recommend you install a recent release of Perl 5.])
  322. AC_MSG_NOTICE([http://www.perl.org/])
  323. AC_CACHE_CHECK([for perl Config module], [cs_cv_perl_mod_config],
  324. [AS_IF([AC_RUN_LOG([$PERL -MConfig -e 0 1>&2])],
  325. [cs_cv_perl_mod_config=yes], [cs_cv_perl_mod_config=no])])])
  326. AS_VAR_SET_IF([cs_cv_perl_cflags], [],
  327. [AS_IF([test $cs_cv_perl_mod_embed = yes],
  328. [cs_cv_perl_cflags=`AC_RUN_LOG(
  329. [$PERL -MExtUtils::Embed -e ccopts])`
  330. cs_cv_perl_lflags=`AC_RUN_LOG(
  331. [$PERL -MExtUtils::Embed -e ldopts])`
  332. cs_cv_perl_ext=`AC_RUN_LOG([$PERL -MConfig -e \
  333. '$e = $Config{"dlext"} || $Config{"so"} || ""; print "$e"'])`],
  334. [AS_IF([test $cs_cv_perl_mod_config = yes],
  335. [cs_perl_core=`AC_RUN_LOG(
  336. [$PERL -MConfig -e 'print $Config{archlib}'])`
  337. cs_perl_core="${cs_perl_core}/CORE"
  338. cs_cv_perl_cflags=`AC_RUN_LOG(
  339. [$PERL -MConfig -e 'print $Config{ccflags}'])`
  340. cs_cv_perl_cflags="${cs_cv_perl_cflags} -I${cs_perl_core}"
  341. cs_cv_perl_lflags=`AC_RUN_LOG([$PERL -MConfig -e \
  342. 'print $Config{ldflags}, " ", $Config{libs}'])`
  343. cs_cv_perl_lflags="${cs_cv_perl_lflags} -L${cs_perl_core}"
  344. cs_cv_perl_ext=`AC_RUN_LOG([$PERL -MConfig -e \
  345. '$e = $Config{"dlext"}||$Config{"so"}||""; print "$e"'])`],
  346. [cs_perl_core=`AC_RUN_LOG([$PERL -V:archlib | \
  347. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`
  348. cs_perl_core="${cs_perl_core}/CORE"
  349. cs_cv_perl_cflags=`AC_RUN_LOG([$PERL -V:ccflags | \
  350. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`
  351. cs_cv_perl_cflags="${cs_cv_perl_cflags} -I${cs_perl_core}"
  352. cs_cv_perl_lflags=`AC_RUN_LOG([$PERL -V:ldflags | \
  353. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`
  354. cs_perl_lflags_tmp=`AC_RUN_LOG([$PERL -V:libs | \
  355. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`
  356. cs_cv_perl_lflags="${cs_cv_perl_lflags} ${cs_perl_lflags_tmp}
  357. -L${cs_perl_core}"
  358. cs_cv_perl_ext=`AC_RUN_LOG([$PERL -V:dlext | \
  359. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`])])
  360. cs_cv_perl_cflags=CS_PATH_NORMALIZE([$cs_cv_perl_cflags])
  361. cs_cv_perl_cflags=CS_TRIM([$cs_cv_perl_cflags])
  362. cs_cv_perl_lflags=CS_PATH_NORMALIZE([$cs_cv_perl_lflags])
  363. cs_cv_perl_lflags=CS_TRIM([$cs_cv_perl_lflags])])
  364. AS_IF([test -n "$cs_cv_perl_cflags$cs_cv_perl_lflags"],
  365. [CS_CHECK_BUILD([if Perl SDK is usable], [cs_cv_perl],
  366. [AC_LANG_PROGRAM(
  367. [[#include <EXTERN.h>
  368. #include <perl.h>]],
  369. [perl_run(0);])],
  370. [CS_CREATE_TUPLE([$cs_cv_perl_cflags],[],[$cs_cv_perl_lflags])])
  371. AS_IF([test $cs_cv_perl = yes],
  372. [CS_EMIT_BUILD_RESULT([cs_cv_perl], [PERL5])
  373. CS_EMIT_BUILD_PROPERTY([PERL5.MODULE_EXT],[.$cs_cv_perl_ext])])])])
  374. #------------------------------------------------------------------------------
  375. # Check if Python SDK is installed and which compiler and linker flags are
  376. # required to embed Python.
  377. #------------------------------------------------------------------------------
  378. CS_EMIT_CHECK_PYTHON([], [Python scripting interface])
  379. #------------------------------------------------------------------------------
  380. # Check if Java2 SDK is installed and which compiler and linker flags are
  381. # needed. Also check if Ant build tool, which is commonly used to build Java
  382. # projects, is available.
  383. #------------------------------------------------------------------------------
  384. AC_DEFUN([CS_JAVA_HEADER_PATH],
  385. [AC_REQUIRE([AC_CANONICAL_HOST])
  386. AC_REQUIRE([CS_CHECK_HOST])
  387. AS_IF([test x$cs_host_macosx = xyes && # Not cross-building for Darwin.
  388. test -r /System/Library/Frameworks/JavaVM.framework/Headers],
  389. [cs_java_inc="-I/System/Library/Frameworks/JavaVM.framework/Headers"],
  390. [AS_IF([test -n "$JAVA_HOME"],
  391. [cs_java_dir="$JAVA_HOME"],
  392. [AS_IF([test -n "$1"],
  393. [cs_java_dir=`AS_DIRNAME([$1])`
  394. cs_java_dir=`AS_DIRNAME([$cs_java_dir])`],
  395. [cs_java_dir=''])])
  396. AS_IF([test -n "$cs_java_dir"],
  397. [cs_java_inc="-I$cs_java_dir/include"
  398. case $host_os in
  399. mingw*|cygwin*) cs_java_platform=win32 ;;
  400. *) cs_java_platform=`echo $host_os |
  401. sed 's/^\([[^-]]*\).*$/\1/'` ;;
  402. esac
  403. AS_IF([test -n "$cs_java_platform"],
  404. [cs_java_inc="$cs_java_inc
  405. $cs_java_inc/$cs_java_platform"])])])])
  406. AC_PATH_PROGS([JAVA], [java], [],
  407. [$PATH$PATH_SEPARATOR$JAVA_HOME/bin$PATH_SEPARATOR$JAVA_HOME/jre/bin])
  408. CS_EMIT_BUILD_PROPERTY([JAVA], [$JAVA])
  409. AC_PATH_PROGS([JAVAC], [javac], [],
  410. [$PATH$PATH_SEPARATOR$JAVA_HOME/bin$PATH_SEPARATOR$JAVA_HOME/jre/bin])
  411. CS_EMIT_BUILD_PROPERTY([JAVAC], [$JAVAC])
  412. AC_ARG_WITH([java], [AC_HELP_STRING([--with-java],
  413. [use Java scripting interface (default YES)])])
  414. AS_IF([test -z "$with_java"], [with_java=yes])
  415. AS_IF([test "$with_java" != no && test -n "$JAVAC" && test -n "$JAVA"],
  416. [CS_JAVA_HEADER_PATH([$JAVAC])
  417. CS_CHECK_BUILD([if Java2 SDK is usable], [cs_cv_java],
  418. [AC_LANG_PROGRAM(
  419. [[#include <jni.h>
  420. JNIEXPORT void JNICALL f(JNIEnv *env, jobject obj);]])],
  421. [CS_CREATE_TUPLE() CS_CREATE_TUPLE([$cs_java_inc])], [],
  422. [CS_EMIT_BUILD_RESULT([cs_cv_java], [JAVA])])])
  423. AC_PATH_PROGS([ANT], [ant], [], [$PATH$PATH_SEPARATOR$ANT_HOME/bin])
  424. CS_EMIT_BUILD_PROPERTY([ANT], [$ANT])
  425. #------------------------------------------------------------------------------
  426. # Use the CPPFLAGS, CXXFLAGS, CFLAGS, and LDFLAGS passed to configure.
  427. # Further, Autoconf insists upon issuing optimization flags (-O) and debug
  428. # flags (-g) at one and the same time, but this is not suitable for Crystal
  429. # Space's build system, which makes a distinction between `optimize' and
  430. # `debug' builds, so we must filter out these flags.
  431. #------------------------------------------------------------------------------
  432. CFLAGS=`echo "$CFLAGS" | sed 's/-O.//g;s/-g.//g'`
  433. CXXFLAGS=`echo "$CXXFLAGS" | sed 's/-O.//g;s/-g.//g'`
  434. CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS], [$CPPFLAGS $CFLAGS], [+])
  435. CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS], [$CPPFLAGS $CXXFLAGS], [+])
  436. CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [$LDFLAGS], [+])
  437. #------------------------------------------------------------------------------
  438. # Check how to enable compilation warnings. Note that on some platforms, it is
  439. # more appropriate to use -Wmost rather than -Wall even if the compiler
  440. # understands both, thus we attempt -Wmost before -Wall.
  441. #------------------------------------------------------------------------------
  442. CS_EMIT_BUILD_FLAGS([how to enable compilation warnings],
  443. [cs_cv_prog_cxx_enable_warnings],
  444. [CS_CREATE_TUPLE([-Wmost]) CS_CREATE_TUPLE([-Wall])], [C++],
  445. [COMPILER.CFLAGS], [+],
  446. [cs_prog_cxx_enable_warnings="$cs_cv_prog_cxx_enable_warnings"],
  447. [cs_prog_cxx_enable_warnings=''])
  448. #------------------------------------------------------------------------------
  449. # Check how to make compiler treat warnings as errors.
  450. #------------------------------------------------------------------------------
  451. CS_CHECK_BUILD_FLAGS([how to treat warnings as errors],
  452. [cs_cv_prog_cxx_enable_errors], [CS_CREATE_TUPLE([-Werror])], [C++],
  453. [cs_prog_cxx_enable_errors="$cs_cv_prog_cxx_enable_errors"],
  454. [cs_prog_cxx_enable_errors=''])
  455. #------------------------------------------------------------------------------
  456. # Check how to make compiler ignore unused variables and arguments. This is
  457. # needed for code generated by tools, such as Swig, Bison, and Flex, over which
  458. # we have no control.
  459. #------------------------------------------------------------------------------
  460. CS_EMIT_BUILD_FLAGS([how to ignore unused variables],
  461. [cs_cv_prog_cxx_ignore_unused_variables],
  462. [CS_CREATE_TUPLE([-Wno-unused])], [C++],
  463. [COMPILER.C++FLAGS.WARNING.NO_UNUSED])
  464. #------------------------------------------------------------------------------
  465. # Check how to make compiler ignore uninitialized variables and arguments.
  466. # This is needed for code generated by tools, such as Swig, Bison, and Flex,
  467. # over which we have no control.
  468. #------------------------------------------------------------------------------
  469. CS_EMIT_BUILD_FLAGS([how to ignore uninitialized variables],
  470. [cs_cv_prog_cxx_ignore_uninitialized_variables],
  471. [CS_CREATE_TUPLE([-Wno-uninitialized])], [C++],
  472. [COMPILER.C++FLAGS.WARNING.NO_UNINITIALIZED])
  473. #------------------------------------------------------------------------------
  474. # Check if warnings about unknown #pragmas can be disabled. (MSVC and Borland
  475. # use a number of pragmas not understood by GCC, for instance.)
  476. #------------------------------------------------------------------------------
  477. CS_EMIT_BUILD_FLAGS([[how to ignore unknown #pragma directives]],
  478. [cs_cv_prog_cxx_ignore_unknown_pragmas],
  479. [CS_CREATE_TUPLE([-Wno-unknown-pragmas])], [C++], [COMPILER.CFLAGS], [+])
  480. #------------------------------------------------------------------------------
  481. # Check if C++ exceptions can be enabled and disabled.
  482. #------------------------------------------------------------------------------
  483. CS_EMIT_BUILD_FLAGS([how to enable C++ exceptions],
  484. [cs_cv_prog_cxx_enable_exceptions], [CS_CREATE_TUPLE([-fexceptions])],
  485. [C++], [COMPILER.C++FLAGS.EXCEPTIONS.ENABLE], [])
  486. CS_EMIT_BUILD_FLAGS([how to disable C++ exceptions],
  487. [cs_cv_prog_cxx_disable_exceptions], [CS_CREATE_TUPLE([-fno-exceptions])],
  488. [C++], [COMPILER.C++FLAGS.EXCEPTIONS.DISABLE], [],
  489. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS],
  490. [$cs_cv_prog_cxx_disable_exceptions], [+])])
  491. #------------------------------------------------------------------------------
  492. # Check if the linker recognizes "-multiply_defined suppress". This is
  493. # required for MacOS/X 10.1 to avoid warning messages when linking a program
  494. # with "-framework Foundation" if that program does not actually employ any
  495. # Objective-C.
  496. #------------------------------------------------------------------------------
  497. CS_EMIT_BUILD_FLAGS([if -multiply_defined suppress is needed],
  498. [cs_cv_prog_link_suppress_multiple],
  499. [CS_CREATE_TUPLE([], [-multiply_defined suppress])],
  500. [], [COMPILER.LFLAGS], [+])
  501. #------------------------------------------------------------------------------
  502. # Check if the linker recognizes "-force_cpusubtype_ALL". This is required on
  503. # MacOS/X since the Crystal Space's PowerPC implementation of qsqrt() uses the
  504. # `frsqrte' instruction which is only valid when the -force_cpusubtype_ALL flag
  505. # is present. This flag is marked "mandatory" because it is required even for
  506. # external projects if they use qsqrt().
  507. #------------------------------------------------------------------------------
  508. AC_DEFUN([CS_CHECK_FORCE_CPUSUBTYPE_ALL],
  509. [CS_CHECK_BUILD_FLAGS([if -force_cpusubtype_ALL is needed],
  510. [cs_cv_prog_cxx_force_cpusubtype_all],
  511. [CS_CREATE_TUPLE([], [-force_cpusubtype_ALL])])])
  512. CS_CHECK_FORCE_CPUSUBTYPE_ALL
  513. AS_IF([test $cs_cv_prog_cxx_force_cpusubtype_all != no],
  514. [CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS.MANDATORY],
  515. [$cs_cv_prog_cxx_force_cpusubtype_all], [+])])
  516. #------------------------------------------------------------------------------
  517. # Check if the MacOS/X compiler recognizes "-fno-common". This flag is needed
  518. # when building plugin modules (and the libraries which are linked into
  519. # plugins) prior to Apple's introduction of the two-level namespace symbol
  520. # scheme in order to ensure that each plugin module gets its own copy of
  521. # uninitialized global variables.
  522. #------------------------------------------------------------------------------
  523. AC_DEFUN([CS_CHECK_NO_COMMON],
  524. [AC_REQUIRE([AC_CANONICAL_HOST])
  525. case $host_os in
  526. darwin*)
  527. CS_EMIT_BUILD_FLAGS([if -fno-common is needed],
  528. [cs_cv_prog_cxx_no_common],
  529. [CS_CREATE_TUPLE([], [-fno-common])], [C++],
  530. [COMPILER.CFLAGS.MANDATORY], [+])
  531. ;;
  532. esac])
  533. CS_CHECK_NO_COMMON
  534. #------------------------------------------------------------------------------
  535. # Check if Mingw and Cygwin compilers recognize -fvtable-thunks. As of gcc
  536. # 3.x, this option is no longer supported. Unfortunately, rather than
  537. # returning an error code (as it does with other unrecognized options), the
  538. # compiler merely prints a warning message when -fvtable-thunks is used, thus
  539. # we use -Werror to turn the warning into an error.
  540. #------------------------------------------------------------------------------
  541. AC_DEFUN([CS_CHECK_VTABLE_THUNKS],
  542. [AC_REQUIRE([AC_CANONICAL_HOST])
  543. case $host_os in
  544. mingw*|cygwin*)
  545. CS_CHECK_BUILD_FLAGS([if -fvtable-thunks is needed],
  546. [cs_cv_prog_cxx_vtable_thunks],
  547. [CS_CREATE_TUPLE([-fvtable-thunks])], [C++],
  548. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS.MANDATORY],
  549. [$cs_cv_prog_cxx_vtable_thunks], [+])],
  550. [], [$cs_prog_cxx_enable_errors])
  551. ;;
  552. esac])
  553. CS_CHECK_VTABLE_THUNKS
  554. #------------------------------------------------------------------------------
  555. # Check if compiler recognizes -pipe directive.
  556. #------------------------------------------------------------------------------
  557. CS_EMIT_BUILD_FLAGS([if -pipe is accepted], [cs_cv_prog_cxx_pipe],
  558. [CS_CREATE_TUPLE([-pipe])], [C++], [COMPILER.CFLAGS], [+])
  559. #------------------------------------------------------------------------------
  560. # Check if compiler/linker recognizes -shared directive which is needed for
  561. # linking plugin modules. Unfortunately, the Apple compiler (and possibly
  562. # others) require extra effort. Even though the compiler does not recognize
  563. # the -shared option, it nevertheless returns a "success" result after
  564. # complaining that the option is unrecognized. Worse, even -Werror fails to
  565. # coerce the compiler into returning a "failure" result, so we must perform the
  566. # additional task of checking the compiler's output for an appropriate error
  567. # emission, such as "unrecognized option `-shared'".
  568. #------------------------------------------------------------------------------
  569. CS_CHECK_BUILD_FLAGS([if -shared is accepted], [cs_cv_prog_link_shared],
  570. [CS_CREATE_TUPLE([-shared])], [C++],
  571. [CS_EMIT_BUILD_PROPERTY([PLUGIN.LFLAGS], [-shared], [+])], [],
  572. [$cs_prog_cxx_enable_errors], [], [], [nrecognize])
  573. #------------------------------------------------------------------------------
  574. # Check if linker recognizes -soname which is used to assign a name internally
  575. # to plugin modules.
  576. #------------------------------------------------------------------------------
  577. CS_CHECK_BUILD([if -soname is accepted], [cs_cv_prog_link_soname], [],
  578. [CS_CREATE_TUPLE([-Wl,-soname,foobar])], [C++],
  579. [CS_EMIT_BUILD_PROPERTY([PLUGIN.LFLAGS.USE_SONAME], [yes])])
  580. #------------------------------------------------------------------------------
  581. # Check for compiler- and CPU-specific code generation flags. These flags are
  582. # mutually exclusive. Exclusivity is enforced by the CS_CHECK_CODE_GEN_FLAG()
  583. # macro. Note that use of these flags typically means that the resulting
  584. # binary will not be backward compatible. For instance, if Pentium-specific
  585. # instructions are used, the program will not work with earlier processors,
  586. # such as the Intel 486. Because these options are potentially dangerous,
  587. # their use it controlled by the user via --enable-cpu-specific-optimizations
  588. # which accepts "no" (same as "disable"), "minimum" (the default), and
  589. # "maximum". The "minimum" option selects optimizations which are likely to be
  590. # supported by reasonably modern hardware, thus making the resulting
  591. # executables fairly portable.
  592. #
  593. # CS_CHECK_CODE_GEN_FLAG(CPU-PATTERN, FLAGS, [LANGUAGE])
  594. # If compiler- and CPU-specific optimization flags have not already been
  595. # determined, and if the canonical host CPU matches CPU-PATTERN, try
  596. # using the provided compiler FLAGS with the compiler represented by
  597. # LANGUAGE (typically either "C" or "C++"). If language is omitted, C++
  598. # is used. If the compiler accepts the flags, assign them to the shell
  599. # variable cs_cv_prog_cxx_code_gen.
  600. #------------------------------------------------------------------------------
  601. AC_DEFUN([CS_CHECK_CODE_GEN_FLAG],
  602. [AC_REQUIRE([AC_CANONICAL_HOST])
  603. AS_IF([test "$cs_cv_prog_cxx_code_gen" = no],
  604. [case $host_cpu in
  605. $1) CS_BUILD_IFELSE([],
  606. [CS_CREATE_TUPLE([$2])], m4_default([$3],[C++]),
  607. [cs_cv_prog_cxx_code_gen=$cs_build_cflags], [])
  608. ;;
  609. esac])])
  610. AC_MSG_CHECKING([whether to use CPU-specific optimizations])
  611. AC_ARG_ENABLE([cpu-specific-optimizations],
  612. [AC_HELP_STRING([--enable-cpu-specific-optimizations=level],
  613. [enable CPU-specific optimizations; recognized levels are `no',
  614. `minimum' or `min', `maximum' or `max' (default MINIMUM); the `minimum'
  615. option selects optimizations which are likely to be supported by
  616. reasonably modern hardware, thus making the resulting executables
  617. fairly portable; use the `maximum' option with caution since code for
  618. one processor will not work with earlier processors (for example, Intel
  619. 686-specific code will not work with a 586)])],
  620. [case $enable_cpu_specific_optimizations in
  621. yes|min) enable_cpu_specific_optimizations=minimum ;;
  622. max) enable_cpu_specific_optimizations=maximum ;;
  623. esac],
  624. [enable_cpu_specific_optimizations=minimum])
  625. AC_MSG_RESULT([$enable_cpu_specific_optimizations])
  626. case $enable_cpu_specific_optimizations in
  627. no|minimum|maximum) ;;
  628. *) CS_MSG_ERROR([unrecognized option; use `no', `minimum', or `maximum'])
  629. ;;
  630. esac
  631. AS_IF([test $enable_cpu_specific_optimizations != no],
  632. [AC_CACHE_CHECK([for code generation flags], [cs_cv_prog_cxx_code_gen],
  633. [cs_cv_prog_cxx_code_gen=no
  634. AS_IF([test $enable_cpu_specific_optimizations = maximum],
  635. [CS_CHECK_CODE_GEN_FLAG([athlon], [-march=athlon])
  636. CS_CHECK_CODE_GEN_FLAG([athlon], [-mcpu=athlon -march=athlon])
  637. CS_CHECK_CODE_GEN_FLAG([athlon], [-mcpu=athlon])
  638. CS_CHECK_CODE_GEN_FLAG([*686], [-march=i686])
  639. CS_CHECK_CODE_GEN_FLAG([*686], [-mcpu=pentiumpro -march=i686])
  640. CS_CHECK_CODE_GEN_FLAG([*686], [-mcpu=pentiumpro])
  641. CS_CHECK_CODE_GEN_FLAG([*686], [-mpentiumpro -march=i686])
  642. CS_CHECK_CODE_GEN_FLAG([*686], [-mpentiumpro])])
  643. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-march=i586])
  644. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-mcpu=pentium -march=i586])
  645. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-mcpu=pentium])
  646. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-mpentium -march=i586])
  647. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-mpentium])
  648. CS_CHECK_CODE_GEN_FLAG([[*[3-9]86]], [-mcpu=i486])
  649. CS_CHECK_CODE_GEN_FLAG([[*[3-9]86]], [-m486])
  650. CS_CHECK_CODE_GEN_FLAG([alpha], [-mieee])])
  651. AS_IF([test "$cs_cv_prog_cxx_code_gen" != no],
  652. [CS_EMIT_BUILD_PROPERTY(
  653. [COMPILER.CFLAGS], [$cs_cv_prog_cxx_code_gen], [+])])])
  654. #------------------------------------------------------------------------------
  655. # Check for compiler optimization flags.
  656. #------------------------------------------------------------------------------
  657. AC_DEFUN([CS_CHECK_OPTIMIZE_FLAGS],
  658. [AC_REQUIRE([AC_PROG_CC])
  659. AC_REQUIRE([AC_PROG_CXX])
  660. cs_optimize_flags=''
  661. CS_EMIT_BUILD_FLAGS([how to enable optimizations],
  662. [cs_cv_prog_cxx_optimize],
  663. [CS_CREATE_TUPLE([-O3]) CS_CREATE_TUPLE([-O2]) CS_CREATE_TUPLE([-O])],
  664. [C++], [COMPILER.CFLAGS.optimize], [+],
  665. [cs_optimize_flags="$cs_optimize_flags $cs_cv_prog_cxx_optimize"])
  666. CS_EMIT_BUILD_FLAGS([if $CXX recognizes -fomit-frame-pointer],
  667. [cs_cv_prog_cxx_omit_frame_pointer],
  668. [CS_CREATE_TUPLE([-fomit-frame-pointer])],
  669. [C++], [COMPILER.CFLAGS.optimize], [+],
  670. [cs_optimize_flags="$cs_optimize_flags \
  671. $cs_cv_prog_cxx_omit_frame_pointer"])
  672. CS_EMIT_BUILD_FLAGS([if $CXX recognizes -ffast-math],
  673. [cs_cv_prog_cxx_fast_math],
  674. [CS_CREATE_TUPLE([-ffast-math])], [C++],
  675. [COMPILER.CFLAGS.optimize], [+],
  676. [cs_optimize_flags="$cs_optimize_flags $cs_cv_prog_cxx_fast_math"])])
  677. CS_CHECK_OPTIMIZE_FLAGS
  678. #------------------------------------------------------------------------------
  679. # Check for compiler debug flags.
  680. #------------------------------------------------------------------------------
  681. CS_EMIT_BUILD_FLAGS([how to enable compiler debug output],
  682. [cs_cv_prog_cxx_debug],
  683. [CS_CREATE_TUPLE([-g3]) CS_CREATE_TUPLE([-g2]) CS_CREATE_TUPLE([-g])],
  684. [C++], [COMPILER.CFLAGS.debug], [+])
  685. AS_IF([test $cs_cv_prog_cxx_debug != no],
  686. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS.debug], [$cs_cv_prog_cxx_debug],
  687. [+])])
  688. #------------------------------------------------------------------------------
  689. # Check if compiler complains about adding /usr/local/include to the header
  690. # search path. If not, add it to the header search path since not all
  691. # compilers search there by default. Some compiler, on the other hand,
  692. # complain if it is already in the built-in search path, and we would like to
  693. # avoid the complaint, if possible.
  694. #------------------------------------------------------------------------------
  695. AS_IF([test -d /usr/local/include],
  696. [CS_CHECK_BUILD_FLAGS([if -I/usr/local/include is usable],
  697. [cs_cv_prog_cxx_local_include],
  698. [CS_CREATE_TUPLE([-I/usr/local/include])], [C++],
  699. [cs_cv_prog_cxx_local_include=yes],
  700. [cs_cv_prog_cxx_local_include=no],
  701. [$cs_prog_cxx_enable_warnings $cs_prog_cxx_enable_errors])],
  702. [cs_cv_prog_cxx_local_include=no])
  703. AS_IF([test $cs_cv_prog_cxx_local_include = yes],
  704. [CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS], [-I/usr/local/include], [+])
  705. CPPFLAGS="$CPPFLAGS -I/usr/local/include"])
  706. AS_IF([test -d /usr/local/lib],
  707. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-L/usr/local/lib], [+])
  708. LDFLAGS="$LDFLAGS -L/usr/local/lib"])
  709. #------------------------------------------------------------------------------
  710. # Check for X-Windows. If the X-Windows implementation is XFree86, then also
  711. # enable the `VideoMode' extension.
  712. #------------------------------------------------------------------------------
  713. AC_DEFUN([CS_X_CHECK_PREPARE],
  714. [AC_REQUIRE([AC_CANONICAL_HOST])
  715. AC_REQUIRE([CS_CHECK_HOST])
  716. # Explicitly disable X checking on Windows to avoid discovering XFree86 in
  717. # case Cygwin is installed. Doing so allows us to avoid Mesa's OpenGL
  718. # headers during the OpenGL check, and prefer Microsoft's OpenGL headers.
  719. # The Mesa OpenGL headers cause link errors because they do not employ
  720. # __stdcall.
  721. case $host_os in
  722. mingw*|cygwin*) with_x=no ;;
  723. esac
  724. # Explicitly disable X checking on MacOS/X in case the optional XFree86 is
  725. # installed since we want to avoid an undesirable dependency upon XFree86
  726. # in the CS executables and plugins. If the user is actually
  727. # cross-building for Darwin on MacOS/X, then the --with-x option will
  728. # override this test (by setting cs_host_macosx to "no").
  729. AS_IF([test x$cs_host_macosx = xyes], [with_x=no])])
  730. CS_X_CHECK_PREPARE
  731. AC_PATH_X
  732. AC_PATH_XTRA
  733. AS_IF([test "$no_x" != yes],
  734. [# We must be especially careful to instruct CS_EMIT_BUILD_PROPERTY() to
  735. # emit the following properties even if their values are empty. This is
  736. # necessary because of the way that Jam performs "product-wise" variable
  737. # expansion. For example, if X is "x" and Y is undefined, Jam will expand
  738. # "$(X) $(Y)" to "", whereas every other tool in the world will expand it
  739. # to "x ". Since the emitted X11.CFLAGS, X11.LFLAGS, XFREE86VM.CFLAGS, and
  740. # XFREE86VM.LFLAGS properties reference the other variables by name, we
  741. # must ensure that those other variables are defined (even if only with an
  742. # empty string).
  743. CS_EMIT_BUILD_PROPERTY([X11.AVAILABLE], [yes])
  744. CS_EMIT_BUILD_PROPERTY([X_CFLAGS], [$X_CFLAGS], [], [Y])
  745. CS_EMIT_BUILD_PROPERTY([X_LIBS], [$X_LIBS], [], [Y])
  746. CS_EMIT_BUILD_PROPERTY([X_PRE_LIBS], [$X_PRE_LIBS], [], [Y])
  747. CS_EMIT_BUILD_PROPERTY([X_EXTRA_LIBS], [$X_EXTRA_LIBS], [], [Y])
  748. CS_EMIT_BUILD_PROPERTY([X11.CFLAGS], [AS_ESCAPE([$(X_CFLAGS)])])
  749. CS_EMIT_BUILD_PROPERTY([X11.LFLAGS],
  750. [AS_ESCAPE([$(X_PRE_LIBS) $(X_LIBS) -lXext -lX11 $(X_EXTRA_LIBS)])])
  751. CS_CHECK_LIB_WITH([Xxf86vm],
  752. [AC_LANG_PROGRAM(
  753. [[#define XK_MISCELLANY 1
  754. #include <X11/Xlib.h>
  755. #include <X11/Xutil.h>
  756. #include <X11/Xatom.h>
  757. #include <X11/extensions/xf86vmode.h>]],
  758. [XF86VidModeLockModeSwitch(0, 0, 0)])], [], [],
  759. [CS_EMIT_BUILD_PROPERTY([XFREE86VM.AVAILABLE], [yes])
  760. CS_EMIT_BUILD_PROPERTY([XFREE86VM.CFLAGS], [AS_ESCAPE([$(X_CFLAGS)])])
  761. CS_EMIT_BUILD_PROPERTY([XFREE86VM.LFLAGS],
  762. [AS_ESCAPE([$(X_PRE_LIBS) $(X_LIBS) -lXxf86vm -lXext -lX11
  763. $(X_EXTRA_LIBS)])])], [],
  764. [$X_CFLAGS], [], [$X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS])])
  765. #------------------------------------------------------------------------------
  766. # Check for OpenGL and companions. Also check if GLX extensions are supported
  767. # and define the (backward) header property CSGL_EXT_STATIC_ASSERTION if they
  768. # are _not_ supported.
  769. #
  770. # IMPLEMENTATION NOTES
  771. #
  772. # Some Mesa installations require pthread, so pthread flags are employed if
  773. # available.
  774. #
  775. # The check for opengl32 needs to precede other checks because Cygwin users
  776. # often have Mesa installed, and Mesa's OpenGL library is compiled without the
  777. # __stdcall flags which results in link errors, whereas Microsoft's native
  778. # opengl32 works fine. Conversely, some Unix implementations have Wine
  779. # installed (Windows emulation layer) which includes an opengl32.so library.
  780. # We need to avoid detection of this library on Unix since it would cause an
  781. # undesirable dependence upon Wine.
  782. #
  783. # Many OpenGL libraries on Unix already contain GLX, so there is no separate
  784. # GLX library, thus we first check for GLX using the discovered OpenGL library
  785. # before attempting to locate a separate GLX-specific library. The same logic
  786. # is also applied to GLU and GLUT checks.
  787. #
  788. # On MacOS/X, some users have XFree86 installed which creates a link from
  789. # /usr/include/GL to /usr/X11R6/include/GL. We want to ignore this directory
  790. # and instead check for Apple's OpenGL.framework, if we are not cross-building
  791. # for Darwin. We accomplish this by placing the OpenGL.framework test ahead of
  792. # the other tests.
  793. #
  794. # At least one user (Jorrit) has a strange installation in which inclusion of
  795. # <windows.h> fails if an int32 is not present, thus we must take this into
  796. # account.
  797. #------------------------------------------------------------------------------
  798. m4_define([cs_define_int32],
  799. [[#if !HAVE_TYPE_INT32
  800. typedef long int32;
  801. #endif
  802. ]])
  803. AC_DEFUN([CS_CHECK_GL_PREPARE],
  804. [AC_REQUIRE([CS_CHECK_HOST])
  805. AC_REQUIRE([CS_CHECK_COMMON_LIBS])
  806. AC_REQUIRE([CS_CHECK_PTHREAD])
  807. AC_REQUIRE([AC_PATH_X])
  808. AC_REQUIRE([AC_PATH_XTRA])
  809. AC_CHECK_TYPE([int32], [AC_DEFINE([HAVE_TYPE_INT32])], [])
  810. AC_CHECK_HEADERS([windows.h], [], [], [cs_define_int32])])
  811. # CS_GL_INCLUDE(CPP-MACRO,FALLBACK,HEADER)
  812. AC_DEFUN([CS_GL_INCLUDE],
  813. [AC_REQUIRE([CS_CHECK_GL_PREPARE])
  814. [#if HAVE_WINDOWS_H
  815. #if !HAVE_TYPE_INT32
  816. typedef long int32;
  817. #endif
  818. #include <windows.h>
  819. #endif
  820. #ifndef CS_HEADER_GLOBAL
  821. #define CS_HEADER_GLOBAL(X,Y) CS_HEADER_GLOBAL_COMPOSE(X,Y)
  822. #define CS_HEADER_GLOBAL_COMPOSE(X,Y) <X/Y>
  823. #endif
  824. #ifdef $1
  825. #include CS_HEADER_GLOBAL($1,$3)
  826. #else
  827. #include <$2/$3>
  828. #endif]])
  829. CS_CHECK_GL_PREPARE
  830. # Apply plaform-specific flags if necessary.
  831. cs_gl_plat_cflags=''
  832. cs_gl_plat_lflags=''
  833. cs_gl_plat_libs=''
  834. AS_IF([test -n "$cs_cv_libm_cflags$cs_cv_libm_lflags$cs_cv_libm_libs"],
  835. [cs_gl_plat_cflags="$cs_cv_libm_cflags $cs_gl_plat_cflags"
  836. cs_gl_plat_lflags="$cs_cv_libm_lflags $cs_gl_plat_lflags"
  837. cs_gl_plat_libs="$cs_cv_libm_libs $cs_gl_plat_libs"])
  838. AS_IF([test $cs_cv_sys_pthread = yes],
  839. [cs_gl_plat_cflags="$cs_cv_sys_pthread_cflags $cs_gl_plat_cflags"
  840. cs_gl_plat_lflags="$cs_cv_sys_pthread_lflags $cs_gl_plat_lflags"
  841. cs_gl_plat_libs="$cs_cv_sys_pthread_libs $cs_gl_plat_libs"])
  842. AS_IF([test "$no_x" != yes],
  843. [cs_gl_plat_cflags="$X_CFLAGS $cs_gl_plat_cflags"
  844. cs_gl_plat_lflags="$cs_gl_plat_lflags"
  845. cs_gl_plat_libs="
  846. $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS $cs_gl_plat_libs"])
  847. # Mesa requested?
  848. AC_ARG_WITH([mesa], [AC_HELP_STRING([--with-mesa],
  849. [use Mesa OpenGL library if available (default YES)])],
  850. [], [with_mesa=yes])
  851. AS_IF([test $with_mesa != no],
  852. [cs_mesa_gl=CS_CREATE_TUPLE([],[],[-lMesaGL])
  853. cs_mesa_glu=CS_CREATE_TUPLE([],[],[-lMesaGLU])
  854. cs_mesa_glx=CS_CREATE_TUPLE([],[],[-lMesaGLX])])
  855. # MacOS/X or Darwin?
  856. AS_IF([test "x$cs_host_macosx" = "xyes"],
  857. [cs_osx_gl=CS_CREATE_TUPLE([-DCS_OPENGL_PATH=OpenGL],[],
  858. [-framework OpenGL])
  859. cs_osx_glu=CS_CREATE_TUPLE([-DCS_GLU_PATH=OpenGL],[],[-framework OpenGL])
  860. cs_osx_glut=CS_CREATE_TUPLE([-DCS_GLUT_PATH=GLUT],[],[-framework GLUT])])
  861. # Windows?
  862. case $host_os in
  863. mingw*|cygwin*)
  864. cs_win32_gl=CS_CREATE_TUPLE([],[],[-lopengl32])
  865. cs_win32_glu=CS_CREATE_TUPLE([],[],[-lglu32])
  866. cs_win32_glut=CS_CREATE_TUPLE([],[],[-lglut32])
  867. ;;
  868. esac
  869. # Check for OpenGL.
  870. CS_CHECK_BUILD([for OpenGL], [cs_cv_libgl],
  871. [AC_LANG_PROGRAM([CS_GL_INCLUDE([CS_OPENGL_PATH],[GL],[gl.h])],[glEnd()])],
  872. [$cs_win32_gl \
  873. $cs_osx_gl \
  874. CS_CREATE_TUPLE([],[],[-lGL]) \
  875. CS_CREATE_TUPLE([],[],[-lgl]) \
  876. $cs_mesa_gl], [],
  877. [CS_EMIT_BUILD_RESULT([cs_cv_libgl], [GL])], [], [],
  878. [$cs_gl_plat_cflags], [$cs_gl_plat_lflags], [$cs_gl_plat_libs])
  879. AS_IF([test $cs_cv_libgl = yes],
  880. [# Check for GLU.
  881. CS_CHECK_BUILD([for GLU], [cs_cv_libglu],
  882. [AC_LANG_PROGRAM(
  883. [CS_GL_INCLUDE([CS_GLU_PATH],[GL],[glu.h])], [gluNewQuadric()])],
  884. [$cs_osx_glu \
  885. CS_CREATE_TUPLE() \
  886. $cs_win32_glu \
  887. CS_CREATE_TUPLE([],[],[-lGLU]) \
  888. CS_CREATE_TUPLE([],[],[-lglu]) \
  889. $cs_mesa_glu], [],
  890. [CS_EMIT_BUILD_RESULT([cs_cv_libglu], [GLU])], [], [],
  891. [$cs_cv_libgl_cflags], [$cs_cv_libgl_lflags], [$cs_cv_libgl_libs])
  892. # Check for GLUT.
  893. CS_CHECK_BUILD([for GLUT], [cs_cv_libglut],
  894. [AC_LANG_PROGRAM(
  895. [CS_GL_INCLUDE([CS_GLUT_PATH],[GL],[glut.h])], [glutSwapBuffers])],
  896. [$cs_osx_glut \
  897. CS_CREATE_TUPLE() \
  898. $cs_win32_glut \
  899. CS_CREATE_TUPLE([],[],[-lGLUT]) \
  900. CS_CREATE_TUPLE([],[],[-lglut])], [],
  901. [CS_EMIT_BUILD_RESULT([cs_cv_libglut], [GLUT])], [], [],
  902. [$cs_cv_libgl_cflags], [$cs_cv_libgl_lflags], [$cs_cv_libgl_libs])
  903. # Check for GLX.
  904. CS_CHECK_BUILD([for GLX], [cs_cv_libglx],
  905. [AC_LANG_PROGRAM([[#include <GL/glx.h>]], [glXWaitGL()])],
  906. [CS_CREATE_TUPLE() \
  907. CS_CREATE_TUPLE([],[],[-lGLX]) \
  908. CS_CREATE_TUPLE([],[],[-lglx]) \
  909. $cs_mesa_glx], [],
  910. [CS_EMIT_BUILD_RESULT([cs_cv_libglx], [GLX])], [], [],
  911. [$cs_cv_libgl_cflags], [$cs_cv_libgl_lflags], [$cs_cv_libgl_libs])
  912. # Check for GLX extensions. Define CSGL_EXT_STATIC_ASSERTION if _not_
  913. # present.
  914. AS_IF([test $cs_cv_libglx = yes],
  915. [CS_CHECK_BUILD([for GLX extensions], [cs_cv_libglx_extensions],
  916. [AC_LANG_PROGRAM(
  917. [[#define GLX_GLXEXT_PROTOTYPES
  918. #include <GL/glx.h>]],
  919. [glXGetProcAddressARB(0)])],
  920. [CS_CREATE_TUPLE(
  921. [$cs_cv_libglx_cflags],
  922. [$cs_cv_libglx_lflags],
  923. [$cs_cv_libglx_libs])],
  924. [], [], [CS_HEADER_PROPERTY([CSGL_EXT_STATIC_ASSERTION])])])])
  925. #------------------------------------------------------------------------------
  926. # Check for DirectDraw. At least one user (Jorrit) has a strange installation
  927. # in which inclusion of <windows.h> fails if an int32 is not present, thus we
  928. # must take this into account. With Cygwin, we must check for the DirectX
  929. # headers in /usr/include/directx.
  930. #------------------------------------------------------------------------------
  931. AC_CHECK_TYPE([int32], [AC_DEFINE([HAVE_TYPE_INT32])], [])
  932. CS_CHECK_BUILD([for DirectX], [cs_cv_libdirectx],
  933. [AC_LANG_PROGRAM(
  934. [[#if !HAVE_TYPE_INT32
  935. typedef long int32;
  936. #endif
  937. #include <windows.h>
  938. #include <ddraw.h>
  939. #include <dsound.h>
  940. #include <dinput.h>]],
  941. [DirectDrawCreate(0,0,0);
  942. DirectSoundCreate(0,0,0);
  943. DirectInputCreate(0,0,0,0)])],
  944. [CS_CREATE_TUPLE([],[],[-lddraw -ldsound -ldinput]) \
  945. CS_CREATE_TUPLE([-I/usr/include/directx],[],[-lddraw -ldsound -ldinput])],
  946. [], [CS_EMIT_BUILD_RESULT([cs_cv_libdirectx], [DIRECTX])])
  947. #------------------------------------------------------------------------------
  948. # Check for the Windows Multimedia library, used by the 'sndwaveout' plugin.
  949. #------------------------------------------------------------------------------
  950. CS_CHECK_BUILD([for waveout], [cs_cv_libwaveout],
  951. [AC_LANG_PROGRAM(
  952. [[#include <windows.h>
  953. #include <mmsystem.h>]],
  954. [waveOutOpen(0, 0, 0, 0, 0, 0)])],
  955. [CS_CREATE_TUPLE([],[],[-lwinmm])],
  956. [], [CS_EMIT_BUILD_RESULT([cs_cv_libwaveout], [WAVEOUT])])
  957. #------------------------------------------------------------------------------
  958. # Check for zlib. In addition to the standard installed locations, we also
  959. # search CS/libs/zlib*.
  960. #------------------------------------------------------------------------------
  961. CS_CHECK_LIB_WITH([z],
  962. [AC_LANG_PROGRAM([[#include <zlib.h>]], [zlibVersion()])],
  963. [$srcdir/libs/zlib*], [], [CS_EMIT_BUILD_RESULT([cs_cv_libz], [ZLIB])],
  964. [CS_MSG_ERROR([zlib is essential for building CS.])], [], [], [], [zlib])
  965. #------------------------------------------------------------------------------
  966. # Check for libpng. In addition to the standard installed locations, we also
  967. # search CS/libs/libpng*. Some platforms, such as RedHat 8.x require libm.a to
  968. # be linked with libpng, so use libm.a if available.
  969. #------------------------------------------------------------------------------
  970. AC_DEFUN([CS_CHECK_LIBPNG_PREPARE],
  971. [AC_REQUIRE([CS_CHECK_COMMON_LIBS])])
  972. AS_IF([test "$cs_cv_libz" = yes],
  973. [CS_CHECK_LIBPNG_PREPARE
  974. CS_CHECK_LIB_WITH([png],
  975. [AC_LANG_PROGRAM([[#include <png.h>]],
  976. [png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0)])],
  977. [$srcdir/libs/libpng*], [],
  978. [CS_EMIT_BUILD_RESULT([cs_cv_libpng], [PNG])], [],
  979. [$cs_cv_libz_cflags $cs_cv_libm_cflags],
  980. [$cs_cv_libz_lflags $cs_cv_libm_lflags],
  981. [$cs_cv_libz_libs $cs_cv_libm_libs], [libpng])])
  982. #------------------------------------------------------------------------------
  983. # Check for libjpeg. In addition to the standard installed locations, we also
  984. # search CS/libs/*jpeg*.
  985. #------------------------------------------------------------------------------
  986. CS_CHECK_LIB_WITH([jpeg],
  987. [AC_LANG_PROGRAM(
  988. [[#include <stddef.h>
  989. #include <stdio.h>
  990. #include <jpeglib.h>]],
  991. [jpeg_create_compress(0)])],
  992. [$srcdir/libs/*jpeg*], [], [CS_EMIT_BUILD_RESULT([cs_cv_libjpeg], [JPEG])],
  993. [], [], [], [], [libjpeg])
  994. #------------------------------------------------------------------------------
  995. # Check for libmng. In addition to the standard installed locations, we also
  996. # search CS/libs/libmng*.
  997. #------------------------------------------------------------------------------
  998. AS_IF([test "$cs_cv_libz" = yes && test "$cs_cv_libjpeg" = yes],
  999. [CS_CHECK_LIB_WITH([mng],
  1000. [AC_LANG_PROGRAM([[#include <libmng.h>]], [mng_version_release()])],
  1001. [$srcdir/libs/libmng*], [],
  1002. [CS_EMIT_BUILD_RESULT([cs_cv_libmng], [MNG])], [],
  1003. [$cs_cv_libjpeg_cflags $cs_cv_libz_cflags],
  1004. [$cs_cv_libjpeg_lflags $cs_cv_libz_lflags],
  1005. [$cs_cv_libjpeg_libs $cs_cv_libz_libs], [libmng])])
  1006. #------------------------------------------------------------------------------
  1007. # Check for libmikmod. In addition to the standard installed locations, we
  1008. # also search CS/libs/libmikmod*.
  1009. #------------------------------------------------------------------------------
  1010. CS_CHECK_LIB_WITH([mikmod],
  1011. [AC_LANG_PROGRAM(
  1012. [[#include <mikmod.h>]],
  1013. [MikMod_Init("mikmodtest"); MikMod_Exit();])],
  1014. [$srcdir/libs/libmikmod*], [],
  1015. [CS_EMIT_BUILD_RESULT([cs_cv_libmikmod], [MIKMOD])], [],
  1016. [$cs_cv_sys_pthread_cflags],
  1017. [$cs_cv_sys_pthread_lflags],
  1018. [$cs_cv_sys_pthread_libs])
  1019. #------------------------------------------------------------------------------
  1020. # Check for libogg/libvorbis/libvorbisfile. In addition to the standard
  1021. # installed locations, we also search CS/libs/libogg*, CS/libs/libvorbis.*,
  1022. # CS/libs/libvorbisfile*.
  1023. #------------------------------------------------------------------------------
  1024. CS_CHECK_LIB_WITH([ogg],
  1025. [AC_LANG_PROGRAM(
  1026. [[#include <ogg/ogg.h>]],
  1027. [ogg_sync_state state; ogg_sync_init(&state);])],
  1028. [$srcdir/libs/libogg*], [],
  1029. [CS_EMIT_BUILD_RESULT([cs_cv_libogg], [OGG])])
  1030. AS_IF([test "$cs_cv_libogg" = yes],
  1031. [CS_CHECK_LIB_WITH([vorbis],
  1032. [AC_LANG_PROGRAM([[#include <vorbis/codec.h>]],
  1033. [vorbis_info info; vorbis_info_init(&info);])],
  1034. [$srcdir/libs/libvorbis.*], [],
  1035. [CS_EMIT_BUILD_RESULT([cs_cv_libvorbis], [VORBIS])], [],
  1036. [$cs_cv_libogg_cflags],
  1037. [$cs_cv_libogg_lflags],
  1038. [$cs_cv_libogg_libs])])
  1039. AS_IF([test "$cs_cv_libvorbis" = yes],
  1040. [CS_CHECK_LIB_WITH([vorbisfile],
  1041. [AC_LANG_PROGRAM(
  1042. [[#include <vorbis/vorbisfile.h>
  1043. #include <stdio.h>]],
  1044. [OggVorbis_File file; ov_test(stdin, &file, "", 0);])],
  1045. [$srcdir/libs/libvorbisfile*], [],
  1046. [CS_EMIT_BUILD_RESULT([cs_cv_libvorbisfile], [VORBISFILE])], [],
  1047. [$cs_cv_libogg_cflags $cs_cv_libvorbis_cflags],
  1048. [$cs_cv_libogg_lflags $cs_cv_libvorbis_lflags],
  1049. [$cs_cv_libogg_libs $cs_cv_libvorbis_libs])])
  1050. #------------------------------------------------------------------------------
  1051. # Check for lib3ds. In addition to the standard installed locations, we also
  1052. # search CS/libs/lib3ds*.
  1053. #------------------------------------------------------------------------------
  1054. AC_DEFUN([CS_CHECK_LIB3DS_PREPARE],
  1055. [AC_REQUIRE([CS_CHECK_COMMON_LIBS])])
  1056. CS_CHECK_LIB3DS_PREPARE
  1057. CS_CHECK_LIB_WITH([3ds],
  1058. [AC_LANG_PROGRAM([[#include <lib3ds/file.h>]],[lib3ds_file_new();])],
  1059. [$srcdir/libs/lib3ds*], [], [], [], [], [], [$cs_cv_libm_libs],
  1060. [lib3ds-120])
  1061. AS_IF([test $cs_cv_lib3ds = yes],
  1062. [CS_CHECK_BUILD([if lib3ds is sufficiently recent], [cs_cv_lib3ds_recent],
  1063. [AC_LANG_PROGRAM([[#include <lib3ds/io.h>]], [lib3ds_io_free(0);])],
  1064. [], [], [CS_EMIT_BUILD_RESULT([cs_cv_lib3ds], [3DS])], [], [],
  1065. [$cs_cv_lib3ds_cflags], [$cs_cv_lib3ds_lflags], [$cs_cv_lib3ds_libs])])
  1066. #------------------------------------------------------------------------------
  1067. # Check for libode. In addition to the standard installed locations, we also
  1068. # search CS/libs/libode*. Also check if it is a sufficiently recent version.
  1069. # Finally, the cs-win32libs package uses a slightly augmented libode in which
  1070. # functions are exported as `extern "C"' to avoid name mangling problems which
  1071. # would otherwise prevent the package from being used with different compilers.
  1072. # Therefore, we need to check if `extern "C"' is needed.
  1073. #------------------------------------------------------------------------------
  1074. CS_CHECK_LIB_WITH([ode],
  1075. [AC_LANG_PROGRAM([[#include <ode/ode.h>]], [dWorldCreate()])],
  1076. [$srcdir/libs/libode*], [C++])
  1077. AS_IF([test $cs_cv_libode = yes],
  1078. [CS_CHECK_BUILD([if libode is sufficiently recent], [cs_cv_libode_recent],
  1079. [AC_LANG_PROGRAM(
  1080. [[#include <ode/ode.h>]],
  1081. [dWorldID w = dWorldCreate();
  1082. dBodySetGravityMode(0,0);
  1083. dWorldStepFast1(w,0,0);
  1084. dCloseODE();])],
  1085. [], [C++], [CS_EMIT_BUILD_RESULT([cs_cv_libode], [ODE])], [], [],
  1086. [$cs_cv_libode_cflags], [$cs_cv_libode_lflags], [$cs_cv_libode_libs])],
  1087. [cs_cv_libode_recent=no])
  1088. AS_IF([test $cs_cv_libode_recent = yes],
  1089. [CS_CHECK_BUILD([if extern "C" is needed with libode],
  1090. [cs_cv_libode_extern_c],
  1091. [AC_LANG_PROGRAM(
  1092. [[#include <ode/ode.h>
  1093. extern "C"
  1094. int dCollideBoxPlane(dxGeom*,dxGeom*,int,dContactGeom*,int);]],
  1095. [dCollideBoxPlane(0,0,0,0,0);])],
  1096. [], [C++], [CS_EMIT_BUILD_PROPERTY([ODE.EXTERN_C], [yes])], [], [],
  1097. [$cs_cv_libode_cflags], [$cs_cv_libode_lflags], [$cs_cv_libode_libs])])
  1098. #------------------------------------------------------------------------------
  1099. # Check for libopenal.
  1100. #------------------------------------------------------------------------------
  1101. # CS_AL_INCLUDE(CPP-MACRO,FALLBACK,HEADER)
  1102. AC_DEFUN([CS_AL_INCLUDE],
  1103. [[#ifndef CS_HEADER_GLOBAL
  1104. #define CS_HEADER_GLOBAL(X,Y) CS_HEADER_GLOBAL_COMPOSE(X,Y)
  1105. #define CS_HEADER_GLOBAL_COMPOSE(X,Y) <X/Y>
  1106. #endif
  1107. #ifdef $1
  1108. #include CS_HEADER_GLOBAL($1,$3)
  1109. #else
  1110. #include <$2/$3>
  1111. #endif]])
  1112. AC_DEFUN([CS_CHECK_LIBOPENAL],
  1113. [AC_REQUIRE([CS_CHECK_COMMON_LIBS])
  1114. CS_CHECK_BUILD([for OpenAL], [cs_cv_libopenal],
  1115. [AC_LANG_PROGRAM(
  1116. [CS_AL_INCLUDE([CS_OPENAL_PATH],[AL],[alut.h])],
  1117. [alutInit(0,0);])],
  1118. [CS_CREATE_TUPLE([-DCS_OPENAL_PATH=OpenAL],[],[-framework OpenAL]) \
  1119. CS_CREATE_TUPLE([],[],[-lopenal]) \
  1120. CS_CREATE_TUPLE([],[],[-lopenal32]) \
  1121. CS_CREATE_TUPLE([],[],[-lalut -lopenal]) \
  1122. CS_CREATE_TUPLE([],[],[-lalut -lopenal32]) \
  1123. CS_CREATE_TUPLE([],[],[-lALut -lOpenAL32]) \
  1124. CS_CREATE_TUPLE([],[],[-lopenal -ldsound]) \
  1125. CS_CREATE_TUPLE([],[],[-lopenal32 -ldsound]) \
  1126. CS_CREATE_TUPLE([],[],[-lalut -lopenal -ldsound]) \
  1127. CS_CREATE_TUPLE([],[],[-lalut -lopenal32 -ldsound])], [],
  1128. [CS_EMIT_BUILD_RESULT([cs_cv_libopenal], [OPENAL])], [], [],
  1129. [$cs_cv_sys_pthread_cflags],
  1130. [$cs_cv_sys_pthread_lflags],
  1131. [$cs_cv_sys_pthread_libs $cs_cv_libdl_libs $cs_cv_libm_libs])])
  1132. CS_CHECK_LIBOPENAL
  1133. #------------------------------------------------------------------------------
  1134. # Check for FreeType2.
  1135. #------------------------------------------------------------------------------
  1136. AC_CHECK_TOOLS([FT2CONFIG], [freetype-config])
  1137. AC_CACHE_CHECK([for FreeType2], [cs_cv_libft2],
  1138. [AS_IF([test -n "$FT2CONFIG"],
  1139. [cs_cv_libft2=yes
  1140. cs_cv_libft2_cflags=`AC_RUN_LOG([$FT2CONFIG --cflags])`
  1141. cs_cv_libft2_lflags=''
  1142. cs_cv_libft2_libs=`AC_RUN_LOG([$FT2CONFIG --libs])`],
  1143. [cs_cv_libft2=no])])
  1144. AS_IF([test $cs_cv_libft2 = yes],
  1145. [CS_CHECK_BUILD([if freetype2 is sufficiently recent], [cs_cv_ft2_recent],
  1146. [AC_LANG_PROGRAM(
  1147. [[#include <ft2build.h>
  1148. #include FT_INTERNAL_OBJECTS_H
  1149. #include FT_FREETYPE_H
  1150. #include FT_GLYPH_H
  1151. #include FT_MODULE_H]], [return
  1152. FT_LOAD_TARGET_MONO|FT_RENDER_MODE_NORMAL|FT_ENCODING_UNICODE])],
  1153. [], [], [CS_EMIT_BUILD_RESULT([cs_cv_libft2], [FT2])], [], [],
  1154. [$cs_cv_libft2_cflags], [$cs_cv_libft2_lflags], [$cs_cv_libft2_libs])])
  1155. #------------------------------------------------------------------------------
  1156. # For Mingw, test if we need to link explicitly with libmingwex.a. Older
  1157. # versions of Mingw did not have this library, whereas newer interim versions
  1158. # supply it but do not link automatically with it. The very newest versions
  1159. # link with libmingwex.a automatically. To see if libmingwex.a is required, we
  1160. # try calling opendir(), which exists in libming32.a for older releases, and in
  1161. # libmingwex.a for newer releases.
  1162. #------------------------------------------------------------------------------
  1163. AC_DEFUN([CS_CHECK_LIBMINGWX],
  1164. [AC_REQUIRE([AC_CANONICAL_HOST])
  1165. case $host_os in
  1166. mingw*)
  1167. AC_CACHE_CHECK([for libmingwex], [cs_cv_libmingwex],
  1168. [CS_BUILD_IFELSE(
  1169. [AC_LANG_PROGRAM([[#include <dirent.h>]], [opendir("");])],
  1170. [CS_CREATE_TUPLE() CS_CREATE_TUPLE([],[],[-lmingwex])], [],
  1171. [AS_IF([test -n "$cs_build_libs"],
  1172. [cs_cv_libmingwex=yes], [cs_cv_libmingwex=no])],
  1173. [cs_cv_libmingwex=no])])
  1174. ;;
  1175. *) cs_cv_libmingwex=no ;;
  1176. esac])
  1177. CS_CHECK_LIBMINGWX
  1178. AS_IF([test $cs_cv_libmingwex = yes],
  1179. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-lmingwex], [+])])
  1180. #------------------------------------------------------------------------------
  1181. # Check for cal3d.
  1182. #------------------------------------------------------------------------------
  1183. CS_CHECK_LIB_WITH([cal3d],
  1184. [AC_LANG_PROGRAM([[#include <cal3d/cal3d.h>]],
  1185. [CalModel m; m.create(0); m.destroy();])], [], [C++])
  1186. AS_IF([test $cs_cv_libcal3d = yes],
  1187. [CS_CHECK_BUILD([if cal3d is sufficiently recent], [cs_cv_cal3d_recent],
  1188. [AC_LANG_PROGRAM(
  1189. [[#include <cal3d/cal3d.h>]],
  1190. [CalModel m; m.getMixer()->removeAction(0);])],
  1191. [], [C++],
  1192. [CS_EMIT_BUILD_RESULT([cs_cv_libcal3d], [CAL3D])], [], [],
  1193. [$cs_cv_libcal3d_cflags],
  1194. [$cs_cv_libcal3d_lflags],
  1195. [$cs_cv_libcal3d_libs])])
  1196. #------------------------------------------------------------------------------
  1197. # Check for SDL.
  1198. #------------------------------------------------------------------------------
  1199. AC_CHECK_TOOLS([SDLCONFIG], [sdl12-config sdl11-config sdl-config])
  1200. AC_CACHE_CHECK([for SDL], [cs_cv_libsdl],
  1201. [AS_IF([test -n "$SDLCONFIG"],
  1202. [cs_cv_libsdl=yes
  1203. cs_cv_libsdl_cflags=`AC_RUN_LOG([$SDLCONFIG --cflags])`
  1204. cs_cv_libsdl_lflags=''
  1205. cs_cv_libsdl_libs=`AC_RUN_LOG([$SDLCONFIG --libs])`],
  1206. [cs_cv_libsdl=no])])
  1207. AS_IF([test $cs_cv_libsdl = yes],
  1208. [CS_CHECK_BUILD([if SDL is sufficiently recent], [cs_cv_sdl_recent],
  1209. [AC_LANG_PROGRAM([[#include <SDL.h>]], [SDL_EnableKeyRepeat(0,0)])],
  1210. [], [], [CS_EMIT_BUILD_RESULT([cs_cv_libsdl], [SDL])], [], [],
  1211. [$cs_cv_libsdl_cflags], [$cs_cv_libsdl_lflags], [$cs_cv_libsdl_libs])])
  1212. #------------------------------------------------------------------------------
  1213. # Check for VOS.
  1214. #------------------------------------------------------------------------------
  1215. AC_ARG_WITH([vos], [AC_HELP_STRING([--with-vos=dir],
  1216. [specify location of VOS pkg-config files])])
  1217. AS_IF([test -z "$with_vos"], [with_vos=yes])
  1218. AS_IF([test "$with_vos" != no && test "$with_vos" != yes],
  1219. [AS_IF([test -n "$PKG_CONFIG_PATH"],
  1220. [PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$with_vos"],
  1221. [PKG_CONFIG_PATH="$with_vos"])
  1222. export PKG_CONFIG_PATH])
  1223. AC_CHECK_TOOLS([PKGCONFIG], [pkg-config])
  1224. m4_define([cs_vos_pkgs], [libmetaobject_a3dl libmetaobject_misc])
  1225. AS_IF([test "$with_vos" != no],
  1226. [AC_CACHE_CHECK([for VOS], [cs_cv_libvos],
  1227. [AS_IF([test -n "$PKGCONFIG"],
  1228. [AS_IF([AC_RUN_LOG([$PKGCONFIG --exists libmetaobject_a3dl])],
  1229. [cs_cv_libvos=yes
  1230. cs_cv_libvos_cflags="`AC_RUN_LOG(
  1231. [$PKGCONFIG --cflags cs_vos_pkgs])`"
  1232. cs_cv_libvos_lflags=''
  1233. cs_cv_libvos_libs=`AC_RUN_LOG(
  1234. [$PKGCONFIG --libs cs_vos_pkgs])`],
  1235. [cs_cv_libvos=no])],
  1236. [cs_cv_libvos=no])])
  1237. AS_IF([test $cs_cv_libvos = yes],
  1238. [CS_EMIT_BUILD_RESULT([cs_cv_libvos], [VOS])])])
  1239. #------------------------------------------------------------------------------
  1240. # Check if Linux joystick API is present.
  1241. #------------------------------------------------------------------------------
  1242. CS_CHECK_BUILD([for Linux joystick API], [cs_cv_sys_linux_joystick],
  1243. [AC_LANG_PROGRAM(
  1244. [[#include <fcntl.h>
  1245. #include <sys/ioctl.h>
  1246. #include <linux/joystick.h>]],
  1247. [unsigned char axes;
  1248. unsigned char buttons;
  1249. int version;
  1250. char name[[[128]]];
  1251. int fd;
  1252. struct js_event js;
  1253. (void)js;
  1254. ioctl(fd, JSIOCGVERSION, &version);
  1255. ioctl(fd, JSIOCGAXES, &axes);
  1256. ioctl(fd, JSIOCGBUTTONS, &buttons);
  1257. ioctl(fd, JSIOCGNAME(128), name);])],
  1258. [], [],
  1259. [CS_EMIT_BUILD_PROPERTY([LINUXJOYSTICK.AVAILABLE], [yes])])
  1260. #------------------------------------------------------------------------------
  1261. # Check for Cg shader package.
  1262. #------------------------------------------------------------------------------
  1263. AC_CHECK_PROGS([CGC], [cgc])
  1264. CS_EMIT_BUILD_PROPERTY([CGC], [$CGC])
  1265. AC_DEFUN([CS_CHECK_LIBCG],
  1266. [AC_REQUIRE([CS_CHECK_COMMON_LIBS])
  1267. AC_REQUIRE([CS_CHECK_PTHREAD])
  1268. CS_CHECK_LIB_WITH([Cg],
  1269. [AC_LANG_PROGRAM(
  1270. [[#include <Cg/cg.h>]],
  1271. [CGcontext c = cgCreateContext()])],
  1272. [], [], [], [],
  1273. [$cs_cv_libm_cflags $cs_cv_sys_pthread_cflags],
  1274. [$cs_cv_libm_lflags $cs_cv_sys_pthread_lflags],
  1275. [$cs_cv_libm_libs $cs_cv_sys_pthread_libs],
  1276. [cg CG])
  1277. AS_IF([test $cs_cv_libCg = yes],
  1278. [CS_CHECK_LIB_WITH([CgGL],
  1279. [AC_LANG_PROGRAM(
  1280. [[#include <Cg/cg.h>
  1281. #include <Cg/cgGL.h>]],
  1282. [CGprogram p; cgGLBindProgram(p)])],
  1283. [], [],
  1284. [CS_EMIT_BUILD_RESULT([cs_cv_libCgGL], [CG])], [],
  1285. [$cs_cv_libCg_cflags $cs_cv_libgl_cflags $cs_cv_libglu_cflags],
  1286. [$cs_cv_libCg_lflags $cs_cv_libgl_lflags $cs_cv_libglu_lflags],
  1287. [$cs_cv_libCg_libs $cs_cv_libgl_libs $cs_cv_libglu_libs],
  1288. [cggl cgGL CGGL])])])
  1289. CS_CHECK_LIBCG
  1290. #------------------------------------------------------------------------------
  1291. # Check for OpenSoundSystem (OSS).
  1292. #------------------------------------------------------------------------------
  1293. AC_CHECK_HEADER([soundcard.h],
  1294. [CS_HEADER_PROPERTY([CS_HAS_SOUNDCARD_H])
  1295. cs_cv_header_soundcard_h=yes],
  1296. [AC_CHECK_HEADER([sys/soundcard.h],
  1297. [CS_HEADER_PROPERTY([CS_HAS_SYS_SOUNDCARD_H])
  1298. cs_cv_header_soundcard_h=yes],
  1299. [AC_CHECK_HEADER([machine/soundcard.h],
  1300. [CS_HEADER_PROPERTY([CS_HAS_MACHINE_SOUNDCARD_H])
  1301. cs_cv_header_soundcard_h=yes],
  1302. [cs_cv_header_soundcard_h=no])])])
  1303. AS_IF([test $cs_cv_header_soundcard_h = yes],
  1304. [CS_EMIT_BUILD_PROPERTY([OSS.AVAILABLE], [yes])])
  1305. #------------------------------------------------------------------------------
  1306. # Check for Advanced Linux Sound Architecture (ALSA)
  1307. #------------------------------------------------------------------------------
  1308. CS_CHECK_LIB_WITH([asound],
  1309. [AC_LANG_PROGRAM(
  1310. [[#include <alsa/asoundlib.h>]],
  1311. [snd_pcm_hw_params_t* p; snd_pcm_hw_params_alloca(&p);])],
  1312. [], [], [CS_EMIT_BUILD_RESULT([cs_cv_libasound], [ALSA])])
  1313. #------------------------------------------------------------------------------
  1314. # Check for DivX4 or OpenDivX.
  1315. #------------------------------------------------------------------------------
  1316. CS_CHECK_BUILD([for DivX4], [cs_cv_libdivxdecore4],
  1317. [AC_LANG_PROGRAM(
  1318. [[#include <divx4/decore.h>]],
  1319. [DEC_MEM_REQS r; decore(0, DEC_OPT_MEMORY_REQS, 0, &r);])],
  1320. [CS_CREATE_TUPLE([],[],[-ldivxdecore])], [],
  1321. [CS_EMIT_BUILD_RESULT([cs_cv_libdivxdecore4], [DIVX4])])
  1322. AS_IF([test $cs_cv_libdivxdecore4 != yes],
  1323. [CS_CHECK_BUILD([for OpenDivX], [cs_cv_libdivxdecore],
  1324. [AC_LANG_PROGRAM(
  1325. [[#include <decore.h>]],
  1326. [decore(0, DEC_OPT_RELEASE, 0, 0);])],
  1327. [CS_CREATE_TUPLE([],[],[-ldivxdecore])])
  1328. AS_IF([test $cs_cv_libdivxdecore = yes],
  1329. [CS_CHECK_BUILD([is OpenDivX is sufficiently recent],
  1330. [cs_cv_libdivxdecore_recent],
  1331. [AC_LANG_PROGRAM(
  1332. [[#include <decore.h>]],
  1333. [DEC_PARAM d; d.color_depth = 0;])],
  1334. [], [],
  1335. [CS_EMIT_BUILD_RESULT([cs_cv_libdivxdecore], [OPENDIVX])], [], [],
  1336. [$cs_cv_libdivxdecore_cflags],
  1337. [$cs_cv_libdivxdecore_lflags],
  1338. [$cs_cv_libdivxdecore_libs])])])
  1339. #------------------------------------------------------------------------------
  1340. # Check if regular expressions are available.
  1341. #------------------------------------------------------------------------------
  1342. CS_CHECK_BUILD([for regexp support], [cs_cv_regexp],
  1343. [AC_LANG_PROGRAM(
  1344. [[#ifdef HAVE_SYS_TYPES_H
  1345. #include <sys/types.h>
  1346. #endif
  1347. #include <regex.h>]],
  1348. [regex_t re; regcomp (&re, 0, 0); regexec (&re, 0, 0, 0, 0);])],
  1349. [], [],
  1350. [CS_HEADER_PROPERTY([CS_HAS_REGEX])