Makefile文件
CC = aarch64-linux-gnu-gcc
CFLAGS =
SRCS = $(wildcard *.c)
OBJS = $(SRCS:.c=.o)
TARGET = mainall: $(TARGET)$(TARGET): $(OBJS)$(CC) $(CFLAGS) -o $@ $^%.o: %.c$(CC) $(CFLAGS) -c $< -o $@clean:rm -f $(OBJS) $(TARGET)
执行make之后输出:
total 168
-rwxrw-r-- 1 build build 3185 Apr 15 06:27 can.c
-rwxrw-r-- 1 build build 353 Apr 15 06:27 can.h
-rw-rw-r-- 1 build build 5664 Jun 18 11:13 can.o
-rwxrw-r-- 1 build build 4736 Apr 15 06:27 i2c.c
-rwxrw-r-- 1 build build 717 Apr 15 06:27 i2c.h
-rw-rw-r-- 1 build build 7368 Jun 18 11:13 i2c.o
-rwxrwxr-x 1 build build 34664 Jun 18 11:13 main
-rwxrw-r-- 1 build build 2090 Apr 15 06:27 main.c
-rw-rw-r-- 1 build build 4672 Jun 18 11:13 main.o
-rwxrw-r-- 1 build build 246 Jun 18 10:27 Makefile
-rwxrw-r-- 1 build build 573 Apr 15 06:27 README.md
-rwxrw-r-- 1 build build 10416 Apr 15 06:27 spi.c
-rwxrw-r-- 1 build build 5439 Apr 15 06:27 spi.h
-rw-rw-r-- 1 build build 21720 Jun 18 11:13 spi.o
-rwxrw-r-- 1 build build 1654 Apr 15 06:27 system_cmd.c
-rwxrw-r-- 1 build build 166 Apr 15 06:27 system_cmd.h
-rw-rw-r-- 1 build build 3400 Jun 18 11:13 system_cmd.o
-rwxrw-r-- 1 build build 4724 Apr 15 06:27 uart.c
-rwxrw-r-- 1 build build 566 Apr 15 06:27 uart.h
-rw-rw-r-- 1 build build 7384 Jun 18 11:13 uart.o
打包生成了main这个可执行文件,可以放到开发板上进行测试了