flatten the make system a little bit by providing only modules as a

compilation unit.

to add a module as a dependency of another, just add to the MODULE make
variable, instead of APPS/LIBS/DEVS
This commit is contained in:
Travis Geiselbrecht
2008-09-05 04:14:40 -07:00
parent 573f8608e4
commit f54ab82112
10 changed files with 65 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
KOBJS += \
OBJS += \
$(LOCAL_DIR)/dev.o

View File

@@ -1,8 +1,11 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
LIBS += debug heap
MODULES += \
lib/libc \
lib/debug \
lib/heap
KOBJS += \
OBJS += \
$(LOCAL_DIR)/debug.o \
$(LOCAL_DIR)/dpc.o \
$(LOCAL_DIR)/event.o \

View File

@@ -1,15 +1,15 @@
-include local.mk
include macros.mk
PROJECT ?= armemu-test
DEBUG ?= false
PROJECT ?= beagle-test
DEBUG ?= 1
BUILDDIR := build-$(PROJECT)
OUTBIN := $(BUILDDIR)/lk.bin
OUTELF := $(BUILDDIR)/lk
CONFIGHEADER := $(BUILDDIR)/config.h
INCLUDES := -Iinclude
INCLUDES := -I$(BUILDDIR) -Iinclude
CFLAGS := -O2 -g -fno-builtin -finline -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -include $(CONFIGHEADER)
#CFLAGS += -Werror
CPPFLAGS := -fno-exceptions -fno-rtti -fno-threadsafe-statics
@@ -21,12 +21,11 @@ CFLAGS += -ffunction-sections -fdata-sections
LDFLAGS += -gc-sections
# top level rule
all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym
all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym $(OUTELF).size
# the following three object lists are identical except for the ordering
# which is bootobjs, kobjs, objs
BOOTOBJS :=
KOBJS :=
OBJS :=
# a linker script needs to be declared in one of the project/target/platform files
@@ -46,15 +45,14 @@ SRCDEPS := $(CONFIGHEADER)
TARGET :=
PLATFORM :=
ARCH :=
LIBS := libc
APPS :=
DEVS :=
ALLMODULES :=
MODULES :=
# any rules you put here will also be built by the system before considered being complete
EXTRA_BUILDDEPS :=
EXTRA_BUILDDEPS :=
# any rules you put here will be depended on in clean builds
EXTRA_CLEANDEPS :=
EXTRA_CLEANDEPS :=
include project/$(PROJECT)/rules.mk
include target/$(TARGET)/rules.mk
@@ -65,20 +63,15 @@ include target/rules.mk
include kernel/rules.mk
include dev/rules.mk
DEVS := $(sort $(DEVS))
LIBS := $(sort $(LIBS))
APPS := $(sort $(APPS))
include $(addsuffix /rules.mk,$(addprefix dev/,$(DEVS)))
include $(addsuffix /rules.mk,$(addprefix lib/,$(LIBS)))
include $(addsuffix /rules.mk,$(addprefix app/,$(APPS)))
# recursively include any modules in the MODULE variable, leaving a trail of included
# modules in the ALLMODULES list
include module.mk
# any extra top level build dependencies that someone declared
all:: $(EXTRA_BUILDDEPS)
ALLOBJS := \
$(BOOTOBJS) \
$(KOBJS) \
$(OBJS)
# add some automatic configuration defines
@@ -87,21 +80,21 @@ DEFINES += \
TARGET_$(TARGET)=1 \
PLATFORM_$(PLATFORM)=1 \
ARCH_$(ARCH)=1 \
$(addsuffix =1,$(addprefix WITH_DEV_,$(DEVS))) \
$(addsuffix =1,$(addprefix WITH_LIB_,$(LIBS))) \
$(addsuffix =1,$(addprefix WITH_APP_,$(APPS)))
$(addsuffix =1,$(addprefix WITH_,$(ALLMODULES)))
# debug build?
ifeq ($(DEBUG),true)
ifneq ($(DEBUG),)
DEFINES += \
DEBUG=1
DEBUG=$(DEBUG)
endif
ALLOBJS := $(addprefix $(BUILDDIR)/,$(ALLOBJS))
DEPS := $(ALLOBJS:%o=%d)
CC := $(TOOLCHAIN_PREFIX)gcc
# default to no ccache
CCACHE ?=
CC := $(CCACHE) $(TOOLCHAIN_PREFIX)gcc
LD := $(TOOLCHAIN_PREFIX)ld
OBJDUMP := $(TOOLCHAIN_PREFIX)objdump
OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy
@@ -109,6 +102,10 @@ CPPFILT := $(TOOLCHAIN_PREFIX)c++filt
SIZE := $(TOOLCHAIN_PREFIX)size
NM := $(TOOLCHAIN_PREFIX)nm
# comment out or override if you want to see the full output of each command
NOECHO ?= @
# the logic to compile and link stuff is in here
include build.mk
clean: $(EXTRA_CLEANDEPS)
@@ -152,4 +149,3 @@ ifeq ($(filter $(MAKECMDGOALS), clean), )
endif
.PHONY: configheader

21
module.mk Normal file
View File

@@ -0,0 +1,21 @@
# included from the main makefile to include a set of rules.mk to satisfy
# the current MODULE list. If as a byproduct of including the rules.mk
# more stuff shows up on the MODULE list, recurse
# sort and filter out any modules that have already been included
MODULES := $(sort $(MODULES))
MODULES := $(filter-out $(ALLMODULES),$(MODULES))
ifneq ($(MODULES),)
ALLMODULES += $(MODULES)
ALLMODULES := $(sort $(ALLMODULES))
INCMODULES := $(MODULES)
MODULES :=
$(info including $(INCMODULES))
include $(addsuffix /rules.mk,$(INCMODULES))
include module.mk
endif

View File

@@ -3,8 +3,9 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
TARGET := armemu
APPS := tests \
console
MODULES += \
app/tests \
app/console
OBJS += \
$(LOCAL_DIR)/init.o

View File

@@ -3,8 +3,11 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
TARGET := beagle
APPS := tests console stringtests
DEVS :=
MODULES += \
app/tests \
app/console \
app/stringtests
OBJS += \
$(LOCAL_DIR)/init.o

View File

@@ -3,7 +3,9 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
TARGET := osk5912
APPS := tests console
MODULES += \
app/tests \
app/console
OBJS += \
$(LOCAL_DIR)/init.o

View File

@@ -3,7 +3,8 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
TARGET := qemu-arm
APPS := tests
MODULES += \
app/tests
OBJS += \
$(LOCAL_DIR)/init.o

View File

@@ -3,7 +3,8 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
TARGET := sam7ex256
APPS := tests
MODULES += \
app/tests
OBJS += \
$(LOCAL_DIR)/init.o

View File

@@ -2,7 +2,8 @@ LOCAL_DIR := $(GET_LOCAL_DIR)
PLATFORM := omap5912
DEVS := net/smc91c96
MODULES += \
dev/net/smc91c96
OBJS += \
$(LOCAL_DIR)/init.o