SlideShare a Scribd company logo
Make Reloaded
GNU Make - Jak ho možná neznáte
@danielmilde
www.seznam.cz
●
Zápis pravidel
●
Druhy proměnných
●
Kontextově omezené proměnné
●
Automatické proměnné
●
Pravidla se vzorem
●
Pravidla bez fyzického cíle
●
Watch
●
Speciální proměnné
●
Testování makefilů
●
Nastavení shellu
Obsah
Daniel Milde, 2015
www.seznam.cz
cíle : zdroje
předpis
Zápis pravidel
Daniel Milde, 2015
www.seznam.cz
messages.mo : messages.po
msgfmt -o messages.mo messages.po
Zápis pravidel
Daniel Milde, 2015
www.seznam.cz
cíle : zdroje ; předpis
Zápis pravidel
Daniel Milde, 2015
www.seznam.cz
foo = $(bar)
bar = $(shell echo *.c)
all:;@echo $(foo)
bar2 := $(shell echo *.c)
foo2 := $(bar2)
all2:;@echo $(foo2)
Proměnné
Daniel Milde, 2015
www.seznam.cz
files != find . -name '*.c'
files := $(shell find . -name '*.c')
files += some.c
foo ?= $(bar)
Proměnné
Daniel Milde, 2015
www.seznam.cz
files = a.o
a.o: a.c
$(CC) $(CFLAGS) -c -o a.o a.c
main: $(files)
$(CC) $(CFLAGS) -o main $(files)
debug: CFLAGS += -g
debug: main
Proměnné specifické pro cíl
Daniel Milde, 2015
www.seznam.cz
cíle : zdroj zdroj zdroj
předpis
Automatické proměnné
Daniel Milde, 2015
$@ $<
$^
www.seznam.cz
files = a.o
main: $(files)
$(CC) $(CFLAGS) -o $@ $^
debug: CFLAGS += -g
debug: main;
a.o: a.c
$(CC) $(CFLAGS) -c -o $@ $<
Automatické proměnné
Daniel Milde, 2015
www.seznam.cz
%.mo : %.po
msgfmt -o $@ $<
Pravidla se vzorem
Daniel Milde, 2015
www.seznam.cz
files = a.o
main: $(files)
$(CC) $(CFLAGS) -o $@ $^
debug: CFLAGS += -g
debug: main
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
%.o : CFLAGS += -O
Pravidla se vzorem
Daniel Milde, 2015
www.seznam.cz
.PHONY: clean
clean:
rm main *.o
Pravidla bez fyzického cíle
Daniel Milde, 2015
www.seznam.cz
silent-main: main
@true
watch:
@while true; do
make --no-print-directory silent-main;
sleep 0.2;
done
Watch pomocí make
Daniel Milde, 2015
www.seznam.cz
.DEFAULT_GOAL
.RECIPEPREFIX
Speciální proměnné
Daniel Milde, 2015
www.seznam.cz
%::
touch $@
.DEFAULT:
Testování makefilu
Daniel Milde, 2015
www.seznam.cz
.ONESHELL:
SHELL = /usr/bin/python
show :
@f = ['a', 'b', 'c']
print f
Shell
Daniel Milde, 2015
www.seznam.cz
Zdroj: http://www.gnu.org/software/make/manual/make.html
Daniel Mile, 2015
Díky za pozornost!

More Related Content

What's hot

Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
Mamun Rashid, CCDH
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
Steffen Gebert
 
Git and GitFlow branching model
Git and GitFlow branching modelGit and GitFlow branching model
Git and GitFlow branching model
Pavlo Hodysh
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to MavenVadym Lotar
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Svn Basic Tutorial
Svn Basic TutorialSvn Basic Tutorial
Svn Basic Tutorial
Marco Pivetta
 
Dev ops using Jenkins
Dev ops using JenkinsDev ops using Jenkins
Spring Boot & Containers - Do's & Don'ts
Spring Boot & Containers - Do's & Don'tsSpring Boot & Containers - Do's & Don'ts
Spring Boot & Containers - Do's & Don'ts
Julien Wittouck
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
Rupesh Kumar
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
Craig Smith
 
Gerrit Code Review
Gerrit Code ReviewGerrit Code Review
Gerrit Code Review
Luca Milanesio
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
GDSC UofT Mississauga
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
Amazon Web Services
 
DevOps intro
DevOps introDevOps intro
DevOps intro
Abdelrhman Shawky
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat Malladi
 
Version control
Version controlVersion control
Version control
visual28
 

What's hot (20)

Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Git and GitFlow branching model
Git and GitFlow branching modelGit and GitFlow branching model
Git and GitFlow branching model
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Svn Basic Tutorial
Svn Basic TutorialSvn Basic Tutorial
Svn Basic Tutorial
 
Dev ops using Jenkins
Dev ops using JenkinsDev ops using Jenkins
Dev ops using Jenkins
 
Spring Boot & Containers - Do's & Don'ts
Spring Boot & Containers - Do's & Don'tsSpring Boot & Containers - Do's & Don'ts
Spring Boot & Containers - Do's & Don'ts
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Gerrit Code Review
Gerrit Code ReviewGerrit Code Review
Gerrit Code Review
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 
DevOps intro
DevOps introDevOps intro
DevOps intro
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Version control
Version controlVersion control
Version control
 

Make Reloaded