Some must-know rules in Makefile

Define some variables

NAME=led_asm
CROSS_COMPILE = arm-none-linux-gnueabi-

Compile

CC = $(CROSS_COMPILE)gcc

Link to link .o files to generate .elf files

LD = $(CROSS_COMPILE)ld

Generate .bin from .elf file

.bin is a pure binary file

.elf contains symbols

OBJCOPY = $(CROSS_COMPILE)objcopy

rule

all:
$(CC) -O0 -g -c $(NAME).S -o $(NAME).o
@ # -O0: optimization level of the code
@ # -g: add debugging information
@ # -c: only Compile does not link
$(LD) -Ttext=0x43c00000 $(NAME).o -o $(NAME).elf
@ # -Ttext=0x43c00000: Specify the starting position of the code
$(OBJCOPY) -O binary $(NAME). elf $(NAME).bin
@ # -O binary: output binary file

clean:
rm -rf *.elf *.bin *.o

install:
@ # Modify the path to your own contribution folder
cp $(NAME).bin /mnt/hgfs/share/

Regarding the command variable.

WITH

函数库打包程序。默认命令是“ar”。 

AS

汇编语言编译程序。默认命令是“as”。

CC

C语言编译程序。默认命令是“cc”。

CXX

C++ language compiler. The default command is "g++".

CO

从 RCS文件中扩展文件程序。默认命令是“co”。

CPP

C程序的预处理器(输出是标准输出设备)。默认命令是“$(CC) –E”。

FC

Compilers and preprocessors for Fortran and Ratfor. The default command is "f77".

GET

从SCCS文件中扩展文件的程序。默认命令是“get”。 

LEX

Lex方法分析器程序(针对于C或Ratfor)。默认命令是“lex”。

PC

Pascal language compiler. The default command is "pc".

YACC

Yacc grammar analyzer (for C programs). The default command is "yacc".

YACCR

Yacc grammar analyzer (for the Ratfor program). The default command is "yacc -r".

MAKEINFO

转换Texinfo源文件(.texi)到Info文件程序。默认命令是“makeinfo”。

TEX

从TeX源文件创建TeX DVI文件的程序。默认命令是“tex”。

TEXI2DVI

从Texinfo源文件创建军TeX DVI 文件的程序。默认命令是“texi2dvi”。

WEAVE

转换Web到TeX的程序。默认命令是“weave”。

CWEAVE

转换C Web 到 TeX的程序。默认命令是“cweave”。

TANGLE

转换Web到Pascal语言的程序。默认命令是“tangle”。

CTANGLE

转换C Web 到 C。默认命令是“ctangle”。

RM

删除文件命令。默认命令是“rm –f”。

Guess you like

Origin blog.csdn.net/weixin_48430195/article/details/108681706