1 / 8

Introduction to Make

Introduction to Make. Updated by Chirantana Sriram Fall 2000. What Is Make ?. Utility for maintaining up-to-date versions of programs

morley
Download Presentation

Introduction to Make

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Make Updated by Chirantana Sriram Fall 2000

  2. What Is Make ? • Utility for maintaining up-to-date versions of programs • When changes are made to the original source code, it will rebuild executables by determining which program modules need to be recompiled, based on rules defined in a Makefile • Particularly useful for big software projects with large number of source files that depend on one another in complex ways • Automates the process of compiling and linking your programs during the development phase

  3. Hierarchy Dependency for a Project Output Executable Main.o Funct1.o Funct2.o def.h Func2.c Main.c def.h Func1.c def.h

  4. Sample Make File for the Project Output: Main.o Funct1.o Funct2.o cc –o Output Main.o Funct1.o Funct2.o Main.o: Main.c def.h cc –c Main.c Funct1.o: Funct1.c def.h cc –c Funct1.c Funct2.o: Funct2.c def.h cc –c Func2.c

  5. What a rule looks like Rules are of the following form: target ….. : dependencies ….. command ……….. target:Name of a file generated by the program (executables or Object files) dependencies: List of files that are used as input to create the target. command: A command is an action that make carries out to produce the target. Can have more than one command.

  6. Features of Make • Using Variables in Make • Can declare and define values for variables and can reuse them in the rules • Example: objects = program.o foo.o utils.o program : $(objects) cc -o program $(objects) $(objects) : defs.h

  7. Features of Make … • Can use built in functions for Text processing (however cannot define new functions within Makefile) • Syntax: $(function arguments) • Examples: • $(subst from,to,text) • shell function can be used to communicate with world outside of make. • Example: • files := $(shell echo *.c)

  8. Features of Make… • Can use conditionals in Make files • Example: libs_for_gcc = -lgnu normal_libs = foo: $(objects) ifeq ($(CC),gcc) $(CC) -o foo $(objects) $(libs_for_gcc) else $(CC) -o foo $(objects) $(normal_libs) endif

More Related