diff options
| author | EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> | 2024-05-06 23:00:36 -0400 |
|---|---|---|
| committer | EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> | 2024-05-06 23:00:36 -0400 |
| commit | 33bc3446d237a95f1bbf9d5d70a170fa4c4241cd (patch) | |
| tree | 60a07c07c59b92ed21407f59931f25285b89f2aa /kernel/makefile | |
| parent | 982baec992d48343e455bf6e32ca96fbdcddda01 (diff) | |
Improved makefile a bit more and got it working with the other files
Diffstat (limited to 'kernel/makefile')
| -rw-r--r-- | kernel/makefile | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/kernel/makefile b/kernel/makefile index b2a2660..8c2832d 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -1,14 +1,14 @@ # Kernel makefile
-CFLAGS := -ffreestanding -Wall -Wextra -g -std=gnu99 -O2 -Iinclude
-CXXFLAGS := -ffreestanding -Wall -Wextra -fno-exceptions -fno-rtti -g -O2 -Iinclude
-LDFLAGS := -T arch/$(ARCH)/linker.ld -ffreestanding -g -O2 -Iinclude
+CFLAGS := -ffreestanding -Wall -Wextra -g -std=gnu99 -O2 -Iinclude --sysroot=$(SYSROOT)
+CXXFLAGS := -ffreestanding -Wall -Wextra -fno-exceptions -fno-rtti -g -O2 -Iinclude --sysroot=$(SYSROOT)
+LDFLAGS := -T arch/$(ARCH)/linker.ld -ffreestanding -g -O2 -Iinclude --sysroot=$(SYSROOT)
ASMFLAGS :=
ifeq ($(ARCH),x86_64)
-CFLAGS += -mno-red-zone
-CXXFLAGS += -mno-red-zone
-LDFLAGS += -mno-red-zone
+CFLAGS += -mno-red-zone -mcmodel=kernel -mno-sse -mno-sse2 -mno-mmx
+CXXFLAGS += -mno-red-zone -mcmodel=kernel -mno-sse -mno-sse2 -mno-mmx
+LDFLAGS += -mno-red-zone -mcmodel=kernel -mno-sse -mno-sse2 -mno-mmx
ASMFLAGS += -felf64
endif
@@ -16,38 +16,36 @@ ifndef SYSROOT $(error No sysroot specified)
endif
-
-LIBS = -nostdlib -lck -lgcc
+LIBS = -nostdlib -lc -lgcc
#Find all the source files
-C_SOURCES := $(shell find $(PWD)/kernel -type f -name '*.c')
-CPP_SOURCES := $(shell find $(PWD)/kernel -type f -name '*.cpp')
-HEADERS := $(shell find $(PWD) -type f -name '*.h')
-ASMFILES := $(shell find $(PWD) -type f -name '*.asm' ! -name 'crti.asm' ! -name 'crtn.asm')
-CRTBEGIN := $(shell $(CXX) $(CXXFLAGS) -print-file-name=crtbegin.o)
-CRTEND := $(shell $(CXX) $(CXXFLAGS) -print-file-name=crtend.o)
+CPP_SRCS := $(shell find . -type f -name '*.cpp' -not -path './arch/*') \
+ $(shell find $(PWD)/kernel/arch/$(ARCH) -type f -name '*.cpp')
+#HEADERS := $(shell find $(PWD) -type f -name '*.h')
+#ASMFILES := $(shell find $(PWD) -type f -name '*.asm' -prune $(PWD)/arch) \
+ $(shell find $(PWD)/kernel/arch/$(ARCH) -type f -name '*.asm')
-OBJECTS := $(patsubst %.c,%.o,$(C_SOURCES))
-OBJECTS += $(patsubst %.cpp,%.o,$(CPP_SOURCES))
-OBJECTS += $(patsubst %.asm,%.o,$(ASMFILES))
+#OBJS := $(patsubst %.c,%.o,$(C_SOURCES))
+OBJS := $(patsubst %.cpp,%.o,$(CPP_SRCS))
+OBJS += $(patsubst %.asm,%.o,$(ASMFILES))
-DEPFILES := $(patsubst %.c,%.d,$(C_SOURCES))
-DEPFILES += $(patsubst %.cpp,%.d,$(CPP_SOURCES))
+#DEPFILES := $(patsubst %.c,%.d,$(C_SOURCES))
+DEPFILES := $(patsubst %.cpp,%.d,$(CPP_SRCS))
-LINKLST := crti.o
-LINKLST += $(CRTBEGIN)
-LINKLST += $(OBJECTS)
+# LINKLST := crti.o
+# LINKLST += $(CRTBEGIN)
+LINKLST += $(OBJS)
LINKLST += $(LIBS)
-LINKLST += $(CRTEND)
-LINKLST += crtn.o
+# LINKLST += $(CRTEND)
+# LINKLST += crtn.o
-include $(DEPFILES)
-.PHONY: all crt clean kernel.bin
+.PHONY: all clean
-all: crti.o crtn.o kernel.bin
+all: kernel.bin
-kernel.bin: ${OBJECTS}
+kernel.bin: ${OBJS}
$(info [INFO] Linking kernel)
$(CXX) ${LDFLAGS} -o $@ $(LINKLST)
@@ -63,15 +61,15 @@ kernel.bin: ${OBJECTS} $(info [INFO] Assembling $<)
$(NASM) $< $(ASMFLAGS) -o $@ -g
-crti.o:
- $(NASM) arch/$(ARCH)/crti.asm $(ASMFLAGS) -o $@
+# crti.o:
+# $(NASM) arch/$(ARCH)/crti.asm $(ASMFLAGS) -o $@
-crtn.o:
- $(NASM) arch/$(ARCH)/crtn.asm $(ASMFLAGS) -o $@
+# crtn.o:
+# $(NASM) arch/$(ARCH)/crtn.asm $(ASMFLAGS) -o $@
install-headers:
cp -r --preserve=timestamps include/. $(SYSROOT)/usr/include
clean:
$(info [INFO] Cleaning)
- $(RM) ${OBJECTS} $(DEPFILES) crti.o crtn.o
\ No newline at end of file + $(RM) ${OBJS} $(DEPFILES)
\ No newline at end of file |
