1.config.mk
通常配置文件生成之后,即可使用make all进行编译,在如下Makefile里面
ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
# load ARCH, BOARD, and CPU configuration
include $(obj)include/config.mk
export ARCH CPU BOARD VENDOR SOC
ifndef CROSS_COMPILE
ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE =
else
ifeq ($(ARCH),ppc)
CROSS_COMPILE = ppc_8xx-
endif
ifeq ($(ARCH),arm)
CROSS_COMPILE = arm-linux-
endif
......
# load other configuration
include $(TOPDIR)/config.mk
包含了之前我们生成的include/config.mk,并且在以后还能使用ARCH、CPU、BOARD、SOC
然后确定编译平台和所使用的交叉编译工具,然后包含了顶层的config.mk,看顶层config.mk如下几行
#
# Include the make variables (CC, etc...)
#
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
当我们编译的时候使用CROSS_COMPILE=arm-linux-,就会自动编译为相应工具,比如gcc就为arm-linux-gcc
2. LDFLAGS、AFLAGS、CFLAGS
LDFLAGS += -Bstatic -T $(LDSCRIPT) $(PLATFORM_LDFLAGS)
ifneq ($(TEXT_BASE),)
LDFLAGS += -Ttext $(TEXT_BASE)
这里LDSCRIPT如下
ifndef LDSCRIPT
#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
ifeq ($(CONFIG_NAND_U_BOOT),y)
LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
else
LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
endif
这里使用LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
这里TOPDIR就是当前目录,而BOARDDIR为下面所示
ifdef ARCH
sinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules
endif
ifdef CPU
sinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules
endif
ifdef SOC
sinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk # include SoC specific rules
end