Skip to content

Instantly share code, notes, and snippets.

@iheanyi
Created August 21, 2013 16:07
Show Gist options
  • Save iheanyi/6296474 to your computer and use it in GitHub Desktop.
Save iheanyi/6296474 to your computer and use it in GitHub Desktop.
Makefile automation script, makes making makefiles a breeze
cpps = $(wildcard *.cpp */*.cpp)
objs = $(cpps:.cpp=.o)
deps = $(cpps:.cpp=.d)
CPPFLAGS = -I include/ -g -std=c++11 -Wall -Wextra -pedantic -Werror
all: executable
%.d: %.cpp %.o Makefile
g++ $(CPPFLAGS) -MM -MT $(<:.cpp=.o) $< -o $@
ifneq ($(MAKECMDGOALS), clean)
-include $(deps)
endif
executable: $(deps)
echo $(deps)
g++ $(CPPFLAGS) -o executable $(objs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment