]> Zhao Yanbai Git Server - kernel.git/commitdiff
修改Makefile使之能在MacOS Apple Silicon的Docker Linux下编译
authoracevest <zhaoyanbai@126.com>
Wed, 12 Jan 2022 03:36:00 +0000 (03:36 +0000)
committeracevest <zhaoyanbai@126.com>
Wed, 12 Jan 2022 03:36:00 +0000 (03:36 +0000)
Makefile

index 3ca64e03ccd80c8b2403ab79186c1f8b160b8faf..e3db78e3ed8013dd92599d0c7038c8eb1d0c19f6 100644 (file)
--- 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