-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (41 loc) · 1.37 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#
# MAKEFILE
# following hiltmon.com/blog/2013/07/03/a-simple-c-plus-plus-project-structure/
#
# Compiler
CC := g++
# Directories
SRCDIR := src
RUNDIR := run
BUILDDIR := build
TARGETDIR := bin
# Targets
EXECUTABLE := RunDecoderThresholdCalc
TARGET := $(TARGETDIR)/$(EXECUTABLE)
# Code Lists
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
SRCOBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/src/%,$(SOURCES:.$(SRCEXT)=.o))
RUNS := $(shell find $(RUNDIR) -type f -name *.$(SRCEXT))
RUNSOBJECTS := $(patsubst $(RUNDIR)/%,$(BUILDDIR)/runs/%,$(RUNS:.$(SRCEXT)=.o))
# Shared Compiler Flags
CFLAGS := -g -Wall -std=c++11
LIB := -L lib
INC := -I include
# generate executable
$(TARGET): $(SRCOBJECTS) $(RUNSOBJECTS)
@mkdir -p $(TARGETDIR)
@echo " Linking..."
@echo " $(CC) $(SRCOBJECTS) $(BUILDDIR)/runs/$(EXECUTABLE).o -o $(TARGET) $(LIB)"; $(CC) $(SRCOBJECTS) $(BUILDDIR)/runs/$(EXECUTABLE).o -o $(TARGET) $(LIB)
# build sources
$(BUILDDIR)/src/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(BUILDDIR)/src
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
# build runmodes
$(BUILDDIR)/runs/%.o: $(RUNDIR)/%.$(SRCEXT)
@mkdir -p $(BUILDDIR)/runs
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGETDIR)"; $(RM) -r $(BUILDDIR) $(TARGETDIR)
.PHONY: clean