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.
 
 
 

233 regels
7.1 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. LDFLAGS="$LDFLAGS -L$PWD/contrib/gdiplus/lib"
  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. ;;
  87. windows-amd64)
  88. if test "x${MSYSTEM}" = xMINGW64; then
  89. :
  90. elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  91. HOSTFLAGS=--host=x86_64-w64-mingw32
  92. BUILDFLAGS=--build=none
  93. else
  94. echo "Error: could not find win64 compiler" >&2
  95. false
  96. fi
  97. if test "x${MSYSTEM}" = xMINGW32; then
  98. # If using mingw32, we're not really cross-compiling
  99. BUILDFLAGS=
  100. fi
  101. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/x86_64-w64-mingw32/pkgconfig"
  102. LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/x86_64-w64-mingw32"
  103. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.14/lib/x86_64-w64-mingw32"
  104. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/x86_64-w64-mingw32"
  105. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/x86_64-w64-mingw32"
  106. ;;
  107. esac
  108. case "$platform" in
  109. ios-arm)
  110. # No configuration needed
  111. ;;
  112. android-arm)
  113. cd monsterz/android
  114. android update project --path .
  115. ;;
  116. nacl-i386)
  117. ./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"
  118. ;;
  119. nacl-amd64)
  120. ./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"
  121. ;;
  122. ps3-ppu)
  123. PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
  124. ;;
  125. windows-i386|windows-amd64)
  126. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gdiplus/include"
  127. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-1.2.14/include"
  128. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-image-1.2.10/include"
  129. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-mixer-1.2.11/include"
  130. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/glew-1.7.0/include/GL -DGLEW_STATIC"
  131. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/glib-2.0/include"
  132. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/gtk-2.0/include"
  133. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/glib-2.0"
  134. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gtk-2.0"
  135. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/cairo"
  136. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/pango-1.0"
  137. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0"
  138. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/atk-1.0"
  139. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtkglarea-2.0.1/include"
  140. CPPFLAGS="$CPPFLAGS -mms-bitfields"
  141. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
  142. GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
  143. GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
  144. GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
  145. PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
  146. ;;
  147. *)
  148. PATH="$PATH" ./configure
  149. ;;
  150. esac
  151. }
  152. build()
  153. {
  154. cd $top_srcdir
  155. case "$platform" in
  156. ios-arm)
  157. cd monsterz/ios
  158. xcodebuild -configuration Release -sdk iphonesimulator4.3
  159. ;;
  160. android-arm)
  161. cd monsterz/android
  162. ndk-build
  163. ant compile
  164. ;;
  165. *)
  166. make -j6
  167. ;;
  168. esac
  169. }
  170. check()
  171. {
  172. cd $top_srcdir
  173. case "$platform" in
  174. ios-arm)
  175. ;;
  176. android-arm)
  177. ;;
  178. ps3-ppu)
  179. ;;
  180. nacl-*)
  181. ;;
  182. windows-i386)
  183. # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
  184. # exists, use it to run the test suite.
  185. if test "x${MSYSTEM}${DISPLAY}" = x \
  186. && xvfb-run --help 2>&1 >/dev/null; then
  187. xvfb-run make check
  188. else
  189. make check
  190. fi
  191. ;;
  192. windows-amd64)
  193. # No support for Wine64 yet
  194. ;;
  195. *)
  196. make check
  197. ;;
  198. esac
  199. }
  200. clean()
  201. {
  202. cd $top_srcdir
  203. case "$platform" in
  204. ios-arm)
  205. cd monsterz/ios
  206. xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
  207. ;;
  208. android-arm)
  209. cd monsterz/android
  210. ndk-build distclean
  211. ant clean
  212. ;;
  213. *)
  214. make distclean
  215. ;;
  216. esac
  217. }
  218. __init__
  219. echo "lol-build: executing action '$action' on platform '$platform'" >&2
  220. eval "$action"