SlideShare a Scribd company logo
1 of 27
Download to read offline
MAKEFILEMAKEFILE
co to je?
proč používat makefile?
jak ho používáme?
(na co si dát pozor?)
CO TO JE?CO TO JE?
soubor, který:
určuje postup utility make při překladu a
definuje závislosti mezi zdrojovými soubory
CC=gcc
CFLAGS=-I.
DEPS = hellomake.h
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
hellomake: hellomake.o hellofunc.o
$(CC) -o hellomake hellomake.o hellofunc.o
CO TO JE MAKE?CO TO JE MAKE?
Program make je utilita pro automatizaci překladu
zdrojových kódů do binárních souborů
https://cs.wikipedia.org/wiki/Make
PROČ MAKEFILE?PROČ MAKEFILE?
protože jsme líní
SYNTAXESYNTAXE
target1: dependency1 [...]
command1
command2
...
target2: ...
HELLO WORLDHELLO WORLD
...
hello:
echo "Hello world!"
$ make hello
echo "Hello world!"
Hello world!
TATO PREZENTACETATO PREZENTACE
...
reveal: ## reveal-md presentation
@/home/ikar/ctvrtkon/node_modules/.bin/reveal-md 
--host 0.0.0.0 
--watch 
--theme white 
--port 2019 
README.md
$ make reveal
Reveal-server started at http://0.0.0.0:2019
REÁLNÝ PROJEKTREÁLNÝ PROJEKT
BAREVNÁ NÁPOVĚDABAREVNÁ NÁPOVĚDA
...
help: ## list available targets (this page)
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z_-]+:.*?## / 
{printf "033[36m%-30s033[0m %sn", $$1, $$2}' 
$(MAKEFILE_LIST)
reveal: ## reveal-md presentation
...
BAREVNÁ NÁPOVĚDABAREVNÁ NÁPOVĚDA
PROČ MAKEFILE?PROČ MAKEFILE?
protože jsme líní ✓
protože chceme ušetřit čas
SYNTAXESYNTAXE
target1: dependency1 [...]
command1
command2
...
dependency1: dependency2
...
dependency2: ...
commmand3
EXPORT DO PDFEXPORT DO PDF
...
pdf:
@/home/ikar/ctvrtkon/node_modules/.bin/reveal-md 
--print ctvrtkon.pdf 
README.md
$ time make pdf
Attempting to print "README.md?print-pdf"
to filename "ctvrtkon.pdf" as PDF.
real 0m2,089s
user 0m1,287s
sys 0m0,191s
EXPORT DO PDFEXPORT DO PDF
...
pdf: ctvrtkon.pdf
@echo "Done ✓"
ctvrtkon.pdf: README.md
@/home/ikar/ctvrtkon/node_modules/.bin/reveal-md 
--print ctvrtkon.pdf 
README.md
$ time make pdf
Done ✓
real 0m0,007s
user 0m0,004s
sys 0m0,003s
NPM / YARN INSTALLNPM / YARN INSTALL
install: .yarn.success
@echo "All deps satisfied!"
.yarn.success: package.json
@yarn install && touch .yarn.success
NPM / YARN INSTALLNPM / YARN INSTALL
$ time make install
yarn install v1.12.3
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.28s.
All deps satisfied!
real 0m0,723s
user 0m0,770s
sys 0m0,050s
$ time make install
All deps satisfied!
real 0m0,007s
user 0m0,007s
sys 0m0,000s
TATO PREZENTACETATO PREZENTACE
...
reveal: install run ## reveal-md presentation
run:
@/home/ikar/ctvrtkon/node_modules/.bin/reveal-md 
--host 0.0.0.0 --watch --theme white --port 2019 
README.md
install: .yarn.success
@echo "All deps satisfied!"
...
$ make reveal
All deps satisfied!
Reveal-server started at http://0.0.0.0:2019
DĚKUJI ZADĚKUJI ZA
POZORNOSTPOZORNOST
https://gitlab.com/ikar/ctvrtkon
GOTCHASGOTCHAS
SPACESSPACES
...
test:
echo ahoj
$ make test
Makefile:33: *** missing separator. Stop.
ESCAPOVÁNÍ SHELLESCAPOVÁNÍ SHELL
VARIABLESVARIABLES
...
A=makefile_a
B=makefile_b
test:
@A=shell_a; echo $A
@B=shell_b; echo $$B
$ make test
makefile_a
shell_b
NEJSME V BASHINEJSME V BASHI
...
tip:
test:
echo $$RANDOM
$ make test
echo $RANDOM
http://mywiki.wooledge.org/Bashism
UŽ JSME V BASHIUŽ JSME V BASHI
...
SHELL := /bin/bash
test:
echo $$RANDOM
$ make test
echo $RANDOM
42
KAM DÁLKAM DÁL
http://shop.oreilly.com/product/9780596006105.do
DĚKUJI ZADĚKUJI ZA
POZORNOSTPOZORNOST
https://gitlab.com/ikar/ctvrtkon

