KILIB=/u/ksos/ksos32/kernel_interface/lib

test.out: test.ld.sh test.gfo
	@sh -v test.ld.sh
	size $@

test.gfo: test.gfs2
	as -o $@ test.gfs2

test.gfs2: test.gfs fix.test.gfs.ed
	cp test.gfs $@
	ed - $@ < fix.test.gfs.ed

test.ld.sh test.gfs: .lnk/test $(KILIB)/.lnk/KernelCalls \
  $(KILIB)/.lnk/userFdt $(KILIB)/.lnk/K32except $(KILIB)/.lnk/K32baseTypes \
  $(KILIB)/.lnk/K32machine $(KILIB)/.lnk/K32types m2path
	m2l -c -S -E -L -X -n test\
	  | sed -e 's/^/ld /'\
		-e 's= \./= =g'\
		-e 's/ -lc//' > test.ld.sh
# The preceding invocation of sed prepends the "ld" command, removes
# superfluous "./" pathname components, and prevents loading the C library.

.lnk/test: test.mod $(KILIB)/.sym/K32except $(KILIB)/.sym/K32baseTypes \
  $(KILIB)/.sym/K32types $(KILIB)/.sym/KernelCalls $(KILIB)/.sym/userFdt \
  m2path
	run.m2c -T -E test.mod

ttest.out: ttest.ld.sh ttest.gfo
	@sh -v ttest.ld.sh
	size $@

ttest.gfo: ttest.gfs2
	as -o $@ ttest.gfs2

ttest.gfs2: ttest.gfs fix.test.gfs.ed
	cp ttest.gfs $@
	ed - $@ < fix.test.gfs.ed

ttest.ld.sh ttest.gfs: .lnk/ttest $(KILIB)/.lnk/KernelCalls \
  $(KILIB)/.lnk/userFdt $(KILIB)/.lnk/K32except $(KILIB)/.lnk/K32baseTypes \
  $(KILIB)/.lnk/K32machine $(KILIB)/.lnk/K32types m2path
	m2l -c -S -E -L -X -n ttest\
	  | sed -e 's/^/ld /'\
		-e 's= \./= =g'\
		-e 's/ -lc//' > ttest.ld.sh
# The preceding invocation of sed prepends the "ld" command, removes
# superfluous "./" pathname components, and prevents loading the C library.

.lnk/ttest: ttest.mod $(KILIB)/.sym/K32except $(KILIB)/.sym/K32baseTypes \
  $(KILIB)/.sym/K32types $(KILIB)/.sym/KernelCalls $(KILIB)/.sym/userFdt \
  m2path
	run.m2c -T -E ttest.mod

install: test.out
	csh -c "~ksos/tools/install test.out /initial"
