shithub: riscv

ref: 04759ec9af6dcc78ea5873ceaf6db2e3b3920b22
dir: /sys/src/9/port/mkrootc/

View raw version
#!/bin/rc

rfork e
n=`{echo $#*^'%3' | hoc}
if(! ~ $n 0){
	echo 'usage: mkrootc [name cname file]...' >[1=2]
	exit usage
}

tmp=mkroot.$pid.out
fn sigexit {
	rm -f $tmp
}

allcname=()
allname=()
while(! ~ $#* 0){
	name=$1
	cname=$2
	file=$3
	shift
	shift 
	shift
	allname=($allname $name)
	allcname=($allcname $cname)
}

echo '
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "io.h"
#include "../port/error.h"
'

for(i in $allcname){
	echo 'extern uchar '$i'code[];'
	echo 'extern ulong '$i'len;'
}

echo '
void bootlinks(void){
'
x=($allname)
for(i in $allcname){
	name=$x(1)
	*=($x); shift; x=($*)
	echo '	addbootfile("'$name'", '$i'code, '$i'len);'
}
echo '
}
'