More Related Content

Similar to DEV Čtvrtkon #76 - Makefile

Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018
Ortus Solutions, Corp
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Fabien Potencier
 

Similar to DEV Čtvrtkon #76 - Makefile (20)

DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
 
Elixir on Containers
Elixir on ContainersElixir on Containers
Elixir on Containers
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
 
Revoke-Obfuscation
Revoke-ObfuscationRevoke-Obfuscation
Revoke-Obfuscation
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Taking Docker to Dance: Continuous Delivery on AWS
Taking Docker to Dance: Continuous Delivery on AWSTaking Docker to Dance: Continuous Delivery on AWS
Taking Docker to Dance: Continuous Delivery on AWS
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Advanced Mac Software Deployment and Configuration: Just Make It Work!
Advanced Mac Software Deployment and Configuration: Just Make It Work!Advanced Mac Software Deployment and Configuration: Just Make It Work!
Advanced Mac Software Deployment and Configuration: Just Make It Work!
 
Scale your Magento app with Elastic Beanstalk
Scale your Magento app with Elastic BeanstalkScale your Magento app with Elastic Beanstalk
Scale your Magento app with Elastic Beanstalk
 
Composer, putting dependencies on the score
Composer, putting dependencies on the scoreComposer, putting dependencies on the score
Composer, putting dependencies on the score
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricks
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Getting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platformGetting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platform
 
Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and docker
 
Minimum Viable Docker: our journey towards orchestration
Minimum Viable Docker: our journey towards orchestrationMinimum Viable Docker: our journey towards orchestration
Minimum Viable Docker: our journey towards orchestration
 
Word press, the automated way
Word press, the automated wayWord press, the automated way
Word press, the automated way
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
 

More from Ctvrtkoncz

More from Ctvrtkoncz (16)

DEV Čtvrtkon #107 - Štefan Földesi
DEV Čtvrtkon #107 - Štefan FöldesiDEV Čtvrtkon #107 - Štefan Földesi
DEV Čtvrtkon #107 - Štefan Földesi
 
#85 Čtvrtkon - Obsahové UX - Milan Pichlík
#85 Čtvrtkon - Obsahové UX - Milan Pichlík#85 Čtvrtkon - Obsahové UX - Milan Pichlík
#85 Čtvrtkon - Obsahové UX - Milan Pichlík
 
DEV Čtvrtkon #76 - Open API
DEV Čtvrtkon #76 - Open APIDEV Čtvrtkon #76 - Open API
DEV Čtvrtkon #76 - Open API
 
DEV Čtvrtkon #76 - nopCommerce
DEV Čtvrtkon #76 - nopCommerceDEV Čtvrtkon #76 - nopCommerce
DEV Čtvrtkon #76 - nopCommerce
 
DEV Čtvrtkon #76 - Fluent Interface
DEV Čtvrtkon #76 - Fluent InterfaceDEV Čtvrtkon #76 - Fluent Interface
DEV Čtvrtkon #76 - Fluent Interface
 
DEV Čtvrtkon #76 - Nachytřená domácnost
DEV Čtvrtkon #76 - Nachytřená domácnostDEV Čtvrtkon #76 - Nachytřená domácnost
DEV Čtvrtkon #76 - Nachytřená domácnost
 
DEV Čtvrtkon #76 - How to build an evil-free social network: Behind the wheels
DEV Čtvrtkon #76 - How to build an evil-free social network: Behind the wheelsDEV Čtvrtkon #76 - How to build an evil-free social network: Behind the wheels
DEV Čtvrtkon #76 - How to build an evil-free social network: Behind the wheels
 
Čtvrtkon: Podle jakých kritérií vybrat e-shopové řešení
Čtvrtkon: Podle jakých kritérií vybrat e-shopové řešeníČtvrtkon: Podle jakých kritérií vybrat e-shopové řešení
Čtvrtkon: Podle jakých kritérií vybrat e-shopové řešení
 
