GNU Make.

Slides:



Advertisements
Similar presentations
Makefiles. makefiles Problem: You are working on one part of a large programming project (e. g., MS Word).  It consists of hundreds of individual.c files.
Advertisements

The make Utility Programming Tools and Environments Winter 2006.
Separate compilation Large programs are generally separated into multiple files, e.g. tuples.h, ray.h, ray.c, tuples.c main.c With several files, we can.
Makefiles  Provide a way for separate compilation.  Describe the dependencies among the project files.  The make utility.
Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 The CS-220 Development Environment.
The Makefile utility ABC – Chapter 11, Motivation Small programs single file “Not so small” programs : –Many lines of code –Multiple components.
David Notkin Autumn 2009 CSE303 Lecture 21 Some source code walks into a bar. Immediately, the bartender turns red and yells, "GET OUT OF HERE, WE DON'T.
Understanding Makefiles COMP 2400, Fall 2008 Prof. Chris GauthierDickey.
Compilation & linkage.h read.h.c read.c.c main.c.c list.c.h list.h prog1 Linkage: g++ read.o main.o list.o –o prog1.o main.o.o list.o.o read.o Compilation:
1 The Makefile Utility ABC – Chapter 11,
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Software Engineering Recitation 7 Suhit Gupta. Review Anything from last time???
The Makefile Utility ABC – Chapter 11, Motivation Small programs single file “Not so small” programs : –Many lines of code –Multiple components.
Introduction to Make Updated by Prasad Spring 2000.
Guide To UNIX Using Linux Third Edition
G++ and make Dan Wilson CS193 02/01/06. The g++ Compiler What happens when you call g++ to build your program? Phase 1, Compilation:.cpp files are compiled.
Lecture 8  make. Overview: Development process  Creation of source files (.c,.h,.cpp)  Compilation (e.g. *.c  *.o) and linking  Running and testing.
Makefiles. makefiles Problem: You are working on one part of a large programming project (e. g., MS Word).  It consists of hundreds of individual.c files.
Make: the good, the bad, and the ugly Dan Berger Titus Winters
Enabling the ARM Learning in INDIA ARM DEVELOPMENT TOOL SETUP.
July 29, 2003Serguei Mokhov, 1 Makefile Brief Reference COMP 229, 346, 444, 5201 Revision 1.2 Date: July 18, 2004.
Makefiles. makefiles Problem: You are working on one part of a large programming project (e. g., MS Word).  It consists of hundreds of individual.cpp.
Introduction Use of makefiles to manage the build process Declarative, imperative and relational rules Environment variables, phony targets, automatic.
Makefile Introduction Jia – Wei Lin 1. Outline Why we use make ? Create a Description File Rules of Makefile How make Processes a Makefile? GCC Flags.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
System Programming - LAB 1 Programming Environments.
Makefile M.A Doman. Compiling multiple objects Card.cpp -> Card.o Deck.cpp -> Deck.o main.cpp -> main.o main.o Deck.o Card.o -> Dealer.exe.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
CSE 251 Dr. Charles B. Owen Programming in C1 Compilation and Makefiles.
Program Development Tools GNU make (much of this material is adapted from “GNU Make” by Richard Stallman) The make utility automatically determines which.
Data Display Debugger (DDD)
Tools – Ant-MakeEtc 1 CSCE 747 Fall 2013 CSCE 747 Software Testing and Quality Assurance Tools 12 – Hamcrest 10/02/
Makefiles CARYL RAHN. Separate compilation Large programs are generally separated into multiple files, e.g. main.c addmoney.c removemoney.c money.h With.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015 Makefile Tutorial CIS5027.
Modular Programming. Introduction As programs grow larger and larger, it is more desirable to split them into sections or modules. C allows programs to.
Lecture 8  make. Using make for compilation  With medium to large software projects containing many files, it’s difficult to: Type commands to compile.
Emacs, Compilation, and Makefile C151 Multi-User Operating Systems.
Make Make is a system utility that automatically compiles your programs for you Make looks for a file named Makefile (or makefile) in the current directory.
Multiple File Compilation and linking By Bhumik Sapara.
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
Brandon Packard. Why make? So far, you have probably worked on relatively small projects Coding projects can become huge My research consists of 1600.
CSc 352 An Introduction to make Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
Multiple file project management & Makefile
The make utility (original presentation courtesy of Alark Joshi)
CSE 303 Lecture 17 Makefiles reading: Programming in C Ch. 15
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Fall 2015
Brief Intro to Make CST494/ Gannod.
Compilation and Debugging
Compilation and Debugging
Makefiles Caryl Rahn.
SEEM3460 Tutorial The Make Utility.
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Hector Cen Fall 2017
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Rake 4-Dec-18.
Data Structures and Programming Techniques
Unix Programming Environment
CMPSC 60: Week 4 Discussion
Kyle Fitzpatrick Konstantin Zak 11/29/2004
Appendix F C Programming Environment on UNIX Systems
CSc 352: Elementary “make”
CSc 352 An Introduction to make
Compiler vs linker The compiler translates one .c file into a .o file
Makefiles, GDB, Valgrind
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
The make utility (original presentation courtesy of Alark Joshi)
Presentation transcript:

