Make shell command doesn't resolve which opam
$ make
make: opam: Command not found
Makefile:1: /solvuu.mk: No such file or directory
make: *** No rule to make target `/solvuu.mk'. Stop.
and
$ which make
/usr/bin/make
hammerlab-dev2:prohlatype$ make --version
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
and
$ echo "opam: $(which opam)"
opam: /hpc/users/rozenl02/code/foreign/opam/opam
our ~ is NFS mounted.
To add more info, so the issue is that we recommend creating a Makefile with the line
include $(shell opam config var solvuu-build:lib)/solvuu.mk
And the issue OP is experiencing is that the opam executable is not found in this context. It seems Make causes his PATH to be not used correctly. Thus, the $(shell ... ) part ends up being empty, and Make thinks it is supposed to include /solvuu.mk and this of course doesn't exist.
Does anyone know the portable way to call out to a shell command from within Make?
To add a bit more info, I changed the Makefile to
include $(shell /full/path/to/opam config var solvuu-build:lib)/solvuu.mk
so perhaps a more robust mechanism would be to tie an installation of solvuu_build to the opam that it is using?
tie an installation of
solvuu_buildto theopamthat it is using?
I don't think there is a general way to do that because opam is an executable that could be anywhere. It is not related in any way to the directory structure opam maintains because opam is not installed by opam.
I was suggesting inserting the result of which opam during the build phase.
If which opam is a reliable way to get the path to an executable, then we could recommend the following Makefile:
OPAM=$(shell which opam)
include $(shell $(OPAM) config var solvuu-build:lib)/solvuu.mk
Just hit this again, as I was reinstalling things. Can you add that change? On testing, it solves my problems.
Can you add that change?
Do you mean determining the path to opam by doing OPAM=$(shell which opam)? You feel that is the more correct general solution? We just need to update the documentation then.
I'm not clear on exactly what the problem is. If which opam works within the Makefile, it seems impossible that opam is not found because all which does is search PATH.
On my instance the shell opam config var solvuu-build:lib part fails.
But, weirdly, using the OPAM=$(shell which opam) technique succeeds. Maybe because the final shell invocation somehow doesn't operate with the full PATH variable.