summaryrefslogtreecommitdiff
path: root/scripts/Makefile.build
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r--scripts/Makefile.build49
1 files changed, 25 insertions, 24 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f5f9a84fdd99..4bccbe923690 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -40,12 +40,14 @@ endif
ifdef L_TARGET
L_TARGET := $(obj)/$(L_TARGET)
else
+ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-)),)
O_TARGET := $(obj)/built-in.o
endif
+endif
__build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
- $(if $(KBUILD_MODULES),$(obj-m)) \
- $(subdir-ym)
+ $(if $(KBUILD_MODULES),$(obj-m:.o=.ko)) \
+ $(subdir-ym) $(build-targets)
@:
# Compile C sources (.c)
@@ -103,7 +105,9 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
$(call if_changed_dep,cc_o_c)
quiet_cmd_cc_lst_c = MKLST $@
-cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && sh scripts/makelst $*.o System.map $(OBJDUMP) > $@
+ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
+ $(CONFIG_SHELL) $(src)/scripts/makelst $*.o \
+ System.map $(OBJDUMP) > $@
%.lst: %.c FORCE
$(call if_changed_dep,cc_lst_c)
@@ -116,9 +120,6 @@ modkern_aflags := $(AFLAGS_KERNEL)
$(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE)
$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE)
-a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \
- $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
-
quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
@@ -171,21 +172,29 @@ endif
#
# Rule to link composite objects
#
+quiet_cmd_link_multi-y = LD $@
+cmd_link_multi-y = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs))) $($(subst $(obj)/,,$(@:.o=-y)))),$^)
-quiet_cmd_link_multi = LD $(quiet_modtag) $@
-cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs))) $($(subst $(obj)/,,$(@:.o=-y)))),$^)
+quiet_cmd_link_multi-m = LD [M] $@
+cmd_link_multi-m = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.ko=-objs))) $($(subst $(obj)/,,$(@:.ko=-y)))),$^)
+
+quiet_cmd_link_single-m = LD [M] $@
+cmd_link_single-m = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $<
# We would rather have a list of rules like
# foo.o: $(foo-objs)
# but that's not so easy, so we rather make all composite objects depend
# on the set of all their parts
$(multi-used-y) : %.o: $(multi-objs-y) FORCE
- $(call if_changed,link_multi)
+ $(call if_changed,link_multi-y)
+
+$(multi-used-m:.o=.ko) : %.ko: $(multi-objs-m) FORCE
+ $(call if_changed,link_multi-m)
-$(multi-used-m) : %.o: $(multi-objs-m) FORCE
- $(call if_changed,link_multi)
+$(single-used-m:.o=.ko) : %.ko: %.o FORCE
+ $(call if_changed,link_single-m)
-targets += $(multi-used-y) $(multi-used-m)
+targets += $(multi-used-y) $(multi-used-m:.o=.ko) $(single-used-m:.o=.ko)
# Compile programs on the host
# ===========================================================================
@@ -217,9 +226,7 @@ targets += $(multi-used-y) $(multi-used-m)
# Create executable from a single .c file
# host-csingle -> Executable
quiet_cmd_host-csingle = HOSTCC $@
- cmd_host-csingle = $(HOSTCC) -Wp,-MD,$(depfile) \
- $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
- $(HOST_LOADLIBES) -o $@ $<
+ cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOST_LOADLIBES) -o $@ $<
$(host-csingle): %: %.c FORCE
$(call if_changed_dep,host-csingle)
@@ -235,9 +242,7 @@ $(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE
# Create .o file from a single .c file
# host-cobjs -> .o
quiet_cmd_host-cobjs = HOSTCC $@
- cmd_host-cobjs = $(HOSTCC) -Wp,-MD,$(depfile) \
- $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
- $(HOSTCFLAGS_$(@F)) -c -o $@ $<
+ cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $<
$(host-cobjs): %.o: %.c FORCE
$(call if_changed_dep,host-cobjs)
@@ -253,18 +258,14 @@ $(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
# Create .o file from a single .cc (C++) file
quiet_cmd_host-cxxobjs = HOSTCXX $@
- cmd_host-cxxobjs = $(HOSTCXX) -Wp,-MD,$(depfile) \
- $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
- $(HOSTCXXFLAGS_$(@F)) -c -o $@ $<
+ cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $<
$(host-cxxobjs): %.o: %.cc FORCE
$(call if_changed_dep,host-cxxobjs)
# Compile .c file, create position independent .o file
# host-cshobjs -> .o
quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
- cmd_host-cshobjs = $(HOSTCC) -Wp,-MD,$(depfile) -fPIC\
- $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
- $(HOSTCFLAGS_$(@F)) -c -o $@ $<
+ cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
$(host-cshobjs): %.o: %.c FORCE
$(call if_changed_dep,host-cshobjs)