SOURCES=getData.c daytimesrv.c byteorder.c tcpEcho.c\
echosrv.c sigMa.c
CC=gcc
CFLAGS=-Wall -g -O2
#the following is mean:
# replace all ".c" in SOURCES to ".o"
OBJECTS=$(SOURCES:.c=.o)
TARGETS=$(SOURCES:.c=.out)
all:$(TARGETS)
#the following is mean:
#"%.out"mean all the $(TARGETS) ,
#and "%.o" mean replace all the "out" in "$(TARGEGS)"
# to "o"
#"$<" mean each ".o"
#"$@" mean each ".out"
#like $(CC) &(CFLAGS) sigMa.o -o sigMa.out
$(TARGETS):%.out:%.o
$(CC) $(CFLAGS) $< -o $@
.PHONY:clean
clean:
rm -f *.out
rm -f *.o
一个将目录内所有c代码分别编译成独立的out文件的Makefile
最新推荐文章于 2022-10-18 21:41:18 发布