7

My project folders look like this

Makefile
/src
  /flash
    build.xml
  /blabla
    ...

I wrote a Makefile like this

flash: src/flash/bin-debug/App.swf

src/flash/bin-debug/App.swf:
    cd src/flash
    ant

When I execute make flash, I get the following message:

cd src/flash/
ant
Buildfile: build.xml does not exist!
Build failed
make: *** [src/flash/bin-debug/App.swf] Error 1

How can I execute ant in src/flash

Bart
  • 19,692
  • 7
  • 68
  • 77
guilin 桂林
  • 17,050
  • 29
  • 92
  • 146

2 Answers2

7

make creates a new subshell for each line. Try:

src/flash/bin-debug/App.swf:
    cd src/flash; ant

Otherwise the two commands are executed in two separate subshells. The effect of the cd is lost when the first subshell terminates.

NPE
  • 486,780
  • 108
  • 951
  • 1,012
  • Thanks. it works. but it seams if the App.swf once created it will never execute this task any more. are there anyway to force it execute every time or check if any files in `/src/flash/src/**/*`, `/src/flash/res/**/*` changes – guilin 桂林 Feb 27 '12 at 11:41
4

As explained by aix, you must write cd src/flash; ant on a single line.

As you haven't specified any dependencies for the App.swf target, make cannot rebuild when they change. You could add them. The problem is that you don't want to duplicate the work you are already doing with ant.

With GNU Make the solution is to use a phony target. It is a type of target that is not interpreted as a file name and whose commands will be executed every time the target is built.

This looks something like this:

.PHONY: flash

flash:
    cd src/flash; ant

Typing make flash repeatedly will invoke ant every time.