ref: 0c1dd5754491b7d59b14a0dc6dbaa95ab3f18c8c
dir: /sys/src/9/boot/mkboot/
#!/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