If you type make
$ make
the first rule is executed. If you type
$ make boorule,
It executes the statements given after
boorule: boo.c foo.c i.h ba.h
<TAB> echo "I got called"
So you will get,
$ make boorule
echo "I got called"
I got called
Why?
It is the habit of make to print what command it is executing. If you
want to avoid that,
Prefix a '@' before echo.
boorule: boo.c foo.c i.h ba.h
<TAB> @echo "I got called"
Now we are fine.
You can put any shell script in the action part. But you have to
ensure that they all are in one line.
A rule is always one line. Remember that. You have to use a bunch of
'\' characters like this.
Look at this:
boorule:
@for i in `cat /etc/passwd` ; \
do \
echo $$i |cut -d: -f1 ; \
done
It is very complicated.
All I am doing is getting make to execute a shell script for me. But
it is hard because we never bother
about writing all the script commands in one line. In a makefile, you
have to do that.
Look at the above excerpt.
You always use the \ only at the end of the line. Vim's syntax
highlighting can catch when you have a space
after \. Be careful!
Moreover you have to use ; characters to delimit the various commands
of the shell.
Why am I using two $ signs in front of the loop variable i?
$i is a make variable. We want the value in $i, hence $$i.
Obviously makefiles are not easy to master. But they are very powerful.
We will see a few more concepts tomorrow and move on.
-Girish
--
Gayatri Hitech
web: http://gayatri-hitech.com
SpamCheetah Spam filter:
http://spam-cheetah.com
_______________________________________________
To unsubscribe, email [email protected] with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc