Makefile: Expand relative PREFIX path
In my Makefile, there is a PREFIX
variable for specifying where the finished files should be placed. However, internally, I need to use the absolute path of PREFIX
because the working directory changes.
I tried something like
PREFIX=../out
REALPREFIX=`readlink -f $(PREFIX)`
which didn't work, and neither did
default: fixprefix $(addprefix $(REALPREFIX)/,$(OBJS))
fixprefix:
REALPREFIX=`readlink -f $(PR开发者_Python百科EFIX)`
All I need is for the absolute path to be prefixed onto OBJS
when the prerequisites list is calculated.
If you're using GNUMake, you can do this:
REALPREFIX = $(realpath $(PREFIX))
精彩评论