25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

268 lines
8.8 KiB

  1. dnl
  2. dnl Lol Engine
  3. dnl
  4. dnl Copyright © 2010—2017 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. # LOL_AC_INIT()
  13. # ---------------------
  14. AC_DEFUN([LOL_AC_INIT], [
  15. dnl C++11 and later mode. Checked early so that we don't run into surprises.
  16. version_flag=''
  17. LOL_TRY_CXXFLAGS(-std=c++0x, [version_flag='-std=c++0x'])
  18. LOL_TRY_CXXFLAGS(-std=c++11, [version_flag='-std=c++11'])
  19. LOL_TRY_CXXFLAGS(-std=c++14, [version_flag='-std=c++14'])
  20. LOL_TRY_CXXFLAGS(-std=c++17, [version_flag='-std=c++17'])
  21. AM_CXXFLAGS="${AM_CXXFLAGS} ${version_flag}"
  22. CXXFLAGS="${CXXFLAGS} ${version_flag}"
  23. AC_LANG_PUSH(C++)
  24. AC_MSG_CHECKING(for C++11 enum class support)
  25. AC_TRY_LINK([], [enum class Foo : int { Bar, Baz };],
  26. [AC_MSG_RESULT(yes)],
  27. [AC_MSG_RESULT(no)
  28. AC_MSG_ERROR([[C++ compiler does not support C++11 enum classes]])])
  29. AC_LANG_POP(C++)
  30. ]) # LOL_AC_INIT
  31. # LOL_AC_CHECK()
  32. # ---------------------
  33. AC_DEFUN([LOL_AC_CHECK], [
  34. dnl Check that the C++ compiler really works
  35. AC_LANG_PUSH(C++)
  36. AC_MSG_CHECKING(for a fully working C++ compiler)
  37. AC_TRY_LINK([], [],
  38. [AC_MSG_RESULT(yes)],
  39. [AC_MSG_RESULT(no)
  40. AC_MSG_ERROR([[C++ compiler cannot link executables]])])
  41. AC_LANG_POP(C++)
  42. AC_C_CONST
  43. AC_C_INLINE
  44. dnl
  45. dnl Common libraries
  46. dnl
  47. AC_CHECK_LIB(m, sin, LIBS="${LIBS} -lm")
  48. AC_CHECK_LIB(pthread, main, LIBS="${LIBS} -lpthread")
  49. dnl
  50. dnl Activate some header-only libraries
  51. dnl
  52. LOL_CFLAGS="$LOL_CFLAGS -I\$(lol_srcdir)/src/3rdparty/mingw-std-threads"
  53. LOL_CFLAGS="$LOL_CFLAGS -I\$(lol_srcdir)/src/3rdparty/pegtl/include"
  54. LOL_CFLAGS="$LOL_CFLAGS -I\$(lol_srcdir)/src/3rdparty/imgui"
  55. dnl Use system-provided getopt_long?
  56. ac_cv_have_getopt_long="no"
  57. AC_CHECK_HEADERS(getopt.h unistd.h)
  58. AC_CHECK_FUNCS(getopt_long,
  59. [ac_cv_have_getopt_long="yes"],
  60. [AC_CHECK_LIB(gnugetopt, getopt_long,
  61. [ac_cv_have_getopt_long="yes"
  62. LIBS="${LIBS} -lgnugetopt"])])
  63. if test "$ac_cv_have_getopt_long" != "no"; then
  64. AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the ‘getopt_long’ function.)
  65. fi
  66. dnl Use NativeClient?
  67. ac_cv_my_have_nacl="no"
  68. AC_LANG_PUSH(C++)
  69. AC_CHECK_HEADERS(ppapi/cpp/instance.h,
  70. [ac_cv_my_have_nacl="yes"
  71. LOL_LIBS="${LOL_LIBS} -lnosys"
  72. if test "${ac_cv_my_build_mode}" = "xrelease"; then
  73. LOL_TRY_CXXFLAGS(-s, [AM_CXXFLAGS="${AM_CXXFLAGS} -s"])
  74. fi])
  75. AC_LANG_POP(C++)
  76. AM_CONDITIONAL(LOL_USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
  77. dnl Use Android? FIXME: super hacks!
  78. ac_cv_my_have_android="no"
  79. AC_CHECK_LIB(log, __android_log_vprint,
  80. [ac_cv_my_have_android="yes"
  81. LOL_LIBS="${LOL_LIBS} -llog -landroid -module -lEGL -lGLESv2"])
  82. AM_CONDITIONAL(LOL_USE_ANDROID, test "${ac_cv_my_have_android}" != "no")
  83. dnl Use EGL? (autodetect unless GL is disabled)
  84. ac_cv_my_have_egl="no"
  85. if test "${enable_gl}" != "no"; then
  86. PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
  87. if test "${ac_cv_my_have_egl}" != "no"; then
  88. AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
  89. EGL_LIBS="${EGL_LIBS} -lX11"
  90. fi
  91. AC_CHECK_LIB(EGL, main,
  92. [ac_cv_my_have_egl="yes"
  93. AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
  94. EGL_LIBS="-lEGL"])
  95. dnl Raspberry Pi is different, check for it with extra libs; also we
  96. dnl look for a different function to bypass autoconf caching
  97. AC_CHECK_LIB(EGL, eglGetDisplay,
  98. [ac_cv_my_have_egl="yes"
  99. AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
  100. EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
  101. [:],
  102. [-lvcos -lvchiq_arm -lbcm_host -lGLESv2])
  103. fi
  104. AM_CONDITIONAL(LOL_USE_EGL, test "${ac_cv_my_have_egl}" != "no")
  105. dnl Use libpng? (replacement for SDL_image)
  106. ac_cv_my_have_libpng="no"
  107. if test "${enable_png}" != "no"; then
  108. PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
  109. if test "${ac_cv_my_have_libpng}" != "no"; then
  110. AC_DEFINE(LOL_USE_LIBPNG, 1, Define to 1 to use libpng)
  111. fi
  112. fi
  113. AM_CONDITIONAL(LOL_USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
  114. dnl Use Imlib2?
  115. ac_cv_my_have_imlib2="no"
  116. if test "${enable_imlib2}" != "no"; then
  117. PKG_CHECK_MODULES(IMLIB2, imlib2, [ac_cv_my_have_imlib2="yes"], [:])
  118. if test "${ac_cv_my_have_imlib2}" != "no"; then
  119. AC_DEFINE(LOL_USE_IMLIB2, 1, Define to 1 to use Imlib2)
  120. LOL_CFLAGS="${LOL_CFLAGS} ${IMLIB2_CFLAGS}"
  121. LOL_LIBS="${LOL_LIBS} ${IMLIB2_LIBS}"
  122. fi
  123. fi
  124. AM_CONDITIONAL(LOL_USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
  125. dnl Use Windows GDI+?
  126. ac_cv_my_have_gdiplus="no"
  127. AC_LANG_PUSH(C++)
  128. AC_CHECK_HEADERS(gdiplus.h,
  129. [ac_cv_my_have_gdiplus="yes"
  130. LOL_LIBS="${LOL_LIBS} -lgdiplus"],
  131. [ac_cv_my_have_gdiplus="no"],
  132. [#include <algorithm>
  133. using std::min;
  134. using std::max;
  135. #include <windows.h>])
  136. AC_LANG_POP(C++)
  137. if test "${ac_cv_my_have_gdiplus}" != "no"; then
  138. AC_DEFINE(LOL_USE_GDIPLUS, 1, Define to 1 to use GDI+)
  139. fi
  140. AM_CONDITIONAL(LOL_USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
  141. dnl Are we building using MinGW?
  142. LOL_TRY_CXXFLAGS(-mwindows -mwin32,
  143. [AM_CXXFLAGS="${AM_CXXFLAGS} -mwindows -mwin32"
  144. LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"])
  145. dnl Are we building using Emscripten?
  146. ac_cv_my_have_emscripten="no"
  147. AC_CHECK_HEADERS(emscripten.h,
  148. [ac_cv_my_have_emscripten="yes"
  149. dnl XXX: activate this if memory heap is too small
  150. #AM_CXXFLAGS="${AM_CXXFLAGS} -s ALLOW_MEMORY_GROWTH=1"
  151. dnl HACK: until emcc properly adds these to EMSDK_OPTS
  152. CPPFLAGS="${CPPFLAGS} -U__i386__ -U__x86_64__ -U__i386 -U__x86_64 -Ui386 -Ux86_64"
  153. CPPFLAGS="${CPPFLAGS} -U__SSE__ -U__SSE2__ -U__MMX__ -UX87_DOUBLE_ROUNDING"
  154. CPPFLAGS="${CPPFLAGS} -UHAVE_GCC_ASM_FOR_X87 -DEMSCRIPTEN -U__STRICT_ANSI__"
  155. CPPFLAGS="${CPPFLAGS} -U__CYGWIN__"])
  156. AM_CONDITIONAL(LOL_USE_EMSCRIPTEN, test "${ac_cv_my_have_emscripten}" != "no")
  157. dnl Are we on an OS X or iOS platform?
  158. LOL_TRY_LDFLAGS(-framework Foundation,
  159. [LOL_LIBS="${LOL_LIBS} -framework Foundation"])
  160. LOL_TRY_LDFLAGS(-framework CoreGraphics,
  161. [LOL_LIBS="${LOL_LIBS} -framework CoreGraphics"])
  162. LOL_TRY_LDFLAGS(-framework CoreData,
  163. [LOL_LIBS="${LOL_LIBS} -framework CoreData"])
  164. LOL_TRY_LDFLAGS(-framework UIKit,
  165. [LOL_LIBS="${LOL_LIBS} -framework UIKit"])
  166. dnl Other complex checks
  167. LOL_AC_CHECK_OPENGL()
  168. LOL_AC_CHECK_SDL()
  169. LOL_AC_CHECK_FFMPEG()
  170. dnl Debug symbols
  171. LOL_TRY_LDFLAGS(-rdynamic, [AM_LDFLAGS="${AM_LDFLAGS} -rdynamic"])
  172. dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  173. LOL_TRY_CXXFLAGS(-Wall, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wall"])
  174. LOL_TRY_CXXFLAGS(-Wextra, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wextra"])
  175. LOL_TRY_CXXFLAGS(-Wpointer-arith, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wpointer-arith"])
  176. LOL_TRY_CXXFLAGS(-Wcast-align, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-align"])
  177. LOL_TRY_CXXFLAGS(-Wcast-qual, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-qual"])
  178. LOL_TRY_CXXFLAGS(-Wshadow, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wshadow"])
  179. LOL_TRY_CXXFLAGS(-Wsign-compare, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wsign-compare"])
  180. LOL_TRY_CXXFLAGS(-Wstrict-overflow=1, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wstrict-overflow=1"])
  181. dnl Add these even though they're implicitly set, so that we can safely
  182. dnl remove them from within a Makefile.
  183. LOL_TRY_CXXFLAGS(-Wuninitialized, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wuninitialized"])
  184. LOL_TRY_CXXFLAGS(-Wnarrowing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wnarrowing"])
  185. LOL_TRY_CXXFLAGS(-Wunused, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wunused"])
  186. LOL_TRY_CXXFLAGS(-Wcast-align, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-align"])
  187. LOL_TRY_CXXFLAGS(-Wunused-parameter, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wunused-parameter"])
  188. LOL_TRY_CXXFLAGS(-Wstrict-aliasing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wstrict-aliasing"])
  189. LOL_TRY_CXXFLAGS(-Wparentheses, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wparentheses"])
  190. LOL_TRY_CXXFLAGS(-Wreorder, [AM_CXXFLAGS="${AM_CXXFLAGS} -Wreorder"])
  191. dnl Disable these warnings because they're annoyingly verbose
  192. LOL_TRY_CXXFLAGS(-Wno-psabi, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wno-psabi"])
  193. ]) # LOL_AC_CHECK
  194. # LOL_AC_FINI()
  195. # ---------------------
  196. AC_DEFUN([LOL_AC_FINI], [
  197. dnl How to use the Lol Engine outside this tree
  198. LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
  199. LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
  200. LOL_DEPS="${LOL_DEPS} \$(lol_builddir)/src/liblol-core.a"
  201. LOL_DEPS="${LOL_DEPS} \$(lol_builddir)/src/3rdparty/liblol-bullet.a"
  202. LOL_DEPS="${LOL_DEPS} \$(lol_builddir)/src/3rdparty/liblol-lua.a"
  203. dnl How to use the Lol Engine inside this tree
  204. AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(lol_srcdir)/src"
  205. AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_CONFIG_SOURCESUBDIR=\\\"\$(subdir)\\\""
  206. AM_CPPFLAGS="${AM_CPPFLAGS} ${LOL_CFLAGS}"
  207. AM_LDFLAGS="${AM_LDFLAGS} ${LOL_DEPS}"
  208. AM_LDFLAGS="${AM_LDFLAGS} ${LOL_LIBS}"
  209. dnl Extra flags
  210. AC_SUBST(LOL_CFLAGS)
  211. AC_SUBST(LOL_LIBS)
  212. AC_SUBST(LOL_DEPS)
  213. AC_SUBST(AM_CFLAGS)
  214. AC_SUBST(AM_CPPFLAGS)
  215. AC_SUBST(AM_CXXFLAGS)
  216. AC_SUBST(AM_LDFLAGS)
  217. ]) # LOL_AC_FINI