SEEM3460 Tutorial The Make Utility.

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.
CS201 – Makefile Tutorial. A Trivial Makefile # Trivial Makefile for puzzle1.c # Ray S. Babcock, CS201, MSU-Bozeman # 1/5/05 # puzzle1: puzzle1.c gcc.
The Makefile utility ABC – Chapter 11, Motivation Small programs single file “Not so small” programs : –Many lines of code –Multiple components.
Understanding Makefiles COMP 2400, Fall 2008 Prof. Chris GauthierDickey.
1 The Makefile Utility ABC – Chapter 11,
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.
2000 Copyrights, Danielle S. Lahmani UNIX Tools G , Fall 2000 Danielle S. Lahmani Lecture 9.
CS465 - Unix C Programming (cc/make and configuration control)
Computer Science 210 Computer Organization Modular Decomposition Making a Library Separate Compilation.
Lecture 8  make. Overview: Development process  Creation of source files (.c,.h,.cpp)  Compilation (e.g. *.c  *.o) and linking  Running and testing.
July 29, 2003Serguei Mokhov, 1 Makefile Brief Reference COMP 229, 346, 444, 5201 Revision 1.2 Date: July 18, 2004.
Jump to first page (C) 1998, Arun Lakhotia 1 Software Configuration Management: Build Control Arun Lakhotia University of Southwestern Louisiana Po Box.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
System Programming - LAB 1 Programming Environments.
C Tutorial - Program Organization CS Introduction to Operating Systems.
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.
1 CSE 390 Lecture 8 Large Program Management: Make; Ant slides created by Marty Stepp, modified by Jessica Miller and Ruth Anderson
The Make utility. Motivation Small programs all in single cpp file “Not so small” programs : Many lines of code Multiple components More than one programmer.
0 4.1 Basics of Functions + Execution Diagram + make 4.2 Functions Returning Non-integers + Prototype Function 4.3 External Variables 4.4 Scope Rules 4.5.
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
Copyright © 2015 Curt Hill Make An Indispensable Developer’s Tool.
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.
Lecture 8  make. Using make for compilation  With medium to large software projects containing many files, it’s difficult to: Type commands to compile.
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.
C code organization CSE 2451 Rong Shi. Topics C code organization Linking Header files Makefiles.
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
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"
UNIX Development: g++ and make CS 2204 Class meeting 8 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
CSCI 4061 Recitation 2 1.
Makefiles CSSE 332 Operating Systems
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
Large Program Management: Make; Ant
Makefiles Caryl Rahn.
SCMP Special Topic: Software Development Spring 2017 James Skon
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
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
Large Program Management: Make; Ant
Makefiles and the make utility
Large Program Management: Make; Ant
Computer Science 210 Computer Organization
Data Structures and Programming Techniques
Data Scenario: Header and Details files
Header files.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
SCMP Software Development Spring 2018 James Skon
Large Program Management: Make; Ant
CSc 352: Elementary “make”
Large Program Management: Make; Ant
GNU Make.
Large Program Management: Make; Ant
Makefiles and the make utility
CSC 253 Lecture 15.
Introduction to Programming - 1
SCMP Software Development Spring 2018 James Skon
Large Program Management: Make; Ant
The make utility (original presentation courtesy of Alark Joshi)
Presentation transcript:

SEEM3460 Tutorial The Make Utility

Basic Structure of A Make File Line of target and dependency (a rule) target1: part1.o part2.o #this line and the line below are comments #part1.o and part2.o here are dependents Lines of operations describing the updating process [tab]gcc -o target1 part1.o part2.o [tab]chmod 711 target1 The tab character is necessary!

Basic Structure of A Make File Multiple targets can be put in same file: target1: part1.o part2.o [tab]gcc -o target1 part1.o part2.o part1.o: part1.c part1.h [tab]gcc -c part1.c part2.o: part2.c [tab]gcc -c part2.c

Flow of Make Process target1 (8 if 4 or 7): update part1.o (4): date check (3 if 1 or 2): update part1.c (1): date check part1.h (2): date check part2.o (7): date check (6 if 5): update part2.c (5): date check

The Make Utility Update according to Makefile: make -f makefile1 Update part1.o according to makefile1: make -f makefile1 part1.o Other switches: -k (continue other targets when a target errs) -n (do not execute but print the commands) -s (execute but do not print the commands)

Extensive Use of Make Files The use of a make file is never limited to just compiling a program Example 1: Update a piece of output output1.txt: input1.txt [tab]program1 < input1.txt > output1.txt Example 2: Clear temporary files clear: [tab]rm -f tempfile1 tempfile2

Macros (Extra) Macros can be used in make files functioning as variables. The $(marconame) pattern is used to take the value of the macro E.g. CC = gcc part1.o: part1.c part1.h [tab]$(CC) -c part1.c

Special Macros (Extra) There are some special macros that you can use without defining them $@: name of target $?: name of changed dependents E.g. final: part1.c part2.c [tab]gcc -c $? [tab]gcc -o $@ part1.o part2.o