code: 9ferno

ref: b548687a8ed1d0a159c9d3f3f921d93bbb56908e
dir: /os/boot/pc/mkfile/

View raw version
<../../../mkconfig
objtype=386
SYSTARG=$OSTARG
OBJTYPE=386
BIN=$ROOT/Inferno/$OBJTYPE
LIBDIR=$ROOT/Inferno/$OBJTYPE/lib
LIBDIRS=$ROOT/libfis $ROOT/libflate $ROOT/libkern
LIBS=\
	libfis\
	libflate\
	libkern\

LIBFILES=${LIBS:%=$LIBDIR/%.a}
<$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE

BIN=$ROOT/Inferno/$OBJTYPE

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
	
# added to cause libfis and libflate to be made automatically:

$ROOT/Inferno/$OBJTYPE/lib/lib%.a:Q:	all-$SHELLTYPE
	#

rc-lib%.a nt-lib%.a:VQ:
	echo '@{builtin cd ' $ROOT/lib$stem ';mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE install}'
	@{builtin cd  $ROOT/lib$stem ;mk 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE install}

sh-lib%.a:VQ:
	echo "(cd $ROOT/lib$stem ; mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE install)"
	(cd $ROOT/lib$stem ; mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE install)

%-sh:QV:
		for i in $LIBDIRS
		do
			echo "(cd $i ; mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE $stem)"
			(cd $i; mk 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE $stem)
		done

%-rc %-nt:QV:
		for (i in $LIBDIRS)
		{
			echo '@{cd $i ; mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE $stem}'
			@{cd $i; mk 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE $stem}
		}

nuke:V:		clean nuke-$SHELLTYPE