# Comment lines can appear anywhere Macros section (will be discussed later if time permits) Rules section |
|
We will discuss macros later in this webpage
|
|
targetName : depend-on-file1 depend-on-file2 ....
<TAB> UNIX-command-1 # List of commands
<TAB> UNIX-command-2 # used to create the
... # target file
<TAB> UNIX-command-N
|
Explanation:
|
|
hello.o: hello.c # Meaning: target hello.o depends of hello.c <TAB> gcc -c hello.c # Command to keep the target up to date |
Explanation:
|
|
main: func5a.o func5b.o # main depends on func5a.o and func5b.o gcc -o main func5a.o func5b.o func5a.o: func5a.c # func5a.o depends on func5a.c gcc -c func5a.c func5b.o: func5b.c gcc -c func5b.c func5a.c: func5b.h touch func5a.c func5b.c: func5b.h touch func5b.c |
Note:
|
main: func5a.o func5b.o # main depends on func5a.o and func5b.o gcc -o main func5a.o func5b.o func5a.o: func5a.c func5b.h # func5a.o depends on func5a.c gcc -c func5a.c # and (indirectly) also on func5b.h func5b.o: func5b.c func5b.h gcc -c func5b.c |
How to run the program:
|
|
main: func5a.o func5b.o gcc -o main func5a.o func5b.o func5a.o: func5a.c func5b.h gcc -c func5a.c func5b.o: func5b.c func5b.h gcc -c func5b.c |
make targetName # Make the target targetName |
I.e.: we can make different targets by using an additional argument to the make command !
Example:
make func5a.o make func5b.o make main |
|
Example:
|