Subject: Re: should .buildlink-x11 (or .x11-buildlink) ever be different from
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 02/05/2004 11:27:48
Here is one patch that appears to work for me for buildlink2 for when my
X11BASE is same as LOCALBASE (X11BASE is /usr/pkg). (I need buildlink3
done too, but it is quite different.)

--- mk/buildlink2/bsd.buildlink2.mk	5 Feb 2004 09:57:53 -0000	1.110
+++ mk/buildlink2/bsd.buildlink2.mk	5 Feb 2004 19:24:00 -0000
@@ -207,7 +207,11 @@
 _LT_ARCHIVE_TRANSFORM_SED=						\
 	-e "s|$/usr\(/lib/[^ 	]*\.la\)|${BUILDLINK_DIR}\1|g"		\
 	-e "s|${LOCALBASE}\(/lib/[^ 	]*\.la\)|${BUILDLINK_DIR}\1|g"	\
+
+.if ${LOCALBASE} != ${X11BASE}
+_LT_ARCHIVE_TRANSFORM_SED+=						\
 	-e "s|${X11BASE}\(/lib/[^ 	]*\.la\)|${BUILDLINK_DIR}\1|g"
+.endif

 _LT_ARCHIVE_TRANSFORM=							\
 	${SED} ${_LT_ARCHIVE_TRANSFORM_SED} $${file} > $${dest}
@@ -253,14 +257,14 @@
 	if [ ! -f $${cookie} ]; then					\
 		${ECHO_BUILDLINK_MSG} "Linking ${.TARGET:S/-buildlink//} files into ${BUILDLINK_DIR}."; \
 		${MKDIR} ${BUILDLINK_DIR};				\
-		case "${BUILDLINK_PREFIX.${.TARGET:S/-buildlink//}}" in	\
+		buildlink_dir="${BUILDLINK_DIR}";			\
+		if [ "${X11BASE}" != "${LOCALBASE}" ] ; then		\
+			case "${BUILDLINK_PREFIX.${.TARGET:S/-buildlink//}}" in\
 		${X11BASE})						\
 			buildlink_dir="${BUILDLINK_X11_DIR}";		\
 			;;						\
-		*)							\
-			buildlink_dir="${BUILDLINK_DIR}";		\
-			;;						\
 		esac;							\
+		fi;							\
 		pkg_prefix=;						\
 		if [ -n "${BUILDLINK_PKGBASE.${.TARGET:S/-buildlink//}}" ]; then \
 			pkg_prefix=`${PKG_INFO} -qp ${BUILDLINK_PKGBASE.${.TARGET:S/-buildlink//}} | ${AWK} '{ sub("${BUILDLINK_PREFIX.${.TARGET:S/-buildlink//}}", "", $$2); sub("/", "", $$2); print $$2; exit }'`/; \
@@ -348,24 +352,30 @@
 #
 # Convert direct paths to shared libraries into "-Ldir -llib" equivalents.
 #
+.if ${X11BASE} != ${LOCALBASE}
 _BLNK_TRANSFORM+=	p:${X11BASE}
+.endif
 _BLNK_TRANSFORM+=	p:${LOCALBASE}
 _BLNK_TRANSFORM+=	p:/usr/lib
 #
 # Convert direct paths to static libraries in ${LOCALBASE} or ${X11BASE}
 # into references into ${BUILDLINK_DIR}.
 #
+.if ${X11BASE} != ${LOCALBASE}
 _BLNK_TRANSFORM+=	static:${X11BASE}:${_BLNK_MANGLE_DIR.BUILDLINK_X11_DIR}
+.endif
 _BLNK_TRANSFORM+=	static:${LOCALBASE}:${_BLNK_MANGLE_DIR.BUILDLINK_DIR}
 #
 # Transform references into ${X11BASE} into ${BUILDLINK_X11_DIR} but if
 # the package doesn't use X11, then just remove these references altogether.
 #
-.if defined(USE_X11)
+.if ${X11BASE} != ${LOCALBASE}
+.  if defined(USE_X11)
 _BLNK_TRANSFORM+=	I:${X11BASE}:${_BLNK_MANGLE_DIR.BUILDLINK_X11_DIR}
 _BLNK_TRANSFORM+=	L:${X11BASE}:${_BLNK_MANGLE_DIR.BUILDLINK_X11_DIR}
-.else
+.  else
 _BLNK_TRANSFORM+=	r:${X11BASE}
+.  endif
 .endif
 #
 # Transform references into ${LOCALBASE} into ${BUILDLINK_DIR}.
@@ -921,8 +931,10 @@

 _BLNK_CHECK_PATTERNS+=	-e "-I${LOCALBASE}/[a-rt-z]"
 _BLNK_CHECK_PATTERNS+=	-e "-L${LOCALBASE}/[a-rt-z]"
+.if ${X11BASE} != ${LOCALBASE}
 _BLNK_CHECK_PATTERNS+=	-e "-I${X11BASE}/"
 _BLNK_CHECK_PATTERNS+=	-e "-L${X11BASE}/"
+.endif

 buildlink-check:
 	@if [ -f ${_BLNK_WRAP_LOG} ]; then				\




   Jeremy C. Reed
   http://bsd.reedmedia.net/