toolchain.lua 24 KB

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