Makefile revision 1.93 1 # $NetBSD: Makefile,v 1.93 2023/02/06 20:26:05 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 192,214 # due to suppressed bool errors
24 LINTFLAGS.scan.c+= -X 307 # static variable unused
25
26 CPPFLAGS+= -DIS_LINT1
27 CPPFLAGS+= -I${.CURDIR} -I${.OBJDIR}
28 CPPFLAGS+= ${DEBUG:D-DDEBUG -DYYDEBUG}
29
30 COPTS.err.c+= ${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :}
31
32 BINDIR= /usr/libexec
33
34 CLEANFILES+= ${MAN} ${MAN}.date
35
36 .if ${USETOOLS} == "yes"
37 LINT1= ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
38 .endif
39 LINT1?= ./${PROG}
40
41 ${MAN}.date: err.c
42 sed -E \
43 -e 's,.*(....)/([0-9]{2})/0?([0-9]+).*,\2 \3\, \1,' \
44 -e 's,^01,January,' \
45 -e 's,^02,February,' \
46 -e 's,^03,March,' \
47 -e 's,^04,April,' \
48 -e 's,^05,May,' \
49 -e 's,^06,June,' \
50 -e 's,^07,July,' \
51 -e 's,^08,August,' \
52 -e 's,^09,September,' \
53 -e 's,^10,October,' \
54 -e 's,^11,November,' \
55 -e 's,^12,December,' \
56 -e 1q \
57 ${.ALLSRC} > ${.TARGET}
58
59 # Extra -UYYDEBUG since cgram.c contains 'int yydebug; if (yydebug)'.
60 cgram.ln: cgram.c
61 ${LINT} ${LINTFLAGS} \
62 ${CPPFLAGS:C/-([IDUW]) */-\1/Wg:M-[IDUW]*} \
63 -i -UYYDEBUG ${.IMPSRC}
64
65 ${MAN}: makeman err.c Makefile ${MAN}.date
66 ${_MKTARGET_CREATE}
67 ${HOST_SH} ${.ALLSRC:M*makeman} \
68 "$$(cat ${.ALLSRC:M*.date})" ${.ALLSRC:M*err.c} \
69 >${.TARGET}
70
71 LDADD+= -lm
72 .ifndef HOSTPROG
73 DPADD+= ${LIBM}
74
75 LDADD+= -ll
76 DPADD+= ${LIBL}
77 .endif
78
79 err-msgs.h: err.c
80 ${_MKTARGET_CREATE}
81 sp='[[:space:]]*'; \
82 from="^$$sp\(\".*\"\)\,$$sp/\*$$sp\(Q*[0-9][0-9]*\)$$sp\*/\$$"; \
83 ${TOOL_SED} -n -e "s,$$from,#define MSG_\2 \1,p" < ${.ALLSRC:M*err.c} > ${.TARGET}.tmp
84 mv -f ${.TARGET}.tmp ${.TARGET}
85
86 CLEANFILES+= err-msgs.h
87 DPSRCS+= err-msgs.h
88 CPPFLAGS+= -I.
89
90 externs1.h: err-msgs.h
91 ${SRCS:Nerr.c}: err-msgs.h
92
93 add-test: .PHONY
94 @set -eu; \
95 test=${NAME:Q}; \
96 [ "$$test" ] || { \
97 echo "usage: ${MAKE} add-test NAME=<name>"; \
98 exit; \
99 }; \
100 \
101 cd '../../../tests/usr.bin/xlint/lint1'; \
102 if [ -f "$$test.c" ]; then \
103 echo "error: test $$test already exists in $$PWD."; \
104 exit 1; \
105 fi; \
106 \
107 echo "=> Adding test $$test"; \
108 printf '%s\n' \
109 '/* $$''NetBSD$$ */' \
110 "# 3 \"$$test.c\"" \
111 '' \
112 '/*' \
113 ' * TODO: Explain the purpose of the test.' \
114 ' */' \
115 '' \
116 '/* lint1-extra-flags: -Z */' \
117 '/* lint1-flags: -Z */' \
118 '/* lint1-only-if: schar uchar ilp32 lp64 int long */' \
119 '/* lint1-skip-if: ldbl-64 ldbl-96 ldbl-128 */' \
120 '' \
121 '// TODO: Add some code that passes.' \
122 '// TODO: Add some code that fails.' \
123 > "$$test.c"; \
124 cvs add "$$test.c"; \
125 printf '%s\n' \
126 '/^FILES+=/i' \
127 "FILES+= $$test.c" \
128 '.' 'w' 'q' \
129 | ed Makefile; \
130 ${MAKE} sync-mi
131
132 .include <bsd.prog.mk>
133