OpenSDE Packages Database (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.

145 lines
4.2 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../dietlibc/dietlibc.conf
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2004 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- T2-COPYRIGHT-NOTE-END ---
  15. var_insert patchfiles ' ' "$confdir/libm.patch.bz2"
  16. dietlibc_initial_fixup() {
  17. sed -i /WANT_SYSENTER/d dietfeatures.h
  18. sed -i "s,(CROSS)strip,(STRIP),g" Makefile
  19. sed -i "s,(CROSS)ar,(AR),g" Makefile
  20. sed -i "s,(CROSS)ld,(LD),g" Makefile
  21. case "$arch_machine" in
  22. powerpc) ln -vs bin-ppc bin-powerpc ;;
  23. powerpc64) ln -vs bin-ppc64 bin-powerpc64 ;;
  24. esac
  25. if atstage cross || [ "$toolsdir" == tools.cross ] ; then
  26. mkdir -p bin-$cpu bin-$hostcpu
  27. ln -s bin-$cpu "bin-${CC%%-*}"
  28. fi
  29. }
  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
  34. #!/bin/sh
  35. #PATH=\${PATH/\$(dirname \$( type -p \$0 ))/}; PATH=\${PATH/::/:}
  36. exec $dietbin ${pkg_dietlibc_orig_target}-$x "\$@"
  37. EOT
  38. chmod +x $toolsbin/${arch_target}-$x
  39. done
  40. }
  41. dietlibc_install_toolscross() {
  42. local diet=bin-$1/diet
  43. cp -v $diet-i $toolsbin/diet
  44. [ ! -f $diet-dyn-i ] ||
  45. cp -v $diet-dyn-i $toolsbin/diet-dyn
  46. }
  47. dietlibc_build_nativewrapper() {
  48. local DOPTCOMMON="-Os -DVERSION=\"$ver\" $dietfeatures"
  49. local DOPT="$DOPTCOMMON -DDIETHOME=\"$PWD\""
  50. local DOPTI="$DOPTCOMMON -DDIETHOME=\"$root/$prefix\" -DINSTALLVERSION"
  51. patch -p1 < $confdir/hostlibc.diff
  52. $HOSTCC $DOPT diet.c -o bin-$hostcpu/diet
  53. $HOSTCC $DOPT diet.c -o bin-$hostcpu/diet-dyn -D__DYN_LIB
  54. $HOSTCC $DOPTI diet.c -o bin-$hostcpu/diet-i
  55. $HOSTCC $DOPTI diet.c -o bin-$hostcpu/diet-dyn-i -D__DYN_LIB
  56. patch -Rp1 < $confdir/hostlibc.diff
  57. }
  58. dietlibc_final_fixup() {
  59. for x in ppc ppc64; do
  60. if [ -d $root/$libdir-$x ] ; then
  61. rm -f $root/$libdir-${x/ppc/powerpc}
  62. ln -sfnv lib-$x $root/$libdir-${x/ppc/powerpc}
  63. fi
  64. done
  65. }
  66. prefix=usr/dietlibc
  67. set_confopt
  68. bindir=/usr/bin
  69. libdir=/$prefix/lib
  70. if [ "$SDECFG_LIBC" = "dietlibc" ] ; then
  71. includedir=/usr/include
  72. fi
  73. var_append makeopt ' ' prefix=/$prefix
  74. var_append makeinstopt ' ' prefix=/$prefix
  75. var_append makeopt ' ' LIBDIR=$libdir
  76. var_append makeinstopt ' ' LIBDIR=$libdir
  77. var_append makeinstopt ' ' BINDIR=$bindir
  78. var_append makeinstopt ' ' MAN1DIR=$mandir/man1
  79. cpu="`echo $arch | arch2uname | sed -e s/sh.$/sh/`"
  80. hostcpu="`/bin/uname -m | uname2arch | arch2uname`"
  81. toolsbin=$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/diet-bin
  82. if [ "$SDECFG_DIETLIBC_DYN" = 1 ]; then
  83. case $cpu in
  84. arm|i386|x86_64)
  85. var_append makeopt " " "dyn"
  86. ;;
  87. esac
  88. fi
  89. # dietlibc contains non Thumb aware assembly ...
  90. var_remove GCC_WRAPPER_INSERT " " "-mthumb"
  91. # special features
  92. dietfeatures='-DWANT_DYNAMIC -DWANT_MALLOC_ZERO'
  93. [ "$SDECFG_DIETWANT_SYSENTER" = "1" ] &&
  94. var_append dietfeatures ' ' '-DWANT_SYSENTER'
  95. var_append GCC_WRAPPER_APPEND ' ' "$dietfeatures"
  96. if atstage toolchain; then
  97. makeopt=
  98. makeinstopt=
  99. hook_add postmake 4 'mkdir -p $base/build/${SDECFG_ID}${includedir}/'
  100. hook_add postmake 5 'cp -rv include/* $base/build/${SDECFG_ID}${includedir}/'
  101. else
  102. hook_add postpatch 5 'dietlibc_initial_fixup'
  103. [ $toolsdir != tools.cross ] ||
  104. hook_add premake 5 'dietlibc_make_wrappers'
  105. var_append makeopt ' ' all
  106. if atstage cross || [ "$toolsdir" == tools.cross ]; then
  107. # first build a native diet wrapper
  108. hook_add premake 7 "dietlibc_build_nativewrapper"
  109. hook_add premake 8 "dietlibc_install_toolscross $hostcpu"
  110. fi
  111. if atstage native; then
  112. # dietlibc uses uname - so we always need to set MYARCH
  113. var_append makeopt ' ' "MYARCH=$cpu"
  114. var_append makeinstopt ' ' "MYARCH=$cpu"
  115. else
  116. var_append makeopt ' ' "CROSS=$archprefix CC=cc"
  117. var_append makeopt ' ' "MYARCH=$hostcpu"
  118. var_append makeopt ' ' "ARCH=$cpu"
  119. var_append makeinstopt ' ' "MYARCH=$hostcpu"
  120. var_append makeinstopt ' ' "ARCH=$cpu"
  121. fi
  122. hook_add postmake 9 'dietlibc_final_fixup'
  123. fi