#specify all source files here
SRCS = hw.c helper.c
#specify target here(name of executable)
TARG = hw
#specify compiler, compile flags, and needed libs
CC = gcc
OPTS = -Wall -O
LIBS = -lm
#this translates .c files in src list to .o's
OBJS = $(SRCS: %.c = %.o)
#all is not really needed,but is used to generate the target
all:$(TARG)
$(TARG):$(OBJS)
$(CC) -o $(TARG) $(OBJS) $(LIBS)
#this is a generic rule for .o files
%.o:%.c
$(CC) $(OPTS) -c $< -o $@
#and finally, a clean line
clean:
rm -rf $(OBJS) $(TARG)
联系客服