Skip to content

Instantly share code, notes, and snippets.

@jiafulow
Last active November 1, 2016 17:18
Show Gist options
  • Save jiafulow/b4822f833d153440e79863ec0948c400 to your computer and use it in GitHub Desktop.
Save jiafulow/b4822f833d153440e79863ec0948c400 to your computer and use it in GitHub Desktop.
CXX=clang++
CXXFLAGS=-g -std=c++11 -Wall -pedantic
BIN=prog
SRC=$(wildcard *.cpp)
OBJ=$(SRC:%.cpp=%.o)
# $^ is all the dependencies
# $? is all the modified dependencies
all: $(OBJ)
$(CXX) -o $(BIN) $^
# $@ is the the target
# $< is the the first dependency
%.o: %.c
$(CXX) $@ -c $<
clean:
rm -f *.o
rm $(BIN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment