[email protected] Represents the target file $^ Represents all dependent files $ Represents the first dependent file $? Represents a list of dependent files ...">

当前位置:网站首页>General makefile (I) single C language compilation template

General makefile (I) single C language compilation template

2022-07-05 08:00:00 Drink more hot water-

[email protected] Represents the target file
$^ Represents all dependent files
$< Represents the first dependent file
$? Represents a list of dependent files that are newer than the target

A single C Language compilation :

#set a name as compile target
TARGET=main

CC=gcc
CFLAGS= -c -Wall
LDFLAGS=

SRCS=$(wildcard *.c)
OBJS=$(patsubst %.c,%.o,$(SRCS))

.PHONY: clean

all: $(TARGET)


$(TARGET): $(OBJS)
    $(CC) $^ $(LDFLAGS) -o [email protected]
$(OBJS):%.o:%.c
    $(CC) $(CFLAGS) $< -o [email protected]

clean:
    rm -f $(OBJS) $(TARGET)
原网站

版权声明
本文为[Drink more hot water-]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140547485882.html