Skip to content

Commit f457898

Browse files
author
Yuma Arakawa
committed
kernel: Makefile分離
1 parent 9bcfef8 commit f457898

23 files changed

+77
-48
lines changed

Makefile

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,36 @@
1+
KERNEL_PATH = kernel
12
CFLAGS = -Wall -Wextra
23
CFLAGS += -nostdinc -nostdlib -fno-builtin -c
3-
CFLAGS += -Iinclude
4+
CFLAGS += -Iinclude -I$(KERNEL_PATH)/include
45

5-
.s.o:
6-
as -o $@ $<
7-
.S.o:
8-
gcc $(CFLAGS) -o $@ $<
96
.c.o:
107
gcc $(CFLAGS) -o $@ $<
118

129
all: fd.img
1310

14-
fd.img: boot/boot.bin sys.bin shell.bin uptime.bin
11+
fd.img: boot/boot.bin kernel/kernel.bin shell.bin uptime.bin
1512
cat $+ > $@
1613

1714
boot/boot.bin: FORCE
1815
make -C boot
1916

17+
kernel/kernel.bin: FORCE
18+
make -C kernel
19+
2020
shell.bin: apps/shell.o
2121
ld -o $@ $< -Map apps/shell.map -s -T apps/app.ld -x
2222

2323
uptime.bin: apps/uptime.o
2424
ld -o $@ $< -Map apps/uptime.map -s -T apps/app.ld -x
2525

26-
sys.bin: kernel/sys.o kernel/cpu.o kernel/intr.o kernel/excp.o kernel/memory.o kernel/sched.o kernel/timer.o kernel/console_io.o kernel/debug.o kernel/main.o kernel/kern_task_init.o apps/shell_init.o apps/uptime_init.o
27-
ld -o $@ $+ -Map System.map -s -T kernel/sys.ld -x
28-
29-
kernel/sys.o: kernel/sys.S
30-
31-
kernel/cpu.o: kernel/cpu.c
32-
33-
kernel/intr.o: kernel/intr.c
34-
35-
kernel/excp.o: kernel/excp.c
36-
37-
kernel/memory.o: kernel/memory.c
38-
39-
kernel/sched.o: kernel/sched.c
40-
41-
kernel/timer.o: kernel/timer.c
42-
43-
kernel/console_io.o: kernel/console_io.c
44-
45-
kernel/debug.o: kernel/debug.c
46-
47-
kernel/main.o: kernel/main.c
48-
49-
kernel/kern_task_init.o: kernel/kern_task_init.c
50-
51-
apps/shell_init.o: apps/shell_init.c
52-
53-
apps/uptime_init.o: apps/uptime_init.c
54-
5526
apps/shell.o: apps/shell.c
5627

5728
apps/uptime.o: apps/uptime.c
5829

5930
clean:
6031
make -C boot clean
61-
rm -f *~ *.o *.bin *.dat *.img *.map include/*~ include/*.o kernel/*~ kernel/*.o apps/*~ apps/*.o
32+
make -C kernel clean
33+
rm -f *~ *.o *.bin *.dat *.img *.map include/*~ include/*.o apps/*~ apps/*.o
6234

6335
run: fd.img
6436
qemu -fda $<

apps/shell.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#include <shell.h>
21
#include <io_port.h>
3-
#include <console_io.h>
42
#include <kernel.h>
53

64
#define MAX_LINE_SIZE 512

apps/uptime.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#include <uptime.h>
2-
#include <timer.h>
3-
#include <console_io.h>
41
#include <kernel.h>
5-
#include <sched.h>
2+
#include <console_io.h>
63

74
unsigned int syscall(unsigned int syscall_id, unsigned int arg1, unsigned int arg2, unsigned int arg3);
85

kernel/Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
CFLAGS = -Wall -Wextra
2+
CFLAGS += -nostdinc -nostdlib -fno-builtin -c
3+
CFLAGS += -Iinclude
4+
5+
.S.o:
6+
gcc $(CFLAGS) -o $@ $<
7+
.c.o:
8+
gcc $(CFLAGS) -o $@ $<
9+
10+
kernel.bin: sys.o cpu.o intr.o excp.o memory.o sched.o timer.o console_io.o debug.o main.o kern_task_init.o shell_init.o uptime_init.o
11+
ld -o $@ $+ -Map System.map -s -T sys.ld -x
12+
13+
sys.o: sys.S
14+
15+
cpu.o: cpu.c
16+
17+
intr.o: intr.c
18+
19+
excp.o: excp.c
20+
21+
memory.o: memory.c
22+
23+
sched.o: sched.c
24+
25+
timer.o: timer.c
26+
27+
console_io.o: console_io.c
28+
29+
debug.o: debug.c
30+
31+
main.o: main.c
32+
33+
kern_task_init.o: kern_task_init.c
34+
35+
shell_init.o: shell_init.c
36+
37+
uptime_init.o: uptime_init.c
38+
39+
clean:
40+
rm -f *~ *.o *.bin *.dat *.img *.map
41+
42+
.PHONY: clean

kernel/cpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <cpu.h>
2-
#include <shell.h>
3-
#include <uptime.h>
2+
#include <shell_init.h>
3+
#include <uptime_init.h>
44

55
void init_gdt(unsigned int idx, unsigned int base, unsigned int limit)
66
{
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)