Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

10 лет назад
10 лет назад
10 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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/ffmpeg-20141018/lib/i686-w64-mingw32"
  160. LDFLAGS="$LDFLAGS -L$PWD/external/glew-1.9.0/lib/i686-w64-mingw32"
  161. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-2.0.3/lib/i686-w64-mingw32"
  162. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-image-2.0.0/lib/i686-w64-mingw32"
  163. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-2.0.0/lib/i686-w64-mingw32"
  164. LDFLAGS="$LDFLAGS -L$PWD/external/gtk-2.22.1/lib"
  165. LDFLAGS="$LDFLAGS -L$PWD/external/gtk-2.22.1/bin"
  166. LDFLAGS="$LDFLAGS -L$PWD/external/gtkglarea-2.0.1/lib"
  167. LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/i686-w64-mingw32"
  168. ;;
  169. win*-amd64)
  170. if test "x${MSYSTEM}" = xMINGW64; then
  171. :
  172. elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  173. HOSTFLAGS=--host=x86_64-w64-mingw32
  174. BUILDFLAGS=--build=none
  175. else
  176. echo "Error: could not find win64 compiler" >&2
  177. false
  178. fi
  179. if test "x${MSYSTEM}" = xMINGW32; then
  180. # If using mingw32, we're not really cross-compiling
  181. BUILDFLAGS=
  182. fi
  183. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/gtkglarea-2.0.1/lib/pkgconfig"
  184. PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
  185. LDFLAGS="$LDFLAGS -L$PWD/external/ffmpeg-20141018/lib/x86_64-w64-mingw32"
  186. LDFLAGS="$LDFLAGS -L$PWD/external/glew-1.9.0/lib/x86_64-w64-mingw32"
  187. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-2.0.3/lib/x86_64-w64-mingw32"
  188. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-image-2.0.0/lib/x86_64-mingw32"
  189. LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-2.0.0/lib/x86_64-mingw32"
  190. LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
  191. ;;
  192. *-i386)
  193. # Ensure we're _really_ on i386
  194. CXXFLAGS="$CXXFLAGS -m32"
  195. ;;
  196. *-amd64)
  197. # Ensure we're _really_ on amd64
  198. CXXFLAGS="$CXXFLAGS -m64"
  199. ;;
  200. web-*)
  201. # Force cross-compilation because AC_TRY_LINK is going to check
  202. # whether our binaries have the executable bit set.
  203. HOSTFLAGS=--host=none
  204. BUILDFLAGS=--build=`$top_srcdir/.auto/config.guess`
  205. ;;
  206. esac
  207. case "$platform" in
  208. ios-arm)
  209. XCODE="/Applications/Xcode.app/Contents/Developer"
  210. SDKVER="6.1"
  211. DEVROOT="$XCODE/Platforms/iPhoneOS.platform/Developer"
  212. SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
  213. CC="$XCODE/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  214. CXX="$XCODE/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  215. do_configure --host=armv7-apple-darwin10 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" CC="$CC" CXX="$CXX"
  216. ;;
  217. android-arm)
  218. 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"
  219. CFLAGS="$CFLAGS -march=armv5te -mtune=xscale -msoft-float -mthumb"
  220. CXXFLAGS="$CXXFLAGS -march=armv5te -mtune=xscale -msoft-float -mthumb -fno-rtti -fno-exceptions"
  221. LOL_LIBS="$LOL_LIBS -L$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi -lstlport_shared -lm -fpic -XCClinker -shared -u ANativeActivity_onCreate"
  222. 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"
  223. # FIXME: is this needed?
  224. # ant debug
  225. # ant debug install
  226. # ant clean
  227. ;;
  228. raspi-arm)
  229. 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"
  230. ;;
  231. nacl-i386)
  232. 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"
  233. ;;
  234. nacl-amd64)
  235. 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"
  236. ;;
  237. osx-amd64)
  238. # HACK: use clang++ because of a memory leak in llvm-g++.
  239. do_configure CXX=clang++ CC=clang
  240. ;;
  241. ps3-ppu)
  242. PATH="$PATH" do_configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=powerpc
  243. ;;
  244. win*-i386|win*-amd64)
  245. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-2.0.3/include"
  246. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-image-2.0.0/include"
  247. CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-mixer-2.0.0/include"
  248. CPPFLAGS="$CPPFLAGS -I$PWD/external/ffmpeg-20141018/include"
  249. CPPFLAGS="$CPPFLAGS -I$PWD/external/glew-1.9.0/include/GL -DGLEW_STATIC"
  250. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/glib-2.0/include"
  251. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/gtk-2.0/include"
  252. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/glib-2.0"
  253. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gtk-2.0"
  254. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/cairo"
  255. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/pango-1.0"
  256. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gdk-pixbuf-2.0"
  257. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/atk-1.0"
  258. CPPFLAGS="$CPPFLAGS -I$PWD/external/gtkglarea-2.0.1/include"
  259. CPPFLAGS="$CPPFLAGS -mms-bitfields"
  260. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
  261. GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
  262. GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
  263. GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"
  264. CPPFLAGS="$CPPFLAGS -I$PWD/external/libcaca-0.99.beta18/include -DCACA_STATIC"
  265. PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" do_configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
  266. ;;
  267. web-*)
  268. # We use --enable-release otherwise builds are really too slow
  269. 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-}"
  270. ;;
  271. *)
  272. PATH="$PATH" do_configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
  273. ;;
  274. esac
  275. }
  276. build()
  277. {
  278. cd "$top_srcdir"
  279. case "$platform" in
  280. win*-i386)
  281. # Because of locking issues in Wine’s winepath.exe, we only
  282. # build the static libraries in parallel.
  283. make -j$LOL_PARALLEL -C src/bullet
  284. make -j$LOL_PARALLEL -C src/lua
  285. make -j$LOL_PARALLEL -C src/ liblolcore.a
  286. make
  287. ;;
  288. *)
  289. make -j$LOL_PARALLEL
  290. ;;
  291. esac
  292. }
  293. check()
  294. {
  295. cd "$top_srcdir"
  296. case "$platform" in
  297. ios-arm)
  298. ;;
  299. android-arm)
  300. ;;
  301. raspi-arm)
  302. ;;
  303. ps3-ppu)
  304. ;;
  305. nacl-*)
  306. ;;
  307. web-*)
  308. ;;
  309. win*-i386)
  310. # If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
  311. # exists, use it to run the test suite.
  312. if test "x${MSYSTEM}${DISPLAY}" = x \
  313. && xvfb-run --help 2>&1 >/dev/null; then
  314. xvfb-run -a make check VERBOSE=1
  315. else
  316. make check VERBOSE=1
  317. fi
  318. ;;
  319. win*-amd64)
  320. # No support for Wine64 yet
  321. ;;
  322. *)
  323. make check VERBOSE=1
  324. ;;
  325. esac
  326. }
  327. clean()
  328. {
  329. cd "$top_srcdir"
  330. case "$platform" in
  331. *)
  332. make distclean
  333. ;;
  334. esac
  335. }
  336. __init__
  337. echo "lol-build: executing action '$action' on platform '$platform'" >&2
  338. eval "$action"