toolchain.lua 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  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. "-U__STRICT_ANSI__",
  296. "-Wunused-value",
  297. "-fdata-sections",
  298. "-ffunction-sections",
  299. "-msse2",
  300. "-Wunused-value",
  301. "-Wundef",
  302. }
  303. linkoptions {
  304. "-Wl,--gc-sections",
  305. }
  306. configuration { "x32", "mingw-gcc" }
  307. targetdir (_buildDir .. "win32_mingw-gcc" .. "/bin")
  308. objdir (_buildDir .. "win32_mingw-gcc" .. "/obj")
  309. libdirs {
  310. _libDir .. "lib/win32_mingw-gcc",
  311. "$(DXSDK_DIR)/lib/x86",
  312. }
  313. buildoptions { "-m32" }
  314. configuration { "x64", "mingw-gcc" }
  315. targetdir (_buildDir .. "win64_mingw-gcc" .. "/bin")
  316. objdir (_buildDir .. "win64_mingw-gcc" .. "/obj")
  317. libdirs {
  318. _libDir .. "lib/win64_mingw-gcc",
  319. "$(DXSDK_DIR)/lib/x64",
  320. "$(GLES_X64_DIR)",
  321. }
  322. buildoptions { "-m64" }
  323. configuration { "mingw-clang" }
  324. buildoptions {
  325. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  326. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  327. "-isystem$(MINGW)/x86_64-w64-mingw32/include",
  328. }
  329. linkoptions {
  330. "-Qunused-arguments",
  331. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  332. }
  333. configuration { "x32", "mingw-clang" }
  334. targetdir (_buildDir .. "win32_mingw-clang" .. "/bin")
  335. objdir (_buildDir .. "win32_mingw-clang" .. "/obj")
  336. libdirs {
  337. _libDir .. "lib/win32_mingw-clang",
  338. "$(DXSDK_DIR)/lib/x86",
  339. }
  340. buildoptions { "-m32" }
  341. configuration { "x64", "mingw-clang" }
  342. targetdir (_buildDir .. "win64_mingw-clang" .. "/bin")
  343. objdir (_buildDir .. "win64_mingw-clang" .. "/obj")
  344. libdirs {
  345. _libDir .. "lib/win64_mingw-clang",
  346. "$(DXSDK_DIR)/lib/x64",
  347. "$(GLES_X64_DIR)",
  348. }
  349. buildoptions { "-m64" }
  350. configuration { "linux-gcc and not linux-clang" }
  351. buildoptions {
  352. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  353. }
  354. configuration { "linux-clang" }
  355. configuration { "linux-*" }
  356. buildoptions {
  357. "-std=c++0x",
  358. "-msse2",
  359. "-Wunused-value",
  360. "-Wundef",
  361. }
  362. links {
  363. "rt",
  364. }
  365. linkoptions {
  366. "-Wl,--gc-sections",
  367. }
  368. configuration { "linux-gcc", "x32" }
  369. targetdir (_buildDir .. "linux32_gcc" .. "/bin")
  370. objdir (_buildDir .. "linux32_gcc" .. "/obj")
  371. libdirs { _libDir .. "lib/linux32_gcc" }
  372. buildoptions {
  373. "-m32",
  374. }
  375. configuration { "linux-gcc", "x64" }
  376. targetdir (_buildDir .. "linux64_gcc" .. "/bin")
  377. objdir (_buildDir .. "linux64_gcc" .. "/obj")
  378. libdirs { _libDir .. "lib/linux64_gcc" }
  379. buildoptions {
  380. "-m64",
  381. }
  382. configuration { "linux-clang", "x32" }
  383. targetdir (_buildDir .. "linux32_clang" .. "/bin")
  384. objdir (_buildDir .. "linux32_clang" .. "/obj")
  385. libdirs { _libDir .. "lib/linux32_clang" }
  386. buildoptions {
  387. "-m32",
  388. }
  389. configuration { "linux-clang", "x64" }
  390. targetdir (_buildDir .. "linux64_clang" .. "/bin")
  391. objdir (_buildDir .. "linux64_clang" .. "/obj")
  392. libdirs { _libDir .. "lib/linux64_clang" }
  393. buildoptions {
  394. "-m64",
  395. }
  396. configuration { "android-*" }
  397. flags {
  398. "NoImportLib",
  399. }
  400. includedirs {
  401. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
  402. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  403. }
  404. linkoptions {
  405. "-nostdlib",
  406. "-static-libgcc",
  407. }
  408. links {
  409. "c",
  410. "dl",
  411. "m",
  412. "android",
  413. "log",
  414. "gnustl_static",
  415. "gcc",
  416. }
  417. buildoptions {
  418. "-fPIC",
  419. "-std=c++0x",
  420. "-no-canonical-prefixes",
  421. "-Wa,--noexecstack",
  422. "-fstack-protector",
  423. "-ffunction-sections",
  424. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  425. "-Wunused-value",
  426. "-Wundef",
  427. }
  428. linkoptions {
  429. "-no-canonical-prefixes",
  430. "-Wl,--no-undefined",
  431. "-Wl,-z,noexecstack",
  432. "-Wl,-z,relro",
  433. "-Wl,-z,now",
  434. }
  435. configuration { "android-arm" }
  436. targetdir (_buildDir .. "android-arm" .. "/bin")
  437. objdir (_buildDir .. "android-arm" .. "/obj")
  438. libdirs {
  439. _libDir .. "lib/android-arm",
  440. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
  441. }
  442. includedirs {
  443. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
  444. }
  445. buildoptions {
  446. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm",
  447. "-mthumb",
  448. "-march=armv7-a",
  449. "-mfloat-abi=softfp",
  450. "-mfpu=neon",
  451. "-Wunused-value",
  452. "-Wundef",
  453. }
  454. linkoptions {
  455. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm",
  456. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtbegin_so.o",
  457. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtend_so.o",
  458. "-march=armv7-a",
  459. "-Wl,--fix-cortex-a8",
  460. }
  461. configuration { "android-mips" }
  462. targetdir (_buildDir .. "android-mips" .. "/bin")
  463. objdir (_buildDir .. "android-mips" .. "/obj")
  464. libdirs {
  465. _libDir .. "lib/android-mips",
  466. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips",
  467. }
  468. includedirs {
  469. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips/include",
  470. }
  471. buildoptions {
  472. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips",
  473. "-Wunused-value",
  474. "-Wundef",
  475. }
  476. linkoptions {
  477. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips",
  478. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtbegin_so.o",
  479. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtend_so.o",
  480. }
  481. configuration { "android-x86" }
  482. targetdir (_buildDir .. "android-x86" .. "/bin")
  483. objdir (_buildDir .. "android-x86" .. "/obj")
  484. libdirs {
  485. _libDir .. "lib/android-x86",
  486. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86",
  487. }
  488. includedirs {
  489. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include",
  490. }
  491. buildoptions {
  492. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86",
  493. "-march=i686",
  494. "-mtune=atom",
  495. "-mstackrealign",
  496. "-msse3",
  497. "-mfpmath=sse",
  498. "-Wunused-value",
  499. "-Wundef",
  500. }
  501. linkoptions {
  502. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86",
  503. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtbegin_so.o",
  504. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtend_so.o",
  505. }
  506. configuration { "asmjs" }
  507. targetdir (_buildDir .. "asmjs" .. "/bin")
  508. objdir (_buildDir .. "asmjs" .. "/obj")
  509. libdirs { _libDir .. "lib/asmjs" }
  510. buildoptions {
  511. "-isystem$(EMSCRIPTEN)/system/include",
  512. "-isystem$(EMSCRIPTEN)/system/include/libc",
  513. "-Wunused-value",
  514. "-Wundef",
  515. }
  516. configuration { "freebsd" }
  517. targetdir (_buildDir .. "freebsd" .. "/bin")
  518. objdir (_buildDir .. "freebsd" .. "/obj")
  519. libdirs { _libDir .. "lib/freebsd" }
  520. includedirs {
  521. bxDir .. "include/compat/freebsd",
  522. }
  523. configuration { "nacl or nacl-arm or pnacl" }
  524. buildoptions {
  525. "-std=c++0x",
  526. "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
  527. "-fno-stack-protector",
  528. "-fdiagnostics-show-option",
  529. "-fdata-sections",
  530. "-ffunction-sections",
  531. "-Wunused-value",
  532. "-Wundef",
  533. }
  534. includedirs {
  535. "$(NACL_SDK_ROOT)/include",
  536. bxDir .. "include/compat/nacl",
  537. }
  538. configuration { "nacl" }
  539. buildoptions {
  540. "-pthread",
  541. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  542. "-msse2",
  543. }
  544. linkoptions {
  545. "-Wl,--gc-sections",
  546. }
  547. configuration { "x32", "nacl" }
  548. targetdir (_buildDir .. "nacl-x86" .. "/bin")
  549. objdir (_buildDir .. "nacl-x86" .. "/obj")
  550. libdirs { _libDir .. "lib/nacl-x86" }
  551. linkoptions { "-melf32_nacl" }
  552. configuration { "x32", "nacl", "Debug" }
  553. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug" }
  554. configuration { "x32", "nacl", "Release" }
  555. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Release" }
  556. configuration { "x64", "nacl" }
  557. targetdir (_buildDir .. "nacl-x64" .. "/bin")
  558. objdir (_buildDir .. "nacl-x64" .. "/obj")
  559. libdirs { _libDir .. "lib/nacl-x64" }
  560. linkoptions { "-melf64_nacl" }
  561. configuration { "x64", "nacl", "Debug" }
  562. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Debug" }
  563. configuration { "x64", "nacl", "Release" }
  564. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Release" }
  565. configuration { "nacl-arm" }
  566. buildoptions {
  567. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  568. }
  569. targetdir (_buildDir .. "nacl-arm" .. "/bin")
  570. objdir (_buildDir .. "nacl-arm" .. "/obj")
  571. libdirs { _libDir .. "lib/nacl-arm" }
  572. configuration { "nacl-arm", "Debug" }
  573. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Debug" }
  574. configuration { "nacl-arm", "Release" }
  575. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Release" }
  576. configuration { "pnacl" }
  577. targetdir (_buildDir .. "pnacl" .. "/bin")
  578. objdir (_buildDir .. "pnacl" .. "/obj")
  579. libdirs { _libDir .. "lib/pnacl" }
  580. configuration { "pnacl", "Debug" }
  581. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  582. configuration { "pnacl", "Release" }
  583. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  584. configuration { "Xbox360" }
  585. targetdir (_buildDir .. "xbox360" .. "/bin")
  586. objdir (_buildDir .. "xbox360" .. "/obj")
  587. includedirs { bxDir .. "include/compat/msvc" }
  588. libdirs { _libDir .. "lib/xbox360" }
  589. defines {
  590. "NOMINMAX",
  591. "_XBOX",
  592. }
  593. configuration { "osx", "x32" }
  594. targetdir (_buildDir .. "osx32_gcc" .. "/bin")
  595. objdir (_buildDir .. "osx32_gcc" .. "/obj")
  596. libdirs { _libDir .. "lib/osx32_gcc" }
  597. buildoptions {
  598. "-m32",
  599. }
  600. configuration { "osx", "x64" }
  601. targetdir (_buildDir .. "osx64_gcc" .. "/bin")
  602. objdir (_buildDir .. "osx64_gcc" .. "/obj")
  603. libdirs { _libDir .. "lib/osx64_gcc" }
  604. buildoptions {
  605. "-m64",
  606. }
  607. configuration { "osx" }
  608. buildoptions {
  609. "-Wfatal-errors",
  610. "-msse2",
  611. "-Wunused-value",
  612. "-Wundef",
  613. }
  614. includedirs { bxDir .. "include/compat/osx" }
  615. configuration { "ios-*" }
  616. linkoptions {
  617. "-lc++",
  618. }
  619. buildoptions {
  620. "-miphoneos-version-min=7.0",
  621. "-Wfatal-errors",
  622. "-Wunused-value",
  623. "-Wundef",
  624. }
  625. includedirs { bxDir .. "include/compat/ios" }
  626. configuration { "ios-arm" }
  627. targetdir (_buildDir .. "ios-arm" .. "/bin")
  628. objdir (_buildDir .. "ios-arm" .. "/obj")
  629. libdirs { _libDir .. "lib/ios-arm" }
  630. linkoptions {
  631. "-arch armv7",
  632. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  633. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  634. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  635. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  636. }
  637. buildoptions {
  638. "-arch armv7",
  639. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  640. }
  641. configuration { "ios-simulator" }
  642. targetdir (_buildDir .. "ios-simulator" .. "/bin")
  643. objdir (_buildDir .. "ios-simulator" .. "/obj")
  644. libdirs { _libDir .. "lib/ios-simulator" }
  645. linkoptions {
  646. "-arch i386",
  647. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  648. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  649. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  650. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  651. }
  652. buildoptions {
  653. "-arch i386",
  654. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  655. }
  656. configuration { "qnx-arm" }
  657. targetdir (_buildDir .. "qnx-arm" .. "/bin")
  658. objdir (_buildDir .. "qnx-arm" .. "/obj")
  659. libdirs { _libDir .. "lib/qnx-arm" }
  660. -- includedirs { bxDir .. "include/compat/qnx" }
  661. buildoptions {
  662. "-std=c++0x",
  663. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  664. "-Wunused-value",
  665. "-Wundef",
  666. }
  667. configuration { "rpi" }
  668. targetdir (_buildDir .. "rpi" .. "/bin")
  669. objdir (_buildDir .. "rpi" .. "/obj")
  670. libdirs {
  671. _libDir .. "lib/rpi",
  672. "/opt/vc/lib",
  673. }
  674. defines {
  675. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  676. "__STDC_VERSION__=199901L",
  677. }
  678. buildoptions {
  679. "-std=c++0x",
  680. "-Wunused-value",
  681. "-Wundef",
  682. }
  683. includedirs {
  684. "/opt/vc/include",
  685. "/opt/vc/include/interface/vcos/pthreads",
  686. "/opt/vc/include/interface/vmcs_host/linux",
  687. }
  688. links {
  689. "rt",
  690. }
  691. linkoptions {
  692. "-Wl,--gc-sections",
  693. }
  694. configuration {} -- reset configuration
  695. end
  696. function strip()
  697. configuration { "android-arm", "Release" }
  698. postbuildcommands {
  699. "$(SILENT) echo Stripping symbols.",
  700. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  701. }
  702. configuration { "android-mips", "Release" }
  703. postbuildcommands {
  704. "$(SILENT) echo Stripping symbols.",
  705. "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  706. }
  707. configuration { "android-x86", "Release" }
  708. postbuildcommands {
  709. "$(SILENT) echo Stripping symbols.",
  710. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  711. }
  712. configuration { "linux-* or rpi", "Release" }
  713. postbuildcommands {
  714. "$(SILENT) echo Stripping symbols.",
  715. "$(SILENT) strip -s \"$(TARGET)\""
  716. }
  717. configuration { "mingw*", "Release" }
  718. postbuildcommands {
  719. "$(SILENT) echo Stripping symbols.",
  720. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  721. }
  722. configuration { "pnacl" }
  723. postbuildcommands {
  724. "$(SILENT) echo Running pnacl-finalize.",
  725. "$(SILENT) " .. naclToolchain .. "finalize \"$(TARGET)\""
  726. }
  727. configuration { "*nacl*", "Release" }
  728. postbuildcommands {
  729. "$(SILENT) echo Stripping symbols.",
  730. "$(SILENT) " .. naclToolchain .. "strip -s \"$(TARGET)\""
  731. }
  732. configuration { "asmjs" }
  733. postbuildcommands {
  734. "$(SILENT) echo Running asmjs finalize.",
  735. "$(SILENT) $(EMSCRIPTEN)/emcc -O2 -s TOTAL_MEMORY=268435456 \"$(TARGET)\" -o \"$(TARGET)\".html"
  736. -- ALLOW_MEMORY_GROWTH
  737. }
  738. configuration {} -- reset configuration
  739. end