-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
148 lines (125 loc) · 4.1 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# MODIFIABLE PART
PROGRAM := afe
BUILDDIR := build
OBJDIR := $(BUILDDIR)/obj
BINDIR := $(BUILDDIR)/bin
DEPDIR := $(BUILDDIR)/deps
SRCDIR := src
LDLIBS := -lasound -ldl -lpthread
CPPFLAGS := -I src/ -I src/SignalProcessor -I src/AudioStream -I src/AFEUtilities
CXXFLAGS := -g3 -O3 \
-Wall \
-Wextra \
-Wstrict-aliasing \
-pedantic \
-Werror \
-Wunreachable-code \
-Wcast-align \
-Wcast-qual \
-Wctor-dtor-privacy \
-Winit-self \
-Wlogical-op \
-Wmissing-include-dirs \
-Wnoexcept \
-Woverloaded-virtual \
-Wredundant-decls \
-Wshadow \
-Wsign-promo \
-Wstrict-null-sentinel \
-Wswitch-default \
-Wundef \
-Wno-unused \
-Wno-parentheses \
-fdiagnostics-show-option
# Write down all the source files here used to compile the final app
# Sources in other direcotry then src will break the build
# In such a case this makefile needs to be updated a bit...
_SOURCES = main.cpp \
AudioStreamBase.cpp \
AudioStream.cpp \
AudioStreamException.cpp \
AudioFrontEnd.cpp \
AFEUtilities.cpp
SOURCES = src/main.cpp \
src/AudioStream/AudioStreamBase.cpp \
src/AudioStream/AudioStream.cpp \
src/AudioStream/AudioStreamException.cpp \
src/AudioFrontEnd/AudioFrontEnd.cpp \
src/AFEUtilities/AFEUtilities.cpp
OBJECTS = build/obj/main.o \
src/AudioStream/AudioStreamBase.cpp \
src/AudioStream/AudioStream.o \
build/obj/AudioStreamException.o \
build/obj/AudioFrontEnd.o \
src/AFEUtilities/AFEUtilities.o
APPOBJECTS = build/obj/main.o \
build/obj/AudioStreamBase.o \
build/obj/AudioStream.o \
build/obj/AudioStreamException.o \
build/obj/AudioFrontEnd.o \
build/obj/AFEUtilities.o
#TODO move source/objects etc. file definitions from this makefile into its own makefile????
# NON-MODIFIABLE PART
# DON'T TOUCH THE REST OF THIS SCIRPT, IF YOU DON'T KNOW, WHAT YOU ARE DOING
#
# additional flags to generate header dependencies files
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
# postcompile command to move the newly generated dependency files
# so they won't get deleted after build finishes
POSTCOMPILE = mv -f $(DEPDIR)/$(*F).Td $(DEPDIR)/$(*F).d && touch $@
INSTALLDIR := ../deploy_afe
.PHONY: all clean distclean
# our default build target
all: $(PROGRAM) | $(INSTALLDIR)
make -C src/SignalProcessor
cp $(BINDIR)/* $(INSTALLDIR)
cp -d src/SignalProcessor/$(BINDIR)/* $(INSTALLDIR)
cp misc/* $(INSTALLDIR)
cp TODO.md $(INSTALLDIR)
distclean:
rm -rf build
make -C src/SignalProcessor distclean
rm -rf $(INSTALLDIR)
clean:
rm -rf build/bin build/obj
make -C src/SignalProcessor clean
# rule to build our program out of object files
# | $(BINDIR) - make sure there is a $(BINDIR) directory
# before linking object files into final binary
$(PROGRAM): $(APPOBJECTS) | $(BINDIR)
@echo "Linking: $@"
$(CXX) $(APPOBJECTS) -o$(BINDIR)/$@ $(LDLIBS) $(LDFLAGS)
# rule to build objects out of sources
# to force rebuild not just on source files update, but also on header files,
# we need to add the prerequisity on $(DEPDIR)/%.d
# as part of the build the compiler generates dependency files based on
# DEPFLAGS
# as the result appears to be intermediate, it would be erased at the end of
# build, thus a POSTCOMPILE action is introduced to move the generated files
# for future use
# make sure there is a $(DEPDIR) directory before building our objects
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(DEPDIR)/%.d | $(DEPDIR)
#@echo "\nBuilding: $@"
$(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
$(POSTCOMPILE)
# make sure there is a $(OBJDIR) directory before building any object files
$(OBJECTS): | $(OBJDIR)
$(OBJDIR):
mkdir -p $@
$(BINDIR):
mkdir -p $@
$(DEPDIR):
mkdir -p $@
$(INSTALLDIR):
mkdir -p $@
DEPFILES := $(_SOURCES:%.cpp=$(DEPDIR)/%.d)
# for very first built, there are no dep files. In such case
# provide a rule, which does nothing
$(DEPFILES):
# include the content of all generated DEPFILES containing
# dependancy on header files
include $(wildcard $(DEPFILES))
include src/AudioStream/makefile
include src/AudioFrontEnd/makefile
include src/AFEUtilities/makefile
#include src/SignalProcessor/makefile