Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Basic Makefile template
default: all
DEBUG ?= -g -ggdb -DDEBUG
ifeq ($(DEBUG),)
override DEBUG := -DNDEBUG
endif
override LDFLAGS += -lstdc++
override CFLAGS += $(DEBUG) -MD -MP
override CXXFLAGS += $(DEBUG) -MD -MP
PROGRAMS := \
test \
#
COMMON := \
#
DEPENDS = $(PROGRAMS:=.d) $(COMMON:=.d)
-include $(DEPENDS)
OBJECTS = $(PROGRAMS:=.o) $(COMMON:=.o)
$(PROGRAMS) : %: %.o $(COMMON:=.o)
all: $(PROGRAMS)
.PHONY: clean
clean:
rm -rf $(PROGRAMS) $(OBJECTS) $(DEPENDS)
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment