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