tags:

views:

148

answers:

2

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?

A: 

I am assuming you are new to Makefile. Then you must make sure there is a <tab> character before the commands "do a whole bunch", "cp" and "zip...". This is a syntax requirement of Makefiles.

Amit Kumar
True - but not really an answer to the question. Since the 'install' part worked, this much must have been resolved.
Jonathan Leffler
+2  A: 

try to add this line in your makefile

.PHONY : install dist

zhongshu
That was it. Can you elaborate why this is necessary? Thanks.
cschol
Was the install directory called 'install' (or perhaps 'dist')? That tends to confuse things. The '.PHONY' notation (a GNU Make extension) means roughly that the 'target' is to be treated as always out of date.
Jonathan Leffler