diff mbox series

[RFC,XEN,10/23] xen,Kbuild: Handle __OBJECT_*__

Message ID 20191023164837.2700240-11-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series Kconfig update + WIP of using Kbuild | expand

Commit Message

Anthony PERARD Oct. 23, 2019, 4:48 p.m. UTC
Define __OBJECT_FILE__ and __OBJECT_LABEL__ as it is done in
arch/x86/Rules.mk.

Those defines would also be created when doing an ARM build, when
Kbuild will be used to build xen.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/scripts/Makefile.lib | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/xen/scripts/Makefile.lib b/xen/scripts/Makefile.lib
index 19641e836dc3..7ba3cf034c98 100644
--- a/xen/scripts/Makefile.lib
+++ b/xen/scripts/Makefile.lib
@@ -97,20 +97,12 @@  real-obj-m	:= $(addprefix $(obj)/,$(real-obj-m))
 multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
 subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
 
-# Finds the multi-part object the current object will be linked into.
-# If the object belongs to two or more multi-part objects, all of them are
-# concatenated with a colon separator.
-modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
-		$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))))
-
-modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
-
-# These flags are needed for modversions and compiling, so we define them here
-# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
-# end up in (or would, if it gets compiled in)
-name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
-basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
-modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname))
+object_file_flags  = '-D__OBJECT_FILE__="$(subst $(obj)/,,$@)"'
+ifeq ($(findstring -DHAVE_AS_QUOTED_SYM,$(KBUILD_CFLAGS)),)
+object_file_flags += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(@)))'
+else
+object_file_flags += '-D__OBJECT_LABEL__=$(subst -,_,$(@))'
+endif
 
 # See comment about INIT_SECTIONS_ONLY in include/xen/compiler.h
 $(filter %.init.o,$(real-obj-y) $(extra-y)): ccflags-y += -DINIT_SECTIONS_ONLY
@@ -168,13 +160,13 @@  endif
 
 c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
 		 $(_c_flags) $(modkern_cflags)                           \
-		 $(basename_flags) $(modname_flags)
+		 $(object_file_flags)
 
 a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
-		 $(_a_flags) $(modkern_aflags)
+		 $(object_file_flags) $(_a_flags)
 
 cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
-		 $(_cpp_flags)
+		 $(object_file_flags) $(_cpp_flags)
 
 ld_flags       = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))