25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

288 satır
9.7 KiB

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