Home | History | Annotate | Line # | Download | only in lint1
Makefile revision 1.95
      1 #	$NetBSD: Makefile,v 1.95 2023/03/28 14:44:35 rillig Exp $
      2 
      3 .include <bsd.own.mk>
      4 
      5 PROG=		lint1
      6 SRCS=		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 
     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.cgram.c+=	-X 351		# 'extern' declaration in .c file
     23 LINTFLAGS.scan.c+=	-X 107,126,330,331,332,333	# strict bool mode
     24 LINTFLAGS.scan.c+=	-X 192,214	# due to suppressed bool errors
     25 LINTFLAGS.scan.c+=	-X 307		# static variable unused
     26 LINTFLAGS.scan.c+=	-X 351		# 'extern' declaration in .c file
     27 
     28 CPPFLAGS+=	-DIS_LINT1
     29 CPPFLAGS+=	-I${.CURDIR} -I${.OBJDIR}
     30 CPPFLAGS+=	${DEBUG:D-DDEBUG -DYYDEBUG}
     31 
     32 COPTS.err.c+=	${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :}
     33 
     34 BINDIR=		/usr/libexec
     35 
     36 CLEANFILES+=	${MAN} ${MAN}.date
     37 
     38 .if ${USETOOLS} == "yes"
     39 LINT1=		${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
     40 .endif
     41 LINT1?=		./${PROG}
     42 
     43 ${MAN}.date:	err.c
     44 	sed -E \
     45 	    -e 's,.*(....)/([0-9]{2})/0?([0-9]+).*,\2 \3\, \1,' \
     46 	    -e 's,^01,January,' \
     47 	    -e 's,^02,February,' \
     48 	    -e 's,^03,March,' \
     49 	    -e 's,^04,April,' \
     50 	    -e 's,^05,May,' \
     51 	    -e 's,^06,June,' \
     52 	    -e 's,^07,July,' \
     53 	    -e 's,^08,August,' \
     54 	    -e 's,^09,September,' \
     55 	    -e 's,^10,October,' \
     56 	    -e 's,^11,November,' \
     57 	    -e 's,^12,December,' \
     58 	    -e 1q \
     59 	    ${.ALLSRC} > ${.TARGET}
     60 
     61 # Extra -UYYDEBUG for lint's strict bool mode, since cgram.c contains 'int
     62 # yydebug; if (yydebug)'.
     63 cgram.ln: cgram.c
     64 	${LINT} ${LINTFLAGS} ${LINTFLAGS.${.IMPSRC}} \
     65 	    ${CPPFLAGS:C/-([IDUW]) */-\1/Wg:M-[IDUW]*} \
     66 	    -i -UYYDEBUG ${.IMPSRC}
     67 
     68 ${MAN}:		makeman err.c Makefile ${MAN}.date
     69 	${_MKTARGET_CREATE}
     70 	${HOST_SH} ${.ALLSRC:M*makeman} \
     71 	    "$$(cat ${.ALLSRC:M*.date})" ${.ALLSRC:M*err.c} \
     72 	    >${.TARGET}
     73 
     74 LDADD+=		-lm
     75 .ifndef HOSTPROG
     76 DPADD+=		${LIBM}
     77 
     78 LDADD+=		-ll
     79 DPADD+=		${LIBL}
     80 .endif
     81 
     82 err-msgs.h: err.c
     83 	${_MKTARGET_CREATE}
     84 	sp='[[:space:]]*'; \
     85 	from="^$$sp\(\".*\"\)\,$$sp/\*$$sp\(Q*[0-9][0-9]*\)$$sp\*/\$$"; \
     86 	${TOOL_SED} -n -e "s,$$from,#define MSG_\2 \1,p" < ${.ALLSRC:M*err.c} > ${.TARGET}.tmp
     87 	mv -f ${.TARGET}.tmp ${.TARGET}
     88 
     89 CLEANFILES+=	err-msgs.h
     90 DPSRCS+=	err-msgs.h
     91 CPPFLAGS+=	-I.
     92 
     93 externs1.h: err-msgs.h
     94 ${SRCS:Nerr.c}: err-msgs.h
     95 
     96 add-test: .PHONY
     97 	@set -eu; \
     98 	test=${NAME:Q}; \
     99 	[ "$$test" ] || { \
    100 		echo "usage: ${MAKE} add-test NAME=<name>"; \
    101 		exit; \
    102 	}; \
    103 	\
    104 	cd '../../../tests/usr.bin/xlint/lint1'; \
    105 	if [ -f "$$test.c" ]; then \
    106 		echo "error: test $$test already exists in $$PWD."; \
    107 		exit 1; \
    108 	fi; \
    109 	\
    110 	echo "=> Adding test $$test"; \
    111 	printf '%s\n' \
    112 		'/*	$$''NetBSD$$	*/' \
    113 		"# 3 \"$$test.c\"" \
    114 		'' \
    115 		'/*' \
    116 		' * TODO: Explain the purpose of the test.' \
    117 		' */' \
    118 		'' \
    119 		'/* lint1-extra-flags: -Z */' \
    120 		'/* lint1-flags: -Z */' \
    121 		'/* lint1-only-if: schar uchar ilp32 lp64 int long */' \
    122 		'/* lint1-skip-if: ldbl-64 ldbl-96 ldbl-128 */' \
    123 		'' \
    124 		'// TODO: Add some code that passes.' \
    125 		'// TODO: Add some code that fails.' \
    126 	> "$$test.c"; \
    127 	cvs add "$$test.c"; \
    128 	${MAKE} sync-mi
    129 
    130 .include <bsd.prog.mk>
    131