Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. # 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?
  84. ac_cv_my_have_egl="no"
  85. PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
  86. if test "${ac_cv_my_have_egl}" != "no"; then
  87. AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
  88. EGL_LIBS="${EGL_LIBS} -lX11"
  89. fi
  90. AC_CHECK_LIB(EGL, main,
  91. [ac_cv_my_have_egl="yes"
  92. AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
  93. EGL_LIBS="-lEGL"])
  94. dnl Raspberry Pi is different, check for it with extra libs; also we
  95. dnl look for a different function to bypass autoconf caching
  96. AC_CHECK_LIB(EGL, eglGetDisplay,
  97. [ac_cv_my_have_egl="yes"
  98. AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
  99. EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
  100. [:],
  101. [-lvcos -lvchiq_arm -lbcm_host -lGLESv2])
  102. AM_CONDITIONAL(LOL_USE_EGL, test "${ac_cv_my_have_egl}" != "no")
  103. dnl Use libpng? (replacement for SDL_image)
  104. ac_cv_my_have_libpng="no"
  105. PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
  106. if test "${ac_cv_my_have_libpng}" != "no"; then
  107. AC_DEFINE(LOL_USE_LIBPNG, 1, Define to 1 to use libpng)
  108. fi
  109. AM_CONDITIONAL(LOL_USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
  110. dnl Use Imlib2?
  111. ac_cv_my_have_imlib2="no"
  112. PKG_CHECK_MODULES(IMLIB2, imlib2, [ac_cv_my_have_imlib2="yes"], [:])
  113. if test "${ac_cv_my_have_imlib2}" != "no"; then
  114. AC_DEFINE(LOL_USE_IMLIB2, 1, Define to 1 to use Imlib2)
  115. LOL_CFLAGS="${LOL_CFLAGS} ${IMLIB2_CFLAGS}"
  116. LOL_LIBS="${LOL_LIBS} ${IMLIB2_LIBS}"
  117. fi
  118. AM_CONDITIONAL(LOL_USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
  119. dnl Use Windows GDI+?
  120. ac_cv_my_have_gdiplus="no"
  121. AC_LANG_PUSH(C++)
  122. AC_CHECK_HEADERS(gdiplus.h,
  123. [ac_cv_my_have_gdiplus="yes"
  124. LOL_LIBS="${LOL_LIBS} -lgdiplus"],
  125. [ac_cv_my_have_gdiplus="no"],
  126. [#include <algorithm>
  127. using std::min;
  128. using std::max;
  129. #include <windows.h>])
  130. AC_LANG_POP(C++)
  131. if test "${ac_cv_my_have_gdiplus}" != "no"; then
  132. AC_DEFINE(LOL_USE_GDIPLUS, 1, Define to 1 to use GDI+)
  133. fi
  134. AM_CONDITIONAL(LOL_USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
  135. dnl Use libavcodec? (required for movie encoding)
  136. ac_cv_my_have_ffmpeg="yes"
  137. PKG_CHECK_MODULES([LIBAVCODEC], [libavcodec], [:], [ac_cv_my_have_ffmpeg=no])
  138. PKG_CHECK_MODULES([LIBAVUTIL], [libavutil], [:], [ac_cv_my_have_ffmpeg=no])
  139. PKG_CHECK_MODULES([LIBAVFORMAT], [libavformat], [:], [ac_cv_my_have_ffmpeg=no])
  140. PKG_CHECK_MODULES([LIBSWSCALE], [libswscale], [:], [ac_cv_my_have_ffmpeg=no])
  141. if test "${ac_cv_my_have_ffmpeg}" = "no"; then
  142. ac_cv_my_have_ffmpeg="yes"
  143. AC_CHECK_HEADERS(libavcodec/avcodec.h, [:], [ac_cv_my_have_ffmpeg=no])
  144. AC_CHECK_HEADERS(libavformat/avformat.h, [:], [ac_cv_my_have_ffmpeg=no])
  145. AC_CHECK_HEADERS(libswscale/swscale.h, [:], [ac_cv_my_have_ffmpeg=no])
  146. if test "${ac_cv_my_have_ffmpeg}" = "yes"; then
  147. LIBAVCODEC_LIBS="-lavcodec"
  148. LIBAVUTIL_LIBS="-lavutil"
  149. LIBAVFORMAT_LIBS="-lavformat"
  150. LIBSWSCALE_LIBS="-lswscale"
  151. AC_CHECK_LIB(ws2_32, main, LOL_LIBS="${LOL_LIBS} -lws2_32")
  152. fi
  153. fi
  154. if test "${ac_cv_my_have_ffmpeg}" != "no"; then
  155. AC_DEFINE(LOL_USE_FFMPEG, 1, Define to 1 to use FFmpeg)
  156. LOL_CFLAGS="${LOL_CFLAGS} ${LIBAVFORMAT_CFLAGS} ${LIBAVUTIL_CFLAGS} ${LIBAVCODEC_CFLAGS} ${LIBSWSCALE_CFLAGS}"
  157. LOL_LIBS="${LOL_LIBS} ${LIBAVFORMAT_LIBS} ${LIBAVUTIL_LIBS} ${LIBAVCODEC_LIBS} ${LIBSWSCALE_LIBS}"
  158. fi
  159. AM_CONDITIONAL(LOL_USE_FFMPEG, test "${ac_cv_my_have_ffmpeg}" != "no")
  160. dnl Are we building using MinGW?
  161. LOL_TRY_CXXFLAGS(-mwindows -mwin32,
  162. [AM_CXXFLAGS="${AM_CXXFLAGS} -mwindows -mwin32"
  163. LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"])
  164. dnl Are we building using Emscripten?
  165. ac_cv_my_have_emscripten="no"
  166. AC_CHECK_HEADERS(emscripten.h,
  167. [ac_cv_my_have_emscripten="yes"
  168. dnl XXX: activate this if memory heap is too small
  169. #AM_CXXFLAGS="${AM_CXXFLAGS} -s ALLOW_MEMORY_GROWTH=1"
  170. dnl HACK: until emcc properly adds these to EMSDK_OPTS
  171. CPPFLAGS="${CPPFLAGS} -U__i386__ -U__x86_64__ -U__i386 -U__x86_64 -Ui386 -Ux86_64"
  172. CPPFLAGS="${CPPFLAGS} -U__SSE__ -U__SSE2__ -U__MMX__ -UX87_DOUBLE_ROUNDING"
  173. CPPFLAGS="${CPPFLAGS} -UHAVE_GCC_ASM_FOR_X87 -DEMSCRIPTEN -U__STRICT_ANSI__"
  174. CPPFLAGS="${CPPFLAGS} -U__CYGWIN__"])
  175. AM_CONDITIONAL(LOL_USE_EMSCRIPTEN, test "${ac_cv_my_have_emscripten}" != "no")
  176. dnl Are we on an OS X or iOS platform?
  177. LOL_TRY_LDFLAGS(-framework Foundation,
  178. [LOL_LIBS="${LOL_LIBS} -framework Foundation"])
  179. LOL_TRY_LDFLAGS(-framework CoreGraphics,
  180. [LOL_LIBS="${LOL_LIBS} -framework CoreGraphics"])
  181. LOL_TRY_LDFLAGS(-framework CoreData,
  182. [LOL_LIBS="${LOL_LIBS} -framework CoreData"])
  183. LOL_TRY_LDFLAGS(-framework UIKit,
  184. [LOL_LIBS="${LOL_LIBS} -framework UIKit"])
  185. dnl Other complex checks
  186. LOL_AC_CHECK_OPENGL()
  187. LOL_AC_CHECK_SDL()
  188. dnl Debug symbols
  189. LOL_TRY_LDFLAGS(-rdynamic, [AM_LDFLAGS="${AM_LDFLAGS} -rdynamic"])
  190. dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  191. LOL_TRY_CXXFLAGS(-Wall, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wall"])
  192. LOL_TRY_CXXFLAGS(-Wextra, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wextra"])
  193. LOL_TRY_CXXFLAGS(-Wpointer-arith, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wpointer-arith"])
  194. LOL_TRY_CXXFLAGS(-Wcast-align, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-align"])
  195. LOL_TRY_CXXFLAGS(-Wcast-qual, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-qual"])
  196. LOL_TRY_CXXFLAGS(-Wshadow, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wshadow"])
  197. LOL_TRY_CXXFLAGS(-Wsign-compare, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wsign-compare"])
  198. LOL_TRY_CXXFLAGS(-Wstrict-overflow=1, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wstrict-overflow=1"])
  199. dnl Add these even though they're implicitly set, so that we can safely
  200. dnl remove them from within a Makefile.
  201. LOL_TRY_CXXFLAGS(-Wmaybe-uninitialized, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wmaybe-uninitialized"])
  202. LOL_TRY_CXXFLAGS(-Wnarrowing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wnarrowing"])
  203. LOL_TRY_CXXFLAGS(-Wunused, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wunused"])
  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_DEPS="${LOL_DEPS} \$(lol_builddir)/src/3rdparty/liblol-bullet.a"
  218. LOL_DEPS="${LOL_DEPS} \$(lol_builddir)/src/3rdparty/liblol-lua.a"
  219. dnl How to use the Lol Engine inside this tree
  220. AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(lol_srcdir)/src"
  221. AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_CONFIG_SOURCESUBDIR=\\\"\$(subdir)\\\""
  222. AM_CPPFLAGS="${AM_CPPFLAGS} ${LOL_CFLAGS}"
  223. AM_LDFLAGS="${AM_LDFLAGS} ${LOL_DEPS}"
  224. AM_LDFLAGS="${AM_LDFLAGS} ${LOL_LIBS}"
  225. dnl Extra flags
  226. AC_SUBST(LOL_CFLAGS)
  227. AC_SUBST(LOL_LIBS)
  228. AC_SUBST(LOL_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