Skip to content

Instantly share code, notes, and snippets.

@qas612820704
Created February 19, 2017 16:17
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 qas612820704/41704c25941b9f53c1acdefcf42dba84 to your computer and use it in GitHub Desktop.
Save qas612820704/41704c25941b9f53c1acdefcf42dba84 to your computer and use it in GitHub Desktop.
SDIR= src
IDIR= $(SDIR)/include
CC= g++
CFLAGS=-I$(IDIR)
DBG=-g -D DEBUG
ODIR=$(SDIR)/obj
LDIR=$(SDIR)/lib
BDIR=bin
SRC= $(shell find $(SDIR) -type f -name '*.cpp')
OBJ= $(patsubst $(SDIR)/%.cpp,$(ODIR)/%.o,$(SRC))
DBGOBJ= $(patsubst $(SDIR)/%.cpp,$(ODIR)/%-dbg.o,$(SRC))
all: $(BDIR)/server
.PHONY: debug
debug: $(BDIR)/server-dbg
gdb $(BDIR)/server-dbg
$(BDIR)/server: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS)
$(ODIR)/%.o: $(SDIR)/%.cpp
@mkdir -p $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(BDIR)/server-dbg: $(DBGOBJ)
$(CC) $(DBG) -o $@ $^ $(CFLAGS)
$(ODIR)/%-dbg.o: $(SDIR)/%.cpp
$(CC) $(DBG) -c -o $@ $< $(CFLAGS)
.PHONY: start clean
start:
$(BDIR)/server
clean:
rm $(ODIR)/*
rm $(BDIR)/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment