Re add program build into makefile
This commit is contained in:
parent
334c6a6439
commit
0f4cd96cbf
6
Makefile
6
Makefile
@ -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
13
prog/Makefile
Normal 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
4
prog/main.c
Normal file
@ -0,0 +1,4 @@
|
||||
int _start() {
|
||||
int x=17;
|
||||
return x+3;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user