From 8b7ddb2f7018da6c717610694a0384e9a82195b0 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Sat, 5 Mar 2016 00:53:05 +0100 Subject: [PATCH] make: use variable for pkg subdir --- Makefile.buildtests | 7 ++++++- Makefile.include | 20 +++++++++++--------- Makefile.vars | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile.buildtests b/Makefile.buildtests index 6845f89a7f..5dc662e71c 100644 --- a/Makefile.buildtests +++ b/Makefile.buildtests @@ -55,6 +55,7 @@ buildtest: RIOTBASE=$${RIOTBASE} \ RIOTBOARD=$${RIOTBOARD} \ RIOTCPU=$${RIOTCPU} \ + RIOTPKG=$${RIOTPKG} \ BINDIRBASE=$${BINDIRBASE} \ RIOTNOLINK=$${RIOTNOLINK} \ RIOT_VERSION=$${RIOT_VERSION} \ @@ -90,6 +91,7 @@ buildtest: RIOTBASE=$${RIOTBASE} \ RIOTBOARD=$${RIOTBOARD} \ RIOTCPU=$${RIOTCPU} \ + RIOTPKG=$${RIOTPKG} \ BINDIRBASE=$${BINDIRBASE} \ RIOTNOLINK=$${RIOTNOLINK} \ RIOT_VERSION=$${RIOT_VERSION} \ @@ -127,6 +129,7 @@ info-buildsizes: RIOTBASE=$${RIOTBASE} \ RIOTBOARD=$${RIOTBOARD} \ RIOTCPU=$${RIOTCPU} \ + RIOTPKG=$${RIOTPKG} \ BINDIRBASE=$${BINDIRBASE} \ $(MAKE) info-buildsize 2>/dev/null | tail -n-1 | cut -f-4)" "$${BOARD}"; \ done; @@ -143,6 +146,7 @@ info-buildsizes-diff: RIOTBASE=$${RIOTBASE} \ RIOTBOARD=$${RIOTBOARD} \ RIOTCPU=$${RIOTCPU} \ + RIOTPKG=$${RIOTPKG} \ BINDIRBASE=$${BINDIRBASE} \ $(MAKE) info-buildsize 2>/dev/null | tail -n-1 | cut -f-4; \ done | \ @@ -176,6 +180,7 @@ info-build: @echo 'RIOTBASE: $(RIOTBASE)' @echo 'RIOTBOARD: $(RIOTBOARD)' @echo 'RIOTCPU: $(RIOTCPU)' + @echo 'RIOTPKG: $(RIOTPKG)' @echo '' @echo 'DEFAULT_MODULE: $(sort $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE)))' @echo 'DISABLE_MODULE: $(sort $(DISABLE_MODULE))' @@ -296,5 +301,5 @@ info-files: echo "$$CPPSRC" | xargs dirname -- | sort | uniq | xargs -I{} find {} -name "Makefile*"; \ echo "$$CPPSRC" | xargs $(CXX) $(CXXFLAGS) $(INCLUDES) -MM 2> /dev/null | grep -o "[^ ]\+\.h"; \ fi; \ - $(foreach pkg,$(USEPKG),find $(RIOTBASE)/pkg/$(pkg) -type f;) \ + $(foreach pkg,$(USEPKG),find $(RIOTPKG)/$(pkg) -type f;) \ ) | sort | uniq | sed 's#$(RIOTBASE)/##' diff --git a/Makefile.include b/Makefile.include index 182f632922..5c642bd378 100644 --- a/Makefile.include +++ b/Makefile.include @@ -15,6 +15,8 @@ RIOTCPU := $(abspath $(RIOTCPU)) RIOTBOARD ?= $(RIOTBASE)/boards RIOTBOARD := $(abspath $(RIOTBOARD)) +RIOTPKG ?= $(RIOTBASE)/pkg + RIOTPROJECT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd) RIOTPROJECT := $(abspath $(RIOTPROJECT)) @@ -247,33 +249,33 @@ INCLUDES += $(USEMODULE_INCLUDES_:%=-I%) # The `clean` needs to be serialized before everything else. ifneq (, $(filter clean, $(MAKECMDGOALS))) - all $(BASELIBS) $(USEPKG:%=$(RIOTBASE)/pkg/%/Makefile.include): clean + all $(BASELIBS) $(USEPKG:%=$(RIOTPKG)/%/Makefile.include): clean endif # include Makefile.includes for packages in $(USEPKG) -$(RIOTBASE)/pkg/%/Makefile.include:: - $(AD)"$(MAKE)" -C $(RIOTBASE)/pkg/$* Makefile.include +$(RIOTPKG)/%/Makefile.include:: + $(AD)"$(MAKE)" -C $(RIOTPKG)/$* Makefile.include -.PHONY: $(USEPKG:%=$(RIOTBASE)/pkg/%/Makefile.include) --include $(USEPKG:%=$(RIOTBASE)/pkg/%/Makefile.include) +.PHONY: $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) +-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) .PHONY: $(USEPKG:%=${BINDIR}%.a) $(USEPKG:%=${BINDIR}%.a): @mkdir -p ${BINDIR} - "$(MAKE)" -C $(RIOTBASE)/pkg/$(patsubst ${BINDIR}%.a,%,$@) + "$(MAKE)" -C $(RIOTPKG)/$(patsubst ${BINDIR}%.a,%,$@) clean: - -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i clean ; done + -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i clean ; done -@rm -rf $(BINDIR) -@rm -rf $(SCANBUILD_OUTPUTDIR) # Remove intermediates, but keep the .elf, .hex and .map etc. clean-intermediates: - -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i clean ; done + -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i clean ; done -@rm -rf $(BINDIR)/*.a $(BINDIR)/*/ distclean: - -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i distclean ; done + -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done -@rm -rf $(BINDIRBASE) flash: all diff --git a/Makefile.vars b/Makefile.vars index ba5e8d0e06..73f33d835b 100644 --- a/Makefile.vars +++ b/Makefile.vars @@ -16,6 +16,7 @@ export APPDEPS # Files / Makefile targets that need to be created export RIOTBASE # The root folder of RIOT. The folder where this very file lives in. export RIOTCPU # For third party CPUs this folder is the base of the CPUs. export RIOTBOARD # For third party BOARDs this folder is the base of the BOARDs. +export RIOTPKG # For overriding RIOT's pkg directory export RIOTPROJECT # Top level git root of the project being built, or PWD if not a git repository export BINDIRBASE # This is the folder where the application should be built in. For each BOARD a different subfolder is used. export BINDIR # This is the folder where the application should be built in.