next up previous contents
Next: Case 3: no makefile, Up: Make without Makefile Previous: Case 1: no makefile,   Contents

Case 2: no makefile, build at once

Now we erase the generated files so we are back with only our source:
bash-2.05b# rm mainprog.o
bash-2.05b# rm mainprog
bash-2.05b# ls
mainprog.c
and we ask make to just create mainprog directly:
bash-2.05b# make mainprog
cc     mainprog.c   -o mainprog
bash-2.05b# ls
mainprog  mainprog.c
bash-2.05b# ./mainprog
I am the main program
I depend on nothing
make called the compiler with the source mainprog.c and asked for the output to be named mainprog.

Suppose we ask again:

bash-2.05b# make mainprog
make: `mainprog' is up to date.
bash-2.05b# ls -l
total 16
-rwxr-xr-x    1 root     root        11593 Mar  9 05:28 mainprog
-rw-r--r--    1 root     root          125 Mar  9 05:07 mainprog.c
Since mainprog exists and is newer than mainprog.c there is nothing to do.

root 2004-03-15