Fix platform-specific makefile
This commit is contained in:
parent
dea2a0a1d3
commit
d8dade3fb3
23
Makefile
23
Makefile
@ -1,10 +1,17 @@
|
||||
PLAT=i386
|
||||
C_SOURCES = $(wildcard kernel/*.c drivers/$(PLAT)/*.c drivers/$(PLAT)/*/*.c cpu/$(PLAT)/*.c fs/*.c)
|
||||
ASM = $(wildcard cpu/$(PLAT)/*.asm)
|
||||
S_ASM = $(wildcard cpu/$(PLAT)/*.s)
|
||||
LIBC_SOURCES = $(wildcard libc/*.c libc/*/*.c)
|
||||
LIBC_HEADERS = $(wildcard libc/*.h libc/*/*.h)
|
||||
OBJ = $(C_SOURCES:.c=.o $(shell cat psinfo/$(PLAT)/o.txt))
|
||||
OBJ = $(C_SOURCES:.c=.o cpu/$(PLAT)/boot.o)
|
||||
ASM_OBJ = $(S_ASM:.s=.o)
|
||||
S_ASM_OBJ = $(ASM:.asm=.o)
|
||||
LIBC_OBJ = $(LIBC_SOURCES:.c=.o)
|
||||
CC = $(shell cat psinfo/$(PLAT)/cc.txt)
|
||||
AS = $(shell cat psinfo/$(PLAT)/as.txt)
|
||||
AR = $(shell cat psinfo/$(PLAT)/ar.txt)
|
||||
EMU = $(shell cat psinfo/$(PLAT)/emu.txt)
|
||||
GDB = $(shell cat psinfo/$(PLAT)/gdb.txt)
|
||||
CFLAGS = -Isysroot/usr/include -Wextra -Wall -Wno-unused-parameter -g -ffreestanding
|
||||
QFLAGS = -hda image.img -m 2G -boot d -cdrom os.iso -serial stdio #-chardev socket,id=s1,port=3000,host=localhost -serial chardev:s1
|
||||
@ -14,10 +21,10 @@ QFLAGS = -hda image.img -m 2G -boot d -cdrom os.iso -serial stdio #-chardev soc
|
||||
all: os.iso
|
||||
|
||||
run: os.iso
|
||||
qemu-system-i386 $(QFLAGS) > drv_log # -monitor stdio
|
||||
$(EMU) $(QFLAGS) > drv_log # -monitor stdio
|
||||
|
||||
debug: os.iso kernel/kernel.elf
|
||||
qemu-system-i386 -s $(QFLAGS) &
|
||||
$(EMU)-s $(QFLAGS) &
|
||||
$(GDB) -ex "target remote localhost:1234" -ex "symbol-file kernel/kernel.elf"
|
||||
|
||||
os.iso: kernel/kernel.elf initrd/* initrd/prog.elf
|
||||
@ -29,8 +36,8 @@ initrd/prog.elf: prog/*
|
||||
cd prog && make
|
||||
cp prog/prog.elf initrd
|
||||
|
||||
kernel/kernel.elf: $(OBJ) libc/libc.a
|
||||
i386-elf-gcc -T linker.ld -o $@ $(CFLAGS) -nostdlib $^ -lgcc
|
||||
kernel/kernel.elf: $(OBJ) $(ASM_OBJ) $(S_ASM_OBJ) libc/libc.a
|
||||
$(CC) -T linker.ld -o $@ $(CFLAGS) -nostdlib $^ -lgcc
|
||||
|
||||
sysroot: $(LIBC_HEADERS)
|
||||
mkdir -p sysroot/usr/include
|
||||
@ -39,7 +46,7 @@ sysroot: $(LIBC_HEADERS)
|
||||
|
||||
|
||||
libc/libc.a: $(LIBC_OBJ)
|
||||
i386-elf-ar rcs $@ $^
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
%.o: %.c sysroot
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
@ -48,7 +55,7 @@ libc/libc.a: $(LIBC_OBJ)
|
||||
nasm $< -f elf -o $@
|
||||
|
||||
%.o: %.s
|
||||
i386-elf-as $< -o $@
|
||||
$(AS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ) libc/libc.a kernel/cstart.o cpu/memory.h os.iso */*.elf iso/boot/initrd.tar
|
||||
rm -rf $(OBJ) $(OBJ) $(ASM_OBJ) $(S_ASM_OBJ) libc/libc.a kernel/cstart.o cpu/memory.h os.iso */*.elf iso/boot/initrd.tar
|
||||
|
1
psinfo/i386/ar.txt
Normal file
1
psinfo/i386/ar.txt
Normal file
@ -0,0 +1 @@
|
||||
i386-elf-ar
|
1
psinfo/i386/as.txt
Normal file
1
psinfo/i386/as.txt
Normal file
@ -0,0 +1 @@
|
||||
i386-elf-as
|
1
psinfo/i386/emu.txt
Normal file
1
psinfo/i386/emu.txt
Normal file
@ -0,0 +1 @@
|
||||
qemu-system-i386
|
@ -1,5 +0,0 @@
|
||||
cpu/i386/interrupt.o
|
||||
cpu/i386/paging_helpers.o
|
||||
cpu/i386/seg_upd.o
|
||||
cpu/i386/tasking_helpers.o
|
||||
kernel/boot.o
|
Loading…
Reference in New Issue
Block a user