Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

300 Zeilen
11 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. # Try to count CPU cores. First obvious try: /proc/cpuinfo on Linux
  43. case "$cpu_count" in
  44. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  45. *) if [ -r "/proc/cpuinfo" ]; then
  46. cpu_count="$(grep -c '^processor\>' /proc/cpuinfo 2>/dev/null || true)"
  47. fi ;;
  48. esac
  49. # If that didn't work, try sysctl (for OS X machines)
  50. case "$cpu_count" in
  51. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  52. *) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null || true)" ;;
  53. esac
  54. # Otherwise, CPUInfo.exe (from Xoreax's XGE) may help on Windows
  55. case "$cpu_count" in
  56. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  57. *) cpu_count="$(CPUInfo.exe | sed -ne 's/CPU Cores.* \([0-9][0-9]*\)/\1/p')" ;;
  58. esac
  59. # Otherwise, Windows may define NUMBER_OF_PROCESSORS
  60. case "$cpu_count" in
  61. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  62. *) cpu_count="$NUMBER_OF_PROCESSORS" ;;
  63. esac
  64. # Otherwise, be conservative and assume 1 CPU core
  65. case "$cpu_count" in
  66. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  67. *) cpu_count=1 ;;
  68. esac
  69. # Now decide how many parallel threads to launch
  70. case "$cpu_count" in
  71. 1) LOL_PARALLEL=1 ;;
  72. 2) LOL_PARALLEL=3 ;;
  73. *) LOL_PARALLEL="$(expr $cpu_count '*' 3 / 2)" ;;
  74. esac
  75. case "${MSYSTEM}" in
  76. MINGW32|MINGW64)
  77. PATH="$PATH:./external/gtk-2.22.1/bin"
  78. M4PATH="$M4PATH:./external/gtk-2.22.1/share/aclocal"
  79. ;;
  80. esac
  81. # Ensure we don’t launch weird Windows binaries when cross-compiling
  82. case "${platform}" in
  83. win*)
  84. WINEDLLOVERRIDES="winemenubuilder.exe=d;wineboot.exe=d"
  85. export WINEDLLOVERRIDES
  86. ;;
  87. esac
  88. }
  89. bootstrap()
  90. {
  91. cd "$top_srcdir"
  92. case "$platform" in
  93. ios-arm)
  94. # No bootstrapping needed
  95. ;;
  96. *)
  97. PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
  98. ;;
  99. esac
  100. }
  101. configure()
  102. {
  103. cd "$top_srcdir"
  104. case "$platform" in
  105. android-arm)
  106. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
  107. LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/arm-linux-androideabi -lz"
  108. CPPFLAGS="$CPPFLAGS -I$PWD/external/libcaca-0.99.beta18/include -DCACA_STATIC"
  109. ;;
  110. win*-i386)
  111. if test "x${MSYSTEM}" = xMINGW32; then
  112. :
  113. elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then
  114. HOSTFLAGS=--host=i586-mingw32msvc
  115. BUILDFLAGS=--build=none
  116. elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  117. HOSTFLAGS=--host=i686-w64-mingw32
  118. BUILDFLAGS=--build=none
  119. else
  120. echo "Error: could not find win32 compiler" >&2
  121. false
  122. fi
  123. if test "x${MSYSTEM}" = xMINGW64; then
  124. # If using mingw64, we're not really cross-compiling
  125. BUILDFLAGS=
  126. fi
  127. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/gtkglarea-2.0.1/lib/pkgconfig"
  128. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
  129. LDFLAGS="$LDFLAGS -L$PWD/external/glew-1.9.0/lib/i686-w64-mingw32"
  130. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-1.2.15/lib/i686-w64-mingw32"
  131. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-image-1.2.10/lib/i686-w64-mingw32"
  132. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-1.2.11/lib/i686-w64-mingw32"
  133. LDFLAGS="$LDFLAGS -L$PWD/external/gtk-2.22.1/lib"
  134. LDFLAGS="$LDFLAGS -L$PWD/external/gtk-2.22.1/bin"
  135. LDFLAGS="$LDFLAGS -L$PWD/external/gtkglarea-2.0.1/lib"
  136. LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/i686-w64-mingw32"
  137. ;;
  138. win*-amd64)
  139. if test "x${MSYSTEM}" = xMINGW64; then
  140. :
  141. elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  142. HOSTFLAGS=--host=x86_64-w64-mingw32
  143. BUILDFLAGS=--build=none
  144. else
  145. echo "Error: could not find win64 compiler" >&2
  146. false
  147. fi
  148. if test "x${MSYSTEM}" = xMINGW32; then
  149. # If using mingw32, we're not really cross-compiling
  150. BUILDFLAGS=
  151. fi
  152. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/gtkglarea-2.0.1/lib/pkgconfig"
  153. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
  154. LDFLAGS="$LDFLAGS -L$PWD/external/glew-1.9.0/lib/x86_64-w64-mingw32"
  155. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-1.2.15/lib/x86_64-w64-mingw32"
  156. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-image-1.2.10/lib/x86_64-w64-mingw32"
  157. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-1.2.11/lib/x86_64-w64-mingw32"
  158. LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
  159. ;;
  160. *-i386)
  161. # Ensure we're _really_ on i386
  162. CXXFLAGS="$CXXFLAGS -m32"
  163. ;;
  164. *-amd64)
  165. # Ensure we're _really_ on amd64
  166. CXXFLAGS="$CXXFLAGS -m64"
  167. ;;
  168. esac
  169. case "$platform" in
  170. ios-arm)
  171. # No configuration needed
  172. ;;
  173. android-arm)
  174. CPPFLAGS="$CPPFLAGS -Wno-psabi -I$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport -fpic -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64"
  175. CFLAGS="$CFLAGS -march=armv5te -mtune=xscale -msoft-float -mthumb"
  176. CXXFLAGS="$CXXFLAGS -march=armv5te -mtune=xscale -msoft-float -mthumb -fno-rtti -fno-exceptions"
  177. LOL_LIBS="$LOL_LIBS -L$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi -lstlport_shared -lm -fpic -XCClinker -shared"
  178. PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure --host=arm-linux-androideabi ac_cv_exeext=.so CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" LOL_LIBS="$LOL_LIBS"
  179. # FIXME: is this needed?
  180. # ant debug
  181. # ant debug install
  182. # ant clean
  183. ;;
  184. raspi-arm)
  185. ./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"
  186. ;;
  187. nacl-i386)
  188. ./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"
  189. ;;
  190. nacl-amd64)
  191. ./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"
  192. ;;
  193. ps3-ppu)
  194. PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
  195. ;;
  196. win*-i386|win*-amd64)
  197. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-1.2.15/include"
  198. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-image-1.2.10/include"
  199. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-mixer-1.2.11/include"
  200. CPPFLAGS="$CPPFLAGS -I$PWD/external/glew-1.9.0/include/GL -DGLEW_STATIC"
  201. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/glib-2.0/include"
  202. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/gtk-2.0/include"
  203. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/glib-2.0"
  204. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gtk-2.0"
  205. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/cairo"
  206. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/pango-1.0"
  207. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gdk-pixbuf-2.0"
  208. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/atk-1.0"
  209. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtkglarea-2.0.1/include"
  210. CPPFLAGS="$CPPFLAGS -mms-bitfields"
  211. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
  212. GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
  213. GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
  214. GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
  215. CPPFLAGS="$CPPFLAGS -I$PWD/external/libcaca-0.99.beta18/include -DCACA_STATIC"
  216. PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
  217. ;;
  218. *)
  219. PATH="$PATH" ./configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
  220. ;;
  221. esac
  222. }
  223. build()
  224. {
  225. cd "$top_srcdir"
  226. case "$platform" in
  227. ios-arm)
  228. cd monsterz/ios
  229. xcodebuild -configuration Release -sdk iphonesimulator4.3
  230. ;;
  231. *)
  232. make -j$LOL_PARALLEL
  233. ;;
  234. esac
  235. }
  236. check()
  237. {
  238. cd "$top_srcdir"
  239. case "$platform" in
  240. ios-arm)
  241. ;;
  242. android-arm)
  243. ;;
  244. raspi-arm)
  245. ;;
  246. ps3-ppu)
  247. ;;
  248. nacl-*)
  249. ;;
  250. win*-i386)
  251. # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
  252. # exists, use it to run the test suite.
  253. if test "x${MSYSTEM}${DISPLAY}" = x \
  254. && xvfb-run --help 2>&1 >/dev/null; then
  255. xvfb-run make check
  256. else
  257. make check
  258. fi
  259. ;;
  260. win*-amd64)
  261. # No support for Wine64 yet
  262. ;;
  263. *)
  264. make check
  265. ;;
  266. esac
  267. }
  268. clean()
  269. {
  270. cd "$top_srcdir"
  271. case "$platform" in
  272. ios-arm)
  273. cd monsterz/ios
  274. xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
  275. ;;
  276. *)
  277. make distclean
  278. ;;
  279. esac
  280. }
  281. __init__
  282. echo "lol-build: executing action '$action' on platform '$platform'" >&2
  283. eval "$action"