generated from Vyvy-vi/new-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
50 lines (36 loc) · 959 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
39
40
41
42
43
44
45
46
47
48
49
50
CC = g++
CFLAGS = -g -Wall -std=c++14
#CPPFLAGS = -I/opt/homebrew/include -L/opt/homebrew/lib
SRC = src
OBJ = obj
SRCS = $(shell find $(SRC) -name '*.cpp')
OBJS = $(patsubst $(SRC)/%.cpp, $(OBJ)/%.o, $(SRCS))
BINDIR = bin
BIN = $(BINDIR)/file-utils
TEST = tests
TESTS = $(wildcard $(TEST)/*.cpp)
TESTBINS = $(patsubst $(TEST)/%.cpp, $(TEST)/bin/%, $(TESTS))
all: $(BIN)
$(BIN): $(BINDIR) $(OBJ) $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $@
$(OBJ)/%.o: $(SRC)/%.cpp $(SRC)/%.h
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(OBJ)/%.o: $(SRC)/%.cpp
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(TEST)/bin/%: $(TEST)/%.cpp
$(CC) $(CFLAGS) $< -o $@ $(CPPFLAGS) -lcriterion
$(TEST)/bin:
mkdir $@
$(TEST)/inputs:
mkdir $@
rm -rf $@/*.txt
$(OBJ):
mkdir $@
$(BINDIR):
mkdir $@
test: $(BIN) $(TEST)/bin $(TEST)/inputs $(TESTBINS)
for test in $(TESTBINS) ; do ./$$test ; done
clean:
$(RM) -r $(BINDIR)/** $(OBJ)/** $(TEST)/bin/** $(TEST)/inputs/*.txt