Skip to content

Instantly share code, notes, and snippets.

@mlowen
Created November 3, 2015 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlowen/3851635c5a04c7480256 to your computer and use it in GitHub Desktop.
Save mlowen/3851635c5a04c7480256 to your computer and use it in GitHub Desktop.
Simple generic makefile
APPNAME = test
SRCDIR = src
OBJDIR = obj
BINDIR = bin
SRC = $(shell find $(SRCDIR) | grep .cc)
OBJ = $(patsubst $(SRCDIR)/%.cc, $(OBJDIR)/%.o, $(SRC))
.PHONEY: all clean init
all: clean $(APPNAME)
clean:
rm -rfd $(OBJDIR) $(BINDIR)
init:
mkdir $(OBJDIR) $(BINDIR)
$(foreach DIR, $(patsubst $(SRCDIR)/%, $(OBJDIR)/%, $(shell find $(SRCDIR)/* -type d)), mkdir $(DIR))
$(APPNAME): init $(OBJ)
$(CXX) -o $(BINDIR)/$(APPNAME).exe $(OBJ)
$(OBJDIR)/%.o: $(SRCDIR)/%.cc
$(CXX) -c $< -o $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment