I need to compile xyz kernel driver 2 times by passing a flag to use it as a configuration parameter in the source code. I need to generate the .ko files as xyz0.ko and xyz1.ko. Below is the required content from xyz kernel Makefile.
obj-m += xyz.o
xyz-objs = $(OBJECTS)
modules:
for number in 0 1 ; do \
CROSS_COMPILE=$(_CROSS_COMPILE) make ARCH=arm64 -C $(_KDIR) M=$(PWD) EXTRA_CFLAGS="- Dinst=$$number" modules ; \
mv xyx.ko $(_INSTALL_MOD_PATH)/lib/modules/5.2.0/extra/xyz$$number.ko ; \
rm -f $(OBJECTS) xyz$$number.* ; \
done
But as per the above command every times i need to generate xyz.ko, rename xyz.ko to xyz$$number.ko and copy to target directory. Is there any way that directly i can able to generate "xyz$$number.ko" and install directly in the target directory.
If i use below command for installing .ko file to target, its installing xyz.ko not xyz0.ko or xyz1.ko
CROSS_COMPILE=$(_CROSS_COMPILE) make ARCH=arm64 INSTALL_MOD_PATH=$(_INSTALL_MOD_PATH) -C $(_KDIR) M=$(CURDIR) V=$(V) modules_install
I am calling "modules" from buildroot package.mk file
Kindly help me with your inputs