Upgrade yt-dlp from version stable@2024.10.07 to stable@2024.12.13
[sunny256-utils.git] / Lib / std / c / src / Makefile
blob82831ae1e0ed642a33c04a855d1eceee7af53b5d
1 # Makefile for STDexecDTS.c
2 # File ID: STDuuidDTS
3 # Author: Øyvind A. Holm <sunny@sunbase.org>
5 CC = cc
6 EXEC = STDexecDTS
7 LD = cc
8 PREFIX = /usr/local
10 CFILES =
11 CFILES += binbuf.c
12 CFILES += STDexecDTS.c
13 CFILES += io.c
14 CFILES += selftest.c
15 CFILES += strings.c
16 CFLAGS =
17 CFLAGS += $$(test -n "$(GCOV)" && echo -n "-fprofile-arcs -ftest-coverage")
18 CFLAGS += $$(test -n "$(PROF)" && echo -n "-pg")
19 CFLAGS += -O0
20 CFLAGS += -Wall
21 CFLAGS += -Werror
22 CFLAGS += -Wextra
23 CFLAGS += -c
24 CFLAGS += -g
25 DEPS = version.h $(HFILES) Makefile
26 GNCOV_STR = $$(test -n "$(GNCOV)" && echo "-g")
27 HFILES =
28 HFILES += STDexecDTS.h
29 HFILES += binbuf.h
30 HTMLFILE = $(EXEC).html
31 INSTALL_TARGETS =
32 INSTALL_TARGETS += $(PREFIX)/bin/$(EXEC)
33 INSTALL_TARGETS += $(PREFIX)/share/man/man1/$(MANPAGE)
34 LDFLAGS =
35 LDFLAGS += $$(test -n "$(PROF)" && echo -n "-pg")
36 LIBS =
37 LIBS += $$(test -n "$(GCOV)" && echo "-lgcov --coverage")
38 MANPAGE = $(EXEC).1
39 MANSRC = $(MANPAGE).man
40 MAN_DATE = $$(grep EXEC_DATE version.h | cut -d '"' -f 2 | sed 's/-/\\\\-/g;')
41 OBJS =
42 OBJS += STDexecDTS.o
43 OBJS += binbuf.o
44 OBJS += io.o
45 OBJS += selftest.o
46 OBJS += strings.o
47 PDFFILE = $(EXEC).pdf
48 TESTS = all
50 CMD_VALGRIND = valgrind
51 CMD_VALGRIND += -q
52 CMD_VALGRIND += --leak-check=full
53 CMD_VALGRIND += --show-leak-kinds=all
54 CMD_VALGRIND += --
55 MAN_VERSION = $$(grep EXEC_VERSION version.h | cut -d '"' -f 2 \
56 | sed 's/-/\\\\-/g;')
57 TESTABLE_LINES = $$(grep -E '^ +\#\#\#\#\#:' *.c.gcov \
58 | grep -vF '/* gncov */' | wc -l)
60 .PHONY: all
61 all: $(EXEC) $(MANPAGE)
63 $(EXEC): $(OBJS)
64 $(LD) -o $(EXEC) $(LDFLAGS) $(OBJS) $(LIBS)
66 $(HTMLFILE): $(MANPAGE)
67 man -Thtml ./$(MANPAGE) >$@.tmp
68 mv $@.tmp $@
70 $(MANPAGE): $(MANSRC) version.h
71 sed "s/RPL_DATE/$(MAN_DATE)/g; s/RPL_VERSION/$(MAN_VERSION)/g;" \
72 <$< >$@.tmp
73 mv $@.tmp $@
75 $(PDFFILE): $(MANPAGE)
76 man -Tpdf ./$(MANPAGE) >$@.tmp
77 mv $@.tmp $@
79 version.h: Gen-version $(CFILES) $(HFILES) Makefile
80 ./Gen-version
82 binbuf.o: binbuf.c $(DEPS)
83 $(CC) $(CFLAGS) binbuf.c
85 STDexecDTS.o: STDexecDTS.c $(DEPS)
86 $(CC) $(CFLAGS) STDexecDTS.c
88 io.o: io.c $(DEPS)
89 $(CC) $(CFLAGS) io.c
91 selftest.o: selftest.c $(DEPS)
92 $(CC) $(CFLAGS) selftest.c
94 strings.o: strings.c $(DEPS)
95 $(CC) $(CFLAGS) strings.c
97 .PHONY: clean
98 clean:
99 rm -f $(EXEC) $(OBJS)
100 rm -f $(HTMLFILE) $(HTMLFILE).tmp
101 rm -f $(MANPAGE) $(MANPAGE).tmp
102 rm -f $(PDFFILE) $(PDFFILE).tmp
103 rm -f *.gcda *.gcno *.gcov
104 rm -f gmon.out gmon.sum
105 rm -f version.h
107 .PHONY: edit
108 edit: tags
109 $(EDITOR) $$(git ls-files)
110 rm tags
112 .PHONY: gcov
113 gcov:
114 $(MAKE) clean test GCOV=1
115 gcov $(CFILES)
116 @echo $$(grep -E '^ +#####:' *.c.gcov | wc -l) untested lines >&2
117 @echo $$(grep -E '^ +#####:' *.c.gcov | grep -F '/* gncov */' \
118 | wc -l) gncov lines >&2
119 @echo $(TESTABLE_LINES) testable lines >&2
121 .PHONY: gcov-cmt
122 gcov-cmt: gcov
123 gcov-cmt $(GNCOV_STR) $(CFILES)
125 .PHONY: gcov-cmt-clean
126 gcov-cmt-clean:
127 gcov-cmt -d $(CFILES)
129 .PHONY: gdb
130 gdb: $(EXEC)
131 gdb -x gdbrc $$(cat gdbopts 2>/dev/null) $(EXEC)
133 .PHONY: html
134 html: $(HTMLFILE)
136 .PHONY: install
137 install: $(INSTALL_TARGETS)
139 .PHONY: pdf
140 pdf: $(PDFFILE)
142 $(PREFIX)/bin/$(EXEC): $(EXEC)
143 mkdir -p $(PREFIX)/bin
144 install $(EXEC) $(PREFIX)/bin/$(EXEC)
146 $(PREFIX)/share/man/man1/$(MANPAGE): $(MANPAGE)
147 mkdir -p $(PREFIX)/share/man/man1
148 install $(MANPAGE) $(PREFIX)/share/man/man1/$(MANPAGE)
150 tags: $(CFILES) $(HFILES)
151 ctags $(CFILES) $(HFILES)
153 .PHONY: test
154 test: $(EXEC)
155 ./$(EXEC) --selftest $(TESTS)
157 .PHONY: testall
158 testall:
159 $(MAKE) testcomb WHAT=test
161 .PHONY: testcomb
162 testcomb:
163 $(MAKE) clean $(WHAT) NDEBUG=1
164 $(MAKE) clean $(WHAT) UNUSED=1
165 $(MAKE) clean $(WHAT) NDEBUG=1 UNUSED=1
166 $(MAKE) clean $(WHAT)
168 .PHONY: testsrc
169 testsrc:
170 @echo Check files for long lines >&2
171 @for f in $(CFILES) $(HFILES) $(MANSRC) Gen-version Makefile; do \
172 [ -f "$$f" ] && expand "$$f" | sed 's/ $$//;' \
173 | grep -q -E '.{80}' && echo "$$f"; \
174 done | grep . && exit 1 || true
176 .PHONY: tlok
177 tlok:
178 @$(MAKE) -s gcov 2>.make-tlok.tmp >&2; res=$$?; \
179 if test $$res -eq 0; then \
180 printf '%u:%u\n' \
181 "$(TESTABLE_LINES)" \
182 "$$(grep ^1\\.\\. .make-tlok.tmp \
183 | perl -pe 's/^1\.\.(\d+).*/$$1/;')"; \
184 else \
185 grep "Looks like you failed" <.make-tlok.tmp \
186 | perl -p \
187 -e 's/.*failed (\d+) tests? of (\d+).*/$$1\/$$2 FAIL/;'; \
188 fi; \
189 [ -e $(EXEC) ] || echo FAIL; \
190 rm .make-tlok.tmp
192 .PHONY: tlokall
193 tlokall:
194 @echo -n "tlok TESTS=all : "
195 @$(MAKE) -s tlok TESTS=all
196 @echo -n "tlok TESTS=func : "
197 @$(MAKE) -s tlok TESTS=func
198 @echo -n "tlok TESTS=exec : "
199 @$(MAKE) -s tlok TESTS=exec
200 @echo -n "tlok TESTS=func,exec : "
201 @$(MAKE) -s tlok TESTS=func,exec
202 @echo -n "tlok TESTS=none : "
203 @$(MAKE) -s tlok TESTS=none
205 .PHONY: uninstall
206 uninstall:
207 rm -f $(INSTALL_TARGETS)
209 .PHONY: valgrind
210 valgrind: $(EXEC)
211 ./$(EXEC) --valgrind $(TESTS)
212 $(CMD_VALGRIND) ./$(EXEC) --selftest $(TESTS) | grep -v ^ok
214 .PHONY: valgrindall
215 valgrindall:
216 $(MAKE) testcomb WHAT=valgrind