Subject: pkg/30029: [PATCH] devel/glib2 patches in defines never seen by the compiler
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <idart@performancedesign.no>
List: pkgsrc-bugs
Date: 04/22/2005 07:59:00
>Number:         30029
>Category:       pkg
>Synopsis:       [PATCH] devel/glib2 patches in defines never seen by the compiler
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 22 07:59:00 +0000 2005
>Originator:     Idar Tollefsen
>Release:        N/A
>Organization:
Performance Design
>Environment:
Darwin fulcrum.local 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC  Power Macintosh powerpc
>Description:
devel/glib2/patch/patch-ah replaces certain directory variables in glib/gutils.c with defines to pkgsrc directories. devel/glib2/Makefile then tries to define these by settings some of them in CONFIGURE_ENV and all of them as -D flags in CPPFLAGS.

Unfortunately, the definitions set up the Makefile are never propagated to the command line and the build fails.

>How-To-Repeat:
Just try to build devel/glib2.
It is possible that the problem is platform specific.
If so, try to build devel/glib2 on OS X.
>Fix:
Altough the problem _might_ be OS X specific, the solution isn't.
Instead of trying to get the necessary defines passed to the compiler from the command line, include the definitions in config.h.

The patch also changes F77=${FALSE} to only apply to SunOS where the comment says it's needed. It otherwise generates annoying warnings during configuration.

Here's the patch against devel/glib2/Makefile:
----------------------------------------------

--- Makefile.orig	Fri Apr 22 08:47:33 2005
+++ Makefile	Fri Apr 22 09:24:04 2005
@@ -34,7 +34,6 @@
 PKGCONFIG_OVERRIDE+=	gthread-2.0.pc.in
 
 GNU_CONFIGURE=		# defined
-CONFIGURE_ENV+=		PKGLOCALEDIR=${PKGLOCALEDIR}
 CONFIGURE_ARGS+=	--enable-gtk-doc=no
 CONFIGURE_ARGS+=	--includedir=${PREFIX}/include/glib
 CONFIGURE_ARGS+=	--with-html-dir=${PREFIX}/share/doc
@@ -42,18 +41,16 @@
 
 CONFIGURE_ARGS.gnu-iconv=	--with-libiconv=gnu
 
-# Avoid an ICE in gcc2 on sparc64
-CONFIGURE_ENV+=		F77=${FALSE}
-
 CONFIGURE_ENV+=		PERL=${PERL5}
 CONFIGURE_ENV+=		PERL_PATH=${PERL5}
 
-CPPFLAGS+=		-DPREFIX="\"${PREFIX}\""
-CPPFLAGS+=		-DPKGLOCALEDIR="\"${PKGLOCALEDIR}\""
-CPPFLAGS+=		-DPKG_SYSCONFDIR="\"${PKG_SYSCONFDIR}\""
-
 .include "../../mk/bsd.prefs.mk"
 
+# Avoid an ICE in gcc2 on sparc64
+.if ${OPSYS} == "SunOS"
+CONFIGURE_ENV+=		F77=${FALSE}
+.endif
+
 # FreeBSD fix for libgthread:
 # Be sure libgthread is linked to the threaded library (libc_r), otherwise
 # -pthread is added and this won't work with libraries, only executable
@@ -73,6 +70,13 @@
 PRINT_PLIST_AWK+=	/^@dirrm include\/glib$$/ \
 				{ print "@unexec $${RMDIR} %D/" $$2 \
 				  " 2>/dev/null || $${TRUE}"; next; }
+
+post-configure:
+	@${ECHO} "" >> ${WRKSRC}/config.h
+	@${ECHO} "/* pkgsrc definitions. */" >> ${WRKSRC}/config.h
+	@${ECHO} "#define PREFIX \"${PREFIX}\"" >> ${WRKSRC}/config.h
+	@${ECHO} "#define PKGLOCALEDIR \"${PKGLOCALEDIR}\"" >> ${WRKSRC}/config.h
+	@${ECHO} "#define PKG_SYSCONFDIR \"${PKG_SYSCONFDIR}\"" >> ${WRKSRC}/config.h
 
 .include "../../converters/libiconv/buildlink3.mk"
 .include "../../devel/gettext-lib/buildlink3.mk"