2013-08-21 8 views
19

Ho un makefile che è come questo:Come vengono stampati in uscita un commento in un makefile

install: 
    @somecommand 

    #some explanation for next command 
    @lastcommand 

Quello che succede è che il commento #some explanation for next command viene stampato quando eseguo make install. Come posso inserire un commento in un makefile che non viene stampato? Forse sto cercando l'equivalente Unix per il windowsy echo off?

(Effettivamente, il contrario di this question.)

risposta

35

Non rientrare il commento - quando la linea inizia con una scheda, è un comando che viene eseguito dalla shell (ed il guscio tratta il commento come un commento).

Proof of concept (ss.mk):

all: 
    echo "This is the first command" 
    # This comment is echoed 

# This comment is not echoed 
    echo "This is the second command" 

Esempio di output:

$ make -f ss.mk 
echo "This is the first command" 
This is the first command 
# This comment is echoed 
echo "This is the second command" 
This is the second command 
$ 
+3

non sarà anche mostrato un commento frastagliata preceduto da un '@', se * veramente * desidera far rientrare :-) – cmbuckley

+3

@cbuckley: Questo è vero, ma è un modo molto pesante di scrivere un commento perché 'make' forgerà ed eseguirà una shell che analizzerà il commento, deducendo che si tratta di un commento, e quindi esci con successo ... a meno che 'make' lo ottimizzi, cosa che probabilmente non lo farà. –

+0

Sì ... in precedenza il mio commento si è concluso con qualcosa con l'effetto di "... ma probabilmente è ridicolo." Non sono sicuro del motivo per cui l'ho rimosso! – cmbuckley

Problemi correlati