toolchain.lua 25 KB

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