Subject: BUILD_USES_LEX and BUILD_USES_YACC
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
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/buildlink2.mk, 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 bsd.pkg.mk 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
.endif
.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
.endif
Or maybe something like the following could be used for mk/yacc.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/bsd.prefs.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
.else
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
.endif # YACC not defined
.endif # YACC_MK
Jeremy C. Reed
http://bsd.reedmedia.net/