SlideShare a Scribd company logo
1 of 18
Download to read offline
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

Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Omar Fathy
 
Develop Basic joomla! MVC component for version 3
Develop Basic joomla! MVC component for version 3Develop Basic joomla! MVC component for version 3
Develop Basic joomla! MVC component for version 3Gunjan Patel
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8Simon Ritter
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js선협 이
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondKaushal Dhruw
 
Architecture java j2 ee a partager
Architecture java j2 ee a partagerArchitecture java j2 ee a partager
Architecture java j2 ee a partageraliagadir
 
Jenkinsを使った初めての継続的インテグレーション
Jenkinsを使った初めての継続的インテグレーションJenkinsを使った初めての継続的インテグレーション
Jenkinsを使った初めての継続的インテグレーションdcubeio
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 OverviewMike Ensor
 
Git Introduction
Git IntroductionGit Introduction
Git IntroductionGareth Hall
 
MVC, MVVM, ReactorKit, VIPER를 거쳐 RIB 정착기
MVC, MVVM, ReactorKit, VIPER를 거쳐 RIB 정착기MVC, MVVM, ReactorKit, VIPER를 거쳐 RIB 정착기
MVC, MVVM, ReactorKit, VIPER를 거쳐 RIB 정착기정민 안
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using SeleniumWeifeng Zhang
 
Dealing with Merge Conflicts in Git
Dealing with Merge Conflicts in GitDealing with Merge Conflicts in Git
Dealing with Merge Conflicts in Gitgittower
 
Bài 3: Servlet&Cookie&Session - Lập Trình Mạng Nâng Cao
Bài 3: Servlet&Cookie&Session - Lập Trình Mạng Nâng CaoBài 3: Servlet&Cookie&Session - Lập Trình Mạng Nâng Cao
Bài 3: Servlet&Cookie&Session - Lập Trình Mạng Nâng CaoTuan Nguyen
 
PHPCon China 2016 - 從學徒變大師:談 Laravel 框架擴充與套件開發
PHPCon China 2016 - 從學徒變大師:談 Laravel 框架擴充與套件開發PHPCon China 2016 - 從學徒變大師:談 Laravel 框架擴充與套件開發
PHPCon China 2016 - 從學徒變大師:談 Laravel 框架擴充與套件開發Shengyou Fan
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 

What's hot (20)

Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Develop Basic joomla! MVC component for version 3
Develop Basic joomla! MVC component for version 3Develop Basic joomla! MVC component for version 3
Develop Basic joomla! MVC component for version 3
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & Beyond
 
Architecture java j2 ee a partager
Architecture java j2 ee a partagerArchitecture java j2 ee a partager
Architecture java j2 ee a partager
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
Jenkinsを使った初めての継続的インテグレーション
Jenkinsを使った初めての継続的インテグレーションJenkinsを使った初めての継続的インテグレーション
Jenkinsを使った初めての継続的インテグレーション
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
MVC, MVVM, ReactorKit, VIPER를 거쳐 RIB 정착기
MVC, MVVM, ReactorKit, VIPER를 거쳐 RIB 정착기MVC, MVVM, ReactorKit, VIPER를 거쳐 RIB 정착기
MVC, MVVM, ReactorKit, VIPER를 거쳐 RIB 정착기
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using Selenium
 
Dealing with Merge Conflicts in Git
Dealing with Merge Conflicts in GitDealing with Merge Conflicts in Git
Dealing with Merge Conflicts in Git
 
Bài 3: Servlet&Cookie&Session - Lập Trình Mạng Nâng Cao
Bài 3: Servlet&Cookie&Session - Lập Trình Mạng Nâng CaoBài 3: Servlet&Cookie&Session - Lập Trình Mạng Nâng Cao
Bài 3: Servlet&Cookie&Session - Lập Trình Mạng Nâng Cao
 
PHPCon China 2016 - 從學徒變大師:談 Laravel 框架擴充與套件開發
PHPCon China 2016 - 從學徒變大師:談 Laravel 框架擴充與套件開發PHPCon China 2016 - 從學徒變大師:談 Laravel 框架擴充與套件開發
PHPCon China 2016 - 從學徒變大師:談 Laravel 框架擴充與套件開發
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 

Make Reloaded