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

前端 未结 6 1440
深忆病人
深忆病人 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 11:46

    The easiest thing is indeed to fix the file names.

    Failing that, though, write your commands to put double quotes around the file names. The easiest and safest thing is to put all the file names into macros; the trick there is that you have to escape the double quotes, which Make is otherwise going to want to eat up itself.

    So: FN="\"C:\My Documents\myfiles.c\"" FN2="C:\My Documents\myfile2.c"

    or use $(CC) $(CFLAGS) "$(FN2)"

    The trick here is to echo your command line with echo

    echo $(CC) $(CFLAGS) "$(FN2)"
    

    or use make -d to get all the details of what make is trying to do.

    You may need to hack about with this a bit, in particular, you may need to double up the escapes

提交回复
热议问题