cleanup makefiles and remove duplication
Makefile.inc duplicates many of the existing targets in Makefile. Instead of duplication, pass all none local targets to Makefile and implement only those needed locally. Change-Id: I1e923dd398a138543fa676ab67570b630c75d7ea Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
8205366f37
commit
fde80d7ead
4 changed files with 44 additions and 43 deletions
2
Kbuild
Normal file
2
Kbuild
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# The build system expects this file
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -435,7 +435,7 @@ outputmakefile:
|
||||||
ifneq ($(KBUILD_SRC),)
|
ifneq ($(KBUILD_SRC),)
|
||||||
$(Q)ln -fsn $(srctree) source
|
$(Q)ln -fsn $(srctree) source
|
||||||
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
|
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
|
||||||
$(srctree) $(objtree) $(VERSION_MAJOR) $(PATCHLEVEL)
|
$(srctree) $(objtree) $(VERSION_MAJOR) $(VERSION_MINOR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Support for using generic headers in asm-generic
|
# Support for using generic headers in asm-generic
|
||||||
|
@ -456,7 +456,7 @@ asm-generic:
|
||||||
|
|
||||||
version_h := include/generated/version.h
|
version_h := include/generated/version.h
|
||||||
|
|
||||||
no-dot-config-targets := clean mrproper distclean \
|
no-dot-config-targets := pristine distclean clean mrproper help \
|
||||||
cscope gtags TAGS tags help% %docs check% coccicheck \
|
cscope gtags TAGS tags help% %docs check% coccicheck \
|
||||||
$(version_h) headers_% archheaders archscripts \
|
$(version_h) headers_% archheaders archscripts \
|
||||||
kernelversion %src-pkg
|
kernelversion %src-pkg
|
||||||
|
|
67
Makefile.inc
67
Makefile.inc
|
@ -1,9 +1,10 @@
|
||||||
# vim: filetype=make
|
# vim: filetype=make
|
||||||
|
|
||||||
PROJECT_BASE ?= $(shell pwd)
|
PROJECT_BASE ?= $(shell pwd)
|
||||||
|
O ?= $(PROJECT_BASE)/outdir
|
||||||
|
|
||||||
ARCH ?= x86
|
ARCH ?= x86
|
||||||
|
|
||||||
O ?= $(PROJECT_BASE)/outdir
|
|
||||||
# Turn O into an absolute path; we call the main Kbuild with $(MAKE) -C
|
# Turn O into an absolute path; we call the main Kbuild with $(MAKE) -C
|
||||||
# which changes the working directory, relative paths don't work right.
|
# which changes the working directory, relative paths don't work right.
|
||||||
# Need to create the directory first to make readlink happy
|
# Need to create the directory first to make readlink happy
|
||||||
|
@ -12,6 +13,7 @@ override O := $(shell readlink -f $(O))
|
||||||
|
|
||||||
export ARCH MDEF_FILE QEMU_EXTRA_FLAGS PROJECT_BASE
|
export ARCH MDEF_FILE QEMU_EXTRA_FLAGS PROJECT_BASE
|
||||||
|
|
||||||
|
# FIXME: Simplify this, very ugly
|
||||||
ifdef PLATFORM_CONFIG
|
ifdef PLATFORM_CONFIG
|
||||||
ifndef KERNEL_TYPE
|
ifndef KERNEL_TYPE
|
||||||
$(error KERNEL_TYPE is not defined! Set it to either micro or nano)
|
$(error KERNEL_TYPE is not defined! Set it to either micro or nano)
|
||||||
|
@ -33,12 +35,11 @@ endif
|
||||||
|
|
||||||
SOURCE_DIR ?= $(PROJECT_BASE)/src/
|
SOURCE_DIR ?= $(PROJECT_BASE)/src/
|
||||||
# Kbuild doesn't work correctly if this is an absolute path
|
# 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 := $(shell python -c "import os.path; print(\"%s\" % os.path.relpath(os.path.realpath('$(SOURCE_DIR)'), os.path.realpath('$(ZEPHYR_BASE)')))")/
|
||||||
export SOURCE_DIR
|
export SOURCE_DIR
|
||||||
|
|
||||||
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
|
||||||
else if [ -x /bin/bash ]; then echo /bin/bash; \
|
|
||||||
else echo sh; fi ; fi)
|
|
||||||
|
|
||||||
ifeq ("$(origin V)", "command line")
|
ifeq ("$(origin V)", "command line")
|
||||||
KBUILD_VERBOSE = $(V)
|
KBUILD_VERBOSE = $(V)
|
||||||
|
@ -55,62 +56,60 @@ else
|
||||||
S = -s
|
S = -s
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
BEENTHERE = $(O)/.$(ARCH)-$(PLATFORM_CONFIG)-$(KERNEL_TYPE).env
|
||||||
|
|
||||||
|
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
||||||
|
else if [ -x /bin/bash ]; then echo /bin/bash; \
|
||||||
|
else echo sh; fi ; fi)
|
||||||
|
|
||||||
|
zephyrmake = @$(MAKE) -C $(ZEPHYR_BASE) O=$(1) CFLAGS="$(CFLAGS)" \
|
||||||
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) $(2)
|
||||||
|
|
||||||
all: $(CONFIG_DEPS) $(O)/.dir
|
all: $(CONFIG_DEPS) $(O)/.dir
|
||||||
$(Q)$(MAKE) -C $(ZEPHYR_BASE) O=$(O) \
|
$(Q)$(call zephyrmake,$(O),$@)
|
||||||
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) \
|
|
||||||
CFLAGS=$(CFLAGS)
|
|
||||||
|
|
||||||
clean: distclean
|
|
||||||
|
|
||||||
pristine: distclean
|
|
||||||
|
|
||||||
distclean:
|
|
||||||
@rm -rf $(O)
|
|
||||||
|
|
||||||
mrproper: clean FORCE
|
|
||||||
$(Q)$(MAKE) -C $(ZEPHYR_BASE) PROJECT=$(PROJECT_BASE) mrproper
|
|
||||||
|
|
||||||
%config: $(O)/.dir FORCE
|
|
||||||
$(Q)$(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) PROJECT=$(PROJECT_BASE) $@
|
|
||||||
|
|
||||||
qemu: $(CONFIG_DEPS) $(O)/.dir
|
qemu: $(CONFIG_DEPS) $(O)/.dir
|
||||||
$(Q)$(MAKE) -C $(ZEPHYR_BASE) O=$(O) \
|
$(Q)$(call zephyrmake,$(O),$@)
|
||||||
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) \
|
|
||||||
CFLAGS=$(CFLAGS) qemu
|
|
||||||
|
|
||||||
|
|
||||||
$(O)/.config: $(O)/.dir $(O)/.$(ARCH)-$(PLATFORM_CONFIG)-$(KERNEL_TYPE).env
|
# FIXME: Use defconfig to create directory and copy file
|
||||||
|
$(O)/.config: $(O)/.dir $(BEENTHERE)
|
||||||
$(Q)cp $(KBUILD_DEFCONFIG_PATH) $(O)/.config
|
$(Q)cp $(KBUILD_DEFCONFIG_PATH) $(O)/.config
|
||||||
|
|
||||||
$(O)/.initconfig: mergeconfig
|
$(O)/.initconfig: mergeconfig
|
||||||
$(Q)yes "" | $(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) \
|
$(Q)yes "" | $(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) \
|
||||||
PROJECT=$(PROJECT_BASE) oldconfig
|
PROJECT=$(PROJECT_BASE) oldconfig
|
||||||
touch $@
|
$(Q)touch $@
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME: Use provided mergeconfig target in kconfig/Makefile
|
||||||
|
#
|
||||||
ifneq ($(strip $(CONF_FILE)),)
|
ifneq ($(strip $(CONF_FILE)),)
|
||||||
mergeconfig: $(O)/.config $(CONF_FILE)
|
mergeconfig: $(O)/.config $(CONF_FILE)
|
||||||
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
||||||
-q -m -O $(O) $(O)/.config $(CONF_FILE)
|
-q -m -O $(O) $(O)/.config $(CONF_FILE)
|
||||||
else
|
else
|
||||||
mergeconfig: defconfig $(CONF_FILE);
|
mergeconfig: defconfig $(CONF_FILE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(CONF_FILE):;
|
|
||||||
|
pristine:
|
||||||
|
$(Q)rm -rf $(O)
|
||||||
|
|
||||||
%/.dir:
|
%/.dir:
|
||||||
$(Q)set -e;
|
$(Q)set -e;
|
||||||
$(Q)test -s $(abspath $(dir $@)) || mkdir $(abspath $(dir $@)) -p
|
$(Q)test -s $(abspath $(dir $@)) || mkdir $(abspath $(dir $@)) -p
|
||||||
$(Q)touch $@
|
$(Q)touch $@
|
||||||
|
|
||||||
help:
|
|
||||||
$(Q)$(MAKE) -C $(ZEPHYR_BASE) help
|
|
||||||
|
|
||||||
$(O)/.$(ARCH)-$(PLATFORM_CONFIG)-$(KERNEL_TYPE).env: FORCE
|
$(BEENTHERE): FORCE
|
||||||
@rm -rf $(O)/.*.env
|
$(Q)rm -rf $(O)/.*.env
|
||||||
$(Q)touch $(O)/.$(ARCH)-$(PLATFORM_CONFIG)-$(KERNEL_TYPE).env
|
$(Q)touch $@
|
||||||
|
|
||||||
PHONY += FORCE clean mrproper
|
|
||||||
FORCE:
|
# Catch all
|
||||||
|
%:
|
||||||
|
$(Q)$(call zephyrmake,$(O),$@)
|
||||||
|
|
||||||
.PHONY: $(PHONY)
|
.PHONY: $(PHONY)
|
||||||
.PRECIOUS: %/.dir
|
.PRECIOUS: %/.dir
|
||||||
|
|
|
@ -156,14 +156,14 @@ cleanup()
|
||||||
rm -f .tmp_System.map
|
rm -f .tmp_System.map
|
||||||
rm -f .tmp_kallsyms*
|
rm -f .tmp_kallsyms*
|
||||||
rm -f .tmp_version
|
rm -f .tmp_version
|
||||||
rm -f .tmp_${KERNEL_NAME}*
|
rm -f .tmp_*
|
||||||
rm -f System.map
|
rm -f System.map
|
||||||
rm -f ${KERNEL_NAME}.lnk
|
rm -f *.lnk
|
||||||
rm -f ${KERNEL_NAME}.map
|
rm -f *.map
|
||||||
rm -f ${KERNEL_NAME}.elf
|
rm -f *.elf
|
||||||
rm -f ${KERNEL_NAME}.lst
|
rm -f *.lst
|
||||||
rm -f ${KERNEL_NAME}.bin
|
rm -f *.bin
|
||||||
rm -f ${KERNEL_NAME}.strip
|
rm -f *.strip
|
||||||
rm -f staticIdt.o
|
rm -f staticIdt.o
|
||||||
rm -f linker.cmd
|
rm -f linker.cmd
|
||||||
rm -f final-linker.cmd
|
rm -f final-linker.cmd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue