Skip to content

Instantly share code, notes, and snippets.

@rightson
Last active February 16, 2019 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightson/6f188c5c657ce5f563152ab000826905 to your computer and use it in GitHub Desktop.
Save rightson/6f188c5c657ce5f563152ab000826905 to your computer and use it in GitHub Desktop.
Naive Makefile for compiling and running single c++ source file
TARGET := $(MAKECMDGOALS)
CXX_FLAGS := -std=c++11
$(TARGET): force-clean
g++ $(TARGET).cpp $(CXX_FLAGS) -o $(TARGET) && ./$(TARGET)
force-clean:
\rm -f $(TARGET)
# given source file name: 100.cpp
# just enter `make 100` to build and run it
# if you have a lot of "single c++ file", it's your good friend!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment