Brandon Packard. Why make? So far, you have probably worked on relatively small projects Coding projects can become huge My research consists of 1600.

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.
ANT: Another Nice Tool Ali Beyad October 1, 2003.
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.
1 CSE 390 Lecture 8 Large Program Management: Make; Ant slides created by Marty Stepp, modified by Josh Goodwin
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:
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.
Basic linux shell commands and Makefiles. Log on to engsoft.rutgers.edu Open SSH Secure Shell – Quick Connect Hostname: engsoft.rutgers.edu Username/password:
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.
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.
July 2011CMSC 341 CVS/Ant 1 CMSC 341 Java Packages Ant CVS Project Submission.
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
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).
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;
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
Data Display Debugger (DDD)
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.
Object Oriented Programming COP3330 / CGS5409.  Assignment Submission Overview  Compiling with g++  Using Makefiles  Misc. Review.
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.
Problem Solving With C++ Recitation – make February 2016.
Multiple File Compilation and linking By Bhumik Sapara.
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:
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
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.
Object Oriented Programming COP3330 / CGS5409.  Assignment Submission Overview  Compiling with g++  Using Makefiles  Misc. Review.
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
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
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
Large Program Management: Make; Ant
Makefiles and the make utility
Large Program Management: Make; Ant
Data Structures and Programming Techniques
CSE 390 Lecture 8 Large Program Management: Make; Ant
CMSC 202 Additional Lecture – Makefiles
SCMP Software Development Spring 2018 James Skon
Large Program Management: Make; Ant
Build Tools (make) CSE 333 Autumn 2018
Large Program Management: Make; Ant
GNU Make.
Large Program Management: Make; Ant
Makefiles and the make utility
CSE 390 Lecture 8 Large Program Management: Make; Ant
SCMP Software Development Spring 2018 James Skon
SPL – PS1 Introduction to C++.
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.
g++ features, better makefiles
Large Program Management: Make; Ant
Presentation transcript:

Brandon Packard

Why make? So far, you have probably worked on relatively small projects Coding projects can become huge My research consists of 1600 java files (not all written by me of course)

Are makefiles worth it? Imagine typing out javac file1.java, file2.java, file3.java, …., file1600.java Could store the compilation command in a text file, but there is an easier way

What is make? Make is a tool that lets you compile code with a single small command. Implemented on tux, with the “make” command. Requires a Makefile to work

Writing a Makefile 4 major pieces (for our purposes): Variables Targets Commands Prerequisites

Variables Declared at the top of the file Much like variables in bash CC = g++ Now you can use $(CC) instead of g++

Variables Variables can be set to represent an entire group of files Can make the main body of the make file much easier to read.

Targets These are what you reference from the command line For makefiles that can do multiple things, this lets you specify which behaviour you want Syntax is the name of the target followed by a colon.

Target examples clean: run: To run the clean target, you would type “make clean” at the command line. Default target is the first one in the file.

Commands These are what get executed when you run make. Go on the line under the target Can compile code, run files, clean up directories, mostly anything you can do in the shell

Example Commands $(CC) -c markov.cpp Compiles the code but does not link it rm -f *.o Removes all object files from the current directory $(someProgram) > $(someFile) Runs the program in the first variable and puts the output to the file held as the second variable

Prerequisites Used to the commands have the files they need Can also be used to order targets If the prerequisite is empty, another target may be ran to obtain it

Prerequisites Are placed on the same line as the target, after the colon: run: someJavaFile.class If the class file is not present, make will try to obtain it by running other targets (such as a compile target)

A (fairly) simple make file RESULT=hello all: $(RESULT) $(RESULT): main.o g++ main.o -o $(RESULT) main.o: main.cpp g++ -c main.cpp clean: rm -rf *o $(RESULT)

A (fairly) simple make file RESULT=hello all: $(RESULT) $(RESULT): main.o g++ main.o -o $(RESULT) main.o: main.cpp g++ -c main.cpp clean: rm -rf *o $(RESULT) Variable Target Prerequisite Command

A (fairly) simple make file RESULT=hello all: $(RESULT) $(RESULT): main.o g++ main.o -o $(RESULT) main.o: main.cpp g++ -c main.cpp clean: rm -rf *o $(RESULT) Command: make all (assume we only have main.cpp) 1. all target calls the RESULT target 2. RESULT needs main.o, but does not have it. Calls main.o target

A (fairly) simple make file RESULT=hello all: $(RESULT) $(RESULT): main.o g++ main.o -o $(RESULT) main.o: main.cpp g++ -c main.cpp clean: rm -rf *o $(RESULT) 3. main.o target runs this command to compile (but not link) main.cpp 4. RESULT now has its prerequisites fulfilled - links object file into executable Command: make all (assume we only have main.cpp)

A (fairly) simple make file RESULT=hello all: $(RESULT) $(RESULT): main.o g++ main.o -o $(RESULT) main.o: main.cpp g++ -c main.cpp clean: rm -rf *o $(RESULT) command: make clean the clean target will remove all of the object files in the directory, as well as the executable

Makefiles can be very complex Makefiles can be full of special targets, implicit rules, and even conditionals Simple makefiles should suit our purposes well enough Will be using make files to submit your other programming assignments

Fin Questions? Comments? Concerns? Doubts about my sanity?