《嵌入式Linux中Makefile万能写法》
SRC := $(wildcard *.c)
OBJ := $(patsubst %.c, %.o, $(SRC))
CC = gcc
CCLINK = g++
CFLAGS = -g -Wall
xdma: $(OBJ)
$(CCLINK) $(CFLAGS) $^ -o $@
$(OBJ): %.o:%.c
$(CC) $(CFLAGS) -c $^ -o $@
.PHONY:clean
clean:
rm *.o xdma
SRC := ${wildcard *.c}
OBJ := ${patsubst %.c, %.o, $(SRC)}
CC = arm-linux-gcc
CCLINK = arm-linux-ld
CFLAGS = -g -c -Wall
all: $(OBJ)
$(CCLINK) -Wall $^ -o main.bin
$(OBJ): %.o:%.c
$(CC) $(CFLAGS) $^ -o $@
.PHONY:clean
clean:
find ./ -iname '*.o' -print0 | xargs -0 rm
# find ./ \( -iname "*.o" -o -iname "*.exe" \) -print0 | xargs -0 rm