6 Star 11 Fork 6

rtfsc/ouros

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
make-old 6.78 KB
一键复制 编辑 原始数据 按行查看 历史
rtfsc 提交于 2021-11-27 06:34 . interrupt 80%
BUILD_DIR = ./build
ENTRY_POINT = 0xc0001500
AS = nasm
CC = gcc
LD = ld
LIB = -I lib/ -I lib/kernel/ -I lib/user/ -I kernel/ -I device/ -I thread/ -I userprog/
ASFLAGS = -f elf
CFLAGS1 = -Wall $(LIB) -E -fno-builtin \
-m32 -fno-stack-protector -nostdinc -fno-pic -gdwarf-2
CFLAGS = -Wall $(LIB) -c -fno-builtin \
-m32 -fno-stack-protector -nostdinc -fno-pic -gdwarf-2
LDFLAGS =-m elf_i386 -T script/kernel.ld -Map $(BUILD_DIR)/kernel.map -nostdlib
OBJS = ${BUILD_DIR}/grub_head.o $(BUILD_DIR)/main.o $(BUILD_DIR)/init.o \
$(BUILD_DIR)/timer.o $(BUILD_DIR)/kernel.o $(BUILD_DIR)/print.o \
$(BUILD_DIR)/debug.o $(BUILD_DIR)/memory.o $(BUILD_DIR)/bitmap.o \
$(BUILD_DIR)/string.o $(BUILD_DIR)/thread.o $(BUILD_DIR)/list.o \
$(BUILD_DIR)/switch.o $(BUILD_DIR)/console.o $(BUILD_DIR)/sync.o \
$(BUILD_DIR)/keyboard.o $(BUILD_DIR)/ioqueue.o $(BUILD_DIR)/tss.o \
$(BUILD_DIR)/process.o ${BUILD_DIR}/syscall_user.o \
$(BUILD_DIR)/syscall.o ${BUILD_DIR}/stdio.o ${BUILD_DIR}/ide.o\
$(BUILD_DIR)/interrupt.o ${BUILD_DIR}/boot.o \
############## c代码编译 ###############
$(BUILD_DIR)/main.o: kernel/main.c include/asm-i386/print.h \
include/asm-i386/stdint.h kernel/init.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/init.o: kernel/init.c kernel/init.h include/asm-i386/print.h \
include/asm-i386/stdint.h include/asm-i386/interrupt.h include/asm-i386/timer.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/interrupt.o: kernel/interrupt.c include/asm-i386/interrupt.h \
include/asm-i386/stdint.h include/linux/global.h lib/kernel/io.h include/asm-i386/print.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/timer.o: device/timer.c include/asm-i386/timer.h include/asm-i386/stdint.h\
lib/kernel/io.h include/asm-i386/print.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/debug.o: kernel/debug.c include/linux/debug.h \
include/asm-i386/print.h include/asm-i386/stdint.h include/asm-i386/interrupt.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/string.o: arch/i386/lib/string.c include/asm-i386/string.h include/asm-i386/stdint.h include/linux/global.h \
include/asm-i386/stdint.h include/linux/debug.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/bitmap.o: lib/kernel/bitmap.c include/asm-i386/bitmap.h \
include/linux/global.h include/asm-i386/stdint.h include/asm-i386/string.h include/asm-i386/stdint.h \
include/asm-i386/print.h include/asm-i386/interrupt.h include/linux/debug.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/memory.o: kernel/memory.c include/linux/memory.h include/asm-i386/stdint.h include/asm-i386/bitmap.h \
include/linux/global.h include/linux/global.h include/linux/debug.h include/asm-i386/print.h \
lib/kernel/io.h include/asm-i386/interrupt.h include/asm-i386/string.h include/asm-i386/stdint.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/thread.o: thread/thread.c include/linux/thread.h include/asm-i386/stdint.h include/linux/list.h \
include/linux/global.h include/asm-i386/string.h include/asm-i386/stdint.h include/linux/debug.h \
include/asm-i386/interrupt.h include/asm-i386/print.h include/linux/memory.h \
include/asm-i386/bitmap.h include/linux/process.h include/linux/thread.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/list.o: lib/kernel/list.c include/linux/list.h include/linux/global.h include/asm-i386/stdint.h \
include/asm-i386/interrupt.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/console.o: device/console.c include/asm-i386/console.h include/asm-i386/stdint.h \
include/asm-i386/print.h include/linux/sync.h include/linux/list.h include/linux/global.h \
include/linux/thread.h include/linux/thread.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/sync.o: thread/sync.c include/linux/sync.h include/linux/list.h include/linux/global.h \
include/asm-i386/stdint.h include/linux/thread.h include/asm-i386/string.h include/asm-i386/stdint.h include/linux/debug.h \
include/asm-i386/interrupt.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/keyboard.o: device/keyboard.c device/keyboard.h include/asm-i386/print.h \
include/asm-i386/stdint.h include/asm-i386/interrupt.h lib/kernel/io.h include/linux/ioqueue.h \
include/linux/thread.h include/linux/list.h include/linux/global.h include/linux/sync.h \
include/linux/thread.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/ioqueue.o: device/ioqueue.c include/linux/ioqueue.h include/asm-i386/stdint.h include/linux/thread.h \
include/linux/list.h include/linux/global.h include/linux/sync.h include/linux/thread.h include/asm-i386/interrupt.h \
include/linux/debug.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/tss.o: userprog/tss.c userprog/tss.h include/linux/thread.h include/asm-i386/stdint.h \
include/linux/list.h include/linux/global.h include/asm-i386/string.h include/asm-i386/stdint.h \
include/asm-i386/print.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/process.o: userprog/process.c include/linux/process.h include/linux/thread.h \
include/asm-i386/stdint.h include/linux/list.h include/linux/global.h include/linux/debug.h \
include/linux/memory.h include/asm-i386/bitmap.h userprog/tss.h include/asm-i386/interrupt.h \
include/asm-i386/string.h include/asm-i386/stdint.h
$(CC) $(CFLAGS) $< -o $@
${BUILD_DIR}/syscall_user.o: userprog/syscall_user.c include/linux/syscall.h include/linux/syscall_user.h include/asm-i386/stdint.h
${CC} ${CFLAGS} $< -o $@
${BUILD_DIR}/syscall.o : kernel/syscall.c include/asm-i386/stdint.h\
include/linux/thread.h include/linux/syscall.h include/asm-i386/stdio.h include/asm-i386/console.h include/asm-i386/string.h
${CC} ${CFLAGS} $< -o $@
${BUILD_DIR}/stdio.o : lib/stdio.c include/asm-i386/stdio.h include/asm-i386/interrupt.h \
include/linux/global.h include/asm-i386/string.h include/linux/syscall.h include/asm-i386/print.h
${CC} ${CFLAGS} $< -o $@
${BUILD_DIR}/ide.o: device/ide.c include/asm-i386/ide.h include/asm-i386/stdint.h include/asm-i386/stdio.h include/linux/global.h include/linux/sync.h
${CC} ${CFLAGS} $< -o $@
${BUILD_DIR}/boot.o: boot/boot.c include/asm-i386/stdint.h include/linux/multiboot.h include/linux/global.h
${CC} ${CFLAGS} $< -o $@
############## 汇编代码编译 ###############
$(BUILD_DIR)/kernel.o: kernel/kernel.S
$(AS) $(ASFLAGS) $< -o $@
$(BUILD_DIR)/print.o: lib/kernel/print.S
$(AS) $(ASFLAGS) $< -o $@
$(BUILD_DIR)/switch.o: thread/switch.S
$(AS) $(ASFLAGS) $< -o $@
${BUILD_DIR}/grub_head.o: boot/grub_head.S
$(AS) $(ASFLAGS) $< -o $@ -I ./boot/include/
############## 链接所有目标文件 #############
$(BUILD_DIR)/kernel.bin: $(OBJS)
$(LD) $(LDFLAGS) $^ -o $@
.PHONY : mk_dir hd clean all
mk_dir:
if [[ ! -d $(BUILD_DIR) ]];then mkdir $(BUILD_DIR);fi
update_image:
sudo cp /home/ljy/myos/build/kernel.bin /home/ljy/disk/boot/
sync
sleep 1
clean:
cd $(BUILD_DIR) && rm -f ./*
build: $(BUILD_DIR)/kernel.bin
all:clean mk_dir build update_image
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/wsljy2021/ouros.git
git@gitee.com:wsljy2021/ouros.git
wsljy2021
ouros
ouros
dev

搜索帮助