Hello again everybody.
I have a question which may be very basic for allot of you, so here it goes.

I want to understand the process of creating makefiles. I've I realise there's some books out there like
'Mastering Cmake' and 'GNU Make' which describe the insides of these things, but I'm wondering where people
go to get the basic knowledge needed to understand all about makefiles and their uses and how they work.
The very beginners stuff. I was hoping there was maybe a textbook out there with this kind of info in it. Textbooks provide some good beginners information so I thought it would apply well to me.

It's the whole build process I want to improve my knowledge in, so I thought Makefiles are a good place to start. Correct me if I'm wrong.
I don't want to use too many websites for this kind of thing as often they're just too complicated or random. The structured process of a book is the kind of approach I'm looking for.


5 Years
Discussion Span
Last Post by Tumlee

I'm wondering where people go to get the basic knowledge needed to understand all about makefiles and their uses and how they work.

Make is a domain specific language, people learn it the way they would any other language: by reading documentation, books, tutorials, and maybe even watching videos.

The structured process of a book is the kind of approach I'm looking for.

Then get a book, they've been written on Make. Here are two relatively recent ones:




This is one of those arcane fields of knowledge where you have to sit at the foot of a master for 20 years before you are ready to go and create your own Makefiles from scratch... :-)

Actually, RTFM (the GNU make docs are very thorough), remember that cmake is NOT make (they are very different animals - make will damage you, but cmake will have you for lunch - and not in a good way!).

Also, study other make files. The FOSS community has a gazillion examples of good (and some bad) ones. Myself, after 30 years writing make files, I consider myself marginally compitent, and am still learning / re-learning the tricks all the time.


And, FWIW, I would still rather write a Makefile to build software than use an IDE such as VS or Eclipse, though I have extensively used all of them over the years.


"Makefile". The name alone fills my whole being with horror. The time I wasted getting it right! But then again, perhaps I did not RTFM enough, because being young I was too eager to get things done quickly... Because of that experience, I love IDEs.


Thanks everyone..
My understanding of Makefiles is this. If it has been constructed for MSW then the commands in the Makefile should be Command Line commands.. so to speak. Meaning that the command line should be able to read them. I have the GNU Make book and I also have books on Windows Cmd Line and MSDOS..But the commands for creating makefiles in GNU Make aren't in any of these books so I'm wondering how the command line reads them. Are these a whole different set of commands?


Well, Makefiles are typically Linux/Unix cruft. I use them on Windows inside the Cygwin environment. For Windows-only code, I do use VS instead, pain in the butt it may be! :-) If in a "linux" environment (including Cygwin), then you can use bash shell commands in the make file for complex processing requirements. Do you have an example of what you want to do? That would help us to better advise you.


Hi Rubberman.

Thanks for this. I'm actually really interested in understanding how to build and adapt open source software to build properly in a Windows environment. I've build a few small things and going further there are a million open source softare options out there so I just wanted to udnerstand things better. Allot of them include a makefile for a Linux environment but I want to build them for use on Windows. I know Cygwin is a good option if I'm trying to adapt a Unix based program to a Windows environment but I just thought that if I understand makefiles better then I could addapt them myself.

Probably the best way to do this is to use CMAKE, which I think is wonderful by the way, to create a makefile for me. To do that I'll need to create a CMakeLists file and to do that I'll need to be able to understand how the original Makefile was created for a Linux environment and then retype some instructions into a CMakeLists text file and then from that generate a Makefile for the Windows environment for me. The Makefile could then be used to build the open source software properly. Does that sound logical or am I on the wrong track? I could be.

Given the proliferation of open source software out there and the inclination of people/buisinesses to use it I thought this would be a very handy science to learn and understand.

I don't have a specific example but if you could let me know if I have things conceptually right or wrong, that would be really great.

Thanks so much.


I personally use CMake myself for all of my projects. It's a really simple build system and it avoids all the boilerplate that you have to go through when writing a Makefile manually. If you're a FOSS purist, though, keep in mind that although CMake is open source software, it's technically not GNU. ;)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.