toolchain.lua 23 KB

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