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.
 
 
 

273 line
9.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. # - 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. *)
  76. PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
  77. ;;
  78. esac
  79. }
  80. configure()
  81. {
  82. cd "$top_srcdir"
  83. case "$platform" in
  84. win*-i386)
  85. if test "x${MSYSTEM}" = xMINGW32; then
  86. :
  87. elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then
  88. HOSTFLAGS=--host=i586-mingw32msvc
  89. BUILDFLAGS=--build=none
  90. elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  91. HOSTFLAGS=--host=i686-w64-mingw32
  92. BUILDFLAGS=--build=none
  93. else
  94. echo "Error: could not find win32 compiler" >&2
  95. false
  96. fi
  97. if test "x${MSYSTEM}" = xMINGW64; then
  98. # If using mingw64, we're not really cross-compiling
  99. BUILDFLAGS=
  100. fi
  101. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
  102. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
  103. LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/i686-w64-mingw32"
  104. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.15/lib/i686-w64-mingw32"
  105. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/i686-w64-mingw32"
  106. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/i686-w64-mingw32"
  107. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/lib"
  108. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtk-2.22.1/bin"
  109. LDFLAGS="$LDFLAGS -L$PWD/contrib/gtkglarea-2.0.1/lib"
  110. LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/i686-w64-mingw32"
  111. ;;
  112. win*-amd64)
  113. if test "x${MSYSTEM}" = xMINGW64; then
  114. :
  115. elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  116. HOSTFLAGS=--host=x86_64-w64-mingw32
  117. BUILDFLAGS=--build=none
  118. else
  119. echo "Error: could not find win64 compiler" >&2
  120. false
  121. fi
  122. if test "x${MSYSTEM}" = xMINGW32; then
  123. # If using mingw32, we're not really cross-compiling
  124. BUILDFLAGS=
  125. fi
  126. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"
  127. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/contrib/libcaca-0.99.beta18/lib/pkgconfig"
  128. LDFLAGS="$LDFLAGS -L$PWD/contrib/glew-1.7.0/lib/x86_64-w64-mingw32"
  129. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-1.2.15/lib/x86_64-w64-mingw32"
  130. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-image-1.2.10/lib/x86_64-w64-mingw32"
  131. LDFLAGS="$LDFLAGS -L$PWD/contrib/sdl-mixer-1.2.11/lib/x86_64-w64-mingw32"
  132. LDFLAGS="$LDFLAGS -L$PWD/contrib/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
  133. ;;
  134. *-i386)
  135. # Ensure we're _really_ on i386
  136. CXXFLAGS="$CXXFLAGS -m32"
  137. ;;
  138. *-amd64)
  139. # Ensure we're _really_ on amd64
  140. CXXFLAGS="$CXXFLAGS -m64"
  141. ;;
  142. esac
  143. case "$platform" in
  144. ios-arm)
  145. # No configuration needed
  146. ;;
  147. android-arm)
  148. CPPFLAGS="-Wno-psabi -I$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport -fpic -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64"
  149. CFLAGS="-march=armv5te -mtune=xscale -msoft-float -mthumb"
  150. CXXFLAGS="-march=armv5te -mtune=xscale -msoft-float -mthumb -fno-rtti -fno-exceptions"
  151. LOL_LIBS="-L$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi -lstlport_shared -lm -fpic -XCClinker -shared"
  152. ./configure --host=arm-linux-androideabi ac_cv_exeext=.so CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LOL_LIBS="$LOL_LIBS"
  153. # FIXME: is this needed?
  154. # ant debug
  155. # ant debug install
  156. # ant clean
  157. ;;
  158. raspi-arm)
  159. ./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 -I$RASPI_SDK_ROOT/chroot/usr/include" LDFLAGS="-L$RASPI_SDK_ROOT/firmware/opt/vc/lib -L$RASPI_SDK_ROOT/chroot/lib/arm-linux-gnueabihf -Wl,-rpath-link -Wl,$RASPI_SDK_ROOT/chroot/lib/arm-linux-gnueabihf -L$RASPI_SDK_ROOT/chroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link -Wl,$RASPI_SDK_ROOT/chroot/usr/lib/arm-linux-gnueabihf -Wl,--unresolved-symbols=ignore-in-shared-libs"
  160. ;;
  161. nacl-i386)
  162. ./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"
  163. ;;
  164. nacl-amd64)
  165. ./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"
  166. ;;
  167. ps3-ppu)
  168. PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
  169. ;;
  170. win*-i386|win*-amd64)
  171. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-1.2.15/include"
  172. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-image-1.2.10/include"
  173. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/sdl-mixer-1.2.11/include"
  174. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/glew-1.7.0/include/GL -DGLEW_STATIC"
  175. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/glib-2.0/include"
  176. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/lib/gtk-2.0/include"
  177. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/glib-2.0"
  178. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gtk-2.0"
  179. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/cairo"
  180. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/pango-1.0"
  181. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0"
  182. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtk-2.22.1/include/atk-1.0"
  183. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/gtkglarea-2.0.1/include"
  184. CPPFLAGS="$CPPFLAGS -mms-bitfields"
  185. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
  186. GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
  187. GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
  188. GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
  189. CPPFLAGS="$CPPFLAGS -I$PWD/contrib/libcaca-0.99.beta18/include -DCACA_STATIC"
  190. PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
  191. ;;
  192. *)
  193. PATH="$PATH" ./configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
  194. ;;
  195. esac
  196. }
  197. build()
  198. {
  199. cd "$top_srcdir"
  200. case "$platform" in
  201. ios-arm)
  202. cd monsterz/ios
  203. xcodebuild -configuration Release -sdk iphonesimulator4.3
  204. ;;
  205. *)
  206. make -j$LOL_PARALLEL
  207. ;;
  208. esac
  209. }
  210. check()
  211. {
  212. cd "$top_srcdir"
  213. case "$platform" in
  214. ios-arm)
  215. ;;
  216. android-arm)
  217. ;;
  218. raspi-arm)
  219. ;;
  220. ps3-ppu)
  221. ;;
  222. nacl-*)
  223. ;;
  224. win*-i386)
  225. # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
  226. # exists, use it to run the test suite.
  227. if test "x${MSYSTEM}${DISPLAY}" = x \
  228. && xvfb-run --help 2>&1 >/dev/null; then
  229. xvfb-run make check
  230. else
  231. make check
  232. fi
  233. ;;
  234. win*-amd64)
  235. # No support for Wine64 yet
  236. ;;
  237. *)
  238. make check
  239. ;;
  240. esac
  241. }
  242. clean()
  243. {
  244. cd "$top_srcdir"
  245. case "$platform" in
  246. ios-arm)
  247. cd monsterz/ios
  248. xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
  249. ;;
  250. *)
  251. make distclean
  252. ;;
  253. esac
  254. }
  255. __init__
  256. echo "lol-build: executing action '$action' on platform '$platform'" >&2
  257. eval "$action"