Makefile revision 1.86 1 # $NetBSD: Makefile,v 1.86 2021/09/05 16:36:56 rillig Exp $
2
3 .include <bsd.own.mk>
4
5 PROG= lint1
6 SRCS= cgram.y \
7 ckbool.c ckctype.c ckgetopt.c debug.c \
8 decl.c emit.c emit1.c err.c func.c init.c inittyp.c lex.c \
9 main1.c mem.c mem1.c oper.c scan.l tree.c tyname.c
10
11 MAN= lint.7
12 YHEADER=
13 #DBG= -g
14 #CPPFLAGS+= -DYYDEBUG=1
15 #YFLAGS+= -v
16 #LFLAGS+= -d
17
18 CWARNFLAGS.clang+= -Wno-error=implicit-int-float-conversion
19 LINTFLAGS+= -T
20 LOBJS.${PROG}+= ${SRCS:M*.y:.y=.ln}
21 LOBJS.${PROG}+= ${SRCS:M*.l:.l=.ln}
22 LINTFLAGS.scan.c+= -X 107,126,330,331,332,333 # strict bool mode
23 LINTFLAGS.scan.c+= -X 162 # comparison of 'unsigned <= 0'
24 LINTFLAGS.scan.c+= -X 192,214 # due to suppressed bool errors
25 LINTFLAGS.scan.c+= -X 307 # static variable unused
26
27 CPPFLAGS+= -DIS_LINT1
28 CPPFLAGS+= -I${.CURDIR}
29 CPPFLAGS+= ${DEBUG:D-DDEBUG -DYYDEBUG}
30
31 COPTS.err.c+= ${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :}
32
33 BINDIR= /usr/libexec
34
35 CLEANFILES+= ${MAN} ${MAN}.date
36
37 .if ${USETOOLS} == "yes"
38 LINT1= ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
39 .endif
40 LINT1?= ./${PROG}
41
42 ${MAN}.date: err.c
43 sed -E \
44 -e 's,.*(....)/([0-9]{2})/0?([0-9]+).*,\2 \3\, \1,' \
45 -e 's,^01,January,' \
46 -e 's,^02,February,' \
47 -e 's,^03,March,' \
48 -e 's,^04,April,' \
49 -e 's,^05,May,' \
50 -e 's,^06,June,' \
51 -e 's,^07,July,' \
52 -e 's,^08,August,' \
53 -e 's,^09,September,' \
54 -e 's,^10,October,' \
55 -e 's,^11,November,' \
56 -e 's,^12,December,' \
57 -e 1q \
58 ${.ALLSRC} > ${.TARGET}
59
60 ${MAN}: makeman ${LINT1:./%=%} Makefile ${MAN}.date
61 ${_MKTARGET_CREATE}
62 ${HOST_SH} ${.ALLSRC:M*makeman} "$$(cat ${.ALLSRC:M*.date})" ${LINT1} -m >${.TARGET}
63
64 LDADD+= -lm
65 .ifndef HOSTPROG
66 DPADD+= ${LIBM}
67
68 LDADD+= -ll
69 DPADD+= ${LIBL}
70 .endif
71
72 .include "Makefile.err-msgs-h"
73 ${SRCS:Nerr.c}: err-msgs.h
74
75 add-test: .PHONY
76 @set -eu; \
77 test=${NAME:Q}; \
78 [ "$$test" ] || { \
79 echo "usage: ${MAKE} add-test NAME=<name>"; \
80 exit; \
81 }; \
82 \
83 cd '../../../tests/usr.bin/xlint/lint1'; \
84 if [ -f "$$test.c" ]; then \
85 echo "error: test $$test already exists in $$PWD."; \
86 exit 1; \
87 fi; \
88 \
89 echo "=> Adding test $$test"; \
90 printf '%s\n' \
91 '/* $$''NetBSD$$ */' \
92 "# 3 \"$$test.c\"" \
93 '' \
94 '/*' \
95 ' * TODO: Explain the purpose of the test.' \
96 ' */' \
97 '' \
98 '/* lint1-extra-flags: -Z */' \
99 '/* lint1-flags: -Z */' \
100 '/* lint1-only-if: schar uchar ilp32 lp64 int long */' \
101 '/* lint1-skip-if: ldbl-64 ldbl-96 ldbl-128 */' \
102 '' \
103 '// TODO: Add some code that passes.' \
104 '// TODO: Add some code that fails.' \
105 > "$$test.c"; \
106 > "$$test.exp"; \
107 cvs add "$$test.c" "$$test.exp"; \
108 printf '%s\n' \
109 '/^FILES+=/i' \
110 "FILES+= $$test.c" \
111 "FILES+= $$test.exp" \
112 '.' 'w' 'q' \
113 | ed Makefile; \
114 ${MAKE} sync-mi
115
116 .include <bsd.prog.mk>
117