Makefile 记录

example:

# not include multi-dir
TOOL_CHAIN = gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-
CC = ${TOOL_CHAIN}gcc
AS = ${TOOL_CHAIN}as
AR = ${TOOL_CHAIN}ar
LD = ${TOOL_CHAIN}ld
OBJCOPY = ${TOOL_CHAIN}objcopy
OBJDUMP = ${TOOL_CHAIN}objdump
READELF = ${TOOL_CHAIN}readelf

C_FLAGS := -Wall -I/usr/include -O0 -std=c11 -mcpu=cortex-m4 -mthumb -fno-builtin
LD_FLAGS := -T xxx.lds

all: main.c hello.c
	echo "This is a makefile test"
	${CC} -o [email protected] $^ ${C_FLAGS} ${LD_FLAGS}
	${OBJCOPY} -O binary -S [email protected] [email protected]
	${OBJDUMP} -D -m arm [email protected] > [email protected]

clean:
	rm all -fr

${} and $() are the same meaning, they can be used to represent the variables
:= signifies instant equal
all signifies target, main.c hello.c are prerequiries
$@ signifies the target
$^ signifies all the prerequiries
$< signifies the first prerequiries

猜你喜欢

转载自www.cnblogs.com/georgemxx/p/12763791.html