0

I have this simple command in makefile. However, I am unable to get to work the same file so that I can use the same file for on mac as well as windows machine to run

serve:
    docker run --rm -it -p 8000:8000 -v ${PWD}:/docs helloworld

How can I get PWD variable for windows?

I cannot use CD or %CD% because it will not then work on MAC.

codebased
  • 6,945
  • 9
  • 50
  • 84
  • 1
    Try `$${PWD}`. `${PWD}` is expanded by make before being passed to the shell. And as there is no such make variable it expands as the empty string. While `$${PWD}` is expanded by make as `${PWD}`, passed to the shell, that itself expands it to the current directory. Another option is to use the `CURDIR` make variable, if what you want is the directory from which make is invoked: `$(CURDIR):/docs`. Here, it is make that expands `$(CURDIR)` to the directory of make invocation before passing the result to the shell. – Renaud Pacalet Apr 06 '22 at 07:51
  • @RenaudPacalet Had completely overlooked CURDIR. Deleted my answer as it was strictly inferior to expanding that built-in variable. – Andreas Apr 06 '22 at 09:48
  • 2
    Just to note that `CURDIR` is a GNU make feature. If you're using some other implementation of make it won't be set. – MadScientist Apr 06 '22 at 13:20

0 Answers0