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

前端 未结 6 1432
深忆病人
深忆病人 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:03

    I found a great inspiration at http://www.mail-archive.com/help-make@gnu.org/msg05201.html which got me going. My own test application consists of a directory of WW2-era Jazz FLV files downloaded from YouTube and an audio subdirectory into which I'd like to store the OGA audio versions of each one. And, of course, the file names contain spaces. I would then like to run ffmpeg2theora to

    Here is the GNUMake Makefile that I've hacked together to work. Thanks to all of the hints on this site and also the referenced site above!

    sq = $(subst $(sp),?,$1)
    qs = $(subst ?,$(sp),$1)
    
    e :=
    sp := $(e) $(e)
    
    FLVS := $(foreach file,var,$(call sq,$(wildcard *.flv)))
    FLVS := $(subst .flv?,.flv ,$(FLVS))
    
    AUDIOS := $(patsubst %.flv,audio/%.oga,$(FLVS))
    
    .PHONY: audios show
    
    audios: $(AUDIOS)
    
    $(AUDIOS) : $(FLVS)
        ffmpeg2theora --novideo -o "$(call qs,$@)" "$(call qs,$(notdir $(patsubst %.oga,audio/%.flv,$@)))"
    
    show:
        echo $(FLVS)
        echo $(AUDIOS)
    

提交回复
热议问题