0

I am creating a bash script that uses a local copy of gcc for arm. I need to have multiple versions of gcc around for compatibility. My bash script downloads the binary correctly, sets up the path locally but the make files ignore the local version.

After reading some docs make: Using Environment Variables I found that there is an export -e OPTION=VALUE from a bash script that will override the make default path.

This works well in my local copy of bash, but when running it through circle testing servers it fails, saying that -e is an invalid option.

Anyone know of a better way to override paths inside of make? Specifically for a third party project that I can't change the make files for.

GCC_ARM_VER=gcc-arm-none-eabi-4_8-2014q2 export -e GCC_ARM_PATH=$BINDIR/gcc-arm-embedded/$GCC_ARM_VER/bin export PATH=$GCC_ARM_PATH:$PATH make all -s -C "$BASE_FIRMWARE/"firmware APPDIR="$CWD/firmware" TARGET_DIR="$CWD/bin" PLATFORM="$1" || exit 

And then in the make file (arm-tools.mk):

 # Define the compiler/tools prefix GCC_PREFIX ?= arm-none-eabi- include $(COMMON_BUILD)/common-tools.mk AR = $(GCC_ARM_PATH)$(GCC_PREFIX)gcc-ar # # default flags for targeting ARM # # C compiler flags CFLAGS += -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb # C++ specific flags CPPFLAGS += -fno-exceptions -fno-rtti -fcheck-new CONLYFLAGS += ASFLAGS += -g3 -gdwarf-2 -mcpu=cortex-m3 -mthumb LDFLAGS += -nostartfiles -Xlinker --gc-sections ... 
2
  • I think you misread make manual. As said here ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/… -e is make option, not export option. Back to your question - is GCC_ARM_PATH set somewhere in your arm-tools.mk before it's used? Commented Jun 12, 2016 at 17:24
  • If you must fix something, arguments set on the command line to make cannot be overridden (in the top-level make) by either the environment or the makefile. The normal precedence hierarchy (highest to lowest) is command-line argument, makefile, environment; the make -e option changes that to command-line argument, environment, makefile. Commented Jun 12, 2016 at 17:31

1 Answer 1

2

To clarify what Jonathan said, you don't want to use export -e and you don't want to use make -e and you don't need to modify the makefiles. All you have to do if you want your variable assignment to take precedence is to add it to the make command line:

GCC_ARM_VER=gcc-arm-none-eabi-4_8-2014q2 export PATH=$GCC_ARM_PATH:$PATH make all -s -C "$BASE_FIRMWARE/"firmware \ APPDIR="$CWD/firmware" TARGET_DIR="$CWD/bin" PLATFORM="$1" \ GCC_ARM_PATH="$BINDIR/gcc-arm-embedded/$GCC_ARM_VER/bin" \ || exit 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.