[PPC] Move include/asm-ppc/arch-* to arch/ppc/*/include/mach
[barebox-mini2440.git] / Makefile
blobb0cb8fa2a3575c1403dae8637699ecb827b0fa9a
1 VERSION = 2
2 PATCHLEVEL = 0
3 SUBLEVEL = 0
4 EXTRAVERSION =-rc10
5 NAME = Amissive Actinocutious Kiwi
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:
14 # o use make's built-in rules and variables
15 # (this increases performance and avoid hard-to-debug behavour);
16 # o print "Entering directory ...";
17 MAKEFLAGS += -rR --no-print-directory
19 # We are using a recursive build, so we need to do a little thinking
20 # to get the ordering right.
22 # Most importantly: sub-Makefiles should only ever modify files in
23 # their own directory. If in some directory we have a dependency on
24 # a file in another dir (which doesn't happen often, but it's often
25 # unavoidable when linking the built-in.o targets which finally
26 # turn into uboot), we will call a sub make in that other dir, and
27 # after that we are sure that everything which is in that other dir
28 # is now up to date.
30 # The only cases where we need to modify files which have global
31 # effects are thus separated out and done before the recursive
32 # descending is started. They are now explicitly listed as the
33 # prepare rule.
35 # To put more focus on warnings, be less verbose as default
36 # Use 'make V=1' to see the full commands
38 ifdef V
39 ifeq ("$(origin V)", "command line")
40 KBUILD_VERBOSE = $(V)
41 endif
42 endif
43 ifndef KBUILD_VERBOSE
44 KBUILD_VERBOSE = 0
45 endif
47 # Call a source code checker (by default, "sparse") as part of the
48 # C compilation.
50 # Use 'make C=1' to enable checking of only re-compiled files.
51 # Use 'make C=2' to enable checking of *all* source files, regardless
52 # of whether they are re-compiled or not.
54 # See the file "Documentation/sparse.txt" for more details, including
55 # where to get the "sparse" utility.
57 ifdef C
58 ifeq ("$(origin C)", "command line")
59 KBUILD_CHECKSRC = $(C)
60 endif
61 endif
62 ifndef KBUILD_CHECKSRC
63 KBUILD_CHECKSRC = 0
64 endif
66 # Use make M=dir to specify directory of external module to build
67 # Old syntax make ... SUBDIRS=$PWD is still supported
68 # Setting the environment variable KBUILD_EXTMOD take precedence
69 ifdef SUBDIRS
70 KBUILD_EXTMOD ?= $(SUBDIRS)
71 endif
72 ifdef M
73 ifeq ("$(origin M)", "command line")
74 KBUILD_EXTMOD := $(M)
75 endif
76 endif
79 # kbuild supports saving output files in a separate directory.
80 # To locate output files in a separate directory two syntaxes are supported.
81 # In both cases the working directory must be the root of the kernel src.
82 # 1) O=
83 # Use "make O=dir/to/store/output/files/"
85 # 2) Set KBUILD_OUTPUT
86 # Set the environment variable KBUILD_OUTPUT to point to the directory
87 # where the output files shall be placed.
88 # export KBUILD_OUTPUT=dir/to/store/output/files/
89 # make
91 # The O= assignment takes precedence over the KBUILD_OUTPUT environment
92 # variable.
95 # KBUILD_SRC is set on invocation of make in OBJ directory
96 # KBUILD_SRC is not intended to be used by the regular user (for now)
97 ifeq ($(KBUILD_SRC),)
99 # OK, Make called in directory where kernel src resides
100 # Do we want to locate output files in a separate directory?
101 ifdef O
102 ifeq ("$(origin O)", "command line")
103 KBUILD_OUTPUT := $(O)
104 endif
105 endif
107 # That's our default target when none is given on the command line
108 PHONY := _all
109 _all:
111 ifneq ($(KBUILD_OUTPUT),)
112 # Invoke a second make in the output directory, passing relevant variables
113 # check that the output directory actually exists
114 saved-output := $(KBUILD_OUTPUT)
115 KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
116 $(if $(KBUILD_OUTPUT),, \
117 $(error output directory "$(saved-output)" does not exist))
119 PHONY += $(MAKECMDGOALS)
121 $(filter-out _all,$(MAKECMDGOALS)) _all:
122 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
123 KBUILD_SRC=$(CURDIR) \
124 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@
126 # Leave processing to above invocation of make
127 skip-makefile := 1
128 endif # ifneq ($(KBUILD_OUTPUT),)
129 endif # ifeq ($(KBUILD_SRC),)
131 # We process the rest of the Makefile if this is the final invocation of make
132 ifeq ($(skip-makefile),)
134 # If building an external module we do not care about the all: rule
135 # but instead _all depend on modules
136 PHONY += all
137 _all: all
139 srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
140 objtree := $(CURDIR)
141 src := $(srctree)
142 obj := $(objtree)
144 VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
146 export srctree objtree VPATH
148 # Cross compiling and selecting different set of gcc/bin-utils
149 # ---------------------------------------------------------------------------
151 # When performing cross compilation for other architectures ARCH shall be set
152 # to the target architecture. (See arch/* for the possibilities).
153 # ARCH can be set during invocation of make:
154 # make ARCH=ia64
155 # Another way is to have ARCH set in the environment.
156 # The default ARCH is the host where make is executed.
158 # CROSS_COMPILE specify the prefix used for all executables used
159 # during compilation. Only gcc and related bin-utils executables
160 # are prefixed with $(CROSS_COMPILE).
161 # CROSS_COMPILE can be set on the command line
162 # make CROSS_COMPILE=ia64-linux-
163 # Alternatively CROSS_COMPILE can be set in the environment.
164 # Default value for CROSS_COMPILE is not to prefix executables
166 ARCH ?= sandbox
167 CROSS_COMPILE ?=
169 # Architecture as present in compile.h
170 UTS_MACHINE := $(ARCH)
171 SRCARCH := $(ARCH)
173 KCONFIG_CONFIG ?= .config
175 # SHELL used by kbuild
176 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
177 else if [ -x /bin/bash ]; then echo /bin/bash; \
178 else echo sh; fi ; fi)
180 HOSTCC = gcc
181 HOSTCXX = g++
182 HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
183 HOSTCXXFLAGS = -O2
185 # Decide whether to build built-in, modular, or both.
186 # Normally, just do built-in.
188 KBUILD_MODULES :=
189 KBUILD_BUILTIN := 1
191 # If we have only "make modules", don't compile built-in objects.
192 # When we're building modules with modversions, we need to consider
193 # the built-in objects during the descend as well, in order to
194 # make sure the checksums are up to date before we record them.
196 ifeq ($(MAKECMDGOALS),modules)
197 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
198 endif
200 # If we have "make <whatever> modules", compile modules
201 # in addition to whatever we do anyway.
202 # Just "make" or "make all" shall build modules as well
204 ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
205 KBUILD_MODULES := 1
206 endif
208 export KBUILD_MODULES KBUILD_BUILTIN
209 export KBUILD_CHECKSRC KBUILD_SRC
211 # Beautify output
212 # ---------------------------------------------------------------------------
214 # Normally, we echo the whole command before executing it. By making
215 # that echo $($(quiet)$(cmd)), we now have the possibility to set
216 # $(quiet) to choose other forms of output instead, e.g.
218 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
219 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
221 # If $(quiet) is empty, the whole command will be printed.
222 # If it is set to "quiet_", only the short version will be printed.
223 # If it is set to "silent_", nothing will be printed at all, since
224 # the variable $(silent_cmd_cc_o_c) doesn't exist.
226 # A simple variant is to prefix commands with $(Q) - that's useful
227 # for commands that shall be hidden in non-verbose mode.
229 # $(Q)ln $@ :<
231 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
232 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
234 ifeq ($(KBUILD_VERBOSE),1)
235 quiet =
237 else
238 quiet=quiet_
239 Q = @
240 endif
242 # If the user is running make -s (silent mode), suppress echoing of
243 # commands
245 ifneq ($(findstring s,$(MAKEFLAGS)),)
246 quiet=silent_
247 endif
249 export quiet Q KBUILD_VERBOSE
252 # Look for make include files relative to root of kernel src
253 MAKEFLAGS += --include-dir=$(srctree)
255 # We need some generic definitions.
256 include $(srctree)/scripts/Kbuild.include
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 GENKSYMS = scripts/genksyms/genksyms
271 DEPMOD = /sbin/depmod
272 KALLSYMS = scripts/kallsyms
273 PERL = perl
274 CHECK = sparse
276 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
277 CFLAGS_KERNEL =
278 AFLAGS_KERNEL =
280 LDFLAGS_MODULE = -T common/module.lds
282 # When compiling out-of-tree modules, put MODVERDIR in the module
283 # tree rather than in the kernel tree. The kernel tree might
284 # even be read-only.
285 export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
287 # Use LINUXINCLUDE when you must reference the include/ directory.
288 # Needed to be compatible with the O= option
289 LINUXINCLUDE := -Iinclude \
290 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
291 -I$(srctree)/arch/$(ARCH)/include \
292 -include include/linux/autoconf.h
294 CPPFLAGS := -D__KERNEL__ -D__U_BOOT__ $(LINUXINCLUDE) -fno-builtin -ffreestanding
296 CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
297 -fno-strict-aliasing -fno-common -Os -pipe
298 AFLAGS := -D__ASSEMBLY__
300 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
301 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
302 KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
304 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
305 export ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
306 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
307 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
309 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
310 export CFLAGS CFLAGS_KERNEL
311 export AFLAGS AFLAGS_KERNEL
313 # Files to ignore in find ... statements
315 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
316 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
318 # ===========================================================================
319 # Rules shared between *config targets and build targets
321 # Basic helpers built in scripts/
322 PHONY += scripts_basic
323 scripts_basic:
324 $(Q)$(MAKE) $(build)=scripts/basic
326 # To avoid any implicit rule to kick in, define an empty command.
327 scripts/basic/%: scripts_basic ;
329 PHONY += outputmakefile
330 # outputmakefile generates a Makefile in the output directory, if using a
331 # separate output directory. This allows convenient use of make in the
332 # output directory.
333 outputmakefile:
334 ifneq ($(KBUILD_SRC),)
335 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
336 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
337 endif
339 # To make sure we do not include .config for any of the *config targets
340 # catch them early, and hand them over to scripts/kconfig/Makefile
341 # It is allowed to specify more targets when calling make, including
342 # mixing *config targets and build targets.
343 # For example 'make oldconfig all'.
344 # Detect when mixed targets is specified, and make a second invocation
345 # of make so .config is not included in this case either (for *config).
347 no-dot-config-targets := clean mrproper distclean \
348 cscope TAGS tags help %docs check% \
349 include/linux/version.h headers_% \
350 kernelrelease kernelversion
352 config-targets := 0
353 mixed-targets := 0
354 dot-config := 1
356 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
357 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
358 dot-config := 0
359 endif
360 endif
362 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
363 config-targets := 1
364 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
365 mixed-targets := 1
366 endif
367 endif
369 ifeq ($(mixed-targets),1)
370 # ===========================================================================
371 # We're called with mixed targets (*config and build targets).
372 # Handle them one by one.
374 %:: FORCE
375 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
377 else
378 ifeq ($(config-targets),1)
379 # ===========================================================================
380 # *config targets only - make sure prerequisites are updated, and descend
381 # in scripts/kconfig to make the *config target
383 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
384 # KBUILD_DEFCONFIG may point out an alternative default configuration
385 # used for 'make defconfig'
386 include $(srctree)/arch/$(ARCH)/Makefile
387 export KBUILD_DEFCONFIG
389 config %config: scripts_basic outputmakefile FORCE
390 $(Q)mkdir -p include/linux include/config
391 $(Q)$(MAKE) $(build)=scripts/kconfig $@
393 else
394 # ===========================================================================
395 # Build targets only - this includes uboot, arch specific targets, clean
396 # targets and others. In general all targets except *config targets.
398 # Additional helpers built in scripts/
399 # Carefully list dependencies so we do not try to build scripts twice
400 # in parallel
401 PHONY += scripts
402 scripts: scripts_basic include/config/auto.conf
403 $(Q)$(MAKE) $(build)=$(@)
405 # Objects we will link into uboot / subdirs we need to visit
406 common-y := common/ drivers/ commands/ lib/ net/ fs/
408 ifeq ($(dot-config),1)
409 # Read in config
410 -include include/config/auto.conf
412 # Read in dependencies to all Kconfig* files, make sure to run
413 # oldconfig if changes are detected.
414 -include include/config/auto.conf.cmd
416 # To avoid any implicit rule to kick in, define an empty command
417 $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
419 # If .config is newer than include/config/auto.conf, someone tinkered
420 # with it and forgot to run make oldconfig.
421 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
422 # we execute the config step to be sure to catch updated Kconfig files
423 include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
424 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
426 else
427 # Dummy target needed, because used as prerequisite
428 include/config/auto.conf: ;
429 endif # $(dot-config)
431 # The all: target is the default when no target is given on the
432 # command line.
433 # This allow a user to issue only 'make' to build a kernel
434 # Defaults uboot but it is usually overridden in the arch makefile
435 all: uboot.bin
437 include $(srctree)/arch/$(ARCH)/Makefile
439 ifdef CONFIG_DEBUG_INFO
440 CFLAGS += -g
441 endif
443 # Force gcc to behave correct even for buggy distributions
444 CFLAGS += $(call cc-option, -fno-stack-protector)
446 # arch Makefile may override CC so keep this after arch Makefile is included
447 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
448 CHECKFLAGS += $(NOSTDINC_FLAGS)
450 # warn about C99 declaration after statement
451 CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
453 # disable pointer signed / unsigned warnings in gcc 4.0
454 CFLAGS += $(call cc-option,-Wno-pointer-sign,)
456 # Default kernel image to build when no specific target is given.
457 # KBUILD_IMAGE may be overruled on the command line or
458 # set in the environment
459 # Also any assignments in arch/$(ARCH)/Makefile take precedence over
460 # this default value
461 export KBUILD_IMAGE ?= uboot
463 uboot-dirs := $(patsubst %/,%,$(filter %/, $(common-y)))
465 uboot-alldirs := $(sort $(uboot-dirs) $(patsubst %/,%,$(filter %/, \
466 $(common-n) $(common-) \
467 $(core-n) $(core-) $(drivers-n) $(drivers-) \
468 $(net-n) $(net-) $(libs-n) $(libs-))))
470 common-y := $(patsubst %/, %/built-in.o, $(common-y))
472 # Build uboot
473 # ---------------------------------------------------------------------------
474 # uboot is built from the objects selected by $(uboot-init) and
475 # $(uboot-main). Most are built-in.o files from top-level directories
476 # in the kernel tree, others are specified in arch/$(ARCH)Makefile.
477 # Ordering when linking is important, and $(uboot-init) must be first.
479 # FIXME: This picture is wrong for U-Boot. We have no init, driver, mm
481 # uboot
484 # +-< $(uboot-init)
485 # | +--< init/version.o + more
487 # +--< $(uboot-main)
488 # | +--< driver/built-in.o mm/built-in.o + more
490 # +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
492 # uboot version cannot be updated during normal
493 # descending-into-subdirs phase since we do not yet know if we need to
494 # update uboot.
496 # System.map is generated to document addresses of all kernel symbols
498 uboot-common := $(common-y)
499 uboot-all := $(uboot-common)
500 uboot-lds := $(lds-y)
502 # Rule to link uboot
503 # May be overridden by arch/$(ARCH)/Makefile
504 quiet_cmd_uboot__ ?= LD $@
505 cmd_uboot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_uboot) -o $@ \
506 -T $(uboot-lds) $(uboot-head) \
507 --start-group $(uboot-common) --end-group \
508 $(filter-out $(uboot-lds) $(uboot-common) FORCE ,$^)
510 # Generate new uboot version
511 quiet_cmd_uboot_version = GEN .version
512 cmd_uboot_version = set -e; \
513 if [ ! -r .version ]; then \
514 rm -f .version; \
515 echo 1 >.version; \
516 else \
517 mv .version .old_version; \
518 expr 0$$(cat .old_version) + 1 >.version; \
519 fi; \
522 # Generate System.map
523 quiet_cmd_sysmap = SYSMAP
524 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
526 # Link of uboot
527 # Generate System.map and verify that the content is consistent
528 # Use + in front of the uboot_version rule to silent warning with make -j2
529 # First command is ':' to allow us to use + in front of the rule
530 define rule_uboot__
533 $(call cmd,uboot__)
535 $(Q)echo 'cmd_$@ := $(cmd_uboot__)' > $(@D)/.$(@F).cmd
537 $(Q)$(if $($(quiet)cmd_sysmap), \
538 echo ' $($(quiet)cmd_sysmap) System.map' &&) \
539 $(cmd_sysmap) $@ System.map; \
540 if [ $$? -ne 0 ]; then \
541 rm -f $@; \
542 /bin/false; \
544 endef
546 ifdef CONFIG_KALLSYMS
547 # Generate section listing all symbols and add it into uboot $(kallsyms.o)
548 # It's a three stage process:
549 # o .tmp_uboot1 has all symbols and sections, but __kallsyms is
550 # empty
551 # Running kallsyms on that gives us .tmp_kallsyms1.o with
552 # the right size - uboot version is updated during this step
553 # o .tmp_uboot2 now has a __kallsyms section of the right size,
554 # but due to the added section, some addresses have shifted.
555 # From here, we generate a correct .tmp_kallsyms2.o
556 # o The correct .tmp_kallsyms2.o is linked into the final uboot.
557 # o Verify that the System.map from uboot matches the map from
558 # .tmp_uboot2, just in case we did not generate kallsyms correctly.
559 # o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
560 # .tmp_uboot3 and .tmp_kallsyms3.o. This is only meant as a
561 # temporary bypass to allow the kernel to be built while the
562 # maintainers work out what went wrong with kallsyms.
564 ifdef CONFIG_KALLSYMS_EXTRA_PASS
565 last_kallsyms := 3
566 else
567 last_kallsyms := 2
568 endif
570 kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
572 define verify_kallsyms
573 $(Q)$(if $($(quiet)cmd_sysmap), \
574 echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \
575 $(cmd_sysmap) .tmp_uboot$(last_kallsyms) .tmp_System.map
576 $(Q)cmp -s System.map .tmp_System.map || \
577 (echo Inconsistent kallsyms data; \
578 echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \
579 rm .tmp_kallsyms* ; /bin/false )
580 endef
582 # Update uboot version before link
583 # Use + in front of this rule to silent warning about make -j1
584 # First command is ':' to allow us to use + in front of this rule
585 cmd_ksym_ld = $(cmd_uboot__)
586 define rule_ksym_ld
588 +$(call cmd,uboot_version)
589 $(call cmd,uboot__)
590 $(Q)echo 'cmd_$@ := $(cmd_uboot__)' > $(@D)/.$(@F).cmd
591 endef
593 # Generate .S file with all kernel symbols
594 quiet_cmd_kallsyms = KSYM $@
595 cmd_kallsyms = $(NM) -g -n $< | $(KALLSYMS) > $@
597 .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
598 $(call if_changed_dep,as_o_S)
600 .tmp_kallsyms%.S: .tmp_uboot% $(KALLSYMS)
601 $(call cmd,kallsyms)
603 # .tmp_uboot1 must be complete except kallsyms, so update uboot version
604 .tmp_uboot1: $(uboot-lds) $(uboot-all) FORCE
605 $(call if_changed_rule,ksym_ld)
607 .tmp_uboot2: $(uboot-lds) $(uboot-all) .tmp_kallsyms1.o FORCE
608 $(call if_changed,uboot__)
610 .tmp_uboot3: $(uboot-lds) $(uboot-all) .tmp_kallsyms2.o FORCE
611 $(call if_changed,uboot__)
613 # Needs to visit scripts/ before $(KALLSYMS) can be used.
614 $(KALLSYMS): scripts ;
616 # Generate some data for debugging strange kallsyms problems
617 debug_kallsyms: .tmp_map$(last_kallsyms)
619 .tmp_map%: .tmp_uboot% FORCE
620 ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
622 .tmp_map3: .tmp_map2
624 .tmp_map2: .tmp_map1
626 endif # ifdef CONFIG_KALLSYMS
628 # Do modpost on a prelinked vmlinux. The finally linked vmlinux has
629 # relevant sections renamed as per the linker script.
630 quiet_cmd_uboot-modpost = LD $@
631 cmd_uboot-modpost = $(LD) $(LDFLAGS) -r -o $@ \
632 $(vmlinux-init) --start-group $(uboot-main) --end-group \
633 $(filter-out $(uboot-init) $(uboot-main) $(uboot-lds) FORCE ,$^)
634 define rule_uboot-modpost
636 +$(call cmd,uboot-modpost)
637 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
638 $(Q)echo 'cmd_$@ := $(cmd_uboot-modpost)' > $(dot-target).cmd
639 endef
641 uboot.bin: uboot
642 $(Q)$(OBJCOPY) -O binary uboot uboot.bin
643 $(Q)$(OBJDUMP) -d uboot > uboot.S
645 # uboot image
646 uboot: $(uboot-lds) $(uboot-head) $(uboot-common) $(kallsyms.o) FORCE
647 $(call uboot-modpost)
648 $(call if_changed_rule,uboot__)
649 $(Q)rm -f .old_version
651 # The actual objects are generated when descending,
652 # make sure no implicit rule kicks in
653 $(sort $(uboot-head) $(uboot-common) ) $(uboot-lds): $(uboot-dirs) ;
655 # Handle descending into subdirectories listed in $(uboot-dirs)
656 # Preset locale variables to speed up the build process. Limit locale
657 # tweaks to this spot to avoid wrong language settings when running
658 # make menuconfig etc.
659 # Error messages still appears in the original language
661 PHONY += $(uboot-dirs)
662 $(uboot-dirs): prepare scripts
663 $(Q)$(MAKE) $(build)=$@
665 # Build the kernel release string
667 # The KERNELRELEASE value built here is stored in the file
668 # include/config/kernel.release, and is used when executing several
669 # make targets, such as "make install" or "make modules_install."
671 # The eventual kernel release string consists of the following fields,
672 # shown in a hierarchical format to show how smaller parts are concatenated
673 # to form the larger and final value, with values coming from places like
674 # the Makefile, kernel config options, make command line options and/or
675 # SCM tag information.
677 # $(KERNELVERSION)
678 # $(VERSION) eg, 2
679 # $(PATCHLEVEL) eg, 6
680 # $(SUBLEVEL) eg, 18
681 # $(EXTRAVERSION) eg, -rc6
682 # $(localver-full)
683 # $(localver)
684 # localversion* (all localversion* files)
685 # $(CONFIG_LOCALVERSION) (from kernel config setting)
686 # $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set)
687 # ./scripts/setlocalversion (SCM tag, if one exists)
688 # $(LOCALVERSION) (from make command line if provided)
690 # Note how the final $(localver-auto) string is included *only* if the
691 # kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the
692 # moment, only git is supported but other SCMs can edit the script
693 # scripts/setlocalversion and add the appropriate checks as needed.
695 nullstring :=
696 space := $(nullstring) # end of line
698 ___localver = $(objtree)/localversion* $(srctree)/localversion*
699 __localver = $(sort $(wildcard $(___localver)))
700 # skip backup files (containing '~')
701 _localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))
703 localver = $(subst $(space),, \
704 $(shell cat /dev/null $(_localver)) \
705 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
707 # If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called
708 # and if the SCM is know a tag from the SCM is appended.
709 # The appended tag is determined by the SCM used.
711 # Currently, only git is supported.
712 # Other SCMs can edit scripts/setlocalversion and add the appropriate
713 # checks as needed.
714 ifdef CONFIG_LOCALVERSION_AUTO
715 _localver-auto = $(shell $(CONFIG_SHELL) \
716 $(srctree)/scripts/setlocalversion $(srctree))
717 localver-auto = $(LOCALVERSION)$(_localver-auto)
718 endif
720 localver-full = $(localver)$(localver-auto)
722 # Store (new) KERNELRELASE string in include/config/kernel.release
723 kernelrelease = $(KERNELVERSION)$(localver-full)
724 include/config/kernel.release: include/config/auto.conf FORCE
725 $(Q)rm -f $@
726 $(Q)echo $(kernelrelease) > $@
729 # Things we need to do before we recursively start building the kernel
730 # or the modules are listed in "prepare".
731 # A multi level approach is used. prepareN is processed before prepareN-1.
732 # archprepare is used in arch Makefiles and when processed asm symlink,
733 # version.h and scripts_basic is processed / created.
735 # Listed in dependency order
736 PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
738 # prepare-all is deprecated, use prepare as valid replacement
739 PHONY += prepare-all
741 # prepare3 is used to check if we are building in a separate output directory,
742 # and if so do:
743 # 1) Check that make has not been executed in the kernel src $(srctree)
744 # 2) Create the include2 directory, used for the second asm symlink
745 prepare3: include/config/kernel.release
746 ifneq ($(KBUILD_SRC),)
747 @echo ' Using $(srctree) as source for kernel'
748 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
749 echo " $(srctree) is not clean, please run 'make mrproper'";\
750 echo " in the '$(srctree)' directory.";\
751 /bin/false; \
753 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
754 $(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/u-boot.h ]; then \
755 ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
757 endif
759 # prepare2 creates a makefile if using a separate output directory
760 prepare2: prepare3 outputmakefile
762 prepare1: prepare2 include/linux/version.h include/linux/utsrelease.h \
763 include/asm include/config.h include/config/auto.conf
765 ifneq ($(KBUILD_MODULES),)
766 $(Q)mkdir -p $(MODVERDIR)
767 $(Q)rm -f $(MODVERDIR)/*
768 endif
770 archprepare: prepare1 scripts_basic
772 prepare0: archprepare FORCE
773 $(Q)$(MAKE) $(build)=.
775 # All the preparing..
776 prepare prepare-all: prepare0
778 # Leave this as default for preprocessing uboot.lds.S, which is now
779 # done in arch/$(ARCH)/kernel/Makefile
781 export CPPFLAGS_uboot.lds += -P -C -U$(ARCH)
783 # FIXME: The asm symlink changes when $(ARCH) changes. That's
784 # hard to detect, but I suppose "make mrproper" is a good idea
785 # before switching between archs anyway.
787 define check-symlink
788 set -e; \
789 if [ -L include/asm ]; then \
790 asmlink=`readlink include/asm | cut -d '-' -f 2`; \
791 if [ "$$asmlink" != "$(SRCARCH)" ]; then \
792 echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
793 echo " set ARCH or save .config and run 'make mrproper' to fix it"; \
794 exit 1; \
795 fi; \
797 endef
799 # We create the target directory of the symlink if it does
800 # not exist so the test in chack-symlink works and we have a
801 # directory for generated filesas used by some architectures.
802 define create-symlink
803 if [ ! -L include/asm ]; then \
804 echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
805 if [ ! -d include/asm-$(SRCARCH) ]; then \
806 mkdir -p include/asm-$(SRCARCH); \
807 fi; \
808 ln -fsn asm-$(SRCARCH) $@; \
810 endef
812 include/asm:
813 $(Q)$(check-symlink)
814 $(Q)$(create-symlink)
816 include/config.h: include/config/auto.conf
817 @echo ' SYMLINK $@ -> board/$(board-y)/config.h'
818 ifneq ($(KBUILD_SRC),)
819 $(Q)ln -fsn $(srctree)/board/$(board-y)/config.h $@
820 else
821 @ln -fsn ../board/$(board-y)/config.h $@
822 endif
824 # Generate some files
825 # ---------------------------------------------------------------------------
827 # KERNELRELEASE can change from a few different places, meaning version.h
828 # needs to be updated, so this check is forced on all builds
830 uts_len := 64
831 define filechk_utsrelease.h
832 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
833 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
834 exit 1; \
835 fi; \
836 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";)
837 endef
839 define filechk_version.h
840 (echo \#define LINUX_VERSION_CODE $(shell \
841 expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
842 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
843 endef
845 include/linux/version.h: $(srctree)/Makefile FORCE
846 $(call filechk,version.h)
848 include/linux/utsrelease.h: include/config/kernel.release FORCE
849 $(call filechk,utsrelease.h)
851 # ---------------------------------------------------------------------------
853 PHONY += depend dep
854 depend dep:
855 @echo '*** Warning: make $@ is unnecessary now.'
857 # ---------------------------------------------------------------------------
858 # Modules
860 ifdef CONFIG_MODULES
862 # By default, build modules as well
864 all: modules
866 # Build modules
868 PHONY += modules
869 modules: $(uboot-dirs) $(if $(KBUILD_BUILTIN),uboot)
870 @echo ' Building modules, stage 2.';
871 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
874 # Target to prepare building external modules
875 PHONY += modules_prepare
876 modules_prepare: prepare scripts
878 # Target to install modules
879 PHONY += modules_install
880 modules_install: _modinst_ _modinst_post
882 PHONY += _modinst_
883 _modinst_:
884 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
885 echo "Warning: you may need to install module-init-tools"; \
886 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
887 sleep 1; \
889 @rm -rf $(MODLIB)/kernel
890 @rm -f $(MODLIB)/source
891 @mkdir -p $(MODLIB)/kernel
892 @ln -s $(srctree) $(MODLIB)/source
893 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
894 rm -f $(MODLIB)/build ; \
895 ln -s $(objtree) $(MODLIB)/build ; \
897 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
899 # If System.map exists, run depmod. This deliberately does not have a
900 # dependency on System.map since that would run the dependency tree on
901 # vmlinux. This depmod is only for convenience to give the initial
902 # boot a modules.dep even before / is mounted read-write. However the
903 # boot script depmod is the master version.
904 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
905 depmod_opts :=
906 else
907 depmod_opts := -b $(INSTALL_MOD_PATH) -r
908 endif
909 PHONY += _modinst_post
910 _modinst_post: _modinst_
911 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
913 else # CONFIG_MODULES
915 # Modules not configured
916 # ---------------------------------------------------------------------------
918 modules modules_install: FORCE
919 @echo
920 @echo "The present kernel configuration has modules disabled."
921 @echo "Type 'make config' and enable loadable module support."
922 @echo "Then build a kernel with module support enabled."
923 @echo
924 @exit 1
926 endif # CONFIG_MODULES
929 # Cleaning is done on three levels.
930 # make clean Delete most generated files
931 # Leave enough to build external modules
932 # make mrproper Delete the current configuration, and all generated files
933 # make distclean Remove editor backup files, patch leftover files and the like
935 # Directories & files removed with 'make clean'
936 CLEAN_DIRS += $(MODVERDIR)
937 CLEAN_FILES += uboot System.map include/uboot_default_env.h \
938 .tmp_version .tmp_uboot* uboot.bin uboot.S \
939 .tmp_kallsyms* uboot_default_env
941 # Directories & files removed with 'make mrproper'
942 MRPROPER_DIRS += include/config include2 usr/include
943 MRPROPER_FILES += .config .config.old include/asm .version .old_version \
944 include/linux/autoconf.h include/linux/version.h \
945 include/linux/utsrelease.h include/config.h \
946 Module.symvers tags TAGS cscope*
948 # clean - Delete most, but leave enough to build external modules
950 clean: rm-dirs := $(CLEAN_DIRS)
951 clean: rm-files := $(CLEAN_FILES)
952 clean-dirs := $(addprefix _clean_,$(srctree) $(uboot-alldirs))
954 PHONY += $(clean-dirs) clean archclean
955 $(clean-dirs):
956 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
958 clean: archclean $(clean-dirs)
959 $(call cmd,rmdirs)
960 $(call cmd,rmfiles)
961 @find . $(RCS_FIND_IGNORE) \
962 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
963 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
964 -o -name '*.symtypes' \) \
965 -type f -print | xargs rm -f
967 # mrproper - Delete all generated files, including .config
969 mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
970 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
971 mrproper-dirs := $(addprefix _mrproper_,scripts)
973 PHONY += $(mrproper-dirs) mrproper archmrproper
974 $(mrproper-dirs):
975 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
977 mrproper: clean archmrproper $(mrproper-dirs)
978 $(call cmd,rmdirs)
979 $(call cmd,rmfiles)
981 # distclean
983 PHONY += distclean
985 distclean: mrproper
986 @find $(srctree) $(RCS_FIND_IGNORE) \
987 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
988 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
989 -o -name '.*.rej' -o -size 0 \
990 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
991 -type f -print | xargs rm -f
994 # Packaging of the kernel to various formats
995 # ---------------------------------------------------------------------------
996 # rpm target kept for backward compatibility
997 package-dir := $(srctree)/scripts/package
999 %pkg: include/config/kernel.release FORCE
1000 $(Q)$(MAKE) $(build)=$(package-dir) $@
1001 rpm: include/config/kernel.release FORCE
1002 $(Q)$(MAKE) $(build)=$(package-dir) $@
1005 # Brief documentation of the typical targets used
1006 # ---------------------------------------------------------------------------
1008 boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig)
1009 boards := $(notdir $(boards))
1011 help:
1012 @echo 'Cleaning targets:'
1013 @echo ' clean - Remove most generated files but keep the config and'
1014 @echo ' enough build support to build external modules'
1015 @echo ' mrproper - Remove all generated files + config + various backup files'
1016 @echo ' distclean - mrproper + remove editor backup and patch files'
1017 @echo ' docs - start doxygen for all output types (only HTML - FIXME)'
1018 @echo ' htmldocs - create documentation in HTML format'
1019 @echo ''
1020 @echo 'Configuration targets:'
1021 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1022 @echo ''
1023 @echo 'Other generic targets:'
1024 @echo ' all - Build all targets marked with [*]'
1025 @echo '* uboot - Build the bare kernel'
1026 @echo ' dir/ - Build all files in dir and below'
1027 @echo ' dir/file.[ois] - Build specified target only'
1028 @echo ' dir/file.ko - Build module including final link'
1029 @echo ' tags/TAGS - Generate tags file for editors'
1030 @echo ' cscope - Generate cscope index'
1031 @echo ' (default: $(INSTALL_HDR_PATH))'
1032 @echo ''
1033 @echo 'Static analysers'
1034 @echo ' checkstack - Generate a list of stack hogs'
1035 @echo ' namespacecheck - Name space analysis on compiled kernel'
1036 @if [ -r include/asm-$(ARCH)/Kbuild ]; then \
1037 echo ' headers_check - Sanity check on exported headers'; \
1039 @echo ''
1040 @echo 'Architecture specific targets ($(ARCH)):'
1041 @$(if $(archhelp),$(archhelp),\
1042 echo ' No architecture specific help defined for $(ARCH)')
1043 @echo ''
1044 @$(if $(boards), \
1045 $(foreach b, $(boards), \
1046 printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1047 echo '')
1049 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
1050 @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
1051 @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
1052 @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
1053 @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
1054 @echo ''
1055 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
1056 @echo 'For further info see the ./README file'
1058 # Generate doxygen docs
1059 # ---------------------------------------------------------------------------
1060 .PHONY += docs htmldocs
1062 docs : htmldocs
1064 htmldocs:
1065 @echo 'Running doxygen with local Doxyfile'
1066 $(Q)doxygen Doxyfile
1068 # Generate tags for editors
1069 # ---------------------------------------------------------------------------
1071 #We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
1072 #(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
1073 #Adding $(srctree) adds about 20M on i386 to the size of the output file!
1075 ifeq ($(src),$(obj))
1076 __srctree =
1077 else
1078 __srctree = $(srctree)/
1079 endif
1081 ifeq ($(ALLSOURCE_ARCHS),)
1082 ifeq ($(ARCH),um)
1083 ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
1084 else
1085 ALLINCLUDE_ARCHS := $(ARCH)
1086 endif
1087 else
1088 #Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behavour.
1089 ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
1090 endif
1092 ALLSOURCE_ARCHS := $(ARCH)
1094 define find-sources
1095 ( find $(__srctree) $(RCS_FIND_IGNORE) \
1096 \( -name include -o -name arch \) -prune -o \
1097 -name $1 -print; \
1098 for ARCH in $(ALLSOURCE_ARCHS) ; do \
1099 find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \
1100 -name $1 -print; \
1101 done ; \
1102 find $(__srctree)include $(RCS_FIND_IGNORE) \
1103 \( -name config -o -name 'asm-*' \) -prune \
1104 -o -name $1 -print; \
1105 for ARCH in $(ALLINCLUDE_ARCHS) ; do \
1106 test -e $(__srctree)include/asm-$${arch} && \
1107 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
1108 -name $1 -print; \
1109 test -e $(__srctree)arch/$${arch}/include/asm && \
1110 find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \
1111 -name $1 -print; \
1112 done ; \
1113 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
1114 -name $1 -print )
1115 endef
1117 define all-sources
1118 $(call find-sources,'*.[chS]')
1119 endef
1120 define all-kconfigs
1121 $(call find-sources,'Kconfig*')
1122 endef
1123 define all-defconfigs
1124 $(call find-sources,'defconfig')
1125 endef
1127 define xtags
1128 if $1 --version 2>&1 | grep -iq exuberant; then \
1129 $(all-sources) | xargs $1 -a \
1130 -I __initdata,__exitdata,__acquires,__releases \
1131 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
1132 --extra=+f --c-kinds=+px \
1133 --regex-asm='/ENTRY\(([^)]*)\).*/\1/'; \
1134 $(all-kconfigs) | xargs $1 -a \
1135 --langdef=kconfig \
1136 --language-force=kconfig \
1137 --regex-kconfig='/^[[:blank:]]*config[[:blank:]]+([[:alnum:]_]+)/\1/'; \
1138 $(all-defconfigs) | xargs -r $1 -a \
1139 --langdef=dotconfig \
1140 --language-force=dotconfig \
1141 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \
1142 elif $1 --version 2>&1 | grep -iq emacs; then \
1143 $(all-sources) | xargs $1 -a; \
1144 $(all-kconfigs) | xargs $1 -a \
1145 --regex='/^[ \t]*config[ \t]+\([a-zA-Z0-9_]+\)/\1/'; \
1146 $(all-defconfigs) | xargs -r $1 -a \
1147 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \
1148 else \
1149 $(all-sources) | xargs $1 -a; \
1151 endef
1153 quiet_cmd_cscope-file = FILELST cscope.files
1154 cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
1156 quiet_cmd_cscope = MAKE cscope.out
1157 cmd_cscope = cscope -b
1159 cscope: FORCE
1160 $(call cmd,cscope-file)
1161 $(call cmd,cscope)
1163 quiet_cmd_TAGS = MAKE $@
1164 define cmd_TAGS
1165 rm -f $@; \
1166 $(call xtags,etags)
1167 endef
1169 TAGS: FORCE
1170 $(call cmd,TAGS)
1172 quiet_cmd_tags = MAKE $@
1173 define cmd_tags
1174 rm -f $@; \
1175 $(call xtags,ctags)
1176 endef
1178 tags: FORCE
1179 $(call cmd,tags)
1182 endif #ifeq ($(config-targets),1)
1183 endif #ifeq ($(mixed-targets),1)
1185 # Single targets
1186 # ---------------------------------------------------------------------------
1187 # Single targets are compatible with:
1188 # - build whith mixed source and output
1189 # - build with separate output dir 'make O=...'
1190 # - external modules
1192 # target-dir => where to store outputfile
1193 # build-dir => directory in kernel source tree to use
1195 build-dir = $(patsubst %/,%,$(dir $@))
1196 target-dir = $(dir $@)
1198 %.s: %.c prepare scripts FORCE
1199 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1200 %.i: %.c prepare scripts FORCE
1201 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1202 %.o: %.c prepare scripts FORCE
1203 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1204 %.lst: %.c prepare scripts FORCE
1205 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1206 %.s: %.S prepare scripts FORCE
1207 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1208 %.o: %.S prepare scripts FORCE
1209 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1210 %.symtypes: %.c prepare scripts FORCE
1211 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1213 # Modules
1214 / %/: prepare scripts FORCE
1215 $(Q)$(MAKE) $(build)=$(build-dir)
1216 %.ko: prepare scripts FORCE
1217 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1218 $(build)=$(build-dir) $(@:.ko=.o)
1219 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1221 # FIXME Should go into a make.lib or something
1222 # ===========================================================================
1224 quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
1225 cmd_rmdirs = rm -rf $(rm-dirs)
1227 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
1228 cmd_rmfiles = rm -f $(rm-files)
1231 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
1232 $(NOSTDINC_FLAGS) $(CPPFLAGS) \
1233 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1235 quiet_cmd_as_o_S = AS $@
1236 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
1238 # read all saved command lines
1240 targets := $(wildcard $(sort $(targets)))
1241 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
1243 ifneq ($(cmd_files),)
1244 $(cmd_files): ; # Do not try to update included dependency files
1245 include $(cmd_files)
1246 endif
1248 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1249 # Usage:
1250 # $(Q)$(MAKE) $(clean)=dir
1251 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1253 endif # skip-makefile
1255 PHONY += FORCE
1256 FORCE:
1258 # Cancel implicit rules on top Makefile, `-rR' will apply to sub-makes.
1259 Makefile: ;
1261 # Declare the contents of the .PHONY variable as phony. We keep that
1262 # information in a variable se we can use it in if_changed and friends.
1263 .PHONY: $(PHONY)
1266 # sanity checks for check default environemnt
1268 ifdef CONFIG_DEFAULT_ENVIRONMENT
1270 ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH),"")
1271 $(error default environment path empty))
1272 endif
1274 saved-env_path := $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
1275 CONFIG_DEFAULT_ENVIRONMENT_PATH := $(shell cd $(if $(filter /%,$(CONFIG_DEFAULT_ENVIRONMENT_PATH)),,$(srctree)/)$(CONFIG_DEFAULT_ENVIRONMENT_PATH) && /bin/pwd)
1276 $(if $(CONFIG_DEFAULT_ENVIRONMENT_PATH),, \
1277 $(error default environment path $(saved-env_path) does not exist))
1279 endif # ifdef CONFIG_DEFAULT_ENVIRONMENT