Last active
November 9, 2017 03:01
-
-
Save eigenfoo/640a3633ccbcdc4636878adb8557a00d to your computer and use it in GitHub Desktop.
C++ simple general-purpose Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: clean debug run | |
CXX = g++ | |
CXXFLAGS = -std=c++11 -Wall -Wextra | |
LDFLAGS = | |
SOURCES = hash.cpp spellcheck.cpp | |
OBJECTS = $(SOURCES:.cpp=.o) | |
EXECUTABLE = spell.exe | |
all: $(SOURCES) $(EXECUTABLE) | |
$(EXECUTABLE): $(OBJECTS) | |
$(CXX) $(CXXFLAGS) -o $@ $(OBJECTS) $(LDFLAGS) | |
.cpp.o: | |
$(CXX) $(CXXFLAGS) -c $< | |
clean: | |
rm -rf $(EXECUTABLE) $(OBJECTS) debug.exe *.stackdump *~ *.dSYM/ | |
debug: | |
$(CXX) $(CXXFLAGS) -g -o debug.exe $(SOURCES) | |
run: | |
./$(EXECUTABLE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Makefile should be adequate for most non-enterprise projects: only lines 3 through 9 need be edited for project-specific details.
See here and here for great crash courses on Makefiles.