What is the most reliable way of using GNUMake with filenames containing spaces?

前端 未结 6 1429
深忆病人
深忆病人 2021-01-12 11:11

I want to use GNUMake to run a rule-based makefile which builds a set of C files in a directory structure (on a Windows file system).

The root directory, some sub-di

6条回答
  •  深忆病人
    2021-01-12 12:08

    I've typically used what is sort of a combination of Dana the Sane's answer and Brian Yoder's answer.

    You just use the $(subst) function to replace all occurances of spaces with escaped spaces. EG:

    empty := 
    space := $(empty) $(empty)
    program_files := $(subst $(space),\$(space),$(ProgramFiles))
    

    (Note that with some older versions of make on Windows you would also need to use another $(subst) to change path backslashes to slashes)

提交回复
热议问题