Browse Source

Makefile: refactor subdirectory makefiles

master
Aaron Lindsay 8 years ago
parent
commit
c455b1eeb3
9 changed files with 75 additions and 24 deletions
  1. +9
    -5
      Makefile
  2. +0
    -3
      boot/Makefile.inc
  3. +10
    -0
      boot/kernel.mk
  4. +0
    -5
      devices/Makefile.inc
  5. +12
    -0
      devices/kernel.mk
  6. +12
    -0
      footer.mk
  7. +13
    -0
      header.mk
  8. +0
    -11
      kernel/Makefile.inc
  9. +19
    -0
      kernel/kernel.mk

+ 9
- 5
Makefile View File

@ -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 =
include boot/Makefile.inc
include kernel/Makefile.inc
include devices/Makefile.inc
# Define KOBJS as a 'simply expanded' variable
KOBJS :=
# 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


+ 0
- 3
boot/Makefile.inc View File

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

+ 10
- 0
boot/kernel.mk View File

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

+ 0
- 5
devices/Makefile.inc View File

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

+ 12
- 0
devices/kernel.mk View 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
- 0
footer.mk View 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
- 0
header.mk View 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

+ 0
- 11
kernel/Makefile.inc View File

@ -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
- 0
kernel/kernel.mk View 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

Loading…
Cancel
Save