include make_opt.txt

TOOLPATH = ../z_tools/
INCPATH  = ../z_tools/haribote/

MAKE     = $(TOOLPATH)make.exe -r
EDIMG    = $(TOOLPATH)edimg.exe
IMGTOL   = $(TOOLPATH)imgtol.com
COPY     = copy
DEL      = del

# デフォルト動作

default :
	$(MAKE) tuos.img

# ファイル生成規則

tuos.img : kernel/$(IPLNAME).bin kernel/tuos.sys Makefile \
		type/type.hrb chklang/chklang.hrb invader/invader.hrb \
		calc/calc.hrb tview/tview.hrb mmlplay/mmlplay.hrb \
		mark/mark.hrb gview/gview.hrb edit/edit.ehr \
		noodle3/noodle3.hrb noodle4/noodle4.hrb noodle5/noodle5.hrb \
		guicalc/guicalc.ehr ver/ver.ehr splash/splash.img
	$(EDIMG)   imgin:../z_tools/fdimg0at.tek \
		wbinimg src:kernel/$(IPLNAME).bin len:512 from:0 to:0 \
		copy from:kernel/tuos.sys to:@: \
		mkdir dir:@:usr \
		mkdir dir:@:usr/share \
		mkdir dir:@:usr/share/fonts \
		mkdir dir:@:usr/share/splash \
		mkdir dir:@:root \
		mkdir dir:@:root/apps size:32 \
		mkdir dir:@:etc \
		mkdir dir:@:etc/doc \
		mkdir dir:@:etc/mml \
		mkdir dir:@:etc/img \
		copy from:noodle3/noodle3.hrb to:@:root/apps/ \
		copy from:noodle4/noodle4.hrb to:@:root/apps/ \
		copy from:noodle5/noodle5.hrb to:@:root/apps/ \
		copy from:type/type.hrb to:@:root/apps/ \
		copy from:chklang/chklang.hrb to:@:root/apps/ \
		copy from:invader/invader.hrb to:@:root/apps/ \
		copy from:calc/calc.hrb to:@:root/apps/ \
		copy from:tview/tview.hrb to:@:root/apps/ \
		copy from:mmlplay/mmlplay.hrb to:@:root/apps/ \
		copy from:mark/mark.hrb to:@:root/apps/ \
		copy from:edit/edit.ehr to:@:root/apps/ \
		copy from:guicalc/guicalc.ehr to:@:root/apps/ \
		copy from:mmldata/kirakira.mml to:@:etc/mml/ \
		copy from:mmldata/fujisan.mml to:@:etc/mml/ \
		copy from:mmldata/daigo.mml to:@:etc/mml/ \
		copy from:mmldata/daiku.mml to:@:etc/mml/ \
		copy from:pictdata/fujisan.jpg to:@:etc/img/ \
		copy from:pictdata/night.bmp to:@:etc/img/ \
		copy from:gview/gview.hrb to:@:root/apps/ \
		copy from:ver/ver.ehr to:@:root/apps/ \
		copy from:readme/README.txt to:@:etc/doc/ \
		copy from:sjis/sjis.fnt to:@:usr/share/fonts/ \
		copy from:splash/splash.img to:@:usr/share/splash/ \
		imgout:tuos.img

# コマンド

run :
	$(MAKE) tuos.img
	$(COPY) tuos.img ..\z_tools\qemu\fdimage0.bin
	$(MAKE) -C ../z_tools/qemu

install :
	$(MAKE) tuos.img
	$(IMGTOL) w a: tuos.img

full :
	$(MAKE) -C kernel
	$(MAKE) -C apilib
	$(MAKE) -C noodle3
	$(MAKE) -C noodle4
	$(MAKE) -C noodle5
	$(MAKE) -C type
	$(MAKE) -C chklang
	$(MAKE) -C invader
	$(MAKE) -C calc
	$(MAKE) -C tview
	$(MAKE) -C mmlplay
	$(MAKE) -C mark
	$(MAKE) -C edit
	$(MAKE) -C guicalc
	$(MAKE) -C gview
	$(MAKE) -C ver
	$(MAKE) -C splash
	$(MAKE) tuos.img

run_full :
	$(MAKE) full
	$(COPY) tuos.img ..\z_tools\qemu\fdimage0.bin
	$(MAKE) -C ../z_tools/qemu

install_full :
	$(MAKE) full
	$(IMGTOL) w a: tuos.img

run_os :
	$(MAKE) -C tuos
	$(MAKE) run

clean :
# 何もしない

src_only :
	$(MAKE) clean
	-$(DEL) tuos.img

clean_full :
	$(MAKE) -C kernel		clean
	$(MAKE) -C apilib		clean
	$(MAKE) -C noodle3		clean
	$(MAKE) -C noodle4		clean
	$(MAKE) -C noodle5		clean
	$(MAKE) -C type			clean
	$(MAKE) -C chklang		clean
	$(MAKE) -C invader		clean
	$(MAKE) -C calc			clean
	$(MAKE) -C tview		clean
	$(MAKE) -C mmlplay		clean
	$(MAKE) -C mark			clean
	$(MAKE) -C edit			clean
	$(MAKE) -C guicalc		clean
	$(MAKE) -C gview		clean
	$(MAKE) -C ver			clean
	$(MAKE) -C splash		clean

src_only_full :
	$(MAKE) -C kernel		src_only
	$(MAKE) -C apilib		src_only
	$(MAKE) -C noodle3		src_only
	$(MAKE) -C noodle4		src_only
	$(MAKE) -C noodle5		src_only
	$(MAKE) -C type			src_only
	$(MAKE) -C chklang		src_only
	$(MAKE) -C invader		src_only
	$(MAKE) -C calc			src_only
	$(MAKE) -C tview		src_only
	$(MAKE) -C mmlplay		src_only
	$(MAKE) -C mark			src_only
	$(MAKE) -C edit			src_only
	$(MAKE) -C guicalc		src_only
	$(MAKE) -C gview		src_only
	$(MAKE) -C ver			src_only
	$(MAKE) -C splash		src_only
	-$(DEL) tuos.img

refresh :
	$(MAKE) full
	$(MAKE) clean_full
	-$(DEL) tuos.img
