Charly
Charly

Reputation: 1352

Makefile autocompletion for paths (e.g. for defconfig)

I have a project with a menuconfig configuration for which this I use several *_defconfig files as default configurations. These defconfig files are grouped for each project:

/
  - projects
    - projectA
      - configs
         - 32bit_defconfig
         - 64bit_defconfig
         - foo_defconfig
    - projectB
      - configs
         - 32bit_defconfig
         - 64bit_defconfig
         - bar_defconfig

Now I would like to have a makefile, where I get the autocompletion for these defconfigs:

$ make projects/pr<TAB>
projects/projectA
projects/projectB

I thought about writing a Makefile like this:

projects/%/configs/%_defconfig: FORCE
    echo $@

Currently the only thing which is working is this rule, where I have no autocompletion for the path:

# e.g. 'make projects/88000-000/configs/32bit_defconfig'
%_defconfig: FORCE
    $(MAKE) -f tools/make/menuconfig.mk $@

PS: Autocompletion works for regular make targets.

Upvotes: 1

Views: 249

Answers (1)

Charly
Charly

Reputation: 1352

You can use wildcards for this reason:

DEFCONFIGS=$(wildcard projects/*/configs/*_defconfig)

test: FORCE
    echo $(DEFCONFIG)

$(DEFCONFIGS): FORCE
    $(MAKE) -f tools/make/menuconfig.mk $@

First use the test-target to check whether your wildcard is working, then you can use autocompletion:

$ make <TAB>
all                      default                  install_toolchain
buildroot-menuconfig     FORCE                    menuconfig
clean                    install                  projects/
$ make projects/<TAB>
92107-110/  BananaPro/
$

Upvotes: 1

Related Questions