forked from frejoel/tsdemux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (66 loc) · 1.8 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
75
76
77
78
79
80
81
82
83
CC = gcc
ODIR = bin
CCDIR = coverage
INSTALL_DIR = /usr/local
CCOBJDIR = $(CCDIR)/obj
CFLAGS = -Ibin -Lbin
LIBS = -ltsdemux
.SECONDEXPANSION:
OBJ_TESTS := $(patsubst %.c, %.o, $(wildcard test/*.c))
OBJ_EXAMPLES := $(patsubst %.c, %.o, $(wildcard examples/*.c))
DEBUG ?= 0
COVERAGE ?= 0
PROFILING ?= 0
ifeq ($(COVERAGE), 1)
CFLAGS += -fprofile-arcs -ftest-coverage -fprofile-dir=$(CCOBJDIR)
DEBUG = 1
endif
ifeq ($(PROFILING), 1)
CFLAGS += -pg
DEBUG = 1
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O2
endif
all: static tests examples
.PHONY: style static tests check clean
style:
astyle --style=linux -n src/*.h src/*.c
static:
mkdir -p $(ODIR)
$(CC) -c -o $(ODIR)/libtsdemux.a $(CFLAGS) src/tsdemux.c
cp src/tsdemux.h $(ODIR)/tsdemux.h
%.o: %.c
$(CC) -o $@ $< $(CFLAGS) $(LIBS)
install: static
mkdir -p $(INSTALL_DIR)/include/libtsdemux
mkdir -p $(INSTALL_DIR)/lib
cp $(ODIR)/tsdemux.h $(INSTALL_DIR)/include/libtsdemux/
cp $(ODIR)/libtsdemux.a $(INSTALL_DIR)/lib/
remove:
rm -f $(INSTALL_DIR)/include/libtsdemux/libtsdemux.h
rm -r -f $(INSTALL_DIR)/include/libtsdemux
rm -f $(INSTALL_DIR)/lib/libtsdemux.a
test: static $(OBJ_TESTS)
tests: static $(OBJ_TESTS)
examples: static $(OBJ_EXAMPLES)
check: tests $(OBJ_TESTS)
./test-runner.sh
ifeq ($(COVERAGE), 1)
mkdir -p $(CCDIR)
rm -f *.gcno
rm -f $(CCOBJDIR)/*.gcda
mv bin/*.gcno $(CCOBJDIR)/bin/
lcov --directory $(CCOBJDIR) --capture --output-file $(CCDIR)/coverage.info
genhtml --output-directory $(CCDIR)/html $(CCDIR)/coverage.info
endif
clean:
rm -f -r $(ODIR) $(CCDIR)
rm -f -r test/*.o.dSYM
find . -type f -name '*.o' -exec rm {} \;
find . -type f -name '*.o.dSYM' -exec rm {} \;
find . -type f -name '*.o.gcno' -exec rm {} \;
find . -type f -name '*.o.gcda' -exec rm {} \;
find . -type f -name 'gmon.out' -exec rm {} \;