From 283d8cc7d2acbfc873897e886658364b12fc5e3b Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Wed, 6 Aug 2014 18:08:35 +0400 Subject: [PATCH] Makefile: fix build for directories with spaces When full path of a source directory has spaces in it, that makes shell and Make split the path, so special treatment is necessary. Additionally, @F doesn't honour the escaping, so has to be avoided. Reported-by: Roman Faizullin Signed-off-by: Paul Fertser --- Makefile | 8 +++++--- lib/Makefile.include | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 1f66bfc0..0edf3f70 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,9 @@ LIBDIR := $(DESTDIR)/$(PREFIX)/lib SHAREDIR := $(DESTDIR)/$(PREFIX)/share/libopencm3/scripts INSTALL := install -SRCLIBDIR:= $(realpath lib) +space:= +space+= +SRCLIBDIR:= $(subst $(space),\$(space),$(realpath lib)) TARGETS:= stm32/f0 stm32/f1 stm32/f2 stm32/f3 stm32/f4 stm32/l1 lpc13xx lpc17xx \ lpc43xx/m4 lpc43xx/m0 lm3s lm4f \ @@ -62,7 +64,7 @@ build: lib LIB_DIRS:=$(wildcard $(addprefix lib/,$(TARGETS))) $(LIB_DIRS): $(IRQ_DEFN_FILES:=.genhdr) @printf " BUILD $@\n"; - $(Q)$(MAKE) --directory=$@ SRCLIBDIR=$(SRCLIBDIR) + $(Q)$(MAKE) --directory=$@ SRCLIBDIR="$(SRCLIBDIR)" lib: $(LIB_DIRS) $(Q)true @@ -92,7 +94,7 @@ clean: $(IRQ_DEFN_FILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) %.clean: $(Q)if [ -d $* ]; then \ printf " CLEAN $*\n"; \ - $(MAKE) -C $* clean SRCLIBDIR=$(SRCLIBDIR) || exit $?; \ + $(MAKE) -C $* clean SRCLIBDIR="$(SRCLIBDIR)" || exit $?; \ fi; diff --git a/lib/Makefile.include b/lib/Makefile.include index 4c44bf6e..70fdd5c3 100644 --- a/lib/Makefile.include +++ b/lib/Makefile.include @@ -29,12 +29,12 @@ OBJS += vector.o systick.o scb.o nvic.o assert.o sync.o dwt.o all: $(SRCLIBDIR)/$(LIBNAME).a $(SRCLIBDIR)/$(LIBNAME).a: $(SRCLIBDIR)/$(LIBNAME).ld $(OBJS) - @printf " AR $(@F)\n" - $(Q)$(AR) $(ARFLAGS) $@ $(OBJS) + @printf " AR $(LIBNAME).a\n" + $(Q)$(AR) $(ARFLAGS) "$@" $(OBJS) $(SRCLIBDIR)/$(LIBNAME).ld: $(LIBNAME).ld - @printf " CP $(@F)\n" - $(Q)cp $^ $@ + @printf " CP $(LIBNAME).ld\n" + $(Q)cp $^ "$@" $(Q)if [ -f $(LIBNAME)_rom_to_ram.ld ]; then cp $(LIBNAME)_rom_to_ram.ld $(SRCLIBDIR); fi %.o: %.c