Jump to first page (C) 1998, Arun Lakhotia 1 Software Configuration Management: Build Control Arun Lakhotia University of Southwestern Louisiana Po Box.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

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.
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.
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 20 static make.
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.
The Makefile Utility ABC – Chapter 11, Motivation Small programs single file “Not so small” programs : –Many lines of code –Multiple components.
CS Lecture 11 Outline Compiling C programs using gcc Archiving modules Using Makefiles Debugging using gdb Assignment 3 discussion Lecture 111CS.
26-Jun-15 Rake. rake and make A program can consist of many source code files This is always true in Rails! The files may need to be compiled in a certain.
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
2000 Copyrights, Danielle S. Lahmani UNIX Tools G , Fall 2000 Danielle S. Lahmani Lecture 9.
CS465 - Unix C Programming (cc/make and configuration control)
1 Building. 2 Goals of this Lecture Help you learn about: The build process for multi-file programs Partial builds of multi-file programs make, a popular.
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.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Make: the good, the bad, and the ugly Dan Berger Titus Winters
Introduction to Shell Script Programming
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.
Configuration Management (CM)
리눅스 : Lecture 5 UNIX 유틸리티 : text editor, compilation (make), …
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
Jump to first page (c) 1999, A. Lakhotia 1 Software engineering? Arun Lakhotia University of Louisiana at Lafayette Po Box Lafayette, LA 70504, USA.
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
The Makefile (in a windows environment) Make reads its instructions from text files. An initialization file is read first, followed by the makefile. The.
Jump to first page (C) 1998, Arun Lakhotia 1 Software Configuration Management: Version Control Arun Lakhotia University of Southwestern Louisiana Po Box.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
Week 2-3 Control flow (review) Conditional statements If, else, else if, switch-case, break Loop constructs for, while, do-while, break, continue, label--go;
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
Configuration Management CSCI 5801: Software Engineering.
Makefiles CARYL RAHN. Separate compilation Large programs are generally separated into multiple files, e.g. main.c addmoney.c removemoney.c money.h With.
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.
C code organization CSE 2451 Rong Shi. Topics C code organization Linking Header files Makefiles.
CSI605 Introduction to make. Advantages of Make Significantly reduces the amount of time spent compiling a program. Insures that programs are compiled.
Chapter Linux Basics. Acknowledgements This presentation was prepared by – Banyat Settapanich – Bahran Madaen This presentation will be updated later.
Build Tools 1. Building a program for a large project is usually managed by a build tool that controls the various steps involved. These steps may include:
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"
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.
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
Hank Childs, University of Oregon April 13 th, 2016 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / /
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.
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
Makefiles and the make utility
Rake 4-Dec-18.
Data Structures and Programming Techniques
CMPSC 60: Week 4 Discussion
Build Tools (make) CSE 333 Autumn 2018
CSc 352 An Introduction to make
Makefiles and the make utility
The make utility (original presentation courtesy of Alark Joshi)
Presentation transcript:

Jump to first page (C) 1998, Arun Lakhotia 1 Software Configuration Management: Build Control Arun Lakhotia University of Southwestern Louisiana Po Box Lafayette, LA 70504, USA

Jump to first page (C) 1998, Arun Lakhotia 2 Software Configuration Management n Practice of handling changes systematically n Three components u Build control u Version control u Change control

Jump to first page (C) 1998, Arun Lakhotia 3 Build control n Maintaining the consistency between components, in particular the derived components. n Derived components u Executables u Hardcopy manuals u Compact Disk u Test results and summaries

Jump to first page (C) 1998, Arun Lakhotia 4 Dynamic dependencies User Requirements Test results Test cases Executable Hardcopy document Code Electronic document

Jump to first page (C) 1998, Arun Lakhotia 5 Need for automated support n Forgettng to create “derived components” leads to incosistent executables, manuals, etc. n Creation of “derived components” manually is tedious, repetituous, and boring. n The relationship (inputs, outputs, transforms) are static n Over time one forgets the mechanisms for transforming inputs to outputs n The same transformation sequence can be applied else where.

Jump to first page (C) 1998, Arun Lakhotia 6 General pattern of deriving components C1 C2 C3 C4 C5 C6 C7 I2 I1 I3 I4 T4 T3 T2 T1 T5T6 D0 Ti: Transformers Ci: Input components Ik: Intermediate components Di: Output (final) component

Jump to first page (C) 1998, Arun Lakhotia 7 Specific example: Deriving executable WordDriver.c WordDriver.h acc WordFile.c WordFile.o WordDriver.o WordFile.h Library WordDriver If any of the.c or.h file changes then WordDriver should be recreated

Jump to first page (C) 1998, Arun Lakhotia 8 Information needed to build components n The sources n The targets n The rules used to create targets from sources n Example u Source: file.c file.h u Target: file.o u Rule: acc -c file.c

Jump to first page (C) 1998, Arun Lakhotia 9 Make: A tool to manage builds n Requires u Components u Dependencies u Transformation rules n Provides u Language to describe the above u Language allows expression of very general rules u Will check for consistency between sources and targets u Will invoke commands necessary to create targets from sources

