Home | History | Annotate | Line # | Download | only in lint1
      1 #	$NetBSD: Makefile,v 1.106 2024/06/08 09:09:19 rillig Exp $
      2 
      3 .include <bsd.own.mk>
      4 
      5 PROG=		lint1
      6 SRCS=		cgram.y \
      7 		ckbool.c ckctype.c ckgetopt.c cksnprintb.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 ${MAN}.date:	err.c
     39 	${_MKTARGET_CREATE}
     40 	${TOOL_SED} -E \
     41 	    -e 's,.*(....)/([0-9]{2})/0?([0-9]+).*,\2 \3\, \1,' \
     42 	    -e 's,^01,January,' \
     43 	    -e 's,^02,February,' \
     44 	    -e 's,^03,March,' \
     45 	    -e 's,^04,April,' \
     46 	    -e 's,^05,May,' \
     47 	    -e 's,^06,June,' \
     48 	    -e 's,^07,July,' \
     49 	    -e 's,^08,August,' \
     50 	    -e 's,^09,September,' \
     51 	    -e 's,^10,October,' \
     52 	    -e 's,^11,November,' \
     53 	    -e 's,^12,December,' \
     54 	    -e 1q \
     55 	    ${.ALLSRC} > ${.TARGET}
     56 
     57 # Extra -UYYDEBUG for lint's strict bool mode, since cgram.c contains 'int
     58 # yydebug; if (yydebug)'.
     59 cgram.ln: cgram.c
     60 	${LINT} ${LINTFLAGS} ${LINTFLAGS.${.IMPSRC}} \
     61 	    ${CPPFLAGS:C/-([IDUW]) */-\1/Wg:M-[IDUW]*} \
     62 	    -i -UYYDEBUG ${.IMPSRC}
     63 
     64 ${MAN}:		makeman err.c Makefile ${MAN}.date
     65 	${_MKTARGET_CREATE}
     66 	SED=${TOOL_SED:Q} ${HOST_SH} ${.ALLSRC:M*makeman} \
     67 	    "$$(cat ${.ALLSRC:M*.date})" ${.ALLSRC:M*err.c} \
     68 	    >${.TARGET}
     69 
     70 LDADD+=		-lm
     71 .ifndef HOSTPROG
     72 DPADD+=		${LIBM}
     73 
     74 LDADD+=		-ll
     75 DPADD+=		${LIBL}
     76 .endif
     77 
     78 err-msgs.h: err.c
     79 	${_MKTARGET_CREATE}
     80 	sp='[[:space:]]*'; \
     81 	from="^$$sp\(\"[^\"].*\"\)\,$$sp// \(Q*[0-9][0-9]*\)\$$"; \
     82 	${TOOL_SED} -n -e "s,$$from,#define MSG_\2 \1,p" < ${.ALLSRC:M*err.c} > ${.TARGET}.tmp
     83 	mv -f ${.TARGET}.tmp ${.TARGET}
     84 
     85 CLEANFILES+=	err-msgs.h
     86 DPSRCS+=	err-msgs.h
     87 CPPFLAGS+=	-I.
     88 
     89 add-test: .PHONY
     90 	@cd '../../../tests/usr.bin/xlint/lint1' && ${MAKE} add-test
     91 
     92 .include <bsd.prog.mk>
     93