-def update_cross_compile(color_enabled):
- """Update per-arch CROSS_COMPILE via environment variables
-
- The default CROSS_COMPILE values are available
- in the CROSS_COMPILE list above.
-
- You can override them via environment variables
- CROSS_COMPILE_{ARCH}.
-
- For example, if you want to override toolchain prefixes
- for ARM and PowerPC, you can do as follows in your shell:
-
- export CROSS_COMPILE_ARM=...
- export CROSS_COMPILE_POWERPC=...
-
- Then, this function checks if specified compilers really exist in your
- PATH environment.
- """
- archs = []
-
- for arch in os.listdir('arch'):
- if os.path.exists(os.path.join('arch', arch, 'Makefile')):
- archs.append(arch)
-
- # arm64 is a special case
- archs.append('aarch64')
-
- for arch in archs:
- env = 'CROSS_COMPILE_' + arch.upper()
- cross_compile = os.environ.get(env)
- if not cross_compile:
- cross_compile = CROSS_COMPILE.get(arch, '')
-
- for path in os.environ["PATH"].split(os.pathsep):
- gcc_path = os.path.join(path, cross_compile + 'gcc')
- if os.path.isfile(gcc_path) and os.access(gcc_path, os.X_OK):
- break
- else:
- print >> sys.stderr, color_text(color_enabled, COLOR_YELLOW,
- 'warning: %sgcc: not found in PATH. %s architecture boards will be skipped'
- % (cross_compile, arch))
- cross_compile = None
-
- CROSS_COMPILE[arch] = cross_compile
-