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– Abhishek A Nov 09 '11 at 15:42/? Do you guarantee that the argument is a relative path? Are you assuming GNU make? – Gilles 'SO- stop being evil' Nov 09 '11 at 23:05