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.

286 lines
8.9 KiB

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