Copyright © 2015 Curt Hill Make An Indispensable Developer’s Tool.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
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.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
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.
The Makefile Utility ABC – Chapter 11, Motivation Small programs single file “Not so small” programs : –Many lines of code –Multiple components.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Lecture 8  make. Overview: Development process  Creation of source files (.c,.h,.cpp)  Compilation (e.g. *.c  *.o) and linking  Running and testing.
A First Program Using C#
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Unix Makefiles COP 3330 Lecture Notes Dr. David A. Gaitros.
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.
Lecture Set 2 Part B – Configuring Visual Studio; Configuration Options and The Help System (scan quickly for future reference)
Copyright © Curt Hill Java Looking at our first console application in Eclipse.
Scons Writing Solid Code Overview What is scons? scons Basics Other cools scons stuff Resources.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
Copyright © 2005 Curt Hill Constants in C++ Why and How.
Chapter 13. Applets and HTML HTML Applets Computer Programming with JAVA.
Hans-Peter Plag November 6, 2014 Session 4 (Programming Languages) (Data Types and Variables) Expressions and Operators Flow Control.
The Makefile (in a windows environment) Make reads its instructions from text files. An initialization file is read first, followed by the makefile. The.
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.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
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.
Copyright © 2015 Curt Hill Java for Minecraft Those things you should know.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Interfaces About Interfaces Interfaces and abstract classes provide more structured way to separate interface from implementation
Copyright © 2012 MICS‘12 and Curt Hill Development Systems: A Review Curt Hill Professor of Math and Computer Science Valley City State University
Parser Generation Using SLK and Flex++ Copyright © 2015 Curt Hill.
Copyright © Curt Hill The Compound Statement C-Family Languages and Scope.
Makefiles CARYL RAHN. Separate compilation Large programs are generally separated into multiple files, e.g. main.c addmoney.c removemoney.c money.h With.
Scanner Generation Using SLK and Flex++ Followed by a Demo Copyright © 2015 Curt Hill.
Emacs, Compilation, and Makefile C151 Multi-User Operating Systems.
Batch Files Weaker form of UNIX shell scripts. Introduction UNIX may use one of several shells The shell is the command interpreter It interacts with.
Batch Files Weaker form of UNIX shell scripts Copyright © by Curt Hill.
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:
Copyright © Curt Hill Simple I/O Input and Output using the System and Scanner Objects.
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
1 Week 8 Creating Simple Shell Scripts. 2 Chapter Objectives  In this chapter, you will :  Learn how to create Shell Scripts  Commenting / Making Portable.
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.
Batch Files More flow of control Copyright © by Curt Hill.
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
C Copyright © 2009, Oracle. All rights reserved. Using SQL Developer.
The Second C++ Program Variables, Types, I/O Animation!
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Fall 2015
PowerShell Introduction Copyright © 2016 – Curt Hill.
Brief Intro to Make CST494/ Gannod.
Using SLK and Flex++ Followed by a Demo
Makefiles Caryl Rahn.
SEEM3460 Tutorial The Make Utility.
Parser and Scanner Generation: An Introduction
Assembler, Compiler, Interpreter
Copyright © – Curt Hill Bash Scripting Fundamentals Copyright © – Curt Hill.
Compilers, Make and SubVersion
Accomplishing Executables
Cmdlets “Command-lets”
Copyright © – Curt Hill Bash Flow of Control Copyright © – Curt Hill.
Assembler, Compiler, Interpreter
Writing Large Programs
PowerShell Flow of Control Copyright © 2016 – Curt Hill.
Java Looking at our first console application in Eclipse
Compiler vs linker The compiler translates one .c file into a .o file
SPL – PS1 Introduction to C++.
Presentation transcript:

Copyright © 2015 Curt Hill Make An Indispensable Developer’s Tool

Introduction Make is the name of a “scripting language” interpreter –Designed specifically for compiling and linking a programming project Originally a UNIX program Has escaped the UNIX ecosystem and is now everywhere Refers to any of a set of programs that do approximately the same thing Every IDE either uses an existing make or has a custom one Copyright © 2015 Curt Hill

Components There are typically two –The program itself –The script file that describes the executable build process This often has the name make or makefile With or without an extension Copyright © 2015 Curt Hill

Process Making a project is a matter of checking dependencies and dates A dependency exists when one file depends upon another Thus the executable usually depends upon object files –Object files depend upon source files If an item is older than what it depends upon it must be rebuilt Copyright © 2015 Curt Hill

