1 / 11

Makefile Tutorial CIS5027

Makefile Tutorial CIS5027 . Prof: Dr. Shu-Ching Chen TA: Hsin -Yu Ha. What’s make?. A utility that automatically builds  executable programs and libraries from  source code  by reading files called  makefile  which specify how to derive the target program .

frayne
Download Presentation

Makefile Tutorial CIS5027

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. Makefile TutorialCIS5027 Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha

  2. What’s make? • Autility thatautomatically builds executable programs and libraries from source code by reading files called makefile which specify how to derive the target program. • Make allows you to manage large programs and keep track of which portion of the entire program have been changed. • Makefile tells make how to generate an execution file make make –f MyMakefile

  3. Compiling by hand • Build Process • Files: main.c foo1.c foo2.c • gccmain.c foo1.c foo2.c –o main • gccmain.c foo1.c foo2.c –c gccmain.o foo1.o foo2.o –o main • With make and makefile, you only need to type make

  4. Makefile Format • Target: The file we want to create • Dependencies: Check before creating the target file • Commands: Consider as shell script. Target : dependencies <Tab> system commands

  5. Dependency graph

  6. First Makefile make gccmain.c –c gcc foo1.c –c gccmain.ofool.o –o main

  7. Change one source file touch foo1.c make gcc foo1.c –c gccmain.ofool.o –o main

  8. Variables • $(VAR) or ${VAR} • For example Targets = foo ${Targets}: common.h gcc –o ${Targets} foo.c foo: common.h gcc –o foofoo.c

  9. Difference between :=, = and += x = fooy = $(x) barx = xyz# The value of y would be xyz bar x := fooy := $(x) barx := xyz# The value of y would be foo bar CFLAGS= -c CFLAGS+= -Wall

  10. Makefile Example

  11. Makefile Tutorial • Make manual • http://www.gnu.org/software/make/manual/make.html • 8 functions for transforming text • http://www.gnu.org/software/make/manual/html_node/Functions.html

More Related