-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
39 lines (27 loc) · 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
CXX := g++
CXXFLAGS := -std=c++17
#CPPFLAGS := -DDEBUG
# Required for OSX, does not hurt on other platforms.
CPPFLAGS := -D_XOPEN_SOURCE
DEPFLAGS := -MMD -MP
BUILDDIR := build
OBJECTS := $(patsubst effects/%.cpp,$(BUILDDIR)/lib/%.o,$(wildcard effects/*.cpp))
TESTS := $(patsubst test/%.cpp,$(BUILDDIR)/test/%,$(wildcard test/*.cpp))
DEPS := $(patsubst %.o,%.d,$(OBJECTS)) $(patsubst %,%.d,$(TESTS))
$(shell mkdir -p $(BUILDDIR))
$(shell mkdir -p $(BUILDDIR)/lib)
$(shell mkdir -p $(BUILDDIR)/test)
.PHONY: test lib clean
test: $(TESTS)
@for i in $(TESTS); do echo "Running $$i..."; $$i; done
$(TESTS):$(BUILDDIR)/test/%: test/%.cpp $(BUILDDIR)/effects.a
$(CXX) -I. $(CPPFLAGS) $(CXXFLAGS) $(DEPFLAGS) -o $@ $< $(BUILDDIR)/effects.a
lib: $(BUILDDIR)/effects.a
$(BUILDDIR)/effects.a: $(OBJECTS)
@rm -f $(BUILDDIR)/effects.a
ar rcs $(BUILDDIR)/effects.a $(OBJECTS)
$(OBJECTS):$(BUILDDIR)/lib/%.o: effects/%.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEPFLAGS) -c -o $@ $<
clean:
@rm -rf $(BUILDDIR)
-include $(DEPS)