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 15export CC=$(DragonOS_GCC)/x86_64-elf-gcc 16export LD=ld 17export AS=$(DragonOS_GCC)/x86_64-elf-as 18export NM=$(DragonOS_GCC)/x86_64-elf-nm 19export AR=$(DragonOS_GCC)/x86_64-elf-ar 20export OBJCOPY=$(DragonOS_GCC)/x86_64-elf-objcopy 21 22else ifeq ($(ARCH), riscv64) 23 24export CC=riscv64-unknown-elf-gcc 25# binutils版本需要>=2.38 26# 而ubuntu的unknown-elf的版本比较旧,所以使用了riscv64-linux-gnu-ld 27export LD=riscv64-linux-gnu-ld 28export AS=riscv64-unknown-elf-as 29export NM=riscv64-unknown-elf-nm 30export AR=riscv64-unknown-elf-ar 31export OBJCOPY=riscv64-unknown-elf-objcopy 32 33endif 34 35 36export DEBUG=DEBUG 37 38export CFLAGS_DEFINE_ARCH="__$(ARCH)__" 39 40export GLOBAL_CFLAGS := -fno-builtin -fno-stack-protector -D $(CFLAGS_DEFINE_ARCH) -D $(EMULATOR) -O1 41 42ifeq ($(ARCH), x86_64) 43GLOBAL_CFLAGS += -mcmodel=large -m64 44else ifeq ($(ARCH), riscv64) 45GLOBAL_CFLAGS += -mcmodel=medany -march=rv64imac -mabi=lp64 46endif 47 48ifeq ($(DEBUG), DEBUG) 49GLOBAL_CFLAGS += -g 50endif