local m = {}

local rootdir = path.join(path.getabsolute(path.getdirectory(_SCRIPT)), "../")
local ogg = require("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()

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

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

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



	defines
	{
		"FLAC__NO_DLL",
		"CPU_IS_BIG_ENDIAN=0",
		"FLAC__HAS_OGG=1",
		"HAVE_INTTYPES_H",
		"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>
	}

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

	filter""

end

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

return m
