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.

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