std.h: Don't use `extern` in function prototypes
[sunny256-utils.git] / Lib / std / c / src / Makefile
blob9c6778ef77d8ce8fc375a4c70f755a5ae5812bf8
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: testsrc
117 testsrc:
118 @echo Check files for long lines >&2
119 @for f in $(CFILES) $(HFILES) Gen-version Makefile; do \
120 [ -f "$$f" ] && expand "$$f" | sed 's/ $$//;' \
121 | grep -q -E '.{80}' && echo "$$f"; \
122 done | grep . && exit 1 || true
124 .PHONY: tlok
125 tlok:
126 @$(MAKE) -s gcov 2>.make-tlok.tmp >&2; res=$$?; \
127 if test $$res -eq 0; then \
128 printf '%u:%u\n' \
129 "$(TESTABLE_LINES)" \
130 "$$(grep ^1\\.\\. .make-tlok.tmp \
131 | perl -pe 's/^1\.\.(\d+).*/$$1/;')"; \
132 else \
133 grep "Looks like you failed" <.make-tlok.tmp \
134 | perl -p \
135 -e 's/.*failed (\d+) tests? of (\d+).*/$$1\/$$2 FAIL/;'; \
136 fi; \
137 rm .make-tlok.tmp
139 .PHONY: uninstall
140 uninstall:
141 rm -f $(PREFIX)/bin/$(EXEC)
143 .PHONY: valgrind
144 valgrind:
145 cd t && $(MAKE) valgrind
147 .PHONY: valgrindall
148 valgrindall:
149 $(MAKE) testcomb WHAT=valgrind