toolchain.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  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 = "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-gcc" == _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-gcc")
  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. -- premake.gcc.ar = "$(CLANG)/bin/llvm-ar"
  135. location (_buildDir .. "projects/" .. _ACTION .. "-mingw-clang")
  136. end
  137. if "nacl" == _OPTIONS["gcc"] then
  138. if not os.getenv("NACL_SDK_ROOT") then
  139. print("Set NACL_SDK_ROOT enviroment variables.")
  140. end
  141. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_x86_newlib/bin/x86_64-nacl-"
  142. if os.is("macosx") then
  143. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_x86_newlib/bin/x86_64-nacl-"
  144. elseif os.is("linux") then
  145. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_x86_newlib/bin/x86_64-nacl-"
  146. end
  147. premake.gcc.cc = naclToolchain .. "gcc"
  148. premake.gcc.cxx = naclToolchain .. "g++"
  149. premake.gcc.ar = naclToolchain .. "ar"
  150. location (_buildDir .. "projects/" .. _ACTION .. "-nacl")
  151. end
  152. if "nacl-arm" == _OPTIONS["gcc"] then
  153. if not os.getenv("NACL_SDK_ROOT") then
  154. print("Set NACL_SDK_ROOT enviroment variables.")
  155. end
  156. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_arm_newlib/bin/arm-nacl-"
  157. if os.is("macosx") then
  158. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_arm_newlib/bin/arm-nacl-"
  159. elseif os.is("linux") then
  160. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_arm_newlib/bin/arm-nacl-"
  161. end
  162. premake.gcc.cc = naclToolchain .. "gcc"
  163. premake.gcc.cxx = naclToolchain .. "g++"
  164. premake.gcc.ar = naclToolchain .. "ar"
  165. location (_buildDir .. "projects/" .. _ACTION .. "-nacl-arm")
  166. end
  167. if "osx" == _OPTIONS["gcc"] then
  168. location (_buildDir .. "projects/" .. _ACTION .. "-osx")
  169. end
  170. if "pnacl" == _OPTIONS["gcc"] then
  171. if not os.getenv("NACL_SDK_ROOT") then
  172. print("Set NACL_SDK_ROOT enviroment variables.")
  173. end
  174. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_pnacl/bin/pnacl-"
  175. if os.is("macosx") then
  176. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_pnacl/bin/pnacl-"
  177. elseif os.is("linux") then
  178. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_pnacl/bin/pnacl-"
  179. end
  180. premake.gcc.cc = naclToolchain .. "clang"
  181. premake.gcc.cxx = naclToolchain .. "clang++"
  182. premake.gcc.ar = naclToolchain .. "ar"
  183. location (_buildDir .. "projects/" .. _ACTION .. "-pnacl")
  184. end
  185. if "qnx-arm" == _OPTIONS["gcc"] then
  186. if not os.getenv("QNX_HOST") then
  187. print("Set QNX_HOST enviroment variables.")
  188. end
  189. premake.gcc.cc = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-gcc"
  190. premake.gcc.cxx = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-g++"
  191. premake.gcc.ar = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar"
  192. location (_buildDir .. "projects/" .. _ACTION .. "-qnx-arm")
  193. end
  194. if "rpi" == _OPTIONS["gcc"] then
  195. location (_buildDir .. "projects/" .. _ACTION .. "-rpi")
  196. end
  197. end
  198. flags {
  199. "StaticRuntime",
  200. "NoPCH",
  201. "NativeWChar",
  202. "NoRTTI",
  203. "NoExceptions",
  204. "NoEditAndContinue",
  205. "Symbols",
  206. }
  207. defines {
  208. "__STDC_LIMIT_MACROS",
  209. "__STDC_FORMAT_MACROS",
  210. "__STDC_CONSTANT_MACROS",
  211. }
  212. configuration { "Debug" }
  213. targetsuffix "Debug"
  214. configuration { "Release" }
  215. flags {
  216. "OptimizeSpeed",
  217. }
  218. targetsuffix "Release"
  219. configuration { "vs*", "x86" }
  220. flags {
  221. "EnableSSE2",
  222. }
  223. configuration { "vs*" }
  224. includedirs { bxDir .. "include/compat/msvc" }
  225. defines {
  226. "WIN32",
  227. "_WIN32",
  228. "_HAS_EXCEPTIONS=0",
  229. "_HAS_ITERATOR_DEBUGGING=0",
  230. "_SCL_SECURE=0",
  231. "_SECURE_SCL=0",
  232. "_SCL_SECURE_NO_WARNINGS",
  233. "_CRT_SECURE_NO_WARNINGS",
  234. "_CRT_SECURE_NO_DEPRECATE",
  235. }
  236. buildoptions {
  237. "/Oy-", -- Suppresses creation of frame pointers on the call stack.
  238. "/Ob2", -- The Inline Function Expansion
  239. }
  240. linkoptions {
  241. "/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
  242. }
  243. configuration { "vs2008" }
  244. includedirs { bxDir .. "include/compat/msvc/pre1600" }
  245. configuration { "x32", "vs*" }
  246. targetdir (_buildDir .. "win32_" .. _ACTION .. "/bin")
  247. objdir (_buildDir .. "win32_" .. _ACTION .. "/obj")
  248. libdirs {
  249. _libDir .. "lib/win32_" .. _ACTION,
  250. "$(DXSDK_DIR)/lib/x86",
  251. }
  252. configuration { "x64", "vs*" }
  253. defines { "_WIN64" }
  254. targetdir (_buildDir .. "win64_" .. _ACTION .. "/bin")
  255. objdir (_buildDir .. "win64_" .. _ACTION .. "/obj")
  256. libdirs {
  257. _libDir .. "lib/win64_" .. _ACTION,
  258. "$(DXSDK_DIR)/lib/x64",
  259. }
  260. configuration { "mingw-*" }
  261. defines { "WIN32" }
  262. includedirs { bxDir .. "include/compat/mingw" }
  263. buildoptions {
  264. "-std=c++11",
  265. "-U__STRICT_ANSI__",
  266. "-Wunused-value",
  267. "-fdata-sections",
  268. "-ffunction-sections",
  269. "-msse2",
  270. "-Wunused-value",
  271. "-Wundef",
  272. }
  273. linkoptions {
  274. "-Wl,--gc-sections",
  275. }
  276. configuration { "x32", "mingw-gcc" }
  277. targetdir (_buildDir .. "win32_mingw-gcc" .. "/bin")
  278. objdir (_buildDir .. "win32_mingw-gcc" .. "/obj")
  279. libdirs {
  280. _libDir .. "lib/win32_mingw-gcc",
  281. "$(DXSDK_DIR)/lib/x86",
  282. }
  283. buildoptions { "-m32" }
  284. configuration { "x64", "mingw-gcc" }
  285. targetdir (_buildDir .. "win64_mingw-gcc" .. "/bin")
  286. objdir (_buildDir .. "win64_mingw-gcc" .. "/obj")
  287. libdirs {
  288. _libDir .. "lib/win64_mingw-gcc",
  289. "$(DXSDK_DIR)/lib/x64",
  290. "$(GLES_X64_DIR)",
  291. }
  292. buildoptions { "-m64" }
  293. configuration { "mingw-clang" }
  294. buildoptions {
  295. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  296. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  297. "-isystem$(MINGW)/x86_64-w64-mingw32/include",
  298. }
  299. linkoptions {
  300. "-Qunused-arguments",
  301. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  302. }
  303. configuration { "x32", "mingw-clang" }
  304. targetdir (_buildDir .. "win32_mingw-clang" .. "/bin")
  305. objdir (_buildDir .. "win32_mingw-clang" .. "/obj")
  306. libdirs {
  307. _libDir .. "lib/win32_mingw-clang",
  308. "$(DXSDK_DIR)/lib/x86",
  309. }
  310. buildoptions { "-m32" }
  311. configuration { "x64", "mingw-clang" }
  312. targetdir (_buildDir .. "win64_mingw-clang" .. "/bin")
  313. objdir (_buildDir .. "win64_mingw-clang" .. "/obj")
  314. libdirs {
  315. _libDir .. "lib/win64_mingw-clang",
  316. "$(DXSDK_DIR)/lib/x64",
  317. "$(GLES_X64_DIR)",
  318. }
  319. buildoptions { "-m64" }
  320. configuration { "linux-gcc and not linux-clang" }
  321. buildoptions {
  322. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  323. }
  324. configuration { "linux-clang" }
  325. configuration { "linux-*" }
  326. buildoptions {
  327. "-std=c++0x",
  328. "-msse2",
  329. "-Wunused-value",
  330. "-Wundef",
  331. }
  332. links {
  333. "rt",
  334. }
  335. linkoptions {
  336. "-Wl,--gc-sections",
  337. }
  338. configuration { "linux-gcc", "x32" }
  339. targetdir (_buildDir .. "linux32_gcc" .. "/bin")
  340. objdir (_buildDir .. "linux32_gcc" .. "/obj")
  341. libdirs { _libDir .. "lib/linux32_gcc" }
  342. buildoptions {
  343. "-m32",
  344. }
  345. configuration { "linux-gcc", "x64" }
  346. targetdir (_buildDir .. "linux64_gcc" .. "/bin")
  347. objdir (_buildDir .. "linux64_gcc" .. "/obj")
  348. libdirs { _libDir .. "lib/linux64_gcc" }
  349. buildoptions {
  350. "-m64",
  351. }
  352. configuration { "linux-clang", "x32" }
  353. targetdir (_buildDir .. "linux32_clang" .. "/bin")
  354. objdir (_buildDir .. "linux32_clang" .. "/obj")
  355. libdirs { _libDir .. "lib/linux32_clang" }
  356. buildoptions {
  357. "-m32",
  358. }
  359. configuration { "linux-clang", "x64" }
  360. targetdir (_buildDir .. "linux64_clang" .. "/bin")
  361. objdir (_buildDir .. "linux64_clang" .. "/obj")
  362. libdirs { _libDir .. "lib/linux64_clang" }
  363. buildoptions {
  364. "-m64",
  365. }
  366. configuration { "android-*" }
  367. flags {
  368. "NoImportLib",
  369. }
  370. includedirs {
  371. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
  372. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  373. }
  374. linkoptions {
  375. "-nostdlib",
  376. "-static-libgcc",
  377. }
  378. links {
  379. "c",
  380. "dl",
  381. "m",
  382. "android",
  383. "log",
  384. "gnustl_static",
  385. "gcc",
  386. }
  387. buildoptions {
  388. "-fPIC",
  389. "-std=c++0x",
  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. buildoptions {
  499. "-std=c++0x",
  500. "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
  501. "-fno-stack-protector",
  502. "-fdiagnostics-show-option",
  503. "-fdata-sections",
  504. "-ffunction-sections",
  505. "-Wunused-value",
  506. "-Wundef",
  507. }
  508. includedirs {
  509. "$(NACL_SDK_ROOT)/include",
  510. bxDir .. "include/compat/nacl",
  511. }
  512. configuration { "nacl" }
  513. buildoptions {
  514. "-pthread",
  515. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  516. "-msse2",
  517. }
  518. linkoptions {
  519. "-Wl,--gc-sections",
  520. }
  521. configuration { "x32", "nacl" }
  522. targetdir (_buildDir .. "nacl-x86" .. "/bin")
  523. objdir (_buildDir .. "nacl-x86" .. "/obj")
  524. libdirs { _libDir .. "lib/nacl-x86" }
  525. linkoptions { "-melf32_nacl" }
  526. configuration { "x32", "nacl", "Debug" }
  527. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug" }
  528. configuration { "x32", "nacl", "Release" }
  529. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Release" }
  530. configuration { "x64", "nacl" }
  531. targetdir (_buildDir .. "nacl-x64" .. "/bin")
  532. objdir (_buildDir .. "nacl-x64" .. "/obj")
  533. libdirs { _libDir .. "lib/nacl-x64" }
  534. linkoptions { "-melf64_nacl" }
  535. configuration { "x64", "nacl", "Debug" }
  536. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Debug" }
  537. configuration { "x64", "nacl", "Release" }
  538. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Release" }
  539. configuration { "nacl-arm" }
  540. buildoptions {
  541. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  542. }
  543. targetdir (_buildDir .. "nacl-arm" .. "/bin")
  544. objdir (_buildDir .. "nacl-arm" .. "/obj")
  545. libdirs { _libDir .. "lib/nacl-arm" }
  546. configuration { "nacl-arm", "Debug" }
  547. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Debug" }
  548. configuration { "nacl-arm", "Release" }
  549. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Release" }
  550. configuration { "pnacl" }
  551. targetdir (_buildDir .. "pnacl" .. "/bin")
  552. objdir (_buildDir .. "pnacl" .. "/obj")
  553. libdirs { _libDir .. "lib/pnacl" }
  554. configuration { "pnacl", "Debug" }
  555. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  556. configuration { "pnacl", "Release" }
  557. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  558. configuration { "Xbox360" }
  559. targetdir (_buildDir .. "xbox360" .. "/bin")
  560. objdir (_buildDir .. "xbox360" .. "/obj")
  561. includedirs { bxDir .. "include/compat/msvc" }
  562. libdirs { _libDir .. "lib/xbox360" }
  563. defines {
  564. "NOMINMAX",
  565. "_XBOX",
  566. }
  567. configuration { "osx", "x32" }
  568. targetdir (_buildDir .. "osx32_gcc" .. "/bin")
  569. objdir (_buildDir .. "osx32_gcc" .. "/obj")
  570. libdirs { _libDir .. "lib/osx32_gcc" }
  571. buildoptions {
  572. "-m32",
  573. }
  574. configuration { "osx", "x64" }
  575. targetdir (_buildDir .. "osx64_gcc" .. "/bin")
  576. objdir (_buildDir .. "osx64_gcc" .. "/obj")
  577. libdirs { _libDir .. "lib/osx64_gcc" }
  578. buildoptions {
  579. "-m64",
  580. }
  581. configuration { "osx" }
  582. buildoptions {
  583. "-Wfatal-errors",
  584. "-msse2",
  585. "-Wunused-value",
  586. "-Wundef",
  587. }
  588. includedirs { bxDir .. "include/compat/osx" }
  589. configuration { "ios-*" }
  590. linkoptions {
  591. "-lc++",
  592. }
  593. buildoptions {
  594. "-miphoneos-version-min=7.0",
  595. "-Wfatal-errors",
  596. "-Wunused-value",
  597. "-Wundef",
  598. }
  599. includedirs { bxDir .. "include/compat/ios" }
  600. configuration { "ios-arm" }
  601. targetdir (_buildDir .. "ios-arm" .. "/bin")
  602. objdir (_buildDir .. "ios-arm" .. "/obj")
  603. libdirs { _libDir .. "lib/ios-arm" }
  604. linkoptions {
  605. "-arch armv7",
  606. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  607. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  608. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  609. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  610. }
  611. buildoptions {
  612. "-arch armv7",
  613. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  614. }
  615. configuration { "ios-simulator" }
  616. targetdir (_buildDir .. "ios-simulator" .. "/bin")
  617. objdir (_buildDir .. "ios-simulator" .. "/obj")
  618. libdirs { _libDir .. "lib/ios-simulator" }
  619. linkoptions {
  620. "-arch i386",
  621. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  622. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  623. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  624. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  625. }
  626. buildoptions {
  627. "-arch i386",
  628. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  629. }
  630. configuration { "qnx-arm" }
  631. targetdir (_buildDir .. "qnx-arm" .. "/bin")
  632. objdir (_buildDir .. "qnx-arm" .. "/obj")
  633. libdirs { _libDir .. "lib/qnx-arm" }
  634. -- includedirs { bxDir .. "include/compat/qnx" }
  635. buildoptions {
  636. "-std=c++0x",
  637. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  638. "-Wunused-value",
  639. "-Wundef",
  640. }
  641. configuration { "rpi" }
  642. targetdir (_buildDir .. "rpi" .. "/bin")
  643. objdir (_buildDir .. "rpi" .. "/obj")
  644. libdirs {
  645. _libDir .. "lib/rpi",
  646. "/opt/vc/lib",
  647. }
  648. defines {
  649. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  650. "__STDC_VERSION__=199901L",
  651. }
  652. buildoptions {
  653. "-std=c++0x",
  654. "-Wunused-value",
  655. "-Wundef",
  656. }
  657. includedirs {
  658. "/opt/vc/include",
  659. "/opt/vc/include/interface/vcos/pthreads",
  660. "/opt/vc/include/interface/vmcs_host/linux",
  661. }
  662. links {
  663. "rt",
  664. }
  665. linkoptions {
  666. "-Wl,--gc-sections",
  667. }
  668. configuration {} -- reset configuration
  669. end
  670. function strip()
  671. configuration { "android-arm", "Release" }
  672. postbuildcommands {
  673. "@echo Stripping symbols.",
  674. "@$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  675. }
  676. configuration { "android-mips", "Release" }
  677. postbuildcommands {
  678. "@echo Stripping symbols.",
  679. "@$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  680. }
  681. configuration { "android-x86", "Release" }
  682. postbuildcommands {
  683. "@echo Stripping symbols.",
  684. "@$(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  685. }
  686. configuration { "linux-* or rpi", "Release" }
  687. postbuildcommands {
  688. "@echo Stripping symbols.",
  689. "@strip -s \"$(TARGET)\""
  690. }
  691. configuration { "mingw*", "Release" }
  692. postbuildcommands {
  693. "@echo Stripping symbols.",
  694. "@$(MINGW)/bin/strip -s \"$(TARGET)\""
  695. }
  696. configuration { "pnacl" }
  697. postbuildcommands {
  698. "@echo Running pnacl-finalize.",
  699. "@" .. naclToolchain .. "finalize \"$(TARGET)\""
  700. }
  701. configuration { "*nacl*", "Release" }
  702. postbuildcommands {
  703. "@echo Stripping symbols.",
  704. "@" .. naclToolchain .. "strip -s \"$(TARGET)\""
  705. }
  706. configuration { "asmjs" }
  707. postbuildcommands {
  708. "@echo Running asmjs finalize.",
  709. "@$(EMSCRIPTEN)/emcc -O2 -s TOTAL_MEMORY=268435456 \"$(TARGET)\" -o \"$(TARGET)\".html"
  710. -- ALLOW_MEMORY_GROWTH
  711. }
  712. configuration {} -- reset configuration
  713. end