1
0
포크 0

Makefile: refactor subdirectory makefiles

This commit is contained in:
Aaron Lindsay 2012-09-26 15:35:52 -04:00
부모 f9244836e1
커밋 c455b1eeb3
9개의 변경된 파일74개의 추가작업 그리고 23개의 파일을 삭제

파일 보기

@ -22,11 +22,15 @@ KCFLAGS = -g -Wall -Wextra -Werror -nostdlib -nostartfiles -fno-builtin -std=gnu
KLDFLAGS = -T link.ld -L /usr/lib/gcc/arm-elf/4.7.0/
EXTRA_LIBS = -lgcc
KOBJS =
# Define KOBJS as a 'simply expanded' variable
KOBJS :=
include boot/Makefile.inc
include kernel/Makefile.inc
include devices/Makefile.inc
# Initialize sub-directory Makefile inclusion
BASEDIR = $(shell pwd)
SUBDIRS := boot kernel devices
ifneq (,$(SUBDIRS))
include $(patsubst %,%/kernel.mk,$(SUBDIRS))
endif
.PHONY: all clean boot boot-gdb

파일 보기

@ -1,3 +0,0 @@
BOOT_PREFIX = boot
KOBJS += $(BOOT_PREFIX)/start.o

10
boot/kernel.mk Normal file
파일 보기

@ -0,0 +1,10 @@
DIRNAME := boot
SUBDIRS :=
include $(BASEDIR)/header.mk
OBJS_$(d) := $(d)/start.o
KOBJS += $(OBJS_$(d))
include $(BASEDIR)/footer.mk

파일 보기

@ -1,5 +0,0 @@
DEVICES_PREFIX = devices
KOBJS += $(DEVICES_PREFIX)/pl011.o
KOBJS += $(DEVICES_PREFIX)/pl110.o
KOBJS += $(DEVICES_PREFIX)/pl111.o

12
devices/kernel.mk Normal file
파일 보기

@ -0,0 +1,12 @@
DIRNAME := devices
SUBDIRS :=
include $(BASEDIR)/header.mk
OBJS_$(d) := $(d)/pl011.o \
$(d)/pl110.o \
$(d)/pl111.o
KOBJS += $(OBJS_$(d))
include $(BASEDIR)/footer.mk

12
footer.mk Normal file
파일 보기

@ -0,0 +1,12 @@
# Included at the bottom of each subdirectory Makefile
# Include any subdirectory Makefiles
ifneq (,$(SUBDIRS))
include $(patsubst %,$(d)/%/kernel.mk,$(SUBDIRS))
endif
# Pop the previous directory off the 'stack'
d := $(dirstack_$(sp))
sp := $(basename $(sp))
# Clear SUBDIRS so that it defaults to empty for the next directory
SUBDIRS :=

13
header.mk Normal file
파일 보기

@ -0,0 +1,13 @@
# Included at the top of each subdirectory Makefile, immediately
# following the local re-definition of DIRNAME
# Push the previous directory onto the 'stack'
sp := $(sp).x
dirstack_$(sp) := $(d)
# Update $(d) to be the current directory
ifneq (,$(d))
d := $(d)/$(DIRNAME)
else
d := $(DIRNAME)
endif

파일 보기

@ -1,11 +0,0 @@
KERNEL_PREFIX = kernel
KOBJS += $(KERNEL_PREFIX)/atags.o
KOBJS += $(KERNEL_PREFIX)/console.o
KOBJS += $(KERNEL_PREFIX)/font.o
KOBJS += $(KERNEL_PREFIX)/framebuffer.o
KOBJS += $(KERNEL_PREFIX)/list.o
KOBJS += $(KERNEL_PREFIX)/mm.o
KOBJS += $(KERNEL_PREFIX)/mmu.o
KOBJS += $(KERNEL_PREFIX)/print.o
KOBJS += $(KERNEL_PREFIX)/start_kernel.o

19
kernel/kernel.mk Normal file
파일 보기

@ -0,0 +1,19 @@
DIRNAME := kernel
SUBDIRS :=
include $(BASEDIR)/header.mk
OBJS_$(d) := $(d)/atags.o \
$(d)/console.o \
$(d)/font.o \
$(d)/framebuffer.o \
$(d)/kmalloc.o \
$(d)/list.o \
$(d)/mm.o \
$(d)/mmu.o \
$(d)/print.o \
$(d)/start_kernel.o
KOBJS += $(OBJS_$(d))
include $(BASEDIR)/footer.mk