shithub: riscv

ref: 0196ca7536c295b42e1d27ab8187a3d8e1bda328
dir: /sys/src/boot/pc/mkfile/

View raw version
objtype=386
</$objtype/mkfile
BIN=/386

TARG=9bootiso 9bootpxe 9bootfat 9boothyb mbr pbs

HFILES=mem.h fns.h x16.h

all: 9bootiso 9bootpxe 9bootfat 9boothyb mbr pbs
	
clean:V:
	rm -rf $TARG *.$O test.* tmp

liso.$O: l.s
	$AS -DISO -o $target l.s

lpxe.$O: l.s
	$AS -DPXE -o $target l.s

lfat.$O: l.s
	$AS -DFAT -o $target l.s

lhyb.$O: l.s
	$AS -DFAT -o $target l.s

hyb.$O: iso.c
	$CC $CFLAGS -DFAT -o $target iso.c

%.$O:	%.s
	$AS $stem.s

%.$O:	%.c
	$CC $CFLAGS $stem.c

%.$O:	$HFILES

mbr:	mbr.$O
	$LD -o $target -H3 -T0x0600 -l $prereq
	ls -l $target

pbs:	pbs.$O
	$LD -o $target -H3 -T0x0800 -l $prereq
	ls -l $target

9boot&:	l%.$O %.$O sub.$O apm.$O e820.$O a20.$O uart.$O
	$LD -o $target -H3 -T0x7c00 -l $prereq
	ls -l $target

install:V:
	for (i in $TARG)
		mk $MKFLAGS $i.install

%.install:V:	$BIN/%
	

$BIN/%:	%
	cp $stem $BIN/$stem

test.iso: 9bootiso 9boothyb 9bootfat mbr pbs
	rm -fr tmp $target
	mkdir tmp
	mkdir tmp/386
	mkdir tmp/cfg
	cp 9bootiso tmp/386
	cp /386/9pc tmp/386
	cp /sys/lib/dist/cfg/plan9.ini tmp/cfg/plan9.ini
	echo wait >>tmp/cfg/plan9.ini
	disk/mk9660 -B 386/9bootiso -p <{echo +} -s tmp $target
	@{rfork n
		bind 9boothyb 9bootfat
		dd -if /dev/zero -bs 512 -count 4096 >> $target
		disk/partfs -m /n/partfs $target
		disk=/n/partfs/sdXX
		disk/mbr -m mbr $disk/data
		@{echo a p1 '$-1' '$'
			echo t p1 FAT16
			echo A p1
			echo w
			echo q} | disk/fdisk -b $disk/data
		disk/format -b pbs -d -r 1 $disk/dos 9bootfat
	}
	rm -fr tmp

test.dsk: 9bootfat mbr pbs test.iso
	rm -fr tmp $target
	mkdir tmp
	cp test.iso 9bootfat tmp
	mkdir tmp/386
	cp /386/9pc tmp/386
	echo 'bootfile=/386/9pc' >tmp/plan9.ini
	dd -if /dev/zero -of $target -bs 512 -count 32768
	disk/partfs -m /n/$target $target
	disk=/n/$target/sdXX
	disk/mbr -m mbr $disk/data
	disk/fdisk -baw $disk/data
	disk/prep -bw -a 9fat $disk/plan9
	disk/format -b pbs -d -r 2 $disk/9fat
	s=$target.dos
	m=/n/$target.9fat
	rm -f /srv/$s
	dossrv -f $disk/9fat $s
	mount -c /srv/$s $m
	@{cd tmp; tar c .} | @{cd $m; tar xv}
	unmount $m
	rm -f /srv/$s
	unmount /n/$target
	rm -fr tmp