The make UNIX application to automate the compilation process

  • Recall:  

    • each time you change a C program source file, you must re-compile the C program source file

  • The C compiler of will output an object file with the same file name (but with a different file extension):

                      gcc -c myFileName.c
        myFileName.c  --------------------> myFileName.o

  • File system background info:

    • Each file in the compiler has a time stamp that give ths time when the file was updated

  • Application of the time stamp:   automate the compilation process:

     if ( timeStamp(file.c) > timeStamp(file.o)
         compile file.c
    

The dependency between files in the compilation process

  • There are 3 types of files in a compilation process:

      1. The source file --- is created by the programmer (depends on nothing):

         myFile1.c

      2. The object file which is created from and depends on its source file:

         myFile1.o  -- depends on --> myFile1.c 

      3. The executable program created from (and depends on) all object files:

         myProg  -- depends on --> myFile1.o   myFile2.o ... 

Commands used to produce the dependent files in the compilation process

  • The relationship between myFile1.o and myFile1.c is:

     myFile1.o  -- depends on --> myFile1.c 
    
     myFile1.o  created using:  gcc -c myFile1.c 

  • The command used to produce myProg from myFile1.o, myFile2.o, ... is:

     myProg  -- depends on -->   myFile1.o myFile2.o ... 
    
     myFile1 created using:  gcc -o myProg  myFile1.o myFile2.o ..

The make application:

  • Using a set of (1) dependency rules and (2) commands, the make utility can automate the compilation process