
IPL        = ipl
BNIMG      = bitnos

BOOTPACK_OBJS = \
	bootpack.obj \
	naskfunc.obj \
	serif.obj \
	gothic.obj \
	minifnt.obj \
	system/memory.obj \
	system/bootinfo.obj \
	system/desctable.obj \
	system/graphic.obj \
	system/int.obj \
	system/message.obj \
	system/timer.obj \
	system/sheet.obj \
	system/debugwindow.obj \
	system/window.obj \
	system/mtask.obj \
	system/systemtask.obj \
	system/time.obj \
	system/console.obj \
	system/file.obj \
	system/__cxa_pure_virtual.obj \
	driver/video/vesa.obj \
	driver/io/eflags.obj \
	driver/io/cr0.obj \
	driver/io/gdtr.obj \
	driver/io/tr.obj \
	driver/pic/pic.obj \
	driver/keyboard/keyboard.obj \
	driver/mouse/mouse.obj \
	driver/pit/pit.obj \
	driver/rtc/rtc.obj \
	driver/fat12/fat12.obj \


CPPINCPATH    = /z_tools/bitnos
INCPATH    = /z_tools/bitnos/
TOOLPATH = /z_tools/

MAKE     = $(TOOLPATH)make.exe -r
NASK     = $(TOOLPATH)nask.exe
EDIMG    = $(TOOLPATH)edimg.exe
IMGTOL   = $(TOOLPATH)imgtol.com
BIM2NOS  = $(TOOLPATH)bim2nos.exe
BIM2HRB  = $(TOOLPATH)bim2hrb.exe
BIN2OBJ  = $(TOOLPATH)bin2obj.exe
OBJ2BIM  = $(TOOLPATH)obj2bim.exe
CPP0     = $(TOOLPATH)cpp0.exe
CPP      = $(TOOLPATH)g++.exe -I$(CPPINCPATH) -I/z_tools/guigui00 -Os -Wall -nostdlib -fno-builtin -fno-exceptions -fno-rtti -fno-common -B$(TOOLPATH) -x c++ -c
SJISCONV = $(TOOLPATH)sjisconv.exe
MAKEFONT = $(TOOLPATH)makefont.exe
MAKEFONT6= $(TOOLPATH)makefont6.exe
COPY     = copy
DEL      = del

RULEFILE = /z_tools/bitnos/bitnos.rul

ALL:
	$(MAKE) $(BNIMG).img

$(IPL).bin : $(IPL).nas Makefile
	$(NASK) $(IPL).nas $(IPL).bin $(IPL).lst

boothead.bin : boothead.nas Makefile
	$(NASK) boothead.nas boothead.bin boothead.lst

#bootpack.bim : $(BOOTPACK_OBJS) bootpack.ls Makefile
#	ld -nostdlib -static -L/z_tools/bitnos -Tdata=0x00310000 -T bootpack.ls -o bootpack.bim $(BOOTPACK_OBJS)
bootpack.bim : $(BOOTPACK_OBJS) Makefile
	$(OBJ2BIM) @$(RULEFILE) wredef:0 out:bootpack.bim stack:3136k map:bootpack.map $(BOOTPACK_OBJS)
# 3MB+64KB=3136KB
# 3136k

bootpack.nos : bootpack.bim Makefile
	$(BIM2NOS) bootpack.bim bootpack.nos 0

bitnos.sys : boothead.bin bootpack.nos Makefile
	copy /B boothead.bin+bootpack.nos bitnos.sys

serif.bin : serif.txt Makefile
	$(MAKEFONT) serif.txt serif.bin

gothic.bin : gothic.txt Makefile
	$(MAKEFONT) gothic.txt gothic.bin

minifnt.bin : minifnt.txt Makefile
	$(MAKEFONT6) minifnt.txt minifnt.bin

#hankaku.obj : hankaku.bin Makefile
#	$(BIN2OBJ) hankaku.bin hankaku.obj _hankaku

$(BNIMG).img : $(IPL).bin Makefile bitnos.sys ipl.nas
	$(EDIMG) imgin:/z_tools/fdimg0at.tek \
		wbinimg src:$(IPL).bin len:512 from:0 to:0 \
		copy from:bitnos.sys to:@: \
		copy from:ipl.nas to:@: \
		imgout:$(BNIMG).img

# ʐK
%.cpa : %.cpp Makefile
	$(SJISCONV) -s $*.cpp $*.cpa

%.obj : %.cpa Makefile
	$(CPP) -o $*.obj $*.cpa

%.nas0 : %.nas Makefile
	$(CPP0) -o $*.nas0 $*.nas

%.obj : %.nas0 Makefile
	$(NASK) $*.nas0 $*.obj $*.lst

%.bin : %.txt Makefile
	$(MAKEFONT) $*.txt $*.bin

%.obj : %.bin Makefile
	$(BIN2OBJ) $*.bin $*.obj _$*

%.S : %.cpa Makefile
	$(TOOLPATH)g++.exe -I$(CPPINCPATH) -I/z_tools/guigui00 -Os -Wall -nostdlib \
		-fno-builtin -fno-exceptions -fno-rtti -B$(TOOLPATH) -x c++ -S -o $*.S $*.cpa

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

full:
	$(MAKE) -C apilib
	$(MAKE) -C ../hello
	$(MAKE) -C ../hlt
	$(MAKE) -C ../crack1
	$(MAKE) $(BNIMG).img

clean:
	-$(DEL) *.bim
	-$(DEL) *.bin
	-$(DEL) *.nos
	-$(DEL) *.lst
	-$(DEL) *.map
	-$(DEL) *.obj
	-$(DEL) system\*.obj
	-$(DEL) driver\io\*.obj
	-$(DEL) driver\pic\*.obj
	-$(DEL) driver\video\*.obj
	-$(DEL) driver\mouse\*.obj
	-$(DEL) driver\keyboard\*.obj
	-$(DEL) driver\pit\*.obj
	-$(DEL) driver\rtc\*.obj
	-$(DEL) bitnos.sys

clean_full:
	$(MAKE) clean
	$(MAKE) -C ../hello clean
	$(MAKE) -C ../hlt clean
	$(MAKE) -C ../crack1 clean

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