Makefile学习笔记18|u-boot顶层Makefile04

Makefile学习笔记18|u-boot顶层Makefile04

  希望看到这篇文章的朋友能在评论区留下宝贵的建议来让我们共同成长,谢谢。

  这里是目录

C语言标准

# With the move to GCC 6, we have implicitly upgraded our language
# standard to GNU11 (see https://gcc.gnu.org/gcc-5/porting_to.html).
# Some Linux distributions (including RHEL7, SLES13, Debian 8) still
# have older compilers as their default, so we make it explicit for
# these that our host tools are GNU11 (i.e. C11 w/ GNU extensions).
CSTD_FLAG := -std=gnu11
KBUILD_HOSTCFLAGS += $(CSTD_FLAG)

ifeq ($(HOSTOS),cygwin)
KBUILD_HOSTCFLAGS	+= -ansi
endif

  CSTD_FLAG 变量被显式设置为 -std=gnu11,指定编译宿主机工具时使用 GNU11 标准。这通常是为了确保代码使用最新的语言特性。KBUILD_HOSTCFLAGS 是一个在构建过程中传递给宿主机编译器的标志集合。会加入前面定义好的 CSTD_FLAG,确保所有宿主机编译的 C 代码都采用 GNU11 标准。如果宿主操作系统是 Cygwin,本段代码通过添加 -ansi 标志来调整 KBUILD_HOSTCFLAGS。-ansi 标志告诉 GCC 使用 ANSI C 标准,也就是 C89 标准。这可能因为这些特定版本的 Cygwin 上的 GCC 默认不支持 GNU11 或者是为了解决特定兼容性问题。

适配MAC OS

# Mac OS X / Darwin's C preprocessor is Apple specific.  It
# generates numerous errors and warnings.  We want to bypass it
# and use GNU C's cpp.	To do this we pass the -traditional-cpp
# option to the compiler.  Note that the -traditional-cpp flag
# DOES NOT have the same semantics as GNU C's flag, all it does
# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
#
# Apple's linker is similar, thanks to the new 2 stage linking
# multiple symbol definitions are treated as errors, hence the
# -multiply_defined suppress option to turn off this error.
#
ifeq ($(HOSTOS),darwin)
# get major and minor product version (e.g. '10' and '6' for Snow Leopard)
DARWIN_MAJOR_VERSION	:= $(shell sw_vers -productVersion | cut -f 1 -d '.')
DARWIN_MINOR_VERSION	:= $(shell sw_vers -productVersion | cut -f 2 -d '.')

os_x_before	= $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
	$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值