xref: /netbsd-src/external/bsd/flex/bin/Makefile (revision c4b7a9e7940c62d92a81ee31e05e281e6035fadc)
178b8b34eSchristos#	from: @(#)Makefile	5.4 (Berkeley) 6/24/90
2*c4b7a9e7Slukem#	$NetBSD: Makefile,v 1.17 2023/06/03 09:09:03 lukem Exp $
378b8b34eSchristos#
478b8b34eSchristos# By default, flex will be configured to generate 8-bit scanners only if the
578b8b34eSchristos# -8 flag is given.  If you want it to always generate 8-bit scanners, add
678b8b34eSchristos# "-DDEFAULT_CSIZE=256" to CPPFLAGS.  Note that doing so will double the size
778b8b34eSchristos# of all uncompressed scanners.
878b8b34eSchristos#
978b8b34eSchristos# If on your system you have trouble building flex due to 8-bit character
1078b8b34eSchristos# problems, remove the -8 from FLEX_FLAGS and the "#define FLEX_8_BIT_CHARS"
1178b8b34eSchristos# from the beginning of flexdef.h.
1278b8b34eSchristos#
1378b8b34eSchristos# To bootstrap lex, cp initscan.c to scan.c and run make.
1478b8b34eSchristos
157977e686Schristos.include <bsd.init.mk>
167977e686Schristos
1778b8b34eSchristosPROG=	lex
187977e686SchristosCPPFLAGS+=-I. -I${.CURDIR} -DVERSION=\"${VERSION}\"
1978b8b34eSchristosSRCS=	 \
2078b8b34eSchristosbuf.c \
2178b8b34eSchristosccl.c \
2278b8b34eSchristosdfa.c \
2378b8b34eSchristosecs.c \
2478b8b34eSchristosfilter.c \
2578b8b34eSchristosgen.c \
2678b8b34eSchristosmain.c \
2778b8b34eSchristosmisc.c \
2878b8b34eSchristosnfa.c \
2978b8b34eSchristosoptions.c \
30a7983e8aSplunkyparse.y \
3178b8b34eSchristosregex.c \
32a7983e8aSplunkyscan.l \
3378b8b34eSchristosscanflags.c \
3478b8b34eSchristosscanopt.c \
3578b8b34eSchristosskel.c \
3678b8b34eSchristossym.c \
3778b8b34eSchristostables.c \
3878b8b34eSchristostables_shared.c \
3978b8b34eSchristostblcmp.c \
4078b8b34eSchristosyylex.c
4178b8b34eSchristos
4278b8b34eSchristosYHEADER=1
43a7983e8aSplunkyCLEANFILES+=skel.c
4478b8b34eSchristosINCS	=FlexLexer.h
4578b8b34eSchristosINCSDIR=/usr/include/g++
4678b8b34eSchristosLDADD+=-lm
47452f3eb7Sjoerg.ifndef HOSTPROG
4878b8b34eSchristosDPADD+=${LIBM}
49452f3eb7Sjoerg.endif
5078b8b34eSchristos
5178b8b34eSchristosMAN = flex.1
5278b8b34eSchristos
5378b8b34eSchristosLINKS=	${BINDIR}/lex ${BINDIR}/flex \
5478b8b34eSchristos	${BINDIR}/lex ${BINDIR}/flex++
5578b8b34eSchristosMLINKS=	flex.1 lex.1
5678b8b34eSchristos
572eca3b8eSchristosskel.c: flex.skl mkskel.sh flexint.h tables_shared.h
58cb056e6dSchristos	${TOOL_SED} -e 's/4_/a4_/g; s/m4preproc_/m4_/g' \
594db887aeSchristos	    ${IDIST}/flex.skl | ${TOOL_M4} -I${IDIST} -P \
602eca3b8eSchristos	    -DFLEX_MAJOR_VERSION=`echo ${VERSION} | cut -f 1 -d .` \
612eca3b8eSchristos	    -DFLEX_MINOR_VERSION=`echo ${VERSION} | cut -f 2 -d .` \
622eca3b8eSchristos	    -DFLEX_SUBMINOR_VERSION=`echo ${VERSION} | cut -f 3 -d .` | \
632eca3b8eSchristos	    ${TOOL_SED} -e 's/m4postproc_/m4_/g' | \
64596f930cSchristos	    ${HOST_SH} ${IDIST}/mkskel.sh ${IDIST} ${TOOL_M4} ${VERSION} > ${.TARGET}
6578b8b34eSchristos
6678b8b34eSchristos.ifndef HOSTPROG
6778b8b34eSchristosscan.c: scan.l
6878b8b34eSchristos	${_MKTARGET_LEX}
6978b8b34eSchristos	${LEX} -t -p ${.ALLSRC} >${.TARGET}
7078b8b34eSchristos.endif
7178b8b34eSchristos
7278b8b34eSchristosscan.o yylex.o: parse.h
7378b8b34eSchristos
74350b7ab6Smrg# Ugh. Generates too large offsets with -O2.
7521303c93Smrg.if defined(HAVE_GCC) && ${HAVE_GCC} >= 7 && ${ACTIVE_CC} == "gcc"
76350b7ab6Smrg. if ${MACHINE_CPU} == "m68k" && empty(CFLAGS:M-O0)
77350b7ab6SmrgCOPTS.scan.c+=        -O1
78350b7ab6Smrg. endif
79350b7ab6Smrg.endif
80350b7ab6Smrg
81*c4b7a9e7SlukemCOPTS.filter.c+=	${CC_WNO_FORMAT_TRUNCATION}
82*c4b7a9e7SlukemCOPTS.misc.c+=		${CC_WNO_FORMAT_TRUNCATION}
83*c4b7a9e7SlukemCOPTS.parse.c+=		${CC_WNO_FORMAT_TRUNCATION}
84de11d876Smrg
8578b8b34eSchristos.include <bsd.prog.mk>
86