-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
52 lines (43 loc) · 1.09 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
# settings
PROJECT = tmatrix
TARGET = $(PROJECT)_example
TEST = $(PROJECT)_test
CC = gcc
CFLAGS = -Wall
LDFLAGS = -lm -s
AR = ar
RM = rm -f
.PHONY: all test
# sources
OBJL = \
src/lib/tmatrix.o \
src/lib/tmatrix_calc.o \
src/lib/tmatrix_homo.o \
src/lib/tmatrix_vec.o \
src/lib/tmatrix_io.o \
src/lib/tmatrix_rot.o
OBJM = src/example.o
OBJT = src/tests/tests.o
# main program
all: $(TARGET)
$(TARGET): $(OBJM) lib$(PROJECT).a
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
test: $(TEST)
# build unit tests and run it
$(TEST): $(OBJT) lib$(PROJECT).a
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
./$@
lib$(PROJECT).a: $(OBJL)
$(AR) rcs $@ $^
.c.o:
$(CC) -c $(CFLAGS) $< -o $@
src/lib/tmatrix.o: src/lib/tmatrix.c
src/lib/tmatrix_calc.o: src/lib/tmatrix_calc.c
src/lib/tmatrix_homo.o: src/lib/tmatrix_homo.c
src/lib/tmatrix_vec.o: src/lib/tmatrix_vec.c
src/lib/tmatrix_io.o: src/lib/tmatrix_io.c
src/lib/tmatrix_rot.o: src/lib/tmatrix_rot.c
src/example.o: src/example.c
src/tests/tests.o: src/tests/tests.c
clean:
$(RM) $(OBJL) $(OBJT) $(OBJM) lib$(PROJECT).a $(TEST) $(TARGET)