toolchain.lua 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. --
  2. -- Copyright 2010-2014 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  4. --
  5. local bxDir = (path.getabsolute("..") .. "/")
  6. local naclToolchain = ""
  7. function toolchain(_buildDir, _libDir)
  8. newoption {
  9. trigger = "gcc",
  10. value = "GCC",
  11. description = "Choose GCC flavor",
  12. allowed = {
  13. { "android-arm", "Android - ARM" },
  14. { "android-mips", "Android - MIPS" },
  15. { "android-x86", "Android - x86" },
  16. { "asmjs", "Emscripten/asm.js" },
  17. { "freebsd", "FreeBSD" },
  18. { "linux-gcc", "Linux (GCC compiler)" },
  19. { "linux-clang", "Linux (Clang compiler)" },
  20. { "ios-arm", "iOS - ARM" },
  21. { "ios-simulator", "iOS - Simulator" },
  22. { "mingw-gcc", "MinGW" },
  23. { "mingw-clang", "MinGW (clang compiler)" },
  24. { "nacl", "Native Client" },
  25. { "nacl-arm", "Native Client - ARM" },
  26. { "osx", "OSX" },
  27. { "pnacl", "Native Client - PNaCl" },
  28. { "qnx-arm", "QNX/Blackberry - ARM" },
  29. { "rpi", "RaspberryPi" },
  30. },
  31. }
  32. newoption {
  33. trigger = "vs",
  34. value = "toolset",
  35. description = "Choose VS toolset",
  36. allowed = {
  37. { "vs2012-clang", "Clang 3.6" },
  38. { "vs2013-clang", "Clang 3.6" },
  39. { "winphone8", "Windows Phone 8.0" },
  40. },
  41. }
  42. newoption {
  43. trigger = "with-android",
  44. value = "#",
  45. description = "Set Android platform version (default: android-14).",
  46. }
  47. newoption {
  48. trigger = "with-ios",
  49. value = "#",
  50. description = "Set iOS target version (default: 8.0).",
  51. }
  52. -- Avoid error when invoking genie --help.
  53. if (_ACTION == nil) then return end
  54. location (_buildDir .. "projects/" .. _ACTION)
  55. if _ACTION == "clean" then
  56. os.rmdir(BUILD_DIR)
  57. end
  58. local androidPlatform = "android-14"
  59. if _OPTIONS["with-android"] then
  60. androidPlatform = "android-" .. _OPTIONS["with-android"]
  61. end
  62. local iosPlatform = "8.0"
  63. if _OPTIONS["with-ios"] then
  64. iosPlatform = _OPTIONS["with-ios"]
  65. end
  66. if _ACTION == "gmake" then
  67. if nil == _OPTIONS["gcc"] then
  68. print("GCC flavor must be specified!")
  69. os.exit(1)
  70. end
  71. flags {
  72. "ExtraWarnings",
  73. }
  74. if "android-arm" == _OPTIONS["gcc"] then
  75. if not os.getenv("ANDROID_NDK_ARM") or not os.getenv("ANDROID_NDK_ROOT") then
  76. print("Set ANDROID_NDK_ARM and ANDROID_NDK_ROOT envrionment variables.")
  77. end
  78. premake.gcc.cc = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-gcc"
  79. premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++"
  80. premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
  81. location (_buildDir .. "projects/" .. _ACTION .. "-android-arm")
  82. end
  83. if "android-mips" == _OPTIONS["gcc"] then
  84. if not os.getenv("ANDROID_NDK_MIPS") or not os.getenv("ANDROID_NDK_ROOT") then
  85. print("Set ANDROID_NDK_MIPS and ANDROID_NDK_ROOT envrionment variables.")
  86. end
  87. premake.gcc.cc = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-gcc"
  88. premake.gcc.cxx = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-g++"
  89. premake.gcc.ar = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar"
  90. location (_buildDir .. "projects/" .. _ACTION .. "-android-mips")
  91. end
  92. if "android-x86" == _OPTIONS["gcc"] then
  93. if not os.getenv("ANDROID_NDK_X86") or not os.getenv("ANDROID_NDK_ROOT") then
  94. print("Set ANDROID_NDK_X86 and ANDROID_NDK_ROOT envrionment variables.")
  95. end
  96. premake.gcc.cc = "$(ANDROID_NDK_X86)/bin/i686-linux-android-gcc"
  97. premake.gcc.cxx = "$(ANDROID_NDK_X86)/bin/i686-linux-android-g++"
  98. premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar"
  99. location (_buildDir .. "projects/" .. _ACTION .. "-android-x86")
  100. end
  101. if "asmjs" == _OPTIONS["gcc"] then
  102. if not os.getenv("EMSCRIPTEN") then
  103. print("Set EMSCRIPTEN enviroment variables.")
  104. end
  105. premake.gcc.cc = "$(EMSCRIPTEN)/emcc"
  106. premake.gcc.cxx = "$(EMSCRIPTEN)/em++"
  107. premake.gcc.ar = "ar"
  108. -- premake.gcc.ar = "$(EMSCRIPTEN)/emar"
  109. location (_buildDir .. "projects/" .. _ACTION .. "-asmjs")
  110. end
  111. if "freebsd" == _OPTIONS["gcc"] then
  112. location (_buildDir .. "projects/" .. _ACTION .. "-freebsd")
  113. end
  114. if "ios-arm" == _OPTIONS["gcc"] then
  115. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  116. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  117. premake.gcc.ar = "ar"
  118. location (_buildDir .. "projects/" .. _ACTION .. "-ios-arm")
  119. end
  120. if "ios-simulator" == _OPTIONS["gcc"] then
  121. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  122. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  123. premake.gcc.ar = "ar"
  124. location (_buildDir .. "projects/" .. _ACTION .. "-ios-simulator")
  125. end
  126. if "linux-gcc" == _OPTIONS["gcc"] then
  127. location (_buildDir .. "projects/" .. _ACTION .. "-linux")
  128. end
  129. if "linux-clang" == _OPTIONS["gcc"] then
  130. premake.gcc.cc = "clang"
  131. premake.gcc.cxx = "clang++"
  132. premake.gcc.ar = "ar"
  133. location (_buildDir .. "projects/" .. _ACTION .. "-linux-clang")
  134. end
  135. if "mingw-gcc" == _OPTIONS["gcc"] then
  136. premake.gcc.cc = "$(MINGW)/bin/x86_64-w64-mingw32-gcc"
  137. premake.gcc.cxx = "$(MINGW)/bin/x86_64-w64-mingw32-g++"
  138. premake.gcc.ar = "$(MINGW)/bin/ar"
  139. location (_buildDir .. "projects/" .. _ACTION .. "-mingw-gcc")
  140. end
  141. if "mingw-clang" == _OPTIONS["gcc"] then
  142. premake.gcc.cc = "$(CLANG)/bin/clang"
  143. premake.gcc.cxx = "$(CLANG)/bin/clang++"
  144. premake.gcc.ar = "$(MINGW)/bin/ar"
  145. -- premake.gcc.ar = "$(CLANG)/bin/llvm-ar"
  146. location (_buildDir .. "projects/" .. _ACTION .. "-mingw-clang")
  147. end
  148. if "nacl" == _OPTIONS["gcc"] then
  149. if not os.getenv("NACL_SDK_ROOT") then
  150. print("Set NACL_SDK_ROOT enviroment variables.")
  151. end
  152. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_x86_newlib/bin/x86_64-nacl-"
  153. if os.is("macosx") then
  154. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_x86_newlib/bin/x86_64-nacl-"
  155. elseif os.is("linux") then
  156. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_x86_newlib/bin/x86_64-nacl-"
  157. end
  158. premake.gcc.cc = naclToolchain .. "gcc"
  159. premake.gcc.cxx = naclToolchain .. "g++"
  160. premake.gcc.ar = naclToolchain .. "ar"
  161. location (_buildDir .. "projects/" .. _ACTION .. "-nacl")
  162. end
  163. if "nacl-arm" == _OPTIONS["gcc"] then
  164. if not os.getenv("NACL_SDK_ROOT") then
  165. print("Set NACL_SDK_ROOT enviroment variables.")
  166. end
  167. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_arm_newlib/bin/arm-nacl-"
  168. if os.is("macosx") then
  169. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_arm_newlib/bin/arm-nacl-"
  170. elseif os.is("linux") then
  171. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_arm_newlib/bin/arm-nacl-"
  172. end
  173. premake.gcc.cc = naclToolchain .. "gcc"
  174. premake.gcc.cxx = naclToolchain .. "g++"
  175. premake.gcc.ar = naclToolchain .. "ar"
  176. location (_buildDir .. "projects/" .. _ACTION .. "-nacl-arm")
  177. end
  178. if "osx" == _OPTIONS["gcc"] then
  179. location (_buildDir .. "projects/" .. _ACTION .. "-osx")
  180. end
  181. if "pnacl" == _OPTIONS["gcc"] then
  182. if not os.getenv("NACL_SDK_ROOT") then
  183. print("Set NACL_SDK_ROOT enviroment variables.")
  184. end
  185. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_pnacl/bin/pnacl-"
  186. if os.is("macosx") then
  187. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_pnacl/bin/pnacl-"
  188. elseif os.is("linux") then
  189. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_pnacl/bin/pnacl-"
  190. end
  191. premake.gcc.cc = naclToolchain .. "clang"
  192. premake.gcc.cxx = naclToolchain .. "clang++"
  193. premake.gcc.ar = naclToolchain .. "ar"
  194. location (_buildDir .. "projects/" .. _ACTION .. "-pnacl")
  195. end
  196. if "qnx-arm" == _OPTIONS["gcc"] then
  197. if not os.getenv("QNX_HOST") then
  198. print("Set QNX_HOST enviroment variables.")
  199. end
  200. premake.gcc.cc = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-gcc"
  201. premake.gcc.cxx = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-g++"
  202. premake.gcc.ar = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar"
  203. location (_buildDir .. "projects/" .. _ACTION .. "-qnx-arm")
  204. end
  205. if "rpi" == _OPTIONS["gcc"] then
  206. location (_buildDir .. "projects/" .. _ACTION .. "-rpi")
  207. end
  208. elseif _ACTION == "vs2012" or _ACTION == "vs2013" then
  209. if (_ACTION .. "-clang") == _OPTIONS["vs"] then
  210. premake.vstudio.toolset = ("LLVM-" .. _ACTION)
  211. location (_buildDir .. "projects/" .. _ACTION .. "-clang")
  212. end
  213. if "winphone8" == _OPTIONS["vs"] then
  214. premake.vstudio.toolset = "v110_wp80"
  215. location (_buildDir .. "projects/" .. _ACTION .. "-winphone8")
  216. end
  217. end
  218. flags {
  219. "StaticRuntime",
  220. "NoPCH",
  221. "NativeWChar",
  222. "NoRTTI",
  223. "NoExceptions",
  224. "NoEditAndContinue",
  225. "Symbols",
  226. }
  227. defines {
  228. "__STDC_LIMIT_MACROS",
  229. "__STDC_FORMAT_MACROS",
  230. "__STDC_CONSTANT_MACROS",
  231. }
  232. configuration { "Debug" }
  233. targetsuffix "Debug"
  234. configuration { "Release" }
  235. flags {
  236. "OptimizeSpeed",
  237. }
  238. targetsuffix "Release"
  239. configuration { "vs*", "x86" }
  240. flags {
  241. "EnableSSE2",
  242. }
  243. configuration { "vs*" }
  244. includedirs { bxDir .. "include/compat/msvc" }
  245. defines {
  246. "WIN32",
  247. "_WIN32",
  248. "_HAS_EXCEPTIONS=0",
  249. "_HAS_ITERATOR_DEBUGGING=0",
  250. "_SCL_SECURE=0",
  251. "_SECURE_SCL=0",
  252. "_SCL_SECURE_NO_WARNINGS",
  253. "_CRT_SECURE_NO_WARNINGS",
  254. "_CRT_SECURE_NO_DEPRECATE",
  255. }
  256. buildoptions {
  257. "/Oy-", -- Suppresses creation of frame pointers on the call stack.
  258. "/Ob2", -- The Inline Function Expansion
  259. }
  260. linkoptions {
  261. "/ignore:4221", -- LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
  262. }
  263. configuration { "vs2008" }
  264. includedirs { bxDir .. "include/compat/msvc/pre1600" }
  265. configuration { "x32", "vs*" }
  266. targetdir (_buildDir .. "win32_" .. _ACTION .. "/bin")
  267. objdir (_buildDir .. "win32_" .. _ACTION .. "/obj")
  268. libdirs {
  269. _libDir .. "lib/win32_" .. _ACTION,
  270. "$(DXSDK_DIR)/lib/x86",
  271. }
  272. configuration { "x64", "vs*" }
  273. defines { "_WIN64" }
  274. targetdir (_buildDir .. "win64_" .. _ACTION .. "/bin")
  275. objdir (_buildDir .. "win64_" .. _ACTION .. "/obj")
  276. libdirs {
  277. _libDir .. "lib/win64_" .. _ACTION,
  278. "$(DXSDK_DIR)/lib/x64",
  279. }
  280. configuration { "vs*-clang" }
  281. buildoptions {
  282. "-Qunused-arguments",
  283. }
  284. configuration { "x32", "vs*-clang" }
  285. targetdir (_buildDir .. "win32_" .. _ACTION .. "-clang/bin")
  286. objdir (_buildDir .. "win32_" .. _ACTION .. "-clang/obj")
  287. configuration { "x64", "vs*-clang" }
  288. targetdir (_buildDir .. "win64_" .. _ACTION .. "-clang/bin")
  289. objdir (_buildDir .. "win64_" .. _ACTION .. "-clang/obj")
  290. configuration { "mingw-*" }
  291. defines { "WIN32" }
  292. includedirs { bxDir .. "include/compat/mingw" }
  293. buildoptions {
  294. "-std=c++11",
  295. "-Wunused-value",
  296. "-fdata-sections",
  297. "-ffunction-sections",
  298. "-msse2",
  299. "-Wunused-value",
  300. "-Wundef",
  301. }
  302. linkoptions {
  303. "-Wl,--gc-sections",
  304. }
  305. configuration { "x32", "mingw-gcc" }
  306. targetdir (_buildDir .. "win32_mingw-gcc" .. "/bin")
  307. objdir (_buildDir .. "win32_mingw-gcc" .. "/obj")
  308. libdirs {
  309. _libDir .. "lib/win32_mingw-gcc",
  310. "$(DXSDK_DIR)/lib/x86",
  311. }
  312. buildoptions { "-m32" }
  313. configuration { "x64", "mingw-gcc" }
  314. targetdir (_buildDir .. "win64_mingw-gcc" .. "/bin")
  315. objdir (_buildDir .. "win64_mingw-gcc" .. "/obj")
  316. libdirs {
  317. _libDir .. "lib/win64_mingw-gcc",
  318. "$(DXSDK_DIR)/lib/x64",
  319. "$(GLES_X64_DIR)",
  320. }
  321. buildoptions { "-m64" }
  322. configuration { "mingw-clang" }
  323. buildoptions {
  324. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  325. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  326. "-isystem$(MINGW)/x86_64-w64-mingw32/include",
  327. }
  328. linkoptions {
  329. "-Qunused-arguments",
  330. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  331. }
  332. configuration { "x32", "mingw-clang" }
  333. targetdir (_buildDir .. "win32_mingw-clang" .. "/bin")
  334. objdir (_buildDir .. "win32_mingw-clang" .. "/obj")
  335. libdirs {
  336. _libDir .. "lib/win32_mingw-clang",
  337. "$(DXSDK_DIR)/lib/x86",
  338. }
  339. buildoptions { "-m32" }
  340. configuration { "x64", "mingw-clang" }
  341. targetdir (_buildDir .. "win64_mingw-clang" .. "/bin")
  342. objdir (_buildDir .. "win64_mingw-clang" .. "/obj")
  343. libdirs {
  344. _libDir .. "lib/win64_mingw-clang",
  345. "$(DXSDK_DIR)/lib/x64",
  346. "$(GLES_X64_DIR)",
  347. }
  348. buildoptions { "-m64" }
  349. configuration { "linux-gcc and not linux-clang" }
  350. buildoptions {
  351. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  352. }
  353. configuration { "linux-clang" }
  354. configuration { "linux-*" }
  355. buildoptions {
  356. "-std=c++0x",
  357. "-msse2",
  358. "-Wunused-value",
  359. "-Wundef",
  360. }
  361. links {
  362. "rt",
  363. }
  364. linkoptions {
  365. "-Wl,--gc-sections",
  366. }
  367. configuration { "linux-gcc", "x32" }
  368. targetdir (_buildDir .. "linux32_gcc" .. "/bin")
  369. objdir (_buildDir .. "linux32_gcc" .. "/obj")
  370. libdirs { _libDir .. "lib/linux32_gcc" }
  371. buildoptions {
  372. "-m32",
  373. }
  374. configuration { "linux-gcc", "x64" }
  375. targetdir (_buildDir .. "linux64_gcc" .. "/bin")
  376. objdir (_buildDir .. "linux64_gcc" .. "/obj")
  377. libdirs { _libDir .. "lib/linux64_gcc" }
  378. buildoptions {
  379. "-m64",
  380. }
  381. configuration { "linux-clang", "x32" }
  382. targetdir (_buildDir .. "linux32_clang" .. "/bin")
  383. objdir (_buildDir .. "linux32_clang" .. "/obj")
  384. libdirs { _libDir .. "lib/linux32_clang" }
  385. buildoptions {
  386. "-m32",
  387. }
  388. configuration { "linux-clang", "x64" }
  389. targetdir (_buildDir .. "linux64_clang" .. "/bin")
  390. objdir (_buildDir .. "linux64_clang" .. "/obj")
  391. libdirs { _libDir .. "lib/linux64_clang" }
  392. buildoptions {
  393. "-m64",
  394. }
  395. configuration { "android-*" }
  396. flags {
  397. "NoImportLib",
  398. }
  399. includedirs {
  400. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
  401. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  402. }
  403. linkoptions {
  404. "-nostdlib",
  405. "-static-libgcc",
  406. }
  407. links {
  408. "c",
  409. "dl",
  410. "m",
  411. "android",
  412. "log",
  413. "gnustl_static",
  414. "gcc",
  415. }
  416. buildoptions {
  417. "-fPIC",
  418. "-std=c++0x",
  419. "-no-canonical-prefixes",
  420. "-Wa,--noexecstack",
  421. "-fstack-protector",
  422. "-ffunction-sections",
  423. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  424. "-Wunused-value",
  425. "-Wundef",
  426. }
  427. linkoptions {
  428. "-no-canonical-prefixes",
  429. "-Wl,--no-undefined",
  430. "-Wl,-z,noexecstack",
  431. "-Wl,-z,relro",
  432. "-Wl,-z,now",
  433. }
  434. configuration { "android-arm" }
  435. targetdir (_buildDir .. "android-arm" .. "/bin")
  436. objdir (_buildDir .. "android-arm" .. "/obj")
  437. libdirs {
  438. _libDir .. "lib/android-arm",
  439. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
  440. }
  441. includedirs {
  442. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
  443. }
  444. buildoptions {
  445. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm",
  446. "-mthumb",
  447. "-march=armv7-a",
  448. "-mfloat-abi=softfp",
  449. "-mfpu=neon",
  450. "-Wunused-value",
  451. "-Wundef",
  452. }
  453. linkoptions {
  454. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm",
  455. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtbegin_so.o",
  456. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtend_so.o",
  457. "-march=armv7-a",
  458. "-Wl,--fix-cortex-a8",
  459. }
  460. configuration { "android-mips" }
  461. targetdir (_buildDir .. "android-mips" .. "/bin")
  462. objdir (_buildDir .. "android-mips" .. "/obj")
  463. libdirs {
  464. _libDir .. "lib/android-mips",
  465. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips",
  466. }
  467. includedirs {
  468. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips/include",
  469. }
  470. buildoptions {
  471. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips",
  472. "-Wunused-value",
  473. "-Wundef",
  474. }
  475. linkoptions {
  476. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips",
  477. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtbegin_so.o",
  478. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtend_so.o",
  479. }
  480. configuration { "android-x86" }
  481. targetdir (_buildDir .. "android-x86" .. "/bin")
  482. objdir (_buildDir .. "android-x86" .. "/obj")
  483. libdirs {
  484. _libDir .. "lib/android-x86",
  485. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86",
  486. }
  487. includedirs {
  488. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include",
  489. }
  490. buildoptions {
  491. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86",
  492. "-march=i686",
  493. "-mtune=atom",
  494. "-mstackrealign",
  495. "-msse3",
  496. "-mfpmath=sse",
  497. "-Wunused-value",
  498. "-Wundef",
  499. }
  500. linkoptions {
  501. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86",
  502. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtbegin_so.o",
  503. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtend_so.o",
  504. }
  505. configuration { "asmjs" }
  506. targetdir (_buildDir .. "asmjs" .. "/bin")
  507. objdir (_buildDir .. "asmjs" .. "/obj")
  508. libdirs { _libDir .. "lib/asmjs" }
  509. buildoptions {
  510. "-isystem$(EMSCRIPTEN)/system/include",
  511. "-isystem$(EMSCRIPTEN)/system/include/libc",
  512. "-Wunused-value",
  513. "-Wundef",
  514. }
  515. configuration { "freebsd" }
  516. targetdir (_buildDir .. "freebsd" .. "/bin")
  517. objdir (_buildDir .. "freebsd" .. "/obj")
  518. libdirs { _libDir .. "lib/freebsd" }
  519. includedirs {
  520. bxDir .. "include/compat/freebsd",
  521. }
  522. configuration { "nacl or nacl-arm or pnacl" }
  523. buildoptions {
  524. "-std=c++0x",
  525. "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
  526. "-fno-stack-protector",
  527. "-fdiagnostics-show-option",
  528. "-fdata-sections",
  529. "-ffunction-sections",
  530. "-Wunused-value",
  531. "-Wundef",
  532. }
  533. includedirs {
  534. "$(NACL_SDK_ROOT)/include",
  535. bxDir .. "include/compat/nacl",
  536. }
  537. configuration { "nacl" }
  538. buildoptions {
  539. "-pthread",
  540. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  541. "-msse2",
  542. }
  543. linkoptions {
  544. "-Wl,--gc-sections",
  545. }
  546. configuration { "x32", "nacl" }
  547. targetdir (_buildDir .. "nacl-x86" .. "/bin")
  548. objdir (_buildDir .. "nacl-x86" .. "/obj")
  549. libdirs { _libDir .. "lib/nacl-x86" }
  550. linkoptions { "-melf32_nacl" }
  551. configuration { "x32", "nacl", "Debug" }
  552. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug" }
  553. configuration { "x32", "nacl", "Release" }
  554. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Release" }
  555. configuration { "x64", "nacl" }
  556. targetdir (_buildDir .. "nacl-x64" .. "/bin")
  557. objdir (_buildDir .. "nacl-x64" .. "/obj")
  558. libdirs { _libDir .. "lib/nacl-x64" }
  559. linkoptions { "-melf64_nacl" }
  560. configuration { "x64", "nacl", "Debug" }
  561. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Debug" }
  562. configuration { "x64", "nacl", "Release" }
  563. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Release" }
  564. configuration { "nacl-arm" }
  565. buildoptions {
  566. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  567. }
  568. targetdir (_buildDir .. "nacl-arm" .. "/bin")
  569. objdir (_buildDir .. "nacl-arm" .. "/obj")
  570. libdirs { _libDir .. "lib/nacl-arm" }
  571. configuration { "nacl-arm", "Debug" }
  572. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Debug" }
  573. configuration { "nacl-arm", "Release" }
  574. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Release" }
  575. configuration { "pnacl" }
  576. targetdir (_buildDir .. "pnacl" .. "/bin")
  577. objdir (_buildDir .. "pnacl" .. "/obj")
  578. libdirs { _libDir .. "lib/pnacl" }
  579. configuration { "pnacl", "Debug" }
  580. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  581. configuration { "pnacl", "Release" }
  582. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  583. configuration { "Xbox360" }
  584. targetdir (_buildDir .. "xbox360" .. "/bin")
  585. objdir (_buildDir .. "xbox360" .. "/obj")
  586. includedirs { bxDir .. "include/compat/msvc" }
  587. libdirs { _libDir .. "lib/xbox360" }
  588. defines {
  589. "NOMINMAX",
  590. "_XBOX",
  591. }
  592. configuration { "osx", "x32" }
  593. targetdir (_buildDir .. "osx32_gcc" .. "/bin")
  594. objdir (_buildDir .. "osx32_gcc" .. "/obj")
  595. libdirs { _libDir .. "lib/osx32_gcc" }
  596. buildoptions {
  597. "-m32",
  598. }
  599. configuration { "osx", "x64" }
  600. targetdir (_buildDir .. "osx64_gcc" .. "/bin")
  601. objdir (_buildDir .. "osx64_gcc" .. "/obj")
  602. libdirs { _libDir .. "lib/osx64_gcc" }
  603. buildoptions {
  604. "-m64",
  605. }
  606. configuration { "osx" }
  607. buildoptions {
  608. "-Wfatal-errors",
  609. "-msse2",
  610. "-Wunused-value",
  611. "-Wundef",
  612. }
  613. includedirs { bxDir .. "include/compat/osx" }
  614. configuration { "ios-*" }
  615. linkoptions {
  616. "-lc++",
  617. }
  618. buildoptions {
  619. "-miphoneos-version-min=7.0",
  620. "-Wfatal-errors",
  621. "-Wunused-value",
  622. "-Wundef",
  623. }
  624. includedirs { bxDir .. "include/compat/ios" }
  625. configuration { "ios-arm" }
  626. targetdir (_buildDir .. "ios-arm" .. "/bin")
  627. objdir (_buildDir .. "ios-arm" .. "/obj")
  628. libdirs { _libDir .. "lib/ios-arm" }
  629. linkoptions {
  630. "-arch armv7",
  631. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  632. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  633. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  634. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  635. }
  636. buildoptions {
  637. "-arch armv7",
  638. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  639. }
  640. configuration { "ios-simulator" }
  641. targetdir (_buildDir .. "ios-simulator" .. "/bin")
  642. objdir (_buildDir .. "ios-simulator" .. "/obj")
  643. libdirs { _libDir .. "lib/ios-simulator" }
  644. linkoptions {
  645. "-arch i386",
  646. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  647. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  648. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  649. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  650. }
  651. buildoptions {
  652. "-arch i386",
  653. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  654. }
  655. configuration { "qnx-arm" }
  656. targetdir (_buildDir .. "qnx-arm" .. "/bin")
  657. objdir (_buildDir .. "qnx-arm" .. "/obj")
  658. libdirs { _libDir .. "lib/qnx-arm" }
  659. -- includedirs { bxDir .. "include/compat/qnx" }
  660. buildoptions {
  661. "-std=c++0x",
  662. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  663. "-Wunused-value",
  664. "-Wundef",
  665. }
  666. configuration { "rpi" }
  667. targetdir (_buildDir .. "rpi" .. "/bin")
  668. objdir (_buildDir .. "rpi" .. "/obj")
  669. libdirs {
  670. _libDir .. "lib/rpi",
  671. "/opt/vc/lib",
  672. }
  673. defines {
  674. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  675. "__STDC_VERSION__=199901L",
  676. }
  677. buildoptions {
  678. "-std=c++0x",
  679. "-Wunused-value",
  680. "-Wundef",
  681. }
  682. includedirs {
  683. "/opt/vc/include",
  684. "/opt/vc/include/interface/vcos/pthreads",
  685. "/opt/vc/include/interface/vmcs_host/linux",
  686. }
  687. links {
  688. "rt",
  689. }
  690. linkoptions {
  691. "-Wl,--gc-sections",
  692. }
  693. configuration {} -- reset configuration
  694. end
  695. function strip()
  696. configuration { "android-arm", "Release" }
  697. postbuildcommands {
  698. "$(SILENT) echo Stripping symbols.",
  699. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  700. }
  701. configuration { "android-mips", "Release" }
  702. postbuildcommands {
  703. "$(SILENT) echo Stripping symbols.",
  704. "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  705. }
  706. configuration { "android-x86", "Release" }
  707. postbuildcommands {
  708. "$(SILENT) echo Stripping symbols.",
  709. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  710. }
  711. configuration { "linux-* or rpi", "Release" }
  712. postbuildcommands {
  713. "$(SILENT) echo Stripping symbols.",
  714. "$(SILENT) strip -s \"$(TARGET)\""
  715. }
  716. configuration { "mingw*", "Release" }
  717. postbuildcommands {
  718. "$(SILENT) echo Stripping symbols.",
  719. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  720. }
  721. configuration { "pnacl" }
  722. postbuildcommands {
  723. "$(SILENT) echo Running pnacl-finalize.",
  724. "$(SILENT) " .. naclToolchain .. "finalize \"$(TARGET)\""
  725. }
  726. configuration { "*nacl*", "Release" }
  727. postbuildcommands {
  728. "$(SILENT) echo Stripping symbols.",
  729. "$(SILENT) " .. naclToolchain .. "strip -s \"$(TARGET)\""
  730. }
  731. configuration { "asmjs" }
  732. postbuildcommands {
  733. "$(SILENT) echo Running asmjs finalize.",
  734. "$(SILENT) $(EMSCRIPTEN)/emcc -O2 -s TOTAL_MEMORY=268435456 \"$(TARGET)\" -o \"$(TARGET)\".html"
  735. -- ALLOW_MEMORY_GROWTH
  736. }
  737. configuration {} -- reset configuration
  738. end