25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

308 satır
12 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. # - emscripten-html
  27. # - emscripten-js
  28. #
  29. set -e
  30. action="$1"
  31. platform="$2"
  32. ###############################################################################
  33. # Initialisation code
  34. #
  35. # - sets the top_srcdir variable
  36. # - sets the LOL_PARALLEL variable
  37. # - fix PATH and MKPATH if necessary
  38. #
  39. __init__()
  40. {
  41. top_srcdir="$(dirname "$0")/.."
  42. cd "$top_srcdir"
  43. top_srcdir="`pwd`"
  44. # Try to count CPU cores. First obvious try: /proc/cpuinfo on Linux
  45. case "$cpu_count" in
  46. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  47. *) if [ -r "/proc/cpuinfo" ]; then
  48. cpu_count="$(grep -c '^processor\>' /proc/cpuinfo 2>/dev/null || true)"
  49. fi ;;
  50. esac
  51. # If that didn't work, try sysctl (for OS X machines)
  52. case "$cpu_count" in
  53. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  54. *) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null || true)" ;;
  55. esac
  56. # Otherwise, CPUInfo.exe (from Xoreax's XGE) may help on Windows
  57. case "$cpu_count" in
  58. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  59. *) cpu_count="$(CPUInfo.exe | sed -ne 's/CPU Cores.* \([0-9][0-9]*\)/\1/p')" ;;
  60. esac
  61. # Otherwise, Windows may define NUMBER_OF_PROCESSORS
  62. case "$cpu_count" in
  63. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  64. *) cpu_count="$NUMBER_OF_PROCESSORS" ;;
  65. esac
  66. # Otherwise, be conservative and assume 1 CPU core
  67. case "$cpu_count" in
  68. [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
  69. *) cpu_count=1 ;;
  70. esac
  71. # Now decide how many parallel threads to launch
  72. case "$cpu_count" in
  73. 1) LOL_PARALLEL=1 ;;
  74. 2) LOL_PARALLEL=3 ;;
  75. *) LOL_PARALLEL="$(expr $cpu_count '*' 3 / 2)" ;;
  76. esac
  77. case "${MSYSTEM}" in
  78. MINGW32|MINGW64)
  79. PATH="$PATH:./external/gtk-2.22.1/bin"
  80. M4PATH="$M4PATH:./external/gtk-2.22.1/share/aclocal"
  81. ;;
  82. esac
  83. # Ensure we don’t launch weird Windows binaries when cross-compiling
  84. WINEDLLOVERRIDES="winemenubuilder.exe,wineboot.exe,explorer.exe,winedbg.exe=d"
  85. export WINEDLLOVERRIDES
  86. LLVM_ADD_VERSION=3.0
  87. export LLVM_ADD_VERSION
  88. # Ensure SDL does not redirect stdout/stderr to local files
  89. SDL_STDIO_REDIRECT=0
  90. export SDL_STDIO_REDIRECT
  91. }
  92. bootstrap()
  93. {
  94. cd "$top_srcdir"
  95. case "$platform" in
  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.12/lib/i686-w64-mingw32"
  132. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-1.2.12/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.12/lib/x86_64-msvc"
  157. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-1.2.12/lib/x86_64-msvc"
  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. XCODE="/Applications/Xcode.app/Contents/Developer"
  172. SDKVER="6.1"
  173. DEVROOT="$XCODE/Platforms/iPhoneOS.platform/Developer"
  174. SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
  175. CC="$XCODE/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  176. CXX="$XCODE/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  177. ./configure --host=armv7-apple-darwin10 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" CC="$CC" CXX="$CXX"
  178. ;;
  179. android-arm)
  180. 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"
  181. CFLAGS="$CFLAGS -march=armv5te -mtune=xscale -msoft-float -mthumb"
  182. CXXFLAGS="$CXXFLAGS -march=armv5te -mtune=xscale -msoft-float -mthumb -fno-rtti -fno-exceptions"
  183. LOL_LIBS="$LOL_LIBS -L$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi -lstlport_shared -lm -fpic -XCClinker -shared -u ANativeActivity_onCreate"
  184. 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"
  185. # FIXME: is this needed?
  186. # ant debug
  187. # ant debug install
  188. # ant clean
  189. ;;
  190. raspi-arm)
  191. ./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"
  192. ;;
  193. nacl-i386)
  194. ./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"
  195. ;;
  196. nacl-amd64)
  197. ./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"
  198. ;;
  199. osx-amd64)
  200. # HACK: use clang++ because of a memory leak in llvm-g++.
  201. ./configure CXX=clang++ CC=clang
  202. ;;
  203. ps3-ppu)
  204. PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
  205. ;;
  206. win*-i386|win*-amd64)
  207. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-1.2.15/include"
  208. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-image-1.2.12/include"
  209. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-mixer-1.2.12/include"
  210. CPPFLAGS="$CPPFLAGS -I$PWD/external/glew-1.9.0/include/GL -DGLEW_STATIC"
  211. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/glib-2.0/include"
  212. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/gtk-2.0/include"
  213. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/glib-2.0"
  214. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gtk-2.0"
  215. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/cairo"
  216. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/pango-1.0"
  217. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gdk-pixbuf-2.0"
  218. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/atk-1.0"
  219. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtkglarea-2.0.1/include"
  220. CPPFLAGS="$CPPFLAGS -mms-bitfields"
  221. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
  222. GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
  223. GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
  224. GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
  225. CPPFLAGS="$CPPFLAGS -I$PWD/external/libcaca-0.99.beta18/include -DCACA_STATIC"
  226. PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" ./configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
  227. ;;
  228. emscripten-*)
  229. EM_HOME=$HOME/emscripten
  230. ./configure CC=$EM_HOME/emcc CXX=$EM_HOME/em++ AR=$EM_HOME/emar RANLIB=$EM_HOME/emranlib PKG_CONFIG=/bin/false SDL_CONFIG=/bin/false ac_cv_exeext=".${platform##emscripten-}"
  231. ;;
  232. *)
  233. PATH="$PATH" ./configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
  234. ;;
  235. esac
  236. }
  237. build()
  238. {
  239. cd "$top_srcdir"
  240. case "$platform" in
  241. *)
  242. make -j$LOL_PARALLEL
  243. ;;
  244. esac
  245. }
  246. check()
  247. {
  248. cd "$top_srcdir"
  249. case "$platform" in
  250. ios-arm)
  251. ;;
  252. android-arm)
  253. ;;
  254. raspi-arm)
  255. ;;
  256. ps3-ppu)
  257. ;;
  258. nacl-*)
  259. ;;
  260. win*-i386)
  261. # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
  262. # exists, use it to run the test suite.
  263. if test "x${MSYSTEM}${DISPLAY}" = x \
  264. && xvfb-run --help 2>&1 >/dev/null; then
  265. xvfb-run -a make check
  266. else
  267. make check
  268. fi
  269. ;;
  270. win*-amd64)
  271. # No support for Wine64 yet
  272. ;;
  273. *)
  274. make check
  275. ;;
  276. esac
  277. }
  278. clean()
  279. {
  280. cd "$top_srcdir"
  281. case "$platform" in
  282. *)
  283. make distclean
  284. ;;
  285. esac
  286. }
  287. __init__
  288. echo "lol-build: executing action '$action' on platform '$platform'" >&2
  289. eval "$action"