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
In a Makefile, each line is run in a different shell. If you want to run something in a different directory, you need to cd /dir && something .
The $@ and $< are called automatic variables. The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file. For example: hello.o: hello.c hello.h gcc -c $< -o $@ Here, hello.o is the output file.
The cd (change directory) command moves you into a different directory. To move out of that directory, use cd along with the path to some other location, or use double dots to backtrack, or return home to navigate from there. Navigating a Linux computer is like navigating the internet.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With