c/src/Makefile: Remove `-Wall`, `-Werror` and `-Wextra` from `LDFLAGS`
[sunny256-utils.git] / Lib / std / c / src / Makefile
blob429b282c85602a0c9def561c590ff0837258eaf0
1 # Makefile for STDexecDTS.c
2 # File ID: STDuuidDTS
3 # Author: Øyvind A. Holm <sunny@sunbase.org>
5 PREFIX = /usr/local
7 EXEC = STDexecDTS
9 CC = cc
10 LD = cc
12 CFLAGS =
13 CFLAGS += $$(test -n "$(GCOV)" && echo -n "-fprofile-arcs -ftest-coverage")
14 CFLAGS += $$(test -n "$(PROF)" && echo -n "-pg")
15 CFLAGS += -O0 -c -g
16 CFLAGS += -Wall
17 CFLAGS += -Werror
18 CFLAGS += -Wextra
20 LDFLAGS =
21 LDFLAGS += $$(test -n "$(PROF)" && echo -n "-pg")
23 LIBS =
24 LIBS += $$(test -n "$(GCOV)" && echo "-lgcov --coverage")
26 OBJS =
27 OBJS += STDexecDTS.o
28 OBJS += selftest.o
30 CFILES =
31 CFILES += STDexecDTS.c
32 CFILES += selftest.c
34 HFILES =
35 HFILES += STDexecDTS.h
37 DEPS = version.h $(HFILES) Makefile
38 GNCOV_STR = $$(test -n "$(GNCOV)" && echo "-g")
39 TESTABLE_LINES = $$(grep -E '^ +\#\#\#\#\#:' *.c.gcov \
40 | grep -vF '/* gncov */' | wc -l)
42 .PHONY: all
43 all: $(EXEC)
45 $(EXEC): $(OBJS)
46 $(LD) -o $(EXEC) $(LDFLAGS) $(OBJS) $(LIBS)
48 version.h: Gen-version $(CFILES) $(HFILES) Makefile
49 ./Gen-version
51 STDexecDTS.o: STDexecDTS.c $(DEPS)
52 $(CC) $(CFLAGS) STDexecDTS.c
54 selftest.o: selftest.c $(DEPS)
55 $(CC) $(CFLAGS) selftest.c
57 .PHONY: clean
58 clean:
59 rm -f $(EXEC) $(OBJS)
60 rm -f *.gcda *.gcno *.gcov
61 rm -f gmon.out gmon.sum
62 rm -f version.h
63 cd t && $(MAKE) clean
65 .PHONY: edit
66 edit: tags
67 $(EDITOR) $$(git ls-files)
68 rm tags
70 .PHONY: gcov
71 gcov:
72 $(MAKE) clean test GCOV=1
73 gcov $(CFILES)
74 @echo $$(grep -E '^ +#####:' *.c.gcov | wc -l) untested lines >&2
75 @echo $$(grep -E '^ +#####:' *.c.gcov | grep -F '/* gncov */' \
76 | wc -l) gncov lines >&2
77 @echo $(TESTABLE_LINES) testable lines >&2
79 .PHONY: gcov-cmt
80 gcov-cmt: gcov
81 gcov-cmt $(GNCOV_STR) $(CFILES)
83 .PHONY: gcov-cmt-clean
84 gcov-cmt-clean:
85 gcov-cmt -d $(CFILES)
87 .PHONY: gdb
88 gdb: $(EXEC)
89 gdb -x gdbrc $$(cat gdbopts 2>/dev/null) $(EXEC)
91 .PHONY: install
92 install: $(PREFIX)/bin/$(EXEC)
94 $(PREFIX)/bin/$(EXEC): $(EXEC)
95 mkdir -p $(PREFIX)/bin
96 install $(EXEC) $(PREFIX)/bin/$(EXEC)
98 tags: $(CFILES) $(HFILES)
99 ctags $(CFILES) $(HFILES)
101 .PHONY: test
102 test: $(EXEC)
103 cd t && $(MAKE) test
105 .PHONY: testall
106 testall:
107 $(MAKE) testcomb WHAT=test
109 .PHONY: testcomb
110 testcomb:
111 $(MAKE) clean $(WHAT) NDEBUG=1
112 $(MAKE) clean $(WHAT) UNUSED=1
113 $(MAKE) clean $(WHAT) NDEBUG=1 UNUSED=1
114 $(MAKE) clean $(WHAT)
116 .PHONY: tlok
117 tlok:
118 @$(MAKE) -s gcov 2>.make-tlok.tmp >&2; res=$$?; \
119 if test $$res -eq 0; then \
120 printf '%u:%u\n' \
121 "$(TESTABLE_LINES)" \
122 "$$(grep ^1\\.\\. .make-tlok.tmp \
123 | perl -pe 's/^1\.\.(\d+).*/$$1/;')"; \
124 else \
125 grep "Looks like you failed" <.make-tlok.tmp \
126 | perl -p \
127 -e 's/.*failed (\d+) tests? of (\d+).*/$$1\/$$2 FAIL/;'; \
128 fi; \
129 rm .make-tlok.tmp
131 .PHONY: uninstall
132 uninstall:
133 rm -f $(PREFIX)/bin/$(EXEC)
135 .PHONY: valgrind
136 valgrind:
137 cd t && $(MAKE) valgrind
139 .PHONY: valgrindall
140 valgrindall:
141 $(MAKE) testcomb WHAT=valgrind