1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/dietlibc/dietlibc.conf
3 # Copyright (C) 2004 - 2021 The T2 SDE Project
4 # Copyright (C) 1998 - 2004 ROCK Linux Project
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 dietlibc_initial_fixup() {
14 sed -i /WANT_SYSENTER/d dietfeatures.h
15 #sed -i "s,(CROSS)strip,(STRIP),g" Makefile
16 #sed -i "s,(CROSS)ar,(AR),g" Makefile
17 #sed -i "s,(CROSS)ld,(LD),g" Makefile
19 case "$arch_machine" in
20 powerpc) ln -vs bin-ppc bin-powerpc ;;
21 powerpc64) ln -vs bin-ppc64 bin-powerpc64 ;;
24 if atstage cross || [ "$toolsdir" == tools.cross ]; then
25 mkdir -p bin-$cpu bin-native
26 ln -s bin-$cpu "bin-${CC%%-*}"
30 dietlibc_make_wrappers() {
31 rm -rf $toolsbin; mkdir -p $toolsbin
32 for x in gcc as ld ar ranlib nm; do # wrapper
33 cat <<-EOT > $toolsbin/${arch_target}-$x
35 #PATH=\${PATH/\$(dirname \$( type -p \$0 ))/}; PATH=\${PATH/::/:}
36 exec $dietbin ${pkg_dietlibc_orig_target}-$x "\$@"
38 chmod +x $toolsbin/${arch_target}-$x
42 dietlibc_install_toolscross() {
43 local diet=bin-$1/diet
44 cp -v $diet-i $toolsbin/diet
45 [ ! -f $diet-dyn-i ] ||
46 cp -v $diet-dyn-i $toolsbin/diet-dyn
49 dietlibc_build_nativewrapper() {
50 local DOPTCOMMON="-Os -DVERSION=\"$ver\" $dietfeatures"
51 local DOPT="$DOPTCOMMON -DDIETHOME=\"$PWD\""
52 local DOPTI="$DOPTCOMMON -DDIETHOME=\"/$prefix\" -DINSTALLVERSION"
54 patch -p1 < $confdir/hostlibc.diff
55 $HOSTCC $DOPT diet.c -o bin-native/diet
56 $HOSTCC $DOPT diet.c -o bin-native/diet-dyn -D__DYN_LIB
57 $HOSTCC $DOPTI diet.c -o bin-native/diet-i
58 $HOSTCC $DOPTI diet.c -o bin-native/diet-dyn-i -D__DYN_LIB
59 patch -Rp1 < $confdir/hostlibc.diff
62 dietlibc_final_fixup() {
63 for x in ppc ppc64 parisc; do
64 local trg=${x/ppc/powerpc}
66 if [ -d $root$libdir-$x ]; then
67 rm -f $root$libdir-$trg
68 ln -sfnv lib-$x $root$libdir-$trg
78 if [ "$SDECFG_LIBC" = "dietlibc" ]; then
79 includedir=/usr/include
82 var_append makeopt ' ' prefix=/$prefix
83 var_append makeinstopt ' ' prefix=/$prefix
84 var_append makeopt ' ' LIBDIR=$libdir
85 var_append makeinstopt ' ' LIBDIR=$libdir
86 var_append makeinstopt ' ' BINDIR=$bindir
87 var_append makeinstopt ' ' MAN1DIR=$mandir/man1
89 cpu="`echo $arch | arch2uname | sed -e 's/sh.$/sh/; s/hppa/parisc/'`"
90 hostcpu="native" # `/bin/uname -m | uname2arch | arch2uname`"
92 var_append makeopt ' ' OBJDIR=bin-$cpu
93 var_append makeinstopt ' ' OBJDIR=bin-$cpu
94 var_append makeinstopt ' ' ILIBDIR=$libdir-$cpu
96 [ "$SDECFG_X8664_X32" = 1 ] && cpu=x32
98 toolsbin=$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/diet-bin
100 if [ "$SDECFG_DIETLIBC_DYN" = 1 ]; then
103 var_append makeopt " " "dyn"
108 # dietlibc contains non Thumb aware assembly ...
109 var_remove GCC_WRAPPER_INSERT " " "-mthumb"
112 dietfeatures='-DWANT_MALLOC_ZERO'
113 [[ $arch != hppa* ]] && var_append dietfeatures ' ' '-DWANT_DYNAMIC'
114 [ "$SDECFG_DIETWANT_SYSENTER" = "1" ] &&
115 var_append dietfeatures ' ' '-DWANT_SYSENTER'
116 var_append GCC_WRAPPER_APPEND ' ' "$dietfeatures"
118 if atstage toolchain; then
121 hook_add postmake 4 'mkdir -p $base/build/${SDECFG_ID}${includedir}/'
122 hook_add postmake 4 'find . -name "*.orig" | xargs rm -vf'
123 hook_add postmake 5 'cp -rv include/* $base/build/${SDECFG_ID}${includedir}/'
125 var_append makeopt ' ' all
126 var_append makeinstopt ' ' '-j1' # no parallel install
128 hook_add postpatch 5 'dietlibc_initial_fixup'
129 [ $toolsdir != tools.cross ] ||
130 hook_add premake 5 'dietlibc_make_wrappers'
132 if atstage cross || [ "$toolsdir" == tools.cross ]; then
133 # first build a native diet wrapper
134 hook_add premake 7 "dietlibc_build_nativewrapper"
135 hook_add premake 8 "dietlibc_install_toolscross native" # $hostcpu
137 hook_add postmake 9 'dietlibc_final_fixup'
140 [[ $archprefix == mipsel* ]] && dietarch='mipsel'
142 if atstage native; then
143 # dietlibc uses uname - so we always need to set MYARCH
144 var_append makeopt ' ' "MYARCH=$dietarch"
145 var_append makeinstopt ' ' "MYARCH=$dietarch"
147 var_append makeopt ' ' "CROSS=$archprefix CC=cc"
148 var_append makeopt ' ' "MYARCH=$hostcpu"
149 var_append makeopt ' ' "ARCH=$dietarch"
150 var_append makeinstopt ' ' "MYARCH=$hostcpu"
151 var_append makeinstopt ' ' "ARCH=$dietarch"