Makefile refactor * 2

multiboot
E. Almqvist 3 years ago
parent 68d12d86d2
commit 0ccf261a5c
  1. 23
      Makefile

@ -1,6 +1,19 @@
# Compilation/assembler settings
CC = gcc CC = gcc
CFLAGS = -fno-pie -m32 -Os -ffreestanding CFLAGS = -fno-pie -m32 -Os -ffreestanding
AA = nasm
AFLAGS =
LD = gcc
LDFLAGS = -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32
# Debug settings
VM = qemu-system-x86_64
VMFLAGS =
# Do not touch these.
C_SOURCES = $(wildcard kernel/*.c drivers/*.c lib/*.c) C_SOURCES = $(wildcard kernel/*.c drivers/*.c lib/*.c)
HEADERS = $(wildcard kernel/*.h drivers/*.h lib/*.h) HEADERS = $(wildcard kernel/*.h drivers/*.h lib/*.h)
OBJ = $(C_SOURCES:.c=.o) OBJ = $(C_SOURCES:.c=.o)
@ -8,13 +21,13 @@ OBJ = $(C_SOURCES:.c=.o)
all: eos.iso all: eos.iso
run: all run: all
qemu-system-x86_64 eos.iso $(VM) $(VMFLAGS) eos.iso
drun: clean run drun: clean run
grub: eos_grub.iso grub: eos_grub.iso
qemu-system-x86_64 eos_grub.iso $(VM) $(VMFLAGS) eos_grub.iso
eos_grub.iso : kernel.bin grub/grub.cfg eos_grub.iso : kernel.bin grub/grub.cfg
mkdir -p boot/grub mkdir -p boot/grub
@ -26,17 +39,17 @@ eos.iso: bootloader/bootloader.bin kernel.bin
cat $^ > eos.iso cat $^ > eos.iso
kernel.bin: kernel/kernel_entry.o kernel/enable_paging.o $(OBJ) kernel.bin: kernel/kernel_entry.o kernel/enable_paging.o $(OBJ)
gcc -o $@ $^ -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32 $(LD) -o $@ $^ $(LDFLAGS)
%.o : %.c ${HEADERS} %.o : %.c ${HEADERS}
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
%.o : %.asm %.o : %.asm
nasm $< -f elf -o $@ $(AA) $< -f elf -o $@ $(AFLAGS)
%.bin : %.asm %.bin : %.asm
nasm $< -f bin -o $@ $(AA) $< -f bin -o $@ $(AFLAGS)
clean: clean:
rm -fr *.bin *.dis *.o eos.iso *.map boot/ *.iso rm -fr *.bin *.dis *.o eos.iso *.map boot/ *.iso

Loading…
Cancel
Save