SlideShare a Scribd company logo
Introduction Compiling Makefiles Example Extras




                                Making makefiles
                                  Tutorial for CS-2810


                                       Subhashini V

                                          IIT Madras




                                  Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras



Outline
   Introduction
       Motivation
   Compiling
     Object file
   Makefiles
     Macros
     Naming
     Phony-Targets
   Example
   Extras
      Default-rules
      Remarks

                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Motivation




         The why, what and how of makefiles for you and me.




                                        Figure: xkcd


                (comic is for sudo, but who cares, it has ‘make’)


                                  Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Motivation



Why makefiles?




         Lots of source files: foo1.h, foo2.h, foobar1.cpp, foobar2.cpp
         How to manage them all?
         Compiling is complicated!!!




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Motivation



Why makefiles?




         Lots of source files: foo1.h, foo2.h, foobar1.cpp, foobar2.cpp
         How to manage them all?
         Compiling is complicated!!!
         Solution: make




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Motivation



What are makefiles?




         make - automagically build and manage your programs.
         compile quickly with a single command
         recompile is even quicker




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Motivation



How does it work?



         Give targets (usually a file to be created)
         Specify dependencies for each target.
         Give command to create target from dependencies.
         ‘make’ recursively builds the targets from the set of
         dependencies.
         recompilation - time-stamp of modification




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Object file



.h and .cpp



   .h files contain
         declarations.
         functions that the class promises.
   .cpp files contain
         definitions
         implementations of the promised methods.
         other functions that are not a part of any class.




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Object file



BigInt assignment example




   The BigInt data type in RSA
         BigInt.h - with proposed methods : +, -, *, /, !
         BigInt.cpp - with implementation of methods
         rsa.cpp - ONLY needs #include “BigInt.h”.
         Don’t need BigInt.cpp.




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Object file



Creating Object file

   object file or (.o file)
         For creating rsa.o, no need to include BigInt.cpp!
         Eventually need BigInt.cpp for running.
         Link later.
         You also don’t need main()
   Command:

         g++ -Wall -c rsa.cpp

     * -Wall : all warnings turned on
     * -c : Compiles but doesn’t link



                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Macros Naming Phony-Targets



Makefiles!
   A makefile describes the dependencies between files.




                               Figure: Content of a Makefile


                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Macros Naming Phony-Targets



Targets, Dependencies, Commands




         Target is usually a file. Remember “:”
         Dependencies : .cpp, corresponding .h and other .h files
         Determining dependencies.
         the all important [tab]
         Commands : can be multiple




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Macros Naming Phony-Targets



Use macros!

   Like #define

   OBJS = rsa.o main.o
   CPP = g++
   DEBUG = -g
   CPPFLAGS = -Wall -c $(DEBUG)
   LDFLAGS = -lm

   Usage: $(variable)
   rsa : $(OBJS)
             $(CPP) $(LDFLAGS) $(OBJS) -o rsa
         Automatic variables : $@ , $<, $^ ...



                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Macros Naming Phony-Targets



Naming the file



   Naming and running the make file.
         makefile - run with make
         Makefile - run with make
         give any filename - run as make -f < filename >
   make picks the first target in the file and executes the commands
   if the dependencies are more recent than the target.




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras    Macros Naming Phony-Targets



Phony targets


   Dummy targets to run commands. They don’t actually create files.
         make all
         make clean
         make tar
   Use .PHONY or directly the name.

.PHONY: clean
                                                    Or           clean:
clean:
                                                                      rm -f *.o *~ rsa
     rm -f *.o *~ rsa




                                     Subhashini V    Tutorial on make
Introduction Compiling Makefiles Example Extras



Makefile

OBJS = rsa.o main.o BigInt.o
CPP = g++
DEBUG = -g
CPPFLAGS = -Wall -c $(DEBUG)
LDFLAGS = -lm

rsa :   $(OBJS)
          $(CPP) $(LDFLAGS) $(OBJS) -o rsa
main.o : main.cpp BigInt.h rsa.h
          $(CPP) $(CPPFLAGS) main.cpp -o $@
rsa.o : rsa.cpp rsa.h BigInt.h
          $(CPP) $(CPPFLAGS) rsa.cpp -o $@
BigInt.o : BigInt.cpp BigInt.h
          $(CPP) $(CPPFLAGS) BigInt.cpp -o $@
clean :
          rm -f *.o *~ rsa

                                  Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Default-rules Remarks



Automatic Variables




   $@ , $<, $^
         $@ : used for the target variable.
         $< : the 1st prerequisite.
         $^ : is like “all the above” - all the prerequisites.




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Default-rules Remarks



