How to run a bash script from a Makefile?

后端 未结 3 1386
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 01:48

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?

3条回答
  •  独厮守ぢ
    2021-02-01 02:23

    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
    

提交回复
热议问题