The make Rules111
Command Echoing
By default all commands in the makefile are echoed to standard output as these are exe-
cuted. This provides information about the activity of
make
as it is going through the makefile.
However you can suppress the command echo by starting commands with the character
@
.
This is especially useful in printing information from within the makefile using the
echo
command. For example, you can create a makefile that prints information before it starts execut-
ing. A typical rule in the makefile that displays information about the object before executing
any other command follows. It displays a line showing that
make
is going to build FTP:
ftp: $(SRCS) $(HDRS)
@echo "Building FTP"
@$(CC) $(CFLAGS) $(INCLUDES) ftp.c
@$(CC) $(LDFLAGS) $(COMMON) $(OBJS) -lcommon -o ftp
When
make
reads this file, it displays the following output:
[root@conformix ftp-dir]# make ftp
Building FTP
[root@conformix ftp-dir]#
If you don’t insert the
@
characters in this file, the result will be as follows. You can easily
find the difference between this and the earlier output of the
make
command.
[root@conformix ftp-dir]# make ftp
echo "Building FTP"
Building FTP
gcc -g -O2 -c -I../common-dir ftp.c
gcc -static -L../common-dir ftp.o -lcommon -o ftp
[root@conformix ftp-dir]#
Rules with no Dependencies
Many rules are used with no dependencies. These rules are used to execute commands
without looking into any dependencies. Commands in these rules are guaranteed to be executed.
4.2.2A Basic Makefile
Let us start with a simple makefile shown below. This makefile is used to build
ftp
,
which is the default target.
N O T E There are other ways to suppress the command
echo
. One of these is the use of
s
or
silent
flag on the
command line. However the most common method is the use of
the
@
character.
Next Page >>
<< Previous Page
Back to the Table of Contents