-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
201 lines (144 loc) · 4.74 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#########################
# Makefile for Orange'S #
#########################
# Entry point of Orange'S
# It must have the same value with 'KernelEntryPointPhyAddr' in load.inc!
ENTRYPOINT = 0x1000
# Offset of entry point in kernel file
# It depends on ENTRYPOINT
ENTRYOFFSET = 0x400
# Programs, flags, etc.
ASM = nasm
DASM = objdump
CC = gcc -m32
LD = ld -m elf_i386
ASMBFLAGS = -I boot/include/
ASMKFLAGS = -I include/ -I include/sys/ -f elf
CFLAGS = -I include/ -I include/sys/ -c -fno-builtin -Wall -m32 -fno-stack-protector
#CFLAGS = -I include/ -c -fno-builtin -fno-stack-protector -fpack-struct -Wall
LDFLAGS = -Ttext $(ENTRYPOINT) -Map krnl.map -melf_i386
DASMFLAGS = -D
# This Program
ORANGESBOOT = boot/boot.bin boot/loader.bin
ORANGESKERNEL = kernel.bin
OBJS = kernel/kernel.o lib/syscall.o kernel/start.o kernel/main.o\
kernel/clock.o kernel/keyboard.o kernel/tty.o kernel/console.o\
kernel/i8259.o kernel/global.o kernel/protect.o kernel/proc.o\
kernel/systask.o kernel/hd.o kernel/animation.o\
lib/printf.o lib/vsprintf.o\
lib/kliba.o lib/klib.o lib/string.o lib/ls.o lib/sl.o lib/misc.o lib/mkdir.o\
lib/open.o lib/read.o lib/write.o lib/close.o lib/unlink.o\
lib/getpid.o lib/syslog.o\
applications/calculator.o applications/2048.o applications/pickstick.o applications/clearMine.o applications/guess.o\
fs/main.o fs/open.o fs/misc.o fs/read_write.o\
fs/link.o\
fs/disklog.o
DASMOUTPUT = kernel.bin.asm
# All Phony Targets
.PHONY : everything final image clean realclean disasm all buildimg
# Default starting position
nop :
@echo "why not \`make image' huh? :)"
everything : $(ORANGESBOOT) $(ORANGESKERNEL)
all : realclean everything
image : realclean everything clean buildimg
clean :
rm -f $(OBJS)
realclean :
rm -f $(OBJS) $(ORANGESBOOT) $(ORANGESKERNEL)
disasm :
$(DASM) $(DASMFLAGS) $(ORANGESKERNEL) > $(DASMOUTPUT)
# We assume that "a.img" exists in current folder
buildimg :
dd if=boot/boot.bin of=a.img bs=512 count=1 conv=notrunc
sudo mount -o loop a.img /mnt/floppy/
sudo cp -fv boot/loader.bin /mnt/floppy/
strip kernel.bin -o kernel.bin.stripped
sudo cp -fv kernel.bin.stripped /mnt/floppy/kernel.bin
sudo umount /mnt/floppy
boot/boot.bin : boot/boot.asm boot/include/load.inc boot/include/fat12hdr.inc
$(ASM) $(ASMBFLAGS) -o $@ $<
boot/loader.bin : boot/loader.asm boot/include/load.inc boot/include/fat12hdr.inc boot/include/pm.inc
$(ASM) $(ASMBFLAGS) -o $@ $<
$(ORANGESKERNEL) : $(OBJS)
$(LD) $(LDFLAGS) -o $(ORANGESKERNEL) $(OBJS)
kernel/kernel.o : kernel/kernel.asm
$(ASM) $(ASMKFLAGS) -o $@ $<
lib/syscall.o : lib/syscall.asm
$(ASM) $(ASMKFLAGS) -o $@ $<
kernel/start.o: kernel/start.c
$(CC) $(CFLAGS) -o $@ $<
kernel/main.o: kernel/main.c
$(CC) $(CFLAGS) -o $@ $<
kernel/clock.o: kernel/clock.c
$(CC) $(CFLAGS) -o $@ $<
kernel/keyboard.o: kernel/keyboard.c
$(CC) $(CFLAGS) -o $@ $<
kernel/tty.o: kernel/tty.c
$(CC) $(CFLAGS) -o $@ $<
kernel/animation.o: kernel/animation.c
$(CC) $(CFLAGS) -o $@ $<
kernel/console.o: kernel/console.c
$(CC) $(CFLAGS) -o $@ $<
kernel/i8259.o: kernel/i8259.c
$(CC) $(CFLAGS) -o $@ $<
kernel/global.o: kernel/global.c
$(CC) $(CFLAGS) -o $@ $<
kernel/protect.o: kernel/protect.c
$(CC) $(CFLAGS) -o $@ $<
kernel/proc.o: kernel/proc.c
$(CC) $(CFLAGS) -o $@ $<
lib/printf.o: lib/printf.c
$(CC) $(CFLAGS) -o $@ $<
lib/vsprintf.o: lib/vsprintf.c
$(CC) $(CFLAGS) -o $@ $<
kernel/systask.o: kernel/systask.c
$(CC) $(CFLAGS) -o $@ $<
kernel/hd.o: kernel/hd.c
$(CC) $(CFLAGS) -o $@ $<
lib/klib.o: lib/klib.c
$(CC) $(CFLAGS) -o $@ $<
lib/ls.o: lib/ls.c
$(CC) $(CFLAGS) -o $@ $<
lib/sl.o: lib/sl.c
$(CC) $(CFLAGS) -o $@ $<
lib/misc.o: lib/misc.c
$(CC) $(CFLAGS) -o $@ $<
lib/kliba.o : lib/kliba.asm
$(ASM) $(ASMKFLAGS) -o $@ $<
lib/string.o : lib/string.asm
$(ASM) $(ASMKFLAGS) -o $@ $<
lib/open.o: lib/open.c
$(CC) $(CFLAGS) -o $@ $<
lib/read.o: lib/read.c
$(CC) $(CFLAGS) -o $@ $<
lib/write.o: lib/write.c
$(CC) $(CFLAGS) -o $@ $<
lib/close.o: lib/close.c
$(CC) $(CFLAGS) -o $@ $<
lib/unlink.o: lib/unlink.c
$(CC) $(CFLAGS) -o $@ $<
lib/getpid.o: lib/getpid.c
$(CC) $(CFLAGS) -o $@ $<
lib/syslog.o: lib/syslog.c
$(CC) $(CFLAGS) -o $@ $<
applications/pickstick.o: applications/pickstick.c
$(CC) $(CFLAGS) -o $@ $<
applications/calculator.o: applications/calculator.c
$(CC) $(CFLAGS) -o $@ $<
applications/clearMine.o: applications/clearMine.c
$(CC) $(CFLAGS) -o $@ $<
applications/guess.o: applications/guess.c
$(CC) $(CFLAGS) -o $@ $<
applications/2048.o: applications/2048.c
$(CC) $(CFLAGS) -o $@ $<
fs/main.o: fs/main.c
$(CC) $(CFLAGS) -o $@ $<
fs/open.o: fs/open.c
$(CC) $(CFLAGS) -o $@ $<
fs/read_write.o: fs/read_write.c
$(CC) $(CFLAGS) -o $@ $<
fs/link.o: fs/link.c
$(CC) $(CFLAGS) -o $@ $<
fs/disklog.o: fs/disklog.c
$(CC) $(CFLAGS) -o $@ $<