Skip to content

Commit

Permalink
1.0: library (update PR)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Jul 17, 2022
1 parent ddc86af commit 4bbea67
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 13 deletions.
56 changes: 43 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
# settings
TARGET = example
CFLAGS = -Wall
PROJECT = tmatrix
TARGET = $(PROJECT)_example
TEST = $(PROJECT)_test
CC = gcc
LIBS = -lm

CFLAGS = -Wall
LDFLAGS = -lm -s
AR = ar
RM = rm -f
.PHONY: all test

# sources
SRC = lib/tmatrix.c lib/tmatrix_calc.c lib/tmatrix_homo.c lib/tmatrix_vec.c \
lib/tmatrix_io.c lib/tmatrix_rot.c
MAIN = example.c $(SRC)
TEST = tests/tests.c $(SRC)
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: $(MAIN)
$(CC) $(CFLAGS) $(MAIN) -o $(TARGET) $(LIBS)
all: $(TARGET)

$(TARGET): $(OBJM) lib$(PROJECT).a
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

# build unit tests and run it
test: $(TEST)
$(CC) $(CFLAGS) -g $(TEST) -o $@ $(LIBS)
./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)
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4bbea67

Please sign in to comment.