From 7d8a00b308d64b4ef37135a15f9094e390dbdfe4 Mon Sep 17 00:00:00 2001 From: jlam Date: Wed, 18 Sep 2002 00:46:58 +0000 Subject: Modifications and additions to create a dummy libtool archive to represent a system library so that we can prefer a system library to a pkgsrc one when building with pkgsrc. --- mk/buildlink2/bsd.buildlink2.mk | 95 +++++++++++++++++++++++++++++++---------- mk/buildlink2/fake-la | 40 +++++++++++++++++ mk/buildlink2/post-cache | 4 +- 3 files changed, 115 insertions(+), 24 deletions(-) create mode 100644 mk/buildlink2/fake-la (limited to 'mk') diff --git a/mk/buildlink2/bsd.buildlink2.mk b/mk/buildlink2/bsd.buildlink2.mk index d499ee94ee8..6fa68cffd58 100644 --- a/mk/buildlink2/bsd.buildlink2.mk +++ b/mk/buildlink2/bsd.buildlink2.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.buildlink2.mk,v 1.21 2002/09/17 19:15:35 jlam Exp $ +# $NetBSD: bsd.buildlink2.mk,v 1.22 2002/09/18 00:46:58 jlam Exp $ # # An example package buildlink2.mk file: # @@ -97,6 +97,11 @@ buildlink-directories: ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${BUILDLINK_DIR}/include ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${BUILDLINK_DIR}/lib +# Create the buildlink wrappers before any of the other buildlink targets +# are run, as the wrapper may need to be used in some of those targets. +# +do-buildlink: buildlink-wrappers buildlink-${_BLNK_OPSYS}-wrappers + # Add each of the *-buildlink targets as a prerequisite for the # buildlink target. This ensures that the symlinks are created # before any configure scripts or build commands are called. @@ -194,8 +199,6 @@ _BUILDLINK_USE: .USE ${TOUCH} ${TOUCH_FLAGS} $${cookie}; \ fi -do-buildlink: buildlink-wrappers buildlink-${_BLNK_OPSYS}-wrappers - # _BLNK_TRANSFORM mini language for translating wrapper arguments into # their buildlink equivalents: # @@ -242,13 +245,17 @@ _BLNK_UNPROTECT_SED+= -e "s|_pKgSrCdIr_|${_PKGSRCDIR}|g" # separate variables instead of just one because the contents are too long # for one variable when we substitute into a shell script later on. # -_BLNK_TRANSFORM_SED.1+= ${_BLNK_PROTECT_SED} -_BLNK_TRANSFORM_SED.2+= ${_BLNK_PROTECT_SED} -_BLNK_TRANSFORM_SED.3+= ${_BLNK_PROTECT_SED} +_BLNK_TRANSFORM_SED.1+= ${_BLNK_PROTECT_SED} +_BLNK_TRANSFORM_SED.2+= ${_BLNK_PROTECT_SED} +_BLNK_TRANSFORM_SED.3+= ${_BLNK_PROTECT_SED} # -# Change "/usr/pkg/lib/libfoo.so" into "-L/usr/pkg/lib -lfoo" and +# Change "/usr/lib/libfoo.so" into "-lfoo", +# "/usr/pkg/lib/libfoo.so" into "-L/usr/pkg/lib -lfoo", # "/usr/X11R6/lib/libbar.so" into "-L/usr/X11R6/lib -lbar". # +_BLNK_TRANSFORM_SED.libpath+= \ + -e "s|/usr/lib/lib\([^ ]*\)\.a|-l\1|g" \ + -e "s|/usr/lib/lib\([^ ]*\)\.so|-l\1|g" _BLNK_TRANSFORM_SED.libpath+= \ -e "s|\(${LOCALBASE}/[^ ]*\)/lib\([^ ]*\)\.a|-L\1 -l\2|g" \ -e "s|\(${LOCALBASE}/[^ ]*\)/lib\([^ ]*\)\.so|-L\1 -l\2|g" @@ -256,6 +263,7 @@ _BLNK_TRANSFORM_SED.libpath+= \ -e "s|\(${X11BASE}/[^ ]*\)/lib\([^ ]*\)\.a|-L\1 -l\2|g" \ -e "s|\(${X11BASE}/[^ ]*\)/lib\([^ ]*\)\.so|-L\1 -l\2|g" _BLNK_TRANSFORM_SED.1+= ${_BLNK_TRANSFORM_SED.libpath} +_BLNK_UNTRANSFORM_SED.1+= ${_BLNK_TRANSFORM_SED.libpath} # # Transform "I:/usr/pkg:/buildlink" into: # -e "s|-I/usr/pkg |-I/buildlink |g" @@ -345,12 +353,15 @@ _BLNK_TRANSFORM_SED.l+= \ -e "s|-l${_transform_:C/^l\:([^\:]*)\:([^\:]*)$/\1/}$$|-l${_transform_:C/^l\:([^\:]*)\:([^\:]*)$/\2/}|g" .endfor _BLNK_TRANSFORM_SED.3+= ${_BLNK_TRANSFORM_SED.l} +_BLNK_UNTRANSFORM_SED.3+= ${_BLNK_TRANSFORM_SED.l} # # Fix up references to the x11-links directory. # .if defined(USE_X11) || defined(USE_X11BASE) || defined(USE_IMAKE) _BLNK_TRANSFORM_SED.3+= \ -e "s|${BUILDLINK_DIR}/\(${BUILDLINK_X11_DIR:S/^${LOCALBASE}\///}\)|${LOCALBASE}/\1|g" +_BLNK_UNTRANSFORM_SED.3+= \ + -e "s|${BUILDLINK_DIR}/\(${BUILDLINK_X11_DIR:S/^${LOCALBASE}\///}\)|${LOCALBASE}/\1|g" .endif # # Transform "r:-I/usr/local" into: @@ -365,6 +376,7 @@ _BLNK_TRANSFORM_SED.r+= \ -e "s|${_transform_:S/^r://}/[^ ]*||g" .endfor _BLNK_TRANSFORM_SED.3+= ${_BLNK_TRANSFORM_SED.r} +_BLNK_UNTRANSFORM_SED.3+= ${_BLNK_TRANSFORM_SED.r} # # Explicitly remove "-I/usr/include" and "-L/usr/lib" as they're redundant. # @@ -373,10 +385,15 @@ _BLNK_TRANSFORM_SED.3+= \ -e "s|-I/usr/include$$||g" \ -e "s|-L/usr/lib ||g" \ -e "s|-L/usr/lib$$||g" +_BLNK_UNTRANSFORM_SED.3+= \ + -e "s|-I/usr/include ||g" \ + -e "s|-I/usr/include$$||g" \ + -e "s|-L/usr/lib ||g" \ + -e "s|-L/usr/lib$$||g" -_BLNK_TRANSFORM_SED.1+= ${_BLNK_UNPROTECT_SED} -_BLNK_TRANSFORM_SED.2+= ${_BLNK_UNPROTECT_SED} -_BLNK_TRANSFORM_SED.3+= ${_BLNK_UNPROTECT_SED} +_BLNK_TRANSFORM_SED.1+= ${_BLNK_UNPROTECT_SED} +_BLNK_TRANSFORM_SED.2+= ${_BLNK_UNPROTECT_SED} +_BLNK_TRANSFORM_SED.3+= ${_BLNK_UNPROTECT_SED} _BLNK_CHECK_IS_TEXT_FILE?= \ ${FILE_CMD} $${file} | ${EGREP} "(shell script|text)" >/dev/null 2>&1 @@ -437,9 +454,17 @@ _REPLACE_BUILDLINK= \ ${REPLACE_BUILDLINK} \ `${FIND} . ${_REPLACE_BUILDLINK_PATTERNS_FIND} -print | ${SED} -e 's|^\./||' | ${SORT} -u` +# When "unbuildlinkifying" a file, we must remove references to the +# buildlink directories and change any -llib to the proper replacement +# libraries (-lreadline -> -ledit, etc.). Redundant -Idir and -Ldir +# options are removed to optimize the resulting file. +# REPLACE_BUILDLINK_SED?= # empty _REPLACE_BUILDLINK_SED= ${REPLACE_BUILDLINK_SED} -_REPLACE_BUILDLINK_SED+= ${_BLNK_TRANSFORM_SED.l} +_REPLACE_BUILDLINK_SED+= ${LIBTOOL_ARCHIVE_UNTRANSFORM_SED} +_REPLACE_BUILDLINK_SED+= ${_BLNK_UNTRANSFORM_SED.1} +_REPLACE_BUILDLINK_SED+= ${_BLNK_UNTRANSFORM_SED.2} +_REPLACE_BUILDLINK_SED+= ${_BLNK_UNTRANSFORM_SED.3} BUILDLINK_SUBST_MESSAGE.unbuildlink= \ "Fixing buildlink references in files-to-be-installed." @@ -449,6 +474,19 @@ BUILDLINK_SUBST_SED.unbuildlink= ${_REPLACE_BUILDLINK_SED} post-build: unbuildlink-buildlink-subst unbuildlink-buildlink-subst: _BUILDLINK_SUBST_USE +# Create a fake libtool archive $$lafile that uses the shared libraries +# named in $$libpattern. +# +BUILDLINK_FAKE_LA= \ + if [ ! -f $$lafile ]; then \ + ${ECHO_BUILDLINK_MSG} "Creating libtool archive: $$lafile"; \ + case ${OBJECT_FMT} in \ + Mach-O) _lib=`${LS} -1 $$libpattern | ${HEAD} -1` ;; \ + *) _lib=`${LS} -1r $$libpattern | ${HEAD} -1` ;; \ + esac; \ + ${_BLNK_FAKE_LA} $$_lib > $$lafile; \ + fi + # Generate wrapper scripts for the compiler tools that sanitize the # argument list by converting references to ${LOCALBASE} and ${X11BASE} # into references to ${BUILDLINK_DIR}, ${BUILDLINK_X11PKG_DIR}, and @@ -524,6 +562,7 @@ _BLNK_WRAP_CACHE_TRANSFORM= ${BUILDLINK_DIR}/bin/.cache-trans _BLNK_WRAP_LOGIC_TRANSFORM= ${BUILDLINK_DIR}/bin/.logic-trans _BLNK_WRAP_LOG= ${BUILDLINK_DIR}/.wrapper.log _BLNK_LIBTOOL_FIX_LA= ${BUILDLINK_DIR}/bin/.libtool-fix-la +_BLNK_FAKE_LA= ${BUILDLINK_DIR}/bin/.fake-la .for _wrappee_ in ${_BLNK_WRAPPEES} # @@ -558,17 +597,8 @@ _BLNK_WRAP_ENV.LIBTOOL= # empty _BLNK_WRAPPER_SH.LIBTOOL= ${.CURDIR}/../../mk/buildlink2/libtool.sh _BLNK_WRAP_SANITIZE_PATH.LIBTOOL= # empty -# In the libtool archives, we must remove references to the buildlink -# directories and change any -llib to the proper replacement libraries -# (-lreadline -> -ledit, etc.). Redundant -Ldir options are removed to -# optimize the resulting libtool archives. -# -_BLNK_WRAP_LT_UNTRANSFORM_SED= ${LIBTOOL_ARCHIVE_UNTRANSFORM_SED} -_BLNK_WRAP_LT_UNTRANSFORM_SED+= ${_BLNK_UNTRANSFORM_SED.1} -_BLNK_WRAP_LT_UNTRANSFORM_SED+= ${_BLNK_UNTRANSFORM_SED.2} -_BLNK_WRAP_LT_UNTRANSFORM_SED+= ${_BLNK_UNTRANSFORM_SED.3} -_BLNK_WRAP_LT_UNTRANSFORM_SED+= -e "s|-L/usr/lib ||g" -_BLNK_WRAP_LT_UNTRANSFORM_SED+= -e "s|-L/usr/lib$$||g" +# We need to "unbuildlinkify" any libtool archives. +_BLNK_WRAP_LT_UNTRANSFORM_SED= ${_REPLACE_BUILDLINK_SED} # Don't transform the arguments for imake, which uses the C preprocessor # to generate Makefiles, so that imake will find its config files. @@ -585,6 +615,7 @@ buildlink-wrappers: ${_BLNK_WRAP_CACHE_TRANSFORM} buildlink-wrappers: ${_BLNK_WRAP_LOGIC} buildlink-wrappers: ${_BLNK_WRAP_LOGIC_TRANSFORM} buildlink-wrappers: ${_BLNK_LIBTOOL_FIX_LA} +buildlink-wrappers: ${_BLNK_FAKE_LA} .for _wrappee_ in ${_BLNK_WRAPPEES} CONFIGURE_ENV+= ${_BLNK_WRAP_ENV.${_wrappee_}} @@ -761,6 +792,26 @@ ${_BLNK_LIBTOOL_FIX_LA}: ${.CURDIR}/../../mk/buildlink2/libtool-fix-la ${.ALLSRC} > ${.TARGET}.tmp ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET} +${_BLNK_FAKE_LA}: ${.CURDIR}/../../mk/buildlink2/fake-la + ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H} + ${_PKG_SILENT}${_PKG_DEBUG}${SED} \ + -e "s|@BUILDLINK_DIR@|${BUILDLINK_DIR}|g" \ + -e "s|@BUILDLINK_SHELL@|${BUILDLINK_SHELL}|g" \ + -e "s|@BASENAME@|${BASENAME:Q}|g" \ + -e "s|@CC@|${BUILDLINK_CC:Q}|g" \ + -e "s|@CP@|${CP:Q}|g" \ + -e "s|@DIRNAME@|${DIRNAME:Q}|g" \ + -e "s|@ECHO@|${ECHO:Q}|g" \ + -e "s|@EGREP@|${EGREP:Q}|g" \ + -e "s|@LIBTOOL@|${BUILDLINK_LIBTOOL:Q}|g" \ + -e "s|@MKDIR@|${MKDIR:Q}|g" \ + -e "s|@MV@|${MV:Q}|g" \ + -e "s|@RM@|${RM:Q}|g" \ + -e "s|@SED@|${SED:Q}|g" \ + ${.ALLSRC} > ${.TARGET}.tmp + ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}.tmp + ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET} + clear-buildlink-cache: remove-buildlink-cache buildlink-wrappers remove-buildlink-cache: diff --git a/mk/buildlink2/fake-la b/mk/buildlink2/fake-la new file mode 100644 index 00000000000..da40f702f3b --- /dev/null +++ b/mk/buildlink2/fake-la @@ -0,0 +1,40 @@ +#!@BUILDLINK_SHELL@ +# +# $NetBSD: fake-la,v 1.1 2002/09/18 00:46:59 jlam Exp $ + +BASENAME="@BASENAME@" +CC="@CC@" +CP="@CP@" +DIRNAME="@DIRNAME@" +ECHO="@ECHO@" +LIBTOOL="@LIBTOOL@ --quiet" +MKDIR="@MKDIR@" +MV="@MV@" +RM="@RM@" +SED="@SED@" + +BUILDLINK_DIR="@BUILDLINK_DIR@" + +reallib="$1" +realdir=`${DIRNAME} $reallib` +libname=`${BASENAME} $reallib` +tmpdir=${BUILDLINK_DIR}/.tmp + +if [ ! -f $tmpdir/inst/$libbase.la ]; then + case $libname in + *.so.[0-9]*) + libbase=`${ECHO} $libname | ${SED} -e "s/\.so\.[0-9.]*$//"` + version=`${ECHO} $libname | ${SED} -e "s/.*\.so\.//;s/\./:/g"` + ;; + + *[0-9].dylib) + libbase=`${ECHO} $libname | ${SED} -e "s/\.[0-9.]*\.dylib$//"` + version=`${ECHO} $libname | ${SED} -e "s/^[^.]*\.\([0-9]*\.[0-9]*\)\.dylib/\1/;s/\./:/g"` + ;; + esac + ${MKDIR} $tmpdir/inst + cd $tmpdir + ${LIBTOOL} ${CC} -o $libbase.la -rpath $tmpdir/inst -version-info $version + ${LIBTOOL} --mode=install ${CP} $libbase.la $tmpdir/inst >/dev/null +fi +${SED} -e "s,$tmpdir/inst,$realdir,g" $tmpdir/inst/$libbase.la diff --git a/mk/buildlink2/post-cache b/mk/buildlink2/post-cache index 44b7ebaaea8..594c4739949 100644 --- a/mk/buildlink2/post-cache +++ b/mk/buildlink2/post-cache @@ -1,4 +1,4 @@ -# $NetBSD: post-cache,v 1.4 2002/09/07 07:33:15 jlam Exp $ +# $NetBSD: post-cache,v 1.5 2002/09/18 00:46:59 jlam Exp $ *) case $arg in @@ -42,7 +42,7 @@ ;; esac ;; - -[ILRl]*|-Wl,*|@LOCALBASE@/*/lib*|@X11BASE@/*/lib*) + -[ILRl]*|-Wl,*|/usr/lib/lib*|@LOCALBASE@/*/lib*|@X11BASE@/*/lib*) newarg=`@ECHO@ "X$arg" | $Xsed \ @_BLNK_TRANSFORM_SED.1@ \ @_BLNK_TRANSFORM_SED.2@ \ -- cgit v1.2.3