Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

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