53 lines
1.3 KiB
Makefile
53 lines
1.3 KiB
Makefile
C_SOURCES = $(wildcard *.c)
|
|
ASM_SOURCES = $(wildcard *.s)
|
|
HEADERS = $(wildcard headers/*.h)
|
|
#OBJECTS = loader.o ${C_SOURCES:.c=.o}
|
|
#OBJECTS = ${C_SOURCES:.c=.o ASM_SOURCES:.s=.o}
|
|
OBJECTS = ${ASM_SOURCES:.s=.o} ${C_SOURCES:.c=.o}
|
|
#OBJECTS = ${wildcard *.o}
|
|
CC = i686-elf-gcc
|
|
CFLAGS = -masm=intel -m32 -ffreestanding -fno-builtin -fno-stack-protector \
|
|
-isystem=/usr/include -Wall -Wextra -Werror -c
|
|
LDFLAGS = -T link.ld -melf_i386
|
|
AS = nasm
|
|
ASFLAGS = -f elf32
|
|
|
|
everything: all
|
|
rm -f os.iso
|
|
cp kernel.elf iso/boot/kernel.elf
|
|
genisoimage -R \
|
|
-b boot/grub/stage2_eltorito \
|
|
-no-emul-boot \
|
|
-A os \
|
|
-input-charset utf8 \
|
|
-quiet \
|
|
-boot-info-table \
|
|
-o os.iso \
|
|
iso
|
|
|
|
all: kernel.elf
|
|
|
|
kernel.elf: $(OBJECTS)
|
|
i686-elf-ld $(LDFLAGS) $(OBJECTS) -o kernel.elf
|
|
|
|
os.iso: kernel.elf
|
|
cp kernel.elf iso/boot/kernel.elf
|
|
genisoimage -R \
|
|
-b boot/grub/stage2_eltorito \
|
|
-no-emul-boot \
|
|
-A os \
|
|
-input-charset utf8 \
|
|
-quiet \
|
|
-boot-info-table \
|
|
-o os.iso \
|
|
iso
|
|
|
|
%.o: %.c ${HEADERS}
|
|
$(CC) $(CFLAGS) $< -o $@
|
|
%.o: %.s
|
|
$(AS) $(ASFLAGS) $< -o $@
|
|
|
|
|
|
clean:
|
|
rm *.o
|