Example Suppose x.exe depends upon x.obj, date.obj and classy.obj When make is executed it finds that x.exe is newer than data.obj and x.obj but older than classy.obj It now knows that it must re-link x.exe so as to incorporate the new class.obj It does the same process for obj files that depend on source files –Thus it only compiles and/or links what is out of date Copyright © 2015 Curt Hill

Statement Types Comments – not really a statement Assignments Directives Implicit rules Explicit rules Copyright © 2015 Curt Hill

Syntax Comments are indicated by an octothorp (#) –These are ignored –Standard UNIX scripting practice Assignment statement has a mostly standard format –Variable = expression –The expression does not necessarily look like a C style expression –Often files separated by blanks Copyright © 2015 Curt Hill

Explicit Rules General form is two lines target: dependencies [tab] system commands Targets are typically executables or object files –Other things possible The dependencies are one or more files that the target needs to be built The command is how to accomplish it Copyright © 2015 Curt Hill

Explicit Rules Again The usual form is target as a file: xyz.o: xyz.cpp classy.h [tab] gcc –c xyz.cpp If either classy.h or xyz.cpp is newer than xyz.o or if xyz.o does not exist then gcc with the c option is run on xyz.cpp Copyright © 2015 Curt Hill

Target Usually the target is a file like that previously shown Does not have to be a real file We could do something like: all: xyz.cpp classy.cpp [tab]gcc xyz.cpp classy.cpp The normal execution of gcc will produce xyz.exe not all or all.exe Copyright © 2015 Curt Hill

The $ The $ function is an inclusion of variable’s value Form: $(variable) Thus if we have: CPP = g++.exe Then we later see: $(CPP) -c ggapp.cpp This becomes the command line: g++.exe -c ggapp.cpp We can now easily change compilers or set options Copyright © 2015 Curt Hill

Example: This is from a DevC++ make file Create ggFrm.o Objects/MingW/ggFrm.o: $(GLOBALDEPS) ggFrm.cpp ggFrm.h date.h $(CPP) -c ggFrm.cpp –o Objects/MingW/ggFrm.o $(CXXFLAGS) Copyright © 2015 Curt Hill

Implicit Rules Also known as inference rules This keeps us from explicitly specifying all the rules explicitly Usually involve a wildcard character % Consider the following implicit rule: %.obj : %.cpp [tab] $(CPP) –c $(.SOURCE) This says: whenever you need an object file, such as x.obj, then do a gcc –c x.cpp Copyright © 2015 Curt Hill

Directives If statements that allow some alternatives The keywords are if, else, elif, endif –Sometimes these are prefixed by a % or ! in various derivatives This allows us to parameterize a makefile Copyright © 2015 Curt Hill

Example: if $(CC) == bcc LDFLAGS = /Lf:\bc\lib elif $(CC) == cl LDFLAGS = /Lf:\c6\lib; else abort endif Copyright © 2015 Curt Hill

Languages Do not be confused, the C family is not the only language processing that can occur Many C/C++ projects have one or more subroutines in assembly –FORTRAN numerical routines are also common Most GUIs in Windows have a source file, often a.rc, that compiles into a.res file –Wxforms compile eventually into.res Copyright © 2015 Curt Hill

DevC++ Uses a rather normal UNIX style make The script is in: makefile.win –Even in a console program Program itself is: …\MinGW32\bin\mingw32-make.exe The project file is not the make file –It looks like a UNIX initialization file Copyright © 2015 Curt Hill

Alternatives There is no compelling reason why a system has to follow the UNIX pattern for a make file Eclipse merely compiles all Java files in the projects directory Visual Studio has a proprietary (and hidden) make process Borland/CodeGear/Embarcadero used a variant of UNIX make up through version 6 and then switched to an XML format Copyright © 2015 Curt Hill

References Here are some web references for more information: ses/tutorials/maketutor/ ses/tutorials/maketutor/ all/unixhelp/howto_makefiles.htmlhttp:// all/unixhelp/howto_makefiles.html TutMakefile.htmhttp:// TutMakefile.htm Copyright © 2015 Curt Hill

Finally We should browse through a make file or two Inher_demo has several classes including an inheritance hierarchy Projects\p2c\src\make is a standard UNIX make Copyright © 2015 Curt Hill