Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Makefile - some basics, and a demonstration

Here is a basic rule from a makefile:

  mytarget:   mysource
      echo "myactions"
      uptime > mytarget
      cat -n mysource >> mytarget


mytarget depends on mysource. In other words, the following commands, which are the "rule" that's used to make mytarget from mysource are run if
1. mytarget does not exist or
2. mysource has a more recent timestamp than mytarget, indication that mytarget is out of date.

It is CRITICALLY IMPORTANT that each rule line is preceeded by tabs and not space.

I've created a file called mysource, but no file called mytarget. Let's see how that works:

wizard:mc graham$ ls -l my*
-rw-r--r-- 1 graham staff 45 13 Mar 13:06 mysource
wizard:mc graham$ make
echo "myactions"
myactions
uptime > mytarget
cat -n mysource >> mytarget


The actions (a.k.a. rules, a.k.a. script) have been run and mytarget created:

wizard:mc graham$ ls -l my*
-rw-r--r-- 1 graham staff 45 13 Mar 13:06 mysource
-rw-r--r-- 1 graham staff 122 13 Mar 13:20 mytarget


I run the make again, but there's nothing to be done as mytarget is up to date:

wizard:mc graham$ make
make: `mytarget' is up to date.
wizard:mc graham$ ls -l my*
-rw-r--r-- 1 graham staff 45 13 Mar 13:06 mysource
-rw-r--r-- 1 graham staff 122 13 Mar 13:20 mytarget


I modify mysource - the incoming file. That means mytarget is old (out of date) so when I rerun make, mytarget gets rebuilt:

wizard:mc graham$ echo "Hello World again" >> mysource
wizard:mc graham$ ls -l my*
-rw-r--r-- 1 graham staff 63 13 Mar 13:22 mysource
-rw-r--r-- 1 graham staff 122 13 Mar 13:20 mytarget
wizard:mc graham$ make
echo "myactions"
myactions
uptime > mytarget
cat -n mysource >> mytarget
wizard:mc graham$ ls -l my*
-rw-r--r-- 1 graham staff 63 13 Mar 13:22 mysource
-rw-r--r-- 1 graham staff 147 13 Mar 13:22 mytarget


But if I repeat the same make, mytarget is now correctly dated and so there is nothing to do:

wizard:mc graham$ make
make: `mytarget' is up to date.
wizard:mc graham$

(written 2012-03-13, updated 2012-03-14)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
A168 - Web Application Deployment - Compiler and development tools
  [4585] What is make? What is gcc? - (2015-11-28)
  [4013] Web Frameworks - nested templates - (2013-02-22)
  [3666] Makefile variables - defined internally, from the command line and from the environment - (2012-03-22)
  [3658] Using Make for a distribution - (2012-03-17)
  [3652] A Complete makefile example - (2012-03-14)
  [3632] What is Make? - (2012-03-02)
  [3053] Make - automating the commands for building and installing - (2010-11-16)
  [2674] Make and makefiles - a commented example to help you learn - (2010-03-12)
  [1671] Compiling C programs with gcc - an overview - (2008-06-10)
  [694] Ant and Make - (2006-04-22)


Back to
Possessive Regular Expression Matching - Perl, Objective C and some other languages
Previous and next
or
Horse's mouth home
Forward to
A Complete makefile example
Some other Articles
Sights and scenes - more London trip pictures
On a sunny afternoon in London
What is happening in 59 days time in Melksham?
Makefile - some basics, and a demonstration
Possessive Regular Expression Matching - Perl, Objective C and some other languages
A single action for multiple iPad / iPhone buttons, and animation
iPad and iPhone programming - our seminar weekend with Xcode
Along the brook - East Melksham to Melksham
Exploring Melksham with a film maker
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3651_Mak ... ation.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat