Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours_prog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yassin.elhakoun
cours_prog
Commits
e39df448
Verified
Commit
e39df448
authored
4 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
updated for advanced make
parent
3c0c88d3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
exemples/make/Makefile.1
+11
-0
11 additions, 0 deletions
exemples/make/Makefile.1
slides/Makefile
+8
-8
8 additions, 8 deletions
slides/Makefile
slides/make_avance.md
+17
-53
17 additions, 53 deletions
slides/make_avance.md
with
36 additions
and
61 deletions
exemples/make/Makefile.1
0 → 100644
+
11
−
0
View file @
e39df448
galaxy
:
galaxy.o stars.o vec.o
gcc
-o
galaxy
galaxy.o
galaxy.o
:
galaxy.c
gcc
-c
galaxy.c
stars.o
:
stars.c stars.h vec.h
gcc
-c
galaxy.c
vec.o
:
vec.c vec.h
gcc
-c
vec.c
\ No newline at end of file
This diff is collapsed.
Click to expand it.
slides/Makefile
+
8
−
8
View file @
e39df448
...
...
@@ -11,16 +11,16 @@ REVEALOPTIONS += --self-contained
REVEALOPTIONS
+=
-V
revealjs-url
=
./reveal.js
REVEALOPTIONS
+=
-V
theme
=
white
MD
=
$(
wildcard
*
.md
)
HTML
=
$(
MD:%.md
=
%.html
)
PDF
=
$(
MD:%.md
=
%.pdf
)
MARKDOWN
=
$(
MD:%.md
=
%.markdown
)
MD
=
$(
wildcard
*
.md
)
# Tous les fichiers .md
HTML
=
$(
MD:%.md
=
%.html
)
# Pour les fichier html on transforme .md -> .html
PDF
=
$(
MD:%.md
=
%.pdf
)
# Pour les fichier pdf on transforme .md -> .pdf
MARKDOWN
=
$(
MD:%.md
=
%.markdown
)
# Pour les fichier markdown on transforme .md -> .markdown
all
:
$(PDF) $(HTML)
all
:
$(PDF) $(HTML)
#
La cible par défaut (all) exécute les cibles %.html et %.pdf
markdown
:
$(MARKDOWN)
markdown
:
$(MARKDOWN)
#
La markdown les cibles %.markdown
%.pdf
:
%.md metadata.yaml
%.pdf
:
%.md metadata.yaml
#
%.pdf (chaque fichier %.md génère un fichier avec le même nom mais l'extension .pdf et la dépendance metadata.yaml)
pandoc
-s
$(
OPTIONS
)
$(
PDFOPTIONS
)
-o
$@
$^
%.html
:
%.md metadata.yaml
...
...
@@ -34,7 +34,7 @@ markdown: $(MARKDOWN)
cat
tmp.yaml no_header
>
$@
rm
no_header header.yaml tmp.yaml
yq
:
yq
:
#
On peut même télécharger un petit programme avec notre makefile
wget
-nc
https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64
chmod
"u+x"
yq_linux_amd64
...
...
This diff is collapsed.
Click to expand it.
slides/make_avance.md
+
17
−
53
View file @
e39df448
...
...
@@ -13,6 +13,7 @@ date: 2021-03-03
-
Création du code objet à partir des sources.
-
Création de l'exécutable à partir du code objet.
-
Tout "gros" projet utilise
`make`
(pas uniquement en
`C`
).
-
Il existe d'autres outils pour le
`C`
et d'autres langages (
`cmake`
,
`meson`
,
`maven`
,
`cargo`
, ...).
# Utilisation de `make`
...
...
@@ -22,22 +23,17 @@ date: 2021-03-03
::: {.column width="60%"}
```
bash
# Les commentaires commencent
# par #
# exemple est la cible, example.o
# la dépendance
example: example.o
# ligne exécuté à l'appel de
# `make` (`make example`)
gcc
-o
example example.o
# exemple.o est la cible, example.c
# et example.h les dépendances
exmaple.o: exmaple.c example.h
# ligne exécuté à l'appel de
# `make example.o`
gcc
-c
example.c
galaxy: galaxy.o stars.o vec.o
gcc
-o
galaxy galaxy.o
galaxy.o: galaxy.c
gcc
-c
galaxy.c
stars.o: stars.c stars.h vec.h
gcc
-c
galaxy.c
vec.o: vec.c vec.h
gcc
-c
vec.c
```
:::
...
...
@@ -68,7 +64,7 @@ CC = gcc
# -pedantic Warning lvl archimage
# -O0 Option d'optimisation (0,1,2,3)
# -std=c11 Utilisation du standard c11
# -fsanitize=address Utilisation d
u
s
t
an
dard c11
# -fsanitize=address Utilisation d
es
san
itizers
CFLAGS
=
-g
-Wall
-O0
-std
=
c11
```
...
...
@@ -127,7 +123,7 @@ Ainsi
foo
:
foo.o bar.o
gcc
-o
foo
foo.o
bar.o
$(CFLAGS)
$(LDFLAGS)
# implicitement pour foo.c et bar.c
$(CC)
-c
$(CPPFLAGS)
$(CFLAGS)
$(CC)
-c
$(CFLAGS)
```
# Gestion implicites (2/2)
...
...
@@ -138,7 +134,7 @@ Et pour les dépendances des cibles implicites ça se passe comment?
## Réponse
On peut définir individuellement les
On peut définir individuellement les
dites dépendances
## Fonctionnement
...
...
@@ -146,39 +142,7 @@ Quand `make` rencontre une dépendance sans règle, il va voir dans sa liste de
Ainsi
```
makefile
foo
:
foo.o bar.o
gcc
-o
foo
foo.o
bar.o
$(CFLAGS)
$(LDFLAGS)
# implicitement pour foo.c et bar.c
$(CC)
-c
$(CPPFLAGS)
$(CFLAGS)
foo.o
:
foo.h
bar.o
:
foo.h bar.h
```
# Macros
## Les macros
-
Assignation
```
make
CC
=
gcc
CFLAGS
=
-g
-Wall
-Wextra
-pedantic
-O0
-std
=
c11
LDFLAGS
=
-lm
```
-
Utilisation
```
bash
$(
CC
)
```
-
Déclaration à la ligne de commande
```bash
make CFLAGS="-O3 -Wall"
```
## Variables internes
-
`$@`
: la cible
-
`$^`
: la liste des dépendances
-
`$<`
: la première dépendance
-
`$*`
: le nom de la cible sans extension
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment