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 \
		gview/gview.hrb edit/edit.ehr \
		guicalc/guicalc.ehr ver/ver.ehr splash/splash.img \
		sjis/sjis.fnt readme/readme.txt pictdata/fujisan.jpg pictdata/night.bmp
	$(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: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:edit/edit.ehr to:@:root/apps/ \
		copy from:guicalc/guicalc.ehr to:@:root/apps/ \
		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 type
	$(MAKE) -C chklang
	$(MAKE) -C invader
	$(MAKE) -C calc
	$(MAKE) -C tview
	$(MAKE) -C edit
	$(MAKE) -C guicalc
	$(MAKE) -C gview
	$(MAKE) -C ver
	$(MAKE) -C splash
	$(MAKE) -C sjis
	$(MAKE) -C readme
	$(MAKE) -C pictdata
	$(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 type			clean
	$(MAKE) -C chklang		clean
	$(MAKE) -C invader		clean
	$(MAKE) -C calc			clean
	$(MAKE) -C tview		clean
	$(MAKE) -C edit			clean
	$(MAKE) -C guicalc		clean
	$(MAKE) -C gview		clean
	$(MAKE) -C ver			clean
	$(MAKE) -C splash		clean
	$(MAKE) -C sjis			clean
	$(MAKE) -C readme		clean
	$(MAKE) -C pictdata		clean

src_only_full :
	$(MAKE) -C kernel		src_only
	$(MAKE) -C apilib		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 edit			src_only
	$(MAKE) -C guicalc		src_only
	$(MAKE) -C gview		src_only
	$(MAKE) -C ver			src_only
	$(MAKE) -C splash		src_only
	$(MAKE) -C sjis			src_only
	$(MAKE) -C readme		src_only
	$(MAKE) -C pictdata		src_only
	-$(DEL) tuos.img

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