toolchain.lua 24 KB

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