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