shithub: riscv

ref: d6ea4969607d9d6b33ae5a40a947f8a2aa2c0845
dir: /sys/src/9/boot/mkboot/

View raw version
#!/bin/rc
#
#  this file configures a boot program (/boot) for a kernel.
#
if(! ~ $#* 1){
	echo usage: mkboot file >[1=2]
	exit 1
}

cat <<'---'
#include <u.h>
#include <libc.h>
#include "../boot/boot.h"

---

awk '
	BEGIN	{ bootprog = "boot"; bootdisk = "/dev/sdC0/"; }
	$0 ~ "^boot" && $2=="cpu"\
		{ if(NF == 4 && $3 == "boot")
			bootdisk = $4
		}
	$0 ~ "^boot" && $2=="boot" && NF==3\
		{ bootdisk = $3 }
	END 	{ print "char* bootdisk = \"" bootdisk "\";"
		  print "extern void " bootprog "(int, char**);"
		  print "void"
		  print "main(int argc, char **argv)"
		  print "{"
		  print "\t" bootprog "(argc, argv);"
		  print "}"
		}
' $1