An example to illustrate my question:
Top level makefile
rootdir = $(realpath .)
export includedir = $(rootdir)/include
default:
@$(MAKE) --directory
Perl is portable! Here's a solution using the abs2rel function from the core Perl module File::Spec (resp. File::Spec::Functions):
current_dir= /home/username/projects/app/trunk/src/libs/libfoo/
destination= /home/username/projects/app/build/libfoo/
relative= $(shell perl -MFile::Spec::Functions=abs2rel -E 'say abs2rel(shift, shift)' $(destination) $(current_dir))
makefile_target:
@echo "Use now $(relative)"