kbuild: change kbuild to not rely on incorrect GNU make behavior

The kbuild system takes advantage of an incorrect behavior in GNU make.
Once this behavior is fixed, all files in the kernel rebuild every time,
even if nothing has changed.  This patch ensures kbuild works with both
the incorrect and correct behaviors of GNU make.

For more details on the incorrect behavior, see:

http://lists.gnu.org/archive/html/bug-make/2006-03/msg00003.html

Changes in this patch:
  - Keep all targets that are to be marked .PHONY in a variable, PHONY.
  - Add .PHONY: $(PHONY) to mark them properly.
  - Remove any $(PHONY) files from the $? list when determining whether
    targets are up-to-date or not.

Signed-off-by: Paul Smith <psmith@gnu.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
This commit is contained in:
Paul Smith 2006-03-05 17:14:10 -05:00 committed by Sam Ravnborg
parent 7b75b13cda
commit 4f1933620f
25 changed files with 144 additions and 75 deletions

View File

@ -28,7 +28,7 @@ PS_METHOD = $(prefer-db2x)
### ###
# The targets that may be used. # The targets that may be used.
.PHONY: xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
BOOKS := $(addprefix $(obj)/,$(DOCBOOKS)) BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
xmldocs: $(BOOKS) xmldocs: $(BOOKS)
@ -211,3 +211,9 @@ clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS))
#man put files in man subdir - traverse down #man put files in man subdir - traverse down
subdir- := man/ subdir- := man/
# Declare the contents of the .PHONY variable as phony. We keep that
# information in a variable se we can use it in if_changed and friends.
.PHONY: $(PHONY)

View File

