I have a makefile from which I want to call another external bash script to do another part of the building. How would I best go about doing this.
+5
A:
Just like calling any other command from a makefile:
target: prerequisites
shell_script arg1 arg2 arg3
Regarding your further explanation:
.PHONY: do_script
do_script:
shell_script arg1 arg2 arg3
prerequisites: do_script
target: prerequisites
Carl Norum
2010-03-23 05:00:20
but I need to run the script before the prerequisites
Matthew
2010-03-23 23:47:45
@Matthew, then your makefile is set up incorrectly. Make a new `.PHONY` target that your prerequisites depend on, and run the script in that target.
Carl Norum
2010-03-24 00:15:57
Edited with more for your case.
Carl Norum
2010-03-24 00:17:19
A:
Each of the actions in the makefile rule is a command that will be executed in a subshell. You need to ensure that each command is independent, since each one will be run inside a separate subshell.
For this reason, you will often see line breaks escaped when the author wants several commands to run in the same subshell:
targetfoo:
command_the_first foo bar baz
command_the_second wibble wobble warble
command_the_third which is rather too long \
to fit on a single line so \
intervening line breaks are escaped
command_the_fourth spam eggs beans
bignose
2010-03-23 06:16:14