1 # Makefile for STDexecDTS.c
3 # Author: Øyvind A. Holm <sunny@sunbase.org>
13 CFLAGS
+= $$(test -n
"$(GCOV)" && echo
-n
"-fprofile-arcs -ftest-coverage")
14 CFLAGS
+= $$(test -n
"$(PROF)" && echo
-n
"-pg")
23 LDFLAGS
+= $$(test -n
"$(PROF)" && echo
-n
"-pg")
26 LIBS
+= $$(test -n
"$(GCOV)" && echo
"-lgcov --coverage")
33 CFILES
+= STDexecDTS.c
37 HFILES
+= STDexecDTS.h
39 DEPS
= version.h
$(HFILES
) Makefile
40 GNCOV_STR
= $$(test -n
"$(GNCOV)" && echo
"-g")
41 TESTABLE_LINES
= $$(grep
-E
'^ +\#\#\#\#\#:' *.c.gcov \
42 | grep
-vF
'/* gncov */' | wc
-l
)
48 $(LD
) -o
$(EXEC
) $(LDFLAGS
) $(OBJS
) $(LIBS
)
50 version.h
: Gen-version
$(CFILES
) $(HFILES
) Makefile
53 STDexecDTS.o
: STDexecDTS.c
$(DEPS
)
54 $(CC
) $(CFLAGS
) STDexecDTS.c
56 selftest.o
: selftest.c
$(DEPS
)
57 $(CC
) $(CFLAGS
) selftest.c
62 rm -f
*.gcda
*.gcno
*.gcov
63 rm -f gmon.out gmon.sum
69 $(EDITOR
) $$(git ls-files
)
74 $(MAKE
) clean test GCOV
=1
76 @echo
$$(grep
-E
'^ +#####:' *.c.gcov | wc
-l
) untested lines
>&2
77 @echo
$$(grep
-E
'^ +#####:' *.c.gcov | grep
-F
'/* gncov */' \
78 | wc
-l
) gncov lines
>&2
79 @echo
$(TESTABLE_LINES
) testable lines
>&2
83 gcov-cmt
$(GNCOV_STR
) $(CFILES
)
85 .PHONY
: gcov-cmt-clean
91 gdb
-x gdbrc
$$(cat gdbopts
2>/dev
/null
) $(EXEC
)
94 install: $(PREFIX
)/bin
/$(EXEC
)
96 $(PREFIX
)/bin
/$(EXEC
): $(EXEC
)
97 mkdir
-p
$(PREFIX
)/bin
98 install $(EXEC
) $(PREFIX
)/bin
/$(EXEC
)
100 tags: $(CFILES
) $(HFILES
)
101 ctags
$(CFILES
) $(HFILES
)
109 $(MAKE
) testcomb WHAT
=test
113 $(MAKE
) clean $(WHAT
) NDEBUG
=1
114 $(MAKE
) clean $(WHAT
) UNUSED
=1
115 $(MAKE
) clean $(WHAT
) NDEBUG
=1 UNUSED
=1
116 $(MAKE
) clean $(WHAT
)
120 @echo Check files for long lines
>&2
121 @for f in
$(CFILES
) $(HFILES
) Gen-version Makefile
; do \
122 [ -f
"$$f" ] && expand
"$$f" | sed
's/ $$//;' \
123 | grep
-q
-E
'.{80}' && echo
"$$f"; \
124 done | grep .
&& exit
1 || true
128 @
$(MAKE
) -s gcov
2>.make-tlok.tmp
>&2; res
=$$?
; \
129 if
test $$res -eq
0; then \
131 "$(TESTABLE_LINES)" \
132 "$$(grep ^1\\.\\. .make-tlok.tmp \
133 | perl -pe 's/^1\.\.(\d+).*/$$1/;')"; \
135 grep
"Looks like you failed" <.make-tlok.tmp \
137 -e
's/.*failed (\d+) tests? of (\d+).*/$$1\/$$2 FAIL/;'; \
143 rm -f
$(PREFIX
)/bin
/$(EXEC
)
147 cd t
&& $(MAKE
) valgrind
151 $(MAKE
) testcomb WHAT
=valgrind