From 996fdfdc65a5adfb6442f899c3a9eeba39c48361 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 22 Nov 2002 20:15:19 +0100 Subject: kbuild: Move flags to Makefile.lib a_flags defined in Makefile.lib, and a set of flags made for host related rules. This avoided some duplication in Makefile.build --- scripts/Makefile.lib | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'scripts/Makefile.lib') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index ab209ad5830e..dd074686c2e7 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -128,6 +128,12 @@ modname_flags = -DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname))) c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \ $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \ $(basename_flags) $(modname_flags) $(export_flags) +a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS)\ + $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) +hostc_flags = -Wp,-MD,$(depfile) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS)\ + $(HOSTCFLAGS_$(*F).o) +hostcxx_flags = -Wp,-MD,$(depfile) $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS)\ + $(HOSTCXXFLAGS_$(*F).o) # Finds the multi-part object the current object will be linked into modname-multi = $(subst $(space),_,$(strip $(foreach m,$(multi-used),\ @@ -139,7 +145,7 @@ modname-multi = $(subst $(space),_,$(strip $(foreach m,$(multi-used),\ quiet_cmd_shipped = SHIPPED $@ cmd_shipped = cat $< > $@ -%:: %_shipped +$(obj)/%:: $(src)/%_shipped $(call cmd,shipped) # Commands useful for building a boot image -- cgit v1.2.3 From 80fee71cbb24e2e0f26b284e57d703dd98993133 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 22 Nov 2002 23:15:42 +0100 Subject: kbuild: Introduced build-targets build-targets is used to list targets that is always built. This allowed misuse of EXTRA_TARGETS to be deleted. built-in.o is now only created for directories defining a obj-* variable, avoiding this for scripts and lxdialog One Makefile needed a dummy obj- statement --- Makefile | 2 +- drivers/misc/Makefile | 2 +- scripts/Makefile | 27 ++++----------------------- scripts/Makefile.build | 4 +++- scripts/Makefile.lib | 1 + scripts/lxdialog/Makefile | 8 ++------ 6 files changed, 12 insertions(+), 32 deletions(-) (limited to 'scripts/Makefile.lib') diff --git a/Makefile b/Makefile index 2d97192ece66..50214dd1f61c 100644 --- a/Makefile +++ b/Makefile @@ -629,7 +629,7 @@ xconfig: scripts/kconfig/qconf ./scripts/kconfig/qconf arch/$(ARCH)/Kconfig menuconfig: scripts/kconfig/mconf - $(Q)$(MAKE) -f scripts/Makefile.build obj=scripts lxdialog + $(Q)$(MAKE) -f scripts/Makefile.build obj=scripts/lxdialog ./scripts/kconfig/mconf arch/$(ARCH)/Kconfig config: scripts/kconfig/conf diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index dc7ec8baee12..5ce866f84241 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -1,5 +1,5 @@ # # Makefile for misc devices that really don't fit anywhere else. # - +obj- := misc.o # Dummy rule to force built-in.o to be made include $(TOPDIR)/Rules.make diff --git a/scripts/Makefile b/scripts/Makefile index 5ecc03a43242..25979b0efdb3 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -8,31 +8,12 @@ # docproc: Preprocess .tmpl file in order to generate .sgml documentation # conmakehash: Create arrays for initializing the kernel console tables -EXTRA_TARGETS := fixdep split-include docproc conmakehash +host-progs := fixdep split-include conmakehash docproc +build-targets := $(host-progs) +# Let clean descend into subdirs subdir- := lxdialog kconfig -# Yikes. We need to build this stuff here even if the user only wants -# modules. - -KBUILD_BUILTIN := 1 - -# The following temporary rule will make sure that people's -# trees get updated to the right permissions, since patch(1) -# can't do it -# --------------------------------------------------------------------------- - -host-progs := fixdep split-include conmakehash docproc - -include $(TOPDIR)/Rules.make - - -# --------------------------------------------------------------------------- -# Targets hardcoded and wellknow in top-level makefile -.PHONY: lxdialog -lxdialog: - $(call descend,scripts/lxdialog,) - # fixdep is needed to compile other host programs $(obj)/split-include $(obj)/docproc \ -$(obj)/conmakehash lxdialog: $(obj)/fixdep +$(obj)/conmakehash: $(obj)/fixdep diff --git a/scripts/Makefile.build b/scripts/Makefile.build index db56f901d0ae..37e73b5e0b9b 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) + $(subdir-ym) $(build-targets) @: # Compile C sources (.c) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index dd074686c2e7..0f8c58e0996c 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -92,6 +92,7 @@ host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) # Add subdir path EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS)) +build-targets := $(addprefix $(obj)/,$(build-targets)) obj-y := $(addprefix $(obj)/,$(obj-y)) obj-m := $(addprefix $(obj)/,$(obj-m)) export-objs := $(addprefix $(obj)/,$(export-objs)) diff --git a/scripts/lxdialog/Makefile b/scripts/lxdialog/Makefile index 252c5bf86cd1..f4b40f078ee8 100644 --- a/scripts/lxdialog/Makefile +++ b/scripts/lxdialog/Makefile @@ -15,19 +15,15 @@ endif endif endif -host-progs := lxdialog +host-progs := lxdialog +build-targets := $(host-progs) lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ util.o lxdialog.o msgbox.o -EXTRA_TARGETS := lxdialog - first_rule: ncurses -include $(TOPDIR)/Rules.make - .PHONY: ncurses - ncurses: @echo "main() {}" > lxtemp.c @if $(HOSTCC) lxtemp.c $(HOST_LOADLIBES); then \ -- cgit v1.2.3 From 38a481f510a7add06c4da057c387bc51f9371e6d Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 23 Nov 2002 00:16:15 +0100 Subject: kbuild: No longer use descend macro, added 'Kernel: xxx is ready' text In the top-level Makefile and in the i386 architecture specific makefile no longer use descend. i386 is used as template for other architectures, so they shall be kept nice. Also added a little text: Kernel: arch/i386/boot/bzImage is ready A reminder of what target you did build, and where it is located --- Makefile | 10 +++++----- arch/i386/Makefile | 12 ++++++------ arch/i386/boot/Makefile | 12 +++--------- arch/i386/boot/compressed/Makefile | 1 + scripts/Makefile.lib | 2 +- 5 files changed, 16 insertions(+), 21 deletions(-) (limited to 'scripts/Makefile.lib') diff --git a/Makefile b/Makefile index 50214dd1f61c..b0c754eed306 100644 --- a/Makefile +++ b/Makefile @@ -200,7 +200,7 @@ scripts/docproc scripts/fixdep scripts/split-include : scripts ; .PHONY: scripts scripts: - +@$(Q)$(MAKE) -f scripts/Makefile.build obj=scripts + $(Q)$(MAKE) -f scripts/Makefile.build obj=scripts # Objects we will link into vmlinux / subdirs we need to visit # --------------------------------------------------------------------------- @@ -419,7 +419,7 @@ include/config/MARKER: scripts/split-include include/linux/autoconf.h # with it and forgot to run make oldconfig include/linux/autoconf.h: .config - +@$(call descend,scripts/kconfig,scripts/kconfig/conf) + $(Q)$(MAKE) -f scripts/Makefile.build obj=scripts/kconfig scripts/kconfig/conf ./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig # Generate some files @@ -623,7 +623,7 @@ ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) make_with_config scripts/kconfig/conf scripts/kconfig/mconf scripts/kconfig/qconf: scripts/fixdep FORCE - +@$(call descend,scripts/kconfig,$@) + $(Q)$(MAKE) -f scripts/Makefile.build obj=scripts/kconfig $@ xconfig: scripts/kconfig/qconf ./scripts/kconfig/qconf arch/$(ARCH)/Kconfig @@ -811,7 +811,7 @@ else # ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) # =========================================================================== %:: FORCE - $(MAKE) $@ + $(Q)$(MAKE) $@ endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) endif # ifdef include_config @@ -872,6 +872,6 @@ endef # $(call descend,,) # Recursively call a sub-make in with target -descend = $(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) +descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) FORCE: diff --git a/arch/i386/Makefile b/arch/i386/Makefile index 6e1cddf8ffdc..a9657be239c7 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -66,7 +66,7 @@ drivers-$(CONFIG_OPROFILE) += arch/i386/oprofile/ CFLAGS += -Iarch/i386/$(MACHINE) AFLAGS += -Iarch/i386/$(MACHINE) -makeboot = $(call descend,arch/i386/boot,$(1)) +makeboot =$(Q)$(MAKE) -f scripts/Makefile.build obj=arch/i386/boot $(1) .PHONY: zImage bzImage compressed zlilo bzlilo zdisk bzdisk install \ clean archclean archmrproper @@ -77,20 +77,20 @@ BOOTIMAGE=arch/i386/boot/bzImage zImage zlilo zdisk: BOOTIMAGE=arch/i386/boot/zImage zImage bzImage: vmlinux - +@$(call makeboot,$(BOOTIMAGE)) + $(call makeboot,$(BOOTIMAGE)) compressed: zImage zlilo bzlilo: vmlinux - +@$(call makeboot,BOOTIMAGE=$(BOOTIMAGE) zlilo) + $(call makeboot,BOOTIMAGE=$(BOOTIMAGE) zlilo) zdisk bzdisk: vmlinux - +@$(call makeboot,BOOTIMAGE=$(BOOTIMAGE) zdisk) + $(call makeboot,BOOTIMAGE=$(BOOTIMAGE) zdisk) install: vmlinux - +@$(call makeboot,BOOTIMAGE=$(BOOTIMAGE) install) + $(call makeboot,BOOTIMAGE=$(BOOTIMAGE) install) archclean: - @$(MAKE) -f scripts/Makefile.clean obj=arch/i386/boot + $(Q)$(MAKE) -f scripts/Makefile.clean obj=arch/i386/boot archmrproper: diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile index 3e5ad77e1d33..bcb97140c50f 100644 --- a/arch/i386/boot/Makefile +++ b/arch/i386/boot/Makefile @@ -32,12 +32,6 @@ subdir- := compressed host-progs := tools/build -# Default - -boot: bzImage - -include $(TOPDIR)/Rules.make - # --------------------------------------------------------------------------- $(obj)/zImage: IMAGE_OFFSET := 0x1000 @@ -53,6 +47,7 @@ cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \ $(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \ $(obj)/vmlinux.bin $(obj)/tools/build FORCE $(call if_changed,image) + @echo 'Kernel: $@ is ready' $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE $(call if_changed,objcopy) @@ -64,9 +59,8 @@ $(obj)/setup $(obj)/bootsect: %: %.o FORCE $(call if_changed,ld) $(obj)/compressed/vmlinux: FORCE - +@$(call descend,$(obj)/compressed,IMAGE_OFFSET=$(IMAGE_OFFSET) \ - $(obj)/compressed/vmlinux) - + $(Q)$(MAKE) -f scripts/Makefile.build obj=$(obj)/compressed \ + IMAGE_OFFSET=$(IMAGE_OFFSET) $@ zdisk: $(BOOTIMAGE) dd bs=8192 if=$(BOOTIMAGE) of=/dev/fd0 diff --git a/arch/i386/boot/compressed/Makefile b/arch/i386/boot/compressed/Makefile index 16383b2df2fb..771a41e24e5a 100644 --- a/arch/i386/boot/compressed/Makefile +++ b/arch/i386/boot/compressed/Makefile @@ -13,6 +13,7 @@ LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32 $(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE $(call if_changed,ld) + @: $(obj)/vmlinux.bin: vmlinux FORCE $(call if_changed,objcopy) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0f8c58e0996c..9d08f19e985e 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -243,4 +243,4 @@ endef # $(call descend,,) # Recursively call a sub-make in with target -descend = $(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) +descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) -- cgit v1.2.3 From 5991f8158084d078d4204c7a28d568ffbc962ab1 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 4 Dec 2002 01:36:09 -0600 Subject: kbuild: Build modules as '.ko' --- Makefile | 11 +++++++---- scripts/Makefile.build | 22 +++++++++++++++------- scripts/Makefile.lib | 2 ++ scripts/Makefile.modinst | 6 +++--- 4 files changed, 27 insertions(+), 14 deletions(-) (limited to 'scripts/Makefile.lib') diff --git a/Makefile b/Makefile index 537d7589bfb2..fb633d2f6dd1 100644 --- a/Makefile +++ b/Makefile @@ -162,8 +162,10 @@ PERL = perl MODFLAGS = -DMODULE CFLAGS_MODULE = $(MODFLAGS) AFLAGS_MODULE = $(MODFLAGS) +LDFLAGS_MODULE = -r CFLAGS_KERNEL = AFLAGS_KERNEL = + NOSTDINC_FLAGS = -nostdinc -iwithprefix include CPPFLAGS := -D__KERNEL__ -Iinclude @@ -174,7 +176,7 @@ AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS) export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ - HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB + HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE @@ -543,7 +545,7 @@ _modinst_: .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS)) $(patsubst %, _modinst_%, $(SUBDIRS)) : - $(Q)$(MAKE) -f scripts/Makefile.modinst obj=$(patsubst _modinst_%,%,$@) + $(Q)$(MAKE) -rR -f scripts/Makefile.modinst obj=$(patsubst _modinst_%,%,$@) else # CONFIG_MODULES # Modules not configured @@ -709,8 +711,9 @@ cmd_rmclean = rm -f $(CLEAN_FILES) clean: archclean $(addprefix _clean_,$(clean-dirs)) $(call cmd,rmclean) @find . $(RCS_FIND_IGNORE) \ - \( -name '*.[oas]' -o -name '.*.cmd' -o -name '.*.d' \ - -o -name '.*.tmp' \) -type f -print | xargs rm -f + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '.*.d' -o -name '.*.tmp' \) -type f \ + -print | xargs rm -f # mrproper - delete configuration + modules + core files # diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 37e73b5e0b9b..4bccbe923690 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -46,7 +46,7 @@ endif endif __build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \ - $(if $(KBUILD_MODULES),$(obj-m)) \ + $(if $(KBUILD_MODULES),$(obj-m:.o=.ko)) \ $(subdir-ym) $(build-targets) @: @@ -172,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 # =========================================================================== diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 2fd252467066..f21c0905c2da 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -43,6 +43,7 @@ __obj-m = $(filter-out export.o,$(obj-m)) multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) multi-used := $(multi-used-y) $(multi-used-m) +single-used-m := $(filter-out $(multi-used-m),$(obj-m)) # Build list of the parts of our composite objects, our composite # objects depend on those (obviously) @@ -99,6 +100,7 @@ export-objs := $(addprefix $(obj)/,$(export-objs)) subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) +single-used-m := $(addprefix $(obj)/,$(single-used-m)) multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 45f5387d365f..1ea62f1c679c 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -15,12 +15,12 @@ include scripts/Makefile.lib # ========================================================================== -quiet_cmd_modules_install = INSTALL $(obj-m) +quiet_cmd_modules_install = INSTALL $(obj-m:.o=.ko) cmd_modules_install = mkdir -p $(MODLIB)/kernel && \ - cp $(obj-m) $(MODLIB)/kernel/ + cp $(obj-m:.o=.ko) $(MODLIB)/kernel/ modules_install: $(subdir-ym) -ifneq ($(obj-m),) +ifneq ($(obj-m:.o=.ko),) $(call cmd,modules_install) else @: -- cgit v1.2.3