1 # Makefile for STDexecDTS.c
3 # Author: Øyvind A. Holm <sunny@sunbase.org>
12 CFILES
+= STDexecDTS.c
17 CFLAGS
+= $$(test -n
"$(GCOV)" && echo
-n
"-fprofile-arcs -ftest-coverage")
18 CFLAGS
+= $$(test -n
"$(PROF)" && echo
-n
"-pg")
25 DEPS
= version.h
$(HFILES
) Makefile
26 GNCOV_STR
= $$(test -n
"$(GNCOV)" && echo
"-g")
28 HFILES
+= STDexecDTS.h
30 HTMLFILE
= $(EXEC
).html
32 INSTALL_TARGETS
+= $(PREFIX
)/bin
/$(EXEC
)
33 INSTALL_TARGETS
+= $(PREFIX
)/share
/man
/man1
/$(MANPAGE
)
35 LDFLAGS
+= $$(test -n
"$(PROF)" && echo
-n
"-pg")
37 LIBS
+= $$(test -n
"$(GCOV)" && echo
"-lgcov --coverage")
39 MANSRC
= $(MANPAGE
).man
40 MAN_DATE
= $$(grep EXEC_DATE version.h | cut
-d
'"' -f
2 | sed
's/-/\\\\-/g;')
50 CMD_VALGRIND
= valgrind
52 CMD_VALGRIND
+= --leak-check
=full
53 CMD_VALGRIND
+= --show-leak-kinds
=all
55 MAN_VERSION
= $$(grep EXEC_VERSION version.h | cut
-d
'"' -f
2 \
57 TESTABLE_LINES
= $$(grep
-E
'^ +\#\#\#\#\#:' *.c.gcov \
58 | grep
-vF
'/* gncov */' | wc
-l
)
61 all: $(EXEC
) $(MANPAGE
)
64 $(LD
) -o
$(EXEC
) $(LDFLAGS
) $(OBJS
) $(LIBS
)
66 $(HTMLFILE
): $(MANPAGE
)
67 man
-Thtml .
/$(MANPAGE
) >$@.tmp
70 $(MANPAGE
): $(MANSRC
) version.h
71 sed
"s/RPL_DATE/$(MAN_DATE)/g; s/RPL_VERSION/$(MAN_VERSION)/g;" \
75 $(PDFFILE
): $(MANPAGE
)
76 man
-Tpdf .
/$(MANPAGE
) >$@.tmp
79 version.h
: Gen-version
$(CFILES
) $(HFILES
) Makefile
82 binbuf.o
: binbuf.c
$(DEPS
)
83 $(CC
) $(CFLAGS
) binbuf.c
85 STDexecDTS.o
: STDexecDTS.c
$(DEPS
)
86 $(CC
) $(CFLAGS
) STDexecDTS.c
91 selftest.o
: selftest.c
$(DEPS
)
92 $(CC
) $(CFLAGS
) selftest.c
94 strings.o
: strings.c
$(DEPS
)
95 $(CC
) $(CFLAGS
) strings.c
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
109 $(EDITOR
) $$(git ls-files
)
114 $(MAKE
) clean test GCOV
=1
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
123 gcov-cmt
$(GNCOV_STR
) $(CFILES
)
125 .PHONY
: gcov-cmt-clean
127 gcov-cmt
-d
$(CFILES
)
131 gdb
-x gdbrc
$$(cat gdbopts
2>/dev
/null
) $(EXEC
)
137 install: $(INSTALL_TARGETS
)
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
)
155 .
/$(EXEC
) --selftest
$(TESTS
)
159 $(MAKE
) testcomb WHAT
=test
163 $(MAKE
) clean $(WHAT
) NDEBUG
=1
164 $(MAKE
) clean $(WHAT
) UNUSED
=1
165 $(MAKE
) clean $(WHAT
) NDEBUG
=1 UNUSED
=1
166 $(MAKE
) clean $(WHAT
)
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
178 @
$(MAKE
) -s gcov
2>.make-tlok.tmp
>&2; res
=$$?
; \
179 if
test $$res -eq
0; then \
181 "$(TESTABLE_LINES)" \
182 "$$(grep ^1\\.\\. .make-tlok.tmp \
183 | perl -pe 's/^1\.\.(\d+).*/$$1/;')"; \
185 grep
"Looks like you failed" <.make-tlok.tmp \
187 -e
's/.*failed (\d+) tests? of (\d+).*/$$1\/$$2 FAIL/;'; \
189 [ -e
$(EXEC
) ] || echo FAIL
; \
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
207 rm -f
$(INSTALL_TARGETS
)
211 .
/$(EXEC
) --valgrind
$(TESTS
)
212 $(CMD_VALGRIND
) .
/$(EXEC
) --selftest
$(TESTS
) | grep
-v ^ok
216 $(MAKE
) testcomb WHAT
=valgrind