PageRenderTime 61ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/CS/migrated/tags/PRE_MAP2CS_REMOVAL/configure.ac

#
m4 | 1592 lines | 865 code | 267 blank | 460 comment | 0 complexity | 89444d5a9608ac647cf5e4be43766e1d MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. # configure.ac -*- Autoconf -*-
  2. #==============================================================================
  3. # Copyright (C)2003-2006 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.99])
  14. #==============================================================================
  15. # INITIALIZATION
  16. #==============================================================================
  17. AC_INIT([crystalspace], [cs_version_number],
  18. [crystal-main@lists.sourceforge.net])
  19. CS_PACKAGEINFO([Crystal Space],
  20. [Copyright (C)1998-2005 Jorrit Tyberghein and others],
  21. [http://www.crystalspace3d.org/])
  22. AC_CONFIG_SRCDIR([libs/Jamfile])
  23. AC_CONFIG_AUX_DIR([mk/autoconf])
  24. AC_CANONICAL_HOST
  25. #------------------------------------------------------------------------------
  26. # Check for compilers and linker.
  27. #------------------------------------------------------------------------------
  28. CS_PROG_CC
  29. CS_PROG_CXX
  30. CS_PROG_LINK
  31. AC_PROG_CXXCPP
  32. CS_EMIT_BUILD_PROPERTY([CMD.C++CPP], [$CXXCPP])
  33. AS_IF([test $ac_compiler_gnu = yes],
  34. [cs_compiler_name=GCC CS_HEADER_PROPERTY([CS_COMPILER_GCC])],
  35. [cs_compiler_name="AS_TR_CPP([$CXX])"])
  36. CS_EMIT_BUILD_PROPERTY([COMPILER.TYPE], [$cs_compiler_name])
  37. CS_HEADER_PROPERTY([CS_COMPILER_NAME],
  38. [AS_ESCAPE(["])$cs_compiler_name[]AS_ESCAPE(["])])
  39. #------------------------------------------------------------------------------
  40. # Check for common tools.
  41. #------------------------------------------------------------------------------
  42. CS_CHECK_COMMON_TOOLS_LINK
  43. CS_CHECK_COMMON_TOOLS_BASIC
  44. CS_CHECK_COMMON_TOOLS_DOC_TEXINFO
  45. CS_CHECK_COMMON_TOOLS_DOC_DOXYGEN
  46. CS_CHECK_PROGS([FLEX], [flex])
  47. CS_EMIT_BUILD_PROPERTY([CMD.FLEX], [$FLEX])
  48. CS_CHECK_PROGS([BISON], [bison])
  49. AS_IF([test -n "$BISON"],
  50. [CS_CHECK_PROG_VERSION([bison], [$BISON --version], [1.35], [9.9],
  51. [CS_EMIT_BUILD_PROPERTY([CMD.BISON], [$BISON])])])
  52. CS_CHECK_TOOLS([HHC], [hhc])
  53. CS_EMIT_BUILD_PROPERTY([CMD.HHC], [$HHC])
  54. CS_CHECK_PROGS([SWIG], [swig])
  55. AS_IF([test -n "$SWIG"],
  56. [CS_CHECK_PROG_VERSION([swig], [$SWIG -version 2>&1], [1.3.21],
  57. [9.9|.9], [CS_EMIT_BUILD_PROPERTY([CMD.SWIG], [$SWIG])])])
  58. #------------------------------------------------------------------------------
  59. # In order to avoid alienating users by forcing them to install and use Jam,
  60. # config.status is instructed (see far below) to build Jam on the user's behalf
  61. # from local sources, and to place the executable in the root of the build
  62. # directory. When checking for Jam, in addition to PATH, we also look in root
  63. # of the build directory since we might already have built Jam on a previous
  64. # configure run.
  65. #
  66. # IMPLEMENTATION NOTES
  67. #
  68. # The Crystal Space build system supports Jam versions starting with 2.4.
  69. # Earlier versions are rejected. Examples of rejected versions include Apple's
  70. # highly modified Jam (based upon 2.2.1), and ftjam (based upon
  71. # 2.3.2). BoostJam reports its version number as 3.1.9 (or greater), though it
  72. # is actually based upon Jam 2.4. Since we accept 2.4, and since 3.1.9 passes
  73. # the "jam -v >= 2.4" assertion, this version anomaly is not a problem.
  74. #
  75. # We also check for 'make', since it is used to build Jam locally, when needed.
  76. #------------------------------------------------------------------------------
  77. m4_define([cs_jam_local_exe], [jam$EXEEXT])
  78. CS_PATH_PROGS([JAM], [jam], [], [$PATH$PATH_SEPARATOR.])
  79. AS_IF([test -n "$JAM"],
  80. [CS_CHECK_PROG_VERSION([jam], ["$JAM" -v 2>&1], [2.4], [9.9|.9],
  81. [cs_prog_jam_okay=yes], [cs_prog_jam_okay=no])],
  82. [cs_prog_jam_okay=no])
  83. AS_IF([test $cs_prog_jam_okay != yes],
  84. [JAM=./cs_jam_local_exe CS_NEED_LOCAL_JAM=yes])
  85. CS_EMIT_BUILD_PROPERTY([JAM], [$JAM])
  86. CS_CHECK_PROGS([MAKE], [gnumake gmake make])
  87. #------------------------------------------------------------------------------
  88. # The cs-win32libs package is a convenience archive made available to Windows
  89. # users of Crystal Space. It contains common libraries, headers, and tools
  90. # (such as zlib, libjpeg, cal3d, etc.) usable by MSVC, Mingw/MSYS, and Cygwin
  91. # users. It saves users the bother of having to install these packages
  92. # manually one at a time.
  93. #------------------------------------------------------------------------------
  94. CS_CHECK_CSWIN32LIBS
  95. #------------------------------------------------------------------------------
  96. # Use the CPPFLAGS, CXXFLAGS, CFLAGS, and LDFLAGS passed to configure, as well
  97. # as any additional flags provided by cs-win32libs.
  98. #------------------------------------------------------------------------------
  99. CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS], [$CPPFLAGS $CFLAGS], [+])
  100. CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS], [$CPPFLAGS $CXXFLAGS], [+])
  101. CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [$LDFLAGS], [+])
  102. #------------------------------------------------------------------------------
  103. # Check for typical required libraries (libm, libmx, libdl, libnsl).
  104. #------------------------------------------------------------------------------
  105. AC_LANG_PUSH([C++])
  106. AC_CHECK_HEADERS([cmath], [CS_HEADER_PROPERTY([CS_HAVE_CMATH_H])])
  107. AC_CHECK_HEADERS([math.h], [CS_HEADER_PROPERTY([CS_HAVE_MATH_H])])
  108. AC_LANG_POP([C++])
  109. CS_CHECK_COMMON_LIBS
  110. AS_IF([test $ac_cv_lib_m_pow = yes || test $ac_cv_lib_m_cosf = yes],
  111. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-lm], [+])])
  112. AS_IF([test $ac_cv_lib_mx_cosf = yes],
  113. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-lmx], [+])])
  114. AS_IF([test $ac_cv_lib_dl_dlopen = yes],
  115. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-ldl], [+])])
  116. AS_IF([test $ac_cv_lib_nsl_gethostbyname = yes],
  117. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-lnsl], [+])])
  118. AS_IF([test $ac_cv_lib_m_cosf != no || test $ac_cv_lib_mx_cosf != no],
  119. [CS_HEADER_PROPERTY([CS_HAVE_MATH_H_FLOAT_FUNCS])])
  120. #------------------------------------------------------------------------------
  121. # Check for pthread. Also check if pthread implementation supports the
  122. # recursive mutex extension.
  123. #------------------------------------------------------------------------------
  124. CS_CHECK_PTHREAD([cygwin*])
  125. CS_EMIT_BUILD_RESULT([cs_cv_sys_pthread], [PTHREAD])
  126. AS_IF([test $cs_cv_sys_pthread_mutex_recursive != no],
  127. [CS_HEADER_PROPERTY([CS_PTHREAD_MUTEX_RECURSIVE],
  128. [$cs_cv_sys_pthread_mutex_recursive])])
  129. #------------------------------------------------------------------------------
  130. # Check if RTLD_NOW dlopen() flag is available; some installations (OpenBSD,
  131. # for example) provide only RTLD_LAZY.
  132. #------------------------------------------------------------------------------
  133. AC_DEFUN([CS_CHECK_RTLD],
  134. [AC_REQUIRE([CS_CHECK_COMMON_LIBS])
  135. CS_CHECK_BUILD([for RTLD_NOW], [cs_cv_sys_rtld_now],
  136. [AC_LANG_PROGRAM([[#include <dlfcn.h>]], [dlopen(0, RTLD_NOW)])],
  137. [], [], [CS_HEADER_PROPERTY([CS_HAVE_RTLD_NOW])], [], [],
  138. [], [], [$cs_cv_libdl_libs])])
  139. CS_CHECK_RTLD
  140. #------------------------------------------------------------------------------
  141. # Determine host platform. Recognized families: Unix, Windows, MacOS/X.
  142. #
  143. # CS_CHECK_HOST
  144. # Sets the shell variables cs_host_target and cs_host_family. Client
  145. # code can use these variables to emit appropriate Jam variables and
  146. # CS_PLATFORM_FOO header define.
  147. #------------------------------------------------------------------------------
  148. CS_CHECK_HOST
  149. AS_IF([test "x$cs_host_macosx" = "xyes"],
  150. [# We assume that we always have CoreAudio available on MacOS/X.
  151. CS_EMIT_BUILD_PROPERTY([COREAUDIO.AVAILABLE], [yes])
  152. CS_EMIT_BUILD_PROPERTY([COREAUDIO.LFLAGS], [-framework CoreAudio -framework AudioToolbox])
  153. CS_HEADER_PROPERTY([CS_PLATFORM_MACOSX])],
  154. [case $cs_host_family in
  155. windows)
  156. CS_HEADER_PROPERTY([CS_PLATFORM_WIN32])
  157. ;;
  158. unix)
  159. CS_HEADER_PROPERTY([CS_PLATFORM_UNIX])
  160. esac])
  161. CS_HEADER_PROPERTY([CS_PLATFORM_NAME],
  162. [AS_ESCAPE(["])$cs_host_os_normalized[]AS_ESCAPE(["])])
  163. #------------------------------------------------------------------------------
  164. # Check if Perl SDK is installed and which compiler and linker flags are
  165. # required to embed Perl. Also determine if the glue file can be created with
  166. # ExtUtils::Embed or if it must be created manually.
  167. #------------------------------------------------------------------------------
  168. CS_CHECK_PROGS([PERL], [perl5 perl])
  169. CS_EMIT_BUILD_PROPERTY([PERL5], [$PERL])
  170. CS_EMIT_BUILD_PROPERTY([PERL], [$PERL])
  171. CS_EMIT_BUILD_PROPERTY([CMD.PERL5], [$PERL])
  172. # csperl5 fails to build on many platforms, so default is NO for now.
  173. AC_ARG_WITH([perl], [AC_HELP_STRING([--with-perl],
  174. [use Perl5 scripting interface (default NO)])])
  175. AS_IF([test -z "$with_perl"], [with_perl=no])
  176. AS_IF([test -n "$PERL" && test "$with_perl" != no],
  177. [AC_CACHE_CHECK([for perl ExtUtils::Embed module], [cs_cv_perl_mod_embed],
  178. [AS_IF([AC_RUN_LOG([$PERL -MExtUtils::Embed -e 0 1>&2])],
  179. [cs_cv_perl_mod_embed=yes], [cs_cv_perl_mod_embed=no])])
  180. AS_IF([test $cs_cv_perl_mod_embed = yes],
  181. [CS_EMIT_BUILD_PROPERTY([PERL5.EXTUTILS.EMBED.AVAILABLE], [yes])
  182. AC_CACHE_CHECK([for perl DynaLoader module],
  183. [cs_cv_perl_mod_dynaloader],
  184. [AS_IF([AC_RUN_LOG([$PERL -MDynaLoader -e 0 1>&2])],
  185. [cs_cv_perl_mod_dynaloader=yes],
  186. [cs_cv_perl_mod_dynaloader=no])])
  187. AS_IF([test $cs_cv_perl_mod_dynaloader = yes],
  188. [CS_EMIT_BUILD_PROPERTY([PERL5.DYNALOADER.AVAILABLE], [yes])])],
  189. [# ExtUtils::Embed absent.
  190. AC_MSG_NOTICE([Recommend you install a recent release of Perl 5.])
  191. AC_MSG_NOTICE([http://www.perl.org/])
  192. AC_CACHE_CHECK([for perl Config module], [cs_cv_perl_mod_config],
  193. [AS_IF([AC_RUN_LOG([$PERL -MConfig -e 0 1>&2])],
  194. [cs_cv_perl_mod_config=yes], [cs_cv_perl_mod_config=no])])])
  195. AS_VAR_SET_IF([cs_cv_perl_cflags], [],
  196. [AS_IF([test $cs_cv_perl_mod_embed = yes],
  197. [cs_cv_perl_cflags=`AC_RUN_LOG(
  198. [$PERL -MExtUtils::Embed -e ccopts])`
  199. cs_cv_perl_lflags=`AC_RUN_LOG(
  200. [$PERL -MExtUtils::Embed -e ldopts])`
  201. cs_cv_perl_ext=`AC_RUN_LOG([$PERL -MConfig -e \
  202. '$e = $Config{"dlext"} || $Config{"so"} || ""; print "$e"'])`],
  203. [AS_IF([test $cs_cv_perl_mod_config = yes],
  204. [cs_perl_core=`AC_RUN_LOG(
  205. [$PERL -MConfig -e 'print $Config{archlib}'])`
  206. cs_perl_core="${cs_perl_core}/CORE"
  207. cs_cv_perl_cflags=`AC_RUN_LOG(
  208. [$PERL -MConfig -e 'print $Config{ccflags}'])`
  209. cs_cv_perl_cflags="${cs_cv_perl_cflags} -I${cs_perl_core}"
  210. cs_cv_perl_lflags=`AC_RUN_LOG([$PERL -MConfig -e \
  211. 'print $Config{ldflags}, " ", $Config{libs}'])`
  212. cs_cv_perl_lflags="${cs_cv_perl_lflags} -L${cs_perl_core}"
  213. cs_cv_perl_ext=`AC_RUN_LOG([$PERL -MConfig -e \
  214. '$e = $Config{"dlext"}||$Config{"so"}||""; print "$e"'])`],
  215. [cs_perl_core=`AC_RUN_LOG([$PERL -V:archlib | \
  216. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`
  217. cs_perl_core="${cs_perl_core}/CORE"
  218. cs_cv_perl_cflags=`AC_RUN_LOG([$PERL -V:ccflags | \
  219. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`
  220. cs_cv_perl_cflags="${cs_cv_perl_cflags} -I${cs_perl_core}"
  221. cs_cv_perl_lflags=`AC_RUN_LOG([$PERL -V:ldflags | \
  222. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`
  223. cs_perl_lflags_tmp=`AC_RUN_LOG([$PERL -V:libs | \
  224. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`
  225. cs_cv_perl_lflags="${cs_cv_perl_lflags} ${cs_perl_lflags_tmp}
  226. -L${cs_perl_core}"
  227. cs_cv_perl_ext=`AC_RUN_LOG([$PERL -V:dlext | \
  228. $PERL -e '<STDIN> =~ m/\x27(.*)\x27/; print $1'])`])])
  229. cs_cv_perl_cflags=CS_PATH_NORMALIZE([$cs_cv_perl_cflags])
  230. cs_cv_perl_lflags=CS_PATH_NORMALIZE([$cs_cv_perl_lflags])])
  231. AS_IF([test -n "$cs_cv_perl_cflags$cs_cv_perl_lflags"],
  232. [CS_CHECK_BUILD([if Perl SDK is usable], [cs_cv_perl],
  233. [AC_LANG_PROGRAM(
  234. [[#include <EXTERN.h>
  235. #include <perl.h>]],
  236. [perl_run(0);])],
  237. [CS_CREATE_TUPLE([$cs_cv_perl_cflags],[],[$cs_cv_perl_lflags])])
  238. AS_IF([test $cs_cv_perl = yes],
  239. [CS_EMIT_BUILD_RESULT([cs_cv_perl], [PERL5])
  240. CS_EMIT_BUILD_PROPERTY([PERL5.MODULE_EXT],[.$cs_cv_perl_ext])])])])
  241. #------------------------------------------------------------------------------
  242. # Check if Python SDK is installed and which compiler and linker flags are
  243. # required to embed Python.
  244. #------------------------------------------------------------------------------
  245. CS_CHECK_PYTHON([emit], [], [Python scripting interface])
  246. #------------------------------------------------------------------------------
  247. # Check if Java2 SDK is installed and which compiler and linker flags are
  248. # needed. Also check if Ant build tool, which is commonly used to build Java
  249. # projects, is available.
  250. #------------------------------------------------------------------------------
  251. AC_DEFUN([CS_JAVA_FLAGS],
  252. [AC_REQUIRE([AC_CANONICAL_HOST])
  253. AC_REQUIRE([CS_CHECK_HOST])
  254. AS_IF([test x$cs_host_macosx = xyes && # Not cross-building for Darwin.
  255. test -r /System/Library/Frameworks/JavaVM.framework/Headers],
  256. [$1_cflags="-I/System/Library/Frameworks/JavaVM.framework/Headers"
  257. $1_libs="-framework JavaVM"],
  258. [AS_IF([test -n "$JAVA_HOME"],
  259. [$1_dir="$JAVA_HOME"],
  260. [AS_IF([test -n "$2"],
  261. [$1_dir=`AS_DIRNAME([$2])`
  262. $1_dir=`AS_DIRNAME([$$1_dir])`],
  263. [$1_dir=''])])
  264. AS_IF([test -n "$$1_dir"],
  265. [$1_cflags="-I$$1_dir/include"
  266. case $host_os in
  267. mingw*|cygwin*) cs_java_platform=win32 ;;
  268. *) cs_java_platform=`echo $host_os |
  269. sed 's/^\([[^-]]*\).*$/\1/'` ;;
  270. esac
  271. AS_IF([test -n "$cs_java_platform"],
  272. [$1_cflags="$$1_cflags
  273. $$1_cflags/$cs_java_platform"])
  274. $1_cflags=CS_PATH_NORMALIZE([$$1_cflags])])])])
  275. JAVA_HOME=CS_PATH_NORMALIZE([$JAVA_HOME])
  276. AS_IF([test -z "$JAVA" && test -n "$JAVACMD"],
  277. [JAVA=CS_PATH_NORMALIZE([$JAVACMD])])
  278. CS_PATH_PROGS([JAVA], [java], [],
  279. [$JAVA_HOME/bin$PATH_SEPARATOR$JAVA_HOME/jre/bin$PATH_SEPARATOR$PATH])
  280. CS_EMIT_BUILD_PROPERTY([JAVA], [$JAVA])
  281. CS_PATH_PROGS([JAVAC], [javac], [],
  282. [$JAVA_HOME/bin$PATH_SEPARATOR$JAVA_HOME/jre/bin$PATH_SEPARATOR$PATH])
  283. CS_EMIT_BUILD_PROPERTY([JAVAC], [$JAVAC])
  284. AC_ARG_WITH([java], [AC_HELP_STRING([--with-java],
  285. [use Java scripting interface (default YES)])])
  286. AS_IF([test -z "$with_java"], [with_java=yes])
  287. AS_IF([test "$with_java" != no && test -n "$JAVAC" && test -n "$JAVA"],
  288. [CS_JAVA_FLAGS([cs_java], [$JAVAC])
  289. CS_CHECK_BUILD([if Java2 SDK is usable], [cs_cv_java],
  290. [AC_LANG_PROGRAM(
  291. [[#include <jni.h>
  292. JNIEXPORT void JNICALL f(JNIEnv *env, jobject obj);]])],
  293. [CS_CREATE_TUPLE() \
  294. CS_CREATE_TUPLE([$cs_java_cflags],[$cs_java_lflags],[$cs_java_libs])],
  295. [], [CS_EMIT_BUILD_RESULT([cs_cv_java], [JAVA])])])
  296. CS_PATH_PROGS([ANT], [ant], [], [$PATH$PATH_SEPARATOR$ANT_HOME/bin])
  297. CS_EMIT_BUILD_PROPERTY([ANT], [$ANT])
  298. #------------------------------------------------------------------------------
  299. # Check if STL is available. Although STL is not used heavily in Crystal Space,
  300. # a few plugin modules take advantage of it, so they need to know if it is
  301. # available.
  302. #------------------------------------------------------------------------------
  303. CS_CHECK_BUILD([for STL], [cs_cv_libstl],
  304. [AC_LANG_PROGRAM(
  305. [[#include <map>
  306. #include <string>]],
  307. [[std::map<std::string,int> m; m.begin();]])],
  308. [], [C++], [CS_EMIT_BUILD_RESULT([cs_cv_libstl], [STL])])
  309. #------------------------------------------------------------------------------
  310. # Check how to enable and disable compilation warnings, and how to promote
  311. # diagnostics from warning to error status.
  312. #------------------------------------------------------------------------------
  313. CS_COMPILER_WARNINGS([C++], [cs_cv_prog_cxx_enable_warnings],
  314. [CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS],
  315. [$cs_cv_prog_cxx_enable_warnings], [+])])
  316. CS_COMPILER_ERRORS([C++], [cs_cv_prog_cxx_enable_errors])
  317. CS_COMPILER_IGNORE_UNUSED([C++], [cs_cv_prog_cxx_ignore_unused],
  318. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS.WARNING.NO_UNUSED],
  319. [$cs_cv_prog_cxx_ignore_unused])])
  320. CS_COMPILER_IGNORE_UNINITIALIZED([C++], [cs_cv_prog_cxx_ignore_uninitialized],
  321. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS.WARNING.NO_UNINITIALIZED],
  322. [$cs_cv_prog_cxx_ignore_uninitialized])])
  323. CS_COMPILER_IGNORE_PRAGMAS([C++], [cs_cv_prog_cxx_ignore_unknown_pragmas],
  324. [CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS],
  325. [$cs_cv_prog_cxx_ignore_unknown_pragmas], [+])])
  326. # On MacOS/X, use of `long double' in csutil/formatter.h causes complaints.
  327. CS_COMPILER_IGNORE_LONG_DOUBLE([C++], [cs_cv_prog_cxx_ignore_long_double],
  328. [CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS.MANDATORY],
  329. [$cs_cv_prog_cxx_ignore_long_double], [+])])
  330. #------------------------------------------------------------------------------
  331. # Check for option to disable strict-aliasing (enabled by gcc on higher
  332. # optimization levels). This is needed for some code we don't have
  333. # control over (e.g. SWIG-generated code) that breaks strict-aliasing rules.
  334. #------------------------------------------------------------------------------
  335. CS_CHECK_BUILD_FLAGS([for flag to disable string-aliasing],
  336. [cs_cv_prog_cxx_no_strict_aliasing],
  337. [CS_CREATE_TUPLE([-fno-strict-aliasing])], [C++])
  338. AS_IF([test $cs_cv_prog_cxx_no_strict_aliasing != no],
  339. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS.STRICTALIASING.DISABLE],
  340. [$cs_cv_prog_cxx_no_strict_aliasing], [+])])
  341. #------------------------------------------------------------------------------
  342. # Check if C++ exceptions can be enabled and disabled.
  343. #------------------------------------------------------------------------------
  344. CS_EMIT_BUILD_FLAGS([how to enable C++ exceptions],
  345. [cs_cv_prog_cxx_enable_exceptions],
  346. [CS_CREATE_TUPLE([-fexceptions -fno-omit-frame-pointer]) \
  347. CS_CREATE_TUPLE([-fexceptions])],
  348. [C++], [COMPILER.C++FLAGS.EXCEPTIONS.ENABLE])
  349. CS_EMIT_BUILD_FLAGS([how to disable C++ exceptions],
  350. [cs_cv_prog_cxx_disable_exceptions], [CS_CREATE_TUPLE([-fno-exceptions])],
  351. [C++], [COMPILER.C++FLAGS.EXCEPTIONS.DISABLE], [],
  352. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS],
  353. [$cs_cv_prog_cxx_disable_exceptions], [+])])
  354. #------------------------------------------------------------------------------
  355. # Check how to make compiler comply strongly with the official C++ language
  356. # specification. Crystal Space itself can not abide 100% by the standard (for
  357. # instance, we employ `long long', which is not part of the present
  358. # specification), however, some external projects do so (by using gcc's -ansi
  359. # and -pedantic options, for instance). Because such projects may utilize
  360. # Crystal Space, we must ensure that our public headers likewise comply with
  361. # the official specification.
  362. #------------------------------------------------------------------------------
  363. CS_EMIT_BUILD_FLAGS([how to enforce C++ standards conformance],
  364. [cs_cv_prog_cxx_enable_pedantic], [CS_CREATE_TUPLE([-ansi -pedantic])],
  365. [C++], [COMPILER.C++FLAGS.PEDANTIC.ENABLE])
  366. #------------------------------------------------------------------------------
  367. # Check if the linker recognizes "-multiply_defined suppress". This is
  368. # required for MacOS/X 10.1 to avoid warning messages when linking a program
  369. # with "-framework Foundation" if that program does not actually employ any
  370. # Objective-C. Note that we first attempt the uglier equivalent
  371. # "-Wl,-multiply_defined,suppress" in order to make life simpler for external
  372. # projects using cs-config (which reports this linker option in response to
  373. # --libs) in conjunction with GNU libtool. The problem with "-multiply_defined
  374. # suppress" for GNU libtool users is that libtool re-orders linker arguments,
  375. # not realizing that "suppress" must follow immediately after
  376. # "-multiply_defined". The uglier equivalent does not suffer from this problem
  377. # in the hands of libtool since it contains no whitespace.
  378. #------------------------------------------------------------------------------
  379. CS_EMIT_BUILD_FLAGS([if -multiply_defined suppress is needed],
  380. [cs_cv_prog_link_suppress_multiple],
  381. [CS_CREATE_TUPLE([], [-Wl,-multiply_defined,suppress]) \
  382. CS_CREATE_TUPLE([], [-multiply_defined suppress])],
  383. [], [COMPILER.LFLAGS], [+])
  384. #------------------------------------------------------------------------------
  385. # Check if the linker recognizes "-force_cpusubtype_ALL". This is required on
  386. # MacOS/X since the Crystal Space's PowerPC implementation of csQsqrt() uses
  387. # the `frsqrte' instruction which is only valid when the -force_cpusubtype_ALL
  388. # flag is present. This flag is marked "mandatory" because it is required even
  389. # for external projects if they use csQsqrt().
  390. #------------------------------------------------------------------------------
  391. AC_DEFUN([CS_CHECK_FORCE_CPUSUBTYPE_ALL],
  392. [CS_CHECK_BUILD_FLAGS([if -force_cpusubtype_ALL is needed],
  393. [cs_cv_prog_cxx_force_cpusubtype_all],
  394. [CS_CREATE_TUPLE([], [-force_cpusubtype_ALL])])])
  395. CS_CHECK_FORCE_CPUSUBTYPE_ALL
  396. CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS.MANDATORY],
  397. [$cs_cv_prog_cxx_force_cpusubtype_all], [+])
  398. #------------------------------------------------------------------------------
  399. # Check if the MacOS/X compiler recognizes "-fno-common". This flag is needed
  400. # when building plugin modules (and the libraries which are linked into
  401. # plugins) prior to Apple's introduction of the two-level namespace symbol
  402. # scheme in order to ensure that each plugin module gets its own copy of
  403. # uninitialized global variables.
  404. #------------------------------------------------------------------------------
  405. AC_DEFUN([CS_CHECK_NO_COMMON],
  406. [AC_REQUIRE([AC_CANONICAL_HOST])
  407. case $host_os in
  408. darwin*)
  409. CS_EMIT_BUILD_FLAGS([if -fno-common is needed],
  410. [cs_cv_prog_cxx_no_common],
  411. [CS_CREATE_TUPLE([], [-fno-common])], [C++],
  412. [COMPILER.CFLAGS.MANDATORY], [+])
  413. ;;
  414. esac])
  415. CS_CHECK_NO_COMMON
  416. #------------------------------------------------------------------------------
  417. # Check if Mingw and Cygwin compilers recognize -fvtable-thunks. As of gcc
  418. # 3.x, this option is no longer supported. Unfortunately, rather than
  419. # returning an error code (as it does with other unrecognized options), the
  420. # compiler merely prints a warning message when -fvtable-thunks is used, thus
  421. # we use -Werror to turn the warning into an error.
  422. #------------------------------------------------------------------------------
  423. AC_DEFUN([CS_CHECK_VTABLE_THUNKS],
  424. [AC_REQUIRE([AC_CANONICAL_HOST])
  425. case $host_os in
  426. mingw*|cygwin*)
  427. CS_CHECK_BUILD_FLAGS([if -fvtable-thunks is needed],
  428. [cs_cv_prog_cxx_vtable_thunks],
  429. [CS_CREATE_TUPLE([-fvtable-thunks])], [C++],
  430. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS.MANDATORY],
  431. [$cs_cv_prog_cxx_vtable_thunks], [+])],
  432. [], [$cs_cv_prog_cxx_enable_errors])
  433. ;;
  434. esac])
  435. CS_CHECK_VTABLE_THUNKS
  436. #------------------------------------------------------------------------------
  437. # Check how to ask the linker to export all dynamic symbols in debug mode to
  438. # allow the backtrace() callstack creation code to obtain symbols in all cases.
  439. #------------------------------------------------------------------------------
  440. CS_EMIT_BUILD_FLAGS([how to export all dynamic symbols],
  441. [cs_cv_prog_link_export_dynamic], [CS_CREATE_TUPLE([-Wl,-E])],
  442. [C++], [COMPILER.LFLAGS.debug], [+])
  443. #------------------------------------------------------------------------------
  444. # Check if linker recognizes --kill-at which is needed to make csjava.dll
  445. # usable by JNI on Windows. Without this, JNI is unable to find the exported
  446. # JNI glue functions in csjava.dll.
  447. #------------------------------------------------------------------------------
  448. CS_CHECK_BUILD([if --kill-at is accepted], [cs_cv_prog_link_kill_at], [],
  449. [CS_CREATE_TUPLE([],[-Wl,--kill-at])], [C++],
  450. [CS_EMIT_BUILD_PROPERTY([CSJAVA.LFLAGS], [-Wl,--kill-at])])
  451. #------------------------------------------------------------------------------
  452. # Check if C++ function inlining can be enabled and disabled. Apparently, with
  453. # some versions of GNU build tools on Windows, the Crystal Space Python plugin
  454. # fails to link and emits the error message "Error: 0-bit reloc in dll". In
  455. # particular, this occurs with optimizations (such as -O3) enabled. We can
  456. # avoid the error by disabling function inlining.
  457. #------------------------------------------------------------------------------
  458. CS_EMIT_BUILD_FLAGS([how to disable function inlining],
  459. [cs_cv_prog_cxx_disable_inlining],
  460. [CS_CREATE_TUPLE([-fno-inline-functions])],
  461. [C++], [COMPILER.C++FLAGS.INLINING.DISABLE])
  462. #------------------------------------------------------------------------------
  463. # Check if "hidden" visibilty for inline functions is supported.
  464. #
  465. # IMPLEMENTATION NOTES
  466. #
  467. # There is an obscure bug in gcc 3.4.x and 4.0.x where
  468. # -fvisibility-inlines-hidden on AMD64 in combination with -fPIC and -shared
  469. # flags causes the linker to fail with a bogus error stating that the target
  470. # library needs to be built with -fPIC even when it has been built using that
  471. # option. On such installations, if Crystal Space is built with
  472. # -fvisibility-inlines-hidden, then clients liking against Crystal Space
  473. # experience this bogus error. Normally, we would test for this anomaly by
  474. # manipulating a std::basic_string<> in a test program, and avoid
  475. # -fvisibility-inlines-hidden if the test program fails to link, however,
  476. # practical experience has shown that this test is not 100% reliable for all
  477. # such installations. Instead, for simplicity, we disable this flag presently
  478. # for all versions of gcc on AMD64. References:
  479. #
  480. # http://dev.gentoo.org/~kugelfang/pappy-visibility.txt
  481. # http://www.gnu.org/software/gcc/gcc-4.0/changes.html#visibility
  482. # http://www.nedprod.com/programs/gccvisibility.html
  483. # http://bugs.gentoo.org/show_bug.cgi?id=78720
  484. #
  485. # Furthermore, there seems to be a bug on MacOS/X with gcc 4.0.x where use of
  486. # -fvisibility-inlines-hidden causes link problems with external clients which
  487. # do not specify this flag. For this reason, we also disable this flag on
  488. # MacOS/X. In particular, clients receive errors of this sort:
  489. #
  490. # /usr/bin/ld: libcrystalspace.a(scf.o) malformed object, illegal
  491. # reference for -dynamic code (reference to a coalesced section
  492. # (__TEXT,__textcoal_nt) from section (__TEXT,__text) relocation
  493. # entry (1))
  494. #------------------------------------------------------------------------------
  495. CS_CHECK_BUILD_FLAGS([for inline visibility flag],
  496. [cs_cv_prog_cxx_visibility_inlines_hidden],
  497. [CS_CREATE_TUPLE([-fvisibility-inlines-hidden])],[C++])
  498. AS_IF([test -n "$cs_cv_prog_cxx_visibility_inlines_hidden"],
  499. [AC_CACHE_CHECK([if $cs_cv_prog_cxx_visibility_inlines_hidden is buggy],
  500. [cs_cv_prog_cxx_visibility_inlines_hidden_buggy],
  501. [AS_IF([test $ac_compiler_gnu = yes],
  502. [AS_IF([test $host_cpu = x86_64 || test x$cs_host_macosx = xyes],
  503. [cs_cv_prog_cxx_visibility_inlines_hidden_buggy=yes],
  504. [cs_cv_prog_cxx_visibility_inlines_hidden_buggy=no])],
  505. [cs_cv_prog_cxx_visibility_inlines_hidden_buggy=no])])],
  506. [cs_cv_prog_cxx_visibility_inlines_hidden_buggy=no])
  507. AS_IF([test $cs_cv_prog_cxx_visibility_inlines_hidden_buggy != yes],
  508. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS],
  509. [$cs_cv_prog_cxx_visibility_inlines_hidden], [+])])
  510. #------------------------------------------------------------------------------
  511. # Check how to set default symbol visibility, and how to override the setting
  512. # in code.
  513. #------------------------------------------------------------------------------
  514. CS_CHECK_BUILD_FLAGS([for symbol visibility flag],
  515. [cs_cv_prog_cxx_visibility_hidden],
  516. [CS_CREATE_TUPLE([-fvisibility=hidden])], [C++])
  517. CS_SYMBOL_QUALIFIER([how to declare default visibility],
  518. [cs_cv_prog_cxx_declare_visible_def],
  519. [__attribute__((visibility("default")))], [], [C++])
  520. AS_IF([test $cs_cv_prog_cxx_declare_visible_def != no && \
  521. test -n "$cs_cv_prog_cxx_visibility_hidden"],
  522. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS],
  523. [$cs_cv_prog_cxx_visibility_hidden], [+])
  524. CS_HEADER_PROPERTY([CS_VISIBILITY_DEFAULT],
  525. [$cs_cv_prog_cxx_declare_visible_def])])
  526. #------------------------------------------------------------------------------
  527. # Check for compiler- and CPU-specific code generation flags. These flags are
  528. # mutually exclusive. Exclusivity is enforced by the CS_CHECK_CODE_GEN_FLAG()
  529. # macro. Note that use of these flags typically means that the resulting
  530. # binary will not be backward compatible. For instance, if Pentium-specific
  531. # instructions are used, the program will not work with earlier processors,
  532. # such as the Intel 486. Because these options are potentially dangerous,
  533. # their use it controlled by the user via --enable-cpu-specific-optimizations
  534. # which accepts "no" (same as "disable"), "minimum" (the default), and
  535. # "maximum". The "minimum" option selects optimizations which are likely to be
  536. # supported by reasonably modern hardware, thus making the resulting
  537. # executables fairly portable.
  538. #
  539. # CS_CHECK_CODE_GEN_FLAG(CPU-PATTERN, FLAGS, [LANGUAGE])
  540. # If compiler- and CPU-specific optimization flags have not already been
  541. # determined, and if the canonical host CPU matches CPU-PATTERN, try
  542. # using the provided compiler FLAGS with the compiler represented by
  543. # LANGUAGE (typically either "C" or "C++"). If language is omitted, C++
  544. # is used. If the compiler accepts the flags, assign them to the shell
  545. # variable cs_cv_prog_cxx_code_gen.
  546. #------------------------------------------------------------------------------
  547. AC_DEFUN([CS_CHECK_CODE_GEN_FLAG],
  548. [AC_REQUIRE([AC_CANONICAL_HOST])
  549. AS_IF([test "$cs_cv_prog_cxx_code_gen" = no],
  550. [case $host_cpu in
  551. $1) CS_BUILD_IFELSE([],
  552. [CS_CREATE_TUPLE([$2])], m4_default([$3],[C++]),
  553. [cs_cv_prog_cxx_code_gen=$cs_build_cflags], [])
  554. ;;
  555. esac])])
  556. AC_MSG_CHECKING([whether to use CPU-specific optimizations])
  557. AC_ARG_ENABLE([cpu-specific-optimizations],
  558. [AC_HELP_STRING([--enable-cpu-specific-optimizations=level],
  559. [enable CPU-specific optimizations; recognized levels are `no',
  560. `minimum' or `min', `maximum' or `max' (default MINIMUM); the `minimum'
  561. option selects optimizations which are likely to be supported by
  562. reasonably modern hardware, thus making the resulting executables
  563. fairly portable; use the `maximum' option with caution since code for
  564. one processor will not work with earlier processors (for example, Intel
  565. 686-specific code will not work with a 586)])],
  566. [case $enable_cpu_specific_optimizations in
  567. yes|min) enable_cpu_specific_optimizations=minimum ;;
  568. max) enable_cpu_specific_optimizations=maximum ;;
  569. esac],
  570. [enable_cpu_specific_optimizations=minimum])
  571. AC_MSG_RESULT([$enable_cpu_specific_optimizations])
  572. case $enable_cpu_specific_optimizations in
  573. no|minimum|maximum) ;;
  574. *) CS_MSG_ERROR([unrecognized option; use `no', `minimum', or `maximum'])
  575. ;;
  576. esac
  577. AS_IF([test $enable_cpu_specific_optimizations != no],
  578. [AC_CACHE_CHECK([for code generation flags], [cs_cv_prog_cxx_code_gen],
  579. [cs_cv_prog_cxx_code_gen=no
  580. AS_IF([test $enable_cpu_specific_optimizations = maximum],
  581. [CS_CHECK_CODE_GEN_FLAG([athlon], [-march=athlon])
  582. CS_CHECK_CODE_GEN_FLAG([athlon], [-mcpu=athlon -march=athlon])
  583. CS_CHECK_CODE_GEN_FLAG([athlon], [-mcpu=athlon])
  584. CS_CHECK_CODE_GEN_FLAG([*686], [-march=i686])
  585. CS_CHECK_CODE_GEN_FLAG([*686], [-mcpu=pentiumpro -march=i686])
  586. CS_CHECK_CODE_GEN_FLAG([*686], [-mcpu=pentiumpro])
  587. CS_CHECK_CODE_GEN_FLAG([*686], [-mpentiumpro -march=i686])
  588. CS_CHECK_CODE_GEN_FLAG([*686], [-mpentiumpro])])
  589. AS_IF([test $host_vendor = apple],
  590. [# Work around issue on intel macs, where "-fpmath=sse" is on by
  591. # default, but this breaks compilation when combined with
  592. # the "-march=i586" selected below. So the "minimum" optimization
  593. # on x86 Apples is -march=i686.
  594. CS_CHECK_CODE_GEN_FLAG([[*[3-9]86]], [-march=i686])])
  595. CS_CHECK_CODE_GEN_FLAG([x86_64], [-march=k8])
  596. CS_CHECK_CODE_GEN_FLAG([x86_64], [-mtune=k8])
  597. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-march=i586])
  598. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-mcpu=pentium -march=i586])
  599. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-mcpu=pentium])
  600. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-mpentium -march=i586])
  601. CS_CHECK_CODE_GEN_FLAG([[*[5-6]86]], [-mpentium])
  602. CS_CHECK_CODE_GEN_FLAG([[*[3-9]86]], [-march=i486])
  603. CS_CHECK_CODE_GEN_FLAG([[*[3-9]86]], [-mcpu=i486 -march=i486])
  604. CS_CHECK_CODE_GEN_FLAG([[*[3-9]86]], [-mcpu=i486])
  605. CS_CHECK_CODE_GEN_FLAG([[*[3-9]86]], [-m486])
  606. CS_CHECK_CODE_GEN_FLAG([alpha], [-mieee])])
  607. AS_IF([test "$cs_cv_prog_cxx_code_gen" != no],
  608. [CS_EMIT_BUILD_PROPERTY(
  609. [COMPILER.CFLAGS], [$cs_cv_prog_cxx_code_gen], [+])])])
  610. #------------------------------------------------------------------------------
  611. # Check if byteswap.h is available, which contains optimized byte swapping
  612. # functiosn (used for endian conversion).
  613. #------------------------------------------------------------------------------
  614. AC_CHECK_HEADERS([byteswap.h],
  615. [CS_HEADER_PROPERTY([CS_HAVE_BYTESWAP_H])])
  616. #------------------------------------------------------------------------------
  617. # Check for compiler optimization flags.
  618. #------------------------------------------------------------------------------
  619. AC_DEFUN([CS_CHECK_OPTIMIZE_FLAGS],
  620. [AC_REQUIRE([AC_PROG_CC])
  621. AC_REQUIRE([AC_PROG_CXX])
  622. cs_optimize_flags=''
  623. CS_EMIT_BUILD_FLAGS([how to enable optimizations],
  624. [cs_cv_prog_cxx_optimize],
  625. [CS_CREATE_TUPLE([-O3]) CS_CREATE_TUPLE([-O2]) CS_CREATE_TUPLE([-O])],
  626. [C++], [COMPILER.CFLAGS.optimize], [+],
  627. [cs_optimize_flags="$cs_optimize_flags $cs_cv_prog_cxx_optimize"])
  628. CS_EMIT_BUILD_FLAGS([if -fomit-frame-pointer is accepted],
  629. [cs_cv_prog_cxx_omit_frame_pointer],
  630. [CS_CREATE_TUPLE([-fomit-frame-pointer])],
  631. [C++], [COMPILER.CFLAGS.optimize], [+],
  632. [cs_optimize_flags="$cs_optimize_flags \
  633. $cs_cv_prog_cxx_omit_frame_pointer"])
  634. CS_EMIT_BUILD_FLAGS([if -ffast-math is accepted],
  635. [cs_cv_prog_cxx_fast_math],
  636. [CS_CREATE_TUPLE([-ffast-math])], [C++],
  637. [COMPILER.CFLAGS.optimize], [+],
  638. [cs_optimize_flags="$cs_optimize_flags $cs_cv_prog_cxx_fast_math"])])
  639. CS_CHECK_OPTIMIZE_FLAGS
  640. #------------------------------------------------------------------------------
  641. # Check for compiler debug flags.
  642. #------------------------------------------------------------------------------
  643. CS_EMIT_BUILD_FLAGS([how to enable compiler debug output],
  644. [cs_cv_prog_cxx_debug],
  645. [CS_CREATE_TUPLE([-g3]) CS_CREATE_TUPLE([-g2]) CS_CREATE_TUPLE([-g])],
  646. [C++], [COMPILER.CFLAGS.debug], [+],
  647. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS.debug],
  648. [$cs_cv_prog_cxx_debug], [+])])
  649. #------------------------------------------------------------------------------
  650. # Check if compiler complains about adding /usr/local/include to the header
  651. # search path. If not, add it to the header search path since not all
  652. # compilers search there by default. Some compiler, on the other hand,
  653. # complain if it is already in the built-in search path, and we would like to
  654. # avoid the complaint, if possible.
  655. #
  656. # Furthermore, add a -L entry to LDFLAGS for /usr/local/lib if present.
  657. # Finally, add /usr/local/lib to LD_LIBRARY_PATH if present since not all
  658. # platforms do so by default. This will allow some tests to succeed which would
  659. # otherwise fail. An example is the sizeof(wchar_t) check on Solaris, which
  660. # attempts to run a test program. Without augmenting LD_LIBRARY_PATH, the test
  661. # program would fail to run, citing inability to locate libstdc++.so.
  662. #------------------------------------------------------------------------------
  663. AS_IF([test -d /usr/local/include],
  664. [CS_CHECK_BUILD_FLAGS([if -I/usr/local/include is usable],
  665. [cs_cv_prog_cpp_local_include],
  666. [CS_CREATE_TUPLE([-I/usr/local/include])], [C++], [], [],
  667. [$cs_cv_prog_cxx_enable_warnings $cs_cv_prog_cxx_enable_errors])],
  668. [cs_cv_prog_cpp_local_include=''])
  669. AS_IF([test -n "$cs_cv_prog_cpp_local_include"],
  670. [CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS],
  671. [$cs_cv_prog_cpp_local_include], [+])
  672. CPPFLAGS="$CPPFLAGS $cs_cv_prog_cpp_local_include"])
  673. AS_IF([test -d /usr/local/lib],
  674. [CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [-L/usr/local/lib], [+])
  675. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  676. LD_LIBRARY_PATH="$LD_LIBRARY_PATH$PATH_SEPARATOR/usr/local/lib"
  677. export LD_LIBRARY_PATH])
  678. #------------------------------------------------------------------------------
  679. # Check if va_copy() or __va_copy() is available.
  680. #------------------------------------------------------------------------------
  681. # CS_CHECK_VA_COPY(FUNCTION)
  682. AC_DEFUN([CS_CHECK_VA_COPY],
  683. [CS_CHECK_BUILD([for $1], [cs_cv_func_$1],
  684. [AC_LANG_PROGRAM(
  685. [[#include <stdio.h>
  686. #include <stdarg.h>]],
  687. [va_list ap1; va_list ap2; $1(ap1,ap2)])],
  688. [], [], [CS_HEADER_PROPERTY(AS_TR_CPP([CS_HAVE_$1]))], [], [],
  689. [$cs_cv_prog_cxx_enable_pedantic])])
  690. CS_CHECK_VA_COPY([va_copy])
  691. CS_CHECK_VA_COPY([__va_copy])
  692. #------------------------------------------------------------------------------
  693. # Check for X-Windows. If the X-Windows implementation is XFree86, then also
  694. # enable the `VideoMode' extension.
  695. #------------------------------------------------------------------------------
  696. AC_DEFUN([CS_X_CHECK_PREPARE],
  697. [AC_REQUIRE([AC_CANONICAL_HOST])
  698. AC_REQUIRE([CS_CHECK_HOST])
  699. # Explicitly disable X checking on Windows to avoid discovering XFree86 in
  700. # case Cygwin is installed. Doing so allows us to avoid Mesa's OpenGL
  701. # headers during the OpenGL check, and prefer Microsoft's OpenGL headers.
  702. # The Mesa OpenGL headers cause link errors because they do not employ
  703. # __stdcall.
  704. case $host_os in
  705. mingw*|cygwin*) with_x=no ;;
  706. esac
  707. # Explicitly disable X checking on MacOS/X in case the optional XFree86 is
  708. # installed since we want to avoid an undesirable dependency upon XFree86
  709. # in the CS executables and plugins. If the user is actually
  710. # cross-building for Darwin on MacOS/X, then the --with-x option will
  711. # override this test (by setting cs_host_macosx to "no").
  712. AS_IF([test x$cs_host_macosx = xyes], [with_x=no])])
  713. CS_X_CHECK_PREPARE
  714. AC_PATH_X
  715. AC_PATH_XTRA
  716. AS_IF([test "$no_x" != yes],
  717. [# We must be especially careful to instruct CS_EMIT_BUILD_PROPERTY() to
  718. # emit the following properties even if their values are empty. This is
  719. # necessary because of the way that Jam performs "product-wise" variable
  720. # expansion. For example, if X is "x" and Y is undefined, Jam will expand
  721. # "$(X) $(Y)" to "", whereas every other tool in the world will expand it
  722. # to "x ". Since the emitted X11.CFLAGS, X11.LFLAGS, XFREE86VM.CFLAGS, and
  723. # XFREE86VM.LFLAGS properties reference the other variables by name, we
  724. # must ensure that those other variables are defined (even if only with an
  725. # empty string).
  726. CS_EMIT_BUILD_PROPERTY([X11.AVAILABLE], [yes])
  727. CS_EMIT_BUILD_PROPERTY([X_CFLAGS], [$X_CFLAGS], [], [Y])
  728. CS_EMIT_BUILD_PROPERTY([X_LIBS], [$X_LIBS], [], [Y])
  729. CS_EMIT_BUILD_PROPERTY([X_PRE_LIBS], [$X_PRE_LIBS], [], [Y])
  730. CS_EMIT_BUILD_PROPERTY([X_EXTRA_LIBS], [$X_EXTRA_LIBS], [], [Y])
  731. CS_EMIT_BUILD_PROPERTY([X11.CFLAGS], [AS_ESCAPE([$(X_CFLAGS)])])
  732. CS_EMIT_BUILD_PROPERTY([X11.LFLAGS],
  733. [AS_ESCAPE([$(X_PRE_LIBS) $(X_LIBS) -lXext -lX11 $(X_EXTRA_LIBS)])])
  734. CS_CHECK_LIB_WITH([Xxf86vm],
  735. [AC_LANG_PROGRAM(
  736. [[#define XK_MISCELLANY 1
  737. #include <X11/Xlib.h>
  738. #include <X11/Xutil.h>
  739. #include <X11/Xatom.h>
  740. #include <X11/extensions/xf86vmode.h>]],
  741. [XF86VidModeLockModeSwitch(0, 0, 0)])], [], [],
  742. [CS_EMIT_BUILD_PROPERTY([XFREE86VM.AVAILABLE], [yes])
  743. CS_EMIT_BUILD_PROPERTY([XFREE86VM.CFLAGS], [AS_ESCAPE([$(X_CFLAGS)])])
  744. CS_EMIT_BUILD_PROPERTY([XFREE86VM.LFLAGS],
  745. [AS_ESCAPE([$(X_PRE_LIBS) $(X_LIBS) -lXxf86vm -lXext -lX11
  746. $(X_EXTRA_LIBS)])])], [],
  747. [$X_CFLAGS], [], [$X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS])
  748. CS_CHECK_LIB_WITH([Xaw],
  749. [AC_LANG_PROGRAM(
  750. [[#include <X11/Shell.h>
  751. #include <X11/Xaw/Form.h>]],
  752. [XtVaGetValues(0,0,0,0)])],
  753. [], [], [CS_EMIT_BUILD_RESULT([cs_cv_libXaw], [XAW])], [],
  754. [$X_CFLAGS], [], [$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS])])
  755. #------------------------------------------------------------------------------
  756. # Check for OpenGL and companions. Also check if GLX extensions are supported
  757. # and define the (backward) header property CSGL_EXT_STATIC_ASSERTION if they
  758. # are _not_ supported. Finally, check if the type GLhandleARB is exported by
  759. # the GL headers. It is starting to show up in very modern headers, but is
  760. # absent from most.
  761. #
  762. # IMPLEMENTATION NOTES
  763. #
  764. # GLU is not required or used by CrystalSpace itself, but certain 3rd party
  765. # libraries may depend on it (notably Cg).
  766. #------------------------------------------------------------------------------
  767. CS_CHECK_OPENGL
  768. AS_IF([test $cs_cv_libgl = yes],
  769. [# Check for GLhandleARB.
  770. CS_CHECK_BUILD([for GLhandleARB], [cs_cv_libgl_glhandlearb],
  771. [AC_LANG_PROGRAM(
  772. [CS_GL_INCLUDE([CS_OPENGL_PATH],[GL],[gl.h])],
  773. [GLhandleARB x; (void)x;])],
  774. [], [], [CS_HEADER_PROPERTY([CS_HAVE_GLHANDLEARB_T])], [], [],
  775. [$cs_cv_libgl_cflags], [$cs_cv_libgl_lflags], [$cs_cv_libgl_libs])])
  776. CS_CHECK_GLX
  777. # Check for GLX extensions. Define CSGL_EXT_STATIC_ASSERTION if _not_
  778. # present.
  779. CS_CHECK_GLXEXT([], [CS_HEADER_PROPERTY([CSGL_EXT_STATIC_ASSERTION])])
  780. #------------------------------------------------------------------------------
  781. # Check for DirectDraw. At least one user (Jorrit) has a strange installation
  782. # in which inclusion of <windows.h> fails if an int32 is not present, thus we
  783. # must take this into account. With Cygwin, we must check for the DirectX
  784. # headers in /usr/include/directx.
  785. #------------------------------------------------------------------------------
  786. # CS_CHECK_DIRECTX([DSOUND-VERSION])
  787. AC_DEFUN([CS_CHECK_DIRECTX],
  788. [CS_CHECK_BUILD([for DirectX$1], [cs_cv_libdirectx$1],
  789. [AC_LANG_PROGRAM(
  790. [[#if !HAVE_TYPE_INT32
  791. typedef long int32;
  792. #endif
  793. #define DIRECTINPUT_VERSION 0x0500
  794. #include <windows.h>
  795. #include <ddraw.h>
  796. #include <dsound.h>
  797. #include <dinput.h>]],
  798. [DirectDrawCreate(0,0,0);
  799. DirectSoundCreate$1(0,0,0);
  800. DirectInputCreate(0,0,0,0)])],
  801. [CS_CREATE_TUPLE([],[],[-lddraw -ldsound -ldinput]) \
  802. CS_CREATE_TUPLE([-I/usr/include/directx],[],
  803. [-lddraw -ldsound -ldinput])],
  804. [C++], [CS_EMIT_BUILD_RESULT([cs_cv_libdirectx$1], [DIRECTX$1])])])
  805. AS_IF([test $cs_host_family = windows],
  806. [AC_CHECK_TYPE([int32], [AC_DEFINE([HAVE_TYPE_INT32])], [])
  807. CS_CHECK_DIRECTX([])
  808. CS_CHECK_DIRECTX([8])])
  809. #------------------------------------------------------------------------------
  810. # Check for the Windows Multimedia library, used by the 'sndwaveout' plugin.
  811. #------------------------------------------------------------------------------
  812. AS_IF([test $cs_host_family = windows],
  813. [CS_CHECK_BUILD([for waveout], [cs_cv_libwaveout],
  814. [AC_LANG_PROGRAM(
  815. [[#include <windows.h>
  816. #include <mmsystem.h>]],
  817. [waveOutOpen(0, 0, 0, 0, 0, 0)])],
  818. [CS_CREATE_TUPLE([],[],[-lwinmm])],
  819. [], [CS_EMIT_BUILD_RESULT([cs_cv_libwaveout], [WAVEOUT])])])
  820. #------------------------------------------------------------------------------
  821. # Check for zlib. In addition to the standard installed locations, we also
  822. # search CS/libs/zlib*.
  823. #------------------------------------------------------------------------------
  824. CS_CHECK_LIB_WITH([z],
  825. [AC_LANG_PROGRAM([[#include <zlib.h>]], [zlibVersion()])],
  826. [$srcdir/libs/zlib*], [], [CS_EMIT_BUILD_RESULT([cs_cv_libz], [ZLIB])],
  827. [AC_MSG_NOTICE([*** zlib not found; VFS will be unusable])],
  828. [], [], [], [zlib])
  829. #------------------------------------------------------------------------------
  830. # Check for libpng. In addition to the standard installed locations, we also
  831. # search CS/libs/libpng*. Some platforms, such as RedHat 8.x require libm.a to
  832. # be linked with libpng, so use libm.a if available.
  833. #------------------------------------------------------------------------------
  834. AC_DEFUN([CS_CHECK_LIBPNG_PREPARE],
  835. [AC_REQUIRE([CS_CHECK_COMMON_LIBS])])
  836. AS_IF([test "$cs_cv_libz" = yes],
  837. [CS_CHECK_LIBPNG_PREPARE
  838. CS_CHECK_LIB_WITH([png],
  839. [AC_LANG_PROGRAM([[#include <png.h>]],
  840. [png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0)])],
  841. [$srcdir/libs/libpng*], [],
  842. [CS_EMIT_BUILD_RESULT([cs_cv_libpng], [PNG])], [],
  843. [$cs_cv_libz_cflags $cs_cv_libm_cflags],
  844. [$cs_cv_libz_lflags $cs_cv_libm_lflags],
  845. [$cs_cv_libz_libs $cs_cv_libm_libs], [libpng])])
  846. #------------------------------------------------------------------------------
  847. # Check for libjpeg. In addition to the standard installed locations, we also
  848. # search CS/libs/*jpeg*.
  849. #------------------------------------------------------------------------------
  850. CS_CHECK_LIB_WITH([jpeg],
  851. [AC_LANG_PROGRAM(
  852. [[#include <stddef.h>
  853. #include <stdio.h>
  854. #include <jpeglib.h>]],
  855. [jpeg_create_compress(0)])],
  856. [$srcdir/libs/*jpeg*], [], [CS_EMIT_BUILD_RESULT([cs_cv_libjpeg], [JPEG])],
  857. [], [], [], [], [libjpeg])
  858. #------------------------------------------------------------------------------
  859. # Check for libmng. In addition to the standard installed locations, we also
  860. # search CS/libs/libmng*. Note that libmng on some OpenBSD installations has a
  861. # dependency on lcms (http://www.littlecms.com/), so we must check for this
  862. # library, and utilize it explicitly if present.
  863. #------------------------------------------------------------------------------
  864. CS_CHECK_LIB_WITH([lcms],
  865. [AC_LANG_PROGRAM([[#include <lcms.h>]],
  866. [LPLUT p = cmsAllocLUT(); cmsFreeLUT(p);])],
  867. [/usr/include/lcms| /usr/local/include/lcms|])
  868. CS_CHECK_LIB_WITH([mng],
  869. [AC_LANG_PROGRAM([[#include <libmng.h>]], [mng_version_release()])],
  870. [$srcdir/libs/libmng*], [],
  871. [CS_EMIT_BUILD_RESULT([cs_cv_libmng], [MNG])], [],
  872. [$cs_cv_liblcms_cflags $cs_cv_libjpeg_cflags $cs_cv_libz_cflags],
  873. [$cs_cv_liblcms_lflags $cs_cv_libjpeg_lflags $cs_cv_libz_lflags],
  874. [$cs_cv_liblcms_libs $cs_cv_libjpeg_libs $cs_cv_libz_libs],
  875. [libmng])
  876. #------------------------------------------------------------------------------
  877. # Check for MikMod. In addition to the standard installed locations, we also
  878. # search CS/libs/libmikmod*.
  879. #------------------------------------------------------------------------------
  880. CS_CHECK_LIB_WITH([mikmod],
  881. [AC_LANG_PROGRAM(
  882. [[#include <mikmod.h>]],
  883. [MikMod_Init("mikmodtest"); MikMod_Exit();])],
  884. [$srcdir/libs/libmikmod*], [],
  885. [CS_EMIT_BUILD_RESULT([cs_cv_libmikmod], [MIKMOD])], [],
  886. [$cs_cv_sys_pthread_cflags],
  887. [$cs_cv_sys_pthread_lflags],
  888. [$cs_cv_sys_pthread_libs])
  889. #------------------------------------------------------------------------------
  890. # Check for Ogg/Vorbis. In addition to the standard installed locations, we
  891. # also search CS/libs/libogg*, CS/libs/libvorbis.*, CS/libs/libvorbisfile*.
  892. #------------------------------------------------------------------------------
  893. CS_CHECK_LIB_WITH([ogg],
  894. [AC_LANG_PROGRAM(
  895. [[#include <ogg/ogg.h>]],
  896. [ogg_sync_state state; ogg_sync_init(&state);])],
  897. [$srcdir/libs/libogg*], [],
  898. [CS_EMIT_BUILD_RESULT([cs_cv_libogg], [OGG])])
  899. AS_IF([test "$cs_cv_libogg" = yes],
  900. [CS_CHECK_LIB_WITH([vorbis],
  901. [AC_LANG_PROGRAM([[#include <vorbis/codec.h>]],
  902. [vorbis_info info; vorbis_info_init(&info);])],
  903. [$srcdir/libs/libvorbis.*], [],
  904. [CS_EMIT_BUILD_RESULT([cs_cv_libvorbis], [VORBIS])], [],
  905. [$cs_cv_libogg_cflags],
  906. [$cs_cv_libogg_lflags],
  907. [$cs_cv_libogg_libs])])
  908. AS_IF([test "$cs_cv_libvorbis" = yes],
  909. [CS_CHECK_LIB_WITH([vorbisfile],
  910. [AC_LANG_PROGRAM(
  911. [[#include <vorbis/vorbisfile.h>
  912. #include <stdio.h>]],
  913. [OggVorbis_File file; ov_test(stdin, &file, "", 0);])],
  914. [$srcdir/libs/libvorbisfile*], [],
  915. [CS_EMIT_BUILD_RESULT([cs_cv_libvorbisfile], [VORBISFILE])], [],
  916. [$cs_cv_libogg_cflags $cs_cv_libvorbis_cflags],
  917. [$cs_cv_libogg_lflags $cs_cv_libvorbis_lflags],
  918. [$cs_cv_libogg_libs $cs_cv_libvorbis_libs])])
  919. #------------------------------------------------------------------------------
  920. # Check for lib3ds. In addition to the standard installed locations, we also
  921. # search CS/libs/lib3ds*.
  922. #------------------------------------------------------------------------------
  923. AC_DEFUN([CS_CHECK_LIB3DS_PREPARE],
  924. [AC_REQUIRE([CS_CHECK_COMMON_LIBS])])
  925. CS_CHECK_LIB3DS_PREPARE
  926. CS_CHECK_LIB_WITH([3ds],
  927. [AC_LANG_PROGRAM([[#include <lib3ds/file.h>]],[lib3ds_file_new();])],
  928. [$srcdir/libs/lib3ds*], [], [], [], [], [], [$cs_cv_libm_libs],
  929. [lib3ds, lib3ds-120])
  930. AS_IF([test $cs_cv_lib3ds = yes],
  931. [CS_CHECK_BUILD([if lib3ds is sufficiently recent], [cs_cv_lib3ds_recent],
  932. [AC_LANG_PROGRAM([[#include <lib3ds/io.h>]], [lib3ds_io_free(0);])],
  933. [], [], [CS_EMIT_BUILD_RESULT([cs_cv_lib3ds], [3DS])], [], [],
  934. [$cs_cv_lib3ds_cflags], [$cs_cv_lib3ds_lflags], [$cs_cv_lib3ds_libs])])
  935. #------------------------------------------------------------------------------
  936. # Check for ODE. In addition to the standard installed locations, we also
  937. # search CS/libs/libode*. Also check if it is a sufficiently recent version.
  938. #------------------------------------------------------------------------------
  939. CS_CHECK_LIB_WITH([ode],
  940. [AC_LANG_PROGRAM([[#include <ode/ode.h>]], [dWorldCreate()])],
  941. [$srcdir/libs/libode*], [C++])
  942. AS_IF([test $cs_cv_libode = yes],
  943. [CS_CHECK_BUILD([if libode is built with OPCODE support],
  944. [cs_cv_libode_opcode],
  945. [AC_LANG_PROGRAM(
  946. [[#include <ode/ode.h>]],
  947. [dGeomTriMeshDataCreate();])],
  948. [], [C++], [], [], [],
  949. [$cs_cv_libode_cflags], [$cs_cv_libode_lflags], [$cs_cv_libode_libs])],
  950. [cs_cv_libode_opcode=no])
  951. AS_IF([test $cs_cv_libode_opcode = yes],
  952. [CS_CHECK_BUILD([if libode is sufficiently recent], [cs_cv_libode_recent],
  953. [AC_LANG_PROGRAM(
  954. [[#include <ode/ode.h>]],
  955. [dGeomTriMeshGetTriangleCount(0);])],

Large files files are truncated, but you can click here to view the full file