- # if we haven't found a specific, look for a deriving in hardcoded order
- test -e $@ || \
- (dpkg-vendor --derives-from ubuntu && cp ln -s ubuntu $@ ) || \
- ln -s debian $@
+ # if we haven't found a specific, look for a deriving
+ # we do ubuntu and debian last as those are the biggest families
+ # and would therefore potentially 'shadow' smaller families
+ # (especially debian as it sorts quiet early)
+ if ! test -e $@; then \
+ find -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2 | while read DISTRO; do \
+ if [ "$$DISTRO" = 'debian' -o "$$DISTRO" = 'ubuntu' ]; then continue; fi; \
+ if dpkg-vendor --derives-from $$DISTRO; then \
+ ln -s $$DISTRO $@; \
+ break; \
+ fi; \
+ done; \
+ test -e $@ || \
+ (dpkg-vendor --derives-from ubuntu && cp ln -s ubuntu $@ ) || \
+ ln -s debian $@; \
+ fi
+ if test ! -e current/makefile; then \
+ sed "s#@@VENDOR@@#$(notdir $(shell readlink -f current))#" vendor.makefile > current/makefile.auto; \
+ fi