local m = {}

local scriptdir = path.getabsolute(path.getdirectory(_SCRIPT))
local ogg = require("vendor/ogg/build-ogg")
local flac = require("vendor/flac/build-flac")
local vorbis = require("vendor/vorbis/build-vorbis")
local freetype = require("vendor/freetype/build-freetype")
function m.generateproject(liboutdir, intdir)
	project"sfml"
	cppdialect"c++17"
	kind "staticLib"
	targetdir (liboutdir)
	objdir(intdir)
	warnings"Off"

	freetype.link()
	ogg.link()
	flac.link()
	vorbis.link()

	defines
	{
		"SFML_STATIC",
		"MA_NO_MP3",
		"MA_NO_FLAC",
		"MA_NO_ENCODING",
		"MA_NO_RESOURCE_MANAGER",
		"MA_NO_GENERATION",
		"MA_USE_STDINT",
		"STBI_FAILURE_USERMSG",
		"SFML_IS_BIG_ENDIAN=0",
		"FT2_BUILD_LIBRARY",
		"FLAC__NO_DLL",
		"OV_EXCLUDE_STATIC_CALLBACKS",
	}

	includedirs
	{
		path.join(scriptdir, "include"),
		path.join(scriptdir, "src"),
		path.join(scriptdir, "extlibs/headers/glad/include"),
		path.join(scriptdir, "extlibs/headers/mingw"),
		path.join(scriptdir, "extlibs/headers/miniaudio"),
		path.join(scriptdir, "extlibs/headers/minimp3"),
		path.join(scriptdir, "extlibs/headers/stb_image"),
		path.join(scriptdir, "extlibs/headers/vulkan"),

	}

	files
	{
		path.join(scriptdir, "include/SFML/**.hpp"),
		path.join(scriptdir, "include/SFML/**.inl"),
		path.join(scriptdir, "src/SFML/**.hpp"),
		path.join(scriptdir, "src/SFML/**.cpp"),
	}

	filter"system:windows"
	removefiles
	{
		path.join(scriptdir, "src/SFML/System/Unix/**"),
		path.join(scriptdir, "src/SFML/Window/Unix/**"),
		path.join(scriptdir, "src/SFML/Network/Unix/**"),
	}

	filter"system:linux"
	removefiles
	{
		path.join(scriptdir, "src/SFML/System/Win32/**"),
		path.join(scriptdir, "src/SFML/Network/Win32/**"),
		path.join(scriptdir, "src/SFML/Window/Win32/**"),
		path.join(scriptdir, "src/SFML/Main/**"),
	}

end

function m.link()
	defines{"SFML_STATIC"}
	externalincludedirs
	{
		path.join(scriptdir, "include"),
		path.join(scriptdir, "src"),
		path.join(scriptdir, "extlibs/headers/glad/include"),
		path.join(scriptdir, "extlibs/headers/mingw"),
		path.join(scriptdir, "extlibs/headers/miniaudio"),
		path.join(scriptdir, "extlibs/headers/minimp3"),
		path.join(scriptdir, "extlibs/headers/stb_image"),
		path.join(scriptdir, "extlibs/headers/vulkan"),
		path.join(scriptdir, "../freetype/include"),
		path.join(scriptdir, "../ogg/include"),
		path.join(scriptdir, "../flac/include"),
		path.join(scriptdir, "../vorbis/include")
	}

	links{"sfml", "freetype", "flac", "vorbis", "ogg"}

	filter"system:windows"
	links{"legacy_stdio_definitions", "opengl32", "gdi32", "winmm", "ws2_32", "openal32"}

	filter"system:linux"
	links{"Xi", "Xrandr", "Xcursor", "X11", "udev", "pthread", "OpenGL", "openal"}

end

return m
