[prev] [index] [next]

Makefiles

A Makefile helps to organise the compilation of modules of a C program

Example:

ex1: ex1.c ex1.h
     gcc -Wall -Werror -o ex1 ex1.c

The UNIX command make

  • looks for a file named Makefile in the current directory
  • and executes the gcc command

    prompt$ make
    gcc -Wall -Werror -o ex1 ex1.c
    

  • or does nothing if the dependencies haven't changed since the last make

    prompt$ make
    make: `ex1' is up to date.