Makefile as an executable script with shebang?

前端 未结 2 1077
青春惊慌失措
青春惊慌失措 2020-12-05 10:20

Is it possible to create an executable script that would be interpreted by make?

I tried this:

#!/usr/bin/env make --makefile=/dev/stdin

main:
              


        
2条回答
  •  失恋的感觉
    2020-12-05 11:15

    The following adds a level of indirection but it's the best solution I've come up with for self-executing makefiles not called "makefile":

    #!/bin/sh
    exec make -f- "$@" << 'eof'
    
    .PHONY: all
    all:
        @echo 'hello world!'
    

    I'm trying to collect #! env hacks for each language / program here.

提交回复
热议问题