1 # Makefile for STDexecDTS.c
3 # Author: Øyvind A. Holm <sunny@sunbase.org>
11 CFILES
+= STDexecDTS.c
14 CFLAGS
+= $$(test -n
"$(GCOV)" && echo
-n
"-fprofile-arcs -ftest-coverage")
15 CFLAGS
+= $$(test -n
"$(PROF)" && echo
-n
"-pg")
22 DEPS
= version.h
$(HFILES
) Makefile
23 GNCOV_STR
= $$(test -n
"$(GNCOV)" && echo
"-g")
25 HFILES
+= STDexecDTS.h
27 INSTALL_TARGETS
+= $(PREFIX
)/bin
/$(EXEC
)
29 LDFLAGS
+= $$(test -n
"$(PROF)" && echo
-n
"-pg")
31 LIBS
+= $$(test -n
"$(GCOV)" && echo
"-lgcov --coverage")
36 TESTABLE_LINES
= $$(grep
-E
'^ +\#\#\#\#\#:' *.c.gcov \
37 | grep
-vF
'/* gncov */' | wc
-l
)
43 $(LD
) -o
$(EXEC
) $(LDFLAGS
) $(OBJS
) $(LIBS
)
45 version.h
: Gen-version
$(CFILES
) $(HFILES
) Makefile
48 STDexecDTS.o
: STDexecDTS.c
$(DEPS
)
49 $(CC
) $(CFLAGS
) STDexecDTS.c
51 selftest.o
: selftest.c
$(DEPS
)
52 $(CC
) $(CFLAGS
) selftest.c
57 rm -f
*.gcda
*.gcno
*.gcov
58 rm -f gmon.out gmon.sum
64 $(EDITOR
) $$(git ls-files
)
69 $(MAKE
) clean test GCOV
=1
71 @echo
$$(grep
-E
'^ +#####:' *.c.gcov | wc
-l
) untested lines
>&2
72 @echo
$$(grep
-E
'^ +#####:' *.c.gcov | grep
-F
'/* gncov */' \
73 | wc
-l
) gncov lines
>&2
74 @echo
$(TESTABLE_LINES
) testable lines
>&2
78 gcov-cmt
$(GNCOV_STR
) $(CFILES
)
80 .PHONY
: gcov-cmt-clean
86 gdb
-x gdbrc
$$(cat gdbopts
2>/dev
/null
) $(EXEC
)
89 install: $(INSTALL_TARGETS
)
91 $(PREFIX
)/bin
/$(EXEC
): $(EXEC
)
92 mkdir
-p
$(PREFIX
)/bin
93 install $(EXEC
) $(PREFIX
)/bin
/$(EXEC
)
95 tags: $(CFILES
) $(HFILES
)
96 ctags
$(CFILES
) $(HFILES
)
104 $(MAKE
) testcomb WHAT
=test
108 $(MAKE
) clean $(WHAT
) NDEBUG
=1
109 $(MAKE
) clean $(WHAT
) UNUSED
=1
110 $(MAKE
) clean $(WHAT
) NDEBUG
=1 UNUSED
=1
111 $(MAKE
) clean $(WHAT
)
115 @echo Check files for long lines
>&2
116 @for f in
$(CFILES
) $(HFILES
) Gen-version Makefile
; do \
117 [ -f
"$$f" ] && expand
"$$f" | sed
's/ $$//;' \
118 | grep
-q
-E
'.{80}' && echo
"$$f"; \
119 done | grep .
&& exit
1 || true
123 @
$(MAKE
) -s gcov
2>.make-tlok.tmp
>&2; res
=$$?
; \
124 if
test $$res -eq
0; then \
126 "$(TESTABLE_LINES)" \
127 "$$(grep ^1\\.\\. .make-tlok.tmp \
128 | perl -pe 's/^1\.\.(\d+).*/$$1/;')"; \
130 grep
"Looks like you failed" <.make-tlok.tmp \
132 -e
's/.*failed (\d+) tests? of (\d+).*/$$1\/$$2 FAIL/;'; \
138 rm -f
$(INSTALL_TARGETS
)
146 $(MAKE
) testcomb WHAT
=valgrind