GNU Make

Make is a tool which controls: What Is GNU Make? Make is a tool which controls: the generation of executables and other non-source files of a program from the program's source files. From http://www.gnu.org/software/make

Capabilities of Make Enables the end user to build and install your package without knowing the details of how that is done Automatically build and intelligently rebuild Figures out which files it needs to update, based on which source files have changed and determines the proper order for updating files, in case one non-source file depends on another non-source file. if you change a few source files it does not recompile all of your program. Make is not limited to any particular language. the makefile calls the shell commands you need (e.g. runs a compiler to produce an object file, the linker etc…) Make is not limited to building a package. You can also use Make to control installing or deinstalling a package, build the docs etc.. From http://www.gnu.org/software/make

Writing a Makefile A rule in the makefile tells Make how to execute a series of commands target ... : dependencies ... command ... A target is usually the name of a file that is generated by a program (can also be the name of an action to carry out, such as `clean'). A dependency is a file that is used as input to create the target. A target often depends on several files. A command is an action that make carries out. put a tab character at the beginning of every command

Building a cake… cake: cake_mix eggs water icing mix cake_mix eggs water bake cake cool cake apply_icing cake icing cake_mix: money buy cake_mix money: job go to work job: ...

A simple Makefile edit : main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o cc -o edit main.o kbd.o command.o \ display.o insert.o search.o files.o \ utils.o main.o : main.c defs.h cc -c main.c kbd.o : kbd.c defs.h command.h cc -c kbd.c command.o : command.c defs.h command.h cc -c command.c display.o : display.c defs.h buffer.h cc -c display.c insert.o : insert.c defs.h buffer.h cc -c insert.c search.o : search.c defs.h buffer.h cc -c search.c files.o : files.c defs.h buffer.h command.h cc -c files.c utils.o : utils.c defs.h cc -c utils.c clean : rm edit main.o kbd.o command.o \ display.o insert.o search.o \ files.o utils.o

Variables A variable is defined with the syntax var_name = definition and is expanded with with $(var_name) objects = main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o … edit : $(objects) cc -o edit $(objects)

Comments and Pattern Rules “#” identifies comments Everithing follows “#” is considered to be a comment Pattern rules # Assemble the program. t1.%.o : t1.%.dlx dlxasm commands $* The stem with which an implicit rule matches. $@ The file name of the target of the rule. $< The name of the first dependency. $? The names of all the dependencies that are newer than the target, with spaces between them. $^ The names of all the dependencies, with spaces between them.

Special target names .PHONY : clean clean : -rm edit $(objects) .SILENT make will not the print commands to remake those particular files before executing them. …and more (see the manual)

What Makefiles Contain Explicit rules says when and how to remake one or more files, called the rule's targets. Implicit rule says when and how to remake a class of files based on their names. A variable definition is a line that specifies a text string value for a variable A directive is a command for make to do something special while reading the makefile. `#' in a line of a makefile starts a comment.

For further info: On Unix/Linux write “man make” On the Internet: http://www.gnu.org/software/make/ http://www.gnu.org/software/make/manual/ http://www.student.cs.uwaterloo.ca/~isg/res/unix/make/tutorial/index.html

A working example ….the DLV Makefile