uboot主Makefile分析3

《朱老师物联网大讲堂》学习笔记

学习地址:www.zhulaoshi.org


OBJTREE,

编译出来的.o文件的根目录,默认就是当前目录,


SRCTREE,

源码目录,也就是当前目录,


TOPDIR,

源码顶层目录,貌似还看不出它的作用,


MKCONFIG :=$(SRCTREE)/mkconfig

export MKCONFIG

mkconfig是一个脚本,


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

config.mk是在之前make x210_sd_config中根据我们的配置自动生成的,

X210在iNand情况下配置生成的config.mk内容为:
ARCH   = arm
CPU    = s5pc11x
BOARD  = x210
VENDOR = samsung
SOC    = s5pc110

之后使用export将这5个变量导出为环境变量,

x210_sd_config : unconfig
@$(MKCONFIG) $(@:_config=) arm s5pc11x x210 samsung s5pc110
@echo "TEXT_BASE = 0xc3e00000" > $(obj)board/samsung/x210/config.mk

这就是我们的配置,来自于2589行,


ARCH CROSS_COMPILE

这是两个重要的环境变量,

ARCH,来自于配置的过程,

是当前的CPU架构,


CROSS_COMPILE是定义交叉编译工具链的前缀,

不同CPU架构上的交叉编译工具链,只是前缀不一样,后缀都一样,

关于这我们可以在Makefile中更改设置,

也可以再make的时候通过参数来设置,

ifndef CROSS_COMPILE
ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE =
else
ifeq ($(ARCH),ppc)
CROSS_COMPILE = ppc_8xx-
endif
ifeq ($(ARCH),arm)
#CROSS_COMPILE = arm-linux-
#CROSS_COMPILE = /usr/local/arm/4.4.1-eabi-cortex-a8/usr/bin/arm-linux-
#CROSS_COMPILE = /usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-
CROSS_COMPILE = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-
endif
ifeq ($(ARCH),i386)
CROSS_COMPILE = i386-linux-
endif
ifeq ($(ARCH),mips)
CROSS_COMPILE = mips_4KC-
endif
ifeq ($(ARCH),nios)
CROSS_COMPILE = nios-elf-
endif
ifeq ($(ARCH),nios2)
CROSS_COMPILE = nios2-elf-
endif
ifeq ($(ARCH),m68k)
CROSS_COMPILE = m68k-elf-
endif
ifeq ($(ARCH),microblaze)
CROSS_COMPILE = mb-
endif
ifeq ($(ARCH),blackfin)
CROSS_COMPILE = bfin-uclinux-
endif
ifeq ($(ARCH),avr32)
CROSS_COMPILE = avr32-linux-
endif
ifeq ($(ARCH),sh)
CROSS_COMPILE = sh4-linux-
endif
ifeq ($(ARCH),sparc)
CROSS_COMPILE = sparc-elf-
endif	# sparc
endif	# HOSTARCH,ARCH
endif	# CROSS_COMPILE

export	CROSS_COMPILE
前面ARCH的值会决定这里的分支。

你可能感兴趣的:(嵌入式,makefile,uboot,s5pv210)