更新Makefile,提升编译速度

This commit is contained in:
fslongjin
2022-08-01 16:03:17 +08:00
parent bc1d2562c0
commit b2614801ac
6 changed files with 54 additions and 50 deletions

View File

@ -15,7 +15,6 @@ CFLAGS = $(GLOBAL_CFLAGS) -D $(PIC) -I $(shell pwd)
export ASFLAGS := --64
LD_LIST := head.o
OBJ_LIST := head.o
kernel_subdirs := common driver process debug filesystem time arch exception mm smp sched syscall ktest
@ -34,7 +33,7 @@ main.o: main.c
all: kernel
echo "Linking kernel..."
@echo "Linking kernel..."
ld -b elf64-x86-64 -z muldefs -o kernel head.o main.o $(shell find . -name "*.o") -T link.lds
# 生成kallsyms
current_dir=$(pwd)
@ -46,22 +45,23 @@ all: kernel
done
# 重新链接
echo "Re-Linking kernel..."
@echo "Re-Linking kernel..."
ld -b elf64-x86-64 -z muldefs -o kernel head.o main.o $(shell find . -name "*.o") ./debug/kallsyms.o -T link.lds
echo "Generating kernel ELF file..."
@echo "Generating kernel ELF file..."
# 生成内核文件
objcopy -I elf64-x86-64 -O elf64-x86-64 -R ".comment" -R ".eh_frame" kernel ../bin/kernel/kernel.elf
echo "Done."
@echo "Done."
ECHO:
@echo "$@"
$(kernel_subdirs): ECHO
$(MAKE) -C $@ all CFLAGS="$(CFLAGS)" ASFLAGS="$(ASFLAGS)" PIC="$(PIC)" kernel_root_path="$(shell pwd)"
kernel: head.o main.o $(OBJ_LIST)
kernel: head.o main.o $(kernel_subdirs)
@list='$(kernel_subdirs)'; for subdir in $$list; do \
echo "make all in $$subdir";\
cd $$subdir;\
$(MAKE) all CFLAGS="$(CFLAGS)" ASFLAGS="$(ASFLAGS)" PIC="$(PIC)" kernel_root_path="$(shell pwd)";\
cd ..;\
done
clean: