This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (60 loc) · 1.5 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
# Compiler flags
# build directory
BDIR=build
# object directory
ODIR=objects
# source directory
SDIR=src
# include directory
IDIR=include
# test directory
TDIR=test
# library directory
LDIR=lib
# example source directory
EDIR=examples
# example bin directory
EBIN=examples/bin
# generated library path
LIB=$(LDIR)/libtmath.a
# include flag
INC=-I$(IDIR)
# other compiler flags
CFLAGS=-std=c++11 -g -gstabs
TUTILS=tutils
TUTILS_OBJ=$(ODIR)/$(TUTILS).o
_UNITS= abs.o cosecant.o cosine.o cotangent.o degrad.o equality.o \
explog.o factorial.o fcm.o power.o roots.o secant.o sine.o \
tangent.o vector.o matrix.o
OBJECTS=$(patsubst %,$(ODIR)/%,$(_UNITS))
TESTS=$(patsubst %,$(ODIR)/test_%,$(_UNITS))
all: lib tests
@echo "done."
lib: folders $(LIB)
@echo "build library."
folders:
@mkdir -p $(BDIR) $(ODIR) $(LDIR)
tests: folders utils $(TESTS)
@echo "all tests passed."
# build test utilities
utils:
$(CC) $(INC) $(CFLAGS) -c -o $(TUTILS_OBJ) $(TDIR)/test_utils.cpp
$(EBIN):
@mkdir -p $(EBIN)
$(EDIR): $(EBIN) lib
$(CC) $(INC) $(CFLAGS) -o $(EBIN)/gauss $(EDIR)/gauss-method/main.cpp $(LIB)
$(CC) $(INC) $(CFLAGS) -o $(EBIN)/jacobi $(EDIR)/jacobi-iteration/main.cpp $(LIB)
# build and run tests
$(ODIR)/test_%.o: $(TDIR)/%.cpp
$(CC) $(INC) $(CFLAGS) -o $@ $< $(TUTILS_OBJ) $(LIB)
@$@
# build objects
$(ODIR)/%.o: $(SDIR)/%.cpp
$(CC) -c $(INC) -o $@ $< $(CFLAGS)
# build library
$(LIB): $(OBJECTS)
ar rvs $(LIB) $^
# make clean
clean:
@rm -rf $(BDIR) $(ODIR) $(LDIR) $(EBIN)
@echo "workspace cleaned."