Skip to Content
In my last post, I showed you how to use Make to build .NET Core applications. Now you may be saying, hey what do I do on Windows. Well, I mentioned in my last post about nmake, but I didn’t provide much detail other than a reference to the documentation. With that said, here is how you get started with nmake.
This is pretty easy as it now ships as a component of Visual Studio 2017. Hope over here and read about it and make sure when you are installing Visual Studio 2017 that you install the Visual C++ Build Tools component.
With that out of the way, navigate to the following folder using PowerShell to see if nmake is now installed.
$ cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64"
$ .\nmake.exe
Microsoft (R) Program Maintenance Utility Version 14.15.26730.0
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
Now that you have verified it is installed, we should make this easier to use. I don’t like poluting my path, so I am going to add it to my path using my PowerShell profile.
$env:Path += ";C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64"
Great, now restart PowerShell and type the following and you should see the below output.
$ nmake
Microsoft (R) Program Maintenance Utility Version 14.15.26730.0
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
Using it to build .NET Core Apps
Now that we have nmake installed and on our path, let’s use it to build a .NET application.
Create a .NET Core Application.
$ mkdir nmade | cd
$ dotnet new console
Now let’s create a Makefile.
Put the folliwing into your Makefile.
all : clean restore build publish
setup-windows:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
wget -O warp-packer.exe https://github.com/dgiagio/warp/releases/download/v0.1.1/windows-x64.warp-packer.exe
clean:
dotnet clean
restore:
dotnet restore
build:
dotnet build
publish:
dotnet publish -c Release -r win-x64
warp-packer --arch windows-x64 --input_dir bin/Release/netcoreapp2.1/win-x64/publish --exec nmade.exe --output nmade.exe
run:
dotnet run
Let’s setup our Windows environment for the project.
Now let’s run our Makefile using nmake.
$ nmake
---omitting---
Creating self-contained application binary "nmade.exe"...
All done
That’s it, really simple.
Cross-Platform Usage
Now that we know we can create a single Makefile that can run cross-platform what do we need to do to ensure that we don’t use tools that are incompatible? That is a great question and my simple answer is try to use tooling that you know is cross-platform. .NET CLI Global tools are a good example, using PowerShell on Windows is another example because there are many Linux commands that are aliases in PowerShell so your Makefile doesn’t need to be rewritten. Finally another option is to add some more intellegience to your Makefile to determine the differences and execute different targets.
Thanks for reading.
Jamie
If you enjoy the content, then consider buying me a coffee.
Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!
Learn from Guru Rajesh Kumar and double your salary in just one year.
Get Started Now!
Make for Windows: NMake
What is Nmake?
NMAKE is Microsoft’s implementation of the make tool. The Microsoft Program Maintenance Utility (NMAKE.EXE) is a 32-bit tool that builds projects based on commands contained in a description file.
Another definition found on web as well
nmake is the “make” program for Visual Studio. A “make” program builds (makes) an executable and/or package by reading a set of “make” files. These files are essentially scripts that specify what is to be made, what files (header, source code, resource) are needed for each output file, etc. So nmake can be used to completely automate the process.
A frequently asked question: “Where can I find make for Windows?“. The answer is: “Download and use NMake“.
Downloading NMake
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q132084
Direct Downloan Link of Nmake
http://download.microsoft.com/download/vc15/patch/1.52/w95/en-us/nmake15.exe
Installing NMake
Run the downloaded executable to extract the files. Copy both the NMAKE.EXE and the NMAKE.ERR file to your Perl bin directory, normally C:\Perl\bin. Make sure that you copy the NMAKE.ERR file as well.
1. Download nmake15.exe
2. Double click on nmake15.exe. It will generate 3 files: nmake.exe, nmake.err and readme.txt.
3. Copy nmake.exe and nmake.err to \perl\bin, which is where ActivePerl executable files are located.
4. Now try the nmake command in a command window. If you see the following message, NMake 1.5 is installed correctly:
>nmake
Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified Stop.
Example of an NMake session
Normally building Perl modules and installing them consist of the following steps:
perl Makefile.pl
make
make test
make install
Reference:
http://msdn.microsoft.com/en-us/library/dd9y37ha%28v=vs.71%29.aspx
Certification Courses
DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:
- DevOps Certification — Learn the fundamentals and advanced concepts of DevOps practices and tools.
- DevSecOps Certification — Master the integration of security within the DevOps workflow.
- SRE Certification — Gain expertise in Site Reliability Engineering and ensure reliability at scale.
- MLOps Certification — Dive into Machine Learning Operations and streamline ML workflows.
- AiOps Certification — Discover AI-driven operations management for next-gen IT environments.
Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.
multiple versions of the nmake.exe binary, which is part of Microsoft VisualStudio BuildTools, including some decompiled nmake.cpp sources
License
MIT license
0
stars
0
forks
Branches
Tags
Activity
Star
Notifications
You must be signed in to change notification settings
GitHub
WebSite
0
Forks
6
Stars
6
Watchers
nmake
build-tool
Make helper/wrapper in node
How to download and setup nmake
Open terminal and run command
git clone https://github.com/crc442/nmake.git
git clone is used to create a copy or clone of nmake repositories.
You pass git clone a repository URL.
it supports a few different network protocols and corresponding URL formats.
Also you may download zip file with nmake https://github.com/crc442/nmake/archive/master.zip
Or simply clone nmake with SSH
[email protected]:crc442/nmake.git
If you have some problems with nmake
You may open issue on nmake support forum (system) here:
https://github.com/crc442/nmake/issues
Similar to nmake repositories
Here you may see nmake alternatives and analogs
webpack
parcel
guido
tulsi
poi
steal
pax
xmake
jarvis
node-build-monitor
wordpressify
sbt
gradle
fastdex
happypack
retire.js
bashful
style-dictionary
build
javafx-maven-plugin
javafx-gradle-plugin
uncss
windows-build-tools
buck
neutrino
realize
cake
boot
mmake
maven
This article explores alternatives to Makefiles on Windows. Earthly provides a consistent, containerized build environment for Windows users. Check it out.
As the field of DevOps and build release engineering continues to grow, many new tools are being developed to help make building and releasing applications easier. One of the tools that has been in use for many years is Make, which is still heavily used by engineers today.
A Makefile is a simple text file consisting of targets, which can invoke different actions depending on what has been configured. For example, with a Makefile, you can invoke a build of your application, deploy it, or run automated tests and it can dramatically increase the efficiency of your workflow.
Initially, it was Stuart Feldman who began working on the Make utility back in 1976 at Bell Labs. However, the version of Make most commonly used today is GNU Make, which was introduced in the late 1980s.
While the tool was originally meant to run on Linux, Make’s popularity has interested those working on other operating systems as well. There are several ways to run Makefiles on Windows, and in this article you’ll be introduced to each option and learn about their strengths and weaknesses.
Using Make on Windows
Before looking at the different options available, you should know why you want to run Makefiles on Windows in the first place. Or rather, if you’re working on Windows, why are you even interested in Makefiles?
Historically, the biggest reason for wanting Makefiles to run on Windows is that the developers in your organization are working on Windows. Seeing as how the de facto standard for languages like C and C++ is to use Make, it’s no wonder that Windows users want the ability to use Make as well.
As applications and infrastructure become more modern, the cloud is another reason for wanting Makefiles on Windows. Many infrastructure engineers want their applications to be run on Linux, likely led by the adoption of tools like Docker and containerization in general. Additionally, on Linux, a Makefile is the primary tool to use in many cases, especially when it comes to building native Linux applications. However, many engineers are still using Windows on their workstations, leading to the question of how to run Makefiles on Windows. Let’s dive into the possible answers.
Chocolatey
Linux users have been using package managers for decades, yet they’ve never gained much traction on Windows. Up until the release of winget, the concept of a package manager was never something that was natively included on Windows. Instead, Rob Reynolds started working on an independent package manager back in 2011 that would come to be known as Chocolatey. Chocolatey is now widely used on Windows to install packages, and you can use it to install make
as well.
To do so, run the following command in an Administrative PowerShell window:
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'))
You can find the newest installation instructions at any time on the Chocolatey website.
Once Chocolatey is installed, you may have to close down the PowerShell window and open it back up. After that, run the following command:
Once the script is done running, make
will be installed. You may need to restart the PowerShell window again, but at this point you are ready to use Makefiles on Windows.
Chocolatey will likely be the most popular option for those who want to stick to a pure Windows installation. It’s easy to install, easy to use, and you don’t need to jump through any hoops or workarounds to get it working.
At this point, you can use make
just like you otherwise would, and you can test it by running make -v
.
Cygwin
Historically, one of the most popular ways of running any type of Linux functionality on Windows has been to use Cygwin. Cygwin aims to give a Linux feeling to Windows by holding a large collection of GNU and open source tools. It’s important to note that this does not mean it will give you native Linux functionality. However, it does allow you to use Linux tools on Windows. There’s a big difference between the two; for instance, Cygwin does not have access to Unix functionality like signals, PTYs, and so on. It’s a great tool for when you want to use familiar Linux commands but still want them to be run on Windows.
To use Cygwin for Makefiles, start by downloading and installing Cygwin. During the installation, you’ll see a window popping up asking you what packages you want to install. In the top left corner, make sure to select Full and then search for make
.
Your search will give you a list of several different packages. You want to choose the one that’s labeled just as make
. Change the dropdown menu where it says Skip to the latest version.
Now you can finish the installation by clicking Next in the bottom right corner. Once the installation is done, you can open up Cygwin and verify that make
has been installed by executing make --version
.
NMAKE
One of the alternatives that you’ll often hear about regarding running Makefiles on Windows is NMAKE. While it is an alternative to make
, note that you cannot simply take your existing Makefiles from Linux and run them using NMAKE; they have to be ported.
First of all, the compilers are different on Windows and Linux, so if you are specifying your compiler in your Makefile, you’ll have to change that to whatever is relevant on Windows. At the same time, you’ll have to change the flags that you send to the compiler, because Windows typically denotes the flags using /
instead of -
.
On top of that, it doesn’t recognize all the syntax that you’re used to from GNU Make, like .PHONY
. Lastly, Windows obviously doesn’t recognize the commands that work on Linux, so if you have specified any Linux-specific commands in your Makefiles, you’ll also have to port them.
All in all, if your entire organization uses Windows and you simply want the typical functionality of GNU Make, then NMAKE is a viable solution. However, if you just want to quickly run your traditional Makefiles on Windows, NMAKE is not the answer.
CMake
As with NMAKE, CMake is not a direct way to run your Makefiles on Windows. Instead, CMake is a tool to generate Makefiles, at least on Linux. It works by defining a CMakeLists.txt
file in the root directory of your application. Once you execute cmake
, it generates the files you need to build your application, no matter what operating system you’re on.
On Linux, this means that it creates Makefiles for you to run, but on Windows it may mean that it creates a Visual Studio solution.
CMake is a great solution if you don’t care too much about running Makefiles specifically, but you want the functionality, namely the ease of use in a build process, that you can get from Makefiles.
Windows Subsystem for Linux
The Windows Subsystem for Linux (WSL) is an honorable mention. It’s cheating a bit to say that it’s a way to run Makefiles “on Windows,” as your Makefiles won’t actually be running on Windows.
If you haven’t heard of WSL before, here’s an extremely oversimplified explanation: It uses Hyper-V to create a hyper-optimized virtual machine on your computer, in which it runs Linux. Basically, you get a native Linux kernel running on your Windows computer, with a terminal that feels as if it’s part of Windows.
You should look into WSL if what you care about most is having Windows as your regular desktop environment, but you’re fine with all of your programming and development going on inside of Linux.
Conclusion
As you can see, there are a few different ways you can be successful in running Makefiles on Windows. However, you do need to be wary of the fact that it will never be a perfect solution. Every solution is in some way a workaround, and the closest you’ll get to feeling like you’re using native Makefiles while using Windows is to install something like WSL.
If you enjoyed this tutorial you might want to grab a copy the free eBook “Makefile ins and outs”. In it you’ll learn many tips and tricks for structuring builds and scaling up a build process. From how to write a simple Makefile to how to deal with dependencies and everything in between. Download this free Makefile book right now.