tags:

views:

109

answers:

6

Hi, I am looking for some basic information regarding makefile structure. Any pointers will be highly appreciated. Thanks.

+5  A: 

Start here!

Secko
+1, Possibly the single best programming-related resource on the web.
Carl Norum
@Carl Norum Yep, got to wear the horns and the beard of GNU.
Secko
The question specifically asked for NMAKE. Why would you confuse someone by sending them to documentation for a different system?
Adrian McCarthy
Says - "I am looking for some basic information regarding makefile structure."
Secko
More likely it's because the poster doesn't know better and isn't aware of the differences. Since he specifically mentioned nmake, referring him to GNU make probably will make him confused (or just frustrated).
jamesdlin
A: 

You may want to have a look at the Autobook

nico
Another good answer with a neg value. +1
Noah Roberts
@Noah Roberts: Cheers. It would be nice for people to downvote to explain why they do it... like the little orange popup suggests...
nico
A: 

See the description of the structure of a makefile in the Wikipedia article for a start. Some of the links there are pretty helpful too.

wallyk
+5  A: 

The best help I think I can give anyone desiring to learn how to write their own makefiles is:

DON'T DO IT!!!

Use a makefile generator. There's a lot out there. One of the best I've seen is CMake but there's also automake/autoconf/all that.

You can also use a totally different build system like Ant (but that's by far the only option in this category).

Make actually kind of sucks. I haven't touched one in 10 years. Put your development effort where it will do the most good, in your code.

Noah Roberts
Well, before Cmake it is usefull just to get acquaintance with makefiles, to understand how it evolved historically.
Max
Ant is the same as make. It is just as complex and basically defines its own language within XML.
Martin York
+1 for advocating CMake over Make.
Michael Aaron Safyan
@Martin, yeah, Ant is not the way to go; for Java, one should use Maven. I actually think Make is easier to understand than Ant, and for C and C++, the CMake build system is definitely the best.
Michael Aaron Safyan
Yeah, I've never used Ant or Maven. I looked at them briefly but never tried them. I wasn't advocating them, only indicating them as an alternative. I've used CMake before and liked it a lot. Currently I mostly just use the build system in the IDE I'm using.
Noah Roberts
@Max - I wouldn't worry about it. CMake abstracts away the Make garbage fairly effectively. If you were using automake and friends then it might be likely you'd eventually have to resort to Make syntax to make the right macros. I don't see that as likely when using CMake. One partial reason at least may be that CMake can generate things like VS solutions in addition to makefiles of varying syntax and birthright.
Noah Roberts
@Noah Roberts. Yes, you are absolutely right. btw, I also use CMake, but it is just interesting how it works, I mean, CMake produces makefiles (or, as you said VS solutions), and what is inside makefiles, what does make with them, etc.
Max
A: 

For very quick start (if you haven't yet tried) - read this, very simple.

If you want start writing makefiles in couple hours - this one.

To be a monster in makefiles use official, commonly you need this as reference book.

Max
+1 for direct link to resources specifically requested by the OP. No idea why anyone would neg this answer.
Noah Roberts
+3  A: 

Official NMAKE documentation.

There are several other types of build systems that use "makefiles". Several of the other answers here are pointing you to these other systems. They all implement the same basic ideas, but the capabilities and syntax vary, sometimes in subtle ways. If you need to learn how to use NMAKE (which is the one you mentioned in the title), and you read GNU make documentation, you're likely to get confused.

Adrian McCarthy
No idea why this was downvoted. The differences between NMAKE and GNU Make are significant.
Brian Neal
@Brian Neal: Someone seems to have downvoted all the answers to this question...
nico