summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/setup-defconfig.inc
blob: 74689290866a9780e3eb399882ff0108d6d59732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# KERNEL_LOCALVERSION can be set to add a tag to the end of the
# kernel version string.  such as the commit id
KERNEL_LOCALVERSION ?= ""

# Check the defconfig file and see if it points to an in kernel
# defconfig that should be used, or if it is a complete config file
# Or if it points to a combined defconfig that lists both in kernel
# defconfig and associated config fragments.

do_configure() {
    # Always copy the defconfig file to .config to keep consistency
    # between the case where there is a real config and the in kernel
    # tree config
    cp ${WORKDIR}/defconfig ${S}/.config

    echo ${KERNEL_LOCALVERSION} > ${B}/.scmversion
    echo ${KERNEL_LOCALVERSION} > ${S}/.scmversion

    # First, check if pointing to a combined config with config fragments
    config=`cat ${S}/.config | grep use-combined-config | cut -d= -f2`
    if [ -n "$config" ]
    then
        cp $config ${S}/.config
    fi

    # Second, extract any config fragments listed in the defconfig
    config=`cat ${S}/.config | grep config-fragment | cut -d= -f2`
    if [ -n "$config" ]
    then
        configfrags=""
        for f in $config
        do
            # Check if the config fragment is available
            if [ ! -e "$f" ]
            then
                echo "Could not find kernel config fragment $f"
                exit 1
            else
                # Sanitize config fragment files to be relative to sources
                configfrags+=" ${S}/$f"
            fi
        done
    fi

    # Third, check if pointing to a known in kernel defconfig
    config=`cat ${S}/.config | grep use-kernel-config | cut -d= -f2`
    if [ -n "$config" ]
    then
        oe_runmake $config
    else
        yes '' | oe_runmake oldconfig
    fi

    # Fourth, handle config fragments specified in the recipe
    # The assumption is that the config fragment will be specified with the absolute path.
    # E.g. ${WORKDIR}/config1.cfg or ${S}/config2.cfg
    if [ -n "${KERNEL_CONFIG_FRAGMENTS}" ]
    then
        for f in ${KERNEL_CONFIG_FRAGMENTS}
        do
            # Check if the config fragment is available
            if [ ! -e "$f" ]
            then
                echo "Could not find kernel config fragment $f"
                exit 1
            fi
        done
    fi

    # Now that all the fragments are located merge them
    if [ -n "${KERNEL_CONFIG_FRAGMENTS}" -o -n "$configfrags" ]
    then
        ( cd ${WORKDIR} && ${S}/scripts/kconfig/merge_config.sh -m -r -O ${S} ${S}/.config $configfrags ${KERNEL_CONFIG_FRAGMENTS} 1>&2 )
        yes '' | oe_runmake oldconfig
    fi
}