Home | History | Annotate | Line # | Download | only in lint1
Makefile revision 1.76
      1 #	$NetBSD: Makefile,v 1.76 2021/07/04 08:49:41 rillig Exp $
      2 
      3 .include <bsd.own.mk>
      4 
      5 PROG=		lint1
      6 SRCS=		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 
     11 MAN=		lint.7
     12 YHEADER=
     13 #DBG=		-g
     14 #CPPFLAGS+=	-DYYDEBUG=1
     15 #YFLAGS+=	-v
     16 #LFLAGS+=	-d
     17 
     18 CWARNFLAGS.clang+=	-Wno-error=implicit-int-float-conversion
     19 LINTFLAGS+=		-T
     20 LOBJS.${PROG}+=		${SRCS:M*.y:.y=.ln}
     21 LOBJS.${PROG}+=		${SRCS:M*.l:.l=.ln}
     22 LINTFLAGS.scan.c=	-X 107,126,330,331,332,333
     23 
     24 CPPFLAGS+=	-DIS_LINT1
     25 CPPFLAGS+=	-I${.CURDIR}
     26 CPPFLAGS+=	${DEBUG:D-DDEBUG}
     27 
     28 COPTS.err.c+=	${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :}
     29 
     30 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101177
     31 .if ${HAVE_GCC:U0} >= 9 &&	\
     32 	(${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb")
     33 COPTS.lex.c+=	-O0
     34 .endif
     35 
     36 BINDIR=		/usr/libexec
     37 
     38 CLEANFILES+=	${MAN}
     39 CLEANFILES+=	*.gcno *.gcda *.gcov
     40 
     41 .if ${USETOOLS} == "yes"
     42 LINT1=		${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
     43 .endif
     44 LINT1?=		./${PROG}
     45 
     46 ${MAN}:		makeman ${LINT1:C/^\.\///} Makefile
     47 	${_MKTARGET_CREATE}
     48 	${HOST_SH} ${.ALLSRC:M*makeman} ${LINT1} -m >${.TARGET}
     49 
     50 LDADD+=		-lm
     51 .ifndef HOSTPROG
     52 DPADD+=		${LIBM}
     53 
     54 LDADD+=		-ll
     55 DPADD+=		${LIBL}
     56 .endif
     57 
     58 .include "Makefile.err-msgs-h"
     59 ${SRCS:Nerr.c}: err-msgs.h
     60 
     61 add-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 
     99 .include <bsd.prog.mk>
    100