summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2020-06-23 12:07:01 +0900
committerSascha Hauer <s.hauer@pengutronix.de>2020-06-23 12:18:04 +0200
commitcca129e716fef156831ee26a624d2d0a0550ba8c (patch)
treef305ae175806abd30065b1f7284ec9614169db9f /Makefile
parentbc4840e98b94e4e78f76b761293d965edcfb094d (diff)
downloadbarebox-cca129e716fef156831ee26a624d2d0a0550ba8c.tar.gz
barebox-cca129e716fef156831ee26a624d2d0a0550ba8c.tar.xz
kbuild: add infrastructure to build userspace programs
Import Linux commit 7f3a59db274c3e3d884c785e363a054110f1c266 Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile13
1 files changed, 10 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index debdd61e13..d2ceeed711 100644
--- a/Makefile
+++ b/Makefile
@@ -363,9 +363,12 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
HOSTCC = gcc
HOSTCXX = g++
-KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
- -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
- $(HOSTCFLAGS)
+
+export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
+ -O2 -fomit-frame-pointer -std=gnu89
+export KBUILD_USERLDFLAGS :=
+
+KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
@@ -609,6 +612,10 @@ KBUILD_CFLAGS += $(call cc-option, -fno-delete-null-pointer-checks,)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+# Align the bit size of userspace programs with the kernel
+KBUILD_USERCFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
+KBUILD_USERLDFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
+
# arch Makefile may override CC so keep this after arch Makefile is included
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)