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?

1

5 Answers 5

22

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

7
  • 3
    Ah yes, I did find that, but discarded that possibility because the last update to that project was about 8 years ago. But you're right -- I'll guess I'll give it a try when I'm back at work, and report back :) Sep 8, 2014 at 18:27
  • 2
    In fact, I just noticed that make under my modern Ubuntu 14.04 installation is also version 3.81 from 2006. I guess then, it's just really stable and has all the features it needs, and so there simply was no need for further updates ;) Sep 8, 2014 at 18:30
  • 7
    It works, though PowerShell did not find the make command automatically. I had to set up a make alias pointing to the actual make.exe executable in my PowerShell profile. Thanks! Sep 9, 2014 at 10:03
  • 7
    notepad $profile (or edit your PowerShell profile however you like) and add new-item alias:make -value 'C:\Program Files (x86)\GnuWin32\bin\make.exe' - make sure that's the right path to your make.exe Aug 23, 2016 at 17:32
  • 9
    You can simply add C:\Program Files (x86)\GnuWin32\bin to your Path.
    – forzagreen
    Oct 24, 2017 at 15:51
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.

1
  • 1
    For anyone using Powershell instead of CMD: 4. $env:Path += "C:\Program Files (x86)\GnuWin32\bin" 5. Get-ChildItem Env:Path | format-list
    – Mir
    Jun 22, 2022 at 17:44
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
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 20, 2022 at 12:21
  • 1
    Sorry, but will you please elaborate on what is unclear? The question boils down to: "How do I install make for Powershell?" Compared to earlier, installing make has never been easier and therefore I wanted to add this new way of doing it. It doesn't require any change of environment variables or anything. It only required Chocolatey and then running choco install make. I've now added how to install Chocolatey, but I don't think that that is an improvement since that may change. Oct 21, 2022 at 8:11
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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .