-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
108 lines (85 loc) · 3.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
SOURCEPATH = src/
HEADERPATH = $(SOURCEPATH)header/
OBJECTPATH = obj/
RESOURCEPATH = resources/
TOOLPATH = ../../z_tools/
LIBINCPATH = ../../z_tools/haribote/
INCPATH = include/
CSOURCES=$(wildcard $(SOURCEPATH)*.c)
ASEMBLESOURCES=$(wildcard $(SOURCEPATH)*.nas)
OBJS_BOOTPACK= \
$(addprefix $(OBJECTPATH), $(notdir $(CSOURCES:.c=.obj))) \
$(addprefix $(OBJECTPATH), $(notdir $(ASEMBLESOURCES:.nas=.obj))) \
$(OBJECTPATH)hankaku.obj
MAKE = make -r
NASK = $(TOOLPATH)nask
CC1 = $(TOOLPATH)gocc1 -I$(LIBINCPATH) -I$(INCPATH) -Os -Wall -quiet
GAS2NASK = $(TOOLPATH)gas2nask -a
OBJ2BIM = $(TOOLPATH)obj2bim
MAKEFONT = $(TOOLPATH)makefont
BIN2OBJ = $(TOOLPATH)bin2obj
BIM2HRB = $(TOOLPATH)bim2hrb
RULEFILE = $(TOOLPATH)haribote/haribote.rul
EDIMG = $(TOOLPATH)edimg
IMGTOL = $(TOOLPATH)imgtol
COPY = cp
DEL = rm -f
# デフォルト動作
default :
$(MAKE) img
# ファイル生成規則
# nask でアセンブラを bin にコンパイル
$(OBJECTPATH)ipl10.bin : $(HEADERPATH)ipl10.nas Makefile
$(NASK) $(HEADERPATH)ipl10.nas $(OBJECTPATH)ipl10.bin $(OBJECTPATH)ipl10.lst
$(OBJECTPATH)asmhead.bin : $(HEADERPATH)asmhead.nas Makefile
$(NASK) $(HEADERPATH)asmhead.nas $(OBJECTPATH)asmhead.bin $(OBJECTPATH)asmhead.lst
# makefont でフォントの bin -> obj 生成
$(OBJECTPATH)hankaku.bin : $(RESOURCEPATH)hankaku.txt Makefile
$(MAKEFONT) $(RESOURCEPATH)hankaku.txt $(OBJECTPATH)hankaku.bin
$(OBJECTPATH)hankaku.obj : $(OBJECTPATH)hankaku.bin Makefile
$(BIN2OBJ) $(OBJECTPATH)hankaku.bin $(OBJECTPATH)hankaku.obj _hankaku
# obj 同士をリンクし,bim を生成
$(OBJECTPATH)bootpack.bim : $(OBJS_BOOTPACK) Makefile
$(OBJ2BIM) @$(RULEFILE) \
out:$(OBJECTPATH)bootpack.bim \
stack:3136k \
map:$(OBJECTPATH)bootpack.map \
$(OBJS_BOOTPACK)
# 3MB+64KB=3136KB
# 「はりぼてOS」用の形式に変換
$(OBJECTPATH)bootpack.hrb : $(OBJECTPATH)bootpack.bim Makefile
$(BIM2HRB) $(OBJECTPATH)bootpack.bim $(OBJECTPATH)bootpack.hrb 0
# cat コマンドにより asmhead と bootpack を連結し,bootpack.hrb を生成
$(OBJECTPATH)haribote.sys : $(OBJECTPATH)asmhead.bin $(OBJECTPATH)bootpack.hrb Makefile
cat $(OBJECTPATH)asmhead.bin $(OBJECTPATH)bootpack.hrb > $(OBJECTPATH)haribote.sys
# edimg によってディスクイメージに保存
haribote.img : $(OBJECTPATH)ipl10.bin $(OBJECTPATH)haribote.sys Makefile
$(EDIMG) imgin:../../z_tools/fdimg0at.tek \
wbinimg src:$(OBJECTPATH)ipl10.bin len:512 from:0 to:0 \
copy from:$(OBJECTPATH)haribote.sys to:@: \
imgout:haribote.img
# 一般規則
# cc (Cコンパイラ) でCコードをアセンブリコード(.gas)にコンパイル
$(SOURCEPATH)%.gas : $(SOURCEPATH)%.c Makefile
$(CC1) -o $(SOURCEPATH)$*.gas $(SOURCEPATH)$*.c
# アセンブラ gas 用のアセンブリコードを,nask 用に変換する
$(SOURCEPATH)%.nas : $(SOURCEPATH)%.gas Makefile
$(GAS2NASK) $(SOURCEPATH)$*.gas $(SOURCEPATH)$*.nas
# アセンブラ nask によってアセンブルし obj を生成
$(OBJECTPATH)%.obj : $(SOURCEPATH)%.nas Makefile
$(NASK) $(SOURCEPATH)$*.nas $(OBJECTPATH)$*.obj $(OBJECTPATH)$*.lst
# コマンド
img :
$(MAKE) haribote.img
run :
$(MAKE) img
$(COPY) haribote.img ../../z_tools/qemu/fdimage0.bin
$(MAKE) -C ../../z_tools/qemu
install :
$(MAKE) img
$(IMGTOL) w a: haribote.img
clean :
-$(DEL) obj/*
src_only :
$(MAKE) clean
-$(DEL) haribote.img