K32LIB=/u/ksos/ksos32/kernel/lib
system =
compile	=-E
link =-E -n

library:	programs objects symbols

programs:	testXX.out
###test09.out  test14.out M2C

symbols:	.sym/KernelCalls .sym/fixKcalls .sym/userFdt

objects:	.lnk/test09 .lnk/test14 .lnk/testXX \
		.lnk/KernelCalls .lnk/fixKcalls .lnk/userFdt

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

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

testXX.gfs2:	testXX.gfs fix.testXX.gfs.ed
		ed - testXX.gfs < fix.testXX.gfs.ed

testXX.ld.sh testXX.gfs:	.lnk/testXX \
  .lnk/KernelCalls .lnk/fixKcalls \
  $(K32LIB)/.lnk/K32except \
  $(K32LIB)/.lnk/K32baseTypes \
  $(K32LIB)/.lnk/K32types
	m2l -c -S -L -X -n -E testXX | sed -e 's/^/ld /' \
		-e 's= \./= =g' \
			> testXX.ld.sh
# The preceding invocation of sed prepends the "ld" command and removes
# superfluous "./" pathname components.


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

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

test09.gfs2:	test09.gfs fix.test09.gfs.ed
		ed - test09.gfs < fix.test09.gfs.ed

test09.ld.sh test09.gfs:	.lnk/test09 $(K32LIB)/.lnk/K32except \
  .lnk/KernelCalls $(K32LIB)/.lnk/K32baseTypes \
  $(K32LIB)/.lnk/K32types
	m2l -c -S -L -X -n -E test09 | sed -e 's/^/ld /' -e 's= \./= =g' > test09.ld.sh
# The preceding invocation of sed prepends the "ld" command and removes
# superfluous "./" pathname components.


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

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

test14.gfs2:	test14.gfs fix.test14.gfs.ed
		ed - test14.gfs < fix.test14.gfs.ed

test14.ld.sh test14.gfs:	.lnk/test14 $(K32LIB)/.lnk/K32except \
  .lnk/KernelCalls $(K32LIB)/.lnk/K32baseTypes \
  $(K32LIB)/.lnk/K32types
	m2l -c -S -L -X -n -E test14 | sed -e 's/^/ld /' -e 's= \./= =g' > test14.ld.sh
# The preceding invocation of sed prepends the "ld" command and removes
# superfluous "./" pathname components.





.lnk/testXX:	testXX.mod $(K32LIB)/.sym/K32except \
  .sym/KernelCalls .sym/fixKcalls
		m2c$(system) $(compile)	testXX

.lnk/test09:	test09.mod $(K32LIB)/.sym/K32except \
  .sym/KernelCalls .sym/fixKcalls
		m2c$(system) $(compile)	test09

.lnk/test14:	test14.mod $(K32LIB)/.sym/K32except \
  .sym/KernelCalls .sym/fixKcalls
		m2c$(system) $(compile)	test14

KernelCalls.s: KernelCalls.mod .sym/KernelCalls .sym/fixKcalls \
  $(K32LIB)/.sym/K32baseTypes \
  $(K32LIB)/.sym/K32calls \
  $(K32LIB)/.sym/K32callp \
  $(K32LIB)/.sym/K32types	\
  $(K32LIB)/.sym/K32except
		m2c$(system) $(compile)	-S KernelCalls.mod
		rm -f .lnk/KernelCalls

.lnk/KernelCalls:	KernelCalls.s fixKcalls.sed .sym/fixKcalls
		sed -f fixKcalls.sed KernelCalls.s | tee KernelCalls.s2 | as -o $@ 



.sym/KernelCalls: KernelCalls.def .sym/fixKcalls \
  $(K32LIB)/.sym/K32baseTypes \
  $(K32LIB)/.sym/K32types	\
  $(K32LIB)/.sym/K32except \
  $(K32LIB)/.sym/K32machine 
		m2c$(system) -d	$(compile) KernelCalls

.sym/fixKcalls:	fixKcalls.def $(K32LIB)/.sym/K32except
	m2c -E -d fixKcalls.def

.lnk/fixKcalls:	fixKcalls.mod $(K32LIB)/.sym/K32except
	m2c -E fixKcalls.mod


M2C:	$(K32LIB)/M2C
	cat $(K32LIB)M2C | sed -e "s/-DPROF//" > M2C

userFdt.s: userFdt.mod .sym/userFdt 
		m2c$(system) $(compile)	-S userFdt.mod
		rm -f .lnk/userFdt

.lnk/userFdt:	userFdt.s fixUserFdt.sed
		sed -f fixUserFdt.sed userFdt.s > userFdt.s2
		as -o $@ userFdt.s2

.sym/userFdt: userFdt.def .sym/fixKcalls \
  $(K32LIB)/.sym/K32baseTypes \
  $(K32LIB)/.sym/K32types	\
  $(K32LIB)/.sym/K32except \
  $(K32LIB)/.sym/K32machine 
		m2c$(system) -d	$(compile) userFdt
