[make] better modularize the build system

-Each module's rules.mk defines a seperate linkage unit. Each
module can have a private set of CFLAGS, DEFINES, INCLUDES, and so
forth.
-Files to be compiled are now added by source, not object.

Most rules.mk files can be converted easily by following these steps:

1) add 'MODULE := $(LOCAL_DIR)' near the top of the file
2) change OBJS += to MODULE_SRCS += and list source files instead of .os
3) add 'include make/module.mk' at the bottom of the file

See make/module.mk for directions.
This commit is contained in:
Travis Geiselbrecht
2012-08-29 14:51:23 -07:00
parent 9c0f307ce6
commit 734f32b143
8 changed files with 259 additions and 98 deletions

View File

@@ -3,3 +3,29 @@ GET_LOCAL_DIR = $(patsubst %/,%,$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKE
# makes sure the target dir exists
MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi
# prepends the BUILD_DIR var to each item in the list
TOBUILDDIR = $(addprefix $(BUILDDIR)/,$(1))
# generate a header file at $1 with an expanded variable in $2
define MAKECONFIGHEADER
@$(MKDIR)
@echo generating $1
@rm -f $1.tmp; \
LDEF=`echo $1 | tr '/\\.-' '_'`; \
echo \#ifndef __$${LDEF}_H > $1.tmp; \
echo \#define __$${LDEF}_H >> $1.tmp; \
for d in `echo $($2) | tr '[:lower:]' '[:upper:]'`; do \
echo "#define $$d" | sed "s/=/\ /g;s/-/_/g;s/\//_/g" >> $1.tmp; \
done; \
echo \#endif >> $1.tmp; \
if [ -f "$1" ]; then \
if cmp "$1.tmp" "$1"; then \
rm -f $1.tmp; \
else \
mv $1.tmp $1; \
fi \
else \
mv $1.tmp $1; \
fi
endef