I am trying to write a Makefile for a JVM port. I have already exported a variable like $CROSS_COMPILE=mipsel-linux-
This can be different for different platformd with its specific toolchains.
The toolchain can be located at different locations, but is guaranteed to be in the PATH( eg: /opt/toolchains/mipsel/bin/mipsel-linux-gcc)
My aim is to genericaly get the path upto “opt/toolchains/mipsel/bin/mipsel-linux-” from within my make file.
My current thinking is the do something like
1) which $(CROSS_COMPILE)gcc —– Which will return something like “/opt/toolchains/mipsel/bin/mipsel-linux-gcc”
2) Use that string and remove the gcc from the end.
I guess this should be possible. I have no idea though on how to proceed. Pointers on how to start will be appreciated.
I have tried “which $(CROSS_COMPILE)gcc” and which ($(CROSS_COMPILE)gcc), both of which arent working
There are plenty of GNU Make funcions to retrieve for example a directory name.
Also note the use of the
:=assignement to compute it only once and thus avoid running thewhichcommand repeatedly.