1#	from: @(#)Makefile	5.4 (Berkeley) 6/24/90
2#	$NetBSD: Makefile,v 1.17 2023/06/03 09:09:03 lukem Exp $
3#
4# By default, flex will be configured to generate 8-bit scanners only if the
5# -8 flag is given.  If you want it to always generate 8-bit scanners, add
6# "-DDEFAULT_CSIZE=256" to CPPFLAGS.  Note that doing so will double the size
7# of all uncompressed scanners.
8# 
9# If on your system you have trouble building flex due to 8-bit character
10# problems, remove the -8 from FLEX_FLAGS and the "#define FLEX_8_BIT_CHARS"
11# from the beginning of flexdef.h.
12#
13# To bootstrap lex, cp initscan.c to scan.c and run make.
14
15.include <bsd.init.mk>
16
17PROG=	lex
18CPPFLAGS+=-I. -I${.CURDIR} -DVERSION=\"${VERSION}\"
19SRCS=	 \
20buf.c \
21ccl.c \
22dfa.c \
23ecs.c \
24filter.c \
25gen.c \
26main.c \
27misc.c \
28nfa.c \
29options.c \
30parse.y \
31regex.c \
32scan.l \
33scanflags.c \
34scanopt.c \
35skel.c \
36sym.c \
37tables.c \
38tables_shared.c \
39tblcmp.c \
40yylex.c
41
42YHEADER=1
43CLEANFILES+=skel.c
44INCS	=FlexLexer.h
45INCSDIR=/usr/include/g++
46LDADD+=-lm
47.ifndef HOSTPROG
48DPADD+=${LIBM}
49.endif
50
51MAN = flex.1
52
53LINKS=	${BINDIR}/lex ${BINDIR}/flex \
54	${BINDIR}/lex ${BINDIR}/flex++
55MLINKS=	flex.1 lex.1 
56
57skel.c: flex.skl mkskel.sh flexint.h tables_shared.h
58	${TOOL_SED} -e 's/4_/a4_/g; s/m4preproc_/m4_/g' \
59	    ${IDIST}/flex.skl | ${TOOL_M4} -I${IDIST} -P \
60	    -DFLEX_MAJOR_VERSION=`echo ${VERSION} | cut -f 1 -d .` \
61	    -DFLEX_MINOR_VERSION=`echo ${VERSION} | cut -f 2 -d .` \
62	    -DFLEX_SUBMINOR_VERSION=`echo ${VERSION} | cut -f 3 -d .` | \
63	    ${TOOL_SED} -e 's/m4postproc_/m4_/g' | \
64	    ${HOST_SH} ${IDIST}/mkskel.sh ${IDIST} ${TOOL_M4} ${VERSION} > ${.TARGET}
65
66.ifndef HOSTPROG
67scan.c: scan.l
68	${_MKTARGET_LEX}
69	${LEX} -t -p ${.ALLSRC} >${.TARGET}
70.endif
71
72scan.o yylex.o: parse.h
73
74# Ugh. Generates too large offsets with -O2.
75.if defined(HAVE_GCC) && ${HAVE_GCC} >= 7 && ${ACTIVE_CC} == "gcc"
76. if ${MACHINE_CPU} == "m68k" && empty(CFLAGS:M-O0)
77COPTS.scan.c+=        -O1
78. endif
79.endif
80
81COPTS.filter.c+=	${CC_WNO_FORMAT_TRUNCATION}
82COPTS.misc.c+=		${CC_WNO_FORMAT_TRUNCATION}
83COPTS.parse.c+=		${CC_WNO_FORMAT_TRUNCATION}
84
85.include <bsd.prog.mk>
86