Makefile revision 1.81
1#	$NetBSD: Makefile,v 1.81 2021/07/31 17:09:21 rillig Exp $
2
3.include <bsd.own.mk>
4
5PROG=		lint1
6SRCS=		cgram.y \
7		ckbool.c ckctype.c ckgetopt.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}
22
23CPPFLAGS+=	-DIS_LINT1
24CPPFLAGS+=	-I${.CURDIR}
25CPPFLAGS+=	${DEBUG:D-DDEBUG -DYYDEBUG}
26
27COPTS.err.c+=	${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :}
28
29BINDIR=		/usr/libexec
30
31CLEANFILES+=	${MAN}
32CLEANFILES+=	*.gcno *.gcda *.gcov
33
34.if ${USETOOLS} == "yes"
35LINT1=		${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
36.endif
37LINT1?=		./${PROG}
38
39${MAN}:		makeman ${LINT1:C/^\.\///} Makefile
40	${_MKTARGET_CREATE}
41	${HOST_SH} ${.ALLSRC:M*makeman} ${LINT1} -m >${.TARGET}
42
43LDADD+=		-lm
44.ifndef HOSTPROG
45DPADD+=		${LIBM}
46
47LDADD+=		-ll
48DPADD+=		${LIBL}
49.endif
50
51.include "Makefile.err-msgs-h"
52${SRCS:Nerr.c}: err-msgs.h
53
54add-test: .PHONY
55	@set -eu; \
56	test=${NAME:Q}; \
57	[ "$$test" ] || { \
58		echo "usage: ${MAKE} add-test NAME=<name>"; \
59		exit; \
60	}; \
61	\
62	cd '../../../tests/usr.bin/xlint/lint1'; \
63	if [ -f "$$test.c" ]; then \
64		echo "error: test $$test already exists in $$PWD."; \
65		exit 1; \
66	fi; \
67	\
68	echo "=> Adding test $$test"; \
69	printf '%s\n' \
70		'/*	$$''NetBSD$$	*/' \
71		"# 3 \"$$test.c\"" \
72		'' \
73		'/*' \
74		' * TODO: Explain the purpose of the test.' \
75		' */' \
76		'' \
77		'/* lint1-extra-flags: -Z */' \
78		'/* lint1-flags: -Z */' \
79		'/* lint1-only-if: schar uchar ilp32 lp64 int long */' \
80		'/* lint1-skip-if: ldbl-64 ldbl-96 ldbl-128 */' \
81		'' \
82		'// TODO: Add some code that passes.' \
83		'// TODO: Add some code that fails.' \
84	> "$$test.c"; \
85	> "$$test.exp"; \
86	cvs add "$$test.c" "$$test.exp"; \
87	printf '%s\n' \
88		'/^FILES+=/i' \
89		"FILES+=		$$test.c" \
90		"FILES+=		$$test.exp" \
91		'.' 'w' 'q' \
92	| ed Makefile; \
93	${MAKE} sync-mi
94
95.include <bsd.prog.mk>
96