From 024024f46876c381df32c732420d1a58f601a55f Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 19 Mar 2020 21:40:32 +0800 Subject: [PATCH] tools: Sync Makefile.win with Makefile.unix and fix the typo error and remove if/else nesting Signed-off-by: Xiang Xiao Change-Id: Ife0c80d396417e8eb37e43d0883f272d4b9247a0 --- tools/Makefile.unix | 62 +++++++++++--------------------- tools/Makefile.win | 86 +++++++++++++++------------------------------ 2 files changed, 50 insertions(+), 98 deletions(-) diff --git a/tools/Makefile.unix b/tools/Makefile.unix index ffc89aa6d6..1bfa18b7a1 100644 --- a/tools/Makefile.unix +++ b/tools/Makefile.unix @@ -54,6 +54,11 @@ CONFIG_VERSION_STRING ?= "0.0" CONFIG_VERSION_BUILD ?= "0" VERSION_ARG = -v $(CONFIG_VERSION_STRING) -b $(CONFIG_VERSION_BUILD) +else + +# Generate .version every time from GIT history + +.PHONY: $(TOPDIR)/.version endif # Control build verbosity @@ -63,13 +68,11 @@ endif ifeq ($(V),1) export Q := -else -ifeq ($(V),2) +else ifeq ($(V),2) export Q := else export Q := @ endif -endif # Default tools @@ -151,13 +154,11 @@ endif ifeq ($(CONFIG_BUILD_PROTECTED),y) include tools/ProtectedLibs.mk -else -ifeq ($(CONFIG_BUILD_KERNEL),y) +else ifeq ($(CONFIG_BUILD_KERNEL),y) include tools/KernelLibs.mk else include tools/FlatLibs.mk endif -endif # LINKLIBS derives from NUTTXLIBS and is simply the same list with the # subdirectory removed @@ -195,9 +196,6 @@ all: $(BIN) .PHONY: dirlinks context clean_context check_context config oldconfig menuconfig nconfig qconfig gconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean .PHONY: pass1 pass1deps pass1dep .PHONY: pass2 pass2deps pass2dep -ifeq ($(GIT_DIR),y) -.PHONY: $(TOPDIR)/.version -endif # Target used to copy include/nuttx/lib/math.h. If CONFIG_ARCH_MATH_H is # defined, then there is an architecture specific math.h header file @@ -217,11 +215,9 @@ endif ifeq ($(CONFIG_ARCH_MATH_H),y) NEED_MATH_H = y -else -ifeq ($(CONFIG_LIBM),y) +else ifeq ($(CONFIG_LIBM),y) NEED_MATH_H = y endif -endif ifeq ($(NEED_MATH_H),y) include/math.h: include/nuttx/lib/math.h @@ -272,7 +268,7 @@ endif # tools/mkversion tool is built and used to create include/nuttx/version.h tools/mkversion$(HOSTEXEEXT): - $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT) + $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT) # [Re-]create .version if it doesn't already exist. @@ -291,14 +287,11 @@ include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion$(HOSTEXEEXT) # tools/mkconfig tool is built and used to create include/nuttx/config.h tools/mkconfig$(HOSTEXEEXT): - $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig$(HOSTEXEEXT) - -staging: - $(Q) mkdir -p staging + $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig$(HOSTEXEEXT) include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig$(HOSTEXEEXT) - $(Q) tools/mkconfig $(TOPDIR) > include/nuttx/config.h.tmp - $(Q) $(call TESTANDREPLACEFILE, include/nuttx/config.h.tmp, $@) + $(Q) tools/mkconfig $(TOPDIR) > $@.tmp + $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) # Targets used to create dependencies @@ -314,18 +307,6 @@ tools/cnvwindeps$(HOSTEXEEXT): # setting up symbolic links with 'generic' directory names to specific, # configured directories. -# Make.defs: -# $(Q) echo "No Make.defs file found, creating one" -# $(Q) echo "include $(TOPDIR)$(DELIM).config" > Make.defs -# $(Q) echo "include $(TOPDIR)$(DELIM)tools$(DELIM)Config.mk" >> Make.defs - -# tools/initialconfig$(HOSTEXEEXT): -# $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" initialconfig$(HOSTEXEEXT) -# -# .config: tools/initialconfig$(HOSTEXEEXT) -# $(Q) echo "No .config file found, creating one" -# $(Q) tools/initialconfig$(HOSTEXEEXT) - # Link the arch//include directory to include/arch include/arch: .config @@ -357,7 +338,7 @@ endif # Link the boards///drivers dir to drivers/platform -$(ARCH_SRC)/drivers: .config +drivers/platform: .config @echo "LN: $(TOPDIR)/drivers/platform to $(BOARD_DIR)/drivers" $(Q) $(DIRLINK) $(BOARD_DIR)/drivers $(TOPDIR)/drivers/platform @@ -377,7 +358,7 @@ ifneq ($(CONFIG_ARCH_CHIP),) $(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip endif -dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip $(ARCH_SRC)/drivers +dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip drivers/platform $(Q) $(MAKE) -C boards dirlinks TOPDIR="$(TOPDIR)" $(Q) $(MAKE) -C openamp dirlinks TOPDIR="$(TOPDIR)" $(Q) $(MAKE) -C $(CONFIG_APPS_DIR) dirlinks TOPDIR="$(TOPDIR)" @@ -389,7 +370,8 @@ dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $( # the config.h and version.h header files in the include/nuttx directory and # the establishment of symbolic links to configured directories. -context: check_context staging include/nuttx/config.h include/nuttx/version.h include/math.h include/float.h include/stdarg.h include/setjmp.h dirlinks +context: check_context include/nuttx/config.h include/nuttx/version.h include/math.h include/float.h include/stdarg.h include/setjmp.h dirlinks + $(Q) mkdir -p staging $(Q) for dir in $(CONTEXTDIRS) ; do \ $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" context; \ done @@ -565,17 +547,15 @@ do_gconfig: dirlinks apps_preconfig gconfig: do_gconfig clean_context -do_savedefconfig: dirlinks apps_preconfig - -savedefconfig: do_savedefconfig +savedefconfig: dirlinks apps_preconfig $(Q) APPSDIR=${CONFIG_APPS_DIR} kconfig-conf --savedefconfig defconfig.tmp Kconfig $(Q) sed -i -e "/CONFIG_APPS_DIR=/d" defconfig.tmp $(Q) grep "CONFIG_ARCH=" .config >> defconfig.tmp $(Q) grep "^CONFIG_ARCH_CHIP_" .config >> defconfig.tmp; true - $(Q) grep "^CONFIG_ARCH_CHIP=" .config >> defconfig.tmp; true - $(Q) grep "CONFIG_ARCH_BOARD=" .config && grep "CONFIG_ARCH_BOARD=" .config >> defconfig.tmp; true - $(Q) grep "^CONFIG_ARCH_CUSTOM" .config && grep "^CONFIG_ARCH_CUSTOM" .config >> defconfig.tmp; true - $(Q) grep "^CONFIG_ARCH_BOARD_CUSTOM=" .config && grep "^CONFIG_ARCH_BOARD_CUSTOM" .config >> defconfig.tmp; true + $(Q) grep "CONFIG_ARCH_CHIP=" .config >> defconfig.tmp; true + $(Q) grep "CONFIG_ARCH_BOARD=" .config >> defconfig.tmp; true + $(Q) grep "^CONFIG_ARCH_CUSTOM" .config >> defconfig.tmp; true + $(Q) grep "^CONFIG_ARCH_BOARD_CUSTOM" .config >> defconfig.tmp; true $(Q) export LC_ALL=C; cat defconfig.tmp | sort | uniq > sortedconfig.tmp $(Q) echo "#" > warning.tmp $(Q) echo "# This file is autogenerated: PLEASE DO NOT EDIT IT." >> warning.tmp diff --git a/tools/Makefile.win b/tools/Makefile.win index 4453cfa5bf..440ad5a4c2 100644 --- a/tools/Makefile.win +++ b/tools/Makefile.win @@ -37,13 +37,14 @@ export SHELL=cmd TOPDIR := ${shell echo %CD%} -include $(TOPDIR)\.config --include $(TOPDIR)/.version include $(TOPDIR)\tools\Config.mk -include $(TOPDIR)\Make.defs +-include $(TOPDIR)\.version + # In case .version file does not exist -CONFIG_VERSION_STRING ?= "Unversioned" +CONFIG_VERSION_STRING ?= "0.0" CONFIG_VERSION_MAJOR ?= 0 CONFIG_VERSION_MINOR ?= 0 CONFIG_VERSION_BUILD ?= "0" @@ -55,13 +56,11 @@ CONFIG_VERSION_BUILD ?= "0" ifeq ($(V),1) export Q := -else -ifeq ($(V),2) +else ifeq ($(V),2) export Q := else export Q := @ endif -endif # This define is passed as EXTRADEFINES for kernel-mode builds. It is also passed # during PASS1 (but not PASS2) context and depend targets. @@ -136,13 +135,11 @@ endif ifeq ($(CONFIG_BUILD_PROTECTED),y) include tools\ProtectedLibs.mk -else -ifeq ($(CONFIG_BUILD_KERNEL),y) +else ifeq ($(CONFIG_BUILD_KERNEL),y) include tools\KernelLibs.mk else include tools\FlatLibs.mk endif -endif # LINKLIBS derives from NUTTXLIBS and is simply the same list with the # subdirectory removed @@ -199,11 +196,9 @@ all: $(BIN) ifeq ($(CONFIG_ARCH_MATH_H),y) NEED_MATH_H = y -else -ifeq ($(CONFIG_LIBM),y) +else ifeq ($(CONFIG_LIBM),y) NEED_MATH_H = y endif -endif ifeq ($(NEED_MATH_H),y) include\math.h: include\nuttx\math.h @@ -254,7 +249,7 @@ endif # tools\mkversion tool is built and used to create include\nuttx\version.h tools\mkversion$(HOSTEXEEXT): - $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT) + $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT) $(TOPDIR)\.version: $(Q) echo CONFIG_VERSION_STRING="0" > .version @@ -262,12 +257,6 @@ $(TOPDIR)\.version: $(Q) echo CONFIG_VERSION_MINOR=0 >> .version $(Q) echo CONFIG_VERSION_BUILD="0" >> .version -# $(Q) if [ ! -f .version ]; then \ -# echo "No .version file found, creating one"; \ -# tools\version.sh -v 0.0 -b 0 .version; \ -# chmod 755 .version; \ -# fi - include\nuttx\version.h: $(TOPDIR)\.version tools\mkversion$(HOSTEXEEXT) $(Q) tools\mkversion$(HOSTEXEEXT) $(TOPDIR) > include\nuttx\version.h @@ -276,10 +265,7 @@ include\nuttx\version.h: $(TOPDIR)\.version tools\mkversion$(HOSTEXEEXT) # tools\mkconfig tool is built and used to create include\nuttx\config.h tools\mkconfig$(HOSTEXEEXT): - $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig$(HOSTEXEEXT) - -staging: - $(Q) mkdir -p staging + $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig$(HOSTEXEEXT) include\nuttx\config.h: $(TOPDIR)\.config tools\mkconfig$(HOSTEXEEXT) $(Q) tools\mkconfig$(HOSTEXEEXT) $(TOPDIR) > include\nuttx\config.h @@ -287,7 +273,7 @@ include\nuttx\config.h: $(TOPDIR)\.config tools\mkconfig$(HOSTEXEEXT) # Targets used to create dependencies tools\mkdeps$(HOSTEXEEXT): - $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkdeps$(HOSTEXEEXT) + $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkdeps$(HOSTEXEEXT) # dirlinks, and helpers # @@ -295,18 +281,6 @@ tools\mkdeps$(HOSTEXEEXT): # setting up symbolic links with 'generic' directory names to specific, # configured directories. -# Make.defs: -# $(Q) echo "No Make.defs file found, creating one" -# $(Q) echo "include $(TOPDIR)$(DELIM).config" > Make.defs -# $(Q) echo "include $(TOPDIR)$(DELIM)tools$(DELIM)Config.mk" >> Make.defs - -# tools\initialconfig$(HOSTEXEEXT): -# $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" initialconfig$(HOSTEXEEXT) -# -# .config: tools\initialconfig$(HOSTEXEEXT) -# $(Q) echo "No .config file found, creating one" -# $(Q) tools\initialconfig$(HOSTEXEEXT) - # Link the arch\\include directory to include\arch include\arch: .config @@ -329,17 +303,6 @@ else $(Q) echo FAKELNK > include\arch\board\.fakelnk endif -# Link the boards\\\drivers dir to drivers\platform - -$(ARCH_SRC)\drivers: .config - @echo LN: $(TOPDIR)\drivers\platform to $(BOARD_DIR)\drivers -ifeq ($(CONFIG_WINDOWS_MKLINK),y) - $(Q) /user:administrator mklink /d $(TOPDIR)\drivers\platform $(BOARD_DIR)\drivers -else - $(Q) xcopy $(BOARD_DIR)\drivers $(TOPDIR)\drivers\platform /c /q /s /e /y /i - $(Q) echo FAKELNK > $(TOPDIR)\drivers\platform\.fakelnk -endif - ifeq ($(COMMON_DIR),y) # Link the boards\\\common dir to arch\\src\board # Link the boards\\\\src dir to arch\\src\board\board @@ -353,7 +316,6 @@ else $(Q) echo FAKELNK > $(ARCH_SRC)\board\.fakelnk endif @echo "LN: $(ARCH_SRC)\board\board to $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\src" - $(Q) $(DIRLINK) $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\src $(ARCH_SRC)\board\board ifeq ($(CONFIG_WINDOWS_MKLINK),y) $(Q) /user:administrator mklink /d $(ARCH_SRC)\board\board $(BOARD_DIR)\$(CONFIG_ARCH_BOARD)\src else @@ -373,7 +335,18 @@ else endif endif -# Link arch\\include\ to arch\\include\chip +# Link the boards\\\drivers dir to drivers\platform + +drivers\platform: .config + @echo LN: $(TOPDIR)\drivers\platform to $(BOARD_DIR)\drivers +ifeq ($(CONFIG_WINDOWS_MKLINK),y) + $(Q) /user:administrator mklink /d $(TOPDIR)\drivers\platform $(BOARD_DIR)\drivers +else + $(Q) xcopy $(BOARD_DIR)\drivers $(TOPDIR)\drivers\platform /c /q /s /e /y /i + $(Q) echo FAKELNK > $(TOPDIR)\drivers\platform .fakelnk +endif + +# Link arch\\src\ to arch\\src\chip $(ARCH_SRC)\chip: .config ifneq ($(CONFIG_ARCH_CHIP),) @@ -386,7 +359,7 @@ else endif endif -# Link arch\\src\ to arch\\src\chip +# Link arch\\include\ to arch\\include\chip include\arch\chip: include\arch ifneq ($(CONFIG_ARCH_CHIP),) @@ -399,7 +372,7 @@ else endif endif -dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(ARCH_SRC)\chip $(ARCH_SRC)\drivers +dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(ARCH_SRC)\chip drivers\platform $(Q) $(MAKE) -C boards dirlinks TOPDIR="$(TOPDIR)" $(Q) $(MAKE) -C openamp dirlinks TOPDIR="$(TOPDIR)" $(Q) $(MAKE) -C $(CONFIG_APPS_DIR) dirlinks TOPDIR="$(TOPDIR)" @@ -411,7 +384,8 @@ dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $( # the config.h and version.h header files in the include\nuttx directory and # the establishment of symbolic links to configured directories. -context: check_context staging include\nuttx\config.h include\nuttx\version.h include\math.h include\float.h include\stdarg.h include\setjmp.h dirlinks +context: check_context include\nuttx\config.h include\nuttx\version.h include\math.h include\float.h include\stdarg.h include\setjmp.h dirlinks + $(Q) mkdir -p staging $(Q) for %%G in ($(CONTEXTDIRS)) do ( $(MAKE) -C %%G TOPDIR="$(TOPDIR)" context ) # clean_context @@ -553,18 +527,16 @@ do_nconfig: dirlinks apps_preconfig nconfig: do_nconfig clean_context -do_savedefconfig: dirlinks apps_preconfig - -savedefconfig: do_savedefconfig +savedefconfig: dirlinks apps_preconfig $(Q) set APPSDIR=$(patsubst "%",%,${CONFIG_APPS_DIR})& kconfig-conf --savedefconfig defconfig.tmp Kconfig $(Q) sed -i -e "/CONFIG_APPS_DIR=/d" defconfig.tmp $(Q) grep "CONFIG_ARCH=" .config >> defconfig.tmp -$(Q) grep "^CONFIG_ARCH_CHIP_" .config >> defconfig.tmp - -$(Q) grep "^CONFIG_ARCH_CHIP=" .config >> defconfig.tmp + -$(Q) grep "CONFIG_ARCH_CHIP=" .config >> defconfig.tmp -$(Q) grep "CONFIG_ARCH_BOARD=" .config >> defconfig.tmp -$(Q) grep "^CONFIG_ARCH_CUSTOM" .config >> defconfig.tmp - -$(Q) grep "^CONFIG_ARCH_BOARD_CUSTOM=" .config >> defconfig.tmp - $(Q) cat defconfig.tmp | sort | uniq > sortedconfig.tmp + -$(Q) grep "^CONFIG_ARCH_BOARD_CUSTOM" .config >> defconfig.tmp + $(Q) export LC_ALL=C; cat defconfig.tmp | sort | uniq > sortedconfig.tmp $(Q) echo "#" > warning.tmp $(Q) echo "# This file is autogenerated: PLEASE DO NOT EDIT IT." >> warning.tmp $(Q) echo "#" >> warning.tmp