toolchain.lua 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  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. "NoPCH",
  193. "NativeWChar",
  194. "NoRTTI",
  195. "NoExceptions",
  196. "NoEditAndContinue",
  197. "Symbols",
  198. }
  199. defines {
  200. "__STDC_LIMIT_MACROS",
  201. "__STDC_FORMAT_MACROS",
  202. "__STDC_CONSTANT_MACROS",
  203. }
  204. configuration { "Debug" }
  205. targetsuffix "Debug"
  206. configuration { "Release" }
  207. flags {
  208. "OptimizeSpeed",
  209. }
  210. targetsuffix "Release"
  211. configuration { "vs*" }
  212. flags {
  213. "EnableSSE2",
  214. }
  215. includedirs { bxDir .. "include/compat/msvc" }
  216. defines {
  217. "WIN32",
  218. "_WIN32",
  219. "_HAS_EXCEPTIONS=0",
  220. "_HAS_ITERATOR_DEBUGGING=0",
  221. "_SCL_SECURE=0",
  222. "_SECURE_SCL=0",
  223. "_SCL_SECURE_NO_WARNINGS",
  224. "_CRT_SECURE_NO_WARNINGS",
  225. "_CRT_SECURE_NO_DEPRECATE",
  226. }
  227. buildoptions {
  228. "/Oy-", -- Suppresses creation of frame pointers on the call stack.
  229. "/Ob2", -- The Inline Function Expansion
  230. }
  231. linkoptions {
  232. "/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
  233. }
  234. configuration { "vs2008" }
  235. includedirs { bxDir .. "include/compat/msvc/pre1600" }
  236. configuration { "x32", "vs*" }
  237. targetdir (_buildDir .. "win32_" .. _ACTION .. "/bin")
  238. objdir (_buildDir .. "win32_" .. _ACTION .. "/obj")
  239. libdirs {
  240. _libDir .. "lib/win32_" .. _ACTION,
  241. "$(DXSDK_DIR)/lib/x86",
  242. }
  243. configuration { "x64", "vs*" }
  244. defines { "_WIN64" }
  245. targetdir (_buildDir .. "win64_" .. _ACTION .. "/bin")
  246. objdir (_buildDir .. "win64_" .. _ACTION .. "/obj")
  247. libdirs {
  248. _libDir .. "lib/win64_" .. _ACTION,
  249. "$(DXSDK_DIR)/lib/x64",
  250. }
  251. configuration { "mingw" }
  252. defines { "WIN32" }
  253. includedirs { bxDir .. "include/compat/mingw" }
  254. buildoptions {
  255. "-std=c++11",
  256. "-U__STRICT_ANSI__",
  257. "-Wunused-value",
  258. "-fdata-sections",
  259. "-ffunction-sections",
  260. "-msse2",
  261. "-Wunused-value",
  262. "-Wundef",
  263. }
  264. linkoptions {
  265. "-Wl,--gc-sections",
  266. }
  267. configuration { "x32", "mingw" }
  268. targetdir (_buildDir .. "win32_mingw" .. "/bin")
  269. objdir (_buildDir .. "win32_mingw" .. "/obj")
  270. libdirs {
  271. _libDir .. "lib/win32_mingw",
  272. "$(DXSDK_DIR)/lib/x86",
  273. }
  274. buildoptions { "-m32" }
  275. configuration { "x64", "mingw" }
  276. targetdir (_buildDir .. "win64_mingw" .. "/bin")
  277. objdir (_buildDir .. "win64_mingw" .. "/obj")
  278. libdirs {
  279. _libDir .. "lib/win64_mingw",
  280. "$(DXSDK_DIR)/lib/x64",
  281. "$(GLES_X64_DIR)",
  282. }
  283. buildoptions { "-m64" }
  284. configuration { "linux-gcc and not linux-clang" }
  285. buildoptions {
  286. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  287. }
  288. configuration { "linux-clang" }
  289. buildoptions {
  290. "--analyze",
  291. }
  292. configuration { "linux-*" }
  293. buildoptions {
  294. "-std=c++0x",
  295. "-U__STRICT_ANSI__",
  296. "-msse2",
  297. "-Wunused-value",
  298. "-Wundef",
  299. }
  300. links {
  301. "rt",
  302. }
  303. linkoptions {
  304. "-Wl,--gc-sections",
  305. }
  306. configuration { "linux-gcc", "x32" }
  307. targetdir (_buildDir .. "linux32_gcc" .. "/bin")
  308. objdir (_buildDir .. "linux32_gcc" .. "/obj")
  309. libdirs { _libDir .. "lib/linux32_gcc" }
  310. buildoptions {
  311. "-m32",
  312. }
  313. configuration { "linux-gcc", "x64" }
  314. targetdir (_buildDir .. "linux64_gcc" .. "/bin")
  315. objdir (_buildDir .. "linux64_gcc" .. "/obj")
  316. libdirs { _libDir .. "lib/linux64_gcc" }
  317. buildoptions {
  318. "-m64",
  319. }
  320. configuration { "linux-clang", "x32" }
  321. targetdir (_buildDir .. "linux32_clang" .. "/bin")
  322. objdir (_buildDir .. "linux32_clang" .. "/obj")
  323. libdirs { _libDir .. "lib/linux32_clang" }
  324. buildoptions {
  325. "-m32",
  326. }
  327. configuration { "linux-clang", "x64" }
  328. targetdir (_buildDir .. "linux64_clang" .. "/bin")
  329. objdir (_buildDir .. "linux64_clang" .. "/obj")
  330. libdirs { _libDir .. "lib/linux64_clang" }
  331. buildoptions {
  332. "-m64",
  333. }
  334. configuration { "android-*" }
  335. flags {
  336. "NoImportLib",
  337. }
  338. includedirs {
  339. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
  340. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  341. }
  342. linkoptions {
  343. "-nostdlib",
  344. "-static-libgcc",
  345. }
  346. links {
  347. "c",
  348. "dl",
  349. "m",
  350. "android",
  351. "log",
  352. "gnustl_static",
  353. "gcc",
  354. }
  355. buildoptions {
  356. "-fPIC",
  357. "-std=c++0x",
  358. "-U__STRICT_ANSI__",
  359. "-no-canonical-prefixes",
  360. "-Wa,--noexecstack",
  361. "-fstack-protector",
  362. "-ffunction-sections",
  363. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  364. "-Wunused-value",
  365. "-Wundef",
  366. }
  367. linkoptions {
  368. "-no-canonical-prefixes",
  369. "-Wl,--no-undefined",
  370. "-Wl,-z,noexecstack",
  371. "-Wl,-z,relro",
  372. "-Wl,-z,now",
  373. }
  374. configuration { "android-arm" }
  375. targetdir (_buildDir .. "android-arm" .. "/bin")
  376. objdir (_buildDir .. "android-arm" .. "/obj")
  377. libdirs {
  378. _libDir .. "lib/android-arm",
  379. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
  380. }
  381. includedirs {
  382. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
  383. }
  384. buildoptions {
  385. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm",
  386. "-mthumb",
  387. "-march=armv7-a",
  388. "-mfloat-abi=softfp",
  389. "-mfpu=neon",
  390. "-Wunused-value",
  391. "-Wundef",
  392. }
  393. linkoptions {
  394. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm",
  395. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtbegin_so.o",
  396. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtend_so.o",
  397. "-march=armv7-a",
  398. "-Wl,--fix-cortex-a8",
  399. }
  400. configuration { "android-mips" }
  401. targetdir (_buildDir .. "android-mips" .. "/bin")
  402. objdir (_buildDir .. "android-mips" .. "/obj")
  403. libdirs {
  404. _libDir .. "lib/android-mips",
  405. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips",
  406. }
  407. includedirs {
  408. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips/include",
  409. }
  410. buildoptions {
  411. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips",
  412. "-Wunused-value",
  413. "-Wundef",
  414. }
  415. linkoptions {
  416. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips",
  417. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtbegin_so.o",
  418. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtend_so.o",
  419. }
  420. configuration { "android-x86" }
  421. targetdir (_buildDir .. "android-x86" .. "/bin")
  422. objdir (_buildDir .. "android-x86" .. "/obj")
  423. libdirs {
  424. _libDir .. "lib/android-x86",
  425. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86",
  426. }
  427. includedirs {
  428. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include",
  429. }
  430. buildoptions {
  431. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86",
  432. "-march=i686",
  433. "-mtune=atom",
  434. "-mstackrealign",
  435. "-msse3",
  436. "-mfpmath=sse",
  437. "-Wunused-value",
  438. "-Wundef",
  439. }
  440. linkoptions {
  441. "--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86",
  442. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtbegin_so.o",
  443. "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtend_so.o",
  444. }
  445. configuration { "asmjs" }
  446. targetdir (_buildDir .. "asmjs" .. "/bin")
  447. objdir (_buildDir .. "asmjs" .. "/obj")
  448. libdirs { _libDir .. "lib/asmjs" }
  449. includedirs {
  450. "$(EMSCRIPTEN)/system/include",
  451. "$(EMSCRIPTEN)/system/include/libc",
  452. }
  453. buildoptions {
  454. "-Wno-unknown-warning-option", -- Linux Emscripten doesn't know about no-warn-absolute-paths...
  455. "-Wno-warn-absolute-paths",
  456. "-Wunused-value",
  457. "-Wundef",
  458. }
  459. configuration { "freebsd" }
  460. targetdir (_buildDir .. "freebsd" .. "/bin")
  461. objdir (_buildDir .. "freebsd" .. "/obj")
  462. libdirs { _libDir .. "lib/freebsd" }
  463. includedirs {
  464. bxDir .. "include/compat/freebsd",
  465. }
  466. configuration { "nacl or nacl-arm or pnacl" }
  467. includedirs {
  468. "$(NACL_SDK_ROOT)/include",
  469. bxDir .. "include/compat/nacl",
  470. }
  471. configuration { "nacl" }
  472. buildoptions {
  473. "-std=c++0x",
  474. "-U__STRICT_ANSI__",
  475. "-pthread",
  476. "-fno-stack-protector",
  477. "-fdiagnostics-show-option",
  478. "-fdata-sections",
  479. "-ffunction-sections",
  480. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  481. "-msse2",
  482. "-Wunused-value",
  483. "-Wundef",
  484. }
  485. linkoptions {
  486. "-Wl,--gc-sections",
  487. }
  488. configuration { "x32", "nacl" }
  489. targetdir (_buildDir .. "nacl-x86" .. "/bin")
  490. objdir (_buildDir .. "nacl-x86" .. "/obj")
  491. libdirs { _libDir .. "lib/nacl-x86" }
  492. linkoptions { "-melf32_nacl" }
  493. configuration { "x32", "nacl", "Debug" }
  494. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug" }
  495. configuration { "x32", "nacl", "Release" }
  496. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Release" }
  497. configuration { "x64", "nacl" }
  498. targetdir (_buildDir .. "nacl-x64" .. "/bin")
  499. objdir (_buildDir .. "nacl-x64" .. "/obj")
  500. libdirs { _libDir .. "lib/nacl-x64" }
  501. linkoptions { "-melf64_nacl" }
  502. configuration { "x64", "nacl", "Debug" }
  503. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Debug" }
  504. configuration { "x64", "nacl", "Release" }
  505. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Release" }
  506. configuration { "nacl-arm" }
  507. buildoptions {
  508. "-std=c++0x",
  509. "-U__STRICT_ANSI__",
  510. "-fno-stack-protector",
  511. "-fdiagnostics-show-option",
  512. "-fdata-sections",
  513. "-ffunction-sections",
  514. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  515. "-Wunused-value",
  516. "-Wundef",
  517. }
  518. targetdir (_buildDir .. "nacl-arm" .. "/bin")
  519. objdir (_buildDir .. "nacl-arm" .. "/obj")
  520. libdirs { _libDir .. "lib/nacl-arm" }
  521. configuration { "nacl-arm", "Debug" }
  522. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Debug" }
  523. configuration { "nacl-arm", "Release" }
  524. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Release" }
  525. configuration { "pnacl" }
  526. buildoptions {
  527. "-std=c++0x",
  528. "-U__STRICT_ANSI__",
  529. "-fno-stack-protector",
  530. "-fdiagnostics-show-option",
  531. "-fdata-sections",
  532. "-ffunction-sections",
  533. "-Wunused-value",
  534. "-Wundef",
  535. }
  536. targetdir (_buildDir .. "pnacl" .. "/bin")
  537. objdir (_buildDir .. "pnacl" .. "/obj")
  538. libdirs { _libDir .. "lib/pnacl" }
  539. configuration { "pnacl", "Debug" }
  540. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  541. configuration { "pnacl", "Release" }
  542. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  543. configuration { "Xbox360" }
  544. targetdir (_buildDir .. "xbox360" .. "/bin")
  545. objdir (_buildDir .. "xbox360" .. "/obj")
  546. includedirs { bxDir .. "include/compat/msvc" }
  547. libdirs { _libDir .. "lib/xbox360" }
  548. defines {
  549. "NOMINMAX",
  550. "_XBOX",
  551. }
  552. configuration { "osx", "x32" }
  553. targetdir (_buildDir .. "osx32_gcc" .. "/bin")
  554. objdir (_buildDir .. "osx32_gcc" .. "/obj")
  555. libdirs { _libDir .. "lib/osx32_gcc" }
  556. buildoptions {
  557. "-m32",
  558. }
  559. configuration { "osx", "x64" }
  560. targetdir (_buildDir .. "osx64_gcc" .. "/bin")
  561. objdir (_buildDir .. "osx64_gcc" .. "/obj")
  562. libdirs { _libDir .. "lib/osx64_gcc" }
  563. buildoptions {
  564. "-m64",
  565. }
  566. configuration { "osx" }
  567. buildoptions {
  568. "-U__STRICT_ANSI__",
  569. "-Wfatal-errors",
  570. "-msse2",
  571. "-Wunused-value",
  572. "-Wundef",
  573. }
  574. includedirs { bxDir .. "include/compat/osx" }
  575. configuration { "ios-*" }
  576. linkoptions {
  577. "-lc++",
  578. }
  579. buildoptions {
  580. "-miphoneos-version-min=7.0",
  581. "-U__STRICT_ANSI__",
  582. "-Wfatal-errors",
  583. "-Wunused-value",
  584. "-Wundef",
  585. }
  586. includedirs { bxDir .. "include/compat/ios" }
  587. configuration { "ios-arm" }
  588. targetdir (_buildDir .. "ios-arm" .. "/bin")
  589. objdir (_buildDir .. "ios-arm" .. "/obj")
  590. libdirs { _libDir .. "lib/ios-arm" }
  591. linkoptions {
  592. "-arch armv7",
  593. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  594. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  595. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  596. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  597. }
  598. buildoptions {
  599. "-arch armv7",
  600. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  601. }
  602. configuration { "ios-simulator" }
  603. targetdir (_buildDir .. "ios-simulator" .. "/bin")
  604. objdir (_buildDir .. "ios-simulator" .. "/obj")
  605. libdirs { _libDir .. "lib/ios-simulator" }
  606. linkoptions {
  607. "-arch i386",
  608. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  609. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  610. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  611. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  612. }
  613. buildoptions {
  614. "-arch i386",
  615. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  616. }
  617. configuration { "qnx-arm" }
  618. targetdir (_buildDir .. "qnx-arm" .. "/bin")
  619. objdir (_buildDir .. "qnx-arm" .. "/obj")
  620. libdirs { _libDir .. "lib/qnx-arm" }
  621. -- includedirs { bxDir .. "include/compat/qnx" }
  622. buildoptions {
  623. "-std=c++0x",
  624. "-U__STRICT_ANSI__",
  625. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  626. "-Wunused-value",
  627. "-Wundef",
  628. }
  629. configuration { "rpi" }
  630. targetdir (_buildDir .. "rpi" .. "/bin")
  631. objdir (_buildDir .. "rpi" .. "/obj")
  632. libdirs {
  633. _libDir .. "lib/rpi",
  634. "/opt/vc/lib",
  635. }
  636. defines {
  637. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  638. "__STDC_VERSION__=199901L",
  639. }
  640. buildoptions {
  641. "-std=c++0x",
  642. "-U__STRICT_ANSI__",
  643. "-Wunused-value",
  644. "-Wundef",
  645. }
  646. includedirs {
  647. "/opt/vc/include",
  648. "/opt/vc/include/interface/vcos/pthreads",
  649. "/opt/vc/include/interface/vmcs_host/linux",
  650. }
  651. links {
  652. "rt",
  653. }
  654. linkoptions {
  655. "-Wl,--gc-sections",
  656. }
  657. configuration {} -- reset configuration
  658. end
  659. function strip()
  660. configuration { "android-arm", "Release" }
  661. postbuildcommands {
  662. "@echo Stripping symbols.",
  663. "@$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  664. }
  665. configuration { "android-mips", "Release" }
  666. postbuildcommands {
  667. "@echo Stripping symbols.",
  668. "@$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  669. }
  670. configuration { "android-x86", "Release" }
  671. postbuildcommands {
  672. "@echo Stripping symbols.",
  673. "@$(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  674. }
  675. configuration { "linux-* or rpi", "Release" }
  676. postbuildcommands {
  677. "@echo Stripping symbols.",
  678. "@strip -s \"$(TARGET)\""
  679. }
  680. configuration { "mingw", "Release" }
  681. postbuildcommands {
  682. "@echo Stripping symbols.",
  683. "@$(MINGW)/bin/strip -s \"$(TARGET)\""
  684. }
  685. configuration { "pnacl" }
  686. postbuildcommands {
  687. "@echo Running pnacl-finalize.",
  688. "@" .. naclToolchain .. "finalize \"$(TARGET)\""
  689. }
  690. configuration { "*nacl*", "Release" }
  691. postbuildcommands {
  692. "@echo Stripping symbols.",
  693. "@" .. naclToolchain .. "strip -s \"$(TARGET)\""
  694. }
  695. configuration { "asmjs" }
  696. postbuildcommands {
  697. "@echo Running asmjs finalize.",
  698. "@$(EMSCRIPTEN)/emcc -O2 -s TOTAL_MEMORY=268435456 \"$(TARGET)\" -o \"$(TARGET)\".html"
  699. -- ALLOW_MEMORY_GROWTH
  700. }
  701. configuration {} -- reset configuration
  702. end