Re add program build into makefile

This commit is contained in:
pjht 2019-03-17 18:04:50 -05:00
parent 334c6a6439
commit 0f4cd96cbf
3 changed files with 22 additions and 1 deletions

View File

@ -15,11 +15,15 @@ debug: os.iso kernel/kernel.elf
qemu-system-i386 -s $(QFLAGS) &
$(GDB) -ex "target remote localhost:1234" -ex "symbol-file kernel/kernel.elf"
os.iso: kernel/kernel.elf initrd/*
os.iso: kernel/kernel.elf initrd/* initrd/prog.elf
cp kernel/kernel.elf iso/boot
ruby makeinitrd.rb initrd iso/boot/initrd
grub-mkrescue -o $@ iso
initrd/prog.elf: prog/*
cd prog && make
cp prog/prog.elf initrd
kernel/kernel.elf: $(OBJ)
i386-elf-ld -T linker.ld -o $@ $^

13
prog/Makefile Normal file
View File

@ -0,0 +1,13 @@
C_SOURCES = $(wildcard *.c)
OBJ = $(C_SOURCES:.c=.o)
CFLAGS = -Wall -g -ffreestanding
CC = i386-elf-gcc
prog.elf: $(OBJ)
i386-elf-ld -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf *.o prog.elf

4
prog/main.c Normal file
View File

@ -0,0 +1,4 @@
int _start() {
int x=17;
return x+3;
}