Crawlicious | tools for web business

Jun/09

11

how to change directory in makefile

How do you change directories in a makefile, run a command and then change back? First off, all the commands that you want to run for that situation must be on the same line, because make executes each line with a new shell (weird huh?). Here is an example…

foo:
    pushd /etc; pwd; popd
    cd /bin; stat ls; cd -

Remember if you cut and paste the above code, you must change the 4 spaces preceding the line to a real tab, or make will freak out.

Either cd or pushd will work, just remember to link all your commands that belong in that same shell with a semicolon, you can also use &&, or ||, but then you need to make certain that you want the logic that implies.

Happy making!

RSS Feed

1 Comment for how to change directory in makefile

PianoMan | October 22, 2009 at 11:01 am

PianoMan…

Megacool Blog indeed!… if anyone else has anything it would be much appreciated. Great website Enjoy!…

Leave a comment!

You must be logged in to post a comment.

«

»

Find it!

Theme Design by devolux.org