[make] Use less shell variables

Use fixed variables for things that can't change, instead of variables
like SRCLIBDIR that was causing a shell call for every single use.

Use less functions in general and less shell expansions.

Use builtin functions like $(realpath blah) instead of $(shell
pwd)/blah  In particular, this was important for me trying to build on
windows with git-shell.  This should help a lot on smaller build
machines, but doesn't make a huge difference on my own.

Remove redundant clean print messages. These also cause more needless
shell expansions.
This commit is contained in:
Karl Palsson
2013-05-22 21:21:12 +00:00
committed by Piotr Esden-Tempski
parent b876b72b39
commit bad5580492
2 changed files with 10 additions and 11 deletions

View File

@@ -29,20 +29,19 @@ OBJS += vector.o systick.o scb.o nvic.o assert.o sync.o
all: $(SRCLIBDIR)/$(LIBNAME).a
$(SRCLIBDIR)/$(LIBNAME).a: $(SRCLIBDIR)/$(LIBNAME).ld $(OBJS)
@printf " AR $(shell basename $(@))\n"
$(Q)$(AR) $(ARFLAGS) $(SRCLIBDIR)/$(shell basename $(@)) $(OBJS)
@printf " AR $(@F)\n"
$(Q)$(AR) $(ARFLAGS) $@ $(OBJS)
$(SRCLIBDIR)/$(LIBNAME).ld: $(LIBNAME).ld
@printf " CP $(LIBNAME).ld\n"
@printf " CP $(@F)\n"
$(Q)cp $^ $@
$(Q)if [ -f $(LIBNAME)_rom_to_ram.ld ]; then cp $(LIBNAME)_rom_to_ram.ld $(SRCLIBDIR); fi
%.o: %.c
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
@printf " CC $(<F)\n"
$(Q)$(CC) $(CFLAGS) -o $@ -c $<
clean:
@printf " CLEAN lib$(subst $(shell cd $(dir $(lastword $(MAKEFILE_LIST))) && pwd),,$(shell pwd))\n"
$(Q)rm -f *.o *.d ../*.o ../*.d
$(Q)rm -f $(SRCLIBDIR)/$(LIBNAME).a
$(Q)rm -f $(SRCLIBDIR)/$(LIBNAME).ld