1 # Set any settings that remain unset from the configuration
3 # Borrowed from the kernel
5 try-run= $(shell set -e; \
7 if ($(1)) > /dev/null 2>&1; \
12 cc-option= $(call try-run,\
13 $(CC) $(1) -S -xc /dev/null -o "$$TMP", $(1), $(2))
15 find-tool=$(shell set -e; if which $(1) > /dev/null 2>&1; \
16 then echo "y"; else echo "n"; fi)
24 BUILD_ARCH=$(shell uname -m)
29 UCLIBC_LOADER = /lib/ld-uClibc.so.0
31 ifeq ($(BUILD_ARCH),x86_64)
32 ifneq ($(BUILD_ARCH), $(TARGET_ARCH))
36 CROSS_LDFLAGS=-melf_i386
39 UCLIBC_LOADER = /lib/ld64-uClibc.so.0
45 GCCVER:=$(shell $(CC) --version | head -n 1 | awk '{print $$3}')
46 GCCMAJ:=$(word 1, $(subst ., ,$(GCCVER)))
47 GCCMIN:=$(word 2, $(subst ., ,$(GCCVER)))
49 # Do a bit of groking of the GCC params
51 GCCDIR:=$(shell $(CC) --print-search-dirs | grep install | awk '{print $$2}')
52 LIBGCC:=$(shell $(CC) $(CROSS_CFLAGS) -print-libgcc-file-name)
54 CFLAGS:=-nostdinc $(CROSS_CFLAGS) $(CFLAGS_platform) -Os -isystem $(STAGING_DIR)/include \
55 -isystem $(GCCDIR)/include
57 ASFLAGS=$(CROSS_ASFLAGS) $(ASFLAGS_platform)
59 STACKPROTECT += $(call cc-option, -fno-stack-protector,)
60 CFLAGS += $(STACKPROTECT)
62 # Borrowed from busybox
63 STRIPCMD := $(STRIP) -s --remove-section=.note --remove-section=.comment
65 # This extra variable is needed because we need the original LDFLAGS
66 # (without any cross flags) for at least busybox, and probably others too
68 LDFLAGS_orig = -nostdlib -L$(STAGING_DIR)/lib \
69 -Wl,-rpath-link,$(STAGING_DIR)/lib -Wl,--dynamic-linker,$(UCLIBC_LOADER) \
72 LDFLAGS=$(CROSS_LDFLAGS) $(LDFLAGS_orig)
74 LIBS = $(STAGING_DIR)/lib/crt1.o -lc $(LIBGCC)
77 HOST_CFLAGS=$(STACKPROTECT)
81 PARALLEL_MAKE=-j$(CONFIG_MAKE_JOBS)
83 export CC AS CFLAGS LDFLAGS ASFLAGS LIBS PARALLEL_MAKE
85 # Several functions to get a custom config file name
87 custom-get-arch = $(if $(CONFIG_TARGET_64BIT),x86_64,i386)
89 custom-config-name = $(shell \
90 echo "$(PACKAGE_DIR)/$(1)/conf/customconfig--$(PAYLOAD)--$(call custom-get-arch)--$(COREBOOT_VENDOR)--$(COREBOOT_BOARD)")
92 custom-config-exists = $(shell if [ -f $(call custom-config-name,$(1)) ]; \