[PATCH] DVB: Other DVB core updates
[linux-2.6/history.git] / Makefile
blobc2510128ce143018cc035a5bee993b86830e99a7
1 VERSION = 2
2 PATCHLEVEL = 6
3 SUBLEVEL = 5
4 EXTRAVERSION =
5 NAME=Zonked Quokka
7 # *DOCUMENTATION*
8 # To see a list of typical targets execute "make help"
9 # More info can be located in ./README
10 # Comments in this file are targeted only to the developer, do not
11 # expect to learn how to build the kernel reading this file.
13 # Do not print "Entering directory ..."
14 MAKEFLAGS += --no-print-directory
16 # We are using a recursive build, so we need to do a little thinking
17 # to get the ordering right.
19 # Most importantly: sub-Makefiles should only ever modify files in
20 # their own directory. If in some directory we have a dependency on
21 # a file in another dir (which doesn't happen often, but it's of
22 # unavoidable when linking the built-in.o targets which finally
23 # turn into vmlinux), we will call a sub make in that other dir, and
24 # after that we are sure that everything which is in that other dir
25 # is now up to date.
27 # The only cases where we need to modify files which have global
28 # effects are thus separated out and done before the recursive
29 # descending is started. They are now explicitly listed as the
30 # prepare rule.
32 # To put more focus on warnings, be less verbose as default
33 # Use 'make V=1' to see the full commands
35 ifdef V
36 ifeq ("$(origin V)", "command line")
37 KBUILD_VERBOSE = $(V)
38 endif
39 endif
40 ifndef KBUILD_VERBOSE
41 KBUILD_VERBOSE = 0
42 endif
44 # Call sparse as part of compilation of C files
45 # Use 'make C=1' to enable sparse checking
47 ifdef C
48 ifeq ("$(origin C)", "command line")
49 KBUILD_CHECKSRC = $(C)
50 endif
51 endif
52 ifndef KBUILD_CHECKSRC
53 KBUILD_CHECKSRC = 0
54 endif
56 # kbuild supports saving output files in a separate directory.
57 # To locate output files in a separate directory two syntax'es are supported.
58 # In both cases the working directory must be the root of the kernel src.
59 # 1) O=
60 # Use "make O=dir/to/store/output/files/"
62 # 2) Set KBUILD_OUTPUT
63 # Set the environment variable KBUILD_OUTPUT to point to the directory
64 # where the output files shall be placed.
65 # export KBUILD_OUTPUT=dir/to/store/output/files/
66 # make
68 # The O= assigment takes precedence over the KBUILD_OUTPUT environment variable.
71 # KBUILD_SRC is set on invocation of make in OBJ directory
72 # KBUILD_SRC is not intended to be used by the regular user (for now)
73 ifeq ($(KBUILD_SRC),)
75 # OK, Make called in directory where kernel src resides
76 # Do we want to locate output files in a separate directory?
77 ifdef O
78 ifeq ("$(origin O)", "command line")
79 KBUILD_OUTPUT := $(O)
80 endif
81 endif
83 # That's our default target when none is given on the command line
84 .PHONY: all
85 all:
87 ifneq ($(KBUILD_OUTPUT),)
88 # Invoke a second make in the output directory, passing relevant variables
89 # check that the output directory actually exists
90 saved-output := $(KBUILD_OUTPUT)
91 KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
92 $(if $(wildcard $(KBUILD_OUTPUT)),, \
93 $(error output directory "$(saved-output)" does not exist))
95 .PHONY: $(MAKECMDGOALS)
97 $(filter-out all,$(MAKECMDGOALS)) all:
98 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
99 KBUILD_SRC=$(CURDIR) KBUILD_VERBOSE=$(KBUILD_VERBOSE) \
100 KBUILD_CHECK=$(KBUILD_CHECK) -f $(CURDIR)/Makefile $@
102 # Leave processing to above invocation of make
103 skip-makefile := 1
104 endif # ifneq ($(KBUILD_OUTPUT),)
105 endif # ifeq ($(KBUILD_SRC),)
107 # We process the rest of the Makefile if this is the final invocation of make
108 ifeq ($(skip-makefile),)
110 # Make sure we're not wasting cpu-cycles doing locale handling, yet do make
111 # sure error messages appear in the user-desired language
112 ifdef LC_ALL
113 LANG := $(LC_ALL)
114 LC_ALL :=
115 endif
116 LC_COLLATE := C
117 LC_CTYPE := C
118 export LANG LC_ALL LC_COLLATE LC_CTYPE
120 srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
121 TOPDIR := $(srctree)
122 # FIXME - TOPDIR is obsolete, use srctree/objtree
123 objtree := $(CURDIR)
124 src := $(srctree)
125 obj := $(objtree)
127 VPATH := $(srctree)
129 export srctree objtree VPATH TOPDIR
131 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
133 # SUBARCH tells the usermode build what the underlying arch is. That is set
134 # first, and if a usermode build is happening, the "ARCH=um" on the command
135 # line overrides the setting of ARCH below. If a native build is happening,
136 # then ARCH is assigned, getting whatever value it gets normally, and
137 # SUBARCH is subsequently ignored.
139 SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
140 -e s/arm.*/arm/ -e s/sa110/arm/ \
141 -e s/s390x/s390/ -e s/parisc64/parisc/ )
143 # Cross compiling and selecting different set of gcc/bin-utils
144 # ---------------------------------------------------------------------------
146 # When performing cross compilation for other architectures ARCH shall be set
147 # to the target architecture. (See arch/* for the possibilities).
148 # ARCH can be set during invocation of make:
149 # make ARCH=ia64
150 # Another way is to have ARCH set in the environment.
151 # The default ARCH is the host where make is executed.
153 # CROSS_COMPILE specify the prefix used for all executables used
154 # during compilation. Only gcc and related bin-utils executables
155 # are prefixed with $(CROSS_COMPILE).
156 # CROSS_COMPILE can be set on the command line
157 # make CROSS_COMPILE=ia64-linux-
158 # Alternatively CROSS_COMPILE can be set in the environment.
159 # Default value for CROSS_COMPILE is not to prefix executables
160 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
162 ARCH ?= $(SUBARCH)
163 CROSS_COMPILE ?=
165 # Architecture as present in compile.h
166 UTS_MACHINE := $(ARCH)
168 # SHELL used by kbuild
169 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
170 else if [ -x /bin/bash ]; then echo /bin/bash; \
171 else echo sh; fi ; fi)
173 HOSTCC = gcc
174 HOSTCXX = g++
175 HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
176 HOSTCXXFLAGS = -O2
178 # Decide whether to build built-in, modular, or both.
179 # Normally, just do built-in.
181 KBUILD_MODULES :=
182 KBUILD_BUILTIN := 1
184 # If we have only "make modules", don't compile built-in objects.
185 # When we're building modules with modversions, we need to consider
186 # the built-in objects during the descend as well, in order to
187 # make sure the checksums are uptodate before we record them.
189 ifeq ($(MAKECMDGOALS),modules)
190 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
191 endif
193 # If we have "make <whatever> modules", compile modules
194 # in addition to whatever we do anyway.
195 # Just "make" or "make all" shall build modules as well
197 ifneq ($(filter all modules,$(MAKECMDGOALS)),)
198 KBUILD_MODULES := 1
199 endif
201 ifeq ($(MAKECMDGOALS),)
202 KBUILD_MODULES := 1
203 endif
205 export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE
206 export KBUILD_CHECKSRC KBUILD_SRC
208 # Beautify output
209 # ---------------------------------------------------------------------------
211 # Normally, we echo the whole command before executing it. By making
212 # that echo $($(quiet)$(cmd)), we now have the possibility to set
213 # $(quiet) to choose other forms of output instead, e.g.
215 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
216 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
218 # If $(quiet) is empty, the whole command will be printed.
219 # If it is set to "quiet_", only the short version will be printed.
220 # If it is set to "silent_", nothing wil be printed at all, since
221 # the variable $(silent_cmd_cc_o_c) doesn't exist.
223 # A simple variant is to prefix commands with $(Q) - that's usefull
224 # for commands that shall be hidden in non-verbose mode.
226 # $(Q)ln $@ :<
228 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
229 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
231 ifeq ($(KBUILD_VERBOSE),1)
232 quiet =
234 else
235 quiet=quiet_
236 Q = @
237 endif
239 # If the user is running make -s (silent mode), suppress echoing of
240 # commands
242 ifneq ($(findstring s,$(MAKEFLAGS)),)
243 quiet=silent_
244 endif
246 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 ;)
248 export quiet Q KBUILD_VERBOSE check_gcc
250 # Look for make include files relative to root of kernel src
251 MAKEFLAGS += --include-dir=$(srctree)
253 # For maximum performance (+ possibly random breakage, uncomment
254 # the following)
256 #MAKEFLAGS += -rR
258 # Make variables (CC, etc...)
260 AS = $(CROSS_COMPILE)as
261 LD = $(CROSS_COMPILE)ld
262 CC = $(CROSS_COMPILE)gcc
263 CPP = $(CC) -E
264 AR = $(CROSS_COMPILE)ar
265 NM = $(CROSS_COMPILE)nm
266 STRIP = $(CROSS_COMPILE)strip
267 OBJCOPY = $(CROSS_COMPILE)objcopy
268 OBJDUMP = $(CROSS_COMPILE)objdump
269 AWK = awk
270 RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
271 else echo rpm; fi)
272 GENKSYMS = scripts/genksyms/genksyms
273 DEPMOD = /sbin/depmod
274 KALLSYMS = scripts/kallsyms
275 PERL = perl
276 CHECK = sparse
277 MODFLAGS = -DMODULE
278 CFLAGS_MODULE = $(MODFLAGS)
279 AFLAGS_MODULE = $(MODFLAGS)
280 LDFLAGS_MODULE = -r
281 CFLAGS_KERNEL =
282 AFLAGS_KERNEL =
284 NOSTDINC_FLAGS = -nostdinc -iwithprefix include
286 CPPFLAGS := -D__KERNEL__ -Iinclude \
287 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include)
289 CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs \
290 -fno-strict-aliasing -fno-common
291 AFLAGS := -D__ASSEMBLY__
293 export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
294 CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
295 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
296 HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE CHECK
298 export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
299 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
300 export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
302 export MODVERDIR := .tmp_versions
304 # The temporary file to save gcc -MD generated dependencies must not
305 # contain a comma
306 comma := ,
307 depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
309 # Files to ignore in find ... statements
311 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o
312 RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
314 # ===========================================================================
315 # Rules shared between *config targets and build targets
317 # Basic helpers built in scripts/
318 .PHONY: scripts_basic
319 scripts_basic:
320 $(Q)$(MAKE) $(build)=scripts/basic
322 # To make sure we do not include .config for any of the *config targets
323 # catch them early, and hand them over to scripts/kconfig/Makefile
324 # It is allowed to specify more targets when calling make, including
325 # mixing *config targets and build targets.
326 # For example 'make oldconfig all'.
327 # Detect when mixed targets is specified, and make a second invocation
328 # of make so .config is not included in this case either (for *config).
330 no-dot-config-targets := clean mrproper distclean \
331 cscope TAGS tags help %docs check%
333 config-targets := 0
334 mixed-targets := 0
335 dot-config := 1
337 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
338 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
339 dot-config := 0
340 endif
341 endif
343 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
344 config-targets := 1
345 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
346 mixed-targets := 1
347 endif
348 endif
350 ifeq ($(mixed-targets),1)
351 # ===========================================================================
352 # We're called with mixed targets (*config and build targets).
353 # Handle them one by one.
355 %:: FORCE
356 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
358 else
359 ifeq ($(config-targets),1)
360 # ===========================================================================
361 # *config targets only - make sure prerequisites are updated, and descend
362 # in scripts/kconfig to make the *config target
364 config: scripts_basic FORCE
365 $(Q)$(MAKE) $(build)=scripts/kconfig $@
366 %config: scripts_basic FORCE
367 $(Q)$(MAKE) $(build)=scripts/kconfig $@
369 else
370 # ===========================================================================
371 # Build targets only - this includes vmlinux, arch specific targets, clean
372 # targets and others. In general all targets except *config targets.
374 # Additional helpers built in scripts/
375 # Carefully list dependencies so we do not try to build scripts twice
376 # in parrallel
377 .PHONY: scripts
378 scripts: scripts_basic include/config/MARKER
379 $(Q)$(MAKE) $(build)=$(@)
381 scripts_basic: include/linux/autoconf.h
384 # That's our default target when none is given on the command line
385 # Note that 'modules' will be added as a prerequisite as well,
386 # in the CONFIG_MODULES part below
388 all: vmlinux
390 # Objects we will link into vmlinux / subdirs we need to visit
391 init-y := init/
392 drivers-y := drivers/ sound/
393 net-y := net/
394 libs-y := lib/
395 core-y := usr/
396 SUBDIRS :=
398 ifeq ($(dot-config),1)
399 # In this section, we need .config
401 # Read in dependencies to all Kconfig* files, make sure to run
402 # oldconfig if changes are detected.
403 -include .config.cmd
405 include .config
407 # If .config needs to be updated, it will be done via the dependency
408 # that autoconf has on .config.
409 # To avoid any implicit rule to kick in, define an empty command
410 .config: ;
412 # If .config is newer than include/linux/autoconf.h, someone tinkered
413 # with it and forgot to run make oldconfig
414 include/linux/autoconf.h: .config
415 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
416 else
417 # Dummy target needed, because used as prerequisite
418 include/linux/autoconf.h: ;
419 endif
421 include $(srctree)/arch/$(ARCH)/Makefile
423 # Let architecture Makefiles change CPPFLAGS if needed
424 CFLAGS := $(CPPFLAGS) $(CFLAGS)
425 AFLAGS := $(CPPFLAGS) $(AFLAGS)
427 core-y += kernel/ mm/ fs/ ipc/ security/ crypto/
429 SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
430 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
431 $(net-y) $(net-m) $(libs-y) $(libs-m)))
433 ALL_SUBDIRS := $(sort $(SUBDIRS) $(patsubst %/,%,$(filter %/, \
434 $(init-n) $(init-) \
435 $(core-n) $(core-) $(drivers-n) $(drivers-) \
436 $(net-n) $(net-) $(libs-n) $(libs-))))
438 init-y := $(patsubst %/, %/built-in.o, $(init-y))
439 core-y := $(patsubst %/, %/built-in.o, $(core-y))
440 drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y))
441 net-y := $(patsubst %/, %/built-in.o, $(net-y))
442 libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
443 libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
444 libs-y := $(libs-y1) $(libs-y2)
446 # Here goes the main Makefile
447 # ---------------------------------------------------------------------------
450 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
451 CFLAGS += -Os
452 else
453 CFLAGS += -O2
454 endif
456 ifndef CONFIG_FRAME_POINTER
457 CFLAGS += -fomit-frame-pointer
458 endif
460 ifdef CONFIG_DEBUG_INFO
461 CFLAGS += -g
462 endif
464 # warn about C99 declaration after statement
465 CFLAGS += $(call check_gcc,-Wdeclaration-after-statement,)
468 # INSTALL_PATH specifies where to place the updated kernel and system map
469 # images. Uncomment if you want to place them anywhere other than root.
472 #export INSTALL_PATH=/boot
475 # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
476 # relocations required by build roots. This is not defined in the
477 # makefile but the arguement can be passed to make if needed.
480 MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
481 export MODLIB
483 # Build vmlinux
484 # ---------------------------------------------------------------------------
486 # This is a bit tricky: If we need to relink vmlinux, we want
487 # the version number incremented, which means recompile init/version.o
488 # and relink init/init.o. However, we cannot do this during the
489 # normal descending-into-subdirs phase, since at that time
490 # we cannot yet know if we will need to relink vmlinux.
491 # So we descend into init/ inside the rule for vmlinux again.
492 head-y += $(HEAD)
493 vmlinux-objs := $(head-y) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y)
495 quiet_cmd_vmlinux__ = LD $@
496 define cmd_vmlinux__
497 $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(head-y) $(init-y) \
498 --start-group \
499 $(core-y) \
500 $(libs-y) \
501 $(drivers-y) \
502 $(net-y) \
503 --end-group \
504 $(filter .tmp_kallsyms%,$^) \
505 -o $@
506 endef
508 # set -e makes the rule exit immediately on error
510 define rule_vmlinux__
511 +set -e; \
512 $(if $(filter .tmp_kallsyms%,$^),, \
513 echo ' GEN .version'; \
514 . $(srctree)/scripts/mkversion > .tmp_version; \
515 mv -f .tmp_version .version; \
516 $(MAKE) $(build)=init; \
518 $(if $($(quiet)cmd_vmlinux__), \
519 echo ' $($(quiet)cmd_vmlinux__)' &&) \
520 $(cmd_vmlinux__); \
521 echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
522 endef
524 define rule_vmlinux
525 $(rule_vmlinux__); \
526 $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
527 endef
529 LDFLAGS_vmlinux += -T arch/$(ARCH)/kernel/vmlinux.lds.s
531 # Generate section listing all symbols and add it into vmlinux
532 # It's a three stage process:
533 # o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
534 # empty
535 # Running kallsyms on that gives us .tmp_kallsyms1.o with
536 # the right size
537 # o .tmp_vmlinux2 now has a __kallsyms section of the right size,
538 # but due to the added section, some addresses have shifted
539 # From here, we generate a correct .tmp_kallsyms2.o
540 # o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
542 ifdef CONFIG_KALLSYMS
544 kallsyms.o := .tmp_kallsyms2.o
546 quiet_cmd_kallsyms = KSYM $@
547 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) > $@
549 .tmp_kallsyms1.o .tmp_kallsyms2.o: %.o: %.S scripts FORCE
550 $(call if_changed_dep,as_o_S)
552 .tmp_kallsyms%.S: .tmp_vmlinux%
553 $(call cmd,kallsyms)
555 .tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
556 +$(call if_changed_rule,vmlinux__)
558 .tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
559 $(call if_changed_rule,vmlinux__)
561 endif
563 # Finally the vmlinux rule
565 vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
566 $(call if_changed_rule,vmlinux)
568 # The actual objects are generated when descending,
569 # make sure no implicit rule kicks in
571 $(sort $(vmlinux-objs)) arch/$(ARCH)/kernel/vmlinux.lds.s: $(SUBDIRS) ;
573 # Handle descending into subdirectories listed in $(SUBDIRS)
575 .PHONY: $(SUBDIRS)
576 $(SUBDIRS): prepare-all scripts
577 $(Q)$(MAKE) $(build)=$@
579 # Things we need to do before we recursively start building the kernel
580 # or the modules are listed in "prepare-all".
581 # A multi level approach is used. prepare1 is updated first, then prepare0.
582 # prepare-all is the collection point for the prepare targets.
584 .PHONY: prepare-all prepare prepare0 prepare1
586 # prepare1 is used to check if we are building in a separate output directory,
587 # and if so do:
588 # 1) Check that make has not been executed in the kernel src $(srctree)
589 # 2) Create the include2 directory, used for the second asm symlink
591 prepare1:
592 ifneq ($(KBUILD_SRC),)
593 @echo ' Using $(srctree) as source for kernel'
594 $(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \
595 echo " $(srctree) is not clean, please run 'make mrproper'";\
596 echo " in the '$(srctree)' directory.";\
597 /bin/false; \
599 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
600 $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
601 endif
603 prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
604 ifdef KBUILD_MODULES
605 ifeq ($(origin SUBDIRS),file)
606 $(Q)rm -rf $(MODVERDIR)
607 else
608 @echo '*** Warning: Overriding SUBDIRS on the command line can cause'
609 @echo '*** inconsistencies'
610 endif
611 endif
612 $(if $(CONFIG_MODULES),$(Q)mkdir -p $(MODVERDIR))
614 # All the preparing..
615 prepare-all: prepare0 prepare
617 # Leave this as default for preprocessing vmlinux.lds.S, which is now
618 # done in arch/$(ARCH)/kernel/Makefile
620 export AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
622 # Single targets
623 # ---------------------------------------------------------------------------
625 %.s: %.c scripts FORCE
626 $(Q)$(MAKE) $(build)=$(@D) $@
627 %.i: %.c scripts FORCE
628 $(Q)$(MAKE) $(build)=$(@D) $@
629 %.o: %.c scripts FORCE
630 $(Q)$(MAKE) $(build)=$(@D) $@
631 %/: scripts prepare FORCE
632 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
633 %.lst: %.c scripts FORCE
634 $(Q)$(MAKE) $(build)=$(@D) $@
635 %.s: %.S scripts FORCE
636 $(Q)$(MAKE) $(build)=$(@D) $@
637 %.o: %.S scripts FORCE
638 $(Q)$(MAKE) $(build)=$(@D) $@
640 # FIXME: The asm symlink changes when $(ARCH) changes. That's
641 # hard to detect, but I suppose "make mrproper" is a good idea
642 # before switching between archs anyway.
644 include/asm:
645 @echo ' SYMLINK $@ -> include/asm-$(ARCH)'
646 $(Q)if [ ! -d include ]; then mkdir -p include; fi;
647 @ln -fsn asm-$(ARCH) $@
649 # Split autoconf.h into include/linux/config/*
651 include/config/MARKER: include/linux/autoconf.h
652 @echo ' SPLIT include/linux/autoconf.h -> include/config/*'
653 @scripts/basic/split-include include/linux/autoconf.h include/config
654 @touch $@
656 # Generate some files
657 # ---------------------------------------------------------------------------
659 # version.h changes when $(KERNELRELEASE) etc change, as defined in
660 # this Makefile
662 uts_len := 64
664 define filechk_version.h
665 if ((`echo -n "$(KERNELRELEASE)" | wc -c ` > $(uts_len))); then \
666 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
667 exit 1; \
668 fi; \
669 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
670 echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
671 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
673 endef
675 include/linux/version.h: Makefile
676 $(call filechk,version.h)
678 # ---------------------------------------------------------------------------
680 .PHONY: depend dep
681 depend dep:
682 @echo '*** Warning: make $@ is unnecessary now.'
684 # ---------------------------------------------------------------------------
685 # Modules
687 ifdef CONFIG_MODULES
689 # By default, build modules as well
691 all: modules
693 # Build modules
695 .PHONY: modules
696 modules: $(SUBDIRS) $(if $(KBUILD_BUILTIN),vmlinux)
697 @echo ' Building modules, stage 2.';
698 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
700 # Install modules
702 .PHONY: modules_install
703 modules_install: _modinst_ _modinst_post
705 .PHONY: _modinst_
706 _modinst_:
707 @if [ -z "`$(DEPMOD) -V | grep module-init-tools`" ]; then \
708 echo "Warning: you may need to install module-init-tools"; \
709 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
710 sleep 1; \
712 @rm -rf $(MODLIB)/kernel
713 @rm -f $(MODLIB)/build
714 @mkdir -p $(MODLIB)/kernel
715 @ln -s $(TOPDIR) $(MODLIB)/build
716 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
718 # If System.map exists, run depmod. This deliberately does not have a
719 # dependency on System.map since that would run the dependency tree on
720 # vmlinux. This depmod is only for convenience to give the initial
721 # boot a modules.dep even before / is mounted read-write. However the
722 # boot script depmod is the master version.
723 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
724 depmod_opts :=
725 else
726 depmod_opts := -b $(INSTALL_MOD_PATH) -r
727 endif
728 .PHONY: _modinst_post
729 _modinst_post: _modinst_
730 if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
732 else # CONFIG_MODULES
734 # Modules not configured
735 # ---------------------------------------------------------------------------
737 modules modules_install: FORCE
738 @echo
739 @echo "The present kernel configuration has modules disabled."
740 @echo "Type 'make config' and enable loadable module support."
741 @echo "Then build a kernel with module support enabled."
742 @echo
743 @exit 1
745 endif # CONFIG_MODULES
747 # Generate asm-offsets.h
748 # ---------------------------------------------------------------------------
750 define filechk_gen-asm-offsets
751 (set -e; \
752 echo "#ifndef __ASM_OFFSETS_H__"; \
753 echo "#define __ASM_OFFSETS_H__"; \
754 echo "/*"; \
755 echo " * DO NOT MODIFY."; \
756 echo " *"; \
757 echo " * This file was generated by arch/$(ARCH)/Makefile"; \
758 echo " *"; \
759 echo " */"; \
760 echo ""; \
761 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
762 echo ""; \
763 echo "#endif" )
764 endef
768 # Cleaning is done on three levels.
769 # make clean Delete all automatically generated files, including
770 # tools and firmware.
771 # make mrproper Delete the current configuration, and related files
772 # Any core files spread around are deleted as well
773 # make distclean Remove editor backup files, patch leftover files and the like
775 # Directories & files removed with 'make clean'
776 CLEAN_DIRS += $(MODVERDIR) include/config include2
777 CLEAN_FILES += vmlinux System.map \
778 include/linux/autoconf.h include/linux/version.h \
779 include/asm include/linux/modversions.h \
780 kernel.spec .tmp*
782 # Files removed with 'make mrproper'
783 MRPROPER_FILES += .version .config .config.old tags TAGS cscope*
785 # clean - Delete all intermediate files
787 clean-dirs += $(addprefix _clean_,$(ALL_SUBDIRS) Documentation/DocBook scripts)
788 .PHONY: $(clean-dirs) clean archclean mrproper archmrproper distclean
789 $(clean-dirs):
790 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
792 clean: rm-dirs := $(wildcard $(CLEAN_DIRS))
793 mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
794 quiet_cmd_rmdirs = $(if $(rm-dirs),CLEAN $(rm-dirs))
795 cmd_rmdirs = rm -rf $(rm-dirs)
797 clean: rm-files := $(wildcard $(CLEAN_FILES))
798 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
799 quiet_cmd_rmfiles = $(if $(rm-files),CLEAN $(rm-files))
800 cmd_rmfiles = rm -rf $(rm-files)
802 clean: archclean $(clean-dirs)
803 $(call cmd,rmdirs)
804 $(call cmd,rmfiles)
805 @find . $(RCS_FIND_IGNORE) \
806 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
807 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
808 -type f -print | xargs rm -f
810 # mrproper
812 distclean: mrproper
813 mrproper: clean archmrproper
814 $(call cmd,rmdirs)
815 $(call cmd,rmfiles)
816 @find . $(RCS_FIND_IGNORE) \
817 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
818 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
819 -o -name '.*.rej' -o -size 0 \
820 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
821 -type f -print | xargs rm -f
823 # Generate tags for editors
824 # ---------------------------------------------------------------------------
826 define all-sources
827 ( find . $(RCS_FIND_IGNORE) \
828 \( -name include -o -name arch \) -prune -o \
829 -name '*.[chS]' -print; \
830 find arch/$(ARCH) $(RCS_FIND_IGNORE) \
831 -name '*.[chS]' -print; \
832 find include $(RCS_FIND_IGNORE) \
833 \( -name config -o -name 'asm-*' \) -prune \
834 -o -name '*.[chS]' -print; \
835 find include/asm-$(ARCH) $(RCS_FIND_IGNORE) \
836 -name '*.[chS]' -print; \
837 find include/asm-generic $(RCS_FIND_IGNORE) \
838 -name '*.[chS]' -print )
839 endef
841 quiet_cmd_cscope-file = FILELST cscope.files
842 cmd_cscope-file = $(all-sources) > cscope.files
844 quiet_cmd_cscope = MAKE cscope.out
845 cmd_cscope = cscope -k -b -q
847 cscope: FORCE
848 $(call cmd,cscope-file)
849 $(call cmd,cscope)
851 quiet_cmd_TAGS = MAKE $@
852 cmd_TAGS = $(all-sources) | etags -
854 # Exuberant ctags works better with -I
856 quiet_cmd_tags = MAKE $@
857 define cmd_tags
858 rm -f $@; \
859 CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
860 $(all-sources) | xargs ctags $$CTAGSF -a
861 endef
863 TAGS: FORCE
864 $(call cmd,TAGS)
866 tags: FORCE
867 $(call cmd,tags)
869 # RPM target
870 # ---------------------------------------------------------------------------
872 .PHONY: rpm
874 # Remove hyphens since they have special meaning in RPM filenames
875 KERNELPATH=kernel-$(subst -,,$(KERNELRELEASE))
877 # If you do a make spec before packing the tarball you can rpm -ta it
879 spec:
880 $(CONFIG_SHELL) $(srctree)/scripts/mkspec > $(objtree)/kernel.spec
882 # a) Build a tar ball
883 # b) generate an rpm from it
884 # c) and pack the result
885 # - Use /. to avoid tar packing just the symlink
887 rpm: clean spec
888 set -e; \
889 cd .. ; \
890 ln -sf $(srctree) $(KERNELPATH) ; \
891 tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
892 rm $(KERNELPATH)
894 set -e; \
895 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version;\
896 mv -f $(objtree)/.tmp_version $(objtree)/.version;
898 $(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz
899 rm ../$(KERNELPATH).tar.gz
901 # Brief documentation of the typical targets used
902 # ---------------------------------------------------------------------------
904 boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig)
905 boards := $(notdir $(boards))
907 help:
908 @echo 'Cleaning targets:'
909 @echo ' clean - remove most generated files but keep the config'
910 @echo ' mrproper - remove all generated files + config + various backup files'
911 @echo ''
912 @echo 'Configuration targets:'
913 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
914 @echo ''
915 @echo 'Other generic targets:'
916 @echo ' all - Build all targets marked with [*]'
917 @echo '* vmlinux - Build the bare kernel'
918 @echo '* modules - Build all modules'
919 @echo ' modules_install - Install all modules'
920 @echo ' dir/ - Build all files in dir and below'
921 @echo ' dir/file.[ois] - Build specified target only'
922 @echo ' rpm - Build a kernel as an RPM package'
923 @echo ' tags/TAGS - Generate tags file for editors'
924 @echo ' cscope - Generate cscope index'
925 @echo ''
926 @echo 'Documentation targets:'
927 @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
928 @echo ''
929 @echo 'Architecture specific targets ($(ARCH)):'
930 @$(if $(archhelp),$(archhelp),\
931 echo ' No architecture specific help defined for $(ARCH)')
932 @echo ''
933 @$(if $(boards), \
934 $(foreach b, $(boards), \
935 printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
936 echo '')
938 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
939 @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
940 @echo ' make C=1 [targets] Check all c source with checker tool'
941 @echo ''
942 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
943 @echo 'For further info see the ./README file'
946 # Documentation targets
947 # ---------------------------------------------------------------------------
948 %docs: scripts FORCE
949 $(Q)$(MAKE) $(build)=Documentation/DocBook $@
951 # Scripts to check various things for consistency
952 # ---------------------------------------------------------------------------
954 configcheck:
955 find * $(RCS_FIND_IGNORE) \
956 -name '*.[hcS]' -type f -print | sort \
957 | xargs $(PERL) -w scripts/checkconfig.pl
959 includecheck:
960 find * $(RCS_FIND_IGNORE) \
961 -name '*.[hcS]' -type f -print | sort \
962 | xargs $(PERL) -w scripts/checkincludes.pl
964 versioncheck:
965 find * $(RCS_FIND_IGNORE) \
966 -name '*.[hcS]' -type f -print | sort \
967 | xargs $(PERL) -w scripts/checkversion.pl
969 endif #ifeq ($(config-targets),1)
970 endif #ifeq ($(mixed-targets),1)
972 # FIXME Should go into a make.lib or something
973 # ===========================================================================
975 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
976 $(NOSTDINC_FLAGS) $(CPPFLAGS) \
977 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
979 quiet_cmd_as_o_S = AS $@
980 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
982 # read all saved command lines
984 targets := $(wildcard $(sort $(targets)))
985 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
987 ifneq ($(cmd_files),)
988 $(cmd_files): ; # Do not try to update included dependency files
989 include $(cmd_files)
990 endif
992 # execute the command and also postprocess generated .d dependencies
993 # file
995 if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
996 $(filter-out $(cmd_$(1)),$(cmd_$@))\
997 $(filter-out $(cmd_$@),$(cmd_$(1)))),\
998 @set -e; \
999 $(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) \
1000 $(cmd_$(1)); \
1001 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
1002 rm -f $(depfile); \
1003 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
1005 # Usage: $(call if_changed_rule,foo)
1006 # will check if $(cmd_foo) changed, or any of the prequisites changed,
1007 # and if so will execute $(rule_foo)
1009 if_changed_rule = $(if $(strip $? \
1010 $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\
1011 $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\
1012 @$(rule_$(1)))
1014 # If quiet is set, only print short version of command
1016 cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
1018 # filechk is used to check if the content of a generated file is updated.
1019 # Sample usage:
1020 # define filechk_sample
1021 # echo $KERNELRELEASE
1022 # endef
1023 # version.h : Makefile
1024 # $(call filechk,sample)
1025 # The rule defined shall write to stdout the content of the new file.
1026 # The existing file will be compared with the new one.
1027 # - If no file exist it is created
1028 # - If the content differ the new file is used
1029 # - If they are equal no change, and no timestamp update
1031 define filechk
1032 @set -e; \
1033 echo ' CHK $@'; \
1034 mkdir -p $(dir $@); \
1035 $(filechk_$(1)) < $< > $@.tmp; \
1036 if [ -r $@ ] && cmp -s $@ $@.tmp; then \
1037 rm -f $@.tmp; \
1038 else \
1039 echo ' UPD $@'; \
1040 mv -f $@.tmp $@; \
1042 endef
1044 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=dir
1045 # Usage:
1046 # $(Q)$(MAKE) $(build)=dir
1047 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
1049 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1050 # Usage:
1051 # $(Q)$(MAKE) $(clean)=dir
1052 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1054 # $(call descend,<dir>,<target>)
1055 # Recursively call a sub-make in <dir> with target <target>
1056 # Usage is deprecated, because make does not see this as an invocation of make.
1057 descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj=$(1) $(2)
1059 endif # skip-makefile
1061 FORCE: