You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

270 lines
7.8 KiB

  1. dnl
  2. dnl Lol Engine
  3. dnl
  4. dnl Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net>
  5. dnl
  6. dnl Lol Engine is free software. It comes without any warranty, to
  7. dnl the extent permitted by applicable law. You can redistribute it
  8. dnl and/or modify it under the terms of the Do What the Fuck You Want
  9. dnl to Public License, Version 2, as published by the WTFPL Task Force.
  10. dnl See http://www.wtfpl.net/ for more details.
  11. dnl
  12. AC_INIT(lolengine, 0.0)
  13. AC_PREREQ(2.50)
  14. AC_CONFIG_AUX_DIR(.auto)
  15. AC_CANONICAL_SYSTEM
  16. AM_INIT_AUTOMAKE([subdir-objects no-define tar-ustar silent-rules])
  17. dnl AM_MAINTAINER_MODE
  18. AM_DEFAULT_VERBOSITY=0
  19. dnl Versioning of the separate software we ship
  20. LOLUNIT_VERSION=0.1
  21. AC_SUBST(LOLUNIT_VERSION)
  22. AC_SUBST(lol_srcdir, '${top_srcdir}')
  23. AC_SUBST(lol_builddir, '${top_builddir}')
  24. AM_PROG_CC_C_O
  25. AC_PROG_CPP
  26. AC_PROG_CXX
  27. AC_PROG_CXXCPP
  28. AC_PROG_RANLIB
  29. LOL_AC_INIT()
  30. AC_LIBTOOL_WIN32_DLL
  31. AM_PROG_LIBTOOL
  32. AC_LIBTOOL_CXX
  33. dnl Ensure an error is thrown if pkg-config M4 files are not found.
  34. m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
  35. m4_pattern_forbid([^PKG_CHECK_MODULES$])
  36. m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
  37. dnl Same for Lol Engine M4 files.
  38. m4_pattern_forbid([^LOL_AC_])
  39. dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
  40. if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
  41. export PKG_CONFIG_LIBDIR=/dev/null
  42. fi
  43. dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
  44. dnl now otherwise it might be set in an obscure if statement. Same thing for
  45. dnl PKG_PROG_PKG_CONFIG which needs to be called first.
  46. AC_EGREP_CPP(yes, foo)
  47. PKG_PROG_PKG_CONFIG()
  48. dnl Check for a working implementation of sed
  49. AC_PROG_SED
  50. AC_MSG_CHECKING(for a sed that understands \t)
  51. if test "$(echo 'x\x' | "${SED}" 's/.*@<:@^x\t@:>@//')" != x; then
  52. AC_MSG_RESULT(no)
  53. AC_MSG_ERROR([[consider installing GNU sed]])
  54. else
  55. AC_MSG_RESULT(yes)
  56. fi
  57. dnl conditional builds
  58. AC_ARG_ENABLE(debug,
  59. [ --enable-debug build debug versions of the game (default no)])
  60. AC_ARG_ENABLE(release,
  61. [ --enable-release build final release of the game (default no)])
  62. AC_ARG_ENABLE(experimental,
  63. [ --enable-experimental experimental build (default no)])
  64. AC_ARG_ENABLE(subproject,
  65. [ --enable-subproject build as a subproject (default no)])
  66. AC_ARG_ENABLE(test,
  67. [ --enable-test build test suite (default yes)])
  68. AC_ARG_ENABLE(tools,
  69. [ --enable-tools build miscellaneous tools (default yes)])
  70. AC_ARG_ENABLE(tutorial,
  71. [ --enable-tutorial build tutorial applications (default yes)])
  72. AC_ARG_ENABLE(samples,
  73. [ --enable-samples build sample applications (default yes)])
  74. AC_ARG_ENABLE(doc,
  75. [ --enable-doc build documentation (needs doxygen and LaTeX)])
  76. dnl Subproject builds
  77. if test "${enable_subproject}" = "yes"; then
  78. AC_MSG_CHECKING(for a config-lol.h file in the parent project)
  79. if test -f "../config-lol.h"; then
  80. AC_MSG_RESULT(yes)
  81. AC_DEFINE(HAVE_CONFIG_LOL_H, 1, Define to if parent project provides config-lol.h)
  82. AH_BOTTOM([
  83. #if HAVE_CONFIG_LOL_H
  84. #include "../config-lol.h"
  85. #endif
  86. ])
  87. else
  88. AC_MSG_RESULT(no)
  89. fi
  90. fi
  91. dnl Common C headers
  92. AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h stdint.h math.h)
  93. AC_CHECK_HEADERS(fastmath.h unistd.h io.h)
  94. AC_CHECK_HEADERS(execinfo.h)
  95. AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
  96. AC_CHECK_HEADERS(sys/wait.h sys/time.h sys/types.h)
  97. dnl Common C++ headers
  98. AC_LANG_PUSH(C++)
  99. AC_CHECK_HEADERS(cxxabi.h)
  100. AC_LANG_POP(C++)
  101. dnl Common C functions
  102. AC_CHECK_FUNCS(getenv system tmpfile tmpnam getcwd _getcwd)
  103. AC_CHECK_FUNCS(backtrace_symbols)
  104. AC_CHECK_FUNCS(gettimeofday usleep)
  105. dnl Build mode
  106. ac_cv_my_build_mode="devel"
  107. if test "x${enable_release}" = "xyes"; then
  108. ac_cv_my_build_mode="release"
  109. fi
  110. if test "x${enable_devel}" = "xyes"; then
  111. ac_cv_my_build_mode="devel"
  112. fi
  113. if test "x${enable_debug}" = "xyes"; then
  114. ac_cv_my_build_mode="debug"
  115. fi
  116. if test "x${ac_cv_my_build_mode}" = "xdebug"; then
  117. AC_DEFINE(LOL_BUILD_DEBUG, 1, Define to 1 to activate debug build)
  118. LOL_TRY_CXXFLAGS(-O, [AM_CXXFLAGS="${AM_CXXFLAGS} -O"])
  119. LOL_TRY_CXXFLAGS(-g, [AM_CXXFLAGS="${AM_CXXFLAGS} -g"])
  120. elif test "x${ac_cv_my_build_mode}" = "xdevel"; then
  121. AC_DEFINE(LOL_BUILD_DEVEL, 1, Define to 1 to activate development build)
  122. LOL_TRY_CXXFLAGS(-Os, [AM_CXXFLAGS="${AM_CXXFLAGS} -Os"])
  123. LOL_TRY_CXXFLAGS(-g, [AM_CXXFLAGS="${AM_CXXFLAGS} -g"])
  124. LOL_TRY_CXXFLAGS(-ffast-math, [AM_CXXFLAGS="${AM_CXXFLAGS} -ffast-math"])
  125. else
  126. AC_DEFINE(LOL_BUILD_RELEASE, 1, Define to 1 to activate final release)
  127. LOL_TRY_CXXFLAGS(-Os, [AM_CXXFLAGS="${AM_CXXFLAGS} -Os"])
  128. LOL_TRY_CXXFLAGS(-ffast-math, [AM_CXXFLAGS="${AM_CXXFLAGS} -ffast-math"])
  129. LOL_TRY_CXXFLAGS(-fomit-frame-pointer, [AM_CXXFLAGS="${AM_CXXFLAGS} -fomit-frame-pointer"])
  130. LOL_TRY_CXXFLAGS(-fno-strength-reduce, [AM_CXXFLAGS="${AM_CXXFLAGS} -fno-strength-reduce"])
  131. fi
  132. dnl Build documentation?
  133. DOXYGEN="no"
  134. LATEX="no"
  135. if test "${enable_doc}" != "no" -a "${enable_subproject}" != "yes"; then
  136. AC_PATH_PROG(DOXYGEN, doxygen, no)
  137. if test "${DOXYGEN}" != "no"; then
  138. # Build LaTeX documentation?
  139. AC_PATH_PROG(LATEX, pdflatex, no)
  140. AC_PATH_PROG(KPSEWHICH, kpsewhich, no)
  141. AC_PATH_PROG(DVIPS, dvips, no)
  142. if test "${DVIPS}" = "no" -o "${KPSEWHICH}" = "no"; then
  143. LATEX="no"
  144. fi
  145. if test "${LATEX}" != "no"; then
  146. AC_MSG_CHECKING(for a4.sty and a4wide.sty)
  147. if "${KPSEWHICH}" a4.sty >/dev/null 2>&1; then
  148. if "${KPSEWHICH}" a4wide.sty >/dev/null 2>&1; then
  149. AC_MSG_RESULT(yes)
  150. else
  151. LATEX="no"
  152. AC_MSG_RESULT(no)
  153. fi
  154. else
  155. LATEX="no"
  156. AC_MSG_RESULT(no)
  157. fi
  158. fi
  159. AC_PATH_PROG(DOT, dot, no)
  160. if test "${DOT}" != "no"; then
  161. LOL_USE_DOT="YES"
  162. else
  163. LOL_USE_DOT="NO"
  164. fi
  165. fi
  166. fi
  167. dnl XXX: disable LaTeX because we use too much memory
  168. LATEX=no
  169. AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
  170. AM_CONDITIONAL(LOL_USE_LATEX, test "${LATEX}" != "no")
  171. AM_CONDITIONAL(LOL_USE_DOT, test "${DOT}" != "no")
  172. AC_SUBST(LOL_USE_DOT)
  173. dnl GCC-specific symbol demangling
  174. AC_LANG_PUSH(C++)
  175. AC_TRY_LINK(
  176. [#include <cxxabi.h>],
  177. [abi::__cxa_demangle(NULL, 0, 0, NULL);],
  178. [AC_DEFINE(HAVE_CXA_DEMANGLE, 1, Define to 1 if abi::__cxa_demangle is available)])
  179. AC_LANG_POP(C++)
  180. LOL_AC_CHECK()
  181. dnl Use libcaca? (required for font generation)
  182. ac_cv_my_have_caca="no"
  183. PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
  184. if test "${ac_cv_my_have_caca}" != "no"; then
  185. AC_DEFINE(LOL_USE_CACA, 1, Define to 1 to use libcaca)
  186. fi
  187. AM_CONDITIONAL(LOL_USE_CACA, test "${ac_cv_my_have_caca}" != "no")
  188. dnl Use GTK+? (required for the deushax editor)
  189. ac_cv_my_have_gtkgl="no"
  190. PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
  191. PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
  192. if test "${ac_cv_my_have_gtkgl}" != "no"; then
  193. AC_DEFINE(LOL_USE_GTKGL, 1, Define to 1 to use GtkGl)
  194. fi
  195. AM_CONDITIONAL(LOL_USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
  196. dnl Optional features
  197. AM_CONDITIONAL(BUILD_TEST, test "${enable_test}" != "no" -a "${enable_subproject}" != "yes")
  198. AM_CONDITIONAL(BUILD_TOOLS, test "${enable_tools}" != "no" -a "${enable_subproject}" != "yes")
  199. AM_CONDITIONAL(BUILD_TUTORIAL, test "${enable_tutorial}" != "no" -a "${enable_subproject}" != "yes")
  200. AM_CONDITIONAL(BUILD_SAMPLES, test "${enable_samples}" != "no" -a "${enable_subproject}" != "yes")
  201. LOL_AC_FINI()
  202. AC_CONFIG_HEADER(config.h)
  203. AC_CONFIG_FILES(
  204. [Makefile
  205. src/Makefile
  206. src/3rdparty/Makefile
  207. src/data/Makefile
  208. src/data/font/Makefile
  209. src/t/Makefile
  210. build/Makefile
  211. binaries/Makefile
  212. doc/Makefile
  213. doc/doxygen.cfg
  214. doc/samples/Makefile
  215. doc/samples/math/Makefile
  216. doc/samples/meshviewer/Makefile
  217. doc/samples/sandbox/Makefile
  218. doc/tutorial/Makefile
  219. tools/Makefile
  220. tools/lolunit/Makefile
  221. tools/vimlol/Makefile
  222. tools/vslol/Makefile
  223. ])
  224. AC_OUTPUT