GNU Make Windows: absolute path to the file that contains the Make file that is currently being interpreted by Make.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GNU Make Windows: absolute path to the file that contains the Make file that is currently being interpreted by Make.

denis.beurive
Hello everybody,

I use to use GNU Make under UNIX, but (unfortunately), I have to work under
Windows. This is not my cup of tea… and I have the MSDOS, which is a
prehistoric tool. However, I have no choice.

Under UNIX, I use to use this construct in order to get the absolute path
to the file that contains the Make file that is currently being interpreted
by Make :

__DIR__ := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

This works fine under UNIX.

However, under Windows, it does not work… The result is totally unexpected.

Does somebody know a reliable way to get the absolute path to the file that
contains the Make file that is currently being interpreted by Make, under
Windows ?

Best regards,

Denis
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: GNU Make Windows: absolute path to the file that contains the Make file that is currently being interpreted by Make.

Eli Zaretskii
> From: Denis BEURIVE <[hidden email]>
> Date: Fri, 30 Sep 2016 23:15:42 +0200
>
> I use to use GNU Make under UNIX, but (unfortunately), I have to work under
> Windows. This is not my cup of tea… and I have the MSDOS, which is a
> prehistoric tool. However, I have no choice.

What do you mean by "I have the MSDOS"?  Are you using MSDOS tools on
Windows?  Or does it mean something else?

> Under UNIX, I use to use this construct in order to get the absolute path
> to the file that contains the Make file that is currently being interpreted
> by Make :
>
> __DIR__ := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
>
> This works fine under UNIX.
>
> However, under Windows, it does not work… The result is totally unexpected.

What is the version of GNU Make you have installed on the Windows
machine?  With Make 4.2, the latest official release, your recipe
works for me.  Here's how I tried this (where "^Z" means Ctrl-Z, the
Windows EOF character):

  D:\usr\eli\data>make -f-
  DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
  all:
          echo $(DIR)
  ^Z
  echo D:/usr/tmp/
  D:/usr/tmp/

> Does somebody know a reliable way to get the absolute path to the file that
> contains the Make file that is currently being interpreted by Make, under
> Windows ?

The file-name related built-in functions should all work on MS-Windows
as you'd expect.  I suspect you have some old version of Make, which
perhaps didn't support some of these functions.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make