blob: 8950e1364e07921a98bbcfaeeb912e95efa0cd0e [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001LOCAL_DIR := $(GET_LOCAL_DIR)
2
3MODULE := $(LOCAL_DIR)
4
5WITH_KERNEL_VM=1
6GLOBAL_DEFINES += \
7 MEMBASE=0x00200000U \
8 KERNEL_ASPACE_BASE=0x00200000U \
9 KERNEL_ASPACE_SIZE=0x7fe00000U \
10 IS_64BIT=1 \
11 SMP_MAX_CPUS=1 \
12 X86_WITH_FPU=1
13
14KERNEL_BASE ?= 0x00200000
15KERNEL_LOAD_OFFSET ?= 0x0
16
17MODULE_SRCS += \
18 $(LOCAL_DIR)/crt0.S \
19 $(LOCAL_DIR)/arch.c \
20 $(LOCAL_DIR)/asm.S \
21 $(LOCAL_DIR)/cache.c \
22 $(LOCAL_DIR)/cache-ops.S \
23 $(LOCAL_DIR)/ops.S \
24 $(LOCAL_DIR)/thread.c \
25 $(LOCAL_DIR)/mmu.c \
26 $(LOCAL_DIR)/faults.c \
27 $(LOCAL_DIR)/descriptor.c \
28 $(LOCAL_DIR)/fpu.c
29
30# set the default toolchain to x86 elf and set a #define
31ifndef TOOLCHAIN_PREFIX
32TOOLCHAIN_PREFIX := x86_64-elf-
33endif
34
35LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(CFLAGS) -print-libgcc-file-name)
36#$(info LIBGCC = $(LIBGCC))
37
38cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`"; \
39 then echo "$(2)"; else echo "$(3)"; fi ;)
40
41# disable SSP if the compiler supports it; it will break stuff
42GLOBAL_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
43
44GLOBAL_COMPILEFLAGS += -fasynchronous-unwind-tables
45GLOBAL_COMPILEFLAGS += -gdwarf-2
46GLOBAL_COMPILEFLAGS += -fno-stack-protector
47GLOBAL_LDFLAGS += -z max-page-size=4096
48
49ARCH_OPTFLAGS := -O2
50
51# potentially generated files that should be cleaned out with clean make rule
52GENERATED += \
53 $(BUILDDIR)/kernel.ld
54
55# rules for generating the linker scripts
56
57$(BUILDDIR)/kernel.ld: $(LOCAL_DIR)/kernel.ld $(wildcard arch/*.ld)
58 @echo generating $@
59 @$(MKDIR)
60 $(NOECHO)cp $< $@
61
62include make/module.mk