Skip to content

Instantly share code, notes, and snippets.

@karlding
Created November 29, 2015 04:58
Show Gist options
  • Save karlding/71d93b00042b585bd99e to your computer and use it in GitHub Desktop.
Save karlding/71d93b00042b585bd99e to your computer and use it in GitHub Desktop.
generic annotated Makefile
# set the compiler name
CXX = g++
# set the compiler flags
# Wall: show all warnings
# MMD: create dependency files
# g: compile binaries with debugging info
CXXFLAGS = -Wall -MMD -g
# object files
OBJECTS = main.o
# dependency files to keep track of objects
DEPENDS = ${OBJECTS:.o=.d}
# output filename
EXEC = filename
${EXEC}: ${OBJECTS}
${CXX} ${CXXFLAGS} ${OBJECTS} -o ${EXEC}
-include ${DEPENDS}
# special targets
.PHONY: clean debug
# clean: remove any objects before making
clean:
rm ${OBJECTS} ${DEPENDS} ${EXEC}
# debug: compile with DEBUG macro enabled
debug: CXXFLAGS += -DDEBUG
debug: ${EXEC}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment