tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

news/pan and mk/tools/gettext.mk



I noticed that news/pan fails to build on the netbsd builder even though
it builds fine for me.

The problem is that it wants the pkgsrc version of msgfmt; the version
on NetBSD 8 isn't new enough. But it picks up the pkgsrc version for me,
so I didn't notice.

I tried a one-off solution in the news/pan/Makefile, something like

# Check if default msgfmt knows the --xml --desktop options.
MSGFMT_TEST!= msgfmt --xml --desktop 2>&1 || true
.if !empty(MSGFMT_TEST:Munknown)
TOOL_DEPENDS+=		gettext-tools>=0.19:../../devel/gettext-tools
CONFIGURE_ENV+=		MSGFMT=${PREFIX}/bin/msgfmt
.endif

or even

# Check if default msgfmt knows the --xml --desktop options.
MSGFMT_TEST!= msgfmt --xml --desktop 2>&1 || true
.if !empty(MSGFMT_TEST:Munknown)
USE_BUILTIN.gettext=    no
.endif

but on irc jperkin proposed that I try to create a GETTEXT_REQD setting.

So I'm looking in mk/tools/gettext.mk, and it seems to me that the
variables MSGFMT_STRIP_MSGID_PLURAL and MSGFMT_STRIP_MSGCTXT aren't set
in a consistent manner; they aren't set under the same condition (not
even in the same .if nesting level). It looks like MSGFMT_STRIP_MSGCTXT
is getting set using the value of _TOOLS_VERSION.msgfmt which may not
even have been set at that point.

Anyway, this confusing issue aside, my current incarnation of changes to
gettext.mk looks like this (including some debugging output to make
sense of the flow of control). Does it make sense so far?


Index: gettext.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/tools/gettext.mk,v
retrieving revision 1.22
diff -u -r1.22 gettext.mk
--- gettext.mk	22 Aug 2018 20:48:37 -0000	1.22
+++ gettext.mk	16 Nov 2018 09:18:10 -0000
@@ -32,8 +32,14 @@
 # is no native tool available.  Don't add "msgfmt" to this list as it's
 # treated specially below.
 #
+.if !defined(GETTEXT_REQD)
+# If the user doesn't set the version, accept any builtin version
+# but the demanded pkgsrc version is set here.
+MSGFMT_AS_REQD=			yes
+GETTEXT_REQD=			0.15
+.endif
 _TOOLS.gettext-tools=		gettext msgmerge xgettext msgconv autopoint
-_TOOLS_DEP.gettext-tools=	gettext-tools>=0.15
+_TOOLS_DEP.gettext-tools=	gettext-tools>=${GETTEXT_REQD}
 
 .for _t_ in ${_TOOLS.gettext-tools}
 .  if !defined(TOOLS_IGNORE.${_t_}) && !empty(USE_TOOLS:C/:.*//:M${_t_})
@@ -55,16 +61,20 @@
 CHECK_BUILTIN.gettext:=	yes
 .    include "../../devel/gettext-lib/builtin.mk"
 CHECK_BUILTIN.gettext:=	no
+.info USE_BUILTIN.gettext is ${USE_BUILTIN.gettext}
 .    if !empty(USE_BUILTIN.gettext:M[nN][oO])
+.info _TOOLS_USE_PKGSRC.msgfmt=	yes
 _TOOLS_USE_PKGSRC.msgfmt=	yes
 .    endif
 
+.info _TOOLS_USE_PKGSRC.msgfmt?=	no
 _TOOLS_USE_PKGSRC.msgfmt?=	no
 .    if empty(_TOOLS_USE_PKGSRC.msgfmt:M[Yy][Ee][Ss]) && \
 	defined(TOOLS_PLATFORM.msgfmt) && !empty(TOOLS_PLATFORM.msgfmt)
 #
 # MSGFMT_STRIP_MSGID_PLURAL: Yes for msgfmt < 0.10.36
 # MSGFMT_STRIP_MSGCTXT: Yes for msgfmt < 0.15
+# MSGFMT_AS_REQD: Yes for msgfmt >= GETTEXT_REQD
 #
 # Determine if the platform-supplied msgfmt is new enough to support
 # the msgid_plural statement.  We need at least 0.10.36 for GNU msgfmt.
@@ -72,9 +82,25 @@
 # XXX Solaris msgfmt also understands msgid_plural but more tests are
 # XXX needed to take advantage of this.
 # XXX
-.      if !defined(_TOOLS_USE_MSGFMT_SH)
 _TOOLS_VERSION.msgfmt!=		${TOOLS_PLATFORM.msgfmt} --version |	\
 				${AWK} '{ print $$4; exit }'
+.info msgfmt version check: ${_TOOLS_VERSION.msgfmt}
+.      if !defined(MSGFMT_AS_REQD)
+MSGFMT_AS_REQD!=						\
+	if ${PKG_ADMIN} pmatch "gettext>=${GETTEXT_REQD}"		\
+			gettext-${_TOOLS_VERSION.msgfmt:Q}; then	\
+		${ECHO} yes;						\
+	else								\
+		${ECHO} no;						\
+	fi
+.      endif
+.      info MSGFMT_AS_REQD==${MSGFMT_AS_REQD}
+.      if empty(MSGFMT_AS_REQD:Myes)
+.        info _TOOLS_USE_PKGSRC.msgfmt=	yes (not AS_REQD)
+_TOOLS_USE_PKGSRC.msgfmt=	yes
+.      else
+.        if !defined(_TOOLS_USE_MSGFMT_SH)
+.          info use platform msgfmt, but do we need to patch it?
 .          if !defined(MSGFMT_STRIP_MSGID_PLURAL)
 MSGFMT_STRIP_MSGID_PLURAL!=						\
 	if ${PKG_ADMIN} pmatch "gettext>0.10.35"			\
@@ -83,9 +109,9 @@
 	else								\
 		${ECHO} yes;						\
 	fi
-.          endif
-.      endif
-.      if !defined(MSGFMT_STRIP_MSGCTXT)
+.            endif
+.        endif
+.        if !defined(MSGFMT_STRIP_MSGCTXT)
 MSGFMT_STRIP_MSGCTXT!=							\
 	if ${PKG_ADMIN} pmatch "gettext>=0.15"				\
 			gettext-${_TOOLS_VERSION.msgfmt:Q}; then	\
@@ -93,10 +119,13 @@
 	else								\
 		${ECHO} yes;						\
 	fi
+.        endif
 .      endif
 .    else
+.      info _TOOLS_USE_PKGSRC.msgfmt=	yes (because there is no platform version)
 _TOOLS_USE_PKGSRC.msgfmt=	yes
 .    endif
+.info MSGFMT_STRIP_MSGID_PLURAL?=	no (_TOOLS_USE_PKGSRC.msgfmt=${_TOOLS_USE_PKGSRC.msgfmt})
 MSGFMT_STRIP_MSGID_PLURAL?=	no
 MSGFMT_STRIP_MSGCTXT?=		no
 .    if ${MSGFMT_STRIP_MSGID_PLURAL} == "yes" || ${MSGFMT_STRIP_MSGCTXT} == "yes"

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- "What good is a Ring of Power
\X/ rhialto/at/falu.nl      -- if you're unable...to Speak." - Agent Elrond

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index