Big reorganization of the makefile
This commit is contained in:
parent
bc53c696fc
commit
fb5fc7ba6c
187
Makefile
187
Makefile
|
@ -52,103 +52,23 @@ CL2='\033[1;36m'
|
||||||
CL3='\033[0m'
|
CL3='\033[0m'
|
||||||
NC='\033[1;37m'
|
NC='\033[1;37m'
|
||||||
|
|
||||||
## MAIN MAKEFILE ------------------------------------------------------------- #
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all : kernel
|
all : OS/K
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
test: all
|
|
||||||
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
|
|
||||||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
|
|
||||||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
|
|
||||||
.PHONY: test32
|
|
||||||
test32: all
|
|
||||||
@qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
|
|
||||||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
|
|
||||||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
|
|
||||||
|
|
||||||
.PHONY: debug
|
|
||||||
debug: all
|
|
||||||
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log &
|
|
||||||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
|
|
||||||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: kernel
|
|
||||||
kernel: $(BINDIR)/kaleid $(BINDIR)/disk.img
|
|
||||||
@mkdir -p $(BINDIR)/disk
|
|
||||||
@echo ${CL2}[[$@]] ${NC}Integrating kernel...${CL3}
|
|
||||||
-@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
|
||||||
@$(MBRDIR)/mount.sh $(BINDIR)/disk.img $(BINDIR)/disk
|
|
||||||
@cp $(BINDIR)/kaleid $(BINDIR)/disk/boot/kaleid
|
|
||||||
@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
|
||||||
@echo ${CL2}[[$@]] ${CL}Success.${CL3}
|
|
||||||
@rmdir $(BINDIR)/disk
|
|
||||||
|
|
||||||
.PHONY: install_mbr
|
|
||||||
install_mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg
|
|
||||||
@mkdir -p $(BINDIR)/disk
|
|
||||||
@echo ${CL2}[$@] ${NC}Installing MBR on image...${CL3}
|
|
||||||
-@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
|
||||||
@$(MBRDIR)/grub-install.sh $(BINDIR)/disk.img $(BINDIR)/disk $(MBRDIR)/grub.cfg
|
|
||||||
@tail -1 grub.log | head -1 | grep "Installation terminée, sans erreur."
|
|
||||||
@rmdir $(BINDIR)/disk
|
|
||||||
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
-@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
|
||||||
@rm -Rvf $(BINDIR)/*.*
|
|
||||||
@rm -Rvf $(OBJDIR)/*.o
|
|
||||||
@rm -Rvf $(OBJDIR)/*/*.o
|
|
||||||
@rm -Rvf $(OBJDIR)/*/*/*.o
|
|
||||||
|
|
||||||
.PHONY: kal_com
|
|
||||||
kal_com: $(OBJDIR)/kaleid/atoi.o $(OBJDIR)/kaleid/ctype.o \
|
|
||||||
$(OBJDIR)/kaleid/itoa.o $(OBJDIR)/kaleid/memory.o \
|
|
||||||
$(OBJDIR)/kaleid/rand.o $(OBJDIR)/kaleid/sprintf.o \
|
|
||||||
$(OBJDIR)/kaleid/status.o $(OBJDIR)/kaleid/string.o \
|
|
||||||
$(OBJDIR)/kaleid/strtol.o $(OBJDIR)/kaleid/argv.o \
|
|
||||||
$(OBJDIR)/kaleid/prog.o $(OBJDIR)/kaleid/atol.o \
|
|
||||||
$(OBJDIR)/kaleid/atou.o $(OBJDIR)/kaleid/atoul.o \
|
|
||||||
$(OBJDIR)/kaleid/utoa.o $(OBJDIR)/kaleid/ltoa.o \
|
|
||||||
$(OBJDIR)/kaleid/ultoa.o
|
|
||||||
|
|
||||||
.PHONY: kal_kern
|
|
||||||
kal_kern: $(OBJDIR)/kaleid/kernel/cpuid.o $(OBJDIR)/kaleid/kernel/init.o \
|
|
||||||
$(OBJDIR)/kaleid/kernel/table.o $(OBJDIR)/kaleid/kernel/cursor.o \
|
|
||||||
$(OBJDIR)/kaleid/kernel/term.o $(OBJDIR)/kaleid/kernel/vga.o \
|
|
||||||
$(OBJDIR)/kaleid/kernel/panic.o
|
|
||||||
|
|
||||||
|
|
||||||
$(BINDIR)/kaleid: $(OBJDIR)/boot/kaleid.x86_64
|
|
||||||
@echo ${CL2}[$@] ${NC}Objcopy...${CL3}
|
|
||||||
@x86_64-elf-objcopy -I elf64-x86-64 -O elf32-i386 $(OBJDIR)/boot/kaleid.x86_64 $(BINDIR)/kaleid
|
|
||||||
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
||||||
|
|
||||||
$(OBJDIR)/boot/kaleid.x86_64: $(OBJDIR)/boot/loader.o kal_com kal_kern
|
|
||||||
@echo ${CL2}[$@] ${NC}Linking kernel objects...${CL3}
|
|
||||||
@$(LD) $(LDFLAGS) -T build/kernel.ld \
|
|
||||||
$(OBJDIR)/boot/loader.o \
|
|
||||||
$(OBJDIR)/kaleid/*.o \
|
|
||||||
$(OBJDIR)/kaleid/kernel/*.o \
|
|
||||||
-o $(OBJDIR)/boot/kaleid.x86_64
|
|
||||||
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
||||||
|
|
||||||
$(OBJDIR)/boot/loader.o: $(LOADERDIR)/loader.asm
|
|
||||||
@echo ${CL2}[$@] ${NC}Making loader...${CL3}
|
|
||||||
@$(ASM) $(ASMFLAGS) $(LOADERDIR)/loader.asm -o $(OBJDIR)/boot/loader.o > /dev/null
|
|
||||||
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
||||||
|
|
||||||
$(BINDIR)/disk.img: $(MBRDIR)/create_disk.sh
|
|
||||||
@echo ${CL2}[$@]${NC} Constructing disk image...${CL3}
|
|
||||||
-@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
|
||||||
@$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img
|
|
||||||
@make install_mbr
|
|
||||||
@echo ${CL2}[$@]${NC} Constructing disk image...${CL3}
|
|
||||||
## KALEID MAKEFILE ----------------------------------------------------------- #
|
## KALEID MAKEFILE ----------------------------------------------------------- #
|
||||||
|
|
||||||
# Crtlib objects
|
# Common objects
|
||||||
|
kal_com_obj= $(OBJDIR)/kaleid/atoi.o $(OBJDIR)/kaleid/ctype.o \
|
||||||
|
$(OBJDIR)/kaleid/itoa.o $(OBJDIR)/kaleid/memory.o \
|
||||||
|
$(OBJDIR)/kaleid/rand.o $(OBJDIR)/kaleid/sprintf.o \
|
||||||
|
$(OBJDIR)/kaleid/status.o $(OBJDIR)/kaleid/string.o \
|
||||||
|
$(OBJDIR)/kaleid/strtol.o $(OBJDIR)/kaleid/argv.o \
|
||||||
|
$(OBJDIR)/kaleid/prog.o $(OBJDIR)/kaleid/atol.o \
|
||||||
|
$(OBJDIR)/kaleid/atou.o $(OBJDIR)/kaleid/atoul.o \
|
||||||
|
$(OBJDIR)/kaleid/utoa.o $(OBJDIR)/kaleid/ltoa.o \
|
||||||
|
$(OBJDIR)/kaleid/ultoa.o
|
||||||
|
|
||||||
$(OBJDIR)/kaleid/atoi.o: $(KERNELDIR)/crtlib/atoi.c
|
$(OBJDIR)/kaleid/atoi.o: $(KERNELDIR)/crtlib/atoi.c
|
||||||
@$(KCC) -D_NEED_ATOI $< -o $@
|
@$(KCC) -D_NEED_ATOI $< -o $@
|
||||||
$(OBJDIR)/kaleid/atol.o: $(KERNELDIR)/crtlib/atoi.c
|
$(OBJDIR)/kaleid/atol.o: $(KERNELDIR)/crtlib/atoi.c
|
||||||
|
@ -179,14 +99,17 @@ $(OBJDIR)/kaleid/string.o: $(KERNELDIR)/crtlib/string.c
|
||||||
@$(KCC) $< -o $@
|
@$(KCC) $< -o $@
|
||||||
$(OBJDIR)/kaleid/strtol.o: $(KERNELDIR)/crtlib/strtol.c
|
$(OBJDIR)/kaleid/strtol.o: $(KERNELDIR)/crtlib/strtol.c
|
||||||
@$(KCC) $< -o $@
|
@$(KCC) $< -o $@
|
||||||
|
|
||||||
# Extra objects
|
|
||||||
$(OBJDIR)/kaleid/argv.o: $(KERNELDIR)/extras/argv.c
|
$(OBJDIR)/kaleid/argv.o: $(KERNELDIR)/extras/argv.c
|
||||||
@$(KCC) $< -o $@
|
@$(KCC) $< -o $@
|
||||||
$(OBJDIR)/kaleid/prog.o: $(KERNELDIR)/extras/prog.c
|
$(OBJDIR)/kaleid/prog.o: $(KERNELDIR)/extras/prog.c
|
||||||
@$(KCC) $< -o $@
|
@$(KCC) $< -o $@
|
||||||
|
|
||||||
# Kernel objects
|
# Kernel objects
|
||||||
|
kal_kern_obj= $(OBJDIR)/kaleid/kernel/cpuid.o $(OBJDIR)/kaleid/kernel/init.o \
|
||||||
|
$(OBJDIR)/kaleid/kernel/table.o $(OBJDIR)/kaleid/kernel/cursor.o \
|
||||||
|
$(OBJDIR)/kaleid/kernel/term.o $(OBJDIR)/kaleid/kernel/vga.o \
|
||||||
|
$(OBJDIR)/kaleid/kernel/panic.o
|
||||||
|
|
||||||
$(OBJDIR)/kaleid/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c
|
$(OBJDIR)/kaleid/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c
|
||||||
@$(KCC) $< -o $@
|
@$(KCC) $< -o $@
|
||||||
$(OBJDIR)/kaleid/kernel/init.o: $(KERNELDIR)/kernel/init/init.c
|
$(OBJDIR)/kaleid/kernel/init.o: $(KERNELDIR)/kernel/init/init.c
|
||||||
|
@ -201,3 +124,77 @@ $(OBJDIR)/kaleid/kernel/vga.o: $(KERNELDIR)/kernel/io/vga.c
|
||||||
@$(KCC) $< -o $@
|
@$(KCC) $< -o $@
|
||||||
$(OBJDIR)/kaleid/kernel/panic.o: $(KERNELDIR)/kernel/ke/panic.c
|
$(OBJDIR)/kaleid/kernel/panic.o: $(KERNELDIR)/kernel/ke/panic.c
|
||||||
@$(KCC) $< -o $@
|
@$(KCC) $< -o $@
|
||||||
|
|
||||||
|
## MAIN MAKEFILE ------------------------------------------------------------- #
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: all
|
||||||
|
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
|
||||||
|
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
|
||||||
|
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
|
||||||
|
.PHONY: test32
|
||||||
|
test32: all
|
||||||
|
@qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
|
||||||
|
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
|
||||||
|
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
|
||||||
|
|
||||||
|
.PHONY: debug
|
||||||
|
debug: all
|
||||||
|
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log &
|
||||||
|
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
|
||||||
|
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
|
||||||
|
|
||||||
|
.PHONY:OS/K
|
||||||
|
OS/K: $(BINDIR)/kaleid $(BINDIR)/disk.img
|
||||||
|
@mkdir -p $(BINDIR)/disk
|
||||||
|
@echo ${CL2}[[$@]] ${NC}Integrating kernel...${CL3}
|
||||||
|
-@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
||||||
|
@$(MBRDIR)/mount.sh $(BINDIR)/disk.img $(BINDIR)/disk
|
||||||
|
@cp $(BINDIR)/kaleid $(BINDIR)/disk/boot/kaleid
|
||||||
|
@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
||||||
|
@echo ${CL2}[[$@]] ${CL}Success.${CL3}
|
||||||
|
@rmdir $(BINDIR)/disk
|
||||||
|
|
||||||
|
.PHONY: install_mbr
|
||||||
|
install_mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg
|
||||||
|
@mkdir -p $(BINDIR)/disk
|
||||||
|
@echo ${CL2}[$@] ${NC}Installing MBR on image...${CL3}
|
||||||
|
-@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
||||||
|
@$(MBRDIR)/grub-install.sh $(BINDIR)/disk.img $(BINDIR)/disk $(MBRDIR)/grub.cfg
|
||||||
|
@tail -1 grub.log | head -1 | grep "Installation terminée, sans erreur."
|
||||||
|
@rmdir $(BINDIR)/disk
|
||||||
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
-@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
||||||
|
@rm -Rvf $(BINDIR)/*.*
|
||||||
|
@rm -Rvf $(OBJDIR)/*.o
|
||||||
|
@rm -Rvf $(OBJDIR)/*/*.o
|
||||||
|
@rm -Rvf $(OBJDIR)/*/*/*.o
|
||||||
|
|
||||||
|
$(BINDIR)/kaleid: $(OBJDIR)/boot/kaleid.x86_64
|
||||||
|
@echo ${CL2}[$@] ${NC}Objcopy...${CL3}
|
||||||
|
@x86_64-elf-objcopy -I elf64-x86-64 -O elf32-i386 $(OBJDIR)/boot/kaleid.x86_64 $(BINDIR)/kaleid
|
||||||
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
||||||
|
|
||||||
|
$(OBJDIR)/boot/kaleid.x86_64: $(kal_kern_obj) $(kal_com_obj) $(OBJDIR)/boot/loader.o
|
||||||
|
@echo ${CL2}[$@] ${NC}Linking kernel objects...${CL3}
|
||||||
|
@$(LD) $(LDFLAGS) -T build/kernel.ld \
|
||||||
|
$(OBJDIR)/boot/loader.o \
|
||||||
|
$(OBJDIR)/kaleid/*.o \
|
||||||
|
$(OBJDIR)/kaleid/kernel/*.o \
|
||||||
|
-o $(OBJDIR)/boot/kaleid.x86_64
|
||||||
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
||||||
|
|
||||||
|
$(OBJDIR)/boot/loader.o: $(LOADERDIR)/loader.asm
|
||||||
|
@echo ${CL2}[$@] ${NC}Making loader...${CL3}
|
||||||
|
@$(ASM) $(ASMFLAGS) $(LOADERDIR)/loader.asm -o $(OBJDIR)/boot/loader.o > /dev/null
|
||||||
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
||||||
|
|
||||||
|
$(BINDIR)/disk.img: $(MBRDIR)/create_disk.sh
|
||||||
|
@echo ${CL2}[$@]${NC} Constructing disk image...${CL3}
|
||||||
|
-@$(MBRDIR)/umount.sh $(BINDIR)/disk
|
||||||
|
@$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img
|
||||||
|
@make install_mbr
|
||||||
|
@echo ${CL2}[$@]${NC} Constructing disk image...${CL3}
|
||||||
|
|
Loading…
Reference in New Issue