I am trying to create a subdirectory in my project (let it have $PROJECT/child ) that needs to pull out the Makefile (call it ../Makefile.inc ) from its parent, $PROJECT/Makefile.inc . Later I want to copy $PROJECT/child to another location so that it can work regardless of $PROJECT .
There is a generic Makefile that needs to be included in both projects and sent when copying a subdirectory, and I want it to be included in both cases. So I thought that I would bind it during the child build if it was not found. (I donβt want to just turn on ../Makefile.inc because it will disappear when I copy the project, and I donβt want the call system to be responsible for installing Makefile.inc .)
With these limitations, here is a terrible hack that I came up with to do this in $PROJECT/child/Makefile :
HACK = $(shell test -f Makefile.inc || ln -f ../Makefile.inc .) include $(HACK)Makefile.inc
Pay attention to the extra special adhesive tape of this second command. I should actually include $(HACK) , even if it ends up empty, so $(shell ...) will be evaluated.; -)
Is there a cleaner way to do this?
source share