Escaping colons in filenames in a Makefile

后端 未结 6 1752
再見小時候
再見小時候 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条回答
  •  萌比男神i
    2020-12-03 21:22

    The following hack worked for me, though it unfortunately relies on $(shell).

    # modify file names immediately
    PRE := $(shell rename : @COLON@ *)
    # example variables that I need
    XDLS = $(wildcard *.xdl)
    YYYS = $(patsubst %.xdl,%.yyy,$(XDLS))
    # restore file names later
    POST = $(shell rename @COLON@ : *)
    
    wrapper: $(YYYS)
        @# restore file names
        $(POST)
    
    $(YYYS):
        @# show file names after $(PRE) renaming but before $(POST) renaming
        @ls
    

    Because PRE is assigned with :=, its associated shell command is run before the XDLS variable is evaluated. The key is to then put the colons back in place after the fact by explicitly invoking $(POST).

提交回复
热议问题