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