Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

makefile: execute one target from another target plus additional commands

Tags:

makefile

I have a makefile with something like the following targets:

install:
    do a whole bunch of stuff to install

dist: install
    cp README.txt $(INSTALL_DIR)
    zip $(INSTALL_DIR)

I am trying to not repeat the commands from target install and make dist execute install first before executing its own commands.

Calling make dist does indeed execute all commands from target install but then just stops and it does not execute its own commands, e.g. the cp.

Am I missing something?

like image 595
cschol Avatar asked Mar 20 '10 05:03

cschol


People also ask

What is $@ in makefile?

$@ is the name of the target being generated, and $< the first prerequisite (usually a source file). You can find a list of all these special variables in the GNU Make manual.

What does .phony do in makefile?

The special rule . PHONY is used to specify that the target is not a file. Common uses are clean and all . This way it won't conflict if you have files named clean or all .


Video Answer


1 Answers

try to add this line in your makefile

.PHONY : install dist

like image 72
zhongshu Avatar answered Nov 03 '22 13:11

zhongshu