From 9ee01470ef6424ea448a7eddc00c1f936727b460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 3 Nov 2015 09:45:33 +0100 Subject: improve Makefiles --- Makefile | 24 +++++++++++++----------- kernel/Makefile | 6 +++--- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 0f7ed29..22c435d 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,29 @@ GRUB_DIR=grub KERNEL_DIR=kernel -DST=iso +ISO_DIR=iso ISO=kernel.iso +.PHONY: kernel iso + all: run -run: kernel.elf +run: kernel qemu-system-i386 -kernel $(KERNEL_DIR)/kernel.elf -run-iso: create_iso +run-iso: $(ISO) qemu-system-i386 -hda $(ISO) -create_iso: cpy - grub-mkrescue -o $(ISO) $(DST) +kernel.iso: iso + grub-mkrescue -o $(ISO) $(ISO_DIR) -cpy: kernel.elf - mkdir -p $(DST)/boot/grub - cp $(KERNEL_DIR)/kernel.elf $(DST)/boot/ - cp $(GRUB_DIR)/grub.cfg $(DST)/boot/grub/ +iso: kernel + mkdir -p $(ISO_DIR)/boot/grub + cp $(KERNEL_DIR)/kernel.elf $(ISO_DIR)/boot/ + cp $(GRUB_DIR)/grub.cfg $(ISO_DIR)/boot/grub/ -kernel.elf: +kernel: cd $(KERNEL_DIR); $(MAKE) clean: cd $(KERNEL_DIR); $(MAKE) clean - -rm -fr $(ISO) $(DST) 2>/dev/null + -rm -fr $(ISO) $(ISO_DIR) 2>/dev/null diff --git a/kernel/Makefile b/kernel/Makefile index cc03386..9846422 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,11 +1,11 @@ all: kernel.elf +.c.o : + gcc -std=gnu99 -m32 -fno-builtin -ffreestanding -nostdlib -Wall -Wextra -c $< -o $@ + kernel.elf: kernel.o entry.o ld -Tlinker.ld -melf_i386 entry.o kernel.o -o kernel.elf -kernel.o: kernel.c - gcc -std=gnu99 -m32 -fno-builtin -ffreestanding -nostdlib -Wall -Wextra -c kernel.c - # entry.o: entry.S # as -32 $< -o entry.o -- cgit v1.1-2-g2b99