summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2007-09-24 09:05:31 -0600
committerGrant Likely <grant.likely@secretlab.ca>2007-11-20 22:33:38 -0700
commit2f155f6c0a1f5e9a306a3f1f4fbe067db7ced3b1 (patch)
tree872745bafb23aa357e7abbdfed81d17c0250ca85 /Makefile
parentf92edbd8a0ef16a2b9127cbb564c09685728e4b0 (diff)
[BUILD] Generate include/autoconf.mk from board config files
Use cpp and sed to postprocess config.h and import the defined values into include/autoconf.mk. autoconf.mk is then included by config.mk to give 'make' access to the board configuration. Doing this enables conditional compilation at the Makefile level instead of by wrapping every .c file with #ifdef/#endif wrappers. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile18
1 files changed, 17 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index ac4b430d7..407b93870 100644
--- a/Makefile
+++ b/Makefile
@@ -342,6 +342,21 @@ $(obj)System.map: $(obj)u-boot
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(obj)System.map
+#
+# Auto-generate the autoconf.mk file (which is included by all makefiles)
+#
+# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
+# the dep file is only include in this top level makefile to determine when
+# to regenerate the autoconf.mk file.
+$(OBJTREE)/include/autoconf.mk: $(obj)include/config.h
+ @echo Generating include/autoconf.mk
+ @# Generate the dependancies
+ @$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -MQ $@ include/common.h > $@.dep
+ @# Extract the config macros
+ @$(CPP) $(CFLAGS) -dM include/common.h | sed -n -f tools/scripts/define2mk.sed >> $@
+
+sinclude $(OBJTREE)/include/autoconf.mk.dep
+
#########################################################################
else
all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
@@ -361,7 +376,8 @@ CHANGELOG:
unconfig:
@rm -f $(obj)include/config.h $(obj)include/config.mk \
- $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp
+ $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
+ $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep
#========================================================================
# PowerPC