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.

146 lines
4.2 KiB

# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# T2 SDE: package/.../dietlibc/dietlibc.conf
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2004 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.
# --- T2-COPYRIGHT-NOTE-END ---
var_insert patchfiles ' ' "$confdir/libm.patch.bz2"
dietlibc_initial_fixup() {
sed -i /WANT_SYSENTER/d dietfeatures.h
sed -i "s,(CROSS)strip,(STRIP),g" Makefile
sed -i "s,(CROSS)ar,(AR),g" Makefile
sed -i "s,(CROSS)ld,(LD),g" Makefile
case "$arch_machine" in
powerpc) ln -vs bin-ppc bin-powerpc ;;
powerpc64) ln -vs bin-ppc64 bin-powerpc64 ;;
esac
if atstage cross || [ "$toolsdir" == tools.cross ] ; then
mkdir -p bin-$cpu bin-$hostcpu
ln -s bin-$cpu "bin-${CC%%-*}"
fi
}
dietlibc_make_wrappers() {
rm -rf $toolsbin; mkdir -p $toolsbin
for x in gcc as ld ar ranlib nm ; do # wrapper
cat <<-EOT > $toolsbin/${arch_target}-$x
#!/bin/sh
#PATH=\${PATH/\$(dirname \$( type -p \$0 ))/}; PATH=\${PATH/::/:}
exec $dietbin ${pkg_dietlibc_orig_target}-$x "\$@"
EOT
chmod +x $toolsbin/${arch_target}-$x
done
}
dietlibc_install_toolscross() {
local diet=bin-$1/diet
cp -v $diet-i $toolsbin/diet
[ ! -f $diet-dyn-i ] ||
cp -v $diet-dyn-i $toolsbin/diet-dyn
}
dietlibc_build_nativewrapper() {
local DOPTCOMMON="-Os -DVERSION=\"$ver\" $dietfeatures"
local DOPT="$DOPTCOMMON -DDIETHOME=\"$PWD\""
local DOPTI="$DOPTCOMMON -DDIETHOME=\"$root/$prefix\" -DINSTALLVERSION"
patch -p1 < $confdir/hostlibc.diff
$HOSTCC $DOPT diet.c -o bin-$hostcpu/diet
$HOSTCC $DOPT diet.c -o bin-$hostcpu/diet-dyn -D__DYN_LIB
$HOSTCC $DOPTI diet.c -o bin-$hostcpu/diet-i
$HOSTCC $DOPTI diet.c -o bin-$hostcpu/diet-dyn-i -D__DYN_LIB
patch -Rp1 < $confdir/hostlibc.diff
}
dietlibc_final_fixup() {
for x in ppc ppc64; do
if [ -d $root/$libdir-$x ] ; then
rm -f $root/$libdir-${x/ppc/powerpc}
ln -sfnv lib-$x $root/$libdir-${x/ppc/powerpc}
fi
done
}
prefix=usr/dietlibc
set_confopt
bindir=/usr/bin
libdir=/$prefix/lib
if [ "$SDECFG_LIBC" = "dietlibc" ] ; then
includedir=/usr/include
fi
var_append makeopt ' ' prefix=/$prefix
var_append makeinstopt ' ' prefix=/$prefix
var_append makeopt ' ' LIBDIR=$libdir
var_append makeinstopt ' ' LIBDIR=$libdir
var_append makeinstopt ' ' BINDIR=$bindir
var_append makeinstopt ' ' MAN1DIR=$mandir/man1
cpu="`echo $arch | arch2uname | sed -e s/sh.$/sh/`"
hostcpu="`/bin/uname -m | uname2arch | arch2uname`"
toolsbin=$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/diet-bin
if [ "$SDECFG_DIETLIBC_DYN" = 1 ]; then
case $cpu in
arm|i386|x86_64)
var_append makeopt " " "dyn"
;;
esac
fi
# dietlibc contains non Thumb aware assembly ...
var_remove GCC_WRAPPER_INSERT " " "-mthumb"
# special features
dietfeatures='-DWANT_DYNAMIC -DWANT_MALLOC_ZERO'
[ "$SDECFG_DIETWANT_SYSENTER" = "1" ] &&
var_append dietfeatures ' ' '-DWANT_SYSENTER'
var_append GCC_WRAPPER_APPEND ' ' "$dietfeatures"
if atstage toolchain; then
makeopt=
makeinstopt=
hook_add postmake 4 'mkdir -p $base/build/${SDECFG_ID}${includedir}/'
hook_add postmake 5 'cp -rv include/* $base/build/${SDECFG_ID}${includedir}/'
else
hook_add postpatch 5 'dietlibc_initial_fixup'
[ $toolsdir != tools.cross ] ||
hook_add premake 5 'dietlibc_make_wrappers'
var_append makeopt ' ' all
if atstage cross || [ "$toolsdir" == tools.cross ]; then
# first build a native diet wrapper
hook_add premake 7 "dietlibc_build_nativewrapper"
hook_add premake 8 "dietlibc_install_toolscross $hostcpu"
fi
if atstage native; then
# dietlibc uses uname - so we always need to set MYARCH
var_append makeopt ' ' "MYARCH=$cpu"
var_append makeinstopt ' ' "MYARCH=$cpu"
else
var_append makeopt ' ' "CROSS=$archprefix CC=cc"
var_append makeopt ' ' "MYARCH=$hostcpu"
var_append makeopt ' ' "ARCH=$cpu"
var_append makeinstopt ' ' "MYARCH=$hostcpu"
var_append makeinstopt ' ' "ARCH=$cpu"
fi
hook_add postmake 9 'dietlibc_final_fixup'
fi