@ -95,7 +95,7 @@ ifdef O
endif endif
# That's our default target when none is given on the command line # That's our default target when none is given on the command line
.PHONY: _all PHONY := _all
_all: _all:
ifneq ($(KBUILD_OUTPUT),) ifneq ($(KBUILD_OUTPUT),)
@ -106,7 +106,7 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
$(if $(KBUILD_OUTPUT),, \ $(if $(KBUILD_OUTPUT),, \
$(error output directory "$(saved-output)" does not exist)) $(error output directory "$(saved-output)" does not exist))
.PHONY: $(MAKECMDGOALS) PHONY += $(MAKECMDGOALS)
$(filter-out _all,$(MAKECMDGOALS)) _all: $(filter-out _all,$(MAKECMDGOALS)) _all:
$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
@ -123,7 +123,7 @@ ifeq ($(skip-makefile),)
# If building an external module we do not care about the all: rule # If building an external module we do not care about the all: rule
# but instead _all depend on modules # but instead _all depend on modules
.PHONY: all PHONY += all
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
_all: all _all: all
else else
@ -337,14 +337,14 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc
# Rules shared between *config targets and build targets # Rules shared between *config targets and build targets
# Basic helpers built in scripts/ # Basic helpers built in scripts/
.PHONY: scripts_basic PHONY += scripts_basic
scripts_basic: scripts_basic:
$(Q)$(MAKE) $(build)=scripts/basic $(Q)$(MAKE) $(build)=scripts/basic
# To avoid any implicit rule to kick in, define an empty command. # To avoid any implicit rule to kick in, define an empty command.
scripts/basic/%: scripts_basic ; scripts/basic/%: scripts_basic ;
.PHONY: outputmakefile PHONY += outputmakefile
# outputmakefile generate a Makefile to be placed in output directory, if # outputmakefile generate a Makefile to be placed in output directory, if
# using a seperate output directory. This allows convinient use # using a seperate output directory. This allows convinient use
# of make in output directory # of make in output directory
@ -420,7 +420,7 @@ ifeq ($(KBUILD_EXTMOD),)
# Additional helpers built in scripts/ # Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice # Carefully list dependencies so we do not try to build scripts twice
# in parrallel # in parrallel
.PHONY: scripts PHONY += scripts
scripts: scripts_basic include/config/MARKER scripts: scripts_basic include/config/MARKER
$(Q)$(MAKE) $(build)=$(@) $(Q)$(MAKE) $(build)=$(@)
@ -720,7 +720,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
# make menuconfig etc. # make menuconfig etc.
# Error messages still appears in the original language # Error messages still appears in the original language
.PHONY: $(vmlinux-dirs) PHONY += $(vmlinux-dirs)
$(vmlinux-dirs): prepare scripts $(vmlinux-dirs): prepare scripts
$(Q)$(MAKE) $(build)=$@ $(Q)$(MAKE) $(build)=$@
@ -773,10 +773,10 @@ kernelrelease = $(KERNELVERSION)$(localver-full)
# version.h and scripts_basic is processed / created. # version.h and scripts_basic is processed / created.
# Listed in dependency order # Listed in dependency order
.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3 PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
# prepare-all is deprecated, use prepare as valid replacement # prepare-all is deprecated, use prepare as valid replacement
.PHONY: prepare-all PHONY += prepare-all
# prepare3 is used to check if we are building in a separate output directory, # prepare3 is used to check if we are building in a separate output directory,
# and if so do: # and if so do:
@ -857,7 +857,7 @@ include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
.PHONY: depend dep PHONY += depend dep
depend dep: depend dep:
@echo '*** Warning: make $@ is unnecessary now.' @echo '*** Warning: make $@ is unnecessary now.'
@ -872,21 +872,21 @@ all: modules
# Build modules # Build modules
.PHONY: modules PHONY += modules
modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
@echo ' Building modules, stage 2.'; @echo ' Building modules, stage 2.';
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
# Target to prepare building external modules # Target to prepare building external modules
.PHONY: modules_prepare PHONY += modules_prepare
modules_prepare: prepare scripts modules_prepare: prepare scripts
# Target to install modules # Target to install modules
.PHONY: modules_install PHONY += modules_install
modules_install: _modinst_ _modinst_post modules_install: _modinst_ _modinst_post
.PHONY: _modinst_ PHONY += _modinst_
_modinst_: _modinst_:
@if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
echo "Warning: you may need to install module-init-tools"; \ echo "Warning: you may need to install module-init-tools"; \
@ -913,7 +913,7 @@ depmod_opts :=
else else
depmod_opts := -b $(INSTALL_MOD_PATH) -r depmod_opts := -b $(INSTALL_MOD_PATH) -r
endif endif
.PHONY: _modinst_post PHONY += _modinst_post
_modinst_post: _modinst_ _modinst_post: _modinst_
if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
@ -956,7 +956,7 @@ clean: rm-dirs := $(CLEAN_DIRS)
clean: rm-files := $(CLEAN_FILES) clean: rm-files := $(CLEAN_FILES)
clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs))
.PHONY: $(clean-dirs) clean archclean PHONY += $(clean-dirs) clean archclean
$(clean-dirs): $(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
@ -974,7 +974,7 @@ mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts)
.PHONY: $(mrproper-dirs) mrproper archmrproper PHONY += $(mrproper-dirs) mrproper archmrproper
$(mrproper-dirs): $(mrproper-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
@ -984,7 +984,7 @@ mrproper: clean archmrproper $(mrproper-dirs)
# distclean # distclean
# #
.PHONY: distclean PHONY += distclean
distclean: mrproper distclean: mrproper
@find $(srctree) $(RCS_FIND_IGNORE) \ @find $(srctree) $(RCS_FIND_IGNORE) \
@ -1000,7 +1000,7 @@ distclean: mrproper
# rpm target kept for backward compatibility # rpm target kept for backward compatibility
package-dir := $(srctree)/scripts/package package-dir := $(srctree)/scripts/package
.PHONY: %-pkg rpm PHONY += %-pkg rpm
%pkg: FORCE %pkg: FORCE
$(Q)$(MAKE) -f $(package-dir)/Makefile $@ $(Q)$(MAKE) -f $(package-dir)/Makefile $@
@ -1092,12 +1092,12 @@ else # KBUILD_EXTMOD
# We are always building modules # We are always building modules
KBUILD_MODULES := 1 KBUILD_MODULES := 1
.PHONY: crmodverdir PHONY += crmodverdir
crmodverdir: crmodverdir:
$(Q)rm -rf $(MODVERDIR) $(Q)rm -rf $(MODVERDIR)
$(Q)mkdir -p $(MODVERDIR) $(Q)mkdir -p $(MODVERDIR)
.PHONY: $(objtree)/Module.symvers PHONY += $(objtree)/Module.symvers
$(objtree)/Module.symvers: $(objtree)/Module.symvers:
@test -e $(objtree)/Module.symvers || ( \ @test -e $(objtree)/Module.symvers || ( \
echo; \ echo; \
@ -1106,7 +1106,7 @@ $(objtree)/Module.symvers:
echo ) echo )
module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
.PHONY: $(module-dirs) modules PHONY += $(module-dirs) modules
$(module-dirs): crmodverdir $(objtree)/Module.symvers $(module-dirs): crmodverdir $(objtree)/Module.symvers
$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
@ -1114,11 +1114,11 @@ modules: $(module-dirs)
@echo ' Building modules, stage 2.'; @echo ' Building modules, stage 2.';
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
.PHONY: modules_install PHONY += modules_install
modules_install: _emodinst_ _emodinst_post modules_install: _emodinst_ _emodinst_post
install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
.PHONY: _emodinst_ PHONY += _emodinst_
_emodinst_: _emodinst_:
$(Q)rm -rf $(MODLIB)/$(install-dir) $(Q)rm -rf $(MODLIB)/$(install-dir)
$(Q)mkdir -p $(MODLIB)/$(install-dir) $(Q)mkdir -p $(MODLIB)/$(install-dir)
@ -1133,13 +1133,13 @@ quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
$(KERNELRELEASE); \ $(KERNELRELEASE); \
fi fi
.PHONY: _emodinst_post PHONY += _emodinst_post
_emodinst_post: _emodinst_ _emodinst_post: _emodinst_
$(call cmd,depmod) $(call cmd,depmod)
clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
.PHONY: $(clean-dirs) clean PHONY += $(clean-dirs) clean
$(clean-dirs): $(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
@ -1161,7 +1161,7 @@ help:
@echo '' @echo ''
# Dummies... # Dummies...
.PHONY: prepare scripts PHONY += prepare scripts
prepare: ; prepare: ;
scripts: ; scripts: ;
endif # KBUILD_EXTMOD endif # KBUILD_EXTMOD
@ -1274,7 +1274,7 @@ namespacecheck:
endif #ifeq ($(config-targets),1) endif #ifeq ($(config-targets),1)
endif #ifeq ($(mixed-targets),1) endif #ifeq ($(mixed-targets),1)
.PHONY: checkstack PHONY += checkstack
checkstack: checkstack:
$(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
$(PERL) $(src)/scripts/checkstack.pl $(ARCH) $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
@ -1357,4 +1357,10 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
endif # skip-makefile endif # skip-makefile
PHONY += FORCE
FORCE: FORCE:
# Declare the contents of the .PHONY variable as phony. We keep that
# information in a variable se we can use it in if_changed and friends.
.PHONY: $(PHONY)

View File

@ -1,6 +1,9 @@
# #
# arch/arm/Makefile # arch/arm/Makefile
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public # This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive # License. See the file "COPYING" in the main directory of this archive
# for more details. # for more details.
@ -176,7 +179,7 @@ endif
archprepare: maketools archprepare: maketools
.PHONY: maketools FORCE PHONY += maketools FORCE
maketools: include/linux/version.h include/asm-arm/.arch FORCE maketools: include/linux/version.h include/asm-arm/.arch FORCE
$(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h

View File

@ -1,6 +1,9 @@
# #
# arch/arm/boot/Makefile # arch/arm/boot/Makefile
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public # This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive # License. See the file "COPYING" in the main directory of this archive
# for more details. # for more details.
@ -73,7 +76,7 @@ $(obj)/bootpImage: $(obj)/bootp/bootp FORCE
$(call if_changed,objcopy) $(call if_changed,objcopy)
@echo ' Kernel: $@ is ready' @echo ' Kernel: $@ is ready'
.PHONY: initrd FORCE PHONY += initrd FORCE
initrd: initrd:
@test "$(INITRD_PHYS)" != "" || \ @test "$(INITRD_PHYS)" != "" || \
(echo This machine does not support INITRD; exit -1) (echo This machine does not support INITRD; exit -1)

View File

@ -1,6 +1,9 @@
# #
# linux/arch/arm/boot/bootp/Makefile # linux/arch/arm/boot/bootp/Makefile
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
LDFLAGS_bootp :=-p --no-undefined -X \ LDFLAGS_bootp :=-p --no-undefined -X \
--defsym initrd_phys=$(INITRD_PHYS) \ --defsym initrd_phys=$(INITRD_PHYS) \
@ -21,4 +24,4 @@ $(obj)/kernel.o: arch/arm/boot/zImage FORCE
$(obj)/initrd.o: $(INITRD) FORCE $(obj)/initrd.o: $(INITRD) FORCE
.PHONY: $(INITRD) FORCE PHONY += $(INITRD) FORCE

View File

@ -1,6 +1,9 @@
# #
# arch/arm26/Makefile # arch/arm26/Makefile
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public # This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive # License. See the file "COPYING" in the main directory of this archive
# for more details. # for more details.
@ -49,9 +52,9 @@ all: zImage
boot := arch/arm26/boot boot := arch/arm26/boot
.PHONY: maketools FORCE PHONY += maketools FORCE
maketools: FORCE maketools: FORCE
# Convert bzImage to zImage # Convert bzImage to zImage
bzImage: vmlinux bzImage: vmlinux

View File

@ -1,6 +1,9 @@
# #
# arch/arm26/boot/Makefile # arch/arm26/boot/Makefile
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public # This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive # License. See the file "COPYING" in the main directory of this archive
# for more details. # for more details.
@ -60,7 +63,7 @@ $(obj)/xipImage: vmlinux FORCE
@echo ' Kernel: $@ is ready' @echo ' Kernel: $@ is ready'
endif endif
.PHONY: initrd PHONY += initrd
initrd: initrd:
@test "$(INITRD_PHYS)" != "" || \ @test "$(INITRD_PHYS)" != "" || \
(echo This machine does not support INITRD; exit -1) (echo This machine does not support INITRD; exit -1)

View File

@ -99,8 +99,8 @@ AFLAGS += $(mflags-y)
boot := arch/i386/boot boot := arch/i386/boot
.PHONY: zImage bzImage compressed zlilo bzlilo \ PHONY += zImage bzImage compressed zlilo bzlilo \
zdisk bzdisk fdimage fdimage144 fdimage288 install zdisk bzdisk fdimage fdimage144 fdimage288 install
all: bzImage all: bzImage

View File

@ -1,6 +1,9 @@
# #
# ia64/Makefile # ia64/Makefile
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public # This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive # License. See the file "COPYING" in the main directory of this archive
# for more details. # for more details.
@ -62,7 +65,7 @@ drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/
boot := arch/ia64/hp/sim/boot boot := arch/ia64/hp/sim/boot
.PHONY: boot compressed check PHONY += boot compressed check
all: compressed unwcheck all: compressed unwcheck

View File

@ -1,6 +1,9 @@
# #
# m32r/Makefile # m32r/Makefile
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
LDFLAGS := LDFLAGS :=
OBJCOPYFLAGS := -O binary -R .note -R .comment -S OBJCOPYFLAGS := -O binary -R .note -R .comment -S
@ -39,7 +42,7 @@ drivers-$(CONFIG_OPROFILE) += arch/m32r/oprofile/
boot := arch/m32r/boot boot := arch/m32r/boot
.PHONY: zImage PHONY += zImage
all: zImage all: zImage

View File

@ -150,7 +150,7 @@ CPPFLAGS_vmlinux.lds := -Upowerpc
BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage
.PHONY: $(BOOT_TARGETS) PHONY += $(BOOT_TARGETS)
boot := arch/$(ARCH)/boot boot := arch/$(ARCH)/boot

View File

@ -82,7 +82,7 @@ drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm
.PHONY: $(BOOT_TARGETS) PHONY += $(BOOT_TARGETS)
all: uImage zImage all: uImage zImage

View File

@ -1,6 +1,9 @@
# #
# arch/ppc/boot/Makefile # arch/ppc/boot/Makefile
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public # This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive # License. See the file "COPYING" in the main directory of this archive
# for more details. # for more details.
@ -25,7 +28,7 @@ subdir- += simple openfirmware
hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree)
.PHONY: $(BOOT_TARGETS) $(bootdir-y) PHONY += $(BOOT_TARGETS) $(bootdir-y)
$(BOOT_TARGETS): $(bootdir-y) $(BOOT_TARGETS): $(bootdir-y)

View File

@ -1,5 +1,8 @@
# Makefile for making bootable images on various OpenFirmware machines. # Makefile for making bootable images on various OpenFirmware machines.
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
# Paul Mackerras January 1997 # Paul Mackerras January 1997
# XCOFF bootable images for PowerMacs # XCOFF bootable images for PowerMacs
# Geert Uytterhoeven September 1997 # Geert Uytterhoeven September 1997
@ -86,7 +89,7 @@ $(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \
# The targets used on the make command-line # The targets used on the make command-line
.PHONY: zImage zImage.initrd PHONY += zImage zImage.initrd
zImage: $(images)/zImage.chrp \ zImage: $(images)/zImage.chrp \
$(images)/zImage.chrp-rs6k $(images)/zImage.chrp-rs6k
@echo ' kernel: $@ is ready ($<)' @echo ' kernel: $@ is ready ($<)'
@ -96,7 +99,7 @@ zImage.initrd: $(images)/zImage.initrd.chrp \
TFTPIMAGE := /tftpboot/zImage TFTPIMAGE := /tftpboot/zImage
.PHONY: znetboot znetboot.initrd PHONY += znetboot znetboot.initrd
znetboot: $(images)/zImage.chrp znetboot: $(images)/zImage.chrp
cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END) cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END)
@echo ' kernel: $@ is ready ($<)' @echo ' kernel: $@ is ready ($<)'

View File

@ -172,7 +172,7 @@ include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/MARKER
archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach
.PHONY: maketools FORCE PHONY += maketools FORCE
maketools: include/linux/version.h FORCE maketools: include/linux/version.h FORCE
$(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h

View File

@ -1,4 +1,7 @@
# #
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
# Copyright (C) 2002 Jeff Dike (jdike@karaya.com) # Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
# Licensed under the GPL # Licensed under the GPL
# #
@ -88,7 +91,7 @@ CONFIG_KERNEL_HALF_GIGS ?= 0
SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
.PHONY: linux PHONY += linux
all: linux all: linux

View File

@ -67,8 +67,8 @@ drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/
boot := arch/x86_64/boot boot := arch/x86_64/boot
.PHONY: bzImage bzlilo install archmrproper \ PHONY += bzImage bzlilo install archmrproper \
fdimage fdimage144 fdimage288 archclean fdimage fdimage144 fdimage288 archclean
#Default target when executing "make" #Default target when executing "make"
all: bzImage all: bzImage

View File

@ -116,16 +116,18 @@ make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
# function to only execute the passed command if necessary # function to only execute the passed command if necessary
# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
# #
if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
@set -e; \ @set -e; \
$(echo-cmd) $(cmd_$(1)); \ $(echo-cmd) $(cmd_$(1)); \
echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd) echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
# execute the command and also postprocess generated .d dependencies # execute the command and also postprocess generated .d dependencies
# file # file
if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ $(filter-out FORCE $(wildcard $^),$^) \
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
@set -e; \ @set -e; \
$(echo-cmd) $(cmd_$(1)); \ $(echo-cmd) $(cmd_$(1)); \
scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
@ -135,6 +137,7 @@ if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
# Usage: $(call if_changed_rule,foo) # Usage: $(call if_changed_rule,foo)
# will check if $(cmd_foo) changed, or any of the prequisites changed, # will check if $(cmd_foo) changed, or any of the prequisites changed,
# and if so will execute $(rule_foo) # and if so will execute $(rule_foo)
if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
@set -e; \ @set -e; \
$(rule_$(1))) $(rule_$(1)))

