OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

339 lines
12 KiB

#!/bin/bash
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: scripts/Build-Tools
# Copyright (C) 2006 - 2007 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
config=default
stagelevel=9
cleanup=0
while [ "$1" ] ; do
case "$1" in
-cleanup) cleanup=1 ; shift ;;
-cfg) config=$2 ; shift ; shift ;;
-[0-9]) options="$options $1" ; stagelevel=${1#-} ; shift ;;
*) echo "Usage: $0 [ -cfg config ] [ -0 | -9 ] \\"
echo " ${0//?/ } [ -cleanup ]" ; exit 1 ;;
esac
done
. lib/functions.in
. lib/parse-config
var_remove PATH ":" $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin
var_remove PATH ":" $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper
mkdir -p tmp
mkdir -p build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin
mkdir -p build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper
mkdir -p build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib
if [ $toolsdir = tools.cross ]; then
mkdir -p build/$SDECFG_ID/TOOLCHAIN/$toolsdir/{var/adm,etc,share,include}
[ -L build/$SDECFG_ID/TOOLCHAIN/$toolsdir/usr ] ||
ln -s . build/$SDECFG_ID/TOOLCHAIN/$toolsdir/usr
[ -L build/$SDECFG_ID/TOOLCHAIN/$toolsdir/sbin ] ||
ln -s bin build/$SDECFG_ID/TOOLCHAIN/$toolsdir/sbin
[ -L build/$SDECFG_ID/TOOLCHAIN/$toolsdir/var/adm/logs ] ||
ln -s ../../../../var/adm/logs \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/var/adm/logs
mkdir -p build/$SDECFG_ID/var/adm/logs
fi
x="$( bash scripts/xfind.sh config/$config/. package/. scripts/. \
misc/. lib/. architecture/. target/. \( ! -name '*.cache' ! \
-name '*.patch*' ! -name '.*' ! -name 'svn-commit.tmp' \
\( \! -name '*.conf' -o -name 'pkg*.conf' \) \) -a -type f \
-newer build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate \
-printf 'Found new/updated file: %p\n' 2> /dev/null )"
if [ "$x" ] ; then
echo_header Found $( echo "$x" | wc -l ) new/updated \
files in source tree:
echo "$x" | head -n 3 | sed 's,/\./,/,g' |
while read y ; do echo_status $y ; done
[ "$( echo "$x" | tail -n +4 )" ] &&
echo_status "** list truncated to save space on the terminal **"
if [ "$SDEDEBUG_TOOLS_SKIP" = 1 ]; then
echo_error "Found \$SDEDEBUG_TOOLS_SKIP ..."
else
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate
if echo "$x" | grep -qv " config/$config/" ; then
echo_header Re-running configuration:
while read -r line ; do
echo_status "$line"
done < <( ./scripts/Config -cfg $config -oldconfig )
fi
fi
fi
if [ $cleanup = 1 ] ; then
echo_header "Removing old stuff in $toolsdir/ directory ..."
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/*
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin/getdu
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin/getfiles
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin/fl_wrparse
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin/fl_stparse
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/fl_wrapper.so
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config-fixarch
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate
fi
if [ ! -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate ] ; then
echo_header "Building tools in build/.../TOOLCHAIN/$toolsdir:"
# CC, CXX, F77 and KCC Wrapper
#
wrappers="cmd_wrapper" ; wrappervars=""
echo_status "Building $toolsdir/wrapper/cmd_wrapper."
$BUILDCC -Wall -O2 src/tools-source/cmd_wrapper.c \
-DENVPREFIX='"CMD"' -DMYNAME='"cmd_wrapper"' \
-o build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/tmp.$$ || exit 1
mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/tmp.$$ \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/cmd_wrapper
#
build_wrapper() {
local x="$( echo ${1//,/ } )" y z
wrappervars="$wrappervars $x"
while shift ; [ $# != 0 ]
do
wrappers="$wrappers $1"
tmp=`mktemp -p build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper`
{
echo '#!/bin/bash'
for y in $x ; do
echo -n "[ \"\$${y}_WRAPPER_DEBUG\" = 1 ] && "
echo "export CMD_WRAPPER_DEBUG=1"
done
for y in $x ; do
echo -n "[ \"\$${y}_WRAPPER_BYPASS\" = 1 ] && "
echo "export CMD_WRAPPER_BYPASS=1"
done
z=""; echo -n 'export CMD_WRAPPER_APPEND_PO="'
for y in $x; do
echo -n "${z}\$${y}_WRAPPER_APPEND_PO"; z=" "
done ; echo '"'
z=""; echo -n 'export CMD_WRAPPER_OTHERS="'
for y in $x; do
echo -n "${z}\$${y}_WRAPPER_OTHERS"; z=":"
done ; echo '"'
z=""; echo -n 'export CMD_WRAPPER_INSERT="'
for y in $x; do
echo -n "${z}\$${y}_WRAPPER_INSERT"; z=" "
done ; echo '"'
z=""; echo -n 'export CMD_WRAPPER_REMOVE="'
for y in $x; do
echo -n "${z}\$${y}_WRAPPER_REMOVE"; z=" "
done ; echo '"'
z=""; echo -n 'export CMD_WRAPPER_APPEND="'
for y in $x; do
echo -n "${z}\$${y}_WRAPPER_APPEND"; z=" "
done ; echo '"'
z=""; echo -n 'export CMD_WRAPPER_FILTER="'
for y in $x; do
echo -n "${z}\$${y}_WRAPPER_FILTER"; z="|"
done ; echo '"'
echo 'exec cmd_wrapper $( basename $0 ) "$@"'
} > $tmp
chmod +rx $tmp
mv $tmp "build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/$1"
done
}
#
while read script ; do . $script
done < <( bash scripts/xfind.sh package/. \
$( get_reverted `get_expanded target/%/. $targetchain` ) misc/. -name 'wrappers.in' )
#
echo_status "Building $toolsdir/wrapper/strip_wrapper."
cat << EOT > build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/strip_wrapper.$$
#!/bin/sh
if [ "\$STRIP_WRAPPER_NOLOOP" = 1 ] ; then
echo "Aaaaaeik! Strip wrapper is looping!" >&2
exit 1
fi
if [ "\$SDECFG_DEBUG" = 0 ] ; then
PATH=\${PATH//\$STRIP_WRAPPER_MYPATH:/}
export STRIP_WRAPPER_NOLOOP=1
exec "\$( basename \$0 )" "\$@"
fi
exit 0
EOT
chmod +x build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/strip_wrapper.$$
mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/strip_wrapper.$$ \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/strip_wrapper
wrappers="$wrappers strip_wrapper"
#
for x in strip $arch_target-strip ; do
[ $crossnative = cross -a $x = strip ] && continue
if [ -x "`type -p $x`" ] ; then
ln -sf strip_wrapper \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/$x
wrappers="$wrappers $x"
fi
done
#
echo_status "Building $toolsdir/wrapper/{uname,arch}."
sed -e "s,@@ARCH_MACHINE@@,$arch_machine,g" \
src/tools-source/uname_wrapper.in.sh > build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/uname
sed -e "s,@@ARCH@@,$( echo $arch | arch2uname ),g" \
src/tools-source/arch_wrapper.in.sh > build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/arch
chmod +x build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/{uname,arch}
wrappers="$wrappers uname arch"
#
echo_status "Building $toolsdir/wrapper/install_wrapper."
cp src/tools-source/install_wrapper.sh build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/install_wrapper
chmod +x build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/install_wrapper
ln -sf install_wrapper build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/install
ln -sf install_wrapper build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/cp
ln -sf install_wrapper build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/ln
ln -sf install_wrapper build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/mv
wrappers="$wrappers install_wrapper install cp ln mv"
#
for x in $( ls build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/ )
do
z=0
for y in $wrappers ; do
[ "$x" = "$y" ] && z=1
done
if [ "$z" = 0 ] ; then
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper/$x
fi
done
# Various small tools
#
for x in getdu getfiles fl_wrparse fl_stparse ; do
echo_status "Building $toolsdir/bin/$x."
$BUILDCC -Wall -O2 src/tools-source/$x.c \
-o build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin/$x.$$ || exit 1
mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin/$x.$$ \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin/$x
done
# Flist Wrapper Library
#
if [ "$SDECFG_FLIST" = "flwrapper" ] ; then
echo_status "Building $toolsdir/lib/fl_wrapper.so."
FLWRAPPER_LIBC=$( ls $xroot/{lib64,lib}/libc.* 2>/dev/null |
head -n1 )
if [ ! -f "$FLWRAPPER_LIBC" ]; then
abort 'Unable to detect /lib/libc.* for flwrapper'
fi
if [ $stagelevel -lt 2 ]; then
FLWRAPPER_BASEDIR=-DFLWRAPPER_BASEDIR=\"$base\"
else
FLWRAPPER_BASEDIR=
fi
sh src/tools-source/fl_wrapper.c.sh > tmp/fl_wrapper_$$.c
$BUILDCC -O2 -shared -fPIC -Wall -ldl tmp/fl_wrapper_$$.c \
$FLWRAPPER_BASEDIR \
-DFLWRAPPER_LIBC=\"${FLWRAPPER_LIBC##*/}\" \
-o build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/fl_wrapper.so.$$ || exit 1
rm tmp/fl_wrapper_$$.c
mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/fl_wrapper.so.$$ \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/fl_wrapper.so
echo_status "Testing $toolsdir/lib/fl_wrapper.so."
if ! sh -c "LD_PRELOAD=\"\$LD_PRELOAD:build/\$SDECFG_ID/`
`TOOLCHAIN/$toolsdir/lib/fl_wrapper.so\" date ; `
`exit \$?" >/dev/null 2>&1
then
echo_error "Detected a problem with the flist" \
"wrapper lib on your system."
echo_error "Please specify another flist-creation" \
"system in your build configuration."
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/fl_wrapper.so
echo ; exit 1
fi
fi
# Create Parse-Config Collection
#
echo_status "Creating $toolsdir/lib/parse-config."
bash scripts/xfind.sh \
architecture/$arch/. package/. $( get_reverted `get_expanded target/%/. $targetchain` ) misc/ -type f \
'(' -name 'parse-config' -o -name 'parse-config-[0-9]' ')' \
-printf '%f\t%p\n' | sed \
-e 's,^parse-config\t,5\t,g' -e 's,^parse-config-\(.\)\t,\1\t,g' | \
sort -n | awk '{ $1="."; print; }' \
> build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config.$$
mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config.$$ \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config
bash scripts/xfind.sh \
architecture/$arch/. package/. $( get_reverted `get_expanded target/%/. $targetchain` ) misc/ -type f \
-name 'parse-config-fixarch' \
-printf '%f\t%p\n' | sort | awk '{ $1="."; print; }' \
> build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config-fixarch.$$
mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config-fixarch.$$ \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config-fixarch
# Create pkg_*_{pre,post}.conf files
#
echo_status "Creating $toolsdir/lib/pkg_*_{pre,post}.conf"
rm -f build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/pkg_*_{pre,post}.conf
for y in `echo architecture/$arch/pkg_*_{pre,post}.conf`; do
if [ -f $y ]; then
echo " . $y" >> build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/${y##*/}
fi
done
if [ $stagelevel -eq 9 ]; then
for x in /var/adm/packages/*; do
ls -1d package/*/${x##*/}/pkg_*_{pre,post}.conf 2> /dev/null
done
else
for x in `grep "^X" config/$config/packages | cut -d ' ' -f 4,5 | tr ' ' '/'`; do
ls -1d package/$x/pkg_*_{pre,post}.conf 2> /dev/null
done
fi | while read y; do
echo " . $y" >> build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/${y##*/}
done
echo -e "${wrappervars// /\n}" | grep . | sort -u |
while read x ; do
echo "export ${x}_WRAPPER_DEBUG=0 ${x}_WRAPPER_BYPASS=0"
echo "export ${x}_WRAPPER_OTHERS='' ${x}_WRAPPER_REMOVE=''"
echo "export ${x}_WRAPPER_INSERT='' ${x}_WRAPPER_APPEND=''"
echo "export ${x}_WRAPPER_FILTER='' ${x}_WRAPPER_APPEND_PO=''"
done > build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/wrapper-config.$$
mv build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/wrapper-config.$$ \
build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/wrapper-config
touch build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate
fi
exit 0