34

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?

Malte Skoruppa
  • 443
  • 1
  • 4
  • 5
  • 1
    Closely related Q&A on Stack Overflow: [How to install and use “make” in Windows?](https://stackoverflow.com/q/32127524/2157640) – Palec Dec 08 '19 at 19:31

5 Answers5

22

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

Leo Chapiro
  • 15,459
  • 5
  • 42
  • 45
  • 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 :) – Malte Skoruppa Sep 08 '14 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 ;) – Malte Skoruppa Sep 08 '14 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! – Malte Skoruppa Sep 09 '14 at 10:03
  • How did you make alias? I am using Windows 2012. and made a make.exe key with value C:\make-3.81.exe but I am not able to run `make.exe -n` on both windows powershell as well as cmd. I always open the installer. – codec Aug 17 '16 at 08:32
  • 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 – alexanderbird Aug 23 '16 at 17:32
  • What about ./configure? – user3083324 Jul 16 '17 at 03:23
  • 9
    You can simply add `C:\Program Files (x86)\GnuWin32\bin` to your Path. – forzagreen Oct 24 '17 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.

user2048773
  • 111
  • 1
  • 2
  • 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 '22 at 17:44
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.

coocooman3
  • 21
  • 1
  • There is a port of 4.3 in EZWinPorts (https://sourceforge.net/projects/ezwinports/files/), and the developer (Eli Zaretskii) is mentioned in the release announcement (https://lists.gnu.org/archive/html/info-gnu/2020-01/msg00004.html), so I assume it is a build of the official source. That build is installed by the Scoop package manager (https://github.com/ScoopInstaller/Main/blob/master/bucket/make.json). – John Freeman Sep 04 '21 at 13:44
2

** 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

  • 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](/help/how-to-answer). – Community Oct 20 '22 at 12:21
  • 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. – Little Helper Oct 21 '22 at 08:11