summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/staging-kernel.inc
blob: a8c2ba4261f105da86ee5becd0013d8bff061b04 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# This .inc file allows building and deploying staging kernel + modules
# with defconfig + fragment cfgs

require kernel-configure.inc

STAGING_NAME ?= "RELEASE"
STAGING_KERNEL_FEATURES ?= ""
KERNEL_FEATURES ?= ""
MODULES_IMAGE_BASE_NAME = "modules-${PV}-${PR}-${MACHINE}"
EXTRA_OEMAKE_prepend_task-stagingkernel = "${PARALLEL_MAKE} "

kernel_do_configure_prepend() {

    configure_kernel "${KERNEL_DEFCONFIG}" "${STAGING_KERNEL_FEATURES}"

}

do_stagingkernel () {
    stagingkernel "${KERNEL_FEATURES}" ${STAGING_NAME}
    if [ -n "${STAGING_KERNEL_FEATURES_RT}" ]; then
        cd ${B}
        stagingkernel "${STAGING_KERNEL_FEATURES_RT}" "rt"
    fi

}

stagingkernel () {

    configure_kernel "${KERNEL_DEFCONFIG}" "${1}"

    # Copy defconfig to .config if .config does not exist. This allows
    # recipes to manage the .config themselves in do_configure_prepend().
    if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
      cp "${WORKDIR}/defconfig" "${B}/.config"
    fi
    yes '' | oe_runmake oldconfig

    if [ ! -z "${INITRAMFS_IMAGE}" ]; then
      for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do
        if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
          cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" initramfs.$img
	fi
      done
    fi

    #
    # Build this alternative kernel
    #
    
    kernel_do_compile
    do_compile_kernelmodules

    #
    # First install the modules to deploy dir
    #
    unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
    if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
        oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" modules_install
    else
        bbnote "no modules to install"
    fi
    if [ -d "${D}/lib" ]; then
        tar -cvzf ${DEPLOY_DIR_IMAGE}/${MODULES_IMAGE_BASE_NAME}-${2}.tgz -C ${D} lib
    fi
	rm -fr ${D}/lib

    #
    # Dont build any dtb:s for the staging kernel
    #

    #
    # Drop the resulting images in the deploy dir
    #
    cd ${S}
    install -d ${DEPLOY_DIR_IMAGE}
    install -m 0644 ${KERNEL_OUTPUT} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}-${2}.bin
    mv  ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}-${2}

    #
    # Install the final config alongside the images
    #
    cd ${S}
    cp .config ${DEPLOY_DIR_IMAGE}/config-${PV}-${PR}-${MACHINE}-${2}.config
    rm -f .config

    #
    # Create symlinks
    #
    cd ${DEPLOY_DIR_IMAGE}
    rm -f ${KERNEL_IMAGE_SYMLINK_NAME}-${2}.bin
    ln -sf ${KERNEL_IMAGE_BASE_NAME}-${2}.bin ${KERNEL_IMAGE_SYMLINK_NAME}-${2}.bin

    rm -f config-${MACHINE}-${2}.config
    ln -sf config-${PV}-${PR}-${MACHINE}-${2}.config config-${MACHINE}-${2}.config
	
}

do_stagingkernel[dirs] = "${DEPLOY_DIR_IMAGE} ${B}"

do_stagingkernel[depends] += "u-boot-mkimage-native:do_populate_sysroot virtual/${TARGET_PREFIX}gcc:do_populate_sysroot virtual/${TARGET_PREFIX}gcc:do_populate_sysroot"

addtask stagingkernel after do_patch before do_configure

#
# For reference, copy .config to deploy image
#
do_deploy_append () {

	install -d ${DEPLOY_DIR_IMAGE}

    #
    # Drop the regular defconfig along side the others for consistency
    #
    cd ${S}
    cp .config ${DEPLOY_DIR_IMAGE}/config-${PV}-${PR}-${MACHINE}.config

    #
    # add symlink
    #
    cd ${DEPLOY_DIR_IMAGE}    
    rm -f config-${MACHINE}.config
    ln -s config-${PV}-${PR}-${MACHINE}.config config-${MACHINE}.config

    if [ -n "${STAGING_KERNEL_FEATURES_RT}" ]; then
    cd ${S}
    install -m 0644 ${KERNEL_OUTPUT}-rt ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}-rt.bin

    #
    # Create symlinks
    #
    cd ${DEPLOYDIR}
    rm -f ${KERNEL_IMAGE_SYMLINK_NAME}-rt.bin
    ln -sf ${KERNEL_IMAGE_BASE_NAME}-rt.bin ${KERNEL_IMAGE_SYMLINK_NAME}-rt.bin
    fi

}

#
# Clean staging kernel related files in deploy dir
#
do_cleanstagingkernel () {
   
   cd ${DEPLOY_DIR_IMAGE}
   rm -f *-${STAGING_NAME}.*

   rm -f config-${PV}-${PR}-${MACHINE}.config
   rm -f config-${MACHINE}.config
   
}

LDFLAGS=""

do_cleanstagingkernel[nostamp] = "1"

addtask cleanstagingkernel after do_cleansstate