Make

易错点:

变量:

两种变量定义方式:

CC=g++
CFLAGS = -g -Wall
INCLUDES = -I/home/newhall/include  -I../include
LFLAGS = -L/home/newhall/lib  -L../lib
LIBS = -lmylib -lm
SRCS = majority_element.cpp
# SRCS = $(wildcard *.c)
# SRCS = $(filter-out support.c, $(wildcard *.c))
OBJS = $(SRCS:.c=.o)
MAIN = myprog

.PHONY: all clean


all: $(MAIN)
  @echo Compiled $(MAIN)

$(MAIN): $(OBJS)
  $(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LFLAGS) $(LIBS)

test: test.cpp
  $(CC) $(CFLAGS) $(INCLUDES) -o test test.cpp

%.o : %.cpp
  $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

clean:
  $(RM) *.o *~ $(MAIN) test