From 9af6d345181c2de0b7133cd800fa4597b7045273 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 3 Sep 2004 14:25:00 +0000 Subject: [PATCH] Clifford Wolf: Added $autoso2a, a mechanism to automatically create a *.a file whenever a *.so file is created. Enabled it for alsa and xfree86 (more to come) [2004082419062801673] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@3992 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- Documentation/Developers/PKG-BUILD-VARS | 1 + misc/tools-source/so2a_wrapper.sh | 63 +++++++++++++++++++++++++ package/base/alsa/alsa.conf | 3 ++ package/x11/xfree86/xfree86.conf | 3 ++ scripts/Build-Pkg | 33 +++++++++++-- scripts/Build-Tools | 4 ++ 6 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 misc/tools-source/so2a_wrapper.sh diff --git a/Documentation/Developers/PKG-BUILD-VARS b/Documentation/Developers/PKG-BUILD-VARS index bc4180ce2..c8725ae18 100644 --- a/Documentation/Developers/PKG-BUILD-VARS +++ b/Documentation/Developers/PKG-BUILD-VARS @@ -66,6 +66,7 @@ taropt ........ tar options for extracting createprefix .. '0' = skip creation for directory skeleton for $prefix createdocs .... '0' = skip automatic copying of documentation files +autoso2a ...... '1' = automatically create *.a files for all *.so files custmain ...... command to execute instead of 'configure, make, make install' mainfunction .. alternate main function instead of build_this_package() diff --git a/misc/tools-source/so2a_wrapper.sh b/misc/tools-source/so2a_wrapper.sh new file mode 100644 index 000000000..5c00b34db --- /dev/null +++ b/misc/tools-source/so2a_wrapper.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# run the original command +"$@"; rc=$? + +if [ -n "$AUTOSO2A_DIR" ] && \ + [[ "$*" == *" -shared "* ]] +then + mkdir -p "$AUTOSO2A_DIR" + { + echo "--"; echo "$0 $*"; shift + arname="a.out"; objs=""; del="" + + while [ "$#" -gt 0 ] + do + case "$1" in + -o) + arname="${2##*/}"; shift + ;; + [^-]*.o|[^-]*.lo) + if [ -f $1 ]; then + echo "Add object: $1" + objs="$objs $1" + else + echo "$0: Don't know how to handle $1 .." >&2 + echo "Don't know how to handle $1 .." + fi + ;; + [^-]*.a|[^-]*.al) + if [ -f $1 ]; then + echo "Add archive: $1" + tmpdir=$( mktemp -d ); del="$del $tmpdir" + ( cd $tmpdir; ar x /dev/fd/0; ) < $1 + for x in $tmpdir/*; do + [ -f $x ] || continue + echo " - $x"; objs="$objs $x" + done + else + echo "$0: Don't know how to handle $1 .." >&2 + echo "Don't know how to handle $1 .." + fi + ;; + [^-]*) + echo "$0: Don't know how to handle $1 .." >&2 + echo "Don't know how to handle $1 .." + ;; + esac + shift + done + + [[ "$arname" == *.so* ]] && arname="${arname%.so*}.a" + echo "Output file: $arname" + + rm -f "$AUTOSO2A_DIR/$arname" + if ! $AUTOSO2A_AR q "$AUTOSO2A_DIR/$arname" $objs 2>&1; then + echo "$0: Got an error while running $AUTOSO2A_AR .." >&2 + fi + $AUTOSO2A_RANLIB "$AUTOSO2A_DIR/$arname" + } >> "$AUTOSO2A_DIR/so2a_wrapper.log" +fi + +exit $rc + diff --git a/package/base/alsa/alsa.conf b/package/base/alsa/alsa.conf index 54c63589b..af95cf9ba 100644 --- a/package/base/alsa/alsa.conf +++ b/package/base/alsa/alsa.conf @@ -79,3 +79,6 @@ EOT autoextract=0 custmain="pkg_alsa_main" +# auto-create missing *.a files +autoso2a=1 + diff --git a/package/x11/xfree86/xfree86.conf b/package/x11/xfree86/xfree86.conf index cb797a43c..31244dd6d 100644 --- a/package/x11/xfree86/xfree86.conf +++ b/package/x11/xfree86/xfree86.conf @@ -88,3 +88,6 @@ fi # don't put the modules in a :dev package splitreg 45 . '/lib/modules/' +# auto-create missing *.a files +autoso2a=1 + diff --git a/scripts/Build-Pkg b/scripts/Build-Pkg index 52a9c5804..17cea8ba2 100755 --- a/scripts/Build-Pkg +++ b/scripts/Build-Pkg @@ -525,7 +525,7 @@ taropt="--use-compress-program=bzip2 -xf" mainfunction="build_this_package" runconf=1 ; runxmkmf=1 ; runmkpl=1 ; runpysetup=1 ; autopatch=1 autoextract=1 ; chownsrcdir=1 ; nocvsinsrcdir=1; patchopt="-bfp1 -z .orig" -createprefix=1 ; createdocs="" ; rmemptydir="" +createprefix=1 ; createdocs="" ; rmemptydir="" ; autoso2a=0 check_shared=1 check_usrlocal=1 @@ -692,6 +692,13 @@ elif [ "$ROCKCFG_FLIST" = "find" ] ; then sleep 2 fi +if [ $stagelevel -gt 1 -a "$autoso2a" = 1 ]; then + export AUTOSO2A_DIR="$builddir/autoso2a" + export AUTOSO2A_AR="$AR" AUTOSO2A_RANLIB="$RANLIB" + var_insert CC_WRAPPER_OTHERS ":" "so2a_wrapper" + var_insert CXX_WRAPPER_OTHERS ":" "so2a_wrapper" +fi + hook_eval prepare # define new abort function for errors while building @@ -843,13 +850,33 @@ abort() { then : ; fi fi + # evaluate flistdel (1/2) + egrep -v "^($flistdel|var/adm/.*)\$" $builddir/flist.txt | sort -u > $builddir/flist.txt.new + mv $builddir/flist.txt.new $builddir/flist.txt + + # copy over missing *.a files + if [ "$autoso2a" = 1 ]; then + echo "Checking for missing .a files ..." + while read d s; do + grep -q "/${s%.so}.a$" $builddir/flist.txt && continue + [ "$d" = "lib" ] && d="usr/lib" + if [ -f "$AUTOSO2A_DIR/${s%.so}.a" ]; then + echo "Installing automatically created $d/${s%.so}.a." + cp "$AUTOSO2A_DIR/${s%.so}.a" "$root/$d/${s%.so}.a" + add_flist "$root/$d/${s%.so}.a" + else + echo "Not found: $AUTOSO2A_DIR/${s%.so}.a" + fi + done < <( egrep '(^|/)lib/[^/]*\.so$' $builddir/flist.txt | sed 's,\(.*\)/,\1 ,' ) + fi + # merge flist of previous build for x in var/adm/flists/$xpkg var/adm/flists/$xpkg:*; do [ -f $x ] && cut -f2- -d' ' $x >> $builddir/flist.txt done - # evaluate flistdel - egrep -v "^($flistdel|var/adm/.*)\$" $builddir/flist.txt > $builddir/flist.txt.new + # evaluate flistdel (2/2) + egrep -v "^($flistdel|var/adm/.*)\$" $builddir/flist.txt | sort -u > $builddir/flist.txt.new mv $builddir/flist.txt.new $builddir/flist.txt hook_eval postflist diff --git a/scripts/Build-Tools b/scripts/Build-Tools index f3b20bf2d..051c0010a 100755 --- a/scripts/Build-Tools +++ b/scripts/Build-Tools @@ -238,6 +238,10 @@ EOT # Various small tools # + echo_status "Building $toolsdir/bin/so2a_wrapper." + cp misc/tools-source/so2a_wrapper.sh build/$ROCKCFG_ID/ROCK/$toolsdir/bin/so2a_wrapper + chmod +x build/$ROCKCFG_ID/ROCK/$toolsdir/bin/so2a_wrapper + # for x in getdu getfiles fl_wrparse fl_stparse descparser; do echo_status "Building $toolsdir/bin/$x." $BUILDCC -Wall -O2 misc/tools-source/$x.c \