Merge bk://kernel.bkbits.net/davem/net-2.5
[linux-2.6/history.git] / Makefile
blob80d119d5599eaec01e378d022c4c0e75854028a5
1 VERSION = 2
2 PATCHLEVEL = 6
3 SUBLEVEL = 0
4 EXTRAVERSION = -test6
6 # *DOCUMENTATION*
7 # To see a list of typical targets execute "make help"
8 # More info can be located in ./README
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.
12 # Do not print "Entering directory ..."
13 MAKEFLAGS += --no-print-directory
15 # We are using a recursive build, so we need to do a little thinking
16 # to get the ordering right.
18 # Most importantly: sub-Makefiles should only ever modify files in
19 # their own directory. If in some directory we have a dependency on
20 # a file in another dir (which doesn't happen often, but it's of
21 # unavoidable when linking the built-in.o targets which finally
22 # turn into vmlinux), we will call a sub make in that other dir, and
23 # after that we are sure that everything which is in that other dir
24 # is now up to date.
26 # The only cases where we need to modify files which have global
27 # effects are thus separated out and done before the recursive
28 # descending is started. They are now explicitly listed as the
29 # prepare rule.
31 # To put more focus on warnings, be less verbose as default
32 # Use 'make V=1' to see the full commands
34 ifdef V
35 ifeq ("$(origin V)", "command line")
36 KBUILD_VERBOSE = $(V)
37 endif
38 endif
39 ifndef KBUILD_VERBOSE
40 KBUILD_VERBOSE = 0
41 endif
43 # Call sparse as part of compilation of C files
44 # Use 'make C=1' to enable sparse checking
46 ifdef C
47 ifeq ("$(origin C)", "command line")
48 KBUILD_CHECKSRC = $(C)
49 endif
50 endif
51 ifndef KBUILD_CHECKSRC
52 KBUILD_CHECKSRC = 0
53 endif
55 # kbuild supports saving output files in a separate directory.
56 # To locate output files in a separate directory two syntax'es are supported.
57 # In both cases the working directory must be the root of the kernel src.
58 # 1) O=
59 # Use "make O=dir/to/store/output/files/"
61 # 2) Set KBUILD_OUTPUT
62 # Set the environment variable KBUILD_OUTPUT to point to the directory
63 # where the output files shall be placed.
64 # export KBUILD_OUTPUT=dir/to/store/output/files/
65 # make
67 # The O= assigment takes precedence over the KBUILD_OUTPUT environment variable.
70 # KBUILD_SRC is set on invocation of make in OBJ directory
71 # KBUILD_SRC is not intended to be used by the regular user (for now)
72 ifeq ($(KBUILD_SRC),)
74 # OK, Make called in directory where kernel src resides
75 # Do we want to locate output files in a separate directory?
76 ifdef O
77 ifeq ("$(origin O)", "command line")
78 KBUILD_OUTPUT := $(O)
79 endif
80 endif
82 ifneq ($(KBUILD_OUTPUT),)
83 # Invoke a second make in the output directory, passing relevant variables
84 KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT); /bin/pwd)
86 .PHONY: $(MAKECMDGOALS) all
88 $(MAKECMDGOALS) all:
89 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
90 KBUILD_SRC=$(CURDIR) KBUILD_VERBOSE=$(KBUILD_VERBOSE) \
91 KBUILD_CHECK=$(KBUILD_CHECK) -f $(CURDIR)/Makefile $(MAKECMDGOALS)
93 # Leave processing to above invocation of make
94 skip-makefile := 1
95 endif # ifneq ($(KBUILD_OUTPUT),)
96 endif # ifeq ($(KBUILD_SRC),)
98 # We process the rest of the Makefile if this is the final invocation of make
99 ifeq ($(skip-makefile),)
101 srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
102 TOPDIR := $(srctree)
103 # FIXME - TOPDIR is obsolete, use srctree/objtree
104 objtree := $(CURDIR)
105 src := $(srctree)
106 obj := $(objtree)
108 VPATH := $(srctree)
110 export srctree objtree VPATH TOPDIR
112 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
114 # SUBARCH tells the usermode build what the underlying arch is. That is set
115 # first, and if a usermode build is happening, the "ARCH=um" on the command
116 # line overrides the setting of ARCH below. If a native build is happening,
117 # then ARCH is assigned, getting whatever value it gets normally, and
118 # SUBARCH is subsequently ignored.
120 SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
121 -e s/arm.*/arm/ -e s/sa110/arm/ \
122 -e s/s390x/s390/ -e s/parisc64/parisc/ )
124 # Cross compiling and selecting different set of gcc/bin-utils
125 # ---------------------------------------------------------------------------
127 # When performing cross compilation for other architectures ARCH shall be set
128 # to the target architecture. (See arch/* for the possibilities).
129 # ARCH can be set during invocation of make:
130 # make ARCH=ia64
131 # Another way is to have ARCH set in the environment.
132 # The default ARCH is the host where make is executed.
134 # CROSS_COMPILE specify the prefix used for all executables used
135 # during compilation. Only gcc and related bin-utils executables
136 # are prefixed with $(CROSS_COMPILE).
137 # CROSS_COMPILE can be set on the command line
138 # make CROSS_COMPILE=ia64-linux-
139 # Alternatively CROSS_COMPILE can be set in the environment.
140 # Default value for CROSS_COMPILE is not to prefix executables
141 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
143 ARCH ?= $(SUBARCH)
144 CROSS_COMPILE ?=
146 # Architecture as present in compile.h
147 UTS_MACHINE := $(ARCH)
149 # SHELL used by kbuild
150 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
151 else if [ -x /bin/bash ]; then echo /bin/bash; \
152 else echo sh; fi ; fi)
154 HOSTCC = gcc
155 HOSTCXX = g++
156 HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
157 HOSTCXXFLAGS = -O2
160 # That's our default target when none is given on the command line
161 # Note that 'modules' will be added as a prerequisite as well,
162 # in the CONFIG_MODULES part below
164 all: vmlinux
166 # Decide whether to build built-in, modular, or both.
167 # Normally, just do built-in.
169 KBUILD_MODULES :=
170 KBUILD_BUILTIN := 1
172 # If we have only "make modules", don't compile built-in objects.
173 # When we're building modules with modversions, we need to consider
174 # the built-in objects during the descend as well, in order to
175 # make sure the checksums are uptodate before we record them.
177 ifeq ($(MAKECMDGOALS),modules)
178 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
179 endif
181 # If we have "make <whatever> modules", compile modules
182 # in addition to whatever we do anyway.
183 # Just "make" or "make all" shall build modules as well
185 ifneq ($(filter all modules,$(MAKECMDGOALS)),)
186 KBUILD_MODULES := 1
187 endif
189 ifeq ($(MAKECMDGOALS),)
190 KBUILD_MODULES := 1
191 endif
193 export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE
194 export KBUILD_CHECKSRC KBUILD_SRC
196 # Beautify output
197 # ---------------------------------------------------------------------------
199 # Normally, we echo the whole command before executing it. By making
200 # that echo $($(quiet)$(cmd)), we now have the possibility to set
201 # $(quiet) to choose other forms of output instead, e.g.
203 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
204 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
206 # If $(quiet) is empty, the whole command will be printed.
207 # If it is set to "quiet_", only the short version will be printed.
208 # If it is set to "silent_", nothing wil be printed at all, since
209 # the variable $(silent_cmd_cc_o_c) doesn't exist.
211 # A simple variant is to prefix commands with $(Q) - that's usefull
212 # for commands that shall be hidden in non-verbose mode.
214 # $(Q)ln $@ :<
216 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
217 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
219 ifeq ($(KBUILD_VERBOSE),1)
220 quiet =
222 else
223 quiet=quiet_
224 Q = @
225 endif
227 # If the user is running make -s (silent mode), suppress echoing of
228 # commands
230 ifneq ($(findstring s,$(MAKEFLAGS)),)
231 quiet=silent_
232 endif
234 check_gcc = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
236 export quiet Q KBUILD_VERBOSE check_gcc
238 # Look for make include files relative to root of kernel src
239 MAKEFLAGS += --include-dir=$(srctree)
241 # For maximum performance (+ possibly random breakage, uncomment
242 # the following)
244 #MAKEFLAGS += -rR
246 # Make variables (CC, etc...)
248 AS = $(CROSS_COMPILE)as
249 LD = $(CROSS_COMPILE)ld
250 CC = $(CROSS_COMPILE)gcc
251 CPP = $(CC) -E
252 AR = $(CROSS_COMPILE)ar
253 NM = $(CROSS_COMPILE)nm
254 STRIP = $(CROSS_COMPILE)strip
255 OBJCOPY = $(CROSS_COMPILE)objcopy
256 OBJDUMP = $(CROSS_COMPILE)objdump
257 AWK = awk
258 RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
259 else echo rpm; fi)
260 GENKSYMS = scripts/genksyms/genksyms
261 DEPMOD = /sbin/depmod
262 KALLSYMS = scripts/kallsyms
263 PERL = perl
264 CHECK = sparse
265 MODFLAGS = -DMODULE
266 CFLAGS_MODULE = $(MODFLAGS)
267 AFLAGS_MODULE = $(MODFLAGS)
268 LDFLAGS_MODULE = -r
269 CFLAGS_KERNEL =
270 AFLAGS_KERNEL =
272 NOSTDINC_FLAGS = -nostdinc -iwithprefix include
274 CPPFLAGS := -D__KERNEL__ -Iinclude \
275 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include)
277 CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
278 -fno-strict-aliasing -fno-common
279 AFLAGS := -D__ASSEMBLY__
281 export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
282 CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
283 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
284 HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE CHECK
286 export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
287 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
288 export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
290 export MODVERDIR := .tmp_versions
292 # The temporary file to save gcc -MD generated dependencies must not
293 # contain a comma
294 comma := ,
295 depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
297 # Files to ignore in find ... statements
299 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o
300 RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
302 # ===========================================================================
303 # Rules shared between *config targets and build targets
305 # Helpers built in scripts/
307 scripts/docproc scripts/split-include : scripts ;
309 .PHONY: scripts scripts/fixdep
310 scripts:
311 $(Q)$(MAKE) $(build)=scripts
313 scripts/fixdep:
314 $(Q)$(MAKE) $(build)=scripts $@
317 # To make sure we do not include .config for any of the *config targets
318 # catch them early, and hand them over to scripts/kconfig/Makefile
319 # It is allowed to specify more targets when calling make, including
320 # mixing *config targets and build targets.
321 # For example 'make oldconfig all'.
322 # Detect when mixed targets is specified, and make a second invocation
323 # of make so .config is not included in this case either (for *config).
325 no-dot-config-targets := clean mrproper distclean \
326 cscope TAGS tags help %docs check%
328 config-targets := 0
329 mixed-targets := 0
330 dot-config := 1
332 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
333 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
334 dot-config := 0
335 endif
336 endif
338 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
339 config-targets := 1
340 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
341 mixed-targets := 1
342 endif
343 endif
345 ifeq ($(mixed-targets),1)
346 # ===========================================================================
347 # We're called with mixed targets (*config and build targets).
348 # Handle them one by one.
350 %:: FORCE
351 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
353 else
354 ifeq ($(config-targets),1)
355 # ===========================================================================
356 # *config targets only - make sure prerequisites are updated, and descend
357 # in scripts/kconfig to make the *config target
359 %config: scripts/fixdep FORCE
360 $(Q)$(MAKE) $(build)=scripts/kconfig $@
361 config : scripts/fixdep FORCE
362 $(Q)$(MAKE) $(build)=scripts/kconfig $@
364 else
365 # ===========================================================================
366 # Build targets only - this includes vmlinux, arch specific targets, clean
367 # targets and others. In general all targets except *config targets.
369 # Objects we will link into vmlinux / subdirs we need to visit
370 init-y := init/
371 drivers-y := drivers/ sound/
372 net-y := net/
373 libs-y := lib/
374 core-y := usr/
375 SUBDIRS :=
377 ifeq ($(dot-config),1)
378 # In this section, we need .config
380 # Read in dependencies to all Kconfig* files, make sure to run
381 # oldconfig if changes are detected.
382 -include .config.cmd
384 include .config
386 # If .config needs to be updated, it will be done via the dependency
387 # that autoconf has on .config.
388 # To avoid any implicit rule to kick in, define an empty command
389 .config: ;
391 # If .config is newer than include/linux/autoconf.h, someone tinkered
392 # with it and forgot to run make oldconfig
393 include/linux/autoconf.h: .config
394 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
396 endif
398 include $(srctree)/arch/$(ARCH)/Makefile
400 # Let architecture Makefiles change CPPFLAGS if needed
401 CFLAGS := $(CPPFLAGS) $(CFLAGS)
402 AFLAGS := $(CPPFLAGS) $(AFLAGS)
404 core-y += kernel/ mm/ fs/ ipc/ security/ crypto/
406 SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
407 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
408 $(net-y) $(net-m) $(libs-y) $(libs-m)))
410 ALL_SUBDIRS := $(sort $(SUBDIRS) $(patsubst %/,%,$(filter %/, \
411 $(init-n) $(init-) \
412 $(core-n) $(core-) $(drivers-n) $(drivers-) \
413 $(net-n) $(net-) $(libs-n) $(libs-))))
415 init-y := $(patsubst %/, %/built-in.o, $(init-y))
416 core-y := $(patsubst %/, %/built-in.o, $(core-y))
417 drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y))
418 net-y := $(patsubst %/, %/built-in.o, $(net-y))
419 libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
420 libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
421 libs-y := $(libs-y1) $(libs-y2)
423 # Here goes the main Makefile
424 # ---------------------------------------------------------------------------
427 ifndef CONFIG_FRAME_POINTER
428 CFLAGS += -fomit-frame-pointer
429 endif
431 ifdef CONFIG_DEBUG_INFO
432 CFLAGS += -g
433 endif
435 # warn about C99 declaration after statement
436 CFLAGS += $(call check_gcc,-Wdeclaration-after-statement,)
439 # INSTALL_PATH specifies where to place the updated kernel and system map
440 # images. Uncomment if you want to place them anywhere other than root.
443 #export INSTALL_PATH=/boot
446 # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
447 # relocations required by build roots. This is not defined in the
448 # makefile but the arguement can be passed to make if needed.
451 MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
452 export MODLIB
454 # Build vmlinux
455 # ---------------------------------------------------------------------------
457 # This is a bit tricky: If we need to relink vmlinux, we want
458 # the version number incremented, which means recompile init/version.o
459 # and relink init/init.o. However, we cannot do this during the
460 # normal descending-into-subdirs phase, since at that time
461 # we cannot yet know if we will need to relink vmlinux.
462 # So we descend into init/ inside the rule for vmlinux again.
463 head-y += $(HEAD)
464 vmlinux-objs := $(head-y) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y)
466 quiet_cmd_vmlinux__ = LD $@
467 define cmd_vmlinux__
468 $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(head-y) $(init-y) \
469 --start-group \
470 $(core-y) \
471 $(libs-y) \
472 $(drivers-y) \
473 $(net-y) \
474 --end-group \
475 $(filter .tmp_kallsyms%,$^) \
476 -o $@
477 endef
479 # set -e makes the rule exit immediately on error
481 define rule_vmlinux__
482 +set -e; \
483 $(if $(filter .tmp_kallsyms%,$^),, \
484 echo ' GEN .version'; \
485 . $(srctree)/scripts/mkversion > .tmp_version; \
486 mv -f .tmp_version .version; \
487 $(MAKE) $(build)=init; \
489 $(if $($(quiet)cmd_vmlinux__), \
490 echo ' $($(quiet)cmd_vmlinux__)' &&) \
491 $(cmd_vmlinux__); \
492 echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
493 endef
495 define rule_vmlinux
496 $(rule_vmlinux__); \
497 $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
498 endef
500 LDFLAGS_vmlinux += -T arch/$(ARCH)/kernel/vmlinux.lds.s
502 # Generate section listing all symbols and add it into vmlinux
503 # It's a three stage process:
504 # o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
505 # empty
506 # Running kallsyms on that gives us .tmp_kallsyms1.o with
507 # the right size
508 # o .tmp_vmlinux2 now has a __kallsyms section of the right size,
509 # but due to the added section, some addresses have shifted
510 # From here, we generate a correct .tmp_kallsyms2.o
511 # o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
513 ifdef CONFIG_KALLSYMS
515 kallsyms.o := .tmp_kallsyms2.o
517 quiet_cmd_kallsyms = KSYM $@
518 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) > $@
520 .tmp_kallsyms1.o .tmp_kallsyms2.o: %.o: %.S scripts FORCE
521 $(call if_changed_dep,as_o_S)
523 .tmp_kallsyms%.S: .tmp_vmlinux%
524 $(call cmd,kallsyms)
526 .tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
527 +$(call if_changed_rule,vmlinux__)
529 .tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
530 $(call if_changed_rule,vmlinux__)
532 endif
534 # Finally the vmlinux rule
536 vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
537 $(call if_changed_rule,vmlinux)
539 # The actual objects are generated when descending,
540 # make sure no implicit rule kicks in
542 $(sort $(vmlinux-objs)) arch/$(ARCH)/kernel/vmlinux.lds.s: $(SUBDIRS) ;
544 # Handle descending into subdirectories listed in $(SUBDIRS)
546 .PHONY: $(SUBDIRS)
547 $(SUBDIRS): prepare-all
548 $(Q)$(MAKE) $(build)=$@
550 # Things we need to do before we recursively start building the kernel
551 # or the modules are listed in "prepare-all".
552 # A multi level approach is used. prepare1 is updated first, then prepare0.
553 # prepare-all is the collection point for the prepare targets.
555 .PHONY: prepare-all prepare prepare0 prepare1
557 # prepare1 is used to check if we are building in a separate output directory,
558 # and if so do:
559 # 1) Check that make has not been executed in the kernel src $(srctree)
560 # 2) Create the include2 directory, used for the second asm symlink
562 prepare1:
563 ifneq ($(KBUILD_SRC),)
564 @echo ' Using $(srctree) as source for kernel'
565 $(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \
566 echo " $(srctree) is not clean, please run 'make mrproper'";\
567 echo " in the '$(srctree)' directory.";\
568 /bin/false; \
570 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
571 $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
572 endif
574 prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
575 ifdef KBUILD_MODULES
576 ifeq ($(origin SUBDIRS),file)
577 $(Q)rm -rf $(MODVERDIR)
578 else
579 @echo '*** Warning: Overriding SUBDIRS on the command line can cause'
580 @echo '*** inconsistencies'
581 endif
582 endif
583 $(if $(CONFIG_MODULES),$(Q)mkdir -p $(MODVERDIR))
585 # All the preparing..
586 prepare-all: prepare0 prepare
588 # Leave this as default for preprocessing vmlinux.lds.S, which is now
589 # done in arch/$(ARCH)/kernel/Makefile
591 export AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
593 # Single targets
594 # ---------------------------------------------------------------------------
596 %.s: %.c scripts FORCE
597 $(Q)$(MAKE) $(build)=$(@D) $@
598 %.i: %.c scripts FORCE
599 $(Q)$(MAKE) $(build)=$(@D) $@
600 %.o: %.c scripts FORCE
601 $(Q)$(MAKE) $(build)=$(@D) $@
602 %/: scripts prepare FORCE
603 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
604 %.lst: %.c scripts FORCE
605 $(Q)$(MAKE) $(build)=$(@D) $@
606 %.s: %.S scripts FORCE
607 $(Q)$(MAKE) $(build)=$(@D) $@
608 %.o: %.S scripts FORCE
609 $(Q)$(MAKE) $(build)=$(@D) $@
611 # FIXME: The asm symlink changes when $(ARCH) changes. That's
612 # hard to detect, but I suppose "make mrproper" is a good idea
613 # before switching between archs anyway.
615 include/asm:
616 @echo ' SYMLINK $@ -> include/asm-$(ARCH)'
617 $(Q)if [ ! -d include ]; then mkdir -p include; fi;
618 @ln -fsn asm-$(ARCH) $@
620 # Split autoconf.h into include/linux/config/*
622 include/config/MARKER: scripts/split-include include/linux/autoconf.h
623 @echo ' SPLIT include/linux/autoconf.h -> include/config/*'
624 @scripts/split-include include/linux/autoconf.h include/config
625 @touch $@
627 # Generate some files
628 # ---------------------------------------------------------------------------
630 # version.h changes when $(KERNELRELEASE) etc change, as defined in
631 # this Makefile
633 uts_len := 64
635 define filechk_version.h
636 if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \
637 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
638 exit 1; \
639 fi; \
640 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
641 echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
642 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
644 endef
646 include/linux/version.h: Makefile
647 $(call filechk,version.h)
649 # ---------------------------------------------------------------------------
651 .PHONY: depend dep
652 depend dep:
653 @echo '*** Warning: make $@ is unnecessary now.'
655 # ---------------------------------------------------------------------------
656 # Modules
658 ifdef CONFIG_MODULES
660 # By default, build modules as well
662 all: modules
664 # Build modules
666 .PHONY: modules
667 modules: $(SUBDIRS) $(if $(KBUILD_BUILTIN),vmlinux)
668 @echo ' Building modules, stage 2.';
669 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
671 # Install modules
673 .PHONY: modules_install
674 modules_install: _modinst_ _modinst_post
676 .PHONY: _modinst_
677 _modinst_:
678 @if [ -z "`$(DEPMOD) -V | grep module-init-tools`" ]; then \
679 echo "Warning: you may need to install module-init-tools"; \
680 echo "See http://www.codemonkey.org.uk/post-halloween-2.5.txt";\
681 sleep 1; \
683 @rm -rf $(MODLIB)/kernel
684 @rm -f $(MODLIB)/build
685 @mkdir -p $(MODLIB)/kernel
686 @ln -s $(TOPDIR) $(MODLIB)/build
687 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
689 # If System.map exists, run depmod. This deliberately does not have a
690 # dependency on System.map since that would run the dependency tree on
691 # vmlinux. This depmod is only for convenience to give the initial
692 # boot a modules.dep even before / is mounted read-write. However the
693 # boot script depmod is the master version.
694 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
695 depmod_opts :=
696 else
697 depmod_opts := -b $(INSTALL_MOD_PATH) -r
698 endif
699 .PHONY: _modinst_post
700 _modinst_post: _modinst_
701 if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
703 else # CONFIG_MODULES
705 # Modules not configured
706 # ---------------------------------------------------------------------------
708 modules modules_install: FORCE
709 @echo
710 @echo "The present kernel configuration has modules disabled."
711 @echo "Type 'make config' and enable loadable module support."
712 @echo "Then build a kernel with module support enabled."
713 @echo
714 @exit 1
716 endif # CONFIG_MODULES
718 # Generate asm-offsets.h
719 # ---------------------------------------------------------------------------
721 define filechk_gen-asm-offsets
722 (set -e; \
723 echo "#ifndef __ASM_OFFSETS_H__"; \
724 echo "#define __ASM_OFFSETS_H__"; \
725 echo "/*"; \
726 echo " * DO NOT MODIFY."; \
727 echo " *"; \
728 echo " * This file was generated by arch/$(ARCH)/Makefile"; \
729 echo " *"; \
730 echo " */"; \
731 echo ""; \
732 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
733 echo ""; \
734 echo "#endif" )
735 endef
739 # Cleaning is done on three levels.
740 # make clean Delete all automatically generated files, including
741 # tools and firmware.
742 # make mrproper Delete the current configuration, and related files
743 # Any core files spread around are deleted as well
744 # make distclean Remove editor backup files, patch leftover files and the like
746 # Files removed with 'make clean'
747 CLEAN_FILES += vmlinux System.map MC*
749 # Files removed with 'make mrproper'
750 MRPROPER_FILES += \
751 include/linux/autoconf.h include/linux/version.h \
752 .version .config .config.old config.in config.old \
753 .menuconfig.log \
754 include/asm \
755 .hdepend include/linux/modversions.h \
756 tags TAGS cscope.out kernel.spec \
757 .tmp*
759 # Directories removed with 'make mrproper'
760 MRPROPER_DIRS += \
761 $(MODVERDIR) \
762 .tmp_export-objs \
763 include/config \
764 include/linux/modules \
765 include2
767 # clean - Delete all intermediate files
769 clean-dirs += $(addprefix _clean_,$(ALL_SUBDIRS) Documentation/DocBook scripts)
770 .PHONY: $(clean-dirs) clean archclean mrproper archmrproper distclean
771 $(clean-dirs):
772 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
774 quiet_cmd_rmclean = RM $$(CLEAN_FILES)
775 cmd_rmclean = rm -f $(CLEAN_FILES)
776 clean: archclean $(clean-dirs)
777 $(call cmd,rmclean)
778 @find . $(RCS_FIND_IGNORE) \
779 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
780 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
781 -type f -print | xargs rm -f
783 # mrproper - delete configuration + modules + core files
785 quiet_cmd_mrproper = RM $$(MRPROPER_DIRS) + $$(MRPROPER_FILES)
786 cmd_mrproper = rm -rf $(MRPROPER_DIRS) && rm -f $(MRPROPER_FILES)
787 mrproper distclean: clean archmrproper
788 @echo ' Making $@ in the srctree'
789 @find . $(RCS_FIND_IGNORE) \
790 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
791 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
792 -o -name '.*.rej' -o -size 0 \
793 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
794 -type f -print | xargs rm -f
795 $(call cmd,mrproper)
797 # Generate tags for editors
798 # ---------------------------------------------------------------------------
800 define all-sources
801 ( find . $(RCS_FIND_IGNORE) \
802 \( -name include -o -name arch \) -prune -o \
803 -name '*.[chS]' -print; \
804 find arch/$(ARCH) $(RCS_FIND_IGNORE) \
805 -name '*.[chS]' -print; \
806 find include $(RCS_FIND_IGNORE) \
807 \( -name config -o -name 'asm-*' \) -prune \
808 -o -name '*.[chS]' -print; \
809 find include/asm-$(ARCH) $(RCS_FIND_IGNORE) \
810 -name '*.[chS]' -print; \
811 find include/asm-generic $(RCS_FIND_IGNORE) \
812 -name '*.[chS]' -print )
813 endef
815 quiet_cmd_cscope = MAKE $@
816 cmd_cscope = $(all-sources) | cscope -k -b -i -
818 quiet_cmd_TAGS = MAKE $@
819 cmd_TAGS = $(all-sources) | etags -
821 # Exuberant ctags works better with -I
823 quiet_cmd_tags = MAKE $@
824 define cmd_tags
825 rm -f $@; \
826 CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
827 $(all-sources) | xargs ctags $$CTAGSF -a
828 endef
830 cscope: FORCE
831 $(call cmd,cscope)
833 TAGS: FORCE
834 $(call cmd,TAGS)
836 tags: FORCE
837 $(call cmd,tags)
839 # RPM target
840 # ---------------------------------------------------------------------------
842 .PHONY: rpm
844 # Remove hyphens since they have special meaning in RPM filenames
845 KERNELPATH=kernel-$(subst -,,$(KERNELRELEASE))
847 # If you do a make spec before packing the tarball you can rpm -ta it
849 spec:
850 $(CONFIG_SHELL) $(srctree)/scripts/mkspec > $(objtree)/kernel.spec
852 # a) Build a tar ball
853 # b) generate an rpm from it
854 # c) and pack the result
855 # - Use /. to avoid tar packing just the symlink
857 rpm: clean spec
858 set -e; \
859 cd .. ; \
860 ln -sf $(srctree) $(KERNELPATH) ; \
861 tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
862 rm $(KERNELPATH)
864 set -e; \
865 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version;\
866 mv -f $(objtree)/.tmp_version $(objtree)/.version;
868 $(RPM) -ta ../$(KERNELPATH).tar.gz
869 rm ../$(KERNELPATH).tar.gz
871 # Brief documentation of the typical targets used
872 # ---------------------------------------------------------------------------
874 help:
875 @echo 'Cleaning targets:'
876 @echo ' clean - remove most generated files but keep the config'
877 @echo ' mrproper - remove all generated files + config + various backup files'
878 @echo ''
879 @echo 'Configuration targets:'
880 @$(MAKE) -f scripts/kconfig/Makefile help
881 @echo ''
882 @echo 'Other generic targets:'
883 @echo ' all - Build all targets marked with [*]'
884 @echo '* vmlinux - Build the bare kernel'
885 @echo '* modules - Build all modules'
886 @echo ' modules_install - Install all modules'
887 @echo ' dir/ - Build all files in dir and below'
888 @echo ' dir/file.[ois] - Build specified target only'
889 @echo ' rpm - Build a kernel as an RPM package'
890 @echo ' tags/TAGS - Generate tags file for editors'
891 @echo ''
892 @echo 'Documentation targets:'
893 @$(MAKE) -f Documentation/DocBook/Makefile dochelp
894 @echo ''
895 @echo 'Architecture specific targets ($(ARCH)):'
896 @$(if $(archhelp),$(archhelp),\
897 echo ' No architecture specific help defined for $(ARCH)')
898 @echo ''
899 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
900 @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
901 @echo ' make C=1 [targets] Check all c source with checker tool'
902 @echo ''
903 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
904 @echo 'For further info see the ./README file'
907 # Documentation targets
908 # ---------------------------------------------------------------------------
909 %docs: scripts/docproc FORCE
910 $(Q)$(MAKE) $(build)=Documentation/DocBook $@
912 # Scripts to check various things for consistency
913 # ---------------------------------------------------------------------------
915 configcheck:
916 find * $(RCS_FIND_IGNORE) \
917 -name '*.[hcS]' -type f -print | sort \
918 | xargs $(PERL) -w scripts/checkconfig.pl
920 includecheck:
921 find * $(RCS_FIND_IGNORE) \
922 -name '*.[hcS]' -type f -print | sort \
923 | xargs $(PERL) -w scripts/checkincludes.pl
925 versioncheck:
926 find * $(RCS_FIND_IGNORE) \
927 -name '*.[hcS]' -type f -print | sort \
928 | xargs $(PERL) -w scripts/checkversion.pl
930 endif #ifeq ($(config-targets),1)
931 endif #ifeq ($(mixed-targets),1)
933 # FIXME Should go into a make.lib or something
934 # ===========================================================================
936 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
937 $(NOSTDINC_FLAGS) $(CPPFLAGS) \
938 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
940 quiet_cmd_as_o_S = AS $@
941 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
943 # read all saved command lines
945 targets := $(wildcard $(sort $(targets)))
946 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
948 ifneq ($(cmd_files),)
949 $(cmd_files): ; # Do not try to update included dependency files
950 include $(cmd_files)
951 endif
953 # execute the command and also postprocess generated .d dependencies
954 # file
956 if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
957 $(filter-out $(cmd_$(1)),$(cmd_$@))\
958 $(filter-out $(cmd_$@),$(cmd_$(1)))),\
959 @set -e; \
960 $(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) \
961 $(cmd_$(1)); \
962 scripts/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
963 rm -f $(depfile); \
964 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
966 # Usage: $(call if_changed_rule,foo)
967 # will check if $(cmd_foo) changed, or any of the prequisites changed,
968 # and if so will execute $(rule_foo)
970 if_changed_rule = $(if $(strip $? \
971 $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\
972 $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\
973 @$(rule_$(1)))
975 # If quiet is set, only print short version of command
977 cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
979 # filechk is used to check if the content of a generated file is updated.
980 # Sample usage:
981 # define filechk_sample
982 # echo $KERNELRELEASE
983 # endef
984 # version.h : Makefile
985 # $(call filechk,sample)
986 # The rule defined shall write to stdout the content of the new file.
987 # The existing file will be compared with the new one.
988 # - If no file exist it is created
989 # - If the content differ the new file is used
990 # - If they are equal no change, and no timestamp update
992 define filechk
993 @set -e; \
994 echo ' CHK $@'; \
995 mkdir -p $(dir $@); \
996 $(filechk_$(1)) < $< > $@.tmp; \
997 if [ -r $@ ] && cmp -s $@ $@.tmp; then \
998 rm -f $@.tmp; \
999 else \
1000 echo ' UPD $@'; \
1001 mv -f $@.tmp $@; \
1003 endef
1005 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=dir
1006 # Usage:
1007 # $(Q)$(MAKE) $(build)=dir
1008 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
1010 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1011 # Usage:
1012 # $(Q)$(MAKE) $(clean)=dir
1013 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1015 # $(call descend,<dir>,<target>)
1016 # Recursively call a sub-make in <dir> with target <target>
1017 # Usage is deprecated, because make does not see this as an invocation of make.
1018 descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj=$(1) $(2)
1020 endif # skip-makefile
1022 FORCE: