usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
[platform/kernel/linux-starfive.git] / scripts / Makefile.lib
index 3fa32f8..bae6254 100644 (file)
@@ -4,6 +4,8 @@ asflags-y  += $(EXTRA_AFLAGS)
 ccflags-y  += $(EXTRA_CFLAGS)
 cppflags-y += $(EXTRA_CPPFLAGS)
 ldflags-y  += $(EXTRA_LDFLAGS)
+always-y   += $(always)
+hostprogs  += $(hostprogs-y) $(hostprogs-m)
 
 # flags that take effect in current and sub directories
 KBUILD_AFLAGS += $(subdir-asflags-y)
@@ -35,7 +37,11 @@ __subdir-y   := $(patsubst %/,%,$(filter %/, $(obj-y)))
 subdir-y       += $(__subdir-y)
 __subdir-m     := $(patsubst %/,%,$(filter %/, $(obj-m)))
 subdir-m       += $(__subdir-m)
+ifdef need-builtin
 obj-y          := $(patsubst %/, %/built-in.a, $(obj-y))
+else
+obj-y          := $(filter-out %/, $(obj-y))
+endif
 obj-m          := $(filter-out %/, $(obj-m))
 
 # Subdirectories we need to descend into
@@ -55,6 +61,8 @@ subdir-obj-y := $(filter %/built-in.a, $(obj-y))
 real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
 real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
 
+always-y += $(always-m)
+
 # DTB
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
 extra-y                                += $(dtb-y)
@@ -68,7 +76,7 @@ endif
 # Add subdir path
 
 extra-y                := $(addprefix $(obj)/,$(extra-y))
-always         := $(addprefix $(obj)/,$(always))
+always-y       := $(addprefix $(obj)/,$(always-y))
 targets                := $(addprefix $(obj)/,$(targets))
 modorder       := $(addprefix $(obj)/,$(modorder))
 obj-m          := $(addprefix $(obj)/,$(obj-m))
@@ -80,12 +88,14 @@ 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=)))))
+# If the object belongs to two or more multi-part objects, list them all.
+modname-multi = $(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))
 
-modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
+modname = $(subst $(space),:,$(__modname))
+modfile = $(addprefix $(obj)/,$(__modname))
 
 # target with $(obj)/ and its suffix stripped
 target-stem = $(basename $(patsubst $(obj)/%,%,$@))
@@ -93,9 +103,10 @@ target-stem = $(basename $(patsubst $(obj)/%,%,$@))
 # 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)
+name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1)))
 basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
 modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname))
+modfile_flags  = -DKBUILD_MODFILE=$(call stringify,$(modfile))
 
 orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
                  $(ccflags-y) $(CFLAGS_$(target-stem).o)
@@ -154,7 +165,7 @@ quiet_modtag = $(if $(part-of-module),[M],   )
 modkern_cflags =                                          \
        $(if $(part-of-module),                           \
                $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
-               $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
+               $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))
 
 modkern_aflags = $(if $(part-of-module),                               \
                        $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE),       \