xref: /freebsd/usr.bin/lex/Makefile (revision 4abd7edcbde21ba7a089c7d1a0bba8f87ebece06)
1# $FreeBSD$
2#
3# By default, flex will be configured to generate 8-bit scanners only if the
4# -8 flag is given.  If you want it to always generate 8-bit scanners, add
5# "-DDEFAULT_CSIZE=256" to CFLAGS.  Note that doing so will double the size
6# of all uncompressed scanners.
7#
8# Bootstrapping of lex is handled automatically.
9# Also note that flex.skel no longer gets installed.
10#
11
12PROG=		lex
13LINKS+=	${BINDIR}/lex ${BINDIR}/lex++
14LINKS+=	${BINDIR}/lex ${BINDIR}/flex
15LINKS+=	${BINDIR}/lex ${BINDIR}/flex++
16
17FLEXDIR=	${.CURDIR}/../../contrib/flex
18
19.PATH:		${FLEXDIR}
20
21SRCS=		buf.c ccl.c dfa.c ecs.c filter.c gen.c main.c misc.c \
22		nfa.c options.c parse.y regex.c scan.c scanflags.c \
23		scanopt.c skel.c sym.c tables.c tables_shared.c \
24		tblcmp.c yylex.c
25LFLAGS+=	-is
26CFLAGS+=	-I. -I${.CURDIR} -I${FLEXDIR} -DHAVE_CONFIG_H
27INCS=		FlexLexer.h
28INCSDIR=	${INCLUDEDIR}
29MLINKS+=	lex.1 flex.1
30MLINKS+=	lex.1 flex++.1
31MLINKS+=	lex.1 lex++.1
32
33WARNS?=		3
34
35CLEANFILES=	scan.c skel.c
36GENFILES=	parse.c parse.h scan.c skel.c
37
38SUBDIR=		lib
39
40FLEX_VERSION=	`awk -f ${.CURDIR}/version.awk ${.CURDIR}/config.h`
41
42skel.c: config.h mkskel.sh flex.skl version.awk
43	sed 's/m4_/m4postproc_/g; s/m4preproc_/m4_/g' \
44	    ${FLEXDIR}/flex.skl | \
45	m4 -I${FLEXDIR} -P ${FLEX_VERSION} | \
46	sed 's/m4postproc_/m4_/g' | \
47	sh ${FLEXDIR}/mkskel.sh > ${.TARGET}
48
49bootstrap: ${GENFILES:S/^/init/g}
50.for _f in ${GENFILES}
51	@diff -I '^#line ' -I '\$$FreeBS[D]: .*\$$' -q \
52	    ${.CURDIR}/init${_f} ${_f} 2> /dev/null || { \
53		echo "Bootstrapping ${_f}" ; \
54		cp -f ${.CURDIR}/init${_f} ${_f} ; \
55	}
56.endfor
57
58test: check
59check: ${PROG}
60	./${PROG} ${LFLAGS} -t ${COMPRESSION} ${FLEXDIR}/scan.l | \
61	diff -I '^#line ' -I '\$$FreeBS[D]: .*\$$' ${.CURDIR}/initscan.c -
62	@echo "Check successful"
63
64.include <bsd.prog.mk>
65