36

Under Linux, sources of projects commonly come with Makefile's. Makefiles contain directives to build these projects using the command make. I am currently forced to use Windows, and so as to be able to use this OS I configured and enhanced the "PowerShell" (by installing some additional programs, such as vim or svn, a module called PSReadLine, writing a PowerShell profile, etc.).

However I could not find whether it is possible to install make in PowerShell. I am aware that I will also have to install programs that make will call, such as, say, g++ or pdflatex, but that'll be for later. For now I would like to get make itself working in the first place.

A bit of research revealed two possibilities:

  1. The accepted answer to this very similar question: How to use makefiles on Windows, suggests to use Cygwin. That's a possibility, Cygwin is great, but since I decided to give PowerShell a chance I would like to know whether this is also possible with PowerShell, not Cygwin. Hence this question is not a duplicate, since that other question was about some possibility to use make in Windows, whereas I am asking for PowerShell in particular.

  2. There exists a make clone for PowerShell clone called poshmake, but the syntax of the Poshmake files is different from usual Makefiles, which is a no-go. I want a true make, as maintaining two versions of Makefiles for all the projects I have lying around is not an option.

So: is it possible to install GNU make, which will understand the syntax of typical Makefiles, such that I can call make from within PowerShell?

5 Answers5

23

Take a look at "Make for Windows". After installing you simply call "make" from CMD or PowerShell.

Leo Chapiro
  • 15,705
11

2021 - March Windows 10 Enterprise 64Bit Successful Approach

Despite looking old, the gnuwin install for "make" works fine reflecting stability and backward support in Linux and Windows.

I followed instructions at http://gnuwin32.sourceforge.net/packages/make.htm and http://gnuwin32.sourceforge.net/install.html. Below is what I actually did:

  1. Download "Complete package, except sources" at (http://gnuwin32.sourceforge.net/downlinks/make.php) this will download:

    make-3.81.exe

  2. execute make-3.81.exe by double clicking on the file

  3. In the install wizard it will show the install path, which by default is:

    C:\Program Files (x86)\GnuWin32

    (In the install wizard I did not install the documentation nor create a start shortcut.)

  4. Add the path to the binaries to the windows path variable. This will be the install path + "\bin". I did this from a windows command shell with:

    set PATH=%PATH%;"C:\Program Files (x86)\GnuWin32\bin"

  5. Confirm addition of path with command:

    echo %PATH%

    That should show the list of paths and include "C:\Program Files (x86)\GnuWin32\bin"

  6. Close any apps or shells you want to use the "make" command within and reopen them. This will get the new path location loaded in the apps.

  7. To test type the following in powershell or windows cmd shell:

    make -v

    It should show the copyright etc.

5

** 2022 update **

With the package manager Chocolatey, run choco install make.

To verify that you now have make, run make --version.


To install Chocolatey, run:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Source: https://docs.chocolatey.org/en-us/choco/setup

2

Install Make for Windows from GNU Make and add C:\Program Files (x86)\GnuWin32\bin to your Path Path Ubication Edit Path

2

As this is the first result I get on Bing when I search for "PowerShell make", I'm creating this answer to note that the official GNU page and the mirrors have Make for Windows source as part of the tar.gz file, and that has been updated to version 4.3 as of January 2020. The provided links to the sourceforge in other answers are still the 2006 3.8.1 version. I am not familiar with the changes in 4.x, as I don't use make enough, but think it's good to keep this question updated so when someone else inevitably finds it they don't get confused.

However, the files on the GNU page do not contain any binaries, so you'll have to build make yourself using GCC or MSVC (which is easy, just a single ./build_w32.bat (with some flags depending on you compiler), which is outlined in the README.W32 file. Then you'll need to take the resulting folder, store it where you want, and add to path or create an alias in PowerShell to run the exe.

Only prebuilt binary I could find is hosted on Chocolatey. The Winget and AppGet (website seems to still be running at time of post though it was supposed to shut down) packages are still the old 3.8.1 versions. If there are any other binary locations, please let me know/post in the comments/edit this answer.