local m = {}

local rootdir = path.join(path.getabsolute(path.getdirectory(_SCRIPT)), "../")
local ogg = require("build-ogg")

function m.generateproject(liboutdir, intdir)
	project"vorbis"
	language"C" -- c++ will mangle names and sfml wont build
	kind"staticLib"
	targetdir (liboutdir)
	objdir(intdir)
	warnings"Off"

	ogg.link()

	includedirs
	{
		path.join(rootdir, "vorbis/include"),
		path.join(rootdir, "vorbis/lib"),
	}

	files
	{
		path.join(rootdir, "vorbis/lib/envelope.h"),
		path.join(rootdir, "vorbis/lib/lpc.h"),
		path.join(rootdir, "vorbis/lib/lsp.h"),
		path.join(rootdir, "vorbis/lib/codebook.h"),
		path.join(rootdir, "vorbis/lib/misc.h"),
		path.join(rootdir, "vorbis/lib/psy.h"),
		path.join(rootdir, "vorbis/lib/masking.h"),
		path.join(rootdir, "vorbis/lib/os.h"),
		path.join(rootdir, "vorbis/lib/mdct.h"),
		path.join(rootdir, "vorbis/lib/smallft.h"),
		path.join(rootdir, "vorbis/lib/highlevel.h"),
		path.join(rootdir, "vorbis/lib/registry.h"),
		path.join(rootdir, "vorbis/lib/scales.h"),
		path.join(rootdir, "vorbis/lib/window.h"),
		path.join(rootdir, "vorbis/lib/lookup.h"),
		path.join(rootdir, "vorbis/lib/lookup_data.h"),
		path.join(rootdir, "vorbis/lib/codec_internal.h"),
		path.join(rootdir, "vorbis/lib/backends.h"),
		path.join(rootdir, "vorbis/lib/bitrate.h"),
		path.join(rootdir, "vorbis/lib/mdct.c"),
		path.join(rootdir, "vorbis/lib/smallft.c"),
		path.join(rootdir, "vorbis/lib/block.c"),
		path.join(rootdir, "vorbis/lib/envelope.c"),
		path.join(rootdir, "vorbis/lib/window.c"),
		path.join(rootdir, "vorbis/lib/lsp.c"),
		path.join(rootdir, "vorbis/lib/lpc.c"),
		path.join(rootdir, "vorbis/lib/analysis.c"),
		path.join(rootdir, "vorbis/lib/synthesis.c"),
		path.join(rootdir, "vorbis/lib/psy.c"),
		path.join(rootdir, "vorbis/lib/info.c"),
		path.join(rootdir, "vorbis/lib/floor1.c"),
		path.join(rootdir, "vorbis/lib/floor0.c"),
		path.join(rootdir, "vorbis/lib/res0.c"),
		path.join(rootdir, "vorbis/lib/mapping0.c"),
		path.join(rootdir, "vorbis/lib/registry.c"),
		path.join(rootdir, "vorbis/lib/codebook.c"),
		path.join(rootdir, "vorbis/lib/sharedbook.c"),
		path.join(rootdir, "vorbis/lib/lookup.c"),
		path.join(rootdir, "vorbis/lib/bitrate.c"),
		path.join(rootdir, "vorbis/lib/vorbisfile.c"),
		path.join(rootdir, "vorbis/lib/vorbisenc.c"),
	}


	filter""
end

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

return m