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.
 
 
 

238 lines
7.4 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. # - windows-i386
  24. # - windows-amd64
  25. #
  26. set -e
  27. action="$1"
  28. platform="$2"
  29. __init__()
  30. {
  31. top_srcdir=$(dirname "$0")/..
  32. cd $top_srcdir
  33. top_srcdir="`pwd`"
  34. case "${MSYSTEM}" in
  35. MINGW32|MINGW64)
  36. PATH="$PATH:./contrib/gtk-2.22.1/bin"
  37. M4PATH="$M4PATH:./contrib/gtk-2.22.1/share/aclocal"
  38. ;;
  39. esac
  40. }
  41. bootstrap()
  42. {
  43. cd $top_srcdir
  44. case "$platform" in
  45. ios-arm)
  46. # No bootstrapping needed
  47. ;;
  48. android-arm)
  49. # No bootstrapping needed
  50. ;;
  51. *)
  52. PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
  53. ;;
  54. esac
  55. }
  56. configure()
  57. {
  58. cd $top_srcdir
  59. case "$platform" in
  60. windows-i386)
  61. if test "x${MSYSTEM}" = xMINGW32; then
  62. :
  63. elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then
  64. HOSTFLAGS=--host=i586-mingw32msvc
  65. BUILDFLAGS=--build=none
  66. elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  67. HOSTFLAGS=--host=i686-w64-mingw32
  68. BUILDFLAGS=--build=none
  69. else
  70. echo "Error: could not find win32 compiler" >&2
  71. false
  72. fi
  73. if test "x${MSYSTEM}" = xMINGW64; then
  74. # If using mingw64, we're not really cross-compiling
  75. BUILDFLAGS=
  76. fi
  77. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
  78. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
  79. LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/i686-w64-mingw32"
  80. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.14/lib/i686-w64-mingw32"
  81. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/i686-w64-mingw32"
  82. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/i686-w64-mingw32"
  83. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/lib"
  84. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/bin"
  85. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtkglarea-2.0.1/lib"
  86. LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/i686-w64-mingw32"
  87. ;;
  88. windows-amd64)
  89. if test "x${MSYSTEM}" = xMINGW64; then
  90. :
  91. elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  92. HOSTFLAGS=--host=x86_64-w64-mingw32
  93. BUILDFLAGS=--build=none
  94. else
  95. echo "Error: could not find win64 compiler" >&2
  96. false
  97. fi
  98. if test "x${MSYSTEM}" = xMINGW32; then
  99. # If using mingw32, we're not really cross-compiling
  100. BUILDFLAGS=
  101. fi
  102. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
  103. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
  104. LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/x86_64-w64-mingw32"
  105. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.14/lib/x86_64-w64-mingw32"
  106. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/x86_64-w64-mingw32"
  107. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/x86_64-w64-mingw32"
  108. LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
  109. ;;
  110. esac
  111. case "$platform" in
  112. ios-arm)
  113. # No configuration needed
  114. ;;
  115. android-arm)
  116. cd monsterz/android
  117. android update project --path .
  118. ;;
  119. nacl-i386)
  120. ./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"
  121. ;;
  122. nacl-amd64)
  123. ./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"
  124. ;;
  125. ps3-ppu)
  126. PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
  127. ;;
  128. windows-i386|windows-amd64)
  129. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-1.2.14/include"
  130. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-image-1.2.10/include"
  131. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-mixer-1.2.11/include"
  132. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/glew-1.7.0/include/GL -DGLEW_STATIC"
  133. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/glib-2.0/include"
  134. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/gtk-2.0/include"
  135. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/glib-2.0"
  136. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gtk-2.0"
  137. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/cairo"
  138. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/pango-1.0"
  139. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0"
  140. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/atk-1.0"
  141. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtkglarea-2.0.1/include"
  142. CPPFLAGS="$CPPFLAGS -mms-bitfields"
  143. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
  144. GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
  145. GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
  146. GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
  147. CPPFLAGS="$CPPFLAGS -L$PWD/contrib/libcaca-0.99.beta18/include"
  148. PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
  149. ;;
  150. *)
  151. PATH="$PATH" ./configure
  152. ;;
  153. esac
  154. }
  155. build()
  156. {
  157. cd $top_srcdir
  158. case "$platform" in
  159. ios-arm)
  160. cd monsterz/ios
  161. xcodebuild -configuration Release -sdk iphonesimulator4.3
  162. ;;
  163. android-arm)
  164. cd monsterz/android
  165. ndk-build
  166. ant compile
  167. ;;
  168. *)
  169. make -j6
  170. ;;
  171. esac
  172. }
  173. check()
  174. {
  175. cd $top_srcdir
  176. case "$platform" in
  177. ios-arm)
  178. ;;
  179. android-arm)
  180. ;;
  181. ps3-ppu)
  182. ;;
  183. nacl-*)
  184. ;;
  185. windows-i386)
  186. # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
  187. # exists, use it to run the test suite.
  188. if test "x${MSYSTEM}${DISPLAY}" = x \
  189. && xvfb-run --help 2>&1 >/dev/null; then
  190. xvfb-run make check
  191. else
  192. make check
  193. fi
  194. ;;
  195. windows-amd64)
  196. # No support for Wine64 yet
  197. ;;
  198. *)
  199. make check
  200. ;;
  201. esac
  202. }
  203. clean()
  204. {
  205. cd $top_srcdir
  206. case "$platform" in
  207. ios-arm)
  208. cd monsterz/ios
  209. xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
  210. ;;
  211. android-arm)
  212. cd monsterz/android
  213. ndk-build distclean
  214. ant clean
  215. ;;
  216. *)
  217. make distclean
  218. ;;
  219. esac
  220. }
  221. __init__
  222. echo "lol-build: executing action '$action' on platform '$platform'" >&2
  223. eval "$action"