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.

259 lines
8.3 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../linux24/linux-conf.in
  5. # Copyright (C) 2006 The OpenSDE Project
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. # Copyright (C) 1998 - 2003 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. treever=${pkg/linux/} ; treever=${treever/-*/}
  17. [ "$lx_cpu" ] ||
  18. # powerpc and mips share the same arch for 32/64, maybe more follow
  19. lx_cpu=`echo $arch | arch2uname | sed -e s/ppc.*/powerpc/ -e s/mips64/mips/`
  20. lx_extraversion=""
  21. lx_kernelrelease=""
  22. lx_customconf="\$base/config/$config/linux.cfg"
  23. # inject a possible pre-/ post-release patch
  24. # we filter out .tar`s to avoid trouble with the linuxsh kernel drop-in trees
  25. var_insert patchfiles " " "`match_source_file patch-.* | grep -v '\.tar\.'`"
  26. #makeopt=`echo $makeopt | sed -n 's/.*\(-j[^ ]*\).*/\1/p'`
  27. makeopt=""
  28. # we need +1 to really saturate the CPUs during the kernel build
  29. [ $SDECFG_PARALLEL_MAX -gt 1 ] &&
  30. var_append makeopt ' ' -j$(( $SDECFG_PARALLEL_MAX + 1 ))
  31. var_append makeopt ' ' "ARCH=$lx_cpu CROSS_COMPILE=$archprefix KCC=$KCC"
  32. makeinstopt="$makeopt"
  33. auto_config ()
  34. {
  35. if [ -f $base/architecture/$arch/kernel$treever.conf.sh ] ; then
  36. echo " using: architecture/$arch/kernel$treever.conf.sh"
  37. . $base/architecture/$arch/kernel$treever.conf.sh > .config
  38. elif [ -f $base/architecture/$arch/kernel$treever.conf.m4 ] ; then
  39. echo " using: architecture/$arch/kernel$treever.conf.m4"
  40. m4 -I $base/architecture/$arch -I $base/architecture/share \
  41. $base/architecture/$arch/kernel$treever.conf.m4 > .config
  42. elif [ -f $base/architecture/$arch/kernel$treever.conf ] ; then
  43. echo " using: architecture/$arch/kernel$treever.conf"
  44. cp $base/architecture/$arch/kernel$treever.conf .config
  45. elif [ -f $base/architecture/$arch/kernel.conf.sh ] ; then
  46. echo " using: architecture/$arch/kernel.conf.sh"
  47. . $base/architecture/$arch/kernel.conf.sh > .config
  48. elif [ -f $base/architecture/$arch/kernel.conf.m4 ] ; then
  49. echo " using: architecture/$arch/kernel.conf.m4"
  50. m4 -I $base/architecture/$arch -I $base/architecture/share \
  51. $base/architecture/$arch/kernel.conf.m4 > .config
  52. elif [ -f $base/architecture/$arch/kernel.conf ] ; then
  53. echo " using: architecture/$arch/kernel.conf"
  54. cp $base/architecture/$arch/kernel.conf .config
  55. else
  56. echo " using: no SDE kernel config found"
  57. cp arch/$lx_cpu/defconfig .config
  58. fi
  59. cp .config{,.1}
  60. # all modules needs to be first so modules can be disabled by i.e.
  61. # the targets later
  62. echo "Enabling all modules ..."
  63. yes '' | eval $MAKE $makeopt no2modconfig > /dev/null ; cp .config{,.2}
  64. if [ -f $base/target/$target/kernel$treever.conf.sh ] ; then
  65. confscripts="$base/target/$target/kernel$treever.conf.sh $confscripts"
  66. elif [ -f $base/target/$target/kernel.conf.sh ] ; then
  67. confscripts="$base/target/$target/kernel.conf.sh $confscripts"
  68. fi
  69. for x in $confscripts ; do
  70. echo " running: $x"
  71. sh $x .config
  72. done
  73. cp .config{,.3}
  74. # merge various text/plain config files
  75. for x in $base/config/$config/linux.cfg \
  76. $base/target/$target/kernel${treever}.conf \
  77. $base/target/$target/kernel.conf ; do
  78. if [ -f $x ] ; then
  79. echo " merging: '$x'"
  80. tag="$(sed '/CONFIG_/ ! d; s,.*CONFIG_\([^ =]*\).*,\1,' \
  81. $x | tr '\n' '|')"
  82. egrep -v "\bCONFIG_($tag)\b" < .config > .config.4
  83. sed 's,\(CONFIG_.*\)=n,# \1 is not set,' \
  84. $x >> .config.4
  85. cp .config{.4,}
  86. fi
  87. done
  88. # create a valid .config
  89. yes '' | eval $MAKE $makeopt oldconfig > /dev/null ; cp .config{,.5}
  90. # last disable broken stuff
  91. rm -f /tmp/$$.sed
  92. list="CONFIG_THIS_DOES_NOT_EXIST"
  93. for x in $pkg_linux_brokenfiles ; do
  94. if [ -f "$x" ] ; then
  95. echo "Disable broken file: $x"
  96. list="$list `tr ' ' '\t' < $x | cut -f1 | grep '^CONFIG_'`"
  97. fi
  98. done
  99. for x in $list ; do
  100. echo "s,^$x=.\$,# $x is not set,;" >> /tmp/$$.sed
  101. done
  102. sed -f /tmp/$$.sed < .config > .config.6
  103. cp .config{.6,} ; rm -f /tmp/$$.sed
  104. # create a valid .config (dependencies might need to be disabled)
  105. yes '' | eval $MAKE $makeopt oldconfig > /dev/null
  106. # save final config
  107. cp .config{,_modules}
  108. echo "Creating config without modules ...."
  109. sed "s,\(CONFIG_.*\)=m,# \1 is not set," .config > .config_new
  110. mv .config_new .config
  111. # create a valid .config (dependencies might need to be disabled)
  112. yes '' | eval $MAKE $makeopt oldconfig > /dev/null
  113. mv .config .config_nomods
  114. # which .config to use?
  115. if [ "$SDECFG_PKG_LINUX_CONFIG_STYLE" = "modules" ] ; then
  116. cp .config{_modules,}
  117. else
  118. cp .config{_nomods,}
  119. fi
  120. }
  121. lx_grabextraversion () {
  122. local ev
  123. ev=$( sed -n -e 's,^[ \t]*EXTRAVERSION[ \t]*=[ \t]*\([^ \t]*\),\1,p' Makefile | tail -n 1 )
  124. if [ "$ev" ]; then
  125. lx_extraversion="${lx_extraversion}${ev}"
  126. # keep intact but commented since the second EXTRAVERSION
  127. # definition, and clean the first.
  128. sed -i -e 's,^\([ \t]*EXTRAVERSION[ \t]*=.*\),#\1,g' \
  129. -e 's,^#\(EXTRAVERSION =\).*,\1,' Makefile
  130. fi
  131. }
  132. lx_injectextraversion () {
  133. local version_header=linux/version.h
  134. local rerun=
  135. if [ -f include/linux/utsrelease.h ]; then
  136. version_header=linux/utsrelease.h
  137. fi
  138. # inject final EXTRAVERSION into Makefile
  139. sed -i -e "s,^\([ \t]*EXTRAVERSION[ \t]*\)=.*,\1= ${lx_extraversion},g" Makefile
  140. # update version.h - we only do this, because some other freaky
  141. # projects like rsbac change EXTRAVERSION in other Makefiles ...
  142. eval $MAKE $makeopt include/$version_header | grep -q "is up to date" && rerun=1
  143. if [ "$rerun" ] ; then
  144. echo "WARNING: Your system's timer resolution is too low ..."
  145. sleep 1 ; touch Makefile
  146. eval $MAKE $makeopt include/$version_header
  147. fi
  148. # get kernel_release
  149. rerun=1
  150. while true; do
  151. lx_kernelrelease="$( echo -e "#include <$version_header>\nUTS_RELEASE" |
  152. gcc -E -I./include - | tail -n 1 | cut -d '"' -f 2 )"
  153. if [ -z "$lx_kernelrelease" -a "$rerun" ]; then
  154. $MAKE $makeopt .kernelrelease include/$version_header
  155. rerun= ; continue
  156. fi
  157. break
  158. done
  159. [ $lx_kernelrelease ] || abort "Could not grab final kernel version!"
  160. }
  161. lx_filter_patch ()
  162. {
  163. pref=`sed -n '/^-EXTRAVERSION =/ {
  164. s/^-EXTRAVERSION =//p
  165. q }' $1`
  166. sed -e "s/^-EXTRAVERSION =.*/-EXTRAVERSION =/" \
  167. -e "s/^+EXTRAVERSION = *$pref/+EXTRAVERSION = /" $1
  168. }
  169. lx_patch ()
  170. {
  171. echo "Generic linux patching ..."
  172. # grab extraversion from vanilla
  173. lx_grabextraversion
  174. hook_eval prepatch
  175. apply_patchfiles lx_grabextraversion lx_filter_patch
  176. hook_eval postpatch
  177. # some arches (sh64 at the time of writing) have a "defect" Makefile
  178. # and do not work without a .config ...
  179. touch .config
  180. echo "Redefining VERSION ..."
  181. lx_extraversion="${lx_extraversion}-dist"
  182. lx_injectextraversion
  183. echo "... linux source patching for ${lx_extraversion} finished."
  184. echo "Correcting user and permissions ..."
  185. chown -R root:root . ; chmod -R u=rwX,go=rX .
  186. if [[ $treever = 24* ]] ; then
  187. echo "Create symlinks and a few headers for <$lx_cpu> ... "
  188. eval $MAKE $makeopt symlinks
  189. cp $base/package/base/linux24/autoconf.h include/linux/
  190. touch include/linux/modversions.h
  191. elif [ "$lx_kernelrelease" != "UTS_RELEASE" ]; then
  192. echo "Create symlinks and a few headers for <$lx_cpu> ... "
  193. eval $MAKE $makeopt include/asm
  194. fi
  195. echo "Clean up the *.orig and *~ files ... "
  196. rm -f .config.old
  197. find -name '*.orig' -o -name '*~' | xargs rm -f
  198. }
  199. lx_config() {
  200. echo "Generic linux configuration ..."
  201. hook_eval preconf
  202. if [ "$SDECFG_PKG_LINUX_CONFIG_STYLE" = none ] ; then
  203. echo "Using $lx_customconf."
  204. echo "Since automatic generation is disabled ..."
  205. eval cp -v $lx_customconf .config || true
  206. else
  207. echo "Automatically creating default configuration ...."
  208. auto_config
  209. fi
  210. if [ "$lx_kernelrelease" == "UTS_RELEASE" ]; then
  211. # we have to run make prepare
  212. eval $MAKE $makeopt prepare
  213. fi
  214. # regrab the version
  215. lx_injectextraversion
  216. [ "$lx_kernelrelease" != "UTS_RELEASE" ] ||
  217. abort "Unable to detect kernel release version!"
  218. echo "... configuration of $lx_kernelrelease finished!"
  219. }
  220. pkg_linux_brokenfiles="$base/architecture/$arch/kernel$treever-disable.lst \
  221. $base/package/*/linux$treever/disable-broken.lst \
  222. $pkg_linux_brokenfiles"