Jump to first page (C) 1998, Arun Lakhotia 10 Make language Target ‘:’ source1 source2 source3 rule Tab file.o : file.c acc -c file.c Tab WordDrive.o: WordDriver.c WordFile.h acc -c WordDriver.c WordFile.c: WordFile.c WordFile.h acc -c WordFile.c WordDriver: WordDriver.o WordFile.o acc -o WordFile WordDriver.o WordFile.o

Jump to first page (C) 1998, Arun Lakhotia 11 Using Make n Create Makefile. Place the dependencies and generation rles in it. n Run Make u % rm *.o u % make WordDriver Make will invoke the following commands acc -c WordFile.c acc -c WordDriver.c acc -o WordFile WordFile.o WordDriver.o u % make WordDriver Make will say ‘WordDriver’ is up to date. % touch WordFile.c (mark the file as changed) % make WordDriver acc -c WordFile.c acc -o WordFile WordFile.c WordDriver.c

Jump to first page (C) 1998, Arun Lakhotia 12 How make detects change? n Make compares the date of creation of the sources and targets n If a source is more recent than a target, it assumes that the source has changed and that the target should be recreated n What are the drawbacks of this logic?

Jump to first page (C) 1998, Arun Lakhotia 13 Builtin rules n Make has a language to express dependencies based on file extensions.c,.o,.h,.etc n It has some predefined rules to create object files and executable files for various programming languages n So it can do a lot of processing without a Makefile

Jump to first page (C) 1998, Arun Lakhotia 14 Using Built-in rules n Assume Makefile has no rule for Formatter.o % make Formatter.o cc -sun4 -c Formatter.c n How do you say which compiler to use? u Introduce the following line in the Makefile CC= gcc u It says use “gcc” for compiling. n How do you provide compiler options? u Assign option values to CFLAGS CFLAGS= -DFLAG=1 -g

Jump to first page (C) 1998, Arun Lakhotia 15 Using Make variables n CC and CFLAGS are make variables n You can introduce your own make variables n How do you assign value to a variable? VARIABLE= value n How do you USE value of a variable? $(VARIABLE) gives the variables value. n Variables can be used to reduce repetition in Makefiles

Jump to first page (C) 1998, Arun Lakhotia 16 Example Makefile # EXEC gives the name of the executable EXEC = WordDriver # The variable OBJS gives the name of the.o files needed to # create the executable OBJS = WordFile.o WordDriver.o # The following define CC and CFLAGS to be used for compiling # and linking the files CC = gcc CFLAGS = -g # The following rule states how to generate $(EXEC) from $(OBJS) $(EXEC): $(OBJS) $(CC) $(CFLAGS) -o $(EXEC) $(OBJS)

Jump to first page (C) 1998, Arun Lakhotia 17 Using Make for testing n Components u Input file:.dat u Output file:.res n Dependencies: Program “pgm” transforms Input file to Output file n Transformation rule % pgm input.dat > output.res n Test case files: file1.dat, file2.dat, file3.dat … file1.res : file1.dat pgm file1.dat > file1.res file2.res: file2.dat pgm file2.dat > file2.res...

Jump to first page (C) 1998, Arun Lakhotia 18 Introducing transformation rules n Rule for transforming.dat file to.res file. % is a pattern match symbol. %.res matches with any file name with.res extension. The rule says a file “xxx.res” can be created from “xx.dat” $< represents the source represents the target %.res : %.dat pgm $

Jump to first page (C) 1998, Arun Lakhotia 19 Generating filenames in Makefile n You may like to generate the name of.o file from the name of.c file, instead of hardcoding them. n This can be achieved by doing substitution within a pattern match variable, as below. n $(SRC:%.c=%.o) replaces all names with.c to names with.o. The match is performed a “word” at a time. SRC = file1.c file2.c file3.c OBJS = $(SRC:%.c=%.o) EXEC = pgm $(EXEC) : $(OBJS) $(CC) -o $(EXEC) $(OBJS)

Jump to first page (C) 1998, Arun Lakhotia 20 Generating source filenames n Even typing in the name of the source files is not always desirable n One may want the names to be picked up from the directory n This is particularly useful for testcase files n In the following the suffix “:sh” says that execute the value being assigned to TESTCASES as a shell command and assign the output to TESTCASES. n Names of.res files are then generated from the names of.dat files TESTCASES:sh = echo *.dat RESFILES = $(TESTCASES:%.dat=%.res)

Jump to first page (C) 1998, Arun Lakhotia 21 Generating.h dependencies n The.o <--.h dependency can be generated automatically using makedepend. % makedepend f1.c f2.c f3.c … modifies the Makefile and introduces.o/.h dependency. SRCS= f1.c f2.c f3.c makedepend: makedepend $(SRCS) To generate the dependencies introduce the above in your Makefile and give the following command: % make makedepend

Jump to first page (C) 1998, Arun Lakhotia 22 Summary: Make n Make provides a language to describe chains of dependencies and transformation rules to generate derived components n The transformation rules can be written for an individual set of files or for a whole class of files n Its language provides macro variables, mechanism to use pattern match to substitute values in variable, and for assigning output of shell command to a variable.