1VERSION = 2 2PATCHLEVEL = 5 3SUBLEVEL = 39 4EXTRAVERSION = 5 6# *DOCUMENTATION* 7# Too see a list of typical targets execute "make help" 8# More info can be located in ./Documentation/kbuild 9# Comments in this file is targeted only to the developer, do not 10# expect to learn how to build the kernel reading this file. 11 12# We are using a recursive build, so we need to do a little thinking 13# to get the ordering right. 14# 15# Most importantly: sub-Makefiles should only ever modify files in 16# their own directory. If in some directory we have a dependency on 17# a file in another dir (which doesn't happen often, but it's of 18# unavoidable when linking the built-in.o targets which finally 19# turn into vmlinux), we will call a sub make in that other dir, and 20# after that we are sure that everything which is in that other dir 21# is now up to date. 22# 23# The only cases where we need to modify files which have global 24# effects are thus separated out and done before the recursive 25# descending is started. They are now explicitly listed as the 26# prepare rule. 27 28KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) 29 30# SUBARCH tells the usermode build what the underlying arch is. That is set 31# first, and if a usermode build is happening, the "ARCH=um" on the command 32# line overrides the setting of ARCH below. If a native build is happening, 33# then ARCH is assigned, getting whatever value it gets normally, and 34# SUBARCH is subsequently ignored. 35 36SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) 37ARCH := $(SUBARCH) 38 39KERNELPATH=kernel-$(shell echo $(KERNELRELEASE) | sed -e "s/-//g") 40 41CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 42 else if [ -x /bin/bash ]; then echo /bin/bash; \ 43 else echo sh; fi ; fi) 44TOPDIR := $(CURDIR) 45 46HOSTCC = gcc 47HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 48 49CROSS_COMPILE = 50 51# That's our default target when none is given on the command line 52 53all: vmlinux 54 55# Print entire command lines instead of short version 56# For now, leave the default 57 58ifndef KBUILD_VERBOSE 59 KBUILD_VERBOSE = 1 60endif 61 62# Decide whether to build built-in, modular, or both. 63# Normally, just do built-in. 64 65KBUILD_MODULES := 66KBUILD_BUILTIN := 1 67 68# If we have only "make modules", don't compile built-in objects. 69 70ifeq ($(MAKECMDGOALS),modules) 71 KBUILD_BUILTIN := 72endif 73 74# If we have "make <whatever> modules", compile modules 75# in addition to whatever we do anyway. 76 77ifneq ($(filter modules,$(MAKECMDGOALS)),) 78 KBUILD_MODULES := 1 79endif 80 81# Just "make" or "make all" shall build modules as well 82 83ifeq ($(MAKECMDGOALS),) 84 KBUILD_MODULES := 1 85endif 86 87ifneq ($(filter all,$(MAKECMDGOALS)),) 88 KBUILD_MODULES := 1 89endif 90 91export KBUILD_MODULES KBUILD_BUILTIN 92 93# Beautify output 94# --------------------------------------------------------------------------- 95# 96# Normally, we echo the whole command before executing it. By making 97# that echo $($(quiet)$(cmd)), we now have the possibility to set 98# $(quiet) to choose other forms of output instead, e.g. 99# 100# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ 101# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 102# 103# If $(quiet) is empty, the whole command will be printed. 104# If it is set to "quiet_", only the short version will be printed. 105# If it is set to "silent_", nothing wil be printed at all, since 106# the variable $(silent_cmd_cc_o_c) doesn't exist. 107 108# If the user wants quiet mode, echo short versions of the commands 109# only and suppress the 'Entering/Leaving directory' messages 110 111ifneq ($(KBUILD_VERBOSE),1) 112 quiet=quiet_ 113 MAKEFLAGS += --no-print-directory 114endif 115 116# If the user is running make -s (silent mode), suppress echoing of 117# commands 118 119ifneq ($(findstring s,$(MAKEFLAGS)),) 120 quiet=silent_ 121endif 122 123export quiet 124 125# 126# Include the make variables (CC, etc...) 127# 128 129AS = $(CROSS_COMPILE)as 130LD = $(CROSS_COMPILE)ld 131CC = $(CROSS_COMPILE)gcc 132CPP = $(CC) -E 133AR = $(CROSS_COMPILE)ar 134NM = $(CROSS_COMPILE)nm 135STRIP = $(CROSS_COMPILE)strip 136OBJCOPY = $(CROSS_COMPILE)objcopy 137OBJDUMP = $(CROSS_COMPILE)objdump 138MAKEFILES = $(TOPDIR)/.config 139GENKSYMS = /sbin/genksyms 140DEPMOD = /sbin/depmod 141KALLSYMS = /sbin/kallsyms 142PERL = perl 143MODFLAGS = -DMODULE 144CFLAGS_MODULE = $(MODFLAGS) 145AFLAGS_MODULE = $(MODFLAGS) 146CFLAGS_KERNEL = 147AFLAGS_KERNEL = 148EXPORT_FLAGS = 149NOSTDINC_FLAGS = -nostdinc -iwithprefix include 150 151export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ 152 CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ 153 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL 154 155export CPPFLAGS EXPORT_FLAGS NOSTDINC_FLAGS OBJCOPYFLAGS 156export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 157export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 158 159src := . 160obj := . 161srctree := $(TOPDIR) 162objtree := $(TOPDIR) 163 164export srctree objtree 165 166# The temporary file to save gcc -MD generated dependencies must not 167# contain a comma 168depfile = $(subst $(comma),_,$(@D)/.$(@F).d) 169 170noconfig_targets := xconfig menuconfig config oldconfig randconfig \ 171 defconfig allyesconfig allnoconfig allmodconfig \ 172 clean mrproper distclean \ 173 help tags TAGS sgmldocs psdocs pdfdocs htmldocs \ 174 checkconfig checkhelp checkincludes 175 176RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o 177RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS 178 179# Helpers built in scripts/ 180# --------------------------------------------------------------------------- 181 182scripts/docproc scripts/fixdep scripts/split-include : scripts ; 183 184.PHONY: scripts 185scripts: 186 @$(MAKE) -C scripts 187 188ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) 189 190# Here goes the main Makefile 191# =========================================================================== 192# 193# If the user gave a *config target, it'll be handled in another 194# section below, since in this case we cannot include .config 195# Same goes for other targets like clean/mrproper etc, which 196# don't need .config, either 197 198# In this section, we need .config 199 200-include .config 201 202# If .config doesn't exist - tough luck 203 204.config: arch/$(ARCH)/config.in $(shell find . -name Config.in) 205 @echo '***' 206 @if [ -f $@ ]; then \ 207 echo '*** The tree was updated, so your .config may be'; \ 208 echo '*** out of date!'; \ 209 else \ 210 echo '*** You have not yet configured your kernel!'; \ 211 fi 212 @echo '***' 213 @echo '*** Please run some configurator (e.g. "make oldconfig" or' 214 @echo '*** "make menuconfig" or "make xconfig").' 215 @echo '***' 216 @exit 1 217 218# 219# INSTALL_PATH specifies where to place the updated kernel and system map 220# images. Uncomment if you want to place them anywhere other than root. 221# 222 223#export INSTALL_PATH=/boot 224 225# 226# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 227# relocations required by build roots. This is not defined in the 228# makefile but the arguement can be passed to make if needed. 229# 230 231MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) 232export MODLIB 233 234# 235# standard CFLAGS 236# 237 238CPPFLAGS := -D__KERNEL__ -I$(objtree)/include 239 240CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \ 241 -fomit-frame-pointer -fno-strict-aliasing -fno-common 242AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS) 243 244ifdef CONFIG_MODULES 245EXPORT_FLAGS := -DEXPORT_SYMTAB 246endif 247 248# Link components for vmlinux 249# --------------------------------------------------------------------------- 250 251init-y := init/ 252drivers-y := drivers/ sound/ 253networks-y := net/ 254libs-y := lib/ 255 256CORE_FILES := kernel/built-in.o mm/built-in.o fs/built-in.o \ 257 ipc/built-in.o security/built-in.o 258SUBDIRS += kernel mm fs ipc security 259 260include arch/$(ARCH)/Makefile 261 262SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m))) 263INIT += $(patsubst %/, %/built-in.o, $(init-y)) 264 265SUBDIRS += $(patsubst %/,%,$(filter %/, $(core-y) $(core-m))) 266CORE_FILES := $(patsubst %/, %/built-in.o, $(core-y)) $(CORE_FILES) 267 268SUBDIRS += $(patsubst %/,%,$(filter %/, $(drivers-y) $(drivers-m))) 269DRIVERS += $(patsubst %/, %/built-in.o, $(drivers-y)) 270 271SUBDIRS += $(patsubst %/,%,$(filter %/, $(networks-y) $(networks-m))) 272NETWORKS += $(patsubst %/, %/built-in.o, $(networks-y)) 273 274SUBDIRS += $(patsubst %/,%,$(filter %/, $(libs-y) $(libs-m))) 275LIBS += $(patsubst %/, %/lib.a, $(libs-y)) 276 277export NETWORKS DRIVERS LIBS HEAD LDFLAGS MAKEBOOT 278 279# boot target 280# --------------------------------------------------------------------------- 281 282boot: vmlinux 283 @$(MAKE) -C arch/$(ARCH)/boot 284 285# Build vmlinux 286# --------------------------------------------------------------------------- 287 288# This is a bit tricky: If we need to relink vmlinux, we want 289# the version number incremented, which means recompile init/version.o 290# and relink init/init.o. However, we cannot do this during the 291# normal descending-into-subdirs phase, since at that time 292# we cannot yet know if we will need to relink vmlinux. 293# So we descend into init/ inside the rule for vmlinux again. 294 295vmlinux-objs := $(HEAD) $(INIT) $(CORE_FILES) $(LIBS) $(DRIVERS) $(NETWORKS) 296 297quiet_cmd_link_vmlinux = LD $@ 298define cmd_link_vmlinux 299 $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(HEAD) $(INIT) \ 300 --start-group \ 301 $(CORE_FILES) \ 302 $(LIBS) \ 303 $(DRIVERS) \ 304 $(NETWORKS) \ 305 --end-group \ 306 $(filter $(kallsyms.o),$^) \ 307 -o $@ 308endef 309 310# set -e makes the rule exit immediately on error 311 312define rule_vmlinux 313 set -e 314 echo ' Generating build number' 315 . scripts/mkversion > .tmp_version 316 mv -f .tmp_version .version 317 +$(MAKE) -C init 318 $(call cmd,link_vmlinux) 319 echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd 320 $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map 321endef 322 323LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s 324 325# Generate section listing all symbols and add it into vmlinux 326 327ifdef CONFIG_KALLSYMS 328 329kallsyms.o := .tmp_kallsyms.o 330 331quiet_cmd_kallsyms = KSYM $@ 332cmd_kallsyms = $(KALLSYMS) $< > $@ 333 334.tmp_kallsyms.o: .tmp_vmlinux 335 $(call cmd,kallsyms) 336 337# After generating .tmp_vmlinux just like vmlinux, decrement the version 338# number again, so the final vmlinux gets the same one. 339# Ignore return value of 'expr'. 340 341define rule_.tmp_vmlinux 342 $(rule_vmlinux) 343 if expr 0`cat .version` - 1 > .tmp_version; then true; fi 344 mv -f .tmp_version .version 345endef 346 347.tmp_vmlinux: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE 348 $(call if_changed_rule,.tmp_vmlinux) 349 350endif 351 352# Finally the vmlinux rule 353 354vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/vmlinux.lds.s FORCE 355 $(call if_changed_rule,vmlinux) 356 357# The actual objects are generated when descending, 358# make sure no implicit rule kicks in 359 360$(sort $(vmlinux-objs)): $(SUBDIRS) ; 361 362# Handle descending into subdirectories listed in $(SUBDIRS) 363 364.PHONY: $(SUBDIRS) 365$(SUBDIRS): .hdepend prepare 366 @$(MAKE) -C $@ 367 368# Things we need done before we descend to build or make 369# module versions are listed in "prepare" 370 371.PHONY: prepare 372prepare: include/linux/version.h include/asm include/config/MARKER 373 @echo ' Starting the build. KBUILD_BUILTIN=$(KBUILD_BUILTIN) KBUILD_MODULES=$(KBUILD_MODULES)' 374 375# This can be used by arch/$ARCH/Makefile to preprocess 376# their vmlinux.lds.S file 377 378AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH) 379 380arch/$(ARCH)/vmlinux.lds.s: arch/$(ARCH)/vmlinux.lds.S scripts FORCE 381 $(call if_changed_dep,as_s_S) 382 383targets += arch/$(ARCH)/vmlinux.lds.s 384 385# Single targets 386# --------------------------------------------------------------------------- 387 388%.s: %.c FORCE 389 @$(MAKE) -C $(@D) $(@F) 390%.i: %.c FORCE 391 @$(MAKE) -C $(@D) $(@F) 392%.o: %.c FORCE 393 @$(MAKE) -C $(@D) $(@F) 394%.lst: %.c FORCE 395 @$(MAKE) -C $(@D) $(@F) 396%.s: %.S FORCE 397 @$(MAKE) -C $(@D) $(@F) 398%.o: %.S FORCE 399 @$(MAKE) -C $(@D) $(@F) 400 401# FIXME: The asm symlink changes when $(ARCH) changes. That's 402# hard to detect, but I suppose "make mrproper" is a good idea 403# before switching between archs anyway. 404 405include/asm: 406 @echo ' Making asm->asm-$(ARCH) symlink' 407 @ln -s asm-$(ARCH) $@ 408 409# Split autoconf.h into include/linux/config/* 410 411include/config/MARKER: scripts/split-include include/linux/autoconf.h 412 @echo ' SPLIT include/linux/autoconf.h -> include/config/*' 413 @scripts/split-include include/linux/autoconf.h include/config 414 @touch $@ 415 416# if .config is newer than include/linux/autoconf.h, someone tinkered 417# with it and forgot to run make oldconfig 418 419include/linux/autoconf.h: .config 420 @echo '***' 421 @echo '*** You changed .config w/o running make *config?' 422 @echo '*** Please run "make oldconfig"' 423 @echo '***' 424 @exit 1 425 426# Generate some files 427# --------------------------------------------------------------------------- 428 429# version.h changes when $(KERNELRELEASE) etc change, as defined in 430# this Makefile 431 432uts_len := 64 433 434include/linux/version.h: Makefile 435 @if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \ 436 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ 437 exit 1; \ 438 fi; 439 @echo -n ' Generating $@' 440 @(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \ 441 echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \ 442 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \ 443 ) > $@.tmp 444 @$(update-if-changed) 445 446# Generate module versions 447# --------------------------------------------------------------------------- 448 449# The targets are still named depend / dep for traditional 450# reasons, but the only thing we do here is generating 451# the module version checksums. 452 453.PHONY: depend dep $(patsubst %,_sfdep_%,$(SUBDIRS)) 454 455depend dep: .hdepend 456 457# .hdepend is our (misnomed) marker for whether we've run 458# generated module versions 459 460.hdepend: $(if $(filter dep depend,$(MAKECMDGOALS)),FORCE) 461 @$(MAKE) include/linux/modversions.h 462 @touch $@ 463 464ifdef CONFIG_MODVERSIONS 465 466# Update modversions.h, but only if it would change. 467 468include/linux/modversions.h: scripts/fixdep prepare FORCE 469 @rm -rf .tmp_export-objs 470 @$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) 471 @echo -n ' Generating $@' 472 @( echo "#ifndef _LINUX_MODVERSIONS_H";\ 473 echo "#define _LINUX_MODVERSIONS_H"; \ 474 echo "#include <linux/modsetver.h>"; \ 475 cd .tmp_export-objs >/dev/null; \ 476 for f in `find modules -name \*.ver -print | sort`; do \ 477 echo "#include <linux/$${f}>"; \ 478 done; \ 479 echo "#endif"; \ 480 ) > $@.tmp; \ 481 $(update-if-changed) 482 483$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE 484 @$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep 485 486else # !CONFIG_MODVERSIONS 487 488.PHONY: include/linux/modversions.h 489 490include/linux/modversions.h: 491 492endif # CONFIG_MODVERSIONS 493 494# --------------------------------------------------------------------------- 495# Modules 496 497ifdef CONFIG_MODULES 498 499# Build modules 500 501ifdef CONFIG_MODVERSIONS 502MODFLAGS += -include $(objtree)/include/linux/modversions.h 503endif 504 505.PHONY: modules 506modules: $(SUBDIRS) 507 508# Install modules 509 510.PHONY: modules_install 511modules_install: _modinst_ $(patsubst %, _modinst_%, $(SUBDIRS)) _modinst_post 512 513.PHONY: _modinst_ 514_modinst_: 515 @rm -rf $(MODLIB)/kernel 516 @rm -f $(MODLIB)/build 517 @mkdir -p $(MODLIB)/kernel 518 @ln -s $(TOPDIR) $(MODLIB)/build 519 520# If System.map exists, run depmod. This deliberately does not have a 521# dependency on System.map since that would run the dependency tree on 522# vmlinux. This depmod is only for convenience to give the initial 523# boot a modules.dep even before / is mounted read-write. However the 524# boot script depmod is the master version. 525ifeq "$(strip $(INSTALL_MOD_PATH))" "" 526depmod_opts := 527else 528depmod_opts := -b $(INSTALL_MOD_PATH) -r 529endif 530.PHONY: _modinst_post 531_modinst_post: 532 if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi 533 534.PHONY: $(patsubst %, _modinst_%, $(SUBDIRS)) 535$(patsubst %, _modinst_%, $(SUBDIRS)) : 536 @$(MAKE) -C $(patsubst _modinst_%, %, $@) modules_install 537 538else # CONFIG_MODULES 539 540# Modules not configured 541# --------------------------------------------------------------------------- 542 543modules modules_install: FORCE 544 @echo 545 @echo "The present kernel configuration has modules disabled." 546 @echo "Type 'make config' and enable loadable module support." 547 @echo "Then build a kernel with module support enabled." 548 @echo 549 @exit 1 550 551endif # CONFIG_MODULES 552 553# Generate asm-offsets.h 554# --------------------------------------------------------------------------- 555 556define generate-asm-offsets.h 557 (set -e; \ 558 echo "#ifndef __ASM_OFFSETS_H__"; \ 559 echo "#define __ASM_OFFSETS_H__"; \ 560 echo "/*"; \ 561 echo " * DO NOT MODIFY."; \ 562 echo " *"; \ 563 echo " * This file was generated by arch/$(ARCH)/Makefile"; \ 564 echo " *"; \ 565 echo " */"; \ 566 echo ""; \ 567 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ 568 echo ""; \ 569 echo "#endif" ) 570endef 571 572# RPM target 573# --------------------------------------------------------------------------- 574 575# If you do a make spec before packing the tarball you can rpm -ta it 576 577spec: 578 . scripts/mkspec >kernel.spec 579 580# Build a tar ball, generate an rpm from it and pack the result 581# There arw two bits of magic here 582# 1) The use of /. to avoid tar packing just the symlink 583# 2) Removing the .dep files as they have source paths in them that 584# will become invalid 585 586rpm: clean spec 587 find . $(RCS_FIND_IGNORE) \ 588 \( -size 0 -o -name .depend -o -name .hdepend \) \ 589 -type f -print | xargs rm -f 590 set -e; \ 591 cd $(TOPDIR)/.. ; \ 592 ln -sf $(TOPDIR) $(KERNELPATH) ; \ 593 tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \ 594 rm $(KERNELPATH) ; \ 595 cd $(TOPDIR) ; \ 596 . scripts/mkversion > .version ; \ 597 rpm -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \ 598 rm $(TOPDIR)/../$(KERNELPATH).tar.gz 599 600else # ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) 601 602ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) 603 604# Targets which don't need .config 605# =========================================================================== 606# 607# These targets basically have their own Makefile - not quite, but at 608# least its own exclusive section in the same Makefile. The reason for 609# this is the following: 610# To know the configuration, the main Makefile has to include 611# .config. That's a obviously a problem when .config doesn't exist 612# yet, but that could be kludged around with only including it if it 613# exists. 614# However, the larger problem is: If you run make *config, make will 615# include the old .config, then execute your *config. It will then 616# notice that a piece it included (.config) did change and restart from 617# scratch. Which will cause execution of *config again. You get the 618# picture. 619# If we don't explicitly let the Makefile know that .config is changed 620# by *config (the old way), it won't reread .config after *config, 621# thus working with possibly stale values - we don't that either. 622# 623# So we divide things: This part here is for making *config targets, 624# and other targets which should work when no .config exists yet. 625# The main part above takes care of the rest after a .config exists. 626 627# Kernel configuration 628# --------------------------------------------------------------------------- 629 630.PHONY: oldconfig xconfig menuconfig config \ 631 make_with_config 632 633xconfig: 634 @$(MAKE) -C scripts kconfig.tk 635 wish -f scripts/kconfig.tk 636 637menuconfig: 638 @$(MAKE) -C scripts lxdialog 639 $(CONFIG_SHELL) $(src)/scripts/Menuconfig arch/$(ARCH)/config.in 640 641config: 642 $(CONFIG_SHELL) $(src)/scripts/Configure arch/$(ARCH)/config.in 643 644oldconfig: 645 $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in 646 647randconfig: 648 $(CONFIG_SHELL) $(src)/scripts/Configure -r arch/$(ARCH)/config.in 649 650allyesconfig: 651 $(CONFIG_SHELL) $(src)/scripts/Configure -y arch/$(ARCH)/config.in 652 653allnoconfig: 654 $(CONFIG_SHELL) $(src)/scripts/Configure -n arch/$(ARCH)/config.in 655 656allmodconfig: 657 $(CONFIG_SHELL) $(src)/scripts/Configure -m arch/$(ARCH)/config.in 658 659defconfig: 660 yes '' | $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in 661 662# Cleaning up 663# --------------------------------------------------------------------------- 664 665# files removed with 'make clean' 666CLEAN_FILES += \ 667 include/linux/compile.h \ 668 vmlinux System.map \ 669 drivers/char/consolemap_deftbl.c drivers/video/promcon_tbl.c \ 670 drivers/char/conmakehash \ 671 drivers/char/drm/*-mod.c \ 672 drivers/char/defkeymap.c drivers/char/qtronixmap.c \ 673 drivers/pci/devlist.h drivers/pci/classlist.h drivers/pci/gen-devlist \ 674 drivers/zorro/devlist.h drivers/zorro/gen-devlist \ 675 sound/oss/bin2hex sound/oss/hex2hex \ 676 drivers/atm/fore200e_mkfirm drivers/atm/{pca,sba}*{.bin,.bin1,.bin2} \ 677 drivers/scsi/aic7xxx/aic7xxx_seq.h \ 678 drivers/scsi/aic7xxx/aic7xxx_reg.h \ 679 drivers/scsi/aic7xxx/aicasm/aicasm_gram.c \ 680 drivers/scsi/aic7xxx/aicasm/aicasm_scan.c \ 681 drivers/scsi/aic7xxx/aicasm/y.tab.h \ 682 drivers/scsi/aic7xxx/aicasm/aicasm \ 683 drivers/scsi/53c700_d.h drivers/scsi/sim710_d.h \ 684 drivers/scsi/53c7xx_d.h drivers/scsi/53c7xx_u.h \ 685 drivers/scsi/53c8xx_d.h drivers/scsi/53c8xx_u.h \ 686 net/802/cl2llc.c net/802/transit/pdutr.h net/802/transit/timertr.h \ 687 net/802/pseudo/pseudocode.h \ 688 net/khttpd/make_times_h net/khttpd/times.h \ 689 submenu* 690 691# files removed with 'make mrproper' 692MRPROPER_FILES += \ 693 include/linux/autoconf.h include/linux/version.h \ 694 drivers/net/hamradio/soundmodem/sm_tbl_{afsk1200,afsk2666,fsk9600}.h \ 695 drivers/net/hamradio/soundmodem/sm_tbl_{hapn4800,psk4800}.h \ 696 drivers/net/hamradio/soundmodem/sm_tbl_{afsk2400_7,afsk2400_8}.h \ 697 drivers/net/hamradio/soundmodem/gentbl \ 698 sound/oss/*_boot.h sound/oss/.*.boot \ 699 sound/oss/msndinit.c \ 700 sound/oss/msndperm.c \ 701 sound/oss/pndsperm.c \ 702 sound/oss/pndspini.c \ 703 drivers/atm/fore200e_*_fw.c drivers/atm/.fore200e_*.fw \ 704 .version .config* config.in config.old \ 705 .menuconfig.log \ 706 include/asm \ 707 .hdepend $(TOPDIR)/include/linux/modversions.h \ 708 tags TAGS kernel.spec \ 709 .tmpversion 710 711# directories removed with 'make mrproper' 712MRPROPER_DIRS += \ 713 .tmp_export-objs \ 714 include/config \ 715 $(TOPDIR)/include/linux/modules 716 717# That's our way to know about arch specific cleanup. 718 719include arch/$(ARCH)/Makefile 720 721clean: archclean 722 @echo 'Cleaning up' 723 @find . $(RCS_FIND_IGNORE) \ 724 \( -name \*.[oas] -o -name core -o -name .\*.cmd -o \ 725 -name .\*.tmp -o -name .\*.d \) -type f -print \ 726 | grep -v lxdialog/ | xargs rm -f 727 @rm -f $(CLEAN_FILES) 728 @$(MAKE) -f Documentation/DocBook/Makefile clean 729 730mrproper: clean archmrproper 731 @echo 'Making mrproper' 732 @find . $(RCS_FIND_IGNORE) \ 733 \( -name .depend -o -name .\*.cmd \) \ 734 -type f -print | xargs rm -f 735 @rm -f $(MRPROPER_FILES) 736 @rm -rf $(MRPROPER_DIRS) 737 @$(MAKE) -C scripts mrproper 738 @$(MAKE) -f Documentation/DocBook/Makefile mrproper 739 740distclean: mrproper 741 @echo 'Making distclean' 742 @find . $(RCS_FIND_IGNORE) \ 743 \( -not -type d \) -and \ 744 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 745 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ 746 -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -type f \ 747 -print | xargs rm -f 748 749# Generate tags for editors 750# --------------------------------------------------------------------------- 751 752define all-sources 753 ( find . $(RCS_FIND_IGNORE) \ 754 \( -name include -o -name arch \) -prune -o \ 755 -name '*.[chS]' -print; \ 756 find arch/$(ARCH) $(RCS_FIND_IGNORE) \ 757 -name '*.[chS]' -print; \ 758 find include $(RCS_FIND_IGNORE) \ 759 \( -name config -o -name 'asm-*' \) -prune -o \ 760 -o -name '*.[chS]' -print; \ 761 find include/asm-$(ARCH) $(RCS_FIND_IGNORE) \ 762 -name '*.[chS]' -print; \ 763 find include/asm-generic $(RCS_FIND_IGNORE) \ 764 -name '*.[chS]' -print ) 765endef 766 767quiet_cmd_TAGS = MAKE $@ 768cmd_TAGS = $(all-sources) | etags - 769 770# Exuberant ctags works better with -I 771 772quiet_cmd_tags = MAKE $@ 773define cmd_tags 774 rm -f $@; \ 775 CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \ 776 $(all-sources) | xargs ctags $$CTAGSF -a 777endef 778 779TAGS: FORCE 780 $(call cmd,TAGS) 781 782tags: FORCE 783 $(call cmd,tags) 784 785# Brief documentation of the typical targets used 786# --------------------------------------------------------------------------- 787 788help: 789 @echo 'Cleaning targets:' 790 @echo ' clean - remove most generated files but keep the config' 791 @echo ' mrproper - remove all generated files including the config' 792 @echo ' distclean - mrproper + remove files generated by editors and patch' 793 @echo '' 794 @echo 'Configuration targets:' 795 @echo ' oldconfig - Update current config utilising a line-oriented program' 796 @echo ' menuconfig - Update current config utilising a menu based program' 797 @echo ' xconfig - Update current config utilising a X-based program' 798 @echo ' defconfig - New config with default answer to all options' 799 @echo ' allmodconfig - New config selecting modules when possible' 800 @echo ' allyesconfig - New config where all options are accepted with yes' 801 @echo ' allnoconfig - New minimal config' 802 @echo '' 803 @echo 'Other generic targets:' 804 @echo ' all - Build all targets marked with [*]' 805 @echo ' dep - Create module version information' 806 @echo '* vmlinux - Build the bare kernel' 807 @echo '* modules - Build all modules' 808 @echo ' dir/file.[ois]- Build specified target only' 809 @echo ' rpm - Build a kernel as an RPM package' 810 @echo ' tags/TAGS - Generate tags file for editors' 811 @echo '' 812 @echo 'Documentation targets:' 813 @$(MAKE) --no-print-directory -f Documentation/DocBook/Makefile dochelp 814 @echo '' 815 @echo 'Architecture specific targets ($(ARCH)):' 816 @$(MAKE) --no-print-directory -f arch/$(ARCH)/boot/Makefile archhelp 817 @echo '' 818 @echo 'Execute "make" or "make all" to build all targets marked with [*] ' 819 @echo 'For further info browse Documentation/kbuild/*' 820 821 822# Documentation targets 823# --------------------------------------------------------------------------- 824sgmldocs psdocs pdfdocs htmldocs: scripts 825 @$(MAKE) -f Documentation/DocBook/Makefile $@ 826 827# Scripts to check various things for consistency 828# --------------------------------------------------------------------------- 829 830checkconfig: 831 find * $(RCS_FIND_IGNORE) \ 832 -name '*.[hcS]' -type f -print | sort \ 833 | xargs $(PERL) -w scripts/checkconfig.pl 834 835checkhelp: 836 find * $(RCS_FIND_IGNORE) \ 837 -name [cC]onfig.in -print | sort \ 838 | xargs $(PERL) -w scripts/checkhelp.pl 839 840checkincludes: 841 find * $(RCS_FIND_IGNORE) \ 842 -name '*.[hcS]' -type f -print | sort \ 843 | xargs $(PERL) -w scripts/checkincludes.pl 844 845else # ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) 846 847# We're called with both targets which do and do not need 848# .config included. Handle them one after the other. 849# =========================================================================== 850 851%:: FORCE 852 $(MAKE) $@ 853 854endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) 855endif # ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) 856 857# FIXME Should go into a make.lib or something 858# =========================================================================== 859echo_target = $@ 860 861a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \ 862 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) 863 864quiet_cmd_as_s_S = CPP $(echo_target) 865cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< 866 867# read all saved command lines 868 869targets := $(wildcard $(sort $(targets))) 870cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) 871 872ifneq ($(cmd_files),) 873 include $(cmd_files) 874endif 875 876# execute the command and also postprocess generated .d dependencies 877# file 878 879if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ 880 $(filter-out $(cmd_$(1)),$(cmd_$@))\ 881 $(filter-out $(cmd_$@),$(cmd_$(1)))),\ 882 @set -e; \ 883 $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ 884 $(cmd_$(1)); \ 885 $(TOPDIR)/scripts/fixdep $(depfile) $@ $(TOPDIR) '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \ 886 rm -f $(depfile); \ 887 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) 888 889# Usage: $(call if_changed_rule,foo) 890# will check if $(cmd_foo) changed, or any of the prequisites changed, 891# and if so will execute $(rule_foo) 892 893if_changed_rule = $(if $(strip $? \ 894 $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\ 895 $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\ 896 @$(rule_$(1))) 897 898# If quiet is set, only print short version of command 899 900cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) 901 902define update-if-changed 903 if [ -r $@ ] && cmp -s $@ $@.tmp; then \ 904 echo ' (unchanged)'; \ 905 rm -f $@.tmp; \ 906 else \ 907 echo ' (updated)'; \ 908 mv -f $@.tmp $@; \ 909 fi 910endef 911 912 913FORCE: 914

