Bug 136917 - [patch] lang/python26: gettext detection
Summary: [patch] lang/python26: gettext detection
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-python (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-20 05:30 UTC by swell.k
Modified: 2012-06-19 19:00 UTC (History)
0 users

See Also:


Attachments
python26.diff (576 bytes, patch)
2009-07-20 05:30 UTC, swell.k
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description swell.k 2009-07-20 05:30:02 UTC
When using external compiler from ports ${LOCALBASE}/include is
implicitly searched for header files. Because of this HAVE_LIBINTL_H
gets defined iff devel/gettext is installed. As a consequence _locale.so
module fails to build.

To mimic base compiler one can disable ac_cv_header_libintl_h.

However, the solution would be to use gettext when it's
available/specified. Not ignore gettext like base compiler currently
does because it cannot find libintl.h inside /usr/include.

Fix: This is actually a workaround
How-To-Repeat: install devel/gettext
install lang/gcc42

$ cd lang/python26
$ make configure CC=gcc42
[...]

$ fgrep -m1 HAVE_LIBINTL_H $(make -V WRKSRC)/config.log
| #define HAVE_LIBINTL_H 1

$ make CC=gcc42
[...]
*** WARNING: renaming "_locale" since importing it failed: build/lib.freebsd-8.0-BETA2-amd64-2.6/_locale.so: Undefined symbol "libintl_bindtextdomain"
[...]
Failed to build these modules:
_locale
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2009-07-20 05:30:13 UTC
Responsible Changed
From-To: freebsd-ports-bugs->python

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2009-07-20 12:41:04 UTC
Responsible Changed
From-To: python->freebsd-python

Canonicalize assignment.
Comment 3 swell.k 2010-08-06 21:13:37 UTC
The bug affects lang/python31, too, where locale is part of libpython.

  $ pydoc2.6 locale.gettext
  Help on built-in function gettext in locale:

  locale.gettext = gettext(...)
      gettext(msg) -> string
      Return translation of msg.

  $ python2.6
  >>> import locale
  >>> locale.gettext('blah')
  'blah'

BTW, I've simplified CONFIGURE_ENV a bit in order to avoid accidental
override like below

  CONFIGURE_ENV+= CPPFLAGS="-I${LOCALBASE}/foo"
  ...
  CONFIGURE_ENV+= CPPFLAGS="-I${LOCALBASE}/bar"

--- a.diff begins here ---
Index: lang/python26/Makefile
===================================================================
RCS file: /a/.cvsup/ports/lang/python26/Makefile,v
retrieving revision 1.167
diff -u -p -r1.167 Makefile
--- lang/python26/Makefile	19 Jul 2010 21:59:27 -0000	1.167
+++ lang/python26/Makefile	6 Aug 2010 19:58:57 -0000
@@ -56,7 +56,8 @@ OPTIONS=	THREADS "Enable thread support"
 		UCS4 "Use UCS4 for unicode support" on \
 		PYMALLOC "Use python's internal malloc" on \
 		IPV6 "Enable IPv6 support" on \
-		FPECTL "Enable floating point exception handling" off
+		FPECTL "Enable floating point exception handling" off \
+		GETTEXT "Enable gettext support in locale module" off
 
 .include <bsd.port.pre.mk>
 
@@ -83,19 +84,24 @@ PLIST_SUB+=	IF_DEFAULT="@comment "
 # workaround for a bug in base curses.h.
 CFLAGS+=	-D__wchar_t=wchar_t
 
+.if defined(CPPFLAGS)
+CONFIGURE_ENV+=		CPPFLAGS="${CPPFLAGS}"
+.endif
+.if defined(LDFLAGS)
+CONFIGURE_ENV+=		LDFLAGS="${LDFLAGS}"
+.endif
+
 .if !defined(WITHOUT_THREADS)
 .if defined(WITH_PTH)
 CONFIGURE_ARGS+=	--with-pth
 EXTRA_PATCHES+=		${PATCHDIR}/extra-patch-configure-pth
 LIB_DEPENDS+=		pth:${PORTSDIR}/devel/pth
-_PTH_CPPFLAGS=		"-I${LOCALBASE}/include/pth"
-_PTH_LDFLAGS=		"-L${LOCALBASE}/lib/pth"
-CONFIGURE_ENV+=		CPPFLAGS="${_PTH_CPPFLAGS} ${CPPFLAGS}"
-CONFIGURE_ENV+=		LDFLAGS="${_PTH_LDFLAGS} ${LDFLAGS}"
+CPPFLAGS+=		-I${LOCALBASE}/include/pth
+LDFLAGS+=		-L${LOCALBASE}/lib/pth
 .else # !defined(WITH_PTH)
 CONFIGURE_ARGS+=	--with-threads
 CFLAGS+=		${PTHREAD_CFLAGS}
-CONFIGURE_ENV+=		LDFLAGS="${PTHREAD_LIBS} ${LDFLAGS}"
+LDFLAGS+=		${PTHREAD_LIBS}
 .endif # defined(WITH_PTH)
 .if defined(WITHOUT_HUGE_STACK_SIZE)
 CFLAGS+=		-DTHREAD_STACK_SIZE=0x20000
@@ -104,9 +110,6 @@ CFLAGS+=		-DTHREAD_STACK_SIZE=0x100000
 .endif # defined(WITHOUT_HUGE_STACK_SIZE)
 .else # defined(WITHOUT_THREADS)
 CONFIGURE_ARGS+=	--without-threads
-.if defined(LDFLAGS)
-CONFIGURE_ENV+=		LDFLAGS="${LDFLAGS}"
-.endif # defined(LDFLAGS)
 .endif # !defined(WITHOUT_THREADS)
 
 .if !defined(WITHOUT_UCS4) && !defined(WITH_UCS2)
@@ -147,6 +150,14 @@ CONFIGURE_ARGS+=	--disable-ipv6
 CONFIGURE_ARGS+=	--with-fpectl
 .endif
 
+.if defined(WITH_GETTEXT)
+USE_GETTEXT=	yes
+LDFLAGS+=	-L${LOCALBASE}/lib
+CONFIGURE_ENV+=	ac_cv_header_libintl_h=yes
+.else
+CONFIGURE_ENV+=	ac_cv_header_libintl_h=no
+.endif
+
 pre-patch:
 	${CP} -r ${PATCH_WRKSRC}/Lib/plat-freebsd8 \
 		${PATCH_WRKSRC}/Lib/plat-freebsd9
--- a.diff ends here ---
Comment 4 b. f. 2010-08-13 14:56:45 UTC
> +.if defined(CPPFLAGS)
> +CONFIGURE_ENV+=               CPPFLAGS="${CPPFLAGS}"
> +.endif
> +.if defined(LDFLAGS)
> +CONFIGURE_ENV+=               LDFLAGS="${LDFLAGS}"
> +.endif

You need to perform these tests after all additions to CPPFLAGS and
LDFLAGS via OPTIONS, or add both of them unconditionally to the
CONFIGURE_ENV= ... line before the inclusion of bsd.port.pre.mk.  The
latter is the usual approach.  The way you have it now, if there
aren't user-defined CPPFLAGS or some other intervention, CPPFLAGS
won't be added to CONFIGURE_ENV, even if WITH_THREADS and
WITH_PTH=true, because CPPFLAGS won't have been defined when the test
is performed.  Anyway, LDFLAGS is almost always defined, though it may
be empty, via /usr/share/mk/sys.mk.  And note that, although I don't
think it matters for this port, prepending a value to these flags (as
in the current port Makefile) may not have the same effect as
appending a value with += (as in your patched version) because, in
general, search order matters.

b.
Comment 5 swell.k 2010-08-13 15:57:27 UTC
"b. f." <bf1783@googlemail.com> writes:

>> +.if defined(CPPFLAGS)
>> +CONFIGURE_ENV+=               CPPFLAGS="${CPPFLAGS}"
>> +.endif
>> +.if defined(LDFLAGS)
>> +CONFIGURE_ENV+=               LDFLAGS="${LDFLAGS}"
>> +.endif
>
> You need to perform these tests after all additions to CPPFLAGS and
> LDFLAGS via OPTIONS, or add both of them unconditionally to the
> CONFIGURE_ENV= ... line before the inclusion of bsd.port.pre.mk.  The
> latter is the usual approach.  The way you have it now, if there
> aren't user-defined CPPFLAGS or some other intervention, CPPFLAGS
> won't be added to CONFIGURE_ENV, even if WITH_THREADS and
> WITH_PTH=true, because CPPFLAGS won't have been defined when the test
> is performed. Anyway, LDFLAGS is almost always defined, though it may
> be empty, via /usr/share/mk/sys.mk.

Yep, I've confused how variable expansion and flow control works in make(1).
Adding CPPFLAGS/LDFLAGS to CONFIGURE_ENV looks simplier. The diff is regened.

> And note that, although I don't think it matters for this port,
> prepending a value to these flags (as in the current port Makefile)
> may not have the same effect as appending a value with += (as in your
> patched version) because, in general, search order matters.

This can be addressed by properly ordering `+=', e.g.

  CPPFLAGS += -Dfoo=one
  CPPFLAGS += -Dfoo=two

Prepending a value is usually more confusing, but can be done by `:='.

--- a.diff begins here ---
Index: lang/python26/Makefile
===================================================================
RCS file: /a/.cvsup/ports/lang/python26/Makefile,v
retrieving revision 1.167
diff -u -p -r1.167 Makefile
--- lang/python26/Makefile	19 Jul 2010 21:59:27 -0000	1.167
+++ lang/python26/Makefile	13 Aug 2010 14:13:32 -0000
@@ -20,7 +20,8 @@ WRKSRC=		${PYTHON_WRKSRC}/portbld.static
 PATCH_WRKSRC=	${PYTHON_WRKSRC}
 GNU_CONFIGURE=	yes
 CONFIGURE_SCRIPT=	../configure # must be relative
-CONFIGURE_ENV=	OPT="${CFLAGS}" SVNVERSION="echo freebsd"
+CONFIGURE_ENV=	CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" \
+		OPT="${CFLAGS}" SVNVERSION="echo freebsd"
 MAKE_ENV=	VPATH="${PYTHON_WRKSRC}"
 USE_LDCONFIG=	yes
 MAKE_JOBS_SAFE=	yes
@@ -56,7 +57,8 @@ OPTIONS=	THREADS "Enable thread support"
 		UCS4 "Use UCS4 for unicode support" on \
 		PYMALLOC "Use python's internal malloc" on \
 		IPV6 "Enable IPv6 support" on \
-		FPECTL "Enable floating point exception handling" off
+		FPECTL "Enable floating point exception handling" off \
+		GETTEXT "Enable gettext support in locale module" off
 
 .include <bsd.port.pre.mk>
 
@@ -88,14 +90,12 @@ CFLAGS+=	-D__wchar_t=wchar_t
 CONFIGURE_ARGS+=	--with-pth
 EXTRA_PATCHES+=		${PATCHDIR}/extra-patch-configure-pth
 LIB_DEPENDS+=		pth:${PORTSDIR}/devel/pth
-_PTH_CPPFLAGS=		"-I${LOCALBASE}/include/pth"
-_PTH_LDFLAGS=		"-L${LOCALBASE}/lib/pth"
-CONFIGURE_ENV+=		CPPFLAGS="${_PTH_CPPFLAGS} ${CPPFLAGS}"
-CONFIGURE_ENV+=		LDFLAGS="${_PTH_LDFLAGS} ${LDFLAGS}"
+CPPFLAGS+=		-I${LOCALBASE}/include/pth
+LDFLAGS+=		-L${LOCALBASE}/lib/pth
 .else # !defined(WITH_PTH)
 CONFIGURE_ARGS+=	--with-threads
 CFLAGS+=		${PTHREAD_CFLAGS}
-CONFIGURE_ENV+=		LDFLAGS="${PTHREAD_LIBS} ${LDFLAGS}"
+LDFLAGS+=		${PTHREAD_LIBS}
 .endif # defined(WITH_PTH)
 .if defined(WITHOUT_HUGE_STACK_SIZE)
 CFLAGS+=		-DTHREAD_STACK_SIZE=0x20000
@@ -104,9 +104,6 @@ CFLAGS+=		-DTHREAD_STACK_SIZE=0x100000
 .endif # defined(WITHOUT_HUGE_STACK_SIZE)
 .else # defined(WITHOUT_THREADS)
 CONFIGURE_ARGS+=	--without-threads
-.if defined(LDFLAGS)
-CONFIGURE_ENV+=		LDFLAGS="${LDFLAGS}"
-.endif # defined(LDFLAGS)
 .endif # !defined(WITHOUT_THREADS)
 
 .if !defined(WITHOUT_UCS4) && !defined(WITH_UCS2)
@@ -147,6 +144,14 @@ CONFIGURE_ARGS+=	--disable-ipv6
 CONFIGURE_ARGS+=	--with-fpectl
 .endif
 
+.if defined(WITH_GETTEXT)
+USE_GETTEXT=	yes
+LDFLAGS+=	-L${LOCALBASE}/lib
+CONFIGURE_ENV+=	ac_cv_header_libintl_h=yes
+.else
+CONFIGURE_ENV+=	ac_cv_header_libintl_h=no
+.endif
+
 pre-patch:
 	${CP} -r ${PATCH_WRKSRC}/Lib/plat-freebsd8 \
 		${PATCH_WRKSRC}/Lib/plat-freebsd9
--- a.diff ends here ---
Comment 6 dfilter service freebsd_committer freebsd_triage 2012-06-19 18:48:52 UTC
mva         2012-06-19 17:48:42 UTC

  FreeBSD ports repository

  Modified files:
    lang/python24        Makefile 
    lang/python25        Makefile 
    lang/python26        Makefile 
    lang/python27        Makefile 
    lang/python31        Makefile 
    lang/python32        Makefile 
  Log:
  - Fix gettext detection for the locale module
  - Explicitly enable/disable gettext support via a new NLS OPTION switch.
  
  PR:             ports/168684 ports/136917
  On behalf of:   python@
  
  Revision  Changes    Path
  1.178     +9 -0      ports/lang/python24/Makefile
  1.170     +9 -0      ports/lang/python25/Makefile
  1.186     +11 -1     ports/lang/python26/Makefile
  1.191     +11 -1     ports/lang/python27/Makefile
  1.183     +11 -1     ports/lang/python31/Makefile
  1.187     +11 -1     ports/lang/python32/Makefile
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 7 Marcus von Appen freebsd_committer freebsd_triage 2012-06-19 18:50:16 UTC
State Changed
From-To: open->closed

Fixed by ports/168684. Thanks!