Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Carmen En

368 views

Published on

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

Carmen En

  1. 1. IES Felipe Trigo - DAI <ul><li>Desarrollo de Aplicaciones Informáticas </li></ul><ul><li>MAKEFILE </li></ul>
  2. 2. Contents <ul><li>Introduction </li></ul><ul><li>General concept </li></ul><ul><li>Dependencies </li></ul><ul><li>Structure of Makefile and rules </li></ul><ul><li>Variables </li></ul><ul><li>Conditions </li></ul><ul><li>Implicit rules </li></ul>
  3. 3. Introduction: MAKE <ul><li>make is a widely used tool for program development in scenarios with multiple, interdependent files . </li></ul><ul><li>It uses rules predefined in a file called makefile o Makefile . </li></ul><ul><li>Construct a 'target' file indicated by the user and derived from a number of 'source' files, from which the target depends . </li></ul><ul><ul><li>$> make –h Help about make </li></ul></ul><ul><ul><li>$> make –n commands that make would execute </li></ul></ul><ul><ul><li>$> make –f filename Specifies that the file containing the rules is called neither 'makefile' nor 'Makefile', but 'filename'. </li></ul></ul>
  4. 4. Introduction: MAKE <ul><li>The make tool supports program development </li></ul><ul><li>Typically, only a small amount of data is changed when the compiler is called </li></ul><ul><li>The make tool keeps track which portions of the entire program have been changed </li></ul><ul><li>Make compiles only those parts </li></ul><ul><li>Make has a powerful dependency graph that is derived from rules </li></ul>
  5. 5. The general concept .c .h .s .o a.out Compiler Assembler Linker Executable program .c .h .s .o a.out Compiler Assembler Linker Executable program .c .s .o
  6. 6. Separation <ul><li>You need dependencies </li></ul><ul><ul><li>“ .h” is required for the first and second .c file </li></ul></ul>.c .h .s .o a.out Compiler Assembler Linker Executable program .c .s .o First Second
  7. 7. Dependency in file MAKEFILE gcc –c data.c gcc –c io.c gcc –c main.c gcc –o project data.o main.o io.o .o .o .o .c .h .c .h .c Main.c Data.c IO.c Data.h IO.h project
  8. 8. Dependency in file MAKEFILE # # First example of a Makefile # project: data.o main.o io.o gcc data.o main.o io.o –o project data.o: data.c data.h gcc –c data.c main.o: data.h io.h main.c gcc –c main.c io.o: io.h io.c gcc –c io.c .o .o .o .c .h .c .h .c Main.c Data.c IO.c Data.h IO.h project
  9. 9. Dependency: Edit data.c .o .o .o .c .h .c .h .c Main.c Data.c IO.c Data.h IO.h project Edit project : data.o main.o io.o gcc data.o main.o io.o –o project data.o : data.c data.h gcc –c data.c main.o: data.h io.h main.c gcc –c main.c io.o: io.h io.c gcc –c io.c
  10. 10. Rules Makefile Computer Architecture Laboratory 2010 main.o : main.c define.h $(CC) –c main.c Shell command(s) Target(s) Separator (:) Dependencies Tabulator symbol

×