Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
compat: fix few compilations by adding compat_autoconf.h support
The Makefile was generating the appropriate CONFIG_COMPAT_KERNEL_* variables for our Makefiles but this was being ignored by C files as compat had no compat_autoconf.h being generated. This patch addresses this but also puhes out the CONFIG_COMPAT_KERNEL_* variable generation to scripts. We have now two scripts: scripts/gen-compat-config.sh - generates .config for Makefile propagation scripts/gen-compat-autoconf.sh - generates compat_autoconf.h for code propagation This fixes running ckmake on older kernels. This issue was present only on compat and not compat_wireless as compat_wireless was generating its own compat_autoconf.h. This fixes compilation against some older kernels of just the compat module alone. Some work is still required for some newer and really ancient kernels: mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [FAILED] Trying kernel 3.2.2-030202-generic [FAILED] Trying kernel 3.1.10-030110-generic [FAILED] Trying kernel 3.0.18-030018-generic [FAILED] Trying kernel 2.6.39-02063904-generic [FAILED] Trying kernel 2.6.38-8-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-12-generic [OK] Trying kernel 2.6.38-11-generic [OK] Trying kernel 2.6.38-10-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [FAILED] Trying kernel 2.6.24-020624-generic [FAILED] Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
- Loading branch information
Showing
5 changed files
with
191 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org> | ||
| # Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de> | ||
| # Copyright 2011 John W. Linville <linville@tuxdriver.com> | ||
| # | ||
| # Use this to parse a small .config equivalent looking file to generate | ||
| # our own autoconf.h. This file has defines for each config option | ||
| # just like the kernels include/linux/autoconf.h | ||
| # | ||
| # XXX: consider using scripts/kconfig/confdata.c instead. | ||
| # On the downside this would require the user to have libc though. | ||
|
|
||
| # This indicates which is the oldest kernel we support | ||
| # Update this if you are adding support for older kernels. | ||
| OLDEST_KERNEL_SUPPORTED="2.6.24" | ||
|
|
||
| if [ $# -ne 1 ]; then | ||
| echo "Usage $0 config-file" | ||
| exit | ||
| fi | ||
|
|
||
| COMPAT_CONFIG="$1" | ||
|
|
||
| if [ ! -f $COMPAT_CONFIG ]; then | ||
| echo "File $1 is not a file" | ||
| exit | ||
| fi | ||
|
|
||
| # Defines a CONFIG_ option if not defined yet, this helps respect | ||
| # linux/autoconf.h | ||
| function define_config { | ||
| VAR=$1 | ||
| VALUE=$2 | ||
| case $VALUE in | ||
| n) # Try to undefine it | ||
| echo "#undef $VAR" | ||
| ;; | ||
| y) | ||
| echo "#ifndef $VAR" | ||
| echo "#define $VAR 1" | ||
| echo "#endif /* $VAR */" | ||
| ;; | ||
| m) | ||
| echo "#ifndef $VAR" | ||
| echo "#define $VAR 1" | ||
| echo "#endif /* $VAR */" | ||
| ;; | ||
| *) # Assume string | ||
| # XXX: add better checks to make sure what was on | ||
| # the right was indeed a string | ||
| echo "#ifndef $VAR" | ||
| echo "#define $VAR \"$VALUE\"" | ||
| echo "#endif /* $VAR */" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| function kernel_version_req { | ||
| VERSION=$(echo $1 | sed -e 's/\./,/g') | ||
| echo "#if (LINUX_VERSION_CODE < KERNEL_VERSION($VERSION))" | ||
| echo "#error compat requirement: Linux >= $VERSION" | ||
| echo "#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION($VERSION) */" | ||
| } | ||
|
|
||
| cat <<EOF | ||
| #ifndef COMPAT_AUTOCONF_INCLUDED | ||
| #define COMPAT_AUTOCONF_INCLUDED | ||
| /* | ||
| * Automatically generated C config: don't edit | ||
| */ | ||
| EOF | ||
|
|
||
| # Checks user is compiling against a kernel we support | ||
| kernel_version_req $OLDEST_KERNEL_SUPPORTED | ||
|
|
||
| # For each CONFIG_FOO=x option | ||
| for i in $(egrep '^CONFIG_|^ifdef CONFIG_|^ifndef CONFIG_|^endif #CONFIG_|^else #CONFIG_' $COMPAT_CONFIG | sed 's/ /+/'); do | ||
| case $i in | ||
| 'ifdef+CONFIG_'* ) | ||
| echo "#$i" | sed -e 's/+/ /' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_3_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(3,\2,0))/' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_2_6_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,\2))/' -e 's/\(ifdef CONFIG_COMPAT_RHEL_\)\([0-9]*\)_\([0-9]*\)/if (defined(RHEL_MAJOR) \&\& RHEL_MAJOR == \2 \&\& RHEL_MINOR >= \3)/' -e 's/\(#ifdef \)\(CONFIG_[^:space:]*\)/#if defined(\2) || defined(\2_MODULE)/' | ||
| continue | ||
| ;; | ||
| 'ifndef+CONFIG_'* ) | ||
| echo "#$i" | sed -e 's/+/ /' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_3_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,\2,0))/' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_2_6_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,\2))/' -e 's/\(ifndef CONFIG_COMPAT_RHEL_\)\([0-9]*\)_\([0-9]*\)/if (!defined(RHEL_MAJOR) || RHEL_MAJOR != \2 || RHEL_MINOR < \3)/' -e 's/\(#ifndef \)\(CONFIG_[^:space:]*\)/#if !defined(\2) \&\& !defined(\2_MODULE)/' | ||
| continue | ||
| ;; | ||
| 'else+#CONFIG_'* | 'endif+#CONFIG_'* ) | ||
| echo "#$i */" |sed -e 's/+#/ \/* /g' | ||
| continue | ||
| ;; | ||
| CONFIG_* ) | ||
| # Get the element on the left of the "=" | ||
| VAR=$(echo $i | cut -d"=" -f 1) | ||
| # Get the element on the right of the "=" | ||
| VALUE=$(echo $i | cut -d"=" -f 2) | ||
|
|
||
| # Any other module which can *definitely* be built as a module goes here | ||
| define_config $VAR $VALUE | ||
| continue | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| echo "#endif /* COMPAT_AUTOCONF_INCLUDED */" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/bin/bash | ||
| # Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org> | ||
| # Copyright 2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
| # | ||
| # This generates a bunch of CONFIG_COMPAT_KERNEL_2_6_22 | ||
| # CONFIG_COMPAT_KERNEL_3_0 .. etc for each kernel release you need an object | ||
| # for. | ||
| # | ||
| # Note: this is part of the compat.git project, not compat-wireless.git, | ||
| # send patches against compat.git. | ||
|
|
||
| if [[ ! -f ${KLIB_BUILD}/Makefile ]]; then | ||
| exit | ||
| fi | ||
|
|
||
| # Actual kernel version | ||
| KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p') | ||
|
|
||
| # 3.0 kernel stuff | ||
| COMPAT_LATEST_VERSION="3" | ||
| KERNEL_SUBLEVEL="-1" | ||
|
|
||
| # This allows all these variables to be propagated through | ||
| # all of our Makefiles | ||
| echo export | ||
|
|
||
| if [[ ${KERNEL_VERSION} -eq "3" ]]; then | ||
| KERNEL_SUBLEVEL=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^3\.\([0-9]\+\).*/\1/p') | ||
| else | ||
| COMPAT_26LATEST_VERSION="39" | ||
| KERNEL_26SUBLEVEL=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') | ||
| let KERNEL_26SUBLEVEL=${KERNEL_26SUBLEVEL}+1 | ||
|
|
||
| for i in $(seq ${KERNEL_26SUBLEVEL} ${COMPAT_26LATEST_VERSION}); do | ||
| echo "CONFIG_COMPAT_KERNEL_2_6_${i}=y" | ||
| done | ||
| fi | ||
|
|
||
| let KERNEL_SUBLEVEL=${KERNEL_SUBLEVEL}+1 | ||
| for i in $(seq ${KERNEL_SUBLEVEL} ${COMPAT_LATEST_VERSION}); do | ||
| echo "CONFIG_COMPAT_KERNEL_3_${i}=y" | ||
| done | ||
|
|
||
| if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} -eq "y" ]]; then | ||
| echo "CONFIG_COMPAT_FIRMWARE_CLASS=m" | ||
| fi | ||
|
|
||
| if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} -eq "y" ]]; then | ||
| echo "CONFIG_COMPAT_KFIFO=m" | ||
| fi |