How to run a bash script from a Makefile?

后端 未结 3 1300
伪装坚强ぢ
伪装坚强ぢ 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:19

    Perhaps not the "right" way to do it like the answers already provided, but I came across this question because I wanted my makefile to run a script I wrote to generate a header file that would provide the version for a whole package of software. I have quite a bit of targets in this package, and didn't want to add a brand new prerequisite to them all. Putting this towards the beginning of my makefile worked for me

    $(shell ./genVer.sh)
    

    which tells make to simply run a shell command. ./genVer.sh is the path (same directory as the makefile) and name of my script to run. This runs no matter which target I specify (including clean, which is the downside, but ultimately not a huge deal to me).

提交回复
热议问题