/*
 * Copyright (c) 2004, Brian Hawkins
 * Permission is granted to use this code without restriction as long
 * as this copyright notice appears in all source files.
 */
 
objExt = ".obj";
exeExt = ".exe";
libExt = ".dll";
libPre = "";
platform = "Windows";

String getCompileCommand(String target, String src, String[] includes)
	{
	ccincs = make.fixPath(includes);
	tFile = new File(target);
	outDir = make.fixPath(tFile.getParent());
	
	ccincs = make.substitute("(.+)", "/I $0", ccincs);
	
	ccflags = "/nologo /c /Zi /W4 /GX /WX /EHsc /GR /Fo"+outDir+"\\ /Fd"+
			target.replaceFirst("(.*\\.)(.*)", "$1pdb")+" ";
	
	if (build.equals("debug"))
		{
		ccflags += "/LDd /MDd /Od /GZ ";
		ccdefs = "/D_DEBUG ";
		}
	else
		{
		ccflags += "/LD /MD /O2 /Gy ";
		ccdefs = "/DNDEBUG ";
		}
	
	return ("cl.exe " + ccflags + ccdefs + make.arrayToString(ccincs) +" "+ src);
	}

	
String getLinkCommand(String target, String[] linkFiles)
	{
	targetpdb = target.replaceFirst("(.*\\.)(.*)", "$1pdb");
	targetlib = target.replaceFirst("(.*\\.)(.*)", "$1lib");
	targetmap = target.replaceFirst("(.*\\.)(.*)", "$1map");
	
	kernel_libs = "kernel32.lib ";
	ldflags = "/nologo /subsystem:console /nodefaultlib /incremental:no "+
		"/mapinfo:exports /mapinfo:fixups /mapinfo:lines /debug /out:"+target+" "+
		"/pdb:"+targetpdb+" /map:"+targetmap+" /machine:i386 ";
		
	if (build.equals("debug"))
		kernel_libs += "msvcrtd.lib msvcprtd.lib ";
	else
		{
		kernel_libs += "msvcrt.lib msvcprt.lib ";
		ldflags += "/opt:ref ";
		}
		
	return ("link.exe " + ldflags + make.fixPath(make.arrayToString(linkFiles)) + kernel_libs);
	}