mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
更新Makefile,提升编译速度
This commit is contained in:
@ -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:
|
||||
|
@ -3,13 +3,15 @@ CFLAGS += -I .
|
||||
|
||||
kernel_common_subdirs:=libELF math
|
||||
|
||||
all: glib.o printk.o cpu.o bitree.o kfifo.o wait_queue.o mutex.o wait.o unistd.o
|
||||
@list='$(kernel_common_subdirs)'; for subdir in $$list; do \
|
||||
echo "make all in $$subdir";\
|
||||
cd $$subdir;\
|
||||
$(MAKE) all CFLAGS="$(CFLAGS)";\
|
||||
cd ..;\
|
||||
done
|
||||
ECHO:
|
||||
@echo "$@"
|
||||
|
||||
$(kernel_common_subdirs): ECHO
|
||||
|
||||
$(MAKE) -C $@ all CFLAGS="$(CFLAGS)" ASFLAGS="$(ASFLAGS)" PIC="$(PIC)"
|
||||
|
||||
all: glib.o printk.o cpu.o bitree.o kfifo.o wait_queue.o mutex.o wait.o unistd.o $(kernel_common_subdirs)
|
||||
|
||||
|
||||
glib.o: glib.c
|
||||
gcc $(CFLAGS) -c glib.c -o glib.o
|
||||
|
@ -17,7 +17,7 @@ generate_kallsyms: kallsyms.o
|
||||
|
||||
nm -n $(kernel_root_path)/kernel | ./kallsyms > kallsyms.S
|
||||
gcc -c kallsyms.S -o kallsyms.o
|
||||
echo "Kallsyms generated."
|
||||
@echo "Kallsyms generated."
|
||||
|
||||
|
||||
clean:
|
||||
|
@ -3,13 +3,15 @@ CFLAGS += -I .
|
||||
|
||||
kernel_driver_subdirs:=video interrupt usb pci uart acpi disk keyboard mouse multiboot2 timers
|
||||
|
||||
all:
|
||||
@list='$(kernel_driver_subdirs)'; for subdir in $$list; do \
|
||||
echo "make all in $$subdir";\
|
||||
cd $$subdir;\
|
||||
$(MAKE) all CFLAGS="$(CFLAGS)" PIC="$(PIC)";\
|
||||
cd ..;\
|
||||
done
|
||||
ECHO:
|
||||
@echo "$@"
|
||||
|
||||
$(kernel_driver_subdirs): ECHO
|
||||
|
||||
$(MAKE) -C $@ all CFLAGS="$(CFLAGS)" ASFLAGS="$(ASFLAGS)" PIC="$(PIC)"
|
||||
|
||||
all: $(kernel_driver_subdirs)
|
||||
|
||||
|
||||
clean:
|
||||
echo "Done."
|
Reference in New Issue
Block a user