diff options
| author | Ron Yorston <rmy@pobox.com> | 2024-01-20 09:35:50 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2024-01-20 09:35:50 +0000 |
| commit | 35f59d8ec0025647f75563c0bedecfc8e082a971 (patch) | |
| tree | c532a05eb29cbfe08cee09fc2292c6070b26fc07 /Makefile | |
| parent | 042520e46621e434c9bd2da6b100b32ccdee55a5 (diff) | |
| download | busybox-w32-35f59d8ec0025647f75563c0bedecfc8e082a971.tar.gz busybox-w32-35f59d8ec0025647f75563c0bedecfc8e082a971.tar.bz2 busybox-w32-35f59d8ec0025647f75563c0bedecfc8e082a971.zip | |
build system: make compiler names configurable
The top-level Makefile hardcoded the host and cross compiler name
to "gcc". Make it possible to set different values either on the
command line (make CROSS_COMPILER=clang) or in the configuration
file.
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 26 |
1 files changed, 24 insertions, 2 deletions
| @@ -196,6 +196,28 @@ ARCH ?= $(SUBARCH) | |||
| 196 | # Architecture as present in compile.h | 196 | # Architecture as present in compile.h |
| 197 | UTS_MACHINE := $(ARCH) | 197 | UTS_MACHINE := $(ARCH) |
| 198 | 198 | ||
| 199 | HOST_COMPILER ?= | ||
| 200 | ifeq ($(HOST_COMPILER),) | ||
| 201 | HOST_COMPILER := $(shell grep ^CONFIG_HOST_COMPILER= .config 2>/dev/null) | ||
| 202 | HOST_COMPILER := $(subst CONFIG_HOST_COMPILER=,,$(HOST_COMPILER)) | ||
| 203 | HOST_COMPILER := $(subst ",,$(HOST_COMPILER)) | ||
| 204 | #") | ||
| 205 | endif | ||
| 206 | ifeq ($(HOST_COMPILER),) | ||
| 207 | HOST_COMPILER := gcc | ||
| 208 | endif | ||
| 209 | |||
| 210 | CROSS_COMPILER ?= | ||
| 211 | ifeq ($(CROSS_COMPILER),) | ||
| 212 | CROSS_COMPILER := $(shell grep ^CONFIG_CROSS_COMPILER= .config 2>/dev/null) | ||
| 213 | CROSS_COMPILER := $(subst CONFIG_CROSS_COMPILER=,,$(CROSS_COMPILER)) | ||
| 214 | CROSS_COMPILER := $(subst ",,$(CROSS_COMPILER)) | ||
| 215 | #") | ||
| 216 | endif | ||
| 217 | ifeq ($(CROSS_COMPILER),) | ||
| 218 | CROSS_COMPILER := gcc | ||
| 219 | endif | ||
| 220 | |||
| 199 | # SHELL used by kbuild | 221 | # SHELL used by kbuild |
| 200 | CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ | 222 | CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ |
| 201 | else if [ -x /bin/bash ]; then echo /bin/bash; \ | 223 | else if [ -x /bin/bash ]; then echo /bin/bash; \ |
| @@ -275,7 +297,7 @@ export quiet Q KBUILD_VERBOSE | |||
| 275 | # Look for make include files relative to root of kernel src | 297 | # Look for make include files relative to root of kernel src |
| 276 | MAKEFLAGS += --include-dir=$(srctree) | 298 | MAKEFLAGS += --include-dir=$(srctree) |
| 277 | 299 | ||
| 278 | HOSTCC = gcc | 300 | HOSTCC = $(HOST_COMPILER) |
| 279 | HOSTCXX = g++ | 301 | HOSTCXX = g++ |
| 280 | HOSTCFLAGS := | 302 | HOSTCFLAGS := |
| 281 | HOSTCXXFLAGS := | 303 | HOSTCXXFLAGS := |
| @@ -293,7 +315,7 @@ MAKEFLAGS += -rR | |||
| 293 | # Make variables (CC, etc...) | 315 | # Make variables (CC, etc...) |
| 294 | 316 | ||
| 295 | AS = $(CROSS_COMPILE)as | 317 | AS = $(CROSS_COMPILE)as |
| 296 | CC = $(CROSS_COMPILE)gcc | 318 | CC = $(CROSS_COMPILE)$(CROSS_COMPILER) |
| 297 | LD = $(CC) -nostdlib | 319 | LD = $(CC) -nostdlib |
| 298 | CPP = $(CC) -E | 320 | CPP = $(CC) -E |
| 299 | AR = $(CROSS_COMPILE)ar | 321 | AR = $(CROSS_COMPILE)ar |
