summaryrefslogtreecommitdiffstats
path: root/makefile
diff options
context:
space:
mode:
authorAlexey Gavrilov <alexey.gavrilov@mail.com>2026-03-27 14:03:55 +0700
committerAlexey Gavrilov <alexey.gavrilov@mail.com>2026-03-27 14:03:55 +0700
commit6ffe96d1e3f0289c2070e050cf8e1a30288e6d91 (patch)
tree746485cfc0f55dad82d1d0daad9677bf63475cba /makefile
parenta4dea4148157a94a9143dbbd92fdd88b4358676c (diff)
Cmake build generator support: build stage
Multi-target architecture implementation: each root source code directory presents the one *INTERFACE* target to it's subdirectory subtargets that link only as *STATIC* library. For instance, *arch* directory presents *Architecture* target then *Architecture* target has *CPUID*, *IO*, *PORT* and etc. dependencies Exact order of linking targets is: boot.o CRTIBUNDLE <TARGETS> CRTNBUNDLE. Sequence destruction cause to UB. Please to pay attention to this. TODO - Debug information - Build type - Toolchain file - Image creation - Build by WinGW compiler on Windows platform (optional) Signed-off-by: Alexey Gavrilov <alexey.gavrilov@mail.com>
Diffstat (limited to 'makefile')
-rw-r--r--makefile72
1 files changed, 0 insertions, 72 deletions
diff --git a/makefile b/makefile
deleted file mode 100644
index 79152f8..0000000
--- a/makefile
+++ /dev/null
@@ -1,72 +0,0 @@
-CC = i686-elf-g++
-LD = ld
-ASM = nasm
-# test -O2 flag
-CFLAGS = -std=c++20 -c -m32 -Wall -ffreestanding -nostdinc -nostdlib -fno-rtti -mgeneral-regs-only
-AFLAGS = -f elf32
-LDFLAGS = -m elf_i386 $(patsubst %,-L%,$(subst :, ,$(LIBS_PATH))) -lgcc
-QEMUFLAGS =
-
-CFILES = $(shell find ./ -type f \( -name \*.cpp -o -name \*.c \))
-AFILES = $(shell find ./ -type f \( -iname \*.s -o -name \*.asm \))
-LDFILE = ./kernel/linker.ld
-SOURCE_FILES = $(CFILES) $(AFILES)
-OBJ_FILES = $(addprefix $(BDIR)/, $(addsuffix .o, $(basename $(SOURCE_FILES))))
-INCLUDE = ./include
-# Bad practice!
-ARCHDIR = arch/x86
-
-ifdef DEBUG
- CFLAGS := -g3 $(CFLAGS)
- AFLAGS := -g $(AFLAGS)
- QEMUFLAGS := -s -S $(QEMUFLAGS)
-endif
-
-OS_BINARY = $(BDIR)/kernel.bin
-BDIR = ./build
-
-BOOTOBJ = $(filter %boot.o, $(OBJ_FILES))
-CRTIOBJ = $(filter %crti.o, $(OBJ_FILES))
-CRTNOBJ = $(filter %crtn.o, $(OBJ_FILES))
-OBJ_REORDERING = $(filter-out $(BOOTOBJ), $(filter-out $(CRTIOBJ), $(filter-out $(CRTNOBJ), $(OBJ_FILES))))
-
-
-.PHONY: install $(SOURCE_FILES)
-
-build: startbuild $(SOURCE_FILES)
- @echo "Bootfile: " $(BOOTOBJ) $(CRTIOBJ) $(CRTNOBJ)
- @echo $(OBJ_FILES)
- echo $(AFLAGS)
- echo $(CFLAGS)
- @echo "Link object files..."
- $(LD) -o $(OS_BINARY) -L$(ARCHDIR) -T$(LDFILE) $(BOOTOBJ) $(CRTIOBJ) $(LIBS_PATH)crtbegin.o $(OBJ_REORDERING) $(LIBS_PATH)crtend.o $(CRTNOBJ) $(LDFLAGS)
- @echo "Project was built"
-
-$(CFILES):
- mkdir -p $(BDIR)/$(@D)
- $(CC) $(CFLAGS) -I $(INCLUDE) -o $(BDIR)/$(addsuffix .o, $(basename $@)) $@
-
-$(AFILES):
- mkdir -p $(BDIR)/$(@D)
- $(ASM) $(AFLAGS) -o $(BDIR)/$(addsuffix .o, $(basename $@)) $@
-
-startbuild:
- @echo $(OBJ_FILES)
- rm -rf $(BDIR)
- mkdir $(BDIR)
- @echo "Compile source files..."
-
-install:
- @echo "Creating an iso image of OS"
- mkdir -p ./iso/os/
- cp ./$(BDIR)/kernel.bin ./iso/os/
- grub-mkrescue -o ./$(BDIR)/kernel.iso ./iso
-
-clean:
- rm -rf $(BDIR)
- rm -rf ./iso/os/kernel.bin
-
-run:
- qemu-system-i386 $(QEMUFLAGS) -cdrom ./$(BDIR)/kernel.iso
-
-all: clean build install run