toolchain.lua 23 KB

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