load arg
load std
autoload=std

fn 9c {
	load arg
	args := $*
	flags=''
	(arg
		I+ {flags = $flags  -I ^ $arg}
		D+ {flags = $flags -$opt ^ $arg}
		'*' {echo unknown option $opt}
		- $args
	)
	cc=cl
	cwd=$emuroot ^ `pwd
	cflags=(-c 
		-nologo
		-W3 
		-Zi
		-Yd
		-MT
		'-D_WIN32_WINNT=0x0400'
		-I$cwd
		-I$emuroot\sys\Nt\386\include
		-I$emuroot\sys\include
		-I$emuroot\sys\libinterp
		-I$emuroot\sys\emu\port
		-I'C:\Program Files\Microsoft Platform SDK\Include'
		-I'C:\Program Files\Microsoft Visual C++ Toolkit 2003\include'
		-Fo$cwd\
		)
	file=$1
	os -d $cwd $cc $cflags $flags $file
}

fn 9l {
	ld=link
	ldflags=(-nologo
		-incremental:no
		-map
		$LDFLAGS
		)
	syslibs=('/libpath:C:\Program Files\Microsoft Platform SDK\lib'
	'/libpath:C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib'
			wsock32.lib 
			user32.lib 
			gdi32.lib 
			advapi32.lib 
			winmm.lib 
			mpr.lib)
	
	cwd=$emuroot ^ `pwd
	file=$1
	file=`{cleanname -d `pwd $file}
	file=`{echo $emuroot ^ $file |sed 's/\//\\/g'}
	args = ${tl $*}
	os -d $cwd $ld $ldflags -out:$file $args $syslibs
}

fn file2root {
	args = $*
	for (i in $args) {
		i = `{cleanname -d `pwd $i}
		echo $emuroot ^ $i |sed 's/\//\\/g'
	}
}

fn 9ar {
	ar=link /lib
	cwd=$emuroot ^ `pwd
	arflags=-nologo
	file=$1
	file=`{cleanname -d `pwd $file}
	file=`{echo $emuroot ^ $file |sed 's/\//\\/g'}
	args = ${tl $*}
	os -d $cwd $ar $arflags -out:$file $args
}

bind /sys/Nt/mkconfig /sys/mkconfig
