Skip to content

Commit 4bbea67

Browse files
committed
1.0: library (update PR)
1 parent ddc86af commit 4bbea67

16 files changed

+43
-13
lines changed

Makefile

+43-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,52 @@
11
# settings
2-
TARGET = example
3-
CFLAGS = -Wall
2+
PROJECT = tmatrix
3+
TARGET = $(PROJECT)_example
4+
TEST = $(PROJECT)_test
45
CC = gcc
5-
LIBS = -lm
6-
6+
CFLAGS = -Wall
7+
LDFLAGS = -lm -s
8+
AR = ar
9+
RM = rm -f
710
.PHONY: all test
811

912
# sources
10-
SRC = lib/tmatrix.c lib/tmatrix_calc.c lib/tmatrix_homo.c lib/tmatrix_vec.c \
11-
lib/tmatrix_io.c lib/tmatrix_rot.c
12-
MAIN = example.c $(SRC)
13-
TEST = tests/tests.c $(SRC)
13+
OBJL = \
14+
src/lib/tmatrix.o \
15+
src/lib/tmatrix_calc.o \
16+
src/lib/tmatrix_homo.o \
17+
src/lib/tmatrix_vec.o \
18+
src/lib/tmatrix_io.o \
19+
src/lib/tmatrix_rot.o
20+
OBJM = src/example.o
21+
OBJT = src/tests/tests.o
1422

1523
# main program
16-
all: $(MAIN)
17-
$(CC) $(CFLAGS) $(MAIN) -o $(TARGET) $(LIBS)
24+
all: $(TARGET)
25+
26+
$(TARGET): $(OBJM) lib$(PROJECT).a
27+
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
1828

19-
# build unit tests and run it
2029
test: $(TEST)
21-
$(CC) $(CFLAGS) -g $(TEST) -o $@ $(LIBS)
22-
./test
30+
31+
# build unit tests and run it
32+
$(TEST): $(OBJT) lib$(PROJECT).a
33+
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
34+
./$@
35+
36+
lib$(PROJECT).a: $(OBJL)
37+
$(AR) rcs $@ $^
38+
39+
.c.o:
40+
$(CC) -c $(CFLAGS) $< -o $@
41+
42+
src/lib/tmatrix.o: src/lib/tmatrix.c
43+
src/lib/tmatrix_calc.o: src/lib/tmatrix_calc.c
44+
src/lib/tmatrix_homo.o: src/lib/tmatrix_homo.c
45+
src/lib/tmatrix_vec.o: src/lib/tmatrix_vec.c
46+
src/lib/tmatrix_io.o: src/lib/tmatrix_io.c
47+
src/lib/tmatrix_rot.o: src/lib/tmatrix_rot.c
48+
src/example.o: src/example.c
49+
src/tests/tests.o: src/tests/tests.c
50+
51+
clean:
52+
$(RM) $(OBJL) $(OBJT) $(OBJM) lib$(PROJECT).a $(TEST) $(TARGET)

example.c src/example.c

File renamed without changes.

lib/tmatrix.c src/lib/tmatrix.c

File renamed without changes.

lib/tmatrix.h src/lib/tmatrix.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/tests.c src/tests/tests.c

File renamed without changes.

0 commit comments

Comments
 (0)