]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/boot/mkboot
Initial import of the new boot(8). Change pccd and pcf to use it.
[plan9front.git] / sys / src / 9 / boot / mkboot
1 #!/bin/rc
2 #
3 #  this file configures a boot program (/boot) for a kernel.
4 #
5 if(! ~ $#* 1){
6         echo usage: mkboot file >[1=2]
7         exit 1
8 }
9
10 cat <<'---'
11 #include <u.h>
12 #include <libc.h>
13 #include "../boot/boot.h"
14
15 ---
16
17 awk '
18         BEGIN   { cpuflag = 0; bootprog = "boot"; bootdisk = "#S/sdC0/"; rootdir = "/root"; }
19         $0 ~ "^boot" && $2=="cpu"\
20                 { cpuflag = 1
21                   if(NF == 4 && $3 == "boot")
22                         bootdisk = $4
23                 }
24         $0 ~ "^boot" && $2=="rootdir" && NF==3\
25                 { rootdir = $3 }
26         $0 ~ "^boot" && ($2=="bboot" || $2=="romboot" || $2=="dosboot")\
27                 { cpuflag = 1;  bootprog = $2; }
28         $0 ~ "^boot" && $2=="boot" && NF==3\
29                 { bootdisk = $3 }
30         END     { print "int cpuflag = " cpuflag ";"
31                   print "char* rootdir = \"" rootdir "\";"
32                   print "char* bootdisk = \"" bootdisk "\";"
33                   print "extern void " bootprog "(int, char**);"
34                   print "void"
35                   print "main(int argc, char **argv)"
36                   print "{"
37                   print "\t" bootprog "(argc, argv);"
38                   print "}"
39                 }
40 ' $1
41
42 #
43 #  configure in a cache file system if a 
44 # /386/bin/root appears in the bootdir section.
45 #
46 ../port/mkextract bootdir 0 $* | awk '
47         BEGIN                   { cfs = 0 }
48         $1 ~ "bin/cfs$" { cfs = 1 }
49         END                     { if(cfs)
50                                         print "int (*cfs)(int) = cache;"
51                                   else
52                                         print "int (*cfs)(int) = 0;"
53                                 }
54         '