[kwlug-disc] Makefiles [was: command prompt history]

unsolicited unsolicited at swiz.ca
Fri Mar 19 23:46:52 EDT 2010


Bob Jonkman wrote, On 03/17/2010 6:47 PM:
> Chris Frey wrote:
>> On Wed, Mar 17, 2010 at 12:17:45AM -0400, Bob Jonkman wrote:
>>  
>>> Urm, no.  Not everyone.  At most, everyone - 1.  That would be me.  
>>> Care to explain?  At a KWLUG meeting?
>>>     
>>
>> I don't want to assume, so are you asking how makefiles in general
>> work, or why they would be useful here?
>>
>> - Chris
>>   
> 
> Yes.

(-:

> 
> --Bob (who believes less is more, and that being brief will encourage a 
> comprehensive lecture series both on how makefiles in general work, and 
> why they would be useful here)

OK, I'll take a quick stab, and probably be killed for it, but ...

In essence, make (attempts to) make a {something}. Or to make sure the 
result (usually a 'target') is not older than its dependents (the 
things that usually are supposed to be inputs or components to a 
something).

So, you specify a (target) [thing to look for a see if it's older than 
any of the dependents] and {dependents} [things that if newer, run the 
commands specified to refresh the target], and a set of commands that 
cause the target to be refreshed.

So, if you have a production directory (target), and a working 
directory (dependents), you specify a 'cp {appropriate options} olddir 
newdir' as your command to run. And type 'make'. Modify a file, type 
make, repeat.

Suppose your commands don't make a result. In essence, typing 'make' 
is akin to having written a script. It will run every time - the 
result is always out of date - it never gets created.

The target can be a placeholder, and the command to update a result 
could simply be 'touch {result}'.

Traditionally, the result is an executable, and the source, well, 
source, and the commands are various 'cc' commands that translate the 
source into the executable. But the essential idea of 'make' is so 
darn useful, that make is used far more widely than just that any 
more. (Take printing a book from component input chapters, for 
example.) And become far more potentially complex and weird, as a 
result. Including substitution variables and lots of other stuff. But 
taken back to basics ... you get people saying 'I use make for that.'

And that's about the extent of my (Linux) make knowledge. And clear as 
mud, I know.

So, I've taken a stab, the flames can begin.




More information about the kwlug-disc mailing list