SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
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!

Más contenido relacionado

La actualidad más candente

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
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Git Terminologies
Git TerminologiesGit Terminologies
Git TerminologiesYash
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
Git and GitFlow branching model
Git and GitFlow branching modelGit and GitFlow branching model
Git and GitFlow branching modelPavlo Hodysh
 
外部環境への依存をテストする
外部環境への依存をテストする外部環境への依存をテストする
外部環境への依存をテストするShunsuke Maeda
 
Git e GitHub - L'essenziale
Git e GitHub - L'essenziale Git e GitHub - L'essenziale
Git e GitHub - L'essenziale Gemma Catolino
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - GitCarlo Bernaschina
 
Introduction to Git Commands and Concepts
Introduction to Git Commands and ConceptsIntroduction to Git Commands and Concepts
Introduction to Git Commands and ConceptsCarl Brown
 
Version control system
Version control systemVersion control system
Version control systemAndrew Liu
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for DocumentationAnne Gentle
 

La actualidad más candente (20)

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
 
Git
GitGit
Git
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git and GitFlow branching model
Git and GitFlow branching modelGit and GitFlow branching model
Git and GitFlow branching model
 
外部環境への依存をテストする
外部環境への依存をテストする外部環境への依存をテストする
外部環境への依存をテストする
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Introduction to gradle
Introduction to gradleIntroduction to gradle
Introduction to gradle
 
SVN Basics
SVN BasicsSVN Basics
SVN Basics
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Git e GitHub - L'essenziale
Git e GitHub - L'essenziale Git e GitHub - L'essenziale
Git e GitHub - L'essenziale
 
Source control
Source controlSource control
Source control
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
 
Version control
Version controlVersion control
Version control
 
Introduction to Git Commands and Concepts
Introduction to Git Commands and ConceptsIntroduction to Git Commands and Concepts
Introduction to Git Commands and Concepts
 
Introduction to Makefile
Introduction to MakefileIntroduction to Makefile
Introduction to Makefile
 
Version control system
Version control systemVersion control system
Version control system
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for Documentation
 

Make Reloaded