{"id":7904,"date":"2026-05-04T10:16:16","date_gmt":"2026-05-04T09:16:16","guid":{"rendered":"https:\/\/workboot.fr\/ciela\/?page_id=7904"},"modified":"2026-05-05T16:57:17","modified_gmt":"2026-05-05T15:57:17","slug":"makefile","status":"publish","type":"page","link":"https:\/\/workboot.fr\/ciela\/makefile\/","title":{"rendered":"Makefile"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Make et makefile ou Makefile , souvent utiliser pour compiler un projet en langage c <\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>cheatsheet<\/summary>\n<div data-wp-interactive=\"core\/file\" class=\"wp-block-file\"><object data-wp-bind--hidden=\"!state.hasPdfPreview\" hidden class=\"wp-block-file__embed\" data=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/05\/bavo-van-achte_gnumake.pdf\" type=\"application\/pdf\" style=\"width:100%;height:600px\" aria-label=\"Contenu embarqu\u00e9 bavo-van-achte_gnumake.\"><\/object><a id=\"wp-block-file--media-3aba81d5-b323-4796-b700-599f07122861\" href=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/05\/bavo-van-achte_gnumake.pdf\">bavo-van-achte_gnumake<\/a><a href=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/05\/bavo-van-achte_gnumake.pdf\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-3aba81d5-b323-4796-b700-599f07122861\">T\u00e9l\u00e9charger<\/a><\/div>\n<\/details>\n\n\n\n<h2 class=\"wp-block-heading\">1. Pourquoi utiliser Make ?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Make<\/strong>\u00a0automatise la compilation :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u00c9vite de retaper\u00a0<code>gcc -o prog main.c utils.c<\/code>\u00a0\u00e0 chaque fois<\/li>\n\n\n\n<li>Ne recompile que les fichiers modifi\u00e9s (gain de temps)<\/li>\n\n\n\n<li>Facilite la gestion des projets multi-fichiers<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. Syntaxe de base<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>cible: d\u00e9pendances\n    commandes<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>Important<\/strong>\u00a0: Les commandes doivent commencer par une\u00a0<strong>tabulation<\/strong>\u00a0(pas des espaces !)<br><\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">il faut comprendre que pour faire la cible il faut la ou les  d\u00e9pendance sinon infaisable <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Premier exemple simple<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">fichier : makefile ou Makefile  (fichier texte)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hello: hello.c\n    gcc -o hello hello.c<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">comme indiqu\u00e9 la d\u00e9pendance est d&rsquo;avoir le fichier hello.c (source)  pour pouvoir avoir hello (cible)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bruno@elliott:~\/Works\/langage_C\/hello$ make\nmake: ***  Aucune r\u00e8gle pour fabriquer la cible \u00ab\u00a0hello.c\u00a0\u00bb, n\u00e9cessaire pour \u00ab\u00a0hello\u00a0\u00bb. Arr\u00eat.\nbruno@elliott:~\/Works\/langage_C\/hello$ ls\nmakefile\nbruno@elliott:~\/Works\/langage_C\/hello$ cat makefile \nhello: hello.c\n\tgcc -o hello hello.c\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">oui il manque le source !<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/***********************\/\n\/* Exemple: hello.c             *\/\n\/***********************\/\n#include &lt;stdlib.h>\n#include &lt;stdio.h>\n\nint main () \n{\n\tputs(\"Bonjour le monde \\n\");\n\treturn EXIT_SUCCESS;\n}\n<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>bruno@elliott:~\/Works\/langage_C\/hello$ cat hello.c \n\/********************************\/\n\/* Exemple: hello.c             *\/\n\/********************************\/\n#include &lt;stdlib.h>\n#include &lt;stdio.h>\n\nint main () \n{\n\tputs(\"Bonjour le monde \\n\");\n\treturn EXIT_SUCCESS;\n}\nbruno@elliott:~\/Works\/langage_C\/hello$ make \ngcc -o hello hello.c\nbruno@elliott:~\/Works\/langage_C\/hello$ ls\nhello  hello.c  makefile\nbruno@elliott:~\/Works\/langage_C\/hello$ make\nmake: \u00ab\u00a0hello\u00a0\u00bb est \u00e0 jour.\nbruno@elliott:~\/Works\/langage_C\/hello$ \n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Les variables automatique de make<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variable Signification Exemple Valeur pour target: dep1 dep2<\/li>\n\n\n\n<li>$@     Nom de la cible                                             $@ \u2192 target target<\/li>\n\n\n\n<li>$&lt;      Premi\u00e8re d\u00e9pendance                                     $&lt; \u2192 dep1 dep1<\/li>\n\n\n\n<li>$^      Toutes les d\u00e9pendances                                  $^ \u2192 dep1 dep2 dep1 dep2<\/li>\n\n\n\n<li>$?      D\u00e9pendances plus r\u00e9centes que la cible         $? dep1 (si plus r\u00e9cent)<\/li>\n\n\n\n<li>$*      Base du nom de fichier (sans extension)       $* \u2192 file pour file.c dep1 (sans .c)<\/li>\n\n\n\n<li>$+     Toutes d\u00e9pendances (avec doublons)             $+ dep1 dep2 dep1<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">$@<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">correspond au nom de la cible &lsquo;target&rsquo;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">$&lt;<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">correspond \u00e0 d\u00e9pendance 1<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">$^<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"> Toutes les d\u00e9pendances $^ \u2192 dep1 dep2 dep1 dep2<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">$? <\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">D\u00e9pendances plus r\u00e9centes que la cible $? dep1 (si plus r\u00e9cent)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">$*<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"> Base du nom de fichier (sans extension) $* \u2192 file pour file.c dep1 (sans .c)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">$+ <\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Toutes d\u00e9pendances (avec doublons) $+ dep1 dep2 dep1<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Exemple de makefile classique (un peu passe partout)<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#la cible (executable)\nTARGET = test\n#Makefile petit projet avec skeletonc\nCFLAGS = -g -Wall -pedantic -ansi\n#compilateur ici gcc\nCC = gcc\nDEB = gdb\n#section pour avoir TARGET il faut TARGET.c et faire \n$(TARGET): $(TARGET).c\n\t$(CC) $&lt; $(CFLAGS) -o $@\n#avec edit on aura le source dans vi\nedit:\t$(TARGET).c\n\tvi $(TARGET).c\n#on va lancer gdb avec l'executable\ngdb:\t$(TARGET)\n\t$(DEB) $(TARGET)\n#on nettoie le projet\nclean:\n\trm $(TARGET)\n# fausses cibles (phony)\n.PHONY: edit gdb clean<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Exemple d&rsquo;un petit projet <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">cptchaine.c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/********************************\n * Projet : passage de chaine\n * Auteur : Bogt\n * Date   : 28\/11\/2022\n ********************************\/\n#include &lt;stdlib.h>\n#include &lt;stdio.h>\n#include \"malib.h\"\n\nint main (int argc, char **argv)\n{\t\n\tint letter_number;\n\tletter_number=lg_chaine (\"Bonjour le monde\");\n\tprintf (\"on a %d lettre(s) ou espace(s) dans cette chaine\\n\",letter_number);\n\treturn EXIT_SUCCESS;\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">malib.c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;stdio.h>\n\/* fonction lg_chaine *\/\nint lg_chaine(char *chaine)\n{\n\tint nb_lettre;\n\tnb_lettre=0;   \/* pas de lettre au d\u00e9part de la fonction *\/\n\tprintf (\"%s \\n\",chaine);\n\twhile (chaine[nb_lettre]!=0)  \/* 0 ou '\\0' *\/\n \t{\n\t\tnb_lettre=nb_lettre+1; \t\/* on a une lettre en plus dans la chaine *\/\n\t}\n\treturn nb_lettre; \/* retour du nombre de lettre *\/\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">malib.h   (header)<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#ifndef __malib__\n#define __malib__\n\/* fonction lg_chaine *\/\nint lg_chaine(char *chaine);\n#endif<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">makefile  (version simple)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cptchaine: cptchaine.o malib.o\n\tgcc -o cptchaine malib.o cptchaine.o -Wall -ansi -pedantic -g\ncptchaine.o: cptchaine.c\n\tgcc -c cptchaine.c -Wall -ansi -pedantic\nmalib.o: malib.c\n\tgcc -Wall -ansi -pedantic -c malib.c\ntarball:\n\ttar -zcvf ..\/cptchaine.tar.gz cptchaine.c malib.c malib.h Makefile\nclean:\n\trm *.o cptchaine <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">version am\u00e9lior\u00e9e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CC = gcc\nCFLAGS = -Wall -ansi -pedantic -g\nOBJ = cptchaine.o malib.o\nTARGET = cptchaine\n\nall: $(TARGET)\n\n$(TARGET): $(OBJ)\n\t$(CC) -o $@ $^ $(CFLAGS)\n\ncptchaine.o: cptchaine.c\n\t$(CC) -c $&lt; -o $@ $(CFLAGS)\n\nmalib.o: malib.c\n\t$(CC) -c $&lt; -o $@ $(CFLAGS)\n\ntarball:\n\ttar -zcvf ..\/$(TARGET).tar.gz cptchaine.c malib.c malib.h Makefile\n\nclean:\n\t$(RM) $(OBJ) $(TARGET)\n\n.PHONY: all clean tarball<\/code><\/pre>\n\n\n\n<div data-wp-interactive=\"core\/file\" class=\"wp-block-file\"><object data-wp-bind--hidden=\"!state.hasPdfPreview\" hidden class=\"wp-block-file__embed\" data=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/05\/bavo-van-achte_gnumake.pdf\" type=\"application\/pdf\" style=\"width:100%;height:600px\" aria-label=\"Contenu embarqu\u00e9 bavo-van-achte_gnumake.\"><\/object><a id=\"wp-block-file--media-1647a008-e99f-4344-9861-6fd91a855731\" href=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/05\/bavo-van-achte_gnumake.pdf\">bavo-van-achte_gnumake<\/a><a href=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/05\/bavo-van-achte_gnumake.pdf\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-1647a008-e99f-4344-9861-6fd91a855731\">T\u00e9l\u00e9charger<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Make et makefile ou Makefile , souvent utiliser pour compiler un projet en langage c 1. Pourquoi utiliser Make ? Make\u00a0automatise la compilation : 2. Syntaxe de base Important\u00a0: Les commandes doivent commencer par une\u00a0tabulation\u00a0(pas des espaces !) il faut comprendre que pour faire la cible il faut la ou les d\u00e9pendance sinon infaisable Premier [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-7904","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/workboot.fr\/ciela\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"Make et makefile ou Makefile , souvent utiliser pour compiler un projet en langage c 1. Pourquoi utiliser Make ? Make\u00a0automatise la compilation : 2. Syntaxe de base Important\u00a0: Les commandes doivent commencer par une\u00a0tabulation\u00a0(pas des espaces !) il faut comprendre que pour faire la cible il faut la ou les d\u00e9pendance sinon infaisable Premier\u2026","_links":{"self":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/7904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/comments?post=7904"}],"version-history":[{"count":29,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/7904\/revisions"}],"predecessor-version":[{"id":7981,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/7904\/revisions\/7981"}],"wp:attachment":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/media?parent=7904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}