From 7b39d3d2963bd9fcca72ca05c43899d3c8d4e1d7 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Wed, 14 Jun 2023 22:48:55 +0300 Subject: [PATCH] Rename make folder to get rid of build error. (#12880) When trying to build firmware with current directory in PATH environment it scans for make command and generates "Permission denied" error in case if current directory in PATH precedes /usr/bin/ directory.In my case it was caused by incorrect pyenv init script. Rename make folder to avoid errors like this. --- .github/workflows/ci.yml | 4 ++-- .gitignore | 2 +- Makefile | 29 +++++++++++++++-------------- {make => mk}/build_verbosity.mk | 0 {make => mk}/checks.mk | 0 {make => mk}/config.mk | 0 {make => mk}/linux.mk | 0 {make => mk}/macosx.mk | 0 {make => mk}/mcu/AT32F4.mk | 0 {make => mk}/mcu/SITL.mk | 0 {make => mk}/mcu/STM32F4.mk | 0 {make => mk}/mcu/STM32F7.mk | 0 {make => mk}/mcu/STM32G4.mk | 0 {make => mk}/mcu/STM32H7.mk | 0 {make => mk}/openocd.mk | 0 {make => mk}/source.mk | 0 {make => mk}/system-id.mk | 0 {make => mk}/tools.mk | 2 +- {make => mk}/windows.mk | 0 src/test/Makefile | 7 ++++--- 20 files changed, 23 insertions(+), 21 deletions(-) rename {make => mk}/build_verbosity.mk (100%) rename {make => mk}/checks.mk (100%) rename {make => mk}/config.mk (100%) rename {make => mk}/linux.mk (100%) rename {make => mk}/macosx.mk (100%) rename {make => mk}/mcu/AT32F4.mk (100%) rename {make => mk}/mcu/SITL.mk (100%) rename {make => mk}/mcu/STM32F4.mk (100%) rename {make => mk}/mcu/STM32F7.mk (100%) rename {make => mk}/mcu/STM32G4.mk (100%) rename {make => mk}/mcu/STM32H7.mk (100%) rename {make => mk}/openocd.mk (100%) rename {make => mk}/source.mk (100%) rename {make => mk}/system-id.mk (100%) rename {make => mk}/tools.mk (98%) rename {make => mk}/windows.mk (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a096d7ce2..4b9ecdcaf8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: id: cache-toolchain with: path: tools - key: ${{ runner.os }}-${{ hashFiles('make/tools.mk') }} + key: ${{ runner.os }}-${{ hashFiles('mk/tools.mk') }} - name: Download and install toolchain if: steps.cache-toolchain.outputs.cache-hit != 'true' @@ -56,7 +56,7 @@ jobs: id: cache-toolchain with: path: tools - key: ${{ runner.os }}-${{ hashFiles('make/tools.mk') }} + key: ${{ runner.os }}-${{ hashFiles('mk/tools.mk') }} - name: Hydrate configuration id: get-config diff --git a/.gitignore b/.gitignore index 6942710520..af249aa66c 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ README.pdf /tools/ /build/ # local changes only -make/local.mk +mk/local.mk # artefacts for VisualGDB (running in Visual Studio) mcu.mak diff --git a/Makefile b/Makefile index 186633ed5e..47d3a556f4 100644 --- a/Makefile +++ b/Makefile @@ -64,23 +64,24 @@ INCLUDE_DIRS := $(SRC_DIR) \ $(ROOT)/src/main/target \ $(ROOT)/src/main/startup LINKER_DIR := $(ROOT)/src/link +MAKE_SCRIPT_DIR := $(ROOT)/mk ## V : Set verbosity level based on the V= parameter ## V=0 Low ## V=1 High -include $(ROOT)/make/build_verbosity.mk +include $(MAKE_SCRIPT_DIR)/build_verbosity.mk # Build tools, so we all share the same versions # import macros common to all supported build systems -include $(ROOT)/make/system-id.mk +include $(MAKE_SCRIPT_DIR)/system-id.mk # developer preferences, edit these at will, they'll be gitignored -ifneq ($(wildcard $(ROOT)/make/local.mk),) -include $(ROOT)/make/local.mk +ifneq ($(wildcard $(MAKE_SCRIPT_DIR)/local.mk),) +include $(MAKE_SCRIPT_DIR)/local.mk endif # pre-build sanity checks -include $(ROOT)/make/checks.mk +include $(MAKE_SCRIPT_DIR)/checks.mk # basic target list BASE_TARGETS := $(sort $(notdir $(patsubst %/,%,$(dir $(wildcard $(ROOT)/src/main/target/*/target.mk))))) @@ -97,10 +98,10 @@ DIRECTORIES := $(DL_DIR) $(TOOLS_DIR) export RM := rm # import macros that are OS specific -include $(ROOT)/make/$(OSFAMILY).mk +include $(MAKE_SCRIPT_DIR)/$(OSFAMILY).mk # include the tools makefile -include $(ROOT)/make/tools.mk +include $(MAKE_SCRIPT_DIR)/tools.mk # Search path for sources VPATH := $(SRC_DIR):$(SRC_DIR)/startup @@ -115,7 +116,7 @@ FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH) # import config handling -include $(ROOT)/make/config.mk +include $(MAKE_SCRIPT_DIR)/config.mk ifeq ($(CONFIG),) ifeq ($(TARGET),) @@ -157,8 +158,8 @@ OPTIMISE_SIZE := -Os LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED) endif -VPATH := $(VPATH):$(ROOT)/make/mcu -VPATH := $(VPATH):$(ROOT)/make +VPATH := $(VPATH):$(MAKE_SCRIPT_DIR)/mcu +VPATH := $(VPATH):$(MAKE_SCRIPT_DIR) # start specific includes ifeq ($(TARGET_MCU),) @@ -175,10 +176,10 @@ ifneq ($(CONFIG),) TARGET_FLAGS := $(TARGET_FLAGS) -DUSE_CONFIG endif -include $(ROOT)/make/mcu/$(TARGET_MCU_FAMILY).mk +include $(MAKE_SCRIPT_DIR)/mcu/$(TARGET_MCU_FAMILY).mk # openocd specific includes -include $(ROOT)/make/openocd.mk +include $(MAKE_SCRIPT_DIR)/openocd.mk # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already. ifeq ($(TARGET_FLASH_SIZE),) @@ -208,7 +209,7 @@ INCLUDE_DIRS := $(INCLUDE_DIRS) \ VPATH := $(VPATH):$(TARGET_DIR) -include $(ROOT)/make/source.mk +include $(MAKE_SCRIPT_DIR)/source.mk ############################################################################### # Things that might need changing to use different tools @@ -578,7 +579,7 @@ version: @echo $(FC_VER) ## help : print this help message and exit -help: Makefile make/tools.mk +help: Makefile mk/tools.mk @echo "" @echo "Makefile for the $(FORKNAME) firmware" @echo "" diff --git a/make/build_verbosity.mk b/mk/build_verbosity.mk similarity index 100% rename from make/build_verbosity.mk rename to mk/build_verbosity.mk diff --git a/make/checks.mk b/mk/checks.mk similarity index 100% rename from make/checks.mk rename to mk/checks.mk diff --git a/make/config.mk b/mk/config.mk similarity index 100% rename from make/config.mk rename to mk/config.mk diff --git a/make/linux.mk b/mk/linux.mk similarity index 100% rename from make/linux.mk rename to mk/linux.mk diff --git a/make/macosx.mk b/mk/macosx.mk similarity index 100% rename from make/macosx.mk rename to mk/macosx.mk diff --git a/make/mcu/AT32F4.mk b/mk/mcu/AT32F4.mk similarity index 100% rename from make/mcu/AT32F4.mk rename to mk/mcu/AT32F4.mk diff --git a/make/mcu/SITL.mk b/mk/mcu/SITL.mk similarity index 100% rename from make/mcu/SITL.mk rename to mk/mcu/SITL.mk diff --git a/make/mcu/STM32F4.mk b/mk/mcu/STM32F4.mk similarity index 100% rename from make/mcu/STM32F4.mk rename to mk/mcu/STM32F4.mk diff --git a/make/mcu/STM32F7.mk b/mk/mcu/STM32F7.mk similarity index 100% rename from make/mcu/STM32F7.mk rename to mk/mcu/STM32F7.mk diff --git a/make/mcu/STM32G4.mk b/mk/mcu/STM32G4.mk similarity index 100% rename from make/mcu/STM32G4.mk rename to mk/mcu/STM32G4.mk diff --git a/make/mcu/STM32H7.mk b/mk/mcu/STM32H7.mk similarity index 100% rename from make/mcu/STM32H7.mk rename to mk/mcu/STM32H7.mk diff --git a/make/openocd.mk b/mk/openocd.mk similarity index 100% rename from make/openocd.mk rename to mk/openocd.mk diff --git a/make/source.mk b/mk/source.mk similarity index 100% rename from make/source.mk rename to mk/source.mk diff --git a/make/system-id.mk b/mk/system-id.mk similarity index 100% rename from make/system-id.mk rename to mk/system-id.mk diff --git a/make/tools.mk b/mk/tools.mk similarity index 98% rename from make/tools.mk rename to mk/tools.mk index 64c5d65fa3..be66069345 100644 --- a/make/tools.mk +++ b/mk/tools.mk @@ -265,7 +265,7 @@ else ifeq (,$(filter %_install test% clean% %-print checks help configs, $(MAKEC ifeq ($(GCC_VERSION),) $(error **ERROR** arm-none-eabi-gcc not in the PATH. Run 'make arm_sdk_install' to install automatically in the tools folder of this repo) else ifneq ($(GCC_VERSION), $(GCC_REQUIRED_VERSION)) - $(error **ERROR** your arm-none-eabi-gcc is '$(GCC_VERSION)', but '$(GCC_REQUIRED_VERSION)' is expected. Override with 'GCC_REQUIRED_VERSION' in make/local.mk or run 'make arm_sdk_install' to install the right version automatically in the tools folder of this repo) + $(error **ERROR** your arm-none-eabi-gcc is '$(GCC_VERSION)', but '$(GCC_REQUIRED_VERSION)' is expected. Override with 'GCC_REQUIRED_VERSION' in mk/local.mk or run 'make arm_sdk_install' to install the right version automatically in the tools folder of this repo) endif # ARM tookchain is in the path, and the version is what's required. diff --git a/make/windows.mk b/mk/windows.mk similarity index 100% rename from make/windows.mk rename to mk/windows.mk diff --git a/src/test/Makefile b/src/test/Makefile index 6930e9b1d8..2adf2676dc 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -14,10 +14,11 @@ USER_DIR = ../main TEST_DIR = unit ROOT = ../.. -OBJECT_DIR = ../../obj/test +OBJECT_DIR = $(ROOT)/obj/test TARGET_DIR = $(USER_DIR)/target +MAKE_SCRIPT_DIR := $(ROOT)/mk -include $(ROOT)/make/system-id.mk +include $(MAKE_SCRIPT_DIR)/system-id.mk VPATH := $(VPATH):$(USER_DIR):$(TEST_DIR) @@ -592,7 +593,7 @@ GTEST_HEADERS = $(GTEST_DIR)/inc/gtest/*.h ## V : Set verbosity level based on the V= parameter ## V=0 Low ## V=1 High -include ../../make/build_verbosity.mk +include $(MAKE_SCRIPT_DIR)/build_verbosity.mk # House-keeping build targets.