Escaping colons in filenames in a Makefile

后端 未结 6 1770
再見小時候
再見小時候 2020-12-03 20:59

Is there a way to get GNU make to work correctly with filenames that contain colons?

The specific problem I\'m running into happens to involve a pattern rule. Here\

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 21:46

    I could not get the answer posted by @navjotk to work, so I am just gonna cheat and do this;

    FILENAME:=foo:bar
    foo_bar:
        touch $(FILENAME)
    
    run:
        if [ ! -e "$(FILENAME)" ]; then $(MAKE) foo_bar; fi
    

    output:

    $ make run
    if [ ! -e "foo:bar" ]; then /Library/Developer/CommandLineTools/usr/bin/make foo_bar; fi
    touch foo:bar
    
    $ ls
    Makefile foo:bar
    

    Close enough for me.

提交回复
热议问题