-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
59 lines (40 loc) · 1.28 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
#
# UranOS makefile
#
#######################
# * CONFIG PART * #
#######################
# Name for the kernel image to be generated
KERNEL_IMAGE=kernel.img
# Set default arch (lol, could we do ARM some day?!)
ARCH=i686
# Options for QEMU
QEMU_PARAMS=
#######################
# * END CONFIG PART * #
#######################
C_SOURCES:=$(shell find . -name '*.c' -not -path './toolchain/*')
ASM_SOURCES:=$(shell find . -name '*.asm' -not -path './toolchain/*')
KERNEL_OBJS = $(subst .c,.o,$(C_SOURCES))
KERNEL_OBJS += $(subst .asm,.o,$(ASM_SOURCES))
# Includes needed CC, QEMU_CMD etc. and toolchain makefile ...
include arch/$(ARCH)/Makefile
all: $(KERNEL_IMAGE) TOOLCHAIN
run: $(KERNEL_IMAGE)
$(QEMU_CMD) -kernel $(KERNEL_IMAGE) $(QEMU_PARAMS)
debug_run: $(KERNEL_IMAGE)
$(QEMU_CMD) -s -S -kernel $(KERNEL_IMAGE) $(QEMU_PARAMS) -no-reboot -no-shutdown
CFLAGS+=-Iinclude -Iarch/$(ARCH)/include -D__URANOS_ARCH_$(ARCH)__
CFLAGS+=-g
include toolchain/toolchain-$(ARCH).mk
$(KERNEL_IMAGE): $(KERNEL_OBJS)
@echo " LD $@"
@ld $(LDFLAGS) -T arch/$(ARCH)/linker.ld -o $(KERNEL_IMAGE) $(KERNEL_OBJS)
%.o: %.c
@echo " CC $< --> $@"
@$(CC) $(CFLAGS) -c $< -o $@
%.o: %.asm
@echo " AS $< --> $@"
@$(AS) $(ASFLAGS) $< -o $@
clean:
@rm $(KERNEL_OBJS) $(KERNEL_IMAGE)