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