Skip to content

Instantly share code, notes, and snippets.

@nathiss
Last active December 12, 2017 15:01
Show Gist options
  • Save nathiss/e6b2844923d7ef2addd06ef469bc7cbf to your computer and use it in GitHub Desktop.
Save nathiss/e6b2844923d7ef2addd06ef469bc7cbf to your computer and use it in GitHub Desktop.
General Makefile for C++ apps.
CXX=g++
LD=g++
CFLAGS=
LDFLAGS=
EXEC=out
SOURCES=$(wildcard *.cc)
OBJECTS=$(SOURCES:.cc=.o)
.PHONY: clean all run
all: clean $(EXEC)
run: all
./$(EXEC)
$(EXEC): $(OBJECTS)
$(LD) $(OBJECTS) $(LDFLAGS) -o $(EXEC)
%.o: %.cpp
$(CXX) -c $(CFLAGS) $< -o $@
clean:
rm -rf $(EXEC) $(OBJECTS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment