Subject: Re: BUILD_USES_LEX and BUILD_USES_YACC
To: grant beattie <grant@NetBSD.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 09/30/2003 17:52:07
On Wed, 1 Oct 2003, grant beattie wrote:
> tools.mk is probably the best place for this, but I do agree that
> USE_GNU_TOOLS would be misleading in this context.
>
> we could create a USE_TOOLS variable, analogous to USE_GNU_TOOLS, and
> perhaps even migrate the GNU stuff to USE_TOOLS.GNU, or similar..
> comments?
Probably USE_TOOLS would be better.
Now it says _TOOLS_OPSYS_HAS_GNU.grep+= includes OpenBSD. The next month's
release of OpenBSD will not include GNU grep.
> > I don't see (but I may be overlooking this), some way for tools.mk to
> > check to see if system's version really exists. And if it doesn't exist
> > then use the BUILD_DEPENDS version.
>
> that can certainly be added.
That would be good. Using the examples that exist now, it just assumes it
is installed if _TOOLS_OPSYS_HAS_GNU has it defined. Also, it assumes that
the variable, like YACC, is correct.
Please have a look at my patch (which doesn't do me any good yet):
Index: mk/tools.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/tools.mk,v
retrieving revision 1.15
diff -u -r1.15 tools.mk
--- mk/tools.mk 2003/09/21 17:40:40 1.15
+++ mk/tools.mk 2003/10/01 00:48:28
@@ -113,7 +113,7 @@
# defining e.g. USE_GNU_TOOLS+="awk sed". Version numbers are not
# considered.
-_TOOLS= awk grep m4 make sed
+_TOOLS= awk grep lex m4 make sed yacc
.if defined(_IGNORE_USE_GNU_TOOLS)
USE_GNU_TOOLS:= # empty
@@ -128,9 +128,11 @@
_TOOLS_OPSYS_HAS_GNU.awk+= FreeBSD-*-* Linux-*-* NetBSD-*-* OpenBSD-*-*
_TOOLS_OPSYS_HAS_GNU.grep+= Darwin-*-* FreeBSD-*-* Linux-*-*
_TOOLS_OPSYS_HAS_GNU.grep+= NetBSD-*-* OpenBSD-*-*
+_TOOLS_OPSYS_HAS_GNU.lex+= FreeBSD-*-* Linux-*-* NetBSD-*-* OpenBSD-*-*
_TOOLS_OPSYS_HAS_GNU.m4+= # empty
_TOOLS_OPSYS_HAS_GNU.make+= Darwin-*-*
_TOOLS_OPSYS_HAS_GNU.sed+= Linux-*-*
+_TOOLS_OPSYS_HAS_GNU.yacc+= FreeBSD-*-* Linux-*-* NetBSD-*-* OpenBSD-*-*
# These platforms have GNUish versions of the tools available in the base
# system, which we already define as ${AWK}, ${SED}, etc. (refer to
@@ -139,9 +141,11 @@
#
_TOOLS_REPLACE_OPSYS.awk+= SunOS-*-*
_TOOLS_REPLACE_OPSYS.grep+= SunOS-*-*
+_TOOLS_REPLACE_OPSYS.lex+= SunOS-*-*
_TOOLS_REPLACE_OPSYS.m4+= # empty
_TOOLS_REPLACE_OPSYS.make+= # empty
_TOOLS_REPLACE_OPSYS.sed+= SunOS-*-*
+_TOOLS_REPLACE_OPSYS.yacc+= SunOS-*-*
# These platforms have completely unusable versions of these tools, and
# no suitable replacement is available.
@@ -224,6 +228,23 @@
MAKEFLAGS+= _IGNORE_USE_GNU_TOOLS=
.endif
+.if ${_TOOLS_REPLACE.lex} == "YES"
+_TOOLS_OVERRIDE.lex= YES
+_TOOLS_PROGNAME.lex= ${LEX}
+.endif
+.if (${_TOOLS_NEED_GNU.lex} == "YES") && empty(PKGPATH:Mdevel/flex)
+BUILD_DEPENDS+= lex>=2.5:../../devel/flex
+_TOOLS_OVERRIDE.lex= YES
+_TOOLS_PROGNAME.lex= ${LOCALBASE}/bin/flex
+. if exists(${_TOOLS_PROGNAME.lex})
+LEX:= ${_TOOLS_PROGNAME.lex}
+. endif
+.endif
+.if !empty(PKGPATH:Mdevel/flex)
+_TOOLS_OVERRIDE.lex= NO
+MAKEFLAGS+= _IGNORE_USE_GNU_TOOLS=
+.endif
+
.if ${_TOOLS_REPLACE.m4} == "YES"
_TOOLS_OVERRIDE.m4= YES
_TOOLS_PROGNAME.m4= ${M4}
@@ -272,6 +293,23 @@
.endif
.if !empty(PKGPATH:Mtextproc/gsed)
_TOOLS_OVERRIDE.sed= NO
+MAKEFLAGS+= _IGNORE_USE_GNU_TOOLS=
+.endif
+
+.if ${_TOOLS_REPLACE.yacc} == "YES"
+_TOOLS_OVERRIDE.yacc= YES
+_TOOLS_PROGNAME.yacc= ${YACC}
+.endif
+.if (${_TOOLS_NEED_GNU.yacc} == "YES") && empty(PKGPATH:Mdevel/bison)
+BUILD_DEPENDS+= bison>=1.0:../../devel/bison
+_TOOLS_OVERRIDE.yacc= YES
+_TOOLS_PROGNAME.yacc= ${LOCALBASE}/bin/bison -y
+. if exists(${_TOOLS_PROGNAME.yacc})
+YACC:= ${_TOOLS_PROGNAME.yacc}
+. endif
+.endif
+.if !empty(PKGPATH:Mdevel/yacc)
+_TOOLS_OVERRIDE.yacc= NO
MAKEFLAGS+= _IGNORE_USE_GNU_TOOLS=
.endif
Jeremy C. Reed
http://bsd.reedmedia.net/