Makefile revision 1.72
1#	$NetBSD: Makefile,v 1.72 2021/06/23 07:11:41 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 print.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}
21#LOBJS.${PROG}+=	${SRCS:M*.l:.l=.ln}
22LINTFLAGS.scan.c=	-X 107,330,331,333
23
24CPPFLAGS+=	-DIS_LINT1
25CPPFLAGS+=	-I${.CURDIR}
26CPPFLAGS+=	${DEBUG:D-DDEBUG}
27
28COPTS.err.c+=	${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :}
29
30# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101177
31.if ${HAVE_GCC} == 9 &&	\
32	(${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb")
33COPTS.lex.c+=	-O0
34.endif
35
36BINDIR=		/usr/libexec
37
38CLEANFILES+=	${MAN}
39CLEANFILES+=	*.gcno *.gcda *.gcov
40
41.if ${USETOOLS} == "yes"
42LINT1=		${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
43.endif
44LINT1?=		./${PROG}
45
46${MAN}:		makeman ${LINT1:C/^\.\///} Makefile
47	${_MKTARGET_CREATE}
48	${HOST_SH} ${.ALLSRC:M*makeman} ${LINT1} -m >${.TARGET}
49
50LDADD+=		-lm
51.ifndef HOSTPROG
52DPADD+=		${LIBM}
53
54LDADD+=		-ll
55DPADD+=		${LIBL}
56.endif
57
58.include "Makefile.err-msgs-h"
59${SRCS:Nerr.c}: err-msgs.h
60
61add-test: .PHONY
62	@set -eu; \
63	test=${NAME:Q}; \
64	[ "$$test" ] || { \
65		echo "usage: ${MAKE} add-test NAME=<name>"; \
66		exit; \
67	}; \
68	\
69	cd '../../../tests/usr.bin/xlint/lint1'; \
70	if [ -f "$$test.c" ]; then \
71		echo "error: test $$test already exists in $$PWD."; \
72		exit 1; \
73	fi; \
74	\
75	echo "=> Adding test $$test"; \
76	printf '%s\n' \
77		'/*	$$''NetBSD$$	*/' \
78		"# 3 \"$$test.c\"" \
79		'' \
80		'/*' \
81		' * TODO: Explain the purpose of the test.' \
82		' */' \
83		'' \
84		'/* lint1-extra-flags: -p */' \
85		'' \
86		'// TODO: Add some code that passes.' \
87		'// TODO: Add some code that fails.' \
88	> "$$test.c"; \
89	> "$$test.exp"; \
90	cvs add "$$test.c" "$$test.exp"; \
91	printf '%s\n' \
92		'/^FILES+=/i' \
93		"FILES+=		$$test.c" \
94		"FILES+=		$$test.exp" \
95		'.' 'w' 'q' \
96	| ed Makefile; \
97	${MAKE} sync-mi; \
98	printf '%s\n' '/^test_case /i' "test_case $$test" '.' 'w' 'q' \
99	| ed t_integration.sh
100
101.include <bsd.prog.mk>
102