From 68ddd33b4298381e63badc888fa122f74a1b970f Mon Sep 17 00:00:00 2001 From: acevest Date: Wed, 12 Jan 2022 03:36:00 +0000 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9Makefile=E4=BD=BF=E4=B9=8B?= =?utf8?q?=E8=83=BD=E5=9C=A8MacOS=20Apple=20Silicon=E7=9A=84Docker=20Linux?= =?utf8?q?=E4=B8=8B=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Makefile | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3ca64e0..e3db78e 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,28 @@ +OS := $(shell uname -s) +CPU_ARCH := $(shell uname -p) + CC = gcc LD = ld -UNAME := $(shell uname -s) -ifeq ($(UNAME), Darwin) - CC = i686-elf-gcc - LD = i686-elf-ld +ifeq ($(OS), Darwin) + # MacOS下安装i686-elf-*的方法: brew install i686-elf-binutils + # Apple Silicon + ifeq ($(CPU_ARCH), arm) + CC = i686-elf-gcc + LD = i686-elf-ld + # Intel MacOS + else ifeq ($(CPU_ARCH), i386) + CC = i686-elf-gcc + LD = i686-elf-ld + endif +else ifeq ($(OS), Linux) + # Apple Silicon Docker Linux + ifeq ($(CPU_ARCH), aarch64) + CC = x86_64-linux-gnu-gcc + LD = x86_64-linux-gnu-ld + endif endif + + CFLAGS = -g -c -fno-builtin -m32 -DBUILDER='"$(shell whoami)"' SYSTEMMAP = System.map KERNELBIN = KERNEL.BIN -- 2.44.0