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.

167 lines
4.7 KiB

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