本着学习交流的原则, 将个人移植u-boot的过程做一个记录. 文章参考了csdn blog里面的很多内容, 有的已经记不得出处了, 只好把当时的摘要直接贴出来. 如果冒犯, 还请见谅. 如有侵权, 请与我邮件联系. 谢谢!
# # 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. $(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h @$(XECHO) Generating $@ ; \ set -e ; \ : Generate the dependancies ; \ $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \ -MQ $(obj)include/autoconf.mk include/common.h > $@ $(obj)include/autoconf.mk: $(obj)include/config.h @$(XECHO) Generating $@ ; \ set -e ; \ : Extract the config macros ; \ $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \ sed -n -f tools/scripts/define2mk.sed > [email protected] && \ mv [email protected] $@
$(obj)spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend
$(MAKE) -C spl all
# Explicitly make _depend in subdirs containing multiple targets to prevent # parallel sub-makes creating .depend files simultaneously. depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \ $(obj)include/spl-autoconf.mk \ $(obj)include/tpl-autoconf.mk \ $(obj)include/autoconf.mk \ $(obj)include/generated/generic-asm-offsets.h \ $(obj)include/generated/asm-offsets.h for dir in $(SUBDIRS) $(CPUDIR) $(LDSCRIPT_MAKEFILE_DIR) ; do \ $(MAKE) -C $$dir _depend ; done
# defines $(obj).depend target include $(SRCTREE)/rules.mk sinclude $(obj).depend
_depend: $(obj).depend # Split the source files into two camps: those in the current directory, and # those somewhere else. For the first camp we want to support CPPFLAGS_<fname> # and for the second we don't / can't. PWD_SRCS := $(filter $(notdir $(SRCS)),$(SRCS)) OTHER_SRCS := $(filter-out $(notdir $(SRCS)),$(SRCS)) # This is a list of dependency files to generate DEPS := $(basename $(patsubst %,$(obj).depend.%,$(PWD_SRCS))) # Join all the dependencies into a single file, in three parts # 1 .Concatenate all the generated depend files together # 2. Add in the deps from OTHER_SRCS which we couldn't process # 3. Add in the HOSTSRCS $(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(DEPS) $(OTHER_SRCS) \ $(HOSTSRCS) cat /dev/null $(DEPS) >$@ @for f in $(OTHER_SRCS); do \ g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ $(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ done @for f in $(HOSTSRCS); do \ g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ done MAKE_DEPEND = $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \ -MQ $(addsuffix .o,$(obj)$(basename $<)) $< >$@ $(obj).depend.%: %.c $(MAKE_DEPEND) $(obj).depend.%: %.S $(MAKE_DEPEND) $(HOSTOBJS): $(obj)%.o: %.c $(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c $(NOPEDOBJS): $(obj)%.o: %.c $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c #########################################################################