Default automatic rules to compile

   Example-1
   prog: foo.o foobar.o ...
   <TAB> (nothing)

                 $(CPP) $(LDFLAGS) $^ -o $@
   (if prog.o (or prog.c) is one of the prerequisites.)
   Example-2
   prog: prog.c prog.h
   <TAB> (nothing)

            $(CPP) $(CPPFLAGS) -c $< -o $@
   Check these.


                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Default-rules Remarks



‘make’ from within the editor


   Some editors like Vim allow you to call ‘make’ while still editing
   the makefile :)
         :make - to run the Makefile.
   To navigate through the errors and fix compilation issues fast, try
         :copen - Opens the quickfix window, to show the results of
         the compilation.
         :cnext or :cn - jump to the next error in source code.
         :cprev or :cp - jump to the previous error in source code.




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Default-rules Remarks



Remarks




         Don’t forget to put the TAB before entering the command.
         Look at examples of Makefiles.
         Lots of tutorials and resources available online.




                                     Subhashini V   Tutorial on make
Introduction Compiling Makefiles Example Extras   Default-rules Remarks



Questions?




                                         Just make it.




                                     Subhashini V   Tutorial on make

More Related Content

What's hot

Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
Sadia Bashir
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
Ramasubbu .P
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
Anu Chaudhry
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
sudhir singh yadav
 
Linux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell ScriptingLinux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell Scripting
Emertxe Information Technologies Pvt Ltd
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
Md. Zahid Hossain Shoeb
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
Chandan Kumar Rana
 
Linux commands
Linux commandsLinux commands
Linux commands
penetration Tester
 
Grep - A powerful search utility
Grep - A powerful search utilityGrep - A powerful search utility
Grep - A powerful search utility
Nirajan Pant
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
Bhavesh Padharia
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
vceder
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
Amit Ghosh
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
SHUBHA CHATURVEDI
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
Shakeel Shafiq
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
Lilesh Pathe
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
MohanKumar Palanichamy
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Manav Prasad
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
Nishant Munjal
 

What's hot (20)

Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Linux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell ScriptingLinux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell Scripting
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Grep - A powerful search utility
Grep - A powerful search utilityGrep - A powerful search utility
Grep - A powerful search utility
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 

Viewers also liked

Makefiles Intro
Makefiles IntroMakefiles Intro
Makefiles Intro
Ynon Perek
 
Makefile
MakefileMakefile
Makefile
Ionela
 
Makefiles Bioinfo
Makefiles BioinfoMakefiles Bioinfo
Makefiles Bioinfo
Giovanni Marco Dall'Olio
 
GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介
Wen Liao
 
Introduction to makefile
Introduction to makefileIntroduction to makefile
Introduction to makefile
Ray Song
 
Open Budget Format: Issues on Development of Specification and Converter Impl...
Open Budget Format: Issues on Development of Specification and Converter Impl...Open Budget Format: Issues on Development of Specification and Converter Impl...
Open Budget Format: Issues on Development of Specification and Converter Impl...
Olya Parkhimovich
 
Physics 1
Physics 1Physics 1
Physics 1
Manulat
 
भारतीय मानसून
भारतीय मानसूनभारतीय मानसून
भारतीय मानसूनDinesh Gaekwad
 
Bhikshuk (भिक्षुक)
Bhikshuk (भिक्षुक)Bhikshuk (भिक्षुक)
Bhikshuk (भिक्षुक)
Hindijyan
 
ppt of our Solar system in hindi
ppt of our Solar system in hindippt of our Solar system in hindi
ppt of our Solar system in hindi
vethics
 
जलवायु
जलवायुजलवायु
जलवायु
Pardeep Kumar
 
Physics and its laws in anaesthesia
Physics and its laws in anaesthesiaPhysics and its laws in anaesthesia
Physics and its laws in anaesthesia
Sivaramakrishnan Dhamotharan
 
Water In Hindi
Water In HindiWater In Hindi
Water In Hindi
Naveenchandra Halemani
 
GENERAL PHYSICS 1 TEACHING GUIDE
GENERAL PHYSICS 1 TEACHING GUIDEGENERAL PHYSICS 1 TEACHING GUIDE
GENERAL PHYSICS 1 TEACHING GUIDE
PRINTDESK by Dan
 
Impacts of water pollution hindi
Impacts of water pollution hindiImpacts of water pollution hindi
Impacts of water pollution hindi
Water Community India
 
force and laws of motion
force and laws of motionforce and laws of motion
force and laws of motion
ashutoshrockx
 
