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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. #!/bin/sh
  2. #
  3. # Lol Engine build script
  4. # Usage:
  5. # lol-build [<flags>...] <action> [<platform>]
  6. #
  7. # Supported flags:
  8. # --enable-debug
  9. # --enable-devel
  10. # --enable-release
  11. #
  12. # Where <action> is one of:
  13. # - bootstrap
  14. # - configure
  15. # - build
  16. # - check
  17. # - clean
  18. #
  19. # And <platform> is one of:
  20. # - linux-i386
  21. # - linux-amd64
  22. # - nacl-i386
  23. # - nacl-amd64
  24. # - ios-arm
  25. # - osx-amd64
  26. # - android-arm
  27. # - ps3-ppu
  28. # - win*-i386
  29. # - win*-amd64
  30. # - raspi-arm
  31. # - web-html
  32. # - web-js
  33. #
  34. set -e
  35. ###############################################################################
  36. # Commandline parsing
  37. #
  38. action=""
  39. platform=""
  40. configure_flags=""
  41. while [ "$#" -gt 0 ]; do
  42. case "$1" in
  43. --enable-debug|--enable-devel|--enable-release)
  44. configure_flags="${configure_flags} $1"
  45. ;;
  46. --*)
  47. echo "E: invalid flag $1"
  48. exit 1
  49. ;;
  50. *)
  51. if [ -z "$action" ]; then
  52. action="$1"
  53. else
  54. platform="$1"
  55. fi
  56. ;;
  57. esac
  58. shift
  59. done
  60. ###############################################################################
  61. # Initialisation code
  62. #
  63. # - sets the top_srcdir variable
  64. # - sets the LOL_PARALLEL variable
  65. # - fix PATH and MKPATH if necessary
  66. #
  67. __init__()
  68. {
  69. top_srcdir="$(dirname "$0")/.."
  70. cd "$top_srcdir"
  71. top_srcdir="`pwd`"
  72. # Try to count CPU cores. First obvious try: /proc/cpuinfo on Linux
  73. case "$cpu_count" in
  74. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  75. *) if [ -r "/proc/cpuinfo" ]; then
  76. cpu_count="$(grep -c '^processor\>' /proc/cpuinfo 2>/dev/null || true)"
  77. fi ;;
  78. esac
  79. # If that didn't work, try sysctl (for OS X machines)
  80. case "$cpu_count" in
  81. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  82. *) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null || true)" ;;
  83. esac
  84. # Otherwise, CPUInfo.exe (from Xoreax's XGE) may help on Windows
  85. case "$cpu_count" in
  86. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  87. *) cpu_count="$(CPUInfo.exe | sed -ne 's/CPU Cores.* \([0-9][0-9]*\)/\1/p')" ;;
  88. esac
  89. # Otherwise, Windows may define NUMBER_OF_PROCESSORS
  90. case "$cpu_count" in
  91. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  92. *) cpu_count="$NUMBER_OF_PROCESSORS" ;;
  93. esac
  94. # Otherwise, be conservative and assume 1 CPU core
  95. case "$cpu_count" in
  96. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  97. *) cpu_count=1 ;;
  98. esac
  99. # Now decide how many parallel threads to launch
  100. case "$cpu_count" in
  101. 1) LOL_PARALLEL=1 ;;
  102. 2) LOL_PARALLEL=3 ;;
  103. *) LOL_PARALLEL="$(expr $cpu_count '*' 3 / 2)" ;;
  104. esac
  105. case "${MSYSTEM}" in
  106. MINGW32|MINGW64)
  107. PATH="$PATH:./external/gtk-2.22.1/bin"
  108. M4PATH="$M4PATH:./external/gtk-2.22.1/share/aclocal"
  109. ;;
  110. esac
  111. # Ensure we don’t launch weird Windows binaries when cross-compiling
  112. WINEDLLOVERRIDES="winemenubuilder.exe,wineboot.exe,explorer.exe,winedbg.exe=d"
  113. export WINEDLLOVERRIDES
  114. # Ensure SDL does not redirect stdout/stderr to local files
  115. SDL_STDIO_REDIRECT=0
  116. export SDL_STDIO_REDIRECT
  117. }
  118. bootstrap()
  119. {
  120. cd "$top_srcdir"
  121. case "$platform" in
  122. *)
  123. PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
  124. ;;
  125. esac
  126. }
  127. do_configure()
  128. {
  129. ./configure ${configure_flags} "$@"
  130. }
  131. configure()
  132. {
  133. cd "$top_srcdir"
  134. case "$platform" in
  135. android-arm)
  136. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
  137. LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/arm-linux-androideabi -lz"
  138. CPPFLAGS="$CPPFLAGS -I$PWD/external/libcaca-0.99.beta18/include -DCACA_STATIC"
  139. ;;
  140. win*-i386)
  141. if test "x${MSYSTEM}" = xMINGW32; then
  142. :
  143. elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then
  144. HOSTFLAGS=--host=i586-mingw32msvc
  145. BUILDFLAGS=--build=none
  146. elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  147. HOSTFLAGS=--host=i686-w64-mingw32
  148. BUILDFLAGS=--build=none
  149. else
  150. echo "Error: could not find win32 compiler" >&2
  151. false
  152. fi
  153. if test "x${MSYSTEM}" = xMINGW64; then
  154. # If using mingw64, we're not really cross-compiling
  155. BUILDFLAGS=
  156. fi
  157. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/gtkglarea-2.0.1/lib/pkgconfig"
  158. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
  159. LDFLAGS="$LDFLAGS -L$PWD/external/glew-1.9.0/lib/i686-w64-mingw32"
  160. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-2.0.3/lib/i686-w64-mingw32"
  161. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-image-2.0.0/lib/i686-w64-mingw32"
  162. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-2.0.0/lib/i686-w64-mingw32"
  163. LDFLAGS="$LDFLAGS -L$PWD/external/gtk-2.22.1/lib"
  164. LDFLAGS="$LDFLAGS -L$PWD/external/gtk-2.22.1/bin"
  165. LDFLAGS="$LDFLAGS -L$PWD/external/gtkglarea-2.0.1/lib"
  166. LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/i686-w64-mingw32"
  167. ;;
  168. win*-amd64)
  169. if test "x${MSYSTEM}" = xMINGW64; then
  170. :
  171. elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  172. HOSTFLAGS=--host=x86_64-w64-mingw32
  173. BUILDFLAGS=--build=none
  174. else
  175. echo "Error: could not find win64 compiler" >&2
  176. false
  177. fi
  178. if test "x${MSYSTEM}" = xMINGW32; then
  179. # If using mingw32, we're not really cross-compiling
  180. BUILDFLAGS=
  181. fi
  182. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/gtkglarea-2.0.1/lib/pkgconfig"
  183. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
  184. LDFLAGS="$LDFLAGS -L$PWD/external/glew-1.9.0/lib/x86_64-w64-mingw32"
  185. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-2.0.3/lib/x86_64-w64-mingw32"
  186. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-image-2.0.0/lib/x86_64-mingw32"
  187. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-2.0.0/lib/x86_64-mingw32"
  188. LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
  189. ;;
  190. *-i386)
  191. # Ensure we're _really_ on i386
  192. CXXFLAGS="$CXXFLAGS -m32"
  193. ;;
  194. *-amd64)
  195. # Ensure we're _really_ on amd64
  196. CXXFLAGS="$CXXFLAGS -m64"
  197. ;;
  198. web-*)
  199. # Force cross-compilation because AC_TRY_LINK is going to check
  200. # whether our binaries have the executable bit set.
  201. HOSTFLAGS=--host=none
  202. BUILDFLAGS=--build=`$top_srcdir/.auto/config.guess`
  203. ;;
  204. esac
  205. case "$platform" in
  206. ios-arm)
  207. XCODE="/Applications/Xcode.app/Contents/Developer"
  208. SDKVER="6.1"
  209. DEVROOT="$XCODE/Platforms/iPhoneOS.platform/Developer"
  210. SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
  211. CC="$XCODE/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  212. CXX="$XCODE/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  213. do_configure --host=armv7-apple-darwin10 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" CC="$CC" CXX="$CXX"
  214. ;;
  215. android-arm)
  216. CPPFLAGS="$CPPFLAGS -Wno-psabi -I$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport -I$ANDROID_NDK_ROOT/sources/android/native_app_glue -fpic -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64"
  217. CFLAGS="$CFLAGS -march=armv5te -mtune=xscale -msoft-float -mthumb"
  218. CXXFLAGS="$CXXFLAGS -march=armv5te -mtune=xscale -msoft-float -mthumb -fno-rtti -fno-exceptions"
  219. LOL_LIBS="$LOL_LIBS -L$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi -lstlport_shared -lm -fpic -XCClinker -shared -u ANativeActivity_onCreate"
  220. PKG_CONFIG_PATH="$PKG_CONFIG_PATH" do_configure --host=arm-linux-androideabi ac_cv_exeext=.so CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" LOL_LIBS="$LOL_LIBS"
  221. # FIXME: is this needed?
  222. # ant debug
  223. # ant debug install
  224. # ant clean
  225. ;;
  226. raspi-arm)
  227. do_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/firmware/opt/vc/include/interface/vmcs_host/linux -I$RASPI_SDK_ROOT/chroot/usr/include -I$RASPI_SDK_ROOT/chroot/usr/include/arm-linux-gnueabihf" 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"
  228. ;;
  229. nacl-i386)
  230. do_configure CXX=i686-nacl-g++ CC=i686-nacl-gcc ac_cv_exeext=.32.nexe --host=i386 CPPFLAGS="-I$NACL_SDK_ROOT/include" LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp -u _ZN2pp12CreateModuleEv"
  231. ;;
  232. nacl-amd64)
  233. do_configure CXX=x86_64-nacl-g++ CC=x86_64-nacl-gcc ac_cv_exeext=.64.nexe --host=x86_64 CPPFLAGS="-I$NACL_SDK_ROOT/include" LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp -u _ZN2pp12CreateModuleEv"
  234. ;;
  235. osx-amd64)
  236. # HACK: use clang++ because of a memory leak in llvm-g++.
  237. do_configure CXX=clang++ CC=clang
  238. ;;
  239. ps3-ppu)
  240. PATH="$PATH" do_configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
  241. ;;
  242. win*-i386|win*-amd64)
  243. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-2.0.3/include"
  244. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-image-2.0.0/include"
  245. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-mixer-2.0.0/include"
  246. CPPFLAGS="$CPPFLAGS -I$PWD/external/glew-1.9.0/include/GL -DGLEW_STATIC"
  247. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/glib-2.0/include"
  248. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/gtk-2.0/include"
  249. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/glib-2.0"
  250. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gtk-2.0"
  251. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/cairo"
  252. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/pango-1.0"
  253. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gdk-pixbuf-2.0"
  254. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/atk-1.0"
  255. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtkglarea-2.0.1/include"
  256. CPPFLAGS="$CPPFLAGS -mms-bitfields"
  257. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
  258. GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
  259. GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
  260. GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
  261. CPPFLAGS="$CPPFLAGS -I$PWD/external/libcaca-0.99.beta18/include -DCACA_STATIC"
  262. PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" do_configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
  263. ;;
  264. web-*)
  265. # We use --enable-release otherwise builds are really too slow
  266. do_configure --enable-release $HOSTFLAGS $BUILDFLAGS CC=emcc CXX=em++ AR=emar RANLIB=emranlib PKG_CONFIG=/bin/false SDL_CONFIG=/bin/false ac_cv_exeext=".${platform##web-}"
  267. ;;
  268. *)
  269. PATH="$PATH" do_configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
  270. ;;
  271. esac
  272. }
  273. build()
  274. {
  275. cd "$top_srcdir"
  276. case "$platform" in
  277. *)
  278. make -j$LOL_PARALLEL
  279. ;;
  280. esac
  281. }
  282. check()
  283. {
  284. cd "$top_srcdir"
  285. case "$platform" in
  286. ios-arm)
  287. ;;
  288. android-arm)
  289. ;;
  290. raspi-arm)
  291. ;;
  292. ps3-ppu)
  293. ;;
  294. nacl-*)
  295. ;;
  296. web-*)
  297. ;;
  298. win*-i386)
  299. # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
  300. # exists, use it to run the test suite.
  301. if test "x${MSYSTEM}${DISPLAY}" = x \
  302. && xvfb-run --help 2>&1 >/dev/null; then
  303. xvfb-run -a make check VERBOSE=1
  304. else
  305. make check VERBOSE=1
  306. fi
  307. ;;
  308. win*-amd64)
  309. # No support for Wine64 yet
  310. ;;
  311. *)
  312. make check VERBOSE=1
  313. ;;
  314. esac
  315. }
  316. clean()
  317. {
  318. cd "$top_srcdir"
  319. case "$platform" in
  320. *)
  321. make distclean
  322. ;;
  323. esac
  324. }
  325. __init__
  326. echo "lol-build: executing action '$action' on platform '$platform'" >&2
  327. eval "$action"