Something like this?
$ tree -F
.
|-- Folder1/
|-- Folder2/
|-- Makefile
|-- app1
`-- service1
2 directories, 3 files
$ cat Makefile
DIRS := $(notdir $(shell find . -mindepth 1 -maxdepth 1 -type d))
DIRNAMES := $(addprefix print-folder-name-,$(DIRS))
.PHONY: $(DIRNAMES) print-folder-names
print-folder-names: $(DIRNAMES)
$(DIRNAMES): print-folder-name-%:
@printf '%s\n' '$*'
$ make print-folder-names
Folder2
Folder1
Everything is quite simple and easy to understand. The only subtlety is probably the static pattern rule $(DIRNAMES): print-folder-name-%:
. It is equivalent to one single rule per folder:
print-folder-name-Folder1:
@printf '%s\n' 'Folder1'
print-folder-name-Folder2:
@printf '%s\n' 'Folder2'
Of course, in the same rule you can do anything you like (else than printing its name) for each folder; just adapt the recipe. The $*
automatic variable expands as the stem of the pattern (the folder name in this case).
EDIT: if you also want to print something special for some folders, you can also use target-specific make variables:
$ cat Makefile
...
print-folder-name-Folder2: SOMEMORETEXT := ' foo'
$(DIRNAMES): print-folder-name-%:
@printf '%s%s\n' '$*' $(SOMEMORETEXT)
$ make print-folder-names
Folder2 foo
Folder1