package/firmware/ipq-wifi/Makefile is one example of a (semi-)dynamically generated package that probably does much of what you need, installing a specific file based on which "variant" is requested.
Is there a way to avoid calling each time the generate-tesseract-data-package?
I tried to replace all that calls with a simple $(foreach PACKAGE,$(ALLTESSERACTPACKAGES),$(eval $(call generate-tesseract-data-package,$(PACKAGE)))), but the make menuconfig throws error:
ERROR: please fix package/utils/tesseract/Makefile - see logs/package/utils/tesseract/dump.txt for details
Collecting package info: done
tmp/.config-package.in:33096:error: recursive dependency detected!
For a resolution refer to Documentation/kbuild/kconfig-language.txt
subsection "Kconfig recursive dependency limitations"