The Makefile

  • The make utility uses an input file named Makefile

  • The Makefile contains a number of rules in the following form:

    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
    

    The first line specifies a dependency

    The dependency line is followed by any number of lines that begins with a <TAB> specifying the commands used to create the targetName file


  • Default target:

      • The first targetName in the Makefile is the default target

      • Make will build the default target if no argument is provided to the make command

How to run the Make utility

 

  • Command to make a specific target:

      make  targetName 

    Effect:

    • make will execute the commands associated with the target targetName


  • Command to make the default target:

      make  

    (The first targetName in the Makefile is the default target)

Other uses of Make

 

  • The make utility is very flexible

  • You can use make to automate many different projects beside compiling a C program !

  • Anecdote:

      • Emory students who needs to write an honor thesis in the CS department have automated the type setting commands with make

     

     

In the next set of slides, I will show you how to automate the compilation of hello.c using Make