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.
 
 
 

279 lines
8.8 KiB

  1. #!/bin/sh
  2. #
  3. # Lol Engine build script
  4. # Usage:
  5. # lol-build <action> [<platform>]
  6. #
  7. # Where <action> is one of:
  8. # - bootstrap
  9. # - configure
  10. # - build
  11. # - check
  12. # - clean
  13. #
  14. # And <platform> is one of:
  15. # - linux-i386
  16. # - linux-amd64
  17. # - nacl-i386
  18. # - nacl-amd64
  19. # - ios-arm
  20. # - osx-amd64
  21. # - android-arm
  22. # - ps3-ppu
  23. # - win*-i386
  24. # - win*-amd64
  25. # - raspi-arm
  26. #
  27. set -e
  28. action="$1"
  29. platform="$2"
  30. ###############################################################################
  31. # Initialisation code
  32. #
  33. # - sets the top_srcdir variable
  34. # - sets the LOL_PARALLEL variable
  35. # - fix PATH and MKPATH if necessary
  36. #
  37. __init__()
  38. {
  39. top_srcdir="$(dirname "$0")/.."
  40. cd "$top_srcdir"
  41. top_srcdir="`pwd`"
  42. case "$cpu_count" in
  43. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  44. *) if [ -r "/proc/cpuinfo" ]; then
  45. cpu_count="$(grep -c '^processor\>' /proc/cpuinfo)"
  46. fi ;;
  47. esac
  48. case "$cpu_count" in
  49. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  50. *) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null)" ;;
  51. esac
  52. case "$cpu_count" in
  53. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  54. *) cpu_count=1 ;;
  55. esac
  56. case "$cpu_count" in
  57. 1) LOL_PARALLEL=1 ;;
  58. 2) LOL_PARALLEL=3 ;;
  59. *) LOL_PARALLEL="$(expr $cpu_count '*' 3 / 2)" ;;
  60. esac
  61. case "${MSYSTEM}" in
  62. MINGW32|MINGW64)
  63. PATH="$PATH:./contrib/gtk-2.22.1/bin"
  64. M4PATH="$M4PATH:./contrib/gtk-2.22.1/share/aclocal"
  65. ;;
  66. esac
  67. }
  68. bootstrap()
  69. {
  70. cd "$top_srcdir"
  71. case "$platform" in
  72. ios-arm)
  73. # No bootstrapping needed
  74. ;;
  75. android-arm)
  76. # No bootstrapping needed
  77. ;;
  78. *)
  79. PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
  80. ;;
  81. esac
  82. }
  83. configure()
  84. {
  85. cd "$top_srcdir"
  86. case "$platform" in
  87. win*-i386)
  88. if test "x${MSYSTEM}" = xMINGW32; then
  89. :
  90. elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then
  91. HOSTFLAGS=--host=i586-mingw32msvc
  92. BUILDFLAGS=--build=none
  93. elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  94. HOSTFLAGS=--host=i686-w64-mingw32
  95. BUILDFLAGS=--build=none
  96. else
  97. echo "Error: could not find win32 compiler" >&2
  98. false
  99. fi
  100. if test "x${MSYSTEM}" = xMINGW64; then
  101. # If using mingw64, we're not really cross-compiling
  102. BUILDFLAGS=
  103. fi
  104. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
  105. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
  106. LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/i686-w64-mingw32"
  107. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.15/lib/i686-w64-mingw32"
  108. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/i686-w64-mingw32"
  109. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/i686-w64-mingw32"
  110. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/lib"
  111. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/bin"
  112. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtkglarea-2.0.1/lib"
  113. LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/i686-w64-mingw32"
  114. ;;
  115. win*-amd64)
  116. if test "x${MSYSTEM}" = xMINGW64; then
  117. :
  118. elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  119. HOSTFLAGS=--host=x86_64-w64-mingw32
  120. BUILDFLAGS=--build=none
  121. else
  122. echo "Error: could not find win64 compiler" >&2
  123. false
  124. fi
  125. if test "x${MSYSTEM}" = xMINGW32; then
  126. # If using mingw32, we're not really cross-compiling
  127. BUILDFLAGS=
  128. fi
  129. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
  130. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
  131. LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/x86_64-w64-mingw32"
  132. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.15/lib/x86_64-w64-mingw32"
  133. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/x86_64-w64-mingw32"
  134. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/x86_64-w64-mingw32"
  135. LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
  136. ;;
  137. *-i386)
  138. # Ensure we're _really_ on i386
  139. CXXFLAGS="$CXXFLAGS -m32"
  140. ;;
  141. *-amd64)
  142. # Ensure we're _really_ on amd64
  143. CXXFLAGS="$CXXFLAGS -m64"
  144. ;;
  145. esac
  146. case "$platform" in
  147. ios-arm)
  148. # No configuration needed
  149. ;;
  150. android-arm)
  151. cd monsterz/android
  152. android update project --path .
  153. ;;
  154. raspi-arm)
  155. ./configure --host=arm-bcm2708hardfp-linux-gnueabi CPPFLAGS="-I$RASPI_SDK_ROOT/firmware/opt/vc/include -I$RASPI_SDK_ROOT/firmware/opt/vc/include/interface/vcos/pthreads" LDFLAGS="-L$RASPI_SDK_ROOT/firmware/opt/vc/lib"
  156. ;;
  157. nacl-i386)
  158. ./configure CXX=i686-nacl-g++ CC=i686-nacl-gcc ac_cv_exeext=.32.nexe --host=i386 LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp -u _ZN2pp12CreateModuleEv"
  159. ;;
  160. nacl-amd64)
  161. ./configure CXX=x86_64-nacl-g++ CC=x86_64-nacl-gcc ac_cv_exeext=.64.nexe --host=x86_64 LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp -u _ZN2pp12CreateModuleEv"
  162. ;;
  163. ps3-ppu)
  164. PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
  165. ;;
  166. win*-i386|win*-amd64)
  167. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-1.2.15/include"
  168. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-image-1.2.10/include"
  169. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-mixer-1.2.11/include"
  170. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/glew-1.7.0/include/GL -DGLEW_STATIC"
  171. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/glib-2.0/include"
  172. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/gtk-2.0/include"
  173. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/glib-2.0"
  174. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gtk-2.0"
  175. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/cairo"
  176. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/pango-1.0"
  177. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0"
  178. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/atk-1.0"
  179. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtkglarea-2.0.1/include"
  180. CPPFLAGS="$CPPFLAGS -mms-bitfields"
  181. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
  182. GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
  183. GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
  184. GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
  185. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/libcaca-0.99.beta18/include -DCACA_STATIC"
  186. PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
  187. ;;
  188. *)
  189. PATH="$PATH" ./configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
  190. ;;
  191. esac
  192. }
  193. build()
  194. {
  195. cd "$top_srcdir"
  196. case "$platform" in
  197. ios-arm)
  198. cd monsterz/ios
  199. xcodebuild -configuration Release -sdk iphonesimulator4.3
  200. ;;
  201. android-arm)
  202. cd monsterz/android
  203. ndk-build
  204. ant compile
  205. ;;
  206. *)
  207. make -j$LOL_PARALLEL
  208. ;;
  209. esac
  210. }
  211. check()
  212. {
  213. cd "$top_srcdir"
  214. case "$platform" in
  215. ios-arm)
  216. ;;
  217. android-arm)
  218. ;;
  219. raspi-arm)
  220. ;;
  221. ps3-ppu)
  222. ;;
  223. nacl-*)
  224. ;;
  225. win*-i386)
  226. # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
  227. # exists, use it to run the test suite.
  228. if test "x${MSYSTEM}${DISPLAY}" = x \
  229. && xvfb-run --help 2>&1 >/dev/null; then
  230. xvfb-run make check
  231. else
  232. make check
  233. fi
  234. ;;
  235. win*-amd64)
  236. # No support for Wine64 yet
  237. ;;
  238. *)
  239. make check
  240. ;;
  241. esac
  242. }
  243. clean()
  244. {
  245. cd "$top_srcdir"
  246. case "$platform" in
  247. ios-arm)
  248. cd monsterz/ios
  249. xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
  250. ;;
  251. android-arm)
  252. cd monsterz/android
  253. ndk-build distclean
  254. ant clean
  255. ;;
  256. *)
  257. make distclean
  258. ;;
  259. esac
  260. }
  261. __init__
  262. echo "lol-build: executing action '$action' on platform '$platform'" >&2
  263. eval "$action"