PACKAGES := $(shell find ./ -mindepth 1 -name Makefile -type f -printf "%h\n")

ifneq ($(shell git rev-parse HEAD),)
PACKAGES := $(shell git ls-tree -r --name-only $$(git rev-parse HEAD) | grep "\/Makefile$$" | sed 's/\/Makefile$$//')
else
PACKAGES := $(shell find ./ -mindepth 1 -name Makefile -type f -printf "%h\n")
endif

Use git-ls-tree to get real package names
Use git-ls-tree to get real package names
