-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
38 lines (29 loc) · 972 Bytes
/
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
CC := g++
SRCDIR := src
TSTDIR := tests
OBJDIR := build
BINDIR := bin
MAIN := src/main.cpp
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
MAIN_OBJECTS := $(filter-out $(OBJDIR)/tester.o,$(OBJECTS))
TESTER_OBJECTS := $(filter-out $(OBJDIR)/main.o,$(OBJECTS))
TSTSOURCES := $(shell find $(TSTDIR) -type f -name *.$(SRCEXT))
# -g debug, --coverage cobertura
CFLAGS := -g --coverage -Wall -O3 -std=c++20
LIBS := -lcurl
INC := -I include/
$(OBJDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
main: $(MAIN_OBJECTS)
@mkdir -p $(BINDIR)
$(CC) $(CFLAGS) $(INC) $^ -o $(BINDIR)/main $(LIBS)
tests: $(TESTER_OBJECTS)
@mkdir -p $(BINDIR)
$(CC) $(CFLAGS) $(INC) $(TSTSOURCES) $^ -o $(BINDIR)/tester $(LIBS)
all: main
clean:
$(RM) -r $(OBJDIR)/* $(BINDIR)/* coverage/* *.gcda *.gcno
.PHONY: clean