View File

@ -4,7 +4,7 @@
src := $(obj) src := $(obj)
.PHONY: __build PHONY := __build
__build: __build:
# Read .config if it exist, otherwise ignore # Read .config if it exist, otherwise ignore
@ -308,14 +308,14 @@ targets += $(multi-used-y) $(multi-used-m)
# Descending # Descending
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
.PHONY: $(subdir-ym) PHONY += $(subdir-ym)
$(subdir-ym): $(subdir-ym):
$(Q)$(MAKE) $(build)=$@ $(Q)$(MAKE) $(build)=$@
# Add FORCE to the prequisites of a target to force it to be always rebuilt. # Add FORCE to the prequisites of a target to force it to be always rebuilt.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
.PHONY: FORCE PHONY += FORCE
FORCE: FORCE:
@ -330,3 +330,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
ifneq ($(cmd_files),) ifneq ($(cmd_files),)
include $(cmd_files) include $(cmd_files)
endif endif
# Declare the contents of the .PHONY variable as phony. We keep that
# information in a variable se we can use it in if_changed and friends.
.PHONY: $(PHONY)

View File

@ -4,7 +4,7 @@
src := $(obj) src := $(obj)
.PHONY: __clean PHONY := __clean
__clean: __clean:
# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
@ -87,10 +87,16 @@ endif
# Descending # Descending
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
.PHONY: $(subdir-ymn) PHONY += $(subdir-ymn)
$(subdir-ymn): $(subdir-ymn):
$(Q)$(MAKE) $(clean)=$@ $(Q)$(MAKE) $(clean)=$@
# If quiet is set, only print short version of command # If quiet is set, only print short version of command
cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
# Declare the contents of the .PHONY variable as phony. We keep that
# information in a variable se we can use it in if_changed and friends.
.PHONY: $(PHONY)

