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.

Slides:



Advertisements
Similar presentations
The make Utility Programming Tools and Environments Winter 2006.
Advertisements

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.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Systems Dev. Tutorial II: Make, utilities, & scripting Recitation Wednesday, Sept 13 th, 2006.
CS 202 Computer Science II Lab Fall 2009 September 17.
1 CS 201 Makefile Debzani Deb. 2 Remember this? 3 What is a Makefile? A Makefile is a collection of instructions that is used to compile your program.
Basic linux shell commands and Makefiles. Log on to engsoft.rutgers.edu Open SSH Secure Shell – Quick Connect Hostname: engsoft.rutgers.edu Username/password:
CS465 - Unix C Programming (cc/make and configuration control)
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.
Chapter 3 Getting Started with C++
Unix Makefiles COP 3330 Lecture Notes Dr. David A. Gaitros.
July 29, 2003Serguei Mokhov, 1 Makefile Brief Reference COMP 229, 346, 444, 5201 Revision 1.2 Date: July 18, 2004.
Introduction make is a UNIX utility for building projects that are comprised of multiple source filesmake is a UNIX utility for building projects that.
Adv. UNIX: large/131 Advanced UNIX v Objectives of these slides: –learn how to write/manage large programs consisting of multiple files, which.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
Multiple Files. Monolithic vs Modular  one file before  system includes  main driver function  prototypes  function.
CSC 221: Computer Programming I Fall 2001  C++ basics  program structure: comments, #include, main, return  output: streams, cout, endl  input: variables,
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, Geany CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 05, 2005 Lecture Number: 4.
Navigating the C++ Development Environment
Makefiles CARYL RAHN. Separate compilation Large programs are generally separated into multiple files, e.g. main.c addmoney.c removemoney.c money.h With.
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.
Multiple File Compilation and linking By Bhumik Sapara.
C code organization CSE 2451 Rong Shi. Topics C code organization Linking Header files Makefiles.
Dayu Zhang 9/10/2014 Lab03. Outline Brief Review of the 4 Steps in Hello.cpp Example Understand endl and \n Understand Comment Programming Exercise -
Brandon Packard. Why make? So far, you have probably worked on relatively small projects Coding projects can become huge My research consists of 1600.
Makefile Script file to automate program compilation and linking (making) 1. Write the "makefile" 2. Write your programs 3. Run "make" or "make -f makefile"
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
UNIX Development: g++ and make CS 2204 Class meeting 8 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Software Engineering Algorithms, Compilers, & Lifecycle.
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
Multiple file project management & Makefile
The make utility (original presentation courtesy of Alark Joshi)
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Fall 2015
Topic Pre-processor cout To output a message.
Brief Intro to Make CST494/ Gannod.
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
Compilation and Debugging
Compilation and Debugging
Makefiles Caryl Rahn.
SEEM3460 Tutorial The Make Utility.
SCMP Special Topic: Software Development Spring 2017 James Skon
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
Chapter 2 – Getting Started
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Makefiles and the make utility
Data Structures and Programming Techniques
CMPSC 60: Week 4 Discussion
CMSC 202 Additional Lecture – Makefiles
SCMP Software Development Spring 2018 James Skon
CSCE-221 Makefile Introduction
CSc 352: Elementary “make”
Makefiles and the make utility
Compiler vs linker The compiler translates one .c file into a .o file
Introduction to Programming - 1
SCMP Software Development Spring 2018 James Skon
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:

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 –Describes the relationships among files that comprise you program –Gives the commands for updating each file Using the Makefile, make automatically: –Determines which files need to be recompiled –Issues the commands to recompile them

A Simple Program // hello.cpp #include #include “hello.h” using namespace std; int main() { cout << MESSAGE << endl; }

The Header File // hello.h #define MESSAGE "Hello World!"

Compiling and Running the Program Compiling: –g++ -O2 -o hello hello.cpp Running –./hello Result: –Hello World!

Makefile Composed of: –Comments (from a pound sign to the end of a line) # This is a comment –Macros – just like in your program CFLAGS= -O2 –Targets – lists dependencies and rules for updating hello: hello

The Makefile # Makefile for hello.cpp CFLAGS = -O2 hello: hello.h hello.cpp g++ $(CFLAGS) -o hello hello.cpp

Compiling and Running the Program with Make Compiling: –make Running –./hello Result: –Hello World! Note: make is really unnecessary for such a simple program, but is essential for programs with lots of source files

Make - Pitfalls Make is very picky about some things: –Indenting must be done with tabs not spaces –Dependencies must be correct If nothing has changed make will tell you the target is “up to date”

A More Complicated Example 5 source files Some shared header files Multiple targets –Make creates the first target by default E.g. make –You can specify others: E,g, make clean

Let’s Write a Makefile 3 header files –src1.h – used by src1.cpp –src2.h – used by src2.cpp –global.h – used by src1.cpp, src2.cpp, and main.cpp 4 source files –src1.cpp – routines used by main.cpp –src2.cpp – routines used by main.cpp –src3.cpp – routines used by src2.cpp –main.cpp – main program

Questions What will make do if we touch: –global.h? –src1.h? –src2.h? –src3.cpp? –main.cpp?