Proper kernel
This commit is contained in:
21
Makefile
21
Makefile
@@ -38,7 +38,7 @@ TARGET = BOOTX64.EFI
|
||||
TARGET_SO = bootx64.so
|
||||
OBJ = $(BUILD_DIR)/main.o
|
||||
KERNEL_TARGET = kernel.elf
|
||||
KERNEL_OBJ = $(BUILD_DIR)/kernel.o
|
||||
KERNEL_OBJS = $(BUILD_DIR)/kernel.o $(BUILD_DIR)/string_utils.o $(BUILD_DIR)/commands.o
|
||||
KERNEL_LD = kernel.ld
|
||||
|
||||
# QEMU settings
|
||||
@@ -76,7 +76,8 @@ QEMU_FLAGS = -machine q35 \
|
||||
-drive if=pflash,format=raw,file=$(BUILD_DIR)/OVMF_VARS.fd \
|
||||
-drive format=raw,file=fat:rw:$(BUILD_DIR) \
|
||||
-net none \
|
||||
-nographic
|
||||
-nographic \
|
||||
-no-reboot
|
||||
|
||||
# Phony targets
|
||||
.PHONY: all clean run setup install-deps
|
||||
@@ -96,15 +97,25 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Compile kernel source
|
||||
$(KERNEL_OBJ): $(SRC_DIR)/kernel.c
|
||||
$(BUILD_DIR)/kernel.o: $(SRC_DIR)/kernel.c
|
||||
@echo "Compiling kernel.c..."
|
||||
$(CC) -ffreestanding -fno-stack-protector -fno-pic -fshort-wchar \
|
||||
-mno-red-zone -Wall -Wextra $(EFI_INCLUDES) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/string_utils.o: $(SRC_DIR)/string_utils.c
|
||||
@echo "Compiling string_utils.c..."
|
||||
$(CC) -ffreestanding -fno-stack-protector -fno-pic -fshort-wchar \
|
||||
-mno-red-zone -Wall -Wextra $(EFI_INCLUDES) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/commands.o: $(SRC_DIR)/commands.c
|
||||
@echo "Compiling commands.c..."
|
||||
$(CC) -ffreestanding -fno-stack-protector -fno-pic -fshort-wchar \
|
||||
-mno-red-zone -Wall -Wextra $(EFI_INCLUDES) -c $< -o $@
|
||||
|
||||
# Link kernel ELF
|
||||
$(BUILD_DIR)/$(KERNEL_TARGET): $(KERNEL_OBJ) $(KERNEL_LD)
|
||||
$(BUILD_DIR)/$(KERNEL_TARGET): $(KERNEL_OBJS) $(KERNEL_LD)
|
||||
@echo "Linking kernel ELF..."
|
||||
$(LD) -nostdlib -T $(KERNEL_LD) $(KERNEL_OBJ) -o $@
|
||||
$(LD) -nostdlib -T $(KERNEL_LD) $(KERNEL_OBJS) -o $@
|
||||
|
||||
# Link to create shared object
|
||||
$(BUILD_DIR)/$(TARGET_SO): $(OBJ)
|
||||
|
||||
Reference in New Issue
Block a user