-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathBuild.mk
More file actions
204 lines (170 loc) · 6.08 KB
/
Build.mk
File metadata and controls
204 lines (170 loc) · 6.08 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# --- general settings ---------------------------------------------------------
name = upipe
description = Upipe multimedia framework
version = 1.0
cflags = -O2 -g $(warn) $(warn_c)
cxxflags = -O2 -g $(warn) $(warn_cxx)
cppflags = -I$(top_builddir) -Iinclude -I$(top_srcdir)/include
ldflags = $(if $(or $(have_apple),$(have_san)),,-Wl,--no-undefined) \
$(if $(have_apple),,-Wl,--exclude-libs,ALL)
warn = -Wall \
-Wextra \
-Wno-unused-parameter \
-Wno-sign-compare \
-Wmissing-declarations \
-Wwrite-strings \
-Wredundant-decls \
-Wundef \
-Wmissing-include-dirs
warn_opt = -Wstrict-prototypes \
-Wmissing-prototypes \
-Wold-style-definition \
-Wduplicated-cond \
-Wduplicated-branches \
-Wlogical-op \
-Wrestrict \
-Wformat=2 \
-Wno-vla-larger-than \
-Wno-vla-cxx-extension
warn_c = $(foreach w,$(warn_opt),$(call try_cc,$w))
warn_cxx = $(foreach w,$(warn_opt),$(call try_cxx,$w))
distfiles = AUTHORS \
COPYING \
COPYING.LGPLv2 \
COPYING.MIT \
INSTALL \
README
subdirs = lib examples tests x86 luajit doc
# --- config checks ------------------------------------------------------------
SED ?= sed
NM ?= $(CROSS)nm
configs += atomic
atomic-assert = __ATOMIC_SEQ_CST
configs += eventfd
eventfd-includes = sys/eventfd.h
eventfd-functions = eventfd
configs += features.h
features.h-includes = features.h
configs += net/if.h
net/if.h-includes = net/if.h
configs += pic
pic-assert = __pic__
configs += pipe
pipe-includes = unistd.h
pipe-functions = pipe
configs += pthread
pthread-cppflags = -pthread
pthread-ldflags = -pthread
configs += semaphore
semaphore-includes = semaphore.h
semaphore-functions = sem_init
configs += unistd.h
unistd.h-includes = unistd.h
configs += writev
writev-includes = sys/uio.h
writev-functions = writev
# --- headers locations --------------------------------------------------------
includes-transform = :lib/%=include/%
includesubdir = $(notdir $(patsubst %/,%,$(dir $1)))
# --- config.h generation ------------------------------------------------------
genfiles = config.h include/upipe/config.h
config.h:
$(call cmd,config.h)
# --- coding-style checks ------------------------------------------------------
check-whitespace:
@check_attr() { \
git check-attr $$2 "$$1" | grep -q ": $$3$$"; \
}; \
pfx="^ *\([0-9]*\) "; \
git ls-files -- :$(top_srcdir)/*.[ch] | while read file; do \
check_attr "$$file" binary set && continue; \
check_attr "$$file" check-coding-style unset && continue; \
out=$$({ \
cat -n "$$file" | $(SED) -n \
-e "s/$$pfx.* $$/\1: trailing whitespace/p" \
-e "s/$$pfx.* .*/\1: invalid tab/p" \
-e "1s/$$pfx$$/\1: leading newline/p" \
-e "\$$s/$$pfx$$/\1: trailing newline/p"; \
{ cat "$$file"; echo '#'; } | cat -n | $(SED) -n \
-e "\$$s/$$pfx..*#$$/\1: missing newline/p"; \
} | while read -r line; do echo "$$file:$$line"; done); \
test -n "$$out" && echo "$$out" && ret=1; \
test -z "$$ret"; \
done
check-untracked:
@if git ls-files $(top_srcdir) --others --exclude-standard | grep .; then exit 1; fi
check-headers: include/upipe/config.h
@for header in $(top_srcdir)/include/*/*.h; do \
h=$${header#$(top_srcdir)/include/}; \
if [ $$h != "upipe/config.h" ]; then \
guard=$$(echo _$${h}_ | tr [a-z] [A-Z] | tr '/.-' _); \
if ! grep -q $$guard $$header; then \
echo "$(c_red)FAIL$(c_end): $$h: invalid guard"; ret=1; \
fi; \
if ! grep -q Copyright $$header; then \
echo "$(c_red)FAIL$(c_end): $$h: missing copyright"; ret=1; \
fi; \
fi; \
if $(CC) -I$(top_srcdir)/include -Iinclude \
$(CPPFLAGS) $(CFLAGS) -Werror \
-include $$header -c -xc /dev/null -o /dev/null; \
then echo "$(c_green)PASS$(c_end): $$h"; \
else echo "$(c_red)FAIL$(c_end): $$h"; ret=1; \
fi; \
done; \
test -z "$$ret"
check-spelling:
@codespell \
--skip=$(top_srcdir)/lib/upipe-blackmagic/include \
--skip=$(top_srcdir)/lib/upipe-modules/http-parser \
--ignore-words-list multicat,happend,inout,parms,hist \
--ignore-regex '"te\.' \
$(top_srcdir)/doc \
$(top_srcdir)/examples \
$(top_srcdir)/include \
$(top_srcdir)/lib \
$(top_srcdir)/luajit \
$(top_srcdir)/tests \
$(top_srcdir)/x86
check-tests:
@cd $(top_srcdir)/tests; \
for src in *.c; do \
if grep -q '^#undef NDEBUG' $$src; \
then echo "$(c_green)PASS$(c_end): $$src"; \
else echo "$(c_red)FAIL$(c_end): $$src"; ret=1; \
fi; \
done; \
test -z "$$ret"
check-licenses:
@cd $(top_srcdir) && for file in $$(find \
-path './lib/upipe-blackmagic/include' -prune -o \
-path './lib/upipe-filters/zoneplate/videotestsrc.[ch]' -prune -o \
-path './lib/upipe-modules/http-parser' -prune -o \
-path './lib/upipe-ts/rsa_asn1.[ch]' -prune -o \
-path './lib/upipe-dveo/asi_ioctl.h' -prune -o \
-path './tests/checkasm' -prune -o \
-path './tests/upipe_h264_framer_test.h' -prune -o \
\( -name '*.c' -o -name '*.h' -o -name '*.cpp' \) -print); do \
if ! grep -q SPDX-License-Identifier: "$$file"; then \
echo "$${file#./}: missing SPDX-License-Identifier"; \
ret=1; \
fi; \
done; \
test -z "$$ret"
show-licenses:
@for lib in $$(find $(top_srcdir)/lib -maxdepth 1 -mindepth 1 -type d); do \
echo -n "$${lib##*/}:"; \
{ find "$(top_srcdir)/include/$${lib##*/}" -name '*.h'; \
find "$$lib" -name '*.c' -o -name '*.h' -o -name '*.cpp'; } | \
while read file; do \
sed -n 's/ \* SPDX-License-Identifier: //p' "$$file"; \
done | sort -u | while read id; do echo -n " $$id"; done; \
echo; \
done
symbols_allow = ubuf uclock ucookie udict umem umutex upipe uprobe upump uref ustring uuri
check-symbols:
@cd $(top_builddir) && \
if $(NM) -ACPDU $$(find . -name *.$(_so).* ! -type l) | \
grep -v ': \($(subst $() ,\|,$(symbols_allow))\|\)_'; then \
exit 1; \
fi