Čtvrtkon #71 - Jan Kaštánek - Java & Docker & Microsevices
Čtvrtkon #71 - Jan Kaštánek - Java & Docker & MicrosevicesČtvrtkon #71 - Jan Kaštánek - Java & Docker & Microsevices
Čtvrtkon #71 - Jan Kaštánek - Java & Docker & Microsevices
 
Čtvrtkon #71 - Marian Benčat - Angular a NativeScript
Čtvrtkon #71 - Marian Benčat - Angular a NativeScriptČtvrtkon #71 - Marian Benčat - Angular a NativeScript
Čtvrtkon #71 - Marian Benčat - Angular a NativeScript
 
Čtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal HatákČtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal Haták
 
Jak nakrmit Facebook firemní stránku a Instagram obsahem, co její fanoušci do...
Jak nakrmit Facebook firemní stránku a Instagram obsahem, co její fanoušci do...Jak nakrmit Facebook firemní stránku a Instagram obsahem, co její fanoušci do...
Jak nakrmit Facebook firemní stránku a Instagram obsahem, co její fanoušci do...
 
Pravdy a lži o reklamě na Facebooku - Lukáš Chládek
Pravdy a lži o reklamě na Facebooku - Lukáš ChládekPravdy a lži o reklamě na Facebooku - Lukáš Chládek
Pravdy a lži o reklamě na Facebooku - Lukáš Chládek
 
Vilibald Wanča - Api design-lifecycle
Vilibald Wanča - Api design-lifecycleVilibald Wanča - Api design-lifecycle
Vilibald Wanča - Api design-lifecycle
 
Jan Kaštánek - Od webových aplikací k Androidu
Jan Kaštánek - Od webových aplikací k AndroiduJan Kaštánek - Od webových aplikací k Androidu
Jan Kaštánek - Od webových aplikací k Androidu
 
Propagace eshopu v praxi - Čtvrtkon
Propagace eshopu v praxi - ČtvrtkonPropagace eshopu v praxi - Čtvrtkon
Propagace eshopu v praxi - Čtvrtkon
 

Recently uploaded

audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
lolsDocherty
 
Production 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptxProduction 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptx
ChloeMeadows1
 

Recently uploaded (16)

How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?
 
Reggie miller choke t shirtsReggie miller choke t shirts
Reggie miller choke t shirtsReggie miller choke t shirtsReggie miller choke t shirtsReggie miller choke t shirts
Reggie miller choke t shirtsReggie miller choke t shirts
 
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
 
Thank You Luv I’ll Never Walk Alone Again T shirts
Thank You Luv I’ll Never Walk Alone Again T shirtsThank You Luv I’ll Never Walk Alone Again T shirts
Thank You Luv I’ll Never Walk Alone Again T shirts
 
I’ll See Y’All Motherfuckers In Game 7 Shirt
I’ll See Y’All Motherfuckers In Game 7 ShirtI’ll See Y’All Motherfuckers In Game 7 Shirt
I’ll See Y’All Motherfuckers In Game 7 Shirt
 
Development Lifecycle.pptx for the secure development of apps
Development Lifecycle.pptx for the secure development of appsDevelopment Lifecycle.pptx for the secure development of apps
Development Lifecycle.pptx for the secure development of apps
 
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
 
Bug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's GuideBug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's Guide
 
Production 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptxProduction 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptx
 
Topology of the Network class 8 .ppt pdf
Topology of the Network class 8 .ppt pdfTopology of the Network class 8 .ppt pdf
Topology of the Network class 8 .ppt pdf
 
Statistical Analysis of DNS Latencies.pdf
Statistical Analysis of DNS Latencies.pdfStatistical Analysis of DNS Latencies.pdf
Statistical Analysis of DNS Latencies.pdf
 
Premier Mobile App Development Agency in USA.pdf
Premier Mobile App Development Agency in USA.pdfPremier Mobile App Development Agency in USA.pdf
Premier Mobile App Development Agency in USA.pdf
 
Cyber Security Services Unveiled: Strategies to Secure Your Digital Presence
Cyber Security Services Unveiled: Strategies to Secure Your Digital PresenceCyber Security Services Unveiled: Strategies to Secure Your Digital Presence
Cyber Security Services Unveiled: Strategies to Secure Your Digital Presence
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case Study
 
Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdf
 
iThome_CYBERSEC2024_Drive_Into_the_DarkWeb
iThome_CYBERSEC2024_Drive_Into_the_DarkWebiThome_CYBERSEC2024_Drive_Into_the_DarkWeb
iThome_CYBERSEC2024_Drive_Into_the_DarkWeb
 

DEV Čtvrtkon #76 - Makefile