What is the simplest code to get the top-level directory part of a makefile variable? Example:
BUILD_DIR = dir/subdir/.../sub-a-dub-dir
distclean:
rm -rf <some code which evaluates to "dir" from $(BUILD_DIR)>
PS: I don't mean $(dir $(dir $(BUILD_DIR))), but something which gets the first directory part of any variable value.
dirname /tmp/foo/barwill give/tmpordirname foo/bar/bazwill givefoo/? Do you guarantee that the argument is a relative path? Are you assuming GNU make?