xref: /DragonOS/env.mk (revision ce5850adbf74ec6c6717bbb5b1749f1fbff4ca0d)
1
2ifeq ($(ARCH), )
3# !!!!在这里设置ARCH,可选 x86_64 和 riscv64
4# !!!!!!!如果不同时调整这里以及vscode的settings.json,那么自动补全和检查将会失效
5export ARCH?=x86_64
6endif
7
8ifeq ($(EMULATOR), )
9export EMULATOR=__NO_EMULATION__
10endif
11
12# 设置编译器
13ifeq ($(ARCH), x86_64)
14
15# 如果 x86_64时,DragonOS_GCC 为空,那么设置为默认值
16export DragonOS_GCC?=$(HOME)/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin
17
18export CC=$(DragonOS_GCC)/x86_64-elf-gcc
19export LD=ld
20export AS=$(DragonOS_GCC)/x86_64-elf-as
21export NM=$(DragonOS_GCC)/x86_64-elf-nm
22export AR=$(DragonOS_GCC)/x86_64-elf-ar
23export OBJCOPY=$(DragonOS_GCC)/x86_64-elf-objcopy
24
25else ifeq ($(ARCH), riscv64)
26
27export CC=riscv64-unknown-elf-gcc
28# binutils版本需要>=2.38
29# 而ubuntu的unknown-elf的版本比较旧,所以使用了riscv64-linux-gnu-ld
30export LD=riscv64-linux-gnu-ld
31export AS=riscv64-unknown-elf-as
32export NM=riscv64-unknown-elf-nm
33export AR=riscv64-unknown-elf-ar
34export OBJCOPY=riscv64-unknown-elf-objcopy
35
36endif
37
38
39export DEBUG=DEBUG
40
41export CFLAGS_DEFINE_ARCH="__$(ARCH)__"
42
43export GLOBAL_CFLAGS := -fno-builtin -fno-stack-protector -D $(CFLAGS_DEFINE_ARCH) -D $(EMULATOR) -O1
44
45ifeq ($(ARCH), x86_64)
46GLOBAL_CFLAGS += -mcmodel=large -m64
47else ifeq ($(ARCH), riscv64)
48GLOBAL_CFLAGS += -mcmodel=medany -march=rv64imac -mabi=lp64
49endif
50
51ifeq ($(DEBUG), DEBUG)
52GLOBAL_CFLAGS += -g
53endif