Last active
October 14, 2016 06:05
-
-
Save souvik1997/b0781138198daa5b3c303f27d64f1cd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e853e113da0a9dd8ca5e3408d2972a0e91504e99 Mon Sep 17 00:00:00 2001 | |
From: Souvik Banerjee <souvik1997@gmail.com> | |
Date: Fri, 14 Oct 2016 00:05:47 -0500 | |
Subject: [PATCH] macos | |
--- | |
common.mak | 20 +++++++++++++------- | |
kernel/Makefile | 3 +-- | |
kernel/mbr.S | 2 +- | |
3 files changed, 15 insertions(+), 10 deletions(-) | |
diff --git a/common.mak b/common.mak | |
index 406c61f..cb5652f 100644 | |
--- a/common.mak | |
+++ b/common.mak | |
@@ -1,9 +1,15 @@ | |
-CFLAGS = -std=c99 -m32 -nostdlib -nostdinc -g -O3 -Wall -Werror | |
-CCFLAGS = -std=c++1y -fno-exceptions -fno-rtti -m32 -ffreestanding -nostdlib -g -O3 -Wall -Werror | |
+TARGET=i386-pc-none-elf | |
+CFLAGS = -std=c99 -m32 -nostdlib -nostdinc -g -O3 -Wall -Werror -Wno-implicit-exception-spec-mismatch --target=$(TARGET) | |
+CCFLAGS = -std=c++1y -fno-exceptions -fno-rtti -m32 -ffreestanding -nostdlib -g -O3 -Wall -Werror -Wno-implicit-exception-spec-mismatch --target=$(TARGET) | |
CFILES = $(wildcard *.c) | |
CCFILES = $(wildcard *.cc) | |
SFILES = $(wildcard *.S) $(wildcard *.s) | |
+CC=/usr/local/opt/llvm/bin/clang | |
+CXX=/usr/local/opt/llvm/bin/clang++ | |
+LD=x86_64-unknown-elf-ld | |
+OBJCOPY=x86_64-unknown-elf-objcopy | |
+AS=x86_64-unknown-elf-as | |
OFILES = $(subst .cc,.o,$(CCFILES)) $(subst .c,.o,$(CFILES)) $(subst .s,.o,$(subst .S,.o,$(SFILES))) | |
@@ -11,19 +17,19 @@ OFILES = $(subst .cc,.o,$(CCFILES)) $(subst .c,.o,$(CFILES)) $(subst .s,.o,$(sub | |
.SECONDARY : | |
%.o : Makefile %.c | |
- gcc -c -MD $(CFLAGS) $*.c | |
+ $(CC) -c -MD $(CFLAGS) $*.c | |
%.o : Makefile %.cc | |
- g++ -c -MD $(CCFLAGS) $*.cc | |
+ $(CXX) -c -MD $(CCFLAGS) $*.cc | |
%.o : Makefile %.S | |
- gcc -MD -m32 -c $*.S | |
+ $(CC) -MD -m32 $(CFLAGS) -c $*.S | |
%.o : Makefile %.s | |
- gcc -MD -m32 -c $*.s | |
+ $(CC) -MD -m32 -c $*.s | |
%.bin : Makefile % | |
- objcopy -O binary $* $*.bin | |
+ $(OBJCOPY) -O binary $* $*.bin | |
%.img : Makefile %.bin | |
dd if=$*.bin of=$*.img bs=512 conv=sync > /dev/null 2>&1 | |
diff --git a/kernel/Makefile b/kernel/Makefile | |
index 2b51c9b..daa61ee 100644 | |
--- a/kernel/Makefile | |
+++ b/kernel/Makefile | |
@@ -3,8 +3,7 @@ all : kernel.img | |
-include ../common.mak | |
kernel : Makefile $(OFILES) $(CFILES) $(SFILES) $(CCFILES) | |
- ld -T script.ld -N -m elf_i386 -e start -o kernel $(OFILES) | |
+ $(LD) -T script.ld -N -m elf_i386 -e start -o kernel $(OFILES) | |
clean :: | |
rm -f kernel | |
- | |
diff --git a/kernel/mbr.S b/kernel/mbr.S | |
index 607c3da..22494a5 100644 | |
--- a/kernel/mbr.S | |
+++ b/kernel/mbr.S | |
@@ -96,7 +96,7 @@ | |
mov $0x8000,%ax | |
jmp *%ax | |
end: | |
- .skip 510 - (end - start) | |
+ .skip 510 - (136) | |
.byte 0x55 | |
.byte 0xaa | |
-- | |
2.8.4 (Apple Git-73) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment