How do I get `make` to prompt the user for a password and store it in a Makefile variable?

后端 未结 2 1705
抹茶落季
抹茶落季 2021-02-04 04:12

I\'m writing a Makefile, and some of the commands the makefile runs require a password. I\'d like to give the user the ability to either pass this in as a Makefile variable usi

2条回答
  •  庸人自扰
    2021-02-04 04:41

    To answer @joeb 's question:

    $ make; echo "---Makefile---"; cat Makefile
    Password: 
    test
    test
    ---Makefile---
    all: first second
    PASSWORD ?= $(shell read -s -p "Password: " pass; echo $$pass)
    define formatted
    first:
            @echo $1
    second:
            @echo $1
    endef
    
    $(eval $(call formatted,$(PASSWORD)))
    

提交回复
热议问题