1 # This .inc file allows you to build and deploy multiple sets of kernel + modules with different defconfigs
2 #
3 # Note that this include will NOT stage anything nor create packages, since that is virtually impossible
4 # Userspace should be built against the 'regular' kernel
5 #
6 # The intended usecase is for machines that have mutually exclusive drivers due to e.g. pinmuxing issues.
7 # For example the LogicPD omap-l138 experimenter board can have multiple mutually exclusive expansion boards
8 # like lcd, ethernet, sound, 20x2 character LCD, etc. To be able to easily test all of those you can use this .inc
9 #
10 # To make it easier finding the original defconfig from a running kernel, this also forcefully turns on
11 # CONFIG_IKCONFIG_PROC so people can do 'zcat /proc/config.gz' on the target.
13 require linux.inc
15 SRC_URI_append = " \
16 file://configs/ "
18 MULTI_CONFIG_BASE_SUFFIX = "multi-config-"
20 # bitbake.conf only prepends PARALLEL make in tasks called do_compile, which isn't the case for multiconfig
21 # So explicitly enable it for compileconfigs in here
22 EXTRA_OEMAKE = "${PARALLEL_MAKE} "
24 do_compileconfigs () {
26 # fixup for fetcher change
27 if [ -e ${WORKDIR}/configs/configs ] ; then
28 if [ -e ${WORKDIR}/configs/configs/.empty ] ; then
29 mv ${WORKDIR}/configs/configs/.empty ${WORKDIR}/configs/
30 fi
31 mv ${WORKDIR}/configs/configs/* ${WORKDIR}/configs/
32 rm -rf ${WORKDIR}/configs/configs
33 fi
35 # Compile and Install additional kernel configs if found
36 if [ -e ${WORKDIR}/configs/.empty ] ; then
37 echo "No configs found in configs/ directory, skipping to regular build"
38 else
39 echo "Multiple configs found, building those first"
41 # Context Save the regular 'defconfig'
42 cp ${WORKDIR}/defconfig ${WORKDIR}/defconfig.save
44 for config in ${WORKDIR}/configs/* ; do
46 # Copy in alternative config
47 cd ${S}
48 cp $config ${WORKDIR}/defconfig
50 # Enable config to be viewed on the target
51 echo "CONFIG_IKCONFIG=y" >> ${WORKDIR}/defconfig
52 echo "CONFIG_IKCONFIG_PROC=y" >> ${WORKDIR}/defconfig
54 # Build and Install this alternative kernel
55 do_configure
56 kernel_do_compile
57 do_compile_kernelmodules
58 kernel_do_install
60 # Drop the resulting images in the deploy dir
61 install -d ${DEPLOY_DIR_IMAGE}
62 install -m 0644 ${KERNEL_OUTPUT} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).bin
64 if [ -d "${D}/lib" ]; then
65 fakeroot tar -cvzf ${DEPLOY_DIR_IMAGE}/${MODULES_IMAGE_BASE_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).tgz -C ${D} lib
66 fi
68 # Install the final config alongside the images
69 cp .config ${DEPLOY_DIR_IMAGE}/config-${PV}-${PR}-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).config
71 # Create symlinks
72 cd ${DEPLOY_DIR_IMAGE}
73 rm -f ${KERNEL_IMAGE_SYMLINK_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).bin
74 ln -sf ${KERNEL_IMAGE_BASE_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).bin ${KERNEL_IMAGE_SYMLINK_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).bin
75 rm -f modules-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).tgz
76 ln -sf ${MODULES_IMAGE_BASE_NAME}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).tgz modules-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).tgz
77 rm -f config-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).config
78 ln -sf config-${PV}-${PR}-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).config config-${MACHINE}.${MULTI_CONFIG_BASE_SUFFIX}$(basename $config).config
80 done
82 # Restore the regular 'defconfig'
83 cp ${WORKDIR}/defconfig.save ${WORKDIR}/defconfig
84 fi
85 }
87 # For reference, copy .config to deploy image
88 do_deploy_append () {
90 install -d ${DEPLOY_DIR_IMAGE}
92 # Drop the regular defconfig along side the others for consistency
93 cd ${S}
94 cp .config ${DEPLOY_DIR_IMAGE}/config-${PV}-${PR}-${MACHINE}.config
96 # add symlink
97 cd ${DEPLOY_DIR_IMAGE}
98 rm -f config-${MACHINE}.config
99 ln -s config-${PV}-${PR}-${MACHINE}.config config-${MACHINE}.config
101 rm -f modules-${MACHINE}.tgz
102 ln -sf ${MODULES_IMAGE_BASE_NAME}.tgz modules-${MACHINE}.tgz
104 }
106 do_compileconfigs[depends] += "u-boot-mkimage-native:do_populate_sysroot virtual/${TARGET_PREFIX}gcc:do_populate_sysroot virtual/${TARGET_PREFIX}gcc${KERNEL_CCSUFFIX}:do_populate_sysroot"
107 addtask compileconfigs after do_patch before do_configure