]> Zhao Yanbai Git Server - kernel.git/commitdiff
fix compile under MacOS
authoracevest <zhaoyanbai@126.com>
Fri, 29 Oct 2021 00:00:13 +0000 (08:00 +0800)
committeracevest <zhaoyanbai@126.com>
Fri, 29 Oct 2021 00:00:13 +0000 (08:00 +0800)
Makefile

index 8814119bacfccea881f83aa4a46e7a5bf26be2f8..75dbf4a6ddc5c1d11180dad66f223c8bac6e1113 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,10 @@
 CC                     = gcc
+LD                     = ld
+UNAME := $(shell uname -s)
+ifeq ($(UNAME), Darwin)
+       CC              = i686-elf-gcc
+       LD              = i686-elf-ld
+endif
 CFLAGS         = -g -c -fno-builtin -m32
 SYSTEMMAP      = System.map
 KERNELBIN      = KERNEL.BIN
@@ -15,7 +21,7 @@ HEADER_FILES := $(foreach DIR, $(INC_DIRS), $(wildcard $(DIR)/*.h))
 OBJS := $(patsubst %,%.o,$(SOURCE_FILES))
 
 ${KERNELBIN}: ${OBJS}
-       ld -m elf_i386 -M -T$(LINKSCRIPT) $(OBJS) -o $@ > $(SYSTEMMAP)
+       ${LD} -m elf_i386 -M -T$(LINKSCRIPT) $(OBJS) -o $@ > $(SYSTEMMAP)
        rm kernel/setup.c.o
 
 %.S.o: %.S ${HEADER_FILES}