achieved to compile the kvm tools against uclibc using buildrom
[kvm-coreboot.git] / scripts / Build.settings
blob4bec75be5c4494403abdd6c1310374eab30a2907
1 # Set any settings that remain unset from the configuration
3 # Borrowed from the kernel
5 try-run= $(shell set -e; \
6            TMP=".$$$$.tmp"; \
7            if ($(1)) > /dev/null 2>&1; \
8            then echo "$(2)"; \
9            else echo "$(3)"; \
10            fi; rm -rf "$$TMP")
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)
19 CC ?= gcc
20 STRIP ?= strip
21 AS ?= as
22 LC ?= ld
24 BUILD_ARCH=$(shell uname -m)
26 CROSS_CFLAGS=
27 CROSS_ASFLAGS=
28 CROSS_LDFLAGS=
29 UCLIBC_LOADER = /lib/ld-uClibc.so.0
31 ifeq ($(BUILD_ARCH),x86_64)
32 ifneq ($(BUILD_ARCH), $(TARGET_ARCH))
34 CROSS_ASFLAGS=--32
35 CROSS_CFLAGS=-m32
36 CROSS_LDFLAGS=-melf_i386
38 else
39 UCLIBC_LOADER = /lib/ld64-uClibc.so.0
40 endif
41 endif
43 # Get the GCC version
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) \
70 $(LDFLAGS_platform)
72 LDFLAGS=$(CROSS_LDFLAGS) $(LDFLAGS_orig)
74 LIBS = $(STAGING_DIR)/lib/crt1.o -lc $(LIBGCC)
76 HOST_CC=gcc
77 HOST_CFLAGS=$(STACKPROTECT)
78 HOST_LDFLAGS=
80 HOSTCC=$(HOST_CC)
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)) ]; \
93                         then echo 1; fi)