# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/dietlibc/dietlibc.conf # Copyright (C) 2004 - 2023 The T2 SDE Project # Copyright (C) 1998 - 2004 ROCK Linux Project # # This Copyright note is generated by scripts/Create-CopyPatch, # 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 version 2. # --- T2-COPYRIGHT-NOTE-END --- dietlibc_initial_fixup() { sed -i /WANT_SYSENTER/d dietfeatures.h case "$arch_machine" in powerpc) ln -vs bin-ppc bin-powerpc ;; powerpc64) ln -vs bin-ppc64 bin-powerpc64 ;; esac if atstage cross || [ "$toolsdir" == cross ]; then mkdir -p bin-$cpu bin-native 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 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=\"/$prefix\" -DINSTALLVERSION" patch -p1 < $confdir/hostlibc.diff $HOSTCC $DOPT diet.c -o bin-native/diet $HOSTCC $DOPT diet.c -o bin-native/diet-dyn -D__DYN_LIB $HOSTCC $DOPTI diet.c -o bin-native/diet-i $HOSTCC $DOPTI diet.c -o bin-native/diet-dyn-i -D__DYN_LIB patch -Rp1 < $confdir/hostlibc.diff } dietlibc_final_fixup() { for x in ppc ppc64 parisc; do local trg=${x/ppc/powerpc} trg=${x/parisc/hppa} if [ -d $root$libdir-$x ]; then rm -f $root$libdir-$trg ln -sfnv lib-$x $root$libdir-$trg 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/; s/hppa/parisc/'`" hostcpu="native" # `/bin/uname -m | uname2arch | arch2uname`" var_append makeopt ' ' OBJDIR=bin-$cpu var_append makeinstopt ' ' OBJDIR=bin-$cpu var_append makeinstopt ' ' ILIBDIR=$libdir-$cpu [ "$SDECFG_X8664_X32" = 1 ] && cpu=x32 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_MALLOC_ZERO' [[ $arch != hppa* ]] && var_append dietfeatures ' ' '-DWANT_DYNAMIC' [ "$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 4 'find . -name "*.orig" | xargs rm -vf' hook_add postmake 5 'cp -rv include/* $base/build/${SDECFG_ID}${includedir}/' else var_append makeopt ' ' all var_append makeinstopt ' ' '-j1' hook_add postpatch 5 'dietlibc_initial_fixup' [ $toolsdir != cross ] || hook_add premake 5 'dietlibc_make_wrappers' if atstage cross || [ "$toolsdir" == cross ]; then # first build a native diet wrapper hook_add premake 7 "dietlibc_build_nativewrapper" hook_add premake 8 "dietlibc_install_toolscross native" # $hostcpu fi hook_add postmake 9 'dietlibc_final_fixup' dietarch=$cpu [[ $archprefix == mipsel* ]] && dietarch='mipsel' if atstage native; then # dietlibc uses uname - so we always need to set MYARCH var_append makeopt ' ' "MYARCH=$dietarch" var_append makeinstopt ' ' "MYARCH=$dietarch" else var_append makeopt ' ' "CROSS=$archprefix CC=cc" var_append makeopt ' ' "MYARCH=$hostcpu" var_append makeopt ' ' "ARCH=$dietarch" var_append makeinstopt ' ' "MYARCH=$hostcpu" var_append makeinstopt ' ' "ARCH=$dietarch" fi fi