xref: /freebsd/usr.bin/lex/Makefile (revision 533a4a629626ef953d5f9d4414edc2db8c68d2f8)
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=	${SRCTOP}/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
35NO_WMISLEADING_INDENTATION=
36
37CLEANFILES=	scan.c skel.c
38GENFILES=	parse.c parse.h scan.c skel.c
39
40SUBDIR=		lib
41
42FLEX_VERSION=	`awk -f ${.CURDIR}/version.awk ${.CURDIR}/config.h`
43
44skel.c: config.h mkskel.sh flex.skl version.awk
45	sed 's/m4_/m4postproc_/g; s/m4preproc_/m4_/g' \
46	    ${FLEXDIR}/flex.skl | \
47	m4 -I${FLEXDIR} -P ${FLEX_VERSION} | \
48	sed 's/m4postproc_/m4_/g' | \
49	sh ${FLEXDIR}/mkskel.sh > ${.TARGET}
50
51bootstrap: ${GENFILES:S/^/init/g}
52.for _f in ${GENFILES}
53	@diff -I '^#line ' -I '\$$FreeBS[D]: .*\$$' -q \
54	    ${.CURDIR}/init${_f} ${_f} 2> /dev/null || { \
55		echo "Bootstrapping ${_f}" ; \
56		${CP} ${.CURDIR}/init${_f} ${_f} ; \
57	}
58.endfor
59
60test: check
61check: ${PROG}
62	./${PROG} ${LFLAGS} -t ${COMPRESSION} ${FLEXDIR}/scan.l | \
63	diff -I '^#line ' -I '\$$FreeBS[D]: .*\$$' ${.CURDIR}/initscan.c -
64	@echo "Check successful"
65
66.include <bsd.prog.mk>
67