Modify OpenWrt build system to use a variable for the current hardcoded .config

I am trying to modify the openwrt build system to use a variable rather than the currently hardcoded .config for the build system but am finding that it is more difficult that simply editing Makefile.

I started by doing just that: editing Makefile but quickly found that there are other scripts called by it that needed to be modified as well. I have what I started here but it is not working. Perhaps there is a much smarter way?

Use-case: I would like to modify update_kernel.sh to run multiple targets in parallel. I have a "working" script doing this but I get collisions because all have .config hard-coded whereas I need to define unique names for it for the parallel piece to work.

Example output of my broken attempt:

% echo CONFIG_TARGET_bcm27xx=y > .config.bcm27xx
% echo CONFIG_ALL_KMODS=y >> .config.bcm27xx
% make KCONFIG_CONFIG=.config.bcm27xx defconfig KERNEL_PATCHVER=5.15 WORKCONFIG=.work.bcm27xx
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a build dependency on 'libpam', which does not exist
WARNING: Makefile 'package/boot/kexec-tools/Makefile' has a dependency on 'liblzma', which does not exist
WARNING: Makefile 'package/network/services/lldpd/Makefile' has a dependency on 'libnetsnmp', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a build dependency on 'libpam', which does not exist
#
# configuration written to .config.bcm27xx
#

I get an error due to some of the I think C code needed the hard-coded .config as well. I have no experience modifying these types of files so I am at a dead-end:

% make KCONFIG_CONFIG=.config.bcm27xx WORKCONFIG=.work.bcm27xx target/linux/refresh V=ws KERNEL_PATCHVER=5.15 LINUX_VERSION=5.15.76 LINUX_KERNEL_HASH=skip
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a build dependency on 'libpam', which does not exist
WARNING: Makefile 'package/boot/kexec-tools/Makefile' has a dependency on 'liblzma', which does not exist
WARNING: Makefile 'package/network/services/lldpd/Makefile' has a dependency on 'libnetsnmp', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a build dependency on 'libpam', which does not exist
make[2]: Entering directory '/scratch/stable/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/scratch/stable/scripts/config'
make[2]: *** No rule to make target '.config', needed by '/scratch/stable/staging_dir/target-mips_24kc_musl/stamp/.target_prereq'.  Stop.
make[1]: *** [/scratch/stable/include/toplevel.mk:209: prereq] Error 2
make: *** [/scratch/stable/include/toplevel.mk:229: target/linux/refresh] Error 2

As OpenWrt relies on an external project (the linux kernel's kconfig) for this kind of configuration and dependency resolution services (which gets semi-regularly updated), changing this might provide more pain than gain.

perhaps maintain multiple buildroots, linking in changed elements?

I feel like I am pretty close to getting this working natively. I just can't seem to identify what is failing. Perhaps it is one of the compiled programs? I don't know C in order to edit those pieces.

I gave up on modifying the build system and took your suggestion for linking for parallel execution. I came up with this using that strategy. Seems to work.

1 Like