Makefile revision 1.98 1 # $NetBSD: Makefile,v 1.98 2023/07/11 17:33:45 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 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
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 # Extra -UYYDEBUG for lint's strict bool mode, since cgram.c contains 'int
61 # yydebug; if (yydebug)'.
62 cgram.ln: cgram.c
63 ${LINT} ${LINTFLAGS} ${LINTFLAGS.${.IMPSRC}} \
64 ${CPPFLAGS:C/-([IDUW]) */-\1/Wg:M-[IDUW]*} \
65 -i -UYYDEBUG ${.IMPSRC}
66
67 ${MAN}: makeman err.c Makefile ${MAN}.date
68 ${_MKTARGET_CREATE}
69 ${HOST_SH} ${.ALLSRC:M*makeman} \
70 "$$(cat ${.ALLSRC:M*.date})" ${.ALLSRC:M*err.c} \
71 >${.TARGET}
72
73 LDADD+= -lm
74 .ifndef HOSTPROG
75 DPADD+= ${LIBM}
76
77 LDADD+= -ll
78 DPADD+= ${LIBL}
79 .endif
80
81 err-msgs.h: err.c
82 ${_MKTARGET_CREATE}
83 sp='[[:space:]]*'; \
84 from="^$$sp\(\"[^\"].*\"\)\,$$sp/\*$$sp\(Q*[0-9][0-9]*\)$$sp\*/\$$"; \
85 ${TOOL_SED} -n -e "s,$$from,#define MSG_\2 \1,p" < ${.ALLSRC:M*err.c} > ${.TARGET}.tmp
86 mv -f ${.TARGET}.tmp ${.TARGET}
87
88 CLEANFILES+= err-msgs.h
89 DPSRCS+= err-msgs.h
90 CPPFLAGS+= -I.
91
92 externs1.h: err-msgs.h
93 ${SRCS:Nerr.c}: err-msgs.h
94
95 add-test: .PHONY
96 @set -eu; \
97 test=${NAME:Q}; \
98 [ "$$test" ] || { \
99 echo "usage: ${MAKE} add-test NAME=<name>"; \
100 exit; \
101 }; \
102 \
103 cd '../../../tests/usr.bin/xlint/lint1'; \
104 if [ -f "$$test.c" ]; then \
105 echo "error: test $$test already exists in $$PWD."; \
106 exit 1; \
107 fi; \
108 \
109 echo "=> Adding test $$test"; \
110 printf '%s\n' \
111 '/* $$''NetBSD$$ */' \
112 "# 3 \"$$test.c\"" \
113 '' \
114 '/*' \
115 ' * TODO: Explain the purpose of the test.' \
116 ' */' \
117 '' \
118 '/* lint1-extra-flags: -Z */' \
119 '/* lint1-flags: -Z */' \
120 '/* lint1-only-if: schar uchar ilp32 lp64 int long */' \
121 '/* lint1-skip-if: ldbl64 ldbl96 ldbl128 */' \
122 '' \
123 '// TODO: Add some code that passes.' \
124 '// TODO: Add some code that fails.' \
125 > "$$test.c"; \
126 cvs add "$$test.c"; \
127 ${MAKE} sync-mi
128
129 .include <bsd.prog.mk>
130