toolchain.lua 23 KB

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