To: None <>
From: Jeremy C. Reed <>
List: tech-pkg
Date: 09/30/2003 10:41:47
Many packages need a lex and/or a yacc to build.

Many of these packages check for SunOS then do a BUILD_DEPENDS of flex
(and/or bison).

I'd like to suggest that we get rid of these SunoS-specific checks.

We already have a BUILD_USES_MSGFMT setting.

Maybe we can have BUILD_USES_LEX and BUILD_USES_YACC settings too.

It has also been suggested to have a pkgsrc/devel/flex/, but
I am not sure how that would work for a BUILD_DEPENDS only. Any examples?

I also understand that some implementations of lex/flex are not adequate.
So maybe that can be checked too.

I have been using a byacc (even under Linux) for six months. It is in
pkgsrc-wip. Maybe the check for a yacc should allow using byacc, yacc, or
bison -y.

My has:

.if defined(BUILD_USES_LEX) && \
    (!exists(/usr/bin/lex) || !exists(/usr/bin/flex))
# XXX This should be made smarter so it can check if lex is good enough.
BUILD_DEPENDS+=		flex-[0-9]*:../../devel/flex
LEX=			${LOCALBASE}/bin/flex

.if defined(BUILD_USES_YACC) && !exists(/usr/bin/yacc)
# XXX This could be smarter to check for byacc and bison too.
# XXX Also a byacc package is available that could be used.
BUILD_DEPENDS+=		bison-[0-9]*:../../devel/bison
YACC=			${LOCALBASE}/bin/bison -y

Or maybe something like the following could be used for mk/

# $NetBSD$
# This Makefile fragment is included by packages that need a yacc
# at build time.

.if !defined(YACC_MK)
YACC_MK= # defined

.include "../../mk/"

.if !defined(YACC)

.if exists(/usr/bin/yacc)
   YACC=	/usr/bin/yacc
.elif exists(/usr/bin/bison)
   YACC=	/usr/bin/bison -y
.elif defined(USE_BSD_YACC)
   BUILD_DEPENDS+=	byacc-[0-9]*:../../wip/byacc
   YACC=	${LOCALBASE}/bin/byacc
   BUILD_DEPENDS+=	bison-[0-9]*:../../devel/bison
   # Note: some packages auto-detect type of yacc and if using
   # -y it may have problems; maybe fix those packages.
   YACC=	${LOCALBASE}/bin/bison -y

.endif # YACC not defined

.endif  # YACC_MK

   Jeremy C. Reed