# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/linux/linux-conf.in # Copyright (C) 2004 - 2023 The T2 SDE Project # Copyright (C) 1998 - 2003 ROCK Linux Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2. # --- T2-COPYRIGHT-NOTE-END --- if [ ! "$lx_cpu" ]; then lx_cpu=`echo $arch | arch2uname | sed 's/mips64/mips/;s/bfin/blackfin/;s/aarch64/arm64/;s/hppa.*/parisc/;s/riscv64/riscv/;s/s390x/s390/'` # unifications since ~2.6 lx_cpu=`echo $lx_cpu | sed 's/i386/x86/;s/x86_64/x86/;s/ppc.*/powerpc/;s/loongarch64/loongarch/;s/sparc64/sparc/'` fi lx_extraversion="" lx_kernelrelease="" lx_customconf="\$base/config/$config/linux.cfg" # cleanups in this fat directory are a bit expensive nocvsinsrcdir=0 chownsrcdir=0 # inject a possible pre-/ post-release patch # we filter out .tar`s to avoid trouble with the linuxsh kernel drop-in trees var_insert patchfiles " " "`match_source_file patch-.* | grep -v '\.tar\.'`" makeopt="${SDECFG_PARALLEL_MAX:+-j$SDECFG_PARALLEL_MAX}" var_append makeopt ' ' 'ARCH=$lx_cpu CROSS_COMPILE=$archprefix HOSTCC=cc CC=$KCC' makeinstopt="$makeopt" auto_config () { if [ -f $base/architecture/$arch/linux.conf ]; then echo " using: architecture/$arch/linux.conf" cat $base/architecture/$arch/linux.conf >> .config elif [ -f $base/architecture/$arch/linux.conf.sh ]; then echo " using: architecture/$arch/linux.conf.sh" . $base/architecture/$arch/linux.conf.sh >> .config elif [ -f $base/architecture/$arch/linux.conf.m4 ]; then echo " using: architecture/$arch/linux.conf.m4" m4 -I $base/architecture/$arch -I $base/architecture/share \ $base/architecture/$arch/linux.conf.m4 >> .config else echo " using: no SDE linux kernel config found" cat arch/$lx_cpu/defconfig >> .config fi case "$SDECFG_OPT" in size*|smart) echo "CONFIG_CC_OPTIMIZE_FOR_SIZE=y" >> .config ;; *) echo "# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set" >> .config ;; esac cp .config{,.1} # all modules needs to be first so modules can be disabled by i.e. # the targets later echo "Enabling all modules ..." yes '' | eval $MAKE $makeopt no2modconfig > /dev/null; cp .config{,.2} if [ -f $base/target/$target/linux.conf.sh ]; then confscripts="$base/target/$target/linux.conf.sh $confscripts" fi for x in $confscripts; do echo " running: $x" sh $x .config done cp .config{,.3} # merge various text/plain config files for x in $base/config/$config/linux.cfg \ $base/target/$target/linux.conf; do if [ -f $x ]; then echo " merging: '$x'" tag="$(sed '/CONFIG_/ ! d; s,.*CONFIG_\([^ =]*\).*,\1,' \ $x | tr '\n' '|')" egrep -v "\bCONFIG_($tag)\b" < .config > .config.4 sed 's,\(CONFIG_.*\)=n,# \1 is not set,' \ $x >> .config.4 cp .config{.4,} fi done # create a valid .config yes '' | eval $MAKE $makeopt oldconfig > /dev/null; cp .config{,.5} # last disable broken stuff rm -f /tmp/$$.sed list="CONFIG_THIS_DOES_NOT_EXIST" for x in $pkg_linux_brokenfiles; do if [ -f "$x" ]; then echo "Disable broken file: $x" list="$list `tr ' ' '\t' < $x | cut -f1 | grep '^CONFIG_'`" fi done for x in $list; do echo "s,^$x=.\$,# $x is not set,;" >> /tmp/$$.sed done sed -f /tmp/$$.sed < .config > .config.6 cp .config{.6,}; rm -f /tmp/$$.sed # create a valid .config (dependencies might need to be disabled) yes '' | eval $MAKE $makeopt oldconfig > /dev/null # save final config cp .config{,_modules} echo "Creating config without modules ...." sed "s,\(CONFIG_.*\)=m,# \1 is not set," .config > .config_new mv .config_new .config # create a valid .config (dependencies might need to be disabled) yes '' | eval $MAKE $makeopt oldconfig > /dev/null mv .config .config_nomods # which .config to use? if [ "$SDECFG_PKG_LINUX_CONFIG_STYLE" = "modules" ]; then cp .config{_modules,} else cp .config{_nomods,} fi } lx_grabextraversion () { local ev ev=$(sed -n -e 's,^[ \t]*EXTRAVERSION[ \t]*=[ \t]*\([^ \t]*\),\1,p' Makefile | tail -n 1) if [ "$ev" ]; then lx_extraversion="${lx_extraversion}${ev}" # keep intact but commented since the second EXTRAVERSION # definition, and clean the first. sed -i -e 's,^\([ \t]*EXTRAVERSION[ \t]*=.*\),#\1,g' \ -e 's,^#\(EXTRAVERSION =\).*,\1,' Makefile fi } lx_injectextraversion () { # inject final EXTRAVERSION into Makefile sed -i -e "s,^\([ \t]*EXTRAVERSION[ \t]*\)=.*,\1= ${lx_extraversion},g" Makefile # update version.h - we only do this, because some other freaky # projects like rsbac change EXTRAVERSION in other Makefiles ... local rerun="" (eval $MAKE $makeopt include/generated/utsrelease.h || eval $MAKE $makeopt include/linux/utsrelease.h || eval $MAKE $makeopt include/linux/version.h) | grep -q "is up to date" && rerun=1 if [ "$rerun" ]; then echo "WARNING: Your system's timer resolution is too low ..." sleep 1; touch Makefile eval $MAKE $makeopt include/generated/utsrelease.h || eval $MAKE $makeopt include/linux/utsrelease.h || eval $MAKE $makeopt include/linux/version.h fi # get kernel_release rerun=1 while true; do for fn in include/generated/utsrelease.h \ include/linux/utsrelease.h \ include/linux/version.h; do [ -f $fn ] && versionh=$fn && break done lx_kernelrelease="$(echo -e "#include \"$versionh\"\nUTS_RELEASE" | $KCC -E - | tail -n 1 | cut -d '"' -f 2)" if [ -z "$lx_kernelrelease" -a "$rerun" ]; then $MAKE $makeopt .kernelrelease include/linux/version.h $MAKE $makeopt include/generated/utsrelease.h || $MAKE $makeopt include/linux/utsrelease.h rerun=; continue fi break done if [ ! "$lx_kernelrelease" -o "$lx_kernelrelease" = "UTS_RELEASE" ]; then abort "Could not grab final kernel version!" fi } lx_filter_patch () { local prefix="`sed -n '/^-EXTRAVERSION =/ { s/^-EXTRAVERSION =//p; q }' $1`" # whitespace after EXTRAVERSION must be preserve to apply expr= # only tweak EXTRAVERSION if no space content [ "${prefix%% }" ] && var_append expr ';' "s/^-EXTRAVERSION =.*/-EXTRAVERSION =/" var_append expr ';' "s/^+EXTRAVERSION = *$prefix/+EXTRAVERSION =/" sed -e "$expr" $1 } lx_patch () { echo "Generic linux patching ..." # grab extraversion from vanilla lx_grabextraversion apply_patchfiles lx_grabextraversion lx_filter_patch # some arches (avr32, sh64 at the time of writing) have a "defect" Makefile # and do not work without a .config ... yes '' | eval $MAKE $makeopt oldconfig > /dev/null echo "Redefining VERSION ..." lx_extraversion="${lx_extraversion}-t2" lx_injectextraversion echo "... linux source patching for ${lx_extraversion} finished." echo "Clean up the *.orig and *~ files ... " rm -f .config.old .config } lx_config() { echo "Generic linux configuration ..." if [ "$SDECFG_PKG_LINUX_CONFIG_STYLE" = none ]; then echo "Using $lx_customconf." echo "Since automatic generation is disabled ..." eval cp -v $lx_customconf .config || true else echo "Automatically creating default configuration ...." auto_config fi # regrab for stuff like rsbac ... :-( lx_injectextraversion echo "... configuration of $lx_kernelrelease finished!" } pkg_linux_brokenfiles="$base/architecture/$arch/linux-disable.lst \ $base/package/*/linux/disable-broken.lst \ $pkg_linux_brokenfiles"