linux-bk/Makefile
<<
>>
Prefs
   1VERSION = 2
   2PATCHLEVEL = 5
   3SUBLEVEL = 56
   4EXTRAVERSION =
   5
   6# *DOCUMENTATION*
   7# To see a list of typical targets execute "make help"
   8# More info can be located in ./Documentation/kbuild
   9# Comments in this file are 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
  41UTS_MACHINE := $(ARCH)
  42
  43CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  44          else if [ -x /bin/bash ]; then echo /bin/bash; \
  45          else echo sh; fi ; fi)
  46TOPDIR  := $(CURDIR)
  47
  48HOSTCC          = gcc
  49HOSTCXX         = g++
  50HOSTCFLAGS      = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  51HOSTCXXFLAGS    = -O2
  52
  53CROSS_COMPILE   =
  54
  55#       That's our default target when none is given on the command line
  56
  57all:    vmlinux
  58
  59#       Decide whether to build built-in, modular, or both.
  60#       Normally, just do built-in.
  61
  62KBUILD_MODULES :=
  63KBUILD_BUILTIN := 1
  64
  65#       If we have only "make modules", don't compile built-in objects.
  66
  67ifeq ($(MAKECMDGOALS),modules)
  68  KBUILD_BUILTIN :=
  69endif
  70
  71#       If we have "make <whatever> modules", compile modules
  72#       in addition to whatever we do anyway.
  73
  74ifneq ($(filter modules,$(MAKECMDGOALS)),)
  75  KBUILD_MODULES := 1
  76endif
  77
  78#       Just "make" or "make all" shall build modules as well
  79
  80ifeq ($(MAKECMDGOALS),)
  81  KBUILD_MODULES := 1
  82endif
  83
  84ifneq ($(filter all,$(MAKECMDGOALS)),)
  85  KBUILD_MODULES := 1
  86endif
  87
  88export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE
  89
  90# Beautify output
  91# ---------------------------------------------------------------------------
  92#
  93# Normally, we echo the whole command before executing it. By making
  94# that echo $($(quiet)$(cmd)), we now have the possibility to set
  95# $(quiet) to choose other forms of output instead, e.g.
  96#
  97#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
  98#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
  99#
 100# If $(quiet) is empty, the whole command will be printed.
 101# If it is set to "quiet_", only the short version will be printed. 
 102# If it is set to "silent_", nothing wil be printed at all, since
 103# the variable $(silent_cmd_cc_o_c) doesn't exist.
 104
 105#       For now, leave verbose as default
 106
 107ifndef KBUILD_VERBOSE
 108  KBUILD_VERBOSE = 1
 109endif
 110
 111MAKEFLAGS += --no-print-directory
 112
 113# For maximum performance (+ possibly random breakage, uncomment
 114# the following)
 115
 116#MAKEFLAGS += -rR
 117
 118#       If the user wants quiet mode, echo short versions of the commands 
 119#       only
 120
 121ifeq ($(KBUILD_VERBOSE),1)
 122  quiet =
 123  Q =
 124else
 125  quiet=quiet_
 126  Q = @
 127endif
 128
 129#       If the user is running make -s (silent mode), suppress echoing of
 130#       commands
 131
 132ifneq ($(findstring s,$(MAKEFLAGS)),)
 133  quiet=silent_
 134endif
 135
 136export quiet Q KBUILD_VERBOSE
 137
 138#       Paths to obj / src tree
 139
 140src     := .
 141obj     := .
 142srctree := .
 143objtree := .
 144
 145export srctree objtree
 146
 147#       Make variables (CC, etc...)
 148
 149AS              = $(CROSS_COMPILE)as
 150LD              = $(CROSS_COMPILE)ld
 151CC              = $(CROSS_COMPILE)gcc
 152CPP             = $(CC) -E
 153AR              = $(CROSS_COMPILE)ar
 154NM              = $(CROSS_COMPILE)nm
 155STRIP           = $(CROSS_COMPILE)strip
 156OBJCOPY         = $(CROSS_COMPILE)objcopy
 157OBJDUMP         = $(CROSS_COMPILE)objdump
 158AWK             = awk
 159GENKSYMS        = /sbin/genksyms
 160DEPMOD          = /sbin/depmod
 161KALLSYMS        = scripts/kallsyms
 162PERL            = perl
 163MODFLAGS        = -DMODULE
 164CFLAGS_MODULE   = $(MODFLAGS)
 165AFLAGS_MODULE   = $(MODFLAGS)
 166LDFLAGS_MODULE  = -r
 167CFLAGS_KERNEL   =
 168AFLAGS_KERNEL   =
 169
 170NOSTDINC_FLAGS  = -nostdinc -iwithprefix include
 171
 172CPPFLAGS        := -D__KERNEL__ -Iinclude
 173CFLAGS          := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
 174                   -fno-strict-aliasing -fno-common
 175AFLAGS          := -D__ASSEMBLY__ $(CPPFLAGS)
 176
 177export  VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
 178        CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
 179        CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
 180        HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE
 181
 182export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
 183export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 
 184export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 185
 186# The temporary file to save gcc -MD generated dependencies must not
 187# contain a comma
 188depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
 189
 190noconfig_targets := xconfig menuconfig config oldconfig randconfig \
 191                    defconfig allyesconfig allnoconfig allmodconfig \
 192                    clean mrproper distclean \
 193                    help tags TAGS sgmldocs psdocs pdfdocs htmldocs \
 194                    checkconfig checkhelp checkincludes
 195
 196RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o
 197RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
 198
 199# Helpers built in scripts/
 200# ---------------------------------------------------------------------------
 201
 202scripts/docproc scripts/fixdep scripts/split-include : scripts ;
 203
 204.PHONY: scripts
 205scripts:
 206        $(Q)$(MAKE) $(build)=scripts
 207
 208# Objects we will link into vmlinux / subdirs we need to visit
 209# ---------------------------------------------------------------------------
 210
 211init-y          := init/
 212drivers-y       := drivers/ sound/
 213net-y           := net/
 214libs-y          := lib/
 215core-y          := usr/
 216SUBDIRS         :=
 217
 218ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
 219
 220export include_config := 1
 221
 222-include .config
 223
 224endif
 225
 226include arch/$(ARCH)/Makefile
 227
 228core-y          += kernel/ mm/ fs/ ipc/ security/ crypto/
 229
 230SUBDIRS         += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 231                     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
 232                     $(net-y) $(net-m) $(libs-y) $(libs-m)))
 233
 234ALL_SUBDIRS     := $(sort $(SUBDIRS) $(patsubst %/,%,$(filter %/, \
 235                     $(init-n) $(init-) \
 236                     $(core-n) $(core-) $(drivers-n) $(drivers-) \
 237                     $(net-n)  $(net-)  $(libs-n)    $(libs-))))
 238
 239init-y          := $(patsubst %/, %/built-in.o, $(init-y))
 240core-y          := $(patsubst %/, %/built-in.o, $(core-y))
 241drivers-y       := $(patsubst %/, %/built-in.o, $(drivers-y))
 242net-y           := $(patsubst %/, %/built-in.o, $(net-y))
 243libs-y          := $(patsubst %/, %/lib.a, $(libs-y))
 244
 245ifdef include_config
 246
 247# Here goes the main Makefile
 248# ===========================================================================
 249#
 250# If the user gave a *config target, it'll be handled in another
 251# section below, since in this case we cannot include .config
 252# Same goes for other targets like clean/mrproper etc, which
 253# don't need .config, either
 254
 255#       In this section, we need .config
 256
 257-include .config.cmd
 258
 259ifdef CONFIG_MODULES
 260export EXPORT_FLAGS := -DEXPORT_SYMTAB
 261endif
 262
 263ifndef CONFIG_FRAME_POINTER
 264CFLAGS          += -fomit-frame-pointer
 265endif
 266
 267#
 268# INSTALL_PATH specifies where to place the updated kernel and system map
 269# images.  Uncomment if you want to place them anywhere other than root.
 270#
 271
 272#export INSTALL_PATH=/boot
 273
 274#
 275# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
 276# relocations required by build roots.  This is not defined in the
 277# makefile but the arguement can be passed to make if needed.
 278#
 279
 280MODLIB  := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
 281export MODLIB
 282
 283# Build vmlinux
 284# ---------------------------------------------------------------------------
 285
 286#       This is a bit tricky: If we need to relink vmlinux, we want
 287#       the version number incremented, which means recompile init/version.o
 288#       and relink init/init.o. However, we cannot do this during the
 289#       normal descending-into-subdirs phase, since at that time
 290#       we cannot yet know if we will need to relink vmlinux.
 291#       So we descend into init/ inside the rule for vmlinux again.
 292
 293vmlinux-objs := $(HEAD) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y)
 294
 295quiet_cmd_vmlinux__ = LD      $@
 296define cmd_vmlinux__
 297        $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(HEAD) $(init-y) \
 298        --start-group \
 299        $(core-y) \
 300        $(libs-y) \
 301        $(drivers-y) \
 302        $(net-y) \
 303        --end-group \
 304        $(filter .tmp_kallsyms%,$^) \
 305        -o $@
 306endef
 307
 308#       set -e makes the rule exit immediately on error
 309#       Final awk script makes sure per-cpu vars are in per-cpu section, as
 310#       old gcc (eg egcs 2.92.11) ignores section attribute if uninitialized.
 311
 312define rule_vmlinux__
 313        set -e
 314        $(if $(filter .tmp_kallsyms%,$^),,
 315          echo '  Generating build number'
 316          . $(src)/scripts/mkversion > .tmp_version
 317          mv -f .tmp_version .version
 318          $(Q)$(MAKE) $(build)=init
 319        )
 320        $(call cmd,vmlinux__)
 321        echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
 322endef
 323
 324define rule_vmlinux_no_percpu
 325        $(rule_vmlinux__)
 326        $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
 327endef
 328
 329ifdef CONFIG_SMP
 330define rule_vmlinux
 331        $(rule_vmlinux_no_percpu)
 332        $(AWK) -f $(srctree)/scripts/per-cpu-check.awk < System.map
 333endef
 334else
 335define rule_vmlinux
 336        $(rule_vmlinux_no_percpu)
 337endef
 338endif
 339
 340LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s
 341
 342#       Generate section listing all symbols and add it into vmlinux
 343#       It's a three stage process:
 344#       o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
 345#         empty
 346#         Running kallsyms on that gives as .tmp_kallsyms1.o with
 347#         the right size
 348#       o .tmp_vmlinux2 now has a __kallsyms section of the right size,
 349#         but due to the added section, some addresses have shifted
 350#         From here, we generate a correct .tmp_kallsyms2.o
 351#       o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
 352
 353ifdef CONFIG_KALLSYMS
 354
 355kallsyms.o := .tmp_kallsyms2.o
 356
 357quiet_cmd_kallsyms = KSYM    $@
 358cmd_kallsyms = $(NM) -n $< | scripts/kallsyms > $@
 359
 360.tmp_kallsyms1.o .tmp_kallsyms2.o: %.o: %.S scripts FORCE
 361        $(call if_changed_dep,as_o_S)
 362
 363.tmp_kallsyms%.S: .tmp_vmlinux%
 364        $(call cmd,kallsyms)
 365
 366.tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE
 367        $(call if_changed_rule,vmlinux__)
 368
 369.tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/vmlinux.lds.s FORCE
 370        $(call if_changed_rule,vmlinux__)
 371
 372endif
 373
 374#       Finally the vmlinux rule
 375
 376vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/vmlinux.lds.s FORCE
 377        $(call if_changed_rule,vmlinux)
 378
 379#       The actual objects are generated when descending, 
 380#       make sure no implicit rule kicks in
 381
 382$(sort $(vmlinux-objs)): $(SUBDIRS) ;
 383
 384#       Handle descending into subdirectories listed in $(SUBDIRS)
 385
 386.PHONY: $(SUBDIRS)
 387$(SUBDIRS): .hdepend prepare
 388        $(Q)$(MAKE) $(build)=$@
 389
 390#       Things we need done before we descend to build or make
 391#       module versions are listed in "prepare"
 392
 393.PHONY: prepare
 394prepare: include/linux/version.h include/asm include/config/MARKER
 395        @echo '  Starting the build. KBUILD_BUILTIN=$(KBUILD_BUILTIN) KBUILD_MODULES=$(KBUILD_MODULES)'
 396
 397#       This can be used by arch/$ARCH/Makefile to preprocess
 398#       their vmlinux.lds.S file
 399
 400AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
 401
 402arch/$(ARCH)/vmlinux.lds.s: %.s: %.S scripts FORCE
 403        $(call if_changed_dep,as_s_S)
 404
 405targets += arch/$(ARCH)/vmlinux.lds.s
 406
 407# Single targets
 408# ---------------------------------------------------------------------------
 409
 410%.s: %.c scripts FORCE
 411        $(Q)$(MAKE) $(build)=$(@D) $@
 412%.i: %.c scripts FORCE
 413        $(Q)$(MAKE) $(build)=$(@D) $@
 414%.o: %.c scripts FORCE
 415        $(Q)$(MAKE) $(build)=$(@D) $@
 416%.ko: scripts FORCE
 417        $(Q)$(MAKE) $(build)=$(@D) $@
 418%.lst: %.c scripts FORCE
 419        $(Q)$(MAKE) $(build)=$(@D) $@
 420%.s: %.S scripts FORCE
 421        $(Q)$(MAKE) $(build)=$(@D) $@
 422%.o: %.S scripts FORCE
 423        $(Q)$(MAKE) $(build)=$(@D) $@
 424
 425#       FIXME: The asm symlink changes when $(ARCH) changes. That's
 426#       hard to detect, but I suppose "make mrproper" is a good idea
 427#       before switching between archs anyway.
 428
 429include/asm:
 430        @echo '  Making asm->asm-$(ARCH) symlink'
 431        @ln -s asm-$(ARCH) $@
 432
 433#       Split autoconf.h into include/linux/config/*
 434
 435include/config/MARKER: scripts/split-include include/linux/autoconf.h
 436        @echo '  SPLIT  include/linux/autoconf.h -> include/config/*'
 437        @scripts/split-include include/linux/autoconf.h include/config
 438        @touch $@
 439
 440#       if .config is newer than include/linux/autoconf.h, someone tinkered
 441#       with it and forgot to run make oldconfig
 442
 443include/linux/autoconf.h: .config
 444        $(Q)$(MAKE) $(build)=scripts/kconfig scripts/kconfig/conf
 445        ./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
 446
 447# Generate some files
 448# ---------------------------------------------------------------------------
 449
 450#       version.h changes when $(KERNELRELEASE) etc change, as defined in
 451#       this Makefile
 452
 453uts_len := 64
 454
 455include/linux/version.h: Makefile
 456        @if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \
 457          echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
 458          exit 1; \
 459        fi;
 460        @echo -n '  Generating $@'
 461        @(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
 462          echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
 463         echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
 464        ) > $@.tmp
 465        @$(update-if-changed)
 466
 467# Generate module versions
 468# ---------------------------------------------------------------------------
 469
 470#       The targets are still named depend / dep for traditional
 471#       reasons, but the only thing we do here is generating
 472#       the module version checksums.
 473
 474.PHONY: depend dep $(patsubst %,_sfdep_%,$(SUBDIRS))
 475
 476depend dep: .hdepend
 477
 478#       .hdepend is our (misnomed) marker for whether we've
 479#       generated module versions
 480
 481make-versions := $(strip $(if $(filter dep depend,$(MAKECMDGOALS)),1) \
 482                         $(if $(wildcard .hdepend),,1))
 483
 484.hdepend: prepare FORCE
 485ifneq ($(make-versions),)
 486        @$(MAKE) include/linux/modversions.h
 487        @touch $@
 488endif
 489
 490ifdef CONFIG_MODVERSIONS
 491
 492#       Update modversions.h, but only if it would change.
 493
 494.PHONY: __rm_tmp_export-objs
 495__rm_tmp_export-objs: 
 496        @rm -rf .tmp_export-objs
 497
 498include/linux/modversions.h: $(patsubst %,_modver_%,$(SUBDIRS))
 499        @echo -n '  Generating $@'
 500        @( echo "#ifndef _LINUX_MODVERSIONS_H";\
 501           echo "#define _LINUX_MODVERSIONS_H"; \
 502           echo "#include <linux/modsetver.h>"; \
 503           cd .tmp_export-objs >/dev/null; \
 504           for f in `find modules -name \*.ver -print | sort`; do \
 505             echo "#include <linux/$${f}>"; \
 506           done; \
 507           echo "#endif"; \
 508        ) > $@.tmp; \
 509        $(update-if-changed)
 510
 511.PHONY: $(patsubst %, _modver_%, $(SUBDIRS))
 512$(patsubst %, _modver_%, $(SUBDIRS)): __rm_tmp_export-objs
 513        $(Q)$(MAKE) -f scripts/Makefile.modver obj=$(patsubst _modver_%,%,$@)
 514
 515else # !CONFIG_MODVERSIONS
 516
 517.PHONY: include/linux/modversions.h
 518
 519include/linux/modversions.h:
 520
 521endif # CONFIG_MODVERSIONS
 522
 523# ---------------------------------------------------------------------------
 524# Modules
 525
 526ifdef CONFIG_MODULES
 527
 528#       Build modules
 529
 530ifdef CONFIG_MODVERSIONS
 531MODFLAGS += -include include/linux/modversions.h
 532endif
 533
 534.PHONY: modules
 535modules: $(SUBDIRS)
 536
 537#       Install modules
 538
 539.PHONY: modules_install
 540modules_install: _modinst_ $(patsubst %, _modinst_%, $(SUBDIRS)) _modinst_post
 541
 542.PHONY: _modinst_
 543_modinst_:
 544        @rm -rf $(MODLIB)/kernel
 545        @rm -f $(MODLIB)/build
 546        @mkdir -p $(MODLIB)/kernel
 547        @ln -s $(TOPDIR) $(MODLIB)/build
 548
 549# If System.map exists, run depmod.  This deliberately does not have a
 550# dependency on System.map since that would run the dependency tree on
 551# vmlinux.  This depmod is only for convenience to give the initial
 552# boot a modules.dep even before / is mounted read-write.  However the
 553# boot script depmod is the master version.
 554ifeq "$(strip $(INSTALL_MOD_PATH))" ""
 555depmod_opts     :=
 556else
 557depmod_opts     := -b $(INSTALL_MOD_PATH) -r
 558endif
 559.PHONY: _modinst_post
 560_modinst_post:
 561        if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
 562
 563.PHONY: $(patsubst %, _modinst_%, $(SUBDIRS))
 564$(patsubst %, _modinst_%, $(SUBDIRS)) :
 565        $(Q)$(MAKE) -rR -f scripts/Makefile.modinst obj=$(patsubst _modinst_%,%,$@)
 566else # CONFIG_MODULES
 567
 568# Modules not configured
 569# ---------------------------------------------------------------------------
 570
 571modules modules_install: FORCE
 572        @echo
 573        @echo "The present kernel configuration has modules disabled."
 574        @echo "Type 'make config' and enable loadable module support."
 575        @echo "Then build a kernel with module support enabled."
 576        @echo
 577        @exit 1
 578
 579endif # CONFIG_MODULES
 580
 581# Generate asm-offsets.h 
 582# ---------------------------------------------------------------------------
 583
 584define generate-asm-offsets.h
 585        (set -e; \
 586         echo "#ifndef __ASM_OFFSETS_H__"; \
 587         echo "#define __ASM_OFFSETS_H__"; \
 588         echo "/*"; \
 589         echo " * DO NOT MODIFY."; \
 590         echo " *"; \
 591         echo " * This file was generated by arch/$(ARCH)/Makefile"; \
 592         echo " *"; \
 593         echo " */"; \
 594         echo ""; \
 595         sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
 596         echo ""; \
 597         echo "#endif" )
 598endef
 599
 600# RPM target
 601# ---------------------------------------------------------------------------
 602
 603#       If you do a make spec before packing the tarball you can rpm -ta it
 604
 605spec:
 606        . scripts/mkspec >kernel.spec
 607
 608#       Build a tar ball, generate an rpm from it and pack the result
 609#       There arw two bits of magic here
 610#       1) The use of /. to avoid tar packing just the symlink
 611#       2) Removing the .dep files as they have source paths in them that
 612#          will become invalid
 613
 614rpm:    clean spec
 615        find . $(RCS_FIND_IGNORE) \
 616                \( -size 0 -o -name .depend -o -name .hdepend \) \
 617                -type f -print | xargs rm -f
 618        set -e; \
 619        cd $(TOPDIR)/.. ; \
 620        ln -sf $(TOPDIR) $(KERNELPATH) ; \
 621        tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
 622        rm $(KERNELPATH) ; \
 623        cd $(TOPDIR) ; \
 624        $(CONFIG_SHELL) $(srctree)/scripts/mkversion > .version ; \
 625        rpm -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \
 626        rm $(TOPDIR)/../$(KERNELPATH).tar.gz
 627
 628else # ifdef include_config
 629
 630ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
 631
 632# Targets which don't need .config
 633# ===========================================================================
 634#
 635# These targets basically have their own Makefile - not quite, but at
 636# least its own exclusive section in the same Makefile. The reason for
 637# this is the following:
 638# To know the configuration, the main Makefile has to include
 639# .config. That's a obviously a problem when .config doesn't exist
 640# yet, but that could be kludged around with only including it if it
 641# exists.
 642# However, the larger problem is: If you run make *config, make will
 643# include the old .config, then execute your *config. It will then
 644# notice that a piece it included (.config) did change and restart from
 645# scratch. Which will cause execution of *config again. You get the
 646# picture.
 647# If we don't explicitly let the Makefile know that .config is changed
 648# by *config (the old way), it won't reread .config after *config,
 649# thus working with possibly stale values - we don't that either.
 650#
 651# So we divide things: This part here is for making *config targets,
 652# and other targets which should work when no .config exists yet.
 653# The main part above takes care of the rest after a .config exists.
 654
 655# Kernel configuration
 656# ---------------------------------------------------------------------------
 657
 658.PHONY: oldconfig xconfig menuconfig config \
 659        make_with_config
 660
 661scripts/kconfig/conf scripts/kconfig/mconf scripts/kconfig/qconf: scripts/fixdep FORCE
 662        $(Q)$(MAKE) $(build)=scripts/kconfig $@
 663
 664xconfig: scripts/kconfig/qconf
 665        ./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
 666
 667menuconfig: scripts/kconfig/mconf
 668        $(Q)$(MAKE) $(build)=scripts/lxdialog
 669        ./scripts/kconfig/mconf arch/$(ARCH)/Kconfig
 670
 671config: scripts/kconfig/conf
 672        ./scripts/kconfig/conf arch/$(ARCH)/Kconfig
 673
 674oldconfig: scripts/kconfig/conf
 675        ./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
 676
 677randconfig: scripts/kconfig/conf
 678        ./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
 679
 680allyesconfig: scripts/kconfig/conf
 681        ./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
 682
 683allnoconfig: scripts/kconfig/conf
 684        ./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
 685
 686allmodconfig: scripts/kconfig/conf
 687        ./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
 688
 689defconfig: scripts/kconfig/conf
 690        ./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
 691
 692###
 693# Cleaning is done on three levels.
 694# make clean     Delete all automatically generated files, including
 695#                tools and firmware.
 696# make mrproper  Delete the current configuration, and related files
 697#                Any core files spread around is deleted as well
 698# make distclean Remove editor backup files, patch leftover files and the like
 699
 700# Files removed with 'make clean'
 701CLEAN_FILES += vmlinux System.map MC*
 702
 703# Files removed with 'make mrproper'
 704MRPROPER_FILES += \
 705        include/linux/autoconf.h include/linux/version.h \
 706        .version .config .config.old config.in config.old \
 707        .menuconfig.log \
 708        include/asm \
 709        .hdepend include/linux/modversions.h \
 710        tags TAGS kernel.spec \
 711        .tmp*
 712
 713# Directories removed with 'make mrproper'
 714MRPROPER_DIRS += \
 715        .tmp_export-objs \
 716        include/config \
 717        include/linux/modules
 718
 719# clean - Delete all intermediate files
 720#
 721clean-dirs += $(ALL_SUBDIRS) Documentation/DocBook scripts
 722
 723$(addprefix _clean_,$(clean-dirs)):
 724        $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
 725
 726quiet_cmd_rmclean = RM  $$(CLEAN_FILES)
 727cmd_rmclean       = rm -f $(CLEAN_FILES)
 728clean: archclean $(addprefix _clean_,$(clean-dirs))
 729        $(call cmd,rmclean)
 730        @find . $(RCS_FIND_IGNORE) \
 731                \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
 732                -o -name '.*.d' -o -name '.*.tmp' \) -type f \
 733                -print | xargs rm -f
 734
 735# mrproper - delete configuration + modules + core files
 736#
 737quiet_cmd_mrproper = RM  $$(MRPROPER_DIRS) + $$(MRPROPER_FILES)
 738cmd_mrproper = rm -rf $(MRPROPER_DIRS) && rm -f $(MRPROPER_FILES)
 739mrproper distclean: clean archmrproper
 740        @echo '  Making $@ in the srctree'
 741        @find . $(RCS_FIND_IGNORE) \
 742                \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
 743                -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
 744                -o -name '.*.rej' -o -size 0 \
 745                -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
 746                -type f -print | xargs rm -f
 747        $(call cmd,mrproper)
 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 \
 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 + config + various backup files'
 792        @echo  ''
 793        @echo  'Configuration targets:'
 794        @echo  '  oldconfig     - Update current config utilising a line-oriented program'
 795        @echo  '  menuconfig    - Update current config utilising a menu based program'
 796        @echo  '  xconfig       - Update current config utilising a X-based program'
 797        @echo  '  defconfig     - New config with default answer to all options'
 798        @echo  '  allmodconfig  - New config selecting modules when possible'
 799        @echo  '  allyesconfig  - New config where all options are accepted with yes'
 800        @echo  '  allnoconfig   - New minimal config'
 801        @echo  ''
 802        @echo  'Other generic targets:'
 803        @echo  '  all           - Build all targets marked with [*]'
 804        @echo  '  dep           - Create module version information'
 805        @echo  '* vmlinux       - Build the bare kernel'
 806        @echo  '* modules       - Build all modules'
 807        @echo  '  dir/file.[ois]- Build specified target only'
 808        @echo  '  rpm           - Build a kernel as an RPM package'
 809        @echo  '  tags/TAGS     - Generate tags file for editors'
 810        @echo  ''
 811        @echo  'Documentation targets:'
 812        @$(MAKE) --no-print-directory -f Documentation/DocBook/Makefile dochelp
 813        @echo  ''
 814        @echo  'Architecture specific targets ($(ARCH)):'
 815        @$(if $(archhelp),$(archhelp),\
 816                echo '  No architecture specific help defined for $(ARCH)')
 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        $(Q)$(MAKE) $(build)=Documentation/DocBook $@
 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        $(Q)$(MAKE) $@
 853
 854endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
 855endif # ifdef include_config
 856
 857# FIXME Should go into a make.lib or something 
 858# ===========================================================================
 859
 860a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) $(NOSTDINC_FLAGS) \
 861          $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
 862
 863quiet_cmd_as_s_S = CPP     $@
 864cmd_as_s_S       = $(CPP) $(a_flags)   -o $@ $< 
 865
 866quiet_cmd_as_o_S = AS      $@
 867cmd_as_o_S       = $(CC) $(a_flags) -c -o $@ $<
 868
 869# read all saved command lines
 870
 871targets := $(wildcard $(sort $(targets)))
 872cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
 873
 874ifneq ($(cmd_files),)
 875  include $(cmd_files)
 876endif
 877
 878# execute the command and also postprocess generated .d dependencies
 879# file
 880
 881if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
 882                          $(filter-out $(cmd_$(1)),$(cmd_$@))\
 883                          $(filter-out $(cmd_$@),$(cmd_$(1)))),\
 884        @set -e; \
 885        $(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))';) \
 886        $(cmd_$(1)); \
 887        scripts/fixdep $(depfile) $@ '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \
 888        rm -f $(depfile); \
 889        mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
 890
 891# Usage: $(call if_changed_rule,foo)
 892# will check if $(cmd_foo) changed, or any of the prequisites changed,
 893# and if so will execute $(rule_foo)
 894
 895if_changed_rule = $(if $(strip $? \
 896                               $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\
 897                               $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\
 898                       @$(rule_$(1)))
 899
 900# If quiet is set, only print short version of command
 901
 902cmd = @$(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
 903
 904define update-if-changed
 905        if [ -r $@ ] && cmp -s $@ $@.tmp; then \
 906                echo ' (unchanged)'; \
 907                rm -f $@.tmp; \
 908        else \
 909                echo ' (updated)'; \
 910                mv -f $@.tmp $@; \
 911        fi
 912endef
 913
 914# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
 915# Usage:
 916# $(Q)$(MAKE) $(build)=dir
 917build := -f scripts/Makefile.build obj
 918
 919# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
 920# Usage:
 921# $(Q)$(MAKE) $(clean)=dir
 922clean := -f scripts/Makefile.clean obj
 923
 924#       $(call descend,<dir>,<target>)
 925#       Recursively call a sub-make in <dir> with target <target>
 926# Usage is deprecated, because make do not see this as an invocation of make.
 927descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2)
 928
 929FORCE:
 930
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.