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 25export LD=riscv64-unknown-elf-ld 26export AS=riscv64-unknown-elf-as 27export NM=riscv64-unknown-elf-nm 28export AR=riscv64-unknown-elf-ar 29export OBJCOPY=riscv64-unknown-elf-objcopy 30 31endif 32 33 34export DEBUG=DEBUG 35 36export CFLAGS_DEFINE_ARCH="__$(ARCH)__" 37 38export GLOBAL_CFLAGS := -fno-builtin -fno-stack-protector -D $(CFLAGS_DEFINE_ARCH) -D $(EMULATOR) -O1 39 40ifeq ($(ARCH), x86_64) 41GLOBAL_CFLAGS += -mcmodel=large -m64 42else ifeq ($(ARCH), riscv64) 43GLOBAL_CFLAGS += -mcmodel=medany -march=rv64imac -mabi=lp64 44endif 45 46ifeq ($(DEBUG), DEBUG) 47GLOBAL_CFLAGS += -g 48endif