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.6 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 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. dietlibc_initial_fixup() {
  31. sed -i /WANT_SYSENTER/d dietfeatures.h
  32. sed -i "s,(CROSS)strip,(STRIP),g" Makefile
  33. sed -i "s,(CROSS)ar,(AR),g" Makefile
  34. sed -i "s,(CROSS)ld,(LD),g" Makefile
  35. case "$arch_machine" in
  36. powerpc) ln -vs bin-ppc bin-powerpc ;;
  37. powerpc64) ln -vs bin-ppc64 bin-powerpc64 ;;
  38. esac
  39. if atstage cross || [ "$toolsdir" == tools.cross ] ; then
  40. mkdir -p bin-$cpu bin-$hostcpu
  41. ln -s bin-$cpu "bin-${CC%%-*}"
  42. fi
  43. }
  44. dietlibc_install_headers() {
  45. find include/* -name '*.orig' -exec rm -v '{}' \;
  46. mkdir -p $base/build/${SDECFG_ID}${includedir}/
  47. cp -rv include/* $base/build/${SDECFG_ID}${includedir}/
  48. }
  49. dietlibc_make_wrappers() {
  50. rm -rf $toolsbin; mkdir -p $toolsbin
  51. for x in gcc as ld ar ranlib nm ; do # wrapper
  52. cat <<-EOT > $toolsbin/${arch_target}-$x
  53. #!/bin/sh
  54. #PATH=\${PATH/\$(dirname \$( type -p \$0 ))/}; PATH=\${PATH/::/:}
  55. exec $dietbin ${pkg_dietlibc_orig_target}-$x "\$@"
  56. EOT
  57. chmod +x $toolsbin/${arch_target}-$x
  58. done
  59. }
  60. dietlibc_install_toolscross() {
  61. local diet=bin-$1/diet
  62. cp -v $diet-i $toolsbin/diet
  63. [ ! -f $diet-dyn-i ] ||
  64. cp -v $diet-dyn-i $toolsbin/diet-dyn
  65. }
  66. dietlibc_build_nativewrapper() {
  67. local DOPTCOMMON="-Os -DVERSION=\"$ver\" $dietfeatures"
  68. local DOPT="$DOPTCOMMON -DDIETHOME=\"$PWD\""
  69. local DOPTI="$DOPTCOMMON -DDIETHOME=\"$root/$prefix\" -DINSTALLVERSION"
  70. patch -p1 < $confdir/hostlibc.diff
  71. $HOSTCC $DOPT diet.c -o bin-$hostcpu/diet
  72. $HOSTCC $DOPT diet.c -o bin-$hostcpu/diet-dyn -D__DYN_LIB
  73. $HOSTCC $DOPTI diet.c -o bin-$hostcpu/diet-i
  74. $HOSTCC $DOPTI diet.c -o bin-$hostcpu/diet-dyn-i -D__DYN_LIB
  75. patch -Rp1 < $confdir/hostlibc.diff
  76. }
  77. dietlibc_final_fixup() {
  78. for x in ppc ppc64; do
  79. if [ -d $root/$libdir-$x ] ; then
  80. rm -f $root/$libdir-${x/ppc/powerpc}
  81. ln -sfnv lib-$x $root/$libdir-${x/ppc/powerpc}
  82. fi
  83. done
  84. }
  85. prefix=usr/dietlibc
  86. set_confopt
  87. bindir=/usr/bin
  88. libdir=/$prefix/lib
  89. if [ "$SDECFG_LIBC" = "dietlibc" ] ; then
  90. includedir=/usr/include
  91. fi
  92. var_append makeopt ' ' prefix=/$prefix
  93. var_append makeinstopt ' ' prefix=/$prefix
  94. var_append makeopt ' ' LIBDIR=$libdir
  95. var_append makeinstopt ' ' LIBDIR=$libdir
  96. var_append makeinstopt ' ' BINDIR=$bindir
  97. var_append makeinstopt ' ' MAN1DIR=$mandir/man1
  98. cpu="`echo $arch | arch2uname | sed -e s/sh.$/sh/`"
  99. hostcpu="`/bin/uname -m | uname2arch | arch2uname`"
  100. toolsbin=$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/diet-bin
  101. if [ "$SDECFG_DIETLIBC_DYN" = 1 ]; then
  102. case $cpu in
  103. arm|i386|x86_64)
  104. var_append makeopt " " "dyn"
  105. ;;
  106. esac
  107. fi
  108. # dietlibc contains non Thumb aware assembly ...
  109. var_remove GCC_WRAPPER_INSERT " " "-mthumb"
  110. # special features
  111. dietfeatures='-DWANT_DYNAMIC -DWANT_MALLOC_ZERO'
  112. [ "$SDECFG_DIETWANT_SYSENTER" = "1" ] &&
  113. var_append dietfeatures ' ' '-DWANT_SYSENTER'
  114. var_append GCC_WRAPPER_APPEND ' ' "$dietfeatures"
  115. if atstage toolchain; then
  116. makeopt=
  117. makeinstopt=
  118. hook_add postmake 5 'dietlibc_install_headers'
  119. else
  120. hook_add postpatch 5 'dietlibc_initial_fixup'
  121. [ $toolsdir != tools.cross ] ||
  122. hook_add premake 5 'dietlibc_make_wrappers'
  123. var_append makeopt ' ' all
  124. if atstage cross || [ "$toolsdir" == tools.cross ]; then
  125. # first build a native diet wrapper
  126. hook_add premake 7 "dietlibc_build_nativewrapper"
  127. hook_add premake 8 "dietlibc_install_toolscross $hostcpu"
  128. fi
  129. if atstage native; then
  130. # dietlibc uses uname - so we always need to set MYARCH
  131. var_append makeopt ' ' "MYARCH=$cpu"
  132. var_append makeinstopt ' ' "MYARCH=$cpu"
  133. else
  134. var_append makeopt ' ' "CROSS=$archprefix CC=cc"
  135. var_append makeopt ' ' "MYARCH=$hostcpu"
  136. var_append makeopt ' ' "ARCH=$cpu"
  137. var_append makeinstopt ' ' "MYARCH=$hostcpu"
  138. var_append makeinstopt ' ' "ARCH=$cpu"
  139. fi
  140. hook_add postmake 9 'dietlibc_final_fixup'
  141. fi