Makefile revision 1.89
1#	$NetBSD: Makefile,v 1.89 2022/04/09 14:50:18 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.scan.c+=	-X 107,126,330,331,332,333	# strict bool mode
23LINTFLAGS.scan.c+=	-X 192,214	# due to suppressed bool errors
24LINTFLAGS.scan.c+=	-X 307		# static variable unused
25
26CPPFLAGS+=	-DIS_LINT1
27CPPFLAGS+=	-I${.CURDIR} -I${.OBJDIR}
28CPPFLAGS+=	${DEBUG:D-DDEBUG -DYYDEBUG}
29
30COPTS.err.c+=	${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :}
31
32BINDIR=		/usr/libexec
33
34CLEANFILES+=	${MAN} ${MAN}.date
35
36.if ${USETOOLS} == "yes"
37LINT1=		${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
38.endif
39LINT1?=		./${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)'.
60cgram.ln: cgram.c
61	: extra
62	${LINT} ${LINTFLAGS} \
63	    ${CPPFLAGS:C/-([IDUW]) */-\1/Wg:M-[IDUW]*} \
64	    -i -UYYDEBUG ${.IMPSRC}
65
66${MAN}:		makeman ${LINT1:./%=%} Makefile ${MAN}.date
67	${_MKTARGET_CREATE}
68	${HOST_SH} ${.ALLSRC:M*makeman} "$$(cat ${.ALLSRC:M*.date})" ${LINT1} -m >${.TARGET}
69
70LDADD+=		-lm
71.ifndef HOSTPROG
72DPADD+=		${LIBM}
73
74LDADD+=		-ll
75DPADD+=		${LIBL}
76.endif
77
78.include "Makefile.err-msgs-h"
79${SRCS:Nerr.c}: err-msgs.h
80
81add-test: .PHONY
82	@set -eu; \
83	test=${NAME:Q}; \
84	[ "$$test" ] || { \
85		echo "usage: ${MAKE} add-test NAME=<name>"; \
86		exit; \
87	}; \
88	\
89	cd '../../../tests/usr.bin/xlint/lint1'; \
90	if [ -f "$$test.c" ]; then \
91		echo "error: test $$test already exists in $$PWD."; \
92		exit 1; \
93	fi; \
94	\
95	echo "=> Adding test $$test"; \
96	printf '%s\n' \
97		'/*	$$''NetBSD$$	*/' \
98		"# 3 \"$$test.c\"" \
99		'' \
100		'/*' \
101		' * TODO: Explain the purpose of the test.' \
102		' */' \
103		'' \
104		'/* lint1-extra-flags: -Z */' \
105		'/* lint1-flags: -Z */' \
106		'/* lint1-only-if: schar uchar ilp32 lp64 int long */' \
107		'/* lint1-skip-if: ldbl-64 ldbl-96 ldbl-128 */' \
108		'' \
109		'// TODO: Add some code that passes.' \
110		'// TODO: Add some code that fails.' \
111	> "$$test.c"; \
112	> "$$test.exp"; \
113	cvs add "$$test.c" "$$test.exp"; \
114	printf '%s\n' \
115		'/^FILES+=/i' \
116		"FILES+=		$$test.c" \
117		"FILES+=		$$test.exp" \
118		'.' 'w' 'q' \
119	| ed Makefile; \
120	${MAKE} sync-mi
121
122.include <bsd.prog.mk>
123