import os

Import("baseEnvironment")

env = baseEnvironment.Clone()

env.Append(CPPPATH = ["src", "../libwendy/src"])
env.Append(LIBPATH = ["../libwendy/lib"])
env.Append(LIBS = ["wendy"])
if env["CC"] == "cl":
	env.Append(CPPFLAGS = ["/Z7", "/W2", "/wd4251", "/EHsc"])
else:
	env.Append(CPPFLAGS = ["-g", "-Wall", "-Werror"])

if os.name == "nt":
	env.Append(CPPPATH = ["$BINARYDEPS/dokan"])
	env.Append(LIBPATH = ["$BINARYDEPS/dokan"])
	env.Append(CPPDEFINES = ["UNICODE", "_UNICODE"])
	env.Append(LIBS = ["psapi", "dokan"])
else:
	env.ParseConfig("pkg-config --cflags --libs fuse")
	env.Append(CPPDEFINES = "FUSE_USE_VERSION=28")

progNode = env.Program("bin/wendyfs", env.Glob("src/*.cpp"))

if os.name == "nt":
	env.Command("bin/wendy.dll", "../libwendy/lib/wendy.dll", Copy("$TARGET", "$SOURCE"))
	env.Command("bin/libcurl.dll", "$BINARYDEPS/curl/lib/libcurl.dll", Copy("$TARGET", "$SOURCE"))
	env.Command("bin/libcJSON.dll", "$BINARYDEPS/cjson/libcJSON.dll", Copy("$TARGET", "$SOURCE"))

distItems = [
	("wendyfs${PROGSUFFIX}", progNode)
]
Return("distItems")

