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.
 
 
 

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