TOOL = ../../z_tools/
INC = $(TOOL)haribote/
APILIB = ../api/

MAKE = $(TOOL)make.exe -r
NASK = $(TOOL)nask.exe
CC1 = $(TOOL)cc1.exe -I$(INC) -Os -Wall -quiet
GAS2NASK = $(TOOL)gas2nask.exe -a
OBJ2BIM = $(TOOL)obj2bim.exe
MAKEFONT = $(TOOL)makefont.exe
BIN2OBJ = $(TOOL)bin2obj.exe
BIM2HRB = $(TOOL)bim2hrb.exe
BIM2BIN = $(TOOL)bim2bin.exe
SJISCONV = $(TOOL)sjisconv.exe -s
RULEFILE = ../haribote.rul

# ftHg
default:
	$(MAKE) $(APP).hrb

# ʋK
%.ca: %.c Makefile
	$(SJISCONV) $*.c $*.ca
%.gas: %.ca Makefile
	$(CC1) -o $*.gas $*.c

%.nas: %.gas Makefile
	$(GAS2NASK) $*.gas $*.nas

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

%.bim: %.obj $(APILIB)api.lib Makefile ../Makeapp
	$(OBJ2BIM) @$(RULEFILE) out:$*.bim map:$*.map stack:$(STACK) $*.obj $(APILIB)api.lib

%.org: %.bim Makefile ../Makeapp
	$(BIM2HRB) $*.bim $*.org $(MALLOC)

%.hrb: %.org Makefile ../Makeapp
	$(BIM2BIN) -osacmp in:$*.org out:$*.hrb

# R}h
clean:
	del *.lst
	del *.obj
	del *.map
	del *.bim
	del *.org
	del *.hrb
