Skip to content

Instantly share code, notes, and snippets.

@Ghost-VR
Created April 29, 2020 08:23
Show Gist options
  • Save Ghost-VR/4abb08a823b854e8309527a2d1587c7b to your computer and use it in GitHub Desktop.
Save Ghost-VR/4abb08a823b854e8309527a2d1587c7b to your computer and use it in GitHub Desktop.
A very simple and efficient Makefile for C++, good for course projects!
CXX :=g++
CXXFLAGS :=-Wall
SRCS :=$(wildcard *.cpp)
SRCS :=$(filter-out demo.cpp, $(SRCS))
SRCS_H :=$(patsubst %.cpp, %.h, $(SRCS))
OBJS :=$(patsubst %.cpp, %.o, $(SRCS))
all: build
run: build
./demo
submit:
zip submission.zip *.h *.cpp *.md Makefile
$(OBJS): $(SRCS) $(SRCS_H)
clean:
-rm $(OBJS)
-rm demo
build: demo.cpp $(OBJS)
$(CXX) $(CXXFLAGS) -o demo demo.cpp $(OBJS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment