Basic Makefile template
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
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) | |
.PHONY: all | |
all: $(PROGRAMS) | |
.PHONY: clean | |
clean: | |
rm -rf $(PROGRAMS) $(OBJECTS) $(DEPENDS) | |
$(PROGRAMS) $(OBJECTS): | $(filter clean,$(MAKECMDGOALS)) | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment