aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorXander <xander@icth.xyz>2023-06-28 22:49:01 +0200
committerXander <xander@icth.xyz>2023-06-28 22:49:01 +0200
commitc5bd05fa070d25ae6700660347bdb59ae84390e6 (patch)
tree437ebe500f0576c7017138288cdfe8a532c4535f /Makefile
parent448ecd41edd95b86930b5ac7288f2ea9311d476c (diff)
downloadats-os-c5bd05fa070d25ae6700660347bdb59ae84390e6.tar.xz
ats-os-c5bd05fa070d25ae6700660347bdb59ae84390e6.zip
Calling c code
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile13
1 files changed, 11 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 4178a71..02592c9 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,10 @@ assembly_source_files := $(wildcard arch/$(arch)/boot/*.asm)
assembly_object_files := $(patsubst arch/$(arch)/boot/%.asm, \
build/arch/$(arch)/%.o, $(assembly_source_files))
+c_source_files := $(wildcard kernel/*.c)
+c_object_files := $(patsubst kernel/%.c, \
+ build/kernel/%.o, $(c_source_files))
+
.PHONY: all clean run iso
all: $(kernel)
@@ -27,10 +31,15 @@ $(iso): $(kernel) $(grub_cfg)
@grub-mkrescue -o $(iso) build/isofiles 2> /dev/null
@rm -r build/isofiles
-$(kernel): $(assembly_object_files) $(linker_script)
- @ld -n -T $(linker_script) -o $(kernel) $(assembly_object_files)
+$(kernel): $(assembly_object_files) $(linker_script) $(c_object_files)
+ @ld -n -T $(linker_script) -o $(kernel) $(assembly_object_files) $(c_object_files) -nostdlib -z noexecstack
# compile assembly files
build/arch/$(arch)/%.o: arch/$(arch)/boot/%.asm
@mkdir -p $(shell dirname $@)
@nasm -felf64 $< -o $@
+
+build/kernel/%.o: kernel/%.c
+ @mkdir -p $(shell dirname $@)
+ @gcc -ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -m64 -c $< -o $@
+