View File

@ -2,7 +2,7 @@
# Installing modules # Installing modules
# ========================================================================== # ==========================================================================
.PHONY: __modinst PHONY := __modinst
__modinst: __modinst:
include scripts/Kbuild.include include scripts/Kbuild.include
@ -12,7 +12,7 @@ include scripts/Kbuild.include
__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
.PHONY: $(modules) PHONY += $(modules)
__modinst: $(modules) __modinst: $(modules)
@: @:
@ -27,3 +27,9 @@ modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
$(modules): $(modules):
$(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) $(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
# Declare the contents of the .PHONY variable as phony. We keep that
# information in a variable se we can use it in if_changed and friends.
.PHONY: $(PHONY)

View File

@ -32,7 +32,7 @@
# Step 4 is solely used to allow module versioning in external modules, # Step 4 is solely used to allow module versioning in external modules,
# where the CRC of each module is retrieved from the Module.symers file. # where the CRC of each module is retrieved from the Module.symers file.
.PHONY: _modpost PHONY := _modpost
_modpost: __modpost _modpost: __modpost
include .config include .config
@ -60,7 +60,7 @@ quiet_cmd_modpost = MODPOST
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
$(filter-out FORCE,$^) $(filter-out FORCE,$^)
.PHONY: __modpost PHONY += __modpost
__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
$(call cmd,modpost) $(call cmd,modpost)
@ -97,7 +97,7 @@ targets += $(modules)
# Add FORCE to the prequisites of a target to force it to be always rebuilt. # Add FORCE to the prequisites of a target to force it to be always rebuilt.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
.PHONY: FORCE PHONY += FORCE
FORCE: FORCE:
@ -112,3 +112,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
ifneq ($(cmd_files),) ifneq ($(cmd_files),)
include $(cmd_files) include $(cmd_files)
endif endif
# Declare the contents of the .PHONY variable as phony. We keep that
# information in a variable se we can use it in if_changed and friends.
.PHONY: $(PHONY)

View File

@ -2,7 +2,7 @@
# Kernel configuration targets # Kernel configuration targets
# These targets are used from top-level makefile # These targets are used from top-level makefile
.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
xconfig: $(obj)/qconf xconfig: $(obj)/qconf
$< arch/$(ARCH)/Kconfig $< arch/$(ARCH)/Kconfig
@ -42,7 +42,7 @@ update-po-config: $(obj)/kxgettext
$(Q)rm -f arch/um/Kconfig_arch $(Q)rm -f arch/um/Kconfig_arch
$(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
randconfig: $(obj)/conf randconfig: $(obj)/conf
$< -r arch/$(ARCH)/Kconfig $< -r arch/$(ARCH)/Kconfig

View File

@ -7,10 +7,10 @@ check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh
# we really need to do so. (Do not call gcc as part of make mrproper) # we really need to do so. (Do not call gcc as part of make mrproper)
HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
HOST_EXTRACFLAGS += -DLOCALE
.PHONY: dochecklxdialog HOST_EXTRACFLAGS += -DLOCALE
PHONY += dochecklxdialog
$(obj)/dochecklxdialog: $(obj)/dochecklxdialog:
$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)

View File

@ -32,7 +32,7 @@ MKSPEC := $(srctree)/scripts/package/mkspec
PREV := set -e; cd ..; PREV := set -e; cd ..;
# rpm-pkg # rpm-pkg
.PHONY: rpm-pkg rpm PHONY += rpm-pkg rpm
$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
$(CONFIG_SHELL) $(MKSPEC) > $@ $(CONFIG_SHELL) $(MKSPEC) > $@
@ -54,10 +54,10 @@ rpm-pkg rpm: $(objtree)/kernel.spec
clean-files := $(objtree)/kernel.spec clean-files := $(objtree)/kernel.spec
# binrpm-pkg # binrpm-pkg
.PHONY: binrpm-pkg PHONY += binrpm-pkg
$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
binrpm-pkg: $(objtree)/binkernel.spec binrpm-pkg: $(objtree)/binkernel.spec
$(MAKE) KBUILD_SRC= $(MAKE) KBUILD_SRC=
set -e; \ set -e; \
@ -72,7 +72,7 @@ clean-files += $(objtree)/binkernel.spec
# Deb target # Deb target
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
.PHONY: deb-pkg PHONY += deb-pkg
deb-pkg: deb-pkg:
$(MAKE) KBUILD_SRC= $(MAKE) KBUILD_SRC=
$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
@ -82,7 +82,7 @@ clean-dirs += $(objtree)/debian/
# tarball targets # tarball targets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
.PHONY: tar%pkg PHONY += tar%pkg
tar%pkg: tar%pkg:
$(MAKE) KBUILD_SRC= $(MAKE) KBUILD_SRC=
$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@