summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux.inc
blob: 1f28a5633bf65aa7859e0090b8c681b0da6f849a (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
DESCRIPTION = "Linux Kernel"
SECTION = "kernel"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"

inherit kernel siteinfo
require recipes-kernel/linux/linux-yocto.inc

KERNEL_EXTRA_ARGS += "dtbs"

# Set the verbosity of kernel messages during runtime
# You can define CMDLINE_DEBUG in your local.conf or distro.conf to override this behaviour
CMDLINE_DEBUG ?= '${@base_conditional("DISTRO_TYPE", "release", "quiet", "debug", d)}'
CMDLINE_append = " ${CMDLINE_DEBUG}"

# Set a variable in .configure
# $1 - Configure variable to be set
# $2 - value [n/y/value]
kernel_configure_variable() {
    # Remove the config
    CONF_SED_SCRIPT="$CONF_SED_SCRIPT /CONFIG_$1[ =]/d;"
    if test "$2" = "n"
    then
        echo "# CONFIG_$1 is not set" >> ${B}/.config
    else
        echo "CONFIG_$1=$2" >> ${B}/.config
    fi
}

# Quirk for udev greater or equal 141
UDEV_GE_141 ?= "1"

do_configure_prepend() {
    # Clean .config
    echo "" > ${B}/.config
    CONF_SED_SCRIPT=""

    # bigendian support
    if [[ "${MACHINE}" =~ .*-be ]]; then
            kernel_configure_variable CPU_BIG_ENDIAN y
    fi

    # Set cmdline
    kernel_configure_variable CMDLINE "\"${CMDLINE}\""

    # Localversion
    kernel_configure_variable LOCALVERSION "\"\""
    kernel_configure_variable LOCALVERSION_AUTO n

    # Udev quirks
    # Newer versions of udev mandate that sysfs doesn't have deprecated entries
    if [ "${UDEV_GE_141}" = "1" ] ; then
        kernel_configure_variable SYSFS_DEPRECATED n
        kernel_configure_variable SYSFS_DEPRECATED_V2 n
        kernel_configure_variable HOTPLUG y
        kernel_configure_variable UEVENT_HELPER_PATH "\"\""
        kernel_configure_variable UNIX y
        kernel_configure_variable SYSFS y
        kernel_configure_variable PROC_FS y
        kernel_configure_variable TMPFS y
        kernel_configure_variable INOTIFY_USER y
        kernel_configure_variable SIGNALFD y
        kernel_configure_variable TMPFS_POSIX_ACL y
        kernel_configure_variable BLK_DEV_BSG y
        kernel_configure_variable DEVTMPFS y
        kernel_configure_variable DEVTMPFS_MOUNT y
    fi

    # Newer inits like systemd need cgroup support
    if [ "${KERNEL_ENABLE_CGROUPS}" = "1" ] ; then
        kernel_configure_variable CGROUP_SCHED y
        kernel_configure_variable CGROUPS y
        kernel_configure_variable CGROUP_NS y
        kernel_configure_variable CGROUP_FREEZER y
        kernel_configure_variable CGROUP_DEVICE y
        kernel_configure_variable CPUSETS y
        kernel_configure_variable PROC_PID_CPUSET y
        kernel_configure_variable CGROUP_CPUACCT y
        kernel_configure_variable RESOURCE_COUNTERS y
    fi

    # Activate CONFIG_LEGACY_PTYS
    kernel_configure_variable LEGACY_PTYS y

    # Keep this the last line
    # Remove all modified configs and add the rest to .config
    sed -e "${CONF_SED_SCRIPT}" < '${WORKDIR}/defconfig' >> '${B}/.config'

    yes '' | oe_runmake oldconfig
}

do_deploy_append() {                                                                                         
        install -m 0644 ${B}/arch/arm64/boot/dts/amd/amd-overdrive.dtb ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.dtb
}                                                                                                            

# Automatically depend on lzop-native if CONFIG_KERNEL_LZO is enabled
python () {
    try:
        defconfig = bb.fetch2.localpath('file://defconfig', d)
    except bb.fetch2.FetchError:
        return

    try:
        configfile = open(defconfig)
    except IOError:
        return

    if 'CONFIG_KERNEL_LZO=y\n' in configfile.readlines():
        depends = d.getVar('DEPENDS', False)
        d.setVar('DEPENDS', depends + ' lzop-native')
}