9a0c090b122dc69d4295717b83e8f629d9a9606d
1 # This .inc file allows building and deploying multiple sets of kernel + modules
2 # with different defconfigs
3 #
4 # Note that this include will NOT stage anything nor create packages, since that
5 # is virtually impossible. Userspace should be built against the 'regular' kernel
6 #
7 # The intended usecase is for machines that have mutually exclusive drivers due
8 # to e.g. pinmuxing issues. For example the LogicPD omap-l138 experimenter board
9 # can have multiple mutually exclusive expansion boards like lcd, ethernet,
10 # sound, 20x2 character LCD, etc. To be able to easily test all of those you can
11 # use this .inc
12 #
13 # To make it easier finding the original defconfig from a running kernel, this
14 # also forcefully turns on CONFIG_IKCONFIG_PROC so people can do
15 # 'zcat /proc/config.gz' on the target.
16 #
17 # The function get_kernelversion uses generated header files to extract the
18 # version number. But those files are not available until do_compile, and
19 # do_compileconfigs is injected before that, hence the version becomes None
20 # and breaks in several places. Introduce a task do_preparekernel that calls
21 # "make prepare" in the kernel tree to generate all the necessary files.
23 require linux.inc
25 SRC_URI += " \
26 file://configs "
28 MULTI_CONFIG_BASE_SUFFIX = "multi-config-"
29 MODULES_IMAGE_BASE_NAME = "modules-${PV}-${PR}-${MACHINE}"
31 do_preparekernel () {
32 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
33 oe_runmake prepare CC="${KERNEL_CC}" LD="${KERNEL_LD}"
34 }
36 addtask preparekernel after do_configure before do_compile
38 do_compileconfigs () {
40 # fixup for fetcher change
41 if [ -e ${WORKDIR}/configs/configs ] ; then
42 if [ -e ${WORKDIR}/configs/configs/empty ] ; then
43 mv ${WORKDIR}/configs/configs/empty ${WORKDIR}/configs/
44 fi
45 mv ${WORKDIR}/configs/configs/* ${WORKDIR}/configs/
46 rm -rf ${WORKDIR}/configs/configs
47 fi
49 # Compile and Install additional kernel configs if found
50 if [ -e ${WORKDIR}/configs/empty ] ; then
51 echo "No configs found in configs/ directory, skipping to regular build"
52 else
53 echo "Multiple configs found, building those first"
55 # Context Save the regular 'defconfig'
56 cp ${WORKDIR}/defconfig ${WORKDIR}/defconfig.save
58 for config in ${WORKDIR}/configs/* ; do
60 # Copy in alternative config
61 cd ${S}
62 cp $config ${WORKDIR}/defconfig
64 # Enable config to be viewed on the target
65 echo "CONFIG_IKCONFIG=y" >> ${WORKDIR}/defconfig
66 echo "CONFIG_IKCONFIG_PROC=y" >> ${WORKDIR}/defconfig
68 # Build and Install this alternative kernel
69 do_configure
70 kernel_do_compile
71 do_compile_kernelmodules
72 kernel_do_install
74 # Drop the resulting images in the deploy dir
75 install -d ${DEPLOY_DIR_IMAGE}
76 install -m 0644 ${KERNEL_OUTPUT} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).bin
78 if [ -d "${D}/lib" ]; then
79 tar --owner=root --group=root -cvzf ${DEPLOY_DIR_IMAGE}/${MODULES_IMAGE_BASE_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).tgz -C ${D} lib
80 fi
82 # Install the final config alongside the images
83 cp .config ${DEPLOY_DIR_IMAGE}/config-${PV}-${PR}-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).config
85 # Create symlinks
86 cd ${DEPLOY_DIR_IMAGE}
87 rm -f ${KERNEL_IMAGE_SYMLINK_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).bin
88 ln -sf ${KERNEL_IMAGE_BASE_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).bin ${KERNEL_IMAGE_SYMLINK_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).bin
89 rm -f modules-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).tgz
90 ln -sf ${MODULES_IMAGE_BASE_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).tgz modules-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).tgz
91 rm -f config-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).config
92 ln -sf config-${PV}-${PR}-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).config config-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).config
94 done
96 # Restore the regular 'defconfig'
97 cp ${WORKDIR}/defconfig.save ${WORKDIR}/defconfig
98 cd ${S}
99 do_configure
100 fi
101 }
103 # For reference, copy .config to deploy image
104 do_deploy_append () {
106 install -d ${DEPLOY_DIR_IMAGE}
108 # Drop the regular defconfig along side the others for consistency
109 cd ${S}
110 cp .config ${DEPLOY_DIR_IMAGE}/config-${PV}-${PR}-${MACHINE}.config
112 # add symlink
113 cd ${DEPLOY_DIR_IMAGE}
114 rm -f config-${MACHINE}.config
115 ln -s config-${PV}-${PR}-${MACHINE}.config config-${MACHINE}.config
117 rm -f modules-${MACHINE}.tgz
118 ln -sf ${MODULES_IMAGE_BASE_NAME}.tgz modules-${MACHINE}.tgz
120 }
122 do_compileconfigs[depends] += "u-boot-mkimage-native:do_populate_sysroot virtual/${TARGET_PREFIX}gcc:do_populate_sysroot"
123 addtask compileconfigs after do_preparekernel before do_compile