Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ jobs:
run: sudo apt-get install -y clang-format

- name: Run clang-format in dry-run mode
run: |
find src/ include/ -type f \( -name '*.c' -o -name '*.h' \) ! -name 'limine.h' -exec clang-format --Werror --dry-run {} +
run: make format
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: all kernel clean format

all: kernel

kernel:
@echo "Building Kernel..."
$(MAKE) -C kernel

format:
@echo "Formatting Kernel..."
$(MAKE) -C kernel format

clean:
@echo "Cleaning Kernel..."
$(MAKE) -C kernel clean
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ echo -e "\e[1;33m\n$(heading "Building OS binaries")\n\e[0m"

make -j$(nproc)

echo -e "\nentry.elf generated with size $(wc -c <"build/entry.elf") bytes"
echo -e "\nentry.elf generated with size $(wc -c <"build/kernel/entry.elf") bytes"

echo -e "\e[1;33m\n$(heading "Building Limine-deploy")\n\e[0m"

Expand All @@ -130,7 +130,7 @@ mkdir -p iso_root/boot/limine

# Copy the relevant files over.
cp -v limine.conf limine/limine-bios.sys limine/limine-bios-cd.bin limine/limine-uefi-cd.bin iso_root/boot/limine/
cp -v build/entry.elf iso_root/boot/
cp -v build/kernel/entry.elf iso_root/boot/

# Create the EFI boot tree and copy Limine's EFI executables over.
mkdir -p iso_root/EFI/BOOT
Expand Down
22 changes: 13 additions & 9 deletions GNUmakefile → kernel/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,36 +81,40 @@ endif

# Use "find" to glob all *.c, *.s, and *.asm files in the tree and obtain the
# object and header dependency file names.
override CFILES := $(shell find -L . -type f -name '*.c' | grep -v 'limine/')
override ASFILES := $(shell find -L . -type f -name '*.s' | grep -v 'limine/')
override OBJ := $(patsubst %.c,build/%.c.o,$(CFILES)) $(patsubst %.s,build/%.s.o,$(ASFILES))
override HEADER_DEPS := $(patsubst %.c,build/%.c.d,$(CFILES)) $(patsubst %.s,build/%.s.d,$(ASFILES))
override CFILES := $(shell find -L . -type f -name '*.c')
override ASFILES := $(shell find -L . -type f -name '*.s')

# Output directory for the build. Can be overridden.
override BUILD_DIR := ../build/kernel

override OBJ := $(patsubst %.c,$(BUILD_DIR)/%.c.o,$(CFILES)) $(patsubst %.s,$(BUILD_DIR)/%.s.o,$(ASFILES))
override HEADER_DEPS := $(patsubst %.c,$(BUILD_DIR)/%.c.d,$(CFILES)) $(patsubst %.s,$(BUILD_DIR)/%.s.d,$(ASFILES))

# Default target.
.PHONY: all
all: build/$(KERNEL)
all: $(BUILD_DIR)/$(KERNEL)

# Link rules for the final kernel executable.
build/$(KERNEL): $(OBJ)
$(BUILD_DIR)/$(KERNEL): $(OBJ)
$(LD) $(OBJ) $(LDFLAGS) -o $@

# Include header dependencies.
-include $(HEADER_DEPS)

# Compilation rules for *.c files.
build/%.c.o: %.c | $(BUILD_DIR)
$(BUILD_DIR)/%.c.o: %.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

# Compilation rules for *.S files.
build/%.s.o: %.s
$(BUILD_DIR)/%.s.o: %.s
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

# Remove object files and the final executable.
.PHONY: clean
clean:
rm -rf $(KERNEL) $(OBJ) $(HEADER_DEPS)
rm -rf $(BUILD_DIR)

# Format C source and header files (only touches src/ and main/)
.PHONY: format
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading