modprobe-small: fix and simplify rmmod
[oweals/busybox.git] / scripts / Makefile.build
index e48e60da304092be6a66ed3f5f071ce1080a4f0b..5eac45f91f86852f322af06cd52c214f39925d99 100644 (file)
@@ -13,8 +13,13 @@ __build:
 include scripts/Kbuild.include
 
 # The filename Kbuild has precedence over Makefile
+# bbox: we also try to include Kbuild file in obj tree first
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
-include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
+include $(if $(wildcard $(src)/Kbuild), $(src)/Kbuild, \
+               $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, \
+                       $(kbuild-dir)/Makefile \
+               ) \
+       )
 
 include scripts/Makefile.lib
 
@@ -216,7 +221,7 @@ $(real-objs-m)      : modkern_aflags := $(AFLAGS_MODULE)
 $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE)
 
 quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
-cmd_as_s_S       = $(CPP) $(a_flags)   -o $@ $< 
+cmd_as_s_S       = $(CPP) $(a_flags)   -o $@ $<
 
 %.s: %.S FORCE
        $(call if_changed_dep,as_s_S)
@@ -250,9 +255,10 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
 ifdef builtin-target
 quiet_cmd_link_o_target = LD      $@
 # If the list of objects to link is empty, just create an empty built-in.o
+# -nostdlib is added to make "make LD=gcc ..." work (some people use that)
 cmd_link_o_target = $(if $(strip $(obj-y)),\
-                     $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
-                     rm -f $@; $(AR) rcs $@)
+               $(LD) -nostdlib $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
+               rm -f $@; $(AR) rcs $@)
 
 $(builtin-target): $(obj-y) FORCE
        $(call if_changed,link_o_target)
@@ -284,7 +290,7 @@ link_multi_deps =                     \
 $(filter $(addprefix $(obj)/,         \
 $($(subst $(obj)/,,$(@:.o=-objs)))    \
 $($(subst $(obj)/,,$(@:.o=-y)))), $^)
+
 quiet_cmd_link_multi-y = LD      $@
 cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)