CC = gcc
target = udp_simple_server
obj = udp_server.o
DIR = ($shell pwd)
QUIET_CC = @printf ' %b %b\n' CC $@ 1>&2;
QUIET_LD = @printf ' %b %b\n' LD $@ 1>&2;
%.o: %.c
$(QUIET_CC)$(CC) -c $< -o $@
$(target): $(obj)
$(QUIET_LD)$(CC) -o $(target) $(obj)
.PHONY : clean
clean:
rm -rf $(target)
优化
CC = gcc
CFLAGS= -Wall
target = udp_simple_server
obj = test1.o\
test2.o\
test3.o\
main.o
DIR = ($shell pwd)
QUIET_CC = @printf ' %b %b\n' CC $@ 1>&2;
QUIET_LD = @printf ' %b %b\n' LD $@ 1>&2;
QUIET_CLEAN = @printf ' %b' CLEAN $(obj) $(target)'\n' 1>&2;
%.o: %.c
$(QUIET_CC)$(CC) -c $(CFLAGS) $< -o $@
$(target): $(obj)
$(QUIET_LD)$(CC) -o $(target) $(obj)
PHONY : clean
clean:
$(QUIET_CLEAN) rm -rf $(obj) $(target)