diff --git a/Makefile b/Makefile index 27e3f3c6c62..44c0713dab3 100644 --- a/Makefile +++ b/Makefile @@ -218,7 +218,7 @@ objtree := . src := $(srctree) obj := $(objtree) -VPATH := $(srctree) +VPATH := $(SOURCE_DIR_PARENT) $(srctree) export srctree objtree VPATH @@ -731,13 +731,13 @@ export KBUILD_IMAGE ?= zephyr zephyr-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(drivers-y) \ $(libs-y))) -zephyr-app-dirs := $(patsubst %/,%,$(filter %/, $(app-y))) +zephyr-app-dirs := $(SOURCE_DIR) zephyr-alldirs := $(sort $(zephyr-dirs) $(zephyr-app-dirs) $(patsubst %/,%,$(filter %/, \ $(core-) $(drivers-) $(libs-) $(app-)))) core-y := $(patsubst %/, %/built-in.o, $(core-y)) -app-y := $(patsubst %/, %/built-in.o, $(app-y)) +app-y := $(patsubst %, %/built-in.o, $(notdir $(zephyr-app-dirs))) drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) @@ -879,8 +879,9 @@ $(zephyr-dirs): prepare scripts $(Q)$(MAKE) $(build)=$@ PHONY += $(zephyr-app-dirs) +$(zephyr-app-dirs): zephyr-app-dir-root = $(abspath $(patsubst %, %/.., $@)) $(zephyr-app-dirs): prepare scripts - $(Q)$(MAKE) $(build)=$@ + $(Q)$(MAKE) $(build)=$(@F) srctree=$(zephyr-app-dir-root) # Things we need to do before we recursively start building the kernel # or the modules are listed in "prepare". diff --git a/Makefile.inc b/Makefile.inc index 289f9b67756..4953f0dc8e3 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -39,11 +39,12 @@ $(error BOARD is not defined!) endif SOURCE_DIR ?= $(PROJECT_BASE)/src/ -# Kbuild doesn't work correctly if this is an absolute path -# FIXME Do not depend on python -override SOURCE_DIR := $(shell python -c "import os.path; print(\"%s\" % os.path.relpath(os.path.realpath('$(SOURCE_DIR)'), os.path.realpath('$(ZEPHYR_BASE)')))")/ +override SOURCE_DIR := $(abspath $(SOURCE_DIR)) override SOURCE_DIR := $(subst \,/,$(SOURCE_DIR)) -export SOURCE_DIR +override SOURCE_DIR_PARENT := $(patsubst %, %/.., $(SOURCE_DIR)) +override SOURCE_DIR_PARENT := $(abspath $(SOURCE_DIR_PARENT)) +override SOURCE_DIR_PARENT := $(subst \,/,$(SOURCE_DIR_PARENT)) +export SOURCE_DIR SOURCE_DIR_PARENT ifeq ("$(origin V)", "command line") KBUILD_VERBOSE = $(V)