Hindi Workshop हिंदी कार्यशाला
 Hindi Workshop हिंदी कार्यशाला Hindi Workshop हिंदी कार्यशाला
Hindi Workshop हिंदी कार्यशाला
Vijay Nagarkar
 
Atoms
AtomsAtoms

Viewers also liked (20)

Makefiles Intro
Makefiles IntroMakefiles Intro
Makefiles Intro
 
Makefile
MakefileMakefile
Makefile
 
Makefiles Bioinfo
Makefiles BioinfoMakefiles Bioinfo
Makefiles Bioinfo
 
GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介
 
Introduction to makefile
Introduction to makefileIntroduction to makefile
Introduction to makefile
 
Open Budget Format: Issues on Development of Specification and Converter Impl...
Open Budget Format: Issues on Development of Specification and Converter Impl...Open Budget Format: Issues on Development of Specification and Converter Impl...
Open Budget Format: Issues on Development of Specification and Converter Impl...
 
Physics 1
Physics 1Physics 1
Physics 1
 
भारतीय मानसून
भारतीय मानसूनभारतीय मानसून
भारतीय मानसून
 
Bhikshuk (भिक्षुक)
Bhikshuk (भिक्षुक)Bhikshuk (भिक्षुक)
Bhikshuk (भिक्षुक)
 
Hindi ppt
Hindi pptHindi ppt
Hindi ppt
 
ppt of our Solar system in hindi
ppt of our Solar system in hindippt of our Solar system in hindi
ppt of our Solar system in hindi
 
जलवायु
जलवायुजलवायु
जलवायु
 
Physics and its laws in anaesthesia
Physics and its laws in anaesthesiaPhysics and its laws in anaesthesia
Physics and its laws in anaesthesia
 
Water In Hindi
Water In HindiWater In Hindi
Water In Hindi
 
GENERAL PHYSICS 1 TEACHING GUIDE
GENERAL PHYSICS 1 TEACHING GUIDEGENERAL PHYSICS 1 TEACHING GUIDE
GENERAL PHYSICS 1 TEACHING GUIDE
 
Impacts of water pollution hindi
Impacts of water pollution hindiImpacts of water pollution hindi
Impacts of water pollution hindi
 
force and laws of motion
force and laws of motionforce and laws of motion
force and laws of motion
 
Photo electric effect
Photo electric effectPhoto electric effect
Photo electric effect
 
Hindi Workshop हिंदी कार्यशाला
 Hindi Workshop हिंदी कार्यशाला Hindi Workshop हिंदी कार्यशाला
Hindi Workshop हिंदी कार्यशाला
 
Atoms
AtomsAtoms
Atoms
 

Similar to makefiles tutorial

