local m = {}

local scriptdir = path.getabsolute(path.getdirectory(_SCRIPT))
local ogg = require("vendor/ogg/build-ogg")
function m.generateproject(liboutdir, intdir)
	project"flac"
	language"C" -- c++ will mangle names and sfml wont build
	kind"staticLib"
	targetdir (liboutdir)
	objdir(intdir)
	warnings"Off"

	ogg.link()

	defines
	{
		"FLAC__NO_DLL",
		"CPU_IS_BIG_ENDIAN=0",
		"FLAC__HAS_OGG=1",
		"PACKAGE_VERSION=\"\"",
	}

	filter"system:linux"
	defines
	{
		"HAVE_LROUND",--fix error in lpc.c <Static declaration of 'lround' follows non-static declaration>
		"HAVE_STDINT_H", --fix error in alloc.h <# error>
	}

	includedirs
	{
		path.join(scriptdir, "include"),
		path.join(scriptdir, "src/libFLAC/include"),
	}

	files
	{
		path.join(scriptdir, "src/libFLAC/**.c"),
	}

	removefiles
	{
		path.join(scriptdir, "src/libFLAC/deduplication/**"),
	}

	filter"system:windows"
	files
	{
		path.join(scriptdir, "src/share/win_utf8_io/**.c"),
	}

	filter""

end

function m.link()
	externalincludedirs
	{
		path.join(scriptdir, "include"),
		path.join(scriptdir, "src/libFLAC/include"),
		path.join(scriptdir, "../ogg/include")
	}
	links {"flac", "ogg"}
end

return m
