Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying path in makefile (GNU make on Windows)

Tags:

path

makefile

I'm using GNU make to build a project using Microsoft Visual C++, and I'd like to be able to run it from any CMD window rather than having to open the preconfigured one where the path (and various other environment variables) are preconfigured by a batch file. Ideally I'd like to define the relevant environment variables in the makefile itself, so all I need to do is pop open a CMD window and type "make".

By and large this is straightforward, but I'm struggling with PATH; so far every syntax I've tried for taking the standard PATH variable (as defined in the operating system) and appending the paths to the various build tools has failed.

Rather than go through the six or seven different syntaxes I have tried - some of which gave error messages, some of which didn't give error messages but just didn't work - I'll ask the question plainly:

  • What line to I have to put in my makefile so that the path to link.exe, namely "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin", will be added to the path used by "make"?

So far the nearest I've come to success has been to define:

LINK = "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\link.exe"

...and replace all subsequent references to "link.exe" by $(LINK), but this fails because link.exe has various dependencies (such as mspdb80.dll) that also have to be on the path.

like image 841
Eos Pengwern Avatar asked Jun 06 '11 22:06

Eos Pengwern


People also ask

How do I add GNU to my path?

To make it executable you need to open the Start menu and search for Edit the system environment variables. Click Environment Variables, then under System variables choose Path and click Edit. Click New and insert C:\Program Files (x86)\GnuWin32\bin , then save the changes.

How do I change the directory in makefile?

-C dir, --directory=dir Change to directory dir before reading the makefiles or doing anything else. If multiple -C options are specified, each is interpreted relative to the previous one: -C / -C etc is equivalent to -C /etc. This is typically used with recursive invocations of make.

What is $$ in makefile?

Double dollar sign If you want a string to have a dollar sign, you can use $$ . This is how to use a shell variable in bash or sh . Note the differences between Makefile variables and Shell variables in this next example.


1 Answers

This works:

DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE
VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin

export Path:=$(DevEnvDir);$(VCINSTALLDIR);$(Path)

It was the need for "export" and for case-sensitivity that had defeated me before.

like image 126
Eos Pengwern Avatar answered Sep 28 '22 04:09

Eos Pengwern