How Symfony changed my life (#SfPot, Paris, 19th November 2015)
How Symfony changed my life (#SfPot, Paris, 19th November 2015)How Symfony changed my life (#SfPot, Paris, 19th November 2015)
How Symfony changed my life (#SfPot, Paris, 19th November 2015)
Matthias Noback
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My Life
Matthias Noback
 
GNU Parallel: Lab meeting—technical talk
GNU Parallel: Lab meeting—technical talkGNU Parallel: Lab meeting—technical talk
GNU Parallel: Lab meeting—technical talk
Hoffman Lab
 
Makefile for python projects
Makefile for python projectsMakefile for python projects
Makefile for python projects
Mpho Mphego
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
Joe Ferguson
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
Diego Freniche Brito
 
PowerShell: Automation for everyone
PowerShell: Automation for everyonePowerShell: Automation for everyone
PowerShell: Automation for everyone
Gavin Barron
 
PowerShell: Automation for Everyone
PowerShell: Automation for EveryonePowerShell: Automation for Everyone
PowerShell: Automation for Everyone
Intergen
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
FAST
 
Using Doctrine Migrations to Synchronize Databases
Using Doctrine Migrations to Synchronize DatabasesUsing Doctrine Migrations to Synchronize Databases
Using Doctrine Migrations to Synchronize Databases
Bryce Embry
 
Writing Rust Command Line Applications
Writing Rust Command Line ApplicationsWriting Rust Command Line Applications
Writing Rust Command Line Applications
All Things Open
 
Doit apac-2010-1.0
Doit apac-2010-1.0Doit apac-2010-1.0
Doit apac-2010-1.0
eduardo schettino
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]
Benny Siegert
 
Reusando componentes Zope fuera de Zope
Reusando componentes Zope fuera de ZopeReusando componentes Zope fuera de Zope
Reusando componentes Zope fuera de Zope
menttes
 
PHP Programming: Intro
PHP Programming: IntroPHP Programming: Intro
PHP Programming: Intro
Things Lab
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generators
dantleech
 
3. build your own php extension ai ti aptech
3. build your own php extension   ai ti aptech3. build your own php extension   ai ti aptech
3. build your own php extension ai ti aptechQuang Anh Le
 
07 build your-own_php_extension
07 build your-own_php_extension07 build your-own_php_extension
07 build your-own_php_extensionNguyen Duc Phu
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extensionVõ Duy Tuấn
 

Similar to makefiles tutorial (20)

How Symfony changed my life (#SfPot, Paris, 19th November 2015)
How Symfony changed my life (#SfPot, Paris, 19th November 2015)How Symfony changed my life (#SfPot, Paris, 19th November 2015)
How Symfony changed my life (#SfPot, Paris, 19th November 2015)
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My Life
 
GNU Parallel: Lab meeting—technical talk
GNU Parallel: Lab meeting—technical talkGNU Parallel: Lab meeting—technical talk
GNU Parallel: Lab meeting—technical talk
 
Makefile for python projects
Makefile for python projectsMakefile for python projects
Makefile for python projects
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
PowerShell: Automation for everyone
PowerShell: Automation for everyonePowerShell: Automation for everyone
PowerShell: Automation for everyone
 
PowerShell: Automation for Everyone
PowerShell: Automation for EveryonePowerShell: Automation for Everyone
PowerShell: Automation for Everyone
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
 
Using Doctrine Migrations to Synchronize Databases
Using Doctrine Migrations to Synchronize DatabasesUsing Doctrine Migrations to Synchronize Databases
Using Doctrine Migrations to Synchronize Databases
 
Writing Rust Command Line Applications
Writing Rust Command Line ApplicationsWriting Rust Command Line Applications
Writing Rust Command Line Applications
 
Doit apac-2010-1.0
Doit apac-2010-1.0Doit apac-2010-1.0
Doit apac-2010-1.0
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]
 
Reusando componentes Zope fuera de Zope
Reusando componentes Zope fuera de ZopeReusando componentes Zope fuera de Zope
Reusando componentes Zope fuera de Zope
 
C# tutorial
C# tutorialC# tutorial
C# tutorial
 
PHP Programming: Intro
PHP Programming: IntroPHP Programming: Intro
PHP Programming: Intro
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generators
 
3. build your own php extension ai ti aptech
3. build your own php extension   ai ti aptech3. build your own php extension   ai ti aptech
3. build your own php extension ai ti aptech
 
07 build your-own_php_extension
07 build your-own_php_extension07 build your-own_php_extension
07 build your-own_php_extension
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extension
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

makefiles tutorial

  • 1. Introduction Compiling Makefiles Example Extras Making makefiles Tutorial for CS-2810 Subhashini V IIT Madras Subhashini V Tutorial on make
  • 2. Introduction Compiling Makefiles Example Extras Outline Introduction Motivation Compiling Object file Makefiles Macros Naming Phony-Targets Example Extras Default-rules Remarks Subhashini V Tutorial on make
  • 3. Introduction Compiling Makefiles Example Extras Motivation The why, what and how of makefiles for you and me. Figure: xkcd (comic is for sudo, but who cares, it has ‘make’) Subhashini V Tutorial on make
  • 4. Introduction Compiling Makefiles Example Extras Motivation Why makefiles? Lots of source files: foo1.h, foo2.h, foobar1.cpp, foobar2.cpp How to manage them all? Compiling is complicated!!! Subhashini V Tutorial on make
  • 5. Introduction Compiling Makefiles Example Extras Motivation Why makefiles? Lots of source files: foo1.h, foo2.h, foobar1.cpp, foobar2.cpp How to manage them all? Compiling is complicated!!! Solution: make Subhashini V Tutorial on make
  • 6. Introduction Compiling Makefiles Example Extras Motivation What are makefiles? make - automagically build and manage your programs. compile quickly with a single command recompile is even quicker Subhashini V Tutorial on make
  • 7. Introduction Compiling Makefiles Example Extras Motivation How does it work? Give targets (usually a file to be created) Specify dependencies for each target. Give command to create target from dependencies. ‘make’ recursively builds the targets from the set of dependencies. recompilation - time-stamp of modification Subhashini V Tutorial on make
  • 8. Introduction Compiling Makefiles Example Extras Object file .h and .cpp .h files contain declarations. functions that the class promises. .cpp files contain definitions implementations of the promised methods. other functions that are not a part of any class. Subhashini V Tutorial on make
  • 9. Introduction Compiling Makefiles Example Extras Object file BigInt assignment example The BigInt data type in RSA BigInt.h - with proposed methods : +, -, *, /, ! BigInt.cpp - with implementation of methods rsa.cpp - ONLY needs #include “BigInt.h”. Don’t need BigInt.cpp. Subhashini V Tutorial on make
  • 10. Introduction Compiling Makefiles Example Extras Object file Creating Object file object file or (.o file) For creating rsa.o, no need to include BigInt.cpp! Eventually need BigInt.cpp for running. Link later. You also don’t need main() Command: g++ -Wall -c rsa.cpp * -Wall : all warnings turned on * -c : Compiles but doesn’t link Subhashini V Tutorial on make
  • 11. Introduction Compiling Makefiles Example Extras Macros Naming Phony-Targets Makefiles! A makefile describes the dependencies between files. Figure: Content of a Makefile Subhashini V Tutorial on make
  • 12. Introduction Compiling Makefiles Example Extras Macros Naming Phony-Targets Targets, Dependencies, Commands Target is usually a file. Remember “:” Dependencies : .cpp, corresponding .h and other .h files Determining dependencies. the all important [tab] Commands : can be multiple Subhashini V Tutorial on make
  • 13. Introduction Compiling Makefiles Example Extras Macros Naming Phony-Targets Use macros! Like #define OBJS = rsa.o main.o CPP = g++ DEBUG = -g CPPFLAGS = -Wall -c $(DEBUG) LDFLAGS = -lm Usage: $(variable) rsa : $(OBJS) $(CPP) $(LDFLAGS) $(OBJS) -o rsa Automatic variables : $@ , $<, $^ ... Subhashini V Tutorial on make
  • 14. Introduction Compiling Makefiles Example Extras Macros Naming Phony-Targets Naming the file Naming and running the make file. makefile - run with make Makefile - run with make give any filename - run as make -f < filename > make picks the first target in the file and executes the commands if the dependencies are more recent than the target. Subhashini V Tutorial on make
  • 15. Introduction Compiling Makefiles Example Extras Macros Naming Phony-Targets Phony targets Dummy targets to run commands. They don’t actually create files. make all make clean make tar Use .PHONY or directly the name. .PHONY: clean Or clean: clean: rm -f *.o *~ rsa rm -f *.o *~ rsa Subhashini V Tutorial on make
  • 16. Introduction Compiling Makefiles Example Extras Makefile OBJS = rsa.o main.o BigInt.o CPP = g++ DEBUG = -g CPPFLAGS = -Wall -c $(DEBUG) LDFLAGS = -lm rsa : $(OBJS) $(CPP) $(LDFLAGS) $(OBJS) -o rsa main.o : main.cpp BigInt.h rsa.h $(CPP) $(CPPFLAGS) main.cpp -o $@ rsa.o : rsa.cpp rsa.h BigInt.h $(CPP) $(CPPFLAGS) rsa.cpp -o $@ BigInt.o : BigInt.cpp BigInt.h $(CPP) $(CPPFLAGS) BigInt.cpp -o $@ clean : rm -f *.o *~ rsa Subhashini V Tutorial on make
  • 17. Introduction Compiling Makefiles Example Extras Default-rules Remarks Automatic Variables $@ , $<, $^ $@ : used for the target variable. $< : the 1st prerequisite. $^ : is like “all the above” - all the prerequisites. Subhashini V Tutorial on make
  • 18. Introduction Compiling Makefiles Example Extras Default-rules Remarks Default automatic rules to compile Example-1 prog: foo.o foobar.o ... <TAB> (nothing) $(CPP) $(LDFLAGS) $^ -o $@ (if prog.o (or prog.c) is one of the prerequisites.) Example-2 prog: prog.c prog.h <TAB> (nothing) $(CPP) $(CPPFLAGS) -c $< -o $@ Check these. Subhashini V Tutorial on make
  • 19. Introduction Compiling Makefiles Example Extras Default-rules Remarks ‘make’ from within the editor Some editors like Vim allow you to call ‘make’ while still editing the makefile :) :make - to run the Makefile. To navigate through the errors and fix compilation issues fast, try :copen - Opens the quickfix window, to show the results of the compilation. :cnext or :cn - jump to the next error in source code. :cprev or :cp - jump to the previous error in source code. Subhashini V Tutorial on make
  • 20. Introduction Compiling Makefiles Example Extras Default-rules Remarks Remarks Don’t forget to put the TAB before entering the command. Look at examples of Makefiles. Lots of tutorials and resources available online. Subhashini V Tutorial on make
  • 21. Introduction Compiling Makefiles Example Extras Default-rules Remarks Questions? Just make it. Subhashini V Tutorial on make