toolchain.lua 25 KB

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