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 $(PREFIX)`
All I need is for the absolute path to be prefixed onto OBJS
when the prerequisites list is calculated.
You can use the shell function, and use realpath(1) (which is part of coreutils) and the --relative-to flag. You can even process a whole list of files with one invocation of realpath(1) since it knows how to process many file names.
$(addprefix prefix , names …) The argument names is regarded as a series of names, separated by whitespace; prefix is used as a unit. The value of prefix is prepended to the front of each individual name and the resulting larger names are concatenated with single spaces between them.
That's what abspath does. It creates an absolute path. That means it must be anchored at the root.
The syntax of the Android.mk allows you to group your sources into modules. A module is either a static library, a shared library, or a standalone executable. You can define one or more modules in each Android.mk file, and you can use the same source file in multiple modules.
If you're using GNUMake, you can do this:
REALPREFIX = $(realpath $(PREFIX))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With