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