Skip to content

Instantly share code, notes, and snippets.

@yuuichi-fujioka
Created April 18, 2013 11:46
Show Gist options
  • Save yuuichi-fujioka/5412131 to your computer and use it in GitHub Desktop.
Save yuuichi-fujioka/5412131 to your computer and use it in GitHub Desktop.
サブディレクトリにソースとヘッダを置いている場合のMakefile
DESTDIR = bin
PROGRAM = $(DESTDIR)/test
SRCS = main.cpp sub.cpp
OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d)
VPATH = src
CXXFLAGS = -I include/
.PHONY: all
all: $(PROGRAM)
sinclude $(DEPS)
$(PROGRAM): $(OBJS)
mkdir -p $(DESTDIR)
$(CXX) $(OBJS) -o $(PROGRAM)
.cpp.o:
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $(@)
.PHONY: clean
clean:
rm -fr $(PROGRAM) $(OBJS) $(DEPS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment