For 2023 (and 2024 ...) - we are now fully retired from IT training. We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here)) |
A Complete makefile example
Part of a series, written to brush up some make notes I'm using for some make training next week
Let's write a complete makefile - from first principles:
# This is our first makefile
# Target "always" never exists, so rules will always run
always:
echo "Hello Make World"
# Rule will only run if "once" already exists
# By touching the file, we create it thus preventing re-runs
once:
echo "single shot"
touch once
# Target "clean" never exists, so this will always run
# extra "@" supresses the echoing of the command being run
# but you still see their output
clean:
@echo "Cleaning up"
@rm once
@echo "Completed"
Let's see that running:
wizard:mc graham$ make -f firstmake
echo "Hello Make World"
Hello Make World
wizard:mc graham$ make -f firstmake
echo "Hello Make World"
Hello Make World
wizard:mc graham$ make -f firstmake once
echo "single shot"
single shot
touch once
wizard:mc graham$ make -f firstmake once
make: `once' is up to date.
wizard:mc graham$
Some things to note:
* If no dependencies are given, the rule is always applied (and if multiple dependencies are given, then the rules are applied if ANY of the files is newer than the target)
* touch is commonly used to create an empty file if you're wanting to perform actions and don't really need an output file at all.
* If you preceed a command with an @symbol, the command is not echoed out as it is run. The first two examples above rather nastily double up the echoed text, but in "clean" that's not the case.
* If an error occurs during the application of a rule, it will cease at that point:
wizard:mc graham$ make clean
Cleaning up
rm: once: No such file or directory
make: *** [clean] Error 1
wizard:mc graham$
but an extra - sign will cause the error to be ignored in that the rule will continue:
@-rm once
* The default makefile is called "makefile" or "Makefile" (both will work). You can use the -f command line option to specify a different file, or the MAKEFILES environment variable though this latter has some implications with regard to nesting of makefiles later on:
wizard:mc graham$ export MAKEFILES=secondmake
wizard:mc graham$ make clean
Cleaning up
wizard:mc graham$ (written 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 [694] Ant and Make - (2006-04-22) [1671] Compiling C programs with gcc - an overview - (2008-06-10) [2674] Make and makefiles - a commented example to help you learn - (2010-03-12) [3053] Make - automating the commands for building and installing - (2010-11-16) [3632] What is Make? - (2012-03-02) [3651] Makefile - some basics, and a demonstration - (2012-03-13) [3658] Using Make for a distribution - (2012-03-17) [3666] Makefile variables - defined internally, from the command line and from the environment - (2012-03-22) [4013] Web Frameworks - nested templates - (2013-02-22) [4585] What is make? What is gcc? - (2015-11-28)
Some other Articles
TrainWest 2012 - 14th and 15th April, Melksham, WiltshireSights and scenes - more London trip picturesOn a sunny afternoon in LondonWhat is happening in 59 days time in Melksham?A Complete makefile examplePossessive Regular Expression Matching - Perl, Objective C and some other languagesA single action for multiple iPad / iPhone buttons, and animationiPad and iPhone programming - our seminar weekend with XcodeAlong the brook - East Melksham to Melksham
|
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).
|
|