IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Shell et commandes GNU Discussion :

Makefile : Suppression non désirée des .jpg créés.


Sujet :

Shell et commandes GNU

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2014
    Messages : 2
    Points : 2
    Points
    2
    Par défaut Makefile : Suppression non désirée des .jpg créés.
    Bonsoir à tous!

    J'ai lancé des recherches sur google, lu la FAQ du forum et les règles du site et recherché sur le forum sans résultats, je me permets donc de créer un sujet.

    Petite présentation : Je suis actuellement étudiant en informatique (ensimag pour ceux qui connaissent) et un projet de Makefile nous a été donné à faire. Nous venons juste de découvrire les makefile donc mes connaissances restent relativement faibles mais je pense avoir compris le principe. Je travaille sous Centos 6.5 64 bits.

    But du projet : à partir d'un répertoire source contenant des images .jpg, il nous est demandé de créer une page index.html dans un répertoire /dest qui affiche ces images redimenssionnées.

    Le problème : Tout fonctionne, j'ai bien vérifié avec
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    makefile dest/index -rRd
    sauf qu'au final, j'ai :
    Successfully remade target file `dest/index.html'.
    Removing intermediate files...
    rm dest/black_texture_terminal_background.jpg dest/hot-keely-hazell-looking-sexy.jpg dest/images.jpg dest/youm.jpg
    Make supprime donc mes images redimenssionnées du dossier /dest ce qui fait qu'en tapant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    firefox /dest/index.html
    Rien n'est affiché puisque les images appellées par index.html ne sont plus dans le dossier /dest.

    Ma question : Pourquoi make considère-t-il ces fichiers comme intermédiaires? J'ai cru comprendre qu'en effet, make supprimait les fichiers qu'il avait eu besoin de créer au fur et à mesure de la compilation mais ceux-ci sont explicitement créés par moi-même? Est-il possible de lui demander de conserver ces fichiers ou dois-je changer quelque chose à mon code?

    Mon Makefile :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    # Source and destination directories, to be configured here:
    SOURCE=~/Pictures
    DEST=./dest
     
    IMAGES=${shell cd $(SOURCE) && echo *.jpg}
    THUMBS=$(IMAGES:%=$(DEST)/%)
    IMAGE_DESC=$(IMAGES:%.jpg=$(DEST)/%.inc)
     
     
    # TODO
    $(DEST)/%.inc: $(DEST)/%.jpg
    	./generate-img-fragment_make.sh $< > $@ 
     
    $(DEST)/index.html: $(IMAGE_DESC)
    	./generate-index.sh --html_head >> $@ ; \
    	for k in $(IMAGE_DESC) ; do \
    	./generate-index.sh $$k >> $@ ; \
    	done ; \
    	./generate-index.sh --html_tail >> $@ ; 
     
     
    $(DEST)/%.jpg: $(SOURCE)/%.jpg
    	convert $< -resize 200x200 $@
    Descriptions des scripts du Makefile

    generate-img-fragment_make prend en argument $1 une image.jpg et donne le code html nécessaire.
    generate-index.sh donne le head et le tail du html avec --html_head et --html_tail et effectue un simple cat $1 dans les autres cas.

    Le verbose complet du make :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
     
    [Fitz@localhost squelette-tpl-unix]$ make dest/index.html -rRd
    GNU Make 3.81
    Copyright (C) 2006  Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.
     
    This program built for x86_64-redhat-linux-gnu
    Reading makefiles...
    Reading makefile `Makefile'...
    Updating makefiles....
     Considering target file `Makefile'.
      Looking for an implicit rule for `Makefile'.
      No implicit rule found for `Makefile'.
      Finished prerequisites of target file `Makefile'.
     No need to remake target `Makefile'.
    Updating goal targets....
    Considering target file `dest/index.html'.
     File `dest/index.html' does not exist.
      Considering target file `dest/black_texture_terminal_background.inc'.
       File `dest/black_texture_terminal_background.inc' does not exist.
       Looking for an implicit rule for `dest/black_texture_terminal_background.inc'.
       Trying pattern rule with stem `black_texture_terminal_background'.
       Trying implicit prerequisite `dest/black_texture_terminal_background.jpg'.
       Trying pattern rule with stem `black_texture_terminal_background'.
       Trying implicit prerequisite `dest/black_texture_terminal_background.jpg'.
       Looking for a rule with intermediate file `dest/black_texture_terminal_background.jpg'.
        Avoiding implicit rule recursion.
        Trying pattern rule with stem `black_texture_terminal_background'.
        Trying implicit prerequisite `/home/Fitz/Pictures/black_texture_terminal_background.jpg'.
       Found an implicit rule for `dest/black_texture_terminal_background.inc'.
         Considering target file `/home/Fitz/Pictures/black_texture_terminal_background.jpg'.
          Looking for an implicit rule for `/home/Fitz/Pictures/black_texture_terminal_background.jpg'.
          No implicit rule found for `/home/Fitz/Pictures/black_texture_terminal_background.jpg'.
          Finished prerequisites of target file `/home/Fitz/Pictures/black_texture_terminal_background.jpg'.
         No need to remake target `/home/Fitz/Pictures/black_texture_terminal_background.jpg'.
       Considering target file `dest/black_texture_terminal_background.jpg'.
        File `dest/black_texture_terminal_background.jpg' does not exist.
         Pruning file `/home/Fitz/Pictures/black_texture_terminal_background.jpg'.
        Finished prerequisites of target file `dest/black_texture_terminal_background.jpg'.
       Must remake target `dest/black_texture_terminal_background.jpg'.
    convert /home/Fitz/Pictures/black_texture_terminal_background.jpg -resize 200x200 dest/black_texture_terminal_background.jpg
    Putting child 0x009425a0 (dest/black_texture_terminal_background.jpg) PID 4126 on the chain.
    Live child 0x009425a0 (dest/black_texture_terminal_background.jpg) PID 4126 
    Reaping winning child 0x009425a0 PID 4126 
    Removing child 0x009425a0 PID 4126 from chain.
       Successfully remade target file `dest/black_texture_terminal_background.jpg'.
       Finished prerequisites of target file `dest/black_texture_terminal_background.inc'.
      Must remake target `dest/black_texture_terminal_background.inc'.
    ./generate-img-fragment_make.sh dest/black_texture_terminal_background.jpg > dest/black_texture_terminal_background.inc 
    Putting child 0x0094e020 (dest/black_texture_terminal_background.inc) PID 4130 on the chain.
    Live child 0x0094e020 (dest/black_texture_terminal_background.inc) PID 4130 
    Reaping winning child 0x0094e020 PID 4130 
    Removing child 0x0094e020 PID 4130 from chain.
      Successfully remade target file `dest/black_texture_terminal_background.inc'.
      Considering target file `dest/hot-keely-hazell-looking-sexy.inc'.
       File `dest/hot-keely-hazell-looking-sexy.inc' does not exist.
       Looking for an implicit rule for `dest/hot-keely-hazell-looking-sexy.inc'.
       Trying pattern rule with stem `hot-keely-hazell-looking-sexy'.
       Trying implicit prerequisite `dest/hot-keely-hazell-looking-sexy.jpg'.
       Trying pattern rule with stem `hot-keely-hazell-looking-sexy'.
       Trying implicit prerequisite `dest/hot-keely-hazell-looking-sexy.jpg'.
       Looking for a rule with intermediate file `dest/hot-keely-hazell-looking-sexy.jpg'.
        Avoiding implicit rule recursion.
        Trying pattern rule with stem `hot-keely-hazell-looking-sexy'.
        Trying implicit prerequisite `/home/Fitz/Pictures/hot-keely-hazell-looking-sexy.jpg'.
       Found an implicit rule for `dest/hot-keely-hazell-looking-sexy.inc'.
         Considering target file `/home/Fitz/Pictures/hot-keely-hazell-looking-sexy.jpg'.
          Looking for an implicit rule for `/home/Fitz/Pictures/hot-keely-hazell-looking-sexy.jpg'.
          No implicit rule found for `/home/Fitz/Pictures/hot-keely-hazell-looking-sexy.jpg'.
          Finished prerequisites of target file `/home/Fitz/Pictures/hot-keely-hazell-looking-sexy.jpg'.
         No need to remake target `/home/Fitz/Pictures/hot-keely-hazell-looking-sexy.jpg'.
       Considering target file `dest/hot-keely-hazell-looking-sexy.jpg'.
        File `dest/hot-keely-hazell-looking-sexy.jpg' does not exist.
         Pruning file `/home/Fitz/Pictures/hot-keely-hazell-looking-sexy.jpg'.
        Finished prerequisites of target file `dest/hot-keely-hazell-looking-sexy.jpg'.
       Must remake target `dest/hot-keely-hazell-looking-sexy.jpg'.
    convert /home/Fitz/Pictures/hot-keely-hazell-looking-sexy.jpg -resize 200x200 dest/hot-keely-hazell-looking-sexy.jpg
    Putting child 0x0094d910 (dest/hot-keely-hazell-looking-sexy.jpg) PID 4133 on the chain.
    Live child 0x0094d910 (dest/hot-keely-hazell-looking-sexy.jpg) PID 4133 
    Reaping winning child 0x0094d910 PID 4133 
    Removing child 0x0094d910 PID 4133 from chain.
       Successfully remade target file `dest/hot-keely-hazell-looking-sexy.jpg'.
       Finished prerequisites of target file `dest/hot-keely-hazell-looking-sexy.inc'.
      Must remake target `dest/hot-keely-hazell-looking-sexy.inc'.
    ./generate-img-fragment_make.sh dest/hot-keely-hazell-looking-sexy.jpg > dest/hot-keely-hazell-looking-sexy.inc 
    Putting child 0x0094d970 (dest/hot-keely-hazell-looking-sexy.inc) PID 4137 on the chain.
    Live child 0x0094d970 (dest/hot-keely-hazell-looking-sexy.inc) PID 4137 
    Reaping winning child 0x0094d970 PID 4137 
    Removing child 0x0094d970 PID 4137 from chain.
      Successfully remade target file `dest/hot-keely-hazell-looking-sexy.inc'.
      Considering target file `dest/images.inc'.
       File `dest/images.inc' does not exist.
       Looking for an implicit rule for `dest/images.inc'.
       Trying pattern rule with stem `images'.
       Trying implicit prerequisite `dest/images.jpg'.
       Trying pattern rule with stem `images'.
       Trying implicit prerequisite `dest/images.jpg'.
       Looking for a rule with intermediate file `dest/images.jpg'.
        Avoiding implicit rule recursion.
        Trying pattern rule with stem `images'.
        Trying implicit prerequisite `/home/Fitz/Pictures/images.jpg'.
       Found an implicit rule for `dest/images.inc'.
         Considering target file `/home/Fitz/Pictures/images.jpg'.
          Looking for an implicit rule for `/home/Fitz/Pictures/images.jpg'.
          No implicit rule found for `/home/Fitz/Pictures/images.jpg'.
          Finished prerequisites of target file `/home/Fitz/Pictures/images.jpg'.
         No need to remake target `/home/Fitz/Pictures/images.jpg'.
       Considering target file `dest/images.jpg'.
        File `dest/images.jpg' does not exist.
         Pruning file `/home/Fitz/Pictures/images.jpg'.
        Finished prerequisites of target file `dest/images.jpg'.
       Must remake target `dest/images.jpg'.
    convert /home/Fitz/Pictures/images.jpg -resize 200x200 dest/images.jpg
    Putting child 0x0094dd90 (dest/images.jpg) PID 4140 on the chain.
    Live child 0x0094dd90 (dest/images.jpg) PID 4140 
    Reaping winning child 0x0094dd90 PID 4140 
    Removing child 0x0094dd90 PID 4140 from chain.
       Successfully remade target file `dest/images.jpg'.
       Finished prerequisites of target file `dest/images.inc'.
      Must remake target `dest/images.inc'.
    ./generate-img-fragment_make.sh dest/images.jpg > dest/images.inc 
    Putting child 0x009501e0 (dest/images.inc) PID 4144 on the chain.
    Live child 0x009501e0 (dest/images.inc) PID 4144 
    Reaping winning child 0x009501e0 PID 4144 
    Removing child 0x009501e0 PID 4144 from chain.
      Successfully remade target file `dest/images.inc'.
      Considering target file `dest/youm.inc'.
       File `dest/youm.inc' does not exist.
       Looking for an implicit rule for `dest/youm.inc'.
       Trying pattern rule with stem `youm'.
       Trying implicit prerequisite `dest/youm.jpg'.
       Trying pattern rule with stem `youm'.
       Trying implicit prerequisite `dest/youm.jpg'.
       Looking for a rule with intermediate file `dest/youm.jpg'.
        Avoiding implicit rule recursion.
        Trying pattern rule with stem `youm'.
        Trying implicit prerequisite `/home/Fitz/Pictures/youm.jpg'.
       Found an implicit rule for `dest/youm.inc'.
         Considering target file `/home/Fitz/Pictures/youm.jpg'.
          Looking for an implicit rule for `/home/Fitz/Pictures/youm.jpg'.
          No implicit rule found for `/home/Fitz/Pictures/youm.jpg'.
          Finished prerequisites of target file `/home/Fitz/Pictures/youm.jpg'.
         No need to remake target `/home/Fitz/Pictures/youm.jpg'.
       Considering target file `dest/youm.jpg'.
        File `dest/youm.jpg' does not exist.
         Pruning file `/home/Fitz/Pictures/youm.jpg'.
        Finished prerequisites of target file `dest/youm.jpg'.
       Must remake target `dest/youm.jpg'.
    convert /home/Fitz/Pictures/youm.jpg -resize 200x200 dest/youm.jpg
    Putting child 0x00950750 (dest/youm.jpg) PID 4147 on the chain.
    Live child 0x00950750 (dest/youm.jpg) PID 4147 
    Reaping winning child 0x00950750 PID 4147 
    Removing child 0x00950750 PID 4147 from chain.
       Successfully remade target file `dest/youm.jpg'.
       Finished prerequisites of target file `dest/youm.inc'.
      Must remake target `dest/youm.inc'.
    ./generate-img-fragment_make.sh dest/youm.jpg > dest/youm.inc 
    Putting child 0x009502b0 (dest/youm.inc) PID 4151 on the chain.
    Live child 0x009502b0 (dest/youm.inc) PID 4151 
    Reaping winning child 0x009502b0 PID 4151 
    Removing child 0x009502b0 PID 4151 from chain.
      Successfully remade target file `dest/youm.inc'.
     Finished prerequisites of target file `dest/index.html'.
    Must remake target `dest/index.html'.
    ./generate-index.sh --html_head >> dest/index.html ; \
    	for k in ./dest/black_texture_terminal_background.inc ./dest/hot-keely-hazell-looking-sexy.inc ./dest/images.inc ./dest/youm.inc ; do \
    	./generate-index.sh $k >> dest/index.html ; \
    	done ; \
    	./generate-index.sh --html_tail >> dest/index.html ; \
     
    Putting child 0x00942230 (dest/index.html) PID 4155 on the chain.
    Live child 0x00942230 (dest/index.html) PID 4155 
    Reaping winning child 0x00942230 PID 4155 
    Removing child 0x00942230 PID 4155 from chain.
    Successfully remade target file `dest/index.html'.
    Removing intermediate files...
    rm dest/black_texture_terminal_background.jpg dest/hot-keely-hazell-looking-sexy.jpg dest/images.jpg dest/youm.jpg
    Merci à ceux qui ont eu le courage de me lire et merci pour vos futures questions/réponses/critiques!

    Bonne soirée!

  2. #2
    Modérateur
    Avatar de jlliagre
    Homme Profil pro
    Ingénieur support avancé & développement
    Inscrit en
    Juin 2007
    Messages
    2 695
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur support avancé & développement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 695
    Points : 7 882
    Points
    7 882
    Par défaut
    Pour que make n'efface pas ces fichiers, tu peux rajouter la ligne suivante dans ton Makefile :
    ɹǝsn *sıɹɐlos*

  3. #3
    Expert confirmé
    Homme Profil pro
    Développeur informatique en retraite
    Inscrit en
    Avril 2008
    Messages
    2 101
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique en retraite

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 101
    Points : 5 849
    Points
    5 849
    Par défaut
    Juste une petite remarque:
    généralement, dans un makefile, on met des cibles explicites, dont la première est la cible par défaut.
    ça évite de devoir connaître la cible dest/index.html et permet donc de remplacer make dest/index.html par make tout court.

    Par exemple:
    all : pour tout générer avec la commande "make" sans argument
    clean : pour tout nettoyer et repartir à zéro
    install : pour générer l'installation
    etc.

  4. #4
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2014
    Messages : 2
    Points : 2
    Points
    2
    Par défaut
    Citation Envoyé par jack-ft Voir le message
    Juste une petite remarque:
    généralement, dans un makefile, on met des cibles explicites, dont la première est la cible par défaut.
    ça évite de devoir connaître la cible dest/index.html et permet donc de remplacer make dest/index.html par make tout court.

    Par exemple:
    all : pour tout générer avec la commande "make" sans argument
    clean : pour tout nettoyer et repartir à zéro
    install : pour générer l'installation
    etc.
    Désolé de mes réponses tardives...
    Oui, oui, bien sûr, c'était pas finalisé encore et j'ai bien rajouté un all (appelé gallery) et un clean. Par contre, je ne vois pas ce qu'un install est censé faire.

    Citation Envoyé par jlliagre Voir le message
    Pour que make n'efface pas ces fichiers, tu peux rajouter la ligne suivante dans ton Makefile :
    Je ne comprends pas pourquoi le %. Ca ne va pas causer un conflit avec mes autres règles en %.jgp? Ou alors make va seuleument passer par precious et continuer la recherche de règles ensuite?

    En tout cas, j'ai utilisé d'après http://www.thinkplexx.com/learn/howt...rmediate-files
    Et ca fonctionne.

  5. #5
    Modérateur
    Avatar de jlliagre
    Homme Profil pro
    Ingénieur support avancé & développement
    Inscrit en
    Juin 2007
    Messages
    2 695
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur support avancé & développement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 695
    Points : 7 882
    Points
    7 882
    Par défaut
    Citation Envoyé par Fitz_ Voir le message
    Je ne comprends pas pourquoi le %. Ca ne va pas causer un conflit avec mes autres règles en %.jgp? Ou alors make va seuleument passer par precious et continuer la recherche de règles ensuite?
    Est-ce que tu as essayé ".PRECIOUS" ?
    Est-ce que tu avais besoin de préserver d'autres fichiers que les .jpg ?
    Qu'est-ce qui te fait penser qu'il y aurait eu un conflit ?
    ɹǝsn *sıɹɐlos*

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Approximation non désirée des nombres immenses
    Par schecter dans le forum MATLAB
    Réponses: 21
    Dernier message: 15/06/2009, 17h15
  2. Conversion non désirée des nombres a virgule
    Par bilou972 dans le forum C#
    Réponses: 5
    Dernier message: 10/12/2008, 02h47
  3. Non coloriage des rectangles créés et rendus visibles
    Par keketteboy dans le forum VBA Access
    Réponses: 6
    Dernier message: 12/06/2008, 18h33
  4. Duplication non désirée des données
    Par Hades5k dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 15/08/2006, 21h27
  5. Transparence non désirée des TPanel
    Par Manopower dans le forum Composants VCL
    Réponses: 3
    Dernier message: 07/11/2005, 09h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo