150477Speter# $FreeBSD: releng/10.3/usr.bin/lex/Makefile 250881 2013-05-21 19:32:35Z jkim $
22258Scsgr#
32258Scsgr# By default, flex will be configured to generate 8-bit scanners only if the
42258Scsgr# -8 flag is given.  If you want it to always generate 8-bit scanners, add
52258Scsgr# "-DDEFAULT_CSIZE=256" to CFLAGS.  Note that doing so will double the size
62258Scsgr# of all uncompressed scanners.
72258Scsgr#
82258Scsgr# Bootstrapping of lex is handled automatically.
92307Scsgr# Also note that flex.skel no longer gets installed.
102258Scsgr#
112258Scsgr
122258ScsgrPROG=		lex
1313343SpeterLINKS+=	${BINDIR}/lex ${BINDIR}/lex++
1413343SpeterLINKS+=	${BINDIR}/lex ${BINDIR}/flex
1513343SpeterLINKS+=	${BINDIR}/lex ${BINDIR}/flex++
162258Scsgr
17250881SjkimFLEXDIR=	${.CURDIR}/../../contrib/flex
18250881Sjkim
19250881Sjkim.PATH:		${FLEXDIR}
20250881Sjkim
21250881SjkimSRCS=		buf.c ccl.c dfa.c ecs.c filter.c gen.c main.c misc.c \
22250881Sjkim		nfa.c options.c parse.y regex.c scan.c scanflags.c \
23250881Sjkim		scanopt.c skel.c sym.c tables.c tables_shared.c \
24250881Sjkim		tblcmp.c yylex.c
252258ScsgrLFLAGS+=	-is
26250881SjkimCFLAGS+=	-I. -I${.CURDIR} -I${FLEXDIR} -DHAVE_CONFIG_H
2796462SruINCS=		FlexLexer.h
28132862SkanINCSDIR=	${INCLUDEDIR}
2913343SpeterMLINKS+=	lex.1 flex.1
3013343SpeterMLINKS+=	lex.1 flex++.1
3113343SpeterMLINKS+=	lex.1 lex++.1
322258Scsgr
33250881SjkimWARNS?=		3
34201386Sed
3553462SdtCLEANFILES=	scan.c skel.c
36250881SjkimGENFILES=	parse.c parse.h scan.c skel.c
372258Scsgr
382258ScsgrSUBDIR=		lib
392258Scsgr
40250881SjkimFLEX_VERSION=	`awk -f ${.CURDIR}/version.awk ${.CURDIR}/config.h`
4153462Sdt
42250881Sjkimskel.c: config.h mkskel.sh flex.skl version.awk
43250881Sjkim	sed 's/m4_/m4postproc_/g; s/m4preproc_/m4_/g' \
44250881Sjkim	    ${FLEXDIR}/flex.skl | \
45250881Sjkim	m4 -I${FLEXDIR} -P ${FLEX_VERSION} | \
46250881Sjkim	sed 's/m4postproc_/m4_/g' | \
47250881Sjkim	sh ${FLEXDIR}/mkskel.sh > ${.TARGET}
48250881Sjkim
49250881Sjkimbootstrap: ${GENFILES:S/^/init/g}
50250881Sjkim.for _f in ${GENFILES}
51250881Sjkim	@diff -I '^#line ' -I '\$$FreeBS[D]: .*\$$' -q \
52250881Sjkim	    ${.CURDIR}/init${_f} ${_f} 2> /dev/null || { \
53250881Sjkim		echo "Bootstrapping ${_f}" ; \
54250881Sjkim		cp -f ${.CURDIR}/init${_f} ${_f} ; \
5518372Speter	}
56250881Sjkim.endfor
572258Scsgr
582258Scsgrtest: check
59250881Sjkimcheck: ${PROG}
60250881Sjkim	./${PROG} ${LFLAGS} -t ${COMPRESSION} ${FLEXDIR}/scan.l | \
61250881Sjkim	diff -I '^#line ' -I '\$$FreeBS[D]: .*\$$' ${.CURDIR}/initscan.c -
622258Scsgr	@echo "Check successful"
632258Scsgr
642258Scsgr.include <bsd.prog.mk>
65