Browse Source

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 <roman@faizullin.info>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
pull/344/head
Paul Fertser 10 years ago
committed by Karl Palsson
parent
commit
283d8cc7d2
  1. 8
      Makefile
  2. 8
      lib/Makefile.include

8
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;

8
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

Loading…
Cancel
Save